@appbaseio/reactivesearch-vue 3.0.0-rc.6.4 → 3.0.0-rc.6.6

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.
@@ -25,9 +25,10 @@ var Flex = require('./Flex-ddde6d26.js');
25
25
  var analytics = require('@appbaseio/reactivecore/lib/actions/analytics');
26
26
  var ReactiveBase = require('./ReactiveBase.js');
27
27
  var hotkeys = _interopDefault(require('hotkeys-js'));
28
+ var xss = _interopDefault(require('xss'));
28
29
  var remarkable = require('remarkable');
29
- var DropDown = require('./DropDown-aef75c14.js');
30
- var Input = require('./Input-56eba499.js');
30
+ var DropDown = require('./DropDown-dcdaf54f.js');
31
+ var Input = require('./Input-df30e5fc.js');
31
32
  var Container = require('./Container-29f049b2.js');
32
33
  var Highlight = _interopDefault(require('vue-highlight-words'));
33
34
  var query = require('@appbaseio/reactivecore/lib/actions/query');
@@ -52,7 +53,9 @@ var ResultList = require('./ResultList.js');
52
53
  var StateProvider = require('./StateProvider.js');
53
54
 
54
55
  var _templateObject;
55
- var InputGroup = vueEmotion.styled('div')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: stretch;\n\twidth: 100%;\n"])));
56
+ var InputGroup = vueEmotion.styled('div')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: stretch;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\n\t", "\n};\n"])), function (props) {
57
+ return props.isOpen && 'box-shadow: rgb(0 0 0 / 20%) 0px 0px 15px;';
58
+ });
56
59
  InputGroup.defaultProps = {
57
60
  className: 'input-group'
58
61
  };
@@ -1070,6 +1073,9 @@ var AIFeedback = vue.defineComponent({
1070
1073
  }
1071
1074
  });
1072
1075
 
