@microsoft/omnichannel-chat-widget 0.1.0-main.07f52ee → 0.1.0-main.0e38a73

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 (347) hide show
  1. package/README.md +35 -11
  2. package/lib/cjs/assets/Audios.js +8 -0
  3. package/lib/cjs/assets/Icons.js +28 -0
  4. package/lib/cjs/common/Constants.js +31 -150
  5. package/lib/cjs/common/KeyCodes.js +0 -3
  6. package/lib/cjs/common/contextDataStore/DataStoreManager.js +0 -4
  7. package/lib/cjs/common/storage/default/defaultCacheManager.js +24 -0
  8. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +102 -0
  9. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +78 -0
  10. package/lib/cjs/common/telemetry/TelemetryConstants.js +81 -22
  11. package/lib/cjs/common/telemetry/TelemetryHelper.js +26 -54
  12. package/lib/cjs/common/telemetry/TelemetryManager.js +14 -34
  13. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  14. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -3
  15. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +49 -35
  16. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -14
  17. package/lib/cjs/common/utils.js +80 -80
  18. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +21 -45
  19. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -26
  20. package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  21. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -70
  22. package/lib/cjs/components/dimlayer/DimLayer.js +0 -4
  23. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +8 -36
  24. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -8
  25. package/lib/cjs/components/footerstateful/FooterStateful.js +14 -46
  26. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
  27. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -44
  28. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
  29. package/lib/cjs/components/headerstateful/HeaderStateful.js +23 -34
  30. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -14
  31. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +37 -0
  32. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +18 -0
  33. package/lib/cjs/{assets/assets.d.js → components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js} +0 -0
  34. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +32 -0
  35. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +62 -0
  36. package/lib/cjs/components/livechatwidget/common/Deferred.js +35 -0
  37. package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
  38. package/lib/cjs/components/livechatwidget/common/createAdapter.js +10 -9
  39. package/lib/cjs/components/livechatwidget/common/createFooter.js +4 -23
  40. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -10
  41. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +36 -44
  42. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +82 -57
  43. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
  44. package/lib/cjs/components/livechatwidget/common/endChat.js +127 -61
  45. package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
  46. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +8 -17
  47. package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
  48. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +58 -54
  49. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +131 -56
  50. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +9 -33
  51. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -15
  52. package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
  53. package/lib/cjs/components/livechatwidget/common/startChat.js +157 -77
  54. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -11
  55. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -11
  56. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +296 -136
  57. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +4 -17
  58. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
  59. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -14
  60. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -23
  61. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  62. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
  63. package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  64. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  65. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +11 -44
  66. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +26 -34
  67. package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  68. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -24
  69. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
  70. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
  71. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
  72. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  73. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +9 -26
  74. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -15
  75. package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
  76. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +54 -88
  77. package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
  78. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  79. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  80. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +10 -0
  81. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +0 -4
  82. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +33 -80
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +9 -19
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -60
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
  98. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  99. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
  100. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
  101. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
  102. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
  103. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
  104. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
  105. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -12
  106. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +6 -28
  107. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  108. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +13 -30
  109. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
  110. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -34
  111. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
  112. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +7 -18
  113. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +16 -19
  114. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
  115. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
  116. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
  117. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
  118. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
  119. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
  120. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
  121. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +33 -0
  122. package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
  123. package/lib/cjs/contexts/ChatContextStore.js +0 -2
  124. package/lib/cjs/contexts/ChatSDKStore.js +0 -2
  125. package/lib/cjs/contexts/common/ConversationState.js +4 -3
  126. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -9
  127. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +14 -10
  128. package/lib/cjs/contexts/createReducer.js +150 -107
  129. package/lib/cjs/controller/componentController.js +5 -34
  130. package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
  131. package/lib/cjs/hooks/useChatContextStore.js +0 -6
  132. package/lib/cjs/hooks/useChatSDKStore.js +0 -6
  133. package/lib/cjs/index.js +0 -5
  134. package/lib/cjs/plugins/newMessageEventHandler.js +78 -0
  135. package/lib/esm/assets/Audios.js +1 -0
  136. package/lib/esm/assets/Icons.js +11 -0
  137. package/lib/esm/common/Constants.js +28 -138
  138. package/lib/esm/common/KeyCodes.js +0 -2
  139. package/lib/esm/common/contextDataStore/DataStoreManager.js +0 -2
  140. package/lib/esm/common/storage/default/defaultCacheManager.js +16 -0
  141. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +95 -0
  142. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
  143. package/lib/esm/common/telemetry/TelemetryConstants.js +80 -17
  144. package/lib/esm/common/telemetry/TelemetryHelper.js +27 -44
  145. package/lib/esm/common/telemetry/TelemetryManager.js +14 -23
  146. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  147. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  148. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +49 -23
  149. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -10
  150. package/lib/esm/common/utils.js +73 -45
  151. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +21 -16
  152. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +23 -13
  153. package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  154. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +13 -46
  155. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +8 -15
  156. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
  157. package/lib/esm/components/footerstateful/FooterStateful.js +15 -26
  158. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -37
  159. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
  160. package/lib/esm/components/headerstateful/HeaderStateful.js +24 -20
  161. package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
  162. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +30 -0
  163. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +11 -0
  164. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  165. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +25 -0
  166. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +55 -0
  167. package/lib/esm/components/livechatwidget/common/Deferred.js +28 -0
  168. package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
  169. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -4
  170. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
  171. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
  172. package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
  173. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +83 -46
  174. package/lib/esm/components/livechatwidget/common/endChat.js +131 -50
  175. package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
  176. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +10 -12
  177. package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
  178. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +60 -26
  179. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +129 -50
  180. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +9 -23
  181. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -6
  182. package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
  183. package/lib/esm/components/livechatwidget/common/startChat.js +161 -61
  184. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  185. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
  186. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +302 -92
  187. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +4 -5
  188. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
  189. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -4
  190. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -11
  191. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  192. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
  193. package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  194. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  195. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +15 -29
  196. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +29 -13
  197. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  198. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -6
  199. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
  200. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  201. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  202. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  203. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +9 -18
  204. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -11
  205. package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
  206. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -17
  207. package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
  208. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  209. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  210. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -0
  211. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +0 -2
  212. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  213. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  214. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  215. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  216. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  217. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  218. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  219. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  220. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
  221. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
  222. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +34 -66
  223. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +11 -11
  224. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -39
  225. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
  226. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
  227. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
  228. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  229. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
  230. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
  231. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
  232. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
  233. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
  234. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
  235. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +3 -3
  236. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +7 -14
  237. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +3 -3
  238. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +15 -19
  239. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
  240. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -29
  241. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
  242. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +9 -14
  243. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +16 -14
  244. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
  245. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
  246. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
  247. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
  248. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
  249. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
  250. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
  251. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +27 -0
  252. package/lib/esm/contexts/ChatAdapterStore.js +2 -1
  253. package/lib/esm/contexts/ChatContextStore.js +2 -1
  254. package/lib/esm/contexts/ChatSDKStore.js +2 -1
  255. package/lib/esm/contexts/common/ConversationState.js +4 -3
  256. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -9
  257. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +14 -6
  258. package/lib/esm/contexts/createReducer.js +150 -103
  259. package/lib/esm/controller/componentController.js +6 -5
  260. package/lib/esm/hooks/useChatAdapterStore.js +0 -4
  261. package/lib/esm/hooks/useChatContextStore.js +0 -4
  262. package/lib/esm/hooks/useChatSDKStore.js +0 -4
  263. package/lib/esm/plugins/newMessageEventHandler.js +71 -0
  264. package/lib/types/assets/Audios.d.ts +1 -0
  265. package/lib/types/assets/Icons.d.ts +11 -0
  266. package/lib/types/common/Constants.d.ts +27 -2
  267. package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
  268. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  269. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  270. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  271. package/lib/types/common/telemetry/TelemetryConstants.d.ts +55 -4
  272. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  273. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -4
  274. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  275. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  276. package/lib/types/common/utils.d.ts +8 -1
  277. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  278. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  279. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +5 -1
  280. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  281. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  282. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  283. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  284. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  285. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  286. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  287. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  288. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +7 -2
  289. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  290. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  291. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  292. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  293. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  294. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +4 -3
  295. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  296. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
  297. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  298. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  299. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -2
  300. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  301. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -0
  302. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  303. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  304. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  305. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +4 -1
  306. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  307. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  308. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  309. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  310. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  311. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  312. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  313. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
  314. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
  315. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  316. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  317. package/lib/types/contexts/common/ConversationState.d.ts +4 -2
  318. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +4 -2
  319. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +12 -9
  320. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  321. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  322. package/package.json +12 -13
  323. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  324. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  325. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  326. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  327. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  328. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  329. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  330. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  331. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  332. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  333. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  334. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  335. package/lib/esm/assets/assets.d.js +0 -0
  336. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  337. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  338. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  339. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  340. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  341. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  342. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  343. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  344. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  345. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  346. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  347. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,34 +1,25 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
