@koredev/agentai-web-sdk 1.3.8-rc → 1.4.0-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,2345 +1,183 @@
1
1
  "use strict";
2
2
  self["webpackHotUpdateaa_sdk"]("KoreAASDK",{
3
3
 
4
- /***/ "./src/components/common/services/rootService.ts":
5
- /*!*******************************************************!*\
6
- !*** ./src/components/common/services/rootService.ts ***!
7
- \*******************************************************/
4
+ /***/ "./src/components/common/services/web-socket-service.ts":
5
+ /*!**************************************************************!*\
6
+ !*** ./src/components/common/services/web-socket-service.ts ***!
7
+ \**************************************************************/
8
8
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
9
 
10
10
  __webpack_require__.r(__webpack_exports__);
11
11
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
13
- /* harmony export */ rootService: () => (/* binding */ rootService)
12
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
14
13
  /* 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
- var __assign = (undefined && undefined.__assign) || function () {
25
- __assign = Object.assign || function(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
- t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
-
36
-
37
-
38
-
39
-
14
+ /* harmony import */ var socket_io_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! socket.io-client */ "./node_modules/socket.io-client/build/esm/index.js");
15
+ /* harmony import */ var _constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
40
16
 
41
17
 
42
-
43
-
44
- var rootService = /** @class */ (function () {
45
- function rootService() {
46
- var _a;
47
- var _this = this;
48
- this.isAutomationOnGoing = false;
49
- this.currentAutomationId = '';
50
- this.grantResponseObj = {};
51
- this.prefsAccessObj = {
52
- tabsNTitles: [],
53
- prefs: {},
54
- };
55
- this.connectionDetails = {};
56
- this.settingsData = {};
57
- this.numOfLines = 4;
58
- this.maxHeight = 'max-content';
59
- this.scrollHeight = Number.MAX_VALUE;
60
- this.classConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst;
61
- this.idConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.IdMapConstant;
62
- this.faqambiguityResponse = false;
63
- this.activeTab = '';
64
- this.activeTabType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST;
65
- this.internalTransfer = false;
66
- this.internalTransferData = {};
67
- this.proactiveModeStatus = false;
68
- this.OverRideMode = false;
69
- this.manualAssistOverrideMode = false;
70
- this.autoScrollStatus = true;
71
- this.myBotTabSessionId = '';
72
- this.assistTabSessionId = '';
73
- this.sentSearchResponse = false;
74
- this.searchedResultData = {};
75
- this.proactiveMode = false;
76
- this.socketConnect = false;
77
- this.isProceedToClose = false;
78
- this.dynClObjs = {};
79
- this.hideActionButtons = false;
80
- this.hideSendButton = false;
81
- this.hideCopyButton = false;
82
- this.isUpdateFeedBackDetailsFlag = false;
83
- this.tabs = {
84
- ast: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST,
85
- mB: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT,
86
- srch: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEARCH,
87
- trnspt: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.TRANSCRIPT
88
- };
89
- this.tabsTitleAsKey = (_a = {},
90
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST] = 'ast',
91
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT] = 'mB',
92
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEARCH] = 'srch',
93
- _a[_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.TRANSCRIPT] = 'trnspt',
94
- _a);
95
- this.entitiesValueArray = [];
96
- this.mybotEntitiestValueArray = [];
97
- this.interruptDialogList = [];
98
- this.mybotInterruptDialogList = [];
99
- this.menuResponse = [];
100
- this.toggleInterruptPopup = function (hostInstance, flag) {
101
- var _a, _b, _c, _d;
102
- 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));
103
- if (flag) {
104
- (_c = interruptPopup.classList) === null || _c === void 0 ? void 0 : _c.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
105
- }
106
- else {
107
- (_d = interruptPopup.classList) === null || _d === void 0 ? void 0 : _d.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
108
- }
109
- };
110
- this.toggleTerminatePopup = function (hostInstance, flag) {
111
- var _a, _b, _c, _d;
112
- 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));
113
- if (flag) {
114
- (_c = terminatePopup.classList) === null || _c === void 0 ? void 0 : _c.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
115
- }
116
- else {
117
- (_d = terminatePopup.classList) === null || _d === void 0 ? void 0 : _d.add(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
118
- }
119
- };
120
- this.appendTemplate = function (template, entityNode) {
121
- var _a;
122
- if (template && (entityNode === null || entityNode === void 0 ? void 0 : entityNode.templateRender) && (entityNode === null || entityNode === void 0 ? void 0 : entityNode.template)) {
123
- (_a = template === null || template === void 0 ? void 0 : template.querySelector('.chat-container')) === null || _a === void 0 ? void 0 : _a.append(entityNode.template);
124
- }
125
- };
18
+ var websocketservice = /** @class */ (function () {
19
+ function websocketservice(hostIns) {
20
+ this.prevTimeStamp = 0;
21
+ this.intervalTime = 510;
22
+ this.count = 1;
23
+ this.hostIns = hostIns;
126
24
  }
127
- rootService.prototype.formatSearchResponse = function (response, isSearch, suggestionIndex, suggestionFrom) {
128
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
129
- if (isSearch === void 0) { isSearch = false; }
130
- if (suggestionFrom === void 0) { suggestionFrom = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT; }
131
- var suggestions = response.suggestions;
132
- var dialoguesArray = suggestions.dialogs || [];
133
- var faqArray = suggestions.faqs || [];
134
- var snippersArray = this.formatSnippetResponse(((_a = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _a === void 0 ? void 0 : _a.snippets) || [], response, suggestionIndex);
135
- var filesArray = ((_b = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) === null || _b === void 0 ? void 0 : _b.files) || [];
136
- var searchResponse = {};
137
- 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) {
138
- delete suggestions.searchassist.snippets;
139
- }
140
- var searchassistKeys = Object.keys((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) || {});
141
- if ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist) && (searchassistKeys === null || searchassistKeys === void 0 ? void 0 : searchassistKeys.length) == 1 && searchassistKeys[0] === 'searchRequestId') {
142
- suggestions.searchassist = {};
143
- }
144
- 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))) {
145
- searchResponse.dialogs = [];
146
- searchResponse.faqs = [];
147
- searchResponse.articles = [];
148
- searchResponse.snippets = [];
149
- searchResponse.files = [];
150
- if (suggestions.searchassist && ((_g = Object.keys(suggestions.searchassist)) === null || _g === void 0 ? void 0 : _g.length) > 0) {
151
- var _loop_1 = function (source) {
152
- if (source != "snippets" && source != "file" && source != 'searchRequestId') {
153
- suggestions.searchassist[source] = this_1.checkEmptyObjectsInArray(suggestions.searchassist[source]);
154
- if (suggestions.searchassist[source] && ((_h = Object.keys(suggestions.searchassist[source])) === null || _h === void 0 ? void 0 : _h.length) > 0) {
155
- searchResponse.articles.push.apply(searchResponse.articles, suggestions.searchassist[source]);
156
- }
157
- }
158
- if (source == "file") {
159
- suggestions.searchassist[source] = this_1.checkEmptyObjectsInArray(suggestions.searchassist[source]);
160
- if (suggestions.searchassist[source] && ((_j = Object.keys(suggestions.searchassist[source])) === null || _j === void 0 ? void 0 : _j.length) > 0) {
161
- searchResponse.files.push.apply(searchResponse.files, suggestions.searchassist[source]);
162
- }
163
- }
164
- if (source && source != 'searchRequestId') {
165
- (_k = suggestions === null || suggestions === void 0 ? void 0 : suggestions.searchassist[source]) === null || _k === void 0 ? void 0 : _k.forEach(function (item) {
166
- item.subType = source;
167
- });
168
- }
169
- };
170
- var this_1 = this;
171
- for (var source in suggestions.searchassist) {
172
- _loop_1(source);
173
- }
174
- for (var _i = 0, _p = searchResponse.articles; _i < _p.length; _i++) {
175
- var article = _p[_i];
176
- article.showMoreButton = true;
177
- article.showLessButton = false;
178
- article.content = article.content ? article.content : '';
179
- article.contentId = article.contentId;
180
- article.userInput = response.userInput;
181
- article.sourceMsgId = response.sourceMsgId || '';
182
- article.subType = article.subType;
183
- article.intType = isSearch ? 'mybot' : 'assist';
184
- article.feedbackData = this.prepareFeedbackForSuggestions('article', article, {});
185
- }
186
- for (var _q = 0, _r = searchResponse.files; _q < _r.length; _q++) {
187
- var file = _r[_q];
188
- file.showMoreButton = true;
189
- file.showLessButton = false;
190
- file.content = file.content ? file.content : '';
191
- file.contentId = file.contentId;
192
- file.userInput = response.userInput;
193
- file.sourceMsgId = response.sourceMsgId || '';
194
- file.subType = file.subType;
195
- file.intType = isSearch ? 'mybot' : 'assist';
196
- file.feedbackData = this.prepareFeedbackForSuggestions('file', file, {});
197
- }
198
- }
199
- for (var _s = 0, faqArray_1 = faqArray; _s < faqArray_1.length; _s++) {
200
- var faq = faqArray_1[_s];
201
- var faqObject = {
202
- question: faq.question,
203
- displayName: faq.displayName,
204
- taskRefId: faq === null || faq === void 0 ? void 0 : faq.taskRefId,
205
- answer: (faq.answer && faq.answer.length > 0) ? [] : false,
206
- showMoreButton: true,
207
- showLessButton: false,
208
- answerRender: faq.answer || false,
209
- childBotId: faq.childBotId,
210
- childBotName: faq.childBotName,
211
- answerCount: 1,
212
- sourceMsgId: response.sourceMsgId || '',
213
- positionId: faq.positionId,
214
- userInput: response.userInput,
215
- intType: response.intType
216
- };
217
- if (faq.answer && faq.answer.length > 0) {
218
- for (var _t = 0, _u = faq.answer; _t < _u.length; _t++) {
219
- var ans = _u[_t];
220
- var object = {
221
- ans: ans,
222
- taskRefId: faq.taskRefId,
223
- showMoreButton: true,
224
- showLessButton: false,
225
- displayName: faq.displayName,
226
- sourceMsgId: response.sourceMsgId || '',
227
- positionId: faq.positionId
228
- };
229
- faqObject.answer.push(object);
230
- }
231
- }
232
- var feedbackData = faq.historyFeedback ? faq.historyFeedback : {};
233
- faqObject.feedbackData = this.prepareFeedbackForSuggestions('faqs', faqObject, feedbackData);
234
- faqObject.feedbackData.interactionType = isSearch ? 'mybot' : 'assist';
235
- searchResponse.faqs.push(faqObject);
236
- }
237
- 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) {
238
- if ((snippersArray === null || snippersArray === void 0 ? void 0 : snippersArray.length) > 0) {
239
- searchResponse.snippets = Object.assign([], snippersArray);
240
- }
241
- for (var _v = 0, _w = searchResponse.snippets; _v < _w.length; _v++) {
242
- var snippet = _w[_v];
243
- snippet.showMoreButton = true;
244
- snippet.showLessButton = false;
245
- snippet.subType = 'snippets';
246
- }
247
- }
248
- for (var _x = 0, dialoguesArray_1 = dialoguesArray; _x < dialoguesArray_1.length; _x++) {
249
- var dialog = dialoguesArray_1[_x];
250
- if (dialog.entities && ((_o = dialog.entities) === null || _o === void 0 ? void 0 : _o.length) > 0) {
251
- dialog.entities.forEach(function (entity) {
252
- entity.editMode = false;
253
- });
254
- }
255
- searchResponse.dialogs.push({
256
- intentName: dialog.name,
257
- childBotId: dialog.childBotId,
258
- childBotName: dialog.childBotName,
259
- entities: dialog.entities,
260
- userInput: response.userInput,
261
- sourceMsgId: response.sourceMsgId || '',
262
- positionId: (0,_utils_randomuuid__WEBPACK_IMPORTED_MODULE_5__["default"])('positionId'),
263
- traits: response.traits || [],
264
- dialogId: dialog.dialogId ? dialog.dialogId : this.matchDialogIdfromMenuResponse(dialog),
265
- suggestionFrom: suggestionFrom || _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT
266
- });
267
- }
268
- }
269
- return searchResponse;
270
- };
271
- rootService.prototype.formatSnippetResponse = function (snippetsArray, response, suggestionIndex) {
272
- var _a;
273
- var snipObje = {};
274
- snipObje['contentArray'] = [];
275
- snipObje['sources'] = [];
276
- snipObje['internalInfo'] = [];
277
- snipObje['sendCopyText'] = '';
278
- var snippetResponeArray = [];
279
- if ((snippetsArray === null || snippetsArray === void 0 ? void 0 : snippetsArray.length) > 0) {
280
- snippetsArray.forEach(function (snippet) {
281
- var _a;
282
- if (snippet === null || snippet === void 0 ? void 0 : snippet.templateType) {
283
- if (snippet.templateType == 'active_citation_snippet' || snippet.templateType == 'citation_snippet') {
284
- if ((snippet === null || snippet === void 0 ? void 0 : snippet.content) &&
285
- Array.isArray(snippet === null || snippet === void 0 ? void 0 : snippet.content) &&
286
- ((_a = snippet === null || snippet === void 0 ? void 0 : snippet.content) === null || _a === void 0 ? void 0 : _a.length) > 0) {
287
- snippet.content.forEach(function (ansSnippet) {
288
- var ansObj = {
289
- ans: ansSnippet.answer_fragment,
290
- sources: (ansSnippet === null || ansSnippet === void 0 ? void 0 : ansSnippet.sources) || [],
291
- internalFlag: snippet.internalFlag
292
- };
293
- snipObje['contentArray'].push(ansObj);
294
- snipObje.internalFlag = snippet.internalFlag || false;
295
- snipObje.isActCit = true;
296
- });
297
- }
298
- }
299
- else {
300
- if (snippet === null || snippet === void 0 ? void 0 : snippet.content) {
301
- if (Array.isArray(snippet === null || snippet === void 0 ? void 0 : snippet.content)) {
302
- snippet.content = snippet === null || snippet === void 0 ? void 0 : snippet.content.join('\n');
303
- }
304
- snipObje.internalFlag = snippet.internalFlag || false;
305
- var otherType = {
306
- ans: snippet.content,
307
- internalFlag: snippet.internalFlag
308
- };
309
- if (snippet.url) {
310
- otherType['sources'] = [{ title: snippet.source, url: snippet.url }];
311
- }
312
- snipObje.contentArray.push(otherType);
313
- }
314
- }
315
- snipObje.templateType = snippet.templateType;
316
- snipObje.positionId = snippet.positionId;
317
- snipObje.sourceMsgId = response.sourceMsgId || '';
318
- snipObje.intType = response.intType;
319
- snipObje.isFromGeneratedSummary = response.isFromGeneratedSummary;
320
- snipObje.userInput = response.userInput || '';
321
- }
322
- });
323
- var extInfo_1 = '';
324
- var interlInfo_1 = '';
325
- var uniqueSource_1 = [];
326
- (_a = snipObje['contentArray']) === null || _a === void 0 ? void 0 : _a.forEach(function (entry) {
327
- var _a;
328
- var _b;
329
- var className = '';
330
- (_a = snipObje.sources).push.apply(_a, ((entry === null || entry === void 0 ? void 0 : entry.sources) || []).filter(function (item) {
331
- var returnValue = item.url && uniqueSource_1.indexOf(item.title) == -1;
332
- if (returnValue) {
333
- uniqueSource_1.push(item.title);
334
- }
335
- if (uniqueSource_1.indexOf(item.title) != -1) {
336
- className += "fragment-ext-".concat(uniqueSource_1.indexOf(item.title) + 1, "-").concat(suggestionIndex);
337
- }
338
- return returnValue;
339
- }));
340
- if (!entry.internalFlag) {
341
- snipObje['sendCopyText'] += entry.ans;
342
- }
343
- var temp = "<span class=\"".concat(className, "\">").concat(entry.ans, " ");
344
- 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)) {
345
- for (var _i = 0, _c = entry === null || entry === void 0 ? void 0 : entry.sources; _i < _c.length; _i++) {
346
- var source = _c[_i];
347
- if ((source === null || source === void 0 ? void 0 : source.title) && uniqueSource_1.indexOf(source === null || source === void 0 ? void 0 : source.title) != -1) {
348
- var srcCount = uniqueSource_1.indexOf(source.title);
349
- temp += "<span class=\"source-count-num\">".concat(srcCount + 1, "</span>");
350
- }
351
- }
352
- }
353
- temp += '</span>';
354
- if (entry.internalFlag) {
355
- interlInfo_1 += temp;
356
- }
357
- else {
358
- extInfo_1 += temp;
359
- }
360
- });
361
- snipObje['contentArray'] = [];
362
- snipObje['internalInfo'] = [];
363
- if (interlInfo_1 === null || interlInfo_1 === void 0 ? void 0 : interlInfo_1.trim()) {
364
- snipObje['internalInfo'].push(interlInfo_1 === null || interlInfo_1 === void 0 ? void 0 : interlInfo_1.trim());
365
- }
366
- if (extInfo_1 === null || extInfo_1 === void 0 ? void 0 : extInfo_1.trim()) {
367
- snipObje['contentArray'].push(extInfo_1 === null || extInfo_1 === void 0 ? void 0 : extInfo_1.trim());
368
- }
369
- snipObje.feedbackData = this.prepareFeedbackForSuggestions('answer', snipObje, {});
370
- snippetResponeArray.push(snipObje);
371
- }
372
- return snippetResponeArray;
373
- };
374
- rootService.prototype.updateSearchResponse = function (assistResponseArray, response, ambiguityTokenExt) {
375
- var _a, _b, _c, _d;
376
- response.suggestions.faqs = this.formatFAQResponse(response.suggestions.faqs);
377
- 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) {
378
- if (faq.question === ambiguityTokenExt.question) {
379
- return faq;
380
- }
381
- });
382
- var faqWithoutAnswer = {};
383
- if (faqWithoutAnswerIndex >= 0) {
384
- faqWithoutAnswer = (_c = response === null || response === void 0 ? void 0 : response.suggestions) === null || _c === void 0 ? void 0 : _c.faqs[faqWithoutAnswerIndex];
385
- }
386
- if (faqWithoutAnswer && ((_d = Object.keys(faqWithoutAnswer)) === null || _d === void 0 ? void 0 : _d.length) > 0) {
387
- var updatedArray = assistResponseArray.map(function (item, idx) {
388
- var _a;
389
- if (idx === ambiguityTokenExt.assistSuggestion) {
390
- var updatedItem = __assign({}, item);
391
- var existingFaq = (_a = updatedItem.searchResponse) === null || _a === void 0 ? void 0 : _a.faqs[ambiguityTokenExt.index];
392
- if (existingFaq && faqWithoutAnswer && (faqWithoutAnswer === null || faqWithoutAnswer === void 0 ? void 0 : faqWithoutAnswer.answer)) {
393
- existingFaq.answer = faqWithoutAnswer === null || faqWithoutAnswer === void 0 ? void 0 : faqWithoutAnswer.answer;
394
- existingFaq.toggle = true;
395
- existingFaq.showMoreButton = false;
396
- existingFaq.showLessButton = false;
397
- existingFaq.showSpinner = false;
398
- }
399
- updatedItem.faqArrowClickResponse = true;
400
- return updatedItem;
401
- }
402
- return item;
403
- });
404
- return updatedArray;
405
- }
406
- };
407
- rootService.prototype.checkEmptyObjectsInArray = function (arr) {
408
- 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); });
409
- return arr;
410
- };
411
- rootService.prototype.formatFAQResponse = function (faqArray) {
412
- var _a, _b;
413
- var searchResponse = [];
414
- if (faqArray && (faqArray === null || faqArray === void 0 ? void 0 : faqArray.length) > 0) {
415
- for (var _i = 0, faqArray_2 = faqArray; _i < faqArray_2.length; _i++) {
416
- var faq = faqArray_2[_i];
417
- var faqObject = {
418
- question: faq.question,
419
- taskRefId: faq === null || faq === void 0 ? void 0 : faq.taskRefId,
420
- 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
421
- };
422
- if (faq.answer && faq.answer.length > 0) {
423
- for (var _c = 0, _d = faq.answer; _c < _d.length; _c++) {
424
- var ans = _d[_c];
425
- var object = {
426
- taskRefId: faq.taskRefId,
427
- ans: ans,
428
- showMoreButton: true,
429
- showLessButton: false,
430
- };
431
- (_b = faqObject === null || faqObject === void 0 ? void 0 : faqObject.answer) === null || _b === void 0 ? void 0 : _b.push(object);
432
- }
433
- }
434
- searchResponse.push(faqObject);
435
- }
436
- }
437
- return searchResponse;
438
- };
439
- rootService.prototype.openurlInBrowser = function (url) {
440
- window.open(url, '_blank');
441
- // if (this.settingsData?.urlOpenBehaviour && this.settingsData?.urlOpenBehaviour?.sendPostEvent) {
442
- // let message = {
443
- // method: 'AgentAssist.UrlClickedMessage',
444
- // from: 'agent_assist',
445
- // url: url
446
- // };
447
- // window.parent.postMessage(message, '*');
448
- // } else {
449
- // window.open(url, '_blank');
450
- // }
451
- };
452
- rootService.prototype.extractTextFromElement = function (element) {
453
- var text = '';
454
- if (element) {
455
- var extractText_1 = function (node) {
456
- if (node.nodeType === Node.TEXT_NODE) {
457
- text += node.textContent;
458
- }
459
- else if (node.nodeType === Node.ELEMENT_NODE) {
460
- var childNodes = node.childNodes;
461
- for (var i = 0; i < childNodes.length; i++) {
462
- extractText_1(childNodes[i]);
463
- }
464
- }
465
- };
466
- extractText_1(element);
467
- }
468
- return text.trim();
469
- };
470
- rootService.prototype.handleSendCopyButton = function (actionType, faq_or_article_obj, selectType) {
471
- var message = {};
472
- if (actionType == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND) {
473
- message = {
474
- method: 'send',
475
- name: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SENDMSG,
476
- conversationId: this.connectionDetails.conversationId,
477
- // payload: selectType == ProjConstants.FAQ ? (faq_or_article_obj.answer || faq_or_article_obj.ans) : faq_or_article_obj.content
478
- payload: faq_or_article_obj.sendContent
479
- };
480
- if (selectType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE) {
481
- message['title'] = faq_or_article_obj.title;
482
- message['contentId'] = faq_or_article_obj.contentId;
483
- }
484
- else {
485
- message['title'] = faq_or_article_obj.displayName;
486
- message['contentId'] = faq_or_article_obj.taskRefId;
487
- }
488
- }
489
- else {
490
- message = {
491
- method: 'copy',
492
- name: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPYMSG,
493
- conversationId: this.connectionDetails.conversationId,
494
- // payload: selectType == ProjConstants.FAQ ? (faq_or_article_obj.answer || faq_or_article_obj.ans) : faq_or_article_obj.content
495
- payload: faq_or_article_obj.sendContent
496
- };
497
- if (selectType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE) {
498
- message['title'] = faq_or_article_obj.title;
499
- message['contentId'] = faq_or_article_obj.contentId;
500
- }
501
- else {
502
- message['title'] = faq_or_article_obj.displayName;
503
- message['contentId'] = faq_or_article_obj.taskRefId;
504
- }
505
- }
506
- message['type'] = (selectType == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ) ? 'faq' : 'article';
507
- // window.parent.postMessage(message, '*');
508
- return (this.faqArticleSendorCopyEvent(selectType, message, faq_or_article_obj));
509
- };
510
- rootService.prototype.faqArticleSendorCopyEvent = function (selectType, message, faq_or_article_obj) {
511
- var _a, _b;
512
- var data = {
513
- botId: this.connectionDetails.botId,
514
- conversationId: this.connectionDetails.conversationId,
515
- experience: (_a = this.connectionDetails) === null || _a === void 0 ? void 0 : _a.channel,
516
- source: this.connectionDetails.source,
517
- usedType: message.method,
518
- type: message.type,
519
- name: message.name,
520
- payload: message.payload,
521
- title: message.title,
522
- contentId: message.contentId,
523
- positionId: faq_or_article_obj.positionId ? faq_or_article_obj.positionId : '',
524
- 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,
525
- };
526
- data = this.addSourceMsgIdToRequestParams(faq_or_article_obj, data);
527
- if (this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.Tabs.SEARCH) {
528
- data.skipMsg = this.sentSearchResponse;
529
- data.input = ((_b = this.searchedResultData) === null || _b === void 0 ? void 0 : _b.userInput) || '';
530
- this.sentSearchResponse = true;
531
- }
532
- if (faq_or_article_obj.subType) {
533
- data.subType = faq_or_article_obj.subType;
534
- }
535
- return data;
536
- };
537
- rootService.prototype.addSourceMsgIdToRequestParams = function (data, requestParams) {
538
- if (data.sourceMsgId) {
539
- if (data.sourceMsgId == 'fromLibrary') {
540
- requestParams['fromLibrary'] = true;
541
- }
542
- else {
543
- requestParams['sourceMsgId'] = data.sourceMsgId;
544
- }
545
- }
546
- return requestParams;
547
- };
548
- rootService.prototype.addSentOrCopiedTextForFaqs = function (ansObj, ele, sendText, hostInstance) {
549
- var titleInfoSec = ele.querySelector(this.classConstants.SUGGESTION_EACH_TITLE);
550
- var titleSendText = ele.querySelector("".concat(this.classConstants.SUGGESTION_EACH_TITLE, " ").concat(this.classConstants.SUGGESTION_SENT_TEXT));
551
- if (!ansObj.send && !titleSendText) {
552
- ansObj.send = sendText;
553
- var eachFAQSentText = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.ActionButtonsSentText, { ansObj: ansObj }, hostInstance);
554
- titleInfoSec.append(eachFAQSentText);
555
- }
556
- var sendTextele = ele.querySelector(this.classConstants.SEND_TEXT);
557
- sendTextele.textContent = sendText;
558
- };
559
- rootService.prototype.addSentOrCopiedTextForFiles = function (file, ele, sendText, hostInstance) {
560
- if (!file.send) {
561
- file.send = sendText;
562
- var eachFileSentText = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.ActionButtonsSentText, { file: file }, hostInstance);
563
- ele.querySelector(this.classConstants.SUGGESTION_EACH_TITLE).append(eachFileSentText);
564
- }
565
- var sendTextele = ele.querySelector(this.classConstants.SEND_TEXT);
566
- sendTextele.textContent = sendText;
567
- };
568
- rootService.prototype.addSentOrCopiedTextForArticle = function (article, ele, sendText, hostInstance) {
569
- if (!article.send) {
570
- article.send = sendText;
571
- var eachArticleSentText = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.ActionButtonsSentText, { article: article }, hostInstance);
572
- ele.querySelector(this.classConstants.SUGGESTION_EACH_TITLE).append(eachArticleSentText);
573
- }
574
- var sendTextele = ele.querySelector(this.classConstants.SEND_TEXT);
575
- sendTextele.textContent = sendText;
576
- };
577
- rootService.prototype.addSentOrCopiedTextForSnippets = function (snippet, ele, sendText, hostInstance) {
578
- if (!snippet.send) {
579
- snippet.send = sendText;
580
- var eachSnippetSentText = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_atom_actionButtons__WEBPACK_IMPORTED_MODULE_4__.ActionButtonsSentText, { snippet: snippet }, hostInstance);
581
- ele.querySelector(this.classConstants.SUGGESTION_EACH_TITLE).append(eachSnippetSentText);
582
- }
583
- var sendTextele = ele.querySelector(this.classConstants.SEND_TEXT);
584
- sendTextele.textContent = sendText;
585
- };
586
- rootService.prototype.handleSendCopyButtonForFaq = function (actionType, ansObj, selectType, sourceMsgId, hostInstance) {
587
- // let faqTemplate = this.faqcontent.find((element : any, index : any) => index === inx);
588
- // let faqTemplate = faqList[inx];
589
- ansObj.sourceMsgId = sourceMsgId;
590
- ansObj.sendContent = ansObj.answer || ansObj.ans;
591
- var copyEventData = this.handleSendCopyButton(actionType, ansObj, selectType);
592
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
593
- };
594
- rootService.prototype.handleSendCopyButtonForSnippet = function (actionType, snippetObj, selectType, hostInstance) {
595
- snippetObj.sendContent = (snippetObj.sendCopyText);
596
- var copyEventData = this.handleSendCopyButton(actionType, snippetObj, selectType);
597
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
598
- };
599
- rootService.prototype.handleSendCopyButtonArticleOrFile = function (actionType, articleObj, selectType, hostInstance) {
600
- articleObj.sendContent = articleObj.content;
601
- var copyEventData = this.handleSendCopyButton(actionType, articleObj, selectType);
602
- this.emitSendOrCopyEvent(copyEventData, hostInstance);
603
- };
604
- ;
605
- rootService.prototype.handleActionTemplateClickEventsForFAQ = function (eachActionTemplate, faq, ansObj, faqListHTMLEle, hostInstance) {
606
- var _this = this;
607
- var _a, _b;
608
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
609
- _this.handleSendCopyButtonForFaq(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, ansObj, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ, faq.sourceMsgId, hostInstance);
610
- _this.addSentOrCopiedTextForFaqs(ansObj, faqListHTMLEle, 'Sent', hostInstance);
611
- }, eachActionTemplate);
612
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
613
- _this.handleSendCopyButtonForFaq(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, ansObj, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.FAQ, faq.sourceMsgId, hostInstance);
614
- _this.addSentOrCopiedTextForFaqs(ansObj, faqListHTMLEle, 'Copied', hostInstance);
615
- }, eachActionTemplate);
616
- };
617
- rootService.prototype.emitSendOrCopyEvent = function (copyEventData, hostInstance) {
618
- if ((copyEventData === null || copyEventData === void 0 ? void 0 : copyEventData.usedType) === 'send') {
619
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_SEND_MESSAGE, copyEventData);
620
- }
621
- else {
622
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.AGENT_COPY_MESSAGE, copyEventData);
623
- }
624
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, copyEventData);
625
- };
626
- rootService.prototype.handleFaqExpandCloseBtnClickEvents = function (expandClostBtnTemplate, faqSuggestionBodyList, suggestionHeaderActionTemplate, faqListHTMLIndex, hostInstance) {
627
- var _this = this;
628
- var _a, _b;
629
- var expandElement = expandClostBtnTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_EXPAND);
630
- var closeElement = expandClostBtnTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_CLOSE);
631
- 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));
632
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_FAQ_EXPAND, 'click', function () {
633
- var _a, _b, _c, _d, _e, _f, _g, _h;
634
- if ((_a = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
635
- (_b = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
636
- }
637
- (_c = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
638
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
639
- var _a, _b;
640
- if ((_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
641
- (_b = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
642
- }
643
- });
644
- (_d = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _d === void 0 ? void 0 : _d.add(_this.classConstants.HIDE_ELEMENT);
645
- //hide header send copy btns
646
- (_e = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _e === void 0 ? void 0 : _e.add(_this.classConstants.HIDE_ELEMENT);
647
- //add send copy btns for first answer
648
- var firstAnswerActionBtn = (_f = faqSuggestionBodyList[0]) === null || _f === void 0 ? void 0 : _f.querySelector(_this.classConstants.SUGGESTION_SENDCPY_ACTION);
649
- if ((_g = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _g === void 0 ? void 0 : _g.contains(_this.classConstants.HIDE_ELEMENT)) {
650
- (_h = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _h === void 0 ? void 0 : _h.remove(_this.classConstants.HIDE_ELEMENT);
651
- }
652
- }, expandClostBtnTemplate);
653
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_FAQ_CLOSE, 'click', function () {
654
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
655
- if ((_a = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
656
- (_b = expandElement === null || expandElement === void 0 ? void 0 : expandElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
657
- }
658
- (_c = closeElement === null || closeElement === void 0 ? void 0 : closeElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
659
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
660
- var _a;
661
- if (index != 0) {
662
- (_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
663
- }
664
- });
665
- if ((_d = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _d === void 0 ? void 0 : _d.contains(_this.classConstants.HIDE_ELEMENT)) {
666
- (_e = faqAnsLenghtElement === null || faqAnsLenghtElement === void 0 ? void 0 : faqAnsLenghtElement.classList) === null || _e === void 0 ? void 0 : _e.remove(_this.classConstants.HIDE_ELEMENT);
667
- }
668
- //show header send copy btns
669
- if ((_f = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _f === void 0 ? void 0 : _f.contains(_this.classConstants.HIDE_ELEMENT)) {
670
- (_g = suggestionHeaderActionTemplate === null || suggestionHeaderActionTemplate === void 0 ? void 0 : suggestionHeaderActionTemplate.classList) === null || _g === void 0 ? void 0 : _g.remove(_this.classConstants.HIDE_ELEMENT);
671
- }
672
- //remove send copy btns for first answer
673
- var firstAnswerActionBtn = (_h = faqSuggestionBodyList[0]) === null || _h === void 0 ? void 0 : _h.querySelector(_this.classConstants.SUGGESTION_SENDCPY_ACTION);
674
- (_j = firstAnswerActionBtn === null || firstAnswerActionBtn === void 0 ? void 0 : firstAnswerActionBtn.classList) === null || _j === void 0 ? void 0 : _j.add(_this.classConstants.HIDE_ELEMENT);
675
- }, expandClostBtnTemplate);
676
- };
677
- rootService.prototype.handleActionTemplateClickEventsForSnippet = function (eachActionTemplate, snippet, snippetListHtmlEle, hostInstance) {
678
- var _this = this;
679
- var _a, _b;
680
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
681
- _this.handleSendCopyButtonForSnippet(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, snippet, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
682
- _this.addSentOrCopiedTextForSnippets(snippet, snippetListHtmlEle, 'Sent', hostInstance);
683
- }, eachActionTemplate);
684
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
685
- _this.handleSendCopyButtonForSnippet(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, snippet, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
686
- _this.addSentOrCopiedTextForSnippets(snippet, snippetListHtmlEle, 'Copied', hostInstance);
687
- }, eachActionTemplate);
688
- };
689
- rootService.prototype.handleActionTemplateClickEventsForArticle = function (eachActionTemplate, article, articleListHtmlEle, hostInstance) {
690
- var _this = this;
691
- var _a, _b;
692
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
693
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, article, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
694
- _this.addSentOrCopiedTextForArticle(article, articleListHtmlEle, 'Sent', hostInstance);
695
- }, eachActionTemplate);
696
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
697
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, article, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
698
- _this.addSentOrCopiedTextForArticle(article, articleListHtmlEle, 'Copied', hostInstance);
699
- }, eachActionTemplate);
700
- };
701
- rootService.prototype.handleActionTemplateClickEventsForFile = function (eachActionTemplate, file, fileListHtmlEle, hostInstance) {
702
- var _this = this;
703
- var _a, _b;
704
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_SEND_BTN, 'click', function () {
705
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, file, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
706
- _this.addSentOrCopiedTextForFiles(file, fileListHtmlEle, 'Sent', hostInstance);
707
- }, eachActionTemplate);
708
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(this.classConstants.SUGGESTION_COPY_BTN, 'click', function () {
709
- _this.handleSendCopyButtonArticleOrFile(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, file, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ARTICLE, hostInstance);
710
- _this.addSentOrCopiedTextForFiles(file, fileListHtmlEle, 'Copied', hostInstance);
711
- }, eachActionTemplate);
712
- };
713
- rootService.prototype.handleSuggestionLessClickEvent = function (actionHtml, suggestionElement, listHtml, hostInstance) {
714
- var _this = this;
715
- var _a;
716
- var moreElement = actionHtml.querySelector(this.classConstants.SUGGESTION_MORE_LINK);
717
- var lessElement = actionHtml.querySelector(this.classConstants.SUGGESTION_LESS_LINK);
718
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(this.classConstants.SUGGESTION_MORE_LINK, 'click', function () {
719
- var _a, _b, _c;
720
- if ((_a = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
721
- (_b = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
722
- }
723
- (_c = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
724
- listHtml.forEach(function (item) {
725
- var _a, _b;
726
- if ((_a = item === null || item === void 0 ? void 0 : item.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
727
- (_b = item === null || item === void 0 ? void 0 : item.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
728
- }
729
- });
730
- }, suggestionElement);
731
- };
732
- rootService.prototype.handleSuggestionMoreClickEvent = function (actionHtml, suggestionElement, listHtml, hostInstance) {
733
- var _this = this;
734
- var _a;
735
- var moreElement = actionHtml.querySelector(this.classConstants.SUGGESTION_MORE_LINK);
736
- var lessElement = actionHtml.querySelector(this.classConstants.SUGGESTION_LESS_LINK);
737
- (_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 () {
738
- var _a, _b, _c;
739
- if ((_a = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
740
- (_b = moreElement === null || moreElement === void 0 ? void 0 : moreElement.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
741
- }
742
- (_c = lessElement === null || lessElement === void 0 ? void 0 : lessElement.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
743
- listHtml.forEach(function (item, inx) {
744
- var _a;
745
- if (inx >= 2 && item) {
746
- (_a = item === null || item === void 0 ? void 0 : item.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
747
- }
748
- });
749
- }, suggestionElement);
750
- };
751
- rootService.prototype.setFaqIndividualLoader = function (inx, hide, id) {
752
- var _this = this;
753
- var _a, _b, _c, _d;
754
- if (hide === void 0) { hide = false; }
755
- var faqSuggestionEle = document.getElementById(id);
756
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
757
- var faqLoaderEle = (_a = faqListHTML[inx]) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.SUGGESTION_EACH_HEADER, " ").concat(this.classConstants.SUGGESTION_EACH_TITLE, " ").concat(this.classConstants.SUGGESTION_FAQ_ANS_LOADER));
758
- if (hide && faqLoaderEle) {
759
- (_b = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.HIDE_ELEMENT);
760
- }
761
- else if (faqLoaderEle) {
762
- if ((_c = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _c === void 0 ? void 0 : _c.contains(this.classConstants.HIDE_ELEMENT)) {
763
- (_d = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
764
- }
25
+ websocketservice.prototype.socketConnection = function (configOptions) {
26
+ var _this = this;
27
+ var _a, _b;
28
+ this.configOptions = configOptions;
29
+ var finalUrl = ((_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.connectionDetails) === null || _a === void 0 ? void 0 : _a.domainURL) + '/koreagentassist';
30
+ var config = {
31
+ url: finalUrl,
32
+ options: {
33
+ path: '/agentassist/api/v1/chat',
34
+ autoConnect: true,
35
+ transports: ['websocket', 'polling', 'flashsocket'],
36
+ reconnection: true,
37
+ reconnectionDelay: 5000,
38
+ reconnectionAttempts: 13,
39
+ query: { 'jToken': (_b = configOptions === null || configOptions === void 0 ? void 0 : configOptions.connectionDetails) === null || _b === void 0 ? void 0 : _b.token }
40
+ }
41
+ };
42
+ this._agentAssistSocket = (0,socket_io_client__WEBPACK_IMPORTED_MODULE_0__.io)(config.url, config.options);
43
+ this._agentAssistSocket.connect();
44
+ this.listenEvents();
45
+ this._agentAssistSocket.on("connect", function () {
46
+ console.log("connect");
47
+ _this.hostIns.emit('ON_SOCKET_CONNECTION', configOptions);
48
+ if (!_this.hostIns.rootService.socketConnect) {
49
+ _this.hostIns.rootService.socketConnect = true;
50
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.INTERNAL_EVENTS.GET_CHECKLISTS, true);
51
+ }
52
+ });
53
+ // Handle initial connection errors
54
+ this._agentAssistSocket.on("connect_error", function (error) {
55
+ console.log("connect_error", error);
56
+ });
57
+ // Handle connection timeout
58
+ this._agentAssistSocket.on("connect_timeout", function () {
59
+ console.log("connect_timeout");
60
+ });
61
+ // Handle successful reconnection
62
+ this._agentAssistSocket.on("reconnect", function (attemptNumber) {
63
+ console.log("reconnect", attemptNumber);
64
+ });
65
+ // Handle each reconnection attempt
66
+ this._agentAssistSocket.on("reconnect_attempt", function (attemptNumber) {
67
+ console.log("reconnect_attempt", attemptNumber);
68
+ });
69
+ // Handle failed reconnection attempts
70
+ this._agentAssistSocket.on("reconnect_error", function (error) {
71
+ console.log("reconnect_error", error);
72
+ });
73
+ // Handle final failed reconnection after all attempts
74
+ this._agentAssistSocket.on("reconnect_failed", function () {
75
+ console.log("reconnect_failed");
76
+ });
77
+ // Handle ping timeout
78
+ this._agentAssistSocket.on("ping_timeout", function () {
79
+ console.log("ping_timeout");
80
+ });
81
+ };
82
+ websocketservice.prototype.emitEvents = function (eventName, requestParams, keepOldTraceId) {
83
+ if (keepOldTraceId === void 0) { keepOldTraceId = false; }
84
+ var _a = this.configOptions.connectionDetails, fromSAT = _a.fromSAT, source = _a.source, autoBotId = _a.autoBotId, channel = _a.channel, interactiveLanguage = _a.interactiveLanguage, botId = _a.botId;
85
+ if (requestParams) {
86
+ requestParams.isExtAD = fromSAT ? false : true;
87
+ requestParams.source = source;
88
+ requestParams.experience = channel;
89
+ requestParams.traceId = (keepOldTraceId && requestParams.traceId) ? requestParams.traceId : 'ua-f0f3edc3-16ca-4e02-9363-4f48c602df62';
90
+ requestParams.language = interactiveLanguage;
91
+ }
92
+ if (eventName == 'internal_transfer') {
93
+ requestParams.botId = botId;
94
+ }
95
+ this._agentAssistSocket.emit(eventName, requestParams);
96
+ };
97
+ websocketservice.prototype.listenEvents = function () {
98
+ var _this = this;
99
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_response, function (data) {
100
+ _this.hostIns.rootService.assistTabSessionId = '';
101
+ if (data.sessionId) {
102
+ _this.hostIns.rootService.assistTabSessionId = data === null || data === void 0 ? void 0 : data.sessionId;
103
+ }
104
+ var settimeoutTime = _this.getTimeout();
765
105
  setTimeout(function () {
766
- var _a;
767
- (_a = faqLoaderEle === null || faqLoaderEle === void 0 ? void 0 : faqLoaderEle.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
768
- }, 10000);
769
- }
770
- };
771
- rootService.prototype.addOrHideFAQArrows = function (faqUpArrowTemplate, faqDownArrowTemplate, type) {
772
- var _a, _b, _c, _d, _e, _f;
773
- if (type === 'up') {
774
- if ((_a = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(this.classConstants.HIDE_ELEMENT)) {
775
- (_b = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(this.classConstants.HIDE_ELEMENT);
776
- }
777
- (_c = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
778
- }
779
- else {
780
- if ((_d = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _d === void 0 ? void 0 : _d.contains(this.classConstants.HIDE_ELEMENT)) {
781
- (_e = faqUpArrowTemplate === null || faqUpArrowTemplate === void 0 ? void 0 : faqUpArrowTemplate.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
782
- }
783
- (_f = faqDownArrowTemplate === null || faqDownArrowTemplate === void 0 ? void 0 : faqDownArrowTemplate.classList) === null || _f === void 0 ? void 0 : _f.add(this.classConstants.HIDE_ELEMENT);
784
- }
785
- };
786
- rootService.prototype.toggleArrows = function (index, faqId) {
787
- var _a;
788
- var faqSuggestionEle = document.getElementById(faqId);
789
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
790
- var suggestionHeaderTemplate = (_a = faqListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelector(this.classConstants.SUGGESTION_EACH_HEADER);
791
- var faqUpArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_UP_ARROW);
792
- var faqDownArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(this.classConstants.SUGGESTION_FAQ_DOWN_ARROW);
793
- this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'down');
794
- };
795
- rootService.prototype.openLinksInBrowser = function (url) {
796
- this.openurlInBrowser(url);
797
- };
798
- ;
799
- rootService.prototype.openurlInBrowserForSnippet = function (url, snippet, hostInstance) {
800
- this.openurlInBrowser(url);
801
- this.handleUrlClickEvent(url, snippet, hostInstance);
802
- };
803
- rootService.prototype.handleUrlClickEvent = function (url, snippet, hostInstance) {
804
- var socketRequestParams = this.commonRequestParamsForActivity(snippet);
805
- socketRequestParams.eventType = "url_clicked";
806
- socketRequestParams.url = url;
807
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_activity_request, socketRequestParams);
808
- };
809
- rootService.prototype.commonRequestParamsForActivity = function (snippet) {
810
- var _a = this.connectionDetails, botId = _a.botId, conversationId = _a.conversationId, channel = _a.channel;
811
- var socketRequestParams = {
812
- botId: botId,
813
- conversationId: conversationId,
814
- event: "clicked",
815
- sourceMsgId: snippet.sourceMsgId,
816
- dataSource: "snippet",
817
- positionId: snippet.positionId,
818
- // participant : rootServiceInstance?.internalTransferData?.participant || {}
819
- };
820
- return socketRequestParams;
821
- };
822
- rootService.prototype.emitSearchRequestForAssistSuggestions = function (value, isSearch, faq, hostInstance) {
823
- var connectionDetails = Object.assign({}, this.connectionDetails);
824
- connectionDetails.value = value;
825
- connectionDetails.isSearch = isSearch;
826
- // connectionDetails.positionId = searchObj?.positionId;
827
- if (connectionDetails.interactiveLanguage && typeof connectionDetails.interactiveLanguage == 'string' && connectionDetails.interactiveLanguage != "''") {
828
- connectionDetails['language'] = connectionDetails.interactiveLanguage; // Return the default value for null, undefined, or "''"
829
- }
830
- if (faq.sourceMsgId) {
831
- connectionDetails['sourceMsgId'] = faq.sourceMsgId;
832
- }
833
- var agent_assist_request_params = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
834
- if (faq.ambiguityToken) {
835
- agent_assist_request_params.uiunqref = faq.ambiguityToken;
836
- }
837
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, agent_assist_request_params);
838
- };
839
- rootService.prototype.emitSearchRequestForSearch = function (searchTextObj, isSearch, faq, hostInstance) {
840
- var _a, _b;
841
- if (faq === void 0) { faq = {}; }
842
- var searchTextValue = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.value;
843
- 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 });
844
- if (connectionDetails.interactiveLanguage && typeof connectionDetails.interactiveLanguage === 'string' && connectionDetails.interactiveLanguage !== "''") {
845
- connectionDetails.language = connectionDetails.interactiveLanguage;
846
- }
847
- if (faq && faq.sourceMsgId) {
848
- connectionDetails.sourceMsgId = faq.sourceMsgId;
849
- }
850
- var agentAssistAgentRequestParams = hostInstance.prepareAgentAssistAgentRequestParams(connectionDetails);
851
- if (isSearch) {
852
- agentAssistAgentRequestParams.startTime = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.stTime;
853
- agentAssistAgentRequestParams.endTime = searchTextObj === null || searchTextObj === void 0 ? void 0 : searchTextObj.edTime;
854
- }
855
- if (faq.ambiguityToken) {
856
- agentAssistAgentRequestParams.uiunqref = faq.ambiguityToken;
857
- }
858
- // agentAssistAgentRequestParams.participant = rootService?.internalTransferData?.participant || {};
859
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, agentAssistAgentRequestParams);
860
- };
861
- ;
862
- rootService.prototype.handleFaqAmbiguityDescElement = function (faqId, ambiguityToken, faqs, hostInstance) {
863
- var _a, _b, _c, _d;
864
- var faqSuggestionEle = document.getElementById(faqId);
865
- var faqListHTML = faqSuggestionEle === null || faqSuggestionEle === void 0 ? void 0 : faqSuggestionEle.querySelectorAll(this.classConstants.SUGGESTION_EACH);
866
- var faqinx = ambiguityToken === null || ambiguityToken === void 0 ? void 0 : ambiguityToken.index;
867
- var descEle;
868
- var faqwithAns = faqs[faqinx];
869
- this.setFaqIndividualLoader(faqinx, true, faqId);
870
- if (faqwithAns && ((_a = faqwithAns === null || faqwithAns === void 0 ? void 0 : faqwithAns.answer) === null || _a === void 0 ? void 0 : _a.length) > 0 && faqListHTML[faqinx]) {
871
- descEle = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_3__.FaqAnswerPlacement, { faq: faqwithAns }, hostInstance);
872
- 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 });
873
- if (descEle) {
874
- var feedbackWrapper = (_c = (_b = faqListHTML[faqinx]) === null || _b === void 0 ? void 0 : _b.querySelector) === null || _c === void 0 ? void 0 : _c.call(_b, "".concat(this.classConstants.FEEDBACK_WRAPPER).concat(faqwithAns === null || faqwithAns === void 0 ? void 0 : faqwithAns.positionId));
875
- if (feedbackWrapper) {
876
- faqListHTML[faqinx].insertBefore(descEle, feedbackWrapper);
877
- }
878
- else {
879
- faqListHTML[faqinx].append(descEle);
880
- }
881
- 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);
882
- }
883
- }
884
- var suggestionHeaderTemplate = (_d = faqListHTML[faqinx]) === null || _d === void 0 ? void 0 : _d.querySelector(this.classConstants.SUGGESTION_EACH_HEADER);
885
- this.addOrHideFAQActionExpandCloseElements(faqwithAns, suggestionHeaderTemplate, faqListHTML, faqinx, hostInstance);
886
- };
887
- rootService.prototype.handleFaqToggle = function (faq, index, type, faqListHTML, hostInstance, isAssistSuggestion, props) {
888
- var _this = this;
889
- var _a;
890
- faq.toggle = !faq.toggle;
891
- faq.seeMoreWrapper = false;
892
- var faqSuggestionBodyList = (_a = faqListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelectorAll(this.classConstants.SUGGESTION_EACH_BODY);
893
- if (type == 'down' && !faq.answer) {
894
- if (isAssistSuggestion) {
895
- this.checkAnswerAndToggleForAssist(faq, index, hostInstance, props);
896
- }
897
- else {
898
- this.checkAnswerAndToggleForSearch(faq, index, hostInstance);
899
- }
900
- }
901
- else if (type == 'down' && faq.answer) {
902
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
903
- var _a, _b;
904
- if ((_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.HIDE_ELEMENT)) {
905
- (_b = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
906
- }
907
- });
908
- }
909
- else if (type == 'up') {
910
- faqSuggestionBodyList.forEach(function (ansTemplate, index) {
911
- var _a;
912
- (_a = ansTemplate === null || ansTemplate === void 0 ? void 0 : ansTemplate.classList) === null || _a === void 0 ? void 0 : _a.add(_this.classConstants.HIDE_ELEMENT);
913
- });
914
- }
915
- };
916
- rootService.prototype.checkAnswerAndToggleForAssist = function (faq, index, hostInstance, props) {
917
- if (!faq.answer && faq.toggle) {
918
- faq.ambiguityToken = btoa(JSON.stringify({ question: faq.question, index: index, assistSuggestion: props.suggestionIndex }));
919
- this.emitSearchRequestForAssistSuggestions(faq.displayName, false, faq, hostInstance);
920
- var faqId = this.idConstants.ASSIST_FAQ_SUGGESTION + props.suggestionIndex;
921
- this.setFaqIndividualLoader(index, false, faqId);
922
- }
923
- };
924
- ;
925
- rootService.prototype.checkAnswerAndToggleForSearch = function (faq, index, hostInstance) {
926
- if (!faq.answer && faq.toggle) {
927
- faq.ambiguityToken = btoa(JSON.stringify({ question: faq.question, index: index }));
928
- this.emitSearchRequestForSearch({ value: faq.displayName }, false, faq, hostInstance);
929
- this.setFaqIndividualLoader(index, false, this.idConstants.SEARCH_FAQ_SUGGESTION);
930
- }
931
- };
932
- rootService.prototype.renderEachFaqInSuggestionList = function (searchResponse, faqListHTML, hostInstance, isAssistSuggestion, props) {
933
- var _this = this;
934
- var _a;
935
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.faqs) === null || _a === void 0 ? void 0 : _a.forEach(function (faq, index) {
936
- var _a, _b, _c, _d;
937
- var suggestionHeaderTemplate = (_a = faqListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER);
938
- var faqUpArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(_this.classConstants.SUGGESTION_FAQ_UP_ARROW);
939
- var faqDownArrowTemplate = suggestionHeaderTemplate === null || suggestionHeaderTemplate === void 0 ? void 0 : suggestionHeaderTemplate.querySelector(_this.classConstants.SUGGESTION_FAQ_DOWN_ARROW);
940
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_FAQ_UP_ARROW, 'click', function () {
941
- _this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'up');
942
- _this.handleFaqToggle(faq, index, 'up', faqListHTML, hostInstance, isAssistSuggestion, props);
943
- }, suggestionHeaderTemplate);
944
- (_c = hostInstance.eventManager) === null || _c === void 0 ? void 0 : _c.addEventListener(_this.classConstants.SUGGESTION_FAQ_DOWN_ARROW, 'click', function () {
945
- _this.addOrHideFAQArrows(faqUpArrowTemplate, faqDownArrowTemplate, 'down');
946
- _this.handleFaqToggle(faq, index, 'down', faqListHTML, hostInstance, isAssistSuggestion, props);
947
- }, suggestionHeaderTemplate);
948
- if (faq.answer && ((_d = faq === null || faq === void 0 ? void 0 : faq.answer) === null || _d === void 0 ? void 0 : _d.length) > 0 && !_this.hideActionButtons) {
949
- _this.addOrHideFAQActionExpandCloseElements(faq, suggestionHeaderTemplate, faqListHTML, index, hostInstance);
950
- }
106
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_RESPONSE, data);
107
+ }, settimeoutTime);
951
108
  });
952
- };
953
- rootService.prototype.renderEachSnippetInSuggestionList = function (searchResponse, snippetListHtml, hostInstance) {
954
- var _this = this;
955
- var _a;
956
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.snippets) === null || _a === void 0 ? void 0 : _a.forEach(function (snippet, index) {
957
- var _a, _b;
958
- if (snippet.contentArray.length > 0) {
959
- 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);
960
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
961
- (_a = snippetListHtml[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
962
- _this.handleActionTemplateClickEventsForSnippet(eachActionTemplate, snippet, snippetListHtml[index], hostInstance);
963
- }
964
- }
965
- var sourceListHtml = snippetListHtml[index].querySelectorAll(_this.classConstants.SUGGESTION_SNIPPET_SOURCE_TAG);
966
- (_b = snippet.sources) === null || _b === void 0 ? void 0 : _b.forEach(function (source, inx) {
967
- var _a;
968
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.SUGGESTION_SNIPPET_LINK, 'click', function () {
969
- _this.openurlInBrowserForSnippet(source.url, snippet, hostInstance);
970
- }, sourceListHtml[inx]);
971
- });
109
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_menu_response, function (data) {
110
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_MENU_RESPONSE, data);
972
111
  });
