@appbaseio/reactivesearch-vue 3.3.0 → 3.3.1

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 (87) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +440 -696
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +4 -4
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-f96a0570.js → Button-7aee17e3.js} +1 -1
  6. package/dist/cjs/{DropDown-ebe20e81.js → CancelSvg-6094cd37.js} +1 -292
  7. package/dist/cjs/{Card-63968d94.js → Card-abff695e.js} +2 -2
  8. package/dist/cjs/{ComponentWrapper-0334c14b.js → ComponentWrapper-3bedbe57.js} +2 -2
  9. package/dist/cjs/{Container-29f049b2.js → Container-1c05785a.js} +1 -1
  10. package/dist/cjs/DropDown-815d458e.js +299 -0
  11. package/dist/cjs/DynamicRangeSlider.js +6 -6
  12. package/dist/cjs/{Flex-ddde6d26.js → Flex-f7af0673.js} +1 -1
  13. package/dist/cjs/{FormControlList-fadd792f.js → FormControlList-2c10e01a.js} +1 -1
  14. package/dist/cjs/{Input-cee51a53.js → Input-55fbd8e1.js} +1 -1
  15. package/dist/cjs/{ListItem-7a682970.js → ListItem-f272f502.js} +2 -2
  16. package/dist/cjs/MultiDropdownList.js +11 -10
  17. package/dist/cjs/MultiList.js +9 -9
  18. package/dist/cjs/MultiRange.js +7 -7
  19. package/dist/cjs/{Pagination-c53a18ab.js → Pagination-accd2fbf.js} +1 -1
  20. package/dist/cjs/{PreferencesConsumer-7bee3c57.js → PreferencesConsumer-37cab7a0.js} +2 -2
  21. package/dist/cjs/RangeInput.js +9 -9
  22. package/dist/cjs/RangeSlider.js +7 -7
  23. package/dist/cjs/ReactiveBase.js +2 -2
  24. package/dist/cjs/ReactiveComponent.js +4 -4
  25. package/dist/cjs/ReactiveGoogleMap.js +8 -8
  26. package/dist/cjs/ReactiveList.js +10 -10
  27. package/dist/cjs/ResultCard.js +3 -3
  28. package/dist/cjs/ResultList.js +3 -3
  29. package/dist/cjs/{install-c61d8b86.js → SearchBox-4dff47b4.js} +39 -1681
  30. package/dist/cjs/SearchBox.js +38 -0
  31. package/dist/cjs/SelectedFilters.js +5 -5
  32. package/dist/cjs/SingleDropdownList.js +11 -10
  33. package/dist/cjs/SingleList.js +9 -9
  34. package/dist/cjs/SingleRange.js +7 -7
  35. package/dist/cjs/StateProvider.js +2 -2
  36. package/dist/cjs/{Title-8802a218.js → Title-d513ac26.js} +1 -1
  37. package/dist/cjs/ToggleButton.js +7 -7
  38. package/dist/cjs/{_rollupPluginBabelHelpers-f8b843f8.js → _rollupPluginBabelHelpers-1a877b17.js} +14 -14
  39. package/dist/cjs/{index-1f41363f.js → index-7ca9570e.js} +1 -1
  40. package/dist/cjs/index.js +21 -19
  41. package/dist/cjs/install-246c0dab.js +1683 -0
  42. package/dist/cjs/install.js +19 -17
  43. package/dist/cjs/{ssr-8dd13d43.js → ssr-15d936a0.js} +1 -1
  44. package/dist/cjs/{utils-c9bd5628.js → utils-a3db8765.js} +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/es/{Button-5c2cf399.js → Button-8178e39a.js} +1 -1
  47. package/dist/es/{DropDown-36fa9ac5.js → CancelSvg-5b82ad4f.js} +3 -293
  48. package/dist/es/{Card-54b9e7a0.js → Card-3a81ac7b.js} +2 -2
  49. package/dist/es/{ComponentWrapper-46d04344.js → ComponentWrapper-90d42a29.js} +2 -2
  50. package/dist/es/{Container-d00219f7.js → Container-e2261542.js} +1 -1
  51. package/dist/es/DropDown-f8049812.js +295 -0
  52. package/dist/es/DynamicRangeSlider.js +6 -6
  53. package/dist/es/{Flex-25792bc3.js → Flex-5d11362e.js} +1 -1
  54. package/dist/es/{FormControlList-fe6eaee4.js → FormControlList-968ff972.js} +1 -1
  55. package/dist/es/{Input-437ae439.js → Input-cda7f4ad.js} +1 -1
  56. package/dist/es/{ListItem-e3c6acf4.js → ListItem-beea18db.js} +2 -2
  57. package/dist/es/MultiDropdownList.js +11 -10
  58. package/dist/es/MultiList.js +9 -9
  59. package/dist/es/MultiRange.js +7 -7
  60. package/dist/es/{Pagination-591fdb79.js → Pagination-b2160aac.js} +1 -1
  61. package/dist/es/{PreferencesConsumer-0856ed43.js → PreferencesConsumer-a2bd59db.js} +2 -2
  62. package/dist/es/RangeInput.js +9 -9
  63. package/dist/es/RangeSlider.js +7 -7
  64. package/dist/es/ReactiveBase.js +2 -2
  65. package/dist/es/ReactiveComponent.js +4 -4
  66. package/dist/es/ReactiveGoogleMap.js +8 -8
  67. package/dist/es/ReactiveList.js +10 -10
  68. package/dist/es/ResultCard.js +3 -3
  69. package/dist/es/ResultList.js +3 -3
  70. package/dist/es/{install-4fe6038c.js → SearchBox-57e3a0ff.js} +14 -1668
  71. package/dist/es/SearchBox.js +29 -0
  72. package/dist/es/SelectedFilters.js +5 -5
  73. package/dist/es/SingleDropdownList.js +11 -10
  74. package/dist/es/SingleList.js +9 -9
  75. package/dist/es/SingleRange.js +7 -7
  76. package/dist/es/StateProvider.js +2 -2
  77. package/dist/es/{Title-863dfa42.js → Title-100fe896.js} +1 -1
  78. package/dist/es/ToggleButton.js +7 -7
  79. package/dist/es/{_rollupPluginBabelHelpers-ded08042.js → _rollupPluginBabelHelpers-5e8399d7.js} +14 -14
  80. package/dist/es/{index-104f1dfb.js → index-3af85a74.js} +1 -1
  81. package/dist/es/index.js +21 -19
  82. package/dist/es/install-74125db1.js +1676 -0
  83. package/dist/es/install.js +19 -17
  84. package/dist/es/{ssr-c630ccb9.js → ssr-40133887.js} +1 -1
  85. package/dist/es/{utils-d7dd4f4e.js → utils-badbb2a8.js} +1 -1
  86. package/dist/es/version.js +1 -1
  87. package/package.json +3 -3
