@appbaseio/reactivesearch-vue 3.0.0-rc.8 → 3.0.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 (86) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +8635 -6246
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{ComponentWrapper-0b9ffb1a.js → ComponentWrapper-0334c14b.js} +1 -1
  6. package/dist/cjs/{DropDown-82d92f8b.js → DropDown-26666911.js} +3 -3
  7. package/dist/cjs/DynamicRangeSlider.js +7 -4
  8. package/dist/cjs/{Input-fcd780de.js → Input-3ecdb905.js} +7 -66
  9. package/dist/cjs/MultiDropdownList.js +7 -6
  10. package/dist/cjs/MultiList.js +6 -5
  11. package/dist/cjs/MultiRange.js +5 -4
  12. package/dist/cjs/{Pagination-bcf8af5f.js → Pagination-c53a18ab.js} +1 -1
  13. package/dist/cjs/{PreferencesConsumer-85dee673.js → PreferencesConsumer-7bee3c57.js} +1 -1
  14. package/dist/cjs/RangeInput.js +8 -5
  15. package/dist/cjs/RangeSlider.js +8 -5
  16. package/dist/cjs/ReactiveBase.js +20 -18
  17. package/dist/cjs/ReactiveComponent.js +5 -4
  18. package/dist/cjs/ReactiveGoogleMap.js +8 -5
  19. package/dist/cjs/ReactiveList.js +6 -5
  20. package/dist/cjs/ResultCard.js +1 -1
  21. package/dist/cjs/ResultList.js +1 -1
  22. package/dist/cjs/SelectedFilters.js +2 -2
  23. package/dist/cjs/SingleDropdownList.js +7 -6
  24. package/dist/cjs/SingleList.js +6 -5
  25. package/dist/cjs/SingleRange.js +5 -4
  26. package/dist/cjs/StateProvider.js +1 -1
  27. package/dist/cjs/ToggleButton.js +5 -4
  28. package/dist/cjs/{index-779ed366.js → index-1f41363f.js} +7 -3
  29. package/dist/cjs/index.js +11 -9
  30. package/dist/cjs/{install-2a1c953d.js → install-08b8d6e7.js} +483 -152
  31. package/dist/cjs/install.js +11 -9
  32. package/dist/cjs/version.js +1 -1
  33. package/dist/cjs/{vueTypes-a5f1745e.js → vueTypes-289a891a.js} +2 -1
  34. package/dist/components/ReactiveBase/ReactiveBase.d.ts +33 -0
  35. package/dist/components/basic/ReactiveComponent.d.ts +30 -0
  36. package/dist/components/basic/ReactiveComponentPrivate.d.ts +10 -0
  37. package/dist/components/basic/SelectedFilters.d.ts +24 -0
  38. package/dist/components/basic/StateProvider.d.ts +12 -0
  39. package/dist/components/list/MultiDropdownList.d.ts +49 -0
  40. package/dist/components/list/MultiList.d.ts +47 -0
  41. package/dist/components/list/SingleDropdownList.d.ts +47 -0
  42. package/dist/components/list/SingleList.d.ts +47 -0
  43. package/dist/components/list/ToggleButton.d.ts +33 -0
  44. package/dist/components/list/TreeList.d.ts +48 -0
  45. package/dist/components/range/DynamicRangeSlider.d.ts +38 -0
  46. package/dist/components/range/MultiRange.d.ts +30 -0
  47. package/dist/components/range/RangeInput.d.ts +30 -0
  48. package/dist/components/range/RangeSlider.d.ts +40 -0
  49. package/dist/components/range/SingleRange.d.ts +28 -0
  50. package/dist/components/result/ReactiveList.d.ts +55 -0
  51. package/dist/components/result/ResultCard.d.ts +10 -0
  52. package/dist/components/result/ResultList.d.ts +11 -0
  53. package/dist/components/search/AIAnswer.d.ts +44 -0
  54. package/dist/components/search/SearchBox.d.ts +107 -0
  55. package/dist/es/{ComponentWrapper-a2635cfc.js → ComponentWrapper-46d04344.js} +1 -1
  56. package/dist/es/{DropDown-8075451b.js → DropDown-48045fde.js} +3 -3
  57. package/dist/es/DynamicRangeSlider.js +8 -5
  58. package/dist/es/{Input-4cd74b38.js → Input-83dee8c5.js} +7 -66
  59. package/dist/es/MultiDropdownList.js +7 -6
  60. package/dist/es/MultiList.js +6 -5
  61. package/dist/es/MultiRange.js +5 -4
  62. package/dist/es/{Pagination-50fc3ef5.js → Pagination-591fdb79.js} +1 -1
  63. package/dist/es/{PreferencesConsumer-b058d14e.js → PreferencesConsumer-0856ed43.js} +1 -1
  64. package/dist/es/RangeInput.js +8 -5
  65. package/dist/es/RangeSlider.js +9 -6
  66. package/dist/es/ReactiveBase.js +20 -18
  67. package/dist/es/ReactiveComponent.js +5 -4
  68. package/dist/es/ReactiveGoogleMap.js +8 -5
  69. package/dist/es/ReactiveList.js +6 -5
  70. package/dist/es/ResultCard.js +1 -1
  71. package/dist/es/ResultList.js +1 -1
  72. package/dist/es/SelectedFilters.js +2 -2
  73. package/dist/es/SingleDropdownList.js +7 -6
  74. package/dist/es/SingleList.js +6 -5
  75. package/dist/es/SingleRange.js +5 -4
  76. package/dist/es/StateProvider.js +1 -1
  77. package/dist/es/ToggleButton.js +5 -4
  78. package/dist/es/{index-882489e1.js → index-104f1dfb.js} +7 -3
  79. package/dist/es/index.js +12 -10
  80. package/dist/es/{install-f4f2557b.js → install-e883f435.js} +484 -153
  81. package/dist/es/install.js +11 -9
  82. package/dist/es/version.js +1 -1
  83. package/dist/es/{vueTypes-09cab4d3.js → vueTypes-f503e267.js} +2 -1
  84. package/dist/index.d.ts +40 -0
  85. package/dist/types.ts +226 -0
  86. package/package.json +5 -3
@@ -1,5 +1,5 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { SEARCH_COMPONENTS_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
2
+ import { SEARCH_COMPONENTS_MODES, AI_TRIGGER_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
3
3
  import _transformOn from '@vue/babel-helper-vue-transform-on';
4
4
  import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
5
5
  import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
@@ -9,22 +9,22 @@ import { styled } from '@appbaseio/vue-emotion';
9
9
  import { css, keyframes } from '@emotion/css';
10
10
  import { lighten } from 'polished';
11
11
  import { B as Button } from './Button-5c2cf399.js';
12
- import { t as types } from './vueTypes-09cab4d3.js';
12
+ import { t as types } from './vueTypes-f503e267.js';
13
13
  import { RLConnected as ReactiveList } from './ReactiveList.js';
14
14
  import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
15
- import { g as getComponent, h as hasCustomRenderer, f as decodeHtml, i as isQueryIdentical, u as updateDefaultQuery, j as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-882489e1.js';
16
- import { C as ComponentWrapper } from './ComponentWrapper-a2635cfc.js';
17
- import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.js';
15
+ import { g as getComponent, h as hasCustomRenderer, f as decodeHtml, i as isQueryIdentical, u as updateDefaultQuery, j as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-104f1dfb.js';
16
+ import { C as ComponentWrapper } from './ComponentWrapper-46d04344.js';
17
+ import { P as PreferencesConsumer } from './PreferencesConsumer-0856ed43.js';
18
18
  import { T as Title } from './Title-863dfa42.js';
19
19
  import { L as ListItem } from './ListItem-e3c6acf4.js';
20
20
  import { F as Flex } from './Flex-25792bc3.js';
21
21
  import { recordAISessionUsefulness } from '@appbaseio/reactivecore/lib/actions/analytics';
22
22
  import ReactiveBase from './ReactiveBase.js';
23
23
  import hotkeys from 'hotkeys-js';
24
- import { Remarkable } from 'remarkable';
25
24
  import xss from 'xss';
26
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-8075451b.js';
27
- import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, A as Actions$1, a as suggestions, b as searchboxSuggestions } from './Input-4cd74b38.js';
25
+ import { Remarkable } from 'remarkable';
26
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-48045fde.js';
27
+ import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, A as Actions$1, a as suggestions, b as searchboxSuggestions } from './Input-83dee8c5.js';
28
28
  import { C as Container } from './Container-d00219f7.js';
29
29
  import Highlight from 'vue-highlight-words';
30
30
  import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
@@ -54,7 +54,7 @@ var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemp
54
54
  searchBox = _ref.searchBox;
55
55
  return searchBox && "background-color: " + (theme.colors.backgroundColor || '#fafafa') + ";\n\t\tcolor: " + (theme.colors.textColor || '#fff') + ";\n\n\t\t&:focus-within {\n\t\t\tbackground-color: " + (theme.colors.backgroundColor || '#fff') + ";\n\t\t}";
56
56
  }, function (props) {
57
- return props.isOpen && 'box-shadow: rgb(0 0 0 / 20%) 0px 0px 15px;';
57
+ return props.isOpen && "box-shadow: rgb(0 0 0 / 20%) 0px 0px 15px;\n\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;";
58
58
  });