973
- };
974
- rootService.prototype.renderEachArticleInSuggestionList = function (searchResponse, articlesListHTML, hostInstance) {
975
- var _this = this;
976
- var _a;
977
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.articles) === null || _a === void 0 ? void 0 : _a.forEach(function (article, index) {
978
- var _a, _b;
979
- if ((article === null || article === void 0 ? void 0 : article.content) && !(article === null || article === void 0 ? void 0 : article.internalFlag)) {
980
- 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);
981
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
982
- (_a = articlesListHTML[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
983
- _this.handleActionTemplateClickEventsForArticle(eachActionTemplate, article, articlesListHTML[index], hostInstance);
984
- }
985
- }
986
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_ARTICLE_LINK, 'click', function () {
987
- _this.openLinksInBrowser(article.link);
988
- }, articlesListHTML[index]);
112
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_coaching_response, function (data) {
113
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_COACHING_RESPONSES, data);
989
114
  });
990
- };
991
- rootService.prototype.renderEachFileInSuggestionList = function (searchResponse, filesListHtml, hostInstance) {
992
- var _this = this;
993
- var _a;
994
- (_a = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.files) === null || _a === void 0 ? void 0 : _a.forEach(function (file, index) {
995
- var _a, _b;
996
- if ((file === null || file === void 0 ? void 0 : file.content) && !(file === null || file === void 0 ? void 0 : file.internalFlag)) {
997
- 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);
998
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
999
- (_a = filesListHtml[index]) === null || _a === void 0 ? void 0 : _a.querySelector(_this.classConstants.SUGGESTION_EACH_HEADER).append(eachActionTemplate);
1000
- _this.handleActionTemplateClickEventsForFile(eachActionTemplate, file, filesListHtml[index], hostInstance);
1001
- }
1002
- }
1003
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener(_this.classConstants.SUGGESTION_FILE_LINK, 'click', function () {
1004
- _this.openLinksInBrowser(file.link);
1005
- }, filesListHtml[index]);
115
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.checklist_step_response, function (data) {
116
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.CHECKLIST_STEP_RESPONSE, data);
1006
117
  });
