@microsoft/omnichannel-chat-widget 1.8.7 → 2.0.0-main.5ebd4eb

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 (251) hide show
  1. package/README.md +52 -5
  2. package/lib/cjs/common/Constants.js +5 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +234 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +19 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +2 -3
  7. package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +91 -0
  8. package/lib/cjs/common/utils.js +93 -17
  9. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +16 -6
  10. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -10
  11. package/lib/cjs/components/citationpanestateful/CitationDim.js +2 -3
  12. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +27 -5
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +23 -3
  14. package/lib/cjs/components/dimlayer/DimLayer.js +1 -3
  15. package/lib/cjs/components/draggable/DraggableChatWidget.js +35 -15
  16. package/lib/cjs/components/draggable/DraggableEventEmitter.js +10 -1
  17. package/lib/cjs/components/draggable/DraggableEventReceiver.js +1 -3
  18. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  19. package/lib/cjs/components/errorboundary/ErrorBoundary.js +4 -12
  20. package/lib/cjs/components/footerstateful/FooterStateful.js +18 -9
  21. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  22. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  23. package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -12
  24. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +27 -4
  25. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  26. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  27. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  28. package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
  29. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
  30. package/lib/cjs/components/livechatwidget/common/endChat.js +12 -9
  31. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +182 -1
  32. package/lib/cjs/components/livechatwidget/common/recoveryEligibilityTelemetry.js +60 -0
  33. package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
  34. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +160 -21
  35. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +16 -11
  36. package/lib/cjs/components/notificationpanestateful/NotificationPaneStateful.js +19 -12
  37. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +13 -6
  38. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  39. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +12 -5
  40. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  41. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  42. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -7
  43. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +16 -7
  44. package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +10 -2
  45. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  46. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  47. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  48. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  49. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  50. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  51. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  53. package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
  54. package/lib/cjs/components/webchatcontainerstateful/interfaces/IWebChatAction.js +17 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +22 -6
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -35
  63. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +199 -0
  64. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +29 -15
  65. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  66. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  67. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  68. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  69. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  70. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  71. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  72. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  73. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +14 -12
  74. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +16 -14
  75. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +18 -30
  76. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +10 -2
  77. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  78. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -12
  79. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  80. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +83 -0
  81. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  82. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -1
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -30
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  98. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +5 -0
  99. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  100. package/lib/cjs/contexts/createReducer.js +15 -0
  101. package/lib/cjs/controller/componentController.js +13 -1
  102. package/lib/cjs/hooks/useWindowDimensions.js +13 -5
  103. package/lib/cjs/package.json +1 -0
  104. package/lib/cjs/plugins/createChatTranscript.js +3 -4
  105. package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
  106. package/lib/esm/common/Constants.js +5 -0
  107. package/lib/esm/common/facades/FacadeChatSDK.js +235 -10
  108. package/lib/esm/common/telemetry/TelemetryConstants.js +19 -0
  109. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  110. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +2 -3
  111. package/lib/esm/common/telemetry/sanitizeSasInPayload.js +84 -0
  112. package/lib/esm/common/utils.js +88 -14
  113. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +15 -5
  114. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +19 -9
  115. package/lib/esm/components/citationpanestateful/CitationDim.js +2 -3
  116. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +26 -4
  117. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -2
  118. package/lib/esm/components/dimlayer/DimLayer.js +1 -3
  119. package/lib/esm/components/draggable/DraggableChatWidget.js +34 -14
  120. package/lib/esm/components/draggable/DraggableEventEmitter.js +10 -1
  121. package/lib/esm/components/draggable/DraggableEventReceiver.js +1 -3
  122. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  123. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -12
  124. package/lib/esm/components/footerstateful/FooterStateful.js +17 -8
  125. package/lib/esm/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  126. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  127. package/lib/esm/components/headerstateful/HeaderStateful.js +22 -10
  128. package/lib/esm/components/livechatwidget/LiveChatWidget.js +27 -4
  129. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  130. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  131. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  132. package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
  133. package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
  134. package/lib/esm/components/livechatwidget/common/endChat.js +12 -9
  135. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +182 -1
  136. package/lib/esm/components/livechatwidget/common/recoveryEligibilityTelemetry.js +52 -0
  137. package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
  138. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +159 -20
  139. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +14 -9
  140. package/lib/esm/components/notificationpanestateful/NotificationPaneStateful.js +17 -10
  141. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -5
  142. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  143. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +11 -4
  144. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  145. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  146. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -6
  147. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +15 -6
  148. package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +9 -1
  149. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  150. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  151. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  152. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  153. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  154. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  155. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  156. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  157. package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
  158. package/lib/esm/components/webchatcontainerstateful/interfaces/IWebChatAction.js +10 -1
  159. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  160. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  161. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  162. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  163. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  164. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +19 -4
  165. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  166. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -32
  167. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +193 -0
  168. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +28 -14
  169. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  170. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  171. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  172. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  173. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  174. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  175. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  176. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  177. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +13 -11
  178. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +15 -13
  179. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +17 -27
  180. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +9 -1
  181. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  182. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -10
  183. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  184. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +77 -0
  185. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  186. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -2
  187. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  188. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  189. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  190. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  191. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  192. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  193. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  194. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  195. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  196. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  197. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -31
  198. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  199. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  200. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  201. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  202. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +5 -0
  203. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  204. package/lib/esm/contexts/createReducer.js +15 -0
  205. package/lib/esm/controller/componentController.js +13 -1
  206. package/lib/esm/hooks/useWindowDimensions.js +13 -5
  207. package/lib/esm/plugins/createChatTranscript.js +3 -4
  208. package/lib/esm/plugins/newMessageEventHandler.js +20 -3
  209. package/lib/types/common/Constants.d.ts +4 -0
  210. package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
  211. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
  212. package/lib/types/common/telemetry/TelemetryConstants.d.ts +15 -2
  213. package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
  214. package/lib/types/common/utils.d.ts +3 -1
  215. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  216. package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
  217. package/lib/types/components/livechatwidget/common/recoveryEligibilityTelemetry.d.ts +17 -0
  218. package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +6 -0
  219. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
  220. package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
  221. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  222. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatAction.d.ts +16 -1
  223. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
  224. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
  225. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
  226. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
  227. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
  228. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.d.ts +2 -4
  229. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +2 -4
  230. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.d.ts +2 -4
  231. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +10 -0
  232. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +2 -4
  233. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +2 -2
  234. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +2 -4
  235. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +2 -2
  236. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +2 -4
  237. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +2 -2
  238. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.d.ts +2 -4
  239. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.d.ts +2 -4
  240. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.d.ts +2 -4
  241. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +2 -4
  242. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +2 -4
  243. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.d.ts +2 -4
  244. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.d.ts +2 -4
  245. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  246. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.d.ts +2 -4
  247. package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
  248. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  249. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
  250. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  251. package/package.json +71 -57
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { Constants, HtmlAttributeNames } from "../../../../../common/Constants";
8
8
  import DOMPurify from "dompurify";