59
59
  InputGroup.defaultProps = {
60
60
  className: 'input-group'
@@ -804,7 +804,7 @@ var HorizontalSkeletonLoader = defineComponent({
804
804
  });
805
805
 
806
806
  var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
807
- var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n"])), function (props) {
807
+ var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n\n\t.--trigger-message-wrapper {\n\t\tcursor: pointer;\n\t}\n"])), function (props) {
808
808
  return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
809
809
  });
810
810
  var ChatContainer = styled('div')(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\theight: 100%;\n\tposition: relative;\n\t.--ai-answer-error-container {\n\t\ttext-align: center;\n\t\tposition: absolute;\n\t\tbottom: 0px;\n\t\t", ";\n\t\tz-index: 1;\n\t\tleft: 50%;\n\t\ttransform: translateX(-50%);\n\t\twidth: 100%;\n\n\t\t.--default-error-element {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tpadding: 10px;\n\t\t\tbackground-color: ", ";\n\t\t\tbox-shadow: 0 -5px 5px -2px\n\t\t\t\t", ";\n\n\t\t\tspan {\n\t\t\t\tmargin-bottom: 5px;\n\t\t\t}\n\n\t\t\tbutton {\n\t\t\t}\n\t\t}\n\t}\n\n\t", ";\n"])), function (props) {
@@ -829,11 +829,15 @@ var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTem
829
829
  return finalColor;
830
830
  }, typingDots);
831
831
  var resetCSS = function resetCSS(props) {
832
- return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
832
+ return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t\twhite-space: pre-wrap;\n\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
833
+ // eslint-disable-next-line no-nested-ternary
834
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\n\t}\n\n\tpre{\n\t\tcolor: " + (
833
835
  // eslint-disable-next-line no-nested-ternary
834
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\t}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
836
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
835
837
  // eslint-disable-next-line no-nested-ternary
836
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
838
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\ncode[class*='language-'],\n\tpre[class*='language-'] {\n\t\tcolor: " + (
839
+ // eslint-disable-next-line no-nested-ternary
840
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\ttext-shadow: none;\n\t}\n\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
837
841
  };