1007
- };
1008
- // search
1009
- rootService.prototype.handleSearchText = function (searchText, hostInstance) {
1010
- var _a, _b;
1011
- if (searchText.isEntered) {
1012
- this.emitSearchRequestForSearch(searchText, true, {}, hostInstance);
1013
- }
1014
- 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);
1015
- 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));
1016
- if (inputBlock) {
1017
- var inputSearchIcon = inputBlock === null || inputBlock === void 0 ? void 0 : inputBlock.querySelector(this.classConstants.SEARCH_INPUT_ICON);
1018
- var inputCloseIcon = inputBlock === null || inputBlock === void 0 ? void 0 : inputBlock.querySelector(this.classConstants.SEARCH_INPUT_CLOSE);
1019
- if (searchText.value) {
1020
- inputSearchIcon.classList.add(this.classConstants.HIDE_ELEMENT);
1021
- inputCloseIcon.classList.remove(this.classConstants.HIDE_ELEMENT);
1022
- }
1023
- else {
1024
- inputCloseIcon.classList.add(this.classConstants.HIDE_ELEMENT);
1025
- inputSearchIcon.classList.remove(this.classConstants.HIDE_ELEMENT);
1026
- }
1027
- inputEle.value = searchText.value;
1028
- }
1029
- };
1030
- rootService.prototype.addOrHideFAQActionExpandCloseElements = function (faq, suggestionHeaderTemplate, faqListHTML, index, hostInstance) {
1031
- var _this = this;
1032
- var _a, _b, _c, _d, _e;
1033
- 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);
1034
- if (suggestionHeaderTemplate && eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) != '#text') {
1035
- suggestionHeaderTemplate.append(eachActionTemplate);
1036
- this.handleActionTemplateClickEventsForFAQ(eachActionTemplate, faq, faq.answer[0], faqListHTML[index], hostInstance);
1037
- }
1038
- if (((_a = faq.answer) === null || _a === void 0 ? void 0 : _a.length) > 1) {
1039
- var faqSuggestionBodyList_1 = (_b = faqListHTML[index]) === null || _b === void 0 ? void 0 : _b.querySelectorAll(this.classConstants.SUGGESTION_EACH_BODY);
1040
- (_c = faq.answer) === null || _c === void 0 ? void 0 : _c.forEach(function (ansObj, inx) {
1041
- 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);
1042
- if (eachAnsActionTemplate && (eachAnsActionTemplate === null || eachAnsActionTemplate === void 0 ? void 0 : eachAnsActionTemplate.nodeName) != '#text') {
1043
- if (faqSuggestionBodyList_1 && (faqSuggestionBodyList_1 === null || faqSuggestionBodyList_1 === void 0 ? void 0 : faqSuggestionBodyList_1.length) > 0) {
1044
- faqSuggestionBodyList_1[inx].prepend(eachAnsActionTemplate);
1045
- _this.handleActionTemplateClickEventsForFAQ(eachAnsActionTemplate, faq, ansObj, faqListHTML[index], hostInstance);
1046
- }
1047
- }
1048
- });
1049
- var expandClostBtnTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_3__.FaqExpandCloseBtn, {}, hostInstance);
1050
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, expandClostBtnTemplate, {
1051
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FAQ_EXPAND_CLOSE_TEMPLATE,
1052
- data: {}
1053
- });
1054
- (_d = faqListHTML[index]) === null || _d === void 0 ? void 0 : _d.append(expandClostBtnTemplate);
1055
- 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));
1056
- this.handleFaqExpandCloseBtnClickEvents(expandClostBtnTemplate, faqSuggestionBodyList_1, suggestionHeaderActionTemplate, faqListHTML[index], hostInstance);
1057
- }
1058
- };
1059
- rootService.prototype.handleSeeMoreButtonsForSearchAssist = function (suggestionElement, descClassName, moreContainer, hostInstance) {
1060
- var _this = this;
1061
- var suggestionBodyFaq = suggestionElement === null || suggestionElement === void 0 ? void 0 : suggestionElement.querySelectorAll('.suggestion-item-card .suggestion-body-faq');
1062
- suggestionBodyFaq === null || suggestionBodyFaq === void 0 ? void 0 : suggestionBodyFaq.forEach(function (bodyele, i) {
1063
- var _a;
1064
- var desc = bodyele.querySelector(descClassName);
1065
- if (desc) {
1066
- var overlimitContainer = bodyele === null || bodyele === void 0 ? void 0 : bodyele.querySelector(moreContainer);
1067
- var moreButton_1 = overlimitContainer === null || overlimitContainer === void 0 ? void 0 : overlimitContainer.querySelector(_this.classConstants.MORE_BUTTON);
1068
- var isOverLimit = desc.scrollHeight > desc.clientHeight;
1069
- if (isOverLimit) {
1070
- overlimitContainer.classList.remove(_this.classConstants.HIDE_ELEMENT);
1071
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.MORE_BUTTON, 'click', function (e) {
1072
- desc.classList.toggle(_this.classConstants.SUGGESTION_EXPANDED);
1073
- 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;
1074
- }, overlimitContainer);
1075
- }
1076
- }
118
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.checklist_response, function (data) {
119
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.CHECKLIST_RESPONSE, data);
1077
120
  });