+ import { ConfirmationPane } from "@microsoft/omnichannel-chat-components";
2
3
  import React, { useEffect } from "react";
3
4
  import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
4
- import { BroadcastService, ConfirmationPane } from "@microsoft/omnichannel-chat-components";
5
5
  import { DimLayer } from "../dimlayer/DimLayer";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
7
  import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
8
8
  import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
9
- import { PostChatSurveyMode } from "../postchatsurveypanestateful/enums/PostChatSurveyMode";
10
9
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
11
10
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
12
11
  import useChatContextStore from "../../hooks/useChatContextStore";
13
- import useChatSDKStore from "../../hooks/useChatSDKStore";
14
- import { Constants } from "../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
12
 
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
14
  export const ConfirmationPaneStateful = props => {
17
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
18
-
19
15
  const initialTabIndexMap = new Map();
20
- let elements = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
-
22
- const chatSDK = useChatSDKStore();
16
+ let elements = [];
23
17
  const [state, dispatch] = useChatContextStore();
24
18
  const {
25
- endChat
26
- } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ prepareEndChat
20
+ } = props;
27
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
-
29
22
  const [adapter] = useChatAdapterStore();
30
- const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
31
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
32
23
  const controlProps = {
33
24
  id: "oc-lcw-confirmation-pane",
34
25
  dir: state.domainStates.globalDir,
@@ -41,30 +32,9 @@ export const ConfirmationPaneStateful = props => {
41
32
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
42
33
  payload: false
43
34
  });
