{"version":3,"file":"useAIState.mjs","names":[],"sources":["../../../../../src/components/AIStateIndicator/hooks/useAIState.ts"],"sourcesContent":["import type { AIIndicatorState, AIState, Channel } from 'stream-chat';\nimport { AIStates } from 'stream-chat';\n\nimport { useStateStore } from '../../../store';\n\nconst aiStateSelector = (nextValue: AIIndicatorState) => ({\n  aiState: nextValue.aiState,\n});\n\n/**\n * Returns the AI state of the channel, driven by its `ai_indicator.*` events. Falls back to\n * `AIStates.Idle` when there is no channel or no state yet.\n *\n * @param {Channel} channel - The channel for which we want to know the AI state.\n * @returns {{ aiState: AIState }} The current AI state for the given channel.\n */\nexport const useAIState = (channel?: Channel): { aiState: AIState } => {\n  const { aiState } = useStateStore(channel?.state, aiStateSelector) ?? {};\n\n  return { aiState: aiState ?? AIStates.Idle };\n};\n"],"mappings":";;;AAKA,IAAM,mBAAmB,eAAiC,EACxD,SAAS,UAAU,QACrB;;;;;;;;AASA,IAAa,cAAc,YAA4C;CACrE,MAAM,EAAE,YAAY,cAAc,SAAS,OAAO,eAAe,KAAK,CAAC;CAEvE,OAAO,EAAE,SAAS,WAAW,SAAS,KAAK;AAC7C"}