1078
- };
1079
- rootService.prototype.handleSeeMoreButtonsForFaq = function (suggestionElement, descClassName, moreContainer, hostInstance, faqinx) {
1080
- var _this = this;
1081
- if (faqinx === void 0) { faqinx = -1; }
1082
- var suggestionEachFaq = suggestionElement === null || suggestionElement === void 0 ? void 0 : suggestionElement.querySelectorAll(this.classConstants.SUGGESTION_EACH);
1083
- suggestionEachFaq === null || suggestionEachFaq === void 0 ? void 0 : suggestionEachFaq.forEach(function (eachFaq, i) {
1084
- var _a;
1085
- if (faqinx == -1 || faqinx === i) {
1086
- (_a = eachFaq.querySelectorAll(_this.classConstants.SUGGESTION_EACH_BODY)) === null || _a === void 0 ? void 0 : _a.forEach(function (bodyele, ii) {
1087
- var _a;
1088
- var desc = bodyele.querySelector(descClassName);
1089
- if (desc) {
1090
- var overlimitContainer = bodyele === null || bodyele === void 0 ? void 0 : bodyele.querySelector(moreContainer);
1091
- var moreButton_2 = overlimitContainer === null || overlimitContainer === void 0 ? void 0 : overlimitContainer.querySelector(_this.classConstants.MORE_BUTTON);
1092
- var isOverLimit = desc.scrollHeight > desc.clientHeight;
1093
- if (isOverLimit) {
1094
- overlimitContainer.classList.remove(_this.classConstants.HIDE_ELEMENT);
1095
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(_this.classConstants.MORE_BUTTON, 'click', function (e) {
1096
- desc.classList.toggle(_this.classConstants.SUGGESTION_EXPANDED);
1097
- 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;
1098
- }, overlimitContainer);
1099
- }
1100
- if (ii > 0) {
1101
- bodyele.classList.add(_this.classConstants.HIDE_ELEMENT);
1102
- }
1103
- }
1104
- });
1105
- }
121
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.realtime_sentiment_response, function (data) {
1106
122
  });
1107
- };
1108
- // playbook related logic.
1109
- rootService.prototype.prepareChecklistPayload = function (event, checkListData, checklistObj, step) {
1110
- var _a, _b, _c;
1111
- if (step === void 0) { step = false; }
1112
- var payload = {
1113
- "payload": {
1114
- "event": event,
1115
- "conversationId": this.connectionDetails.conversationId,
1116
- "ccVersion": checkListData === null || checkListData === void 0 ? void 0 : checkListData.ccVersion,
1117
- "accountId": checkListData === null || checkListData === void 0 ? void 0 : checkListData.accountId,
1118
- "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,
1119
- "agentInfo": {
1120
- "agentId": "", // mendatory field
1121
- //any other fields
1122
- },
1123
- "timestamp": 0,
1124
- "context": {}
1125
- }
1126
- };
1127
- if (step) {
1128
- payload.payload.checklistStep = checklistObj;
1129
- }
1130
- else {
1131
- payload.payload.checklist = checklistObj;
1132
- }
1133
- return payload;
1134
- };
1135
- rootService.prototype.sendAndCopyForPlaybook = function (eventName, payload, eachPlaybookStep, hostInstance) {
1136
- var message = {
1137
- 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,
1138
- 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,
1139
- conversationId: this.connectionDetails.conversationId,
1140
- payload: payload,
1141
- };
1142
- if (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND_METHOD) {
1143
- 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 } });
1144
- }
1145
- else if (eventName == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY_METHOD) {
1146
- 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 } });
1147
- }
1148
- };
1149
- rootService.prototype.sendCheckListCompleteEvent = function (prevCheckListsData, id, hostInstance) {
1150
- var checklistParams = this.prepareChecklistPayload('checklist_closed', prevCheckListsData, { "id": id });
1151
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.checklist_closed, checklistParams);
1152
- };
1153
- rootService.prototype.checkAllStagesCompleted = function (prevCheckListsData, id, hostInstance) {
1154
- var _a, _b, _c, _d, _e, _f, _g;
1155
- var checklists = prevCheckListsData.checklists;
1156
- var completed = false;
1157
- var i = (checklists || []).findIndex(function (item) { return item._id === id; });
1158
- if (((_a = checklists[i]) === null || _a === void 0 ? void 0 : _a.type) !== 'primary') {
1159
- completed = (((_b = checklists[i].stages[0]) === null || _b === void 0 ? void 0 : _b.steps) || [])
1160
- .every(function (item) { return item.complete; });
1161
- if (completed) {
1162
- checklists[i].completed = true;
1163
- this.sendCheckListCompleteEvent(prevCheckListsData, id, hostInstance);
1164
- }
1165
- }
1166
- else {
1167
- var open_1 = (((_c = checklists[i].stages[0]) === null || _c === void 0 ? void 0 : _c.steps) || [])
1168
- .every(function (item) { return item.complete; });
1169
- if (open_1) {
1170
- }
1171
- var close_1 = (((_d = checklists[i].stages[1]) === null || _d === void 0 ? void 0 : _d.steps) || [])
1172
- .every(function (item) { return item.complete; });
1173
- if (close_1) {
1174
- (_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);
1175
- }
1176
- // if (close) {
1177
- // if (!this.openAck) {
1178
- // this.isCloseCompleted = true;
1179
- // setTimeout(() => {
1180
- // this.isCloseCompleted = false;
1181
- // this.openAck = true;
1182
- // }, 3000);
1183
- // }
1184
- // }
1185
- if (open_1 && close_1) {
1186
- checklists[i].completed = true;
1187
- completed = true;
1188
- }
1189
- if (completed) {
1190
- this.sendCheckListCompleteEvent(prevCheckListsData, id, hostInstance);
1191
- }
1192
- }
1193
- };
1194
- rootService.prototype.updateStepTemplate = function (prevCheckListsData, hostInstance) {
1195
- var _a, _b;
1196
- (_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) {
1197
- var _a;
1198
- (_a = stage === null || stage === void 0 ? void 0 : stage.steps) === null || _a === void 0 ? void 0 : _a.map(function (step, stepInx) {
1199
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1200
- 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));
1201
- 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));
1202
- if (stepEle) {
1203
- if (step.ongoing === false) {
1204
- (_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);
1205
- (_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);
1206
- (_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);
1207
- (_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);
1208
- }
1209
- if (step.complete === true) {
1210
- (_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);
1211
- }
1212
- if (step.ongoing === true) {
1213
- (_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);
1214
- (_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);
1215
- (_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);
1216
- (_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);
1217
- }
123
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_agent_response, function (data) {
124
+ var settimeoutTime = _this.getTimeout();
125
+ setTimeout(function () {
126
+ _this.hostIns.rootService.sentSearchResponse = false;
127
+ _this.hostIns.rootService.myBotTabSessionId = '';
128
+ if (data.sessionId) {
129
+ _this.hostIns.rootService.myBotTabSessionId = data === null || data === void 0 ? void 0 : data.sessionId;
1218
130
  }
1219
- });
1220
- });
1221
- };
1222
- rootService.prototype.selectNextStep = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1223
- var _a, _b;
1224
- var allStepsComplete = true;
1225
- var index = 0;
1226
- this.closeAllStepsInStage(prevCheckListsData, clIndex, stInx);
1227
- 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++) {
1228
- var step = _c[_i];
1229
- if (!step.complete) {
1230
- step.ongoing = true;
1231
- allStepsComplete = false;
1232
- this.selSpInx = index;
1233
- this.scrollView(step._id, hostInstance);
1234
- break;
1235
- }
1236
- index++;
1237
- }
1238
- return allStepsComplete;
1239
- };
1240
- rootService.prototype.closeAllStepsInStage = function (prevCheckListsData, clIndex, stInx) {
1241
- var _a;
1242
- (_a = prevCheckListsData.checklists[clIndex]) === null || _a === void 0 ? void 0 : _a.stages.forEach(function (stage) {
1243
- stage === null || stage === void 0 ? void 0 : stage.steps.forEach(function (step) {
1244
- step.ongoing = false;
1245
- });
1246
- });
1247
- };
1248
- rootService.prototype.selectStepForRandom = function (stInx, step, stepInx, hostInstance) {
1249
- this.selStInx = stInx;
1250
- this.selSpInx = stepInx;
1251
- step.ongoing = true;
1252
- var stepId = step._id;
1253
- this.scrollView(stepId, hostInstance);
1254
- };
1255
- rootService.prototype.selectStage = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1256
- this.selStInx = stInx;
1257
- this.selectNextStep(prevCheckListsData, clIndex, stInx, hostInstance);
1258
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1259
- };
1260
- rootService.prototype.scrollView = function (stepId, hostInstance) {
1261
- if (hostInstance.chatEle.querySelector("#".concat(stepId))) {
1262
- hostInstance.chatEle.querySelector("#".concat(stepId)).scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
1263
- }
1264
- };
1265
- // update proceed to close button based on primary checklists
1266
- rootService.prototype.showProceedToCloseBtn = function (hostInstance) {
1267
- var _a;
1268
- 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));
1269
- proceedToClostBtn.classList.remove(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ClassMapConstanst.HIDE_ELEMENT);
1270
- };
1271
- rootService.prototype.clickStep = function (prevCheckListsData, stInx, step, stepInx, hostInstance) {
1272
- var selCLInx = this.selCLInx;
1273
- var selStInx = this.selStInx;
1274
- var selSpInx = this.selSpInx;
1275
- var checklists = prevCheckListsData.checklists;
1276
- var cl = checklists[selCLInx];
1277
- if ((step === null || step === void 0 ? void 0 : step.complete) || (step === null || step === void 0 ? void 0 : step.ongoing)) {
1278
- return;
1279
- }
1280
- else if ((cl === null || cl === void 0 ? void 0 : cl.order) === "random") {
1281
- checklists[selCLInx].stages[selStInx].steps[selSpInx].ongoing = false;
1282
- this.selectStepForRandom(stInx, step, stepInx, hostInstance);
1283
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1284
- }
1285
- else {
1286
- return;
1287
- }
1288
- };
1289
- rootService.prototype.getNumberstepCompInStage = function (prevCheckListsData) {
1290
- var _a, _b;
1291
- var stepNum = 0;
1292
- 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++) {
1293
- var step = _c[_i];
1294
- if (step.complete) {
1295
- stepNum += 1;
1296
- }
1297
- }
1298
- return stepNum;
1299
- };
1300
- rootService.prototype.handleStageCheck = function (parentEle, stInx, stageList, hostInstance) {
1301
- var _a, _b;
1302
- 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));
1303
- if (selectedStageSpan) {
1304
- selectedStageSpan.innerText = (_b = stageList[stInx]) === null || _b === void 0 ? void 0 : _b.name;
1305
- }
1306
- stageList === null || stageList === void 0 ? void 0 : stageList.map(function (stage, inx) {
1307
- var _a, _b;
1308
- 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));
1309
- 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);
131
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_AGENT_RESPONSE, data);
132
+ }, settimeoutTime);
1310
133
  });