44
-
45
35
  try {
46
- // check agent has joined conversation
47
- const conversationDetails = await chatSDK.getConversationDetails();
48
-
49
- if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed && conversationDetails.canRenderPostChat === Constants.truePascal) {
50
- const loadPostChatEvent = {
51
- eventName: "LoadPostChatSurvey"
52
- };
53
- BroadcastService.postMessage(loadPostChatEvent);
54
- } else {
55
- setTabIndices(elements, initialTabIndexMap, true);
56
-
57
- try {
58
- await endChat(adapter);
59
- } catch (error) {
60
- TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
61
- Event: TelemetryEvent.CloseChatMethodException,
62
- ExceptionDetails: {
63
- exception: `Failed to endChat: ${error}`
64
- }
65
- });
66
- }
67
- }
36
+ setTabIndices(elements, initialTabIndexMap, true);
37
+ await prepareEndChat(adapter, state);
68
38
  } catch (ex) {
69
39
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
70
40
  Event: TelemetryEvent.GetConversationDetailsCallFailed,
@@ -84,31 +54,28 @@ export const ConfirmationPaneStateful = props => {
84
54
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
85
55
  payload: false
86
56
  });
87
- const previousFocused = state.appStates.previousElementOnFocusBeforeModalOpen;
88
-
89
- if (previousFocused) {
90
- setFocusOnElement(previousFocused);
57
+ const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
58
+ if (previousFocusedElementId) {
59
+ setFocusOnElement("#" + previousFocusedElementId);
91
60
  dispatch({
92
- type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT,
61
+ type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
93
62
  payload: null
94
63
  });
95
64
  } else {
96
65
  setFocusOnSendBox();
97
66
  }
98
-
99
67
  setTabIndices(elements, initialTabIndexMap, true);
100
68
  },
101
69
  ...(props === null || props === void 0 ? void 0 : props.controlProps)
102
- }; // Move focus to the first button
70
+ };
103
71
 
