@azure/communication-react 1.16.0-alpha-202404241515 → 1.16.0-alpha-202404260012

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 (48) hide show
  1. package/dist/communication-react.d.ts +12 -1
  2. package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-CwSsJHm9.js → ChatMessageComponentAsRichTextEditBox-BLhY8s2s.js} +4 -4
  3. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-BLhY8s2s.js.map +1 -0
  4. package/dist/dist-cjs/communication-react/{index-BN2-SHYR.js → index-r7pKdpFV.js} +266 -98
  5. package/dist/dist-cjs/communication-react/index-r7pKdpFV.js.map +1 -0
  6. package/dist/dist-cjs/communication-react/index.js +1 -1
  7. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  8. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  9. package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js +1 -1
  10. package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js.map +1 -1
  11. package/dist/dist-esm/calling-stateful-client/src/CallContext.d.ts +1 -0
  12. package/dist/dist-esm/calling-stateful-client/src/CallContext.js +18 -0
  13. package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
  14. package/dist/dist-esm/calling-stateful-client/src/CapabilitiesSubscriber.js +4 -0
  15. package/dist/dist-esm/calling-stateful-client/src/CapabilitiesSubscriber.js.map +1 -1
  16. package/dist/dist-esm/calling-stateful-client/src/Converter.js +12 -3
  17. package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
  18. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +28 -1
  19. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
  20. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +2 -2
  21. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -1
  22. package/dist/dist-esm/react-components/src/components/InputBoxButton.d.ts +1 -0
  23. package/dist/dist-esm/react-components/src/components/InputBoxButton.js +9 -8
  24. package/dist/dist-esm/react-components/src/components/InputBoxButton.js.map +1 -1
  25. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextTableContextMenu.js +3 -3
  26. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextTableContextMenu.js.map +1 -1
  27. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +22 -7
  28. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
  29. package/dist/dist-esm/react-components/src/components/SendBox.js +16 -6
  30. package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
  31. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +15 -0
  32. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +19 -0
  33. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
  34. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js +3 -1
  35. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js.map +1 -1
  36. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.d.ts +1 -1
  37. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.js +3 -3
  38. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.js.map +1 -1
  39. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +26 -12
  40. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +130 -66
  41. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
  42. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +11 -1
  43. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
  44. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/index.d.ts +1 -1
  45. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/index.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-CwSsJHm9.js.map +0 -1
  48. package/dist/dist-cjs/communication-react/index-BN2-SHYR.js.map +0 -1
@@ -176,7 +176,7 @@ function getDefaultExportFromCjs (x) {
176
176
  // Copyright (c) Microsoft Corporation.
177
177
  // Licensed under the MIT License.
178
178
  // GENERATED FILE. DO NOT EDIT MANUALLY.
179
- var telemetryVersion = '1.16.0-alpha-202404241515';
179
+ var telemetryVersion = '1.16.0-alpha-202404260012';
180
180
 
181
181
 
182
182
  var telemetryVersion$1 = /*@__PURE__*/getDefaultExportFromCjs(telemetryVersion);
@@ -1359,7 +1359,7 @@ const _captionsBannerSelector = reselect__namespace.createSelector([getCaptions,
1359
1359
  var _a, _b, _c;
1360
1360
  const userId = getCaptionsSpeakerIdentifier(c);
1361
1361
  return {
1362
- id: (_a = c.speaker.displayName) !== null && _a !== void 0 ? _a : 'Unnamed Participant' + index,
1362
+ id: ((_a = c.speaker.displayName) !== null && _a !== void 0 ? _a : 'Unnamed Participant') + index,
1363
1363
  displayName: (_b = c.speaker.displayName) !== null && _b !== void 0 ? _b : 'Unnamed Participant',
1364
1364
  captionText: (_c = c.captionText) !== null && _c !== void 0 ? _c : '',
1365
1365
  userId
@@ -1790,6 +1790,16 @@ function convertSdkCallToDeclarativeCall(call) {
1790
1790
  declarativeRemoteParticipants[toFlatCommunicationIdentifier(participant.identifier)] =
1791
1791
  convertSdkParticipantToDeclarativeParticipant(participant);
1792
1792
  });
1793
+ /* @conditional-compile-remove(hide-attendee-name) */
1794
+ let hideAttendeeNames = false;
1795
+ /* @conditional-compile-remove(hide-attendee-name) */
1796
+ if (call.feature(communicationCalling.Features.Capabilities).capabilities &&
1797
+ call.feature(communicationCalling.Features.Capabilities).capabilities.viewAttendeeNames) {
1798
+ const viewAttendeeNames = call.feature(communicationCalling.Features.Capabilities).capabilities.viewAttendeeNames;
1799
+ if (!viewAttendeeNames.isPresent && viewAttendeeNames.reason === 'MeetingRestricted') {
1800
+ hideAttendeeNames = true;
1801
+ }
1802
+ }
1793
1803
  return {
1794
1804
  id: call.id,
1795
1805
  /* @conditional-compile-remove(teams-identity-support) */
@@ -1841,8 +1851,7 @@ function convertSdkCallToDeclarativeCall(call) {
1841
1851
  maxRemoteVideoStreams: call.feature(communicationCalling.Features.OptimalVideoCount).optimalVideoCount
1842
1852
  },
1843
1853
  /* @conditional-compile-remove(hide-attendee-name) */
1844
- // TODO: Replace this once the SDK supports hide attendee name
1845
- hideAttendeeNames: false,
1854
+ hideAttendeeNames,
1846
1855
  /* @conditional-compile-remove(meeting-id) */
1847
1856
  info: _isACSCall(call) ? call.info : _isTeamsCall(call) ? call.info : undefined
1848
1857
  };
@@ -2315,6 +2324,24 @@ let CallContext$2 = class CallContext {
2315
2324
  }
2316
2325
  });
2317
2326
  }
2327
+ /* @conditional-compile-remove(hide-attendee-name) */
2328
+ setHideAttendeeNames(callId, capabilitiesChangeInfo) {
2329
+ this.modifyState((draft) => {
2330
+ const call = draft.calls[this._callIdHistory.latestCallId(callId)];
2331
+ if (capabilitiesChangeInfo.oldValue.viewAttendeeNames !== capabilitiesChangeInfo.newValue.viewAttendeeNames) {
2332
+ const viewAttendeeNames = capabilitiesChangeInfo.newValue.viewAttendeeNames;
2333
+ if (call &&
2334
+ viewAttendeeNames &&
2335
+ !viewAttendeeNames.isPresent &&
2336
+ viewAttendeeNames.reason === 'MeetingRestricted') {
2337
+ call.hideAttendeeNames = true;
2338
+ }
2339
+ else {
2340
+ call.hideAttendeeNames = false;
2341
+ }
2342
+ }
2343
+ });
2344
+ }
2318
2345
  /* @conditional-compile-remove(spotlight) */