1311
- };
1312
- rootService.prototype.selectNextStage = function (prevCheckListsData, clIndex, stInx, hostInstance) {
1313
- var _a, _b, _c, _d;
1314
- var allStepsCompleteInStage = this.selectNextStep(prevCheckListsData, clIndex, stInx, hostInstance);
1315
- if (allStepsCompleteInStage && ((_a = prevCheckListsData.checklists[clIndex]) === null || _a === void 0 ? void 0 : _a.stages[stInx + 1])) {
1316
- if (((_b = prevCheckListsData.checklists[clIndex]) === null || _b === void 0 ? void 0 : _b.stages[stInx + 1].name) != 'Close' || this.isProceedToClose) {
1317
- 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));
1318
- this.handleStageCheck(stageDropdown, stInx + 1, (_d = prevCheckListsData.checklists[clIndex]) === null || _d === void 0 ? void 0 : _d.stages, hostInstance);
1319
- this.selectStage(prevCheckListsData, clIndex, stInx + 1, hostInstance);
1320
- }
1321
- }
1322
- this.updateStepTemplate(prevCheckListsData, hostInstance);
1323
- };
1324
- rootService.prototype.confirmationBtnForPlaybook = function (btn, eachPlaybookStep, hostInstance) {
1325
- 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;
1326
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, eachPlaybookStep, { event: eventName, data: { btn: btn } });
1327
- };
1328
- rootService.prototype.hideDropdownTemplate = function (cls) {
1329
- var sharedowns = document.getElementsByClassName(cls);
1330
- var i;
1331
- for (i = 0; i < sharedowns.length; i++) {
1332
- var openSharedown = sharedowns[i];
1333
- if (openSharedown.classList.contains('show')) {
1334
- openSharedown.classList.remove('show');
1335
- }
1336
- }
1337
- };
1338
- rootService.prototype.prepareFeedbackForSuggestions = function (suggestionType, suggestion, feedbackData) {
1339
- var _a, _b, _c;
1340
- if (feedbackData === void 0) { feedbackData = {}; }
1341
- var renderResponse = {
1342
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK,
1343
- positionId: suggestion.positionId,
1344
- submitForm: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? true : false,
1345
- feedback: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? feedbackData.feedback : '',
1346
- feedbackDetails: ((_a = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedbackDetails) === null || _a === void 0 ? void 0 : _a.length) ? feedbackData.feedbackDetails : [],
1347
- comment: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment) ? feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment : '',
1348
- sourceMsgId: suggestion.sourceMsgId || '',
1349
- query: suggestion.userInput,
1350
- suggestionType: suggestionType,
1351
- subType: suggestion.subType || ''
1352
- };
1353
- if (suggestionType == 'answer') {
1354
- renderResponse.isFromGeneratedSummary = suggestion.isFromGeneratedSummary;
1355
- renderResponse.answerType = suggestion.templateType;
1356
- renderResponse.title = suggestion.title;
1357
- renderResponse.answer = suggestion.sendCopyText || '';
1358
- renderResponse.interactionType = suggestion.intType;
1359
- renderResponse.sources = suggestion.sources;
1360
- if (((_b = suggestion.internalInfo) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1361
- renderResponse.answer += suggestion.internalInfo.join(' ');
1362
- }
1363
- }
1364
- else if (suggestionType == 'article' || suggestionType == 'file') {
1365
- renderResponse.title = suggestion.title;
1366
- renderResponse.answer = suggestion.content || '';
1367
- renderResponse.interactionType = suggestion.intType;
1368
- }
1369
- else if (suggestionType == 'faqs') {
1370
- var answer_1 = '';
1371
- if (Array.isArray(suggestion === null || suggestion === void 0 ? void 0 : suggestion.answer)) {
1372
- (_c = suggestion === null || suggestion === void 0 ? void 0 : suggestion.answer) === null || _c === void 0 ? void 0 : _c.forEach(function (element) {
1373
- answer_1 += element.ans;
1374
- });
1375
- }
1376
- renderResponse.title = suggestion.question;
1377
- renderResponse.answer = answer_1;
1378
- }
1379
- return renderResponse;
1380
- };
1381
- rootService.prototype.prepareFeedbackDataForDialog = function (automation, feedbackData) {
1382
- var _a;
1383
- if (feedbackData === void 0) { feedbackData = {}; }
1384
- var renderResponse = {
1385
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK,
1386
- uuid: automation.uuid,
1387
- dialogName: automation.dialogName,
1388
- positionId: automation.dialogId,
1389
- submitForm: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? true : false,
1390
- feedback: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedback) ? feedbackData.feedback : '',
1391
- feedbackDetails: ((_a = feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.feedbackDetails) === null || _a === void 0 ? void 0 : _a.length) ? feedbackData.feedbackDetails : [],
1392
- comment: (feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment) ? feedbackData === null || feedbackData === void 0 ? void 0 : feedbackData.comment : '',
1393
- sourceMsgId: automation.sourceMsgId || ''
1394
- };
1395
- return renderResponse;
1396
- };
1397
- //Assist and mybot tab starts
1398
- rootService.prototype.makeOverrideEvent = function (hostInstance, flag) {
1399
- if (this.OverRideMode && this.proactiveModeStatus && !this.manualAssistOverrideMode) {
1400
- hostInstance.handleOverrideMode(flag, null);
1401
- }
1402
- };
1403
- rootService.prototype.getTypeOfResponse = function (data) {
1404
- var _a, _b, _c, _d;
1405
- var responseType = '';
1406
- if (!this.isAutomationOnGoing && data.suggestions && ((_a = Object.keys(data.suggestions)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1407
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS;
1408
- }
1409
- else if (!data.sendMenuRequest) {
1410
- if (this.isAutomationOnGoing && ((_b = data.buttons) === null || _b === void 0 ? void 0 : _b.length) > 0 && (this.currentAutomationId && !data.positionId || (data.positionId == this.currentAutomationId))) {
1411
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE;
1412
- }
1413
- else if (!this.isAutomationOnGoing && ((_c = data.buttons) === null || _c === void 0 ? void 0 : _c.length) > 0) {
1414
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK;
1415
- }
1416
- }
1417
- else if (((_d = data === null || data === void 0 ? void 0 : data.buttons) === null || _d === void 0 ? void 0 : _d.length) > 0) {
1418
- responseType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG;
1419
- }
1420
- return responseType;
1421
- };
1422
- rootService.prototype.sendRunClickEvent = function (hostInstance, dialog, intent) {
1423
- var _a;
1424
- if (intent === void 0) { intent = false; }
1425
- this.prepareSendCopyEventForRun(hostInstance, dialog, intent);
1426
- var connectionDetails = Object.assign({}, this.connectionDetails);
1427
- connectionDetails.value = dialog.intentName;
1428
- if (dialog.intentName && intent) {
1429
- connectionDetails.intentName = dialog.intentName;
1430
- }
1431
- connectionDetails.positionId = dialog.positionId;
1432
- connectionDetails.entities = this.entitiesValueArray;
1433
- connectionDetails.childBotId = dialog.childBotId;
1434
- connectionDetails.childBotName = dialog.childBotName;
1435
- connectionDetails.sourceMsgId = dialog.sourceMsgId || '';
1436
- if (dialog.taskRefId) {
1437
- connectionDetails.taskRefId = dialog.taskRefId;
1438
- }
1439
- if (dialog.dialogId) {
1440
- connectionDetails.dialogId = dialog.dialogId;
1441
- }
1442
- if (dialog.userInput) {
1443
- connectionDetails.userInput = dialog.userInput;
1444
- }
1445
- if (dialog.traits && ((_a = dialog.traits) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1446
- connectionDetails.traits = dialog.traits;
1447
- }
1448
- if (dialog.intentName === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.DISCARD_ALL && !intent) {
1449
- connectionDetails.isDiscard = true;
1450
- }
1451
- if (dialog.agentRunButton) {
1452
- connectionDetails.isSearch = false;
1453
- var myBotRequestParams = hostInstance.prepareAgentAssistAgentRequestParams(connectionDetails);
1454
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, myBotRequestParams);
1455
- this.mybotEntitiestValueArray = [];
1456
- }
1457
- else {
1458
- var assistRequestParams = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
1459
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, assistRequestParams);
1460
- this.entitiesValueArray = [];
1461
- }
1462
- };
1463
- rootService.prototype.prepareSendCopyEventForRun = function (hostInstance, dialog, intent) {
1464
- if (intent === void 0) { intent = false; }
1465
- var payloadForBE = Object.assign({}, this.connectionDetails);
1466
- if (dialog.intentName && intent) {
1467
- payloadForBE.intentName = dialog.intentName;
1468
- payloadForBE.title = dialog.intentName;
1469
- }
1470
- payloadForBE.type = 'dialog';
1471
- payloadForBE.input = dialog.userInput;
1472
- payloadForBE.sessionId = (dialog.suggestionFrom === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) ? this.assistTabSessionId : this.myBotTabSessionId;
1473
- payloadForBE = this.addSourceMsgIdToRequestParams(dialog, payloadForBE);
1474
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, payloadForBE);
1475
- };
1476
- rootService.prototype.matchDialogIdfromMenuResponse = function (dialog) {
1477
- var _a, _b;
1478
- var taskRefId = dialog.taskRefId;
1479
- if (taskRefId && this.menuResponse && ((_a = this.menuResponse) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1480
- var response = (_b = this.menuResponse) === null || _b === void 0 ? void 0 : _b.find(function (obj) { return obj.taskRefId === taskRefId; });
1481
- if (response && response.dialogId) {
1482
- dialog.dialogId = response.dialogId;
1483
- }
1484
- }
1485
- return dialog.dialogId;
1486
- };
1487
- rootService.prototype.handleDialogClickEvents = function (menuHTML, dialogs, hostInstance) {
1488
- var _this = this;
1489
- dialogs === null || dialogs === void 0 ? void 0 : dialogs.forEach(function (suggestion, index) {
1490
- var _a, _b, _c, _d, _e, _f;
1491
- (_b = (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(_this.classConstants.DIALOG_RUN_BTN).concat(suggestion.positionId), 'click', function (e) {
1492
- suggestion.agentRunButton = false;
1493
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, suggestion);
1494
- }, menuHTML);
1495
- (_d = (_c = hostInstance.eventManager) === null || _c === void 0 ? void 0 : _c.addEventListener) === null || _d === void 0 ? void 0 : _d.call(_c, "".concat(_this.classConstants.DIALOG_AGENT_RUN_BTN).concat(suggestion.positionId), 'click', function (e) {
1496
- suggestion.agentRunButton = true;
1497
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.INTERNAL_EVENTS.RUN_CLICK_EVENT, suggestion);
1498
- }, menuHTML);
1499
- (_f = (_e = hostInstance.eventManager) === null || _e === void 0 ? void 0 : _e.addEventListener) === null || _f === void 0 ? void 0 : _f.call(_e, "".concat(_this.classConstants.DIALOG_AGENT_RUN_ELIPSE_BTN).concat(suggestion.positionId), 'click', function (e) {
1500
- var _a;
1501
- (_a = menuHTML === null || menuHTML === void 0 ? void 0 : menuHTML.querySelector("".concat(_this.classConstants.DIALOG_AGENT_RUN_WRAPPER).concat(suggestion.positionId))) === null || _a === void 0 ? void 0 : _a.classList.toggle('show');
1502
- }, menuHTML);
1503
- });
1504
- };
1505
- rootService.prototype.runDialogForAssistOrMybot = function (hostInstance, dialog, runInitent) {
1506
- if (runInitent === void 0) { runInitent = false; }
1507
- if (!runInitent) {
1508
- this.sendRunClickEvent(hostInstance, dialog, true);
1509
- }
1510
- if (dialog.agentRunButton) {
1511
- }
1512
- else {
1513
- this.updateLocalStorageForAssist(hostInstance, dialog, true);
1514
- }
1515
- };
1516
- rootService.prototype.updateLocalStorageForAssist = function (hostInstance, dialog, flag) {
1517
- this.isAutomationOnGoing = flag;
1518
- this.updateAssistDialogTemplate(hostInstance, dialog, flag);
1519
- };
1520
- rootService.prototype.updateAssistDialogTemplate = function (hostInstance, dialog, flag) {
1521
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1522
- var termianteBtn = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ASSIST_TERMINATE_BUTTON));
1523
- var listviewBtn = (_b = hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelector("".concat(this.classConstants.ASSIST_LISTVIEW_BUTTON));
1524
- 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));
1525
- var assistHeaderDialogName = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.querySelector("".concat(this.classConstants.ASSIST_HEADER_DIALOG_NAME));
1526
- if (flag) {
1527
- (_d = termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.classList) === null || _d === void 0 ? void 0 : _d.remove(this.classConstants.HIDE_ELEMENT);
1528
- (_e = listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.classList) === null || _e === void 0 ? void 0 : _e.remove(this.classConstants.HIDE_ELEMENT);
1529
- (_f = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.classList) === null || _f === void 0 ? void 0 : _f.remove(this.classConstants.HIDE_ELEMENT);
1530
- assistHeaderDialogName.innerText = dialog.intentName;
1531
- }
1532
- else {
1533
- this.manualAssistOverrideMode = false;
1534
- (_g = termianteBtn === null || termianteBtn === void 0 ? void 0 : termianteBtn.classList) === null || _g === void 0 ? void 0 : _g.add(this.classConstants.HIDE_ELEMENT);
1535
- (_h = listviewBtn === null || listviewBtn === void 0 ? void 0 : listviewBtn.classList) === null || _h === void 0 ? void 0 : _h.add(this.classConstants.HIDE_ELEMENT);
1536
- (_j = assistHeaderDialogWrapper === null || assistHeaderDialogWrapper === void 0 ? void 0 : assistHeaderDialogWrapper.classList) === null || _j === void 0 ? void 0 : _j.add(this.classConstants.HIDE_ELEMENT);
1537
- }
1538
- };
1539
- rootService.prototype.prepareDialogObjForInitDialog = function (data) {
1540
- var initDialogrenderResp = {
1541
- intentName: data.intentName,
1542
- childBotId: data.childBotId,
1543
- childBotName: data.childBotName,
1544
- entities: data.entities || [],
1545
- userInput: data.userInput,
1546
- sourceMsgId: data.sourceMsgId || '',
1547
- positionId: data.positionId,
1548
- traits: data.traits || [],
1549
- dialogId: data.dialogId ? data.dialogId : this.matchDialogIdfromMenuResponse(data),
1550
- suggestionFrom: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST
1551
- };
1552
- return initDialogrenderResp;
1553
- };
1554
- rootService.prototype.prepareSuggestionResponse = function (data, responseId, suggestionIndex) {
1555
- var assistDataNode = {
1556
- data: data,
1557
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SUGGESTIONS,
1558
- uuid: responseId,
1559
- searchResponse: this.formatSearchResponse(data, false, suggestionIndex, _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST)
1560
- };
1561
- return assistDataNode;
1562
- };
1563
- rootService.prototype.prepareAutomationReponse = function (res, responseId) {
1564
- this.currentAutomationId = res.positionId;
1565
- var renderResponse = {
1566
- data: res,
1567
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION,
1568
- uuid: responseId,
1569
- dialogId: res.positionId,
1570
- dialogName: res.intentName,
1571
- sourceMsgId: res.sourceMsgId || "",
1572
- automationNodes: [this.prepareDialogStartNodeResponse(res.positionId)]
1573
- };
1574
- return renderResponse;
1575
- };
1576
- rootService.prototype.prepareAutomationNodeResponse = function (data, responseId) {
1577
- var renderResponse = {
1578
- data: data,
1579
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE,
1580
- uuid: responseId
1581
- };
1582
- return renderResponse;
1583
- };
1584
- rootService.prototype.prepareDialogStartNodeResponse = function (dialogId) {
1585
- var renderResponse = {
1586
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_START,
1587
- uuid: (0,_utils_koregenerateuuid__WEBPACK_IMPORTED_MODULE_6__["default"])(),
1588
- dialogId: dialogId
1589
- };
1590
- return renderResponse;
1591
- };
1592
- rootService.prototype.prepareDialogEndNodeResponse = function (dialogId) {
1593
- var renderResponse = {
1594
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END,
1595
- uuid: (0,_utils_koregenerateuuid__WEBPACK_IMPORTED_MODULE_6__["default"])(),
1596
- dialogId: dialogId
1597
- };
1598
- return renderResponse;
1599
- };
1600
- rootService.prototype.prepareEntityNodeResponse = function (response, dataObj, hostInstance) {
1601
- var _a, _b, _c;
1602
- var templateRender = ((_a = response === null || response === void 0 ? void 0 : response.templateResult) === null || _a === void 0 ? void 0 : _a.parsedPayload) ? true : false;
1603
- dataObj.nodeType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE;
1604
- dataObj.value = (_b = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _b === void 0 ? void 0 : _b.value;
1605
- dataObj.sendData = (_c = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _c === void 0 ? void 0 : _c.value;
1606
- dataObj.entityValue = '';
1607
- console.log("🚀 ~ rootService ~ prepareMsgNodeResponse ~ response.templateResult:", response.templateResult);
1608
- dataObj.template = this.getTemplateHtml(templateRender, response.templateResult, hostInstance);
1609
- console.log("🚀 ~ rootService ~ prepareMsgNodeResponse ~ dataObj.template:", dataObj.template);
1610
- dataObj.templateRender = templateRender;
1611
- return dataObj;
1612
- };
1613
- rootService.prototype.prepareMsgNodeResponse = function (response, dataObj, hostInstance) {
1614
- var _a, _b, _c;
1615
- var templateRender = ((_a = response === null || response === void 0 ? void 0 : response.templateResult) === null || _a === void 0 ? void 0 : _a.parsedPayload) ? true : false;
1616
- dataObj.nodeType = _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE;
1617
- dataObj.value = (_b = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _b === void 0 ? void 0 : _b.value;
1618
- dataObj.sendData = (_c = response === null || response === void 0 ? void 0 : response.buttons[0]) === null || _c === void 0 ? void 0 : _c.value;
1619
- console.log("🚀 ~ rootService ~ prepareMsgNodeResponse ~ response.templateResult:", response.templateResult);
1620
- dataObj.template = this.getTemplateHtml(templateRender, response.templateResult, hostInstance);
1621
- console.log("🚀 ~ rootService ~ prepareMsgNodeResponse ~ dataObj.template:", dataObj.template);
1622
- dataObj.templateRender = templateRender;
1623
- return dataObj;
1624
- };
1625
- rootService.prototype.prepareSmallTalkResponse = function (data, responseId) {
1626
- var renderResponse = {
1627
- data: data,
1628
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.SMALLTALK,
1629
- uuid: responseId
1630
- };
1631
- return renderResponse;
1632
- };
1633
- rootService.prototype.prepareWelcomeMsgResponse = function (data, responseId) {
1634
- var assistDataNode = {
1635
- data: data,
1636
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG,
1637
- uuid: responseId,
1638
- hideOverrideDiv: true,
1639
- toggleOverride: false,
1640
- nodeType: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE
1641
- };
1642
- return assistDataNode;
1643
- };
1644
- rootService.prototype.toggleInterruptDropdown = function (hostInstance) {
1645
- var _a, _b, _c, _d, _e;
1646
- hostInstance.localStorageService.setInterruptDialogList(this.interruptDialogList);
1647
- var interruptDialogWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ASSIST_INTERRUPT_WRAPPER));
1648
- if (((_b = this.interruptDialogList) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1649
- (_c = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _c === void 0 ? void 0 : _c.remove(this.classConstants.HIDE_ELEMENT);
1650
- }
1651
- else {
1652
- (_d = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.classList) === null || _d === void 0 ? void 0 : _d.add(this.classConstants.HIDE_ELEMENT);
1653
- }
1654
- var interruptCountEle = interruptDialogWrapper === null || interruptDialogWrapper === void 0 ? void 0 : interruptDialogWrapper.querySelector("".concat(this.classConstants.ASSIST_INTERRUPT_COUNT));
1655
- if (interruptCountEle) {
1656
- interruptCountEle.innerText = (_e = this.interruptDialogList) === null || _e === void 0 ? void 0 : _e.length;
1657
- }
1658
- };
1659
- // handleEmptyLine(answer : any, quotflag = false, type : string = '') {
1660
- // let eleanswer = '';
1661
- // if (typeof answer === 'string') {
1662
- // eleanswer = (type === 'faq') ? answer.replace(/(\r\n|\n|\r)/gm, "<br>") : answer;
1663
- // eleanswer = this.aaHelpers.convertMDtoHTML(eleanswer, "bot", eleanswer)
1664
- // eleanswer = this.replaceLtGt(eleanswer, quotflag)
1665
- // // if (quotflag) {
1666
- // // eleanswer = this.replaceLtGt(eleanswer, quotflag)
1667
- // // }
1668
- // return eleanswer.replace(new RegExp("(<br />)+$"),'');
1669
- // }
1670
- // return eleanswer;
1671
- // }
1672
- // replaceLtGt(htmlString : any, quotflag : boolean) {
1673
- // let newHtmlStr;
1674
- // newHtmlStr = htmlString.replaceAll("&lt;", "<");
1675
- // newHtmlStr = newHtmlStr.replaceAll("&gt;", ">");
1676
- // if (quotflag) {
1677
- // newHtmlStr = newHtmlStr.replaceAll('"', "&quot;");
1678
- // }
1679
- // return newHtmlStr;
1680
- // }
1681
- // Welocome message logic starts
1682
- rootService.prototype.handleWelcomeMsgResponse = function (welcomeMsgResponse, template, hostInstance) {
1683
- var _this = this;
1684
- welcomeMsgResponse.buttons.forEach(function (message, index) {
1685
- var welcomeMsgObj = _this.createWelcomeMessageObject(message.value, index);
1686
- _this.insertActionTemplate(welcomeMsgObj, index, template, hostInstance);
1687
- });
1688
- };
1689
- rootService.prototype.handleNodeResponse = function (automationNodeObj, template, hostInstance) {
1690
- this.insertActionTemplate(automationNodeObj, null, template, hostInstance);
1691
- };
1692
- rootService.prototype.insertActionTemplate = function (nodeObj, index, template, hostInstance) {
1693
- 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);
1694
- if (eachActionTemplate && (eachActionTemplate === null || eachActionTemplate === void 0 ? void 0 : eachActionTemplate.nodeName) !== '#text') {
1695
- var parentNode = this.getParentNode(template, index);
1696
- if (parentNode) {
1697
- parentNode.insertBefore(eachActionTemplate, parentNode.firstChild);
1698
- this.handleActionTemplateClickEventsForNodes(eachActionTemplate, nodeObj, template, hostInstance);
1699
- }
1700
- }
1701
- };
1702
- rootService.prototype.getParentNode = function (template, index) {
1703
- if (index !== null) {
1704
- return template === null || template === void 0 ? void 0 : template.querySelector("".concat(this.classConstants.WELCOME_MSG_NODE).concat(index));
1705
- }
1706
- return template === null || template === void 0 ? void 0 : template.querySelector(this.classConstants.NODE_BODY);
1707
- };
1708
- rootService.prototype.createWelcomeMessageObject = function (value, index) {
1709
- return {
1710
- sendData: value,
1711
- index: index,
1712
- type: _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG,
1713
- };
1714
- };
1715
- rootService.prototype.handleActionTemplateClickEventsForNodes = function (eachActionTemplate, automationNodeObj, template, hostInstance) {
1716
- var _this = this;
1717
- var _a;
1718
- var sendTextTemplate = (_a = template.querySelector) === null || _a === void 0 ? void 0 : _a.call(template, "".concat(this.classConstants.NODE_SEND_TEXT));
1719
- this.addClickEventListenerForActionNodes(eachActionTemplate, this.classConstants.SUGGESTION_SEND_BTN, function () { return _this.handleSendOrCopyClickEvent(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND, sendTextTemplate, automationNodeObj, hostInstance); }, hostInstance);
1720
- this.addClickEventListenerForActionNodes(eachActionTemplate, this.classConstants.SUGGESTION_COPY_BTN, function () { return _this.handleSendOrCopyClickEvent(_constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.COPY, sendTextTemplate, automationNodeObj, hostInstance); }, hostInstance);
1721
- };
1722
- rootService.prototype.addClickEventListenerForActionNodes = function (template, eventSelector, callback, hostInstance) {
1723
- var _a;
1724
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(eventSelector, 'click', callback, template);
1725
- };
1726
- // Welocome message logic ends
1727
- //Send copy click events handling logic starts
1728
- rootService.prototype.handleSendOrCopyClickEvent = function (type, sendTextTemplate, automationNodeObj, hostInstance) {
1729
- this.toggleSendTextTemplate(sendTextTemplate, type);
1730
- this.handleSendCopyButtonForNodes(type, automationNodeObj.sendData, automationNodeObj, hostInstance);
1731
- automationNodeObj.skipMsg = true;
1732
- if (automationNodeObj.type === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.WELCOME_MSG) {
1733
- this.removeWelcomeMessages(automationNodeObj, hostInstance);
1734
- }
1735
- };
1736
- rootService.prototype.toggleSendTextTemplate = function (sendTextTemplate, type) {
1737
- if (!sendTextTemplate)
1738
- return;
1739
- sendTextTemplate.classList.remove(this.classConstants.HIDE_ELEMENT);
1740
- sendTextTemplate.innerText = type === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? 'Sent' : 'Copied';
1741
- };
1742
- rootService.prototype.removeWelcomeMessages = function (automationNodeObj, hostInstance) {
1743
- var _a;
1744
- 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));
1745
- welcomeMsgNodes === null || welcomeMsgNodes === void 0 ? void 0 : welcomeMsgNodes.forEach(function (node) {
1746
- var _a;
1747
- if (!node.classList.contains("aa-welcome-msg-".concat(automationNodeObj.index))) {
1748
- (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node);
1749
- }
134
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_endoftask, function (data) {
135
+ var settimeoutTime = _this.getTimeout();
136
+ setTimeout(function () {
137
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.END_OF_TASK_RESPONSE, data);
138
+ }, settimeoutTime);
1750
139
  });
1751
- };
1752
- rootService.prototype.handleSendCopyButtonForNodes = function (actionType, sendData, automation, hostInstance) {
1753
- var message = this.createMessagePayload(actionType, sendData);
1754
- console.log("\uD83D\uDE80 ~ agentAssist.".concat(actionType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? 'SendMessage' : 'CopyMessage', " for message nodes"));
1755
- this.messageNodeSendorCopyEvent(actionType, sendData, automation, hostInstance);
1756
- };
1757
- rootService.prototype.createMessagePayload = function (actionType, sendData) {
1758
- return {
1759
- method: actionType === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.SEND ? 'send' : 'copy',
1760
- 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,
1761
- conversationId: this.connectionDetails.conversationId,
1762
- payload: sendData,
1763
- };
1764
- };
1765
- rootService.prototype.messageNodeSendorCopyEvent = function (eventName, payload, automation, hostInstance) {
1766
- var payloadForBE = this.buildBackendPayload(eventName, payload, automation);
1767
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_send_or_copy, payloadForBE);
1768
- };
1769
- rootService.prototype.buildBackendPayload = function (eventName, payload, automation) {
1770
- var _a, _b, _c, _d;
1771
- var basePayload = {
1772
- 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,
1773
- 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,
1774
- conversationId: this.connectionDetails.conversationId,
1775
- payload: payload,
1776
- botId: this.connectionDetails.botId,
1777
- positionId: automation === null || automation === void 0 ? void 0 : automation.dialogId,
1778
- type: 'sentence',
1779
- sessionId: this.getSessionId(),
1780
- skipMsg: ((_a = automation === null || automation === void 0 ? void 0 : automation.data) === null || _a === void 0 ? void 0 : _a.errorMsg) || automation.skipMsg || false,
1781
- };
1782
- 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)) {
1783
- basePayload.componentType = automation.data.componentType;
1784
- }
1785
- else if (!((_d = automation === null || automation === void 0 ? void 0 : automation.data) === null || _d === void 0 ? void 0 : _d.isPrompt)) {
1786
- basePayload.partialMessage = true;
1787
- }
1788
- return this.addSourceMsgIdToRequestParams(automation, basePayload);
1789
- };
1790
- rootService.prototype.getSessionId = function () {
1791
- return this.activeTab === _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT ? this.myBotTabSessionId : this.assistTabSessionId;
1792
- };
1793
- //Send copy click events handling logic ends
1794
- // Feedback logic for suggestions and automations starts
1795
- rootService.prototype.renderFeedbackForEachSuggestion = function (suggestionListTemplate, suggestionList, hostInstance) {
1796
- var _this = this;
1797
- suggestionListTemplate === null || suggestionListTemplate === void 0 ? void 0 : suggestionListTemplate.forEach(function (suggestionTemplate, index) {
1798
- var _a;
1799
- var positionId = (_a = suggestionList[index]) === null || _a === void 0 ? void 0 : _a.positionId;
1800
- var feedbackWrapperTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.FeedbackWrapperInsideDialog, { dialog: { dialogId: positionId } }, hostInstance);
1801
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, feedbackWrapperTemplate, {
1802
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FEEDBACK_WRAPER_TEMPLATE,
1803
- data: { dialog: { dialogId: positionId } }
1804
- });
1805
- suggestionTemplate.append(feedbackWrapperTemplate);
1806
- _this.handleFeedbackType({ dialogId: positionId, feedbackData: suggestionList[index].feedbackData }, suggestionTemplate, hostInstance);
140
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.user_message, function (data) {
141
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.USER_TRANSCRIPT_RESPONSE, data);
1807
142
  });
