{"version":3,"file":"useThreadHead.mjs","names":[],"sources":["../../../../../src/components/MessageList/hooks/useThreadHead.tsx"],"sourcesContent":["import React from 'react';\n\nimport { ThreadHead as DefaultThreadHead } from '../../Thread/ThreadHead';\nimport { useComponentContext } from '../../../context';\nimport { useThreadContext } from '../../Threads';\nimport { useStateStore } from '../../../store';\n\nimport { omitUndefinedProps } from '../omitUndefinedProps';\n\nimport type { ThreadState } from 'stream-chat';\nimport type { MessageProps } from '../../Message/types';\n\nconst parentMessageSelector = ({ parentMessage }: ThreadState) => ({ parentMessage });\n\n/** The props a message list gives each of its messages, which the parent message gets too. */\nexport type ThreadHeadMessageProps = Omit<Partial<MessageProps>, 'message'>;\n\n/**\n * The parent message a thread list renders above its replies, or `null` outside a thread.\n *\n * The head belongs to the list, not to `Thread`, because it has to sit inside the scroll\n * container. It takes the list-wide message props the replies get, so handlers such as\n * `onMentionsClick` apply to the parent message as well.\n */\nexport const useThreadHead = (messageProps?: ThreadHeadMessageProps) => {\n  const thread = useThreadContext();\n  const { ThreadHead = DefaultThreadHead } = useComponentContext();\n  const { parentMessage } = useStateStore(thread?.state, parentMessageSelector) ?? {};\n\n  if (!parentMessage) return null;\n\n  return (\n    <ThreadHead\n      key={parentMessage.id}\n      {...omitUndefinedProps(messageProps)}\n      message={parentMessage}\n    />\n  );\n};\n"],"mappings":";;;;;;;;AAYA,IAAM,yBAAyB,EAAE,qBAAkC,EAAE,cAAc;;;;;;;;AAYnF,IAAa,iBAAiB,iBAA0C;CACtE,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,YAAA,eAAa,eAAsB,oBAAoB;CAC/D,MAAM,EAAE,kBAAkB,cAAc,QAAQ,OAAO,qBAAqB,KAAK,CAAC;CAElF,IAAI,CAAC,eAAe,OAAO;CAE3B,OACE,oBAAC,cAAD;EAEE,GAAI,mBAAmB,YAAY;EACnC,SAAS;CACV,GAHM,cAAc,EAGpB;AAEL"}