@carbon/ai-chat 0.1.6 → 0.1.7-alpha0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/cjs/{cds-aichat-internal.js → AppContainer.js} +615 -7203
  2. package/dist/cjs/Carousel.js +24 -16
  3. package/dist/cjs/Chat.js +813 -805
  4. package/dist/cjs/GenesysMessengerServiceDesk.js +60 -52
  5. package/dist/cjs/HumanAgentServiceImpl.js +103 -95
  6. package/dist/cjs/NiceDFOServiceDesk.js +56 -48
  7. package/dist/cjs/PDFViewerContainer.js +58 -149
  8. package/dist/cjs/ReactPlayer.js +2 -2
  9. package/dist/cjs/SFServiceDesk.js +66 -58
  10. package/dist/cjs/ServiceDeskImpl.js +2 -2
  11. package/dist/cjs/Table.js +457 -341
  12. package/dist/cjs/ZendeskServiceDesk.js +36 -28
  13. package/dist/cjs/_node-resolve_empty.js +2 -2
  14. package/dist/cjs/agentActions.js +5 -5
  15. package/dist/cjs/aiChatEntry.js +163 -144
  16. package/dist/cjs/anonymousUserIDStorage.js +8 -8
  17. package/dist/cjs/ar-dz.js +4 -4
  18. package/dist/cjs/ar-kw.js +4 -4
  19. package/dist/cjs/ar-ly.js +4 -4
  20. package/dist/cjs/ar-ma.js +4 -4
  21. package/dist/cjs/ar-sa.js +4 -4
  22. package/dist/cjs/ar-tn.js +4 -4
  23. package/dist/cjs/ar.js +4 -4
  24. package/dist/cjs/ar2.js +2 -2
  25. package/dist/cjs/cds-aichat-container.js +111 -23
  26. package/dist/cjs/cds-aichat-custom-element.js +42 -30
  27. package/dist/cjs/cs.js +4 -4
  28. package/dist/cjs/cs2.js +2 -2
  29. package/dist/cjs/de-at.js +4 -4
  30. package/dist/cjs/de-ch.js +4 -4
  31. package/dist/cjs/de.js +4 -4
  32. package/dist/cjs/de2.js +2 -2
  33. package/dist/cjs/en-au.js +4 -4
  34. package/dist/cjs/en-ca.js +4 -4
  35. package/dist/cjs/en-gb.js +4 -4
  36. package/dist/cjs/en-ie.js +4 -4
  37. package/dist/cjs/en-il.js +4 -4
  38. package/dist/cjs/en-nz.js +4 -4
  39. package/dist/cjs/es-do.js +4 -4
  40. package/dist/cjs/es-us.js +4 -4
  41. package/dist/cjs/es.js +4 -4
  42. package/dist/cjs/es2.js +2 -2
  43. package/dist/cjs/export.js +3 -3
  44. package/dist/cjs/export.legacy.js +3 -3
  45. package/dist/cjs/fontUtils.js +2 -2
  46. package/dist/cjs/fr-ca.js +4 -4
  47. package/dist/cjs/fr-ch.js +4 -4
  48. package/dist/cjs/fr.js +4 -4
  49. package/dist/cjs/fr2.js +2 -2
  50. package/dist/cjs/highlight_js.js +2 -2
  51. package/dist/cjs/it-ch.js +4 -4
  52. package/dist/cjs/it.js +4 -4
  53. package/dist/cjs/it2.js +2 -2
  54. package/dist/cjs/ja.js +4 -4
  55. package/dist/cjs/ja2.js +2 -2
  56. package/dist/cjs/ko.js +4 -4
  57. package/dist/cjs/ko2.js +2 -2
  58. package/dist/cjs/markdown.js +2362 -14
  59. package/dist/cjs/mockServiceDesk.js +42 -34
  60. package/dist/cjs/nl.js +4 -4
  61. package/dist/cjs/nl2.js +2 -2
  62. package/dist/cjs/pt-br.js +4 -4
  63. package/dist/cjs/pt-br2.js +2 -2
  64. package/dist/cjs/pt.js +4 -4
  65. package/dist/cjs/render.js +18 -10
  66. package/dist/cjs/zh-cn.js +4 -4
  67. package/dist/cjs/zh-tw.js +4 -4
  68. package/dist/cjs/zh-tw2.js +2 -2
  69. package/dist/cjs/zh.js +2 -2
  70. package/dist/es/{cds-aichat-internal.js → AppContainer.js} +1117 -7671
  71. package/dist/es/Carousel.js +16 -8
  72. package/dist/es/Chat.js +16 -8
  73. package/dist/es/GenesysMessengerServiceDesk.js +16 -8
  74. package/dist/es/HumanAgentServiceImpl.js +16 -8
  75. package/dist/es/NiceDFOServiceDesk.js +16 -8
  76. package/dist/es/PDFViewerContainer.js +16 -107
  77. package/dist/es/ReactPlayer.js +2 -2
  78. package/dist/es/SFServiceDesk.js +16 -8
  79. package/dist/es/ServiceDeskImpl.js +2 -2
  80. package/dist/es/Table.js +426 -310
  81. package/dist/es/ZendeskServiceDesk.js +16 -8
  82. package/dist/es/_node-resolve_empty.js +2 -2
  83. package/dist/es/agentActions.js +3 -3
  84. package/dist/es/aiChatEntry.js +136 -117
  85. package/dist/es/anonymousUserIDStorage.js +3 -3
  86. package/dist/es/ar-dz.js +3 -3
  87. package/dist/es/ar-kw.js +3 -3
  88. package/dist/es/ar-ly.js +3 -3
  89. package/dist/es/ar-ma.js +3 -3
  90. package/dist/es/ar-sa.js +3 -3
  91. package/dist/es/ar-tn.js +3 -3
  92. package/dist/es/ar.js +3 -3
  93. package/dist/es/ar2.js +2 -2
  94. package/dist/es/cds-aichat-container.js +103 -15
  95. package/dist/es/cds-aichat-custom-element.js +30 -18
  96. package/dist/es/cs.js +3 -3
  97. package/dist/es/cs2.js +2 -2
  98. package/dist/es/de-at.js +3 -3
  99. package/dist/es/de-ch.js +3 -3
  100. package/dist/es/de.js +3 -3
  101. package/dist/es/de2.js +2 -2
  102. package/dist/es/en-au.js +3 -3
  103. package/dist/es/en-ca.js +3 -3
  104. package/dist/es/en-gb.js +3 -3
  105. package/dist/es/en-ie.js +3 -3
  106. package/dist/es/en-il.js +3 -3
  107. package/dist/es/en-nz.js +3 -3
  108. package/dist/es/es-do.js +3 -3
  109. package/dist/es/es-us.js +3 -3
  110. package/dist/es/es.js +3 -3
  111. package/dist/es/es2.js +2 -2
  112. package/dist/es/export.js +3 -3
  113. package/dist/es/export.legacy.js +3 -3
  114. package/dist/es/fontUtils.js +2 -2
  115. package/dist/es/fr-ca.js +3 -3
  116. package/dist/es/fr-ch.js +3 -3
  117. package/dist/es/fr.js +3 -3
  118. package/dist/es/fr2.js +2 -2
  119. package/dist/es/highlight_js.js +2 -2
  120. package/dist/es/it-ch.js +3 -3
  121. package/dist/es/it.js +3 -3
  122. package/dist/es/it2.js +2 -2
  123. package/dist/es/ja.js +3 -3
  124. package/dist/es/ja2.js +2 -2
  125. package/dist/es/ko.js +3 -3
  126. package/dist/es/ko2.js +2 -2
  127. package/dist/es/markdown.js +2361 -15
  128. package/dist/es/mockServiceDesk.js +16 -8
  129. package/dist/es/nl.js +3 -3
  130. package/dist/es/nl2.js +2 -2
  131. package/dist/es/pt-br.js +3 -3
  132. package/dist/es/pt-br2.js +2 -2
  133. package/dist/es/pt.js +3 -3
  134. package/dist/es/render.js +17 -9
  135. package/dist/es/zh-cn.js +3 -3
  136. package/dist/es/zh-tw.js +3 -3
  137. package/dist/es/zh-tw2.js +2 -2
  138. package/dist/es/zh.js +2 -2
  139. package/dist/types/aiChatEntry.d.ts +69 -9
  140. package/package.json +27 -14
  141. package/dist/cjs/jstz.min.js +0 -43
  142. package/dist/cjs/markdown_attrs.js +0 -805
  143. package/dist/es/jstz.min.js +0 -41
  144. package/dist/es/markdown_attrs.js +0 -803
