stream-chat-react
Version:
React components to create chat conversations or livestream style chat
1,309 lines (1,283 loc) • 1.43 MB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all2) => {
for (var name2 in all2)
__defProp(target, name2, { get: all2[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/inline-style-parser/index.js
var require_inline_style_parser = __commonJS({
"node_modules/inline-style-parser/index.js"(exports, module2) {
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
var NEWLINE_REGEX = /\n/g;
var WHITESPACE_REGEX = /^\s*/;
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;
var TRIM_REGEX = /^\s+|\s+$/g;
var NEWLINE = "\n";
var FORWARD_SLASH = "/";
var ASTERISK = "*";
var EMPTY_STRING = "";
var TYPE_COMMENT = "comment";
var TYPE_DECLARATION = "declaration";
module2.exports = function(style, options) {
if (typeof style !== "string") {
throw new TypeError("First argument must be a string");
}
if (!style) return [];
options = options || {};
var lineno = 1;
var column = 1;
function updatePosition(str) {
var lines = str.match(NEWLINE_REGEX);
if (lines) lineno += lines.length;
var i = str.lastIndexOf(NEWLINE);
column = ~i ? str.length - i : column + str.length;
}
function position3() {
var start2 = { line: lineno, column };
return function(node2) {
node2.position = new Position(start2);
whitespace2();
return node2;
};
}
function Position(start2) {
this.start = start2;
this.end = { line: lineno, column };
this.source = options.source;
}
Position.prototype.content = style;
var errorsList = [];
function error(msg) {
var err = new Error(
options.source + ":" + lineno + ":" + column + ": " + msg
);
err.reason = msg;
err.filename = options.source;
err.line = lineno;
err.column = column;
err.source = style;
if (options.silent) {
errorsList.push(err);
} else {
throw err;
}
}
function match(re2) {
var m = re2.exec(style);
if (!m) return;
var str = m[0];
updatePosition(str);
style = style.slice(str.length);
return m;
}
function whitespace2() {
match(WHITESPACE_REGEX);
}
function comments(rules) {
var c;
rules = rules || [];
while (c = comment()) {
if (c !== false) {
rules.push(c);
}
}
return rules;
}
function comment() {
var pos = position3();
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
var i = 2;
while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
++i;
}
i += 2;
if (EMPTY_STRING === style.charAt(i - 1)) {
return error("End of comment missing");
}
var str = style.slice(2, i - 2);
column += 2;
updatePosition(str);
style = style.slice(i);
column += 2;
return pos({
type: TYPE_COMMENT,
comment: str
});
}
function declaration() {
var pos = position3();
var prop = match(PROPERTY_REGEX);
if (!prop) return;
comment();
if (!match(COLON_REGEX)) return error("property missing ':'");
var val = match(VALUE_REGEX);
var ret = pos({
type: TYPE_DECLARATION,
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
});
match(SEMICOLON_REGEX);
return ret;
}
function declarations() {
var decls = [];
comments(decls);
var decl;
while (decl = declaration()) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
return decls;
}
whitespace2();
return declarations();
};
function trim(str) {
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
}
}
});
// node_modules/style-to-object/cjs/index.js
var require_cjs = __commonJS({
"node_modules/style-to-object/cjs/index.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = StyleToObject2;
var inline_style_parser_1 = __importDefault(require_inline_style_parser());
function StyleToObject2(style, iterator) {
var styleObject = null;
if (!style || typeof style !== "string") {
return styleObject;
}
var declarations = (0, inline_style_parser_1.default)(style);
var hasIterator = typeof iterator === "function";
declarations.forEach(function(declaration) {
if (declaration.type !== "declaration") {
return;
}
var property = declaration.property, value = declaration.value;
if (hasIterator) {
iterator(property, value, declaration);
} else if (value) {
styleObject = styleObject || {};
styleObject[property] = value;
}
});
return styleObject;
}
}
});
// node_modules/extend/index.js
var require_extend = __commonJS({
"node_modules/extend/index.js"(exports, module2) {
"use strict";
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var defineProperty = Object.defineProperty;
var gOPD = Object.getOwnPropertyDescriptor;
var isArray = function isArray2(arr) {
if (typeof Array.isArray === "function") {
return Array.isArray(arr);
}
return toStr.call(arr) === "[object Array]";
};
var isPlainObject2 = function isPlainObject3(obj) {
if (!obj || toStr.call(obj) !== "[object Object]") {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, "constructor");
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
var key;
for (key in obj) {
}
return typeof key === "undefined" || hasOwn.call(obj, key);
};
var setProperty = function setProperty2(target, options) {
if (defineProperty && options.name === "__proto__") {
defineProperty(target, options.name, {
enumerable: true,
configurable: true,
value: options.newValue,
writable: true
});
} else {
target[options.name] = options.newValue;
}
};
var getProperty = function getProperty2(obj, name2) {
if (name2 === "__proto__") {
if (!hasOwn.call(obj, name2)) {
return void 0;
} else if (gOPD) {
return gOPD(obj, name2).value;
}
}
return obj[name2];
};
module2.exports = function extend2() {
var options, name2, src, copy, copyIsArray, clone;
var target = arguments[0];
var i = 1;
var length = arguments.length;
var deep = false;
if (typeof target === "boolean") {
deep = target;
target = arguments[1] || {};
i = 2;
}
if (target == null || typeof target !== "object" && typeof target !== "function") {
target = {};
}
for (; i < length; ++i) {
options = arguments[i];
if (options != null) {
for (name2 in options) {
src = getProperty(target, name2);
copy = getProperty(options, name2);
if (target !== copy) {
if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && isArray(src) ? src : [];
} else {
clone = src && isPlainObject2(src) ? src : {};
}
setProperty(target, { name: name2, newValue: extend2(deep, clone, copy) });
} else if (typeof copy !== "undefined") {
setProperty(target, { name: name2, newValue: copy });
}
}
}
}
}
return target;
};
}
});
// src/index.ts
var src_exports = {};
__export(src_exports, {
ACTIONS_NOT_WORKING_IN_THREAD: () => ACTIONS_NOT_WORKING_IN_THREAD,
AIStateIndicator: () => AIStateIndicator,
AIStates: () => AIStates,
ATTACHMENT_GROUPS_ORDER: () => ATTACHMENT_GROUPS_ORDER,
ActionsIcon: () => ActionsIcon,
AddCommentForm: () => AddCommentForm,
AmountBar: () => AmountBar,
Attachment: () => Attachment,
AttachmentActions: () => AttachmentActions,
AttachmentActionsContainer: () => AttachmentActionsContainer,
AttachmentPreviewList: () => AttachmentPreviewList,
AttachmentSelector: () => AttachmentSelector,
AttachmentWithinContainer: () => AttachmentWithinContainer,
Audio: () => Audio,
AudioContainer: () => AudioContainer,
AudioRecorder: () => AudioRecorder,
Avatar: () => Avatar,
BaseImage: () => BaseImage,
BinIcon: () => BinIcon,
ButtonWithSubmenu: () => ButtonWithSubmenu,
Card: () => Card,
CardAudio: () => CardAudio,
CardContainer: () => CardContainer,
Channel: () => Channel,
ChannelActionContext: () => ChannelActionContext,
ChannelActionProvider: () => ChannelActionProvider,
ChannelAvatar: () => ChannelAvatar,
ChannelHeader: () => ChannelHeader,
ChannelList: () => ChannelList,
ChannelListContext: () => ChannelListContext,
ChannelListContextProvider: () => ChannelListContextProvider,
ChannelListMessenger: () => ChannelListMessenger,
ChannelPreview: () => ChannelPreview,
ChannelPreviewActionButtons: () => ChannelPreviewActionButtons,
ChannelPreviewMessenger: () => ChannelPreviewMessenger,
ChannelSearch: () => ChannelSearch,
ChannelStateContext: () => ChannelStateContext,
ChannelStateProvider: () => ChannelStateProvider,
Chat: () => Chat,
ChatContext: () => ChatContext,
ChatProvider: () => ChatProvider,
ChatView: () => ChatView,
CheckSignIcon: () => CheckSignIcon,
Checkmark: () => Checkmark,
CloseIcon: () => CloseIcon,
CommandItem: () => CommandItem,
ComponentContext: () => ComponentContext,
ComponentProvider: () => ComponentProvider,
ConnectionStatus: () => ConnectionStatus,
CooldownTimer: () => CooldownTimer,
CustomMessageActionsList: () => CustomMessageActionsList,
DateSeparator: () => DateSeparator,
DefaultAttachmentSelectorComponents: () => DefaultAttachmentSelectorComponents,
DialogAnchor: () => DialogAnchor,
DialogManager: () => DialogManager,
DialogManagerProvider: () => DialogManagerProvider,
DialogPortalDestination: () => DialogPortalDestination,
DialogPortalEntry: () => DialogPortalEntry,
DownloadButton: () => DownloadButton,
DownloadIcon: () => DownloadIcon2,
EditMessageForm: () => EditMessageForm,
EditMessageModal: () => EditMessageModal,
EmoticonItem: () => EmoticonItem,
EmptyStateIndicator: () => EmptyStateIndicator,
EndPollDialog: () => EndPollDialog,
EventComponent: () => EventComponent,
FileAttachment: () => FileAttachment,
FileContainer: () => FileContainer,
FileSizeIndicator: () => FileSizeIndicator,
FixedHeightMessage: () => FixedHeightMessage,
Gallery: () => Gallery,
GalleryContainer: () => GalleryContainer,
Geolocation: () => Geolocation,
GeolocationContainer: () => GeolocationContainer,
GiphyPreviewMessage: () => GiphyPreviewMessage,
GlobalModal: () => GlobalModal,
GroupAvatar: () => GroupAvatar,
ImageComponent: () => ImageComponent,
ImageContainer: () => ImageContainer,
InfiniteScroll: () => InfiniteScroll,
LinkIcon: () => LinkIcon,
LinkPreviewCard: () => LinkPreviewCard,
LinkPreviewList: () => LinkPreviewList,
LoadMoreButton: () => LoadMoreButton,
LoadMorePaginator: () => LoadMorePaginator,
LoadingChannels: () => LoadingChannels,
LoadingErrorIndicator: () => LoadingErrorIndicator,
LoadingIndicator: () => LoadingIndicator,
LoadingIndicatorIcon: () => LoadingIndicatorIcon,
MAX_MESSAGE_REACTIONS_TO_FETCH: () => MAX_MESSAGE_REACTIONS_TO_FETCH,
MAX_QUERY_CHANNELS_LIMIT: () => MAX_QUERY_CHANNELS_LIMIT,
MESSAGE_ACTIONS: () => MESSAGE_ACTIONS,
MediaContainer: () => MediaContainer,
MediaRecordingState: () => MediaRecordingState,
Message: () => Message,
MessageActions: () => MessageActions,
MessageActionsBox: () => MessageActionsBox,
MessageActionsWrapper: () => MessageActionsWrapper,
MessageBlocked: () => MessageBlocked,
MessageBounceModal: () => MessageBounceModal,
MessageBouncePrompt: () => MessageBouncePrompt,
MessageBounceProvider: () => MessageBounceProvider,
MessageContext: () => MessageContext,
MessageDeleted: () => MessageDeleted,
MessageDeliveredIcon: () => MessageDeliveredIcon,
MessageDeliveryStatus: () => MessageDeliveryStatus,
MessageEditedTimestamp: () => MessageEditedTimestamp,
MessageErrorIcon: () => MessageErrorIcon,
MessageInput: () => MessageInput,
MessageInputContext: () => MessageInputContext,
MessageInputContextProvider: () => MessageInputContextProvider,
MessageInputFlat: () => MessageInputFlat,
MessageIsThreadReplyInChannelButtonIndicator: () => MessageIsThreadReplyInChannelButtonIndicator,
MessageList: () => MessageList,
MessageListContext: () => MessageListContext,
MessageListContextProvider: () => MessageListContextProvider,
MessageListNotifications: () => MessageListNotifications,
MessageNotification: () => MessageNotification,
MessageOptions: () => MessageOptions,
MessageProvider: () => MessageProvider,
MessageRepliesCountButton: () => MessageRepliesCountButton,
MessageSimple: () => MessageSimple,
MessageStatus: () => MessageStatus,
MessageText: () => MessageText,
MessageTimestamp: () => MessageTimestamp,
MicIcon: () => MicIcon,
Modal: () => Modal,
ModalDialogManagerProvider: () => ModalDialogManagerProvider,
ModalGallery: () => ModalGallery,
NotificationTranslationTopic: () => NotificationTranslationTopic,
PauseIcon: () => PauseIcon2,
PinIcon: () => PinIcon,
PinIndicator: () => PinIndicator,
PlayButton: () => PlayButton,
PlayIcon: () => PlayIcon,
PlaybackRateButton: () => PlaybackRateButton,
Poll: () => Poll,
PollActions: () => PollActions,
PollAnswerList: () => PollAnswerList,
PollContent: () => PollContent,
PollContext: () => PollContext,
PollCreationDialog: () => PollCreationDialog,
PollHeader: () => PollHeader,
PollOptionList: () => PollOptionList,
PollOptionSelector: () => PollOptionSelector,
PollOptionsFullList: () => PollOptionsFullList,
PollProvider: () => PollProvider,
PollResults: () => PollResults,
PollVote: () => PollVote,
PollVoteListing: () => PollVoteListing,
PopperTooltip: () => PopperTooltip,
ProgressBar: () => ProgressBar,
QuotedMessage: () => QuotedMessage,
QuotedMessagePreview: () => QuotedMessagePreview,
QuotedMessagePreviewHeader: () => QuotedMessagePreviewHeader,
QuotedPoll: () => QuotedPoll,
ReactionIcon: () => ReactionIcon,
ReactionSelector: () => ReactionSelector,
ReactionsList: () => ReactionsList,
ReactionsListModal: () => ReactionsListModal,
RecordingPermission: () => RecordingPermission,
RecordingPermissionDeniedNotification: () => RecordingPermissionDeniedNotification,
RecordingTimer: () => RecordingTimer,
ReminderNotification: () => ReminderNotification,
RetryIcon: () => RetryIcon,
SUPPORTED_VIDEO_FORMATS: () => SUPPORTED_VIDEO_FORMATS,
SafeAnchor: () => SafeAnchor,
ScrollToBottomButton: () => ScrollToBottomButton,
SearchBar: () => SearchBar,
SearchInput: () => SearchInput,
SearchResults: () => SearchResults,
SendButton: () => SendButton,
SendIcon: () => SendIcon,
ShareLocationDialog: () => ShareLocationDialog,
SimpleAttachmentSelector: () => SimpleAttachmentSelector,
SimpleReactionsList: () => SimpleReactionsList,
SpriteImage: () => SpriteImage,
StartRecordingAudioButton: () => StartRecordingAudioButton,
StreamEmoji: () => StreamEmoji,
StreamedMessageText: () => StreamedMessageText,
Streami18n: () => Streami18n,
SuggestPollOptionForm: () => SuggestPollOptionForm,
SuggestionList: () => SuggestionList,
SuggestionListItem: () => SuggestionListItem,
TextareaComposer: () => TextareaComposer,
Thread: () => Thread,
ThreadContext: () => ThreadContext,
ThreadHeader: () => ThreadHeader,
ThreadIcon: () => ThreadIcon,
ThreadList: () => ThreadList,
ThreadListItem: () => ThreadListItem,
ThreadListItemUI: () => ThreadListItemUI,
ThreadProvider: () => ThreadProvider,
ThreadStart: () => ThreadStart,
Tooltip: () => Tooltip,
TranslationBuilder: () => TranslationBuilder,
TranslationContext: () => TranslationContext,
TranslationProvider: () => TranslationProvider,
TranslationTopic: () => TranslationTopic,
TypingContext: () => TypingContext,
TypingIndicator: () => TypingIndicator,
TypingProvider: () => TypingProvider,
UNREAD_MESSAGE_SEPARATOR_CLASS: () => UNREAD_MESSAGE_SEPARATOR_CLASS,
UnMemoizedLoadMorePaginator: () => UnMemoizedLoadMorePaginator,
UnreadMessagesNotification: () => UnreadMessagesNotification,
UnreadMessagesSeparator: () => UnreadMessagesSeparator,
UnsupportedAttachment: () => UnsupportedAttachment,
UnsupportedAttachmentContainer: () => UnsupportedAttachmentContainer,
UploadButton: () => UploadButton,
UploadIcon: () => UploadIcon,
UserItem: () => UserItem,
VirtualizedMessageList: () => VirtualizedMessageList,
VoiceRecordingContainer: () => VoiceRecordingContainer,
WaveProgressBar: () => WaveProgressBar,
Window: () => Window,
WithComponents: () => WithComponents,
WithDragAndDropUpload: () => WithDragAndDropUpload,
areMessagePropsEqual: () => areMessagePropsEqual,
areMessageUIPropsEqual: () => areMessageUIPropsEqual,
attachmentTypeIconMap: () => attachmentTypeIconMap,
deTranslations: () => de_default,
defaultAllowedTagNames: () => defaultAllowedTagNames,
defaultAttachmentSelectorActionSet: () => defaultAttachmentSelectorActionSet,
defaultComponents: () => defaultComponents,
defaultDateTimeParser: () => defaultDateTimeParser,
defaultPinPermissions: () => defaultPinPermissions,
defaultReactionOptions: () => defaultReactionOptions,
defaultRenderMessages: () => defaultRenderMessages,
defaultTranslatorFunction: () => defaultTranslatorFunction,
displayDuration: () => displayDuration,
divMod: () => divMod,
downSample: () => downSample,
emojiMarkdownPlugin: () => emojiMarkdownPlugin,
enTranslations: () => en_default,
esTranslations: () => es_default,
escapeRegExp: () => escapeRegExp,
extractSortValue: () => extractSortValue,
findLastPinnedChannelIndex: () => findLastPinnedChannelIndex,
frTranslations: () => fr_default,
getChannel: () => getChannel,
getDisplayImage: () => getDisplayImage,
getDisplayTitle: () => getDisplayTitle,
getGroupChannelDisplayInfo: () => getGroupChannelDisplayInfo,
getGroupStyles: () => getGroupStyles,
getImages: () => getImages,
getIsFirstUnreadMessage: () => getIsFirstUnreadMessage,
getLastReceived: () => getLastReceived,
getLatestMessagePreview: () => getLatestMessagePreview,
getMessageActions: () => getMessageActions,
getNonImageAttachments: () => getNonImageAttachments,
getReadByTooltipText: () => getReadByTooltipText,
getReadStates: () => getReadStates,
getWholeChar: () => getWholeChar,
handleActionWarning: () => handleActionWarning,
hasMoreMessagesProbably: () => hasMoreMessagesProbably,
hasNotMoreMessages: () => hasNotMoreMessages,
hiTranslations: () => hi_default,
htmlToTextPlugin: () => htmlToTextPlugin,
insertIntro: () => insertIntro,
isChannel: () => isChannel,
isChannelArchived: () => isChannelArchived,
isChannelPinned: () => isChannelPinned,
isChrome: () => isChrome,
isDate: () => isDate,
isDateSeparatorMessage: () => isDateSeparatorMessage,
isDayOrMoment: () => isDayOrMoment,
isFirefox: () => isFirefox,
isGalleryAttachmentType: () => isGalleryAttachmentType,
isIntroMessage: () => isIntroMessage,
isLanguageSupported: () => isLanguageSupported,
isLocalMessage: () => isLocalMessage,
isMessageBlocked: () => isMessageBlocked,
isMessageBounced: () => isMessageBounced,
isMessageEdited: () => isMessageEdited,
isNumberOrString: () => isNumberOrString,
isOnlyEmojis: () => isOnlyEmojis,
isSafari: () => isSafari,
isSvgAttachment: () => isSvgAttachment,
isUserMuted: () => isUserMuted,
itTranslations: () => it_default,
jaTranslations: () => ja_default,
keepLineBreaksPlugin: () => keepLineBreaksPlugin,
koTranslations: () => ko_default,
makeDateMessageId: () => makeDateMessageId,
makeIntroMessage: () => makeIntroMessage,
mapToUserNameOrId: () => mapToUserNameOrId,
markDownRenderers: () => markDownRenderers,
matchMarkdownLinks: () => matchMarkdownLinks,
mentionsMarkdownPlugin: () => mentionsMarkdownPlugin,
messageCodeBlocks: () => messageCodeBlocks,
messageHasAttachments: () => messageHasAttachments,
messageHasReactions: () => messageHasReactions,
missingUseFlagHandlerParameterWarning: () => missingUseFlagHandlerParameterWarning,
missingUseMuteHandlerParamsWarning: () => missingUseMuteHandlerParamsWarning,
modalDialogId: () => modalDialogId,
modalDialogManagerId: () => modalDialogManagerId,
moveChannelUp: () => moveChannelUp,
moveChannelUpwards: () => moveChannelUpwards,
nlTranslations: () => nl_default,
processMessages: () => processMessages,
ptTranslations: () => pt_default,
reactionHandlerWarning: () => reactionHandlerWarning,
renderPreviewText: () => renderPreviewText,
renderText: () => renderText,
resampleWaveformData: () => resampleWaveformData,
ruTranslations: () => ru_default,
shouldConsiderArchivedChannels: () => shouldConsiderArchivedChannels,
shouldConsiderPinnedChannels: () => shouldConsiderPinnedChannels,
shouldRenderMessageActions: () => shouldRenderMessageActions,
showMessageActionsBox: () => showMessageActionsBox,
trTranslations: () => tr_default,
upSample: () => upSample,
useAIState: () => useAIState,
useActionHandler: () => useActionHandler,
useActiveThread: () => useActiveThread,
useAttachmentManagerState: () => useAttachmentManagerState,
useAttachmentsForPreview: () => useAttachmentsForPreview,
useAudioController: () => useAudioController,
useCanCreatePoll: () => useCanCreatePoll,
useChannelActionContext: () => useChannelActionContext,
useChannelDeletedListener: () => useChannelDeletedListener,
useChannelEditMessageHandler: () => useEditMessageHandler,
useChannelHiddenListener: () => useChannelHiddenListener,
useChannelListContext: () => useChannelListContext,
useChannelMembershipState: () => useChannelMembershipState,
useChannelMentionsHandler: () => useMentionsHandlers,
useChannelPreviewInfo: () => useChannelPreviewInfo,
useChannelStateContext: () => useChannelStateContext,
useChannelTruncatedListener: () => useChannelTruncatedListener,
useChannelUpdatedListener: () => useChannelUpdatedListener,
useChannelVisibleListener: () => useChannelVisibleListener,
useChat: () => useChat,
useChatContext: () => useChatContext,
useComponentContext: () => useComponentContext,
useConnectionRecoveredListener: () => useConnectionRecoveredListener,
useCooldownTimer: () => useCooldownTimer,
useCreateChatClient: () => useCreateChatClient,
useDeleteHandler: () => useDeleteHandler,
useDialog: () => useDialog,
useDialogAnchor: () => useDialogAnchor,
useDialogIsOpen: () => useDialogIsOpen,
useDialogManager: () => useDialogManager,
useEditHandler: () => useEditHandler,
useEnrichedMessages: () => useEnrichedMessages,
useFlagHandler: () => useFlagHandler,
useLastReadData: () => useLastReadData,
useLegacyThreadContext: () => useLegacyThreadContext,
useLiveLocationSharingManager: () => useLiveLocationSharingManager,
useMarkUnreadHandler: () => useMarkUnreadHandler,
useMentionsHandler: () => useMentionsHandler,
useMessageBounceContext: () => useMessageBounceContext,
useMessageComposer: () => useMessageComposer,
useMessageComposerHasSendableData: () => useMessageComposerHasSendableData,
useMessageContext: () => useMessageContext,
useMessageInputContext: () => useMessageInputContext,
useMessageInputControls: () => useMessageInputControls,
useMessageListContext: () => useMessageListContext,
useMessageListElements: () => useMessageListElements,
useMessageListScrollManager: () => useMessageListScrollManager,
useMessageNewListener: () => useMessageNewListener,
useMessageReminder: () => useMessageReminder,
useMessageTextStreaming: () => useMessageTextStreaming,
useMobileNavigation: () => useMobileNavigation,
useModalDialog: () => useModalDialog,
useModalDialogIsOpen: () => useModalDialogIsOpen,
useModalDialogManager: () => useModalDialogManager,
useMuteHandler: () => useMuteHandler,
useNewMessageNotification: () => useNewMessageNotification,
useNotificationAddedToChannelListener: () => useNotificationAddedToChannelListener,
useNotificationMessageNewListener: () => useNotificationMessageNewListener,
useNotificationRemovedFromChannelListener: () => useNotificationRemovedFromChannelListener,
useNotifications: () => useNotifications,
useOpenThreadHandler: () => useOpenThreadHandler,
useOpenedDialogCount: () => useOpenedDialogCount,
usePaginatedChannels: () => usePaginatedChannels,
usePinHandler: () => usePinHandler,
usePollAnswerPagination: () => usePollAnswerPagination,
usePollContext: () => usePollContext,
usePollOptionVotesPagination: () => usePollOptionVotesPagination,
usePrependedMessagesCount: () => usePrependedMessagesCount,
useReactionHandler: () => useReactionHandler,
useReactionsFetcher: () => useReactionsFetcher,
useRetryHandler: () => useRetryHandler,
useScrollLocationLogic: () => useScrollLocationLogic,
useShouldForceScrollToBottom: () => useShouldForceScrollToBottom,
useStateStore: () => useStateStore,
useThreadContext: () => useThreadContext,
useThreadList: () => useThreadList,
useThreadListItemContext: () => useThreadListItemContext,
useThreadsViewContext: () => useThreadsViewContext,
useTranslationContext: () => useTranslationContext,
useTypingContext: () => useTypingContext,
useUserHandler: () => useUserHandler,
useUserPresenceChangedListener: () => useUserPresenceChangedListener,
useUserRole: () => useUserRole,
validateAndGetMessage: () => validateAndGetMessage,
withChannelActionContext: () => withChannelActionContext,
withChannelStateContext: () => withChannelStateContext,
withChatContext: () => withChatContext,
withComponentContext: () => withComponentContext,
withMessageContext: () => withMessageContext,
withTranslationContext: () => withTranslationContext,
withTypingContext: () => withTypingContext
});
module.exports = __toCommonJS(src_exports);
// src/components/Attachment/Attachment.tsx
var import_react272 = __toESM(require("react"));
var import_stream_chat14 = require("stream-chat");
// src/components/Attachment/AttachmentContainer.tsx
var import_react271 = __toESM(require("react"));
var import_react_player2 = __toESM(require("react-player"));
var import_clsx69 = __toESM(require("clsx"));
var linkify = __toESM(require("linkifyjs"));
var import_stream_chat13 = require("stream-chat");
// src/components/Attachment/AttachmentActions.tsx
var import_react19 = __toESM(require("react"));
// src/context/ChannelActionContext.tsx
var import_react = __toESM(require("react"));
var ChannelActionContext = import_react.default.createContext(void 0);
var ChannelActionProvider = ({
children,
value
}) => /* @__PURE__ */ import_react.default.createElement(ChannelActionContext.Provider, { value }, children);
var useChannelActionContext = (componentName) => {
const contextValue = (0, import_react.useContext)(ChannelActionContext);
if (!contextValue) {
console.warn(
`The useChannelActionContext hook was called outside of the ChannelActionContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
var withChannelActionContext = (Component2) => {
const WithChannelActionContextComponent = (props) => {
const channelActionContext = useChannelActionContext();
return /* @__PURE__ */ import_react.default.createElement(Component2, { ...props, ...channelActionContext });
};
WithChannelActionContextComponent.displayName = (Component2.displayName || Component2.name || "Component").replace("Base", "");
return WithChannelActionContextComponent;
};
// src/context/ChannelListContext.tsx
var import_react2 = __toESM(require("react"));
var ChannelListContext = (0, import_react2.createContext)(
void 0
);
var ChannelListContextProvider = ({
children,
value
}) => /* @__PURE__ */ import_react2.default.createElement(ChannelListContext.Provider, { value }, children);
var useChannelListContext = (componentName) => {
const contextValue = (0, import_react2.useContext)(ChannelListContext);
if (!contextValue) {
console.warn(
`The useChannelListContext hook was called outside of the ChannelListContext provider. Make sure this hook is called within the ChannelList component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// src/context/ChannelStateContext.tsx
var import_react3 = __toESM(require("react"));
var ChannelStateContext = import_react3.default.createContext(void 0);
var ChannelStateProvider = ({
children,
value
}) => /* @__PURE__ */ import_react3.default.createElement(ChannelStateContext.Provider, { value }, children);
var useChannelStateContext = (componentName) => {
const contextValue = (0, import_react3.useContext)(ChannelStateContext);
if (!contextValue) {
console.warn(
`The useChannelStateContext hook was called outside of the ChannelStateContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
var withChannelStateContext = (Component2) => {
const WithChannelStateContextComponent = (props) => {
const channelStateContext = useChannelStateContext();
return /* @__PURE__ */ import_react3.default.createElement(Component2, { ...props, ...channelStateContext });
};
WithChannelStateContextComponent.displayName = (Component2.displayName || Component2.name || "Component").replace("Base", "");
return WithChannelStateContextComponent;
};
// src/context/ChatContext.tsx
var import_react4 = __toESM(require("react"));
// src/context/utils/getDisplayName.ts
var getDisplayName = (Component2) => Component2.displayName || Component2.name || "Component";
// src/context/ChatContext.tsx
var ChatContext = import_react4.default.createContext(void 0);
var ChatProvider = ({
children,
value
}) => /* @__PURE__ */ import_react4.default.createElement(ChatContext.Provider, { value }, children);
var useChatContext = (componentName) => {
const contextValue = (0, import_react4.useContext)(ChatContext);
if (!contextValue) {
console.warn(
`The useChatContext hook was called outside of the ChatContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
var withChatContext = (Component2) => {
const WithChatContextComponent = (props) => {
const chatContext = useChatContext();
return /* @__PURE__ */ import_react4.default.createElement(Component2, { ...props, ...chatContext });
};
WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component2)}`;
return WithChatContextComponent;
};
// src/context/ComponentContext.tsx
var import_react5 = __toESM(require("react"));
var ComponentContext = import_react5.default.createContext({});
var ComponentProvider = ({
children,
value
}) => /* @__PURE__ */ import_react5.default.createElement(ComponentContext.Provider, { value }, children);
var useComponentContext = (_componentName) => (0, import_react5.useContext)(ComponentContext);
var withComponentContext = (Component2) => {
const WithComponentContextComponent = (props) => {
const componentContext = useComponentContext();
return /* @__PURE__ */ import_react5.default.createElement(Component2, { ...props, ...componentContext });
};
WithComponentContextComponent.displayName = (Component2.displayName || Component2.name || "Component").replace("Base", "");
return WithComponentContextComponent;
};
// src/context/DialogManagerContext.tsx
var import_react10 = __toESM(require("react"));
var import_stream_chat2 = require("stream-chat");
// src/components/Dialog/DialogManager.ts
var import_nanoid = require("nanoid");
var import_stream_chat = require("stream-chat");
var DialogManager = class {
constructor({ id } = {}) {
this.state = new import_stream_chat.StateStore({
dialogsById: {}
});
this.id = id ?? (0, import_nanoid.nanoid)();
}
get openDialogCount() {
return Object.values(this.state.getLatestValue().dialogsById).reduce(
(count, dialog) => {
if (dialog.isOpen) return count + 1;
return count;
},
0
);
}
get(id) {
return this.state.getLatestValue().dialogsById[id];
}
getOrCreate({ id }) {
let dialog = this.state.getLatestValue().dialogsById[id];
if (!dialog) {
dialog = {
close: () => {
this.close(id);
},
id,
isOpen: false,
open: () => {
this.open({ id });
},
removalTimeout: void 0,
remove: () => {
this.remove(id);
},
toggle: (closeAll = false) => {
this.toggle({ id }, closeAll);
}
};
this.state.next((current) => ({
...current,
...{ dialogsById: { ...current.dialogsById, [id]: dialog } }
}));
}
if (dialog.removalTimeout) {
clearTimeout(dialog.removalTimeout);
this.state.next((current) => ({
...current,
...{
dialogsById: {
...current.dialogsById,
[id]: {
...dialog,
removalTimeout: void 0
}
}
}
}));
}
return dialog;
}
open(params, closeRest) {
const dialog = this.getOrCreate(params);
if (dialog.isOpen) return;
if (closeRest) {
this.closeAll();
}
this.state.next((current) => ({
...current,
dialogsById: { ...current.dialogsById, [dialog.id]: { ...dialog, isOpen: true } }
}));
}
close(id) {
const dialog = this.state.getLatestValue().dialogsById[id];
if (!dialog?.isOpen) return;
this.state.next((current) => ({
...current,
dialogsById: { ...current.dialogsById, [dialog.id]: { ...dialog, isOpen: false } }
}));
}
closeAll() {
Object.values(this.state.getLatestValue().dialogsById).forEach(
(dialog) => dialog.close()
);
}
toggle(params, closeAll = false) {
if (this.state.getLatestValue().dialogsById[params.id]?.isOpen) {
this.close(params.id);
} else {
this.open(params, closeAll);
}
}
remove(id) {
const state = this.state.getLatestValue();
const dialog = state.dialogsById[id];
if (!dialog) return;
if (dialog.removalTimeout) {
clearTimeout(dialog.removalTimeout);
}
this.state.next((current) => {
const newDialogs = { ...current.dialogsById };
delete newDialogs[id];
return {
...current,
dialogsById: newDialogs
};
});
}
/**
* Marks the dialog state as unused. If the dialog id is referenced again quickly,
* the state will not be removed. Otherwise, the state will be removed after
* a short timeout.
*/
markForRemoval(id) {
const dialog = this.state.getLatestValue().dialogsById[id];
if (!dialog) {
return;
}
this.state.next((current) => ({
...current,
dialogsById: {
...current.dialogsById,
[id]: {
...dialog,
removalTimeout: setTimeout(() => {
this.remove(id);
}, 16)
}
}
}));
}
};
// src/components/Dialog/DialogPortal.tsx
var import_react9 = __toESM(require("react"));
// src/components/Dialog/hooks/useDialog.ts
var import_react7 = require("react");
// src/store/hooks/useStateStore.ts
var import_react6 = require("react");
var import_shim = require("use-sync-external-store/shim");
var noop = () => {
};
function useStateStore(store, selector8) {
const wrappedSubscription = (0, import_react6.useCallback)(
(onStoreChange) => {
const unsubscribe = store?.subscribeWithSelector(selector8, onStoreChange);
return unsubscribe ?? noop;
},
[store, selector8]
);
const wrappedSnapshot = (0, import_react6.useMemo)(() => {
let cachedTuple;
return () => {
const currentValue = store?.getLatestValue();
if (!currentValue) return void 0;
if (cachedTuple && cachedTuple[0] === currentValue) {
return cachedTuple[1];
}
const newlySelected = selector8(currentValue);
if (cachedTuple) {
let selectededAreEqualToCached = true;
for (const key in cachedTuple[1]) {
if (cachedTuple[1][key] === newlySelected[key]) continue;
selectededAreEqualToCached = false;
break;
}
if (selectededAreEqualToCached) return cachedTuple[1];
}
cachedTuple = [currentValue, newlySelected];
return cachedTuple[1];
};
}, [store, selector8]);
const state = (0, import_shim.useSyncExternalStore)(wrappedSubscription, wrappedSnapshot);
return state;
}
// src/components/Dialog/hooks/useDialog.ts
var useDialog = ({ dialogManagerId, id }) => {
const { dialogManager } = useDialogManager({ dialogManagerId });
(0, import_react7.useEffect)(
() => () => {
dialogManager.markForRemoval(id);
},
[dialogManager, id]
);
return dialogManager.getOrCreate({ id });
};
var modalDialogId = "modal-dialog";
var useModalDialog = () => useDialog({ dialogManagerId: modalDialogManagerId, id: modalDialogId });
var useDialogIsOpen = (id, dialogManagerId) => {
const { dialogManager } = useDialogManager({ dialogManagerId });
const dialogIsOpenSelector = (0, import_react7.useCallback)(
({ dialogsById }) => ({ isOpen: !!dialogsById[id]?.isOpen }),
[id]
);
return useStateStore(dialogManager.state, dialogIsOpenSelector).isOpen;
};
var useModalDialogIsOpen = () => useDialogIsOpen(modalDialogId, modalDialogManagerId);
var openedDialogCountSelector = (nextValue) => ({
openedDialogCount: Object.values(nextValue.dialogsById).reduce((count, dialog) => {
if (dialog.isOpen) return count + 1;
return count;
}, 0)
});
var useOpenedDialogCount = ({
dialogManagerId
} = {}) => {
const { dialogManager } = useDialogManager({ dialogManagerId });
return useStateStore(dialogManager.state, openedDialogCountSelector).openedDialogCount;
};
// src/components/Portal/Portal.ts
var import_react8 = require("react");
var import_react_dom = require("react-dom");
var Portal = ({
children,
getPortalDestination,
isOpen
}) => {
const [portalDestination, setPortalDestination] = (0, import_react8.useState)(null);
(0, import_react8.useLayoutEffect)(() => {
const destination = getPortalDestination();
if (!destination || !isOpen) return;
setPortalDestination(destination);
}, [getPortalDestination, isOpen]);
if (!portalDestination) return null;
return (0, import_react_dom.createPortal)(children, portalDestination);
};
// src/components/Dialog/DialogPortal.tsx
var DialogPortalDestination = () => {
const { dialogManager } = useDialogManager();
const openedDialogCount = useOpenedDialogCount();
if (!openedDialogCount) return null;
return /* @__PURE__ */ import_react9.default.createElement(
"div",
{
className: "str-chat__dialog-overlay",
"data-str-chat__portal-id": dialogManager.id,
"data-testid": "str-chat__dialog-overlay",
onClick: () => dialogManager.closeAll(),
style: {
"--str-chat__dialog-overlay-height": openedDialogCount > 0 ? "100%" : "0"
}
}
);
};
var DialogPortalEntry = ({
children,
dialogId
}) => {
const { dialogManager } = useDialogManager({ dialogId });
const dialogIsOpen = useDialogIsOpen(dialogId, dialogManager.id);
const getPortalDestination = (0, import_react9.useCallback)(
() => document.querySelector(`div[data-str-chat__portal-id="${dialogManager.id}"]`),
[dialogManager.id]
);
return /* @__PURE__ */ import_react9.default.createElement(Portal, { getPortalDestination, isOpen: dialogIsOpen }, children);
};
// src/context/DialogManagerContext.tsx
var dialogManagersRegistry = new import_stream_chat2.StateStore({});
var getDialogManager = (id) => dialogManagersRegistry.getLatestValue()[id];
var getOrCreateDialogManager = (id) => {
let manager = getDialogManager(id);
if (!manager) {
manager = new DialogManager({ id });
dialogManagersRegistry.partialNext({ [id]: manager });
}
return manager;
};
var removeDialogManager = (id) => {
if (!getDialogManager(id)) return;
dialogManagersRegistry.partialNext({ [id]: void 0 });
};
var DialogManagerProviderContext = import_react10.default.createContext(void 0);
var DialogManagerProvider = ({
children,
id
}) => {
const [dialogManager, setDialogManager] = (0, import_react10.useState)(() => {
if (id) return getDialogManager(id) ?? null;
return new DialogManager();
});
(0, import_react10.useEffect)(() => {
if (!id) return;
setDialogManager(getOrCreateDialogManager(id));
return () => {
removeDialogManager(id);
setDialogManager(null);
};
}, [id]);
if (!dialogManager) return null;
return /* @__PURE__ */ import_react10.default.createElement(DialogManagerProviderContext.Provider, { value: { dialogManager } }, children, /* @__PURE__ */ import_react10.default.createElement(DialogPortalDestination, null));
};
var getManagerFromStore = ({
dialogId,
dialogManagerId,
newState,
previousState
}) => {
let managerInNewState;
let managerInPrevState;
if (dialogManagerId) {
if (!dialogId) {
managerInNewState = newState[dialogManagerId];
managerInPrevState = previousState?.[dialogManagerId];
} else {
if (newState[dialogManagerId]?.get(dialogId)) {
managerInNewState = newState[dialogManagerId];
}
if (previousState?.[dialogManagerId]?.get(dialogId)) {
managerInPrevState = previousState[dialogManagerId];
}
}
} else if (dialogId) {
managerInNewState = Object.values(newState).find(
(dialogMng) => dialogId && dialogMng?.get(dialogId)
);
managerInPrevState = previousState && Object.values(previousState).find(
(dialogMng) => dialogId && dialogMng?.get(dialogId)
);
}
return { managerInNewState, managerInPrevState };
};
var useDialogManager = ({
dialogId,
dialogManagerId
} = {}) => {
const nearestDialogManagerContext = (0, import_react10.useContext)(DialogManagerProviderContext);
const [dialogManagerContext, setDialogManagerContext] = (0, import_react10.useState)(() => {
const { managerInNewState } = getManagerFromStore({
dialogId,
dialogManagerId,
newState: dialogManagersRegistry.getLatestValue(),
previousState: void 0
});
return managerInNewState ? { dialogManager: managerInNewState } : nearestDialogManagerContext;
});
(0, import_react10.useEffect)(() => {
if (!dialogId && !dialogManagerId) return;
const unsubscribe = dialogManagersRegistry.subscribeWithSelector(
(state) => state,
(newState, previousState) => {
const { managerInNewState, managerInPrevState } = getManagerFromStore({
dialogId,
dialogManagerId,
newState,
previousState
});
if (!managerInPrevState || managerInNewState?.id !== managerInPrevState.id) {
setDialogManagerContext((prevState) => {
if (prevState?.dialogManager.id === managerInNewState?.id) return prevState;
return {
dialogManager: managerInNewState || nearestDialogManagerContext?.dialogManager
};
});
}
}
);
return () => {
unsubscribe();
};
}, [dialogId, dialogManagerId, nearestDialogManagerContext?.dialogManager]);
if (!dialogManagerContext?.dialogManager) {
console.warn(
`Dialog manager (manager id: ${dialogManagerId}, dialog id: ${dialogId}) is not available`
);
}
return dialogManagerContext;
};
var modalDialogManagerId = "modal-dialog-manager";
var ModalDialogManagerProvider = ({ children }) => /* @__PURE__ */ import_react10.default.createElement(DialogManagerProvider, { id: modalDialogManagerId }, children);
var useModalDialogManager = () => (0, import_react10.useMemo)(() => getDialogManager(modalDialogManagerId), []);
// src/context/MessageContext.tsx
var import_react11 = __toESM(require("react"));
var MessageContext = import_react11.default.createContext(
void 0
);
var MessageProvider = ({
children,
value
}) => /* @__PURE__ */ import_react11.default.createElement(MessageContext.Provider, { value }, children);
var useMessageContext = (_componentName) => {
const contextValue = (0, import_react11.useContext)(MessageContext);
if (!contextValue) {
return {};
}
return contextValue;
};
var withMessageContext = (Component2) => {
const WithMessageContextComponent = (props) => {
const messageContext = useMessageContext();
return /* @__PURE__ */ import_react11.default.createElement(Component2, { ...props, ...messageContext });
};
WithMessageContextComponent.displayName = (Component2.displayName || Component2.name || "Component").replace("Base", "");
return WithMessageContextComponent;
};
// src/context/MessageBounceContext.tsx
var import_react12 = __toESM(require("react"));
var MessageBounceContext = (0, import_react12.createContext)(
void 0
);
function useMessageBounceContext(componentName) {
const contextValue = (0, import_react12.useContext)(MessageBounceContext);
if (!contextValue) {
console.warn(
`The useMessageBounceContext hook was called outside of the MessageBounceContext provider. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
}
function MessageBounceProvider({ children }) {
const {
handleRetry: doHandleRetry,
message,
setEditingState
} = useMessageContext("MessageBounceProvider");
if (!isMessageBounced(message)) {
console.warn(
`The MessageBounceProvider was rendered for a message that is not bounced. Have you missed the "isMessageBounced" check?`
);
}
const { removeMessage } = useChannelActionContext("MessageBounceProvider");
const handleDelete2 = (0, import_react12.useCallback)(() => {
removeMessage(message);
}, [message, removeMessage]);
const handleEdit = (0, import_react12.useCallback)(
(e) => {
setEditingState(e);
},
[setEditingState]
);
const handleRetry = (0, import_react12.useCallback)(() => {
doHandleRetry(message);
}, [doHandleRetry, message]);
const value = (0, import_react12.useMemo)(
() => ({
handleDelete: handleDelete2,
handleEdit,
handleRetry,
message
}),
[handleDelete2, handleEdit, handleRetry, message]
);
return /* @__PURE__ */ import_react12.default.createElement(MessageBounceContext.Provider, { value }, children);
}
// src/context/MessageInputContext.tsx
var import_react13 = __toESM(require("react"));
var MessageInputContext = (0, import_react13.createContext)(
void 0
);
var MessageInputContextProvider = ({
children,
value
}) => /* @__PURE__ */ import_react13.default.createElement(MessageInputContext.Provider, { value }, children);
var useMessageInputContext = (c