9
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
9
10
  import { WebChatActionType } from "../../enums/WebChatActionType";
10
11
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
11
12
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
@@ -90,23 +91,25 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
90
91
  return action;
91
92
  };
92
93
 
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
94
95
  const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
95
- let {
96
- dispatch
97
- } = _ref;
96
+ let dispatch = _ref.dispatch;
98
97
  return next => action => {
99
- if (action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
98
+ if (!isWebChatAction(action)) {
99
+ return next(action);
100
+ }
101
+ let currentAction = action;
102
+ if (currentAction.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
100
103
  try {
101
- var _action$payload;
102
- const text = (_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.activity) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
104
+ var _currentAction$payloa;
105
+ const text = (_currentAction$payloa = currentAction.payload) === null || _currentAction$payloa === void 0 || (_currentAction$payloa = _currentAction$payloa.activity) === null || _currentAction$payloa === void 0 ? void 0 : _currentAction$payloa.text;
103
106
  if (text) {
104
- action = processHTMLText(action, text, honorsTargetInHTMLLinks ?? false);
107
+ currentAction = processHTMLText(currentAction, text, honorsTargetInHTMLLinks ?? false);
105
108
  }
106
109
  } catch (e) {
107
110
  let errorMessage = "Failed to validate action.";
108
111
  try {
109
- errorMessage += JSON.stringify(action);
112
+ errorMessage += JSON.stringify(currentAction);
110
113
  } catch (e) {
111
114
  errorMessage += " (unable to stringify action)";
112
115
  }
@@ -119,7 +122,7 @@ const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
119
122
  });
120
123
  }
121
124
  }
122
- return next(action);
125
+ return next(currentAction);
123
126
  };
124
127
  };
125
128
  export default htmlTextMiddleware;
@@ -2,18 +2,47 @@
2
2
 