@@ -13,38 +13,46 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  'use strict';
24
24
 
25
- var cdsAichatInternal = require('./cds-aichat-internal.js');
25
+ var AppContainer = require('./AppContainer.js');
26
26
  var agentActions = require('./agentActions.js');
27
- require('lit');
28
- require('lit/decorators.js');
29
27
  require('react');
30
- require('react-dom');
31
28
  require('./highlight_js.js');
32
29
  require('@carbon/react');
30
+ require('classnames');
33
31
  require('react-intl');
34
32
  require('react-redux');
33
+ require('tabbable');
34
+ require('@carbon/icons-react');
35
35
  require('./markdown.js');
36
- require('./markdown_attrs.js');
36
+ require('tslib');
37
+ require('lit');
38
+ require('lit/decorators.js');
37
39
  require('@carbon/web-components/es/components/button/index.js');
38
40
  require('@carbon/web-components/es/components/overflow-menu/index.js');
39
41
  require('lit/directives/unsafe-html.js');
42
+ require('prop-types');
40
43
  require('@carbon/web-components/es/components/slug/index.js');
41
44
  require('@carbon/web-components/es/components/popover/defs.js');
42
45
  require('@carbon/web-components/es/components/slug/defs.js');
46
+ require('@floating-ui/react');
47
+ require('react-dom');
43
48
  require('@carbon/web-components/es/components/slug/slug-action-button.js');
44
49
  require('@carbon/web-components/es/components/slug/slug.js');
50
+ require('@carbon/web-components/es/components/inline-loading/index.js');
51
+ require('@carbon/icon-helpers');
52
+ require('@carbon/icons');
53
+ require('lit/directives/unsafe-svg.js');
45
54
  require('@carbon/web-components/es/components/textarea/index.js');
46
55
  require('@carbon/web-components/es/components/icon-button/index.js');
47
- require('lit/directives/unsafe-svg.js');
48
56
  require('@carbon/web-components/es/components/tag/index.js');
49
57
  require('@carbon/web-components/es/components/chat-button/index.js');
50
58
  require('@carbon/web-components/es/components/button/button.js');
@@ -132,7 +140,7 @@ const AVAILABILITY_TIMEOUT_MS = 5000;
132
140
  * The amount of time to wait before displaying the "bot returns" message.
133
141
  */
134
142
  const BOT_RETURN_DELAY = 1500;
135
- const { FROM_USER, RECONNECTED, DISCONNECTED, AGENT_ENDED_CHAT, AGENT_JOINED, USER_ENDED_CHAT, CHAT_WAS_ENDED, TRANSFER_TO_AGENT, AGENT_LEFT_CHAT, RELOAD_WARNING, SHARING_CANCELLED, SHARING_DECLINED, SHARING_ACCEPTED, SHARING_REQUESTED, SHARING_ENDED, } = cdsAichatInternal.AgentMessageType;
143
+ const { FROM_USER, RECONNECTED, DISCONNECTED, AGENT_ENDED_CHAT, AGENT_JOINED, USER_ENDED_CHAT, CHAT_WAS_ENDED, TRANSFER_TO_AGENT, AGENT_LEFT_CHAT, RELOAD_WARNING, SHARING_CANCELLED, SHARING_DECLINED, SHARING_ACCEPTED, SHARING_REQUESTED, SHARING_ENDED, } = AppContainer.AgentMessageType;
136
144
  class HumanAgentServiceImpl {
137
145
  constructor(serviceManager) {
138
146
  /**
@@ -178,7 +186,7 @@ class HumanAgentServiceImpl {
178
186
  const { store, instance } = this.serviceManager;
179
187
  const state = store.getState();
180
188
  const { config, persistedToBrowserStorage } = state;
181
- const serviceDeskState = cdsAichatInternal.cloneDeep(persistedToBrowserStorage.chatState.agentState.serviceDeskState);
189
+ const serviceDeskState = AppContainer.cloneDeep(persistedToBrowserStorage.chatState.agentState.serviceDeskState);
182
190
  this.serviceDeskCallback = new ServiceDeskCallbackImpl(this.serviceManager, this);
183
191
  if (config.public.serviceDeskFactory) {
184
192
  // A custom service desk factory was provided so use that to create the service desk.
@@ -189,35 +197,35 @@ class HumanAgentServiceImpl {
189
197
  };
190
198
  this.serviceDesk = await config.public.serviceDeskFactory(parameters);
191
199
  validateCustomServiceDesk(this.serviceDesk);
192
- cdsAichatInternal.debugLog('Initializing a custom service desk');
200
+ AppContainer.debugLog('Initializing a custom service desk');
193
201
  }
194
202
  else {
195
203
  const { initConfig, mainConfig } = config.remote;
196
204
  const { serviceDesk } = config.public;
197
205
  const integrationType = serviceDesk.integrationType || initConfig.service_desk.integration_type;
198
206
  switch (integrationType) {
199
- case cdsAichatInternal.BuiltInServiceDesk.ZENDESK: {
207
+ case AppContainer.BuiltInServiceDesk.ZENDESK: {
200
208
  const sdConfig = mainConfig.service_desk;
201
209
  const { ZendeskServiceDesk } = await Promise.resolve().then(function () { return require(
202
210
  /* webpackChunkName: 'zendesk' */ './ZendeskServiceDesk.js'); });
