@koredev/agentai-web-sdk 3.22.0-rc → 3.22.1-rc

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,3828 +0,0 @@
1
- "use strict";
2
- self["webpackHotUpdateaa_sdk"]("KoreAASDK",{
3
-
4
- /***/ "./src/components/common/services/rootService.ts":
5
- /*!*******************************************************!*\
6
- !*** ./src/components/common/services/rootService.ts ***!
7
- \*******************************************************/
8
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
-
10
- __webpack_require__.r(__webpack_exports__);
11
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
13
- /* harmony export */ rootService: () => (/* binding */ rootService)
14
- /* harmony export */ });
15
- /* harmony import */ var _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
16
- /* harmony import */ var _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants/projConsts */ "./src/components/common/constants/projConsts.ts");
17
- /* harmony import */ var _templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../templatemanager/base/domManager */ "./src/components/common/templatemanager/base/domManager.tsx");
18
- /* harmony import */ var _templatemanager_tabs_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../templatemanager/tabs/suggestions/faq/faq */ "./src/components/common/templatemanager/tabs/suggestions/faq/faq.tsx");
19
- /* harmony import */ var _templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../templatemanager/tabs/atom/actionButtons */ "./src/components/common/templatemanager/tabs/atom/actionButtons.tsx");
20
- /* harmony import */ var _utils_randomuuid__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/randomuuid */ "./src/components/common/utils/randomuuid.ts");
21
- /* harmony import */ var _utils_koregenerateuuid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/koregenerateuuid */ "./src/components/common/utils/koregenerateuuid.ts");
22
- /* harmony import */ var _templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../templatemanager/tabs/automation/automation */ "./src/components/common/templatemanager/tabs/automation/automation.tsx");
23
- /* harmony import */ var _templatemanager_tabs_feedback_feedback__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../templatemanager/tabs/feedback/feedback */ "./src/components/common/templatemanager/tabs/feedback/feedback.tsx");
24
- /* harmony import */ var _utils_interceptor__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/interceptor */ "./src/components/common/utils/interceptor.ts");
25
- /* harmony import */ var _constants_settingsConsts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants/settingsConsts */ "./src/components/common/constants/settingsConsts.ts");
26
- /* harmony import */ var _constants_default_config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../constants/default.config */ "./src/components/common/constants/default.config.ts");
27
- /* harmony import */ var _templatemanager_tabs_ErrorBoundary_ErrorHandler__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../templatemanager/tabs/ErrorBoundary/ErrorHandler */ "./src/components/common/templatemanager/tabs/ErrorBoundary/ErrorHandler.ts");
28
- /* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! dompurify */ "./node_modules/dompurify/dist/purify.es.mjs");
29
- /* harmony import */ var _utils_domUtils__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../utils/domUtils */ "./src/utils/domUtils.ts");
30
- /* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! marked */ "./node_modules/marked/lib/marked.esm.js");
31
- var __assign = (undefined && undefined.__assign) || function () {
32
- __assign = Object.assign || function(t) {
33
- for (var s, i = 1, n = arguments.length; i < n; i++) {
34
- s = arguments[i];
35
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
36
- t[p] = s[p];
37
- }
38
- return t;
39
- };
40
- return __assign.apply(this, arguments);
41
- };
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
- var rootService = /** @class */ (function () {
59
- function rootService(hostInstance) {
60
- var _a;
61
- var _this = this;
62
- this.isAutomationOnGoing = false;
63
- this.isMyBotAutomationOnGoing = false;
64
- this.currentAutomationId = '';
65
- this.currentMybotAutomationId = '';
66
- this.isCustomTabAutomationOnGoing = false;
67
- this.currentCustomTabAutomationId = '';
68
- this.grantResponseObj = {};
69
- this.isInitialInternalTransferTriggered = false;
70
- this.prefsAccessObj = {
71
- tabsNTitles: [],
72
- prefs: {},
73
- orderTabs: [],
74
- defaultTab: ""
75
- };
76
- this.customTabPrefsObj = {
77
- customTabEnabled: false,
78
- customTabPrefs: {},
79
- customTabWlD: [],
80
- customTablbl: ''
81
- };
82
- this.connectionDetails = {};
83
- this.aaSettings = {};
84
- this.menuResponseArr = [];
85
- this.numOfLines = 4;
86
- this.maxHeight = 'max-content';
87
- this.scrollHeight = Number.MAX_VALUE;
88
- this.classConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst;
89
- this.idConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.IdMapConstant;
90
- this.faqambiguityResponse = false;
91
- this.activeTab = '';
92
- this.internalTransfer = false;
93
- this.internalTransferData = {};
94
- this.proactiveMode = false;
95
- this.OverRideMode = false;
96
- this.manualAssistOverrideMode = false;
97
- this.autoScrollStatus = true;
98
- this.isOnReadyCalled = false;
99
- this.agenticStart = false;
100
- this.myBotTabSessionId = '';
101
- this.assistTabSessionId = '';
102
- this.sentSearchResponse = false;
103
- this.searchedResultData = {};
104
- this.socketConnect = false;
105
- this.tabsNTitles = [];
106
- this.isAnonymousFlowEnabled = false;
107
- this.isAnonymousFlowTriggered = false;
108
- this.isHooksApi = false;
109
- this.isAgenticCoPilotEnabled = false;
110
- this.isAgenticPaused = false;
111
- this.isAgenticAutoSendEnabled = true;
112
- this.sendingTimeForAgenticAutoSend = 5000;
113
- this.isPlaybookHistory = false;
114
- this.isProceedToClose = false;
115
- this.dynClObjs = {};
116
- this.DialogsinGroups = {};
117
- this.hideActionButtons = false;
118
- this.hideSendButton = false;
119
- this.hideCopyButton = false;
120
- this.isUpdateFeedBackDetailsFlag = false;
121
- this.moreBtnActive = false;
122
- this.tabs = {
123
- ast: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST,
124
- mB: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT,
125
- srch: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEARCH,
126
- trnspt: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.TRANSCRIPT
127
- };
128
- this.tabsTitleAsKey = (_a = {},
129
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST] = 'ast',
130
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT] = 'mB',
131
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEARCH] = 'srch',
132
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.TRANSCRIPT] = 'trnspt',
133
- _a);
134
- this.widgetFeedbackData = {
135
- selectedSuggestions: [],
136
- comment: '',
137
- type: '',
138
- positionId: ''
139
- };
140
- this.isWidgetFeedbackAPICalled = false;
141
- this.widgetHistoryType = '';
142
- this.entitiesValueArray = [];
143
- this.mybotEntitiestValueArray = [];
144
- this.interruptDialogList = [];
145
- this.mybotInterruptDialogList = [];
146
- this.customInterruptDialogList = [];
147
- this.isExitEventTriggered = false;
148
- this.isSearchConvEnabled = false;
149
- this.searchHistoryData = [];
150
- this.menuResponse = [];
151
- this.isGroups = false;
152
- this.isHistory = true;
153
- this.customTabHistoryData = [];
154
- this.disableWidgetFlag = false;
155
- this.defaultFeedbackSettings = _constants_default_config__WEBPACK_IMPORTED_MODULE_11__.DEFAULT_FEEDBACK_SETTINGS;
156
- this.defaultSuggestionObj = _constants_default_config__WEBPACK_IMPORTED_MODULE_11__.DEFAULT_WIDGET_SETTINGS;
157
- this.tableList = ['table', 'tableList', 'custom_table'];
158
- this.realtimeSentiData = {};
159
- this.isSummariesGenerated = false;
160
- this.generatedSummaries = [];
161
- this.maxIntSummaryCount = 2;
162
- this.currentGenIntSummaryCount = 0;
163
- this.summaryInProgress = false;
164
- this.finalSummaryGenerated = false;
165
- this.hiddenClasses = [];
166
- this.summaryStatus = 200;
167
- this.summaryRetryCount = 0;
168
- this.interimSummary = false;
169
- this.customTabEntitiesValueArray = [];
170
- this.agenticNodeArray = [];
171
- this.currCl = '';
172
- this.currSt = '';
173
- this.isAgenticStreamingEnabled = false;
174
- this.agenticSearchResultsMap = {};
175
- this.toggleInterruptPopup = function (hostInstance, flag, currentDialogName) {
176
- var _a, _b, _c, _d;
177
- var interruptPopup = (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(_this.classConstants.INTERRUPT_POPUP));
178
- if (flag) {
179
- interruptPopup.querySelector("".concat(_this.classConstants.INTERRUPT_CURRENT_DIALOG)).innerText = currentDialogName;
180
- (_c = interruptPopup.classList) === null || _c === void 0 ? void 0 : _c.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
181
- }
182
- else {
183
- (_d = interruptPopup.classList) === null || _d === void 0 ? void 0 : _d.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
184
- }
185
- };
186
- this.toggleTerminatePopup = function (hostInstance, flag) {
187
- var _a, _b, _c, _d;
188
- var terminatePopup = (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(_this.classConstants.TERMIANTE_POPUP));
189
- if (flag) {
190
- (_c = terminatePopup.classList) === null || _c === void 0 ? void 0 : _c.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
191
- }
192
- else {
193
- (_d = terminatePopup.classList) === null || _d === void 0 ? void 0 : _d.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
194
- }
195
- };
196
- this.appendTemplate = function (template, entityNode) {
197
- _this.appendTemplateToContainer(template, entityNode);
198
- };
199
- this.checkTransferDetailsAndDisableWidget = function (hostInstance) {
200
- setTimeout(function () {
201
- var _a;
202
- var appState = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.localStorageService) === null || _a === void 0 ? void 0 : _a.getConvObjFromLS();
203
- if (appState) {
204
- var internalTransferDetails = appState[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.storageConst.INTERNAL_TRANSFER];
205
- if (internalTransferDetails) {
206
- hostInstance.disableWidget(internalTransferDetails.isDisabled);
207
- }
208
- }
209
- });
210
- };
211
- this.checkDialogGroupingAndMake = function (hostInstance, suggestionArr, prefsData) {
212
- var _a, _b, _c, _d, _e, _f;
213
- if (prefsData.length === 0) {
214
- return suggestionArr;
215
- }
216
- var botId = (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.config) === null || _a === void 0 ? void 0 : _a.connectionDetails) === null || _b === void 0 ? void 0 : _b.botId;
217
- var isE = (_d = (_c = prefsData[botId]) === null || _c === void 0 ? void 0 : _c.grpConfig) === null || _d === void 0 ? void 0 : _d.isE;
218
- var dialogGrp = (_f = (_e = prefsData[botId]) === null || _e === void 0 ? void 0 : _e.grpConfig) === null || _f === void 0 ? void 0 : _f.dgGrps;
219
- if (isE && dialogGrp[0].gn === '_default' && dialogGrp.length === 1) {
220
- _this.isGroups = false;
221
- return _this.defaultGroupMake(dialogGrp[0].dlgs, suggestionArr);
222
- }
223
- else if (isE && dialogGrp.length >= 1) {
224
- _this.isGroups = true;
225
- return _this.groupsMake(dialogGrp, suggestionArr);
226
- }
227
- return suggestionArr;
228
- };
229
- this.groupsMake = function (dialogGroups, suggestionArr) {
230
- var _a;
231
- var dialogGroupArr = [];
232
- var hashMapSuggestionArr = {};
233
- for (var index = 0; index < suggestionArr.length; index++) {
234
- hashMapSuggestionArr[(_a = suggestionArr[index]) === null || _a === void 0 ? void 0 : _a.taskRefId] = index;
235
- }
236
- for (var _i = 0, dialogGroups_1 = dialogGroups; _i < dialogGroups_1.length; _i++) {
237
- var grpObj = dialogGroups_1[_i];
238
- var grpObjGroupName = grpObj === null || grpObj === void 0 ? void 0 : grpObj.gn;
239
- var grpObjGroupDialogArr = grpObj === null || grpObj === void 0 ? void 0 : grpObj.dlgs;
240
- var dialogArrItems = [];
241
- var dialogGroupArrItem = {
242
- "gn": grpObjGroupName,
243
- "isExpanded": (grpObj === null || grpObj === void 0 ? void 0 : grpObj.isExpanded) || false
244
- };
245
- for (var _b = 0, grpObjGroupDialogArr_1 = grpObjGroupDialogArr; _b < grpObjGroupDialogArr_1.length; _b++) {
246
- var dialogIds = grpObjGroupDialogArr_1[_b];
247
- if (hashMapSuggestionArr.hasOwnProperty(dialogIds)) {
248
- dialogArrItems.push(suggestionArr[hashMapSuggestionArr[dialogIds]]);
249
- _this.DialogsinGroups[dialogIds] = 1;
250
- }
251
- }
252
- dialogGroupArrItem.dlgs = dialogArrItems;
253
- dialogGroupArr.push(dialogGroupArrItem);
254
- }
255
- _this.checkOthersAndMake(dialogGroupArr, suggestionArr);
256
- dialogGroupArr = _this.checkEmptyGrps(dialogGroupArr);
257
- return dialogGroupArr;
258
- };
259
- this.checkOthersAndMake = function (dialogGroupArr, suggestionArr) {
260
- var OthersDialogsArr = [];
261
- suggestionArr.map(function (items, index) {
262
- if (!((items === null || items === void 0 ? void 0 : items.taskRefId) in _this.DialogsinGroups)) {
263
- OthersDialogsArr.push(items);
264
- }
265
- });
266
- if (OthersDialogsArr.length > 0) {
267
- var OthersGroup = {
268
- "gn": "Others"
269
- };
270
- OthersGroup.dlgs = OthersDialogsArr;
271
- dialogGroupArr.push(OthersGroup);
272
- }
273
- };
274
- this.fetchSummaries = function (hostInstance) {
275
- var _a;
276
- if (_this.isSummariesGenerated) {
277
- return;
278
- }
279
- var payload = {
280
- conversationId: _this.connectionDetails.conversationId,
281
- botId: _this.connectionDetails.botId,
282
- participant: ((_a = _this === null || _this === void 0 ? void 0 : _this.internalTransferData) === null || _a === void 0 ? void 0 : _a.participant) || {}
283
- };
284
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.get_summaries, payload);
285
- };
286
- this.checkDynamicTasksAndFilter = function (hostIns, typedText) {
287
- var menuResponse = typeof structuredClone === 'function'
288
- ? structuredClone(_this.menuResponseArr)
289
- : JSON.parse(JSON.stringify(_this.menuResponseArr));
290
- var filterItems = menuResponse.filter(function (obj) { return obj === null || obj === void 0 ? void 0 : obj.intentName.toLowerCase().includes(typedText.toLowerCase()); });
291
- return filterItems;
292
- };
293
- this.checkEmptyGrps = function (dialogGroupArr) {
294
- return dialogGroupArr.filter(function (obj) { var _a; return ((_a = obj === null || obj === void 0 ? void 0 : obj.dlgs) === null || _a === void 0 ? void 0 : _a.length) > 0; });
295
- };
296
- this.convertAgenticMarkdownToHtml = function (markdownContent) {
297
- var _a;
298
- markdownContent = ((_a = markdownContent === null || markdownContent === void 0 ? void 0 : markdownContent.replace(/<[^>]*>/g, '')) === null || _a === void 0 ? void 0 : _a.replace(/[^a-zA-Z0-9]n/g, '\n')) || '';
299
- return marked__WEBPACK_IMPORTED_MODULE_15__.marked.parse(markdownContent);
300
- };
301
- this.setStreamingAgenticSearchResults = function (response, resultsElement) {
302
- var _a, _b, _c;
303
- if (!response || !resultsElement || !(response === null || response === void 0 ? void 0 : response.requestId)) {
304
- return;
305
- }
306
- if (!_this.agenticSearchResultsMap[response === null || response === void 0 ? void 0 : response.requestId]) {
307
- _this.agenticSearchResultsMap[response === null || response === void 0 ? void 0 : response.requestId] = '';
308
- }
309
- if (response === null || response === void 0 ? void 0 : response.isLastEvent) {
310
- return;
311
- }
312
- var desc = resultsElement === null || resultsElement === void 0 ? void 0 : resultsElement.querySelector(_this.classConstants.AGENTIC_SEARCH_RESULTS_TITLE);
313
- if (desc && !((_a = desc === null || desc === void 0 ? void 0 : desc.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.SUGGESTION_EXPANDED))) {
314
- var overlimitContainer = resultsElement === null || resultsElement === void 0 ? void 0 : resultsElement.querySelector(_this.classConstants.MORE_BTN_CONTAINER);
315
- var moreButton = overlimitContainer === null || overlimitContainer === void 0 ? void 0 : overlimitContainer.querySelector(_this.classConstants.MORE_BUTTON);
316
- var scrollDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(desc);
317
- var clientDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeDimensions)(desc);
318
- var isOverLimit = scrollDimensions.scrollHeight > clientDimensions.height;
319
- if (isOverLimit) {
320
- overlimitContainer.classList.remove(_this.classConstants.HIDE_ELEMENT);
321
- desc.classList.toggle(_this.classConstants.SUGGESTION_EXPANDED);
322
- moreButton.textContent = desc.classList.contains(_this.classConstants.SUGGESTION_EXPANDED) ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_LESS : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_MORE;
323
- }
324
- }
325
- var searchResultsElement = resultsElement === null || resultsElement === void 0 ? void 0 : resultsElement.querySelector(_this.classConstants.AGENTIC_SEARCH_RESULTS_TITLE);
326
- if (searchResultsElement) {
327
- _this.agenticSearchResultsMap[response === null || response === void 0 ? void 0 : response.requestId] += ((_c = (_b = response === null || response === void 0 ? void 0 : response.response) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.content) || '';
328
- var finalResultHtml = _this.convertAgenticMarkdownToHtml(_this.agenticSearchResultsMap[response === null || response === void 0 ? void 0 : response.requestId]);
329
- searchResultsElement.innerHTML = finalResultHtml;
330
- }
331
- };
332
- this.aaHelpers = hostInstance.chatWindowInstance.helpers;
333
- this.handleEmptyLine = this.handleEmptyLine.bind(this);
334
- }
335
- rootService.prototype.sanitizeHTML = function (html) {
336
- var config = {
337
- ADD_ATTR: ['target', 'rel'],
338
- ALLOWED_ATTR: ['href', 'target', 'rel', 'class'],
339
- ALLOW_DATA_ATTR: true,
340
- FORCE_BODY: true,
341
- ALLOWED_TAGS: ['a', 'p', 'span', 'b', 'i', 'em', 'strong', 'br'], // Common HTML tags
342
- };
343
- return dompurify__WEBPACK_IMPORTED_MODULE_13__["default"].sanitize(html, config);
344
- };
345
- rootService.prototype.updateDefaultFeedbackData = function () {
346
- var _this = this;
347
- var categories = Object.keys(this.defaultFeedbackSettings);
348
- categories.forEach(function (category) {
349
- var languages = Object.keys(_this.defaultSuggestionObj[category]);
350
- _this.defaultFeedbackSettings[category].negativeKeyWords = {};
351
- languages.forEach(function (language) {
352
- var langArray = _this.defaultSuggestionObj[category][language].map(function (element, index) { return ({
353
- isEnabled: index <= 4,
354
- key: element
355
- }); });
356
- _this.defaultFeedbackSettings[category].negativeKeyWords[language] = langArray;
357
- });
358
- });
359
- };
360
- rootService.prototype.formatSearchResponse = function (response, isSearch, suggestionIndex, suggestionFrom) {
361
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
362
- if (isSearch === void 0) { isSearch = false; }
363
- if (suggestionFrom === void 0) { suggestionFrom = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT; }
364
- var suggestions = response.suggestions;
365
- var dialoguesArray = suggestions.dialogs || [];
366
- var faqArray = suggestions.faqs || [];
367
- var snippersArray = this.formatSnippetResponse(((_a = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _a === void 0 ? void 0 : _a.snippets) || [], response, suggestionIndex);
368
- var filesArray = ((_b = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _b === void 0 ? void 0 : _b.files) || [];
369
- var searchResponse = {};
370
- if ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) && ((_c = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _c === void 0 ? void 0 : _c.snippets) && ((_e = (_d = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _d === void 0 ? void 0 : _d.snippets) === null || _e === void 0 ? void 0 : _e.length) == 0) {
371
- delete suggestions.searchassist.snippets;
372
- }
373
- var searchassistKeys = Object.keys((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) || {});
374
- if ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) && (searchassistKeys === null || searchassistKeys === void 0 ? void 0 : searchassistKeys.length) == 1 && searchassistKeys[0] === 'searchRequestId') {
375
- suggestions.searchassist = {};
376
- }
377
- if (dialoguesArray.length || faqArray.length || snippersArray.length || filesArray.length || ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) && ((_f = Object.keys(suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist)) === null || _f === void 0 ? void 0 : _f.length))) {
378
- searchResponse.dialogs = [];
379
- searchResponse.faqs = [];
380
- searchResponse.articles = [];
381
- searchResponse.snippets = [];
382
- searchResponse.files = [];
383
- if (suggestions.searchassist && ((_g = Object.keys(suggestions.searchassist)) === null || _g === void 0 ? void 0 : _g.length) > 0) {
384
- var _loop_1 = function (source) {
385
- if (source != "snippets" && source != "file" && source != 'searchRequestId') {
386
- suggestions.searchassist[source] = this_1.checkEmptyObjectsInArray(suggestions.searchassist[source]);
387
- if (suggestions.searchassist[source] && ((_h = Object.keys(suggestions.searchassist[source])) === null || _h === void 0 ? void 0 : _h.length) > 0) {
388
- searchResponse.articles.push.apply(searchResponse.articles, suggestions.searchassist[source]);
389
- }
390
- }
391
- if (source == "file") {
392
- suggestions.searchassist[source] = this_1.checkEmptyObjectsInArray(suggestions.searchassist[source]);
393
- if (suggestions.searchassist[source] && ((_j = Object.keys(suggestions.searchassist[source])) === null || _j === void 0 ? void 0 : _j.length) > 0) {
394
- searchResponse.files.push.apply(searchResponse.files, suggestions.searchassist[source]);
395
- }
396
- }
397
- if (source && source != 'searchRequestId') {
398
- (_k = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist[source]) === null || _k === void 0 ? void 0 : _k.forEach(function (item) {
399
- item.subType = source;
400
- });
401
- }
402
- };
403
- var this_1 = this;
404
- for (var source in suggestions.searchassist) {
405
- _loop_1(source);
406
- }
407
- for (var _i = 0, _p = searchResponse.articles; _i < _p.length; _i++) {
408
- var article = _p[_i];
409
- article.showMoreButton = true;
410
- article.showLessButton = false;
411
- article.content = article.content ? article.content : '';
412
- article.contentId = article.contentId;
413
- article.userInput = response.userInput;
414
- article.sourceMsgId = response.sourceMsgId || '';
415
- article.subType = article.subType;
416
- article.intType = isSearch ? 'mybot' : 'assist';
417
- article.feedbackData = this.prepareFeedbackForSuggestions('article', article, {});
418
- }
419
- for (var _q = 0, _r = searchResponse.files; _q < _r.length; _q++) {
420
- var file = _r[_q];
421
- file.showMoreButton = true;
422
- file.showLessButton = false;
423
- file.content = file.content ? file.content : '';
424
- file.contentId = file.contentId;
425
- file.userInput = response.userInput;
426
- file.sourceMsgId = response.sourceMsgId || '';
427
- file.subType = file.subType;
428
- file.intType = isSearch ? 'mybot' : 'assist';
429
- file.feedbackData = this.prepareFeedbackForSuggestions('file', file, {});
430
- }
431
- }
432
- for (var _s = 0, faqArray_1 = faqArray; _s < faqArray_1.length; _s++) {
433
- var faq = faqArray_1[_s];
434
- var faqObject = {
435
- question: faq.question,
436
- displayName: faq.displayName,
437
- taskRefId: faq === null || faq === void 0 ? void 0 : faq.taskRefId,
438
- answer: (faq.answer && faq.answer.length > 0) ? [] : false,
439
- showMoreButton: true,
440
- showLessButton: false,
441
- answerRender: faq.answer || false,
442
- childBotId: faq.childBotId,
443
- childBotName: faq.childBotName,
444
- answerCount: 1,
445
- sourceMsgId: response.sourceMsgId || '',
446
- positionId: faq.positionId,
447
- userInput: response.userInput,
448
- intType: response.intType,
449
- reqId: (response === null || response === void 0 ? void 0 : response.reqId) || '',
450
- isConversationalSearch: this.isSearchConvEnabled || false
451
- };
452
- if (faq.answer && faq.answer.length > 0) {
453
- for (var _t = 0, _u = faq.answer; _t < _u.length; _t++) {
454
- var ans = _u[_t];
455
- var object = {
456
- ans: ans,
457
- taskRefId: faq.taskRefId,
458
- showMoreButton: true,
459
- showLessButton: false,
460
- displayName: faq.displayName,
461
- sourceMsgId: response.sourceMsgId || '',
462
- positionId: faq.positionId
463
- };
464
- faqObject.answer.push(object);
465
- }
466
- }
467
- var feedbackData = faq.historyFeedback ? faq.historyFeedback : {};
468
- faqObject.feedbackData = this.prepareFeedbackForSuggestions('faqs', faqObject, feedbackData);
469
- faqObject.feedbackData.interactionType = isSearch ? 'mybot' : 'assist';
470
- searchResponse.faqs.push(faqObject);
471
- }
472
- if (((_m = (_l = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _l === void 0 ? void 0 : _l.snippets) === null || _m === void 0 ? void 0 : _m.length) > 0) {
473
- if ((snippersArray === null || snippersArray === void 0 ? void 0 : snippersArray.length) > 0) {
474
- searchResponse.snippets = Object.assign([], snippersArray);
475
- }
476
- for (var _v = 0, _w = searchResponse.snippets; _v < _w.length; _v++) {
477
- var snippet = _w[_v];
478
- snippet.showMoreButton = true;
479
- snippet.showLessButton = false;
480
- snippet.subType = 'snippets';
481
- }
482
- }
483
- for (var _x = 0, dialoguesArray_1 = dialoguesArray; _x < dialoguesArray_1.length; _x++) {
484
- var dialog = dialoguesArray_1[_x];
485
- if (dialog.entities && ((_o = dialog.entities) === null || _o === void 0 ? void 0 : _o.length) > 0) {
486
- dialog.entities.forEach(function (entity) {
487
- entity.editMode = false;
488
- });
489
- }
490
- searchResponse.dialogs.push({
491
- intentName: dialog.name,
492
- childBotId: dialog.childBotId,
493
- childBotName: dialog.childBotName,
494
- entities: dialog.entities,
495
- userInput: response.userInput,
496
- sourceMsgId: response.sourceMsgId || '',
497
- positionId: (0,_utils_randomuuid__WEBPACK_IMPORTED_MODULE_5__["default"])('positionId'),
498
- traits: response.traits || [],
499
- dialogId: dialog.dialogId ? dialog.dialogId : this.matchDialogIdfromMenuResponse(dialog),
500
- suggestionFrom: suggestionFrom || _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT
501
- });
502
- }
503
- }
504
- return searchResponse;
505
- };
506
- rootService.prototype.formatSnippetResponse = function (snippetsArray, response, suggestionIndex) {
507
- var _a;
508
- var snipObje = {};
509
- snipObje['contentArray'] = [];
510
- snipObje['sources'] = [];
511
- snipObje['internalInfo'] = [];
512
- snipObje['sendCopyText'] = '';
513
- var snippetResponeArray = [];
514
- if ((snippetsArray === null || snippetsArray === void 0 ? void 0 : snippetsArray.length) > 0) {
515
- snippetsArray.forEach(function (snippet) {
516
- var _a;
517
- if (snippet === null || snippet === void 0 ? void 0 : snippet.templateType) {
518
- if (snippet.templateType == 'active_citation_snippet' || snippet.templateType == 'citation_snippet') {
519
- if ((snippet === null || snippet === void 0 ? void 0 : snippet.content) &&
520
- Array.isArray(snippet === null || snippet === void 0 ? void 0 : snippet.content) &&
521
- ((_a = snippet === null || snippet === void 0 ? void 0 : snippet.content) === null || _a === void 0 ? void 0 : _a.length) > 0) {
522
- snippet.content.forEach(function (ansSnippet) {
523
- var ansObj = {
524
- ans: ansSnippet.answer_fragment,
525
- sources: (ansSnippet === null || ansSnippet === void 0 ? void 0 : ansSnippet.sources) || [],
526
- internalFlag: snippet.internalFlag
527
- };
528
- snipObje['contentArray'].push(ansObj);
529
- snipObje.internalFlag = snippet.internalFlag || false;
530
- snipObje.isActCit = true;
531
- });
532
- }
533
- }
534
- else {
535
- if (snippet === null || snippet === void 0 ? void 0 : snippet.content) {
536
- if (Array.isArray(snippet === null || snippet === void 0 ? void 0 : snippet.content)) {
537
- snippet.content = snippet === null || snippet === void 0 ? void 0 : snippet.content.join('\n');
538
- }
539
- snipObje.internalFlag = snippet.internalFlag || false;
540
- var otherType = {
541
- ans: snippet.content,
542
- internalFlag: snippet.internalFlag
543
- };
544
- if (snippet.url) {
545
- otherType['sources'] = [{ title: snippet.source, url: snippet.url }];
546
- }
547
- snipObje.contentArray.push(otherType);
548
- }
549
- }
550
- snipObje.templateType = snippet.templateType;
551
- snipObje.positionId = snippet.positionId;
552
- snipObje.sourceMsgId = response.sourceMsgId || '';
553
- snipObje.intType = response.intType;
554
- snipObje.isFromGeneratedSummary = response.isFromGeneratedSummary;
555
- snipObje.userInput = response.userInput || '';
556
- }
557
- });
558
- var extInfo_1 = '';
559
- var interlInfo_1 = '';
560
- var uniqueSource_1 = [];
561
- (_a = snipObje['contentArray']) === null || _a === void 0 ? void 0 : _a.forEach(function (entry) {
562
- var _a;
563
- var _b;
564
- var className = '';
565
- (_a = snipObje.sources).push.apply(_a, ((entry === null || entry === void 0 ? void 0 : entry.sources) || []).filter(function (item) {
566
- var returnValue = item.url && uniqueSource_1.indexOf(item.title) == -1;
567
- if (returnValue) {
568
- uniqueSource_1.push(item.title);
569
- }
570
- if (uniqueSource_1.indexOf(item.title) != -1) {
571
- className += "fragment-ext-".concat(uniqueSource_1.indexOf(item.title) + 1, "-").concat(suggestionIndex);
572
- }
573
- return returnValue;
574
- }));
575
- if (!entry.internalFlag) {
576
- snipObje['sendCopyText'] += entry.ans;
577
- }
578
- var temp = "<span class=\"".concat(className, "\">").concat(entry.ans, " ");
579
- if (Array.isArray(entry === null || entry === void 0 ? void 0 : entry.sources) && ((_b = entry === null || entry === void 0 ? void 0 : entry.sources) === null || _b === void 0 ? void 0 : _b.length)) {
580
- for (var _i = 0, _c = entry === null || entry === void 0 ? void 0 : entry.sources; _i < _c.length; _i++) {
581
- var source = _c[_i];
582
- if ((source === null || source === void 0 ? void 0 : source.title) && uniqueSource_1.indexOf(source === null || source === void 0 ? void 0 : source.title) != -1) {
583
- var srcCount = uniqueSource_1.indexOf(source.title);
584
- temp += "<span class=\"source-count-num\">".concat(srcCount + 1, "</span>");
585
- }
586
- }
587
- }
588
- temp += '</span>';
589
- if (entry.internalFlag) {
590
- interlInfo_1 += temp;
591
- }
592
- else {
593
- extInfo_1 += temp;
594
- }
595
- });
596
- snipObje['contentArray'] = [];
597
- snipObje['internalInfo'] = [];
598
- if (interlInfo_1 === null || interlInfo_1 === void 0 ? void 0 : interlInfo_1.trim()) {
599
- snipObje['internalInfo'].push(interlInfo_1 === null || interlInfo_1 === void 0 ? void 0 : interlInfo_1.trim());
600
- }
601
- if (extInfo_1 === null || extInfo_1 === void 0 ? void 0 : extInfo_1.trim()) {
602
- snipObje['contentArray'].push(extInfo_1 === null || extInfo_1 === void 0 ? void 0 : extInfo_1.trim());
603
- }
604
- snipObje.feedbackData = this.prepareFeedbackForSuggestions('answer', snipObje, {});
605
- snippetResponeArray.push(snipObje);
606
- }
607
- return snippetResponeArray;
608
- };
609
- rootService.prototype.updateSearchResponse = function (assistResponseArray, response, ambiguityTokenExt) {
610
- var _a, _b, _c, _d;
611
- response.suggestions.faqs = this.formatFAQResponse(response.suggestions.faqs);
612
- var faqWithoutAnswerIndex = (_b = (_a = response === null || response === void 0 ? void 0 : response.suggestions) === null || _a === void 0 ? void 0 : _a.faqs) === null || _b === void 0 ? void 0 : _b.findIndex(function (faq, index) {
613
- if (faq.question === ambiguityTokenExt.question) {
614
- return faq;
615
- }
616
- });
617
- var faqWithoutAnswer = {};
618
- if (faqWithoutAnswerIndex >= 0) {
619
- faqWithoutAnswer = (_c = response === null || response === void 0 ? void 0 : response.suggestions) === null || _c === void 0 ? void 0 : _c.faqs[faqWithoutAnswerIndex];
620
- }
621
- if (faqWithoutAnswer && ((_d = Object.keys(faqWithoutAnswer)) === null || _d === void 0 ? void 0 : _d.length) > 0) {
622
- var updatedArray = assistResponseArray.map(function (item, idx) {
623
- var _a;
624
- if (idx === ambiguityTokenExt.assistSuggestion) {
625
- var updatedItem = __assign({}, item);
626
- var existingFaq = (_a = updatedItem.searchResponse) === null || _a === void 0 ? void 0 : _a.faqs[ambiguityTokenExt.index];
627
- if (existingFaq && faqWithoutAnswer && (faqWithoutAnswer === null || faqWithoutAnswer === void 0 ? void 0 : faqWithoutAnswer.answer)) {
628
- existingFaq.answer = faqWithoutAnswer === null || faqWithoutAnswer === void 0 ? void 0 : faqWithoutAnswer.answer;
629
- existingFaq.toggle = true;
630
- existingFaq.showMoreButton = false;
631
- existingFaq.showLessButton = false;
632
- existingFaq.showSpinner = false;
633
- }
634
- updatedItem.faqArrowClickResponse = true;
635
- return updatedItem;
636
- }
637
- return item;
638
- });
639
- return updatedArray;
640
- }
641
- };
642
- rootService.prototype.checkEmptyObjectsInArray = function (arr) {
643
- arr = arr.filter(function (obj) { var _a; return (obj && ((_a = Object.keys(obj)) === null || _a === void 0 ? void 0 : _a.length) > 0) && (obj.title || obj.content); });
644
- return arr;
645
- };
646
- rootService.prototype.formatFAQResponse = function (faqArray) {
647
- var _a, _b;
648
- var searchResponse = [];
649
- if (faqArray && (faqArray === null || faqArray === void 0 ? void 0 : faqArray.length) > 0) {
650
- for (var _i = 0, faqArray_2 = faqArray; _i < faqArray_2.length; _i++) {
651
- var faq = faqArray_2[_i];
652
- var faqObject = {
653
- question: faq.question,
654
- taskRefId: faq === null || faq === void 0 ? void 0 : faq.taskRefId,
655
- answer: ((faq === null || faq === void 0 ? void 0 : faq.answer) && ((_a = faq === null || faq === void 0 ? void 0 : faq.answer) === null || _a === void 0 ? void 0 : _a.length) > 0) ? [] : false
656
- };
657
- if (faq.answer && faq.answer.length > 0) {
658
- for (var _c = 0, _d = faq.answer; _c < _d.length; _c++) {
659
- var ans = _d[_c];
660
- var object = {
661
- taskRefId: faq.taskRefId,
662
- ans: ans,
663
- showMoreButton: true,
664
- showLessButton: false,
665
- };
666
- (_b = faqObject === null || faqObject === void 0 ? void 0 : faqObject.answer) === null || _b === void 0 ? void 0 : _b.push(object);
667
- }
668
- }
669
- searchResponse.push(faqObject);
670
- }
671
- }
672
- return searchResponse;
673
- };
674
- rootService.prototype.openurlInBrowser = function (url, hostInstance) {
675
- var _a, _b, _c;
676
- // window.open(url, '_blank');
677
- if (((_a = this.aaSettings) === null || _a === void 0 ? void 0 : _a.urlOpenBehaviour) && ((_c = (_b = this.aaSettings) === null || _b === void 0 ? void 0 : _b.urlOpenBehaviour) === null || _c === void 0 ? void 0 : _c.sendPostEvent)) {
678
- var message = {
679
- method: 'AgentAssist.UrlClickedMessage',
680
- from: 'agent_assist',
681
- url: url
682
- };
683
- // window.parent.postMessage(message, '*');
684
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ON_URL_CLICK, data: { message: message } });
685
- }
686
- else {
687
- window.open(url, '_blank');
688
- }
689
- };
690
- rootService.prototype.extractTextFromElement = function (element) {
691
- var text = '';
692
- if (element) {
693
- var extractText_1 = function (node) {
694
- if (node.nodeType === Node.TEXT_NODE) {
695
- text += node.textContent;
696
- }
697
- else if (node.nodeType === Node.ELEMENT_NODE) {
698
- var childNodes = node.childNodes;
699
- for (var i = 0; i < childNodes.length; i++) {
700
- extractText_1(childNodes[i]);
701
- }
702
- }
703
- };
704
- extractText_1(element);
705
- }
706
- return text.trim();
707
- };
708
- rootService.prototype.handleSendCopyButton = function (actionType, faq_or_article_obj, selectType) {
709
- var message = {};
710
- if (actionType == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND) {
711
- message = {
712
- method: 'send',
713
- name: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SENDMSG,
714
- conversationId: this.connectionDetails.conversationId,
715
- // payload: selectType == ProjConstants.FAQ ? (faq_or_article_obj.answer || faq_or_article_obj.ans) : faq_or_article_obj.content
716
- payload: faq_or_article_obj.sendContent
717
- };
718
- if (selectType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE) {
719
- message['title'] = faq_or_article_obj.title;
720
- message['contentId'] = faq_or_article_obj.contentId;
721
- }
722
- else {
723
- message['title'] = faq_or_article_obj.displayName;
724
- message['contentId'] = faq_or_article_obj.taskRefId;
725
- }
726
- }
727
- else {
728
- message = {
729
- method: 'copy',
730
- name: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPYMSG,
731
- conversationId: this.connectionDetails.conversationId,
732
- // payload: selectType == ProjConstants.FAQ ? (faq_or_article_obj.answer || faq_or_article_obj.ans) : faq_or_article_obj.content
733
- payload: faq_or_article_obj.sendContent
734
- };
735
- if (selectType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE) {
736
- message['title'] = faq_or_article_obj.title;
737
- message['contentId'] = faq_or_article_obj.contentId;
738
- }
739
- else {
740
- message['title'] = faq_or_article_obj.displayName;
741
- message['contentId'] = faq_or_article_obj.taskRefId;
742
- }
743
- }
744
- message['type'] = (selectType == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ) ? 'faq' : 'article';
745
- // window.parent.postMessage(message, '*');
746
- return (this.faqArticleSendorCopyEvent(selectType, message, faq_or_article_obj));
747
- };
748
- rootService.prototype.faqArticleSendorCopyEvent = function (selectType, message, faq_or_article_obj) {
749
- var _a, _b;
750
- var data = {
751
- botId: this.connectionDetails.botId,
752
- conversationId: this.connectionDetails.conversationId,
753
- experience: (_a = this.connectionDetails) === null || _a === void 0 ? void 0 : _a.channel,
754
- source: this.connectionDetails.source,
755
- usedType: message.method,
756
- type: message.type,
757
- name: message.name,
758
- payload: message.payload,
759
- title: message.title,
760
- contentId: message.contentId,
761
- positionId: faq_or_article_obj.positionId ? faq_or_article_obj.positionId : '',
762
- sessionId: (this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.MYBOT || this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.SEARCH) ? this.myBotTabSessionId : this.assistTabSessionId,
763
- };
764
- data = this.addSourceMsgIdToRequestParams(faq_or_article_obj, data);
765
- if (this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.SEARCH) {
766
- data.skipMsg = this.sentSearchResponse;
767
- data.input = ((_b = this.searchedResultData) === null || _b === void 0 ? void 0 : _b.userInput) || '';
768
- this.sentSearchResponse = true;
769
- }
770
- if (faq_or_article_obj.subType) {
771
- data.subType = faq_or_article_obj.subType;
772
- }
773
- return data;
774
- };
775
- rootService.prototype.addSourceMsgIdToRequestParams = function (data, requestParams) {
776
- if (data.sourceMsgId) {
777
- if (data.sourceMsgId == 'fromLibrary') {
778
- requestParams['fromLibrary'] = true;
779
- }
780
- else {
781
- requestParams['sourceMsgId'] = data.sourceMsgId;
782
- }
783
- }
784
- return requestParams;
785
- };
786
- rootService.prototype.addSentOrCopiedTextForFaqs = function (ansObj, ele, sendText, hostInstance) {
787
- this.sendTextAddAndEmitEvent('faqs', ansObj, ele, sendText, hostInstance);
788
- };
789
- rootService.prototype.addSentOrCopiedTextForFiles = function (file, ele, sendText, hostInstance) {
790
- this.sendTextAddAndEmitEvent('file', file, ele, sendText, hostInstance);
791
- };
792
- rootService.prototype.addSentOrCopiedTextForArticle = function (article, ele, sendText, hostInstance) {
793
- this.sendTextAddAndEmitEvent('article', article, ele, sendText, hostInstance);
794
- };
795
- rootService.prototype.addSentOrCopiedTextForSnippets = function (snippet, ele, sendText, hostInstance) {
796
- this.sendTextAddAndEmitEvent('snippet', snippet, ele, sendText, hostInstance);
797
- };
798
- rootService.prototype.sendTextAddAndEmitEvent = function (type, suggestionObj, ele, sendText, hostInstance) {
799
- var _a;
800
- if (!suggestionObj.send) {
801
- suggestionObj.send = sendText;
802
- var eachSuggestionSentText = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.ActionButtonsSentText, (_a = {}, _a[type] = suggestionObj, _a), hostInstance);
803
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, eachSuggestionSentText, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.SENT_BUTTON_TEMPLATE, data: suggestionObj });
804
- ele.querySelector(this.classConstants.SUGGESTION_EACH_TITLE).append(eachSuggestionSentText);
805
- }
806
- if (typeof this.prefsOpacity === 'number') {
807
- ele.style.opacity = (this.prefsOpacity / 100);
808
- }
809
- var sendTextele = ele.querySelector(this.classConstants.SEND_TEXT);
810
- sendTextele.textContent = sendText;
811
- };
812
- rootService.prototype.handleSendCopyButtonForFaq = function (actionType, ansObj, selectType, sourceMsgId, faqListHTMLEle, hostInstance) {
813
- // let faqTemplate = this.faqcontent.find((element : any, index : any) => index === inx);
814
- // let faqTemplate = faqList[inx];
815
- ansObj.sourceMsgId = sourceMsgId;
816
- ansObj.sendContent = ansObj.answer || ansObj.ans;
817
- var node = faqListHTMLEle.querySelector('p');
818
- ansObj.sendContent = this.prepareSendText(ansObj.sendContent, false, node);
819
- var copyEventData = this.handleSendCopyButton(actionType, ansObj, selectType);
820
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
821
- };
822
- rootService.prototype.handleSendCopyButtonForSnippet = function (actionType, snippetObj, selectType, snippetListHTMLEle, hostInstance) {
823
- snippetObj.sendContent = (snippetObj.sendCopyText);
824
- var node = snippetListHTMLEle.querySelector('p');
825
- snippetObj.sendContent = this.prepareSendText(snippetObj.sendContent, false, node);
826
- var copyEventData = this.handleSendCopyButton(actionType, snippetObj, selectType);
827
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
828
- };
829
- rootService.prototype.handleSendCopyButtonArticleOrFile = function (actionType, articleObj, selectType, articleListHTMLEle, hostInstance) {
830
- articleObj.sendContent = articleObj.content;
831
- var node = articleListHTMLEle.querySelector('p');
832
- articleObj.sendContent = this.prepareSendText(articleObj.sendContent, false, node);
833
- var copyEventData = this.handleSendCopyButton(actionType, articleObj, selectType);
834
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
835
- };
836
- ;
837
- rootService.prototype.handleActionTemplateClickEventsForFAQ = function (eachActionTemplate, faq, ansObj, faqListHTMLEle, hostInstance) {
838
- var _this = this;
839
- var _a, _b;
840
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
841
- _this.handleSendCopyButtonForFaq(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, ansObj, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ, faq.sourceMsgId, faqListHTMLEle, hostInstance);
842
- _this.addSentOrCopiedTextForFaqs(ansObj, faqListHTMLEle, 'Sent', hostInstance);
843
- }, eachActionTemplate);
844
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
845
- _this.handleSendCopyButtonForFaq(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, ansObj, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ, faq.sourceMsgId, faqListHTMLEle, hostInstance);
846
- _this.addSentOrCopiedTextForFaqs(ansObj, faqListHTMLEle, 'Copied', hostInstance);
847
- }, eachActionTemplate);
848
- };
849
- rootService.prototype.emitSendOrCopyEvent = function (copyEventData, hostInstance) {
850
- if ((copyEventData === null || copyEventData === void 0 ? void 0 : copyEventData.usedType) === 'send') {
851
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_SEND_MESSAGE, data: copyEventData, msg: copyEventData === null || copyEventData === void 0 ? void 0 : copyEventData.payload });
852
- }
853
- else {
854
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_COPY_MESSAGE, data: copyEventData, msg: copyEventData === null || copyEventData === void 0 ? void 0 : copyEventData.payload });
855
- }
856
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, copyEventData);
857
- };
858
- rootService.prototype.handleFaqExpandCloseBtnClickEvents = function (expandClostBtnTemplate, faqSuggestionBodyList, suggestionHeaderActionTemplate, faqListHTMLIndex, hostInstance) {
859
- var _this = this;
860
- var _a, _b;
861
- var expandElement = expandClostBtnTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_EXPAND);
862
- var closeElement = expandClostBtnTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_CLOSE);
863
- var faqAnsLenghtElement = faqListHTMLIndex === null || faqListHTMLIndex === void 0 ? void 0 : faqListHTMLIndex.querySelector("".concat(this.classConstants.SUGGESTION_EACH_HEADER, " ").concat(this.classConstants.SUGGESTION_EACH_TITLE, " ").concat(this.classConstants.SUGGESTION_FAQ_ANS_LENGTH));
864
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_FAQ_EXPAND, 'click', function () {
865
- var _a, _b, _c, _d, _e, _f, _g, _h;
866
- if ((_a = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
867
- (_b = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
868
- }
869
- (_c = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
870
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
871
- var _a, _b;
872
- if ((_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
873
- (_b = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
874
- }
875
- });
876
- (_d = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _d === void 0 ? void 0 : _d.add(_this.classConstants.HIDE_ELEMENT);
877
- //hide header send copy btns
878
- (_e = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
879
- //add send copy btns for first answer
880
- var firstAnswerActionBtn = (_f = faqSuggestionBodyList[0]) === null || _f === void 0 ? void 0 : _f.querySelector(_this.classConstants.SUGGESTION_SENDCPY_ACTION);
881
- if ((_g = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _g === void 0 ? void 0 : _g.contains(_this.classConstants.HIDE_ELEMENT)) {
882
- (_h = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _h === void 0 ? void 0 : _h.remove(_this.classConstants.HIDE_ELEMENT);
883
- }
884
- }, expandClostBtnTemplate);
885
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_FAQ_CLOSE, 'click', function () {
886
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
887
- if ((_a = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
888
- (_b = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
889
- }
890
- (_c = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
891
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
892
- var _a;
893
- if (index != 0) {
894
- (_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
895
- }
896
- });
897
- if ((_d = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _d === void 0 ? void 0 : _d.contains(_this.classConstants.HIDE_ELEMENT)) {
898
- (_e = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _e === void 0 ? void 0 : _e.remove(_this.classConstants.HIDE_ELEMENT);
899
- }
900
- //show header send copy btns
901
- if ((_f = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _f === void 0 ? void 0 : _f.contains(_this.classConstants.HIDE_ELEMENT)) {
902
- (_g = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _g === void 0 ? void 0 : _g.remove(_this.classConstants.HIDE_ELEMENT);
903
- }
904
- //remove send copy btns for first answer
905
- var firstAnswerActionBtn = (_h = faqSuggestionBodyList[0]) === null || _h === void 0 ? void 0 : _h.querySelector(_this.classConstants.SUGGESTION_SENDCPY_ACTION);
906
- (_j = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _j === void 0 ? void 0 : _j.add(_this.classConstants.HIDE_ELEMENT);
907
- }, expandClostBtnTemplate);
908
- };
909
- rootService.prototype.handleActionTemplateClickEventsForSnippet = function (eachActionTemplate, snippet, snippetListHtmlEle, hostInstance) {
910
- var _this = this;
911
- var _a, _b;
912
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
913
- _this.handleSendCopyButtonForSnippet(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, snippet, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, snippetListHtmlEle, hostInstance);
914
- _this.addSentOrCopiedTextForSnippets(snippet, snippetListHtmlEle, 'Sent', hostInstance);
915
- }, eachActionTemplate);
916
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
917
- _this.handleSendCopyButtonForSnippet(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, snippet, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, snippetListHtmlEle, hostInstance);
918
- _this.addSentOrCopiedTextForSnippets(snippet, snippetListHtmlEle, 'Copied', hostInstance);
919
- }, eachActionTemplate);
920
- };
921
- rootService.prototype.handleActionTemplateClickEventsForArticle = function (eachActionTemplate, article, articleListHtmlEle, hostInstance) {
922
- var _this = this;
923
- var _a, _b;
924
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
925
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, article, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, articleListHtmlEle, hostInstance);
926
- _this.addSentOrCopiedTextForArticle(article, articleListHtmlEle, 'Sent', hostInstance);
927
- if (articleListHtmlEle === null || articleListHtmlEle === void 0 ? void 0 : articleListHtmlEle.querySelector('.aa-agentic-search-results-title')) {
928
- hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.sendAgentMessage({
929
- author: {
930
- id: "authorids",
931
- type: 'AGENT',
932
- firstName: "first name",
933
- lastName: "last name"
934
- },
935
- message: (article === null || article === void 0 ? void 0 : article.sendContent) || '',
936
- type: 'USER',
937
- });
938
- }
939
- }, eachActionTemplate);
940
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
941
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, article, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, articleListHtmlEle, hostInstance);
942
- _this.addSentOrCopiedTextForArticle(article, articleListHtmlEle, 'Copied', hostInstance);
943
- if (articleListHtmlEle === null || articleListHtmlEle === void 0 ? void 0 : articleListHtmlEle.querySelector('.aa-agentic-search-results-title')) {
944
- hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.sendAgentMessage({
945
- author: {
946
- id: "authorids",
947
- type: 'AGENT',
948
- firstName: "first name",
949
- lastName: "last name"
950
- },
951
- message: (article === null || article === void 0 ? void 0 : article.sendContent) || '',
952
- type: 'USER',
953
- });
954
- }
955
- }, eachActionTemplate);
956
- };
957
- rootService.prototype.handleActionTemplateClickEventsForFile = function (eachActionTemplate, file, fileListHtmlEle, hostInstance) {
958
- var _this = this;
959
- var _a, _b;
960
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
961
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, file, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, fileListHtmlEle, hostInstance);
962
- _this.addSentOrCopiedTextForFiles(file, fileListHtmlEle, 'Sent', hostInstance);
963
- }, eachActionTemplate);
964
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
965
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, file, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, fileListHtmlEle, hostInstance);
966
- _this.addSentOrCopiedTextForFiles(file, fileListHtmlEle, 'Copied', hostInstance);
967
- }, eachActionTemplate);
968
- };
969
- rootService.prototype.handleSuggestionLessClickEvent = function (actionHtml, suggestionElement, listHtml, hostInstance) {
970
- var _this = this;
971
- var _a;
972
- var moreElement = actionHtml.querySelector(this.classConstants.SUGGESTION_MORE_LINK);
973
- var lessElement = actionHtml.querySelector(this.classConstants.SUGGESTION_LESS_LINK);
974
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_MORE_LINK, 'click', function () {
975
- var _a, _b, _c;
976
- if ((_a = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
977
- (_b = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
978
- }
979
- (_c = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
980
- listHtml.forEach(function (item) {
981
- var _a, _b;
982
- if ((_a = item === null || item === void 0 ? void 0 : item.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
983
- (_b = item === null || item === void 0 ? void 0 : item.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
984
- }
985
- });
986
- }, suggestionElement);
987
- };
988
- rootService.prototype.handleSuggestionMoreClickEvent = function (actionHtml, suggestionElement, listHtml, hostInstance) {
989
- var _this = this;
990
- var _a;
991
- var moreElement = actionHtml.querySelector(this.classConstants.SUGGESTION_MORE_LINK);
992
- var lessElement = actionHtml.querySelector(this.classConstants.SUGGESTION_LESS_LINK);
993
- (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_LESS_LINK, 'click', function () {
994
- var _a, _b, _c;
995
- if ((_a = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
996
- (_b = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
997
- }
998
- (_c = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
999
- listHtml.forEach(function (item, inx) {
1000
- var _a;
1001
- if (inx >= 2 && item) {
1002
- (_a = item === null || item === void 0 ? void 0 : item.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
1003
- }
1004
- });
1005
- }, suggestionElement);
1006
- };
1007
- rootService.prototype.setFaqIndividualLoader = function (inx, hide, id, hostInstance) {
1008
- var _this = this;
1009
- var _a, _b, _c, _d, _e;
1010
- if (hide === void 0) { hide = false; }
1011
- var faqSuggestionEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("#".concat(id));
1012
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
1013
- var faqLoaderEle = null;
1014
- if (faqListHTML && (faqListHTML === null || faqListHTML === void 0 ? void 0 : faqListHTML.length) > 0) {
1015
- faqLoaderEle = (_b = faqListHTML[inx]) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.SUGGESTION_EACH_HEADER, " ").concat(this.classConstants.SUGGESTION_EACH_TITLE, " ").concat(this.classConstants.SUGGESTION_FAQ_ANS_LOADER));
1016
- }
1017
- if (hide && faqLoaderEle) {
1018
- (_c = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
1019
- }
1020
- else if (faqLoaderEle) {
1021
- if ((_d = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _d === void 0 ? void 0 : _d.contains(this.classConstants.HIDE_ELEMENT)) {
1022
- (_e = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
1023
- }
1024
- setTimeout(function () {
1025
- var _a;
1026
- (_a = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
1027
- }, 10000);
1028
- }
1029
- };
1030
- rootService.prototype.addOrHideFAQArrows = function (faqUpArrowTemplate, faqDownArrowTemplate, type) {
1031
- var _a, _b, _c, _d, _e, _f;
1032
- if (type === 'up') {
1033
- if ((_a = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(this.classConstants.HIDE_ELEMENT)) {
1034
- (_b = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(this.classConstants.HIDE_ELEMENT);
1035
- }
1036
- (_c = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
1037
- }
1038
- else {
1039
- if ((_d = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _d === void 0 ? void 0 : _d.contains(this.classConstants.HIDE_ELEMENT)) {
1040
- (_e = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
1041
- }
1042
- (_f = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _f === void 0 ? void 0 : _f.add(this.classConstants.HIDE_ELEMENT);
1043
- }
1044
- };
1045
- rootService.prototype.toggleArrows = function (index, faqId, hostInstance) {
1046
- var _a, _b;
1047
- var faqSuggestionEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("#".concat(faqId));
1048
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
1049
- if (faqListHTML) {
1050
- var suggestionHeaderTemplate = (_b = faqListHTML[index]) === null || _b === void 0 ? void 0 : _b.querySelector(this.classConstants.SUGGESTION_EACH_HEADER);
1051
- var faqUpArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_UP_ARROW);
1052
- var faqDownArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_DOWN_ARROW);
1053
- this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'down');
1054
- }
1055
- };
1056
- rootService.prototype.openLinksInBrowser = function (url, hostInstance) {
1057
- this.openurlInBrowser(url, hostInstance);
1058
- };
1059
- ;
1060
- rootService.prototype.openurlInBrowserForSnippet = function (url, snippet, hostInstance) {
1061
- this.openurlInBrowser(url, hostInstance);
1062
- this.handleUrlClickEvent(url, snippet, hostInstance);
1063
- };
1064
- rootService.prototype.handleUrlClickEvent = function (url, snippet, hostInstance) {
1065
- var socketRequestParams = this.commonRequestParamsForActivity(snippet);
1066
- socketRequestParams.eventType = "url_clicked";
1067
- socketRequestParams.url = url;
1068
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_activity_request, socketRequestParams);
1069
- };
1070
- rootService.prototype.commonRequestParamsForActivity = function (snippet) {
1071
- var _a;
1072
- var _b = this.connectionDetails, botId = _b.botId, conversationId = _b.conversationId, channel = _b.channel;
1073
- var socketRequestParams = {
1074
- botId: botId,
1075
- conversationId: conversationId,
1076
- event: "clicked",
1077
- sourceMsgId: snippet.sourceMsgId,
1078
- dataSource: "snippet",
1079
- positionId: snippet.positionId,
1080
- participant: ((_a = this === null || this === void 0 ? void 0 : this.internalTransferData) === null || _a === void 0 ? void 0 : _a.participant) || {}
1081
- };
1082
- return socketRequestParams;
1083
- };
1084
- rootService.prototype.emitSearchRequestForAssistSuggestions = function (value, isSearch, faq, hostInstance) {
1085
- var connectionDetails = Object.assign({}, this.connectionDetails);
1086
- connectionDetails.value = value;
1087
- connectionDetails.isSearch = isSearch;
1088
- // connectionDetails.positionId = searchObj?.positionId;
1089
- if (connectionDetails.interactiveLanguage && typeof connectionDetails.interactiveLanguage == 'string' && connectionDetails.interactiveLanguage != "''") {
1090
- connectionDetails['language'] = connectionDetails.interactiveLanguage; // Return the default value for null, undefined, or "''"
1091
- }
1092
- if (faq.sourceMsgId) {
1093
- connectionDetails['sourceMsgId'] = faq.sourceMsgId;
1094
- }
1095
- var agent_assist_request_params = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
1096
- if (faq.ambiguityToken) {
1097
- agent_assist_request_params.uiunqref = faq.ambiguityToken;
1098
- }
1099
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, agent_assist_request_params);
1100
- };
1101
- rootService.prototype.emitSearchRequestForSearch = function (searchTextObj, isSearch, faq, hostInstance) {
1102
- var _a, _b, _c;
1103
- if (faq === void 0) { faq = {}; }
1104
- var searchTextValue = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.value;
1105
- var connectionDetails = __assign(__assign({}, (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.socketConnection) === null || _a === void 0 ? void 0 : _a.configOptions) === null || _b === void 0 ? void 0 : _b.connectionDetails), { value: searchTextValue, isSearch: isSearch });
1106
- if (connectionDetails.interactiveLanguage && typeof connectionDetails.interactiveLanguage === 'string' && connectionDetails.interactiveLanguage !== "''") {
1107
- connectionDetails.language = connectionDetails.interactiveLanguage;
1108
- }
1109
- if (faq && ((faq === null || faq === void 0 ? void 0 : faq.sourceMsgId) || (faq === null || faq === void 0 ? void 0 : faq.reqId))) {
1110
- connectionDetails.sourceMsgId = (faq === null || faq === void 0 ? void 0 : faq.sourceMsgId) || (faq === null || faq === void 0 ? void 0 : faq.reqId);
1111
- }
1112
- var agentAssistAgentRequestParams = hostInstance.prepareAgentAssistAgentRequestParams(connectionDetails);
1113
- if (isSearch) {
1114
- agentAssistAgentRequestParams.startTime = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.stTime;
1115
- agentAssistAgentRequestParams.endTime = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.edTime;
1116
- }
1117
- if (faq.ambiguityToken) {
1118
- agentAssistAgentRequestParams.uiunqref = faq.ambiguityToken;
1119
- }
1120
- // Use reqId from searchTextObj if available (for conversation search)
1121
- if ((searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.isConversationalSearch) && (searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.reqId)) {
1122
- agentAssistAgentRequestParams.reqId = searchTextObj.reqId;
1123
- }
1124
- // Also check faq parameter (existing logic)
1125
- if ((faq === null || faq === void 0 ? void 0 : faq.isConversationalSearch) && (faq === null || faq === void 0 ? void 0 : faq.reqId)) {
1126
- agentAssistAgentRequestParams.reqId = faq === null || faq === void 0 ? void 0 : faq.reqId;
1127
- }
1128
- agentAssistAgentRequestParams.participant = ((_c = this.internalTransferData) === null || _c === void 0 ? void 0 : _c.participant) || {};
1129
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, agentAssistAgentRequestParams);
1130
- };
1131
- ;
1132
- rootService.prototype.handleFaqAmbiguityDescElement = function (faqId, ambiguityToken, faqs, hostInstance) {
1133
- var _a, _b, _c, _d, _e;
1134
- var faqSuggestionEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("#".concat(faqId));
1135
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
1136
- var faqinx = ambiguityToken === null || ambiguityToken === void 0 ? void 0 : ambiguityToken.index;
1137
- var descEle;
1138
- var faqwithAns = faqs[faqinx];
1139
- this.setFaqIndividualLoader(faqinx, true, faqId, hostInstance);
1140
- if (faqwithAns && ((_b = faqwithAns === null || faqwithAns === void 0 ? void 0 : faqwithAns.answer) === null || _b === void 0 ? void 0 : _b.length) > 0 && faqListHTML[faqinx]) {
1141
- descEle = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_3__.FaqAnswerPlacement, { faq: faqwithAns, hostInstance: hostInstance }, hostInstance);
1142
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, descEle, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FAQ_ANSWER_AFTER_TOGGLE, data: faqs });
1143
- if (descEle) {
1144
- var feedbackWrapper = (_d = (_c = faqListHTML[faqinx]) === null || _c === void 0 ? void 0 : _c.querySelector) === null || _d === void 0 ? void 0 : _d.call(_c, "".concat(this.classConstants.FEEDBACK_WRAPPER).concat(faqwithAns === null || faqwithAns === void 0 ? void 0 : faqwithAns.positionId));
1145
- if (feedbackWrapper) {
1146
- faqListHTML[faqinx].insertBefore(descEle, feedbackWrapper);
1147
- }
1148
- else {
1149
- faqListHTML[faqinx].append(descEle);
1150
- }
1151
- this.handleSeeMoreButtonsForFaq(faqSuggestionEle, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.DESC_TEXT_SUGGESTION, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.MORE_BTN_CONTAINER, hostInstance, faqinx);
1152
- }
1153
- }
1154
- var suggestionHeaderTemplate = (_e = faqListHTML[faqinx]) === null || _e === void 0 ? void 0 : _e.querySelector(this.classConstants.SUGGESTION_EACH_HEADER);
1155
- this.addOrHideFAQActionExpandCloseElements(faqwithAns, suggestionHeaderTemplate, faqListHTML, faqinx, hostInstance);
1156
- };
1157
- rootService.prototype.handleFaqToggle = function (faq, index, type, faqListHTML, hostInstance, isAssistSuggestion, props) {
1158
- var _this = this;
1159
- var _a;
1160
- faq.toggle = !faq.toggle;
1161
- faq.seeMoreWrapper = false;
1162
- var faqSuggestionBodyList = (_a = faqListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelectorAll(this.classConstants.SUGGESTION_EACH_BODY);
1163
- if (type == 'down' && !faq.answer) {
1164
- if (isAssistSuggestion) {
1165
- this.checkAnswerAndToggleForAssist(faq, index, hostInstance, props);
1166
- }
1167
- else {
1168
- this.checkAnswerAndToggleForSearch(faq, index, hostInstance);
1169
- }
1170
- }
1171
- else if (type == 'down' && faq.answer) {
1172
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
1173
- var _a, _b;
1174
- if ((_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
1175
- (_b = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
1176
- }
1177
- });
1178
- }
1179
- else if (type == 'up') {
1180
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
1181
- var _a;
1182
- (_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
1183
- });
1184
- }
1185
- };
1186
- rootService.prototype.checkAnswerAndToggleForAssist = function (faq, index, hostInstance, props) {
1187
- if (!faq.answer && faq.toggle) {
1188
- faq.ambiguityToken = btoa(JSON.stringify({ question: faq.question, index: index, assistSuggestion: props.suggestionIndex }));
1189
- this.emitSearchRequestForAssistSuggestions(faq.displayName, false, faq, hostInstance);
1190
- var faqId = this.idConstants.ASSIST_FAQ_SUGGESTION + props.suggestionIndex;
1191
- this.setFaqIndividualLoader(index, false, faqId, hostInstance);
1192
- }
1193
- };
1194
- ;
1195
- rootService.prototype.checkAnswerAndToggleForSearch = function (faq, index, hostInstance) {
1196
- if (!faq.answer && faq.toggle) {
1197
- faq.ambiguityToken = btoa(JSON.stringify({ question: faq.question, index: index }));
1198
- this.emitSearchRequestForSearch({ value: faq.displayName }, false, faq, hostInstance);
1199
- var faqId = (faq === null || faq === void 0 ? void 0 : faq.isConversationalSearch) ? this.idConstants.SEARCH_FAQ_SUGGESTION + '-xo' + (faq === null || faq === void 0 ? void 0 : faq.reqId) : this.idConstants.SEARCH_FAQ_SUGGESTION + '-xo';
1200
- this.setFaqIndividualLoader(index, false, faqId, hostInstance);
1201
- }
1202
- };
1203
- rootService.prototype.renderEachFaqInSuggestionList = function (searchResponse, faqListHTML, hostInstance, isAssistSuggestion, props) {
1204
- var _this = this;
1205
- var _a;
1206
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.faqs) === null || _a === void 0 ? void 0 : _a.forEach(function (faq, index) {
1207
- var _a, _b, _c, _d;
1208
- var suggestionHeaderTemplate = (_a = faqListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER);
1209
- var faqUpArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(_this.classConstants.SUGGESTION_FAQ_UP_ARROW);
1210
- var faqDownArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(_this.classConstants.SUGGESTION_FAQ_DOWN_ARROW);
1211
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_FAQ_UP_ARROW, 'click', function () {
1212
- _this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'up');
1213
- _this.handleFaqToggle(faq, index, 'up', faqListHTML, hostInstance, isAssistSuggestion, props);
1214
- }, suggestionHeaderTemplate);
1215
- (_c = hostInstance.eventManager) === null || _c === void 0 ? void 0 : _c.addEventListener(_this.classConstants.SUGGESTION_FAQ_DOWN_ARROW, 'click', function () {
1216
- _this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'down');
1217
- _this.handleFaqToggle(faq, index, 'down', faqListHTML, hostInstance, isAssistSuggestion, props);
1218
- }, suggestionHeaderTemplate);
1219
- if (faq.answer && ((_d = faq === null || faq === void 0 ? void 0 : faq.answer) === null || _d === void 0 ? void 0 : _d.length) > 0 && !_this.hideActionButtons) {
1220
- _this.addOrHideFAQActionExpandCloseElements(faq, suggestionHeaderTemplate, faqListHTML, index, hostInstance);
1221
- }
1222
- });
1223
- };
1224
- rootService.prototype.renderEachSnippetInSuggestionList = function (searchResponse, snippetListHtml, hostInstance) {
1225
- var _this = this;
1226
- var _a;
1227
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.snippets) === null || _a === void 0 ? void 0 : _a.forEach(function (snippet, index) {
1228
- var _a, _b;
1229
- if (snippet.contentArray.length > 0) {
1230
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { snippet: snippet, hostInstance: hostInstance, rootServiceInstance: hostInstance.rootService }, hostInstance);
1231
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1232
- (_a = snippetListHtml[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
1233
- _this.handleActionTemplateClickEventsForSnippet(eachActionTemplate, snippet, snippetListHtml[index], hostInstance);
1234
- }
1235
- }
1236
- var sourceListHtml = snippetListHtml[index].querySelectorAll(_this.classConstants.SUGGESTION_SNIPPET_SOURCE_TAG);
1237
- (_b = snippet.sources) === null || _b === void 0 ? void 0 : _b.forEach(function (source, inx) {
1238
- var _a;
1239
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.SUGGESTION_SNIPPET_LINK, 'click', function () {
1240
- _this.openurlInBrowserForSnippet(source.url, snippet, hostInstance);
1241
- }, sourceListHtml[inx]);
1242
- });
1243
- });
1244
- };
1245
- rootService.prototype.handleSendCopyForAgenticSearchResults = function (agenticSearchResultsElement, response, hostInstance) {
1246
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { agenticSearchResultsElement: agenticSearchResultsElement, hostInstance: hostInstance, rootServiceInstance: hostInstance.rootService }, hostInstance);
1247
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1248
- agenticSearchResultsElement === null || agenticSearchResultsElement === void 0 ? void 0 : agenticSearchResultsElement.querySelector(this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
1249
- this.handleActionTemplateClickEventsForArticle(eachActionTemplate, response === null || response === void 0 ? void 0 : response.response, agenticSearchResultsElement, hostInstance);
1250
- }
1251
- };
1252
- rootService.prototype.renderEachArticleInSuggestionList = function (searchResponse, articlesListHTML, hostInstance) {
1253
- var _this = this;
1254
- var _a;
1255
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.articles) === null || _a === void 0 ? void 0 : _a.forEach(function (article, index) {
1256
- var _a, _b;
1257
- if ((article === null || article === void 0 ? void 0 : article.content) && !(article === null || article === void 0 ? void 0 : article.internalFlag)) {
1258
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { article: article, hostInstance: hostInstance, rootServiceInstance: hostInstance.rootService }, hostInstance);
1259
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1260
- (_a = articlesListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
1261
- _this.handleActionTemplateClickEventsForArticle(eachActionTemplate, article, articlesListHTML[index], hostInstance);
1262
- }
1263
- }
1264
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_ARTICLE_LINK, 'click', function () {
1265
- _this.openLinksInBrowser(article.link, hostInstance);
1266
- }, articlesListHTML[index]);
1267
- });
1268
- };
1269
- rootService.prototype.renderEachFileInSuggestionList = function (searchResponse, filesListHtml, hostInstance) {
1270
- var _this = this;
1271
- var _a;
1272
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.files) === null || _a === void 0 ? void 0 : _a.forEach(function (file, index) {
1273
- var _a, _b;
1274
- if ((file === null || file === void 0 ? void 0 : file.content) && !(file === null || file === void 0 ? void 0 : file.internalFlag)) {
1275
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { file: file, hostInstance: hostInstance, rootServiceInstance: hostInstance.rootService }, hostInstance);
1276
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1277
- (_a = filesListHtml[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
1278
- _this.handleActionTemplateClickEventsForFile(eachActionTemplate, file, filesListHtml[index], hostInstance);
1279
- }
1280
- }
1281
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_FILE_LINK, 'click', function () {
1282
- _this.openLinksInBrowser(file.link, hostInstance);
1283
- }, filesListHtml[index]);
1284
- });
1285
- };
1286
- // search
1287
- rootService.prototype.handleSearchText = function (searchText, hostInstance) {
1288
- var _a, _b;
1289
- if (searchText.isEntered) {
1290
- this.emitSearchRequestForSearch(searchText, true, {}, hostInstance);
1291
- }
1292
- var inputBlock = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(this.classConstants.SEARCH_INPUT_BLOCK);
1293
- var inputEle = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("#".concat(this.idConstants.SEARCH_INPUT));
1294
- if (inputBlock) {
1295
- var inputCloseIcon = inputBlock === null || inputBlock === void 0 ? void 0 : inputBlock.querySelector(this.classConstants.SEARCH_INPUT_CLOSE);
1296
- if (searchText.value) {
1297
- inputCloseIcon.classList.remove(this.classConstants.HIDE_ELEMENT);
1298
- }
1299
- else {
1300
- inputCloseIcon.classList.add(this.classConstants.HIDE_ELEMENT);
1301
- }
1302
- inputEle.value = searchText.value;
1303
- }
1304
- };
1305
- rootService.prototype.addOrHideFAQActionExpandCloseElements = function (faq, suggestionHeaderTemplate, faqListHTML, index, hostInstance) {
1306
- var _this = this;
1307
- var _a, _b, _c, _d, _e;
1308
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { ansObj: faq.answer[0], hostInstance: hostInstance, addHideClass: false, rootServiceInstance: hostInstance.rootService }, hostInstance);
1309
- if (suggestionHeaderTemplate && eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1310
- suggestionHeaderTemplate.append(eachActionTemplate);
1311
- this.handleActionTemplateClickEventsForFAQ(eachActionTemplate, faq, faq.answer[0], faqListHTML[index], hostInstance);
1312
- }
1313
- if (((_a = faq.answer) === null || _a === void 0 ? void 0 : _a.length) > 1) {
1314
- var faqSuggestionBodyList_1 = (_b = faqListHTML[index]) === null || _b === void 0 ? void 0 : _b.querySelectorAll(this.classConstants.SUGGESTION_EACH_BODY);
1315
- (_c = faq.answer) === null || _c === void 0 ? void 0 : _c.forEach(function (ansObj, inx) {
1316
- var eachAnsActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtons, { ansObj: ansObj, hostInstance: hostInstance, addHideClass: (inx == 0 ? true : false), rootServiceInstance: hostInstance.rootService }, hostInstance);
1317
- if (eachAnsActionTemplate && (eachAnsActionTemplate === null || eachAnsActionTemplate === void 0 ? void 0 : eachAnsActionTemplate.nodeName) != '#text') {
1318
- if (faqSuggestionBodyList_1 && (faqSuggestionBodyList_1 === null || faqSuggestionBodyList_1 === void 0 ? void 0 : faqSuggestionBodyList_1.length) > 0) {
1319
- faqSuggestionBodyList_1[inx].prepend(eachAnsActionTemplate);
1320
- _this.handleActionTemplateClickEventsForFAQ(eachAnsActionTemplate, faq, ansObj, faqListHTML[index], hostInstance);
1321
- }
1322
- }
1323
- });
1324
- var expandClostBtnTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_3__.FaqExpandCloseBtn, {}, hostInstance);
1325
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, expandClostBtnTemplate, {
1326
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FAQ_EXPAND_CLOSE_TEMPLATE,
1327
- data: {}
1328
- });
1329
- (_d = faqListHTML[index]) === null || _d === void 0 ? void 0 : _d.append(expandClostBtnTemplate);
1330
- var suggestionHeaderActionTemplate = (_e = faqListHTML[index]) === null || _e === void 0 ? void 0 : _e.querySelector("".concat(this.classConstants.SUGGESTION_EACH_HEADER, " ").concat(this.classConstants.SUGGESTION_SENDCPY_ACTION));
1331
- this.handleFaqExpandCloseBtnClickEvents(expandClostBtnTemplate, faqSuggestionBodyList_1, suggestionHeaderActionTemplate, faqListHTML[index], hostInstance);
1332
- }
1333
- };
1334
- rootService.prototype.handleSeeMoreButtonsForSearchAssist = function (suggestionElement, descClassName, moreContainer, hostInstance) {
1335
- var _this = this;
1336
- var suggestionBodyFaq = suggestionElement === null || suggestionElement === void 0 ? void 0 : suggestionElement.querySelectorAll('.suggestion-item-card .suggestion-body-faq');
1337
- suggestionBodyFaq === null || suggestionBodyFaq === void 0 ? void 0 : suggestionBodyFaq.forEach(function (bodyele, i) {
1338
- var _a;
1339
- var desc = bodyele.querySelector(descClassName);
1340
- if (desc) {
1341
- var overlimitContainer = bodyele === null || bodyele === void 0 ? void 0 : bodyele.querySelector(moreContainer);
1342
- var moreButton_1 = overlimitContainer === null || overlimitContainer === void 0 ? void 0 : overlimitContainer.querySelector(_this.classConstants.MORE_BUTTON);
1343
- var scrollDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(desc);
1344
- var clientDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeDimensions)(desc);
1345
- var isOverLimit = scrollDimensions.scrollHeight > clientDimensions.height;
1346
- if (isOverLimit || (_this.isAgenticStreamingEnabled && scrollDimensions.scrollHeight >= clientDimensions.height)) {
1347
- overlimitContainer.classList.remove(_this.classConstants.HIDE_ELEMENT);
1348
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.MORE_BUTTON, 'click', function (e) {
1349
- desc.classList.toggle(_this.classConstants.SUGGESTION_EXPANDED);
1350
- moreButton_1.textContent = desc.classList.contains(_this.classConstants.SUGGESTION_EXPANDED) ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_LESS : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_MORE;
1351
- }, overlimitContainer);
1352
- }
1353
- }
1354
- });
1355
- };
1356
- rootService.prototype.handleSeeMoreButtonsForFaq = function (suggestionElement, descClassName, moreContainer, hostInstance, faqinx) {
1357
- var _this = this;
1358
- if (faqinx === void 0) { faqinx = -1; }
1359
- var suggestionEachFaq = suggestionElement === null || suggestionElement === void 0 ? void 0 : suggestionElement.querySelectorAll(this.classConstants.SUGGESTION_EACH);
1360
- suggestionEachFaq === null || suggestionEachFaq === void 0 ? void 0 : suggestionEachFaq.forEach(function (eachFaq, i) {
1361
- var _a;
1362
- if (faqinx == -1 || faqinx === i) {
1363
- (_a = eachFaq.querySelectorAll(_this.classConstants.SUGGESTION_EACH_BODY)) === null || _a === void 0 ? void 0 : _a.forEach(function (bodyele, ii) {
1364
- var _a;
1365
- var desc = bodyele.querySelector(descClassName);
1366
- if (desc) {
1367
- var overlimitContainer = bodyele === null || bodyele === void 0 ? void 0 : bodyele.querySelector(moreContainer);
1368
- var moreButton_2 = overlimitContainer === null || overlimitContainer === void 0 ? void 0 : overlimitContainer.querySelector(_this.classConstants.MORE_BUTTON);
1369
- var scrollDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(desc);
1370
- var clientDimensions = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeDimensions)(desc);
1371
- var isOverLimit = scrollDimensions.scrollHeight > clientDimensions.height;
1372
- if (isOverLimit) {
1373
- overlimitContainer.classList.remove(_this.classConstants.HIDE_ELEMENT);
1374
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.MORE_BUTTON, 'click', function (e) {
1375
- desc.classList.toggle(_this.classConstants.SUGGESTION_EXPANDED);
1376
- moreButton_2.textContent = desc.classList.contains(_this.classConstants.SUGGESTION_EXPANDED) ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_LESS : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.READ_MORE;
1377
- }, overlimitContainer);
1378
- }
1379
- if (ii > 0) {
1380
- bodyele.classList.add(_this.classConstants.HIDE_ELEMENT);
1381
- }
1382
- }
1383
- });
1384
- }
1385
- });
1386
- };
1387
- // playbook related logic.
1388
- rootService.prototype.prepareChecklistPayload = function (event, checkListData, checklistObj, step, stageId) {
1389
- var _a, _b, _c, _d, _e, _f;
1390
- if (step === void 0) { step = false; }
1391
- if (stageId === void 0) { stageId = ''; }
1392
- var payload = {
1393
- "event": event,
1394
- "conversationId": this.connectionDetails.conversationId,
1395
- "ccVersion": checkListData === null || checkListData === void 0 ? void 0 : checkListData.ccVersion,
1396
- "accountId": checkListData === null || checkListData === void 0 ? void 0 : checkListData.accountId,
1397
- "botId": ((_a = this.connectionDetails) === null || _a === void 0 ? void 0 : _a.fromSAT) ? (_b = this.connectionDetails) === null || _b === void 0 ? void 0 : _b.instanceBotId : (_c = this.connectionDetails) === null || _c === void 0 ? void 0 : _c.botId,
1398
- "agentInfo": {
1399
- "agentId": "", // mendatory field
1400
- //any other fields
1401
- },
1402
- "timestamp": 0,
1403
- "context": {}
1404
- };
1405
- if (checkListData === null || checkListData === void 0 ? void 0 : checkListData.isSuggestedCL) {
1406
- payload.isSuggestedCL = true;
1407
- }
1408
- if (step) {
1409
- payload.checklistStep = checklistObj;
1410
- }
1411
- else {
1412
- payload.checklist = checklistObj;
1413
- }
1414
- if (stageId) {
1415
- payload.checklist.stageId = stageId;
1416
- }
1417
- var payloadStructure = {
1418
- "botId": ((_d = this.connectionDetails) === null || _d === void 0 ? void 0 : _d.fromSAT) ? (_e = this.connectionDetails) === null || _e === void 0 ? void 0 : _e.instanceBotId : (_f = this.connectionDetails) === null || _f === void 0 ? void 0 : _f.botId,
1419
- "payload": payload
1420
- };
1421
- return payloadStructure;
1422
- };
1423
- rootService.prototype.sendAndCopyForPlaybook = function (eventName, payload, eachPlaybookStep, hostInstance) {
1424
- var message = {
1425
- method: (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD) ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY_METHOD,
1426
- name: (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD) ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SENDMSG : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPYMSG,
1427
- conversationId: this.connectionDetails.conversationId,
1428
- payload: payload,
1429
- };
1430
- if (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD) {
1431
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, eachPlaybookStep, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.PLAYBOOK_SEND_EVENT, data: { message: message } });
1432
- }
1433
- else if (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY_METHOD) {
1434
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, eachPlaybookStep, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.PLAYBOOK_COPY_EVENT, data: { message: message } });
1435
- }
1436
- };
1437
- rootService.prototype.sendCheckListCompleteEvent = function (prevCheckListsData, id, hostInstance) {
1438
- var checklistParams = this.prepareChecklistPayload('checklist_closed', prevCheckListsData, { "id": id });
1439
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.checklist_closed, checklistParams);
1440
- };
1441
- rootService.prototype.checkAllStagesCompleted = function (prevCheckListsData, id, hostInstance) {
1442
- var _a, _b, _c, _d, _e, _f, _g;
1443
- var checklists = prevCheckListsData.checklists;
1444
- var completed = false;
1445
- var i = (checklists || []).findIndex(function (item) { return item._id === id; });
1446
- if (((_a = checklists[i]) === null || _a === void 0 ? void 0 : _a.type) !== 'primary') {
1447
- completed = (((_b = checklists[i].stages[0]) === null || _b === void 0 ? void 0 : _b.steps) || [])
1448
- .every(function (item) { return item.complete; });
1449
- if (completed) {
1450
- checklists[i].completed = true;
1451
- this.sendCheckListCompleteEvent(prevCheckListsData, id, hostInstance);
1452
- }
1453
- }
1454
- else {
1455
- var open_1 = (((_c = checklists[i].stages[0]) === null || _c === void 0 ? void 0 : _c.steps) || [])
1456
- .every(function (item) { return item.complete; });
1457
- if (open_1) {
1458
- }
1459
- var close_1 = (((_d = checklists[i].stages[1]) === null || _d === void 0 ? void 0 : _d.steps) || [])
1460
- .every(function (item) { return item.complete; });
1461
- if (close_1) {
1462
- (_g = (_f = (_e = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _e === void 0 ? void 0 : _e.querySelector(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.PROCEEDTOCLOSE_BTN)) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_DISABLE_MSG);
1463
- }
1464
- // if (close) {
1465
- // if (!this.openAck) {
1466
- // this.isCloseCompleted = true;
1467
- // setTimeout(() => {
1468
- // this.isCloseCompleted = false;
1469
- // this.openAck = true;
1470
- // }, 3000);
1471
- // }
1472
- // }
1473
- if (open_1 && close_1) {
1474
- checklists[i].completed = true;
1475
- completed = true;
1476
- }
1477
- if (completed) {
1478
- this.sendCheckListCompleteEvent(prevCheckListsData, id, hostInstance);
1479
- }
1480
- }
1481
- };
1482
- rootService.prototype.updateStepTemplate = function (prevCheckListsData, hostInstance) {
1483
- var _a, _b;
1484
- (_b = (_a = prevCheckListsData.checklists[this.selCLInx]) === null || _a === void 0 ? void 0 : _a.stages) === null || _b === void 0 ? void 0 : _b.map(function (stage, stInx) {
1485
- var _a;
1486
- (_a = stage === null || stage === void 0 ? void 0 : stage.steps) === null || _a === void 0 ? void 0 : _a.map(function (step, stepInx) {
1487
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1488
- var stepEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_EACH_STEP).concat(stInx, "-").concat(stepInx));
1489
- var stepCloseEle = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STEP_COMPLETE_BTN).concat(stInx, "-").concat(stepInx));
1490
- if (stepEle) {
1491
- if (step.ongoing === false) {
1492
- (_b = stepEle === null || stepEle === void 0 ? void 0 : stepEle.classList) === null || _b === void 0 ? void 0 : _b.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STEP_ONGOING);
1493
- (_d = (_c = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_HEADER_STEP))) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_DISABLE_MSG);
1494
- (_e = stepCloseEle === null || stepCloseEle === void 0 ? void 0 : stepCloseEle.classList) === null || _e === void 0 ? void 0 : _e.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1495
- (_g = (_f = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STEP_SEND_BLOCK))) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1496
- }
1497
- if (step.complete === true) {
1498
- (_j = (_h = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_HEADER_STEP_NAME))) === null || _h === void 0 ? void 0 : _h.classList) === null || _j === void 0 ? void 0 : _j.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STRIKE);
1499
- }
1500
- if (step.ongoing === true) {
1501
- (_k = stepEle === null || stepEle === void 0 ? void 0 : stepEle.classList) === null || _k === void 0 ? void 0 : _k.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STEP_ONGOING);
1502
- (_m = (_l = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_HEADER_STEP))) === null || _l === void 0 ? void 0 : _l.classList) === null || _m === void 0 ? void 0 : _m.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_DISABLE_MSG);
1503
- (_o = stepCloseEle === null || stepCloseEle === void 0 ? void 0 : stepCloseEle.classList) === null || _o === void 0 ? void 0 : _o.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1504
- (_q = (_p = stepEle === null || stepEle === void 0 ? void 0 : stepEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_STEP_SEND_BLOCK))) === null || _p === void 0 ? void 0 : _p.classList) === null || _q === void 0 ? void 0 : _q.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1505
- }
1506
- }
1507
- });
1508
- });
1509
- };
1510
- rootService.prototype.selectNextStep = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1511
- var _a, _b;
1512
- var allStepsComplete = true;
1513
- var index = 0;
1514
- this.closeAllStepsInStage(prevCheckListsData, clIndex, stInx);
1515
- for (var _i = 0, _c = (_b = (_a = prevCheckListsData.checklists[clIndex]) === null || _a === void 0 ? void 0 : _a.stages[stInx]) === null || _b === void 0 ? void 0 : _b.steps; _i < _c.length; _i++) {
1516
- var step = _c[_i];
1517
- if (!step.complete) {
1518
- step.ongoing = true;
1519
- allStepsComplete = false;
1520
- this.selSpInx = index;
1521
- this.scrollView(step._id, hostInstance);
1522
- break;
1523
- }
1524
- index++;
1525
- }
1526
- return allStepsComplete;
1527
- };
1528
- rootService.prototype.closeAllStepsInStage = function (prevCheckListsData, clIndex, stInx) {
1529
- var _a;
1530
- (_a = prevCheckListsData.checklists[clIndex]) === null || _a === void 0 ? void 0 : _a.stages.forEach(function (stage) {
1531
- stage === null || stage === void 0 ? void 0 : stage.steps.forEach(function (step) {
1532
- step.ongoing = false;
1533
- });
1534
- });
1535
- };
1536
- rootService.prototype.selectStepForRandom = function (stInx, step, stepInx, hostInstance) {
1537
- this.selStInx = stInx;
1538
- this.selSpInx = stepInx;
1539
- step.ongoing = true;
1540
- var stepId = step._id;
1541
- this.scrollView(stepId, hostInstance);
1542
- };
1543
- rootService.prototype.selectStage = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1544
- this.selStInx = stInx;
1545
- this.selectNextStep(prevCheckListsData, clIndex, stInx, hostInstance);
1546
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1547
- };
1548
- rootService.prototype.scrollView = function (stepId, hostInstance) {
1549
- if (hostInstance.chatEle.querySelector("#".concat(stepId))) {
1550
- hostInstance.chatEle.querySelector("#".concat(stepId)).scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
1551
- }
1552
- };
1553
- // update proceed to close button based on primary checklists
1554
- rootService.prototype.showProceedToCloseBtn = function (hostInstance) {
1555
- var _a;
1556
- var proceedToClostBtn = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.PROCEEDTOCLOSE_BTN));
1557
- proceedToClostBtn.classList.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1558
- };
1559
- rootService.prototype.clickStep = function (prevCheckListsData, stInx, step, stepInx, hostInstance) {
1560
- var selCLInx = this.selCLInx;
1561
- var selStInx = this.selStInx;
1562
- var selSpInx = this.selSpInx;
1563
- var checklists = prevCheckListsData.checklists;
1564
- var cl = checklists[selCLInx];
1565
- if ((step === null || step === void 0 ? void 0 : step.complete) || (step === null || step === void 0 ? void 0 : step.ongoing)) {
1566
- return;
1567
- }
1568
- else if ((cl === null || cl === void 0 ? void 0 : cl.order) === "random") {
1569
- checklists[selCLInx].stages[selStInx].steps[selSpInx].ongoing = false;
1570
- this.selectStepForRandom(stInx, step, stepInx, hostInstance);
1571
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1572
- }
1573
- else {
1574
- return;
1575
- }
1576
- };
1577
- rootService.prototype.getNumberstepCompInStage = function (prevCheckListsData) {
1578
- var _a, _b;
1579
- var stepNum = 0;
1580
- for (var _i = 0, _c = (_b = (_a = prevCheckListsData.checklists[this.selCLInx]) === null || _a === void 0 ? void 0 : _a.stages[this.selStInx]) === null || _b === void 0 ? void 0 : _b.steps; _i < _c.length; _i++) {
1581
- var step = _c[_i];
1582
- if (step.complete) {
1583
- stepNum += 1;
1584
- }
1585
- }
1586
- return stepNum;
1587
- };
1588
- rootService.prototype.handleStageCheck = function (parentEle, stInx, stageList, hostInstance) {
1589
- var _a, _b;
1590
- var selectedStageSpan = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.SELECTED_STAGE));
1591
- if (selectedStageSpan) {
1592
- selectedStageSpan.innerText = (_b = stageList[stInx]) === null || _b === void 0 ? void 0 : _b.name;
1593
- }
1594
- stageList === null || stageList === void 0 ? void 0 : stageList.map(function (stage, inx) {
1595
- var _a, _b;
1596
- var ele = parentEle === null || parentEle === void 0 ? void 0 : parentEle.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.CHECKLIST_SELECTED_STAGE_CHECK).concat(inx));
1597
- inx === stInx ? (_a = ele === null || ele === void 0 ? void 0 : ele.classList) === null || _a === void 0 ? void 0 : _a.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT) : (_b = ele === null || ele === void 0 ? void 0 : ele.classList) === null || _b === void 0 ? void 0 : _b.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1598
- });
1599
- };
1600
- rootService.prototype.selectNextStage = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1601
- var _a, _b, _c, _d;
1602
- var allStepsCompleteInStage = this.selectNextStep(prevCheckListsData, clIndex, stInx, hostInstance);
1603
- if (allStepsCompleteInStage && ((_a = prevCheckListsData.checklists[clIndex]) === null || _a === void 0 ? void 0 : _a.stages[stInx + 1])) {
1604
- if (((_b = prevCheckListsData.checklists[clIndex]) === null || _b === void 0 ? void 0 : _b.stages[stInx + 1].name) != 'Close' || this.isProceedToClose) {
1605
- var stageDropdown = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.STAGE_DROPDOWN));
1606
- this.handleStageCheck(stageDropdown, stInx + 1, (_d = prevCheckListsData.checklists[clIndex]) === null || _d === void 0 ? void 0 : _d.stages, hostInstance);
1607
- this.selectStage(prevCheckListsData, clIndex, stInx + 1, hostInstance);
1608
- }
1609
- }
1610
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1611
- };
1612
- rootService.prototype.confirmationBtnForPlaybook = function (btn, eachPlaybookStep, hostInstance) {
1613
- var eventName = btn.title === 'yes' ? _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.PLAYBOOK_CONFIRMATION_YES : _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.PLAYBOOK_CONFIRMATION_NO;
1614
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, eachPlaybookStep, { event: eventName, data: { btn: btn } });
1615
- };
1616
- rootService.prototype.hideDropdownTemplate = function (cls, hostInstace) {
1617
- var _a;
1618
- var sharedowns = (_a = hostInstace === null || hostInstace === void 0 ? void 0 : hostInstace.chatEle) === null || _a === void 0 ? void 0 : _a.getElementsByClassName(cls);
1619
- var i;
1620
- for (i = 0; i < sharedowns.length; i++) {
1621
- var openSharedown = sharedowns[i];
1622
- if (openSharedown.classList.contains('show')) {
1623
- openSharedown.classList.remove('show');
1624
- }
1625
- }
1626
- };
1627
- rootService.prototype.prepareFeedbackForSummary = function (feedbackData) {
1628
- var _a;
1629
- var renderResponse = {
1630
- type: 'summary',
1631
- positionId: feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.positionId,
1632
- summaryId: feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.summaryId,
1633
- traceId: feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.traceId,
1634
- submitForm: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? true : false,
1635
- feedback: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? feedbackData.feedback : '',
1636
- feedbackDetails: ((_a = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedbackDetails) === null || _a === void 0 ? void 0 : _a.length) ? feedbackData.feedbackDetails : [],
1637
- comment: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment) ? feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment : '',
1638
- sourceMsgId: '',
1639
- query: '',
1640
- suggestionType: 'summary',
1641
- interactionType: 'assist',
1642
- };
1643
- return renderResponse;
1644
- };
1645
- rootService.prototype.prepareFeedbackForSuggestions = function (suggestionType, suggestion, feedbackData) {
1646
- var _a, _b, _c;
1647
- if (feedbackData === void 0) { feedbackData = {}; }
1648
- var renderResponse = {
1649
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK,
1650
- positionId: suggestion.positionId,
1651
- submitForm: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? true : false,
1652
- feedback: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? feedbackData.feedback : '',
1653
- feedbackDetails: ((_a = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedbackDetails) === null || _a === void 0 ? void 0 : _a.length) ? feedbackData.feedbackDetails : [],
1654
- comment: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment) ? feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment : '',
1655
- sourceMsgId: suggestion.sourceMsgId || '',
1656
- query: suggestion.userInput,
1657
- suggestionType: suggestionType,
1658
- subType: suggestion.subType || ''
1659
- };
1660
- if (suggestionType == 'answer') {
1661
- renderResponse.isFromGeneratedSummary = suggestion.isFromGeneratedSummary;
1662
- renderResponse.answerType = suggestion.templateType;
1663
- renderResponse.title = suggestion.title;
1664
- renderResponse.answer = suggestion.sendCopyText || '';
1665
- renderResponse.interactionType = suggestion.intType;
1666
- renderResponse.sources = suggestion.sources;
1667
- if (((_b = suggestion.internalInfo) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1668
- renderResponse.answer += suggestion.internalInfo.join(' ');
1669
- }
1670
- }
1671
- else if (suggestionType == 'article' || suggestionType == 'file') {
1672
- renderResponse.title = suggestion.title;
1673
- renderResponse.answer = suggestion.content || '';
1674
- renderResponse.interactionType = suggestion.intType;
1675
- }
1676
- else if (suggestionType == 'faqs') {
1677
- var answer_1 = '';
1678
- if (Array.isArray(suggestion === null || suggestion === void 0 ? void 0 : suggestion.answer)) {
1679
- (_c = suggestion === null || suggestion === void 0 ? void 0 : suggestion.answer) === null || _c === void 0 ? void 0 : _c.forEach(function (element) {
1680
- answer_1 += element.ans;
1681
- });
1682
- }
1683
- renderResponse.title = suggestion.question;
1684
- renderResponse.answer = answer_1;
1685
- }
1686
- return renderResponse;
1687
- };
1688
- rootService.prototype.prepareFeedbackDataForDialog = function (automation, feedbackData, isHistory) {
1689
- var _a;
1690
- if (feedbackData === void 0) { feedbackData = {}; }
1691
- if (isHistory === void 0) { isHistory = false; }
1692
- var renderResponse = {
1693
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK,
1694
- uuid: automation.uuid,
1695
- dialogName: automation.dialogName,
1696
- positionId: automation.dialogId,
1697
- submitForm: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? true : false,
1698
- feedback: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? feedbackData.feedback : '',
1699
- feedbackDetails: ((_a = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedbackDetails) === null || _a === void 0 ? void 0 : _a.length) ? feedbackData.feedbackDetails : [],
1700
- comment: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment) ? feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment : '',
1701
- sourceMsgId: automation.sourceMsgId || '',
1702
- isHistory: isHistory
1703
- };
1704
- return renderResponse;
1705
- };
1706
- //Assist and mybot tab starts
1707
- rootService.prototype.makeOverrideEvent = function (hostInstance, flag) {
1708
- if (this.OverRideMode && this.proactiveMode && !this.manualAssistOverrideMode) {
1709
- hostInstance.handleOverrideMode(flag, null);
1710
- }
1711
- };
1712
- rootService.prototype.getTypeOfResponse = function (data) {
1713
- var _a, _b, _c, _d, _e, _f;
1714
- var responseType = '';
1715
- if (!this.isAutomationOnGoing && data.suggestions && ((_a = Object.keys(data.suggestions)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1716
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS;
1717
- }
1718
- else if (this.isAutomationOnGoing && data.ambiguityList && ((_b = Object.keys(data.ambiguityList)) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1719
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS;
1720
- }
1721
- else if (!data.sendMenuRequest) {
1722
- if (this.isAutomationOnGoing && ((_c = data.buttons) === null || _c === void 0 ? void 0 : _c.length) > 0 && (this.currentAutomationId && !data.positionId || (data.positionId == this.currentAutomationId))) {
1723
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE;
1724
- }
1725
- else if (!this.isAutomationOnGoing && ((_d = data.buttons) === null || _d === void 0 ? void 0 : _d.length) > 0) {
1726
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK;
1727
- }
1728
- else if (this.isAutomationOnGoing && data.suggestions && ((_e = Object.keys(data.suggestions)) === null || _e === void 0 ? void 0 : _e.length) > 0) {
1729
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS;
1730
- }
1731
- else {
1732
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE;
1733
- }
1734
- }
1735
- else if (((_f = data === null || data === void 0 ? void 0 : data.buttons) === null || _f === void 0 ? void 0 : _f.length) > 0) {
1736
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG;
1737
- }
1738
- return responseType;
1739
- };
1740
- rootService.prototype.getMybotTypeOfResponse = function (data) {
1741
- var _a, _b;
1742
- var responseType = '';
1743
- if (this.isMyBotAutomationOnGoing && ((_a = data.buttons) === null || _a === void 0 ? void 0 : _a.length) > 0 && (this.currentMybotAutomationId && !data.positionId || (data.positionId == this.currentMybotAutomationId))) {
1744
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE;
1745
- }
1746
- else if (!this.isAutomationOnGoing && ((_b = data.buttons) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1747
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK;
1748
- }
1749
- return responseType;
1750
- };
1751
- rootService.prototype.getCustomTabTypeOfResponse = function (data) {
1752
- var _a, _b;
1753
- var responseType = '';
1754
- if (this.isCustomTabAutomationOnGoing && ((_a = data.buttons) === null || _a === void 0 ? void 0 : _a.length) > 0 && (this.currentCustomTabAutomationId && !data.positionId || (data.positionId == this.currentCustomTabAutomationId))) {
1755
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE;
1756
- }
1757
- else if (!this.isCustomTabAutomationOnGoing && ((_b = data.buttons) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1758
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK;
1759
- }
1760
- return responseType;
1761
- };
1762
- rootService.prototype.sendRunClickEvent = function (hostInstance, dialog, intent) {
1763
- var _a;
1764
- if (intent === void 0) { intent = false; }
1765
- this.prepareSendCopyEventForRun(hostInstance, dialog, intent);
1766
- var connectionDetails = Object.assign({}, this.connectionDetails);
1767
- connectionDetails.value = dialog.intentName;
1768
- if (dialog.intentName && intent) {
1769
- connectionDetails.intentName = dialog.intentName;
1770
- }
1771
- connectionDetails.positionId = dialog.positionId;
1772
- connectionDetails.entities = this.entitiesValueArray;
1773
- connectionDetails.childBotId = dialog.childBotId;
1774
- connectionDetails.childBotName = dialog.childBotName;
1775
- connectionDetails.sourceMsgId = dialog.sourceMsgId || '';
1776
- if (dialog.taskRefId) {
1777
- connectionDetails.taskRefId = dialog.taskRefId;
1778
- }
1779
- if (dialog.dialogId) {
1780
- connectionDetails.dialogId = dialog.dialogId;
1781
- }
1782
- if (dialog.userInput) {
1783
- connectionDetails.userInput = dialog.userInput;
1784
- }
1785
- if (dialog.traits && ((_a = dialog.traits) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1786
- connectionDetails.traits = dialog.traits;
1787
- }
1788
- if (dialog.intentName === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.DISCARD_ALL && !intent) {
1789
- connectionDetails.isDiscard = true;
1790
- }
1791
- if (dialog.agentRunButton) {
1792
- connectionDetails.isSearch = false;
1793
- var myBotRequestParams = hostInstance.prepareAgentAssistAgentRequestParams(connectionDetails);
1794
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, myBotRequestParams);
1795
- this.mybotEntitiestValueArray = [];
1796
- }
1797
- else if (dialog.customTabInterrupt) {
1798
- var assistRequestParams = hostInstance.prepareAgentAssistCustomRequestParams(connectionDetails);
1799
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_custom_request, assistRequestParams);
1800
- this.customTabEntitiesValueArray = [];
1801
- }
1802
- else {
1803
- var assistRequestParams = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
1804
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, assistRequestParams);
1805
- this.entitiesValueArray = [];
1806
- }
1807
- };
1808
- rootService.prototype.prepareSendCopyEventForRun = function (hostInstance, dialog, intent) {
1809
- if (intent === void 0) { intent = false; }
1810
- var payloadForBE = Object.assign({}, this.connectionDetails);
1811
- if (dialog.intentName && intent) {
1812
- payloadForBE.intentName = dialog.intentName;
1813
- payloadForBE.title = dialog.intentName;
1814
- }
1815
- payloadForBE.type = 'dialog';
1816
- payloadForBE.input = dialog.userInput;
1817
- payloadForBE.sessionId = (dialog.suggestionFrom === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST || dialog.suggestionFrom === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM) ? this.assistTabSessionId : this.myBotTabSessionId;
1818
- payloadForBE = this.addSourceMsgIdToRequestParams(dialog, payloadForBE);
1819
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, payloadForBE);
1820
- };
1821
- rootService.prototype.matchDialogIdfromMenuResponse = function (dialog) {
1822
- var _a, _b;
1823
- var taskRefId = dialog.taskRefId;
1824
- if (taskRefId && this.menuResponse && ((_a = this.menuResponse) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1825
- var response = (_b = this.menuResponse) === null || _b === void 0 ? void 0 : _b.find(function (obj) { return obj.taskRefId === taskRefId; });
1826
- if (response && response.dialogId) {
1827
- dialog.dialogId = response.dialogId;
1828
- }
1829
- }
1830
- return dialog.dialogId;
1831
- };
1832
- rootService.prototype.addEventListenerForDialogSuggestion = function (menuHTML, suggestion, hostInstance) {
1833
- var _a, _b;
1834
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener("".concat(this.classConstants.DIALOG_RUN_BTN).concat(suggestion.positionId), 'click', function (e) {
1835
- if (suggestion === null || suggestion === void 0 ? void 0 : suggestion.customTabInterrupt) {
1836
- suggestion.customTabInterrupt = false;
1837
- }
1838
- suggestion.agentRunButton = false;
1839
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.RUN_CLICK_EVENT, data: suggestion });
1840
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, JSON.parse(JSON.stringify(suggestion)));
1841
- }, menuHTML);
1842
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener("".concat(this.classConstants.DIALOG_AGENT_RUN_BTN).concat(suggestion.positionId), 'click', function (e) {
1843
- e.stopPropagation(); // Stop event from bubbling
1844
- suggestion.agentRunButton = true;
1845
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.RUN_CLICK_EVENT, data: suggestion });
1846
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, JSON.parse(JSON.stringify(suggestion)));
1847
- }, menuHTML);
1848
- };
1849
- rootService.prototype.handleDialogClickEvents = function (menuHTML, dialogs, hostInstance) {
1850
- var _this = this;
1851
- var _a;
1852
- dialogs === null || dialogs === void 0 ? void 0 : dialogs.forEach(function (suggestion, index) {
1853
- var suggestionsHtmlList = menuHTML === null || menuHTML === void 0 ? void 0 : menuHTML.querySelectorAll("".concat(_this.classConstants.DIALOG_RUN_BTN).concat(suggestion.positionId));
1854
- var agentRunButtonHtmlList = menuHTML === null || menuHTML === void 0 ? void 0 : menuHTML.querySelectorAll("".concat(_this.classConstants.DIALOG_AGENT_RUN_BTN).concat(suggestion.positionId));
1855
- if (suggestionsHtmlList && (suggestionsHtmlList === null || suggestionsHtmlList === void 0 ? void 0 : suggestionsHtmlList.length) > 1) {
1856
- suggestionsHtmlList === null || suggestionsHtmlList === void 0 ? void 0 : suggestionsHtmlList.forEach(function (itemList) {
1857
- itemList === null || itemList === void 0 ? void 0 : itemList.addEventListener('click', function (e) {
1858
- e.stopPropagation(); // Stop event from bubbling
1859
- e.stopImmediatePropagation(); // Stop event from bubbling
1860
- if (e.currentTarget === e.target || e.currentTarget.contains(e.target)) {
1861
- if (suggestion === null || suggestion === void 0 ? void 0 : suggestion.customTabInterrupt) {
1862
- suggestion.customTabInterrupt = false;
1863
- }
1864
- suggestion.agentRunButton = false;
1865
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.RUN_CLICK_EVENT, data: suggestion });
1866
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, JSON.parse(JSON.stringify(suggestion)));
1867
- }
1868
- });
1869
- });
1870
- }
1871
- if (agentRunButtonHtmlList && (agentRunButtonHtmlList === null || agentRunButtonHtmlList === void 0 ? void 0 : agentRunButtonHtmlList.length) > 1) {
1872
- agentRunButtonHtmlList === null || agentRunButtonHtmlList === void 0 ? void 0 : agentRunButtonHtmlList.forEach(function (itemList) {
1873
- itemList === null || itemList === void 0 ? void 0 : itemList.addEventListener('click', function (e) {
1874
- e.stopPropagation(); // Stop event from bubbling
1875
- e.stopImmediatePropagation(); // Stop event from bubbling
1876
- if (e.currentTarget === e.target || e.currentTarget.contains(e.target)) {
1877
- suggestion.agentRunButton = true;
1878
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, '', { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.RUN_CLICK_EVENT, data: suggestion });
1879
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, JSON.parse(JSON.stringify(suggestion)));
1880
- }
1881
- });
1882
- });
1883
- }
1884
- if ((agentRunButtonHtmlList === null || agentRunButtonHtmlList === void 0 ? void 0 : agentRunButtonHtmlList.length) > 1 || (suggestionsHtmlList === null || suggestionsHtmlList === void 0 ? void 0 : suggestionsHtmlList.length) > 1) {
1885
- return;
1886
- }
1887
- _this.addEventListenerForDialogSuggestion(menuHTML, suggestion, hostInstance);
1888
- });
1889
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener("".concat(this.classConstants.WRONG_SUGGESTION_BTN), 'click', function (e) {
1890
- var footerTag = hostInstance.chatEle.querySelector(_this.classConstants.FOOTER);
1891
- hostInstance.openSearchTab(footerTag, true);
1892
- }, menuHTML);
1893
- };
1894
- // removeRunwithAgentInputs(menuHTML: any) {
1895
- // // Get all currently open dropdowns
1896
- // const openDropdowns = menuHTML?.querySelectorAll('.aa-elipse-dropdown.show');
1897
- // // Close only the other dropdowns, not the one that was just clicked
1898
- // openDropdowns?.forEach((element: any) => {
1899
- // // Check if this dropdown was the one that triggered the event
1900
- // if (!element.contains(event?.target as Node)) {
1901
- // element.classList.remove('show');
1902
- // }
1903
- // });
1904
- // }
1905
- rootService.prototype.runDialogForAssistOrMybot = function (hostInstance, dialog, runInitent) {
1906
- if (runInitent === void 0) { runInitent = false; }
1907
- if (!runInitent) {
1908
- this.sendRunClickEvent(hostInstance, dialog, true);
1909
- }
1910
- if (dialog.agentRunButton) {
1911
- this.updateLocalStorageForMybot(hostInstance, dialog, true);
1912
- }
1913
- else if (dialog.customTabInterrupt) {
1914
- this.updateLocalStorageForCustomTab(hostInstance, dialog, true);
1915
- }
1916
- else {
1917
- this.updateLocalStorageForAssist(hostInstance, dialog, true);
1918
- }
1919
- };
1920
- rootService.prototype.updateLocalStorageForAssist = function (hostInstance, dialog, flag) {
1921
- this.isAutomationOnGoing = flag;
1922
- this.updateAssistDialogTemplate(hostInstance, dialog, flag);
1923
- };
1924
- rootService.prototype.updateLocalStorageForMybot = function (hostInstance, dialog, flag) {
1925
- this.isMyBotAutomationOnGoing = flag;
1926
- this.updateMybotDialogTemplate(hostInstance, dialog, flag);
1927
- };
1928
- rootService.prototype.updateLocalStorageForCustomTab = function (hostInstance, dialog, flag) {
1929
- this.isCustomTabAutomationOnGoing = flag;
1930
- this.updateCustomTabDialogTemplate(hostInstance, dialog, flag);
1931
- };
1932
- rootService.prototype.updateCustomTabDialogTemplate = function (hostInstance, dialog, flag) {
1933
- var _a, _b, _c, _d, _e, _f, _g;
1934
- var termianteBtn = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.CUSTOM_TAB_TERMINATE_BTN));
1935
- var listviewBtn = (_b = hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.CUSTOM_TAB_LISTVIEW_BTN));
1936
- var customTabHeaderDialogWrapper = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(this.classConstants.CUSTOM_TAB_HEADER_DIALOG_WRAPPER));
1937
- var customTabHeaderDialogName = customTabHeaderDialogWrapper === null || customTabHeaderDialogWrapper === void 0 ? void 0 : customTabHeaderDialogWrapper.querySelector("".concat(this.classConstants.CUSTOM_TAB_HEADER_DIALOG_NAME));
1938
- if (flag) {
1939
- (_d = termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
1940
- (_e = listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
1941
- termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.removeAttribute(this.classConstants.DISABLED);
1942
- listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.removeAttribute(this.classConstants.DISABLED);
1943
- (_f = customTabHeaderDialogWrapper === null || customTabHeaderDialogWrapper === void 0 ? void 0 : customTabHeaderDialogWrapper.classList) === null || _f === void 0 ? void 0 : _f.remove(this.classConstants.HIDE_ELEMENT);
1944
- if (customTabHeaderDialogName) {
1945
- customTabHeaderDialogName.innerText = dialog.intentName;
1946
- }
1947
- }
1948
- else {
1949
- termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.setAttribute(this.classConstants.DISABLED, true);
1950
- listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.setAttribute(this.classConstants.DISABLED, true);
1951
- (_g = customTabHeaderDialogWrapper === null || customTabHeaderDialogWrapper === void 0 ? void 0 : customTabHeaderDialogWrapper.classList) === null || _g === void 0 ? void 0 : _g.add(this.classConstants.HIDE_ELEMENT);
1952
- }
1953
- };
1954
- rootService.prototype.updateMybotDialogTemplate = function (hostInstance, dialog, flag) {
1955
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1956
- var termianteBtn = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.MYBOT_TERMINATE_BUTTON));
1957
- var listviewBtn = (_b = hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.MYBOT_LISTVIEW_BUTTON));
1958
- var mybotHeaderDialogWrapper = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(this.classConstants.MYBOT_HEADER_DIALOG_WRAPPER));
1959
- var mybotHeaderDialogName = mybotHeaderDialogWrapper === null || mybotHeaderDialogWrapper === void 0 ? void 0 : mybotHeaderDialogWrapper.querySelector("".concat(this.classConstants.MYBOT_HEADER_DIALOG_NAME));
1960
- if (flag) {
1961
- (_d = termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
1962
- (_e = listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
1963
- (_f = mybotHeaderDialogWrapper === null || mybotHeaderDialogWrapper === void 0 ? void 0 : mybotHeaderDialogWrapper.classList) === null || _f === void 0 ? void 0 : _f.remove(this.classConstants.HIDE_ELEMENT);
1964
- mybotHeaderDialogName.innerText = dialog.intentName;
1965
- }
1966
- else {
1967
- this.manualAssistOverrideMode = false;
1968
- (_g = termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.classList) === null || _g === void 0 ? void 0 : _g.add(this.classConstants.HIDE_ELEMENT);
1969
- (_h = listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.classList) === null || _h === void 0 ? void 0 : _h.add(this.classConstants.HIDE_ELEMENT);
1970
- (_j = mybotHeaderDialogWrapper === null || mybotHeaderDialogWrapper === void 0 ? void 0 : mybotHeaderDialogWrapper.classList) === null || _j === void 0 ? void 0 : _j.add(this.classConstants.HIDE_ELEMENT);
1971
- }
1972
- };
1973
- rootService.prototype.updateAssistDialogTemplate = function (hostInstance, dialog, flag) {
1974
- var _a, _b, _c, _d, _e;
1975
- var termianteBtn = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ASSIST_TERMINATE_BUTTON));
1976
- var listviewBtn = (_b = hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.ASSIST_LISTVIEW_BUTTON));
1977
- var assistHeaderDialogWrapper = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(this.classConstants.ASSIST_HEADER_DIALOG_WRAPPER));
1978
- var assistHeaderDialogName = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.querySelector("".concat(this.classConstants.ASSIST_HEADER_DIALOG_NAME));
1979
- if (flag) {
1980
- termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.removeAttribute(this.classConstants.DISABLED);
1981
- listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.removeAttribute(this.classConstants.DISABLED);
1982
- (_d = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
1983
- assistHeaderDialogName.innerText = dialog.intentName;
1984
- }
1985
- else {
1986
- this.manualAssistOverrideMode = false;
1987
- termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.setAttribute(this.classConstants.DISABLED, true);
1988
- listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.setAttribute(this.classConstants.DISABLED, true);
1989
- (_e = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.classList) === null || _e === void 0 ? void 0 : _e.add(this.classConstants.HIDE_ELEMENT);
1990
- }
1991
- };
1992
- rootService.prototype.prepareDialogObjForAssistHistory = function (data) {
1993
- var dialogObj = this.prepareDialogObjForInitDialog(data);
1994
- return dialogObj;
1995
- };
1996
- rootService.prototype.prepareDialogObjForMybotHistory = function (data) {
1997
- var dialogObj = this.prepareDialogObjForInitDialog(data);
1998
- dialogObj.suggestionFrom = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT;
1999
- return dialogObj;
2000
- };
2001
- rootService.prototype.prepareDialogObjForCustomTabHistory = function (data) {
2002
- var dialogObj = this.prepareDialogObjForInitDialog(data);
2003
- dialogObj.suggestionFrom = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM;
2004
- return dialogObj;
2005
- };
2006
- rootService.prototype.prepareDialogObjForInitDialog = function (data) {
2007
- var initDialogrenderResp = {
2008
- intentName: data.intentName,
2009
- childBotId: data.childBotId,
2010
- childBotName: data.childBotName,
2011
- entities: data.entities || [],
2012
- userInput: data.userInput,
2013
- sourceMsgId: data.sourceMsgId || '',
2014
- positionId: data.positionId,
2015
- traits: data.traits || [],
2016
- dialogId: data.dialogId ? data.dialogId : this.matchDialogIdfromMenuResponse(data),
2017
- suggestionFrom: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST
2018
- };
2019
- return initDialogrenderResp;
2020
- };
2021
- rootService.prototype.prepareSuggestionResponse = function (data, responseId, suggestionIndex) {
2022
- var searchResponse = this.formatSearchResponse(data, false, suggestionIndex, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST);
2023
- var assistDataNode = {
2024
- data: data,
2025
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS,
2026
- uuid: responseId,
2027
- searchResponse: searchResponse
2028
- };
2029
- return assistDataNode;
2030
- };
2031
- rootService.prototype.prepareAutomationReponse = function (res, responseId, tab) {
2032
- if (tab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) {
2033
- this.currentAutomationId = res.positionId;
2034
- }
2035
- else if (tab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT) {
2036
- this.currentMybotAutomationId = res.positionId;
2037
- }
2038
- else {
2039
- this.currentCustomTabAutomationId = res.positionId;
2040
- }
2041
- var renderResponse = {
2042
- data: res,
2043
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION,
2044
- uuid: responseId,
2045
- dialogId: res.positionId,
2046
- dialogName: res.intentName,
2047
- sourceMsgId: res.sourceMsgId || "",
2048
- automationNodes: [this.prepareDialogStartNodeResponse(res.positionId)]
2049
- };
2050
- return renderResponse;
2051
- };
2052
- rootService.prototype.prepareAutomationNodeResponse = function (data, responseId) {
2053
- var renderResponse = {
2054
- data: data,
2055
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE,
2056
- uuid: responseId
2057
- };
2058
- return renderResponse;
2059
- };
2060
- rootService.prototype.prepareDialogStartNodeResponse = function (dialogId) {
2061
- var renderResponse = {
2062
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_START,
2063
- uuid: (0,_utils_koregenerateuuid__WEBPACK_IMPORTED_MODULE_6__["default"])(),
2064
- dialogId: dialogId
2065
- };
2066
- return renderResponse;
2067
- };
2068
- rootService.prototype.prepareDialogEndNodeResponse = function (dialogId) {
2069
- var renderResponse = {
2070
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END,
2071
- uuid: (0,_utils_koregenerateuuid__WEBPACK_IMPORTED_MODULE_6__["default"])(),
2072
- dialogId: dialogId
2073
- };
2074
- return renderResponse;
2075
- };
2076
- rootService.prototype.prepareEntityNodeResponse = function (response, dataObj, hostInstance) {
2077
- var _a, _b, _c;
2078
- var templateRender = ((_a = response === null || response === void 0 ? void 0 : response.templateResult) === null || _a === void 0 ? void 0 : _a.parsedPayload) ? true : false;
2079
- dataObj.nodeType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE;
2080
- dataObj.value = (_b = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _b === void 0 ? void 0 : _b.value;
2081
- dataObj.sendData = (_c = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _c === void 0 ? void 0 : _c.value;
2082
- dataObj.template = this.getTemplateHtml(templateRender, response.templateResult, hostInstance);
2083
- dataObj.templateRender = templateRender;
2084
- if (dataObj === null || dataObj === void 0 ? void 0 : dataObj.attachments) {
2085
- dataObj.userInput = response === null || response === void 0 ? void 0 : response.userInput;
2086
- }
2087
- return dataObj;
2088
- };
2089
- rootService.prototype.prepareMsgNodeResponse = function (response, dataObj, hostInstance) {
2090
- var _a, _b, _c;
2091
- var templateRender = ((_a = response === null || response === void 0 ? void 0 : response.templateResult) === null || _a === void 0 ? void 0 : _a.parsedPayload) ? true : false;
2092
- dataObj.nodeType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE;
2093
- dataObj.value = (_b = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _b === void 0 ? void 0 : _b.value;
2094
- dataObj.sendData = (_c = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _c === void 0 ? void 0 : _c.value;
2095
- dataObj.template = this.getTemplateHtml(templateRender, response.templateResult, hostInstance);
2096
- dataObj.templateRender = templateRender;
2097
- return dataObj;
2098
- };
2099
- rootService.prototype.prepareSmallTalkResponse = function (data, responseId) {
2100
- var renderResponse = {
2101
- data: data,
2102
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK,
2103
- uuid: responseId
2104
- };
2105
- return renderResponse;
2106
- };
2107
- rootService.prototype.prepareWelcomeMsgResponse = function (data, responseId) {
2108
- var assistDataNode = {
2109
- data: data,
2110
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG,
2111
- uuid: responseId,
2112
- hideOverrideDiv: true,
2113
- toggleOverride: false,
2114
- nodeType: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE
2115
- };
2116
- return assistDataNode;
2117
- };
2118
- rootService.prototype.toggleInterruptDropdown = function (tab, hostInstance) {
2119
- var _a, _b, _c, _d, _e;
2120
- var dialogWrapper = this.classConstants.ASSIST_INTERRUPT_WRAPPER;
2121
- var interruptCount = this.classConstants.ASSIST_INTERRUPT_COUNT;
2122
- hostInstance.localStorageService.setInterruptDialogList(this.interruptDialogList);
2123
- var interruptDialogWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(dialogWrapper));
2124
- if (((_b = this.interruptDialogList) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2125
- (_c = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
2126
- }
2127
- else {
2128
- (_d = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
2129
- }
2130
- var interruptCountEle = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.querySelector("".concat(interruptCount));
2131
- if (interruptCountEle) {
2132
- interruptCountEle.innerText = (_e = this.interruptDialogList) === null || _e === void 0 ? void 0 : _e.length;
2133
- }
2134
- };
2135
- rootService.prototype.toggleMybotInterruptDropdown = function (tab, hostInstance) {
2136
- var _a, _b, _c, _d, _e;
2137
- var dialogWrapper = this.classConstants.MYBOT_INTERRUPT_WRAPPER;
2138
- var interruptCount = this.classConstants.MYBOT_INTERRUPT_COUNT;
2139
- hostInstance.localStorageService.setInterruptDialogList(this.mybotInterruptDialogList);
2140
- var interruptDialogWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(dialogWrapper));
2141
- if (((_b = this.mybotInterruptDialogList) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2142
- (_c = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
2143
- }
2144
- else {
2145
- (_d = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
2146
- }
2147
- var interruptCountEle = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.querySelector("".concat(interruptCount));
2148
- if (interruptCountEle) {
2149
- interruptCountEle.innerText = (_e = this.mybotInterruptDialogList) === null || _e === void 0 ? void 0 : _e.length;
2150
- }
2151
- };
2152
- rootService.prototype.toggleCustomTabInterruptDropdown = function (tab, hostInstance) {
2153
- var _a, _b, _c, _d, _e;
2154
- var dialogWrapper = this.classConstants.CUSTOM_TAB_INTERRUPT_WRAPPER;
2155
- var interruptCount = this.classConstants.CUSTOM_TAB_INTERRUPT_COUNT;
2156
- hostInstance.localStorageService.setInterruptDialogList(this.customInterruptDialogList);
2157
- var interruptDialogWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(dialogWrapper));
2158
- if (((_b = this.customInterruptDialogList) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2159
- (_c = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
2160
- }
2161
- else {
2162
- (_d = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
2163
- }
2164
- var interruptCountEle = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.querySelector("".concat(interruptCount));
2165
- if (interruptCountEle) {
2166
- interruptCountEle.innerText = (_e = this.customInterruptDialogList) === null || _e === void 0 ? void 0 : _e.length;
2167
- }
2168
- };
2169
- rootService.prototype.handleEmptyLine = function (answer, quotflag, type, hostInstace) {
2170
- if (quotflag === void 0) { quotflag = false; }
2171
- if (type === void 0) { type = ''; }
2172
- var eleanswer = '';
2173
- if (typeof answer === 'string') {
2174
- eleanswer = (type === 'faq') ? answer.replace(/(\r\n|\n|\r)/gm, "<br>") : answer;
2175
- eleanswer = this.replaceLtGt(eleanswer, quotflag);
2176
- eleanswer = this.aaHelpers.convertMDtoHTML(eleanswer, "bot", eleanswer);
2177
- // if (quotflag) {
2178
- // eleanswer = this.replaceLtGt(eleanswer, quotflag)
2179
- // }
2180
- return this.sanitizeHTML(eleanswer.replace(new RegExp("(<br />)+$"), ''));
2181
- }
2182
- return this.sanitizeHTML(eleanswer);
2183
- };
2184
- rootService.prototype.replaceLtGt = function (htmlString, quotflag) {
2185
- var newHtmlStr;
2186
- newHtmlStr = htmlString.replaceAll("&lt;", "<");
2187
- newHtmlStr = newHtmlStr.replaceAll("&gt;", ">");
2188
- if (quotflag) {
2189
- newHtmlStr = newHtmlStr.replaceAll('"', "&quot;");
2190
- }
2191
- return newHtmlStr;
2192
- };
2193
- // Welocome message logic starts
2194
- rootService.prototype.handleWelcomeMsgResponse = function (welcomeMsgResponse, template, hostInstance) {
2195
- var _this = this;
2196
- welcomeMsgResponse.buttons.forEach(function (message, index) {
2197
- var welcomeMsgObj = _this.createWelcomeMessageObject(message.value, index);
2198
- _this.insertActionTemplate(welcomeMsgObj, index, template, hostInstance);
2199
- });
2200
- };
2201
- rootService.prototype.handleNodeResponse = function (automationNodeObj, template, hostInstance) {
2202
- this.insertActionTemplate(automationNodeObj, null, template, hostInstance);
2203
- };
2204
- rootService.prototype.insertActionTemplate = function (nodeObj, index, template, hostInstance) {
2205
- var eachActionTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.handleSendCopyButtonsForNodes, { node: nodeObj, hostInstance: hostInstance, rootServiceInstance: hostInstance.rootService }, hostInstance);
2206
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) !== '#text') {
2207
- var parentNode = this.getParentNode(template, index);
2208
- if (parentNode && this.isHistory && typeof this.prefsOpacity === 'number') {
2209
- template.style.opacity = String(this.prefsOpacity / 100);
2210
- }
2211
- if (parentNode) {
2212
- parentNode.insertBefore(eachActionTemplate, parentNode.firstChild);
2213
- this.handleActionTemplateClickEventsForNodes(eachActionTemplate, nodeObj, template, hostInstance);
2214
- }
2215
- }
2216
- };
2217
- rootService.prototype.getParentNode = function (template, index) {
2218
- if (index !== null) {
2219
- return template === null || template === void 0 ? void 0 : template.querySelector("".concat(this.classConstants.WELCOME_MSG_NODE).concat(index));
2220
- }
2221
- return template === null || template === void 0 ? void 0 : template.querySelector(this.classConstants.NODE_BODY);
2222
- };
2223
- rootService.prototype.createWelcomeMessageObject = function (value, index) {
2224
- return {
2225
- sendData: value,
2226
- index: index,
2227
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG,
2228
- };
2229
- };
2230
- rootService.prototype.handleActionTemplateClickEventsForNodes = function (eachActionTemplate, automationNodeObj, template, hostInstance) {
2231
- var _this = this;
2232
- var _a;
2233
- var sendTextTemplate = (_a = template.querySelector) === null || _a === void 0 ? void 0 : _a.call(template, "".concat(this.classConstants.NODE_SEND_TEXT));
2234
- this.addClickEventListenerForActionNodes(eachActionTemplate, this.classConstants.SUGGESTION_SEND_BTN, function () { return _this.handleSendOrCopyClickEvent(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, sendTextTemplate, automationNodeObj, template, hostInstance); }, hostInstance);
2235
- this.addClickEventListenerForActionNodes(eachActionTemplate, this.classConstants.SUGGESTION_COPY_BTN, function () { return _this.handleSendOrCopyClickEvent(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, sendTextTemplate, automationNodeObj, template, hostInstance); }, hostInstance);
2236
- };
2237
- rootService.prototype.addClickEventListenerForActionNodes = function (template, eventSelector, callback, hostInstance) {
2238
- var _a;
2239
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(eventSelector, 'click', callback, template);
2240
- };
2241
- // Welocome message logic ends
2242
- //Send copy click events handling logic starts
2243
- rootService.prototype.handleSendOrCopyClickEvent = function (type, sendTextTemplate, automationNodeObj, template, hostInstance) {
2244
- var _a, _b, _c, _d;
2245
- if (typeof this.prefsOpacity === 'number') {
2246
- template.style.opacity = String((this.prefsOpacity / 100));
2247
- }
2248
- this.toggleSendTextTemplate(sendTextTemplate, type);
2249
- this.handleSendCopyButtonForNodes(type, automationNodeObj.sendData, automationNodeObj, template, hostInstance);
2250
- automationNodeObj.skipMsg = true;
2251
- if (automationNodeObj.type === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG) {
2252
- this.removeWelcomeMessages(automationNodeObj, hostInstance);
2253
- }
2254
- if (type === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND) {
2255
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_SEND_MESSAGE, data: automationNodeObj, template: ((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _a === void 0 ? void 0 : _a.template) ? (_b = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _b === void 0 ? void 0 : _b.template : false, msg: automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.sendData });
2256
- }
2257
- else {
2258
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_COPY_MESSAGE, data: automationNodeObj, template: ((_c = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _c === void 0 ? void 0 : _c.template) ? (_d = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _d === void 0 ? void 0 : _d.template : false, msg: automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.sendData });
2259
- }
2260
- };
2261
- rootService.prototype.toggleSendTextTemplate = function (sendTextTemplate, type) {
2262
- if (!sendTextTemplate)
2263
- return;
2264
- sendTextTemplate.classList.remove(this.classConstants.HIDE_ELEMENT);
2265
- sendTextTemplate.innerText = type === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? 'Sent' : 'Copied';
2266
- };
2267
- rootService.prototype.removeWelcomeMessages = function (automationNodeObj, hostInstance) {
2268
- var _a;
2269
- var welcomeMsgNodes = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.WELCOME_NODES));
2270
- welcomeMsgNodes === null || welcomeMsgNodes === void 0 ? void 0 : welcomeMsgNodes.forEach(function (node) {
2271
- var _a;
2272
- if (!node.classList.contains("aa-welcome-msg-".concat(automationNodeObj.index))) {
2273
- (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node);
2274
- }
2275
- });
2276
- };
2277
- rootService.prototype.handleSendCopyButtonForNodes = function (actionType, sendData, automation, template, hostInstance) {
2278
- var _a, _b;
2279
- var node = (_b = (_a = template.querySelector) === null || _a === void 0 ? void 0 : _a.call(template, "".concat(this.classConstants.NODE_BODY))) === null || _b === void 0 ? void 0 : _b.querySelector('p');
2280
- sendData = this.prepareSendText(sendData, automation.templateRender, node);
2281
- var message = this.createMessagePayload(actionType, sendData);
2282
- this.messageNodeSendorCopyEvent(actionType, sendData, automation, hostInstance);
2283
- };
2284
- rootService.prototype.prepareSendText = function (sendData, templateRender, askCustNode) {
2285
- var _a, _b, _c, _d;
2286
- if (!templateRender) {
2287
- var format = ((_b = (_a = this === null || this === void 0 ? void 0 : this.aaSettings) === null || _a === void 0 ? void 0 : _a.agentActions) === null || _b === void 0 ? void 0 : _b.sharingFormat) ? (_d = (_c = this === null || this === void 0 ? void 0 : this.aaSettings) === null || _c === void 0 ? void 0 : _c.agentActions) === null || _d === void 0 ? void 0 : _d.sharingFormat : 'plainString';
2288
- if (format == 'plainString') {
2289
- sendData = this.extractTextFromElement(askCustNode);
2290
- }
2291
- }
2292
- return sendData;
2293
- };
2294
- rootService.prototype.createMessagePayload = function (actionType, sendData) {
2295
- return {
2296
- method: actionType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? 'send' : 'copy',
2297
- name: actionType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SENDMSG : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPYMSG,
2298
- conversationId: this.connectionDetails.conversationId,
2299
- payload: sendData,
2300
- };
2301
- };
2302
- rootService.prototype.messageNodeSendorCopyEvent = function (eventName, payload, automation, hostInstance) {
2303
- var payloadForBE = this.buildBackendPayload(eventName, payload, automation);
2304
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, payloadForBE);
2305
- };
2306
- rootService.prototype.buildBackendPayload = function (eventName, payload, automation) {
2307
- var _a, _b, _c, _d;
2308
- var basePayload = {
2309
- usedType: eventName === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY_METHOD,
2310
- name: eventName === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SENDMSG : _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPYMSG,
2311
- conversationId: this.connectionDetails.conversationId,
2312
- payload: payload,
2313
- botId: this.connectionDetails.botId,
2314
- positionId: automation === null || automation === void 0 ? void 0 : automation.dialogId,
2315
- type: 'sentence',
2316
- sessionId: this.getSessionId(),
2317
- skipMsg: ((_a = automation === null || automation === void 0 ? void 0 : automation.data) === null || _a === void 0 ? void 0 : _a.errorMsg) || automation.skipMsg || false,
2318
- };
2319
- if (((_b = automation === null || automation === void 0 ? void 0 : automation.data) === null || _b === void 0 ? void 0 : _b.isPrompt) && ((_c = automation === null || automation === void 0 ? void 0 : automation.data) === null || _c === void 0 ? void 0 : _c.componentType)) {
2320
- basePayload.componentType = automation.data.componentType;
2321
- }
2322
- else if (!((_d = automation === null || automation === void 0 ? void 0 : automation.data) === null || _d === void 0 ? void 0 : _d.isPrompt)) {
2323
- basePayload.partialMessage = true;
2324
- }
2325
- return this.addSourceMsgIdToRequestParams(automation, basePayload);
2326
- };
2327
- rootService.prototype.getSessionId = function () {
2328
- return this.activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.MYBOT ? this.myBotTabSessionId : this.assistTabSessionId;
2329
- };
2330
- //Send copy click events handling logic ends
2331
- // Feedback logic for suggestions and automations starts
2332
- rootService.prototype.renderFeedbackForEachSuggestion = function (suggestionListTemplate, suggestionList, feedbackType, hostInstance) {
2333
- var _this = this;
2334
- var _a, _b;
2335
- if ((_b = (_a = this.aaSettings) === null || _a === void 0 ? void 0 : _a.feedback[feedbackType]) === null || _b === void 0 ? void 0 : _b.isEnabled) {
2336
- suggestionListTemplate === null || suggestionListTemplate === void 0 ? void 0 : suggestionListTemplate.forEach(function (suggestionTemplate, index) {
2337
- var _a, _b;
2338
- var positionId = (_a = suggestionList[index]) === null || _a === void 0 ? void 0 : _a.positionId;
2339
- var feedbackWrapperTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.FeedbackWrapperInsideDialog, { dialog: { dialogId: positionId } }, hostInstance);
2340
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, feedbackWrapperTemplate, {
2341
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FEEDBACK_WRAPER_TEMPLATE,
2342
- data: { dialog: { dialogId: positionId } }
2343
- });
2344
- suggestionTemplate.append(feedbackWrapperTemplate);
2345
- _this.handleFeedbackType({ dialogId: positionId, feedbackData: (_b = suggestionList[index]) === null || _b === void 0 ? void 0 : _b.feedbackData }, suggestionTemplate, feedbackType, hostInstance);
2346
- });
2347
- }
2348
- };
2349
- rootService.prototype.handleFeedbackType = function (automation, dialogWrapper, feedbackType, hostInstance) {
2350
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2351
- var dislikeList = [];
2352
- var language = ((_a = this.connectionDetails) === null || _a === void 0 ? void 0 : _a.interactiveLanguage) || 'en';
2353
- language = (_constants_settingsConsts__WEBPACK_IMPORTED_MODULE_10__.FeebackConst.DEFAULT_FEEDBACK_LANGUAGE_LIST.indexOf(language.toLowerCase()) != -1) ? language.toLowerCase() : 'en';
2354
- var suggestionList = ((_d = (_c = (_b = this.aaSettings) === null || _b === void 0 ? void 0 : _b.feedback[feedbackType]) === null || _c === void 0 ? void 0 : _c.negativeKeyWords) === null || _d === void 0 ? void 0 : _d[language]) ?
2355
- (_g = (_f = (_e = this.aaSettings) === null || _e === void 0 ? void 0 : _e.feedback[feedbackType]) === null || _f === void 0 ? void 0 : _f.negativeKeyWords) === null || _g === void 0 ? void 0 : _g[language] : (_j = (_h = this.defaultFeedbackSettings[feedbackType]) === null || _h === void 0 ? void 0 : _h.negativeKeyWords) === null || _j === void 0 ? void 0 : _j[language];
2356
- suggestionList === null || suggestionList === void 0 ? void 0 : suggestionList.forEach(function (element) {
2357
- if (element.isEnabled) {
2358
- dislikeList.push(element.key);
2359
- }
2360
- });
2361
- var showComments = (_l = (_k = this.aaSettings) === null || _k === void 0 ? void 0 : _k.feedback[feedbackType]) === null || _l === void 0 ? void 0 : _l.acceptComment;
2362
- var feedbackHelpfulSection = (_m = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _m === void 0 ? void 0 : _m.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_HELPFUL_SECTION).concat(automation.dialogId));
2363
- var feedbackWrapper = (_o = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _o === void 0 ? void 0 : _o.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_WRAPPER).concat(automation.dialogId));
2364
- var helpSection = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_feedback_feedback__WEBPACK_IMPORTED_MODULE_8__.HelpfulFeedbackSection, { feedbackData: automation === null || automation === void 0 ? void 0 : automation.feedbackData, dialogId: automation.dialogId, suggestionList: dislikeList, showComments: showComments, feedbackType: feedbackType }, hostInstance);
2365
- var negativeFeedbackSection = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_feedback_feedback__WEBPACK_IMPORTED_MODULE_8__.NegativeFeedbackSection, { feedbackData: automation === null || automation === void 0 ? void 0 : automation.feedbackData, suggestionList: dislikeList, dialogId: automation.dialogId, hostInstance: hostInstance, feedbackType: feedbackType, showComments: showComments }, hostInstance);
2366
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, helpSection, {
2367
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.HELPFUL_FEEDBACK_TEMPLATE,
2368
- data: { dialogId: automation.dialogId }
2369
- });
2370
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, negativeFeedbackSection, {
2371
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.NEGATIVE_FEEDBACK_TEMPLATE,
2372
- data: { suggestionList: dislikeList, dialogId: automation.dialogId }
2373
- });
2374
- helpSection && (feedbackHelpfulSection === null || feedbackHelpfulSection === void 0 ? void 0 : feedbackHelpfulSection.append(helpSection));
2375
- negativeFeedbackSection && (feedbackWrapper === null || feedbackWrapper === void 0 ? void 0 : feedbackWrapper.append(negativeFeedbackSection));
2376
- this.handleFeebackClickEvents(helpSection, negativeFeedbackSection, feedbackWrapper, dislikeList, showComments, automation, hostInstance);
2377
- };
2378
- // Feedback logic for suggestions and automations ends
2379
- //Feedback click events start
2380
- rootService.prototype.handleFeebackClickEvents = function (helpSection, negativeFeedbackSection, feedbackWrapper, dislikeList, showComments, automation, hostInstance) {
2381
- var _this = this;
2382
- // Helper to add event listeners
2383
- var addEvent = function (selector, event, handler, element) {
2384
- var _a;
2385
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(selector, event, handler, element);
2386
- };
2387
- // Helper to toggle classes
2388
- var toggleClass = function (element, className, action) {
2389
- var _a;
2390
- (_a = element.classList) === null || _a === void 0 ? void 0 : _a[action](className);
2391
- };
2392
- //check active button
2393
- var activeButton = function (btn) {
2394
- var _a;
2395
- return (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.FEEDBACK_ACTIVE_BUTTON);
2396
- };
2397
- // Handle positive feedback
2398
- var handlePositiveFeedback = function () {
2399
- var positiveButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_POSITIVE));
2400
- var negativeButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE));
2401
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
2402
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
2403
- if (!activeButton(positiveButton)) {
2404
- toggleClass(positiveButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'add');
2405
- toggleClass(negativeButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'remove');
2406
- toggleClass(negativeArrowBtn, _this.classConstants.HIDE_ELEMENT, 'add');
2407
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'remove');
2408
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'add');
2409
- _this.prepareAndMakeFeedbackRequest(automation, negativeFeedbackSection, commentBox, helpSection, 'like', dislikeList, showComments, hostInstance);
2410
- }
2411
- };
2412
- // Handle negative feedback
2413
- var handleNegativeFeedback = function () {
2414
- var positiveButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_POSITIVE));
2415
- var negativeButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE));
2416
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
2417
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
2418
- if (showComments || (dislikeList === null || dislikeList === void 0 ? void 0 : dislikeList.length) > 0) {
2419
- toggleClass(negativeArrowBtn, _this.classConstants.HIDE_ELEMENT, 'remove');
2420
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'remove');
2421
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'add');
2422
- }
2423
- if (!activeButton(negativeButton)) {
2424
- toggleClass(negativeButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'add');
2425
- toggleClass(positiveButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'remove');
2426
- _this.prepareAndMakeFeedbackRequest(automation, negativeFeedbackSection, commentBox, helpSection, 'dislike', dislikeList, showComments, hostInstance);
2427
- }
2428
- };
2429
- // Handle dropdown toggle
2430
- var handleDropdownToggle = function () {
2431
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
2432
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
2433
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'toggle');
2434
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'toggle');
2435
- };
2436
- // Attach event listeners
2437
- addEvent(this.classConstants.FEEDBACK_POSITIVE, 'click', handlePositiveFeedback, helpSection);
2438
- addEvent(this.classConstants.FEEDBACK_NEGATIVE, 'click', handleNegativeFeedback, helpSection);
2439
- addEvent(this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN, 'click', handleDropdownToggle, helpSection);
2440
- // Handle suggestions click
2441
- dislikeList.forEach(function (suggestion, index) {
2442
- var suggestionClassName = "".concat(_this.classConstants.FEEDBACK_SUGGESTION).concat(automation.dialogId, "-").concat(index);
2443
- var suggestionEle = negativeFeedbackSection.querySelector("".concat(suggestionClassName));
2444
- addEvent(suggestionClassName, 'click', function () {
2445
- toggleClass(suggestionEle, _this.classConstants.FEEDBACK_NEGATIVE_SUGGESTION_SELECTION, 'toggle');
2446
- }, negativeFeedbackSection);
2447
- });
2448
- // Handle submit feedback
2449
- addEvent(this.classConstants.FEEDBACK_SUBMIT, 'click', function () {
2450
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
2451
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
2452
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'add');
2453
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'remove');
2454
- _this.prepareAndMakeFeedbackRequest(automation, negativeFeedbackSection, commentBox, helpSection, 'submit', dislikeList, showComments, hostInstance);
2455
- }, negativeFeedbackSection);
2456
- // Handle comment box input
2457
- var commentBox = negativeFeedbackSection.querySelector("".concat(this.classConstants.FEEDBACK_COMMENT).concat(automation.dialogId));
2458
- addEvent("".concat(this.classConstants.FEEDBACK_COMMENT).concat(automation.dialogId), 'input', function (e) {
2459
- var _a;
2460
- var commentLength = ((_a = commentBox === null || commentBox === void 0 ? void 0 : commentBox.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
2461
- negativeFeedbackSection.querySelector("".concat(_this.classConstants.FEEDBACK_COMMENT_COUNT)).innerText = "".concat(commentLength, "/150");
2462
- }, negativeFeedbackSection);
2463
- };
2464
- rootService.prototype.handleWidgetFeedbackClickEvents = function (widgetFeedbackSection, type, hostInstance) {
2465
- var _this = this;
2466
- var addEvent = function (selector, event, handler, element) {
2467
- var _a;
2468
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(selector, event, handler, element);
2469
- };
2470
- var toggleClassInSubmitButton = function (type) {
2471
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2472
- if (type === void 0) { type = 'positive'; }
2473
- if (type === 'negative' && !((_a = _this.widgetFeedbackData.selectedSuggestions) === null || _a === void 0 ? void 0 : _a.length) && !((_b = _this.widgetFeedbackData.comment) === null || _b === void 0 ? void 0 : _b.length)) {
2474
- (_e = (_d = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector) === null || _d === void 0 ? void 0 : _d.call(_c, _this.classConstants.FEEDBACK_SUBMIT_BTN)) === null || _e === void 0 ? void 0 : _e.setAttribute('disabled', true);
2475
- return;
2476
- }
2477
- if ((_h = (_g = (_f = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _f === void 0 ? void 0 : _f.querySelector) === null || _g === void 0 ? void 0 : _g.call(_f, _this.classConstants.FEEDBACK_SUBMIT_BTN)) === null || _h === void 0 ? void 0 : _h.hasAttribute('disabled')) {
2478
- (_l = (_k = (_j = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _j === void 0 ? void 0 : _j.querySelector) === null || _k === void 0 ? void 0 : _k.call(_j, _this.classConstants.FEEDBACK_SUBMIT_BTN)) === null || _l === void 0 ? void 0 : _l.removeAttribute('disabled');
2479
- }
2480
- };
2481
- var handlePositiveFeedbackSection = function (widgetFeedbackSection) {
2482
- var positiveSuggestionsBtns = widgetFeedbackSection === null || widgetFeedbackSection === void 0 ? void 0 : widgetFeedbackSection.querySelectorAll(_this.classConstants.POSITIVE_FEEDBACK);
2483
- var positiveCommentBox = widgetFeedbackSection === null || widgetFeedbackSection === void 0 ? void 0 : widgetFeedbackSection.querySelector(_this.classConstants.POSITIVE_FEEDBACK_COMMENT);
2484
- var widgetFeedbackData = _this.widgetFeedbackData;
2485
- widgetFeedbackData.selectedSuggestions = [];
2486
- if (!widgetFeedbackData.type) {
2487
- widgetFeedbackData.type = 'positive';
2488
- }
2489
- positiveSuggestionsBtns === null || positiveSuggestionsBtns === void 0 ? void 0 : positiveSuggestionsBtns.forEach(function (suggestionBtn) {
2490
- addEvent(".".concat(suggestionBtn.classList[1]), 'click', function (e) {
2491
- var _a, _b;
2492
- if (widgetFeedbackData.type === 'negative') {
2493
- handleAlternateFeedbackSection(widgetFeedbackSection, 'negative', widgetFeedbackData);
2494
- }
2495
- toggleClassInSubmitButton();
2496
- if (e && ((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2497
- if (widgetFeedbackData.selectedSuggestions.includes(e.target.value)) {
2498
- widgetFeedbackData.selectedSuggestions = widgetFeedbackData.selectedSuggestions.filter(function (suggestion) { return suggestion !== e.target.value; });
2499
- suggestionBtn.classList.remove('active-improve-btn');
2500
- }
2501
- else {
2502
- suggestionBtn.classList.add('active-improve-btn');
2503
- widgetFeedbackData.selectedSuggestions.push(e.target.value);
2504
- }
2505
- }
2506
- }, widgetFeedbackSection);
2507
- });
2508
- addEvent(".".concat(positiveCommentBox.classList[2]), 'input', function (e) {
2509
- var _a, _b, _c, _d;
2510
- if (widgetFeedbackData.type === 'negative') {
2511
- handleAlternateFeedbackSection(widgetFeedbackSection, 'negative', widgetFeedbackData);
2512
- }
2513
- toggleClassInSubmitButton();
2514
- widgetFeedbackData.comment = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || '';
2515
- var positiveCommentBoxCount = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(_this.classConstants.FEEDBACK_COMMENT_COUNT, "-").concat(widgetFeedbackData.type));
2516
- if (positiveCommentBoxCount) {
2517
- positiveCommentBoxCount.innerText = "".concat(((_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.length) || 0, "/150");
2518
- }
2519
- }, widgetFeedbackSection);
2520
- };
2521
- var handleNegativeFeedbackSection = function (widgetFeedbackSection) {
2522
- var negativeSuggestionsBtns = widgetFeedbackSection === null || widgetFeedbackSection === void 0 ? void 0 : widgetFeedbackSection.querySelectorAll(_this.classConstants.NEGATIVE_FEEDBACK);
2523
- var negativeCommentBox = widgetFeedbackSection === null || widgetFeedbackSection === void 0 ? void 0 : widgetFeedbackSection.querySelector(_this.classConstants.NEGATIVE_FEEDBACK_COMMENT);
2524
- var widgetFeedbackData = _this.widgetFeedbackData;
2525
- widgetFeedbackData.selectedSuggestions = [];
2526
- if (!widgetFeedbackData.type) {
2527
- widgetFeedbackData.type = 'negative';
2528
- }
2529
- negativeSuggestionsBtns === null || negativeSuggestionsBtns === void 0 ? void 0 : negativeSuggestionsBtns.forEach(function (suggestionBtn) {
2530
- addEvent(".".concat(suggestionBtn.classList[1]), 'click', function (e) {
2531
- var _a, _b;
2532
- if (widgetFeedbackData.type === 'positive') {
2533
- handleAlternateFeedbackSection(widgetFeedbackSection, 'positive', widgetFeedbackData);
2534
- }
2535
- if (e && ((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2536
- if (widgetFeedbackData.selectedSuggestions.includes(e.target.value)) {
2537
- widgetFeedbackData.selectedSuggestions = widgetFeedbackData.selectedSuggestions.filter(function (suggestion) { return suggestion !== e.target.value; });
2538
- suggestionBtn.classList.remove('active-improve-btn');
2539
- }
2540
- else {
2541
- suggestionBtn.classList.add('active-improve-btn');
2542
- widgetFeedbackData.selectedSuggestions.push(e.target.value);
2543
- }
2544
- }
2545
- toggleClassInSubmitButton('negative');
2546
- }, widgetFeedbackSection);
2547
- });
2548
- addEvent(".".concat(negativeCommentBox === null || negativeCommentBox === void 0 ? void 0 : negativeCommentBox.classList[2]), 'input', function (e) {
2549
- var _a, _b, _c, _d;
2550
- if (widgetFeedbackData.type === 'positive') {
2551
- handleAlternateFeedbackSection(widgetFeedbackSection, 'positive', widgetFeedbackData);
2552
- }
2553
- widgetFeedbackData.comment = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || '';
2554
- toggleClassInSubmitButton('negative');
2555
- var negativeCommentBoxCount = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(_this.classConstants.FEEDBACK_COMMENT_COUNT, "-").concat(widgetFeedbackData.type));
2556
- if (negativeCommentBoxCount) {
2557
- negativeCommentBoxCount.innerText = "".concat(((_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.length) || 0, "/150");
2558
- }
2559
- }, widgetFeedbackSection);
2560
- };
2561
- var handleAlternateFeedbackSection = function (widgetFeedbackSection, type, widgetFeedbackData) {
2562
- var _a, _b, _c, _d;
2563
- if (widgetFeedbackData === void 0) { widgetFeedbackData = _this.widgetFeedbackData; }
2564
- if (type === 'negative') {
2565
- var negativeSuggestionsBtns = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll(_this.classConstants.NEGATIVE_FEEDBACK);
2566
- var negativeCommentBox = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector(_this.classConstants.NEGATIVE_FEEDBACK_COMMENT);
2567
- negativeSuggestionsBtns === null || negativeSuggestionsBtns === void 0 ? void 0 : negativeSuggestionsBtns.forEach(function (suggestionBtn) {
2568
- suggestionBtn.classList.remove('active-improve-btn');
2569
- });
2570
- negativeCommentBox.value = '';
2571
- widgetFeedbackData.selectedSuggestions = [];
2572
- widgetFeedbackData.comment = '';
2573
- widgetFeedbackData.type = 'positive';
2574
- }
2575
- else {
2576
- var positiveSuggestionsBtns = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelectorAll(_this.classConstants.POSITIVE_FEEDBACK);
2577
- var positiveCommentBox = (_d = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _d === void 0 ? void 0 : _d.querySelector(_this.classConstants.POSITIVE_FEEDBACK_COMMENT);
2578
- positiveSuggestionsBtns === null || positiveSuggestionsBtns === void 0 ? void 0 : positiveSuggestionsBtns.forEach(function (suggestionBtn) {
2579
- suggestionBtn.classList.remove('active-improve-btn');
2580
- });
2581
- positiveCommentBox.value = '';
2582
- widgetFeedbackData.selectedSuggestions = [];
2583
- widgetFeedbackData.comment = '';
2584
- widgetFeedbackData.type = 'negative';
2585
- }
2586
- };
2587
- if (type === 'positive') {
2588
- handlePositiveFeedbackSection(widgetFeedbackSection);
2589
- }
2590
- else {
2591
- handleNegativeFeedbackSection(widgetFeedbackSection);
2592
- }
2593
- };
2594
- rootService.prototype.prepareAndMakeWidgetFeedbackRequest = function (hostInstance) {
2595
- var _a = this.connectionDetails, botId = _a.botId, conversationId = _a.conversationId, channel = _a.channel;
2596
- var feedbackType = this.widgetFeedbackData.type && (this.widgetFeedbackData.type === 'positive' ? 'like' : 'dislike') || null;
2597
- var feedbackSuggestions = this.widgetFeedbackData.selectedSuggestions;
2598
- var feedbackComment = this.widgetFeedbackData.comment;
2599
- if (!this.widgetFeedbackData.positionId) {
2600
- this.widgetFeedbackData.positionId = (0,_utils_randomuuid__WEBPACK_IMPORTED_MODULE_5__["default"])('positionId');
2601
- }
2602
- var feedbackDetails = {
2603
- botId: botId,
2604
- conversationId: conversationId,
2605
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback,
2606
- positionId: this.widgetFeedbackData.positionId,
2607
- experience: channel,
2608
- feedback: feedbackType,
2609
- feedbackDetails: feedbackSuggestions,
2610
- comment: feedbackComment || '',
2611
- type: 'widget',
2612
- interactionType: 'widget'
2613
- };
2614
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback, feedbackDetails);
2615
- };
2616
- rootService.prototype.prepareAndMakeFeedbackRequest = function (automation, negativeFeedbackSection, commentBox, helpSection, type, dislikeList, showComments, hostInstance) {
2617
- var _a;
2618
- var feedbackData = automation === null || automation === void 0 ? void 0 : automation.feedbackData;
2619
- var _b = this.connectionDetails, botId = _b.botId, conversationId = _b.conversationId, channel = _b.channel;
2620
- var feedbackList = [];
2621
- var activeSuggestionBtnList = negativeFeedbackSection.querySelectorAll(".".concat(this.classConstants.FEEDBACK_NEGATIVE_SUGGESTION_SELECTION));
2622
- activeSuggestionBtnList.forEach(function (suggestionEle) {
2623
- var inputElement = suggestionEle;
2624
- if (inputElement === null || inputElement === void 0 ? void 0 : inputElement.value)
2625
- feedbackList.push(inputElement.value);
2626
- });
2627
- var activeFeedback = (_a = helpSection === null || helpSection === void 0 ? void 0 : helpSection.querySelector(".".concat(this.classConstants.FEEDBACK_ACTIVE_BUTTON))) === null || _a === void 0 ? void 0 : _a.value;
2628
- var feedbackDetails = {
2629
- botId: botId,
2630
- conversationId: conversationId,
2631
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback,
2632
- positionId: feedbackData.positionId,
2633
- experience: channel,
2634
- feedback: activeFeedback || null,
2635
- feedbackDetails: feedbackList,
2636
- comment: (commentBox === null || commentBox === void 0 ? void 0 : commentBox.value) || '',
2637
- };
2638
- if (feedbackData.suggestionType) {
2639
- var sourceMsgId = feedbackData.sourceMsgId, suggestionType = feedbackData.suggestionType, query = feedbackData.query, subType = feedbackData.subType, title = feedbackData.title, answer = feedbackData.answer, sources = feedbackData.sources, isFromGeneratedSummary = feedbackData.isFromGeneratedSummary, answerType = feedbackData.answerType, interactionType = feedbackData.interactionType;
2640
- Object.assign(feedbackDetails, {
2641
- sourceMsgId: sourceMsgId,
2642
- type: suggestionType,
2643
- query: query,
2644
- subType: subType,
2645
- title: title,
2646
- answer: answer,
2647
- interactionType: interactionType
2648
- });
2649
- if (suggestionType === 'answer') {
2650
- Object.assign(feedbackDetails, {
2651
- sources: sources,
2652
- isFromGeneratedSummary: isFromGeneratedSummary,
2653
- answerType: answerType
2654
- });
2655
- }
2656
- }
2657
- else {
2658
- feedbackDetails.taskId = feedbackData.uuid;
2659
- feedbackDetails.taskName = feedbackData.dialogName;
2660
- feedbackDetails.type = 'dialog';
2661
- feedbackDetails.interactionType = this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.ASSIST ? 'assist' : this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.CUSTOM_TAB ? 'custom' : 'mybot';
2662
- }
2663
- if ((feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.suggestionType) === 'summary') {
2664
- feedbackDetails.summaryId = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.summaryId;
2665
- feedbackDetails.traceId = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.traceId;
2666
- }
2667
- this.isUpdateFeedBackDetailsFlag = type != 'dislike' || ((dislikeList === null || dislikeList === void 0 ? void 0 : dislikeList.length) === 0 && !showComments) ? true : false;
2668
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback, feedbackDetails);
2669
- };
2670
- //Feedback click events end
2671
- //smalltalk template code starts
2672
- rootService.prototype.addSmallTalkTemplate = function (smallTalkObj, activeTab, hostInstance) {
2673
- var _a, _b, _c;
2674
- var mybotWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.MYBOT_SECTION));
2675
- var assistWrapper = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.ASSIST_SECTION));
2676
- var customWrapper = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(this.classConstants.CUSTOM_TAB_SECTION));
2677
- var template = this.getSmallTalkTemplate(smallTalkObj, activeTab, hostInstance);
2678
- if (template && assistWrapper && activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) {
2679
- assistWrapper.append(template);
2680
- }
2681
- else if (template && mybotWrapper && activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT) {
2682
- mybotWrapper.append(template);
2683
- }
2684
- else if (template && customWrapper && activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM) {
2685
- customWrapper.append(template);
2686
- }
2687
- };
2688
- ;
2689
- rootService.prototype.getSmallTalkTemplate = function (smallTalkObj, activeTab, hostInstance) {
2690
- var template = null;
2691
- switch (smallTalkObj.nodeType) {
2692
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE:
2693
- var manualMode = this.manualAssistOverrideMode || !this.proactiveMode;
2694
- var payload = { entityNode: smallTalkObj, activeTab: activeTab, manualMode: manualMode, hostInstance: hostInstance };
2695
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.AskCustomer, payload, hostInstance);
2696
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2697
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ASK_CUSTOMER_TEMPLATE,
2698
- data: payload
2699
- });
2700
- this.appendTemplate(template, smallTalkObj);
2701
- this.handleNodeResponse(smallTalkObj, template, hostInstance);
2702
- this.handleEntityNodeClickEvents(template, smallTalkObj, activeTab, hostInstance);
2703
- break;
2704
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE:
2705
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.TellCustomer, { msgNode: smallTalkObj, hostInstance: hostInstance }, hostInstance);
2706
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2707
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.TELL_CUSTOMER_TEMPLATE,
2708
- data: smallTalkObj
2709
- });
2710
- this.appendTemplate(template, smallTalkObj);
2711
- this.handleNodeResponse(smallTalkObj, template, hostInstance);
2712
- break;
2713
- }
2714
- return template;
2715
- };
2716
- ;
2717
- //smallTalk template code ends
2718
- // Automation template code starts
2719
- rootService.prototype.addDialogTemplate = function (automationNodeObj, automation, activeTab, hostInstance) {
2720
- var _a, _b;
2721
- var dialogWrapper = this.getDialogWrapper(hostInstance, automation.dialogId);
2722
- var template = null;
2723
- switch (automationNodeObj.type) {
2724
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_START:
2725
- template = this.getAutomationStartTemplate(automation, hostInstance);
2726
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2727
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.DIALOG_START_TEMPLATE,
2728
- data: automation
2729
- });
2730
- break;
2731
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END:
2732
- this.appendFeedbackWrapper(dialogWrapper, automation, hostInstance);
2733
- template = this.getAutomationEndTemplate(automation, hostInstance);
2734
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2735
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.DIALOG_END_TEMPLATE,
2736
- data: automation
2737
- });
2738
- break;
2739
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE:
2740
- template = this.getAutomationNodeTemplate(automation, automationNodeObj, activeTab, hostInstance);
2741
- break;
2742
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK:
2743
- if ((_b = (_a = this.aaSettings) === null || _a === void 0 ? void 0 : _a.feedback[_constants_settingsConsts__WEBPACK_IMPORTED_MODULE_10__.FeebackConst.DIALOGS]) === null || _b === void 0 ? void 0 : _b.isEnabled) {
2744
- automation.feedbackData = automationNodeObj;
2745
- this.handleFeedbackType(automation, dialogWrapper, _constants_settingsConsts__WEBPACK_IMPORTED_MODULE_10__.FeebackConst.DIALOGS, hostInstance);
2746
- }
2747
- return;
2748
- default:
2749
- return;
2750
- }
2751
- this.appendAutomationEachNodeTemplate(dialogWrapper, template, automationNodeObj, automation.dialogId);
2752
- };
2753
- rootService.prototype.getDialogWrapper = function (hostInstance, dialogId) {
2754
- var _a, _b;
2755
- return (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(this.classConstants.DIALOG_WRAPPER).concat(dialogId));
2756
- };
2757
- rootService.prototype.getAutomationStartTemplate = function (automation, hostInstance) {
2758
- return (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.DialogStart, { dialog: automation }, hostInstance);
2759
- };
2760
- rootService.prototype.getAutomationEndTemplate = function (automation, hostInstance) {
2761
- var _a, _b;
2762
- var feedbackEnable = ((_b = (_a = this.aaSettings) === null || _a === void 0 ? void 0 : _a.feedback[_constants_settingsConsts__WEBPACK_IMPORTED_MODULE_10__.FeebackConst.DIALOGS]) === null || _b === void 0 ? void 0 : _b.isEnabled) ? true : false;
2763
- return (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.DialogEnd, { dialog: automation, feedbackEnable: feedbackEnable }, hostInstance);
2764
- };
2765
- rootService.prototype.appendFeedbackWrapper = function (dialogWrapper, automation, hostInstance) {
2766
- var feedbackWrapperTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.FeedbackWrapperInsideDialog, { dialog: automation }, hostInstance);
2767
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, feedbackWrapperTemplate, {
2768
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FEEDBACK_WRAPER_TEMPLATE,
2769
- data: automation
2770
- });
2771
- dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.append(feedbackWrapperTemplate);
2772
- };
2773
- rootService.prototype.getAutomationNodeTemplate = function (automation, automationNodeObj, activeTab, hostInstance) {
2774
- var template = null;
2775
- switch (automationNodeObj.nodeType) {
2776
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE:
2777
- var manualMode = this.manualAssistOverrideMode || !this.proactiveMode;
2778
- var payload = { entityNode: automationNodeObj, activeTab: activeTab, manualMode: manualMode, hostInstance: hostInstance };
2779
- if (automationNodeObj.data.entityType != 'attachment') {
2780
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.AskCustomer, payload, hostInstance);
2781
- }
2782
- else {
2783
- automationNodeObj.fileObj = {};
2784
- if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) {
2785
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.AttachmentAskCustomer, payload, hostInstance);
2786
- }
2787
- else {
2788
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.MybotAttachmentAskCustomer, payload, hostInstance);
2789
- }
2790
- }
2791
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2792
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ASK_CUSTOMER_TEMPLATE,
2793
- data: payload
2794
- });
2795
- this.appendTemplate(template, automationNodeObj);
2796
- this.templateRenderCheck(template, automationNodeObj, hostInstance);
2797
- this.handleEntityNodeClickEvents(template, automationNodeObj, activeTab, hostInstance);
2798
- break;
2799
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE:
2800
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.TellCustomer, { msgNode: automationNodeObj, hostInstance: hostInstance }, hostInstance);
2801
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2802
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.TELL_CUSTOMER_TEMPLATE,
2803
- data: automationNodeObj
2804
- });
2805
- this.appendTemplate(template, automationNodeObj);
2806
- this.templateRenderCheck(template, automationNodeObj, hostInstance);
2807
- break;
2808
- }
2809
- return template;
2810
- };
2811
- rootService.prototype.checkForGreyOut = function (template, automationNodeObj, hostInstance) {
2812
- if (this.isHistory && typeof this.prefsOpacity === 'number') {
2813
- template.style.opacity = (this.prefsOpacity / 100).toString();
2814
- }
2815
- };
2816
- rootService.prototype.templateRenderCheck = function (template, automationNodeObj, hostInstance) {
2817
- if ((automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.templateRender) !== true) {
2818
- this.handleNodeResponse(automationNodeObj, template, hostInstance);
2819
- }
2820
- else {
2821
- this.checkForGreyOut(template, automationNodeObj, hostInstance);
2822
- }
2823
- };
2824
- rootService.prototype.appendTemplateToContainer = function (template, entityNode) {
2825
- var _a, _b;
2826
- try {
2827
- // Validate inputs
2828
- if (!template) {
2829
- return;
2830
- }
2831
- if (!(entityNode === null || entityNode === void 0 ? void 0 : entityNode.templateRender)) {
2832
- return;
2833
- }
2834
- if (!(entityNode === null || entityNode === void 0 ? void 0 : entityNode.template)) {
2835
- return;
2836
- }
2837
- // Find container element
2838
- var container = template.querySelector('.chat-container');
2839
- if (!container) {
2840
- console.error('Chat container element not found');
2841
- return;
2842
- }
2843
- // Safely append template
2844
- try {
2845
- var timeStamp = (_b = (_a = entityNode === null || entityNode === void 0 ? void 0 : entityNode.template) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, ".top-info");
2846
- if (timeStamp) {
2847
- timeStamp.remove();
2848
- }
2849
- container.append(entityNode.template);
2850
- }
2851
- catch (appendError) {
2852
- console.error('Failed to append template to container:', appendError);
2853
- // Optionally implement fallback behavior here
2854
- }
2855
- }
2856
- catch (error) {
2857
- console.error('Error in appendTemplateToContainer:', error);
2858
- // Optionally implement error recovery or notification system
2859
- }
2860
- };
2861
- rootService.prototype.handleErrorPrompts = function (automation, automationNodeObj, hostInstance) {
2862
- var _this = this;
2863
- var _a, _b, _c, _d;
2864
- var prevEnityNode = null;
2865
- for (var i = ((_a = automation === null || automation === void 0 ? void 0 : automation.automationNodes) === null || _a === void 0 ? void 0 : _a.length) - 1; i >= 0; i--) {
2866
- prevEnityNode = ((_c = (_b = automation.automationNodes[i]) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.isPrompt) ? automation.automationNodes[i] : null;
2867
- if (prevEnityNode) {
2868
- break;
2869
- }
2870
- }
2871
- if (prevEnityNode) {
2872
- var lastAutomationNodes = (_d = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _d === void 0 ? void 0 : _d.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(prevEnityNode.uuid));
2873
- lastAutomationNodes.forEach(function (lastAutomationEle) {
2874
- var _a, _b, _c, _d, _e;
2875
- var entityBody = lastAutomationEle === null || lastAutomationEle === void 0 ? void 0 : lastAutomationEle.querySelector("".concat(_this.classConstants.ENTITY_MSG_BODY));
2876
- if (((_a = prevEnityNode === null || prevEnityNode === void 0 ? void 0 : prevEnityNode.data) === null || _a === void 0 ? void 0 : _a.isPrompt) && ((_b = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _b === void 0 ? void 0 : _b.isErrorPrompt)) {
2877
- automationNodeObj.errorCount = (prevEnityNode.errorCount || 0) + 1;
2878
- entityBody === null || entityBody === void 0 ? void 0 : entityBody.remove();
2879
- }
2880
- else {
2881
- // remove error count from dialog
2882
- var automationEle = (_c = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _c === void 0 ? void 0 : _c.querySelector("".concat(_this.classConstants.DIALOG_WRAPPER).concat(automation.dialogId));
2883
- var errorMsgs = automationEle === null || automationEle === void 0 ? void 0 : automationEle.querySelectorAll(".wrong-res-info");
2884
- errorMsgs === null || errorMsgs === void 0 ? void 0 : errorMsgs.forEach(function (ele) {
2885
- ele.remove();
2886
- });
2887
- // remove error count from listview
2888
- var listView = (_d = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _d === void 0 ? void 0 : _d.querySelector("".concat(_this.classConstants.LIST_VIEW_POPUP));
2889
- var listViewErrorMsgs = listView === null || listView === void 0 ? void 0 : listView.querySelectorAll(".wrong-res-info");
2890
- listViewErrorMsgs === null || listViewErrorMsgs === void 0 ? void 0 : listViewErrorMsgs.forEach(function (ele) {
2891
- ele.remove();
2892
- });
2893
- (_e = entityBody === null || entityBody === void 0 ? void 0 : entityBody.classList) === null || _e === void 0 ? void 0 : _e.remove('error-no-reponse');
2894
- }
2895
- if (lastAutomationEle && typeof _this.prefsOpacity === 'number') {
2896
- lastAutomationEle.style.opacity = (_this.prefsOpacity / 100).toString();
2897
- }
2898
- });
2899
- // let lastAutomationEle = hostInstance?.chatEle?.querySelector(`${this.classConstants.ASK_CUST_NODE}${prevEnityNode.uuid}`);
2900
- }
2901
- };
2902
- rootService.prototype.appendAutomationEachNodeTemplate = function (dialogWrapper, template, automationNodeObj, dialogId) {
2903
- var _a, _b;
2904
- var feedbackWrapper = (_a = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _a === void 0 ? void 0 : _a.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_WRAPPER).concat(dialogId));
2905
- var feedbackHelpfulSection = (_b = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _b === void 0 ? void 0 : _b.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_HELPFUL_SECTION).concat(dialogId));
2906
- if (template && automationNodeObj.type !== _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END) {
2907
- dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.append(template);
2908
- }
2909
- else if (template) {
2910
- feedbackHelpfulSection === null || feedbackHelpfulSection === void 0 ? void 0 : feedbackHelpfulSection.append(template);
2911
- }
2912
- };
2913
- // Automation template code ends
2914
- //Entity node click events starts
2915
- rootService.prototype.handleEntityNodeClickEvents = function (askCustTemplate, automationNodeObj, currentTab, hostInstance) {
2916
- var _this = this;
2917
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2918
- var inputEle = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_INPUT));
2919
- var overrideBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_OVERRIDE_BTN));
2920
- var removeBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_REMOVE_BTN));
2921
- var checkBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_CHECK_BTN));
2922
- var agentIcon = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_AGENT_ICON));
2923
- var errorTemplate = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ERROR_OVERRIDE_TEXT));
2924
- var chooseFileBtn = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_CHOOSE_FILE));
2925
- if (!inputEle) {
2926
- return;
2927
- }
2928
- if (currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM || currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT) {
2929
- (_a = agentIcon === null || agentIcon === void 0 ? void 0 : agentIcon.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
2930
- }
2931
- if ((!this.proactiveMode || this.manualAssistOverrideMode) || (currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT || currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM)) {
2932
- inputEle.readOnly = false;
2933
- inputEle.focus();
2934
- }
2935
- var onOverrideClick = function (e) { return _this.handleOverrideClick(e, errorTemplate, inputEle, overrideBtn, askCustTemplate, removeBtn, checkBtn, automationNodeObj, hostInstance); };
2936
- var onRemoveClick = function (e) { return _this.handleRemoveClick(e, errorTemplate, inputEle, overrideBtn, removeBtn, checkBtn, askCustTemplate, automationNodeObj, hostInstance); };
2937
- var onCheckClick = function (e) { return _this.handleCheckClick(e, inputEle, automationNodeObj, askCustTemplate, hostInstance); };
2938
- var onInputKeydown = function (e) { return _this.handleInputKeydown(e, inputEle, automationNodeObj, askCustTemplate, currentTab, hostInstance); };
2939
- var onInputChange = function (e) { return _this.handleInputChange(e, inputEle, checkBtn); };
2940
- var onChooseFile = function (e) { return _this.handleChooseFile(e, inputEle, askCustTemplate, automationNodeObj, currentTab, hostInstance); };
2941
- var onViewClick = function (e) { return _this.handleViewClick(e, inputEle, askCustTemplate, automationNodeObj, hostInstance); };
2942
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener("".concat(this.classConstants.ENTITY_OVERRIDE_BTN), 'click', onOverrideClick, askCustTemplate);
2943
- (_c = hostInstance.eventManager) === null || _c === void 0 ? void 0 : _c.addEventListener("".concat(this.classConstants.ENTITY_REMOVE_BTN), 'click', onRemoveClick, askCustTemplate);
2944
- (_d = hostInstance.eventManager) === null || _d === void 0 ? void 0 : _d.addEventListener("".concat(this.classConstants.ENTITY_CHECK_BTN), 'click', onCheckClick, askCustTemplate);
2945
- (_e = hostInstance.eventManager) === null || _e === void 0 ? void 0 : _e.addEventListener("".concat(this.classConstants.ENTITY_INPUT), 'keydown', onInputKeydown, askCustTemplate);
2946
- (_f = hostInstance.eventManager) === null || _f === void 0 ? void 0 : _f.addEventListener("".concat(this.classConstants.ENTITY_INPUT), 'input', onInputChange, askCustTemplate);
2947
- if (((_g = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _g === void 0 ? void 0 : _g.entityType) === 'attachment') {
2948
- (_h = hostInstance.eventManager) === null || _h === void 0 ? void 0 : _h.addEventListener("".concat(this.classConstants.ENTITY_INPUT), 'change', onChooseFile, askCustTemplate);
2949
- (_j = hostInstance.eventManager) === null || _j === void 0 ? void 0 : _j.addEventListener("".concat(this.classConstants.ENTITY_ATTACHMENT_VIEW), 'click', onViewClick, askCustTemplate);
2950
- }
2951
- };
2952
- rootService.prototype.handleViewClick = function (e, inputEle, askCustTemplate, automationNodeObj, hostIns) {
2953
- var _a, _b, _c, _d;
2954
- var viewModal = (_a = hostIns === null || hostIns === void 0 ? void 0 : hostIns.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ENTITY_ATTACHMENT_VIEW_MODAL));
2955
- (_b = viewModal === null || viewModal === void 0 ? void 0 : viewModal.classList) === null || _b === void 0 ? void 0 : _b.remove(this.classConstants.HIDE_ELEMENT);
2956
- var image = viewModal === null || viewModal === void 0 ? void 0 : viewModal.querySelector("".concat(this.classConstants.ENTITY_ATTACHMENT_IMAGE));
2957
- image.src = (_d = (_c = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.attachments[0]) === null || _c === void 0 ? void 0 : _c.url) === null || _d === void 0 ? void 0 : _d.fileUrl;
2958
- };
2959
- rootService.prototype.handleChooseFile = function (e, inputEle, askCustTemplate, automationNodeObj, currentTab, hostInstance) {
2960
- var _a, _b, _c;
2961
- automationNodeObj.fileObj = e.target.files[0];
2962
- var chooseFileText = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_CHOOSE_FILE));
2963
- if ((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj) === null || _a === void 0 ? void 0 : _a.name) {
2964
- chooseFileText.innerText = (_b = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj) === null || _b === void 0 ? void 0 : _b.name;
2965
- }
2966
- if ((currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT || !this.proactiveMode || this.manualAssistOverrideMode) && ((_c = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj) === null || _c === void 0 ? void 0 : _c.name)) {
2967
- this.fileUploadCall(automationNodeObj, hostInstance);
2968
- }
2969
- };
2970
- rootService.prototype.handleOverrideClick = function (e, errorTemplate, inputEle, overrideBtn, askCustTemplate, removeBtn, checkBtn, automationNodeObj, hostInstance) {
2971
- var _a, _b, _c, _d, _e, _f;
2972
- if (inputEle) {
2973
- inputEle.readOnly = false;
2974
- inputEle.placeholder = '';
2975
- inputEle.focus();
2976
- (_a = removeBtn === null || removeBtn === void 0 ? void 0 : removeBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
2977
- (_b = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _b === void 0 ? void 0 : _b.remove(this.classConstants.HIDE_ELEMENT);
2978
- (_c = overrideBtn === null || overrideBtn === void 0 ? void 0 : overrideBtn.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
2979
- if (!this.OverRideMode) {
2980
- hostInstance.handleOverrideMode(true, automationNodeObj.dialogId);
2981
- }
2982
- errorTemplate.innerText = '| Type to continue';
2983
- if (!(automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.errorCount)) {
2984
- (_e = (_d = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
2985
- }
2986
- if (((_f = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _f === void 0 ? void 0 : _f.entityType) === 'attachment') {
2987
- this.toggleAttachmentDiv(automationNodeObj, askCustTemplate, inputEle, true);
2988
- }
2989
- }
2990
- };
2991
- rootService.prototype.handleRemoveClick = function (e, errorTemplate, inputEle, overrideBtn, removeBtn, checkBtn, askCustTemplate, automationNodeObj, hostInstance) {
2992
- var _a, _b, _c, _d, _e, _f;
2993
- inputEle.readOnly = true;
2994
- (_a = overrideBtn === null || overrideBtn === void 0 ? void 0 : overrideBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
2995
- (_b = removeBtn === null || removeBtn === void 0 ? void 0 : removeBtn.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.HIDE_ELEMENT);
2996
- (_c = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
2997
- inputEle.placeholder = 'waiting...';
2998
- inputEle.value = '';
2999
- errorTemplate.innerText = '';
3000
- if (!(automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.errorCount)) {
3001
- (_e = (_d = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.add(this.classConstants.HIDE_ELEMENT);
3002
- }
3003
- if (((_f = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _f === void 0 ? void 0 : _f.entityType) === 'attachment') {
3004
- this.toggleAttachmentDiv(automationNodeObj, askCustTemplate, inputEle, false);
3005
- this.addorRemoveAttachemntFileError(automationNodeObj, hostInstance, true);
3006
- }
3007
- };
3008
- rootService.prototype.handleCheckClick = function (e, inputEle, automationNodeObj, askCustTemplate, hostInstance) {
3009
- var _a;
3010
- if (((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3011
- if (automationNodeObj.fileObj && automationNodeObj.fileObj.name) {
3012
- this.fileUploadCall(automationNodeObj, hostInstance);
3013
- }
3014
- }
3015
- else {
3016
- var sanitizedValue = this.sanitizeHTML(inputEle.value);
3017
- inputEle.value = sanitizedValue;
3018
- if (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value) {
3019
- this.assistInputValue(inputEle.value, automationNodeObj, hostInstance);
3020
- this.showAgentIcon(automationNodeObj, hostInstance);
3021
- }
3022
- }
3023
- };
3024
- rootService.prototype.handleInputKeydown = function (e, inputEle, automationNodeObj, askCustTemplate, currentTab, hostInstance) {
3025
- var sanitizedValue = this.sanitizeHTML(inputEle === null || inputEle === void 0 ? void 0 : inputEle.value);
3026
- inputEle.value = sanitizedValue;
3027
- if (e.key === 'Enter' && (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value)) {
3028
- if (currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) {
3029
- this.assistInputValue(inputEle.value, automationNodeObj, hostInstance);
3030
- this.showAgentIcon(automationNodeObj, hostInstance);
3031
- }
3032
- else if (currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT) {
3033
- this.mybotInputValue(inputEle.value, automationNodeObj, hostInstance);
3034
- inputEle.setAttribute('data-inputValue', inputEle === null || inputEle === void 0 ? void 0 : inputEle.value);
3035
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(inputEle);
3036
- if (scrollDims.scrollHeight >= 60) {
3037
- this.hideMoreTextInEntityNode(inputEle, hostInstance, scrollDims.scrollHeight);
3038
- }
3039
- this.showAgentIcon(automationNodeObj, hostInstance);
3040
- }
3041
- else if (currentTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.CUSTOM) {
3042
- this.customInputValue(inputEle.value, automationNodeObj, hostInstance);
3043
- inputEle.setAttribute('data-inputValue', inputEle === null || inputEle === void 0 ? void 0 : inputEle.value);
3044
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(inputEle);
3045
- if (scrollDims.scrollHeight >= 60) {
3046
- this.hideMoreTextInEntityNode(inputEle, hostInstance, scrollDims.scrollHeight);
3047
- }
3048
- this.showAgentIcon(automationNodeObj, hostInstance);
3049
- }
3050
- }
3051
- };
3052
- rootService.prototype.customInputValue = function (inputValue, automationNodeObj, hostInstance) {
3053
- var _a;
3054
- this.addLoaderForAutomation(automationNodeObj, hostInstance);
3055
- var connectionDetails = Object.assign({}, this.connectionDetails);
3056
- connectionDetails.value = inputValue;
3057
- connectionDetails.isSearch = false;
3058
- connectionDetails.positionId = automationNodeObj.dialogId;
3059
- connectionDetails.childBotId = automationNodeObj.data.childBotId;
3060
- connectionDetails.childBotName = automationNodeObj.data.childBotName;
3061
- connectionDetails.sourceMsgId = automationNodeObj.sourceMsgId || '';
3062
- if (((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3063
- var fileObj = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj;
3064
- connectionDetails.attachments = [
3065
- {
3066
- "fileName": (fileObj === null || fileObj === void 0 ? void 0 : fileObj.name) || '',
3067
- "fileType": fileObj === null || fileObj === void 0 ? void 0 : fileObj.type,
3068
- "fileId": fileObj.fileId || '',
3069
- "url": {
3070
- "fileUrl": fileObj.fileURL || ''
3071
- }
3072
- }
3073
- ];
3074
- }
3075
- var agent_assist_custom_request_params = hostInstance.prepareAgentAssistCustomRequestParams(connectionDetails);
3076
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_custom_request, agent_assist_custom_request_params);
3077
- };
3078
- rootService.prototype.handleInputChange = function (e, inputEle, checkBtn) {
3079
- var _a, _b;
3080
- if (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value) {
3081
- this.AutoExpandTextarea(inputEle);
3082
- (_a = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.AGENTASSIST_DISABLED_MSG);
3083
- }
3084
- else {
3085
- (_b = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.AGENTASSIST_DISABLED_MSG);
3086
- }
3087
- };
3088
- rootService.prototype.AutoExpandTextarea = function (inputEle) {
3089
- if (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value) {
3090
- inputEle.style.height = 'auto';
3091
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(inputEle);
3092
- inputEle.style.height = Math.min(scrollDims.scrollHeight, 60) + 'px';
3093
- }
3094
- };
3095
- rootService.prototype.showAttachmentView = function (automationNodeObj, askCustTemplate, inputEle) {
3096
- var _a, _b, _c;
3097
- var viewBtn = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ATTACHMENT_VIEW));
3098
- var attachments = (_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.attachments) === null || _a === void 0 ? void 0 : _a[0];
3099
- var overrideBtn = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_OVERRIDE_BTN));
3100
- inputEle.readOnly = true;
3101
- if (((_b = attachments === null || attachments === void 0 ? void 0 : attachments.url) === null || _b === void 0 ? void 0 : _b.fileUrl) && ((attachments === null || attachments === void 0 ? void 0 : attachments.fileType) == 'image/png' || (attachments === null || attachments === void 0 ? void 0 : attachments.fileType) == 'image')) {
3102
- viewBtn === null || viewBtn === void 0 ? void 0 : viewBtn.classList.remove(this.classConstants.HIDE_ELEMENT);
3103
- (_c = overrideBtn === null || overrideBtn === void 0 ? void 0 : overrideBtn.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
3104
- }
3105
- };
3106
- rootService.prototype.toggleAttachmentDiv = function (automationNodeObj, askCustTemplate, inputEle, flag) {
3107
- var _a, _b, _c, _d, _e, _f;
3108
- var attachmentDiv = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ATTACHMENT_DIV));
3109
- var entityDisplay = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_DISPLAY_NAME));
3110
- var chooseFileText = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_CHOOSE_FILE));
3111
- if (attachmentDiv) {
3112
- if (flag) {
3113
- (_a = attachmentDiv === null || attachmentDiv === void 0 ? void 0 : attachmentDiv.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
3114
- (_b = entityDisplay === null || entityDisplay === void 0 ? void 0 : entityDisplay.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.HIDE_ELEMENT);
3115
- inputEle.type = 'file';
3116
- (_c = inputEle === null || inputEle === void 0 ? void 0 : inputEle.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.INPUT_ATTACHMENT);
3117
- }
3118
- else {
3119
- (_d = attachmentDiv === null || attachmentDiv === void 0 ? void 0 : attachmentDiv.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
3120
- (_e = entityDisplay === null || entityDisplay === void 0 ? void 0 : entityDisplay.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
3121
- inputEle.type = 'text';
3122
- (_f = inputEle === null || inputEle === void 0 ? void 0 : inputEle.classList) === null || _f === void 0 ? void 0 : _f.remove(this.classConstants.INPUT_ATTACHMENT);
3123
- }
3124
- // let textContent = automationNodeObj.data.entityValue ? automationNodeObj.data.entityValue : 'Choose File';
3125
- // chooseFileText.innerText = textContent;
3126
- }
3127
- };
3128
- rootService.prototype.assistInputValue = function (inputValue, automationNodeObj, hostInstance) {
3129
- var _a;
3130
- this.addLoaderForAutomation(automationNodeObj, hostInstance);
3131
- var connectionDetails = Object.assign({}, this.connectionDetails);
3132
- connectionDetails.value = inputValue;
3133
- connectionDetails.positionId = automationNodeObj.dialogId;
3134
- connectionDetails.childBotId = automationNodeObj.data.childBotId;
3135
- connectionDetails.childBotName = automationNodeObj.data.childBotName;
3136
- connectionDetails.sourceMsgId = automationNodeObj.sourceMsgId || '';
3137
- if (((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment' && this.activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.ASSIST) {
3138
- var fileObj = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj;
3139
- connectionDetails.attachments = [
3140
- {
3141
- "fileName": (fileObj === null || fileObj === void 0 ? void 0 : fileObj.name) || '',
3142
- "fileType": fileObj === null || fileObj === void 0 ? void 0 : fileObj.type,
3143
- "fileId": fileObj.fileId || '',
3144
- "url": {
3145
- "fileUrl": fileObj.fileURL || ''
3146
- }
3147
- }
3148
- ];
3149
- }
3150
- var assistRequestParams = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
3151
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, assistRequestParams);
3152
- };
3153
- rootService.prototype.mybotInputValue = function (inputValue, automationNodeObj, hostInstance) {
3154
- var _a;
3155
- this.addLoaderForAutomation(automationNodeObj, hostInstance);
3156
- var connectionDetails = Object.assign({}, this.connectionDetails);
3157
- connectionDetails.value = inputValue;
3158
- connectionDetails.isSearch = false;
3159
- connectionDetails.positionId = automationNodeObj.dialogId;
3160
- connectionDetails.childBotId = automationNodeObj.data.childBotId;
3161
- connectionDetails.childBotName = automationNodeObj.data.childBotName;
3162
- connectionDetails.sourceMsgId = automationNodeObj.sourceMsgId || '';
3163
- if (((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3164
- var fileObj = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj;
3165
- connectionDetails.attachments = [
3166
- {
3167
- "fileName": (fileObj === null || fileObj === void 0 ? void 0 : fileObj.name) || '',
3168
- "fileType": fileObj === null || fileObj === void 0 ? void 0 : fileObj.type,
3169
- "fileId": fileObj.fileId || '',
3170
- "url": {
3171
- "fileUrl": fileObj.fileURL || ''
3172
- }
3173
- }
3174
- ];
3175
- }
3176
- var agent_assist_agent_request_params = hostInstance.prepareAgentAssistAgentRequestParams(connectionDetails);
3177
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, agent_assist_agent_request_params);
3178
- };
3179
- rootService.prototype.handleEntityInput = function (node, hostInstance, disabled) {
3180
- var _this = this;
3181
- var _a;
3182
- if (disabled === void 0) { disabled = false; }
3183
- var entityNodes = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
3184
- entityNodes.forEach(function (askCustTemplate) {
3185
- var _a, _b, _c, _d, _e;
3186
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ACTIONS));
3187
- (_a = actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
3188
- var _a, _b, _c, _d;
3189
- var agentIconBtn = (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains("aa-entity-agent-icon");
3190
- var errorBtn = (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.contains("aa-entity-error-btn");
3191
- var viewBtn = (_c = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _c === void 0 ? void 0 : _c.contains("aa-entity-attachment-view");
3192
- if (btn && !agentIconBtn && (!errorBtn || disabled) && !viewBtn) {
3193
- (_d = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _d === void 0 ? void 0 : _d.add(_this.classConstants.HIDE_ELEMENT);
3194
- }
3195
- });
3196
- (_c = (_b = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ERROR_MESSAGE))) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
3197
- (_e = (_d = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
3198
- });
3199
- };
3200
- rootService.prototype.showAgentIcon = function (node, hostInstance) {
3201
- var _this = this;
3202
- var _a;
3203
- var entityNodes = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
3204
- entityNodes.forEach(function (askCustTemplate) {
3205
- var _a, _b, _c, _d, _e;
3206
- var inputEle = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_INPUT));
3207
- inputEle.readOnly = true;
3208
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ACTIONS));
3209
- (_a = actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
3210
- var _a, _b, _c;
3211
- var agentIconPresent = (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains("aa-entity-agent-icon");
3212
- if (btn && agentIconPresent) {
3213
- (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
3214
- }
3215
- else if (btn) {
3216
- (_c = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
3217
- }
3218
- });
3219
- (_c = (_b = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ERROR_MESSAGE))) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
3220
- (_e = (_d = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
3221
- });
3222
- };
3223
- rootService.prototype.showEntityNodeInputButtons = function (askCustTemplate) {
3224
- var _this = this;
3225
- var _a;
3226
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ACTIONS));
3227
- (_a = actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
3228
- var _a, _b;
3229
- if (btn === null || btn === void 0 ? void 0 : btn.classList.contains('aa-entity-override-btn')) {
3230
- (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.remove(_this.classConstants.HIDE_ELEMENT);
3231
- }
3232
- else {
3233
- (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.add(_this.classConstants.HIDE_ELEMENT);
3234
- }
3235
- });
3236
- };
3237
- //Entity node click events ends
3238
- //Process UserMessages for smalltalk and automation starts
3239
- rootService.prototype.processUserMessages = function (userResponse, lastObj, templateClick, getNode, hostInstance) {
3240
- var _this = this;
3241
- var _a, _b, _c, _d, _e, _f, _g;
3242
- var node = getNode(lastObj);
3243
- if ((_a = node === null || node === void 0 ? void 0 : node.data) === null || _a === void 0 ? void 0 : _a.isPrompt) {
3244
- var fileName = '';
3245
- if ((node === null || node === void 0 ? void 0 : node.type) === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE) {
3246
- if (((_b = node === null || node === void 0 ? void 0 : node.data) === null || _b === void 0 ? void 0 : _b.entityType) === 'attachment') {
3247
- if (((_c = userResponse === null || userResponse === void 0 ? void 0 : userResponse.attachments) === null || _c === void 0 ? void 0 : _c.length) > 0) {
3248
- fileName = (_d = userResponse === null || userResponse === void 0 ? void 0 : userResponse.attachments[0]) === null || _d === void 0 ? void 0 : _d.fileName;
3249
- }
3250
- if ((userResponse === null || userResponse === void 0 ? void 0 : userResponse.entities) && Array.isArray(userResponse.entities[userResponse.entityName]) && ((_e = userResponse === null || userResponse === void 0 ? void 0 : userResponse.entities[userResponse === null || userResponse === void 0 ? void 0 : userResponse.entityName][0]) === null || _e === void 0 ? void 0 : _e.fileId)) {
3251
- node.attachments = userResponse === null || userResponse === void 0 ? void 0 : userResponse.entities[userResponse === null || userResponse === void 0 ? void 0 : userResponse.entityName];
3252
- fileName = !fileName ? (_f = userResponse === null || userResponse === void 0 ? void 0 : userResponse.entities[userResponse === null || userResponse === void 0 ? void 0 : userResponse.entityName][0]) === null || _f === void 0 ? void 0 : _f.fileName : fileName;
3253
- }
3254
- }
3255
- }
3256
- node.data.entityValue = fileName ? fileName : (userResponse === null || userResponse === void 0 ? void 0 : userResponse.entityValue) || userResponse.userInput;
3257
- var entityNodes = (_g = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _g === void 0 ? void 0 : _g.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
3258
- entityNodes.forEach(function (askCustNode) {
3259
- var _a, _b, _c;
3260
- var inputEle = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_INPUT));
3261
- if (((_a = node === null || node === void 0 ? void 0 : node.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3262
- _this.toggleAttachmentDiv(node, askCustNode, inputEle, false);
3263
- _this.showAttachmentView(node, askCustNode, inputEle);
3264
- }
3265
- if (inputEle) {
3266
- inputEle.value = node.data.entityValue;
3267
- }
3268
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(inputEle);
3269
- if (inputEle && scrollDims.scrollHeight >= 60) {
3270
- inputEle.style.height = 'auto';
3271
- inputEle.style.height = 18 + 'px';
3272
- }
3273
- if (templateClick) {
3274
- (_c = (_b = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_AGENT_ICON))) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.remove(_this.classConstants.HIDE_ELEMENT);
3275
- }
3276
- });
3277
- this.handleEntityInput(node, hostInstance);
3278
- }
3279
- return lastObj;
3280
- };
3281
- ;
3282
- rootService.prototype.hideMoreTextInEntityNode = function (inputEle, hostInstance, scrollHeight) {
3283
- var _this = this;
3284
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3285
- inputEle.style.height = 'auto';
3286
- inputEle.style.height = 30 + 'px';
3287
- var expandBtn = (_a = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ENTITY_EXPAND_BTN));
3288
- var reduceBtn = (_b = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.ENTITY_REDUCE_BTN));
3289
- var inputValue = inputEle === null || inputEle === void 0 ? void 0 : inputEle.value;
3290
- if (inputValue) {
3291
- inputEle.value = (inputValue === null || inputValue === void 0 ? void 0 : inputValue.slice(0, 40)) + '...';
3292
- }
3293
- if (!expandBtn) {
3294
- var expandBtn_1 = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.ExpandButtonForEntity, {}, hostInstance);
3295
- hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, expandBtn_1, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ENTITY_EXPAND_BTN, data: { inputEle: inputEle } });
3296
- (_c = expandBtn_1 === null || expandBtn_1 === void 0 ? void 0 : expandBtn_1.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
3297
- (_d = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _d === void 0 ? void 0 : _d.appendChild(expandBtn_1);
3298
- }
3299
- else if (expandBtn && reduceBtn) {
3300
- (_e = expandBtn === null || expandBtn === void 0 ? void 0 : expandBtn.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
3301
- (_f = reduceBtn === null || reduceBtn === void 0 ? void 0 : reduceBtn.classList) === null || _f === void 0 ? void 0 : _f.add(this.classConstants.HIDE_ELEMENT);
3302
- return;
3303
- }
3304
- else {
3305
- (_g = expandBtn === null || expandBtn === void 0 ? void 0 : expandBtn.classList) === null || _g === void 0 ? void 0 : _g.remove(this.classConstants.HIDE_ELEMENT);
3306
- return;
3307
- }
3308
- (_j = (_h = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _h === void 0 ? void 0 : _h.querySelector("".concat(this.classConstants.ENTITY_EXPAND_BTN))) === null || _j === void 0 ? void 0 : _j.addEventListener('click', function (e) {
3309
- e.stopPropagation();
3310
- _this.showMoreTextInEntityNode(inputEle, hostInstance, scrollHeight, inputValue);
3311
- });
3312
- };
3313
- rootService.prototype.showMoreTextInEntityNode = function (inputEle, hostInstance, scrollHeight, inputValue, isListView) {
3314
- var _this = this;
3315
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
3316
- if (isListView === void 0) { isListView = false; }
3317
- var expandBtn = (_a = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ENTITY_EXPAND_BTN));
3318
- var reduceBtn = (_b = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.ENTITY_REDUCE_BTN));
3319
- if (isListView) {
3320
- inputEle.style.height = 'auto';
3321
- inputEle.style.height = 60 + 'px';
3322
- }
3323
- else {
3324
- inputEle.style.height = 'auto';
3325
- inputEle.style.height = Math.min(scrollHeight, 60) + 'px';
3326
- }
3327
- if (inputValue) {
3328
- inputEle.value = inputValue;
3329
- }
3330
- if (!reduceBtn) {
3331
- var reduceBtnHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.ReduceButtonForEntity, {}, hostInstance);
3332
- hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, reduceBtnHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ENTITY_REDUCE_BTN, data: { inputEle: inputEle } });
3333
- (_c = reduceBtnHtml === null || reduceBtnHtml === void 0 ? void 0 : reduceBtnHtml.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
3334
- (_d = expandBtn === null || expandBtn === void 0 ? void 0 : expandBtn.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
3335
- (_e = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _e === void 0 ? void 0 : _e.appendChild(reduceBtnHtml);
3336
- }
3337
- else if (reduceBtn && expandBtn) {
3338
- (_f = reduceBtn === null || reduceBtn === void 0 ? void 0 : reduceBtn.classList) === null || _f === void 0 ? void 0 : _f.remove(this.classConstants.HIDE_ELEMENT);
3339
- (_g = expandBtn === null || expandBtn === void 0 ? void 0 : expandBtn.classList) === null || _g === void 0 ? void 0 : _g.add(this.classConstants.HIDE_ELEMENT);
3340
- }
3341
- else {
3342
- (_h = reduceBtn === null || reduceBtn === void 0 ? void 0 : reduceBtn.classList) === null || _h === void 0 ? void 0 : _h.remove(this.classConstants.HIDE_ELEMENT);
3343
- }
3344
- (_k = (_j = inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement) === null || _j === void 0 ? void 0 : _j.querySelector("".concat(this.classConstants.ENTITY_REDUCE_BTN))) === null || _k === void 0 ? void 0 : _k.addEventListener('click', function (e) {
3345
- e.stopPropagation();
3346
- _this.hideMoreTextInEntityNode(inputEle, hostInstance, scrollHeight);
3347
- });
3348
- };
3349
- rootService.prototype.processUserMessagesForSmallTalk = function (userResponse, lastObj, templateClick, hostInstance) {
3350
- return this.processUserMessages(userResponse, lastObj, templateClick, function (lastObj) { return lastObj; }, hostInstance);
3351
- };
3352
- ;
3353
- rootService.prototype.processUserMessagesForAutomation = function (userResponse, lastObj, templateClick, hostInstance) {
3354
- return this.processUserMessages(userResponse, lastObj, templateClick, function (lastObj) { var _a; return lastObj === null || lastObj === void 0 ? void 0 : lastObj.automationNodes[((_a = lastObj.automationNodes) === null || _a === void 0 ? void 0 : _a.length) - 1]; }, hostInstance);
3355
- };
3356
- ;
3357
- //Process UserMessages for smalltalk and automation ends
3358
- rootService.prototype.getTemplateHtml = function (isTemplateRender, result, hostInstance) {
3359
- return _templatemanager_tabs_ErrorBoundary_ErrorHandler__WEBPACK_IMPORTED_MODULE_12__.ErrorHandler.wrapExternalCall(function () {
3360
- var _a;
3361
- if (!isTemplateRender)
3362
- return null;
3363
- if (!((_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatWindowInstance) === null || _a === void 0 ? void 0 : _a.generateMessageDOM)) {
3364
- console.warn('generateMessageDOM not available');
3365
- return null;
3366
- }
3367
- return hostInstance.chatWindowInstance.generateMessageDOM(result);
3368
- }, null);
3369
- };
3370
- rootService.prototype.handleTemplateClickEvents = function (value, activeTab, positionId, hostInstance) {
3371
- var connectionObj = this.connectionDetails;
3372
- var requestParams = {
3373
- "conversationId": connectionObj.conversationId,
3374
- "query": value,
3375
- "botId": connectionObj.botId,
3376
- "experience": connectionObj === null || connectionObj === void 0 ? void 0 : connectionObj.channel,
3377
- "autoBotId": connectionObj.autoBotId,
3378
- "positionId": positionId
3379
- };
3380
- if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.ASSIST) {
3381
- requestParams.entities = [];
3382
- requestParams.check = true;
3383
- requestParams.intType = "assist";
3384
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, requestParams);
3385
- // this.rootService.setAssistTemplateClick(true);
3386
- }
3387
- else if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.MYBOT) {
3388
- requestParams.isSearch = false;
3389
- requestParams.intType = "myBot";
3390
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, requestParams);
3391
- // this.rootService.setMyBotTemplateClick(true);
3392
- }
3393
- else if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.CUSTOM_TAB) {
3394
- requestParams.intType = "custom";
3395
- requestParams.crId = "custom";
3396
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_custom_request, requestParams);
3397
- }
3398
- };
3399
- rootService.prototype.closeListView = function (hostInstance) {
3400
- var _a, _b, _c, _d, _e, _f;
3401
- (_c = (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(this.classConstants.LIST_VIEW_POPUP)).classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
3402
- (_f = (_e = (_d = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _d === void 0 ? void 0 : _d.querySelector("".concat(this.classConstants.LIST_VIEW_POPUP))) === null || _e === void 0 ? void 0 : _e.querySelectorAll("".concat(this.classConstants.ENTITY_NODE))) === null || _f === void 0 ? void 0 : _f.forEach(function (ele) {
3403
- ele.remove();
3404
- });
3405
- };
3406
- rootService.prototype.addorRemoveAttachemntFileError = function (automationNodeObj, hostInstance, hide) {
3407
- var _this = this;
3408
- var _a;
3409
- if (hide === void 0) { hide = false; }
3410
- if ((automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.data.entityType) === 'attachment') {
3411
- var entityNodes = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(automationNodeObj.uuid));
3412
- entityNodes.forEach(function (askCustNode) {
3413
- var _a, _b, _c, _d;
3414
- var attachmentError = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_ATTACHMENT_LARGE_FILE_MSG));
3415
- var overrideMsg = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_MSG));
3416
- if (((_a = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj) === null || _a === void 0 ? void 0 : _a.largeFileFlag) && !hide) {
3417
- (_b = attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
3418
- (_c = overrideMsg === null || overrideMsg === void 0 ? void 0 : overrideMsg.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
3419
- }
3420
- else {
3421
- (_d = attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.classList) === null || _d === void 0 ? void 0 : _d.add(_this.classConstants.HIDE_ELEMENT);
3422
- }
3423
- });
3424
- }
3425
- };
3426
- //attachment file upload
3427
- rootService.prototype.fileUploadCall = function (automationNodeObj, hostIns) {
3428
- var _this = this;
3429
- var file = automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.fileObj;
3430
- var uploadInprogress = false;
3431
- if (!file) {
3432
- return;
3433
- }
3434
- automationNodeObj.fileObj.largeFileFlag = false;
3435
- // Restrict file size to 25MB
3436
- if (file.size >= 25000000) {
3437
- automationNodeObj.fileObj.largeFileFlag = true;
3438
- this.addorRemoveAttachemntFileError(automationNodeObj, hostIns);
3439
- return;
3440
- }
3441
- var reader = new FileReader();
3442
- reader.readAsText(file);
3443
- reader.onload = function (e) {
3444
- // handle file read if needed
3445
- };
3446
- var CHUNK_SIZE = 1024 * 1024 * 2; // Adjust chunk size (5MB for example)
3447
- var chunkUpload = file.size > CHUNK_SIZE;
3448
- if (chunkUpload) {
3449
- // Simulate chunk file token retrieval (using Promises instead of Observable)
3450
- hostIns.chunkFileUploadService.getFileToken().then(function (token) {
3451
- if (token) {
3452
- hostIns.chunkFileUploadService.uploadChunkFile(token, file).then(function (fileId) {
3453
- if (fileId) {
3454
- _this.getuploadedFileURL(automationNodeObj, fileId, hostIns);
3455
- }
3456
- }).catch(function (err) { return console.error("Error during chunk upload", err); });
3457
- }
3458
- }).catch(function (err) { return console.error("Error retrieving file token", err); });
3459
- }
3460
- else {
3461
- var reader_1 = new FileReader();
3462
- reader_1.readAsDataURL(file);
3463
- var formData = new FormData();
3464
- formData.append('file', file);
3465
- formData.append('fileContext', 'bulkImport');
3466
- formData.append('fileExtension', file.name.substring(file.name.lastIndexOf('.') + 1));
3467
- formData.append('Content-Type', file.type);
3468
- formData.append('fileName', file.name);
3469
- uploadInprogress = true;
3470
- // Simulate file upload using fetch instead of Angular's serviceInvoker
3471
- (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('post_uploadfile', {
3472
- method: 'POST',
3473
- body: formData,
3474
- }, hostIns, {})
3475
- .then(function (res) {
3476
- automationNodeObj.fileObj.largeFileFlag = false;
3477
- automationNodeObj.fileObj.fileId = res.fileId;
3478
- _this.getuploadedFileURL(automationNodeObj, res.fileId, hostIns);
3479
- _this.addorRemoveAttachemntFileError(automationNodeObj, hostIns);
3480
- }).catch(function (err) { return console.error("Error during file upload", err); });
3481
- }
3482
- };
3483
- rootService.prototype.getuploadedFileURL = function (automationNodeObj, fileId, hostIns) {
3484
- // Further logic to handle the uploaded file URL
3485
- var _this = this;
3486
- (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('get_uploadedfile', {
3487
- method: 'GET'
3488
- }, hostIns, { fileId: fileId }).then(function (res) {
3489
- automationNodeObj.fileObj.fileURL = res === null || res === void 0 ? void 0 : res.fileUrl;
3490
- if (_this.activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.ASSIST) {
3491
- _this.assistInputValue(automationNodeObj.fileObj.name, automationNodeObj, hostIns);
3492
- }
3493
- else {
3494
- _this.mybotInputValue(automationNodeObj.fileObj.name, automationNodeObj, hostIns);
3495
- }
3496
- }, function (error) {
3497
- });
3498
- };
3499
- rootService.prototype.scrollToTop = function (element, tab, hostInstance) {
3500
- element === null || element === void 0 ? void 0 : element.scroll({
3501
- top: 0,
3502
- behavior: 'smooth'
3503
- });
3504
- hostInstance.socketConnection.sendScrollEvent("scrollup_clicked", tab);
3505
- };
3506
- rootService.prototype.scrollToTillBottom = function (element, tab, hostInstance) {
3507
- if (element) {
3508
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(element);
3509
- element.scroll({
3510
- top: scrollDims.scrollHeight,
3511
- behavior: 'smooth'
3512
- });
3513
- }
3514
- hostInstance.socketConnection.sendScrollEvent("scrolldown_clicked", tab);
3515
- };
3516
- rootService.prototype.handleAssistScroll = function (hostInstance) {
3517
- var _this = this;
3518
- setTimeout(function () {
3519
- var _a;
3520
- var assistEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.ASSIST_SECTION);
3521
- if ((_this === null || _this === void 0 ? void 0 : _this.autoScrollStatus) && assistEle) {
3522
- var scrollDims = (0,_utils_domUtils__WEBPACK_IMPORTED_MODULE_14__.safeScrollDimensions)(assistEle);
3523
- assistEle.scrollTop = scrollDims.scrollHeight;
3524
- }
3525
- }, 0);
3526
- };
3527
- ;
3528
- rootService.prototype.handleMybotScroll = function (hostInstance) {
3529
- var _a;
3530
- var mybotEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(this.classConstants.MYBOT_SECTION);
3531
- if ((this === null || this === void 0 ? void 0 : this.autoScrollStatus) && mybotEle) {
3532
- mybotEle.scrollTop = mybotEle.scrollHeight;
3533
- }
3534
- };
3535
- ;
3536
- rootService.prototype.handleCustomTabScroll = function (hostInstance) {
3537
- var _a;
3538
- var customTabEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(this.classConstants.CUSTOM_TAB_SECTION);
3539
- if ((this === null || this === void 0 ? void 0 : this.autoScrollStatus) && customTabEle) {
3540
- customTabEle.scrollTop = customTabEle.scrollHeight;
3541
- }
3542
- };
3543
- rootService.prototype.handleConversationSearchScroll = function (hostInstance) {
3544
- var _a;
3545
- var conversationSearchEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(this.classConstants.CONVERSATION_SEARCH_WRAPPER);
3546
- if (conversationSearchEle) {
3547
- conversationSearchEle.scrollTop = conversationSearchEle.scrollHeight;
3548
- }
3549
- };
3550
- rootService.prototype.scrollBottomTranscript = function (hostInstance) {
3551
- var _this = this;
3552
- setTimeout(function () {
3553
- var _a;
3554
- var transcriptEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(_this.classConstants.TRANSCRIPT_WRAPPER));
3555
- if ((_this === null || _this === void 0 ? void 0 : _this.autoScrollStatus) && transcriptEle) {
3556
- transcriptEle.scrollTop = transcriptEle.scrollHeight;
3557
- }
3558
- }, 0);
3559
- };
3560
- rootService.prototype.hideNetworkToastr = function (hostInstance) {
3561
- var _a, _b, _c, _d;
3562
- (_d = (_c = (_b = document.querySelector(".".concat((_a = hostInstance.config) === null || _a === void 0 ? void 0 : _a.container))) === null || _b === void 0 ? void 0 : _b.querySelector(".".concat(this.classConstants.NETWORK_ERROR_TOASTR))) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
3563
- };
3564
- rootService.prototype.showNetworkToastr = function (hostInstance) {
3565
- var _a, _b, _c, _d;
3566
- (_d = (_c = (_b = document.querySelector(".".concat((_a = hostInstance.config) === null || _a === void 0 ? void 0 : _a.container))) === null || _b === void 0 ? void 0 : _b.querySelector(".".concat(this.classConstants.NETWORK_ERROR_TOASTR))) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
3567
- };
3568
- rootService.prototype.addLoaderForAutomation = function (automationNodeObj, hostInstance) {
3569
- var _a;
3570
- var automationNode = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ASK_CUST_NODE).concat(automationNodeObj.uuid, " .input-block-entity"));
3571
- hostInstance.renderIndividualLoader(automationNode);
3572
- };
3573
- rootService.prototype.removeLoaderForAutomation = function (hostInstance, parentNode) {
3574
- hostInstance.removeIndividualLoader(parentNode);
3575
- };
3576
- //history api
3577
- rootService.prototype.getWidgetFeedbackHistory = function (params, hostInstance) {
3578
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('get_feedback', {
3579
- method: 'GET',
3580
- headers: {
3581
- 'Content-Type': 'application/json',
3582
- 'botId': params.botId
3583
- }
3584
- }, hostInstance, {
3585
- conversationId: params.conversationId,
3586
- tab: 'widget'
3587
- });
3588
- };
3589
- rootService.prototype.getAssistHistory = function (params, hostInstance) {
3590
- var botId = hostInstance.rootService.connectionDetails.botId;
3591
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('post_assist_history', {
3592
- method: 'POST',
3593
- // body : JSON.stringify({limit : -1}),
3594
- headers: {
3595
- 'Content-Type': 'application/json',
3596
- // 'botId': botId,
3597
- // 'excludeAccountId': true
3598
- }
3599
- }, hostInstance, {
3600
- botId: botId,
3601
- convId: params.conversationId,
3602
- });
3603
- };
3604
- rootService.prototype.getAssistFeedback = function (params, hostInstance) {
3605
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('get_feedback', {
3606
- method: 'GET',
3607
- headers: {
3608
- 'Content-Type': 'application/json',
3609
- 'botId': params.botId
3610
- }
3611
- }, hostInstance, {
3612
- tab: 'assist',
3613
- conversationId: params.conversationId
3614
- });
3615
- };
3616
- rootService.prototype.getMybotHistory = function (params, hostInstance) {
3617
- var botId = hostInstance.rootService.connectionDetails.botId;
3618
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('post_mybot_history', {
3619
- method: 'POST',
3620
- headers: {
3621
- 'Content-Type': 'application/json',
3622
- // 'botId': botId,
3623
- // 'excludeAccountId': true
3624
- }
3625
- }, hostInstance, {
3626
- botId: botId,
3627
- convId: params.conversationId
3628
- });
3629
- };
3630
- rootService.prototype.getMybotFeedback = function (params, hostInstance) {
3631
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('get_feedback', {
3632
- method: 'GET',
3633
- headers: {
3634
- 'Content-Type': 'application/json',
3635
- 'botId': params.botId
3636
- }
3637
- }, hostInstance, {
3638
- tab: 'mybot',
3639
- conversationId: params.conversationId
3640
- });
3641
- };
3642
- rootService.prototype.getCustomTabFeedback = function (params, hostInstance) {
3643
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_9__["default"])('get_feedback', {
3644
- method: 'GET',
3645
- headers: {
3646
- 'Content-Type': 'application/json',
3647
- 'botId': params.botId
3648
- }
3649
- }, hostInstance, {
3650
- tab: 'custom',
3651
- conversationId: params.conversationId
3652
- });
3653
- };
3654
- rootService.prototype.formatHistoryResponseToNormalRender = function (res, feedbackData, isAssist) {
3655
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
3656
- if (isAssist === void 0) { isAssist = true; }
3657
- var result = {};
3658
- result = Object.assign({}, res.agentAssistDetails);
3659
- result.type = res.type;
3660
- result.buttons = [];
3661
- result.intentName = ((_a = res === null || res === void 0 ? void 0 : res.agentAssistDetails) === null || _a === void 0 ? void 0 : _a.rootTN) || (res === null || res === void 0 ? void 0 : res.tN);
3662
- result._id = res._id;
3663
- result.entityDisplayName = result.newEntityDisplayName ? result.newEntityDisplayName : result.newEntityName;
3664
- result.entityType = (result === null || result === void 0 ? void 0 : result.newEntityType) ? result === null || result === void 0 ? void 0 : result.newEntityType : '';
3665
- result.expectedFormat = result.entityType || result.newEntityType;
3666
- if (result.entities && ((_c = (_b = result === null || result === void 0 ? void 0 : result.entities) === null || _b === void 0 ? void 0 : _b[result === null || result === void 0 ? void 0 : result.entityName]) === null || _c === void 0 ? void 0 : _c.length) > 0) {
3667
- result.attachments = result.entities[result === null || result === void 0 ? void 0 : result.entityName];
3668
- }
3669
- (_d = res === null || res === void 0 ? void 0 : res.components) === null || _d === void 0 ? void 0 : _d.forEach(function (element) {
3670
- var _a;
3671
- var value = (_a = element === null || element === void 0 ? void 0 : element.data) === null || _a === void 0 ? void 0 : _a.text;
3672
- result.buttons.push({ value: value, type: element === null || element === void 0 ? void 0 : element.cT });
3673
- });
3674
- if (isAssist) {
3675
- if (((_f = (_e = result === null || result === void 0 ? void 0 : result.suggestions) === null || _e === void 0 ? void 0 : _e.faqs) === null || _f === void 0 ? void 0 : _f.length) > 0) {
3676
- result.suggestions.faqs[0].answer = [(_h = (_g = res === null || res === void 0 ? void 0 : res.components[0]) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.text];
3677
- }
3678
- if ((result === null || result === void 0 ? void 0 : result.ambiguityList) && ((_j = Object.keys(result === null || result === void 0 ? void 0 : result.ambiguityList)) === null || _j === void 0 ? void 0 : _j.length) > 0) {
3679
- result.suggestions = result.ambiguityList;
3680
- }
3681
- (_l = (_k = result === null || result === void 0 ? void 0 : result.suggestions) === null || _k === void 0 ? void 0 : _k.faqs) === null || _l === void 0 ? void 0 : _l.forEach(function (faq) {
3682
- var _a;
3683
- var feedbackObj = (_a = (feedbackData || [])) === null || _a === void 0 ? void 0 : _a.find(function (feedback) { return feedback.positionId === faq.positionId; });
3684
- faq.historyFeedback = feedbackObj;
3685
- });
3686
- }
3687
- return result;
3688
- };
3689
- rootService.prototype.handlePreviousAutomationNode = function (entityNode, automationNodeObj, templateClick, hostInstance) {
3690
- var _this = this;
3691
- var _a;
3692
- automationNodeObj.expectedFormat = automationNodeObj.entityType;
3693
- if ((entityNode === null || entityNode === void 0 ? void 0 : entityNode.nodeType) === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE) {
3694
- var entityNodes = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(entityNode.uuid));
3695
- entityNodes.forEach(function (askCustNode) {
3696
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3697
- var inputEle = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_INPUT));
3698
- var fileName = '';
3699
- if (((_a = entityNode === null || entityNode === void 0 ? void 0 : entityNode.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3700
- entityNode.attachments = automationNodeObj.attachments;
3701
- automationNodeObj.attachments = null;
3702
- _this.toggleAttachmentDiv(entityNode, askCustNode, inputEle, false);
3703
- _this.showAttachmentView(entityNode, askCustNode, inputEle);
3704
- fileName = (_c = (_b = entityNode === null || entityNode === void 0 ? void 0 : entityNode.attachments) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.fileName;
3705
- }
3706
- if (inputEle && !inputEle.value) {
3707
- inputEle.value = fileName ? fileName : ((automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.entityValue) || (automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.userInput) || '');
3708
- if (!(automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.isErrorPrompt)) {
3709
- (_e = (_d = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_ERROR_MESSAGE))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
3710
- (_g = (_f = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.add(_this.classConstants.HIDE_ELEMENT);
3711
- }
3712
- if (templateClick) {
3713
- (_j = (_h = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_AGENT_ICON))) === null || _h === void 0 ? void 0 : _h.classList) === null || _j === void 0 ? void 0 : _j.remove(_this.classConstants.HIDE_ELEMENT);
3714
- }
3715
- }
3716
- });
3717
- }
3718
- };
3719
- rootService.prototype.handleHistoryPreviousAutomationNode = function (entityNode, automationNodeObj, hostInstance) {
3720
- var _this = this;
3721
- var _a;
3722
- automationNodeObj.expectedFormat = automationNodeObj.entityType;
3723
- if ((entityNode === null || entityNode === void 0 ? void 0 : entityNode.nodeType) === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE) {
3724
- var entityNodes = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(entityNode.uuid));
3725
- entityNodes.forEach(function (askCustNode) {
3726
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3727
- var inputEle = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_INPUT));
3728
- var fileName = '';
3729
- if (((_a = entityNode === null || entityNode === void 0 ? void 0 : entityNode.data) === null || _a === void 0 ? void 0 : _a.entityType) === 'attachment') {
3730
- entityNode.attachments = automationNodeObj.attachments;
3731
- automationNodeObj.attachments = null;
3732
- _this.toggleAttachmentDiv(entityNode, askCustNode, inputEle, false);
3733
- _this.showAttachmentView(entityNode, askCustNode, inputEle);
3734
- fileName = (_c = (_b = entityNode === null || entityNode === void 0 ? void 0 : entityNode.attachments) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.fileName;
3735
- }
3736
- if (inputEle && !inputEle.value) {
3737
- inputEle.value = fileName ? fileName : ((automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.userInput) || (automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.entityValue) || '');
3738
- var height = _this.getHiddenHeight(inputEle, inputEle === null || inputEle === void 0 ? void 0 : inputEle.parentElement);
3739
- inputEle.setAttribute('data-inputValue', inputEle === null || inputEle === void 0 ? void 0 : inputEle.value);
3740
- if (height >= 60) {
3741
- inputEle.style.height = 'auto';
3742
- inputEle.style.height = Math.max(height, 60) + 'px';
3743
- _this.hideMoreTextInEntityNode(inputEle, hostInstance, height);
3744
- }
3745
- if (!(automationNodeObj === null || automationNodeObj === void 0 ? void 0 : automationNodeObj.isErrorPrompt)) {
3746
- (_e = (_d = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_ERROR_MESSAGE))) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
3747
- (_g = (_f = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_MSG))) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.add(_this.classConstants.HIDE_ELEMENT);
3748
- (_j = (_h = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_OVERRIDE_BTN))) === null || _h === void 0 ? void 0 : _h.classList) === null || _j === void 0 ? void 0 : _j.add(_this.classConstants.HIDE_ELEMENT);
3749
- }
3750
- }
3751
- });
3752
- }
3753
- };
3754
- rootService.prototype.getHiddenHeight = function (inputEle, parentEle) {
3755
- var hiddenInput = document.createElement('textarea');
3756
- hiddenInput.style.position = 'absolute';
3757
- hiddenInput.style.visibility = 'hidden';
3758
- hiddenInput.style.fontSize = '12px';
3759
- hiddenInput.style.fontFamily = 'inherit';
3760
- hiddenInput.style.fontWeight = '400';
3761
- hiddenInput.style.lineHeight = '18px';
3762
- hiddenInput.style.padding = '0';
3763
- hiddenInput.style.border = '0';
3764
- hiddenInput.style.opacity = '0';
3765
- hiddenInput.style.overflow = 'hidden';
3766
- hiddenInput.textContent = inputEle.value;
3767
- hiddenInput.style.width = '400px';
3768
- document.body.appendChild(hiddenInput);
3769
- var height = hiddenInput.scrollHeight;
3770
- document.body.removeChild(hiddenInput);
3771
- return height;
3772
- };
3773
- rootService.prototype.findTaskInStringAndMake = function (prefsData, dialogPos, replacement) {
3774
- var _a, _b, _c;
3775
- var stDialog = (_c = (_b = (_a = prefsData === null || prefsData === void 0 ? void 0 : prefsData.sg) === null || _a === void 0 ? void 0 : _a.dT) === null || _b === void 0 ? void 0 : _b.tL[dialogPos]) === null || _c === void 0 ? void 0 : _c.msg;
3776
- var regex = /\{\{task\}\}/gi;
3777
- var dialogSplit = stDialog.split(regex);
3778
- if (dialogSplit.length == 2) {
3779
- return {
3780
- firstSt: dialogSplit[0].trim(),
3781
- lastSt: dialogSplit[1].trim(),
3782
- replaceSt: replacement
3783
- };
3784
- }
3785
- else {
3786
- return {
3787
- firstSt: stDialog,
3788
- lastSt: '',
3789
- replaceSt: ''
3790
- };
3791
- }
3792
- };
3793
- rootService.prototype.defaultGroupMake = function (dialogs, suggestionArr) {
3794
- var _a;
3795
- if (dialogs.length === 0) {
3796
- return suggestionArr;
3797
- }
3798
- var newSuggestionArr = [];
3799
- var hashMapSuggestionArr = {};
3800
- for (var index = 0; index < suggestionArr.length; index++) {
3801
- hashMapSuggestionArr[(_a = suggestionArr[index]) === null || _a === void 0 ? void 0 : _a.taskRefId] = index;
3802
- }
3803
- for (var _i = 0, dialogs_1 = dialogs; _i < dialogs_1.length; _i++) {
3804
- var dialog = dialogs_1[_i];
3805
- if (hashMapSuggestionArr.hasOwnProperty(dialog)) {
3806
- newSuggestionArr.push(suggestionArr[hashMapSuggestionArr[dialog]]);
3807
- }
3808
- }
3809
- return newSuggestionArr;
3810
- };
3811
- return rootService;
3812
- }());
3813
-
3814
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rootService);
3815
-
3816
-
3817
- /***/ })
3818
-
3819
- },
3820
- /******/ function(__webpack_require__) { // webpackRuntimeModules
3821
- /******/ /* webpack/runtime/getFullHash */
3822
- /******/ (() => {
3823
- /******/ __webpack_require__.h = () => ("0856c7b4c1d1c5c999cf")
3824
- /******/ })();
3825
- /******/
3826
- /******/ }
3827
- );
3828
- //# sourceMappingURL=hot-update.js.map