import { singleToArray, warnOnce, type OneOrMany } from '@msinternal/botframework-webchat-base/utils'; import { useMemoIterable } from '@msinternal/botframework-webchat-react-hooks'; import { type AttachmentForScreenReaderMiddleware, type AttachmentMiddleware, type StyleOptions } from 'botframework-webchat-api'; import { type HTMLContentTransformMiddleware } from 'botframework-webchat-component'; import React, { memo, type ReactNode } from 'react'; import AdaptiveCardsComposer from './adaptiveCards/AdaptiveCardsComposer'; import { type AdaptiveCardsStyleOptions } from './adaptiveCards/AdaptiveCardsStyleOptions'; import ShikiComposer from './codeHighlighter/ShikiComposer'; import BundleStylesheet from './stylesheet/BundleStylesheet'; import { type AdaptiveCardsPackage } from './types/AdaptiveCardsPackage'; import { type StrictFullBundleStyleOptions } from './types/FullBundleStyleOptions'; import useComposerProps from './useComposerProps'; type AddFullBundleChildren = ({ extraStyleSet }: { extraStyleSet: any }) => ReactNode; type AddFullBundleProps = Readonly<{ adaptiveCardsHostConfig?: any; adaptiveCardsPackage?: AdaptiveCardsPackage; attachmentForScreenReaderMiddleware?: OneOrMany; attachmentMiddleware?: OneOrMany; children: AddFullBundleChildren; htmlContentTransformMiddleware?: HTMLContentTransformMiddleware[]; nonce?: string | undefined; renderMarkdown?: ( markdown: string, newLineOptions: { markdownRespectCRLF: boolean }, linkOptions: { externalLinkAlt: string } ) => string; styleOptions?: StyleOptions & AdaptiveCardsStyleOptions; styleSet?: any & { options: StrictFullBundleStyleOptions }; /** @deprecated Rename to "adaptiveCardsHostConfig" */ adaptiveCardHostConfig?: any; }>; const adaptiveCardHostConfigDeprecation = warnOnce( '"adaptiveCardHostConfig" is deprecated. Please use "adaptiveCardsHostConfig" instead. "adaptiveCardHostConfig" will be removed on or after 2022-01-01.' ); function AddFullBundle({ adaptiveCardHostConfig, adaptiveCardsHostConfig, adaptiveCardsPackage, attachmentForScreenReaderMiddleware: attachmentForScreenReaderMiddlewareFromProps, attachmentMiddleware: attachmentMiddlewareFromProps, children, htmlContentTransformMiddleware, nonce, renderMarkdown, styleOptions, styleSet }: AddFullBundleProps) { adaptiveCardHostConfig && adaptiveCardHostConfigDeprecation(); const attachmentForScreenReaderMiddleware = useMemoIterable( () => singleToArray(attachmentForScreenReaderMiddlewareFromProps), [attachmentForScreenReaderMiddlewareFromProps] ); const attachmentMiddleware = useMemoIterable( () => singleToArray(attachmentMiddlewareFromProps), [attachmentMiddlewareFromProps] ); const patchedProps = useComposerProps({ attachmentForScreenReaderMiddleware, attachmentMiddleware, htmlContentTransformMiddleware, renderMarkdown, styleOptions, styleSet }); return ( {children(patchedProps)} ); } export default memo(AddFullBundle); export type { AddFullBundleChildren, AddFullBundleProps };