203
211
  this.serviceDesk = new ZendeskServiceDesk(this.serviceDeskCallback, sdConfig, this.serviceManager);
204
212
  break;
205
213
  }
206
- case cdsAichatInternal.BuiltInServiceDesk.SALES_FORCE: {
207
- const regionHostname = cdsAichatInternal.getRegionHostname(config.public);
214
+ case AppContainer.BuiltInServiceDesk.SALES_FORCE: {
215
+ const regionHostname = AppContainer.getRegionHostname(config.public);
208
216
  const sdConfig = mainConfig.service_desk;
209
217
  const { SFServiceDesk } = await Promise.resolve().then(function () { return require(
210
218
  /* webpackChunkName: 'salesforce' */ './SFServiceDesk.js'); });
211
219
  this.serviceDesk = new SFServiceDesk(this.serviceDeskCallback, sdConfig, regionHostname, this.serviceManager);
212
220
  break;
213
221
  }
214
- case cdsAichatInternal.BuiltInServiceDesk.NICE_DFO: {
222
+ case AppContainer.BuiltInServiceDesk.NICE_DFO: {
215
223
  const { NiceDFOServiceDesk } = await Promise.resolve().then(function () { return require(
216
224
  /* webpackChunkName: 'nice' */ './NiceDFOServiceDesk.js'); });
217
225
  this.serviceDesk = new NiceDFOServiceDesk(this.serviceDeskCallback, serviceDesk.niceDFO, this.serviceManager);
218
226
  break;
219
227
  }
220
- case cdsAichatInternal.BuiltInServiceDesk.GENESYS_MESSENGER: {
228
+ case AppContainer.BuiltInServiceDesk.GENESYS_MESSENGER: {
221
229
  const sdConfig = serviceDesk.genesysMessenger;
222
230
  const { GenesysMessengerServiceDesk } = await Promise.resolve().then(function () { return require(
223
231
  /* webpackChunkName: 'genesys' */ './GenesysMessengerServiceDesk.js'); });
@@ -227,7 +235,7 @@ class HumanAgentServiceImpl {
227
235
  default:
228
236
  throw new Error(`Invalid service desk type: "${integrationType}"`);
229
237
  }
230
- cdsAichatInternal.debugLog(`Initializing built-in service desk ${integrationType}`);
238
+ AppContainer.debugLog(`Initializing built-in service desk ${integrationType}`);
231
239
  }
232
240
  // If the service desk supports reconnecting, we don't need to show this warning.
233
241
  this.showLeaveWarning = !this.serviceDesk?.reconnect;
@@ -308,10 +316,10 @@ class HumanAgentServiceImpl {
308
316
  });
309
317
  }
310
318
  catch (error) {
311
- cdsAichatInternal.consoleError('[startChat] An error with the service desk occurred.', error);
319
+ AppContainer.consoleError('[startChat] An error with the service desk occurred.', error);
312
320
  // If it failed to start, then stop connecting and clear the service desk.
313
321
  if (this.serviceDeskCallback) {
314
- await this.serviceDeskCallback.setErrorStatus({ type: cdsAichatInternal.ErrorType.CONNECTING, logInfo: error });
322
+ await this.serviceDeskCallback.setErrorStatus({ type: AppContainer.ErrorType.CONNECTING, logInfo: error });
315
323
  }
316
324
  serviceManager.store.dispatch(agentActions.setIsConnecting(false, null));
317
325
  this.chatStarted = false;
@@ -378,7 +386,7 @@ class HumanAgentServiceImpl {
378
386
  if (isConnected && !skipEndMessages) {
379
387
  // Display the "end chat" messages.
380
388
  const messageType = endedByUser ? USER_ENDED_CHAT : CHAT_WAS_ENDED;
381
- await cdsAichatInternal.addEndChatMessages(messageType, null, BOT_RETURN_DELAY, true, wasSuspended, this.serviceManager);
389
+ await AppContainer.addEndChatMessages(messageType, null, BOT_RETURN_DELAY, true, wasSuspended, this.serviceManager);
382
390
  }
383
391
  }
384
392
  /**
@@ -387,12 +395,12 @@ class HumanAgentServiceImpl {
387
395
  async doEndChat(endedByAgent, preEndChatPayload) {
388
396
  const { isConnected } = this.persistedAgentState();
389
397
  this.cancelAgentJoinedTimer();
390
- this.closeScreenShareRequestModal(cdsAichatInternal.ScreenShareState.CANCELLED);
398
+ this.closeScreenShareRequestModal(AppContainer.ScreenShareState.CANCELLED);
391
399
  try {
392
- await cdsAichatInternal.resolveOrTimeout(this.serviceDesk.endChat({ endedByAgent, preEndChatPayload }), END_CHAT_TIMEOUT_MS);
400
+ await AppContainer.resolveOrTimeout(this.serviceDesk.endChat({ endedByAgent, preEndChatPayload }), END_CHAT_TIMEOUT_MS);
393
401
  }
394
402
  catch (error) {
395
- cdsAichatInternal.consoleError('[doEndChat] An error with the service desk occurred.', error);
403
+ AppContainer.consoleError('[doEndChat] An error with the service desk occurred.', error);
396
404
  }
397
405
  this.chatStarted = false;
398
406
  this.isAgentTyping = false;
@@ -412,8 +420,8 @@ class HumanAgentServiceImpl {
412
420
  return;
413
421
  }
414
422
  const { serviceManager } = this;
415
- cdsAichatInternal.deepFreeze(uploads);
416
- const originalMessage = cdsAichatInternal.createMessageRequestForText(text);
423
+ AppContainer.deepFreeze(uploads);
424
+ const originalMessage = AppContainer.createMessageRequestForText(text);
417
425
  originalMessage.input.agent_message_type = FROM_USER;
418
426
  // Fire the pre:send event that will allow code to customize the message.
419
427
  await serviceManager.fire({ type: "agent:pre:send" /* BusEventType.AGENT_PRE_SEND */, data: originalMessage, files: uploads });