2319
2346
  setSpotlight(callId, spotlightedParticipants, maxParticipantsToSpotlight) {
2320
2347
  this.modifyState((draft) => {
@@ -4044,6 +4071,10 @@ class CapabilitiesSubscriber {
4044
4071
  };
4045
4072
  this.capabilitiesChanged = (data) => {
4046
4073
  this._context.setCapabilities(this._callIdRef.callId, this._capabilitiesFeature.capabilities, data);
4074
+ /* @conditional-compile-remove(hide-attendee-name) */
4075
+ if (data.oldValue.viewAttendeeNames !== data.newValue.viewAttendeeNames) {
4076
+ this._context.setHideAttendeeNames(this._callIdRef.callId, data);
4077
+ }
4047
4078
  };
4048
4079
  this._callIdRef = callIdRef;
4049
4080
  this._context = context;
@@ -8696,7 +8727,7 @@ const iconWrapperStyle$1 = react.mergeStyles({
8696
8727
  * @private
8697
8728
  */
8698
8729
  const InputBoxButton = (props) => {
8699
- const { onRenderIcon, onClick, ariaLabel, className, id, tooltipContent, 'data-testId': dataTestId } = props;
8730
+ const { onRenderIcon, onClick, ariaLabel, className, id, tooltipContent, 'data-testId': dataTestId, ariaDisabled = false } = props;
8700
8731
  const [isHover, setIsHover] = React.useState(false);
8701
8732
  const mergedButtonStyle = react.mergeStyles(inputBoxButtonStyle, className);
8702
8733
  const theme = react.useTheme();
@@ -8708,13 +8739,14 @@ const InputBoxButton = (props) => {
8708
8739
  backgroundColor: isDarkThemed(theme) ? theme.palette.neutralLighter : ''
8709
8740
  };
8710
8741
  return (React.createElement(react.TooltipHost, { hostClassName: inputBoxButtonTooltipStyle, content: tooltipContent, calloutProps: Object.assign({}, calloutProps) },
8711
- React.createElement(react.IconButton, { className: mergedButtonStyle, ariaLabel: ariaLabel, onClick: onClick, id: id, onMouseEnter: () => {
8712
- setIsHover(true);
8713
- }, onMouseLeave: () => {
8714
- setIsHover(false);
8715
- },
8716
- // VoiceOver fix: Avoid icon from stealing focus when IconButton is double-tapped to send message by wrapping with Stack with pointerEvents style to none
8717
- onRenderIcon: () => React.createElement(react.Stack, { className: iconWrapperStyle$1 }, onRenderIcon(isHover)), "data-testid": dataTestId })));
8742
+ React.createElement(react.Stack, { "aria-disabled": ariaDisabled },
8743
+ React.createElement(react.IconButton, { className: mergedButtonStyle, ariaLabel: ariaLabel, onClick: onClick, id: id, onMouseEnter: () => {
8744
+ setIsHover(true);
8745
+ }, onMouseLeave: () => {
8746
+ setIsHover(false);
8747
+ },
8748
+ // VoiceOver fix: Avoid icon from stealing focus when IconButton is double-tapped to send message by wrapping with Stack with pointerEvents style to none
8749
+ onRenderIcon: () => React.createElement(react.Stack, { className: iconWrapperStyle$1 }, onRenderIcon(isHover)), "data-testid": dataTestId }))));
8718
8750
  };
8719
8751
 
8720
8752
  // Copyright (c) Microsoft Corporation.
@@ -9012,6 +9044,25 @@ const sanitizeText = (message) => {
9012
9044
  return message;
9013
9045
  }
9014
9046
  };
9047
+ /**
9048
+ * Determines whether the send box should be disabled for ARIA accessibility.
9049
+ *
9050
+ * @param hasContent - Indicates whether the send box has content.
9051
+ * @param hasCompletedAttachmentUploads - Indicates whether attachment uploads have completed.
9052
+ * @param hasError - Indicates whether there is an error.
9053
+ * @param disabled - Indicates whether the send box is disabled.
9054
+ * @returns A boolean value indicating whether the send box should be disabled for ARIA accessibility.
9055
+ */
9056
+ const isSendBoxButtonAriaDisabled = ({ hasContent,
9057
+ /* @conditional-compile-remove(attachment-upload) */
9058
+ hasCompletedAttachmentUploads, hasError, disabled }) => {
9059
+ return (
9060
+ // no content
9061
+ !(hasContent || /* @conditional-compile-remove(attachment-upload) */ hasCompletedAttachmentUploads) ||
9062
+ //error message exists
9063
+ hasError ||
9064
+ disabled);
9065
+ };
9015
9066
 
9016
9067
  // Copyright (c) Microsoft Corporation.
9017
9068
  // Licensed under the MIT License.
@@ -9416,8 +9467,8 @@ const SendBox = (props) => {
9416
9467
  /* @conditional-compile-remove(attachment-upload) */ hasCompletedAttachmentUploads(attachmentsWithProgress)) {
9417
9468
  onSendMessage && onSendMessage(message);
9418
9469
  setTextValue('');
9470
+ (_a = sendTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
9419
9471
  }
9420
- (_a = sendTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
9421
9472
  };
9422
9473
  const setText = (newValue) => {
9423
9474
  if (newValue === undefined) {
@@ -9432,17 +9483,27 @@ const SendBox = (props) => {
9432
9483
  const mergedStyles = React.useMemo(() => react.concatStyleSets(styles), [styles]);
9433
9484
  const mergedSendIconStyle = React.useMemo(() => sendIconStyle({
9434
9485
  theme,
9435
- hasText: !!textValue,
9486
+ hasText: sanitizeText(textValue).length > 0,
9436
9487
  /* @conditional-compile-remove(attachment-upload) */ hasAttachment: hasCompletedAttachmentUploads(attachmentsWithProgress),
9437
9488
  hasErrorMessage: !!errorMessage,
9438
- customSendIconStyle: styles === null || styles === void 0 ? void 0 : styles.sendMessageIcon
9489
+ customSendIconStyle: styles === null || styles === void 0 ? void 0 : styles.sendMessageIcon,
9490
+ disabled: !!disabled
9439
9491
  }), [
9440
9492
  theme,
9441
9493
  textValue,
9442
9494
  /* @conditional-compile-remove(attachment-upload) */ attachmentsWithProgress,
9443
9495
  errorMessage,
9444
- styles === null || styles === void 0 ? void 0 : styles.sendMessageIcon
9496
+ styles === null || styles === void 0 ? void 0 : styles.sendMessageIcon,
9497
+ disabled
9445
9498
  ]);
9499
+ const isSendBoxButtonAriaDisabledValue = React.useMemo(() => {
9500
+ return isSendBoxButtonAriaDisabled({
9501
+ hasContent: sanitizeText(textValue).length > 0,
9502
+ /* @conditional-compile-remove(attachment-upload) */ hasCompletedAttachmentUploads: hasCompletedAttachmentUploads(attachmentsWithProgress),
9503
+ hasError: !!errorMessage,
9504
+ disabled: !!disabled
9505
+ });
9506
+ }, [/* @conditional-compile-remove(attachment-upload) */ attachmentsWithProgress, disabled, errorMessage, textValue]);
9446
9507
  const onRenderSendIcon = React.useCallback((isHover) => onRenderIcon ? (onRenderIcon(isHover)) : (React.createElement(react.Icon, { iconName: isHover && textValue ? 'SendBoxSendHovered' : 'SendBoxSend', className: mergedSendIconStyle })), [mergedSendIconStyle, onRenderIcon, textValue]);
9447
9508
  // Ensure that errors are cleared when there are no attachments in sendBox
9448
9509
  /* @conditional-compile-remove(attachment-upload) */
@@ -9511,7 +9572,7 @@ const SendBox = (props) => {
9511
9572
  sendMessageOnClick();
9512
9573
  }
9513
9574
  e.stopPropagation();
9514
- }, id: 'sendIconWrapper', className: mergedSendButtonStyle, ariaLabel: localeStrings.sendButtonAriaLabel, tooltipContent: localeStrings.sendButtonAriaLabel })),
9575
+ }, id: 'sendIconWrapper', className: mergedSendButtonStyle, ariaLabel: localeStrings.sendButtonAriaLabel, tooltipContent: localeStrings.sendButtonAriaLabel, ariaDisabled: isSendBoxButtonAriaDisabledValue })),
9515
9576
  /* @conditional-compile-remove(attachment-upload) */
