@microsoft/omnichannel-chat-widget 1.8.4-main.cbab5fc → 1.8.4-main.cc63f01

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 (143) hide show
  1. package/README.md +13 -3
  2. package/lib/cjs/common/Constants.js +5 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
  7. package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +82 -0
  8. package/lib/cjs/common/utils/xssUtils.js +23 -51
  9. package/lib/cjs/common/utils.js +106 -17
  10. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +8 -1
  11. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
  12. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +36 -13
  13. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  14. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  16. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  17. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
  18. package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
  20. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
  21. package/lib/cjs/components/livechatwidget/common/endChat.js +6 -0
  22. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +186 -1
  23. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  24. package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
  25. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -5
  26. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +15 -3
  27. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
  28. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +68 -2
  29. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
  30. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +157 -34
  32. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  33. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
  34. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  35. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  38. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  39. package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -8
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +203 -0
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +81 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  53. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  54. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  55. package/lib/cjs/contexts/createReducer.js +15 -0
  56. package/lib/cjs/controller/componentController.js +13 -1
  57. package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
  58. package/lib/esm/common/Constants.js +5 -0
  59. package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
  60. package/lib/esm/common/telemetry/TelemetryConstants.js +14 -0
  61. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  62. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
  63. package/lib/esm/common/telemetry/sanitizeSasInPayload.js +75 -0
  64. package/lib/esm/common/utils/xssUtils.js +23 -51
  65. package/lib/esm/common/utils.js +99 -14
  66. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +8 -1
  67. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
  68. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +37 -14
  69. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  70. package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  72. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  73. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
  74. package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
  75. package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
  76. package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
  77. package/lib/esm/components/livechatwidget/common/endChat.js +6 -0
  78. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +186 -1
  79. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  80. package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
  81. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -6
  82. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +16 -4
  83. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
  84. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +69 -3
  85. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
  86. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
  87. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +158 -35
  88. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  89. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
  90. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  91. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  92. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
  93. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  94. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  95. package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -6
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +195 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +74 -0
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  110. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  111. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  112. package/lib/esm/contexts/createReducer.js +15 -0
  113. package/lib/esm/controller/componentController.js +13 -1
  114. package/lib/esm/plugins/newMessageEventHandler.js +20 -3
  115. package/lib/types/common/Constants.d.ts +4 -0
  116. package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
  117. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
  118. package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -2
  119. package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
  120. package/lib/types/common/utils/xssUtils.d.ts +5 -21
  121. package/lib/types/common/utils.d.ts +12 -2
  122. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  123. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
  124. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  125. package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
  126. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  127. package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
  128. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
  129. package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
  130. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +3 -0
  131. package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
  132. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +1 -1
  133. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
  134. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
  135. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
  136. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
  137. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
  138. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +12 -0
  139. package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
  140. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  141. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
  142. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  143. package/package.json +37 -9
@@ -4,11 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.defaultAdaptiveCardStyles = void 0;
7
+ var _Constants = require("../../../../common/Constants");
7
8
  const defaultAdaptiveCardStyles = {
8
9
  background: "white",
9
10
  color: "black",
10
11
  anchorColor: "blue",
11
12
  textWhiteSpace: "normal",
12
- buttonWhiteSpace: "normal"
13
+ buttonWhiteSpace: "normal",
14
+ buttonFlexWrap: "nowrap",
15
+ buttonGap: "0px",
16
+ inputFontSize: _Constants.Constants.minInputFontSize
13
17
  };
14
18
  exports.defaultAdaptiveCardStyles = defaultAdaptiveCardStyles;
