@appbaseio/reactivesearch-vue 3.0.0-rc.2 → 3.0.0-rc.3

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 (57) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +8117 -7235
  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/{Button-d4da7470.js → Button-9e179864.js} +13 -6
  6. package/dist/cjs/{DropDown-3797bb6a.js → DropDown-aef75c14.js} +7 -4
  7. package/dist/cjs/DynamicRangeSlider.js +1 -1
  8. package/dist/cjs/{Input-497be42a.js → Input-56eba499.js} +71 -1
  9. package/dist/cjs/MultiDropdownList.js +5 -4
  10. package/dist/cjs/MultiList.js +2 -2
  11. package/dist/cjs/MultiRange.js +1 -1
  12. package/dist/cjs/{Pagination-b1a053a7.js → Pagination-58a0cf3f.js} +2 -2
  13. package/dist/cjs/RangeInput.js +2 -2
  14. package/dist/cjs/RangeSlider.js +1 -1
  15. package/dist/cjs/ReactiveBase.js +1 -1
  16. package/dist/cjs/ReactiveComponent.js +1 -1
  17. package/dist/cjs/ReactiveGoogleMap.js +4 -3
  18. package/dist/cjs/ReactiveList.js +3 -3
  19. package/dist/cjs/ResultCard.js +1 -1
  20. package/dist/cjs/ResultList.js +1 -1
  21. package/dist/cjs/SelectedFilters.js +3 -2
  22. package/dist/cjs/SingleDropdownList.js +5 -4
  23. package/dist/cjs/SingleList.js +2 -2
  24. package/dist/cjs/SingleRange.js +1 -1
  25. package/dist/cjs/ToggleButton.js +3 -2
  26. package/dist/cjs/index.js +7 -7
  27. package/dist/cjs/{install-581d2e18.js → install-b495bb2c.js} +803 -230
  28. package/dist/cjs/install.js +7 -7
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/{vueTypes-d05e44cc.js → vueTypes-a5f1745e.js} +10 -0
  31. package/dist/es/{Button-fd869491.js → Button-c2ff5178.js} +13 -6
  32. package/dist/es/{DropDown-ff8e06b4.js → DropDown-39fedff8.js} +7 -4
  33. package/dist/es/DynamicRangeSlider.js +1 -1
  34. package/dist/es/{Input-f7499ef8.js → Input-11d211d2.js} +71 -2
  35. package/dist/es/MultiDropdownList.js +5 -4
  36. package/dist/es/MultiList.js +2 -2
  37. package/dist/es/MultiRange.js +1 -1
  38. package/dist/es/{Pagination-aecb3914.js → Pagination-ae401c33.js} +2 -2
  39. package/dist/es/RangeInput.js +2 -2
  40. package/dist/es/RangeSlider.js +1 -1
  41. package/dist/es/ReactiveBase.js +1 -1
  42. package/dist/es/ReactiveComponent.js +1 -1
  43. package/dist/es/ReactiveGoogleMap.js +4 -3
  44. package/dist/es/ReactiveList.js +3 -3
  45. package/dist/es/ResultCard.js +1 -1
  46. package/dist/es/ResultList.js +1 -1
  47. package/dist/es/SelectedFilters.js +3 -2
  48. package/dist/es/SingleDropdownList.js +5 -4
  49. package/dist/es/SingleList.js +2 -2
  50. package/dist/es/SingleRange.js +1 -1
  51. package/dist/es/ToggleButton.js +3 -2
  52. package/dist/es/index.js +8 -8
  53. package/dist/es/{install-3c029475.js → install-6011bce3.js} +806 -233
  54. package/dist/es/install.js +7 -7
  55. package/dist/es/version.js +1 -1
  56. package/dist/es/{vueTypes-d64f04f8.js → vueTypes-09cab4d3.js} +10 -0
  57. package/package.json +5 -4
@@ -1,15 +1,15 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
2
  import { SEARCH_COMPONENTS_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
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
5
- import { createVNode, createTextVNode, defineComponent, isVNode, mergeProps, h } from 'vue';
4
+ import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
5
+ import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
6
6
  import VueTypes from 'vue-types';
7
- import { getQueryOptions, suggestionTypes, getObjectFromLocalStorage, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, updateCustomQuery as updateCustomQuery$1, updateDefaultQuery as updateDefaultQuery$1, transformTreeListLocalStateIntoQueryComptaibleFormat, isEqual as isEqual$1, transformRawTreeListData, setDeep, getComponent as getComponent$1, getOptionsFromQuery, checkValueChange as checkValueChange$1, getAggsQuery, updateInternalQuery, isFunction as isFunction$1 } from '@appbaseio/reactivecore/lib/utils/helper';
7
+ import { getQueryOptions, getObjectFromLocalStorage, suggestionTypes, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, updateCustomQuery as updateCustomQuery$1, updateDefaultQuery as updateDefaultQuery$1, transformTreeListLocalStateIntoQueryComptaibleFormat, isEqual as isEqual$1, transformRawTreeListData, setDeep, getComponent as getComponent$1, getOptionsFromQuery, checkValueChange as checkValueChange$1, getAggsQuery, updateInternalQuery, isFunction as isFunction$1 } from '@appbaseio/reactivecore/lib/utils/helper';
8
8
  import { styled, createGlobalStyle } from '@appbaseio/vue-emotion';
9
9
  import { css, keyframes } from '@emotion/css';
10
10
  import { lighten } from 'polished';
11
- import { B as Button } from './Button-fd869491.js';
12
- import { t as types } from './vueTypes-d64f04f8.js';
11
+ import { B as Button } from './Button-c2ff5178.js';
12
+ import { t as types } from './vueTypes-09cab4d3.js';
13
13
  import { RLConnected as ReactiveList } from './ReactiveList.js';
14
14
  import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
15
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';
@@ -18,14 +18,15 @@ import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.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
+ import { recordAISessionUsefulness } from '@appbaseio/reactivecore/lib/actions/analytics';
21
22
  import ReactiveBase from './ReactiveBase.js';
22
23
  import hotkeys from 'hotkeys-js';
23
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './DropDown-ff8e06b4.js';
24
- import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-f7499ef8.js';
24
+ import { Remarkable } from 'remarkable';
25
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './DropDown-39fedff8.js';
26
+ import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, a as suggestions } from './Input-11d211d2.js';
25
27
  import { C as Container } from './Container-d00219f7.js';
26
28
  import Highlight from 'vue-highlight-words';
27
29
  import { fetchAIResponse } from '@appbaseio/reactivecore/lib/actions/query';
28
- import { Remarkable } from 'remarkable';
29
30
  import { replaceDiacritics } from '@appbaseio/reactivecore/lib/utils/suggestions';
30
31
  import { C as Checkbox, R as Radio } from './FormControlList-fe6eaee4.js';
31
32
  import { s as sanitizeObject } from './utils-d7dd4f4e.js';
@@ -47,7 +48,7 @@ import ResultList from './ResultList.js';
47
48
  import StateProvider from './StateProvider.js';
48
49
 
49
50
  var _templateObject;
50
- var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: stretch;\n width: 100%;\n"])));
51
+ var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: stretch;\n\twidth: 100%;\n"])));
51
52
  InputGroup.defaultProps = {
52
53
  className: 'input-group'
53
54
  };
@@ -755,9 +756,305 @@ var _templateObject$7, _templateObject2;
755
756
  var TagsContainer = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tmargin-top: 10px;\n\twidth: 100%;\n"])));
756
757
  var TagItem = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tcursor: default;\n\tbox-sizing: border-box;\n\tmargin: 0 4px 4px 0;\n\tcolor: #000000d9;\n\tfont-size: 14px;\n\tfont-variant: tabular-nums;\n\tline-height: 1.5715;\n\tlist-style: none;\n\tfont-feature-settings: 'tnum';\n\tdisplay: inline-block;\n\theight: auto;\n\tpadding: 0 2px 0 7px;\n\tfont-size: 12px;\n\tline-height: 22px;\n\twhite-space: nowrap;\n\tbackground: #fafafa;\n\tborder: 1px solid #d9d9d9;\n\tborder-radius: 2px;\n\topacity: 1;\n\ttransition: all 0.3s;\n\n\tspan.close-icon {\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\theight: 15px;\n\t\t\tposition: relative;\n\t\t\ttop: 4px;\n\t\t\tfill: #262626;\n\t\t}\n\t}\n"])));
757
758
 