9516
9577
  onRenderAttachmentUploads())));
9517
9578
  };
@@ -10366,11 +10427,11 @@ const TableEditOperationMap = {
10366
10427
  };
10367
10428
  const tableEditInsertMenuItem = {
10368
10429
  key: 'menuNameTableInsert',
10369
- unlocalizedText: 'Insert123',
10430
+ unlocalizedText: 'Insert',
10370
10431
  subItems: {
10371
- menuNameTableInsertAbove: 'Insert above121312 ',
10432
+ menuNameTableInsertAbove: 'Insert above',
10372
10433
  menuNameTableInsertBelow: 'Insert below',
10373
- menuNameTableInsertLeft: 'Insert left123 ',
10434
+ menuNameTableInsertLeft: 'Insert left',
10374
10435
  menuNameTableInsertRight: 'Insert right'
10375
10436
  },
10376
10437
  onClick,
@@ -10841,8 +10902,8 @@ const RichTextSendBox = (props) => {
10841
10902
  onSendMessage(message);
10842
10903
  setContentValue('');
10843
10904
  (_b = editorComponentRef.current) === null || _b === void 0 ? void 0 : _b.setEmptyContent();
10905
+ (_c = editorComponentRef.current) === null || _c === void 0 ? void 0 : _c.focus();
10844
10906
  }
10845
- (_c = editorComponentRef.current) === null || _c === void 0 ? void 0 : _c.focus();
10846
10907
  }, [
10847
10908
  contentValue,
10848
10909
  contentValueOverflow,
@@ -10868,16 +10929,18 @@ const RichTextSendBox = (props) => {
10868
10929
  attachmentUploadsPendingError,
10869
10930
  systemMessage
10870
10931
  ]);
10871
- const onRenderSendIcon = React.useCallback((isHover) => {
10932
+ const hasContent = React.useMemo(() => {
10872
10933
  var _a;
10873
10934
  // get plain text content from the editor to check if the message is empty
10874
10935
  // as the content may contain tags even when the content is empty
10875
10936
  const plainTextContent = (_a = editorComponentRef.current) === null || _a === void 0 ? void 0 : _a.getPlainContent();
10876
- const hasContent = !isContentEmpty({
10937
+ return !isContentEmpty({
10877
10938
  plainTextContent: plainTextContent,
10878
10939
  content: contentValue,
10879
10940
  placeholder: strings.placeholderText
10880
10941
  });
10942
+ }, [contentValue, strings.placeholderText]);
10943
+ const onRenderSendIcon = React.useCallback((isHover) => {
10881
10944
  return (React.createElement(react.Icon, { iconName: isHover && hasContent ? 'SendBoxSendHovered' : 'SendBoxSend', className: sendIconStyle({
10882
10945
  theme,
10883
10946
  hasText: hasContent,
@@ -10887,7 +10950,7 @@ const RichTextSendBox = (props) => {
10887
10950
  defaultTextColor: theme.palette.neutralSecondary,
10888
10951
  disabled: disabled
10889
10952
  }) }));
10890
- }, [contentValue, disabled, hasErrorMessage, strings.placeholderText, theme]);
10953
+ }, [disabled, hasContent, hasErrorMessage, theme]);
10891
10954
  const sendBoxErrorsProps = React.useMemo(() => {
10892
10955
  var _a, _b;
10893
10956
  /* @conditional-compile-remove(attachment-upload) */
@@ -10932,12 +10995,25 @@ const RichTextSendBox = (props) => {
10932
10995
  strings.attachmentMoreMenu,
10933
10996
  theme
10934
10997
  ]);
10998
+ const isSendBoxButtonAriaDisabledValue = React.useMemo(() => {
10999
+ return isSendBoxButtonAriaDisabled({
11000
+ hasContent,
11001
+ /* @conditional-compile-remove(attachment-upload) */ hasCompletedAttachmentUploads: hasCompletedAttachmentUploads(attachmentsWithProgress),
11002
+ hasError: hasErrorMessage,
11003
+ disabled
11004
+ });
11005
+ }, [
11006
+ /* @conditional-compile-remove(attachment-upload) */ attachmentsWithProgress,
11007
+ disabled,
11008
+ hasContent,
11009
+ hasErrorMessage
11010
+ ]);
10935
11011
  const sendButton = React.useMemo(() => {
10936
11012
  return (React.createElement(InputBoxButton, { onRenderIcon: onRenderSendIcon, onClick: (e) => {
10937
11013
  sendMessageOnClick();
10938
11014
  e.stopPropagation(); // Prevents the click from bubbling up and triggering a focus event on the chat.
10939
- }, className: richTextActionButtonsStyle, ariaLabel: localeStrings.sendButtonAriaLabel, tooltipContent: localeStrings.sendButtonAriaLabel }));
10940
- }, [localeStrings.sendButtonAriaLabel, onRenderSendIcon, sendMessageOnClick]);
11015
+ }, className: richTextActionButtonsStyle, ariaLabel: localeStrings.sendButtonAriaLabel, tooltipContent: localeStrings.sendButtonAriaLabel, ariaDisabled: isSendBoxButtonAriaDisabledValue }));
11016
+ }, [isSendBoxButtonAriaDisabledValue, localeStrings.sendButtonAriaLabel, onRenderSendIcon, sendMessageOnClick]);
10941
11017
  /* @conditional-compile-remove(attachment-upload) */