@@ -23,7 +23,7 @@ const defaultWebChatStyles = {
23
23
  bubbleTextColor: "White",
24
24
  hideSendBox: false,
25
25
  hideUploadButton: true,
26
- primaryFont: "Segoe UI, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\"",
26
+ primaryFont: "Segoe UI, Arial, sans-serif",
27
27
  rootHeight: "100%",
28
28
  rootWidth: "100%",
29
29
  sendBoxTextWrap: true,
@@ -34,7 +34,7 @@ const defaultWebChatStyles = {
34
34
  suggestedActionsStackedHeight: 125,
35
35
  suggestedActionsStackedOverflow: "scroll",
36
36
  // eslint-disable-line @typescript-eslint/no-explicit-any
37
- typingAnimationDuration: 3500,
37
+ typingAnimationDuration: 4500,
38
38
  emojiSet: {
39
39
  ":)": "😊",
40
40
  ":-)": "😊",
@@ -44,11 +44,13 @@ exports.postEchoActivity = postEchoActivity;
44
44
  const postBotMessageActivity = function (activityObserver, text) {
45
45
  let tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
46
46
  let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
47
+ let fromOverride = arguments.length > 4 ? arguments[4] : undefined;
47
48
  setTimeout(() => {
48
49
  activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
49
50
  id: (0, _omnichannelChatSdk.uuidv4)(),
50
51
  from: {
51
- ...botUser
52
+ ...botUser,
53
+ ...(fromOverride ?? {})
52
54
  },
53
55
  text,
54
56
  type: "message",
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.patchCitationAnchorsForA11y = void 0;
7
+ // Accessibility helper: Merges WebChat's citation card number badge and link
8
+ // text into a single focusable element.
9
+ //
10
+ // WebChat's LinkDefinitionItem renders an <a> containing a badge <div> (number)
11
+ // and a text <div> (title). On iOS VoiceOver, these block-level descendants are
12
+ // announced as two separate focusable links (e.g. "1, link" and
13
+ // "Assessment of eligibility..., link"). Setting a combined aria-label on the
14
+ // anchor and hiding inner descendants from the accessibility tree ensures the
15
+ // whole card is announced as one link.
16
+
17
+ const CITATION_ANCHOR_SELECTOR = "a.webchat__link-definitions__list-item-box";
18
+ const PATCHED_MARKER = "ocwCitationA11yPatched";
19
+ const STYLE_TAG_ID = "ocw-citation-a11y-styles";
20
+
21
+ // Global CSS injected once per document. Neutralizes iOS Safari's per-inner-
22
+ // element tap highlight / selection / focus rectangles that otherwise make
23
+ // the "1" badge and the link text appear as separate selectable areas even
24
+ // though they are inside a single <a>.
25
+ // Strategy:
26
+ // - Make the anchor a block-level positioning parent.
27
+ // - Add a transparent ::after pseudo-element that covers the entire anchor.
28
+ // iOS Safari hit-tests that overlay as a SINGLE region, so the tap
29
+ // highlight / selection rectangle always covers the whole card instead
30
+ // of just the "1" badge or just the link text.
31
+ // - Make every descendant transparent to pointer / focus, so they can never
32
+ // become a standalone tap target.
33
+ const STYLE_RULES = `
34
+ a.webchat__link-definitions__list-item-box {
35
+ position: relative;
36
+ display: block;
37
+ isolation: isolate;
38
+ -webkit-tap-highlight-color: rgba(0, 120, 212, 0.15);
39
+ -webkit-touch-callout: none;
40
+ cursor: pointer;
41
+ }
42
+ a.webchat__link-definitions__list-item-box::after {
43
+ content: "";
44
+ position: absolute;
45
+ inset: 0;
46
+ z-index: 2;
47
+ background: transparent;
48
+ pointer-events: auto;
49
+ -webkit-tap-highlight-color: rgba(0, 120, 212, 0.15);
50
+ }
51
+ a.webchat__link-definitions__list-item-box * {
52
+ pointer-events: none;
53
+ -webkit-tap-highlight-color: transparent;
54
+ -webkit-touch-callout: none;
55
+ outline: none;
56
+ text-decoration: inherit;
57
+ cursor: inherit;
58
+ }
59
+ `;
60
+ const ensureStyleInjected = doc => {
61
+ if (!doc || typeof doc.getElementById !== "function" || doc.getElementById(STYLE_TAG_ID)) {
62
+ return;
63
+ }
64
+ const style = doc.createElement("style");
65
+ style.id = STYLE_TAG_ID;
66
+ style.textContent = STYLE_RULES;
67
+ (doc.head || doc.documentElement).appendChild(style);
68
+ };
69
+ const patchCitationAnchorsForA11y = root => {
70
+ var _defaultView;
71
+ if (!root || typeof root.querySelectorAll !== "function") {
72
+ return;
73
+ }
74
+
75
+ // Inject global CSS once per document. This covers every citation anchor
76
+ // regardless of whether our per-node patch has run on it yet.
77
+ const rootNode = root;
78
+ const doc = rootNode.ownerDocument ?? ((_defaultView = root.defaultView) === null || _defaultView === void 0 ? void 0 : _defaultView.document) ?? root ?? (typeof document !== "undefined" ? document : null);
79
+ if (doc && typeof doc.createElement === "function") {
80
+ ensureStyleInjected(doc);
81
+ }
82
+
83
+ // Also include the root itself when it matches — calls from MutationObserver
84
+ // pass the anchor element directly, which querySelectorAll wouldn't return.
85
+ const matched = new Set();
86
+ if (typeof root.matches === "function" && root.matches(CITATION_ANCHOR_SELECTOR)) {
87
+ matched.add(root);
88
+ }
89
+ root.querySelectorAll(CITATION_ANCHOR_SELECTOR).forEach(n => {
90
+ matched.add(n);
91
+ });
92
+ matched.forEach(anchor => {
93
+ var _badge$textContent, _textEl$textContent;
94
+ const badge = anchor.querySelector(".webchat__link-definitions__badge");
95
+ const textEl = anchor.querySelector(".webchat__link-definitions__list-item-text");
96
+ const identifier = (badge === null || badge === void 0 ? void 0 : (_badge$textContent = badge.textContent) === null || _badge$textContent === void 0 ? void 0 : _badge$textContent.trim()) ?? "";
97
+ // Prefer the explicit text element. For plain (non-card) citation anchors
98
+ // (no badge), fall back to the title or the anchor's own text. When a
99
+ // badge is present but no text element, avoid using anchor.textContent
100
+ // since it would duplicate the identifier.
101
+ let text = (textEl === null || textEl === void 0 ? void 0 : (_textEl$textContent = textEl.textContent) === null || _textEl$textContent === void 0 ? void 0 : _textEl$textContent.trim()) ?? "";
102
+ if (!text && !badge) {
103
+ var _anchor$getAttribute, _anchor$textContent;
104
+ text = ((_anchor$getAttribute = anchor.getAttribute("title")) === null || _anchor$getAttribute === void 0 ? void 0 : _anchor$getAttribute.trim()) || ((_anchor$textContent = anchor.textContent) === null || _anchor$textContent === void 0 ? void 0 : _anchor$textContent.trim()) || "";
105
+ }
106
+ if (!identifier && !text) {
107
+ return;
108
+ }
109
+ const combinedLabel = identifier && text ? `${identifier}, ${text}` : identifier || text;
110
+
111
+ // Always (re-)apply aria-label if absent. Setting it again with the same
112
+ // value when it already matches is a no-op for the DOM; this keeps the
113
+ // patch idempotent so React re-renders that strip the attribute heal.
114
+ const existingLabel = anchor.getAttribute("aria-label");
115
+ if (!existingLabel) {
116
+ anchor.setAttribute("aria-label", combinedLabel);
117
+ }
118
+
119
+ // Explicitly mark the anchor as a single link so iOS VoiceOver treats
120
+ // the whole card as one element.
121
+ if (!anchor.getAttribute("role")) {
122
+ anchor.setAttribute("role", "link");
123
+ }
124
+
125
+ // Nuclear a11y lockdown of EVERY descendant of the anchor (not just
126
+ // known class names, because WebChat can render additional nodes).
127
+ // iOS VoiceOver is known to split focus on block-level descendants
128
+ // inside an <a>. Applying all of the following guarantees only the
129
+ // outer <a> is a selectable a11y / focus target:
130
+ // - aria-hidden="true" removes element from the a11y tree
131
+ // - role="presentation" strips any implicit semantic role
132
+ // - inert removes element from focus + interaction
133
+ // - tabindex="-1" defensive (covers browsers without inert)
134
+ // - title removed iOS VoiceOver in WKWebView still surfaces
135
+ // elements with a `title` attribute as a
136
+ // separately swipeable item even when
137
+ // aria-hidden=true. WebChat's ItemBody sets
138
+ // title={text} on the inner link-text div,
139
+ // which is the root cause of the "two
140
+ // separate links" announcement on iOS.
141
+ // We move the title to a data-* attribute
142
+ // so any tooltip-like tooling can still
143
+ // read it, but iOS VO ignores it.
144
+ anchor.querySelectorAll("*").forEach(el => {
145
+ const inner = el;
146
+ if (inner.getAttribute("aria-hidden") !== "true") {
147
+ inner.setAttribute("aria-hidden", "true");
148
+ }
149
+ if (inner.getAttribute("role") !== "presentation") {
150
+ inner.setAttribute("role", "presentation");
151
+ }
152
+ if (inner.getAttribute("tabindex") !== "-1") {
153
+ inner.setAttribute("tabindex", "-1");
154
+ }
155
+ if (!inner.hasAttribute("inert")) {
156
+ inner.setAttribute("inert", "");
157
+ }
158
+ const innerTitle = inner.getAttribute("title");
159
+ if (innerTitle !== null) {
160
+ inner.removeAttribute("title");
161
+ if (!inner.dataset.ocwOriginalTitle) {
162
+ inner.dataset.ocwOriginalTitle = innerTitle;
163
+ }
164
+ }
165
+ if (inner.style.pointerEvents !== "none") {
166
+ inner.style.pointerEvents = "none";
167
+ }
168
+ });
169
+
170
+ // DOM-level full-bleed overlay. Inline styles are used so this works
171
+ // even when the widget renders inside a shadow DOM (where an
172
+ // injected <style> tag in document.head cannot reach). The overlay
173
+ // becomes the ONLY visible hit-test target for iOS Safari, so tapping
174
+ // anywhere on the card highlights the entire card instead of just the
175
+ // "1" badge or just the link text.
176
+ const anchorStyle = anchor.style;
177
+ if (!anchorStyle.position) {
178
+ anchorStyle.position = "relative";
179
+ }
180
+ if (!anchorStyle.display || anchorStyle.display === "inline") {
181
+ anchorStyle.display = "block";
182
+ }
183
+ const ownerDoc = anchor.ownerDocument;
184
+ const existingOverlay = anchor.querySelector(":scope > [data-ocw-citation-overlay='true']");
185
+ if (!existingOverlay && ownerDoc && typeof ownerDoc.createElement === "function") {
186
+ const overlay = ownerDoc.createElement("span");
187
+ overlay.setAttribute("aria-hidden", "true");
188
+ overlay.setAttribute("data-ocw-citation-overlay", "true");
189
+ overlay.style.cssText = ["position:absolute", "top:0", "left:0", "right:0", "bottom:0", "z-index:2", "background:transparent", "pointer-events:auto", "-webkit-tap-highlight-color:rgba(0,120,212,0.15)", "-webkit-touch-callout:none", "-webkit-user-select:none", "user-select:none", "cursor:pointer"].join(";");
190
+ anchor.appendChild(overlay);
191
+ }
192
+ anchor.dataset[PATCHED_MARKER] = "true";
193
+ });
194
+ };
195
+ exports.patchCitationAnchorsForA11y = patchCitationAnchorsForA11y;
@@ -76,15 +76,26 @@ const WebChatEventSubscribers = () => {
76
76
  // Dispatch events when connection is established
77
77
  setTimeout(() => {
78
78
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.FETCH_PERSISTENT_CHAT_HISTORY);
79
+ // The trigger activity renders the "Loading previous messages..." banner
80
+ // via LazyLoadActivity. We set webchat:sequence-id to 1 and timestamp
81
+ // to epoch+1ms so WebChat sorts this activity BEFORE all history messages
82
+ // (which have sequence-ids based on transcriptOriginalMessageId timestamps).
83
+ // Without these, WebChat places activities without a sequence-id at the
84
+ // end of the transcript, causing the banner to appear at the bottom and
85
+ // breaking the IntersectionObserver pagination trigger (the observer only
86
+ // fires on visibility transitions — if the element starts visible at the
87
+ // bottom, the initial fire is blocked by the paused state and never
88
+ // re-fires since there is no transition).
79
89
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
80
90
  activity: {
81
91
  from: {
82
92
  role: "bot"
83
93
  },
84
- timestamp: 0,
94
+ timestamp: new Date(1).toISOString(),
85
95
  type: "message",
86
96
  channelData: {
87
- tags: [_Constants.Constants.persistentChatHistoryMessagePullTriggerTag]
97
+ tags: [_Constants.Constants.persistentChatHistoryMessagePullTriggerTag],
98
+ "webchat:sequence-id": 1
88
99
  }
89
100
  }
90
101
  });