1808
- };
1809
- rootService.prototype.handleFeedbackType = function (automation, dialogWrapper, hostInstance) {
1810
- var _a, _b;
1811
- var sampleSuggestions = ["Wrong Suggestion", "Accidental Click", "Time Taking", "Confusing", "Not Satisfactory", "Other"];
1812
- var feedbackHelpfulSection = (_a = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _a === void 0 ? void 0 : _a.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_HELPFUL_SECTION).concat(automation.dialogId));
1813
- var feedbackWrapper = (_b = dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.querySelector) === null || _b === void 0 ? void 0 : _b.call(dialogWrapper, "".concat(this.classConstants.FEEDBACK_WRAPPER).concat(automation.dialogId));
1814
- var helpSection = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_feedback_feedback__WEBPACK_IMPORTED_MODULE_8__.HelpfulFeedbackSection, { dialogId: automation.dialogId }, hostInstance);
1815
- var negativeFeedbackSection = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_feedback_feedback__WEBPACK_IMPORTED_MODULE_8__.NegativeFeedbackSection, { suggestionList: sampleSuggestions, dialogId: automation.dialogId }, hostInstance);
1816
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, helpSection, {
1817
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.HELPFUL_FEEDBACK_TEMPLATE,
1818
- data: { dialogId: automation.dialogId }
143
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_message, function (data) {
144
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_TRANSCRIPT_RESPONSE, data);
1819
145
  });
