{"version":3,"file":"MessageListContext.mjs","names":[],"sources":["../../../src/context/MessageListContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\nimport type { PropsWithChildren } from 'react';\nimport type { RenderedMessage } from '../components';\nimport { requireContext } from './requireContext';\n\nexport type MessageListContextValue = {\n  /** Messages enriched with date separators and, if enabled, the intro message. */\n  processedMessages: RenderedMessage[];\n  /** The scroll container that holds the messages and the typing indicator. */\n  listElement: HTMLElement | null;\n  /** Scrolls the `listElement` to the bottom. */\n  scrollToBottom: () => void;\n};\n\nexport const MessageListContext = createContext<MessageListContextValue | undefined>(\n  undefined,\n);\n\n/** Provides the value to components rendered within the `MessageList`. */\nexport const MessageListContextProvider = ({\n  children,\n  value,\n}: PropsWithChildren<{\n  value: MessageListContextValue;\n}>) => (\n  <MessageListContext.Provider value={value as MessageListContextValue}>\n    {children}\n  </MessageListContext.Provider>\n);\n\nexport const useMessageListContext = () =>\n  requireContext(\n    useContext(MessageListContext),\n    'useMessageListContext',\n    'MessageListContextProvider',\n  );\n"],"mappings":";;;;AAcA,IAAa,qBAAqB,cAChC,KAAA,CACF;;AAGA,IAAa,8BAA8B,EACzC,UACA,YAIA,oBAAC,mBAAmB,UAApB;CAAoC;CACjC;AAC0B,CAAA;AAG/B,IAAa,8BACX,eACE,WAAW,kBAAkB,GAC7B,yBACA,4BACF"}