10942
11018
  const hasAttachmentUploads = React.useMemo(() => {
10943
11019
  return (hasCompletedAttachmentUploads(attachmentsWithProgress) || hasIncompleteAttachmentUploads(attachmentsWithProgress));
@@ -12193,7 +12269,9 @@ const extractContentForAllyMessage = (props) => {
12193
12269
  parsedContent.appendChild(attachmentTextNode);
12194
12270
  }
12195
12271
  // Strip all html tags from the content for aria.
12196
- const message = DOMPurify.sanitize(parsedContent, { ALLOWED_TAGS: [] });
12272
+ let message = DOMPurify.sanitize(parsedContent, { ALLOWED_TAGS: [] });
12273
+ // decode HTML entities so that screen reader can read the content properly.
12274
+ message = decodeEntities(message);
12197
12275
  return message;
12198
12276
  }
12199
12277
  return '';
@@ -12268,6 +12346,31 @@ const processHtmlToReact = (props) => {
12268
12346
  };
12269
12347
  return React.createElement(React.Fragment, null, parse((_a = props.message.content) !== null && _a !== void 0 ? _a : '', options));
12270
12348
  };
12349
+ const decodeEntities = (encodedString) => {
12350
+ // This regular expression matches HTML entities.
12351
+ const translate_re = /&(nbsp|amp|quot|lt|gt);/g;
12352
+ // This object maps HTML entities to their respective characters.
12353
+ const translate = {
12354
+ nbsp: ' ',
12355
+ amp: '&',
12356
+ quot: '"',
12357
+ lt: '<',
12358
+ gt: '>'
12359
+ };
12360
+ return (encodedString
12361
+ // Find all matches of HTML entities defined in translate_re and
12362
+ // replace them with the corresponding character from the translate object.
12363
+ .replace(translate_re, function (match, entity) {
12364
+ return translate[entity];
12365
+ })
12366
+ // Find numeric entities (e.g., &#65;)
12367
+ // and replace them with the equivalent character using the String.fromCharCode method,
12368
+ // which converts Unicode values into characters.
12369
+ .replace(/&#(\d+);/gi, function (match, numStr) {
12370
+ const num = parseInt(numStr, 10);
12371
+ return String.fromCharCode(num);
12372
+ }));
12373
+ };
12271
12374
 
12272
12375
  // Copyright (c) Microsoft Corporation.
12273
12376
  // Licensed under the MIT License.