1820
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, negativeFeedbackSection, {
1821
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.NEGATIVE_FEEDBACK_TEMPLATE,
1822
- data: { suggestionList: sampleSuggestions, dialogId: automation.dialogId }
146
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_user_message, function (data) {
147
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_ASSIST_USER_MESSAGE, data);
1823
148
  });
1824
- helpSection && (feedbackHelpfulSection === null || feedbackHelpfulSection === void 0 ? void 0 : feedbackHelpfulSection.append(helpSection));
1825
- negativeFeedbackSection && (feedbackWrapper === null || feedbackWrapper === void 0 ? void 0 : feedbackWrapper.append(negativeFeedbackSection));
1826
- this.handleFeebackClickEvents(helpSection, negativeFeedbackSection, feedbackWrapper, sampleSuggestions, automation, hostInstance);
1827
- };
1828
- // Feedback logic for suggestions and automations ends
1829
- //Feedback click events start
1830
- rootService.prototype.handleFeebackClickEvents = function (helpSection, negativeFeedbackSection, feedbackWrapper, sampleSuggestions, automation, hostInstance) {
1831
- var _this = this;
1832
- // Helper to add event listeners
1833
- var addEvent = function (selector, event, handler, element) {
1834
- var _a;
1835
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener(selector, event, handler, element);
1836
- };
1837
- // Helper to toggle classes
1838
- var toggleClass = function (element, className, action) {
1839
- var _a;
1840
- (_a = element.classList) === null || _a === void 0 ? void 0 : _a[action](className);
1841
- };
1842
- //check active button
1843
- var activeButton = function (btn) {
1844
- var _a;
1845
- return (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains(_this.classConstants.FEEDBACK_ACTIVE_BUTTON);
1846
- };
1847
- // Handle positive feedback
1848
- var handlePositiveFeedback = function () {
1849
- var positiveButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_POSITIVE));
1850
- var negativeButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE));
1851
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
1852
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
1853
- if (!activeButton(positiveButton)) {
1854
- toggleClass(positiveButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'add');
1855
- toggleClass(negativeButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'remove');
1856
- toggleClass(negativeArrowBtn, _this.classConstants.HIDE_ELEMENT, 'add');
1857
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'remove');
1858
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'add');
1859
- _this.prepareAndMakeFeedbackRequest(automation.feedbackData, negativeFeedbackSection, commentBox, helpSection, 'like', hostInstance);
1860
- }
1861
- };
1862
- // Handle negative feedback
1863
- var handleNegativeFeedback = function () {
1864
- var positiveButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_POSITIVE));
1865
- var negativeButton = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE));
1866
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
1867
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
1868
- toggleClass(negativeArrowBtn, _this.classConstants.HIDE_ELEMENT, 'remove');
1869
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'remove');
1870
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'add');
1871
- if (!activeButton(negativeButton)) {
1872
- toggleClass(negativeButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'add');
1873
- toggleClass(positiveButton, _this.classConstants.FEEDBACK_ACTIVE_BUTTON, 'remove');
1874
- _this.prepareAndMakeFeedbackRequest(automation.feedbackData, negativeFeedbackSection, commentBox, helpSection, 'dislike', hostInstance);
1875
- }
1876
- };
1877
- // Handle dropdown toggle
1878
- var handleDropdownToggle = function () {
1879
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
1880
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
1881
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'toggle');
1882
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'toggle');
1883
- };
1884
- // Attach event listeners
1885
- addEvent(this.classConstants.FEEDBACK_POSITIVE, 'click', handlePositiveFeedback, helpSection);
1886
- addEvent(this.classConstants.FEEDBACK_NEGATIVE, 'click', handleNegativeFeedback, helpSection);
1887
- addEvent(this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN, 'click', handleDropdownToggle, helpSection);
1888
- // Handle suggestions click
1889
- sampleSuggestions.forEach(function (suggestion, index) {
1890
- var suggestionClassName = "".concat(_this.classConstants.FEEDBACK_SUGGESTION).concat(automation.dialogId, "-").concat(index);
1891
- var suggestionEle = negativeFeedbackSection.querySelector("".concat(suggestionClassName));
1892
- addEvent(suggestionClassName, 'click', function () {
1893
- toggleClass(suggestionEle, _this.classConstants.FEEDBACK_NEGATIVE_SUGGESTION_SELECTION, 'toggle');
1894
- }, negativeFeedbackSection);
149
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_feedback_response, function (data) {
150
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_FEEDBACK_RESPONSE, data);
1895
151
  });
1896
- // Handle submit feedback
1897
- addEvent(this.classConstants.FEEDBACK_SUBMIT, 'click', function () {
1898
- var feedbackNegativeBox = feedbackWrapper.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_BOX));
1899
- var negativeArrowBtn = helpSection.querySelector("".concat(_this.classConstants.FEEDBACK_NEGATIVE_DROPDOWN_BTN));
1900
- toggleClass(feedbackNegativeBox, _this.classConstants.HIDE_ELEMENT, 'add');
1901
- toggleClass(negativeArrowBtn, _this.classConstants.FEEDBACK_ROTATE_BTN, 'remove');
1902
- _this.prepareAndMakeFeedbackRequest(automation.feedbackData, negativeFeedbackSection, commentBox, helpSection, 'submit', hostInstance);
1903
- }, negativeFeedbackSection);
1904
- // Handle comment box input
1905
- var commentBox = negativeFeedbackSection.querySelector("".concat(this.classConstants.FEEDBACK_COMMENT).concat(automation.dialogId));
1906
- addEvent("".concat(this.classConstants.FEEDBACK_COMMENT).concat(automation.dialogId), 'input', function (e) {
1907
- var _a;
1908
- var commentLength = ((_a = commentBox === null || commentBox === void 0 ? void 0 : commentBox.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
1909
- negativeFeedbackSection.querySelector("".concat(_this.classConstants.FEEDBACK_COMMENT_COUNT)).innerText = "".concat(commentLength, "/150");
1910
- }, negativeFeedbackSection);
1911
- };
1912
- rootService.prototype.prepareAndMakeFeedbackRequest = function (feedbackData, negativeFeedbackSection, commentBox, helpSection, type, hostInstance) {
1913
- var _a;
1914
- var _b = this.connectionDetails, botId = _b.botId, conversationId = _b.conversationId, channel = _b.channel;
1915
- var feedbackList = [];
1916
- var activeSuggestionBtnList = negativeFeedbackSection.querySelectorAll(".".concat(this.classConstants.FEEDBACK_NEGATIVE_SUGGESTION_SELECTION));
1917
- activeSuggestionBtnList.forEach(function (suggestionEle) {
1918
- var inputElement = suggestionEle;
1919
- if (inputElement === null || inputElement === void 0 ? void 0 : inputElement.value)
1920
- feedbackList.push(inputElement.value);
152
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.response_resolution_comments, function (data) {
153
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.RESOLUTION_COMMENTS_RESPONSE, data);
1921
154
  });
1922
- 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;
1923
- var feedbackDetails = {
1924
- botId: botId,
1925
- conversationId: conversationId,
1926
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback,
1927
- positionId: feedbackData.positionId,
1928
- experience: channel,
1929
- feedback: activeFeedback || null,
1930
- feedbackDetails: feedbackList,
1931
- comment: (commentBox === null || commentBox === void 0 ? void 0 : commentBox.value) || '',
1932
- };
1933
- if (feedbackData.suggestionType) {
1934
- 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;
1935
- Object.assign(feedbackDetails, {
1936
- sourceMsgId: sourceMsgId,
1937
- type: suggestionType,
1938
- query: query,
1939
- subType: subType,
1940
- title: title,
1941
- answer: answer,
1942
- interactionType: interactionType
1943
- });
1944
- if (suggestionType === 'answer') {
1945
- Object.assign(feedbackDetails, {
1946
- sources: sources,
1947
- isFromGeneratedSummary: isFromGeneratedSummary,
1948
- answerType: answerType
1949
- });
1950
- }
1951
- }
1952
- else {
1953
- feedbackDetails.taskId = feedbackData.uuid;
1954
- feedbackDetails.taskName = feedbackData.dialogName;
1955
- feedbackDetails.type = 'dialog';
1956
- feedbackDetails.interactionType = this.activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST ? 'assist' : 'mybot';
1957
- }
1958
- this.isUpdateFeedBackDetailsFlag = type != 'dislike' ? true : false;
1959
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_usage_feedback, feedbackDetails);
1960
- };
1961
- //Feedback click events end
1962
- //smalltalk template code starts
1963
- rootService.prototype.addSmallTalkTemplate = function (smallTalkObj, activeTab, hostInstance) {
1964
- var _a;
1965
- var assistWrapper = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector("".concat(this.classConstants.ASSIST_SECTION));
1966
- var template = this.getSmallTalkTemplate(smallTalkObj, activeTab, hostInstance);
1967
- if (template && assistWrapper) {
1968
- assistWrapper.append(template);
1969
- }
1970
- };
1971
- ;
1972
- rootService.prototype.getSmallTalkTemplate = function (smallTalkObj, activeTab, hostInstance) {
1973
- var template = null;
1974
- switch (smallTalkObj.nodeType) {
1975
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE:
1976
- var manualMode = this.manualAssistOverrideMode || !this.proactiveModeStatus;
1977
- var payload = { entityNode: smallTalkObj, activeTab: activeTab, manualMode: manualMode };
1978
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.AskCustomer, payload, hostInstance);
1979
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
1980
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ASK_CUSTOMER_TEMPLATE,
1981
- data: payload
1982
- });
1983
- this.appendTemplate(template, smallTalkObj);
1984
- this.handleNodeResponse(smallTalkObj, template, hostInstance);
1985
- this.handleEntityNodeClickEvents(template, smallTalkObj, hostInstance);
1986
- break;
1987
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE:
1988
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.TellCustomer, { msgNode: smallTalkObj }, hostInstance);
1989
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
1990
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.TELL_CUSTOMER_TEMPLATE,
1991
- data: smallTalkObj
1992
- });
1993
- this.appendTemplate(template, smallTalkObj);
1994
- this.handleNodeResponse(smallTalkObj, template, hostInstance);
1995
- break;
1996
- }
1997
- return template;
1998
- };
1999
- ;
2000
- //smallTalk template code ends
2001
- // Automation template code starts
2002
- rootService.prototype.addDialogTemplate = function (automationNodeObj, automation, activeTab, hostInstance) {
2003
- var dialogWrapper = this.getDialogWrapper(hostInstance, automation.dialogId);
2004
- var template = null;
2005
- switch (automationNodeObj.type) {
2006
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_START:
2007
- template = this.getAutomationStartTemplate(automation, hostInstance);
2008
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2009
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.DIALOG_START_TEMPLATE,
2010
- data: automation
2011
- });
2012
- break;
2013
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END:
2014
- this.appendFeedbackWrapper(dialogWrapper, automation, hostInstance);
2015
- template = this.getAutomationEndTemplate(automation, hostInstance);
2016
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2017
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.DIALOG_END_TEMPLATE,
2018
- data: automation
2019
- });
2020
- break;
2021
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_NODE:
2022
- template = this.getAutomationNodeTemplate(automation, automationNodeObj, activeTab, hostInstance);
2023
- break;
2024
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.FEEDBACK:
2025
- automation.feedbackData = automationNodeObj;
2026
- this.handleFeedbackType(automation, dialogWrapper, hostInstance);
2027
- return;
2028
- default:
2029
- return;
2030
- }
2031
- this.appendAutomationEachNodeTemplate(dialogWrapper, template, automationNodeObj, automation.dialogId);
2032
- };
2033
- rootService.prototype.getDialogWrapper = function (hostInstance, dialogId) {
2034
- var _a, _b;
2035
- 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));
2036
- };
2037
- rootService.prototype.getAutomationStartTemplate = function (automation, hostInstance) {
2038
- return (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.DialogStart, { dialog: automation }, hostInstance);
2039
- };
2040
- rootService.prototype.getAutomationEndTemplate = function (automation, hostInstance) {
2041
- return (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.DialogEnd, { dialog: automation }, hostInstance);
2042
- };
2043
- rootService.prototype.appendFeedbackWrapper = function (dialogWrapper, automation, hostInstance) {
2044
- var feedbackWrapperTemplate = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.FeedbackWrapperInsideDialog, { dialog: automation }, hostInstance);
2045
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, feedbackWrapperTemplate, {
2046
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.FEEDBACK_WRAPER_TEMPLATE,
2047
- data: automation
155
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agentassist_control_response, function (data) {
2048
156
  });
2049
- dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.append(feedbackWrapperTemplate);
2050
157
  };
