@appbaseio/reactivesearch-vue 3.0.0-rc.17 → 3.0.0-rc.18

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.
@@ -1,5 +1,5 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { SEARCH_COMPONENTS_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
2
+ import { SEARCH_COMPONENTS_MODES, AI_TRIGGER_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
3
3
  import _transformOn from '@vue/babel-helper-vue-transform-on';
4
4
  import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
5
5
  import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
@@ -804,7 +804,7 @@ var HorizontalSkeletonLoader = defineComponent({
804
804
  });
805
805
 
806
806
  var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
807
- var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n"])), function (props) {
807
+ var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n\n\t.--trigger-message-wrapper {\n\t\tcursor: pointer;\n\t}\n"])), function (props) {
808
808
  return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
809
809
  });
810
810
  var ChatContainer = styled('div')(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\theight: 100%;\n\tposition: relative;\n\t.--ai-answer-error-container {\n\t\ttext-align: center;\n\t\tposition: absolute;\n\t\tbottom: 0px;\n\t\t", ";\n\t\tz-index: 1;\n\t\tleft: 50%;\n\t\ttransform: translateX(-50%);\n\t\twidth: 100%;\n\n\t\t.--default-error-element {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tpadding: 10px;\n\t\t\tbackground-color: ", ";\n\t\t\tbox-shadow: 0 -5px 5px -2px\n\t\t\t\t", ";\n\n\t\t\tspan {\n\t\t\t\tmargin-bottom: 5px;\n\t\t\t}\n\n\t\t\tbutton {\n\t\t\t}\n\t\t}\n\t}\n\n\t", ";\n"])), function (props) {
@@ -829,11 +829,15 @@ var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTem
829
829
  return finalColor;
830
830
  }, typingDots);
831
831
  var resetCSS = function resetCSS(props) {
832
- return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
832
+ return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t\twhite-space: pre-wrap;\n\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
833
833
  // eslint-disable-next-line no-nested-ternary
834
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\t}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
834
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\n\t}\n\n\tpre{\n\t\tcolor: " + (
835
835
  // eslint-disable-next-line no-nested-ternary
836
- props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
836
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
837
+ // eslint-disable-next-line no-nested-ternary
838
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\ncode[class*='language-'],\n\tpre[class*='language-'] {\n\t\tcolor: " + (
839
+ // eslint-disable-next-line no-nested-ternary
840
+ props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\ttext-shadow: none;\n\t}\n\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
837
841
  };
