import type React from 'react' /** * Three messaging states a `MessageAttachment.*` card can render in, * mirroring the LinkAttachment / LockedAttachment families. */ export type MessageAttachmentState = 'composer' | 'sent' | 'received' /** * Visual variant of the surrounding `Bubble` chrome. Sender-side bubbles * (`composer`, `sent`) get the dark treatment; recipient-side bubbles * (`received`) get the light treatment. */ export type BubbleVariant = 'dark' | 'light' /** Maps a state to the bubble chrome it should render with. */ export const bubbleVariantForState = ( state: MessageAttachmentState ): BubbleVariant => (state === 'received' ? 'light' : 'dark') /** * Position of a bubble inside a same-author run, mirroring the grouping * stream-chat-react applies to consecutive messages from the same user: * * - `'single'` — standalone message, every corner fully rounded. * - `'first'` — first in a 2+ message run; the corner facing the * next bubble in the run is flattened. * - `'middle'` — both the corner facing the previous bubble and the * corner facing the next bubble are flattened. * - `'end'` — last in a 2+ message run; the corner facing the * previous bubble is flattened (this is also the * bubble the avatar attaches to on the receiver side). * * "Facing" is determined by the bubble's side: sender-aligned bubbles * cluster against their right edge, receiver-aligned bubbles against * their left edge. */ export type BubbleGroupPosition = 'single' | 'first' | 'middle' | 'end' /** * Convenience adapter that derives the `BubbleGroupPosition` from the * three booleans `stream-chat-react` forwards into the `Message` HOC. * Drop-in for `useMessageContext()` consumers: * * ```tsx * const { firstOfGroup, endOfGroup, groupedByUser } = useMessageContext() * * ``` * * @deprecated Unadopted convenience adapter, slated for removal in a future * release. No consumer uses it. Derive `groupPosition` (a `BubbleGroupPosition`) * inline from stream-chat-react's `firstOfGroup` / `endOfGroup` / * `groupedByUser` booleans instead. */ export const bubbleGroupPositionFromStream = ({ firstOfGroup, endOfGroup, groupedByUser, }: { firstOfGroup?: boolean endOfGroup?: boolean groupedByUser?: boolean }): BubbleGroupPosition => { if (!groupedByUser) return 'single' if (firstOfGroup && endOfGroup) return 'single' if (firstOfGroup) return 'first' if (endOfGroup) return 'end' return 'middle' } /** Loading hint forwarded to the underlying `` element. */ export type ImageLoadingMode = 'lazy' | 'eager' /** Preload hint forwarded to the underlying `