3
3
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
4
  import { Constants } from "../../../../../common/Constants";
5
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
5
6
  import { WebChatActionType } from "../../enums/WebChatActionType";
6
7
  import { defaultWebChatStyles } from "../../../common/defaultStyles/defaultWebChatStyles";
7
8
  import { getIconText } from "../../../../../common/utils";
8
9
  let currentAgentInitials = defaultWebChatStyles.botAvatarInitials;
10
+ let currentAgentName = defaultWebChatStyles.botAvatarInitials;
9
11
 
10
12
  // Optional external updater (React context dispatch wrapper) set at runtime
11
13
  let externalInitialsUpdater;
14
+ const hasTransferTag = activity => {
15
+ var _activity$channelData;
16
+ const tags = [...(Array.isArray(activity === null || activity === void 0 || (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) ? activity.channelData.tags : []), ...(Array.isArray(activity === null || activity === void 0 ? void 0 : activity.tags) ? activity.tags : [])];
17
+ return tags.some(tag => typeof tag === "string" && tag.toLowerCase().includes("transfer"));
18
+ };
19
+ const isTransferSystemMessage = activity => {
20
+ const text = ((activity === null || activity === void 0 ? void 0 : activity.text) || "").toString();
21
+ return hasTransferTag(activity) || /\btransfer(?:red|ring)?\b/i.test(text);
22
+ };
23
+ const resetCachedAgentName = dispatch => {
24
+ if (currentAgentName !== defaultWebChatStyles.botAvatarInitials || currentAgentInitials !== defaultWebChatStyles.botAvatarInitials) {
25
+ var _externalInitialsUpda;
26
+ currentAgentName = defaultWebChatStyles.botAvatarInitials;
27
+ currentAgentInitials = defaultWebChatStyles.botAvatarInitials;
28
+ (_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 || _externalInitialsUpda(currentAgentInitials || "");
29
+ BroadcastService.postMessage({
30
+ eventName: "BotAvatarInitialsUpdated",
31
+ payload: {
32
+ initials: currentAgentInitials
33
+ }
34
+ });
35
+ dispatch({
36
+ type: "__BOT_INITIALS_UPDATED__"
37
+ });
38
+ }
39
+ };
12
40
  export const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
13
- let {
14
- dispatch
15
- } = _ref;
41
+ let dispatch = _ref.dispatch;
16
42
  return next => action => {
43
+ if (!isWebChatAction(action)) {
44
+ return next(action);
45
+ }
17
46
  if (onInitialsChange && !externalInitialsUpdater) {
18
47
  externalInitialsUpdater = onInitialsChange; // capture once
19
48
  }
@@ -21,16 +50,31 @@ export const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref =>
21
50
  var _action$payload, _activity$from;
22
51
  const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
23
52
  if (activity !== null && activity !== void 0 && (_activity$from = activity.from) !== null && _activity$from !== void 0 && _activity$from.name && activity.from.role !== Constants.userMessageTag && activity.from.name !== Constants.userMessageTag) {
24
- var _activity$channelData, _activity$tags;
53
+ var _activity$channelData2, _activity$tags;
25
54
  const agentName = activity.from.name.trim();
26
- const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 || (_activity$channelData = _activity$channelData.tags) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.includes(Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(Constants.systemMessageTag));
27
- if (!isSystemMessage && agentName) {
55
+ const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 || (_activity$channelData2 = _activity$channelData2.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(Constants.systemMessageTag));
56
+ if (isSystemMessage) {
57
+ // transfer-stale-bot-name: when a transfer system message indicates the
58
+ // conversation has been routed to a different agent, the
59
+ // previously-cached agent name must NOT linger. Otherwise the
60
+ // next non-system activity (e.g. typing indicator, welcome
61
+ // message, or the new agent's first turn before their name
62
+ // is observed) is announced to screen readers as the OLD
63
+ // agent. Reset to defaults so the next observed name takes
64
+ // effect cleanly.
65
+ if (isTransferSystemMessage(activity)) {
66
+ resetCachedAgentName(dispatch);
67
+ }
68
+ } else if (agentName) {
28
69
  const newInitials = getIconText(agentName) || currentAgentInitials;
29
- if (newInitials !== currentAgentInitials) {
30
- var _externalInitialsUpda;
70
+ const hasInitialsChanged = newInitials !== currentAgentInitials;
71
+ const hasNameChanged = agentName !== currentAgentName;
72
+ currentAgentName = agentName;
73
+ if (hasInitialsChanged) {
74
+ var _externalInitialsUpda2;
31
75
  currentAgentInitials = newInitials;
32
76
  // Notify external React context if provided
33
- (_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 || _externalInitialsUpda(currentAgentInitials || "");
77
+ (_externalInitialsUpda2 = externalInitialsUpdater) === null || _externalInitialsUpda2 === void 0 || _externalInitialsUpda2(currentAgentInitials || "");
34
78
  // Broadcast (optional) for multi-tab sync without forcing consumers
35
79
  BroadcastService.postMessage({
36
80
  eventName: "BotAvatarInitialsUpdated",
@@ -38,6 +82,8 @@ export const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref =>
38
82
  initials: currentAgentInitials
39
83
  }
40
84
  });
85
+ }
86
+ if (hasInitialsChanged || hasNameChanged) {
41
87
  // Also dispatch a no-op action into WebChat store to encourage re-render (cheap)
42
88
  dispatch({
43
89
  type: "__BOT_INITIALS_UPDATED__"
@@ -57,10 +103,10 @@ export const getOverriddenLocalizedStrings = existingOverrides => {
57
103
  };
58
104
  // Apply dynamic bot initials to alt text if not already overridden through props
59
105
  if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_SAID_ALT)) {
60
- result.ACTIVITY_BOT_SAID_ALT = `${currentAgentInitials} said:`;
106
+ result.ACTIVITY_BOT_SAID_ALT = `${currentAgentName} said:`;
61
107
  }
62
108
  if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_ATTACHED_ALT)) {
63
- result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentInitials} attached:`;
109
+ result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentName} attached:`;
64
110
  }
65
111
  return result;
66
112
  };
@@ -4,17 +4,19 @@
4
4
  * Enforces a max character limit that the sender can send to comply to Omnichannel chat services' limitation.
5
5
  ******/
6
6
 
7
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
7
8
  import { NotificationHandler } from "../../notification/NotificationHandler";
8
9
  import { NotificationScenarios } from "../../enums/NotificationScenarios";
9
10
  import { WebChatActionType } from "../../enums/WebChatActionType";
10
11
  import { WebChatMiddlewareConstants } from "../../../../../common/Constants";
11
12
 
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
14
  const createMaxMessageSizeValidator = localizedTexts => _ref => {
14
- let {
15
- dispatch
16
- } = _ref;
15
+ let dispatch = _ref.dispatch;
17
16
  return next => action => {
17
+ if (!isWebChatAction(action)) {
18
+ return next(action);
19
+ }
18
20
  if (action.type === WebChatActionType.WEB_CHAT_SET_SEND_BOX) {
19
21
  var _action$payload;
20
22
  const textLength = ((_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.text) === null || _action$payload === void 0 ? void 0 : _action$payload.length) || 0;
@@ -4,41 +4,35 @@
4
4
  * Adds necessary fields for the activity for the other middlewares to function as expected.
5
5
  ******/
6
6
 
7
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
7
8
  import { Constants } from "../../../../../common/Constants";
8
9
  import { WebChatActionType } from "../../enums/WebChatActionType";
9
-
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
11
- const preProcessingMiddleware = _ref => {
12
- let {
13
- dispatch
14
- } = _ref;
15
- return next => async action => {
16
- if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
17
- const {
18
- activity
19
- } = action.payload;
20
- if (!activity.from || activity.from.role === Constants.userMessageTag) {
21
- action = {
22
- ...action,
23
- payload: {
24
- ...action.payload,
25
- activity: {
26
- ...action.payload.activity,
27
- textFormat: Constants.markdown
28
- }
10
+ const preProcessingMiddleware = () => next => async action => {
11
+ if (!isWebChatAction(action)) {
12
+ return next(action);
13
+ }
14
+ let currentAction = action;
15
+ if (currentAction.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
16
+ const activity = currentAction.payload.activity;
17
+ if (!activity.from || activity.from.role === Constants.userMessageTag) {
18
+ currentAction = {
19
+ ...currentAction,
20
+ payload: {
21
+ ...currentAction.payload,
22
+ activity: {
23
+ ...currentAction.payload.activity,
24
+ textFormat: Constants.markdown
29
25
  }
30
- };
31
- }
26
+ }
27
+ };
32
28
  }
33
- if (action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
34
- const {
35
- activity
36
- } = action.payload;
37
- if (activity) {
38
- action.payload.activity[Constants.actionType] = WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY;
39
- }
29
+ }
30
+ if (currentAction.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
31
+ const activity = currentAction.payload.activity;
32
+ if (activity) {
33
+ currentAction.payload.activity[Constants.actionType] = WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY;
40
34
  }
41
- return next(action);
42
- };
35
+ }
36
+ return next(currentAction);
43
37
  };
44
38
  export default preProcessingMiddleware;
@@ -1,16 +1,16 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
2
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
2
3
  import { LiveChatWidgetActionType } from "../../../../../contexts/common/LiveChatWidgetActionType";
3
4
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
4
5
  import { WebChatActionType } from "../../enums/WebChatActionType";
5
6
  import { executeReducer } from "../../../../../contexts/createReducer";
6
7
  import { isEndConversationDueToOverflowActivity } from "../../../../../common/utils";
7
8
  const queueOverflowHandlingHelper = async (state, dispatch) => {
8
- const {
9
- appStates
10
- } = executeReducer(state, {
11
- type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
12
- payload: undefined
13
- });
9
+ const _executeReducer = executeReducer(state, {
10
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
11
+ payload: undefined
12
+ }),
13
+ appStates = _executeReducer.appStates;
14
14
  if (!appStates.chatDisconnectEventReceived) {
15
15
  dispatch({
16
16
  type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
@@ -24,7 +24,10 @@ const queueOverflowHandlingHelper = async (state, dispatch) => {
24
24
  };
25
25
  export const createQueueOverflowMiddleware = (state, dispatch) => () => next => action => {
26
26
  var _action$payload;
27
- if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
27
+ if (!isWebChatAction(action)) {
28
+ return next(action);
29
+ }
30
+ if (action.type == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
28
31
  const activity = action.payload.activity;
29
32
  if (isEndConversationDueToOverflowActivity(activity)) {
30
33
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
@@ -7,14 +7,16 @@
7
7
  import DOMPurify from "dompurify";
8
8
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
9
9
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
10
+ import { isWebChatAction } from "../../../interfaces/IWebChatAction";
10
11
  import { WebChatActionType } from "../../enums/WebChatActionType";
11
12
 
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
14
  const sanitizationMiddleware = _ref => {
14
- let {
15
- dispatch
16
- } = _ref;
15
+ let dispatch = _ref.dispatch;
17
16
  return next => action => {
17
+ if (!isWebChatAction(action)) {
18
+ return next(action);
19
+ }
18
20
  if (action.type === WebChatActionType.WEB_CHAT_SEND_MESSAGE) {
19
21
  try {
20
22
  var _action$payload;
@@ -1,6 +1,7 @@
1
1
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2
2
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3
3
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
7
  import { HtmlClassNames, HtmlIdNames } from "../../../../common/Constants";
@@ -10,6 +11,8 @@ import { WebChatStoreLoader } from "../WebChatStoreLoader";
10
11
  import { setFocusOnSendBox } from "../../../../common/utils";
11
12
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
12
13
  import { BroadcastEvent } from "../../../../common/telemetry/TelemetryConstants";
14
+ const LIVE_REGION_ID = "oc-lcw-notification-live-region";
15
+ const LIVE_REGION_CLEAR_DELAY_MS = 1000;
13
16
  export let NotificationHandler = /*#__PURE__*/function () {
14
17
  function NotificationHandler() {
15
18
  _classCallCheck(this, NotificationHandler);
@@ -26,9 +29,59 @@ export let NotificationHandler = /*#__PURE__*/function () {
26
29
  message
27
30
  }
28
31
  });
32
+ NotificationHandler.announceToScreenReader(message);
29
33
  NotificationHandler.setFocusOnNotificationCloseButton();
30
34
  }
31
35
  }
36
+
37
+ /**
38
+ * Announces a message immediately to screen readers via an aria-live="assertive" region.
39
+ * This ensures notifications interrupt the current screen reader output
40
+ * instead of waiting for it to finish reading other content.
41
+ */
42
+ }, {
43
+ key: "announceToScreenReader",
44
+ value: function announceToScreenReader(message) {
45
+ let liveRegion = document.getElementById(LIVE_REGION_ID);
46
+ if (!liveRegion) {
47
+ liveRegion = document.createElement("div");
48
+ liveRegion.id = LIVE_REGION_ID;
49
+ liveRegion.setAttribute("aria-live", "assertive");
50
+ liveRegion.setAttribute("role", "alert");
51
+ liveRegion.setAttribute("aria-atomic", "true");
52
+ // Visually hidden but accessible to screen readers
53
+ liveRegion.style.position = "absolute";
54
+ liveRegion.style.width = "1px";
55
+ liveRegion.style.height = "1px";
56
+ liveRegion.style.overflow = "hidden";
57
+ liveRegion.style.clip = "rect(0 0 0 0)";
58
+ liveRegion.style.clipPath = "inset(50%)";
59
+ liveRegion.style.whiteSpace = "nowrap";
60
+ const widgetContainer = document.getElementById(HtmlIdNames.MSLiveChatWidget);
61
+ (widgetContainer || document.body).appendChild(liveRegion);
62
+ }
63
+
64
+ // Clear first, then set after a microtask so the browser detects the change
65
+ // even when the same message is announced consecutively.
66
+ liveRegion.textContent = "";
67
+ requestAnimationFrame(() => {
68
+ if (liveRegion) {
69
+ liveRegion.textContent = message;
70
+ }
71
+ });
72
+
73
+ // Cancel any previous clear timer to avoid prematurely clearing a newer message
74
+ if (NotificationHandler.clearTimeoutId) {
75
+ clearTimeout(NotificationHandler.clearTimeoutId);
76
+ }
77
+
78
+ // Clear the live region after a delay so repeated identical messages still trigger
79
+ NotificationHandler.clearTimeoutId = setTimeout(() => {
80
+ if (liveRegion) {
81
+ liveRegion.textContent = "";
82
+ }
83
+ }, LIVE_REGION_CLEAR_DELAY_MS);
84
+ }
32
85
  }, {
33
86
  key: "dismissNotification",
34
87
  value: function dismissNotification(id) {
@@ -101,4 +154,5 @@ export let NotificationHandler = /*#__PURE__*/function () {
101
154
  };
102
155
  }
103
156
  }]);
104
- }();
157
+ }();
158
+ _defineProperty(NotificationHandler, "clearTimeoutId", void 0);
@@ -4,10 +4,8 @@ export function createWebChatTelemetry() {
4
4
  let isInitEventLogged = false;
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  const handleTelemetry = event => {
7
- const {
8
- level,
9
- name
10
- } = event;
7
+ const level = event.level,
8
+ name = event.name;
11
9
  const loglevel = level ? level.toUpperCase() : "";
12
10
  if ((name === null || name === void 0 ? void 0 : name.toLowerCase()) === "init" && isInitEventLogged) return;
13
11
  switch (loglevel) {
@@ -257,5 +257,10 @@ export let LiveChatWidgetActionType = /*#__PURE__*/function (LiveChatWidgetActio
257
257
  string: Sets/updates current bot avatar initials (used for dynamic refresh of persistent messages)
258
258
  */
259
259
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_AVATAR_INITIALS"] = 49] = "SET_BOT_AVATAR_INITIALS";
260
+ /*
261
+ Parameters:
262
+ true/false: Tracks if user has authenticated (pre-auth or mid-conversation) for reconnect support
263
+ */
264
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_USER_AUTHENTICATED"] = 50] = "SET_USER_AUTHENTICATED";
260
265
  return LiveChatWidgetActionType;
261
266
  }({});
@@ -38,6 +38,21 @@ export const getLiveChatWidgetContextInitialState = props => {
38
38
  if (!initialStateFromCache.domainStates.botAvatarInitials) {
39
39
  initialStateFromCache.domainStates.botAvatarInitials = defaultWebChatStyles.botAvatarInitials;
40
40
  }
41
+ // Default isUserAuthenticated to false if not present in cache
42
+ if (initialStateFromCache.appStates.isUserAuthenticated === undefined) {
43
+ initialStateFromCache.appStates.isUserAuthenticated = false;
44
+ }
45
+ // internal tracking: transient modal pane visibility must NOT survive a page
46
+ // reload. If `showConfirmationPane` / `showEmailTranscriptPane` are
47
+ // restored as `true`, the corresponding pane re-mounts and installs
48
+ // its focus trap (and sets sibling tabindex=-1). The user has no
49
+ // context for why the modal appeared and Tab from the host page can
50
+ // no longer traverse out of the widget. Always start cold for these
51
+ // ephemeral UI flags.
52
+ if (initialStateFromCache.uiStates) {
53
+ initialStateFromCache.uiStates.showConfirmationPane = false;
54
+ initialStateFromCache.uiStates.showEmailTranscriptPane = false;
55
+ }
41
56
  return initialStateFromCache;
42
57
  }
43
58
  const LiveChatWidgetContextInitialState = {
@@ -87,7 +102,8 @@ export const getLiveChatWidgetContextInitialState = props => {
87
102
  selectedSurveyMode: null,
88
103
  postChatParticipantType: undefined,
89
104
  isConversationalSurvey: false,
90
- isConversationalSurveyEnabled: false
105
+ isConversationalSurveyEnabled: false,
106
+ isUserAuthenticated: false
91
107
  },
92
108
  uiStates: {
93
109
  showConfirmationPane: false,
@@ -708,6 +708,21 @@ const reducer = (state, action) => {
708
708
  isConversationalSurvey: action.payload
709
709
  }
710
710
  };
711
+ case LiveChatWidgetActionType.SET_USER_AUTHENTICATED:
712
+ inMemory = {
713
+ ...inMemory,
714
+ appStates: {
715
+ ...inMemory.appStates,
716
+ isUserAuthenticated: action.payload
717
+ }
718
+ };
719
+ return {
720
+ ...state,
721
+ appStates: {
722
+ ...state.appStates,
723
+ isUserAuthenticated: action.payload
724
+ }
725
+ };
711
726
  case LiveChatWidgetActionType.GET_IN_MEMORY_STATE:
712
727
  return inMemory;
713
728
  default:
@@ -1,4 +1,5 @@
1
1
  import { ConversationState } from "../contexts/common/ConversationState";
2
+ import { shouldLoadPersistentChatHistory } from "../components/livechatwidget/common/liveChatConfigUtils";
2
3
  export const shouldShowChatButton = state => {
3
4
  var _state$appStates;
4
5
  return (state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed) && (state === null || state === void 0 || (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === false; // Do not show chat button in case of popout
@@ -16,7 +17,18 @@ export const shouldShowEmailTranscriptPane = state => {
16
17
  return state.uiStates.showEmailTranscriptPane;
17
18
  };
18
19
  export const shouldShowWebChatContainer = state => {
19
- return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive || state.appStates.conversationState === ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
20
+ var _state$domainStates;
21
+ const extendedChatConfig = state === null || state === void 0 || (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatConfig;
22
+ const persistentHistoryEnabled = shouldLoadPersistentChatHistory(extendedChatConfig);
23
+ const isActiveOrInactive = state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
24
+ const isPostchatSurvey = state.appStates.conversationState === ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
25
+ if (persistentHistoryEnabled) {
26
+ // Keep WebChat in DOM even when minimized (CSS hides it via visibility)
27
+ // This preserves scroll position across minimize/maximize cycles
28
+ return isActiveOrInactive || isPostchatSurvey;
29
+ }
30
+ // Original behavior - hide WebChat when minimized
31
+ return !state.appStates.isMinimized && (isActiveOrInactive || isPostchatSurvey);
20
32
  };
21
33
  export const shouldShowLoadingPane = state => {
22
34
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
@@ -1,10 +1,15 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1
7
  import { useState, useEffect } from "react";
2
8
  import useDebounce from "./useDebounce";
3
9
  function getWindowDimensions() {
4
- const {
5
- innerWidth: width,
6
- innerHeight: height
7
- } = window;
10
+ const _window = window,
11
+ width = _window.innerWidth,
12
+ height = _window.innerHeight;
8
13
  return {
9
14
  width,
10
15
  height
@@ -12,7 +17,10 @@ function getWindowDimensions() {
12
17
  }
13
18
  export default function useWindowDimensions() {
14
19
  let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
15
- const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
20
+ const _useState = useState(getWindowDimensions()),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ windowDimensions = _useState2[0],
23
+ setWindowDimensions = _useState2[1];
16
24
  const handleResize = () => setWindowDimensions(getWindowDimensions());
17
25
  const debouncedHandleResize = useDebounce(handleResize, delay);
18
26
  useEffect(() => {
@@ -718,10 +718,9 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
718
718
  if (renderAttachments) {
719
719
  messages = await Promise.all(transcriptMessages.map(async message => {
720
720
  // eslint-disable-line @typescript-eslint/no-explicit-any
721
- const {
722
- amsReferences = message.amsreferences,
723
- amsMetadata
724
- } = message;
721
+ const _message$amsReference = message.amsReferences,
722
+ amsReferences = _message$amsReference === void 0 ? message.amsreferences : _message$amsReference,
723
+ amsMetadata = message.amsMetadata;
725
724
  if (amsReferences && amsMetadata) {
726
725
  const references = JSON.parse(amsReferences);
727
726
  const metadata = JSON.parse(amsMetadata);
@@ -14,6 +14,8 @@ export const createOnNewAdapterActivityHandler = (chatId, userId, startTime) =>
14
14
  // this is a workaround for the fact that we dont have a way to identify if a message is history or new, and it will provide consistency across different scenarios
15
15
 
16
16
  let isHistoryMessageReceivedEventRaised = false;
17
+ let isInQueue = false;
18
+ let agentJoinLogged = false;
17
19
  const onNewAdapterActivityHandler = activity => {
18
20
  raiseMessageEvent(activity);
19
21
  };
@@ -35,9 +37,14 @@ export const createOnNewAdapterActivityHandler = (chatId, userId, startTime) =>
35
37
  });
36
38
  };
37
39
  const systemMessageStrategy = activity => {
38
- var _TelemetryManager$Int3;
40
+ var _activity$channelData, _TelemetryManager$Int3;
39
41
  const payload = buildMessagePayload(activity, userId);
40
42
  payload.messageType = Constants.systemMessageTag;
43
+
44
+ // Track queue entry for agent-join detection
45
+ if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData = _activity$channelData.tags) !== null && _activity$channelData !== void 0 && _activity$channelData.includes(Constants.queuePositionMessageTag)) {
46
+ isInQueue = true;
47
+ }
41
48
  if (isHistoryMessage(activity, startTime)) {
42
49
  var _TelemetryManager$Int2;
43
50
  historyMessageStrategy(polyfillMessagePayloadForEvent(activity, payload, (_TelemetryManager$Int2 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.conversationId));
@@ -70,11 +77,11 @@ export const createOnNewAdapterActivityHandler = (chatId, userId, startTime) =>
70
77
  }
71
78
  };
72
79
  const isValidMessage = activity => {
73
- var _activity$channelData, _activity$channelData2;
80
+ var _activity$channelData2, _activity$channelData3;
74
81
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
82
  const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text);
76
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && _activity$channelData.tags) || (activity === null || activity === void 0 || (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 || (_activity$channelData2 = _activity$channelData2.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.length) === 0;
84
+ const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData2 = activity.channelData) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.tags) || (activity === null || activity === void 0 || (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 || (_activity$channelData3 = _activity$channelData3.tags) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.length) === 0;
78
85
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
86
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
80
87
  if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
@@ -96,6 +103,16 @@ export const createOnNewAdapterActivityHandler = (chatId, userId, startTime) =>
96
103
  historyMessageStrategy(polyfillMessagePayloadForEvent(activity, payload, (_TelemetryManager$Int4 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId));
97
104
  return;
98
105
  }
106
+
107
+ // Log agent joining when first non-history message is received after queue
108
+ if (isInQueue && !agentJoinLogged) {
109
+ agentJoinLogged = true;
110
+ isInQueue = false;
111
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
112
+ Event: TelemetryEvent.AgentJoinedConversation,
113
+ Description: "First message received from agent after queue"
114
+ });
115
+ }
99
116
  firstResponseLatencyTracker.stopClock(payload);
100
117
  const newMessageReceivedEvent = {
101
118
  eventName: BroadcastEvent.NewMessageReceived,
@@ -58,6 +58,8 @@ export declare class Constants {
58
58
  static readonly videoMediaRegex: RegExp;
59
59
  static readonly chromeSupportedInlineMediaRegex: RegExp;
60
60
  static readonly firefoxSupportedInlineMediaRegex: RegExp;
61
+ static readonly AdaptiveCardType = "adaptivecard";
62
+ static readonly SuggestedActionsType = "suggestedactions";
61
63
  static readonly CallAdded = "callAdded";
62
64
  static readonly LocalVideoStreamAdded = "localVideoStreamAdded";
63
65
  static readonly LocalVideoStreamRemoved = "localVideoStreamRemoved";
@@ -108,6 +110,8 @@ export declare class Constants {
108
110
  static readonly Hidden = "Hidden";
109
111
  static readonly EndConversationDueToOverflow = "endconversationduetooverflow";
110
112
  static readonly SkipSessionCloseForPersistentChatFlag = "skipSessionCloseForPersistentChat";
113
+ static readonly minInputFontSizePx = 16;
114
+ static readonly minInputFontSize = "16px";
111
115
  }
112
116
  export declare const Regex: {
113
117
  new (): {};