1076
+ var _templateObject$8;
1077
+ var AutosuggestFooterContainer = vueEmotion.styled('div')(_templateObject$8 || (_templateObject$8 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tcolor: #8792a2;\n\tbackground: #f7fafc;\n\tpadding: 10px;\n\theight: 40px;\n"])));
1078
+
1073
1079
  var _excluded = ["_source"];
1074
1080
  function _isSlot(s) {
1075
1081
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
@@ -1106,7 +1112,8 @@ var SearchBox = vue.defineComponent({
1106
1112
  showAIScreen: false,
1107
1113
  showAIScreenFooter: false,
1108
1114
  showFeedbackComponent: false,
1109
- feedbackState: null
1115
+ feedbackState: null,
1116
+ prefilledAIAnswer: ''
1110
1117
  };
1111
1118
  this.internalComponent = props.componentId + "__internal";
1112
1119
  return this.__state;
@@ -1147,6 +1154,37 @@ var SearchBox = vue.defineComponent({
1147
1154
  },
1148
1155
  stats: function stats() {
1149
1156
  return getResultStats(this);
1157
+ },
1158
+ mergedAIAnswer: function mergedAIAnswer() {
1159
+ return this.prefilledAIAnswer || this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text;
1160
+ },
1161
+ parsedSuggestions: function parsedSuggestions() {
1162
+ var suggestionsArray = [];
1163
+ if (Array.isArray(this.suggestions) && this.suggestions.length) {
1164
+ suggestionsArray = [].concat(withClickIds(this.suggestions));
1165
+ }
1166
+ suggestionsArray = suggestionsArray.map(function (s) {
1167
+ if (s.sectionId) {
1168
+ return s;
1169
+ }
1170
+ return _rollupPluginBabelHelpers._extends({}, s, {
1171
+ sectionId: s._suggestion_type
1172
+ });
1173
+ });
1174
+ var sectionsAccumulated = [];
1175
+ var sectionisedSuggestions = suggestionsArray.reduce(function (acc, d, currentIndex) {
1176
+ if (sectionsAccumulated.includes(d.sectionId)) return acc;
1177
+ if (d.sectionId) {
1178
+ acc[currentIndex] = suggestionsArray.filter(function (g) {
1179
+ return g.sectionId === d.sectionId;
1180
+ });
1181
+ sectionsAccumulated.push(d.sectionId);
1182
+ } else {
1183
+ acc[currentIndex] = d;
1184
+ }
1185
+ return acc;
1186
+ }, {});
1187
+ return Object.values(sectionisedSuggestions);
1150
1188
  }
1151
1189
  },
1152
1190
  props: {
@@ -1178,6 +1216,11 @@ var SearchBox = vue.defineComponent({
1178
1216
  enableQuerySuggestions: VueTypes.bool.def(false),
1179
1217
  enablePopularSuggestions: VueTypes.bool.def(false),
1180
1218
  enableRecentSuggestions: VueTypes.bool.def(false),
1219
+ enableFAQSuggestions: VueTypes.bool.def(false),
1220
+ FAQSuggestionsConfig: VueTypes.shape({
1221
+ sectionLabel: VueTypes.string,
1222
+ size: VueTypes.number
1223
+ }),
1181
1224
  fieldWeights: vueTypes.types.fieldWeights,
1182
1225
  filterLabel: vueTypes.types.string,
1183
1226
  fuzziness: vueTypes.types.fuzziness,
@@ -1213,12 +1256,20 @@ var SearchBox = vue.defineComponent({
1213
1256
  distinctFieldConfig: vueTypes.types.props,
1214
1257
  //
1215
1258
  focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
1259
+ showFocusShortcutsIcon: VueTypes.bool.def(true),
1216
1260
  addonBefore: VueTypes.any,
1217
1261
  addonAfter: VueTypes.any,
1262
+ showSuggestionsFooter: VueTypes.bool.def(true),
1218
1263
  expandSuggestionsContainer: VueTypes.bool.def(true),
1264
+ renderSuggestionsFooter: VueTypes.func,
1219
1265
  index: VueTypes.string,
1220
1266
  popularSuggestionsConfig: VueTypes.object,
1221
1267
  recentSuggestionsConfig: VueTypes.object,
1268
+ featuredSuggestionsConfig: VueTypes.shape({
1269
+ maxSuggestionsPerSection: VueTypes.number,
1270
+ sectionsOrder: VueTypes.arrayOf(VueTypes.string)
1271
+ }),
1272
+ customEvents: VueTypes.object,
1222
1273
  applyStopwords: VueTypes.bool,
1223
1274
  customStopwords: vueTypes.types.stringArray,
1224
1275
  onData: vueTypes.types.func,
@@ -1406,7 +1457,7 @@ var SearchBox = vue.defineComponent({
1406
1457
  resultStats: this.stats,
1407
1458
  AIData: {
1408
1459
  question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
1409
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
1460
+ answer: this.mergedAIAnswerc,
1410
1461
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
1411
1462
  showAIScreen: this.showAIScreen,
1412
1463
  sources: this.getAISourceObjects(),
@@ -1437,7 +1488,7 @@ var SearchBox = vue.defineComponent({
1437
1488
  this.onValueSelectedHandler(currentValue, reactivecore.causes.SEARCH_ICON_CLICK);
1438
1489
  }
1439
1490
  },
1440
- setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
1491
+ setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue, shouldExecuteQuery) {
1441
1492
  var _this2 = this;
1442
1493
  if (isDefaultValue === void 0) {
1443
1494
  isDefaultValue = false;
@@ -1451,6 +1502,9 @@ var SearchBox = vue.defineComponent({
1451
1502
  if (categoryValue === void 0) {
1452
1503
  categoryValue = undefined;
1453
1504
  }
1505
+ if (shouldExecuteQuery === void 0) {
1506
+ shouldExecuteQuery = true;
1507
+ }
1454
1508
  var performUpdate = function performUpdate() {
1455
1509
  if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
1456
1510
  return;
@@ -1486,17 +1540,18 @@ var SearchBox = vue.defineComponent({
1486
1540
  }
1487
1541
  if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1488
1542
  enableAI: true
1489
- } : {});
1543
+ } : {}, shouldExecuteQuery);
1490
1544
  } // in case of strict selection only SUGGESTION_SELECT should be able
1491
1545
  // to set the query otherwise the value should reset
1492
1546
  if (props.strictSelection) {
1493
1547
  if (cause === reactivecore.causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
1494
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1548
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1495
1549
  } else {
1496
1550
  _this2.setValue('', true);
1497
1551
  }
1498
1552
  } else if (props.value === undefined || cause === reactivecore.causes.SUGGESTION_SELECT || cause === reactivecore.causes.CLEAR_VALUE) {
1499
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1553
+ _this2.showAIScreen = false;
1554
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1500
1555
  }
1501
1556
  } else {
1502
1557
  // debounce for handling text while typing
@@ -1507,10 +1562,13 @@ var SearchBox = vue.defineComponent({
1507
1562
  };
1508
1563
  checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1509
1564
  },
1510
- triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
1565
+ triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta, shouldExecuteQuery) {
1511
1566
  if (meta === void 0) {
1512
1567
  meta = {};
1513
1568
  }
1569
+ if (shouldExecuteQuery === void 0) {
1570
+ shouldExecuteQuery = true;
1571
+ }
1514
1572
  if (!this.$props.autosuggest) {
1515
1573
  return;
1516
1574
  }
@@ -1531,12 +1589,15 @@ var SearchBox = vue.defineComponent({
1531
1589
  value: value,
1532
1590
  componentType: constants.componentTypes.searchBox,
1533
1591
  meta: meta
1534
- });
1592
+ }, shouldExecuteQuery);
1535
1593
  },
1536
- triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
1594
+ triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue, shouldExecuteQuery) {
1537
1595
  if (categoryValue === void 0) {
1538
1596
  categoryValue = undefined;
1539
1597
  }
1598
+ if (shouldExecuteQuery === void 0) {
1599
+ shouldExecuteQuery = true;
1600
+ }
1540
1601
  var _this$$props = this.$props,
1541
1602
  customQuery = _this$$props.customQuery,
1542
1603
  filterLabel = _this$$props.filterLabel,
@@ -1565,7 +1626,7 @@ var SearchBox = vue.defineComponent({
1565
1626
  URLParams: URLParams,
1566
1627
  componentType: constants.componentTypes.searchBox,
1567
1628
  category: categoryValue
1568
- });
1629
+ }, shouldExecuteQuery);
1569
1630
  },
1570
1631
  handleFocus: function handleFocus(event) {
1571
1632
  if (this.$props.autosuggest) {
@@ -1664,12 +1725,60 @@ var SearchBox = vue.defineComponent({
1664
1725
  }, e);
1665
1726
  }
1666
1727
  },
1728
+ handleFeaturedSuggestionClicked: function handleFeaturedSuggestionClicked(suggestion) {
1729
+ try {
1730
+ var _this$$refs2, _this$$refs2$this$$pr;
1731
+ if (suggestion.action === helper.featuredSuggestionsActionTypes.NAVIGATE) {
1732
+ var _JSON$parse = JSON.parse(suggestion.subAction),
1733
+ _JSON$parse$target = _JSON$parse.target,
1734
+ target = _JSON$parse$target === void 0 ? '_self' : _JSON$parse$target,
1735
+ _JSON$parse$link = _JSON$parse.link,
1736
+ link = _JSON$parse$link === void 0 ? '/' : _JSON$parse$link;
1737
+ if (typeof window !== 'undefined') {
1738
+ window.open(link, target);
1739
+ }
1740
+ }
1741
+ if (suggestion.action === helper.featuredSuggestionsActionTypes.FUNCTION) {
1742
+ var matchedValues = suggestion.subAction.match(/function\s*\(.*\)(.|\n)*/);
1743
+ var functionStr = matchedValues && matchedValues[0];
1744
+ // eslint-disable-next-line no-new-func
1745
+ var func = new Function("return " + functionStr)();
1746
+ func(suggestion, this.$data.currentValue, this.$props.customEvents);
1747
+ }
1748
+ if (suggestion.action === helper.featuredSuggestionsActionTypes.SELECT) {
1749
+ this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? reactivecore.causes.SUGGESTION_SELECT : reactivecore.causes.ENTER_PRESS);
1750
+ this.onValueSelectedHandler(suggestion.value, reactivecore.causes.SUGGESTION_SELECT);
1751
+ }
1752
+ // blur is important to close the dropdown
1753
+ // on selecting one of featured suggestions
1754
+ // else Downshift probably is focusing the dropdown
1755
+ // and not letting it close
1756
+ // eslint-disable-next-line no-unused-expressions
1757
+ (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$this$$pr = _this$$refs2[this.$props.innerRef]) == null ? void 0 : _this$$refs2$this$$pr.blur();
1758
+ } catch (e) {
1759
+ console.error("Error: There was an error parsing the subAction for the featured suggestion with label, \"" + suggestion.label + "\"", e);
1760
+ }
1761
+ },
1667
1762
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
1668
1763
  var _this4 = this;
1764
+ // handle when FAQ suggestion is clicked
1765
+ if (suggestion && suggestion._suggestion_type === helper.suggestionTypes.FAQ) {
1766
+ this.prefilledAIAnswer = suggestion._answer;
1767
+ this.setValue(suggestion.value, true, this.$props, reactivecore.causes.SUGGESTION_SELECT, true, false, suggestion._category, false);
1768
+ this.isOpen = true;
1769
+ this.showAIScreen = true;
1770
+ return;
1771
+ }
1669
1772
  if (!this.$props.enableAI) this.isOpen = false;else {
1670
1773
  this.showAIScreen = true;
1671
1774
  }
1672
1775
  var value = this.$props.value;
1776
+
1777
+ // handle featured suggestions click event
1778
+ if (suggestion._suggestion_type === helper.suggestionTypes.Featured) {
1779
+ this.handleFeaturedSuggestionClicked(suggestion);
1780
+ return;
1781
+ }
1673
1782
  // Record analytics for selected suggestions
1674
1783
  this.triggerClickAnalytics(suggestion._click_id);
1675
1784
  if (value === undefined) {
@@ -1825,6 +1934,13 @@ var SearchBox = vue.defineComponent({
1825
1934
  customQuery: true
1826
1935
  });
1827
1936
  },
1937
+ suggestionsFooter: function suggestionsFooter() {
1938
+ return typeof renderSuggestionsFooter === 'function' ? this.$props.renderSuggestionsFooter() : vue.createVNode(AutosuggestFooterContainer, null, {
1939
+ "default": function _default() {
1940
+ return [vue.createVNode("div", null, [vue.createTextVNode("\u2191\u2193 Navigate")]), vue.createVNode("div", null, [vue.createTextVNode("\u21A9 Go")])];
1941
+ }
1942
+ });
1943
+ },
1828
1944
  renderEnterButtonElement: function renderEnterButtonElement() {
1829
1945
  var _this6 = this;
1830
1946
  var _this$$props2 = this.$props,
@@ -1852,16 +1968,29 @@ var SearchBox = vue.defineComponent({
1852
1968
  }
1853
1969
  return null;
1854
1970
  },
1971
+ renderShortcut: function renderShortcut() {
1972
+ if (this.$props.focusShortcuts && this.$props.focusShortcuts.length) {
1973
+ var shortcut = this.$props.focusShortcuts[0];
1974
+ shortcut = shortcut.toLowerCase();
1975
+ shortcut = shortcut.replace('shift', '⬆️');
1976
+ shortcut = shortcut.replace('command', 'cmd');
1977
+ shortcut = shortcut.replace('control', 'ctrl');
1978
+ shortcut = shortcut.replace('option', 'alt');
1979
+ return shortcut.toUpperCase();
1980
+ }
1981
+ return '/';
1982
+ },
1855
1983
  renderIcons: function renderIcons() {
1856
1984
  var _this7 = this;
1857
- var _slot3, _slot4, _slot5;
1985
+ var _slot3, _slot4, _slot5, _slot6;
1858
1986
  var _this$$props3 = this.$props,
1859
1987
  iconPosition = _this$$props3.iconPosition,
1860
1988
  showClear = _this$$props3.showClear,
1861
1989
  innerClass = _this$$props3.innerClass,
1862
1990
  getMicInstance = _this$$props3.getMicInstance,
1863
1991
  showVoiceSearch = _this$$props3.showVoiceSearch,
1864
- showIcon = _this$$props3.showIcon;
1992
+ showIcon = _this$$props3.showIcon,
1993
+ showFocusShortcutsIcon = _this$$props3.showFocusShortcutsIcon;
1865
1994
  var renderMic = this.$slots.renderMic || this.$props.renderMic;
1866
1995
  var currentValue = this.$data.currentValue;
1867
1996
  return vue.createVNode("div", null, [vue.createVNode(DropDown.IconGroup, {
@@ -1877,6 +2006,14 @@ var SearchBox = vue.defineComponent({
1877
2006
  "default": function _default() {
1878
2007
  return [_slot3];
1879
2008
  }
2009
+ }), showFocusShortcutsIcon && vue.createVNode(DropDown.ButtonIconWrapper, {
2010
+ "onClick": function onClick(e) {
2011
+ return _this7.focusSearchBox(e);
2012
+ }
2013
+ }, _isSlot(_slot4 = _this7.renderShortcut()) ? _slot4 : {
2014
+ "default": function _default() {
2015
+ return [_slot4];
2016
+ }
1880
2017
  }), showVoiceSearch && vue.createVNode(Mic, {
1881
2018
  "getInstance": getMicInstance,
1882
2019
  "render": renderMic,
@@ -1884,9 +2021,9 @@ var SearchBox = vue.defineComponent({
1884
2021
  "className": getClassName$1(innerClass, 'mic') || null
1885
2022
  }, null), iconPosition === 'right' && showIcon && vue.createVNode(DropDown.IconWrapper, {
1886
2023
  "onClick": _this7.handleSearchIconClick
1887
- }, _isSlot(_slot4 = _this7.renderIcon()) ? _slot4 : {
2024
+ }, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
1888
2025
  "default": function _default() {
1889
- return [_slot4];
2026
+ return [_slot5];
1890
2027
  }
1891
2028
  })];
1892
2029
  }
@@ -1897,23 +2034,23 @@ var SearchBox = vue.defineComponent({
1897
2034
  "default": function _default() {
1898
2035
  return [iconPosition === 'left' && showIcon && vue.createVNode(DropDown.IconWrapper, {
1899
2036
  "onClick": _this7.handleSearchIconClick
1900
- }, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
2037
+ }, _isSlot(_slot6 = _this7.renderIcon()) ? _slot6 : {
1901
2038
  "default": function _default() {
1902
- return [_slot5];
2039
+ return [_slot6];
1903
2040
  }
1904
2041
  })];
1905
2042
  }
1906
2043
  })]);
1907
2044
  },
1908
2045
  focusSearchBox: function focusSearchBox(event) {
1909
- var _this$$refs2, _this$$refs2$this$$pr;
2046
+ var _this$$refs3, _this$$refs3$this$$pr;
1910
2047
  var elt = event.target || event.srcElement;
1911
2048
  var tagName = elt.tagName;
1912
2049
  if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
1913
2050
  // already in an input
1914
2051
  return;
1915
2052
  }
1916
- (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$this$$pr = _this$$refs2[this.$props.innerRef]) == null ? void 0 : _this$$refs2$this$$pr.focus(); // eslint-disable-line
2053
+ (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$this$$pr = _this$$refs3[this.$props.innerRef]) == null ? void 0 : _this$$refs3$this$$pr.focus(); // eslint-disable-line
1917
2054
  },
1918
2055
  listenForFocusShortcuts: function listenForFocusShortcuts() {
1919
2056
  var _this8 = this;
@@ -1953,16 +2090,31 @@ var SearchBox = vue.defineComponent({
1953
2090
  this.currentValue = index.decodeHtml(value);
1954
2091
  this.triggerDefaultQuery(value);
1955
2092
  },
1956
- renderAutoFill: function renderAutoFill(suggestion) {
2093
+ renderActionIcon: function renderActionIcon(suggestion) {
1957
2094
  var _this9 = this;
1958
2095
  var handleAutoFillClick = function handleAutoFillClick(e) {
1959
2096
  e.stopPropagation();
1960
2097
  _this9.onAutofillClick(suggestion);
1961
2098
  };
1962
- /* 👇 avoid showing autofill for category suggestions👇 */
1963
- return suggestion._category ? null : vue.createVNode(AutoFillSvg, {
1964
- "onClick": handleAutoFillClick
1965
- }, null);
2099
+ if (suggestion._suggestion_type === helper.suggestionTypes.Featured) {
2100
+ if (suggestion.action === helper.featuredSuggestionsActionTypes.FUNCTION) {
2101
+ return vue.createVNode(AutoFillSvg, {
2102
+ "style": {
2103
+ transform: 'rotate(135deg)',
2104
+ pointerEvents: 'none'
2105
+ }
2106
+ }, null);
2107
+ }
2108
+ return null;
2109
+ }
2110
+ if (!suggestion._category) {
2111
+ /* 👇 avoid showing autofill for category suggestions👇 */
2112
+
2113
+ return vue.createVNode(AutoFillSvg, {
2114
+ "onClick": handleAutoFillClick
2115
+ }, null);
2116
+ }
2117
+ return null;
1966
2118
  },
1967
2119
  renderTag: function renderTag(item) {
1968
2120
  var _this10 = this;
@@ -2069,7 +2221,7 @@ var SearchBox = vue.defineComponent({
2069
2221
  return vue.createVNode(HorizontalSkeletonLoader, null, null);
2070
2222
  },
2071
2223
  renderAIScreenFooter: function renderAIScreenFooter() {
2072
- var _slot6;
2224
+ var _slot7;
2073
2225
  var _this12 = this;
2074
2226
  var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
2075
2227
  AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
@@ -2084,7 +2236,7 @@ var SearchBox = vue.defineComponent({
2084
2236
  "themePreset": this.$props.themePreset
2085
2237
  }, {
2086
2238
  "default": function _default() {
2087
- return [vue.createTextVNode("Summary generated using the following sources:"), ' ', vue.createVNode(SourceTags, null, _isSlot(_slot6 = _this12.getAISourceObjects().map(function (el) {
2239
+ return [vue.createTextVNode("Summary generated using the following sources:"), ' ', vue.createVNode(SourceTags, null, _isSlot(_slot7 = _this12.getAISourceObjects().map(function (el) {
2088
2240
  return vue.createVNode(Button.Button, {
2089
2241
  "class": "--ai-source-tag " + (getClassName$1(_this12.$props.innerClass, 'ai-source-tag') || ''),
2090
2242
  "title": el[sourceDocumentLabel],
@@ -2097,9 +2249,9 @@ var SearchBox = vue.defineComponent({
2097
2249
  return [el[sourceDocumentLabel]];
2098
2250
  }
2099
2251
  });
2100
- })) ? _slot6 : {
2252
+ })) ? _slot7 : {
2101
2253
  "default": function _default() {
2102
- return [_slot6];
2254
+ return [_slot7];
2103
2255
  }
2104
2256
  })];
2105
2257
  }
@@ -2111,7 +2263,7 @@ var SearchBox = vue.defineComponent({
2111
2263
  if (customAIRenderer) {
2112
2264
  return customAIRenderer({
2113
2265
  question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
2114
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
2266
+ answer: this.mergedAIAnswer,
2115
2267
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
2116
2268
  loading: this.isAIResponseLoading || this.isLoading,
2117
2269
  sources: this.getAISourceObjects(),
@@ -2122,7 +2274,7 @@ var SearchBox = vue.defineComponent({
2122
2274
  return this.renderAIScreenLoader();
2123
2275
  }
2124
2276
  return vue.createVNode("div", null, [vue.createVNode(Answer, {
2125
- "innerHTML": md.render(this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text)
2277
+ "innerHTML": md.render(this.mergedAIAnswer)
2126
2278
  }, null), this.renderAIScreenFooter(), this.showFeedbackComponent && vue.createVNode("div", {
2127
2279
  "class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
2128
2280
  }, [vue.createVNode(AIFeedback, {
@@ -2231,23 +2383,58 @@ var SearchBox = vue.defineComponent({
2231
2383
  highlightedIndex = _ref8.highlightedIndex,
2232
2384
  setHighlightedIndex = _ref8.setHighlightedIndex;
2233
2385
  var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
2234
- var getIcon = function getIcon(iconType) {
2386
+ var getIcon = function getIcon(iconType, item, leaveSpaceForIcon) {
2235
2387
  switch (iconType) {
2236
2388
  case helper.suggestionTypes.Recent:
2237
2389
  return recentSearchesIcon;
2238
2390
  case helper.suggestionTypes.Popular:
2239
2391
  return popularSearchesIcon;
2392
+ case helper.suggestionTypes.Featured:
2393
+ if (item.icon) {
2394
+ return function () {
2395
+ return vue.createVNode("div", {
2396
+ "style": {
2397
+ display: 'flex'
2398
+ },
2399
+ "innerHTML": xss(item.icon)
2400
+ }, null);
2401
+ };
2402
+ }
2403
+ if (item.iconURL) {
2404
+ return function () {
2405
+ return (// When you change below also change the empty icon below
2406
+ vue.createVNode("img", {
2407
+ "style": {
2408
+ maxHeight: '25px'
2409
+ },
2410
+ "src": xss(item.iconURL),
2411
+ "alt": item.value
2412
+ }, null)
2413
+ );
2414
+ };
2415
+ }
2416
+ // Render an empty icon when no icon is provided from the dashboard
2417
+ return function () {
2418
+ return vue.createVNode("span", {
2419
+ "style": {
2420
+ display: 'inline-block',
2421
+ height: '25px',
2422
+ width: leaveSpaceForIcon ? '25px' : 0
2423
+ }
2424
+ }, null);
2425
+ };
2240
2426
  default:
2241
2427
  return null;
2242
2428
  }
2243
2429
  };
2430
+ var indexOffset = 0;
2244
2431
  return vue.createVNode("div", null, [_this15.hasCustomRenderer && _this15.getComponent({
2245
2432
  isOpen: isOpen,
2246
2433
  getItemProps: getItemProps,
2247
2434
  getItemEvents: getItemEvents,
2248
2435
  highlightedIndex: highlightedIndex
2249
2436
  }), _this15.renderErrorComponent(), !_this15.hasCustomRenderer && isOpen && hasSuggestions ? vue.createVNode("ul", {
2250
- "class": Input.suggestions(_this15.themePreset, _this15.theme) + " " + getClassName$1(_this15.$props.innerClass, 'list'),
2437
+ "class": Input.suggestions(_this15.themePreset, _this15.theme) + " " + getClassName$1(_this15.$props.innerClass, 'list') + " " + Input.searchboxSuggestions(_this15.themePreset, _this15.theme) + "\n\t\t\t\t\t\t\t\t\t\t\t\t\t",
2251
2438
  "ref": _dropdownULRef
2252
2439
  }, [_this15.showAIScreen && vue.createVNode(SearchBoxAISection, {
2253
2440
  "themePreset": _this15.$props.themePreset
@@ -2255,43 +2442,63 @@ var SearchBox = vue.defineComponent({
2255
2442
  "default": function _default() {
2256
2443
  return [_this15.renderAIScreen(), ' ', _this15.renderErrorComponent(true)];
2257
2444
  }
2258
- }), !_this15.showAIScreen && _this15.normalizedSuggestions.map(function (item, index) {
2259
- return renderItem ? vue.createVNode("li", vue.mergeProps(getItemProps({
2260
- item: item
2261
- }), getItemEvents({
2262
- item: item
2263
- }), {
2264
- "key": index + 1 + "-" + item.value,
2265
- "style": {
2266
- backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
2267
- justifyContent: 'flex-start',
2268
- alignItems: 'center'
2269
- }
2270
- }), [renderItem(item)]) : vue.createVNode("li", vue.mergeProps(getItemProps({
2271
- item: item
2272
- }), _transformOn(getItemEvents({
2273
- item: item
2274
- })), {
2275
- "key": index + 1 + "-" + item.value,
2276
- "style": {
2277
- backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
2278
- justifyContent: 'flex-start',
2279
- alignItems: 'center'
2280
- }
2281
- }), [vue.createVNode("div", {
2282
- "style": {
2283
- padding: '0 10px 0 0',
2284
- display: 'flex'
2285
- }
2286
- }, [vue.createVNode(CustomSvg, {
2287
- "className": getClassName$1(_this15.$props.innerClass, item._suggestion_type + "-search-icon") || null,
2288
- "icon": getIcon(item._suggestion_type),
2289
- "type": item._suggestion_type + "-search-icon"
2290
- }, null)]), vue.createVNode(SuggestionItem, {
2291
- "currentValue": _this15.currentValue,
2292
- "suggestion": item
2293
- }, null), _this15.renderAutoFill(item)]);
2294
- })]) : _this15.renderNoSuggestions(_this15.normalizedSuggestions)]);
2445
+ }), !_this15.showAIScreen && _this15.parsedSuggestions.map(function (item, itemIndex) {
2446
+ var index = indexOffset + itemIndex;
2447
+ if (Array.isArray(item)) {
2448
+ var sectionHtml = xss(item[0].sectionLabel);
2449
+ indexOffset += item.length - 1;
2450
+ return vue.createVNode("div", {
2451
+ "class": "section-container"
2452
+ }, [sectionHtml ? vue.createVNode("div", {
2453
+ "class": "section-header " + getClassName$1(_this15.$props.innerClass, 'section-label'),
2454
+ "key": "" + item[0].sectionId,
2455
+ "innerHTML": sectionHtml
2456
+ }, null) : null, vue.createVNode("ul", {
2457
+ "class": "section-list"
2458
+ }, [item.map(function (sectionItem, sectionIndex) {
2459
+ var suggestionsHaveIcon = item.some(function (s) {
2460
+ return s.icon || s.iconURL;
2461
+ });
2462
+ return renderItem ? vue.createVNode("li", vue.mergeProps(getItemProps({
2463
+ item: sectionItem
2464
+ }), _transformOn(getItemEvents({
2465
+ item: sectionItem
2466
+ })), {
2467
+ "key": index + sectionIndex,
2468
+ "style": {
2469
+ justifyContent: 'flex-start',
2470
+ alignItems: 'center'
2471
+ },
2472
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this15.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this15.$props.innerClass, 'suggestion-item'))
2473
+ }), [renderItem(sectionItem)]) : vue.createVNode("li", vue.mergeProps(getItemProps({
2474
+ item: sectionItem
2475
+ }), _transformOn(getItemEvents({
2476
+ item: sectionItem
2477
+ })), {
2478
+ "key": index + sectionIndex,
2479
+ "style": {
2480
+ justifyContent: 'flex-start',
2481
+ alignItems: 'center'
2482
+ },
2483
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this15.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this15.$props.innerClass, 'suggestion-item'))
2484
+ }), [vue.createVNode("div", {
2485
+ "style": {
2486
+ padding: '0 10px 0 0',
2487
+ display: 'flex'
2488
+ }
2489
+ }, [vue.createVNode(CustomSvg, {
2490
+ "key": sectionItem._suggestion_type + "-" + sectionIndex,
2491
+ "className": getClassName$1(_this15.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
2492
+ "icon": getIcon(sectionItem._suggestion_type, sectionItem, suggestionsHaveIcon),
2493
+ "type": sectionItem._suggestion_type + "-search-icon"
2494
+ }, null)]), vue.createVNode(SuggestionItem, {
2495
+ "currentValue": _this15.currentValue,
2496
+ "suggestion": sectionItem
2497
+ }, null), _this15.renderActionIcon(sectionItem)]);
2498
+ })])]);
2499
+ }
2500
+ return vue.createVNode("div", null, [vue.createTextVNode("No suggestions")]);
2501
+ }), _this15.$props.showSuggestionsFooter ? _this15.suggestionsFooter() : null]) : _this15.renderNoSuggestions(_this15.normalizedSuggestions)]);
2295
2502
  };
2296
2503
  return vue.createVNode("div", {
2297
2504
  "class": Input.suggestionsContainer
@@ -2331,7 +2538,8 @@ var SearchBox = vue.defineComponent({
2331
2538
  "placeholder": _this15.$props.placeholder,
2332
2539
  "autoFocus": _this15.$props.autoFocus,
2333
2540
  "showFocusShortcutsIcon": _this15.$props.showFocusShortcutsIcon,
2334
- "showVoiceSearch": _this15.$props.showVoiceSearch
2541
+ "showVoiceSearch": _this15.$props.showVoiceSearch,
2542
+ "searchBox": true
2335
2543
  }, getInputProps({
2336
2544
  value: _this15.$data.currentValue === null ? '' : _this15.$data.currentValue
2337
2545
  }), {
@@ -2546,6 +2754,7 @@ var AIAnswer = vue.defineComponent({
2546
2754
  isLoading: vueTypes.types.boolRequired,
2547
2755
  sessionIdFromStore: VueTypes.string,
2548
2756
  showComponent: vueTypes.types.boolRequired,
2757
+ componentError: vueTypes.types.componentObject,
2549
2758
  style: vueTypes.types.style
2550
2759
  },
2551
2760
  mounted: function mounted() {},
@@ -2629,14 +2838,50 @@ var AIAnswer = vue.defineComponent({
2629
2838
  },
2630
2839
  messages: function messages() {
2631
2840
  this.scrollToBottom();
2841
+ },
2842
+ componentError: function componentError(newVal) {
2843
+ var _this = this;
2844
+ if (newVal && newVal._bodyBlob) {
2845
+ this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2846
+ if (!this.AISessionId) {
2847
+ this.generateNewSessionId();
2848
+ }
2849
+ newVal._bodyBlob.text().then(function (textData) {
2850
+ try {
2851
+ var parsedErrorRes = JSON.parse(textData);
2852
+ if (parsedErrorRes.error) {
2853
+ _this.error = parsedErrorRes.error;
2854
+ _this.$emit('on-data', {
2855
+ data: _this.messages,
2856
+ rawData: _this.$props.rawData,
2857
+ loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
2858
+ error: parsedErrorRes.error
2859
+ });
2860
+ }
2861
+ } catch (error) {
2862
+ console.error('Error parsing component error JSON:', error);
2863
+ }
2864
+ })["catch"](function (error) {
2865
+ console.error('Error reading component error text data:', error);
2866
+ });
2867
+ }
2632
2868
  }
2633
2869
  },
2634
2870
  methods: {
2871
+ generateNewSessionId: function generateNewSessionId() {
2872
+ var _this2 = this;
2873
+ var newSessionPromise = this.createAISession();
2874
+ newSessionPromise.then(function (res) {
2875
+ _this2.AISessionId = res.AIsessionId;
2876
+ })["catch"](function (e) {
2877
+ console.error(e);
2878
+ });
2879
+ },
2635
2880
  scrollToBottom: function scrollToBottom() {
2636
- var _this = this;
2881
+ var _this3 = this;
2637
2882
  this.$nextTick(function () {
2638
- var _this$$refs;
2639
- var messageContainer = (_this$$refs = _this.$refs) == null ? void 0 : _this$$refs[_this.$props.innerRef];
2883
+ var _this3$$refs;
2884
+ var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
2640
2885
  if (messageContainer && messageContainer.$el) {
2641
2886
  messageContainer.$el.scrollTo({
2642
2887
  top: messageContainer.$el.scrollHeight,
@@ -2703,7 +2948,7 @@ var AIAnswer = vue.defineComponent({
2703
2948
  "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
2704
2949
  }, [vue.createVNode("div", {
2705
2950
  "class": "--default-error-element"
2706
- }, [vue.createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? "Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && vue.createVNode(Button.Button, {
2951
+ }, [vue.createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? ", Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && vue.createVNode(Button.Button, {
2707
2952
  "primary": true,
2708
2953
  "onClick": this.handleRetryRequest
2709
2954
  }, {
@@ -2754,7 +2999,7 @@ var AIAnswer = vue.defineComponent({
2754
2999
  }
2755
3000
  },
2756
3001
  renderIcons: function renderIcons() {
2757
- var _this2 = this;
3002
+ var _this4 = this;
2758
3003
  var _slot, _slot2;
2759
3004
  var _this$$props = this.$props,
2760
3005
  getMicInstance = _this$$props.getMicInstance,
@@ -2768,12 +3013,12 @@ var AIAnswer = vue.defineComponent({
2768
3013
  "positionType": "absolute"
2769
3014
  }, {
2770
3015
  "default": function _default() {
2771
- return [!_this2.isLoadingState && _this2.AISessionId && _this2.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
3016
+ return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
2772
3017
  "getInstance": getMicInstance,
2773
3018
  "render": renderMic,
2774
- "handleResult": _this2.handleVoiceResults,
3019
+ "handleResult": _this4.handleVoiceResults,
2775
3020
  "class": helper.getClassName(innerClass, 'ai-search-mic') || null
2776
- }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot = _this2.renderIcon()) ? _slot : {
3021
+ }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
2777
3022
  "default": function _default() {
2778
3023
  return [_slot];
2779
3024
  }
@@ -2785,7 +3030,7 @@ var AIAnswer = vue.defineComponent({
2785
3030
  "positionType": "absolute"
2786
3031
  }, {
2787
3032
  "default": function _default() {
2788
- return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot2 = _this2.renderIcon()) ? _slot2 : {
3033
+ return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
2789
3034
  "default": function _default() {
2790
3035
  return [_slot2];
2791
3036
  }
@@ -2797,7 +3042,7 @@ var AIAnswer = vue.defineComponent({
2797
3042
  this.handleSendMessage(e);
2798
3043
  },
2799
3044
  renderEnterButtonElement: function renderEnterButtonElement() {
2800
- var _this3 = this;
3045
+ var _this5 = this;
2801
3046
  var _this$$props2 = this.$props,
2802
3047
  enterButton = _this$$props2.enterButton,
2803
3048
  innerClass = _this$$props2.innerClass;
@@ -2805,16 +3050,16 @@ var AIAnswer = vue.defineComponent({
2805
3050
  if (enterButton) {
2806
3051
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
2807
3052
  if (renderEnterButton) {
2808
- return renderEnterButton(_this3.enterButtonOnClick);
3053
+ return renderEnterButton(_this5.enterButtonOnClick);
2809
3054
  }
2810
3055
  return vue.createVNode(SendButton, {
2811
3056
  "primary": true,
2812
3057
  "type": "submit",
2813
3058
  "tabIndex": 0,
2814
- "onClick": _this3.handleSendMessage,
2815
- "onKeyPress": _this3.handleKeyPress,
3059
+ "onClick": _this5.handleSendMessage,
3060
+ "onKeyPress": _this5.handleKeyPress,
2816
3061
  "class": "ask-btn " + helper.getClassName(innerClass, 'ai-enter-button'),
2817
- "disabled": _this3.isLoadingState || !_this3.AISessionId
3062
+ "disabled": _this5.isLoadingState || !_this5.AISessionId
2818
3063
  }, {
2819
3064
  "default": function _default() {
2820
3065
  return [vue.createTextVNode("Send")];
@@ -2837,10 +3082,10 @@ var AIAnswer = vue.defineComponent({
2837
3082
  return index.getComponent(data, this);
2838
3083
  },
2839
3084
  handleTextAreaHeightChange: function handleTextAreaHeightChange() {
2840
- var _this$$refs2, _this$$refs2$_inputRe, _this$$refs3, _this$$refs3$_inputWr, _this$$refs4;
2841
- var textArea = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputRe = _this$$refs2[_inputRef]) == null ? void 0 : _this$$refs2$_inputRe.$el;
2842
- var inputWrapper = (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$_inputWr = _this$$refs3[_inputWrapperRef]) == null ? void 0 : _this$$refs3$_inputWr.$el;
2843
- var errorContainer = (_this$$refs4 = this.$refs) == null ? void 0 : _this$$refs4[_errorContainerRef];
3085
+ var _this$$refs, _this$$refs$_inputRef, _this$$refs2, _this$$refs2$_inputWr, _this$$refs3;
3086
+ var textArea = (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$_inputRef = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs$_inputRef.$el;
3087
+ var inputWrapper = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputWr = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2$_inputWr.$el;
3088
+ var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
2844
3089
  if (textArea) {
2845
3090
  textArea.style.height = '42px';
2846
3091
  var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
@@ -2872,21 +3117,20 @@ var AIAnswer = vue.defineComponent({
2872
3117
  },
2873
3118
  render: function render() {
2874
3119
  var _slot3;
2875
- var _this4 = this;
3120
+ var _this6 = this;
2876
3121
  var props = this.$props;
2877
3122
  if (!this.shouldShowComponent) {
2878
3123
  return null;
2879
3124
  }
2880
3125
  return vue.createVNode(Chatbox, {
2881
- "style": props.style,
2882
- "class": "--ai-chat-box-wrapper"
3126
+ "style": props.style || {}
2883
3127
  }, {
2884
3128
  "default": function _default() {
2885
- return [_this4.$props.title && vue.createVNode(Title.Title, {
2886
- "class": helper.getClassName(_this4.$props.innerClass, 'title') || ''
3129
+ return [_this6.$props.title && vue.createVNode(Title.Title, {
3130
+ "class": helper.getClassName(_this6.$props.innerClass, 'title') || ''
2887
3131
  }, {
2888
3132
  "default": function _default() {
2889
- return [_this4.$props.title];
3133
+ return [_this6.$props.title];
2890
3134
  }
2891
3135
  }), vue.createVNode(ChatContainer, {
2892
3136
  "class": "--ai-chat-container",
@@ -2894,33 +3138,33 @@ var AIAnswer = vue.defineComponent({
2894
3138
  "showInput": props.showInput
2895
3139
  }, {
2896
3140
  "default": function _default() {
2897
- return [_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2898
- "themePreset": _this4.themePreset,
3141
+ return [_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3142
+ "themePreset": _this6.themePreset,
2899
3143
  "theme": props.theme,
2900
- "ref": _this4.$props.innerRef,
3144
+ "ref": _this6.$props.innerRef,
2901
3145
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
2902
- }, _isSlot$1(_slot3 = _this4.getComponent()) ? _slot3 : {
3146
+ }, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
2903
3147
  "default": function _default() {
2904
3148
  return [_slot3];
2905
3149
  }
2906
- }), !_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2907
- "themePreset": _this4.themePreset,
3150
+ }), !_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3151
+ "themePreset": _this6.themePreset,
2908
3152
  "theme": props.theme,
2909
- "ref": _this4.$props.innerRef,
3153
+ "ref": _this6.$props.innerRef,
2910
3154
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
2911
3155
  }, {
2912
3156
  "default": function _default() {
2913
- return [_this4.messages.map(function (message, index) {
3157
+ return [_this6.messages.map(function (message, index) {
2914
3158
  return vue.createVNode(Message, {
2915
3159
  "key": index,
2916
3160
  "isSender": message.role === constants.AI_ROLES.USER,
2917
3161
  "innerHTML": md$1.render(message.content),
2918
- "themePreset": _this4.themePreset,
3162
+ "themePreset": _this6.themePreset,
2919
3163
  "theme": props.theme,
2920
3164
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || '')
2921
3165
  }, null);
2922
- }), _this4.isLoadingState && vue.createVNode(Message, {
2923
- "themePreset": _this4.themePreset,
3166
+ }), _this6.isLoadingState && vue.createVNode(Message, {
3167
+ "themePreset": _this6.themePreset,
2924
3168
  "theme": props.theme,
2925
3169
  "isSender": false,
2926
3170
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || null)
@@ -2929,31 +3173,31 @@ var AIAnswer = vue.defineComponent({
2929
3173
  return [vue.createVNode(TypingIndicator, null, {
2930
3174
  "default": function _default() {
2931
3175
  return [vue.createVNode(TypingDot, {
2932
- "themePreset": _this4.themePreset
3176
+ "themePreset": _this6.themePreset
2933
3177
  }, null), vue.createVNode(TypingDot, {
2934
- "themePreset": _this4.themePreset
3178
+ "themePreset": _this6.themePreset
2935
3179
  }, null), vue.createVNode(TypingDot, {
2936
- "themePreset": _this4.themePreset
3180
+ "themePreset": _this6.themePreset
2937
3181
  }, null)];
2938
3182
  }
2939
3183
  })];
2940
3184
  }
2941
3185
  })];
2942
3186
  }
2943
- }), _this4.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
3187
+ }), _this6.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
2944
3188
  "class": "--ai-answer-feedback-container " + (helper.getClassName(props.innerClass, 'ai-feedback') || '')
2945
3189
  }, [vue.createVNode(AIFeedback, {
2946
- "hideUI": _this4.isLoadingState || !_this4.sessionId,
2947
- "key": _this4.sessionId,
3190
+ "hideUI": _this6.isLoadingState || !_this6.sessionId,
3191
+ "key": _this6.sessionId,
2948
3192
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
2949
- _this4.trackUsefullness(_this4.sessionId, {
3193
+ _this6.trackUsefullness(_this6.sessionId, {
2950
3194
  useful: useful,
2951
3195
  reason: reason
2952
3196
  });
2953
3197
  }
2954
3198
  }, null)]), props.showInput && vue.createVNode(MessageInputContainer, {
2955
3199
  "class": "--ai-input-container",
2956
- "onSubmit": _this4.handleSendMessage
3200
+ "onSubmit": _this6.handleSendMessage
2957
3201
  }, {
2958
3202
  "default": function _default() {
2959
3203
  return [vue.createVNode(InputGroup, {
@@ -2969,19 +3213,19 @@ var AIAnswer = vue.defineComponent({
2969
3213
  "ref": _inputRef,
2970
3214
  "placeholder": props.placeholder,
2971
3215
  "enterButton": props.enterButton,
2972
- "value": _this4.inputMessage,
2973
- "onInput": _this4.handleMessageInputChange,
3216
+ "value": _this6.inputMessage,
3217
+ "onInput": _this6.handleMessageInputChange,
2974
3218
  "id": props.componentId + "-ai-input",
2975
3219
  "showIcon": props.showIcon,
2976
3220
  "iconPosition": props.iconPosition,
2977
- "themePreset": _this4.themePreset,
2978
- "disabled": _this4.isLoadingState || !_this4.AISessionId,
3221
+ "themePreset": _this6.themePreset,
3222
+ "disabled": _this6.isLoadingState || !_this6.AISessionId,
2979
3223
  "class": helper.getClassName(props.innerClass, 'ai-input') || null
2980
- }, null), ' ', _this4.renderIcons()];
3224
+ }, null), ' ', _this6.renderIcons()];
2981
3225
  }
2982
3226
  })];
2983
3227
  }
2984
- }), _this4.renderEnterButtonElement()];
3228
+ }), _this6.renderEnterButtonElement()];
2985
3229
  }
2986
3230
  }), ' '];
2987
3231
  }
@@ -3008,12 +3252,14 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3008
3252
  rawData: state.rawData[props.componentId],
3009
3253
  themePreset: state.config.themePreset,
3010
3254
  isLoading: state.isLoading[props.componentId] || false,
3011
- sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || ''
3255
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3256
+ componentError: state.error[props.componentId]
3012
3257
  };
3013
3258
  };
3014
3259
  var mapDispatchToProps$1 = {
3015
3260
  getAIResponse: query.fetchAIResponse,
3016
- trackUsefullness: analytics.recordAISessionUsefulness
3261
+ trackUsefullness: analytics.recordAISessionUsefulness,
3262
+ createAISession: query.createAISession
3017
3263
  };
3018
3264
  var AIConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchToProps$1)(AIAnswer), {
3019
3265
  componentType: constants.componentTypes.AIAnswer,
@@ -3027,8 +3273,8 @@ AIConnected.install = function (Vue) {
3027
3273
  // Add componentType for SSR
3028
3274
  AIConnected.componentType = constants.componentTypes.AIAnswer;
3029
3275
 
3030
- var _templateObject$8, _templateObject2$4;
3031
- var HierarchicalMenuList = vueEmotion.styled('ul')(_templateObject$8 || (_templateObject$8 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tmax-height: 0;\n\toverflow: hidden;\n\n\t&.--open {\n\t\tmax-height: 100%;\n\t}\n"])));
3276
+ var _templateObject$9, _templateObject2$4;
3277
+ var HierarchicalMenuList = vueEmotion.styled('ul')(_templateObject$9 || (_templateObject$9 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tmax-height: 0;\n\toverflow: hidden;\n\n\t&.--open {\n\t\tmax-height: 100%;\n\t}\n"])));
3032
3278
  var HierarchicalMenuListItem = vueEmotion.styled('li')(_templateObject2$4 || (_templateObject2$4 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tfont-weight: 400;\n\tline-height: 1.5;\n\tbox-sizing: border-box;\n\n\ta {\n\t\tcolor: #424242;\n\t\ttext-decoration: none;\n\t\tgap: 5px;\n\t\t.--leaf-icon,\n\t\t.--folder-icon {\n\t\t\tline-height: 15px;\n\t\t\tsvg {\n\t\t\t\theight: 15px;\n\t\t\t}\n\t\t}\n\n\t\tinput {\n\t\t\tmargin: 0;\n\t\t\tcursor: pointer;\n\t\t}\n\t}\n\n\t.--switcher-icon {\n\t\ttransition: all 0.2s ease-in;\n\t\tmargin-right: 2px;\n\t}\n\t.--list-child {\n\t\tpadding-left: 1rem;\n\t\tposition: relative;\n\t\t&:before {\n\t\t\theight: 100%;\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\tborder-left: 1px solid #787878;\n\t\t\twidth: 0;\n\t\t\tleft: 19px;\n\t\t\t", ";\n\t\t}\n\n\t\t&.--show-switcher-icon {\n\t\t\tpadding-left: 36px;\n\t\t}\n\t}\n\t.--list-item-label {\n\t\tline-height: 100%;\n\t}\n\t.--list-item-count {\n\t\tmargin-left: 10px;\n\t\tpadding: 0.1rem 0.4rem;\n\t\tfont-size: 0.8rem;\n\t\tcolor: #424242;\n\t\tbackground-color: #dee1e6;\n\t\tborder-radius: 8px;\n\t}\n\t&.-selected-item {\n\t\tfont-weight: 700 !important;\n\t}\n\t&.-expanded-item {\n\t\t& > a {\n\t\t\t& div > .--switcher-icon {\n\t\t\t\ttransform: rotate(90deg);\n\t\t\t}\n\t\t}\n\t}\n\t.--list-item-label-count-wrapper {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\t&:hover {\n\t\t\t.--list-item-count,\n\t\t\t.--list-item-label {\n\t\t\t\tfont-weight: 700;\n\t\t\t}\n\t\t}\n\t}\n"])), function (props) {
3033
3279
  return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
3034
3280
  });