{"version":3,"file":"useChannel.mjs","names":[],"sources":["../../../src/context/useChannel.ts"],"sourcesContent":["import { useThreadContext } from '../components/Threads';\nimport { useChannelInstanceContext } from './ChannelInstanceContext';\n\nimport type { Channel } from 'stream-chat';\n\nexport const useChannel = (): Channel => {\n  const thread = useThreadContext();\n  const channelFromThread = thread?.channel;\n  const { channel: channelFromInstanceContext } = useChannelInstanceContext();\n  const channel = channelFromThread ?? channelFromInstanceContext;\n\n  if (!channel) {\n    throw new Error(\n      'The useChannel hook could not resolve a channel. Make sure this hook is called within a Thread subtree or within a child of Channel (ChannelInstanceContext provider).',\n    );\n  }\n\n  return channel;\n};\n"],"mappings":";;;AAKA,IAAa,mBAA4B;CAEvC,MAAM,oBADS,iBACW,CAAA,EAAQ;CAClC,MAAM,EAAE,SAAS,+BAA+B,0BAA0B;CAC1E,MAAM,UAAU,qBAAqB;CAErC,IAAI,CAAC,SACH,MAAM,IAAI,MACR,wKACF;CAGF,OAAO;AACT"}