@@ -422,19 +430,19 @@ class HumanAgentServiceImpl {
422
430
  const localMessageID = textMessage.ui_state.id;
423
431
  const pairs = [];
424
432
  if (textMessage.item.text) {
425
- pairs.push(cdsAichatInternal.toPair([textMessage], originalMessage));
433
+ pairs.push(AppContainer.toPair([textMessage], originalMessage));
426
434
  }
427
435
  // Add a message for each file upload.
428
436
  uploads.forEach(upload => {
429
437
  // Note that we're going to reuse the file ID for the MessageRequest and LocalMessage to make it easier to
430
438
  // locate the objects when we need to update their states.
431
- const uploadOriginalMessage = cdsAichatInternal.createMessageRequestForFileUpload(upload);
439
+ const uploadOriginalMessage = AppContainer.createMessageRequestForFileUpload(upload);
432
440
  const uploadLocalMessage = agentActions.inputItemToLocalItem(uploadOriginalMessage, uploadOriginalMessage.input.text, upload.id);
433
- pairs.push(cdsAichatInternal.toPair([uploadLocalMessage], uploadOriginalMessage));
441
+ pairs.push(AppContainer.toPair([uploadLocalMessage], uploadOriginalMessage));
434
442
  this.uploadingFiles.add(upload.id);
435
443
  });
436
444
  this.serviceManager.store.dispatch(agentActions.updateFilesUploadInProgress(this.uploadingFiles.size > 0));
437
- await cdsAichatInternal.addMessages(pairs, true, true, !this.isSuspended(), serviceManager);
445
+ await AppContainer.addMessages(pairs, true, true, !this.isSuspended(), serviceManager);
438
446
  // Track when a message from the user is sent to human agent.
439
447
  const trackProps = {
440
448
  eventName: 'Human Message Received from User',
@@ -447,12 +455,12 @@ class HumanAgentServiceImpl {
447
455
  let messageFailed = false;
448
456
  setTimeout(() => {
449
457
  if (!messageSucceeded && !messageFailed) {
450
- this.setMessageErrorState(textMessage.fullMessageID, cdsAichatInternal.MessageErrorState.RETRYING);
458
+ this.setMessageErrorState(textMessage.fullMessageID, AppContainer.MessageErrorState.RETRYING);
451
459
  }
452
460
  }, SEND_TIMEOUT_WARNING_MS);
453
461
  setTimeout(() => {
454
462
  if (!messageSucceeded) {
455
- this.setMessageErrorState(textMessage.fullMessageID, cdsAichatInternal.MessageErrorState.FAILED);
463
+ this.setMessageErrorState(textMessage.fullMessageID, AppContainer.MessageErrorState.FAILED);
456
464
  }
457
465
  }, SEND_TIMEOUT_ERROR_MS);
458
466
  const additionalData = {
@@ -462,13 +470,13 @@ class HumanAgentServiceImpl {
462
470
  // Send the message to the service desk.
463
471
  await this.serviceDesk.sendMessageToAgent(originalMessage, localMessageID, additionalData);
464
472
  messageSucceeded = true;
465
- this.setMessageErrorState(textMessage.fullMessageID, cdsAichatInternal.MessageErrorState.NONE);
473
+ this.setMessageErrorState(textMessage.fullMessageID, AppContainer.MessageErrorState.NONE);
466
474
  await serviceManager.fire({ type: "agent:send" /* BusEventType.AGENT_SEND */, data: originalMessage, files: uploads });
467
475
  }
468
476
  catch (error) {
469
477
  messageFailed = true;
470
- cdsAichatInternal.consoleError('[sendMessageToAgent] An error with the service desk occurred.', error);
471
- this.setMessageErrorState(textMessage.fullMessageID, cdsAichatInternal.MessageErrorState.FAILED);
478
+ AppContainer.consoleError('[sendMessageToAgent] An error with the service desk occurred.', error);
479
+ this.setMessageErrorState(textMessage.fullMessageID, AppContainer.MessageErrorState.FAILED);
472
480
  }
473
481
  }
474
482
  /**
@@ -484,7 +492,7 @@ class HumanAgentServiceImpl {
484
492
  this.serviceDesk.filesSelectedForUpload?.(uploads);
485
493
  }
486
494
  catch (error) {
487
- cdsAichatInternal.consoleError('[userReadMessages] An error with the service desk occurred.', error);
495
+ AppContainer.consoleError('[userReadMessages] An error with the service desk occurred.', error);
488
496
  }
489
497
  }
490
498
  /**
@@ -499,7 +507,7 @@ class HumanAgentServiceImpl {
499
507
  await this.serviceDesk.userReadMessages();
500
508
  }
501
509
  catch (error) {
502
- cdsAichatInternal.consoleError('[userReadMessages] An error with the service desk occurred.', error);
510
+ AppContainer.consoleError('[userReadMessages] An error with the service desk occurred.', error);
503
511
  }
504
512
  }
505
513
  /**
@@ -513,28 +521,28 @@ class HumanAgentServiceImpl {
513
521
  let resultValue;
514
522
  const initialRestartCount = this.serviceManager.restartCount;
515
523
  if (!this.serviceDesk?.areAnyAgentsOnline) {
516
- resultValue = cdsAichatInternal.AgentsOnlineStatus.UNKNOWN;
524
+ resultValue = AppContainer.AgentsOnlineStatus.UNKNOWN;
517
525
  }
518
526
  else {
519
527
  try {
520
528
  const timeoutSeconds = this.serviceManager.store.getState().config.public.serviceDesk?.availabilityTimeoutSeconds;
521
529
  const timeout = timeoutSeconds ? timeoutSeconds * 1000 : AVAILABILITY_TIMEOUT_MS;
522
- const result = await cdsAichatInternal.resolveOrTimeout(this.serviceDesk.areAnyAgentsOnline(connectMessage), timeout);
530
+ const result = await AppContainer.resolveOrTimeout(this.serviceDesk.areAnyAgentsOnline(connectMessage), timeout);
523
531
  if (result === true) {
524
- resultValue = cdsAichatInternal.AgentsOnlineStatus.ONLINE;
532
+ resultValue = AppContainer.AgentsOnlineStatus.ONLINE;
525
533
  }
526
534
  else if (result === false) {
527
- resultValue = cdsAichatInternal.AgentsOnlineStatus.OFFLINE;
535
+ resultValue = AppContainer.AgentsOnlineStatus.OFFLINE;
528
536
  }
529
537
  else {
530
538
  // Any other value for result will return an unknown status.
531
- resultValue = cdsAichatInternal.AgentsOnlineStatus.UNKNOWN;
539
+ resultValue = AppContainer.AgentsOnlineStatus.UNKNOWN;
532
540
  }
533
541
  }
534
542
  catch (error) {
535
- cdsAichatInternal.consoleError('Error attempting to get agent availability', error);
543
+ AppContainer.consoleError('Error attempting to get agent availability', error);
536
544
  // If we fail to get an answer we'll just return false to indicate that no agents are available.
537
- resultValue = cdsAichatInternal.AgentsOnlineStatus.OFFLINE;
545
+ resultValue = AppContainer.AgentsOnlineStatus.OFFLINE;
538
546
  }
539
547
  }
540
548
  if (initialRestartCount === this.serviceManager.restartCount) {
@@ -560,7 +568,7 @@ class HumanAgentServiceImpl {
560
568
  await this.serviceDesk.userTyping?.(isTyping);
561
569
  }
562
570
  catch (error) {
563
- cdsAichatInternal.consoleError('[userTyping] An error with the service desk occurred.', error);
571
+ AppContainer.consoleError('[userTyping] An error with the service desk occurred.', error);
564
572
  }
565
573
  }
566
574
  /**
@@ -571,7 +579,7 @@ class HumanAgentServiceImpl {
571
579
  * @param errorState The state to set of the message.
572
580
  */
573
581
  setMessageErrorState(messageID, errorState) {
574
- this.serviceManager.store.dispatch(cdsAichatInternal.actions.setMessageErrorState(messageID, errorState));
582
+ this.serviceManager.store.dispatch(AppContainer.actions.setMessageErrorState(messageID, errorState));
575
583
  }
576
584
  /**
577
585
  * This is called when an agent fails to join a chat after a given period of time.
@@ -579,8 +587,8 @@ class HumanAgentServiceImpl {
579
587
  async handleAgentJoinedTimeout() {
580
588
  // Display an error to the user.
581
589
  const message = this.serviceManager.store.getState().languagePack.errors_noAgentsJoined;
582
- const { originalMessage, localMessage } = cdsAichatInternal.createLocalMessageForInlineError(message);
583
- await cdsAichatInternal.addMessages([cdsAichatInternal.toPair([localMessage], originalMessage)], true, false, !this.isSuspended(), this.serviceManager);
590
+ const { originalMessage, localMessage } = AppContainer.createLocalMessageForInlineError(message);
591
+ await AppContainer.addMessages([AppContainer.toPair([localMessage], originalMessage)], true, false, !this.isSuspended(), this.serviceManager);
584
592
  // End the chat.
585
593
  this.endChat(false);
586
594
  }
@@ -607,16 +615,16 @@ class HumanAgentServiceImpl {
607
615
  this.closeScreenShareRequestModal(state);
608
616
  let agentMessageType;
609
617
  switch (state) {
610
- case cdsAichatInternal.ScreenShareState.ACCEPTED:
618
+ case AppContainer.ScreenShareState.ACCEPTED:
611
619
  agentMessageType = SHARING_ACCEPTED;
612
620
  break;
613
- case cdsAichatInternal.ScreenShareState.DECLINED:
621
+ case AppContainer.ScreenShareState.DECLINED:
614
622
  agentMessageType = SHARING_DECLINED;
615
623
  break;
616
- case cdsAichatInternal.ScreenShareState.CANCELLED:
624
+ case AppContainer.ScreenShareState.CANCELLED:
617
625
  agentMessageType = SHARING_CANCELLED;
618
626
  break;
619
- case cdsAichatInternal.ScreenShareState.ENDED:
627
+ case AppContainer.ScreenShareState.ENDED:
620
628
  agentMessageType = SHARING_ENDED;
621
629
  break;
622
630
  default:
@@ -651,7 +659,7 @@ class HumanAgentServiceImpl {
651
659
  didReconnect = await this.serviceDesk.reconnect();
652
660
  }
653
661
  catch (error) {
654
- cdsAichatInternal.consoleError(`Error while trying to reconnect to an agent.`, error);
662
+ AppContainer.consoleError(`Error while trying to reconnect to an agent.`, error);
655
663
  }
656
664
  }
657
665
  store.dispatch(agentActions.setIsReconnecting(false));
@@ -668,7 +676,7 @@ class HumanAgentServiceImpl {
668
676
  store.dispatch(agentActions.endChat());
669
677
  if (allowEndChatMessages) {
670
678
  // If we didn't reconnect, then show the "end chat" messages to the user.
671
- await cdsAichatInternal.addEndChatMessages(cdsAichatInternal.AgentMessageType.CHAT_WAS_ENDED, null, 0, false, wasSuspended, this.serviceManager);
679
+ await AppContainer.addEndChatMessages(AppContainer.AgentMessageType.CHAT_WAS_ENDED, null, 0, false, wasSuspended, this.serviceManager);
672
680
  }
673
681
  }
674
682
  else {
@@ -687,7 +695,7 @@ class HumanAgentServiceImpl {
687
695
  this.screenShareRequestPromise.doResolve(state);
688
696
  this.screenShareRequestPromise = null;
689
697
  }
690
- this.serviceManager.store.dispatch(agentActions.setIsScreenSharing(state === cdsAichatInternal.ScreenShareState.ACCEPTED));
698
+ this.serviceManager.store.dispatch(agentActions.setIsScreenSharing(state === AppContainer.ScreenShareState.ACCEPTED));
691
699
  }
692
700
  /**
693
701
  * Adds a local agent message.
@@ -696,8 +704,8 @@ class HumanAgentServiceImpl {
696
704
  if (!agentProfile) {
697
705
  agentProfile = this.persistedAgentState().agentProfile;
698
706
  }
699
- const { localMessage, originalMessage } = await cdsAichatInternal.createAgentLocalMessage(agentMessageType, this.serviceManager, agentProfile, fireEvents);
700
- await cdsAichatInternal.addMessages([cdsAichatInternal.toPair([localMessage], originalMessage)], saveInHistory, false, !this.isSuspended(), this.serviceManager);
707
+ const { localMessage, originalMessage } = await AppContainer.createAgentLocalMessage(agentMessageType, this.serviceManager, agentProfile, fireEvents);
708
+ await AppContainer.addMessages([AppContainer.toPair([localMessage], originalMessage)], saveInHistory, false, !this.isSuspended(), this.serviceManager);
701
709
  }
702
710
  /**
703
711
  * Returns the persisted agent state from the store.
@@ -728,7 +736,7 @@ class ServiceDeskCallbackImpl {
728
736
  * @param capabilities The set of capabilities to update. Only properties that need to be changed need to be included.
729
737
  */
730
738
  updateCapabilities(capabilities) {
731
- this.serviceManager.store.dispatch(agentActions.updateCapabilities(cdsAichatInternal.cloneDeep(capabilities)));
739
+ this.serviceManager.store.dispatch(agentActions.updateCapabilities(AppContainer.cloneDeep(capabilities)));
732
740
  }
733
741
  /**
734
742
  * Sends updated availability information to the chat widget for a user who is waiting to be connected to an
@@ -777,7 +785,7 @@ class ServiceDeskCallbackImpl {
777
785
  // The chat is no longer running.
778
786
  return;
779
787
  }
780
- cdsAichatInternal.debugLog('[ServiceDeskCallbackImpl] agentReadMessages');
788
+ AppContainer.debugLog('[ServiceDeskCallbackImpl] agentReadMessages');
781
789
  }
782
790
  /**
783
791
  * Tells the chat widget if an agent has started or stopped typing.
@@ -806,12 +814,12 @@ class ServiceDeskCallbackImpl {
806
814
  // The chat is no longer running or no message was actually provided.
807
815
  return;
808
816
  }
809
- const messageResponse = typeof message === 'string' ? cdsAichatInternal.createMessageResponseForText(message) : message;
810
- cdsAichatInternal.addDefaultsToMessage(messageResponse);
817
+ const messageResponse = typeof message === 'string' ? AppContainer.createMessageResponseForText(message) : message;
818
+ AppContainer.addDefaultsToMessage(messageResponse);
811
819
  if (messageResponse.output?.generic?.length) {
812
820
  messageResponse.output.generic.forEach(messageItem => {
813
821
  if (!messageItem.agent_message_type) {
814
- messageItem.agent_message_type = cdsAichatInternal.AgentMessageType.FROM_AGENT;
822
+ messageItem.agent_message_type = AppContainer.AgentMessageType.FROM_AGENT;
815
823
  }
816
824
  });
817
825
  }
@@ -828,7 +836,7 @@ class ServiceDeskCallbackImpl {
828
836
  // agent (if there is one).
829
837
  agentProfile = this.persistedAgentState().agentProfile;
830
838
  if (agentProfile) {
831
- cdsAichatInternal.consoleError(`Got agent ID ${agentID} but no agent with that ID joined the conversation. Using the current agent instead.`);
839
+ AppContainer.consoleError(`Got agent ID ${agentID} but no agent with that ID joined the conversation. Using the current agent instead.`);
832
840
  }
833
841
  }
834
842
  }
@@ -840,9 +848,9 @@ class ServiceDeskCallbackImpl {
840
848
  });
841
849
  messageResponse.history.agent_profile = agentProfile;
842
850
  const localMessages = messageResponse.output.generic.map(item => {
843
- return cdsAichatInternal.outputItemToLocalItem(item, messageResponse);
851
+ return AppContainer.outputItemToLocalItem(item, messageResponse);
844
852
  });
845
- await cdsAichatInternal.addMessages([cdsAichatInternal.toPair(localMessages, messageResponse)], true, true, !this.service.isSuspended(), this.serviceManager);
853
+ await AppContainer.addMessages([AppContainer.toPair(localMessages, messageResponse)], true, true, !this.service.isSuspended(), this.serviceManager);
846
854
  // Track when a message from a human agent is sent to the user.
847
855
  const trackProps = {
848
856
  eventName: 'Human Message Sent to User',
@@ -905,7 +913,7 @@ class ServiceDeskCallbackImpl {
905
913
  await this.service.doEndChat(true, event.preEndChatPayload);
906
914
  // Display the "end chat" messages.
907
915
  const { agentProfile } = this.persistedAgentState();
908
- await cdsAichatInternal.addEndChatMessages(AGENT_ENDED_CHAT, agentProfile, BOT_RETURN_DELAY, true, wasSuspended, this.serviceManager);
916
+ await AppContainer.addEndChatMessages(AGENT_ENDED_CHAT, agentProfile, BOT_RETURN_DELAY, true, wasSuspended, this.serviceManager);
909
917
  }
910
918
  /**
911
919
  * Sets the state of the given error type.
@@ -921,36 +929,36 @@ class ServiceDeskCallbackImpl {
921
929
  const { store } = this.serviceManager;
922
930
  const { isConnecting } = store.getState().agentState;
923
931
  if (logInfo) {
924
- cdsAichatInternal.consoleError(`An error occurred in the service desk (type=${type})`, logInfo);
932
+ AppContainer.consoleError(`An error occurred in the service desk (type=${type})`, logInfo);
925
933
  }
926
934
  // If the service desk reports a disconnected error while we're in the middle of connecting, then handle it as a
927
935
  // connecting error instead. This avoids us sending the user a message when we never actually connected.
928
- if (isConnecting && errorInfo.type === cdsAichatInternal.ErrorType.DISCONNECTED && errorInfo.isDisconnected) {
929
- errorInfo = { type: cdsAichatInternal.ErrorType.CONNECTING };
936
+ if (isConnecting && errorInfo.type === AppContainer.ErrorType.DISCONNECTED && errorInfo.isDisconnected) {
937
+ errorInfo = { type: AppContainer.ErrorType.CONNECTING };
930
938
  }
931
939
  switch (errorInfo.type) {
932
- case cdsAichatInternal.ErrorType.DISCONNECTED: {
940
+ case AppContainer.ErrorType.DISCONNECTED: {
933
941
  if (errorInfo.isDisconnected) {
934
942
  // The service desk has become disconnected so show an error and don't allow the user to send messages.
935
943
  this.service.showingDisconnectedError = true;
936
944
  await this.service.addAgentLocalMessage(DISCONNECTED, null, true, false);
937
- store.dispatch(cdsAichatInternal.actions.updateInputState({ isReadonly: true }, true));
945
+ store.dispatch(AppContainer.actions.updateInputState({ isReadonly: true }, true));
938
946
  }
939
947
  else if (this.service.showingDisconnectedError) {
940
948
  // The service desk says it's no longer disconnected but double check that we previously thought we were
941
949
  // disconnected.
942
950
  this.service.showingDisconnectedError = false;
943
951
  await this.service.addAgentLocalMessage(RECONNECTED, null, true, false);
944
- store.dispatch(cdsAichatInternal.actions.updateInputState({ isReadonly: false }, true));
952
+ store.dispatch(AppContainer.actions.updateInputState({ isReadonly: false }, true));
945
953
  }
946
954
  break;
947
955
  }
948
- case cdsAichatInternal.ErrorType.CONNECTING: {
956
+ case AppContainer.ErrorType.CONNECTING: {
949
957
  // If we can't connect, display an inline error message on the bot view.
950
958
  const { languagePack } = this.serviceManager.store.getState();
951
959
  const message = errorInfo.messageToUser || languagePack.errors_connectingToAgent;
952
- const { originalMessage, localMessage } = cdsAichatInternal.createLocalMessageForInlineError(message);
953
- await cdsAichatInternal.addMessages([cdsAichatInternal.toPair([localMessage], originalMessage)], true, false, !this.service.isSuspended(), this.serviceManager);
960
+ const { originalMessage, localMessage } = AppContainer.createLocalMessageForInlineError(message);
961
+ await AppContainer.addMessages([AppContainer.toPair([localMessage], originalMessage)], true, false, !this.service.isSuspended(), this.serviceManager);
954
962
  // Cancel the connecting status.
955
963
  this.serviceManager.store.dispatch(agentActions.setIsConnecting(false, null));
956
964
  this.service.chatStarted = false;
@@ -958,8 +966,8 @@ class ServiceDeskCallbackImpl {
958
966
  await this.service.fireEndChat(false, isConnecting);
959
967
  break;
960
968
  }
961
- case cdsAichatInternal.ErrorType.USER_MESSAGE: {
962
- this.service.setMessageErrorState(errorInfo.messageID, cdsAichatInternal.MessageErrorState.FAILED);
969
+ case AppContainer.ErrorType.USER_MESSAGE: {
970
+ this.service.setMessageErrorState(errorInfo.messageID, AppContainer.MessageErrorState.FAILED);
963
971
  break;
964
972
  }
965
973
  }
@@ -988,31 +996,31 @@ class ServiceDeskCallbackImpl {
988
996
  if (uploadMessage) {
989
997
  // Update the value in the redux store.
990
998
  const partialMessage = {
991
- history: { file_upload_status: cdsAichatInternal.FileStatusValue.COMPLETE },
999
+ history: { file_upload_status: AppContainer.FileStatusValue.COMPLETE },
992
1000
  };
993
1001
  if (isError) {
994
- store.dispatch(cdsAichatInternal.actions.setMessageHistoryProperty(fileID, 'file_upload_status', cdsAichatInternal.FileStatusValue.COMPLETE));
995
- store.dispatch(cdsAichatInternal.actions.setMessageHistoryProperty(fileID, 'error_state', cdsAichatInternal.MessageErrorState.FAILED));
996
- partialMessage.history.error_state = cdsAichatInternal.MessageErrorState.FAILED;
1002
+ store.dispatch(AppContainer.actions.setMessageHistoryProperty(fileID, 'file_upload_status', AppContainer.FileStatusValue.COMPLETE));
1003
+ store.dispatch(AppContainer.actions.setMessageHistoryProperty(fileID, 'error_state', AppContainer.MessageErrorState.FAILED));
1004
+ partialMessage.history.error_state = AppContainer.MessageErrorState.FAILED;
997
1005
  if (errorMessage) {
998
1006
  // Generate an inline error message to show the error to the user.
999
- const { originalMessage, localMessage } = cdsAichatInternal.createLocalMessageForInlineError(errorMessage);
1000
- localMessage.item.agent_message_type = cdsAichatInternal.AgentMessageType.INLINE_ERROR;
1001
- await cdsAichatInternal.addMessages([cdsAichatInternal.toPair([localMessage], originalMessage)], true, true, !this.service.isSuspended(), this.serviceManager);
1007
+ const { originalMessage, localMessage } = AppContainer.createLocalMessageForInlineError(errorMessage);
1008
+ localMessage.item.agent_message_type = AppContainer.AgentMessageType.INLINE_ERROR;
1009
+ await AppContainer.addMessages([AppContainer.toPair([localMessage], originalMessage)], true, true, !this.service.isSuspended(), this.serviceManager);
1002
1010
  }
1003
1011
  }
1004
1012
  else {
1005
1013
  // If the upload was completed successfully, we display a temporary "success" status. This will display a
1006
1014
  // checkmark temporarily before fading out. Session history will store "complete" as the status.
1007
- store.dispatch(cdsAichatInternal.actions.setMessageHistoryProperty(fileID, 'file_upload_status', cdsAichatInternal.FileStatusValue.SUCCESS));
1008
- store.dispatch(cdsAichatInternal.actions.announceMessage({ messageID: 'fileSharing_ariaAnnounceSuccess' }));
1015
+ store.dispatch(AppContainer.actions.setMessageHistoryProperty(fileID, 'file_upload_status', AppContainer.FileStatusValue.SUCCESS));
1016
+ store.dispatch(AppContainer.actions.announceMessage({ messageID: 'fileSharing_ariaAnnounceSuccess' }));
1009
1017
  }
1010
1018
  // Send an update to store the status in session history.
1011
1019
  await this.serviceManager.actions.sendUpdateHistoryEvent(fileID, partialMessage);
1012
1020
  }
1013
1021
  else if (isError) {
1014
1022
  // Update the input area.
1015
- store.dispatch(cdsAichatInternal.actions.fileUploadInputError(fileID, errorMessage, true));
1023
+ store.dispatch(AppContainer.actions.fileUploadInputError(fileID, errorMessage, true));
1016
1024
  }
1017
1025
  this.service.uploadingFiles.delete(fileID);
1018
1026
  this.serviceManager.store.dispatch(agentActions.updateFilesUploadInProgress(this.service.uploadingFiles.size > 0));
@@ -1030,7 +1038,7 @@ class ServiceDeskCallbackImpl {
1030
1038
  return Promise.reject(new Error('Cannot request screen sharing if no chat is in progress.'));
1031
1039
  }
1032
1040
  if (!this.service.screenShareRequestPromise) {
1033
- this.service.screenShareRequestPromise = cdsAichatInternal.resolvablePromise();
1041
+ this.service.screenShareRequestPromise = AppContainer.resolvablePromise();
1034
1042
  this.serviceManager.store.dispatch(agentActions.setShowScreenShareRequest(true));
1035
1043
  await this.service.addAgentLocalMessage(SHARING_REQUESTED);
1036
1044
  }
@@ -1043,7 +1051,7 @@ class ServiceDeskCallbackImpl {
1043
1051
  async screenShareEnded() {
1044
1052
  const wasScreenSharing = this.serviceManager.store.getState().agentState.isScreenSharing;
1045
1053
  const requestPending = this.service.screenShareRequestPromise;
1046
- this.service.closeScreenShareRequestModal(cdsAichatInternal.ScreenShareState.CANCELLED);
1054
+ this.service.closeScreenShareRequestModal(AppContainer.ScreenShareState.CANCELLED);
1047
1055
  if (wasScreenSharing) {
1048
1056
  this.serviceManager.store.dispatch(agentActions.setIsScreenSharing(false));
1049
1057
  await this.service.addAgentLocalMessage(SHARING_ENDED);
@@ -1083,12 +1091,12 @@ class ServiceDeskCallbackImpl {
1083
1091
  const { store } = this.serviceManager;
1084
1092
  let newState;
1085
1093
  if (mergeWithCurrent) {
1086
- newState = cdsAichatInternal.merge({}, store.getState().persistedToBrowserStorage.chatState.agentState.serviceDeskState, state);
1094
+ newState = AppContainer.merge({}, store.getState().persistedToBrowserStorage.chatState.agentState.serviceDeskState, state);
1087
1095
  }
1088
1096
  else {
1089
- newState = cdsAichatInternal.cloneDeep(state);
1097
+ newState = AppContainer.cloneDeep(state);
1090
1098
  }
1091
- store.dispatch(agentActions.setPersistedServiceDeskState(cdsAichatInternal.deepFreeze(newState)));
1099
+ store.dispatch(agentActions.setPersistedServiceDeskState(AppContainer.deepFreeze(newState)));
1092
1100
  }
1093
1101
  }
1094
1102
  /**
@@ -1104,17 +1112,17 @@ function createService(serviceManager) {
1104
1112
  */
1105
1113
  function validateCustomServiceDesk(serviceDesk) {
1106
1114
  if (!serviceDesk) {
1107
- cdsAichatInternal.consoleError('The custom service desk does not appear to be valid. No service desk was provided.', serviceDesk);
1115
+ AppContainer.consoleError('The custom service desk does not appear to be valid. No service desk was provided.', serviceDesk);
1108
1116
  }
1109
1117
  else if (typeof serviceDesk !== 'object') {
1110
- cdsAichatInternal.consoleError(`The custom service desk does not appear to be valid. The type should be "object" but is "${typeof serviceDesk}"`, serviceDesk);
1118
+ AppContainer.consoleError(`The custom service desk does not appear to be valid. The type should be "object" but is "${typeof serviceDesk}"`, serviceDesk);
1111
1119
  }
1112
1120
  else {
1113
1121
  const propertyNames = ['startChat', 'endChat', 'sendMessageToAgent'];
1114
1122
  propertyNames.forEach(propertyName => {
1115
1123
  const value = serviceDesk[propertyName];
1116
1124
  if (typeof value !== 'function') {
1117
- cdsAichatInternal.consoleError(`The custom service desk does not appear to be valid. The type of property "${propertyName}"should be "function" but is "${typeof value}"`, value, serviceDesk);
1125
+ AppContainer.consoleError(`The custom service desk does not appear to be valid. The type of property "${propertyName}"should be "function" but is "${typeof value}"`, value, serviceDesk);
1118
1126
  }
1119
1127
  });
1120
1128
  const name = serviceDesk.getName?.();
@@ -1134,7 +1142,7 @@ function replaceVersionInSessionHistoryKey(localConnectMessage) {
1134
1142
  const sessionHistoryKey = localConnectMessage.item.transfer_info?.session_history_key;
1135
1143
  if (sessionHistoryKey) {
1136
1144
  const sessionHistoryKeySerialized = SessionHistoryKeySerializer.deserialize(sessionHistoryKey);
1137
- sessionHistoryKeySerialized.version = cdsAichatInternal.VERSION;
1145
+ sessionHistoryKeySerialized.version = AppContainer.VERSION;
1138
1146
  return SessionHistoryKeySerializer.serialize(sessionHistoryKeySerialized);
1139
1147
  }
1140
1148
  return '';