838
842
  var messageBGColor = function messageBGColor(props) {
839
843
  var finalBGColor;
@@ -862,7 +866,7 @@ var Message = styled('div')(_templateObject7 || (_templateObject7 = _taggedTempl
862
866
  return resetCSS(props);
863
867
  });
864
868
  var MessageInputContainer = styled('form')(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tpadding-top: 12px;\n\talign-items: stretch;\n\tmargin-top: 10px;\n\t.ai-enter-button-wrapper {\n\t\talign-self: baseline;\n\t\theight: 41px;\n\t}\n"])));
865
- var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t::placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t:-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t::-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\t", "\n"])), function (props) {
869
+ var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t::placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t:-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t::-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\t", "\n\tpadding-left: 35px;\n"])), function (props) {
866
870
  return props.themePreset === 'dark' ? props.theme.colors.borderColor : '#fff';
867
871
  }, function (props) {
868
872
  return props.themePreset === 'dark' ? props.theme.colors.titleColor : props.theme.colors.textColor;
@@ -1084,7 +1088,9 @@ var md = new Remarkable();
1084
1088
  md.set({
1085
1089
  html: true,
1086
1090
  breaks: true,
1087
- xhtmlOut: true
1091
+ xhtmlOut: true,
1092
+ linkify: true,
1093
+ linkTarget: '_blank'
1088
1094
  });
1089
1095
  var _dropdownULRef = 'dropdownULRef';
1090
1096
  var _inputGroupRef = 'inputGroupRef';
@@ -1112,7 +1118,9 @@ var SearchBox = defineComponent({
1112
1118
  showAIScreen: false,
1113
1119
  showAIScreenFooter: false,
1114
1120
  showFeedbackComponent: false,
1115
- feedbackState: null
1121
+ feedbackState: null,
1122
+ faqAnswer: '',
1123
+ faqQuestion: ''
1116
1124
  };
1117
1125
  this.internalComponent = props.componentId + "__internal";
1118
1126
  return this.__state;
@@ -1148,17 +1156,41 @@ var SearchBox = defineComponent({
1148
1156
  }
1149
1157
  },
1150
1158
  computed: {
1159
+ currentTriggerMode: function currentTriggerMode() {
1160
+ return this.$props.AIUIConfig && this.$props.AIUIConfig.triggerOn || AI_TRIGGER_MODES.MANUAL;
1161
+ },
1151
1162
  hasCustomRenderer: function hasCustomRenderer$1() {
1152
1163
  return hasCustomRenderer(this);
1153
1164
  },
1154
1165
  stats: function stats() {
1155
1166
  return getResultStats(this);
1156
1167
  },
1168
+ mergedAIQuestion: function mergedAIQuestion() {
1169
+ return this.faqQuestion || this.AIResponse && this.AIResponse.response && this.AIResponse.response.question;
1170
+ },
1171
+ mergedAIAnswer: function mergedAIAnswer() {
1172
+ return this.faqAnswer || this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text;
1173
+ },
1157
1174
  parsedSuggestions: function parsedSuggestions() {
1158
1175
  var suggestionsArray = [];
1159
1176
  if (Array.isArray(this.suggestions) && this.suggestions.length) {
1160
1177
  suggestionsArray = [].concat(withClickIds(this.suggestions));
1161
1178
  }
1179
+ if (this.renderTriggerMessage() && this.currentValue && !this.isLoading) {
1180
+ suggestionsArray.unshift({
1181
+ label: this.renderTriggerMessage(),
1182
+ value: 'AI_TRIGGER_MESSAGE',
1183
+ _suggestion_type: '_internal_a_i_trigger'
1184
+ });
1185
+ }
1186
+ suggestionsArray = suggestionsArray.map(function (s) {
1187
+ if (s.sectionId) {
1188
+ return s;
1189
+ }
1190
+ return _extends({}, s, {
1191
+ sectionId: s._suggestion_type
1192
+ });
1193
+ });
1162
1194
  var sectionsAccumulated = [];
1163
1195
  var sectionisedSuggestions = suggestionsArray.reduce(function (acc, d, currentIndex) {
1164
1196
  if (sectionsAccumulated.includes(d.sectionId)) return acc;
@@ -1182,6 +1214,7 @@ var SearchBox = defineComponent({
1182
1214
  className: VueTypes.string.def(''),
1183
1215
  clearIcon: types.children,
1184
1216
  componentId: types.stringRequired,
1217
+ compoundClause: types.compoundClause,
1185
1218
  customHighlight: types.func,
1186
1219
  customQuery: types.func,
1187
1220
  defaultQuery: types.func,
@@ -1204,6 +1237,11 @@ var SearchBox = defineComponent({
1204
1237
  enableQuerySuggestions: VueTypes.bool.def(false),
1205
1238
  enablePopularSuggestions: VueTypes.bool.def(false),
1206
1239
  enableRecentSuggestions: VueTypes.bool.def(false),
1240
+ enableFAQSuggestions: VueTypes.bool.def(false),
1241
+ FAQSuggestionsConfig: VueTypes.shape({
1242
+ sectionLabel: VueTypes.string,
1243
+ size: VueTypes.number
1244
+ }),
1207
1245
  fieldWeights: types.fieldWeights,
1208
1246
  filterLabel: types.string,
1209
1247
  fuzziness: types.fuzziness,
@@ -1327,7 +1365,11 @@ var SearchBox = defineComponent({
1327
1365
  if (this.$options.isTagsMode) {
1328
1366
  cause = causes.SUGGESTION_SELECT;
1329
1367
  }
1330
- this.setValue(newVal || '', true, this.$props, cause);
1368
+ if (this.$props.value === undefined) {
1369
+ this.setValue(newVal, newVal === '', this.$props, cause, false);
1370
+ } else {
1371
+ this.setValue(newVal || '', true, this.$props, cause);
1372
+ }
1331
1373
  }
1332
1374
  },
1333
1375
  focusShortcuts: function focusShortcuts() {
@@ -1415,6 +1457,20 @@ var SearchBox = defineComponent({
1415
1457
  }
1416
1458
  },
1417
1459
  methods: {
1460
+ renderTriggerMessage: function renderTriggerMessage() {
1461
+ if (this.$props.enableAI) {
1462
+ if (this.$props.AIUIConfig && this.$props.AIUIConfig.renderTriggerMessage) {
1463
+ return this.$props.AIUIConfig.renderTriggerMessage;
1464
+ }
1465
+ if (this.$slots.renderTriggerMessage) {
1466
+ return this.$slots.renderTriggerMessage();
1467
+ }
1468
+ if (this.currentTriggerMode === AI_TRIGGER_MODES.MANUAL && (this.$props.AIUIConfig ? !this.$props.AIUIConfig.askButton : true)) {
1469
+ return 'Click to trigger AIAnswer';
1470
+ }
1471
+ }
1472
+ return null;
1473
+ },
1418
1474
  handleText: function handleText(value, cause) {
1419
1475
  if (cause === causes.CLEAR_VALUE) {
1420
1476
  this.triggerCustomQuery(value);
@@ -1439,8 +1495,8 @@ var SearchBox = defineComponent({
1439
1495
  value: currentValue,
1440
1496
  resultStats: this.stats,
1441
1497
  AIData: {
1442
- question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
1443
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
1498
+ question: this.mergedAIQuestion,
1499
+ answer: this.mergedAIAnswer,
1444
1500
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
1445
1501
  showAIScreen: this.showAIScreen,
1446
1502
  sources: this.getAISourceObjects(),
@@ -1471,7 +1527,7 @@ var SearchBox = defineComponent({
1471
1527
  this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
1472
1528
  }
1473
1529
  },
1474
- setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
1530
+ setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue, shouldExecuteQuery) {
1475
1531
  var _this2 = this;
1476
1532
  if (isDefaultValue === void 0) {
1477
1533
  isDefaultValue = false;
@@ -1485,6 +1541,9 @@ var SearchBox = defineComponent({
1485
1541
  if (categoryValue === void 0) {
1486
1542
  categoryValue = undefined;
1487
1543
  }
1544
+ if (shouldExecuteQuery === void 0) {
1545
+ shouldExecuteQuery = true;
1546
+ }
1488
1547
  var performUpdate = function performUpdate() {
1489
1548
  if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
1490
1549
  return;
@@ -1513,24 +1572,31 @@ var SearchBox = defineComponent({
1513
1572
  if (_this2.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1514
1573
  queryHandlerValue = Array.isArray(_this2.selectedTags) && _this2.selectedTags.length ? _this2.selectedTags : undefined;
1515
1574
  }
1575
+ if ((_this2.faqAnswer || _this2.faqQuestion) && value === '') {
1576
+ // Empty the previous state
1577
+ _this2.faqAnswer = '';
1578
+ _this2.faqQuestion = '';
1579
+ _this2.showAIScreen = false;
1580
+ }
1516
1581
  if (isDefaultValue) {
1517
1582
  if (_this2.$props.autosuggest) {
1518
1583
  if (toggleIsOpen) {
1519
1584
  _this2.isOpen = false;
1520
1585
  }
1521
- if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1586
+ if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI && _this2.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && _this2.currentValue.endsWith('?') ? {
1522
1587
  enableAI: true
1523
- } : {});
1588
+ } : {}, shouldExecuteQuery);
1524
1589
  } // in case of strict selection only SUGGESTION_SELECT should be able
1525
1590
  // to set the query otherwise the value should reset
1526
1591
  if (props.strictSelection) {
1527
1592
  if (cause === causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
1528
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1593
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1529
1594
  } else {
1530
1595
  _this2.setValue('', true);
1531
1596
  }
1532
1597
  } else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
1533
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1598
+ _this2.showAIScreen = false;
1599
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1534
1600
  }
1535
1601
  } else {
1536
1602
  // debounce for handling text while typing
@@ -1541,10 +1607,13 @@ var SearchBox = defineComponent({
1541
1607
  };
1542
1608
  checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1543
1609
  },
1544
- triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
1610
+ triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta, shouldExecuteQuery) {
1545
1611
  if (meta === void 0) {
1546
1612
  meta = {};
1547
1613
  }
1614
+ if (shouldExecuteQuery === void 0) {
1615
+ shouldExecuteQuery = true;
1616
+ }
1548
1617
  if (!this.$props.autosuggest) {
1549
1618
  return;
1550
1619
  }
@@ -1565,12 +1634,15 @@ var SearchBox = defineComponent({
1565
1634
  value: value,
1566
1635
  componentType: componentTypes.searchBox,
1567
1636
  meta: meta
1568
- });
1637
+ }, shouldExecuteQuery);
1569
1638
  },
1570
- triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
1639
+ triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue, shouldExecuteQuery) {
1571
1640
  if (categoryValue === void 0) {
1572
1641
  categoryValue = undefined;
1573
1642
  }
1643
+ if (shouldExecuteQuery === void 0) {
1644
+ shouldExecuteQuery = true;
1645
+ }
1574
1646
  var _this$$props = this.$props,
1575
1647
  customQuery = _this$$props.customQuery,
1576
1648
  filterLabel = _this$$props.filterLabel,
@@ -1599,7 +1671,7 @@ var SearchBox = defineComponent({
1599
1671
  URLParams: URLParams,
1600
1672
  componentType: componentTypes.searchBox,
1601
1673
  category: categoryValue
1602
- });
1674
+ }, shouldExecuteQuery);
1603
1675
  },
1604
1676
  handleFocus: function handleFocus(event) {
1605
1677
  if (this.$props.autosuggest) {
@@ -1610,7 +1682,9 @@ var SearchBox = defineComponent({
1610
1682
  handleVoiceResults: function handleVoiceResults(_ref) {
1611
1683
  var results = _ref.results;
1612
1684
  if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
1685
+ var _this$$refs2;
1613
1686
  this.setValue(results[0][0].transcript.trim(), true);
1687
+ (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[this.$props.innerRef]) == null || (_this$$refs2 = _this$$refs2.$el) == null ? void 0 : _this$$refs2.focus(); // eslint-disable-line
1614
1688
  }
1615
1689
  },
1616
1690
  triggerQuery: function triggerQuery(_ref2) {
@@ -1650,6 +1724,8 @@ var SearchBox = defineComponent({
1650
1724
  clearValue: function clearValue() {
1651
1725
  this.setValue('', false, this.$props, !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined, false);
1652
1726
  this.onValueSelectedHandler('', !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined);
1727
+ this.showAIScreen = false;
1728
+ this.isOpen = false;
1653
1729
  },
1654
1730
  handleKeyDown: function handleKeyDown(event, highlightedIndex) {
1655
1731
  if (highlightedIndex === void 0) {
@@ -1662,9 +1738,10 @@ var SearchBox = defineComponent({
1662
1738
  } else if (highlightedIndex === null) {
1663
1739
  this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined,
1664
1740
  // to handle tags
1665
- !this.$props.enableAI);
1666
- if (this.$props.enableAI && !this.showAIScreen) {
1741
+ !(this.$props.enableAI && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')));
1742
+ if (this.$props.enableAI && !this.showAIScreen && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')) {
1667
1743
  this.showAIScreen = true;
1744
+ this.isOpen = true;
1668
1745
  }
1669
1746
  this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1670
1747
  }
@@ -1685,7 +1762,7 @@ var SearchBox = defineComponent({
1685
1762
  }
1686
1763
  var value = this.$props.value;
1687
1764
  if (value === undefined) {
1688
- this.setValue(inputValue, false, this.$props, undefined);
1765
+ this.setValue(inputValue, inputValue === '', this.$props, undefined, false);
1689
1766
  } else {
1690
1767
  this.$emit('change', inputValue, function (_ref3) {
1691
1768
  var isOpen = _ref3.isOpen;
@@ -1700,7 +1777,7 @@ var SearchBox = defineComponent({
1700
1777
  },
1701
1778
  handleFeaturedSuggestionClicked: function handleFeaturedSuggestionClicked(suggestion) {
1702
1779
  try {
1703
- var _this$$refs2, _this$$refs2$this$$pr;
1780
+ var _this$$refs3;
1704
1781
  if (suggestion.action === featuredSuggestionsActionTypes.NAVIGATE) {
1705
1782
  var _JSON$parse = JSON.parse(suggestion.subAction),
1706
1783
  _JSON$parse$target = _JSON$parse.target,
@@ -1719,7 +1796,7 @@ var SearchBox = defineComponent({
1719
1796
  func(suggestion, this.$data.currentValue, this.$props.customEvents);
1720
1797
  }
1721
1798
  if (suggestion.action === featuredSuggestionsActionTypes.SELECT) {
1722
- this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS);
1799
+ this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS, false);
1723
1800
  this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT);
1724
1801
  }
1725
1802
  // blur is important to close the dropdown
@@ -1727,21 +1804,41 @@ var SearchBox = defineComponent({
1727
1804
  // else Downshift probably is focusing the dropdown
1728
1805
  // and not letting it close
1729
1806
  // eslint-disable-next-line no-unused-expressions
1730
- (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$this$$pr = _this$$refs2[this.$props.innerRef]) == null ? void 0 : _this$$refs2$this$$pr.blur();
1807
+ (_this$$refs3 = this.$refs) == null || (_this$$refs3 = _this$$refs3[this.$props.innerRef]) == null || (_this$$refs3 = _this$$refs3.el) == null ? void 0 : _this$$refs3.blur();
1731
1808
  } catch (e) {
1732
1809
  console.error("Error: There was an error parsing the subAction for the featured suggestion with label, \"" + suggestion.label + "\"", e);
1733
1810
  }
1734
1811
  },
1735
1812
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
1736
1813
  var _this4 = this;
1737
- if (!this.$props.enableAI) this.isOpen = false;else {
1814
+ var value = this.$props.value;
1815
+ // The state of the suggestion is open by the time it reaches here. i.e. isOpen = true
1816
+ // handle when FAQ suggestion is clicked
1817
+ if (suggestion && suggestion._suggestion_type === suggestionTypes.FAQ) {
1818
+ this.currentValue = suggestion.value;
1819
+ // Handle AI
1820
+ // Independent of enableAI.
1821
+ this.faqAnswer = suggestion._answer;
1822
+ this.faqQuestion = suggestion.value;
1823
+ this.isOpen = true;
1738
1824
  this.showAIScreen = true;
1825
+ if (value !== undefined) this.$emit('change', suggestion.value, function () {});
1826
+ this.onValueSelectedHandler(suggestion.value);
1827
+ return;
1828
+ }
1829
+ if (suggestion && suggestion._suggestion_type === '_internal_a_i_trigger') {
1830
+ this.showAIScreen = true;
1831
+ this.askButtonOnClick();
1832
+ return;
1739
1833
  }
1740
- var value = this.$props.value;
1741
1834
 
1742
1835
  // handle featured suggestions click event
1743
1836
  if (suggestion._suggestion_type === suggestionTypes.Featured) {
1744
1837
  this.handleFeaturedSuggestionClicked(suggestion);
1838
+ // Handle AI
1839
+ if (!this.$props.enableAI) this.isOpen = false;else {
1840
+ this.showAIScreen = true;
1841
+ }
1745
1842
  return;
1746
1843
  }
1747
1844
  // Record analytics for selected suggestions
@@ -1771,6 +1868,11 @@ var SearchBox = defineComponent({
1771
1868
  });
1772
1869
  }
1773
1870
  this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
1871
+
1872
+ // Handle AI
1873
+ if (!this.$props.enableAI) this.isOpen = false;else if (this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && suggestion.value.endsWith('?')) {
1874
+ this.showAIScreen = true;
1875
+ }
1774
1876
  },
1775
1877
  onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
1776
1878
  if (currentValue === void 0) {
@@ -2014,14 +2116,14 @@ var SearchBox = defineComponent({
2014
2116
  })]);
2015
2117
  },
2016
2118
  focusSearchBox: function focusSearchBox(event) {
2017
- var _this$$refs3, _this$$refs3$this$$pr;
2119
+ var _this$$refs4;
2018
2120
  var elt = event.target || event.srcElement;
2019
2121
  var tagName = elt.tagName;
2020
2122
  if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
2021
2123
  // already in an input
2022
2124
  return;
2023
2125
  }
2024
- (_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
2126
+ (_this$$refs4 = this.$refs) == null || (_this$$refs4 = _this$$refs4[this.$props.innerRef]) == null || (_this$$refs4 = _this$$refs4.$el) == null ? void 0 : _this$$refs4.focus(); // eslint-disable-line
2025
2127
  },
2026
2128
  listenForFocusShortcuts: function listenForFocusShortcuts() {
2027
2129
  var _this9 = this;
@@ -2192,37 +2294,44 @@ var SearchBox = defineComponent({
2192
2294
  return createVNode(HorizontalSkeletonLoader, null, null);
2193
2295
  },
2194
2296
  renderAIScreenFooter: function renderAIScreenFooter() {
2195
- var _slot7;
2297
+ var _slot8;
2196
2298
  var _this13 = this;
2197
2299
  var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
2198
2300
  AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
2199
2301
  var _ref6 = AIUIConfig || {},
2200
2302
  _ref6$showSourceDocum = _ref6.showSourceDocuments,
2201
2303
  showSourceDocuments = _ref6$showSourceDocum === void 0 ? true : _ref6$showSourceDocum,
2202
- _ref6$sourceDocumentL = _ref6.sourceDocumentLabel,
2203
- sourceDocumentLabel = _ref6$sourceDocumentL === void 0 ? '_id' : _ref6$sourceDocumentL,
2204
2304
  _ref6$onSourceClick = _ref6.onSourceClick,
2205
2305
  onSourceClick = _ref6$onSourceClick === void 0 ? function () {} : _ref6$onSourceClick;
2306
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
2307
+ if (_this13.$props.AIUIConfig && _this13.$props.AIUIConfig.renderSourceDocument) {
2308
+ return _this13.$props.AIUIConfig.renderSourceDocument(sourceObj);
2309
+ }
2310
+ if (_this13.$slots.renderSourceDocument) {
2311
+ return _this13.$slots.renderSourceDocument(sourceObj);
2312
+ }
2313
+ return sourceObj._id;
2314
+ };
2206
2315
  return showSourceDocuments && this.showAIScreenFooter && this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds ? createVNode(Footer, {
2207
2316
  "themePreset": this.$props.themePreset
2208
2317
  }, {
2209
2318
  "default": function _default() {
2210
- return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot7 = _this13.getAISourceObjects().map(function (el) {
2319
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot8 = _this13.getAISourceObjects().map(function (el) {
2320
+ var _slot7;
2211
2321
  return createVNode(Button, {
2212
2322
  "class": "--ai-source-tag " + (getClassName$1(_this13.$props.innerClass, 'ai-source-tag') || ''),
2213
- "title": el[sourceDocumentLabel],
2214
2323
  "info": true,
2215
2324
  "onClick": function onClick() {
2216
2325
  return onSourceClick && onSourceClick(el);
2217
2326
  }
2218
- }, {
2327
+ }, _isSlot(_slot7 = renderSourceDocumentLabel(el)) ? _slot7 : {
2219
2328
  "default": function _default() {
2220
- return [el[sourceDocumentLabel]];
2329
+ return [_slot7];
2221
2330
  }
2222
2331
  });
2223
- })) ? _slot7 : {
2332
+ })) ? _slot8 : {
2224
2333
  "default": function _default() {
2225
- return [_slot7];
2334
+ return [_slot8];
2226
2335
  }
2227
2336
  })];
2228
2337
  }
@@ -2233,8 +2342,8 @@ var SearchBox = defineComponent({
2233
2342
  var customAIRenderer = this.$props.renderAIAnswer || this.$slots.renderAIAnswer;
2234
2343
  if (customAIRenderer) {
2235
2344
  return customAIRenderer({
2236
- question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
2237
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
2345
+ question: this.mergedAIQuestion,
2346
+ answer: this.mergedAIAnswer,
2238
2347
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
2239
2348
  loading: this.isAIResponseLoading || this.isLoading,
2240
2349
  sources: this.getAISourceObjects(),
@@ -2245,7 +2354,7 @@ var SearchBox = defineComponent({
2245
2354
  return this.renderAIScreenLoader();
2246
2355
  }
2247
2356
  return createVNode("div", null, [createVNode(Answer, {
2248
- "innerHTML": md.render(this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text)
2357
+ "innerHTML": md.render(this.mergedAIAnswer)
2249
2358
  }, null), this.renderAIScreenFooter(), this.showFeedbackComponent && createVNode("div", {
2250
2359
  "class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
2251
2360
  }, [createVNode(AIFeedback, {
@@ -2376,7 +2485,7 @@ var SearchBox = defineComponent({
2376
2485
  return (// When you change below also change the empty icon below
2377
2486
  createVNode("img", {
2378
2487
  "style": {
2379
- maxHeight: '25px'
2488
+ maxWidth: '30px'
2380
2489
  },
2381
2490
  "src": xss(item.iconURL),
2382
2491
  "alt": item.value
@@ -2389,8 +2498,8 @@ var SearchBox = defineComponent({
2389
2498
  return createVNode("span", {
2390
2499
  "style": {
2391
2500
  display: 'inline-block',
2392
- height: '25px',
2393
- width: leaveSpaceForIcon ? '25px' : 0
2501
+ height: '30px',
2502
+ width: leaveSpaceForIcon ? '30px' : 0
2394
2503
  }
2395
2504
  }, null);
2396
2505
  };
@@ -2419,6 +2528,7 @@ var SearchBox = defineComponent({
2419
2528
  var sectionHtml = xss(item[0].sectionLabel);
2420
2529
  indexOffset += item.length - 1;
2421
2530
  return createVNode("div", {
2531
+ "key": "section-" + itemIndex,
2422
2532
  "class": "section-container"
2423
2533
  }, [sectionHtml ? createVNode("div", {
2424
2534
  "class": "section-header " + getClassName$1(_this16.$props.innerClass, 'section-label'),
@@ -2430,23 +2540,43 @@ var SearchBox = defineComponent({
2430
2540
  var suggestionsHaveIcon = item.some(function (s) {
2431
2541
  return s.icon || s.iconURL;
2432
2542
  });
2433
- return renderItem ? createVNode("li", mergeProps(getItemProps({
2434
- item: sectionItem
2435
- }), _transformOn(getItemEvents({
2436
- item: sectionItem
2437
- })), {
2438
- "key": index + sectionIndex,
2439
- "style": {
2440
- justifyContent: 'flex-start',
2441
- alignItems: 'center'
2442
- },
2443
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2444
- }), [renderItem(sectionItem)]) : createVNode("li", mergeProps(getItemProps({
2543
+ if (renderItem) {
2544
+ return createVNode("li", mergeProps(getItemProps({
2545
+ item: sectionItem
2546
+ }), _transformOn(getItemEvents({
2547
+ item: sectionItem
2548
+ })), {
2549
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2550
+ "style": {
2551
+ justifyContent: 'flex-start',
2552
+ alignItems: 'center'
2553
+ },
2554
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2555
+ }), [renderItem(sectionItem)]);
2556
+ }
2557
+ if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
2558
+ return createVNode("li", mergeProps(getItemProps({
2559
+ item: sectionItem
2560
+ }), _transformOn(getItemEvents({
2561
+ item: sectionItem
2562
+ })), {
2563
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2564
+ "style": {
2565
+ justifyContent: 'flex-start',
2566
+ alignItems: 'center'
2567
+ },
2568
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2569
+ }), [createVNode(SuggestionItem, {
2570
+ "currentValue": _this16.currentValue,
2571
+ "suggestion": sectionItem
2572
+ }, null)]);
2573
+ }
2574
+ return createVNode("li", mergeProps(getItemProps({
2445
2575
  item: sectionItem
2446
2576
  }), _transformOn(getItemEvents({
2447
2577
  item: sectionItem
2448
2578
  })), {
2449
- "key": index + sectionIndex,
2579
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2450
2580
  "style": {
2451
2581
  justifyContent: 'flex-start',
2452
2582
  alignItems: 'center'
@@ -2458,6 +2588,7 @@ var SearchBox = defineComponent({
2458
2588
  display: 'flex'
2459
2589
  }
2460
2590
  }, [createVNode(CustomSvg, {
2591
+ "key": sectionItem._suggestion_type + "-" + sectionIndex,
2461
2592
  "className": getClassName$1(_this16.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
2462
2593
  "icon": getIcon(sectionItem._suggestion_type, sectionItem, suggestionsHaveIcon),
2463
2594
  "type": sectionItem._suggestion_type + "-search-icon"
@@ -2468,13 +2599,14 @@ var SearchBox = defineComponent({
2468
2599
  })])]);
2469
2600
  }
2470
2601
  return createVNode("div", null, [createTextVNode("No suggestions")]);
2471
- }), _this16.$props.showSuggestionsFooter ? _this16.suggestionsFooter() : null]) : _this16.renderNoSuggestions(_this16.normalizedSuggestions)]);
2602
+ }), !_this16.showAIScreen && _this16.parsedSuggestions.length && _this16.$props.showSuggestionsFooter ? _this16.suggestionsFooter() : null]) : _this16.renderNoSuggestions(_this16.normalizedSuggestions)]);
2472
2603
  };
2473
2604
  return createVNode("div", {
2474
2605
  "class": suggestionsContainer
2475
2606
  }, [createVNode(InputGroup, {
2476
2607
  "searchBox": true,
2477
- "ref": _inputGroupRef
2608
+ "ref": _inputGroupRef,
2609
+ "isOpen": _this16.$data.isOpen
2478
2610
  }, {
2479
2611
  "default": function _default() {
2480
2612
  return [createVNode(Actions$1, null, {
@@ -2504,17 +2636,13 @@ var SearchBox = defineComponent({
2504
2636
  setHighlightedIndex(null);
2505
2637
  }
2506
2638
  })), {
2639
+ "searchBox": true,
2640
+ "isOpen": _this16.$data.isOpen,
2507
2641
  "id": _this16.$props.componentId + "-input",
2508
- "showIcon": _this16.$props.showIcon,
2509
- "showClear": _this16.$props.showClear,
2510
- "iconPosition": _this16.$props.iconPosition,
2511
2642
  "ref": _this16.$props.innerRef,
2512
2643
  "class": getClassName$1(_this16.$props.innerClass, 'input'),
2513
2644
  "placeholder": _this16.$props.placeholder,
2514
- "autoFocus": _this16.$props.autoFocus,
2515
- "searchBox": true,
2516
- "showFocusShortcutsIcon": _this16.$props.showFocusShortcutsIcon,
2517
- "showVoiceSearch": _this16.$props.showVoiceSearch
2645
+ "autoFocus": _this16.$props.autoFocus
2518
2646
  }, getInputProps({
2519
2647
  value: _this16.$data.currentValue === null ? '' : _this16.$data.currentValue
2520
2648
  }), {
@@ -2561,6 +2689,7 @@ var SearchBox = defineComponent({
2561
2689
  _this16.$emit('key-up', e, _this16.triggerQuery);
2562
2690
  }
2563
2691
  }), {
2692
+ "searchBox": true,
2564
2693
  "class": getClassName$1(_this16.$props.innerClass, 'input') || '',
2565
2694
  "placeholder": _this16.$props.placeholder,
2566
2695
  "autofocus": _this16.$props.autoFocus,
@@ -2662,6 +2791,7 @@ SBConnected.install = function (Vue) {
2662
2791
  // Add componentType for SSR
2663
2792
  SBConnected.componentType = componentTypes.searchBox;
2664
2793
 
2794
+ var _excluded$1 = ["_source"];
2665
2795
  function _isSlot$1(s) {
2666
2796
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
2667
2797
  }
@@ -2669,7 +2799,9 @@ var md$1 = new Remarkable();
2669
2799
  md$1.set({
2670
2800
  html: true,
2671
2801
  breaks: true,
2672
- xhtmlOut: true
2802
+ xhtmlOut: true,
2803
+ linkify: true,
2804
+ linkTarget: '_blank'
2673
2805
  });
2674
2806
  var _inputWrapperRef = 'inputWrapperRef';
2675
2807
  var _inputRef = 'inputRef';
@@ -2682,7 +2814,10 @@ var AIAnswer = defineComponent({
2682
2814
  messages: [],
2683
2815
  inputMessage: '',
2684
2816
  AISessionId: '',
2685
- error: null
2817
+ error: null,
2818
+ sourceDocIds: null,
2819
+ initialHits: null,
2820
+ isTriggered: false
2686
2821
  };
2687
2822
  this.internalComponent = props.componentId + "__internal";
2688
2823
  return this.__state;
@@ -2692,7 +2827,16 @@ var AIAnswer = defineComponent({
2692
2827
  from: 'theme_reactivesearch'
2693
2828
  }
2694
2829
  },
2695
- created: function created() {},
2830
+ created: function created() {
2831
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
2832
+ this.isTriggered = true;
2833
+ } else if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
2834
+ this.isTriggered = true;
2835
+ if (this.AISessionId) {
2836
+ this.handleSendMessage(null, false, '', true);
2837
+ }
2838
+ }
2839
+ },
2696
2840
  computed: {
2697
2841
  hasCustomRenderer: function hasCustomRenderer$1() {
2698
2842
  return hasCustomRenderer(this);
@@ -2705,6 +2849,9 @@ var AIAnswer = defineComponent({
2705
2849
  },
2706
2850
  errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
2707
2851
  return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
2852
+ },
2853
+ hasTriggered: function hasTriggered() {
2854
+ return this.isTriggered;
2708
2855
  }
2709
2856
  },
2710
2857
  props: {
@@ -2743,13 +2890,26 @@ var AIAnswer = defineComponent({
2743
2890
  sessionIdFromStore: VueTypes.string,
2744
2891
  showComponent: types.boolRequired,
2745
2892
  componentError: types.componentObject,
2746
- style: types.style
2893
+ style: types.style,
2894
+ showSourceDocuments: VueTypes.bool.def(false),
2895
+ renderSourceDocument: types.func,
2896
+ onSourceClick: types.func,
2897
+ isAITyping: types.boolRequired,
2898
+ triggerOn: VueTypes.string.def(AI_TRIGGER_MODES.ALWAYS),
2899
+ renderTriggerMessage: types.func
2747
2900
  },
2748
2901
  mounted: function mounted() {},
2749
2902
  watch: {
2750
2903
  AIResponse: function AIResponse(newVal) {
2751
2904
  if (newVal) {
2752
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2905
+ if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
2906
+ this.sourceDocIds = newVal.response.answer.documentIds;
2907
+ var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
2908
+ if (localCache && localCache.meta && localCache.meta.hits) {
2909
+ this.initialHits = localCache.meta.hits;
2910
+ }
2911
+ }
2912
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2753
2913
  var messagesHistory = newVal.messages,
2754
2914
  response = newVal.response;
2755
2915
  var finalMessages = [];
@@ -2760,7 +2920,7 @@ var AIAnswer = defineComponent({
2760
2920
  }
2761
2921
 
2762
2922
  // pushing message history so far
2763
- if (messagesHistory && messagesHistory && Array.isArray(messagesHistory)) {
2923
+ if (messagesHistory && Array.isArray(messagesHistory)) {
2764
2924
  finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
2765
2925
  return msg.role !== AI_ROLES.SYSTEM;
2766
2926
  }));
@@ -2785,6 +2945,9 @@ var AIAnswer = defineComponent({
2785
2945
  loading: this.$props.isAIResponseLoading || this.$props.isLoading,
2786
2946
  error: this.$props.AIResponseError
2787
2947
  });
2948
+ if (newVal && newVal.hits && newVal.hits.hits) {
2949
+ this.initialHits = newVal.hits.hits;
2950
+ }
2788
2951
  },
2789
2952
  isAIResponseLoading: function isAIResponseLoading(newVal) {
2790
2953
  this.$emit('on-data', {
@@ -2809,7 +2972,7 @@ var AIAnswer = defineComponent({
2809
2972
  },
2810
2973
  AIResponseError: function AIResponseError(newVal) {
2811
2974
  this.error = newVal;
2812
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2975
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2813
2976
  if (this.error && !this.AISessionId) {
2814
2977
  var errorMessage = this.errorMessageForMissingSessionId;
2815
2978
  this.error = {
@@ -2830,7 +2993,7 @@ var AIAnswer = defineComponent({
2830
2993
  componentError: function componentError(newVal) {
2831
2994
  var _this = this;
2832
2995
  if (newVal && newVal._bodyBlob) {
2833
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2996
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2834
2997
  if (!this.AISessionId) {
2835
2998
  this.generateNewSessionId();
2836
2999
  }
@@ -2853,23 +3016,154 @@ var AIAnswer = defineComponent({
2853
3016
  console.error('Error reading component error text data:', error);
2854
3017
  });
2855
3018
  }
3019
+ },
3020
+ showComponent: function showComponent() {
3021
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
3022
+ this.isTriggered = true;
3023
+ }
3024
+ },
3025
+ dependentComponentValue: function dependentComponentValue(newVal) {
3026
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
3027
+ this.isTriggered = true;
3028
+ if (this.AISessionId) {
3029
+ this.handleSendMessage(null, false, '', true);
3030
+ }
3031
+ } else if (this.hasTriggered && this.$props.triggerOn !== AI_TRIGGER_MODES.ALWAYS) {
3032
+ this.isTriggered = false;
3033
+ }
3034
+ },
3035
+ AISessionId: function AISessionId(newVal) {
3036
+ if (newVal) {
3037
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
3038
+ this.handleSendMessage(null, false, '', true);
3039
+ }
3040
+ }
3041
+ },
3042
+ triggerOn: function triggerOn(newVal) {
3043
+ if (newVal === AI_TRIGGER_MODES.ALWAYS) {
3044
+ this.isTriggered = true;
3045
+ }
2856
3046
  }
2857
3047
  },
2858
3048
  methods: {
2859
- generateNewSessionId: function generateNewSessionId() {
3049
+ renderTriggerMessageFunc: function renderTriggerMessageFunc() {
3050
+ var triggerOn = this.$props.triggerOn;
3051
+ if (this.$props.renderTriggerMessage) {
3052
+ return this.$props.renderTriggerMessage;
3053
+ }
3054
+ if (this.$slots.renderTriggerMessage) {
3055
+ return this.$slots.renderTriggerMessage();
3056
+ }
3057
+ if (triggerOn === AI_TRIGGER_MODES.QUESTION) {
3058
+ if (!this.dependentComponentValue.endsWith('?')) {
3059
+ return createVNode("span", null, [createVNode("span", {
3060
+ "role": "img",
3061
+ "aria-label": "bulb"
3062
+ }, [createTextVNode("\uD83D\uDCA1")]), createTextVNode("End your question with a question mark (?)")]);
3063
+ }
3064
+ } else if (triggerOn === AI_TRIGGER_MODES.MANUAL) {
3065
+ return createVNode("span", null, [createTextVNode("Click here to ask AI"), ' ', createVNode("span", {
3066
+ "role": "img",
3067
+ "aria-label": "bulb"
3068
+ }, [createTextVNode("\uD83E\uDD16")])]);
3069
+ }
3070
+ return null;
3071
+ },
3072
+ handleTriggerClick: function handleTriggerClick() {
3073
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.MANUAL) {
3074
+ this.handleSendMessage(null, false, '', true);
3075
+ this.isTriggered = true;
3076
+ }
3077
+ },
3078
+ getAISourceObjects: function getAISourceObjects() {
2860
3079
  var _this2 = this;
3080
+ var sourceObjects = [];
3081
+ if (!this.AIResponse) return sourceObjects;
3082
+ var docIds = this.sourceDocIds || [];
3083
+ if (this.initialHits) {
3084
+ docIds.forEach(function (id) {
3085
+ var foundSourceObj = _this2.initialHits.find(function (hit) {
3086
+ return hit._id === id;
3087
+ }) || {};
3088
+ if (foundSourceObj) {
3089
+ var _foundSourceObj$_sour = foundSourceObj._source,
3090
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
3091
+ rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
3092
+ sourceObjects.push(_extends({}, rest, _source));
3093
+ }
3094
+ });
3095
+ } else {
3096
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
3097
+ return {
3098
+ _id: id
3099
+ };
3100
+ }));
3101
+ }
3102
+ return sourceObjects;
3103
+ },
3104
+ renderAIScreenFooter: function renderAIScreenFooter() {
3105
+ var _slot2;
3106
+ var _this3 = this;
3107
+ var _ref = this.$props || {},
3108
+ _ref$showSourceDocume = _ref.showSourceDocuments,
3109
+ showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
3110
+ _ref$onSourceClick = _ref.onSourceClick,
3111
+ onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
3112
+ renderSourceDocument = _ref.renderSourceDocument;
3113
+ var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
3114
+ if (this.isLoadingState || this.isAITyping) {
3115
+ return null;
3116
+ }
3117
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
3118
+ if (customRenderSourceDoc) {
3119
+ return customRenderSourceDoc(sourceObj);
3120
+ }
3121
+ return sourceObj._id;
3122
+ };
3123
+ return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? createVNode(Footer, {
3124
+ "themePreset": this.$props.themePreset,
3125
+ "style": {
3126
+ marginTop: '1.5rem',
3127
+ background: 'inherit'
3128
+ }
3129
+ }, {
3130
+ "default": function _default() {
3131
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
3132
+ var _slot;
3133
+ return createVNode(Button, {
3134
+ "class": "--ai-source-tag " + (getClassName$2(_this3.$props.innerClass, 'ai-source-tag') || ''),
3135
+ "info": true,
3136
+ "onClick": function onClick() {
3137
+ return onSourceClick && onSourceClick(el);
3138
+ },
3139
+ "key": el._id
3140
+ }, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
3141
+ "default": function _default() {
3142
+ return [_slot];
3143
+ }
3144
+ });
3145
+ })) ? _slot2 : {
3146
+ "default": function _default() {
3147
+ return [_slot2];
3148
+ }
3149
+ })];
3150
+ }
3151
+ }) : null;
3152
+ },
3153
+ generateNewSessionId: function generateNewSessionId() {
3154
+ var _this4 = this;
2861
3155
  var newSessionPromise = this.createAISession();
2862
3156
  newSessionPromise.then(function (res) {
2863
- _this2.AISessionId = res.AIsessionId;
3157
+ _this4.AISessionId = res.AIsessionId;
2864
3158
  })["catch"](function (e) {
2865
3159
  console.error(e);
2866
3160
  });
2867
3161
  },
2868
3162
  scrollToBottom: function scrollToBottom() {
2869
- var _this3 = this;
3163
+ var _this5 = this;
2870
3164
  this.$nextTick(function () {
2871
- var _this3$$refs;
2872
- var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
3165
+ var _this5$$refs;
3166
+ var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
2873
3167
  if (messageContainer && messageContainer.$el) {
2874
3168
  messageContainer.$el.scrollTo({
2875
3169
  top: messageContainer.$el.scrollHeight,
@@ -2882,24 +3176,33 @@ var AIAnswer = defineComponent({
2882
3176
  this.inputMessage = e.target.value;
2883
3177
  this.handleTextAreaHeightChange();
2884
3178
  },
2885
- handleSendMessage: function handleSendMessage(e, isRetry, text) {
3179
+ handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
2886
3180
  if (isRetry === void 0) {
2887
3181
  isRetry = false;
2888
3182
  }
2889
3183
  if (text === void 0) {
2890
3184
  text = this.inputMessage;
2891
3185
  }
3186
+ if (fetchMeta === void 0) {
3187
+ fetchMeta = false;
3188
+ }
2892
3189
  if (typeof e === 'object' && e !== null) e.preventDefault();
2893
- if (text.trim()) {
3190
+ if (text.trim() || !text && !e) {
2894
3191
  if (this.isLoadingState) {
2895
3192
  return;
2896
3193
  }
2897
3194
  if (this.AISessionId) {
2898
- if (!isRetry) this.messages = [].concat(this.messages, [{
2899
- content: text,
2900
- role: AI_ROLES.USER
2901
- }]);
2902
- this.getAIResponse(this.AISessionId, this.componentId, text);
3195
+ if (!isRetry) {
3196
+ var finalMessages = [].concat(this.messages);
3197
+ if (text) {
3198
+ finalMessages.push({
3199
+ content: text,
3200
+ role: AI_ROLES.USER
3201
+ });
3202
+ }
3203
+ this.messages = [].concat(finalMessages);
3204
+ }
3205
+ this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
2903
3206
  } else {
2904
3207
  console.error(this.errorMessageForMissingSessionId);
2905
3208
  this.error = {
@@ -2948,7 +3251,6 @@ var AIAnswer = defineComponent({
2948
3251
  return null;
2949
3252
  },
2950
3253
  handleKeyPress: function handleKeyPress(e) {
2951
- window.console.log('e', e);
2952
3254
  if (e.key === 'Enter') {
2953
3255
  this.handleSendMessage(e);
2954
3256
  this.inputMessage = '';
@@ -2980,15 +3282,15 @@ var AIAnswer = defineComponent({
2980
3282
  if (typeof window === 'undefined') return false;
2981
3283
  return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
2982
3284
  },
2983
- handleVoiceResults: function handleVoiceResults(_ref) {
2984
- var results = _ref.results;
3285
+ handleVoiceResults: function handleVoiceResults(_ref2) {
3286
+ var results = _ref2.results;
2985
3287
  if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
2986
3288
  this.handleSendMessage(null, false, results[0][0].transcript.trim());
2987
3289
  }
2988
3290
  },
2989
3291
  renderIcons: function renderIcons() {
2990
- var _this4 = this;
2991
- var _slot, _slot2;
3292
+ var _this6 = this;
3293
+ var _slot3, _slot4;
2992
3294
  var _this$$props = this.$props,
2993
3295
  getMicInstance = _this$$props.getMicInstance,
2994
3296
  showVoiceInput = _this$$props.showVoiceInput,
@@ -3001,14 +3303,14 @@ var AIAnswer = defineComponent({
3001
3303
  "positionType": "absolute"
3002
3304
  }, {
3003
3305
  "default": function _default() {
3004
- return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && createVNode(Mic, {
3306
+ return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && createVNode(Mic, {
3005
3307
  "getInstance": getMicInstance,
3006
3308
  "render": renderMic,
3007
- "handleResult": _this4.handleVoiceResults,
3309
+ "handleResult": _this6.handleVoiceResults,
3008
3310
  "class": getClassName$2(innerClass, 'ai-search-mic') || null
3009
- }, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
3311
+ }, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
3010
3312
  "default": function _default() {
3011
- return [_slot];
3313
+ return [_slot3];
3012
3314
  }
3013
3315
  })];
3014
3316
  }
@@ -3018,9 +3320,9 @@ var AIAnswer = defineComponent({
3018
3320
  "positionType": "absolute"
3019
3321
  }, {
3020
3322
  "default": function _default() {
3021
- return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
3323
+ return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
3022
3324
  "default": function _default() {
3023
- return [_slot2];
3325
+ return [_slot4];
3024
3326
  }
3025
3327
  })];
3026
3328
  }
@@ -3030,7 +3332,7 @@ var AIAnswer = defineComponent({
3030
3332
  this.handleSendMessage(e);
3031
3333
  },
3032
3334
  renderEnterButtonElement: function renderEnterButtonElement() {
3033
- var _this5 = this;
3335
+ var _this7 = this;
3034
3336
  var _this$$props2 = this.$props,
3035
3337
  enterButton = _this$$props2.enterButton,
3036
3338
  innerClass = _this$$props2.innerClass;
@@ -3038,16 +3340,16 @@ var AIAnswer = defineComponent({
3038
3340
  if (enterButton) {
3039
3341
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
3040
3342
  if (renderEnterButton) {
3041
- return renderEnterButton(_this5.enterButtonOnClick);
3343
+ return renderEnterButton(_this7.enterButtonOnClick);
3042
3344
  }
3043
3345
  return createVNode(SendButton, {
3044
3346
  "primary": true,
3045
3347
  "type": "submit",
3046
3348
  "tabIndex": 0,
3047
- "onClick": _this5.handleSendMessage,
3048
- "onKeyPress": _this5.handleKeyPress,
3349
+ "onClick": _this7.handleSendMessage,
3350
+ "onKeyPress": _this7.handleKeyPress,
3049
3351
  "class": "ask-btn " + getClassName$2(innerClass, 'ai-enter-button'),
3050
- "disabled": _this5.isLoadingState || !_this5.AISessionId
3352
+ "disabled": _this7.isLoadingState || !_this7.AISessionId
3051
3353
  }, {
3052
3354
  "default": function _default() {
3053
3355
  return [createTextVNode("Send")];
@@ -3070,9 +3372,9 @@ var AIAnswer = defineComponent({
3070
3372
  return getComponent(data, this);
3071
3373
  },
3072
3374
  handleTextAreaHeightChange: function handleTextAreaHeightChange() {
3073
- var _this$$refs, _this$$refs$_inputRef, _this$$refs2, _this$$refs2$_inputWr, _this$$refs3;
3074
- var textArea = (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$_inputRef = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs$_inputRef.$el;
3075
- var inputWrapper = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputWr = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2$_inputWr.$el;
3375
+ var _this$$refs, _this$$refs2, _this$$refs3;
3376
+ var textArea = (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs.$el;
3377
+ var inputWrapper = (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2.$el;
3076
3378
  var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
3077
3379
  if (textArea) {
3078
3380
  textArea.style.height = '42px';
@@ -3090,6 +3392,20 @@ var AIAnswer = defineComponent({
3090
3392
  }
3091
3393
  this.$forceUpdate();
3092
3394
  }
3395
+ },
3396
+ getTitle: function getTitle() {
3397
+ var _this8 = this;
3398
+ var hasTitle = this.$props.title || this.$slots.title || null;
3399
+ if (hasTitle) {
3400
+ return createVNode(Title, {
3401
+ "class": getClassName$2(this.$props.innerClass, 'ai-title') || null
3402
+ }, {
3403
+ "default": function _default() {
3404
+ return [_this8.$props.title || _this8.$slots.title()];
3405
+ }
3406
+ });
3407
+ }
3408
+ return null;
3093
3409
  }
3094
3410
  },
3095
3411
  beforeUnmount: function beforeUnmount() {
@@ -3104,55 +3420,62 @@ var AIAnswer = defineComponent({
3104
3420
  }
3105
3421
  },
3106
3422
  render: function render() {
3107
- var _slot3;
3108
- var _this6 = this;
3423
+ var _slot5;
3424
+ var _this9 = this;
3109
3425
  var props = this.$props;
3110
3426
  if (!this.shouldShowComponent) {
3111
3427
  return null;
3112
3428
  }
3429
+ if (!this.isTriggered) {
3430
+ return createVNode(Chatbox, {
3431
+ "style": props.style || {}
3432
+ }, {
3433
+ "default": function _default() {
3434
+ return [_this9.getTitle(), createVNode("div", {
3435
+ "class": "--trigger-message-wrapper",
3436
+ "onClick": _this9.handleTriggerClick,
3437
+ "aria-hidden": "true"
3438
+ }, [_this9.renderTriggerMessageFunc()])];
3439
+ }
3440
+ });
3441
+ }
3113
3442
  return createVNode(Chatbox, {
3114
3443
  "style": props.style || {}
3115
3444
  }, {
3116
3445
  "default": function _default() {
3117
- return [_this6.$props.title && createVNode(Title, {
3118
- "class": getClassName$2(_this6.$props.innerClass, 'title') || ''
3119
- }, {
3120
- "default": function _default() {
3121
- return [_this6.$props.title];
3122
- }
3123
- }), createVNode(ChatContainer, {
3446
+ return [_this9.getTitle(), createVNode(ChatContainer, {
3124
3447
  "class": "--ai-chat-container",
3125
3448
  "theme": props.theme,
3126
3449
  "showInput": props.showInput
3127
3450
  }, {
3128
3451
  "default": function _default() {
3129
- return [_this6.hasCustomRenderer && createVNode(MessagesContainer, {
3130
- "themePreset": _this6.themePreset,
3452
+ return [_this9.hasCustomRenderer && createVNode(MessagesContainer, {
3453
+ "themePreset": _this9.themePreset,
3131
3454
  "theme": props.theme,
3132
- "ref": _this6.$props.innerRef,
3455
+ "ref": _this9.$props.innerRef,
3133
3456
  "class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
3134
- }, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
3457
+ }, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
3135
3458
  "default": function _default() {
3136
- return [_slot3];
3459
+ return [_slot5];
3137
3460
  }
3138
- }), !_this6.hasCustomRenderer && createVNode(MessagesContainer, {
3139
- "themePreset": _this6.themePreset,
3461
+ }), !_this9.hasCustomRenderer && createVNode(MessagesContainer, {
3462
+ "themePreset": _this9.themePreset,
3140
3463
  "theme": props.theme,
3141
- "ref": _this6.$props.innerRef,
3464
+ "ref": _this9.$props.innerRef,
3142
3465
  "class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
3143
3466
  }, {
3144
3467
  "default": function _default() {
3145
- return [_this6.messages.map(function (message, index) {
3468
+ return [_this9.messages.map(function (message, index) {
3146
3469
  return createVNode(Message, {
3147
3470
  "key": index,
3148
3471
  "isSender": message.role === AI_ROLES.USER,
3149
3472
  "innerHTML": md$1.render(message.content),
3150
- "themePreset": _this6.themePreset,
3473
+ "themePreset": _this9.themePreset,
3151
3474
  "theme": props.theme,
3152
3475
  "class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
3153
3476
  }, null);
3154
- }), _this6.isLoadingState && createVNode(Message, {
3155
- "themePreset": _this6.themePreset,
3477
+ }), _this9.isLoadingState && createVNode(Message, {
3478
+ "themePreset": _this9.themePreset,
3156
3479
  "theme": props.theme,
3157
3480
  "isSender": false,
3158
3481
  "class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || null)
@@ -3161,31 +3484,31 @@ var AIAnswer = defineComponent({
3161
3484
  return [createVNode(TypingIndicator, null, {
3162
3485
  "default": function _default() {
3163
3486
  return [createVNode(TypingDot, {
3164
- "themePreset": _this6.themePreset
3487
+ "themePreset": _this9.themePreset
3165
3488
  }, null), createVNode(TypingDot, {
3166
- "themePreset": _this6.themePreset
3489
+ "themePreset": _this9.themePreset
3167
3490
  }, null), createVNode(TypingDot, {
3168
- "themePreset": _this6.themePreset
3491
+ "themePreset": _this9.themePreset
3169
3492
  }, null)];
3170
3493
  }
3171
3494
  })];
3172
3495
  }
3173
3496
  })];
3174
3497
  }
3175
- }), _this6.renderErrorComponent(), ' ', props.showFeedback && createVNode("div", {
3498
+ }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && createVNode("div", {
3176
3499
  "class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
3177
3500
  }, [createVNode(AIFeedback, {
3178
- "hideUI": _this6.isLoadingState || !_this6.sessionId,
3179
- "key": _this6.sessionId,
3501
+ "hideUI": _this9.isLoadingState || !_this9.sessionId,
3502
+ "key": _this9.sessionId,
3180
3503
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
3181
- _this6.trackUsefullness(_this6.sessionId, {
3504
+ _this9.trackUsefullness(_this9.sessionId, {
3182
3505
  useful: useful,
3183
3506
  reason: reason
3184
3507
  });
3185
3508
  }
3186
- }, null)]), props.showInput && createVNode(MessageInputContainer, {
3509
+ }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && createVNode(MessageInputContainer, {
3187
3510
  "class": "--ai-input-container",
3188
- "onSubmit": _this6.handleSendMessage
3511
+ "onSubmit": _this9.handleSendMessage
3189
3512
  }, {
3190
3513
  "default": function _default() {
3191
3514
  return [createVNode(InputGroup, {
@@ -3201,19 +3524,19 @@ var AIAnswer = defineComponent({
3201
3524
  "ref": _inputRef,
3202
3525
  "placeholder": props.placeholder,
3203
3526
  "enterButton": props.enterButton,
3204
- "value": _this6.inputMessage,
3205
- "onInput": _this6.handleMessageInputChange,
3527
+ "value": _this9.inputMessage,
3528
+ "onInput": _this9.handleMessageInputChange,
3206
3529
  "id": props.componentId + "-ai-input",
3207
3530
  "showIcon": props.showIcon,
3208
3531
  "iconPosition": props.iconPosition,
3209
- "themePreset": _this6.themePreset,
3210
- "disabled": _this6.isLoadingState || !_this6.AISessionId,
3532
+ "themePreset": _this9.themePreset,
3533
+ "disabled": _this9.isLoadingState || !_this9.AISessionId,
3211
3534
  "class": getClassName$2(props.innerClass, 'ai-input') || null
3212
- }, null), ' ', _this6.renderIcons()];
3535
+ }, null), ' ', _this9.renderIcons()];
3213
3536
  }
3214
3537
  })];
3215
3538
  }
3216
- }), _this6.renderEnterButtonElement()];
3539
+ }), _this9.renderEnterButtonElement()];
3217
3540
  }
3218
3541
  }), ' '];
3219
3542
  }
@@ -3231,9 +3554,11 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3231
3554
  // eslint-disable-next-line prefer-destructuring
3232
3555
  dependencyComponent = dependencyComponent[0];
3233
3556
  }
3234
- var showComponent = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value;
3557
+ var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
3558
+ var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
3235
3559
  return {
3236
3560
  showComponent: showComponent,
3561
+ dependentComponentValue: dependentComponentValue,
3237
3562
  AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
3238
3563
  isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
3239
3564
  AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
@@ -3241,11 +3566,17 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3241
3566
  themePreset: state.config.themePreset,
3242
3567
  isLoading: state.isLoading[props.componentId] || false,
3243
3568
  sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3244
- componentError: state.error[props.componentId]
3569
+ componentError: state.error[props.componentId] || null,
3570
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
3245
3571
  };
3246
3572
  };
3247
3573
  var mapDispatchToProps$1 = {
3248
- getAIResponse: fetchAIResponse,
3574
+ getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
3575
+ if (shouldFetchMeta === void 0) {
3576
+ shouldFetchMeta = false;
3577
+ }
3578
+ return fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
3579
+ },
3249
3580
  trackUsefullness: recordAISessionUsefulness,
3250
3581
  createAISession: createAISession
3251
3582
  };