@@ -0,0 +1,1676 @@
1
+ import { Actions } from '@appbaseio/reactivecore';
2
+ import { AI_TRIGGER_MODES, AI_LOCAL_CACHE_KEY, AI_ROLES, componentTypes, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
3
+ import { b as _objectWithoutPropertiesLoose, a as _extends, _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-5e8399d7.js';
4
+ import { defineComponent, createVNode, createTextVNode, isVNode, mergeProps, h } from 'vue';
5
+ import VueTypes from 'vue-types';
6
+ import { getObjectFromLocalStorage, getClassName, setObjectInLocalStorage, recLookup, updateCustomQuery, updateDefaultQuery, transformTreeListLocalStateIntoQueryComptaibleFormat, isEqual, transformRawTreeListData, setDeep, getComponent as getComponent$1, getOptionsFromQuery, checkValueChange, getQueryOptions, getAggsQuery, updateInternalQuery, isFunction as isFunction$1 } from '@appbaseio/reactivecore/lib/utils/helper';
7
+ import { styled } from '@appbaseio/vue-emotion';
8
+ import { B as Button } from './Button-8178e39a.js';
9
+ import { t as types } from './vueTypes-f503e267.js';
10
+ import { RLConnected as ReactiveList } from './ReactiveList.js';
11
+ import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
12
+ import { h as hasCustomRenderer, a as isFunction, g as getComponent, c as connect } from './index-3af85a74.js';
13
+ import { C as ComponentWrapper } from './ComponentWrapper-90d42a29.js';
14
+ import { P as PreferencesConsumer } from './PreferencesConsumer-a2bd59db.js';
15
+ import { T as Title } from './Title-100fe896.js';
16
+ import { L as ListItem } from './ListItem-beea18db.js';
17
+ import { F as Flex } from './Flex-5d11362e.js';
18
+ import { recordAISessionUsefulness } from '@appbaseio/reactivecore/lib/actions/analytics';
19
+ import ReactiveBase from './ReactiveBase.js';
20
+ import { Remarkable } from 'remarkable';
21
+ import { F as Footer, b as SourceTags, c as SearchSvg, M as Mic, C as Chatbox, d as ChatContainer, e as MessagesContainer, f as Message, T as TypingIndicator, g as TypingDot, A as AIFeedback, h as MessageInputContainer, I as InputGroup, i as MessageInput, j as SendButton, S as SearchBox } from './SearchBox-57e3a0ff.js';
22
+ import { a as IconGroup, I as IconWrapper, b as InputWrapper } from './CancelSvg-5b82ad4f.js';
23
+ import { I as Input } from './Input-cda7f4ad.js';
24
+ import { C as Container } from './Container-e2261542.js';
25
+ import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
26
+ import { replaceDiacritics } from '@appbaseio/reactivecore/lib/utils/suggestions';
27
+ import { C as Checkbox, R as Radio } from './FormControlList-968ff972.js';
28
+ import { s as sanitizeObject } from './utils-badbb2a8.js';
29
+ import { ListConnected as SingleList } from './SingleList.js';
30
+ import { ListConnected as MultiList } from './MultiList.js';
31
+ import types$1 from '@appbaseio/reactivecore/lib/utils/types';
32
+ import { ListConnected as SingleDropdownList } from './SingleDropdownList.js';
33
+ import { ListConnected as MultiDropdownList } from './MultiDropdownList.js';
34
+ import { TBConnected as ToggleButton } from './ToggleButton.js';
35
+ import ReactiveComponent from './ReactiveComponent.js';
36
+ import { RangeConnected as DynamicRangeSlider } from './DynamicRangeSlider.js';
37
+ import { RangeConnected as SingleRange } from './SingleRange.js';
38
+ import { RangeConnected as MultiRange } from './MultiRange.js';
39
+ import { RangeConnected as RangeSlider } from './RangeSlider.js';
40
+ import { RangeConnected as RangeInput } from './RangeInput.js';
41
+ import SelectedFilters from './SelectedFilters.js';
42
+ import ResultCard from './ResultCard.js';
43
+ import ResultList from './ResultList.js';
44
+ import StateProvider from './StateProvider.js';
45
+
46
+ var _excluded = ["_source"];
47
+ function _isSlot(s) {
48
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
49
+ }
50
+ var md = new Remarkable();
51
+ md.set({
52
+ html: true,
53
+ breaks: true,
54
+ xhtmlOut: true,
55
+ linkify: true,
56
+ linkTarget: '_blank'
57
+ });
58
+ var _inputWrapperRef = 'inputWrapperRef';
59
+ var _inputRef = 'inputRef';
60
+ var _errorContainerRef = 'errorContainerRef';
61
+ var AIAnswer = defineComponent({
62
+ name: 'AIAnswer',
63
+ data: function data() {
64
+ var props = this.$props;
65
+ this.__state = {
66
+ messages: [],
67
+ inputMessage: '',
68
+ AISessionId: '',
69
+ error: null,
70
+ sourceDocIds: null,
71
+ initialHits: null,
72
+ isTriggered: false
73
+ };
74
+ this.internalComponent = props.componentId + "__internal";
75
+ return this.__state;
76
+ },
77
+ inject: {
78
+ theme: {
79
+ from: 'theme_reactivesearch'
80
+ }
81
+ },
82
+ created: function created() {
83
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
84
+ this.isTriggered = true;
85
+ } else if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
86
+ this.isTriggered = true;
87
+ if (this.AISessionId) {
88
+ this.handleSendMessage(null, false, '', true);
89
+ }
90
+ }
91
+ },
92
+ computed: {
93
+ hasCustomRenderer: function hasCustomRenderer$1() {
94
+ return hasCustomRenderer(this);
95
+ },
96
+ isLoadingState: function isLoadingState() {
97
+ return this.isAIResponseLoading || this.isLoading;
98
+ },
99
+ shouldShowComponent: function shouldShowComponent() {
100
+ return this.showComponent;
101
+ },
102
+ errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
103
+ return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
104
+ },
105
+ hasTriggered: function hasTriggered() {
106
+ return this.isTriggered;
107
+ }
108
+ },
109
+ props: {
110
+ componentId: types.string.isRequired,
111
+ showVoiceInput: VueTypes.bool.def(false),
112
+ showFeedback: VueTypes.bool.def(true),
113
+ showIcon: VueTypes.bool.def(true),
114
+ onData: types.func,
115
+ innerRef: VueTypes.string.def('AISearchInputField'),
116
+ react: types.react,
117
+ enableAI: VueTypes.bool.def(true),
118
+ AIConfig: types.AIConfig,
119
+ iconPosition: types.iconPosition.def('left'),
120
+ themePreset: types.themePreset,
121
+ theme: types.style,
122
+ icon: types.children,
123
+ iconURL: VueTypes.string.def(''),
124
+ renderMic: types.func,
125
+ getMicInstance: types.func,
126
+ innerClass: types.style,
127
+ placeholder: VueTypes.string.def('Ask a question'),
128
+ title: types.title,
129
+ AIResponse: types.componentObject,
130
+ isAIResponseLoading: VueTypes.bool.def(false),
131
+ AIResponseError: types.componentObject,
132
+ getAIResponse: types.func.isRequired,
133
+ enterButton: types.bool,
134
+ renderEnterButton: types.title,
135
+ showInput: VueTypes.bool.def(true),
136
+ clearSessionOnDestroy: VueTypes.bool.def(true),
137
+ rawData: types.rawData,
138
+ render: types.func,
139
+ onError: types.func,
140
+ renderError: types.title,
141
+ isLoading: types.boolRequired,
142
+ sessionIdFromStore: VueTypes.string,
143
+ showComponent: types.boolRequired,
144
+ componentError: types.componentObject,
145
+ style: types.style,
146
+ showSourceDocuments: VueTypes.bool.def(false),
147
+ renderSourceDocument: types.func,
148
+ onSourceClick: types.func,
149
+ isAITyping: types.boolRequired,
150
+ triggerOn: VueTypes.string.def(AI_TRIGGER_MODES.ALWAYS),
151
+ renderTriggerMessage: types.func
152
+ },
153
+ mounted: function mounted() {},
154
+ watch: {
155
+ AIResponse: function AIResponse(newVal) {
156
+ if (newVal) {
157
+ if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
158
+ this.sourceDocIds = newVal.response.answer.documentIds;
159
+ var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
160
+ if (localCache && localCache.meta && localCache.meta.hits) {
161
+ this.initialHits = localCache.meta.hits;
162
+ }
163
+ }
164
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
165
+ var messagesHistory = newVal.messages,
166
+ response = newVal.response;
167
+ var finalMessages = [];
168
+ if (response && response.error) {
169
+ this.error = {
170
+ message: response.error
171
+ };
172
+ }
173
+ // pushing message history so far
174
+ if (messagesHistory && Array.isArray(messagesHistory)) {
175
+ finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
176
+ return msg.role !== AI_ROLES.SYSTEM;
177
+ }));
178
+ if (finalMessages[0].role === AI_ROLES.USER) {
179
+ finalMessages.shift();
180
+ }
181
+ } else if (response && response.answer && response.answer.text) {
182
+ finalMessages.push({
183
+ role: AI_ROLES.ASSISTANT,
184
+ content: response.answer.text
185
+ });
186
+ if (!this.AISessionId) this.error = {
187
+ message: this.errorMessageForMissingSessionId
188
+ };
189
+ }
190
+ this.messages = finalMessages;
191
+ } else if (!newVal && !this.error) {
192
+ this.messages = [];
193
+ }
194
+ },
195
+ rawData: function rawData(newVal) {
196
+ this.$emit('on-data', {
197
+ data: this.messages,
198
+ rawData: newVal,
199
+ loading: this.$props.isAIResponseLoading || this.$props.isLoading,
200
+ error: this.$props.AIResponseError
201
+ });
202
+ if (newVal && newVal.hits && newVal.hits.hits) {
203
+ this.initialHits = newVal.hits.hits;
204
+ }
205
+ },
206
+ isAIResponseLoading: function isAIResponseLoading(newVal) {
207
+ this.$emit('on-data', {
208
+ data: this.messages,
209
+ rawData: this.$props.rawData,
210
+ loading: newVal || this.isLoading,
211
+ error: this.$props.AIResponseError
212
+ });
213
+ },
214
+ isLoading: function isLoading(newVal) {
215
+ this.$emit('on-data', {
216
+ data: this.messages,
217
+ rawData: this.$props.rawData,
218
+ loading: newVal || this.isAIResponseLoading,
219
+ error: this.$props.AIResponseError
220
+ });
221
+ },
222
+ sessionIdFromStore: function sessionIdFromStore(newVal) {
223
+ if (newVal) {
224
+ this.sessionId = newVal;
225
+ }
226
+ },
227
+ AIResponseError: function AIResponseError(newVal) {
228
+ this.error = newVal;
229
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
230
+ if (this.error && !this.AISessionId) {
231
+ var errorMessage = this.errorMessageForMissingSessionId;
232
+ this.error = {
233
+ message: errorMessage
234
+ };
235
+ console.error(errorMessage);
236
+ }
237
+ this.$emit('on-data', {
238
+ data: this.messages,
239
+ rawData: this.$props.rawData,
240
+ loading: this.isAIResponseLoading || this.isLoading,
241
+ error: newVal
242
+ });
243
+ },
244
+ messages: function messages() {
245
+ this.scrollToBottom();
246
+ },
247
+ componentError: function componentError(newVal) {
248
+ var _this = this;
249
+ if (newVal && newVal._bodyBlob) {
250
+ this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
251
+ if (!this.AISessionId) {
252
+ this.generateNewSessionId();
253
+ }
254
+ newVal._bodyBlob.text().then(function (textData) {
255
+ try {
256
+ var parsedErrorRes = JSON.parse(textData);
257
+ if (parsedErrorRes.error) {
258
+ _this.error = parsedErrorRes.error;
259
+ _this.$emit('on-data', {
260
+ data: _this.messages,
261
+ rawData: _this.$props.rawData,
262
+ loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
263
+ error: parsedErrorRes.error
264
+ });
265
+ }
266
+ } catch (error) {
267
+ console.error('Error parsing component error JSON:', error);
268
+ }
269
+ })["catch"](function (error) {
270
+ console.error('Error reading component error text data:', error);
271
+ });
272
+ }
273
+ },
274
+ showComponent: function showComponent() {
275
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
276
+ this.isTriggered = true;
277
+ }
278
+ },
279
+ dependentComponentValue: function dependentComponentValue(newVal) {
280
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
281
+ this.isTriggered = true;
282
+ if (this.AISessionId) {
283
+ this.handleSendMessage(null, false, '', true);
284
+ }
285
+ } else if (this.hasTriggered && this.$props.triggerOn !== AI_TRIGGER_MODES.ALWAYS) {
286
+ this.isTriggered = false;
287
+ }
288
+ },
289
+ AISessionId: function AISessionId(newVal) {
290
+ if (newVal) {
291
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
292
+ this.handleSendMessage(null, false, '', true);
293
+ }
294
+ }
295
+ },
296
+ triggerOn: function triggerOn(newVal) {
297
+ if (newVal === AI_TRIGGER_MODES.ALWAYS) {
298
+ this.isTriggered = true;
299
+ }
300
+ }
301
+ },
302
+ methods: {
303
+ renderTriggerMessageFunc: function renderTriggerMessageFunc() {
304
+ var triggerOn = this.$props.triggerOn;
305
+ if (this.$props.renderTriggerMessage) {
306
+ return this.$props.renderTriggerMessage;
307
+ }
308
+ if (this.$slots.renderTriggerMessage) {
309
+ return this.$slots.renderTriggerMessage();
310
+ }
311
+ if (triggerOn === AI_TRIGGER_MODES.QUESTION) {
312
+ if (!this.dependentComponentValue.endsWith('?')) {
313
+ return createVNode("span", null, [createVNode("span", {
314
+ "role": "img",
315
+ "aria-label": "bulb"
316
+ }, [createTextVNode("\uD83D\uDCA1")]), createTextVNode("End your question with a question mark (?)")]);
317
+ }
318
+ } else if (triggerOn === AI_TRIGGER_MODES.MANUAL) {
319
+ return createVNode("span", null, [createTextVNode("Click here to ask AI"), ' ', createVNode("span", {
320
+ "role": "img",
321
+ "aria-label": "bulb"
322
+ }, [createTextVNode("\uD83E\uDD16")])]);
323
+ }
324
+ return null;
325
+ },
326
+ handleTriggerClick: function handleTriggerClick() {
327
+ if (this.$props.triggerOn === AI_TRIGGER_MODES.MANUAL) {
328
+ this.handleSendMessage(null, false, '', true);
329
+ this.isTriggered = true;
330
+ }
331
+ },
332
+ getAISourceObjects: function getAISourceObjects() {
333
+ var _this2 = this;
334
+ var sourceObjects = [];
335
+ if (!this.AIResponse) return sourceObjects;
336
+ var docIds = this.sourceDocIds || [];
337
+ if (this.initialHits) {
338
+ docIds.forEach(function (id) {
339
+ var foundSourceObj = _this2.initialHits.find(function (hit) {
340
+ return hit._id === id;
341
+ }) || {};
342
+ if (foundSourceObj) {
343
+ var _foundSourceObj$_sour = foundSourceObj._source,
344
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
345
+ rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded);
346
+ sourceObjects.push(_extends({}, rest, _source));
347
+ }
348
+ });
349
+ } else {
350
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
351
+ return {
352
+ _id: id
353
+ };
354
+ }));
355
+ }
356
+ return sourceObjects;
357
+ },
358
+ renderAIScreenFooter: function renderAIScreenFooter() {
359
+ var _slot2;
360
+ var _this3 = this;
361
+ var _ref = this.$props || {},
362
+ _ref$showSourceDocume = _ref.showSourceDocuments,
363
+ showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
364
+ _ref$onSourceClick = _ref.onSourceClick,
365
+ onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
366
+ renderSourceDocument = _ref.renderSourceDocument;
367
+ var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
368
+ if (this.isLoadingState || this.isAITyping) {
369
+ return null;
370
+ }
371
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
372
+ if (customRenderSourceDoc) {
373
+ return customRenderSourceDoc(sourceObj);
374
+ }
375
+ return sourceObj._id;
376
+ };
377
+ return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? createVNode(Footer, {
378
+ "themePreset": this.$props.themePreset,
379
+ "style": {
380
+ marginTop: '1.5rem',
381
+ background: 'inherit'
382
+ }
383
+ }, {
384
+ "default": function _default() {
385
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot2 = _this3.getAISourceObjects().map(function (el) {
386
+ var _slot;
387
+ return createVNode(Button, {
388
+ "class": "--ai-source-tag " + (getClassName(_this3.$props.innerClass, 'ai-source-tag') || ''),
389
+ "info": true,
390
+ "onClick": function onClick() {
391
+ return onSourceClick && onSourceClick(el);
392
+ },
393
+ "key": el._id
394
+ }, _isSlot(_slot = renderSourceDocumentLabel(el)) ? _slot : {
395
+ "default": function _default() {
396
+ return [_slot];
397
+ }
398
+ });
399
+ })) ? _slot2 : {
400
+ "default": function _default() {
401
+ return [_slot2];
402
+ }
403
+ })];
404
+ }
405
+ }) : null;
406
+ },
407
+ generateNewSessionId: function generateNewSessionId() {
408
+ var _this4 = this;
409
+ var newSessionPromise = this.createAISession();
410
+ newSessionPromise.then(function (res) {
411
+ _this4.AISessionId = res.AIsessionId;
412
+ })["catch"](function (e) {
413
+ console.error(e);
414
+ });
415
+ },
416
+ scrollToBottom: function scrollToBottom() {
417
+ var _this5 = this;
418
+ this.$nextTick(function () {
419
+ var _this5$$refs;
420
+ var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
421
+ if (messageContainer && messageContainer.$el) {
422
+ messageContainer.$el.scrollTo({
423
+ top: messageContainer.$el.scrollHeight,
424
+ behavior: 'smooth'
425
+ });
426
+ }
427
+ });
428
+ },
429
+ handleMessageInputChange: function handleMessageInputChange(e) {
430
+ this.inputMessage = e.target.value;
431
+ this.handleTextAreaHeightChange();
432
+ },
433
+ handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
434
+ if (isRetry === void 0) {
435
+ isRetry = false;
436
+ }
437
+ if (text === void 0) {
438
+ text = this.inputMessage;
439
+ }
440
+ if (fetchMeta === void 0) {
441
+ fetchMeta = false;
442
+ }
443
+ if (typeof e === 'object' && e !== null) e.preventDefault();
444
+ if (text.trim() || !text && !e) {
445
+ if (this.isLoadingState) {
446
+ return;
447
+ }
448
+ if (this.AISessionId) {
449
+ if (!isRetry) {
450
+ var finalMessages = [].concat(this.messages);
451
+ if (text) {
452
+ finalMessages.push({
453
+ content: text,
454
+ role: AI_ROLES.USER
455
+ });
456
+ }
457
+ this.messages = [].concat(finalMessages);
458
+ }
459
+ this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
460
+ } else {
461
+ console.error(this.errorMessageForMissingSessionId);
462
+ this.error = {
463
+ message: "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Trying reloading the App."
464
+ };
465
+ }
466
+ this.inputMessage = '';
467
+ }
468
+ },
469
+ handleRetryRequest: function handleRetryRequest() {
470
+ if (this.messages && !this.isLoadingState) {
471
+ var _this$messages;
472
+ var lastUserRequestMessage = (_this$messages = this.messages[this.messages.length - 1]) == null ? void 0 : _this$messages.content;
473
+ if (this.AISessionId) {
474
+ this.getAIResponse(this.AISessionId, this.componentId, lastUserRequestMessage);
475
+ this.inputMessage = '';
476
+ } else {
477
+ console.error("AISessionId for " + this.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.");
478
+ }
479
+ }
480
+ },
481
+ renderErrorComponent: function renderErrorComponent() {
482
+ var renderError = this.$slots.renderError || this.$props.renderError;
483
+ if (this.error && !this.isLoadingState) {
484
+ var _this$error, _this$error2;
485
+ if (renderError) {
486
+ return createVNode("div", {
487
+ "ref": _errorContainerRef,
488
+ "class": "--ai-answer-error-container " + (getClassName(this.$props.innerClass, 'ai-error') || '')
489
+ }, [isFunction(renderError) ? renderError(this.error, this.handleRetryRequest) : renderError]);
490
+ }
491
+ return createVNode("div", {
492
+ "ref": _errorContainerRef,
493
+ "class": "--ai-answer-error-container " + (getClassName(this.$props.innerClass, 'ai-error') || '')
494
+ }, [createVNode("div", {
495
+ "class": "--default-error-element"
496
+ }, [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, {
497
+ "primary": true,
498
+ "onClick": this.handleRetryRequest
499
+ }, {
500
+ "default": function _default() {
501
+ return [createTextVNode("Try again")];
502
+ }
503
+ })])]);
504
+ }
505
+ return null;
506
+ },
507
+ handleKeyPress: function handleKeyPress(e) {
508
+ if (e.key === 'Enter') {
509
+ this.handleSendMessage(e);
510
+ this.inputMessage = '';
511
+ }
512
+ },
513
+ renderIcon: function renderIcon() {
514
+ if (this.$props.showIcon) {
515
+ if (this.$props.icon) {
516
+ return this.$props.icon;
517
+ }
518
+ if (this.$slots.icon) {
519
+ return this.$slots.icon();
520
+ }
521
+ if (this.$props.iconURL) {
522
+ return createVNode("img", {
523
+ "style": {
524
+ maxHeight: '25px'
525
+ },
526
+ "src": this.$props.iconURL,
527
+ "alt": "search-icon"
528
+ }, null);
529
+ }
530
+ return createVNode(SearchSvg, null, null);
531
+ }
532
+ return null;
533
+ },
534
+ shouldMicRender: function shouldMicRender(showVoiceSearch) {
535
+ // checks for SSR
536
+ if (typeof window === 'undefined') return false;
537
+ return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
538
+ },
539
+ handleVoiceResults: function handleVoiceResults(_ref2) {
540
+ var results = _ref2.results;
541
+ if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
542
+ this.handleSendMessage(null, false, results[0][0].transcript.trim());
543
+ }
544
+ },
545
+ renderIcons: function renderIcons() {
546
+ var _this6 = this;
547
+ var _slot3, _slot4;
548
+ var _this$$props = this.$props,
549
+ getMicInstance = _this$$props.getMicInstance,
550
+ showVoiceInput = _this$$props.showVoiceInput,
551
+ iconPosition = _this$$props.iconPosition,
552
+ innerClass = _this$$props.innerClass;
553
+ var renderMic = this.$slots.renderMic || this.$props.renderMic;
554
+ return createVNode("div", null, [createVNode(IconGroup, {
555
+ "enableAI": true,
556
+ "groupPosition": "right",
557
+ "positionType": "absolute"
558
+ }, {
559
+ "default": function _default() {
560
+ return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && createVNode(Mic, {
561
+ "getInstance": getMicInstance,
562
+ "render": renderMic,
563
+ "handleResult": _this6.handleVoiceResults,
564
+ "class": getClassName(innerClass, 'ai-search-mic') || null
565
+ }, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot(_slot3 = _this6.renderIcon()) ? _slot3 : {
566
+ "default": function _default() {
567
+ return [_slot3];
568
+ }
569
+ })];
570
+ }
571
+ }), createVNode(IconGroup, {
572
+ "enableAI": true,
573
+ "groupPosition": "left",
574
+ "positionType": "absolute"
575
+ }, {
576
+ "default": function _default() {
577
+ return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot(_slot4 = _this6.renderIcon()) ? _slot4 : {
578
+ "default": function _default() {
579
+ return [_slot4];
580
+ }
581
+ })];
582
+ }
583
+ })]);
584
+ },
585
+ enterButtonOnClick: function enterButtonOnClick(e) {
586
+ this.handleSendMessage(e);
587
+ },
588
+ renderEnterButtonElement: function renderEnterButtonElement() {
589
+ var _this7 = this;
590
+ var _this$$props2 = this.$props,
591
+ enterButton = _this$$props2.enterButton,
592
+ innerClass = _this$$props2.innerClass;
593
+ var renderEnterButton = this.$slots.renderEnterButton;
594
+ if (enterButton) {
595
+ var getEnterButtonMarkup = function getEnterButtonMarkup() {
596
+ if (renderEnterButton) {
597
+ return renderEnterButton(_this7.enterButtonOnClick);
598
+ }
599
+ return createVNode(SendButton, {
600
+ "primary": true,
601
+ "type": "submit",
602
+ "tabIndex": 0,
603
+ "onClick": _this7.handleSendMessage,
604
+ "onKeyPress": _this7.handleKeyPress,
605
+ "class": "ask-btn " + getClassName(innerClass, 'ai-enter-button'),
606
+ "disabled": _this7.isLoadingState || !_this7.AISessionId
607
+ }, {
608
+ "default": function _default() {
609
+ return [createTextVNode("Send")];
610
+ }
611
+ });
612
+ };
613
+ return createVNode("div", {
614
+ "class": "ai-enter-button-wrapper"
615
+ }, [getEnterButtonMarkup()]);
616
+ }
617
+ return null;
618
+ },
619
+ getComponent: function getComponent$1() {
620
+ var data = {
621
+ error: this.AIResponseError,
622
+ loading: this.isAIResponseLoading,
623
+ data: this.messages,
624
+ rawData: this.rawData
625
+ };
626
+ return getComponent(data, this);
627
+ },
628
+ handleTextAreaHeightChange: function handleTextAreaHeightChange() {
629
+ var _this$$refs, _this$$refs2, _this$$refs3;
630
+ var textArea = (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs.$el;
631
+ var inputWrapper = (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2.$el;
632
+ var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
633
+ if (textArea) {
634
+ textArea.style.height = '42px';
635
+ var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
636
+ var maxHeight = lineHeight * 11; // max height for 10 lines
637
+ var height = Math.min(textArea.scrollHeight, maxHeight);
638
+ textArea.style.height = height + "px";
639
+ textArea.style.overflowY = height === maxHeight ? 'auto' : 'hidden';
640
+ // wrapper around input/ textarea
641
+ inputWrapper.style.height = height + "px";
642
+ // adjust error-container
643
+
644
+ if (errorContainer) {
645
+ errorContainer.style.bottom = height + "px";
646
+ }
647
+ this.$forceUpdate();
648
+ }
649
+ },
650
+ getTitle: function getTitle() {
651
+ var _this8 = this;
652
+ var hasTitle = this.$props.title || this.$slots.title || null;
653
+ if (hasTitle) {
654
+ return createVNode(Title, {
655
+ "class": getClassName(this.$props.innerClass, 'ai-title') || null
656
+ }, {
657
+ "default": function _default() {
658
+ return [_this8.$props.title || _this8.$slots.title()];
659
+ }
660
+ });
661
+ }
662
+ return null;
663
+ }
664
+ },
665
+ beforeUnmount: function beforeUnmount() {
666
+ if (this.$props.clearSessionOnDestroy) {
667
+ // cleanup logic
668
+ // final Object to store in local storage cache
669
+ var finalCacheObj = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {};
670
+ // delete current component's cache
671
+ delete finalCacheObj[this.$props.componentId];
672
+ // update local cache
673
+ setObjectInLocalStorage(AI_LOCAL_CACHE_KEY, finalCacheObj);
674
+ }
675
+ },
676
+ render: function render() {
677
+ var _slot5;
678
+ var _this9 = this;
679
+ var props = this.$props;
680
+ if (!this.shouldShowComponent) {
681
+ return null;
682
+ }
683
+ if (!this.isTriggered) {
684
+ return createVNode(Chatbox, {
685
+ "style": props.style || {}
686
+ }, {
687
+ "default": function _default() {
688
+ return [_this9.getTitle(), createVNode("div", {
689
+ "class": "--trigger-message-wrapper",
690
+ "onClick": _this9.handleTriggerClick,
691
+ "aria-hidden": "true"
692
+ }, [_this9.renderTriggerMessageFunc()])];
693
+ }
694
+ });
695
+ }
696
+ return createVNode(Chatbox, {
697
+ "style": props.style || {}
698
+ }, {
699
+ "default": function _default() {
700
+ return [_this9.getTitle(), createVNode(ChatContainer, {
701
+ "class": "--ai-chat-container",
702
+ "theme": props.theme,
703
+ "showInput": props.showInput
704
+ }, {
705
+ "default": function _default() {
706
+ return [_this9.hasCustomRenderer && createVNode(MessagesContainer, {
707
+ "themePreset": _this9.themePreset,
708
+ "theme": props.theme,
709
+ "ref": _this9.$props.innerRef,
710
+ "class": "--ai-message-container " + (getClassName(props.innerClass, 'ai-message-container') || '')
711
+ }, _isSlot(_slot5 = _this9.getComponent()) ? _slot5 : {
712
+ "default": function _default() {
713
+ return [_slot5];
714
+ }
715
+ }), !_this9.hasCustomRenderer && createVNode(MessagesContainer, {
716
+ "themePreset": _this9.themePreset,
717
+ "theme": props.theme,
718
+ "ref": _this9.$props.innerRef,
719
+ "class": "--ai-message-container " + (getClassName(props.innerClass, 'ai-message-container') || '')
720
+ }, {
721
+ "default": function _default() {
722
+ return [_this9.messages.map(function (message, index) {
723
+ return createVNode(Message, {
724
+ "key": index,
725
+ "isSender": message.role === AI_ROLES.USER,
726
+ "innerHTML": md.render(message.content),
727
+ "themePreset": _this9.themePreset,
728
+ "theme": props.theme,
729
+ "class": "--ai-answer-message " + (getClassName(props.innerClass, 'ai-message') || '')
730
+ }, null);
731
+ }), _this9.isLoadingState && createVNode(Message, {
732
+ "themePreset": _this9.themePreset,
733
+ "theme": props.theme,
734
+ "isSender": false,
735
+ "class": "--ai-answer-message " + (getClassName(props.innerClass, 'ai-message') || null)
736
+ }, {
737
+ "default": function _default() {
738
+ return [createVNode(TypingIndicator, null, {
739
+ "default": function _default() {
740
+ return [createVNode(TypingDot, {
741
+ "themePreset": _this9.themePreset
742
+ }, null), createVNode(TypingDot, {
743
+ "themePreset": _this9.themePreset
744
+ }, null), createVNode(TypingDot, {
745
+ "themePreset": _this9.themePreset
746
+ }, null)];
747
+ }
748
+ })];
749
+ }
750
+ })];
751
+ }
752
+ }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && createVNode("div", {
753
+ "class": "--ai-answer-feedback-container " + (getClassName(props.innerClass, 'ai-feedback') || '')
754
+ }, [createVNode(AIFeedback, {
755
+ "hideUI": _this9.isLoadingState || !_this9.sessionId,
756
+ "key": _this9.sessionId,
757
+ "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
758
+ _this9.trackUsefullness(_this9.sessionId, {
759
+ useful: useful,
760
+ reason: reason
761
+ });
762
+ }
763
+ }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && createVNode(MessageInputContainer, {
764
+ "class": "--ai-input-container",
765
+ "onSubmit": _this9.handleSendMessage
766
+ }, {
767
+ "default": function _default() {
768
+ return [createVNode(InputGroup, {
769
+ "enableAI": true,
770
+ "isOpen": false
771
+ }, {
772
+ "default": function _default() {
773
+ return [createVNode(InputWrapper, {
774
+ "ref": _inputWrapperRef
775
+ }, {
776
+ "default": function _default() {
777
+ return [createVNode(MessageInput, {
778
+ "ref": _inputRef,
779
+ "placeholder": props.placeholder,
780
+ "enterButton": props.enterButton,
781
+ "value": _this9.inputMessage,
782
+ "onInput": _this9.handleMessageInputChange,
783
+ "id": props.componentId + "-ai-input",
784
+ "showIcon": props.showIcon,
785
+ "iconPosition": props.iconPosition,
786
+ "themePreset": _this9.themePreset,
787
+ "disabled": _this9.isLoadingState || !_this9.AISessionId,
788
+ "class": getClassName(props.innerClass, 'ai-input') || null
789
+ }, null), ' ', _this9.renderIcons()];
790
+ }
791
+ })];
792
+ }
793
+ }), _this9.renderEnterButtonElement()];
794
+ }
795
+ }), ' '];
796
+ }
797
+ })];
798
+ }
799
+ });
800
+ }
801
+ });
802
+ AIAnswer.hasInternalComponent = function () {
803
+ return true;
804
+ };
805
+ var mapStateToProps = function mapStateToProps(state, props) {
806
+ var dependencyComponent = Object.values(props.react)[0];
807
+ if (Array.isArray(dependencyComponent)) {
808
+ // eslint-disable-next-line prefer-destructuring
809
+ dependencyComponent = dependencyComponent[0];
810
+ }
811
+ var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
812
+ var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
813
+ return {
814
+ showComponent: showComponent,
815
+ dependentComponentValue: dependentComponentValue,
816
+ AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
817
+ isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
818
+ AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
819
+ rawData: state.rawData[props.componentId],
820
+ themePreset: state.config.themePreset,
821
+ isLoading: state.isLoading[props.componentId] || false,
822
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
823
+ componentError: state.error[props.componentId] || null,
824
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
825
+ };
826
+ };
827
+ var mapDispatchToProps = {
828
+ getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
829
+ if (shouldFetchMeta === void 0) {
830
+ shouldFetchMeta = false;
831
+ }
832
+ return fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
833
+ },
834
+ trackUsefullness: recordAISessionUsefulness,
835
+ createAISession: createAISession
836
+ };
837
+ var AIConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(AIAnswer), {
838
+ componentType: componentTypes.AIAnswer,
839
+ internalComponent: true
840
+ }));
841
+ AIConnected.name = AIAnswer.name;
842
+ AIConnected.hasInternalComponent = AIAnswer.hasInternalComponent;
843
+ AIConnected.install = function (Vue) {
844
+ Vue.component(AIConnected.name, AIConnected);
845
+ };
846
+ // Add componentType for SSR
847
+ AIConnected.componentType = componentTypes.AIAnswer;
848
+
849
+ var _templateObject, _templateObject2;
850
+ var HierarchicalMenuList = styled('ul')(_templateObject || (_templateObject = _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"])));
851
+ var HierarchicalMenuListItem = styled('li')(_templateObject2 || (_templateObject2 = _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) {
852
+ return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
853
+ });
854
+
855
+ var HierarchicalMenuListItemComponent = {
856
+ name: 'HierarchicalMenuListItemComponent',
857
+ data: function data() {
858
+ return {
859
+ isExpanded: false,
860
+ newParentPath: ''
861
+ };
862
+ },
863
+ created: function created() {
864
+ var listItemLabel = this.listItem.key;
865
+ var newParentPath = listItemLabel;
866
+ if (this.parentPath) {
867
+ newParentPath = "" + this.parentPath + TREELIST_VALUES_PATH_SEPARATOR + listItemLabel;
868
+ }
869
+ this.newParentPath = newParentPath;
870
+ this.isExpanded = !!recLookup(this.selectedValues, newParentPath, TREELIST_VALUES_PATH_SEPARATOR);
871
+ },
872
+ watch: {
873
+ listItem: function listItem(newVal) {
874
+ if (newVal.initiallyExpanded) {
875
+ this.isExpanded = newVal.initiallyExpanded;
876
+ }
877
+ },
878
+ selectedValues: function selectedValues(newVal) {
879
+ this.isExpanded = !!recLookup(newVal, this.newParentPath, TREELIST_VALUES_PATH_SEPARATOR);
880
+ }
881
+ },
882
+ props: {
883
+ parentPath: types$1.string,
884
+ selectedValues: types$1.rawData,
885
+ mode: types$1.string,
886
+ searchTerm: types$1.string,
887
+ listItem: types$1.rawData,
888
+ showLine: types$1.bool,
889
+ renderItem: types$1.func,
890
+ handleListItemClick: types$1.func,
891
+ renderSwitcherIcon: types$1.func,
892
+ showCheckbox: VueTypes.bool,
893
+ innerClass: types$1.style,
894
+ showRadio: VueTypes.bool,
895
+ renderIcon: types$1.func,
896
+ showCount: VueTypes.bool,
897
+ showSwitcherIcon: types$1.bool,
898
+ switcherIcon: types$1.children
899
+ },
900
+ render: function render() {
901
+ var _this = this;
902
+ var _this$$props = this.$props,
903
+ selectedValues = _this$$props.selectedValues,
904
+ mode = _this$$props.mode,
905
+ searchTerm = _this$$props.searchTerm,
906
+ listItem = _this$$props.listItem,
907
+ parentPath = _this$$props.parentPath,
908
+ showLine = _this$$props.showLine,
909
+ renderItem = _this$$props.renderItem,
910
+ handleListItemClick = _this$$props.handleListItemClick,
911
+ showCheckbox = _this$$props.showCheckbox,
912
+ innerClass = _this$$props.innerClass,
913
+ showRadio = _this$$props.showRadio,
914
+ renderIcon = _this$$props.renderIcon,
915
+ showCount = _this$$props.showCount,
916
+ showSwitcherIcon = _this$$props.showSwitcherIcon;
917
+ if (!(listItem instanceof Object) || Object.keys(listItem).length === 0) {
918
+ return null;
919
+ }
920
+ var listItemLabel = listItem.key;
921
+ var listItemCount = listItem.count;
922
+ var isLeafNode = !(Array.isArray(listItem.list) && listItem.list.length > 0);
923
+ var renderSwitcherIcon = function renderSwitcherIcon(isExpandedProp) {
924
+ if (showSwitcherIcon === false) {
925
+ return null;
926
+ }
927
+ var switcherIcon = _this.$props.switcherIcon;
928
+ if (switcherIcon) return switcherIcon(isExpandedProp);
929
+ return (
930
+ /* eslint-disable jsx-a11y/click-events-have-key-events
931
+ , jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-tabindex */
932
+ createVNode("span", {
933
+ "tabIndex": "0",
934
+ "onClick": function onClick(e) {
935
+ e.stopPropagation();
936
+ _this.isExpanded = !_this.isExpanded;
937
+ },
938
+ "class": "--switcher-icon"
939
+ }, [createTextVNode("\u27A4")])
940
+ );
941
+ };
942
+ var isSelected = false;
943
+ if (mode === 'single') {
944
+ if (recLookup(selectedValues, this.newParentPath, TREELIST_VALUES_PATH_SEPARATOR) === true) {
945
+ isSelected = true;
946
+ }
947
+ } else {
948
+ isSelected = !!recLookup(selectedValues, this.newParentPath, TREELIST_VALUES_PATH_SEPARATOR);
949
+ }
950
+ return createVNode(HierarchicalMenuListItem, {
951
+ "class": (isSelected ? '-selected-item' : '') + " " + (this.isExpanded ? '-expanded-item' : ''),
952
+ "key": this.newParentPath,
953
+ "showLine": showLine
954
+ }, {
955
+ "default": function _default() {
956
+ return [createVNode(ListItem, {
957
+ "isTreeListItem": true,
958
+ "onClick": function onClick() {
959
+ handleListItemClick(listItemLabel, parentPath);
960
+ },
961
+ "style": {
962
+ textDecoration: 'none'
963
+ }
964
+ }, {
965
+ "default": function _default() {
966
+ return [renderItem ? renderItem(listItemLabel, listItemCount, isSelected) : createVNode(Flex, {
967
+ "alignItems": "center",
968
+ "gap": "5px"
969
+ }, {
970
+ "default": function _default() {
971
+ return [!isLeafNode && renderSwitcherIcon(isSelected), mode === 'multiple' && showCheckbox && createVNode(Flex, {
972
+ "alignItems": "center",
973
+ "gap": "5px"
974
+ }, {
975
+ "default": function _default() {
976
+ return [createVNode(Checkbox, {
977
+ "type": "checkbox",
978
+ "class": getClassName(innerClass, 'checkbox') || null,
979
+ "checked": isSelected,
980
+ "id": listItemLabel + "-checkbox-" + _this.newParentPath,
981
+ "name": listItemLabel + "-checkbox-" + _this.newParentPath,
982
+ "show": true,
983
+ "readOnly": true
984
+ }, null), createVNode("label", {
985
+ "style": {
986
+ width: '26px',
987
+ marginTop: 0,
988
+ marginBottom: 0,
989
+ marginRight: '-9px',
990
+ left: '-3px'
991
+ },
992
+ "htmlFor": listItemLabel + "-checkbox-" + _this.newParentPath,
993
+ "onClick": function onClick(e) {
994
+ e.stopPropagation();
995
+ }
996
+ }, null)];
997
+ }
998
+ }), mode === 'single' && showRadio && createVNode(Flex, {
999
+ "alignItems": "center",
1000
+ "gap": "5px"
1001
+ }, {
1002
+ "default": function _default() {
1003
+ return [createVNode(Radio, {
1004
+ "checked": isSelected,
1005
+ "class": getClassName(innerClass, 'radio') || null,
1006
+ "id": listItemLabel + "-radio-" + _this.newParentPath,
1007
+ "name": listItemLabel + "-radio-" + _this.newParentPath,
1008
+ "show": true,
1009
+ "readOnly": true,
1010
+ "type": "radio"
1011
+ }, null), createVNode("label", {
1012
+ "style": {
1013
+ width: '26px',
1014
+ marginTop: 0,
1015
+ marginBottom: 0,
1016
+ marginRight: '-9px',
1017
+ left: '-3px'
1018
+ },
1019
+ "htmlFor": listItemLabel + "-radio-" + _this.newParentPath,
1020
+ "onClick": function onClick(e) {
1021
+ e.stopPropagation();
1022
+ }
1023
+ }, null)];
1024
+ }
1025
+ }), ' ', renderIcon(isLeafNode), createVNode("div", {
1026
+ "class": "--list-item-label-count-wrapper"
1027
+ }, [createVNode("span", {
1028
+ "class": "--list-item-label " + (getClassName(innerClass, 'label') || '')
1029
+ }, [listItemLabel]), showCount && createVNode("span", {
1030
+ "class": "--list-item-count " + (getClassName(innerClass, 'count') || '')
1031
+ }, [listItemCount])])];
1032
+ }
1033
+ })];
1034
+ }
1035
+ }), isLeafNode === false && createVNode("div", {
1036
+ "class": "--list-child " + (showSwitcherIcon ? ' --show-switcher-icon' : '')
1037
+ }, [createVNode(HierarchicalMenuComponent, {
1038
+ "key": _this.newParentPath + "-" + listItemLabel + "-" + listItemCount,
1039
+ "listArray": listItem.list,
1040
+ "parentPath": _this.newParentPath,
1041
+ "isExpanded": _this.isExpanded,
1042
+ "listItemProps": {
1043
+ mode: mode,
1044
+ selectedValues: selectedValues,
1045
+ searchTerm: searchTerm,
1046
+ showLine: showLine,
1047
+ renderItem: renderItem,
1048
+ handleListItemClick: handleListItemClick,
1049
+ renderSwitcherIcon: renderSwitcherIcon,
1050
+ showCheckbox: showCheckbox,
1051
+ innerClass: innerClass,
1052
+ showRadio: showRadio,
1053
+ renderIcon: renderIcon,
1054
+ showCount: showCount,
1055
+ showSwitcherIcon: showSwitcherIcon,
1056
+ switcherIcon: _this.$props.switcherIcon
1057
+ }
1058
+ }, null)])];
1059
+ }
1060
+ });
1061
+ }
1062
+ };
1063
+
1064
+ function _isSlot$1(s) {
1065
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
1066
+ }
1067
+ var HierarchicalMenuComponent = {
1068
+ name: 'HierarchicalMenuComponent',
1069
+ props: {
1070
+ listArray: VueTypes.arrayOf(VueTypes.object),
1071
+ // array of objects
1072
+ parentPath: VueTypes.string.def(''),
1073
+ isExpanded: VueTypes.bool.def(false),
1074
+ listItemProps: types$1.rawData
1075
+ },
1076
+ render: function render() {
1077
+ var _slot;
1078
+ var _this$$props = this.$props,
1079
+ listArray = _this$$props.listArray,
1080
+ isExpanded = _this$$props.isExpanded,
1081
+ parentPath = _this$$props.parentPath,
1082
+ listItemProps = _this$$props.listItemProps;
1083
+ if (!Array.isArray(listArray) || listArray.length === 0) {
1084
+ return null;
1085
+ }
1086
+ return createVNode(HierarchicalMenuList, {
1087
+ "class": "" + (isExpanded ? '--open' : ''),
1088
+ "isSelected": isExpanded
1089
+ }, _isSlot$1(_slot = listArray.map(function (listItem) {
1090
+ return createVNode(HierarchicalMenuListItemComponent, mergeProps({
1091
+ "key": parentPath + "__" + JSON.stringify(listItem),
1092
+ "parentPath": parentPath,
1093
+ "listItem": listItem
1094
+ }, listItemProps), null);
1095
+ })) ? _slot : {
1096
+ "default": function _default() {
1097
+ return [_slot];
1098
+ }
1099
+ });
1100
+ }
1101
+ };
1102
+
1103
+ function _isSlot$2(s) {
1104
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
1105
+ }
1106
+ var updateQueryAction = Actions.updateQuery,
1107
+ setQueryOptions = Actions.setQueryOptions;
1108
+ var transformValueIntoLocalState = function transformValueIntoLocalState(valueArray) {
1109
+ var valueToSet = {};
1110
+ if (valueArray.length) {
1111
+ var newSelectedValues = {};
1112
+ valueArray.forEach(function (valueItem) {
1113
+ setDeep(newSelectedValues, valueItem.split(' > '), !recLookup(newSelectedValues, valueItem.split(' > '), TREELIST_VALUES_PATH_SEPARATOR), true);
1114
+ });
1115
+ valueToSet = newSelectedValues;
1116
+ }
1117
+ return valueToSet;
1118
+ };
1119
+ var TreeList = {
1120
+ name: 'TreeList',
1121
+ props: {
1122
+ selectedValue: types.selectedValue,
1123
+ error: types.title,
1124
+ rawData: types.rawData,
1125
+ aggregationData: types.rawData,
1126
+ themePreset: types.themePreset,
1127
+ updateQueryAction: types.funcRequired,
1128
+ setQueryOptions: types.funcRequired,
1129
+ // component props
1130
+ componentId: types.string.isRequired,
1131
+ className: types.string,
1132
+ style: types.style,
1133
+ showRadio: VueTypes.bool.def(false),
1134
+ showCheckbox: types.bool.def(false),
1135
+ mode: VueTypes.oneOf(['single', 'multiple']).def('multiple'),
1136
+ showCount: VueTypes.bool.def(false),
1137
+ showSearch: VueTypes.bool.def(false),
1138
+ showIcon: VueTypes.bool.def(false),
1139
+ icon: types.children,
1140
+ showLeafIcon: VueTypes.bool.def(false),
1141
+ leafIcon: types.children,
1142
+ showLine: VueTypes.bool.def(false),
1143
+ switcherIcon: types.func,
1144
+ render: types.func,
1145
+ renderItem: types.func,
1146
+ innerClass: types.style,
1147
+ placeholder: types.string,
1148
+ title: types.title,
1149
+ isLoading: types.bool,
1150
+ dataField: types.stringArray.isRequired,
1151
+ onQueryChange: types.func,
1152
+ defaultValue: types.stringArray,
1153
+ value: types.stringArray,
1154
+ customQuery: types.func,
1155
+ defaultQuery: types.func,
1156
+ enableAppbase: types.bool,
1157
+ index: types.string,
1158
+ showFilter: types.bool,
1159
+ URLParams: types.bool,
1160
+ filterLabel: types.string,
1161
+ onChange: types.func,
1162
+ onValueChange: types.func,
1163
+ beforeValueChange: types.func,
1164
+ sortBy: types.sortByWithCount.def('count'),
1165
+ onError: types.func,
1166
+ showSwitcherIcon: types.bool.def(true),
1167
+ renderError: types.title,
1168
+ renderNoResults: types.func,
1169
+ loader: types.title,
1170
+ aggergationSize: types.number,
1171
+ endpoint: types.endpoint,
1172
+ queryFormat: types.queryFormatSearch.def('or'),
1173
+ size: types.number.def(100),
1174
+ nestedField: types.string,
1175
+ react: types.react,
1176
+ transformData: types.func,
1177
+ selectAllLabel: types.string,
1178
+ showMissing: VueTypes.bool.def(false),
1179
+ missingLabel: VueTypes.string.def('N/A')
1180
+ },
1181
+ data: function data() {
1182
+ var props = this.$props;
1183
+ this.__state = {
1184
+ selectedValues: {},
1185
+ searchTerm: '',
1186
+ aggregationData: []
1187
+ };
1188
+ this.internalComponent = props.componentId + "__internal";
1189
+ return this.__state;
1190
+ },
1191
+ created: function created() {
1192
+ var props = this.$props;
1193
+ var componentId = props.componentId;
1194
+ var defaultValue = this.defaultValue || this.value;
1195
+ var currentValueArray = this.selectedValue || defaultValue || [];
1196
+ // update local state for selected values
1197
+ if (currentValueArray.length) {
1198
+ var newSelectedValues = transformValueIntoLocalState(currentValueArray);
1199
+ this.setValue(newSelectedValues, true);
1200
+ }
1201
+
1202
+ // Set custom and default queries in store
1203
+ updateCustomQuery(componentId, props, currentValueArray);
1204
+ updateDefaultQuery(componentId, props, currentValueArray);
1205
+ this.updateQueryOptions();
1206
+ },
1207
+ mounted: function mounted() {
1208
+ var _this$$props = this.$props,
1209
+ enableAppbase = _this$$props.enableAppbase,
1210
+ index = _this$$props.index;
1211
+ if (!enableAppbase && index) {
1212
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
1213
+ }
1214
+ },
1215
+ watch: {
1216
+ defaultQuery: function defaultQuery() {
1217
+ this.updateDefaultQuery();
1218
+ this.updateQuery([]);
1219
+ },
1220
+ customQuery: function customQuery() {
1221
+ var valueArray = transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
1222
+ this.updateQuery(valueArray);
1223
+ },
1224
+ sortBy: function sortBy() {
1225
+ this.updateQueryOptions();
1226
+ },
1227
+ dataField: function dataField() {
1228
+ var valueArray = transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
1229
+ this.updateQueryOptions();
1230
+ this.updateQuery(valueArray);
1231
+ },
1232
+ value: function value(newVal, oldVal) {
1233
+ if (!isEqual(newVal, oldVal)) {
1234
+ this.setValue(newVal);
1235
+ }
1236
+ },
1237
+ selectedValue: function selectedValue(newVal) {
1238
+ if (!isEqual(transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues), newVal)) {
1239
+ var _this$$props2 = this.$props,
1240
+ value = _this$$props2.value,
1241
+ onChange = _this$$props2.onChange;
1242
+ var valueToSet = [];
1243
+ if (Array.isArray(newVal) && newVal.length) {
1244
+ valueToSet = newVal;
1245
+ }
1246
+ if (value === undefined) {
1247
+ this.setValue(valueToSet);
1248
+ } else if (onChange && !isEqual(value, valueToSet)) {
1249
+ onChange(valueToSet);
1250
+ }
1251
+ }
1252
+ },
1253
+ aggregationData: function aggregationData(newVal, oldVal) {
1254
+ if (newVal && !isEqual(newVal, oldVal)) {
1255
+ this.$data.aggregationData = newVal;
1256
+ }
1257
+ }
1258
+ },
1259
+ computed: {
1260
+ hasCustomRenderer: function hasCustomRenderer$1() {
1261
+ return hasCustomRenderer(this);
1262
+ }
1263
+ },
1264
+ methods: {
1265
+ renderIcon: function renderIcon(isLeafNode) {
1266
+ var _this$$props3 = this.$props,
1267
+ showIcon = _this$$props3.showIcon,
1268
+ showLeafIcon = _this$$props3.showLeafIcon,
1269
+ icon = _this$$props3.icon;
1270
+ if (isLeafNode) {
1271
+ if (!showLeafIcon) return null;
1272
+ var _ref = this.$slots || this.$props,
1273
+ leafIcon = _ref.leafIcon;
1274
+ if (leafIcon) return leafIcon();
1275
+ return createVNode("span", {
1276
+ "role": "img",
1277
+ "aria-label": "file",
1278
+ "class": "--leaf-icon"
1279
+ }, [createVNode("svg", {
1280
+ "viewBox": "64 64 896 896",
1281
+ "focusable": "false",
1282
+ "data-icon": "file",
1283
+ "width": "1em",
1284
+ "height": "1em",
1285
+ "fill": "currentColor",
1286
+ "aria-hidden": "true"
1287
+ }, [createVNode("path", {
1288
+ "d": "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"
1289
+ }, null)])]);
1290
+ }
1291
+ if (!showIcon) return null;
1292
+ if (icon) {
1293
+ return icon;
1294
+ }
1295
+ if (this.$slots.icon) {
1296
+ return this.$slots.icon();
1297
+ }
1298
+ return createVNode("span", {
1299
+ "role": "img",
1300
+ "aria-label": "folder-open",
1301
+ "class": "--folder-icon"
1302
+ }, [createVNode("svg", {
1303
+ "viewBox": "64 64 896 896",
1304
+ "focusable": "false",
1305
+ "data-icon": "folder-open",
1306
+ "width": "1em",
1307
+ "height": "1em",
1308
+ "fill": "currentColor",
1309
+ "aria-hidden": "true"
1310
+ }, [createVNode("path", {
1311
+ "d": "M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"
1312
+ }, null)])]);
1313
+ },
1314
+ getTransformedData: function getTransformedData() {
1315
+ var _this$$props4 = this.$props,
1316
+ dataField = _this$$props4.dataField,
1317
+ showSearch = _this$$props4.showSearch;
1318
+ var transformedData = transformRawTreeListData(this.$data.aggregationData, dataField);
1319
+ var filteredData = [];
1320
+ if (showSearch && this.searchTerm) {
1321
+ filteredData = this.filterDataBasedOnSearchTerm(transformedData, '');
1322
+ }
1323
+ return filteredData.length ? filteredData : transformedData;
1324
+ },
1325
+ handleInputChange: function handleInputChange(e) {
1326
+ var value = e.target.value;
1327
+ this.searchTerm = value;
1328
+ },
1329
+ renderSearch: function renderSearch() {
1330
+ var _this$$props5 = this.$props,
1331
+ showSearch = _this$$props5.showSearch,
1332
+ innerClass = _this$$props5.innerClass,
1333
+ placeholder = _this$$props5.placeholder,
1334
+ componentId = _this$$props5.componentId,
1335
+ themePreset = _this$$props5.themePreset;
1336
+ if (showSearch) {
1337
+ return createVNode(Input, {
1338
+ "class": getClassName(innerClass, 'input') || null,
1339
+ "onInput": this.handleInputChange,
1340
+ "value": this.searchTerm,
1341
+ "placeholder": placeholder || 'Search',
1342
+ "style": {
1343
+ margin: '0 0 8px'
1344
+ },
1345
+ "aria-label": componentId + "-search",
1346
+ "themePreset": themePreset
1347
+ }, null);
1348
+ }
1349
+ return null;
1350
+ },
1351
+ handleListItemClick: function handleListItemClick(key, parentPath) {
1352
+ var path = key;
1353
+ if (parentPath) {
1354
+ path = "" + parentPath + TREELIST_VALUES_PATH_SEPARATOR + key;
1355
+ }
1356
+ var newSelectedValues = _extends({}, this.selectedValues);
1357
+ if (this.$props.mode === 'single') {
1358
+ newSelectedValues = {};
1359
+ setDeep(newSelectedValues, path.split(TREELIST_VALUES_PATH_SEPARATOR), true, true);
1360
+ } else {
1361
+ var newValue = !recLookup(newSelectedValues, path, TREELIST_VALUES_PATH_SEPARATOR);
1362
+ setDeep(newSelectedValues, path.split(TREELIST_VALUES_PATH_SEPARATOR), newValue, true);
1363
+ }
1364
+ newSelectedValues = sanitizeObject(_extends({}, newSelectedValues));
1365
+ if (this.$props.value === undefined) {
1366
+ this.setValue(newSelectedValues);
1367
+ } else if (this.$props.onChange) {
1368
+ var valueToSet = transformTreeListLocalStateIntoQueryComptaibleFormat(newSelectedValues);
1369
+ this.$props.onChange(valueToSet);
1370
+ }
1371
+ },
1372
+ filterDataBasedOnSearchTerm: function filterDataBasedOnSearchTerm(listArray, parentPath) {
1373
+ var _this = this;
1374
+ if (!(listArray && Array.isArray(listArray) && listArray.length)) {
1375
+ return null;
1376
+ }
1377
+ var result = [];
1378
+ listArray.forEach(function (ele) {
1379
+ var isLeafItem = !ele.list;
1380
+ var newParentPath = ele.key;
1381
+ if (parentPath) {
1382
+ newParentPath = parentPath + "." + ele.key;
1383
+ }
1384
+ var keyHasSearchTerm = replaceDiacritics(ele.key).toLowerCase().includes(replaceDiacritics(_this.$data.searchTerm).toLowerCase()) || recLookup(_this.$data.selectedValues, newParentPath, TREELIST_VALUES_PATH_SEPARATOR);
1385
+ if (isLeafItem && keyHasSearchTerm) {
1386
+ result.push(_extends({}, ele, {
1387
+ initiallyExpanded: keyHasSearchTerm
1388
+ }));
1389
+ } else if (!isLeafItem) {
1390
+ var filteredChildrenItems = _this.filterDataBasedOnSearchTerm(ele.list, newParentPath);
1391
+ if (keyHasSearchTerm || !!filteredChildrenItems.length) {
1392
+ result.push(_extends({}, ele, {
1393
+ initiallyExpanded: keyHasSearchTerm || !!filteredChildrenItems.length,
1394
+ list: filteredChildrenItems
1395
+ }));
1396
+ }
1397
+ }
1398
+ });
1399
+ return result;
1400
+ },
1401
+ getComponent: function getComponent() {
1402
+ var _this$$props6 = this.$props,
1403
+ rawData = _this$$props6.rawData,
1404
+ error = _this$$props6.error,
1405
+ isLoading = _this$$props6.isLoading;
1406
+ var data = {
1407
+ data: this.getTransformedData(),
1408
+ rawData: rawData,
1409
+ error: error,
1410
+ handleClick: this.handleListItemClick,
1411
+ value: this.$data.selectedValues,
1412
+ loading: isLoading,
1413
+ PATH_SEPARATOR: TREELIST_VALUES_PATH_SEPARATOR
1414
+ };
1415
+ return this.$slots.render(data) || getComponent$1(data, this.$props);
1416
+ },
1417
+ getDefaultQuery: function getDefaultQuery(value) {
1418
+ var _this2 = this;
1419
+ var query = null;
1420
+ var type = 'term';
1421
+ var booleanAggregator = this.$props.queryFormat === 'or' ? 'should' : 'must';
1422
+ if (!Array.isArray(value) || value.length === 0) {
1423
+ return null;
1424
+ }
1425
+ if (value) {
1426
+ var _bool;
1427
+ // adds a sub-query with must as an array of objects for each term/value
1428
+ var queryArray = value.map(function (item) {
1429
+ return {
1430
+ bool: {
1431
+ must: item.split(' > ').map(function (subItem, i) {
1432
+ var _type, _ref2;
1433
+ return _ref2 = {}, _ref2[type] = (_type = {}, _type[_this2.$props.dataField[i]] = subItem, _type), _ref2;
1434
+ })
1435
+ }
1436
+ };
1437
+ });
1438
+ var listQuery = {
1439
+ bool: (_bool = {}, _bool[booleanAggregator] = queryArray, _bool)
1440
+ };
1441
+ query = value.length ? listQuery : null;
1442
+ }
1443
+ if (query && this.$props.nestedField) {
1444
+ return {
1445
+ nested: {
1446
+ path: this.$props.nestedField,
1447
+ query: query
1448
+ }
1449
+ };
1450
+ }
1451
+ return query;
1452
+ },
1453
+ updateQuery: function updateQuery(value) {
1454
+ var customQuery = this.$props.customQuery;
1455
+ var query = this.getDefaultQuery(value);
1456
+ var customQueryOptions;
1457
+ if (customQuery) {
1458
+ var _ref3 = customQuery(value, this.$props) || {};
1459
+ query = _ref3.query;
1460
+ customQueryOptions = getOptionsFromQuery(customQuery(value, this.$props));
1461
+ updateCustomQuery(this.$props.componentId, this.$props, value);
1462
+ }
1463
+ this.setQueryOptions(this.$props.componentId, _extends({}, this.generateQueryOptions(), customQueryOptions));
1464
+ this.updateQueryAction({
1465
+ componentId: this.$props.componentId,
1466
+ query: query,
1467
+ value: value,
1468
+ label: this.$props.filterLabel,
1469
+ showFilter: this.$props.showFilter,
1470
+ URLParams: this.$props.URLParams,
1471
+ componentType: componentTypes.treeList
1472
+ });
1473
+ },
1474
+ setValue: function setValue(value, hasMountedParam) {
1475
+ var _this3 = this;
1476
+ if (hasMountedParam === void 0) {
1477
+ hasMountedParam = true;
1478
+ }
1479
+ var finalValues = Array.isArray(value) === false ? transformTreeListLocalStateIntoQueryComptaibleFormat(value) : value;
1480
+ var performUpdate = function performUpdate() {
1481
+ var handleUpdates = function handleUpdates() {
1482
+ _this3.updateQuery(finalValues);
1483
+ if (_this3.$props.onValueChange) _this3.$props.onValueChange(finalValues);
1484
+ };
1485
+ if (hasMountedParam) {
1486
+ _this3.selectedValues = Array.isArray(value) ? transformValueIntoLocalState(value) : value;
1487
+ handleUpdates();
1488
+ } else {
1489
+ handleUpdates();
1490
+ }
1491
+ };
1492
+ checkValueChange(this.$props.componentId, finalValues, this.$props.beforeValueChange, performUpdate);
1493
+ },
1494
+ generateQueryOptions: function generateQueryOptions() {
1495
+ var queryOptions = getQueryOptions(this.$props);
1496
+ var valueArray = transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
1497
+ return getAggsQuery(valueArray, queryOptions, this.$props);
1498
+ },
1499
+ updateDefaultQuery: function updateDefaultQuery$1(queryOptions) {
1500
+ var value = transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
1501
+ // Update default query for RS API
1502
+ updateDefaultQuery(this.$props.componentId, this.$props, value);
1503
+ updateInternalQuery(getInternalComponentID(this.$props.componentId), queryOptions, value, this.$props, this.generateQueryOptions(), null);
1504
+ },
1505
+ updateQueryOptions: function updateQueryOptions() {
1506
+ // for a new query due to other changes don't append after to get fresh results
1507
+ var queryOptions = this.generateQueryOptions(this.$props, {}, transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues));
1508
+ if (this.$props.defaultQuery) {
1509
+ // eslint-disable-next-line no-use-before-define
1510
+ this.updateDefaultQuery(queryOptions);
1511
+ } else {
1512
+ this.setQueryOptions(getInternalComponentID(this.$props.componentId), queryOptions);
1513
+ }
1514
+ }
1515
+ },
1516
+ render: function render() {
1517
+ var _this4 = this;
1518
+ var props = this.$props;
1519
+ var style = props.style,
1520
+ className = props.className,
1521
+ mode = props.mode,
1522
+ showLine = props.showLine,
1523
+ renderItem = props.renderItem,
1524
+ showCheckbox = props.showCheckbox,
1525
+ innerClass = props.innerClass,
1526
+ showRadio = props.showRadio,
1527
+ showCount = props.showCount,
1528
+ showSwitcherIcon = props.showSwitcherIcon,
1529
+ switcherIcon = props.switcherIcon,
1530
+ title = props.title,
1531
+ loader = props.loader,
1532
+ renderError = props.renderError;
1533
+ if (this.isLoading) {
1534
+ return (this.$slots.loader ? this.$slots.loader() : loader) || null;
1535
+ }
1536
+ if (this.error) {
1537
+ if (this.$slots.renderError) {
1538
+ return this.$slots.renderError(this.error);
1539
+ }
1540
+ return isFunction$1(renderError) ? renderError(this.error) : renderError;
1541
+ }
1542
+ var transformedData = this.getTransformedData();
1543
+ if (!transformedData || transformedData.length === 0) {
1544
+ return this.$slots.renderNoResults ? this.$slots.renderNoResults() : null;
1545
+ }
1546
+ return createVNode(Container, {
1547
+ "style": style,
1548
+ "class": className
1549
+ }, {
1550
+ "default": function _default() {
1551
+ return [props.title && createVNode(Title, {
1552
+ "class": getClassName(innerClass, 'title') || null
1553
+ }, _isSlot$2(title) ? title : {
1554
+ "default": function _default() {
1555
+ return [title];
1556
+ }
1557
+ }), _this4.renderSearch(), _this4.hasCustomRenderer ? _this4.getComponent() : createVNode(HierarchicalMenuComponent, {
1558
+ "key": "initial-node",
1559
+ "listArray": transformedData,
1560
+ "parentPath": "",
1561
+ "isExpanded": true,
1562
+ "listItemProps": {
1563
+ mode: mode,
1564
+ selectedValues: _this4.selectedValues,
1565
+ searchTerm: _this4.searchTerm,
1566
+ showLine: showLine,
1567
+ renderItem: renderItem != null ? renderItem : _this4.$slots.renderItem,
1568
+ handleListItemClick: _this4.handleListItemClick,
1569
+ showCheckbox: showCheckbox,
1570
+ innerClass: innerClass,
1571
+ showRadio: showRadio,
1572
+ renderIcon: _this4.renderIcon,
1573
+ showCount: showCount,
1574
+ showSwitcherIcon: showSwitcherIcon,
1575
+ switcherIcon: switcherIcon != null ? switcherIcon : _this4.$slots.switcherIcon
1576
+ }
1577
+ }, null)];
1578
+ }
1579
+ });
1580
+ }
1581
+ };
1582
+ var mapStateToProps$1 = function mapStateToProps(state, props) {
1583
+ return {
1584
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
1585
+ rawData: state.rawData[props.componentId] || {},
1586
+ aggregationData: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId] || {},
1587
+ themePreset: state.config.themePreset,
1588
+ error: state.error[props.componentId],
1589
+ isLoading: state.isLoading[props.componentId],
1590
+ enableAppbase: state.config.enableAppbase
1591
+ };
1592
+ };
1593
+ var mapDispatchtoProps = {
1594
+ setQueryOptions: setQueryOptions,
1595
+ updateQueryAction: updateQueryAction
1596
+ };
1597
+ TreeList.hasInternalComponent = function () {
1598
+ return true;
1599
+ };
1600
+ var TreeListConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps$1, mapDispatchtoProps)(TreeList), {
1601
+ componentType: componentTypes.treeList,
1602
+ internalComponent: TreeList.hasInternalComponent()
1603
+ }));
1604
+ TreeListConnected.name = TreeList.name;
1605
+ TreeListConnected.install = function (Vue) {
1606
+ Vue.component(TreeListConnected.name, TreeListConnected);
1607
+ };
1608
+
1609
+ // Add componentType for SSR
1610
+ TreeListConnected.componentType = componentTypes.treeList;
1611
+
1612
+ var RcConnected = PreferencesConsumer({
1613
+ name: 'RcConnected',
1614
+ render: function render() {
1615
+ var component = ReactiveComponent;
1616
+ switch (this.$attrs.componentType) {
1617
+ case componentTypes.reactiveList:
1618
+ component = ReactiveList;
1619
+ break;
1620
+ case componentTypes.searchBox:
1621
+ component = SearchBox;
1622
+ break;
1623
+ // list components
1624
+ case componentTypes.singleList:
1625
+ component = SingleList;
1626
+ break;
1627
+ case componentTypes.multiList:
1628
+ component = MultiList;
1629
+ break;
1630
+ case componentTypes.singleDropdownList:
1631
+ component = SingleDropdownList;
1632
+ break;
1633
+ case componentTypes.multiDropdownList:
1634
+ component = MultiDropdownList;
1635
+ break;
1636
+ // basic components
1637
+ case componentTypes.toggleButton:
1638
+ component = ToggleButton;
1639
+ break;
1640
+ // range components
1641
+ case componentTypes.dynamicRangeSlider:
1642
+ component = DynamicRangeSlider;
1643
+ break;
1644
+ case componentTypes.singleRange:
1645
+ component = SingleRange;
1646
+ break;
1647
+ case componentTypes.multiRange:
1648
+ component = MultiRange;
1649
+ break;
1650
+ case componentTypes.rangeSlider:
1651
+ component = RangeSlider;
1652
+ break;
1653
+ case componentTypes.rangeInput:
1654
+ component = RangeInput;
1655
+ break;
1656
+ }
1657
+ return h(component, null, this.$slots);
1658
+ }
1659
+ });
1660
+ RcConnected.name = ReactiveComponent.name;
1661
+ RcConnected.hasInternalComponent = ReactiveComponent.hasInternalComponent;
1662
+ // Add componentType for SSR
1663
+ RcConnected.componentType = componentTypes.reactiveComponent;
1664
+ RcConnected.install = function (Vue) {
1665
+ Vue.component(RcConnected.name, RcConnected);
1666
+ };
1667
+
1668
+ var components = [ReactiveList, ResultCard, ResultList, ReactiveBase, SearchBox, SingleList, MultiList, SingleRange, MultiRange, RangeSlider, DynamicRangeSlider, ReactiveComponent, RcConnected, SelectedFilters, ToggleButton, SingleDropdownList, MultiDropdownList, StateProvider, RangeInput, TreeListConnected, AIConnected];
1669
+ function install (Vue) {
1670
+ components.map(function (component) {
1671
+ Vue.use(component);
1672
+ return null;
1673
+ });
1674
+ }
1675
+
1676
+ export { AIConnected as A, RcConnected as R, TreeListConnected as T, install as i };