72
+ // Move focus to the first button
104
73
  useEffect(() => {
105
74
  preventFocusToMoveOutOfElement(controlProps.id);
106
75
  const focusableElements = findAllFocusableElement(`#${controlProps.id}`);
107
-
108
76
  if (focusableElements) {
109
77
  focusableElements[0].focus();
110
78
  }
111
-
112
79
  elements = findParentFocusableElementsWithoutChildContainer(controlProps.id);
113
80
  setTabIndices(elements, initialTabIndexMap, false);
114
81
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -12,34 +12,29 @@ import useChatContextStore from "../../hooks/useChatContextStore";
12
12
  import useChatSDKStore from "../../hooks/useChatSDKStore";
13
13
  export const EmailTranscriptPaneStateful = props => {
14
14
  var _props$controlProps;
15
-
16
15
  const initialTabIndexMap = new Map();
17
16
  let elements = [];
18
- const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
-
17
+ const [state, dispatch] = useChatContextStore();
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
19
  const chatSDK = useChatSDKStore();
21
20
  const [initialEmail, setInitialEmail] = useState("");
22
-
23
21
  const closeEmailTranscriptPane = () => {
24
22
  dispatch({
25
23
  type: LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
26
24
  payload: false
27
25
  });
28
- const previousFocused = state.appStates.previousElementOnFocusBeforeModalOpen;
29
-
30
- if (previousFocused) {
31
- setFocusOnElement(previousFocused);
26
+ const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
27
+ if (previousFocusedElementId) {
28
+ setFocusOnElement("#" + previousFocusedElementId);
32
29
  } else {
33
30
  setFocusOnSendBox();
34
31
  }
35
-
36
32
  dispatch({
37
- type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT,
33
+ type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
38
34
  payload: null
39
35
  });
40
36
  setTabIndices(elements, initialTabIndexMap, true);
41
37
  };
42
-
43
38
  const controlProps = {
44
39
  id: "oclcw-emailTranscriptDialogContainer",
45
40
  dir: state.domainStates.globalDir,
@@ -49,7 +44,6 @@ export const EmailTranscriptPaneStateful = props => {
49
44
  emailAddress: email,
50
45
  attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
51
46
  };
52
-
53
47
  try {
54
48
  await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
55
49
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
@@ -78,16 +72,15 @@ export const EmailTranscriptPaneStateful = props => {
78
72
  },
79
73
  ...props.controlProps,
80
74
  inputInitialText: ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.inputInitialText) ?? initialEmail
81
- }; // Move focus to the first button
75
+ };
82
76
 
77
+ // Move focus to the first button
83
78
  useEffect(() => {
84
79
  preventFocusToMoveOutOfElement(controlProps.id);
85
80
  const focusableElements = findAllFocusableElement(`#${controlProps.id}`);
86
-
87
81
  if (focusableElements) {
88
82
  focusableElements[0].focus();
89
83
  }
90
-
91
84
  elements = findParentFocusableElementsWithoutChildContainer(controlProps.id);
92
85
  setTabIndices(elements, initialTabIndexMap, false);
93
86
  setInitialEmail(state.appStates.preChatResponseEmail);
@@ -19,10 +19,10 @@ describe("EmailTranscriptPaneStateful unit test", () => {
19
19
  attachmentMessage: "sample",
20
20
  locale: "sample"
21
21
  };
22
-
23
22
  try {
24
23
  await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
25
- expect(chatSDK.emailLiveChatTranscript).toHaveBeenCalledTimes(1); // eslint-disable-next-line no-empty
24
+ expect(chatSDK.emailLiveChatTranscript).toHaveBeenCalledTimes(1);
25
+ // eslint-disable-next-line no-empty
26
26
  } catch (ex) {}
27
27
  });
28
28
  it("Method emailLiveChatTranscript throws exception", async () => {
@@ -39,9 +39,9 @@ describe("EmailTranscriptPaneStateful unit test", () => {
39
39
  attachmentMessage: "sample",
40
40
  locale: "sample"
41
41
  };
42
-
43
42
  try {
44
- await chatSDK.emailLiveChatTranscript(chatTranscriptBody); // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
45
  } catch (ex) {
46
46
  expect(ex.message).toEqual(errorMessage);
47
47
  }
@@ -59,9 +59,9 @@ describe("EmailTranscriptPaneStateful unit test", () => {
59
59
  attachmentMessage: "sample",
60
60
  locale: "sample"
61
61
  };
62
-
63
62
  try {
64
- await chatSDK.emailLiveChatTranscript(chatTranscriptBody); // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+ await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
65
  } catch (ex) {
66
66
  expect(ex.message).toEqual(errorMessage);
67
67
  }
@@ -4,28 +4,28 @@ import AudioNotificationStateful from "./audionotificationstateful/AudioNotifica
4
4
  import { Constants } from "../../common/Constants";
5
5
  import { Footer } from "@microsoft/omnichannel-chat-components";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
+ import { NewMessageNotificationSoundBase64 } from "../../assets/Audios";
7
8
  import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
8
9
  import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
9
10
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
10
11
  import { downloadTranscript } from "./downloadtranscriptstateful/DownloadTranscriptStateful";
11
12
  import useChatContextStore from "../../hooks/useChatContextStore";
12
13
  import useChatSDKStore from "../../hooks/useChatSDKStore";
13
- import newMessageNotification from "../../assets/audios/newMessageNotification.mp3"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
 
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
16
  export const FooterStateful = props => {
16
17
  var _footerProps$controlP3, _footerProps$controlP4;
17
-
18
- const [state, dispatch] = useChatContextStore(); // hideFooterDisplay - the purpose of this is to keep the footer always "active",
18
+ const [state, dispatch] = useChatContextStore();
19
+ // hideFooterDisplay - the purpose of this is to keep the footer always "active",
19
20
  // but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
20
21
  // The reason for this approach is to make sure that state variables for audio notification work correctly after minimizing
21
-
22
22
  const {
23
23
  footerProps,
24
24
  downloadTranscriptProps,
25
25
  audioNotificationProps,
26
26
  hideFooterDisplay
27
- } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
-
27
+ } = props;
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
29
  const chatSDK = useChatSDKStore();
30
30
  const controlProps = {
31
31
  id: "oc-lcw-footer",
@@ -49,21 +49,17 @@ export const FooterStateful = props => {
49
49
  },
50
50
  onEmailTranscriptClick: () => {
51
51
  var _footerProps$controlP, _footerProps$controlP2;
52
-
53
52
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
54
53
  Event: TelemetryEvent.EmailTranscriptButtonClicked,
55
54
  Description: "Email Transcript button clicked."
56
55
  });
57
- const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ?? "oc-lcw-footer-emailtranscript-button";
58
- const emailTranscriptButton = document.getElementById(emailTranscriptButtonId);
59
-
60
- if (emailTranscriptButton) {
56
+ const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ?? `${controlProps.id}-emailtranscript-button`;
57
+ if (emailTranscriptButtonId) {
61
58
  dispatch({
62
- type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT,
63
- payload: emailTranscriptButton
59
+ type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
60
+ payload: emailTranscriptButtonId
64
61
  });
65
62
  }
66
-
67
63
  dispatch({
68
64
  type: LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
69
65
  payload: true
@@ -80,25 +76,18 @@ export const FooterStateful = props => {
80
76
  });
81
77
  },
82
78
  ...(footerProps === null || footerProps === void 0 ? void 0 : footerProps.controlProps),
83
- audioNotificationButtonProps: { ...(footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP3 = footerProps.controlProps) === null || _footerProps$controlP3 === void 0 ? void 0 : _footerProps$controlP3.audioNotificationButtonProps),
79
+ audioNotificationButtonProps: {
80
+ ...(footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP3 = footerProps.controlProps) === null || _footerProps$controlP3 === void 0 ? void 0 : _footerProps$controlP3.audioNotificationButtonProps),
84
81
  isAudioMuted: state.appStates.isAudioMuted
85
82
  }
86
83
  };
87
- const footerId = (controlProps === null || controlProps === void 0 ? void 0 : controlProps.id) ?? "oc-lcw-footer";
88
- const footer = document.getElementById(footerId);
89
-
90
- if (footer) {
91
- footer.style.display = hideFooterDisplay ? "none" : "";
92
- }
93
-
94
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Footer, {
84
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
95
85
  componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
96
86
  controlProps: controlProps,
97
87
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
98
88
  }), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
99
- audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? newMessageNotification,
100
- hideAudioNotificationButton: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false,
101
- isAudioMuted: state.appStates.isAudioMuted ?? false
89
+ audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
90
+ isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
102
91
  }));
103
92
  };
104
93
  export default FooterStateful;
@@ -3,27 +3,21 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
3
3
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
4
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
5
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
6
-
7
6
  const processDisplayName = displayName => {
8
7
  // if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
9
8
  const displayNameRegex = ".+:.+";
10
9
  const matchedTeamsDisplayName = displayName.match(displayNameRegex);
11
-
12
10
  if (displayName.indexOf("teamsvisitor") >= 0 && matchedTeamsDisplayName && matchedTeamsDisplayName.length > 0) {
13
11
  displayName = "Customer";
14
12
  }
15
-
16
13
  return displayName;
17
14
  };
18
-
19
15
  const constructIconName = displayName => {
20
16
  if (!displayName) {
21
17
  return "";
22
18
  }
23
-
24
19
  let iconName = "C";
25
20
  const displayNameSplit = displayName.split(" ");
26
-
27
21
  if (displayNameSplit.length > 1) {
28
22
  // get the first letter of name and surname
29
23
  iconName = displayNameSplit[0][0] + displayNameSplit[1][0];
@@ -31,55 +25,42 @@ const constructIconName = displayName => {
31
25
  // get the first letter of name
32
26
  iconName = displayNameSplit[0][0];
33
27
  }
34
-
35
28
  return iconName;
36
29
  };
37
-
38
30
  const processCreatedDateTime = (createdDateTime, chatCount) => {
39
- const formattedDate = new Date(createdDateTime); // TODO: Localization:
40
-
41
- const formattedTimeString = formattedDate.toLocaleTimeString("en-us"
42
- /* Bootstrapper.LiveChatConfiguration.chatWidgetLocale */
43
- , {
31
+ const formattedDate = new Date(createdDateTime);
32
+ // TODO: Localization:
33
+ const formattedTimeString = formattedDate.toLocaleTimeString("en-us" /* Bootstrapper.LiveChatConfiguration.chatWidgetLocale */, {
44
34
  hour: "2-digit",
45
35
  minute: "2-digit"
46
36
  });
47
37
  const formattedSplitTimeString = formattedTimeString.split(" ");
48
38
  let finalizedTimeString = "";
49
-
50
39
  if (formattedSplitTimeString && formattedSplitTimeString.length > 1) {
51
40
  finalizedTimeString = formattedSplitTimeString[0] + " " + formattedSplitTimeString[1];
52
41
  }
53
-
54
42
  if (chatCount == 0) {
55
43
  return formattedDate.toLocaleDateString("en-us") + " " + finalizedTimeString;
56
44
  }
57
-
58
45
  return finalizedTimeString;
59
46
  };
60
-
61
47
  const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
62
48
  if (transcriptContent.toString().toLowerCase().indexOf(TranscriptConstants.TranscriptMessageEmojiMessageType) >= 0) {
63
49
  // eslint-disable-next-line no-useless-escape
64
50
  const emojiRegex = "<img src=\"http.*:\/\/.+\/objects\/.+\/views.+\">";
65
51
  const matchedEmojiImgTag = transcriptContent.match(emojiRegex);
66
-
67
52
  if (matchedEmojiImgTag && matchedEmojiImgTag.length > 0 && transcriptContent.toString().toLowerCase().indexOf(matchedEmojiImgTag[0]) >= 0) {
68
53
  transcriptContent = transcriptContent.replace(matchedEmojiImgTag[0], "");
69
54
  }
70
55
  }
71
-
72
56
  if (!isAgentChat && transcriptContent.toString().toLowerCase().indexOf("a href") >= 0 && transcriptContent.toString().toLowerCase().indexOf("target") >= 0) {
73
57
  transcriptContent = transcriptContent.slice(0, transcriptContent.toString().indexOf("target")) + " style='color:white' " + transcriptContent.slice(transcriptContent.toString().indexOf("target"));
74
58
  }
75
-
76
59
  if (renderMarkDown) {
77
60
  transcriptContent = renderMarkDown(transcriptContent);
78
61
  }
79
-
80
62
  return transcriptContent;
81
63
  };
82
-
83
64
  const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMessage) => {
84
65
  const chats = JSON.parse(chatTranscripts).reverse();
85
66
  const docTypeTag = "<!DOCTYPE html>";
@@ -94,8 +75,9 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
94
75
  let tabIndex = 1;
95
76
  const mainTranscriptSection = "<div class='allTranscripts' style='max-width:60%;min-width:30%;margin-left:20%;background-color:#FFFFFF;'>";
96
77
  let previousDisplayName = "";
97
- let chatCount = 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ let chatCount = 0;
98
79
 
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
81
  chats.forEach(value => {
100
82
  let dialogNameMarginTop = "6px";
101
83
  let dialogboxMarginleft = "40px";
@@ -105,8 +87,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
105
87
  let fileAttachmentName = TranscriptConstants.DefaultFileAttachmentName;
106
88
  let dialogColor = TranscriptConstants.CustomerDialogColor;
107
89
  let fontColor = TranscriptConstants.CustomerFontColor;
108
-
109
- if (value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1 || value.isControlMessage && value.isControlMessage === true || value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType || value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode) {
90
+ const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1;
91
+ const isControlMessage = value.isControlMessage && value.isControlMessage === true;
92
+ const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType;
93
+ const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode;
94
+ const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.hiddenTag.toLowerCase()) !== -1;
95
+ const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
96
+ if (shouldIgnoreMessage) {
110
97
  return;
111
98
  } else if (value.from) {
112
99
  if (value.from.application) {
@@ -121,19 +108,15 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
121
108
  displayName = value.from.user.displayName;
122
109
  dialogColor = TranscriptConstants.CustomerDialogColor;
123
110
  }
124
-
125
111
  displayName = processDisplayName(displayName);
126
112
  iconName = constructIconName(displayName);
127
-
128
113
  if (value.attachments && value.attachments.length > 0 && value.attachments[0].name) {
129
114
  fileAttachmentName = value.attachments[0].name;
130
- value.content = attachmentMessage ?? "The following attachment was uploaded during the conversation:" + fileAttachmentName;
115
+ value.content = attachmentMessage ? attachmentMessage + " " + fileAttachmentName : "The following attachment was uploaded during the conversation: " + fileAttachmentName;
131
116
  }
132
117
  }
133
-
134
118
  let displayNamePlaceholder = processCreatedDateTime(value.createdDateTime, chatCount);
135
119
  let iconPara = "";
136
-
137
120
  if (displayName !== previousDisplayName) {
138
121
  dialogboxMarginleft = "0px";
139
122
  displayNamePlaceholder = "<b>" + displayName + " </b> " + processCreatedDateTime(value.createdDateTime, chatCount);
@@ -144,17 +127,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
144
127
  </div>";
145
128
  tabIndex++;
146
129
  }
147
-
148
130
  if (displayName !== previousDisplayName) {
149
131
  if (previousDisplayName === "") {
150
132
  dialogNameMarginTop = "0px";
151
133
  }
152
-
153
134
  if (previousDisplayName !== "") {
154
135
  dialogNameMarginTop = "20px";
155
136
  }
156
137
  }
157
-
158
138
  const displayNameDiv = "<div style='margin-right:-2px;margin-top:" + dialogNameMarginTop + ";margin-bottom:-2px;margin-left:42px;top:-2px;position:relative;'>\
159
139
  <font tabindex ='" + tabIndex + "' size = '1px' color='#000000' style='font-family:Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;font-weight:500;'>\
160
140
  " + displayNamePlaceholder + "\
@@ -168,16 +148,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
168
148
  });
169
149
  const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
170
150
  return str;
171
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
-
151
+ };
173
152
 
153
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
154
  export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage) => {
175
155
  let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript());
176
-
177
156
  if (typeof data === Constants.String) {
178
157
  data = JSON.parse(data);
179
158
  }
180
-
181
159
  if (data[Constants.ChatMessagesJson] !== null && data[Constants.ChatMessagesJson] !== undefined) {
182
160
  const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
183
161
  const byteCharacters = decodeURIComponent(window.atob(chatTranscripts));
@@ -14,10 +14,10 @@ describe("DownloadTranscriptStateful unit test", () => {
14
14
  };
15
15
  const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
16
16
  jest.spyOn(chatSDK, "getLiveChatTranscript").mockResolvedValue(Promise.resolve());
17
-
18
17
  try {
19
18
  await chatSDK.getLiveChatTranscript();
20
- expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1); // eslint-disable-next-line no-empty
19
+ expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1);
20
+ // eslint-disable-next-line no-empty
21
21
  } catch (ex) {}
22
22
  });