@@ -12800,7 +12903,7 @@ class ErrorBoundary extends React.Component {
12800
12903
  // Copyright (c) Microsoft Corporation.
12801
12904
  // Licensed under the MIT License.
12802
12905
  /* @conditional-compile-remove(rich-text-editor) */
12803
- const ChatMessageComponentAsRichTextEditBox = React.lazy(() => Promise.resolve().then(function () { return require('./ChatMessageComponentAsRichTextEditBox-CwSsJHm9.js'); }));
12906
+ const ChatMessageComponentAsRichTextEditBox = React.lazy(() => Promise.resolve().then(function () { return require('./ChatMessageComponentAsRichTextEditBox-BLhY8s2s.js'); }));
12804
12907
  /**
12805
12908
  * @private
12806
12909
  * Use this function to load RoosterJS dependencies early in the lifecycle.
@@ -12808,7 +12911,7 @@ const ChatMessageComponentAsRichTextEditBox = React.lazy(() => Promise.resolve()
12808
12911
  *
12809
12912
  * @conditional-compile-remove(rich-text-editor)
12810
12913
  */
12811
- const loadChatMessageComponentAsRichTextEditBox = () => Promise.resolve().then(function () { return require('./ChatMessageComponentAsRichTextEditBox-CwSsJHm9.js'); });
12914
+ const loadChatMessageComponentAsRichTextEditBox = () => Promise.resolve().then(function () { return require('./ChatMessageComponentAsRichTextEditBox-BLhY8s2s.js'); });
12812
12915
  /**
12813
12916
  * @private
12814
12917
  */
@@ -37717,12 +37820,12 @@ const chatNotificationContainerStyles = {
37717
37820
  * Used by the CallWithChatComposite to track unread messages for showing as a badge on the Chat Button.
37718
37821
  * @private
37719
37822
  */
37720
- const useUnreadMessagesTracker = (chatAdapter, isChatPaneVisible) => {
37823
+ const useUnreadMessagesTracker = (chatAdapter, isChatPaneVisible, isChatInitiazed) => {
37721
37824
  // Store messageIds of unread messages
37722
37825
  const [unreadChatMessages, setUnreadChatMessages] = React.useState(new Set());
37723
37826
  React.useEffect(() => {
37724
37827
  // Clear unread messages when chat pane is opened
37725
- if (isChatPaneVisible) {
37828
+ if (isChatPaneVisible || !isChatInitiazed) {
37726
37829
  setUnreadChatMessages(new Set());
37727
37830
  return;
37728
37831
  }
@@ -37752,7 +37855,7 @@ const useUnreadMessagesTracker = (chatAdapter, isChatPaneVisible) => {
37752
37855
  chatAdapter.off('messageReceived', incrementUnreadChatMessagesCount);
37753
37856
  chatAdapter.off('messageDeleted', decrementUnreadChatMessagesCount);
37754
37857
  };
37755
- }, [chatAdapter, setUnreadChatMessages, isChatPaneVisible]);
37858
+ }, [chatAdapter, setUnreadChatMessages, isChatPaneVisible, isChatInitiazed]);
37756
37859
  return unreadChatMessages.size;
37757
37860
  };
37758
37861
  /**
@@ -37773,6 +37876,7 @@ const CallWithChatScreen = (props) => {
37773
37876
  }
37774
37877
  const callAdapter = React.useMemo(() => new CallWithChatBackedCallAdapter(callWithChatAdapter), [callWithChatAdapter]);
37775
37878
  const [currentCallState, setCurrentCallState] = React.useState();
37879
+ const [isChatInitialized, setIsChatInitialized] = React.useState(false);
37776
37880
  const [currentPage, setCurrentPage] = React.useState();
37777
37881
  const [isChatOpen, setIsChatOpen] = React.useState(false);
37778
37882
  const containerRef = React.useRef(null);
@@ -37781,6 +37885,7 @@ const CallWithChatScreen = (props) => {
37781
37885
  var _a;
37782
37886
  setCurrentPage(newState.page);
37783
37887
  setCurrentCallState((_a = newState.call) === null || _a === void 0 ? void 0 : _a.state);
37888
+ setIsChatInitialized(newState.chat ? true : false);
37784
37889
  };
37785
37890
  updateCallWithChatPage(callWithChatAdapter.getState());
37786
37891
  callWithChatAdapter.onStateChange(updateCallWithChatPage);
@@ -37838,7 +37943,7 @@ const CallWithChatScreen = (props) => {
37838
37943
  disabled: chatButtonDisabled
37839
37944
  }
37840
37945
  : undefined, [chatButtonDisabled, mobileView, toggleChat, showChatButton]);
37841
- const unreadChatMessagesCount = useUnreadMessagesTracker(chatAdapter, isChatOpen);
37946
+ const unreadChatMessagesCount = useUnreadMessagesTracker(chatAdapter, isChatOpen, isChatInitialized);
37842
37947
  const customChatButton = React.useCallback((args) => ({
37843
37948
  placement: mobileView ? 'primary' : 'secondary',
37844
37949
  onRenderButton: () => (React.createElement(ChatButtonWithUnreadMessagesBadge, { checked: isChatOpen, showLabel: args.displayType !== 'compact', onClick: toggleChat, disabled: chatButtonDisabled, strings: chatButtonStrings, styles: commonButtonStyles, newMessageLabel: callWithChatStrings.chatButtonNewMessageNotificationLabel, unreadChatMessagesCount: unreadChatMessagesCount,
@@ -38092,44 +38197,48 @@ class CallWithChatContext {
38092
38197
  * Created for easy use with the {@link CallWithChatComposite}.
38093
38198
  */
38094
38199
  class AzureCommunicationCallWithChatAdapter {
38095
- constructor(callAdapter, chatAdapterPromise) {
38200
+ constructor(callAdapter, chatAdapter) {
38201
+ this.emitter = new EventEmitter.EventEmitter();
38202
+ this.isAdapterDisposed = false;
38096
38203
  /* @conditional-compile-remove(attachment-upload) */
38097
38204
  this.registerActiveUploads = (files) => {
38098
- var _a, _b;
38099
- return (_b = (_a = this.chatAdapter) === null || _a === void 0 ? void 0 : _a.registerActiveUploads(files)) !== null && _b !== void 0 ? _b : [];
38205
+ return this.executeWithResolvedChatAdapter((adapter) => {
38206
+ return adapter.registerActiveUploads(files);
38207
+ });
38100
38208
  };
38101
38209
  /* @conditional-compile-remove(attachment-upload) */
38102
38210
  this.registerCompletedUploads = (metadata) => {
38103
- var _a, _b;
38104
- return (_b = (_a = this.chatAdapter) === null || _a === void 0 ? void 0 : _a.registerCompletedUploads(metadata)) !== null && _b !== void 0 ? _b : [];
38211
+ return this.executeWithResolvedChatAdapter((adapter) => {
38212
+ return adapter.registerCompletedUploads(metadata);
38213
+ });
38105
38214
  };
38106
38215
  /* @conditional-compile-remove(attachment-upload) */
38107
38216
  this.clearUploads = () => {
38108
- this.chatAdapterPromise.then((adapter) => {
38217
+ this.executeWithResolvedChatAdapter((adapter) => {
38109
38218
  adapter.clearUploads();
38110
38219
  });
38111
38220
  };
38112
38221
  /* @conditional-compile-remove(attachment-upload) */
38113
38222
  this.cancelUpload = (id) => {
38114
- this.chatAdapterPromise.then((adapter) => {
38223
+ this.executeWithResolvedChatAdapter((adapter) => {
38115
38224
  adapter.cancelUpload(id);
38116
38225
  });
38117
38226
  };
38118
38227
  /* @conditional-compile-remove(attachment-upload) */
38119
38228
  this.updateUploadProgress = (id, progress) => {
38120
- this.chatAdapterPromise.then((adapter) => {
38229
+ this.executeWithResolvedChatAdapter((adapter) => {
38121
38230
  adapter.updateUploadProgress(id, progress);
38122
38231
  });
38123
38232
  };
38124
38233
  /* @conditional-compile-remove(attachment-upload) */
38125
38234
  this.updateUploadStatusMessage = (id, errorMessage) => {
38126
- this.chatAdapterPromise.then((adapter) => {
38235
+ this.executeWithResolvedChatAdapter((adapter) => {
38127
38236
  adapter.updateUploadStatusMessage(id, errorMessage);
38128
38237
  });
38129
38238
  };
38130
38239
  /* @conditional-compile-remove(attachment-upload) */
38131
38240
  this.updateUploadMetadata = (id, metadata) => {
38132
- this.chatAdapterPromise.then((adapter) => {
38241
+ this.executeWithResolvedChatAdapter((adapter) => {
38133
38242
  adapter.updateUploadMetadata(id, metadata);
38134
38243
  });
38135
38244
  };
@@ -38140,19 +38249,28 @@ class AzureCommunicationCallWithChatAdapter {
38140
38249
  this.context.updateClientStateWithChatState(newChatAdapterState);
38141
38250
  };
38142
38251
  this.onChatStateChange = onChatStateChange;
38143
- this.chatAdapterPromise = chatAdapterPromise;
38144
- this.chatAdapterPromise.then((chatAdapter) => {
38145
- chatAdapter.onStateChange(this.onChatStateChange);
38146
- /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
38147
- this.chatAdapter = chatAdapter;
38148
- this.context.updateClientStateWithChatState(chatAdapter.getState());
38149
- });
38252
+ if (chatAdapter) {
38253
+ this.updateChatAdapter(chatAdapter);
38254
+ }
38150
38255
  const onCallStateChange = (newCallAdapterState) => {
38151
38256
  this.context.updateClientStateWithCallState(newCallAdapterState);
38152
38257
  };
38153
38258
  this.callAdapter.onStateChange(onCallStateChange);
38154
38259
  this.onCallStateChange = onCallStateChange;
38155
38260
  }
38261
+ setChatAdapterPromise(chatAdapter) {
38262
+ chatAdapter.then((adapter) => {
38263
+ if (!this.isAdapterDisposed) {
38264
+ this.updateChatAdapter(adapter);
38265
+ }
38266
+ });
38267
+ }
38268
+ updateChatAdapter(chatAdapter) {
38269
+ this.chatAdapter = chatAdapter;
38270
+ this.chatAdapter.onStateChange(this.onChatStateChange);
38271
+ this.context.updateClientStateWithChatState(chatAdapter.getState());
38272
+ this.emitter.emit('chatInitialized', this.chatAdapter);
38273
+ }
38156
38274
  bindPublicMethods() {
38157
38275
  this.joinCall.bind(this);
38158
38276
  this.leaveCall.bind(this);
@@ -38273,16 +38391,13 @@ class AzureCommunicationCallWithChatAdapter {
38273
38391
  }
38274
38392
  /** Dispose of the current CallWithChatAdapter. */
38275
38393
  dispose() {
38276
- return __awaiter$2(this, void 0, void 0, function* () {
38277
- this.chatAdapterPromise.then((adapter) => {
38278
- adapter.offStateChange(this.onChatStateChange);
38279
- });
38280
- this.callAdapter.offStateChange(this.onCallStateChange);
38281
- yield this.chatAdapterPromise.then((adapter) => {
38282
- adapter.dispose();
38283
- });
38284
- this.callAdapter.dispose();
38285
- });
38394
+ this.isAdapterDisposed = true;
38395
+ if (this.chatAdapter) {
38396
+ this.chatAdapter.offStateChange(this.onChatStateChange);
38397
+ this.chatAdapter.dispose();
38398
+ }
38399
+ this.callAdapter.offStateChange(this.onCallStateChange);
38400
+ this.callAdapter.dispose();
38286
38401
  }
38287
38402
  /** Remove a participant from the Call only. */
38288
38403
  removeParticipant(userId) {
@@ -38420,7 +38535,7 @@ class AzureCommunicationCallWithChatAdapter {
38420
38535
  /** Fetch initial Call and Chat data such as chat messages. */
38421
38536
  fetchInitialData() {
38422
38537
  return __awaiter$2(this, void 0, void 0, function* () {
38423
- return yield this.chatAdapterPromise.then((adapter) => {
38538
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38424
38539
  return adapter.fetchInitialData();
38425
38540
  });
38426
38541
  });
@@ -38428,7 +38543,7 @@ class AzureCommunicationCallWithChatAdapter {
38428
38543
  /** Send a chat message. */
38429
38544
  sendMessage(content) {
38430
38545
  return __awaiter$2(this, void 0, void 0, function* () {
38431
- return yield this.chatAdapterPromise.then((adapter) => {
38546
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38432
38547
  return adapter.sendMessage(content);
38433
38548
  });
38434
38549
  });
@@ -38437,7 +38552,7 @@ class AzureCommunicationCallWithChatAdapter {
38437
38552
  /** Send a chat message with attachments. */
38438
38553
  sendMessageWithAttachments(content, attachments) {
38439
38554
  return __awaiter$2(this, void 0, void 0, function* () {
38440
- return yield this.chatAdapterPromise.then((adapter) => {
38555
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38441
38556
  const fileSharingMetadata = {
38442
38557
  fileSharingMetadata: JSON.stringify(attachments)
38443
38558
  };
@@ -38450,7 +38565,7 @@ class AzureCommunicationCallWithChatAdapter {
38450
38565
  /** Send a chat read receipt. */
38451
38566
  sendReadReceipt(chatMessageId) {
38452
38567
  return __awaiter$2(this, void 0, void 0, function* () {
38453
- return yield this.chatAdapterPromise.then((adapter) => {
38568
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38454
38569
  return adapter.sendReadReceipt(chatMessageId);
38455
38570
  });
38456
38571
  });
@@ -38458,7 +38573,7 @@ class AzureCommunicationCallWithChatAdapter {
38458
38573
  /** Send an isTyping indicator. */
38459
38574
  sendTypingIndicator() {
38460
38575
  return __awaiter$2(this, void 0, void 0, function* () {
38461
- return yield this.chatAdapterPromise.then((adapter) => {
38576
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38462
38577
  return adapter.sendTypingIndicator();
38463
38578
  });
38464
38579
  });
@@ -38466,7 +38581,7 @@ class AzureCommunicationCallWithChatAdapter {
38466
38581
  /** Load previous Chat messages. */
38467
38582
  loadPreviousChatMessages(messagesToLoad) {
38468
38583
  return __awaiter$2(this, void 0, void 0, function* () {
38469
- return yield this.chatAdapterPromise.then((adapter) => {
38584
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38470
38585
  return adapter.loadPreviousChatMessages(messagesToLoad);
38471
38586
  });
38472
38587
  });
@@ -38474,7 +38589,7 @@ class AzureCommunicationCallWithChatAdapter {
38474
38589
  /** Update an existing message. */
38475
38590
  updateMessage(messageId, content, metadata, options) {
38476
38591
  return __awaiter$2(this, void 0, void 0, function* () {
38477
- return this.chatAdapterPromise.then((adapter) => {
38592
+ return this.executeWithResolvedChatAdapter((adapter) => {
38478
38593
  return adapter.updateMessage(messageId, content, metadata,
38479
38594
  /* @conditional-compile-remove(attachment-upload) */ options);
38480
38595
  });
@@ -38483,20 +38598,20 @@ class AzureCommunicationCallWithChatAdapter {
38483
38598
  /** Delete an existing message. */
38484
38599
  deleteMessage(messageId) {
38485
38600
  return __awaiter$2(this, void 0, void 0, function* () {
38486
- return yield this.chatAdapterPromise.then((adapter) => {
38601
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
38487
38602
  return adapter.deleteMessage(messageId);
38488
38603
  });
38489
38604
  });
38490
38605
  }
38491
38606
  downloadResourceToCache(resourceDetails) {
38492
38607
  return __awaiter$2(this, void 0, void 0, function* () {
38493
- this.chatAdapterPromise.then((adapter) => {
38608
+ this.executeWithResolvedChatAdapter((adapter) => {
38494
38609
  adapter.downloadResourceToCache(resourceDetails);
38495
38610
  });
38496
38611
  });
38497
38612
  }
38498
38613
  removeResourceFromCache(resourceDetails) {
38499
- this.chatAdapterPromise.then((adapter) => {
38614
+ this.executeWithResolvedChatAdapter((adapter) => {
38500
38615
  adapter.removeResourceFromCache(resourceDetails);
38501
38616
  });
38502
38617
  }
@@ -38638,37 +38753,37 @@ class AzureCommunicationCallWithChatAdapter {
38638
38753
  this.callAdapter.on('isSpokenLanguageChanged', listener);
38639
38754
  break;
38640
38755
  case 'messageReceived':
38641
- this.chatAdapterPromise.then((adapter) => {
38756
+ this.executeWithResolvedChatAdapter((adapter) => {
38642
38757
  adapter.on('messageReceived', listener);
38643
38758
  });
38644
38759
  break;
38645
38760
  case 'messageEdited':
38646
- this.chatAdapterPromise.then((adapter) => {
38761
+ this.executeWithResolvedChatAdapter((adapter) => {
38647
38762
  adapter.on('messageEdited', listener);
38648
38763
  });
38649
38764
  break;
38650
38765
  case 'messageDeleted':
38651
- this.chatAdapterPromise.then((adapter) => {
38766
+ this.executeWithResolvedChatAdapter((adapter) => {
38652
38767
  adapter.on('messageDeleted', listener);
38653
38768
  });
38654
38769
  break;
38655
38770
  case 'messageSent':
38656
- this.chatAdapterPromise.then((adapter) => {
38771
+ this.executeWithResolvedChatAdapter((adapter) => {
38657
38772
  adapter.on('messageSent', listener);
38658
38773
  });
38659
38774
  break;
38660
38775
  case 'messageRead':
38661
- this.chatAdapterPromise.then((adapter) => {
38776
+ this.executeWithResolvedChatAdapter((adapter) => {
38662
38777
  adapter.on('messageRead', listener);
38663
38778
  });
38664
38779
  break;
38665
38780
  case 'chatParticipantsAdded':
38666
- this.chatAdapterPromise.then((adapter) => {
38781
+ this.executeWithResolvedChatAdapter((adapter) => {
38667
38782
  adapter.on('participantsAdded', listener);
38668
38783
  });
38669
38784
  break;
38670
38785
  case 'chatParticipantsRemoved':
38671
- this.chatAdapterPromise.then((adapter) => {
38786
+ this.executeWithResolvedChatAdapter((adapter) => {
38672
38787
  adapter.on('participantsRemoved', listener);
38673
38788
  });
38674
38789
  break;
@@ -38676,10 +38791,13 @@ class AzureCommunicationCallWithChatAdapter {
38676
38791
  this.callAdapter.on('error', listener);
38677
38792
  break;
38678
38793
  case 'chatError':
38679
- this.chatAdapterPromise.then((adapter) => {
38794
+ this.executeWithResolvedChatAdapter((adapter) => {
38680
38795
  adapter.on('error', listener);
38681
38796
  });
38682
38797
  break;
38798
+ case 'chatInitialized':
38799
+ this.emitter.on(event, listener);
38800
+ break;
38683
38801
  default:
38684
38802
  throw `Unknown AzureCommunicationCallWithChatAdapter Event: ${event}`;
38685
38803
  }
@@ -38730,37 +38848,37 @@ class AzureCommunicationCallWithChatAdapter {
38730
38848
  this.callAdapter.off('isSpokenLanguageChanged', listener);
38731
38849
  break;
38732
38850
  case 'messageReceived':
38733
- this.chatAdapterPromise.then((adapter) => {
38851
+ this.executeWithResolvedChatAdapter((adapter) => {
38734
38852
  adapter.off('messageReceived', listener);
38735
38853
  });
38736
38854
  break;
38737
38855
  case 'messageEdited':
38738
- this.chatAdapterPromise.then((adapter) => {
38856
+ this.executeWithResolvedChatAdapter((adapter) => {
38739
38857
  adapter.off('messageEdited', listener);
38740
38858
  });
38741
38859
  break;
38742
38860
  case 'messageDeleted':
38743
- this.chatAdapterPromise.then((adapter) => {
38861
+ this.executeWithResolvedChatAdapter((adapter) => {
38744
38862
  adapter.off('messageDeleted', listener);
38745
38863
  });
38746
38864
  break;
38747
38865
  case 'messageSent':
38748
- this.chatAdapterPromise.then((adapter) => {
38866
+ this.executeWithResolvedChatAdapter((adapter) => {
38749
38867
  adapter.off('messageSent', listener);
38750
38868
  });
38751
38869
  break;
38752
38870
  case 'messageRead':
38753
- this.chatAdapterPromise.then((adapter) => {
38871
+ this.executeWithResolvedChatAdapter((adapter) => {
38754
38872
  adapter.off('messageRead', listener);
38755
38873
  });
38756
38874
  break;
38757
38875
  case 'chatParticipantsAdded':
38758
- this.chatAdapterPromise.then((adapter) => {
38876
+ this.executeWithResolvedChatAdapter((adapter) => {
38759
38877
  adapter.off('participantsAdded', listener);
38760
38878
  });
38761
38879
  break;
38762
38880
  case 'chatParticipantsRemoved':
38763
- this.chatAdapterPromise.then((adapter) => {
38881
+ this.executeWithResolvedChatAdapter((adapter) => {
38764
38882
  adapter.off('participantsRemoved', listener);
38765
38883
  });
38766
38884
  break;
@@ -38768,33 +38886,51 @@ class AzureCommunicationCallWithChatAdapter {
38768
38886
  this.callAdapter.off('error', listener);
38769
38887
  break;
38770
38888
  case 'chatError':
38771
- this.chatAdapterPromise.then((adapter) => {
38889
+ this.executeWithResolvedChatAdapter((adapter) => {
38772
38890
  adapter.off('error', listener);
38773
38891
  });
38774
38892
  break;
38893
+ case 'chatInitialized':
38894
+ this.emitter.off(event, listener);
38895
+ break;
38775
38896
  default:
38776
38897
  throw `Unknown AzureCommunicationCallWithChatAdapter Event: ${event}`;
38777
38898
  }
38778
38899
  }
38900
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38901
+ executeWithResolvedChatAdapter(callback) {
38902
+ if (!this.chatAdapter) {
38903
+ console.error('Chat is not initialized');
38904
+ }
38905
+ else {
38906
+ return callback(this.chatAdapter);
38907
+ }
38908
+ }
38779
38909
  }
38780
38910
  /**
38781
38911
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Group Call with an associated Chat thread.
38782
- * @public
38912
+ * @private
38783
38913
  */
38784
38914
  class CallAndChatProvider {
38785
38915
  constructor(locator) {
38786
38916
  this.locator = locator;
38787
38917
  }
38788
- getChatThread() {
38918
+ isCallInfoRequired() {
38919
+ return false;
38920
+ }
38921
+ getChatThreadPromise() {
38789
38922
  return __awaiter$2(this, void 0, void 0, function* () {
38790
- return this.locator.chatThreadId;
38923
+ return this.getChatThread();
38791
38924
  });
38792
38925
  }
38926
+ getChatThread() {
38927
+ return this.locator.chatThreadId;
38928
+ }
38793
38929
  }
38794
38930
  /**
38795
38931
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Teams meeting with an associated Chat thread.
38796
38932
  *
38797
- * @public
38933
+ * @private
38798
38934
  */
38799
38935
  class TeamsMeetingLinkProvider {
38800
38936
  constructor(locator,
@@ -38803,7 +38939,14 @@ class TeamsMeetingLinkProvider {
38803
38939
  /** @conditional-compile-remove(meeting-id) */
38804
38940
  this.callAdapterPromise = callAdapterPromise;
38805
38941
  }
38942
+ isCallInfoRequired() {
38943
+ return true;
38944
+ }
38806
38945
  getChatThread() {
38946
+ /** @conditional-compile-remove(meeting-id) */
38947
+ throw new Error('Chat thread ID should be retrieved from call.callInfo using method getChatThreadPromise');
38948
+ }
38949
+ getChatThreadPromise() {
38807
38950
  return __awaiter$2(this, void 0, void 0, function* () {
38808
38951
  /** @conditional-compile-remove(meeting-id) */
38809
38952
  {
@@ -38832,28 +38975,45 @@ class TeamsMeetingLinkProvider {
38832
38975
  /**
38833
38976
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Teams meeting using meeting id.
38834
38977
  *
38835
- * @public
38978
+ * @private
38836
38979
  */
38837
38980
  class TeamsMeetingIdProvider {
38838
38981
  constructor(locator, callAdapter) {
38839
38982
  this.locator = locator;
38840
38983
  this.callAdapter = callAdapter;
38841
38984
  }
38985
+ isCallInfoRequired() {
38986
+ return true;
38987
+ }
38988
+ getChatThread() {
38989
+ throw new Error('Chat thread ID is not available for Teams meeting ID');
38990
+ }
38842
38991
  /**
38843
38992
  * Wait call to be connected to get thread ID.
38844
38993
  * @returns the chat thread ID for the given meeting ID.
38845
38994
  */
38846
- getChatThread() {
38995
+ getChatThreadPromise() {
38847
38996
  return __awaiter$2(this, void 0, void 0, function* () {
38848
38997
  return new Promise((resolve) => {
38849
38998
  const stateChangeListener = (state) => {
38850
38999
  var _a, _b, _c;
38851
39000
  if (((_a = state.call) === null || _a === void 0 ? void 0 : _a.state) === 'Connected' && ((_b = state.call.info) === null || _b === void 0 ? void 0 : _b.threadId)) {
39001
+ this.callAdapter.then((adapter) => {
39002
+ adapter.offStateChange(stateChangeListener);
39003
+ });
38852
39004
  resolve((_c = state.call.info) === null || _c === void 0 ? void 0 : _c.threadId);
38853
39005
  }
38854
39006
  };
38855
39007
  this.callAdapter.then((adapter) => {
38856
- adapter.onStateChange(stateChangeListener);
39008
+ var _a, _b, _c;
39009
+ const callState = (_a = adapter.getState().call) === null || _a === void 0 ? void 0 : _a.state;
39010
+ const threadId = (_c = (_b = adapter.getState().call) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.threadId;
39011
+ if (callState === 'Connected' && threadId) {
39012
+ resolve(threadId);
39013
+ }
39014
+ else {
39015
+ adapter.onStateChange(stateChangeListener);
39016
+ }
38857
39017
  });
38858
39018
  });
38859
39019
  });
@@ -38878,8 +39038,16 @@ const createAzureCommunicationCallWithChatAdapter = (_a) => __awaiter$2(void 0,
38878
39038
  telemetryImplementationHint: 'CallWithChat'
38879
39039
  });
38880
39040
  const chatThreadAdapter = _createChatThreadAdapterInner(locator, callAdapter);
38881
- const chatAdapter = _createLazyAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThread(), 'CallWithChat');
38882
- return new AzureCommunicationCallWithChatAdapter(yield callAdapter, chatAdapter);
39041
+ if (chatThreadAdapter.isCallInfoRequired()) {
39042
+ const callWithChatAdapter = new AzureCommunicationCallWithChatAdapter(yield callAdapter);
39043
+ const chatAdapterPromise = _createLazyAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThreadPromise(), 'CallWithChat');
39044
+ callWithChatAdapter.setChatAdapterPromise(chatAdapterPromise);
39045
+ return callWithChatAdapter;
39046
+ }
39047
+ else {
39048
+ const chatAdapter = _createAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThread(), 'CallWithChat');
39049
+ return new AzureCommunicationCallWithChatAdapter(yield callAdapter, yield chatAdapter);
39050
+ }
38883
39051
  });
38884
39052
  /**
38885
39053
  * A custom React hook to simplify the creation of {@link CallWithChatAdapter}.
@@ -39008,8 +39176,8 @@ beforeDispose) => {
39008
39176
  */
39009
39177
  const createAzureCommunicationCallWithChatAdapterFromClients = (_b) => __awaiter$2(void 0, [_b], void 0, function* ({ callClient, callAgent, callLocator, chatClient, chatThreadClient, callAdapterOptions }) {
39010
39178
  const callAdapter = yield createAzureCommunicationCallAdapterFromClient(callClient, callAgent, callLocator, callAdapterOptions);
39011
- const chatAdapterPromise = createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);
39012
- return new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapterPromise);
39179
+ const chatAdapter = yield createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);
39180
+ return new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapter);
39013
39181
  });
39014
39182
  const isTeamsMeetingLocator = (locator) => {
39015
39183
  return 'meetingLink' in locator || 'meetingId' in locator;
@@ -39597,4 +39765,4 @@ exports.useTeamsCall = useTeamsCall;
39597
39765
  exports.useTeamsCallAdapter = useTeamsCallAdapter;
39598
39766
  exports.useTeamsCallAgent = useTeamsCallAgent;
39599
39767
  exports.useTheme = useTheme;
39600
- //# sourceMappingURL=index-BN2-SHYR.js.map
39768
+ //# sourceMappingURL=index-r7pKdpFV.js.map