759
+ var _templateObject$8, _templateObject2$1, _templateObject3;
760
+ var skeletonAnimation = keyframes(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteralLoose(["\n 0% {\n background-position: 100% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n"])));
761
+ var SkeletonLoader = styled('div')(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n"])));
762
+ var SkeletonLine = styled('div')(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\theight: 20px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\trgba(220, 220, 220, 0.5) 25%,\n\t\trgba(240, 240, 240, 0.9) 50%,\n\t\trgba(220, 220, 220, 0.5) 75%\n\t);\n\tbackground-size: 200% 100%;\n\tanimation: ", " 1.5s infinite;\n"])), skeletonAnimation);
763
+ var HorizontalSkeletonLoader = defineComponent({
764
+ name: 'HorizontalSkeletonLoader',
765
+ render: function render() {
766
+ return createVNode(SkeletonLoader, null, {
767
+ "default": function _default() {
768
+ return [createVNode(SkeletonLine, null, null), createVNode(SkeletonLine, null, null), createVNode(SkeletonLine, null, null), createVNode(SkeletonLine, null, null)];
769
+ }
770
+ });
771
+ }
772
+ });
773
+
774
+ var _templateObject$9, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
775
+ var Chatbox = styled('div')(_templateObject$9 || (_templateObject$9 = _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) {
776
+ return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
777
+ });
778
+ 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) {
779
+ return props.showInput ? 'bottom: 48px;' : '';
780
+ }, function (props) {
781
+ return props.theme && props.theme.colors && props.theme.colors.backgroundColor ? props.theme.colors.backgroundColor : '#fff';
782
+ }, function (props) {
783
+ return props.theme && props.theme.colors && props.theme.colors.backgroundColor ? props.theme.colors.backgroundColor : '#fff';
784
+ }, function (props) {
785
+ return props.showInput ? ".--ai-answer-feedback-container {\n\t\tmargin-top: 15px;\n\t\tmargin-bottom: -10px;\n\t}" : ".--ai-answer-feedback-container {\n\t\tmargin-top: 4px;\n\t}";
786
+ });
787
+ var MessagesContainer = styled('div')(_templateObject3$1 || (_templateObject3$1 = _taggedTemplateLiteralLoose(["\n\tmax-height: 400px;\n overflow-y: auto;\n\tpadding: 10px;\n\tdisplay: flex;\n\tflex-direction: column;\n\tmin-height: 200px;\n\n}};\n"])));
788
+ var typingDots = keyframes(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n 0% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-70%);\n }\n 100% {\n transform: translateY(0);\n }\n"])));
789
+ var TypingIndicator = styled('div')(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmargin: 5px !important;\n"])));
790
+ var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n\twidth: 6px;\n\theight: 6px;\n\tbackground-color: ", ";\n\tborder-radius: 50%;\n\tmargin: 0 2px !important;\n\tanimation: ", " 1s infinite;\n\t&:nth-child(2) {\n\t\tanimation-delay: 0.2s;\n\t}\n\t&:nth-child(3) {\n\t\tanimation-delay: 0.4s;\n\t}\n"])), function (props) {
791
+ var finalColor;
792
+ if (props.isSender) {
793
+ finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
794
+ } else {
795
+ finalColor = props.themePreset !== 'dark' ? props.theme.colors.borderColor : props.theme.colors.textColor;
796
+ }
797
+ return finalColor;
798
+ }, typingDots);
799
+ var resetCSS = function resetCSS(props) {
800
+ 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: " + (
801
+ // eslint-disable-next-line no-nested-ternary
802
+ 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: " + (
803
+ // eslint-disable-next-line no-nested-ternary
804
+ 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\n\t}\n\n\tli{\n\t\tdisplay: unset;\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";
805
+ };
806
+ var messageBGColor = function messageBGColor(props) {
807
+ var finalBGColor;
808
+ if (props.isSender) {
809
+ finalBGColor = props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor;
810
+ } else {
811
+ finalBGColor = props.themePreset !== 'dark' ? lighten(0.53, props.theme.colors.borderColor) : props.theme.colors.backgroundColor;
812
+ }
813
+ return finalBGColor;
814
+ };
815
+ var Message = styled('div')(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n\tbackground-color: ", ";\n\tcolor: ", ";\n\tborder: 1px solid\n\t\t", ";\n\tpadding: 10px;\n\tborder-radius: 7px;\n\tmargin-bottom: 10px;\n\tmax-width: 80%;\n\talign-self: ", ";\n\tdisplay: inline-block;\n\tposition: relative;\n\toverflow-wrap: anywhere;\n\t", "\n"])), function (props) {
816
+ return messageBGColor(props);
817
+ }, function (props) {
818
+ var finalColor;
819
+ if (props.isSender) {
820
+ finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
821
+ } else {
822
+ finalColor = props.themePreset !== 'dark' ? props.theme.colors.borderColor : props.theme.colors.textColor;
823
+ }
824
+ return finalColor;
825
+ }, function (props) {
826
+ return props.themePreset === 'dark' ? 'currentColor' : messageBGColor(props);
827
+ }, function (props) {
828
+ return props.isSender ? 'flex-end' : 'flex-start';
829
+ }, function (props) {
830
+ return resetCSS(props);
831
+ });
832
+ 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"])));
833
+ 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) {
834
+ return props.themePreset === 'dark' ? props.theme.colors.borderColor : '#fff';
835
+ }, function (props) {
836
+ return props.themePreset === 'dark' ? props.theme.colors.titleColor : props.theme.colors.textColor;
837
+ }, function (props) {
838
+ return props.theme.colors.textColor;
839
+ }, function (props) {
840
+ return props.theme.colors.textColor;
841
+ }, function (props) {
842
+ return props.theme.colors.textColor;
843
+ }, function (_ref) {
844
+ var enterButton = _ref.enterButton;
845
+ return enterButton && "\n\t\t border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n\t";
846
+ });
847
+ var SendButton = styled(Button)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n\tborder: none;\n\tcolor: #ffffff;\n\tcursor: pointer;\n\tfont-size: 16px;\n\tmargin-left: 8px;\n\toutline: none;\n\tpadding: 10px;\n\ttext-align: center;\n"])));
848
+ var AIFeedbackContainer = styled('div')(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n\t.--feedback-svgs-wrapper {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: flex-end;\n\t\tgap: 5px;\n\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\ttransition: all ease-in 0.1s;\n\t\t\t&.selected {\n\t\t\t\ttransform: scale(1.1);\n\t\t\t\tcursor: default;\n\t\t\t}\n\n\t\t\t&:hover {\n\t\t\t\ttransform: scale(1.1);\n\t\t\t}\n\t\t}\n\t}\n\n\t.--feedback-input-wrapper {\n\t\tdisplay: flex;\n\t\tgap: 7px;\n\t}\n"])));
849
+
850
+ var _templateObject$a, _templateObject2$3, _templateObject3$2, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1;
851
+ var fadeInFromBottom = keyframes(_templateObject$a || (_templateObject$a = _taggedTemplateLiteralLoose(["\n 0% {\n opacity: 0;\n transform: translateY(20px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
852
+ var fadeInFromTop = keyframes(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n 0% {\n opacity: 0;\n transform: translateY(-20px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
853
+ var SearchBoxAISection = styled('div')(_templateObject3$2 || (_templateObject3$2 = _taggedTemplateLiteralLoose(["\n\tpadding: 10px;\n\tborder-radius: 4px;\n\tmin-height: 200px;\n\tpadding-top: 20px;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\t.--ai-answer-error-container {\n\t\tposition: absolute;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, -50%);\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\tgap: 10px;\n\t\t}\n\t}\n"])), function (_ref) {
854
+ var themePreset = _ref.themePreset,
855
+ theme = _ref.theme;
856
+ return themePreset === 'dark' ? '#424242' : theme.colors.backgroundColor;
857
+ }, function (_ref2) {
858
+ var theme = _ref2.theme;
859
+ return theme.colors.textColor;
860
+ });
861
+ var Question = styled('div')(_templateObject4$1 || (_templateObject4$1 = _taggedTemplateLiteralLoose(["\n\tfont-weight: bold;\n\tmargin-bottom: 5px;\n\tanimation: ", " 0.5s ease-out;\n"])), fadeInFromTop);
862
+ var Answer = styled('div')(_templateObject5$1 || (_templateObject5$1 = _taggedTemplateLiteralLoose(["\n\t", "\n\tposition: relative;\n\tmargin-bottom: 5px;\n\tmin-height: 100px;\n\toverflow: auto;\n\twhite-space: pre-wrap;\n\tpre {\n\t\twhite-space: pre-wrap;\n\t}\n\tcode,\n\tpre {\n\t\tdisplay: revert;\n\t}\n"])), function (props) {
863
+ return resetCSS(props);
864
+ });
865
+ var Footer = styled('div')(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteralLoose(["\n\tcolor: #777;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 1rem;\n\tflex-wrap: wrap;\n\tanimation: ", " 0.5s ease-out;\n\tpadding: 10px 0;\n\tbackground: white;\n\tbackground-color: ", ";\n\tcolor: ", ";\n"])), fadeInFromBottom, function (_ref3) {
866
+ var themePreset = _ref3.themePreset,
867
+ theme = _ref3.theme;
868
+ return themePreset === 'dark' ? '#424242' : theme.colors.backgroundColor;
869
+ }, function (_ref4) {
870
+ var theme = _ref4.theme;
871
+ return theme.colors.textColor;
872
+ });
873
+ var SourceTags = styled('div')(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tgap: 8px;\n\tflex-wrap: wrap;\n\t.--ai-source-tag {\n\t\tdisplay: inline-block;\n\t\tmax-width: 200px;\n\t\twhite-space: nowrap;\n\t\toverflow: hidden;\n\t\ttext-overflow: ellipsis;\n\t}\n"])));
874
+
875
+ var ThumbsUpSvg = {
876
+ name: 'ThumbsUpSvg',
877
+ props: ['clickHandler', 'className'],
878
+ render: function render() {
879
+ return createVNode("svg", {
880
+ "stroke": "currentColor",
881
+ "fill": "none",
882
+ "strokeWidth": "2",
883
+ "viewBox": "0 0 24 24",
884
+ "strokeLinecap": "round",
885
+ "strokeLinejoin": "round",
886
+ "class": this.$props.className,
887
+ "height": "1em",
888
+ "width": "1em",
889
+ "xmlns": "http://www.w3.org/2000/svg",
890
+ "onClick": this.$props.clickHandler
891
+ }, [createVNode("path", {
892
+ "d": "M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"
893
+ }, null)]);
894
+ }
895
+ };
896
+
897
+ var ThumbsDownSvg = {
898
+ name: 'ThumbsDownSvg',
899
+ props: ['clickHandler', 'className'],
900
+ render: function render() {
901
+ return createVNode("svg", {
902
+ "stroke": "currentColor",
903
+ "fill": "none",
904
+ "strokeWidth": "2",
905
+ "viewBox": "0 0 24 24",
906
+ "strokeLinecap": "round",
907
+ "strokeLinejoin": "round",
908
+ "class": this.$props.className,
909
+ "height": "1em",
910
+ "width": "1em",
911
+ "xmlns": "http://www.w3.org/2000/svg",
912
+ "onClick": this.$props.clickHandler
913
+ }, [createVNode("path", {
914
+ "d": "M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"
915
+ }, null), ' ']);
916
+ }
917
+ };
918
+
919
+ var AIFeedback = defineComponent({
920
+ name: 'FeedbackComponent',
921
+ props: {
922
+ onFeedbackSubmit: {
923
+ type: Function,
924
+ "default": function _default() {}
925
+ },
926
+ hideUI: {
927
+ type: Boolean,
928
+ "default": false
929
+ },
930
+ overrideState: {
931
+ type: Object,
932
+ "default": function _default() {
933
+ return {};
934
+ }
935
+ }
936
+ },
937
+ setup: function setup(props, _ref) {
938
+ var emit = _ref.emit;
939
+ var showInput = ref(false);
940
+ var feedbackType = ref(null);
941
+ var feedbackText = ref('');
942
+ var feedbackRecorded = ref(false);
943
+ var handleButtonClick = function handleButtonClick(type) {
944
+ if (feedbackType.value === type) {
945
+ feedbackType.value = null;
946
+ showInput.value = false;
947
+ } else {
948
+ feedbackType.value = type;
949
+ showInput.value = true;
950
+ }
951
+ };
952
+ var handleInputChange = function handleInputChange(e) {
953
+ feedbackText.value = e.target.value;
954
+ };
955
+ var handleSubmit = function handleSubmit() {
956
+ emit('feedback-submit', feedbackType.value === 'positive', feedbackText.value);
957
+ feedbackText.value = '';
958
+ showInput.value = false;
959
+ feedbackRecorded.value = true;
960
+ };
961
+ var handleCancel = function handleCancel() {
962
+ feedbackType.value = null;
963
+ feedbackText.value = '';
964
+ showInput.value = false;
965
+ };
966
+ watch(function () {
967
+ return props.overrideState;
968
+ }, function (newValue) {
969
+ if (newValue && newValue.isRecorded) {
970
+ feedbackRecorded.value = true;
971
+ feedbackType.value = newValue.feedbackType || 'positive';
972
+ }
973
+ });
974
+ if (props.overrideState && props.overrideState.isRecorded) {
975
+ feedbackRecorded.value = true;
976
+ feedbackType.value = props.overrideState.feedbackType || 'positive';
977
+ }
978
+ return {
979
+ showInput: showInput,
980
+ feedbackType: feedbackType,
981
+ feedbackText: feedbackText,
982
+ feedbackRecorded: feedbackRecorded,
983
+ handleButtonClick: handleButtonClick,
984
+ handleInputChange: handleInputChange,
985
+ handleSubmit: handleSubmit,
986
+ handleCancel: handleCancel
987
+ };
988
+ },
989
+ render: function render() {
990
+ var _this = this;
991
+ if (this.$props.hideUI) {
992
+ return null;
993
+ }
994
+ if (this.feedbackRecorded) {
995
+ return createVNode(AIFeedbackContainer, null, {
996
+ "default": function _default() {
997
+ return [createVNode("div", {
998
+ "class": "--feedback-svgs-wrapper"
999
+ }, [_this.feedbackType === 'positive' ? createVNode(ThumbsUpSvg, {
1000
+ "class": "selected"
1001
+ }, null) : createVNode(ThumbsDownSvg, {
1002
+ "class": "selected"
1003
+ }, null)])];
1004
+ }
1005
+ });
1006
+ }
1007
+ return createVNode(AIFeedbackContainer, null, {
1008
+ "default": function _default() {
1009
+ return [!_this.showInput && createVNode("div", {
1010
+ "class": "--feedback-svgs-wrapper"
1011
+ }, [createVNode(ThumbsUpSvg, {
1012
+ "class": _this.feedbackType === 'positive' ? 'selected' : '',
1013
+ "onClick": function onClick() {
1014
+ return _this.handleButtonClick('positive');
1015
+ }
1016
+ }, null), createVNode(ThumbsDownSvg, {
1017
+ "class": _this.feedbackType === 'negative' ? 'selected' : '',
1018
+ "onClick": function onClick() {
1019
+ return _this.handleButtonClick('negative');
1020
+ }
1021
+ }, null)]), _this.showInput && createVNode("div", {
1022
+ "class": "--feedback-input-wrapper"
1023
+ }, [createVNode(Input, {
1024
+ "show": _this.showInput,
1025
+ "placeholder": _this.feedbackType === 'positive' ? 'What do you like about the response?' : 'What was the issue with the response? How can it be improved?',
1026
+ "value": _this.feedbackText,
1027
+ "onInput": _this.handleInputChange
1028
+ }, null), createVNode(Button, {
1029
+ "primary": true,
1030
+ "onClick": _this.handleSubmit
1031
+ }, {
1032
+ "default": function _default() {
1033
+ return [createTextVNode("Submit")];
1034
+ }
1035
+ }), createVNode(Button, {
1036
+ "onClick": _this.handleCancel
1037
+ }, {
1038
+ "default": function _default() {
1039
+ return [createTextVNode("Cancel")];
1040
+ }
1041
+ })])];
1042
+ }
1043
+ });
1044
+ }
1045
+ });
1046
+
1047
+ var _excluded = ["_source"];
758
1048
  function _isSlot(s) {
759
1049
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
760
1050
  }
1051
+ var md = new Remarkable();
1052
+ md.set({
1053
+ html: true,
1054
+ breaks: true,
1055
+ xhtmlOut: true
1056
+ });
1057
+ var _dropdownULRef = 'dropdownULRef';
761
1058
  var updateQuery = Actions.updateQuery,
762
1059
  setCustomQuery = Actions.setCustomQuery,
763
1060
  setDefaultQuery = Actions.setDefaultQuery,
@@ -778,7 +1075,11 @@ var SearchBox = defineComponent({
778
1075
  currentValue: '',
779
1076
  selectedTags: [],
780
1077
  isOpen: false,
781
- normalizedSuggestions: []
1078
+ normalizedSuggestions: [],
1079
+ showAIScreen: false,
1080
+ showAIScreenFooter: false,
1081
+ showFeedbackComponent: false,
1082
+ feedbackState: null
782
1083
  };
783
1084
  this.internalComponent = props.componentId + "__internal";
784
1085
  return this.__state;
@@ -900,7 +1201,10 @@ var SearchBox = defineComponent({
900
1201
  mode: VueTypes.oneOf(['select', 'tag']).def('select'),
901
1202
  renderSelectedTags: VueTypes.any,
902
1203
  searchboxId: VueTypes.string,
903
- endpoint: types.endpointConfig
1204
+ endpoint: types.endpointConfig,
1205
+ enableAI: types.bool,
1206
+ AIConfig: types.AIConfig,
1207
+ AIUIConfig: types.AIUIConfig
904
1208
  },
905
1209
  mounted: function mounted() {
906
1210
  this.listenForFocusShortcuts();
@@ -1007,6 +1311,47 @@ var SearchBox = defineComponent({
1007
1311
  if (!isEqual(newVal, oldVal)) {
1008
1312
  this.handleTextChange = _debounce(this.handleText, newVal);
1009
1313
  }
1314
+ },
1315
+ isAITyping: function isAITyping(newVal, oldVal) {
1316
+ var _this = this;
1317
+ var scrollAIContainer = function scrollAIContainer() {
1318
+ var dropdownEle = _this.$refs[_dropdownULRef];
1319
+ if (dropdownEle) {
1320
+ dropdownEle.scrollTo({
1321
+ top: dropdownEle.scrollHeight,
1322
+ behavior: 'smooth'
1323
+ });
1324
+ }
1325
+ };
1326
+ if (!newVal && oldVal) {
1327
+ this.showAIScreenFooter = true;
1328
+ if (this.$props.AIUIConfig && typeof this.$props.AIUIConfig.showFeedback === 'boolean' ? this.$props.AIUIConfig.showFeedback : true) {
1329
+ this.showFeedbackComponent = true;
1330
+ }
1331
+ setTimeout(function () {
1332
+ scrollAIContainer();
1333
+ }, 500);
1334
+ } else if (newVal) {
1335
+ this.scrollTimerRef = setTimeout(function () {
1336
+ scrollAIContainer();
1337
+ }, 2000);
1338
+ }
1339
+ },
1340
+ showAIScreen: function showAIScreen(newVal) {
1341
+ if (newVal) {
1342
+ var _this$$refs;
1343
+ if ((_this$$refs = this.$refs) != null && _this$$refs[this.$props.innerRef] && this.$refs[this.$props.innerRef].$el) {
1344
+ this.$refs[this.$props.innerRef].$el.blur();
1345
+ }
1346
+ } else {
1347
+ this.feedbackState = null;
1348
+ this.showFeedbackComponent = false;
1349
+ }
1350
+ },
1351
+ currentValue: function currentValue() {
1352
+ if (this.$props.autosuggest && this.$props.enableAI) {
1353
+ this.handleTextAreaHeightChange();
1354
+ }
1010
1355
  }
1011
1356
  },
1012
1357
  methods: {
@@ -1032,7 +1377,14 @@ var SearchBox = defineComponent({
1032
1377
  data: this.normalizedSuggestions,
1033
1378
  rawData: this.rawData,
1034
1379
  value: currentValue,
1035
- resultStats: this.stats
1380
+ resultStats: this.stats,
1381
+ AIData: {
1382
+ question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
1383
+ answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
1384
+ documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
1385
+ showAIScreen: this.showAIScreen,
1386
+ sources: this.getAISourceObjects()
1387
+ }
1036
1388
  };
1037
1389
  return getComponent(data, this);
1038
1390
  },
@@ -1056,7 +1408,7 @@ var SearchBox = defineComponent({
1056
1408
  }
1057
1409
  },
1058
1410
  setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
1059
- var _this = this;
1411
+ var _this2 = this;
1060
1412
  if (isDefaultValue === void 0) {
1061
1413
  isDefaultValue = false;
1062
1414
  }
@@ -1070,60 +1422,65 @@ var SearchBox = defineComponent({
1070
1422
  categoryValue = undefined;
1071
1423
  }
1072
1424
  var performUpdate = function performUpdate() {
1073
- if (_this.$options.isTagsMode && isEqual(value, _this.selectedTags)) {
1425
+ if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
1074
1426
  return;
1075
1427
  }
1076
- if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1077
- if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
1428
+ if (_this2.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1429
+ if (Array.isArray(_this2.selectedTags) && _this2.selectedTags.length) {
1078
1430
  // check if value already present in selectedTags
1079
- if (typeof value === 'string' && _this.selectedTags.includes(value)) {
1080
- _this.isOpen = false;
1431
+ if (typeof value === 'string' && _this2.selectedTags.includes(value)) {
1432
+ _this2.isOpen = false;
1081
1433
  return;
1082
1434
  }
1083
- _this.selectedTags = [].concat(_this.selectedTags);
1435
+ _this2.selectedTags = [].concat(_this2.selectedTags);
1084
1436
  if (typeof value === 'string' && !!value) {
1085
- _this.selectedTags.push(value);
1086
- } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
1087
- _this.selectedTags = value;
1437
+ _this2.selectedTags.push(value);
1438
+ } else if (Array.isArray(value) && !isEqual(_this2.selectedTags, value)) {
1439
+ _this2.selectedTags = value;
1088
1440
  }
1089
1441
  } else if (value) {
1090
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
1442
+ _this2.selectedTags = typeof value !== 'string' ? value : [].concat(value);
1091
1443
  }
1092
- _this.currentValue = '';
1444
+ _this2.currentValue = '';
1093
1445
  } else {
1094
- _this.currentValue = decodeHtml(value);
1446
+ _this2.currentValue = decodeHtml(value);
1095
1447
  }
1096
1448
  var queryHandlerValue = value;
1097
- if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1098
- queryHandlerValue = Array.isArray(_this.selectedTags) && _this.selectedTags.length ? _this.selectedTags : undefined;
1449
+ if (_this2.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1450
+ queryHandlerValue = Array.isArray(_this2.selectedTags) && _this2.selectedTags.length ? _this2.selectedTags : undefined;
1099
1451
  }
1100
1452
  if (isDefaultValue) {
1101
- if (_this.$props.autosuggest) {
1453
+ if (_this2.$props.autosuggest) {
1102
1454
  if (toggleIsOpen) {
1103
- _this.isOpen = false;
1455
+ _this2.isOpen = false;
1104
1456
  }
1105
- if (typeof _this.currentValue === 'string') _this.triggerDefaultQuery(_this.currentValue);
1457
+ if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1458
+ enableAI: true
1459
+ } : {});
1106
1460
  } // in case of strict selection only SUGGESTION_SELECT should be able
1107
1461
  // to set the query otherwise the value should reset
1108
1462
  if (props.strictSelection) {
1109
- if (cause === causes.SUGGESTION_SELECT || (_this.$options.isTagsMode ? _this.selectedTags.length === 0 : value === '')) {
1110
- _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
1463
+ if (cause === causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
1464
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1111
1465
  } else {
1112
- _this.setValue('', true);
1466
+ _this2.setValue('', true);
1113
1467
  }
1114
1468
  } else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
1115
- _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
1469
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1116
1470
  }
1117
1471
  } else {
1118
1472
  // debounce for handling text while typing
1119
- _this.handleTextChange(value, cause);
1473
+ _this2.handleTextChange(value, cause);
1120
1474
  }
1121
- _this.$emit('valueChange', value);
1122
- _this.$emit('value-change', value);
1475
+ _this2.$emit('valueChange', value);
1476
+ _this2.$emit('value-change', value);
1123
1477
  };
1124
1478
  checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1125
1479
  },
1126
- triggerDefaultQuery: function triggerDefaultQuery(paramValue) {
1480
+ triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
1481
+ if (meta === void 0) {
1482
+ meta = {};
1483
+ }
1127
1484
  if (!this.$props.autosuggest) {
1128
1485
  return;
1129
1486
  }
@@ -1142,7 +1499,8 @@ var SearchBox = defineComponent({
1142
1499
  componentId: this.internalComponent,
1143
1500
  query: query,
1144
1501
  value: value,
1145
- componentType: componentTypes.searchBox
1502
+ componentType: componentTypes.searchBox,
1503
+ meta: meta
1146
1504
  });
1147
1505
  },
1148
1506
  triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
@@ -1238,9 +1596,12 @@ var SearchBox = defineComponent({
1238
1596
  if (this.$props.autosuggest === false) {
1239
1597
  this.enterButtonOnClick();
1240
1598
  } else if (highlightedIndex === null) {
1241
- this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined // to handle tags
1242
- );
1243
-
1599
+ this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined,
1600
+ // to handle tags
1601
+ !this.$props.enableAI);
1602
+ if (this.$props.enableAI && !this.showAIScreen) {
1603
+ this.showAIScreen = true;
1604
+ }
1244
1605
  this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1245
1606
  }
1246
1607
  }
@@ -1250,18 +1611,21 @@ var SearchBox = defineComponent({
1250
1611
  this.$emit('key-down', event, this.triggerQuery);
1251
1612
  },
1252
1613
  onInputChange: function onInputChange(e) {
1253
- var _this2 = this;
1614
+ var _this3 = this;
1254
1615
  var inputValue = e.target.value;
1255
1616
  if (!this.$data.isOpen && this.$props.autosuggest) {
1256
1617
  this.isOpen = true;
1257
1618
  }
1619
+ if (this.showAIScreen) {
1620
+ this.showAIScreen = false;
1621
+ }
1258
1622
  var value = this.$props.value;
1259
1623
  if (value === undefined) {
1260
1624
  this.setValue(inputValue, false, this.$props, undefined);
1261
1625
  } else {
1262
1626
  this.$emit('change', inputValue, function (_ref3) {
1263
1627
  var isOpen = _ref3.isOpen;
1264
- return _this2.triggerQuery({
1628
+ return _this3.triggerQuery({
1265
1629
  defaultQuery: true,
1266
1630
  customQuery: true,
1267
1631
  value: inputValue,
@@ -1271,8 +1635,10 @@ var SearchBox = defineComponent({
1271
1635
  }
1272
1636
  },
1273
1637
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
1274
- var _this3 = this;
1275
- this.isOpen = false;
1638
+ var _this4 = this;
1639
+ if (!this.$props.enableAI) this.isOpen = false;else {
1640
+ this.showAIScreen = true;
1641
+ }
1276
1642
  var value = this.$props.value;
1277
1643
  // Record analytics for selected suggestions
1278
1644
  this.triggerClickAnalytics(suggestion._click_id);
@@ -1292,10 +1658,10 @@ var SearchBox = defineComponent({
1292
1658
  this.setValue(emitValue, true, this.$props, causes.SUGGESTION_SELECT, false, suggestion._category);
1293
1659
  this.$emit('change', emitValue, function (_ref4) {
1294
1660
  var isOpen = _ref4.isOpen;
1295
- return _this3.triggerQuery(_extends({
1661
+ return _this4.triggerQuery(_extends({
1296
1662
  isOpen: isOpen,
1297
1663
  value: emitValue
1298
- }, !_this3.$options.isTagsMode && {
1664
+ }, !_this4.$options.isTagsMode && {
1299
1665
  categoryValue: suggestion._category
1300
1666
  }));
1301
1667
  });
@@ -1329,9 +1695,26 @@ var SearchBox = defineComponent({
1329
1695
  }
1330
1696
  return null;
1331
1697
  },
1332
- renderErrorComponent: function renderErrorComponent() {
1333
- var _this4 = this;
1698
+ renderErrorComponent: function renderErrorComponent(isAIError) {
1699
+ var _this5 = this;
1700
+ if (isAIError === void 0) {
1701
+ isAIError = false;
1702
+ }
1334
1703
  var renderError = this.$slots.renderError || this.$props.renderError;
1704
+ if (isAIError) {
1705
+ if (this.showAIScreen && this.AIResponseError && !this.isAIResponseLoading) {
1706
+ if (renderError) {
1707
+ return createVNode("div", {
1708
+ "class": "--ai-answer-error-container " + (getClassName$1(this.$props.innerClass, 'ai-error') || '')
1709
+ }, [renderError(this.AIResponseError)]);
1710
+ }
1711
+ return createVNode("div", {
1712
+ "class": "--ai-answer-error-container " + (getClassName$1(this.$props.innerClass, 'ai-error') || '')
1713
+ }, [createVNode("div", {
1714
+ "class": "--default-error-element"
1715
+ }, [createVNode("span", null, [typeof this.AIResponseError === 'string' ? this.AIResponseError : this.AIResponseError.message ? this.AIResponseError.message : 'There was an error in generating the response.', this.AIResponseError.code ? "Code:\n\t\t\t\t\t\t\t" + this.AIResponseError.code : ''])])]);
1716
+ }
1717
+ }
1335
1718
  if (this.error && renderError && this.$data.currentValue && !this.isLoading) {
1336
1719
  return createVNode(SuggestionWrapper, {
1337
1720
  "innerClass": this.$props.innerClass,
@@ -1340,7 +1723,7 @@ var SearchBox = defineComponent({
1340
1723
  "themePreset": this.themePreset
1341
1724
  }, {
1342
1725
  "default": function _default() {
1343
- return [isFunction(renderError) ? renderError(_this4.error) : renderError];
1726
+ return [isFunction(renderError) ? renderError(_this5.error) : renderError];
1344
1727
  }
1345
1728
  });
1346
1729
  }
@@ -1405,6 +1788,7 @@ var SearchBox = defineComponent({
1405
1788
  return null;
1406
1789
  },
1407
1790
  enterButtonOnClick: function enterButtonOnClick() {
1791
+ this.showAIScreen = false;
1408
1792
  this.triggerQuery({
1409
1793
  isOpen: false,
1410
1794
  value: this.currentValue,
@@ -1412,7 +1796,7 @@ var SearchBox = defineComponent({
1412
1796
  });
1413
1797
  },
1414
1798
  renderEnterButtonElement: function renderEnterButtonElement() {
1415
- var _this5 = this;
1799
+ var _this6 = this;
1416
1800
  var _this$$props2 = this.$props,
1417
1801
  enterButton = _this$$props2.enterButton,
1418
1802
  innerClass = _this$$props2.innerClass;
@@ -1420,12 +1804,12 @@ var SearchBox = defineComponent({
1420
1804
  if (enterButton) {
1421
1805
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
1422
1806
  if (renderEnterButton) {
1423
- return renderEnterButton(_this5.enterButtonOnClick);
1807
+ return renderEnterButton(_this6.enterButtonOnClick);
1424
1808
  }
1425
1809
  return createVNode(Button, {
1426
1810
  "class": "enter-btn " + getClassName$1(innerClass, 'enter-button'),
1427
1811
  "primary": true,
1428
- "onClick": _this5.enterButtonOnClick
1812
+ "onClick": _this6.enterButtonOnClick
1429
1813
  }, {
1430
1814
  "default": function _default() {
1431
1815
  return [createTextVNode("Search")];
@@ -1439,7 +1823,7 @@ var SearchBox = defineComponent({
1439
1823
  return null;
1440
1824
  },
1441
1825
  renderIcons: function renderIcons() {
1442
- var _this6 = this;
1826
+ var _this7 = this;
1443
1827
  var _slot3, _slot4, _slot5;
1444
1828
  var _this$$props3 = this.$props,
1445
1829
  iconPosition = _this$$props3.iconPosition,
@@ -1456,21 +1840,21 @@ var SearchBox = defineComponent({
1456
1840
  }, {
1457
1841
  "default": function _default() {
1458
1842
  return [currentValue && showClear && createVNode(IconWrapper, {
1459
- "onClick": _this6.clearValue,
1843
+ "onClick": _this7.clearValue,
1460
1844
  "showIcon": showIcon,
1461
1845
  "isClearIcon": true
1462
- }, _isSlot(_slot3 = _this6.renderCancelIcon()) ? _slot3 : {
1846
+ }, _isSlot(_slot3 = _this7.renderCancelIcon()) ? _slot3 : {
1463
1847
  "default": function _default() {
1464
1848
  return [_slot3];
1465
1849
  }
1466
1850
  }), showVoiceSearch && createVNode(Mic, {
1467
1851
  "getInstance": getMicInstance,
1468
1852
  "render": renderMic,
1469
- "handleResult": _this6.handleVoiceResults,
1853
+ "handleResult": _this7.handleVoiceResults,
1470
1854
  "className": getClassName$1(innerClass, 'mic') || null
1471
1855
  }, null), iconPosition === 'right' && showIcon && createVNode(IconWrapper, {
1472
- "onClick": _this6.handleSearchIconClick
1473
- }, _isSlot(_slot4 = _this6.renderIcon()) ? _slot4 : {
1856
+ "onClick": _this7.handleSearchIconClick
1857
+ }, _isSlot(_slot4 = _this7.renderIcon()) ? _slot4 : {
1474
1858
  "default": function _default() {
1475
1859
  return [_slot4];
1476
1860
  }
@@ -1482,8 +1866,8 @@ var SearchBox = defineComponent({
1482
1866
  }, {
1483
1867
  "default": function _default() {
1484
1868
  return [iconPosition === 'left' && showIcon && createVNode(IconWrapper, {
1485
- "onClick": _this6.handleSearchIconClick
1486
- }, _isSlot(_slot5 = _this6.renderIcon()) ? _slot5 : {
1869
+ "onClick": _this7.handleSearchIconClick
1870
+ }, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
1487
1871
  "default": function _default() {
1488
1872
  return [_slot5];
1489
1873
  }
@@ -1492,17 +1876,17 @@ var SearchBox = defineComponent({
1492
1876
  })]);
1493
1877
  },
1494
1878
  focusSearchBox: function focusSearchBox(event) {
1495
- var _this$$refs, _this$$refs$this$$pro;
1879
+ var _this$$refs2, _this$$refs2$this$$pr;
1496
1880
  var elt = event.target || event.srcElement;
1497
1881
  var tagName = elt.tagName;
1498
1882
  if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
1499
1883
  // already in an input
1500
1884
  return;
1501
1885
  }
1502
- (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$this$$pro = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs$this$$pro.focus(); // eslint-disable-line
1886
+ (_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
1503
1887
  },
1504
1888
  listenForFocusShortcuts: function listenForFocusShortcuts() {
1505
- var _this7 = this;
1889
+ var _this8 = this;
1506
1890
  var _this$$props$focusSho = this.$props.focusShortcuts,
1507
1891
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
1508
1892
  if (isEmpty(focusShortcuts)) {
@@ -1517,7 +1901,7 @@ var SearchBox = defineComponent({
1517
1901
  function (event, handler) {
1518
1902
  // Prevent the default refresh event under WINDOWS system
1519
1903
  event.preventDefault();
1520
- _this7.focusSearchBox(event);
1904
+ _this8.focusSearchBox(event);
1521
1905
  });
1522
1906
 
1523
1907
  // if one of modifier keys are used, they are handled below
@@ -1527,7 +1911,7 @@ var SearchBox = defineComponent({
1527
1911
  for (var index = 0; index < modifierKeys.length; index += 1) {
1528
1912
  var element = modifierKeys[index];
1529
1913
  if (hotkeys[element]) {
1530
- _this7.focusSearchBox(event);
1914
+ _this8.focusSearchBox(event);
1531
1915
  break;
1532
1916
  }
1533
1917
  }
@@ -1540,10 +1924,10 @@ var SearchBox = defineComponent({
1540
1924
  this.triggerDefaultQuery(value);
1541
1925
  },
1542
1926
  renderAutoFill: function renderAutoFill(suggestion) {
1543
- var _this8 = this;
1927
+ var _this9 = this;
1544
1928
  var handleAutoFillClick = function handleAutoFillClick(e) {
1545
1929
  e.stopPropagation();
1546
- _this8.onAutofillClick(suggestion);
1930
+ _this9.onAutofillClick(suggestion);
1547
1931
  };
1548
1932
  /* 👇 avoid showing autofill for category suggestions👇 */
1549
1933
  return suggestion._category ? null : createVNode(AutoFillSvg, {
@@ -1551,7 +1935,7 @@ var SearchBox = defineComponent({
1551
1935
  }, null);
1552
1936
  },
1553
1937
  renderTag: function renderTag(item) {
1554
- var _this9 = this;
1938
+ var _this10 = this;
1555
1939
  var innerClass = this.$props.innerClass;
1556
1940
  return createVNode(TagItem, {
1557
1941
  "class": getClassName$1(innerClass, 'selected-tag') || ''
@@ -1562,7 +1946,7 @@ var SearchBox = defineComponent({
1562
1946
  "aria-label": "delete-tag",
1563
1947
  "class": "close-icon",
1564
1948
  "onClick": function onClick() {
1565
- return _this9.clearTag(item);
1949
+ return _this10.clearTag(item);
1566
1950
  }
1567
1951
  }, [createVNode(CancelSvg, null, null)])];
1568
1952
  }
@@ -1585,7 +1969,7 @@ var SearchBox = defineComponent({
1585
1969
  }
1586
1970
  },
1587
1971
  renderTags: function renderTags() {
1588
- var _this10 = this;
1972
+ var _this11 = this;
1589
1973
  if (!Array.isArray(this.selectedTags)) {
1590
1974
  return null;
1591
1975
  }
@@ -1599,25 +1983,189 @@ var SearchBox = defineComponent({
1599
1983
  }) : createVNode(TagsContainer, null, {
1600
1984
  "default": function _default() {
1601
1985
  return [tagsList.map(function (item) {
1602
- return _this10.renderTag(item);
1986
+ return _this11.renderTag(item);
1603
1987
  }), shouldRenderClearAllTag && createVNode(TagItem, {
1604
- "class": getClassName$1(_this10.$props.innerClass, 'selected-tag') || ''
1988
+ "class": getClassName$1(_this11.$props.innerClass, 'selected-tag') || ''
1605
1989
  }, {
1606
1990
  "default": function _default() {
1607
1991
  return [createVNode("span", null, [createTextVNode("Clear All")]), createVNode("span", {
1608
1992
  "role": "img",
1609
1993
  "aria-label": "delete-tag",
1610
1994
  "class": "close-icon",
1611
- "onClick": _this10.clearAllTags
1995
+ "onClick": _this11.clearAllTags
1612
1996
  }, [createVNode(CancelSvg, null, null)])];
1613
1997
  }
1614
1998
  })];
1615
1999
  }
1616
2000
  });
2001
+ },
2002
+ getAISourceObjects: function getAISourceObjects() {
2003
+ var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.componentId];
2004
+ var sourceObjects = [];
2005
+ if (!this.AIResponse) return sourceObjects;
2006
+ var docIds = this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [];
2007
+ if (localCache && localCache.meta && localCache.meta.hits && localCache.meta.hits.hits) {
2008
+ docIds.forEach(function (id) {
2009
+ var foundSourceObj = localCache.meta.hits.hits.find(function (hit) {
2010
+ return hit._id === id;
2011
+ }) || {};
2012
+ if (foundSourceObj) {
2013
+ var _foundSourceObj$_sour = foundSourceObj._source,
2014
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
2015
+ rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded);
2016
+ sourceObjects.push(_extends({}, rest, _source));
2017
+ }
2018
+ });
2019
+ } else {
2020
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
2021
+ return {
2022
+ _id: id
2023
+ };
2024
+ }));
2025
+ }
2026
+ return sourceObjects;
2027
+ },
2028
+ renderAIScreenLoader: function renderAIScreenLoader() {
2029
+ var _this$$props$AIUIConf = this.$props.AIUIConfig,
2030
+ AIUIConfig = _this$$props$AIUIConf === void 0 ? {} : _this$$props$AIUIConf;
2031
+ var _ref5 = AIUIConfig || {},
2032
+ loaderMessage = _ref5.loaderMessage;
2033
+ if (loaderMessage) {
2034
+ return loaderMessage;
2035
+ }
2036
+ if (this.$slots.AILoaderMessage) {
2037
+ return this.$slots.AILoaderMessage();
2038
+ }
2039
+ return createVNode(HorizontalSkeletonLoader, null, null);
2040
+ },
2041
+ renderAIScreenFooter: function renderAIScreenFooter() {
2042
+ var _slot6;
2043
+ var _this12 = this;
2044
+ var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
2045
+ AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
2046
+ var _ref6 = AIUIConfig || {},
2047
+ _ref6$showSourceDocum = _ref6.showSourceDocuments,
2048
+ showSourceDocuments = _ref6$showSourceDocum === void 0 ? true : _ref6$showSourceDocum,
2049
+ _ref6$sourceDocumentL = _ref6.sourceDocumentLabel,
2050
+ sourceDocumentLabel = _ref6$sourceDocumentL === void 0 ? '_id' : _ref6$sourceDocumentL,
2051
+ _ref6$onSourceClick = _ref6.onSourceClick,
2052
+ onSourceClick = _ref6$onSourceClick === void 0 ? function () {} : _ref6$onSourceClick;
2053
+ return showSourceDocuments && this.showAIScreenFooter && this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds ? createVNode(Footer, {
2054
+ "themePreset": this.$props.themePreset
2055
+ }, {
2056
+ "default": function _default() {
2057
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot6 = _this12.getAISourceObjects().map(function (el) {
2058
+ return createVNode(Button, {
2059
+ "class": "--ai-source-tag " + (getClassName$1(_this12.$props.innerClass, 'ai-source-tag') || ''),
2060
+ "title": el[sourceDocumentLabel],
2061
+ "info": true,
2062
+ "onClick": function onClick() {
2063
+ return onSourceClick && onSourceClick(el);
2064
+ }
2065
+ }, {
2066
+ "default": function _default() {
2067
+ return [el[sourceDocumentLabel]];
2068
+ }
2069
+ });
2070
+ })) ? _slot6 : {
2071
+ "default": function _default() {
2072
+ return [_slot6];
2073
+ }
2074
+ })];
2075
+ }
2076
+ }) : null;
2077
+ },
2078
+ renderAIScreen: function renderAIScreen() {
2079
+ var _this13 = this;
2080
+ var customAIRenderer = this.$props.renderAIAnswer || this.$slots.renderAIAnswer;
2081
+ if (customAIRenderer) {
2082
+ return customAIRenderer({
2083
+ question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
2084
+ answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
2085
+ documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
2086
+ loading: this.isAIResponseLoading || this.isLoading,
2087
+ sources: this.getAISourceObjects(),
2088
+ error: this.AIResponseError
2089
+ });
2090
+ }
2091
+ if (this.isAIResponseLoading || this.isLoading) {
2092
+ return this.renderAIScreenLoader();
2093
+ }
2094
+ return createVNode("div", null, [createVNode(Answer, {
2095
+ "innerHTML": md.render(this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text)
2096
+ }, null), this.renderAIScreenFooter(), this.showFeedbackComponent && createVNode("div", {
2097
+ "class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
2098
+ }, [createVNode(AIFeedback, {
2099
+ "overrideState": this.feedbackState,
2100
+ "hideUI": this.isAIResponseLoading || this.isLoading || !this.sessionIdFromStore,
2101
+ "key": this.sessionIdFromStore,
2102
+ "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
2103
+ _this13.feedbackState = {
2104
+ isRecorded: true,
2105
+ feedbackType: useful ? 'positive' : 'negative'
2106
+ };
2107
+ _this13.recordAISessionUsefulness(_this13.sessionIdFromStore, {
2108
+ useful: useful,
2109
+ reason: reason
2110
+ });
2111
+ }
2112
+ }, null)])]);
2113
+ },
2114
+ handleTextAreaHeightChange: function handleTextAreaHeightChange() {
2115
+ var _this$$refs$this$$pro;
2116
+ var textArea = (_this$$refs$this$$pro = this.$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs$this$$pro.$el;
2117
+ if (textArea) {
2118
+ textArea.style.height = '42px';
2119
+ var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
2120
+ var maxHeight = lineHeight * 4; // max height for 3 lines
2121
+ var height = Math.min(textArea.scrollHeight, maxHeight);
2122
+ textArea.style.height = height + "px";
2123
+ textArea.style.overflowY = height === maxHeight ? 'auto' : 'hidden';
2124
+ var dropdownEle = this.$refs[_dropdownULRef];
2125
+ if (dropdownEle) {
2126
+ dropdownEle.style.top = height + "px";
2127
+ }
2128
+ }
2129
+ },
2130
+ askButtonOnClick: function askButtonOnClick() {
2131
+ this.showAIScreen = true;
2132
+ this.isOpen = true;
2133
+ this.triggerDefaultQuery(this.currentValue, {
2134
+ enableAI: true
2135
+ });
2136
+ },
2137
+ renderAskButtonElement: function renderAskButtonElement() {
2138
+ var _this14 = this;
2139
+ var _this$$props4 = this.$props,
2140
+ AIUIConfig = _this$$props4.AIUIConfig,
2141
+ innerClass = _this$$props4.innerClass;
2142
+ var _ref7 = AIUIConfig || {},
2143
+ askButton = _ref7.askButton;
2144
+ var renderAskButton = this.$slots.renderAskButton;
2145
+ if (askButton) {
2146
+ var getEnterButtonMarkup = function getEnterButtonMarkup() {
2147
+ if (renderAskButton) {
2148
+ return renderAskButton(_this14.askButtonOnClick);
2149
+ }
2150
+ return createVNode(Button, {
2151
+ "class": "enter-btn " + getClassName$1(innerClass, 'ask-button'),
2152
+ "info": true,
2153
+ "onClick": _this14.askButtonOnClick
2154
+ }, {
2155
+ "default": function _default() {
2156
+ return [createTextVNode("Ask")];
2157
+ }
2158
+ });
2159
+ };
2160
+ return createVNode("div", {
2161
+ "class": "enter-button-wrapper"
2162
+ }, [getEnterButtonMarkup()]);
2163
+ }
2164
+ return null;
1617
2165
  }
1618
2166
  },
1619
2167
  render: function render() {
1620
- var _this11 = this;
2168
+ var _this15 = this;
1621
2169
  var expandSuggestionsContainer = this.$props.expandSuggestionsContainer;
1622
2170
  var _this$$slots = this.$slots,
1623
2171
  recentSearchesIcon = _this$$slots.recentSearchesIcon,
@@ -1628,26 +2176,26 @@ var SearchBox = defineComponent({
1628
2176
  "class": this.$props.className
1629
2177
  }, {
1630
2178
  "default": function _default() {
1631
- return [_this11.$props.title && createVNode(Title, {
1632
- "class": getClassName$1(_this11.$props.innerClass, 'title') || ''
2179
+ return [_this15.$props.title && createVNode(Title, {
2180
+ "class": getClassName$1(_this15.$props.innerClass, 'title') || ''
1633
2181
  }, {
1634
2182
  "default": function _default() {
1635
- return [_this11.$props.title];
2183
+ return [_this15.$props.title];
1636
2184
  }
1637
- }), _this11.$props.autosuggest ? createVNode(Downshift, {
1638
- "id": _this11.$props.componentId + "-downshift",
1639
- "handleChange": _this11.onSuggestionSelected,
1640
- "handleMouseup": _this11.handleStateChange,
1641
- "isOpen": _this11.$data.isOpen
2185
+ }), _this15.$props.autosuggest ? createVNode(Downshift, {
2186
+ "id": _this15.$props.componentId + "-downshift",
2187
+ "handleChange": _this15.onSuggestionSelected,
2188
+ "handleMouseup": _this15.handleStateChange,
2189
+ "isOpen": _this15.$data.isOpen
1642
2190
  }, {
1643
- "default": function _default(_ref5) {
1644
- var getInputEvents = _ref5.getInputEvents,
1645
- getInputProps = _ref5.getInputProps,
1646
- getItemProps = _ref5.getItemProps,
1647
- getItemEvents = _ref5.getItemEvents,
1648
- isOpen = _ref5.isOpen,
1649
- highlightedIndex = _ref5.highlightedIndex,
1650
- setHighlightedIndex = _ref5.setHighlightedIndex;
2191
+ "default": function _default(_ref8) {
2192
+ var getInputEvents = _ref8.getInputEvents,
2193
+ getInputProps = _ref8.getInputProps,
2194
+ getItemProps = _ref8.getItemProps,
2195
+ getItemEvents = _ref8.getItemEvents,
2196
+ isOpen = _ref8.isOpen,
2197
+ highlightedIndex = _ref8.highlightedIndex,
2198
+ setHighlightedIndex = _ref8.setHighlightedIndex;
1651
2199
  var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
1652
2200
  var getIcon = function getIcon(iconType) {
1653
2201
  switch (iconType) {
@@ -1659,14 +2207,21 @@ var SearchBox = defineComponent({
1659
2207
  return null;
1660
2208
  }
1661
2209
  };
1662
- return createVNode("div", null, [_this11.hasCustomRenderer && _this11.getComponent({
2210
+ return createVNode("div", null, [_this15.hasCustomRenderer && _this15.getComponent({
1663
2211
  isOpen: isOpen,
1664
2212
  getItemProps: getItemProps,
1665
2213
  getItemEvents: getItemEvents,
1666
2214
  highlightedIndex: highlightedIndex
1667
- }), _this11.renderErrorComponent(), !_this11.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
1668
- "class": suggestions(_this11.themePreset, _this11.theme) + " " + getClassName$1(_this11.$props.innerClass, 'list')
1669
- }, [_this11.normalizedSuggestions.map(function (item, index) {
2215
+ }), _this15.renderErrorComponent(), !_this15.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
2216
+ "class": suggestions(_this15.themePreset, _this15.theme) + " " + getClassName$1(_this15.$props.innerClass, 'list'),
2217
+ "ref": _dropdownULRef
2218
+ }, [_this15.showAIScreen && createVNode(SearchBoxAISection, {
2219
+ "themePreset": _this15.$props.themePreset
2220
+ }, {
2221
+ "default": function _default() {
2222
+ return [_this15.renderAIScreen(), ' ', _this15.renderErrorComponent(true)];
2223
+ }
2224
+ }), !_this15.showAIScreen && _this15.normalizedSuggestions.map(function (item, index) {
1670
2225
  return renderItem ? createVNode("li", mergeProps(getItemProps({
1671
2226
  item: item
1672
2227
  }), getItemEvents({
@@ -1674,7 +2229,7 @@ var SearchBox = defineComponent({
1674
2229
  }), {
1675
2230
  "key": index + 1 + "-" + item.value,
1676
2231
  "style": {
1677
- backgroundColor: _this11.getBackgroundColor(highlightedIndex, index),
2232
+ backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
1678
2233
  justifyContent: 'flex-start',
1679
2234
  alignItems: 'center'
1680
2235
  }
@@ -1685,7 +2240,7 @@ var SearchBox = defineComponent({
1685
2240
  })), {
1686
2241
  "key": index + 1 + "-" + item.value,
1687
2242
  "style": {
1688
- backgroundColor: _this11.getBackgroundColor(highlightedIndex, index),
2243
+ backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
1689
2244
  justifyContent: 'flex-start',
1690
2245
  alignItems: 'center'
1691
2246
  }
@@ -1695,97 +2250,133 @@ var SearchBox = defineComponent({
1695
2250
  display: 'flex'
1696
2251
  }
1697
2252
  }, [createVNode(CustomSvg, {
1698
- "className": getClassName$1(_this11.$props.innerClass, item._suggestion_type + "-search-icon") || null,
2253
+ "className": getClassName$1(_this15.$props.innerClass, item._suggestion_type + "-search-icon") || null,
1699
2254
  "icon": getIcon(item._suggestion_type),
1700
2255
  "type": item._suggestion_type + "-search-icon"
1701
2256
  }, null)]), createVNode(SuggestionItem, {
1702
- "currentValue": _this11.currentValue,
2257
+ "currentValue": _this15.currentValue,
1703
2258
  "suggestion": item
1704
- }, null), _this11.renderAutoFill(item)]);
1705
- })]) : _this11.renderNoSuggestions(_this11.normalizedSuggestions)]);
2259
+ }, null), _this15.renderAutoFill(item)]);
2260
+ })]) : _this15.renderNoSuggestions(_this15.normalizedSuggestions)]);
1706
2261
  };
1707
2262
  return createVNode("div", {
1708
2263
  "class": suggestionsContainer
1709
2264
  }, [createVNode(InputGroup, null, {
1710
2265
  "default": function _default() {
1711
- return [_this11.renderInputAddonBefore(), createVNode(InputWrapper, null, {
2266
+ return [_this15.renderInputAddonBefore(), createVNode(InputWrapper, null, {
1712
2267
  "default": function _default() {
1713
- return [createVNode(Input, mergeProps(_transformOn(getInputEvents({
1714
- onInput: _this11.onInputChange,
2268
+ return [_this15.$props.enableAI ? createVNode(TextArea, mergeProps(_transformOn(getInputEvents({
2269
+ onInput: _this15.onInputChange,
2270
+ onBlur: function onBlur(e) {
2271
+ _this15.$emit('blur', e, _this15.triggerQuery);
2272
+ },
2273
+ onFocus: _this15.handleFocus,
2274
+ onKeyPress: function onKeyPress(e) {
2275
+ _this15.$emit('keyPress', e, _this15.triggerQuery);
2276
+ _this15.$emit('key-press', e, _this15.triggerQuery);
2277
+ },
2278
+ onKeyDown: function onKeyDown(e) {
2279
+ return _this15.handleKeyDown(e, highlightedIndex);
2280
+ },
2281
+ onKeyUp: function onKeyUp(e) {
2282
+ _this15.$emit('keyUp', e, _this15.triggerQuery);
2283
+ _this15.$emit('key-up', e, _this15.triggerQuery);
2284
+ },
2285
+ onClick: function onClick() {
2286
+ setHighlightedIndex(null);
2287
+ }
2288
+ })), {
2289
+ "id": _this15.$props.componentId + "-input",
2290
+ "showIcon": _this15.$props.showIcon,
2291
+ "showClear": _this15.$props.showClear,
2292
+ "iconPosition": _this15.$props.iconPosition,
2293
+ "ref": _this15.$props.innerRef,
2294
+ "class": getClassName$1(_this15.$props.innerClass, 'input'),
2295
+ "placeholder": _this15.$props.placeholder,
2296
+ "autoFocus": _this15.$props.autoFocus,
2297
+ "showFocusShortcutsIcon": _this15.$props.showFocusShortcutsIcon,
2298
+ "showVoiceSearch": _this15.$props.showVoiceSearch
2299
+ }, getInputProps({
2300
+ value: _this15.$data.currentValue === null ? '' : _this15.$data.currentValue
2301
+ }), {
2302
+ "themePreset": _this15.themePreset,
2303
+ "autocomplete": "off"
2304
+ }), null) : createVNode(Input, mergeProps(_transformOn(getInputEvents({
2305
+ onInput: _this15.onInputChange,
1715
2306
  onBlur: function onBlur(e) {
1716
- _this11.$emit('blur', e, _this11.triggerQuery);
2307
+ _this15.$emit('blur', e, _this15.triggerQuery);
1717
2308
  },
1718
- onFocus: _this11.handleFocus,
2309
+ onFocus: _this15.handleFocus,
1719
2310
  onKeyPress: function onKeyPress(e) {
1720
- _this11.$emit('keyPress', e, _this11.triggerQuery);
1721
- _this11.$emit('key-press', e, _this11.triggerQuery);
2311
+ _this15.$emit('keyPress', e, _this15.triggerQuery);
2312
+ _this15.$emit('key-press', e, _this15.triggerQuery);
1722
2313
  },
1723
2314
  onKeyDown: function onKeyDown(e) {
1724
- return _this11.handleKeyDown(e, highlightedIndex);
2315
+ return _this15.handleKeyDown(e, highlightedIndex);
1725
2316
  },
1726
2317
  onKeyUp: function onKeyUp(e) {
1727
- _this11.$emit('keyUp', e, _this11.triggerQuery);
1728
- _this11.$emit('key-up', e, _this11.triggerQuery);
2318
+ _this15.$emit('keyUp', e, _this15.triggerQuery);
2319
+ _this15.$emit('key-up', e, _this15.triggerQuery);
1729
2320
  },
1730
2321
  onClick: function onClick() {
1731
2322
  setHighlightedIndex(null);
1732
2323
  }
1733
2324
  })), {
1734
- "id": _this11.$props.componentId + "-input",
1735
- "showIcon": _this11.$props.showIcon,
1736
- "showClear": _this11.$props.showClear,
1737
- "iconPosition": _this11.$props.iconPosition,
1738
- "ref": _this11.$props.innerRef,
1739
- "class": getClassName$1(_this11.$props.innerClass, 'input'),
1740
- "placeholder": _this11.$props.placeholder,
1741
- "autoFocus": _this11.$props.autoFocus
2325
+ "id": _this15.$props.componentId + "-input",
2326
+ "showIcon": _this15.$props.showIcon,
2327
+ "showClear": _this15.$props.showClear,
2328
+ "iconPosition": _this15.$props.iconPosition,
2329
+ "ref": _this15.$props.innerRef,
2330
+ "class": getClassName$1(_this15.$props.innerClass, 'input'),
2331
+ "placeholder": _this15.$props.placeholder,
2332
+ "autoFocus": _this15.$props.autoFocus
1742
2333
  }, getInputProps({
1743
- value: _this11.$data.currentValue === null ? '' : _this11.$data.currentValue
2334
+ value: _this15.$data.currentValue === null ? '' : _this15.$data.currentValue
1744
2335
  }), {
1745
- "themePreset": _this11.themePreset,
2336
+ "themePreset": _this15.themePreset,
1746
2337
  "autocomplete": "off"
1747
- }), null), _this11.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()];
2338
+ }), null), _this15.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()];
1748
2339
  }
1749
- }), _this11.renderInputAddonAfter(), _this11.renderEnterButtonElement()];
2340
+ }), _this15.renderInputAddonAfter(), _this15.renderAskButtonElement(), _this15.renderEnterButtonElement()];
1750
2341
  }
1751
- }), expandSuggestionsContainer && renderSuggestionsDropdown(), _this11.renderTags()]);
2342
+ }), expandSuggestionsContainer && renderSuggestionsDropdown(), _this15.renderTags()]);
1752
2343
  }
1753
2344
  }) : createVNode("div", {
1754
2345
  "class": suggestionsContainer
1755
2346
  }, [createVNode(InputGroup, null, {
1756
2347
  "default": function _default() {
1757
- return [_this11.renderInputAddonBefore(), createVNode(InputWrapper, null, {
2348
+ return [_this15.renderInputAddonBefore(), createVNode(InputWrapper, null, {
1758
2349
  "default": function _default() {
1759
2350
  return [createVNode(Input, mergeProps(_transformOn({
1760
2351
  blur: function blur(e) {
1761
- _this11.$emit('blur', e, _this11.triggerQuery);
2352
+ _this15.$emit('blur', e, _this15.triggerQuery);
1762
2353
  },
1763
2354
  keypress: function keypress(e) {
1764
- _this11.$emit('keyPress', e, _this11.triggerQuery);
1765
- _this11.$emit('key-press', e, _this11.triggerQuery);
2355
+ _this15.$emit('keyPress', e, _this15.triggerQuery);
2356
+ _this15.$emit('key-press', e, _this15.triggerQuery);
1766
2357
  },
1767
- input: _this11.onInputChange,
2358
+ input: _this15.onInputChange,
1768
2359
  focus: function focus(e) {
1769
- _this11.$emit('focus', e, _this11.triggerQuery);
2360
+ _this15.$emit('focus', e, _this15.triggerQuery);
1770
2361
  },
1771
- keydown: _this11.handleKeyDown,
2362
+ keydown: _this15.handleKeyDown,
1772
2363
  keyup: function keyup(e) {
1773
- _this11.$emit('keyUp', e, _this11.triggerQuery);
1774
- _this11.$emit('key-up', e, _this11.triggerQuery);
2364
+ _this15.$emit('keyUp', e, _this15.triggerQuery);
2365
+ _this15.$emit('key-up', e, _this15.triggerQuery);
1775
2366
  }
1776
2367
  }), {
1777
- "class": getClassName$1(_this11.$props.innerClass, 'input') || '',
1778
- "placeholder": _this11.$props.placeholder,
1779
- "autofocus": _this11.$props.autoFocus,
1780
- "value": _this11.$data.currentValue ? _this11.$data.currentValue : '',
1781
- "iconPosition": _this11.$props.iconPosition,
1782
- "showIcon": _this11.$props.showIcon,
1783
- "showClear": _this11.$props.showClear,
1784
- "ref": _this11.$props.innerRef,
1785
- "themePreset": _this11.themePreset
1786
- }), null), _this11.renderIcons()];
2368
+ "class": getClassName$1(_this15.$props.innerClass, 'input') || '',
2369
+ "placeholder": _this15.$props.placeholder,
2370
+ "autofocus": _this15.$props.autoFocus,
2371
+ "value": _this15.$data.currentValue ? _this15.$data.currentValue : '',
2372
+ "iconPosition": _this15.$props.iconPosition,
2373
+ "showIcon": _this15.$props.showIcon,
2374
+ "showClear": _this15.$props.showClear,
2375
+ "ref": _this15.$props.innerRef,
2376
+ "themePreset": _this15.themePreset
2377
+ }), null), _this15.renderIcons()];
1787
2378
  }
1788
- }), _this11.renderInputAddonAfter(), _this11.renderEnterButtonElement()];
2379
+ }), _this15.renderInputAddonAfter(), _this15.renderEnterButtonElement()];
1789
2380
  }
1790
2381
  })])];
1791
2382
  }
@@ -1838,18 +2429,24 @@ var mapStateToProps = function mapStateToProps(state, props) {
1838
2429
  rawData: state.rawData[props.componentId],
1839
2430
  aggregationData: state.compositeAggregations[props.componentId] || [],
1840
2431
  themePreset: state.config.themePreset,
1841
- isLoading: !!state.isLoading[props.componentId + "_active"],
2432
+ isLoading: !!state.isLoading["" + props.componentId],
1842
2433
  error: state.error[props.componentId],
1843
2434
  time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
1844
2435
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
1845
- hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden
2436
+ hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
2437
+ AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response || null,
2438
+ isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
2439
+ AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
2440
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
2441
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
1846
2442
  };
1847
2443
  };
1848
2444
  var mapDispatchToProps = {
1849
2445
  updateQuery: updateQuery,
1850
2446
  setCustomQuery: setCustomQuery,
1851
2447
  setDefaultQuery: setDefaultQuery,
1852
- recordSuggestionClick: recordSuggestionClick
2448
+ recordSuggestionClick: recordSuggestionClick,
2449
+ recordAISessionUsefulness: recordAISessionUsefulness
1853
2450
  };
1854
2451
  var SBConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(SearchBox), {
1855
2452
  componentType: componentTypes.searchBox,
@@ -1865,88 +2462,18 @@ SBConnected.install = function (Vue) {
1865
2462
  // Add componentType for SSR
1866
2463
  SBConnected.componentType = componentTypes.searchBox;
1867
2464
 
1868
- var _templateObject$8, _templateObject2$1, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
1869
- var Chatbox = styled('div')(_templateObject$8 || (_templateObject$8 = _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) {
1870
- return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
1871
- });
1872
- var ChatContainer = styled('div')(_templateObject2$1 || (_templateObject2$1 = _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"])), function (props) {
1873
- return props.showInput ? 'bottom: 48px;' : '';
1874
- }, function (props) {
1875
- return props.theme && props.theme.colors && props.theme.colors.backgroundColor ? props.theme.colors.backgroundColor : '#fff';
1876
- }, function (props) {
1877
- return props.theme && props.theme.colors && props.theme.colors.backgroundColor ? props.theme.colors.backgroundColor : '#fff';
1878
- });
1879
- var MessagesContainer = styled('div')(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n\tmax-height: 400px;\n overflow-y: auto;\n\tpadding: 10px;\n\tdisplay: flex;\n\tflex-direction: column;\n\tmin-height: 200px;\n\n}};\n"])));
1880
- var typingDots = keyframes(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n 0% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-70%);\n }\n 100% {\n transform: translateY(0);\n }\n"])));
1881
- var TypingIndicator = styled('div')(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmargin: 5px !important;\n"])));
1882
- var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n\twidth: 6px;\n\theight: 6px;\n\tbackground-color: ", ";\n\tborder-radius: 50%;\n\tmargin: 0 2px !important;\n\tanimation: ", " 1s infinite;\n\t&:nth-child(2) {\n\t\tanimation-delay: 0.2s;\n\t}\n\t&:nth-child(3) {\n\t\tanimation-delay: 0.4s;\n\t}\n"])), function (props) {
1883
- var finalColor;
1884
- if (props.isSender) {
1885
- finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
1886
- } else {
1887
- finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
1888
- }
1889
- return finalColor;
1890
- }, typingDots);
1891
- var resetCSS = function resetCSS(props) {
1892
- 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: " + (
1893
- // eslint-disable-next-line no-nested-ternary
1894
- 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: " + function (colorProps) {
1895
- return (
1896
- // eslint-disable-next-line no-nested-ternary
1897
- colorProps.isSender ? colorProps.themePreset !== 'dark' ? colorProps.theme.colors.primaryTextColor : colorProps.theme.colors.textColor : colorProps.theme.colors.primaryTextColor
1898
- );
1899
- } + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin: 5px 0;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: 100%;\n\t}\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t}\n";
1900
- };
1901
- var messageBGColor = function messageBGColor(props) {
1902
- var finalBGColor;
1903
- if (props.isSender) {
1904
- finalBGColor = props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor;
1905
- } else {
1906
- finalBGColor = props.themePreset !== 'dark' ? lighten(0.25, props.theme.colors.borderColor) : props.theme.colors.backgroundColor;
1907
- }
1908
- return finalBGColor;
1909
- };
1910
- var Message = styled('div')(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n\tbackground-color: ", ";\n\tcolor: ", ";\n\tborder: 1px solid\n\t\t", ";\n\tpadding: 10px;\n\tborder-radius: 7px;\n\tmargin-bottom: 10px;\n\tmax-width: 80%;\n\talign-self: ", ";\n\tdisplay: inline-block;\n\tposition: relative;\n\toverflow-wrap: anywhere;\n\t", "\n"])), function (props) {
1911
- return messageBGColor(props);
1912
- }, function (props) {
1913
- var finalColor;
1914
- if (props.isSender) {
1915
- finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
1916
- } else {
1917
- finalColor = props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor;
1918
- }
1919
- return finalColor;
1920
- }, function (props) {
1921
- return props.themePreset === 'dark' ? 'currentColor' : messageBGColor(props);
1922
- }, function (props) {
1923
- return props.isSender ? 'flex-end' : 'flex-start';
1924
- }, function (props) {
1925
- return resetCSS(props);
1926
- });
1927
- var MessageInputContainer = styled('form')(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tpadding-top: 12px;\n\talign-items: stretch;\n\tmargin-top: 10px;\n"])));
1928
- var MessageInput = styled(Input)(_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"])), function (props) {
1929
- return props.themePreset === 'dark' ? props.theme.colors.borderColor : '#fff';
1930
- }, function (props) {
1931
- return props.themePreset === 'dark' ? props.theme.colors.titleColor : props.theme.colors.textColor;
1932
- }, function (props) {
1933
- return props.theme.colors.textColor;
1934
- }, function (props) {
1935
- return props.theme.colors.textColor;
1936
- }, function (props) {
1937
- return props.theme.colors.textColor;
1938
- });
1939
- var SendButton = styled(Button)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n\tborder: none;\n\tcolor: #ffffff;\n\tcursor: pointer;\n\tfont-size: 16px;\n\tmargin-left: 8px;\n\toutline: none;\n\tpadding: 10px;\n\ttext-align: center;\n"])));
1940
-
1941
2465
  function _isSlot$1(s) {
1942
2466
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
1943
2467
  }
1944
- var md = new Remarkable();
1945
- md.set({
2468
+ var md$1 = new Remarkable();
2469
+ md$1.set({
1946
2470
  html: true,
1947
2471
  breaks: true,
1948
2472
  xhtmlOut: true
1949
2473
  });
2474
+ var _inputWrapperRef = 'inputWrapperRef';
2475
+ var _inputRef = 'inputRef';
2476
+ var _errorContainerRef = 'errorContainerRef';
1950
2477
  var AIAnswer = defineComponent({
1951
2478
  name: 'AIAnswer',
1952
2479
  data: function data() {
@@ -1980,6 +2507,7 @@ var AIAnswer = defineComponent({
1980
2507
  props: {
1981
2508
  componentId: types.string.isRequired,
1982
2509
  showVoiceInput: VueTypes.bool.def(false),
2510
+ showFeedback: VueTypes.bool.def(true),
1983
2511
  showIcon: VueTypes.bool.def(true),
1984
2512
  onData: types.func,
1985
2513
  innerRef: VueTypes.string.def('AISearchInputField'),
@@ -2100,6 +2628,7 @@ var AIAnswer = defineComponent({
2100
2628
  },
2101
2629
  handleMessageInputChange: function handleMessageInputChange(e) {
2102
2630
  this.inputMessage = e.target.value;
2631
+ this.handleTextAreaHeightChange();
2103
2632
  },
2104
2633
  handleSendMessage: function handleSendMessage(e, isRetry, text) {
2105
2634
  if (isRetry === void 0) {
@@ -2143,16 +2672,19 @@ var AIAnswer = defineComponent({
2143
2672
  renderErrorComponent: function renderErrorComponent() {
2144
2673
  var renderError = this.$slots.renderError || this.$props.renderError;
2145
2674
  if (this.error && !this.isLoadingState) {
2675
+ var _this$error, _this$error2;
2146
2676
  if (renderError) {
2147
2677
  return createVNode("div", {
2678
+ "ref": _errorContainerRef,
2148
2679
  "class": "--ai-answer-error-container " + (getClassName$2(this.$props.innerClass, 'ai-error') || '')
2149
2680
  }, [isFunction(renderError) ? renderError(this.error, this.handleRetryRequest) : renderError]);
2150
2681
  }
2151
2682
  return createVNode("div", {
2683
+ "ref": _errorContainerRef,
2152
2684
  "class": "--ai-answer-error-container " + (getClassName$2(this.$props.innerClass, 'ai-error') || '')
2153
2685
  }, [createVNode("div", {
2154
2686
  "class": "--default-error-element"
2155
- }, [createVNode("span", null, [this.error.message ? this.error.message : 'There was an error in generating the response.', ' ', this.error.code ? "Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && createVNode(Button, {
2687
+ }, [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 && createVNode(Button, {
2156
2688
  "primary": true,
2157
2689
  "onClick": this.handleRetryRequest
2158
2690
  }, {
@@ -2211,6 +2743,7 @@ var AIAnswer = defineComponent({
2211
2743
  innerClass = _this$$props.innerClass;
2212
2744
  var renderMic = this.$slots.renderMic || this.$props.renderMic;
2213
2745
  return createVNode("div", null, [createVNode(IconGroup, {
2746
+ "enableAI": true,
2214
2747
  "groupPosition": "right",
2215
2748
  "positionType": "absolute"
2216
2749
  }, {
@@ -2227,6 +2760,7 @@ var AIAnswer = defineComponent({
2227
2760
  })];
2228
2761
  }
2229
2762
  }), createVNode(IconGroup, {
2763
+ "enableAI": true,
2230
2764
  "groupPosition": "left",
2231
2765
  "positionType": "absolute"
2232
2766
  }, {
@@ -2280,6 +2814,28 @@ var AIAnswer = defineComponent({
2280
2814
  rawData: this.rawData
2281
2815
  };
2282
2816
  return getComponent(data, this);
2817
+ },
2818
+ handleTextAreaHeightChange: function handleTextAreaHeightChange() {
2819
+ var _this$$refs2, _this$$refs2$_inputRe, _this$$refs3, _this$$refs3$_inputWr, _this$$refs4;
2820
+ var textArea = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputRe = _this$$refs2[_inputRef]) == null ? void 0 : _this$$refs2$_inputRe.$el;
2821
+ var inputWrapper = (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$_inputWr = _this$$refs3[_inputWrapperRef]) == null ? void 0 : _this$$refs3$_inputWr.$el;
2822
+ var errorContainer = (_this$$refs4 = this.$refs) == null ? void 0 : _this$$refs4[_errorContainerRef];
2823
+ if (textArea) {
2824
+ textArea.style.height = '42px';
2825
+ var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
2826
+ var maxHeight = lineHeight * 11; // max height for 10 lines
2827
+ var height = Math.min(textArea.scrollHeight, maxHeight);
2828
+ textArea.style.height = height + "px";
2829
+ textArea.style.overflowY = height === maxHeight ? 'auto' : 'hidden';
2830
+ // wrapper around input/ textarea
2831
+ inputWrapper.style.height = height + "px";
2832
+ // adjust error-container
2833
+
2834
+ if (errorContainer) {
2835
+ errorContainer.style.bottom = height + "px";
2836
+ }
2837
+ this.$forceUpdate();
2838
+ }
2283
2839
  }
2284
2840
  },
2285
2841
  beforeUnmount: function beforeUnmount() {
@@ -2333,7 +2889,7 @@ var AIAnswer = defineComponent({
2333
2889
  return createVNode(Message, {
2334
2890
  "key": index,
2335
2891
  "isSender": message.role === AI_ROLES.USER,
2336
- "innerHTML": md.render(message.content),
2892
+ "innerHTML": md$1.render(message.content),
2337
2893
  "themePreset": _this4.themePreset,
2338
2894
  "theme": props.theme,
2339
2895
  "class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
@@ -2359,22 +2915,38 @@ var AIAnswer = defineComponent({
2359
2915
  }
2360
2916
  })];
2361
2917
  }
2362
- }), _this4.renderErrorComponent(), props.showInput && createVNode(MessageInputContainer, {
2918
+ }), _this4.renderErrorComponent(), ' ', props.showFeedback && createVNode("div", {
2919
+ "class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
2920
+ }, [createVNode(AIFeedback, {
2921
+ "hideUI": _this4.isLoadingState || !_this4.sessionId,
2922
+ "key": _this4.sessionId,
2923
+ "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
2924
+ _this4.trackUsefullness(_this4.sessionId, {
2925
+ useful: useful,
2926
+ reason: reason
2927
+ });
2928
+ }
2929
+ }, null)]), props.showInput && createVNode(MessageInputContainer, {
2363
2930
  "class": "--ai-input-container",
2364
2931
  "onSubmit": _this4.handleSendMessage
2365
2932
  }, {
2366
2933
  "default": function _default() {
2367
2934
  return [createVNode(InputGroup, {
2935
+ "enableAI": true,
2368
2936
  "isOpen": false
2369
2937
  }, {
2370
2938
  "default": function _default() {
2371
- return [createVNode(InputWrapper, null, {
2939
+ return [createVNode(InputWrapper, {
2940
+ "ref": _inputWrapperRef
2941
+ }, {
2372
2942
  "default": function _default() {
2373
2943
  return [createVNode(MessageInput, {
2944
+ "ref": _inputRef,
2374
2945
  "type": "text",
2375
2946
  "placeholder": props.placeholder,
2947
+ "enterButton": props.enterButton,
2376
2948
  "value": _this4.inputMessage,
2377
- "onChange": _this4.handleMessageInputChange,
2949
+ "onInput": _this4.handleMessageInputChange,
2378
2950
  "onKeyPress": _this4.handleKeyPress,
2379
2951
  "id": props.componentId + "-ai-input",
2380
2952
  "showIcon": props.showIcon,
@@ -2413,11 +2985,12 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
2413
2985
  rawData: state.rawData[props.componentId],
2414
2986
  themePreset: state.config.themePreset,
2415
2987
  isLoading: state.isLoading[props.componentId] || false,
2416
- sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].sessionId || ''
2988
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || ''
2417
2989
  };
2418
2990
  };
2419
2991
  var mapDispatchToProps$1 = {
2420
- getAIResponse: fetchAIResponse
2992
+ getAIResponse: fetchAIResponse,
2993
+ trackUsefullness: recordAISessionUsefulness
2421
2994
  };
2422
2995
  var AIConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps$1, mapDispatchToProps$1)(AIAnswer), {
2423
2996
  componentType: componentTypes.AIAnswer,
@@ -2431,9 +3004,9 @@ AIConnected.install = function (Vue) {
2431
3004
  // Add componentType for SSR
2432
3005
  AIConnected.componentType = componentTypes.AIAnswer;
2433
3006
 
2434
- var _templateObject$9, _templateObject2$2;
2435
- var HierarchicalMenuList = styled('ul')(_templateObject$9 || (_templateObject$9 = _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"])));
2436
- var HierarchicalMenuListItem = styled('li')(_templateObject2$2 || (_templateObject2$2 = _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) {
3007
+ var _templateObject$b, _templateObject2$4;
3008
+ var HierarchicalMenuList = styled('ul')(_templateObject$b || (_templateObject$b = _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"])));
3009
+ var HierarchicalMenuListItem = styled('li')(_templateObject2$4 || (_templateObject2$4 = _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) {
2437
3010
  return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
2438
3011
  });
2439
3012