838
842
  var messageBGColor = function messageBGColor(props) {
839
843
  var finalBGColor;
@@ -1152,6 +1156,9 @@ var SearchBox = defineComponent({
1152
1156
  }
1153
1157
  },
1154
1158
  computed: {
1159
+ currentTriggerMode: function currentTriggerMode() {
1160
+ return this.$props.AIUIConfig && this.$props.AIUIConfig.triggerOn || AI_TRIGGER_MODES.MANUAL;
1161
+ },
1155
1162
  hasCustomRenderer: function hasCustomRenderer$1() {
1156
1163
  return hasCustomRenderer(this);
1157
1164
  },
@@ -1169,6 +1176,13 @@ var SearchBox = defineComponent({
1169
1176
  if (Array.isArray(this.suggestions) && this.suggestions.length) {
1170
1177
  suggestionsArray = [].concat(withClickIds(this.suggestions));
1171
1178
  }
1179
+ if (this.renderTriggerMessage() && this.currentValue && !this.isLoading) {
1180
+ suggestionsArray.unshift({
1181
+ label: this.renderTriggerMessage(),
1182
+ value: 'AI_TRIGGER_MESSAGE',
1183
+ _suggestion_type: '_internal_a_i_trigger'
1184
+ });
1185
+ }
1172
1186
  suggestionsArray = suggestionsArray.map(function (s) {
1173
1187
  if (s.sectionId) {
1174
1188
  return s;
@@ -1442,6 +1456,20 @@ var SearchBox = defineComponent({
1442
1456
  }
1443
1457
  },
1444
1458
  methods: {
1459
+ renderTriggerMessage: function renderTriggerMessage() {
1460
+ if (this.$props.enableAI) {
1461
+ if (this.$props.AIUIConfig && this.$props.AIUIConfig.renderTriggerMessage) {
1462
+ return this.$props.AIUIConfig.renderTriggerMessage;
1463
+ }
1464
+ if (this.$slots.renderTriggerMessage) {
1465
+ return this.$slots.renderTriggerMessage();
1466
+ }
1467
+ if (this.currentTriggerMode === AI_TRIGGER_MODES.MANUAL && (this.$props.AIUIConfig ? !this.$props.AIUIConfig.askButton : true)) {
1468
+ return 'Click to trigger AIAnswer';
1469
+ }
1470
+ }
1471
+ return null;
1472
+ },
1445
1473
  handleText: function handleText(value, cause) {
1446
1474
  if (cause === causes.CLEAR_VALUE) {
1447
1475
  this.triggerCustomQuery(value);
@@ -1554,7 +1582,7 @@ var SearchBox = defineComponent({
1554
1582
  if (toggleIsOpen) {
1555
1583
  _this2.isOpen = false;
1556
1584
  }
1557
- if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1585
+ if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI && _this2.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && _this2.currentValue.endsWith('?') ? {
1558
1586
  enableAI: true
1559
1587
  } : {}, shouldExecuteQuery);
1560
1588
  } // in case of strict selection only SUGGESTION_SELECT should be able
@@ -1709,9 +1737,10 @@ var SearchBox = defineComponent({
1709
1737
  } else if (highlightedIndex === null) {
1710
1738
  this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined,
1711
1739
  // to handle tags
1712
- !this.$props.enableAI);
1713
- if (this.$props.enableAI && !this.showAIScreen) {
1740
+ !(this.$props.enableAI && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')));
1741
+ if (this.$props.enableAI && !this.showAIScreen && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')) {
1714
1742
  this.showAIScreen = true;
1743
+ this.isOpen = true;
1715
1744
  }
1716
1745
  this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1717
1746
  }
@@ -1796,6 +1825,11 @@ var SearchBox = defineComponent({
1796
1825
  this.onValueSelectedHandler(suggestion.value);
1797
1826
  return;
1798
1827
  }
1828
+ if (suggestion && suggestion._suggestion_type === '_internal_a_i_trigger') {
1829
+ this.showAIScreen = true;
1830
+ this.askButtonOnClick();
1831
+ return;
1832
+ }
1799
1833
 
1800
1834
  // handle featured suggestions click event
1801
1835
  if (suggestion._suggestion_type === suggestionTypes.Featured) {
@@ -1835,7 +1869,7 @@ var SearchBox = defineComponent({
1835
1869
  this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
1836
1870
 
1837
1871
  // Handle AI
1838
- if (!this.$props.enableAI) this.isOpen = false;else {
1872
+ if (!this.$props.enableAI) this.isOpen = false;else if (this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && suggestion.value.endsWith('?')) {
1839
1873
  this.showAIScreen = true;
1840
1874
  }
1841
1875
  },
@@ -2505,18 +2539,38 @@ var SearchBox = defineComponent({
2505
2539
  var suggestionsHaveIcon = item.some(function (s) {
2506
2540
  return s.icon || s.iconURL;
2507
2541
  });
2508
- return renderItem ? createVNode("li", mergeProps(getItemProps({
2509
- item: sectionItem
2510
- }), _transformOn(getItemEvents({
2511
- item: sectionItem
2512
- })), {
2513
- "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2514
- "style": {
2515
- justifyContent: 'flex-start',
2516
- alignItems: 'center'
2517
- },
2518
- "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2519
- }), [renderItem(sectionItem)]) : createVNode("li", mergeProps(getItemProps({
2542
+ if (renderItem) {
2543
+ return createVNode("li", mergeProps(getItemProps({
2544
+ item: sectionItem
2545
+ }), _transformOn(getItemEvents({
2546
+ item: sectionItem
2547
+ })), {
2548
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2549
+ "style": {
2550
+ justifyContent: 'flex-start',
2551
+ alignItems: 'center'
2552
+ },
2553
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2554
+ }), [renderItem(sectionItem)]);
2555
+ }
2556
+ if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
2557
+ return createVNode("li", mergeProps(getItemProps({
2558
+ item: sectionItem
2559
+ }), _transformOn(getItemEvents({
2560
+ item: sectionItem
2561
+ })), {
2562
+ "key": sectionItem._id + "_" + index + "_" + sectionIndex,
2563
+ "style": {
2564
+ justifyContent: 'flex-start',
2565
+ alignItems: 'center'
2566
+ },
2567
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
2568
+ }), [createVNode(SuggestionItem, {
2569
+ "currentValue": _this16.currentValue,
2570
+ "suggestion": sectionItem
2571
+ }, null)]);
2572
+ }
2573
+ return createVNode("li", mergeProps(getItemProps({
2520
2574
  item: sectionItem
2521
2575
  }), _transformOn(getItemEvents({
2522
2576
  item: sectionItem
@@ -2736,6 +2790,7 @@ SBConnected.install = function (Vue) {
2736
2790
  // Add componentType for SSR
2737
2791
  SBConnected.componentType = componentTypes.searchBox;
2738
2792
 
2793
+ var _excluded$1 = ["_source"];
2739
2794
  function _isSlot$1(s) {
2740
2795
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
2741
2796
  }
@@ -2758,7 +2813,10 @@ var AIAnswer = defineComponent({
2758
2813
  messages: [],
2759
2814
  inputMessage: '',
2760
2815
  AISessionId: '',
2761
- error: null
2816
+ error: null,
2817
+ sourceDocIds: null,
2818
+ initialHits: null,
2819
+ isTriggered: false
2762
2820
  };
2763
2821
  this.internalComponent = props.componentId + "__internal";
2764
2822
  return this.__state;
@@ -2768,7 +2826,16 @@ var AIAnswer = defineComponent({
2768
2826
  from: 'theme_reactivesearch'
2769
2827
  }
2770
2828
  },
2771
- created: function created() {},
2829
+ created: function created() {
2830
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
2831
+ this.isTriggered = true;
2832
+ } else if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
2833
+ this.isTriggered = true;
2834
+ if (this.AISessionId) {
2835
+ this.handleSendMessage(null, false, '', true);
2836
+ }
2837
+ }
2838
+ },
2772
2839
  computed: {
2773
2840
  hasCustomRenderer: function hasCustomRenderer$1() {
2774
2841
  return hasCustomRenderer(this);
@@ -2781,6 +2848,9 @@ var AIAnswer = defineComponent({
2781
2848
  },
2782
2849
  errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
2783
2850
  return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
2851
+ },
2852
+ hasTriggered: function hasTriggered() {
2853
+ return this.isTriggered;
2784
2854
  }
2785
2855
  },
2786
2856
  props: {
@@ -2819,13 +2889,26 @@ var AIAnswer = defineComponent({
2819
2889
  sessionIdFromStore: VueTypes.string,
2820
2890
  showComponent: types.boolRequired,
2821
2891
  componentError: types.componentObject,
2822
- style: types.style
2892
+ style: types.style,
2893
+ showSourceDocuments: VueTypes.bool.def(false),
2894
+ renderSourceDocument: types.func,
2895
+ onSourceClick: types.func,
2896
+ isAITyping: types.boolRequired,
2897
+ triggerOn: VueTypes.string.def(AI_TRIGGER_MODES.ALWAYS),
2898
+ renderTriggerMessage: types.func
2823
2899
  },
2824
2900
  mounted: function mounted() {},
2825
2901
  watch: {
2826
2902
  AIResponse: function AIResponse(newVal) {
2827
2903
  if (newVal) {
2828
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2904
+ if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
2905
+ this.sourceDocIds = newVal.response.answer.documentIds;
2906
+ var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
2907
+ if (localCache && localCache.meta && localCache.meta.hits) {
2908
+ this.initialHits = localCache.meta.hits;
2909
+ }
2910
+ }
2911
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2829
2912
  var messagesHistory = newVal.messages,
2830
2913
  response = newVal.response;
2831
2914
  var finalMessages = [];
@@ -2836,7 +2919,7 @@ var AIAnswer = defineComponent({
2836
2919
  }
2837
2920
 
2838
2921
  // pushing message history so far
2839
- if (messagesHistory && messagesHistory && Array.isArray(messagesHistory)) {
2922
+ if (messagesHistory && Array.isArray(messagesHistory)) {
2840
2923
  finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
2841
2924
  return msg.role !== AI_ROLES.SYSTEM;
2842
2925
  }));
@@ -2861,6 +2944,9 @@ var AIAnswer = defineComponent({
2861
2944
  loading: this.$props.isAIResponseLoading || this.$props.isLoading,
2862
2945
  error: this.$props.AIResponseError
2863
2946
  });
2947
+ if (newVal && newVal.hits && newVal.hits.hits) {
2948
+ this.initialHits = newVal.hits.hits;
2949
+ }
2864
2950
  },
2865
2951
  isAIResponseLoading: function isAIResponseLoading(newVal) {
2866
2952
  this.$emit('on-data', {
@@ -2885,7 +2971,7 @@ var AIAnswer = defineComponent({
2885
2971
  },
2886
2972
  AIResponseError: function AIResponseError(newVal) {
2887
2973
  this.error = newVal;
2888
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2974
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2889
2975
  if (this.error && !this.AISessionId) {
2890
2976
  var errorMessage = this.errorMessageForMissingSessionId;
2891
2977
  this.error = {
@@ -2906,7 +2992,7 @@ var AIAnswer = defineComponent({
2906
2992
  componentError: function componentError(newVal) {
2907
2993
  var _this = this;
2908
2994
  if (newVal && newVal._bodyBlob) {
2909
- this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2995
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
2910
2996
  if (!this.AISessionId) {
2911
2997
  this.generateNewSessionId();
2912
2998
  }
@@ -2929,23 +3015,154 @@ var AIAnswer = defineComponent({
2929
3015
  console.error('Error reading component error text data:', error);
2930
3016
  });
2931
3017
  }
3018
+ },
3019
+ showComponent: function showComponent() {
3020
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
3021
+ this.isTriggered = true;
3022
+ }
3023
+ },
3024
+ dependentComponentValue: function dependentComponentValue(newVal) {
3025
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
3026
+ this.isTriggered = true;
3027
+ if (this.AISessionId) {
3028
+ this.handleSendMessage(null, false, '', true);
3029
+ }
3030
+ } else if (this.hasTriggered && this.$props.triggerOn !== AI_TRIGGER_MODES.ALWAYS) {
3031
+ this.isTriggered = false;
3032
+ }
3033
+ },
3034
+ AISessionId: function AISessionId(newVal) {
3035
+ if (newVal) {
3036
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
3037
+ this.handleSendMessage(null, false, '', true);
3038
+ }
3039
+ }
3040
+ },
3041
+ triggerOn: function triggerOn(newVal) {
3042
+ if (newVal === AI_TRIGGER_MODES.ALWAYS) {
3043
+ this.isTriggered = true;
3044
+ }
2932
3045
  }
2933
3046
  },
2934
3047
  methods: {
2935
- generateNewSessionId: function generateNewSessionId() {
3048
+ renderTriggerMessageFunc: function renderTriggerMessageFunc() {
3049
+ var triggerOn = this.$props.triggerOn;
3050
+ if (this.$props.renderTriggerMessage) {
3051
+ return this.$props.renderTriggerMessage;
3052
+ }
3053
+ if (this.$slots.renderTriggerMessage) {
3054
+ return this.$slots.renderTriggerMessage();
3055
+ }
3056
+ if (triggerOn === AI_TRIGGER_MODES.QUESTION) {
3057
+ if (!this.dependentComponentValue.endsWith('?')) {
3058
+ return createVNode("span", null, [createVNode("span", {
3059
+ "role": "img",
3060
+ "aria-label": "bulb"
3061
+ }, [createTextVNode("\uD83D\uDCA1")]), createTextVNode("End your question with a question mark (?)")]);
3062
+ }
3063
+ } else if (triggerOn === AI_TRIGGER_MODES.MANUAL) {
3064
+ return createVNode("span", null, [createTextVNode("Click here to ask AI"), ' ', createVNode("span", {
3065
+ "role": "img",
3066
+ "aria-label": "bulb"
3067
+ }, [createTextVNode("\uD83E\uDD16")])]);
3068
+ }
3069
+ return null;
3070
+ },
3071
+ handleTriggerClick: function handleTriggerClick() {
3072
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.MANUAL) {
3073
+ this.handleSendMessage(null, false, '', true);
3074
+ this.isTriggered = true;
3075
+ }
3076
+ },
3077
+ getAISourceObjects: function getAISourceObjects() {
2936
3078
  var _this2 = this;
3079
+ var sourceObjects = [];
3080
+ if (!this.AIResponse) return sourceObjects;
3081
+ var docIds = this.sourceDocIds || [];
3082
+ if (this.initialHits) {
3083
+ docIds.forEach(function (id) {
3084
+ var foundSourceObj = _this2.initialHits.find(function (hit) {
3085
+ return hit._id === id;
3086
+ }) || {};
3087
+ if (foundSourceObj) {
3088
+ var _foundSourceObj$_sour = foundSourceObj._source,
3089
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
3090
+ rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
3091
+ sourceObjects.push(_extends({}, rest, _source));
3092
+ }
3093
+ });
3094
+ } else {
3095
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
3096
+ return {
3097
+ _id: id
3098
+ };
3099
+ }));
3100
+ }
3101
+ return sourceObjects;
3102
+ },
3103
+ renderAIScreenFooter: function renderAIScreenFooter() {
3104
+ var _slot2;
3105
+ var _this3 = this;
3106
+ var _ref = this.$props || {},
3107
+ _ref$showSourceDocume = _ref.showSourceDocuments,
3108
+ showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
3109
+ _ref$onSourceClick = _ref.onSourceClick,
3110
+ onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
3111
+ renderSourceDocument = _ref.renderSourceDocument;
3112
+ var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
3113
+ if (this.isLoadingState || this.isAITyping) {
3114
+ return null;
3115
+ }
3116
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
3117
+ if (customRenderSourceDoc) {
3118
+ return customRenderSourceDoc(sourceObj);
3119
+ }
3120
+ return sourceObj._id;
3121
+ };
3122
+ return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? createVNode(Footer, {
3123
+ "themePreset": this.$props.themePreset,
3124
+ "style": {
3125
+ marginTop: '1.5rem',
3126
+ background: 'inherit'
3127
+ }
3128
+ }, {
3129
+ "default": function _default() {
3130
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
3131
+ var _slot;
3132
+ return createVNode(Button, {
3133
+ "class": "--ai-source-tag " + (getClassName$2(_this3.$props.innerClass, 'ai-source-tag') || ''),
3134
+ "info": true,
3135
+ "onClick": function onClick() {
3136
+ return onSourceClick && onSourceClick(el);
3137
+ },
3138
+ "key": el._id
3139
+ }, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
3140
+ "default": function _default() {
3141
+ return [_slot];
3142
+ }
3143
+ });
3144
+ })) ? _slot2 : {
3145
+ "default": function _default() {
3146
+ return [_slot2];
3147
+ }
3148
+ })];
3149
+ }
3150
+ }) : null;
3151
+ },
3152
+ generateNewSessionId: function generateNewSessionId() {
3153
+ var _this4 = this;
2937
3154
  var newSessionPromise = this.createAISession();
2938
3155
  newSessionPromise.then(function (res) {
2939
- _this2.AISessionId = res.AIsessionId;
3156
+ _this4.AISessionId = res.AIsessionId;
2940
3157
  })["catch"](function (e) {
2941
3158
  console.error(e);
2942
3159
  });
2943
3160
  },
2944
3161
  scrollToBottom: function scrollToBottom() {
2945
- var _this3 = this;
3162
+ var _this5 = this;
2946
3163
  this.$nextTick(function () {
2947
- var _this3$$refs;
2948
- var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
3164
+ var _this5$$refs;
3165
+ var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
2949
3166
  if (messageContainer && messageContainer.$el) {
2950
3167
  messageContainer.$el.scrollTo({
2951
3168
  top: messageContainer.$el.scrollHeight,
@@ -2958,24 +3175,33 @@ var AIAnswer = defineComponent({
2958
3175
  this.inputMessage = e.target.value;
2959
3176
  this.handleTextAreaHeightChange();
2960
3177
  },
2961
- handleSendMessage: function handleSendMessage(e, isRetry, text) {
3178
+ handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
2962
3179
  if (isRetry === void 0) {
2963
3180
  isRetry = false;
2964
3181
  }
2965
3182
  if (text === void 0) {
2966
3183
  text = this.inputMessage;
2967
3184
  }
3185
+ if (fetchMeta === void 0) {
3186
+ fetchMeta = false;
3187
+ }
2968
3188
  if (typeof e === 'object' && e !== null) e.preventDefault();
2969
- if (text.trim()) {
3189
+ if (text.trim() || !text && !e) {
2970
3190
  if (this.isLoadingState) {
2971
3191
  return;
2972
3192
  }
2973
3193
  if (this.AISessionId) {
2974
- if (!isRetry) this.messages = [].concat(this.messages, [{
2975
- content: text,
2976
- role: AI_ROLES.USER
2977
- }]);
2978
- this.getAIResponse(this.AISessionId, this.componentId, text);
3194
+ if (!isRetry) {
3195
+ var finalMessages = [].concat(this.messages);
3196
+ if (text) {
3197
+ finalMessages.push({
3198
+ content: text,
3199
+ role: AI_ROLES.USER
3200
+ });
3201
+ }
3202
+ this.messages = [].concat(finalMessages);
3203
+ }
3204
+ this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
2979
3205
  } else {
2980
3206
  console.error(this.errorMessageForMissingSessionId);
2981
3207
  this.error = {
@@ -3024,7 +3250,6 @@ var AIAnswer = defineComponent({
3024
3250
  return null;
3025
3251
  },
3026
3252
  handleKeyPress: function handleKeyPress(e) {
3027
- window.console.log('e', e);
3028
3253
  if (e.key === 'Enter') {
3029
3254
  this.handleSendMessage(e);
3030
3255
  this.inputMessage = '';
@@ -3056,15 +3281,15 @@ var AIAnswer = defineComponent({
3056
3281
  if (typeof window === 'undefined') return false;
3057
3282
  return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
3058
3283
  },
3059
- handleVoiceResults: function handleVoiceResults(_ref) {
3060
- var results = _ref.results;
3284
+ handleVoiceResults: function handleVoiceResults(_ref2) {
3285
+ var results = _ref2.results;
3061
3286
  if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
3062
3287
  this.handleSendMessage(null, false, results[0][0].transcript.trim());
3063
3288
  }
3064
3289
  },
3065
3290
  renderIcons: function renderIcons() {
3066
- var _this4 = this;
3067
- var _slot, _slot2;
3291
+ var _this6 = this;
3292
+ var _slot3, _slot4;
3068
3293
  var _this$$props = this.$props,
3069
3294
  getMicInstance = _this$$props.getMicInstance,
3070
3295
  showVoiceInput = _this$$props.showVoiceInput,
@@ -3077,14 +3302,14 @@ var AIAnswer = defineComponent({
3077
3302
  "positionType": "absolute"
3078
3303
  }, {
3079
3304
  "default": function _default() {
3080
- return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && createVNode(Mic, {
3305
+ return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && createVNode(Mic, {
3081
3306
  "getInstance": getMicInstance,
3082
3307
  "render": renderMic,
3083
- "handleResult": _this4.handleVoiceResults,
3308
+ "handleResult": _this6.handleVoiceResults,
3084
3309
  "class": getClassName$2(innerClass, 'ai-search-mic') || null
3085
- }, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
3310
+ }, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
3086
3311
  "default": function _default() {
3087
- return [_slot];
3312
+ return [_slot3];
3088
3313
  }
3089
3314
  })];
3090
3315
  }
@@ -3094,9 +3319,9 @@ var AIAnswer = defineComponent({
3094
3319
  "positionType": "absolute"
3095
3320
  }, {
3096
3321
  "default": function _default() {
3097
- return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
3322
+ return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
3098
3323
  "default": function _default() {
3099
- return [_slot2];
3324
+ return [_slot4];
3100
3325
  }
3101
3326
  })];
3102
3327
  }
@@ -3106,7 +3331,7 @@ var AIAnswer = defineComponent({
3106
3331
  this.handleSendMessage(e);
3107
3332
  },
3108
3333
  renderEnterButtonElement: function renderEnterButtonElement() {
3109
- var _this5 = this;
3334
+ var _this7 = this;
3110
3335
  var _this$$props2 = this.$props,
3111
3336
  enterButton = _this$$props2.enterButton,
3112
3337
  innerClass = _this$$props2.innerClass;
@@ -3114,16 +3339,16 @@ var AIAnswer = defineComponent({
3114
3339
  if (enterButton) {
3115
3340
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
3116
3341
  if (renderEnterButton) {
3117
- return renderEnterButton(_this5.enterButtonOnClick);
3342
+ return renderEnterButton(_this7.enterButtonOnClick);
3118
3343
  }
3119
3344
  return createVNode(SendButton, {
3120
3345
  "primary": true,
3121
3346
  "type": "submit",
3122
3347
  "tabIndex": 0,
3123
- "onClick": _this5.handleSendMessage,
3124
- "onKeyPress": _this5.handleKeyPress,
3348
+ "onClick": _this7.handleSendMessage,
3349
+ "onKeyPress": _this7.handleKeyPress,
3125
3350
  "class": "ask-btn " + getClassName$2(innerClass, 'ai-enter-button'),
3126
- "disabled": _this5.isLoadingState || !_this5.AISessionId
3351
+ "disabled": _this7.isLoadingState || !_this7.AISessionId
3127
3352
  }, {
3128
3353
  "default": function _default() {
3129
3354
  return [createTextVNode("Send")];
@@ -3166,6 +3391,20 @@ var AIAnswer = defineComponent({
3166
3391
  }
3167
3392
  this.$forceUpdate();
3168
3393
  }
3394
+ },
3395
+ getTitle: function getTitle() {
3396
+ var _this8 = this;
3397
+ var hasTitle = this.$props.title || this.$slots.title || null;
3398
+ if (hasTitle) {
3399
+ return createVNode(Title, {
3400
+ "class": getClassName$2(this.$props.innerClass, 'ai-title') || null
3401
+ }, {
3402
+ "default": function _default() {
3403
+ return [_this8.$props.title || _this8.$slots.title()];
3404
+ }
3405
+ });
3406
+ }
3407
+ return null;
3169
3408
  }
3170
3409
  },
3171
3410
  beforeUnmount: function beforeUnmount() {
@@ -3180,55 +3419,62 @@ var AIAnswer = defineComponent({
3180
3419
  }
3181
3420
  },
3182
3421
  render: function render() {
3183
- var _slot3;
3184
- var _this6 = this;
3422
+ var _slot5;
3423
+ var _this9 = this;
3185
3424
  var props = this.$props;
3186
3425
  if (!this.shouldShowComponent) {
3187
3426
  return null;
3188
3427
  }
3428
+ if (!this.isTriggered) {
3429
+ return createVNode(Chatbox, {
3430
+ "style": props.style || {}
3431
+ }, {
3432
+ "default": function _default() {
3433
+ return [_this9.getTitle(), createVNode("div", {
3434
+ "class": "--trigger-message-wrapper",
3435
+ "onClick": _this9.handleTriggerClick,
3436
+ "aria-hidden": "true"
3437
+ }, [_this9.renderTriggerMessageFunc()])];
3438
+ }
3439
+ });
3440
+ }
3189
3441
  return createVNode(Chatbox, {
3190
3442
  "style": props.style || {}
3191
3443
  }, {
3192
3444
  "default": function _default() {
3193
- return [_this6.$props.title && createVNode(Title, {
3194
- "class": getClassName$2(_this6.$props.innerClass, 'title') || ''
3195
- }, {
3196
- "default": function _default() {
3197
- return [_this6.$props.title];
3198
- }
3199
- }), createVNode(ChatContainer, {
3445
+ return [_this9.getTitle(), createVNode(ChatContainer, {
3200
3446
  "class": "--ai-chat-container",
3201
3447
  "theme": props.theme,
3202
3448
  "showInput": props.showInput
3203
3449
  }, {
3204
3450
  "default": function _default() {
3205
- return [_this6.hasCustomRenderer && createVNode(MessagesContainer, {
3206
- "themePreset": _this6.themePreset,
3451
+ return [_this9.hasCustomRenderer && createVNode(MessagesContainer, {
3452
+ "themePreset": _this9.themePreset,
3207
3453
  "theme": props.theme,
3208
- "ref": _this6.$props.innerRef,
3454
+ "ref": _this9.$props.innerRef,
3209
3455
  "class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
3210
- }, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
3456
+ }, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
3211
3457
  "default": function _default() {
3212
- return [_slot3];
3458
+ return [_slot5];
3213
3459
  }
3214
- }), !_this6.hasCustomRenderer && createVNode(MessagesContainer, {
3215
- "themePreset": _this6.themePreset,
3460
+ }), !_this9.hasCustomRenderer && createVNode(MessagesContainer, {
3461
+ "themePreset": _this9.themePreset,
3216
3462
  "theme": props.theme,
3217
- "ref": _this6.$props.innerRef,
3463
+ "ref": _this9.$props.innerRef,
3218
3464
  "class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
3219
3465
  }, {
3220
3466
  "default": function _default() {
3221
- return [_this6.messages.map(function (message, index) {
3467
+ return [_this9.messages.map(function (message, index) {
3222
3468
  return createVNode(Message, {
3223
3469
  "key": index,
3224
3470
  "isSender": message.role === AI_ROLES.USER,
3225
3471
  "innerHTML": md$1.render(message.content),
3226
- "themePreset": _this6.themePreset,
3472
+ "themePreset": _this9.themePreset,
3227
3473
  "theme": props.theme,
3228
3474
  "class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
3229
3475
  }, null);
3230
- }), _this6.isLoadingState && createVNode(Message, {
3231
- "themePreset": _this6.themePreset,
3476
+ }), _this9.isLoadingState && createVNode(Message, {
3477
+ "themePreset": _this9.themePreset,
3232
3478
  "theme": props.theme,
3233
3479
  "isSender": false,
3234
3480
  "class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || null)
@@ -3237,31 +3483,31 @@ var AIAnswer = defineComponent({
3237
3483
  return [createVNode(TypingIndicator, null, {
3238
3484
  "default": function _default() {
3239
3485
  return [createVNode(TypingDot, {
3240
- "themePreset": _this6.themePreset
3486
+ "themePreset": _this9.themePreset
3241
3487
  }, null), createVNode(TypingDot, {
3242
- "themePreset": _this6.themePreset
3488
+ "themePreset": _this9.themePreset
3243
3489
  }, null), createVNode(TypingDot, {
3244
- "themePreset": _this6.themePreset
3490
+ "themePreset": _this9.themePreset
3245
3491
  }, null)];
3246
3492
  }
3247
3493
  })];
3248
3494
  }
3249
3495
  })];
3250
3496
  }
3251
- }), _this6.renderErrorComponent(), ' ', props.showFeedback && createVNode("div", {
3497
+ }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && createVNode("div", {
3252
3498
  "class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
3253
3499
  }, [createVNode(AIFeedback, {
3254
- "hideUI": _this6.isLoadingState || !_this6.sessionId,
3255
- "key": _this6.sessionId,
3500
+ "hideUI": _this9.isLoadingState || !_this9.sessionId,
3501
+ "key": _this9.sessionId,
3256
3502
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
3257
- _this6.trackUsefullness(_this6.sessionId, {
3503
+ _this9.trackUsefullness(_this9.sessionId, {
3258
3504
  useful: useful,
3259
3505
  reason: reason
3260
3506
  });
3261
3507
  }
3262
- }, null)]), props.showInput && createVNode(MessageInputContainer, {
3508
+ }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && createVNode(MessageInputContainer, {
3263
3509
  "class": "--ai-input-container",
3264
- "onSubmit": _this6.handleSendMessage
3510
+ "onSubmit": _this9.handleSendMessage
3265
3511
  }, {
3266
3512
  "default": function _default() {
3267
3513
  return [createVNode(InputGroup, {
@@ -3277,19 +3523,19 @@ var AIAnswer = defineComponent({
3277
3523
  "ref": _inputRef,
3278
3524
  "placeholder": props.placeholder,
3279
3525
  "enterButton": props.enterButton,
3280
- "value": _this6.inputMessage,
3281
- "onInput": _this6.handleMessageInputChange,
3526
+ "value": _this9.inputMessage,
3527
+ "onInput": _this9.handleMessageInputChange,
3282
3528
  "id": props.componentId + "-ai-input",
3283
3529
  "showIcon": props.showIcon,
3284
3530
  "iconPosition": props.iconPosition,
3285
- "themePreset": _this6.themePreset,
3286
- "disabled": _this6.isLoadingState || !_this6.AISessionId,
3531
+ "themePreset": _this9.themePreset,
3532
+ "disabled": _this9.isLoadingState || !_this9.AISessionId,
3287
3533
  "class": getClassName$2(props.innerClass, 'ai-input') || null
3288
- }, null), ' ', _this6.renderIcons()];
3534
+ }, null), ' ', _this9.renderIcons()];
3289
3535
  }
3290
3536
  })];
3291
3537
  }
3292
- }), _this6.renderEnterButtonElement()];
3538
+ }), _this9.renderEnterButtonElement()];
3293
3539
  }
3294
3540
  }), ' '];
3295
3541
  }
@@ -3307,9 +3553,11 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3307
3553
  // eslint-disable-next-line prefer-destructuring
3308
3554
  dependencyComponent = dependencyComponent[0];
3309
3555
  }
3310
- var showComponent = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value;
3556
+ var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
3557
+ var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
3311
3558
  return {
3312
3559
  showComponent: showComponent,
3560
+ dependentComponentValue: dependentComponentValue,
3313
3561
  AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
3314
3562
  isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
3315
3563
  AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
@@ -3317,11 +3565,17 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3317
3565
  themePreset: state.config.themePreset,
3318
3566
  isLoading: state.isLoading[props.componentId] || false,
3319
3567
  sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3320
- componentError: state.error[props.componentId]
3568
+ componentError: state.error[props.componentId] || null,
3569
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
3321
3570
  };
3322
3571
  };
3323
3572
  var mapDispatchToProps$1 = {
3324
- getAIResponse: fetchAIResponse,
3573
+ getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
3574
+ if (shouldFetchMeta === void 0) {
3575
+ shouldFetchMeta = false;
3576
+ }
3577
+ return fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
3578
+ },
3325
3579
  trackUsefullness: recordAISessionUsefulness,
3326
3580
  createAISession: createAISession
3327
3581
  };