2051
- rootService.prototype.getAutomationNodeTemplate = function (automation, automationNodeObj, activeTab, hostInstance) {
2052
- var template = null;
2053
- switch (automationNodeObj.nodeType) {
2054
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.ENTITY_NODE:
2055
- var manualMode = this.manualAssistOverrideMode || !this.proactiveModeStatus;
2056
- var payload = { entityNode: automationNodeObj, activeTab: activeTab, manualMode: manualMode };
2057
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.AskCustomer, payload, hostInstance);
2058
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2059
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.ASK_CUSTOMER_TEMPLATE,
2060
- data: payload
2061
- });
2062
- this.appendTemplate(template, automationNodeObj);
2063
- this.handleNodeResponse(automationNodeObj, template, hostInstance);
2064
- this.handleEntityNodeClickEvents(template, automationNodeObj, hostInstance);
2065
- break;
2066
- case _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.MSG_NODE:
2067
- template = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_templatemanager_tabs_automation_automation__WEBPACK_IMPORTED_MODULE_7__.TellCustomer, { msgNode: automationNodeObj }, hostInstance);
2068
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.BEFORE_VIEW_INIT, template, {
2069
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.SDK_EVENTS.TELL_CUSTOMER_TEMPLATE,
2070
- data: automationNodeObj
2071
- });
2072
- this.appendTemplate(template, automationNodeObj);
2073
- this.handleNodeResponse(automationNodeObj, template, hostInstance);
2074
- break;
2075
- }
2076
- return template;
2077
- };
2078
- rootService.prototype.handleErrorPrompts = function (automation, automationNodeObj, hostInstance) {
2079
- var _this = this;
2080
- var _a, _b, _c, _d;
2081
- var prevEnityNode = null;
2082
- 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--) {
2083
- 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;
2084
- if (prevEnityNode) {
2085
- break;
2086
- }
2087
- }
2088
- if (prevEnityNode) {
2089
- 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));
2090
- lastAutomationNodes.forEach(function (lastAutomationEle) {
2091
- var _a, _b, _c, _d, _e;
2092
- var entityBody = lastAutomationEle === null || lastAutomationEle === void 0 ? void 0 : lastAutomationEle.querySelector("".concat(_this.classConstants.ENTITY_MSG_BODY));
2093
- 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)) {
2094
- automationNodeObj.errorCount = (prevEnityNode.errorCount || 0) + 1;
2095
- entityBody === null || entityBody === void 0 ? void 0 : entityBody.remove();
2096
- }
2097
- else {
2098
- // remove error count from dialog
2099
- 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));
2100
- var errorMsgs = automationEle === null || automationEle === void 0 ? void 0 : automationEle.querySelectorAll(".wrong-res-info");
2101
- errorMsgs === null || errorMsgs === void 0 ? void 0 : errorMsgs.forEach(function (ele) {
2102
- ele.remove();
2103
- });
2104
- // remove error count from listview
2105
- 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));
2106
- var listViewErrorMsgs = listView === null || listView === void 0 ? void 0 : listView.querySelectorAll(".wrong-res-info");
2107
- listViewErrorMsgs === null || listViewErrorMsgs === void 0 ? void 0 : listViewErrorMsgs.forEach(function (ele) {
2108
- ele.remove();
2109
- });
2110
- (_e = entityBody === null || entityBody === void 0 ? void 0 : entityBody.classList) === null || _e === void 0 ? void 0 : _e.remove('error-no-reponse');
2111
- }
2112
- });
2113
- // let lastAutomationEle = hostInstance?.chatEle?.querySelector(`${this.classConstants.ASK_CUST_NODE}${prevEnityNode.uuid}`);
2114
- }
2115
- };
2116
- rootService.prototype.appendAutomationEachNodeTemplate = function (dialogWrapper, template, automationNodeObj, dialogId) {
2117
- var _a, _b;
2118
- 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));
2119
- 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));
2120
- if (template && automationNodeObj.type !== _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.RenderResponseType.AUTOMATION_END) {
2121
- dialogWrapper === null || dialogWrapper === void 0 ? void 0 : dialogWrapper.append(template);
2122
- }
2123
- else if (template) {
2124
- feedbackHelpfulSection === null || feedbackHelpfulSection === void 0 ? void 0 : feedbackHelpfulSection.append(template);
2125
- }
2126
- };
2127
- // Automation template code ends
2128
- //Entity node click events starts
2129
- rootService.prototype.handleEntityNodeClickEvents = function (askCustTemplate, automationNodeObj, hostInstance) {
2130
- var _this = this;
2131
- var _a, _b, _c, _d, _e;
2132
- var inputEle = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_INPUT));
2133
- var overrideBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_OVERRIDE_BTN));
2134
- var removeBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_REMOVE_BTN));
2135
- var checkBtn = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_CHECK_BTN));
2136
- var agentIcon = askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_AGENT_ICON));
2137
- var errorTemplate = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ERROR_OVERRIDE_TEXT));
2138
- if ((!this.proactiveModeStatus || this.manualAssistOverrideMode)) {
2139
- inputEle.readOnly = false;
2140
- inputEle.focus();
2141
- }
2142
- var onOverrideClick = function (e) { return _this.handleOverrideClick(e, errorTemplate, inputEle, removeBtn, checkBtn, automationNodeObj, hostInstance); };
2143
- var onRemoveClick = function (e) { return _this.handleRemoveClick(e, errorTemplate, inputEle, overrideBtn, removeBtn, checkBtn); };
2144
- var onCheckClick = function (e) { return _this.handleCheckClick(e, inputEle, automationNodeObj, hostInstance, askCustTemplate); };
2145
- var onInputKeydown = function (e) { return _this.handleInputKeydown(e, inputEle, automationNodeObj, hostInstance, askCustTemplate); };
2146
- var onInputChange = function (e) { return _this.handleInputChange(e, inputEle, checkBtn); };
2147
- (_a = hostInstance.eventManager) === null || _a === void 0 ? void 0 : _a.addEventListener("".concat(this.classConstants.ENTITY_OVERRIDE_BTN), 'click', onOverrideClick, askCustTemplate);
2148
- (_b = hostInstance.eventManager) === null || _b === void 0 ? void 0 : _b.addEventListener("".concat(this.classConstants.ENTITY_REMOVE_BTN), 'click', onRemoveClick, askCustTemplate);
2149
- (_c = hostInstance.eventManager) === null || _c === void 0 ? void 0 : _c.addEventListener("".concat(this.classConstants.ENTITY_CHECK_BTN), 'click', onCheckClick, askCustTemplate);
2150
- (_d = hostInstance.eventManager) === null || _d === void 0 ? void 0 : _d.addEventListener("".concat(this.classConstants.ENTITY_INPUT), 'keydown', onInputKeydown, askCustTemplate);
2151
- (_e = hostInstance.eventManager) === null || _e === void 0 ? void 0 : _e.addEventListener("".concat(this.classConstants.ENTITY_INPUT), 'input', onInputChange, askCustTemplate);
2152
- };
2153
- rootService.prototype.handleOverrideClick = function (e, errorTemplate, inputEle, removeBtn, checkBtn, automationNodeObj, hostInstance) {
2154
- var _a, _b;
2155
- inputEle.readOnly = false;
2156
- inputEle.placeholder = '';
2157
- inputEle.focus();
2158
- (_a = removeBtn === null || removeBtn === void 0 ? void 0 : removeBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
2159
- (_b = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _b === void 0 ? void 0 : _b.remove(this.classConstants.HIDE_ELEMENT);
2160
- if (!this.OverRideMode) {
2161
- hostInstance.handleOverrideMode(true, automationNodeObj.dialogId);
2162
- }
2163
- errorTemplate.innerText = '| Type to override';
2164
- };
2165
- rootService.prototype.handleRemoveClick = function (e, errorTemplate, inputEle, overrideBtn, removeBtn, checkBtn) {
2166
- var _a, _b, _c;
2167
- inputEle.readOnly = true;
2168
- (_a = overrideBtn === null || overrideBtn === void 0 ? void 0 : overrideBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.HIDE_ELEMENT);
2169
- (_b = removeBtn === null || removeBtn === void 0 ? void 0 : removeBtn.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.HIDE_ELEMENT);
2170
- (_c = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _c === void 0 ? void 0 : _c.add(this.classConstants.HIDE_ELEMENT);
2171
- inputEle.placeholder = 'waiting...';
2172
- inputEle.value = '';
2173
- errorTemplate.innerText = '';
2174
- };
2175
- rootService.prototype.handleCheckClick = function (e, inputEle, automationNodeObj, hostInstance, askCustTemplate) {
2176
- if (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value) {
2177
- this.assistInputValue(inputEle.value, automationNodeObj, hostInstance);
2178
- this.showAgentIcon(automationNodeObj, hostInstance);
2179
- }
2180
- };
2181
- rootService.prototype.handleInputKeydown = function (e, inputEle, automationNodeObj, hostInstance, askCustTemplate) {
2182
- if (e.key === 'Enter' && (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value)) {
2183
- this.assistInputValue(inputEle.value, automationNodeObj, hostInstance);
2184
- this.showAgentIcon(automationNodeObj, hostInstance);
2185
- }
2186
- };
2187
- rootService.prototype.handleInputChange = function (e, inputEle, checkBtn) {
2188
- var _a, _b;
2189
- if (inputEle === null || inputEle === void 0 ? void 0 : inputEle.value) {
2190
- (_a = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _a === void 0 ? void 0 : _a.remove(this.classConstants.AGENTASSIST_DISABLED_MSG);
158
+ websocketservice.prototype.getTimeout = function () {
159
+ var timestamp1 = Date.now();
160
+ var settimeoutTime = this.intervalTime;
161
+ if ((timestamp1 - this.prevTimeStamp) < this.intervalTime) {
162
+ settimeoutTime = (settimeoutTime * this.count) + (this.intervalTime - (timestamp1 - this.prevTimeStamp));
163
+ this.count += 1;
2191
164
  }
2192
165
  else {
2193
- (_b = checkBtn === null || checkBtn === void 0 ? void 0 : checkBtn.classList) === null || _b === void 0 ? void 0 : _b.add(this.classConstants.AGENTASSIST_DISABLED_MSG);
2194
- }
2195
- };
2196
- rootService.prototype.assistInputValue = function (inputValue, automationNodeObj, hostInstance) {
2197
- var connectionDetails = Object.assign({}, this.connectionDetails);
2198
- connectionDetails.value = inputValue;
2199
- connectionDetails.positionId = automationNodeObj.dialogId;
2200
- connectionDetails.childBotId = automationNodeObj.data.childBotId;
2201
- connectionDetails.childBotName = automationNodeObj.data.childBotName;
2202
- connectionDetails.sourceMsgId = automationNodeObj.sourceMsgId || '';
2203
- // if(automationNodeObj?.data?.entityType === 'attachment' && rootServiceInstance.activeTab !== ProjConstants.MYBOT) {
2204
- // connectionDetails.attachments = [
2205
- // {
2206
- // "fileName": this.fileObj?.fileName || '',
2207
- // "fileType": this.fileObj?.fileType,
2208
- // "fileId": this.fileObj.fileId || '',
2209
- // "url": {
2210
- // "fileUrl": this.fileObj.fileURL || ''
2211
- // }
2212
- // }
2213
- // ]
2214
- // }
2215
- var assistRequestParams = hostInstance.prepareAgentAssistRequestParams(connectionDetails);
2216
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, assistRequestParams);
2217
- };
2218
- rootService.prototype.handleEntityInput = function (node, hostInstance, disabled) {
2219
- var _this = this;
2220
- var _a;
2221
- if (disabled === void 0) { disabled = false; }
2222
- var entityNodes = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
2223
- entityNodes.forEach(function (askCustTemplate) {
2224
- var _a, _b, _c;
2225
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ACTIONS));
2226
- (_a = actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
2227
- var _a, _b, _c;
2228
- var agentIconBtn = (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains("aa-entity-agent-icon");
2229
- var errorBtn = (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.contains("aa-entity-error-btn");
2230
- if (btn && !agentIconBtn && (!errorBtn || disabled)) {
2231
- (_c = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
2232
- }
2233
- });
2234
- (_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);
2235
- });
2236
- };
2237
- rootService.prototype.showAgentIcon = function (node, hostInstance) {
2238
- var _this = this;
2239
- var _a;
2240
- var entityNodes = (_a = hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
2241
- entityNodes.forEach(function (askCustTemplate) {
2242
- var _a, _b, _c;
2243
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(_this.classConstants.ENTITY_ACTIONS));
2244
- (_a = actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
2245
- var _a, _b, _c;
2246
- var agentIconPresent = (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.contains("aa-entity-agent-icon");
2247
- if (btn && agentIconPresent) {
2248
- (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.remove(_this.classConstants.HIDE_ELEMENT);
2249
- }
2250
- else if (btn) {
2251
- (_c = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _c === void 0 ? void 0 : _c.add(_this.classConstants.HIDE_ELEMENT);
2252
- }
2253
- });
2254
- (_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);
2255
- });
2256
- };
2257
- rootService.prototype.showEntityNodeInputButtons = function (askCustTemplate) {
2258
- var _this = this;
2259
- var _a;
2260
- var actionButtons = askCustTemplate === null || askCustTemplate === void 0 ? void 0 : askCustTemplate.querySelector("".concat(this.classConstants.ENTITY_ACTIONS));
2261
- (_a = actionButtons.childNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (btn) {
2262
- var _a, _b;
2263
- if (btn === null || btn === void 0 ? void 0 : btn.classList.contains('aa-entity-override-btn')) {
2264
- (_a = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _a === void 0 ? void 0 : _a.remove(_this.classConstants.HIDE_ELEMENT);
2265
- }
2266
- else {
2267
- (_b = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _b === void 0 ? void 0 : _b.add(_this.classConstants.HIDE_ELEMENT);
2268
- }
2269
- });
2270
- };
2271
- //Entity node click events ends
2272
- //Process UserMessages for smalltalk and automation starts
2273
- rootService.prototype.processUserMessages = function (userResponse, lastObj, getNode, hostInstance) {
2274
- var _this = this;
2275
- var _a, _b;
2276
- var node = getNode(lastObj);
2277
- if ((_a = node === null || node === void 0 ? void 0 : node.data) === null || _a === void 0 ? void 0 : _a.isPrompt) {
2278
- node.entityValue = (userResponse === null || userResponse === void 0 ? void 0 : userResponse.entityValue) || userResponse.userInput;
2279
- var entityNodes = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _b === void 0 ? void 0 : _b.querySelectorAll("".concat(this.classConstants.ASK_CUST_NODE).concat(node.uuid));
2280
- entityNodes.forEach(function (askCustNode) {
2281
- var inputEle = askCustNode === null || askCustNode === void 0 ? void 0 : askCustNode.querySelector("".concat(_this.classConstants.ENTITY_INPUT));
2282
- if (inputEle) {
2283
- inputEle.value = node.entityValue;
2284
- }
2285
- });
2286
- this.handleEntityInput(node, hostInstance);
166
+ this.count = 1;
2287
167
  }
2288
- return lastObj;
168
+ this.prevTimeStamp = timestamp1;
169
+ return settimeoutTime;
2289
170
  };
2290
- ;
2291
- rootService.prototype.processUserMessagesForSmallTalk = function (userResponse, lastObj, hostInstance) {
2292
- return this.processUserMessages(userResponse, lastObj, function (lastObj) { return lastObj; }, hostInstance);
2293
- };
2294
- ;
2295
- rootService.prototype.processUserMessagesForAutomation = function (userResponse, lastObj, hostInstance) {
2296
- return this.processUserMessages(userResponse, lastObj, 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);
2297
- };
2298
- ;
2299
- //Process UserMessages for smalltalk and automation ends
2300
- rootService.prototype.getTemplateHtml = function (isTemplateRender, result, hostInstance) {
2301
- var _a;
2302
- var renderedMessage;
2303
- if (isTemplateRender) {
2304
- renderedMessage = (_a = hostInstance.chatWindowInstance) === null || _a === void 0 ? void 0 : _a.generateMessageDOM(result);
171
+ websocketservice.prototype.disconnect = function () {
172
+ if (this._agentAssistSocket && this._agentAssistSocket.connected) {
173
+ this.hostIns.rootService.socketConnect = false;
174
+ this._agentAssistSocket.disconnect();
175
+ this._agentAssistSocket.off();
2305
176
  }
2306
- return renderedMessage;
2307
177
  };
2308
- rootService.prototype.handleTemplateClickEvents = function (value, activeTab, positionId, hostInstance) {
2309
- var connectionObj = this.connectionDetails;
2310
- var requestParams = {
2311
- "conversationId": connectionObj.conversationId,
2312
- "query": value,
2313
- "botId": connectionObj.botId,
2314
- "experience": connectionObj === null || connectionObj === void 0 ? void 0 : connectionObj.channel,
2315
- "autoBotId": connectionObj.autoBotId,
2316
- "positionId": positionId
2317
- };
2318
- if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.ASSIST) {
2319
- requestParams.entities = [];
2320
- requestParams.check = true;
2321
- requestParams.intType = "assist";
2322
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_request, requestParams);
2323
- // this.rootService.setAssistTemplateClick(true);
2324
- }
2325
- else if (activeTab == _constants_projConsts__WEBPACK_IMPORTED_MODULE_1__.ProjConstants.MYBOT) {
2326
- requestParams.isSearch = false;
2327
- requestParams.intType = "myBot";
2328
- hostInstance.socketConnection.emitEvents(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_0__.EVENTS.agent_assist_agent_request, requestParams);
2329
- // this.rootService.setMyBotTemplateClick(true);
2330
- }
2331
- };
2332
- rootService.prototype.closeListView = function (hostInstance) {
2333
- var _a, _b, _c, _d, _e, _f;
2334
- (_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);
2335
- (_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) {
2336
- ele.remove();
2337
- });
2338
- };
2339
- return rootService;
178
+ return websocketservice;
2340
179
  }());
2341
-
2342
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rootService);
180
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (websocketservice);
2343
181
 
2344
182
 
2345
183
  /***/ })
@@ -2348,7 +186,7 @@ var rootService = /** @class */ (function () {
2348
186
  /******/ function(__webpack_require__) { // webpackRuntimeModules
2349
187
  /******/ /* webpack/runtime/getFullHash */
2350
188
  /******/ (() => {
2351
- /******/ __webpack_require__.h = () => ("a044dd2ffe4349402170")
189
+ /******/ __webpack_require__.h = () => ("9e6860066b06c8c263f3")
2352
190
  /******/ })();
2353
191
  /******/
2354
192
  /******/ }