23
23
  it("Method getLiveChatTranscript throws exception", async () => {
@@ -29,9 +29,9 @@ describe("DownloadTranscriptStateful unit test", () => {
29
29
  };
30
30
  const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
31
31
  jest.spyOn(chatSDK, "getLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
32
-
33
32
  try {
34
- await chatSDK.getLiveChatTranscript(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ await chatSDK.getLiveChatTranscript();
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
35
  } catch (ex) {
36
36
  expect(ex.message).toEqual(errorMessage);
37
37
  }
@@ -44,9 +44,9 @@ describe("DownloadTranscriptStateful unit test", () => {
44
44
  widgetId: ""
45
45
  };
46
46
  const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
47
-
48
47
  try {
49
- await chatSDK.getLiveChatTranscript(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ await chatSDK.getLiveChatTranscript();
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
50
  } catch (ex) {
51
51
  expect(ex.message).toEqual(errorMessage);
52
52
  }
@@ -1,5 +1,5 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import React, { useEffect, useState } from "react";
2
+ import React, { useEffect, useRef, useState } from "react";
3
3
  import { ConversationState } from "../../contexts/common/ConversationState";
4
4
  import { Header } from "@microsoft/omnichannel-chat-components";
5
5
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
@@ -9,18 +9,18 @@ import useChatAdapterStore from "../../hooks/useChatAdapterStore";
9
9
  import useChatContextStore from "../../hooks/useChatContextStore";
10
10
  export const HeaderStateful = props => {
11
11
  var _state$domainStates$l, _state$domainStates$l2, _headerProps$controlP, _headerProps$controlP2, _headerProps$controlP3, _outOfOfficeHeaderPro;
12
-
13
- const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
-
12
+ const [state, dispatch] = useChatContextStore();
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
14
  const [adapter] = useChatAdapterStore();
16
15
  const {
17
16
  headerProps,
18
17
  outOfOfficeHeaderProps,
19
18
  endChat
20
- } = props; //Setting OutOfOperatingHours Flag
21
-
19
+ } = props;
20
+ //Setting OutOfOperatingHours Flag
22
21
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
23
22
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
23
+ const conversationState = useRef(state.appStates.conversationState);
24
24
  const controlProps = {
25
25
  id: "oc-lcw-header",
26
26
  dir: state.domainStates.globalDir,
@@ -35,32 +35,33 @@ export const HeaderStateful = props => {
35
35
  });
36
36
  },
37
37
  onCloseClick: async () => {
38
+ var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
38
39
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
39
40
  Event: TelemetryEvent.HeaderCloseButtonClicked,
40
41
  Description: "Header Close button clicked."
41
42
  });
42
-
43
- if (state.appStates.conversationState === ConversationState.Active) {
43
+ if (conversationState.current === ConversationState.Active) {
44
44
  dispatch({
45
45
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
46
46
  payload: true
47
47
  });
48
- } else if (state.appStates.conversationState === ConversationState.Postchat) {
48
+ } else {
49
+ const skipEndChatSDK = true;
50
+ const skipCloseChat = false;
51
+ const postMessageToOtherTabs = true;
52
+ await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
53
+ }
54
+ const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
55
+ if (closeButtonId) {
49
56
  dispatch({
50
- type: LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
51
- payload: false
57
+ type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
58
+ payload: closeButtonId
52
59
  });
53
- await endChat(adapter);
54
60
  }
55
-
56
- dispatch({
57
- type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT,
58
- payload: document.getElementById(`${controlProps.id}-closebutton`)
59
- });
60
61
  },
61
62
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
62
- hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
63
- hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
63
+ hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
64
+ hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
64
65
  hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
65
66
  };
66
67
  const outOfOfficeControlProps = {
@@ -82,7 +83,10 @@ export const HeaderStateful = props => {
82
83
  if (state.appStates.outsideOperatingHours) {
83
84
  setOutOfOperatingHours(true);
84
85
  }
85
- }, []);
86
+ if (state.appStates.conversationState) {
87
+ conversationState.current = state.appStates.conversationState;
88
+ }
89
+ }, [state.appStates]);
86
90
  return /*#__PURE__*/React.createElement(Header, {
87
91
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
88
92
  controlProps: outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeControlProps : controlProps,
@@ -7,8 +7,8 @@ import { createReducer } from "../../contexts/createReducer";
7
7
  import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
8
8
  export const LiveChatWidget = props => {
9
9
  const reducer = createReducer();
10
- const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props)); // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
-
10
+ const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  const [adapter, setAdapter] = useState(undefined);
13
13
  return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
14
14
  value: props.chatSDK
@@ -0,0 +1,30 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ import { Deferred } from "./Deferred";
3
+ export class ActivityStreamHandler {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ /**
9
+ * Use of a deferred pattern, to hold the execution of the activity.
10
+ *
11
+ * */
12
+ static cork() {
13
+ ActivityStreamHandler.restoreDeferred = new Deferred();
14
+ ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
15
+ }
16
+
17
+ /**
18
+ * Resolve the promise, releasing it to continue with the execution of the activity.
19
+ *
20
+ * */
21
+ static uncork() {
22
+ ActivityStreamHandler.restoreDeferred.resolve();
23
+ }
24
+ }
25
+ _defineProperty(ActivityStreamHandler, "restoreDeferred", {
26
+ resolve: () => {
27
+ return "initialState";
28
+ }
29
+ });
30
+ _defineProperty(ActivityStreamHandler, "restorePromise", void 0);