{"version":3,"file":"TypingIndicatorHeader.mjs","names":[],"sources":["../../../../src/components/TypingIndicator/TypingIndicatorHeader.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\n\nimport { TypingIndicatorDots } from './TypingIndicatorDots';\nimport { useChannel } from '../../context';\nimport { useTranslationContext } from '../../context/TranslationContext';\nimport { useThreadContext } from '../Threads';\n\nimport { useDebouncedTypingActive } from './hooks/useDebouncedTypingActive';\nimport { useTypingUsers } from './hooks/useTypingUsers';\nimport { getTypingStatusMessage } from './utils/getTypingStatusMessage';\n\nexport type TypingIndicatorHeaderProps = {\n  /** Whether to show typing in the current thread instead of the channel. Defaults to `false`. */\n  threadList?: boolean;\n};\n\n/**\n * Inline typing text followed by animated dots, for channel and thread headers. Shows only other\n * users and renders nothing when the channel's `typingEvents.enabled` is false.\n */\nexport const TypingIndicatorHeader = (props: TypingIndicatorHeaderProps) => {\n  const { threadList = false } = props;\n\n  const { t } = useTranslationContext();\n  const channel = useChannel();\n  const threadInstance = useThreadContext();\n  const typingUsers = useTypingUsers(\n    channel,\n    threadList ? threadInstance?.id : undefined,\n  );\n  const { displayUsers } = useDebouncedTypingActive(typingUsers);\n  const label = getTypingStatusMessage(displayUsers, t);\n\n  if (displayUsers.length === 0) {\n    return null;\n  }\n\n  return (\n    <span\n      className={clsx('str-chat__typing-indicator-header', {\n        'str-chat__typing-indicator-header--thread': threadList,\n      })}\n      data-testid='typing-indicator-header'\n    >\n      <span className='str-chat__typing-indicator-header__text'>{label}</span>\n      <span className='str-chat__typing-indicator__dots str-chat__typing-indicator-header__dots'>\n        <TypingIndicatorDots />\n      </span>\n    </span>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAa,yBAAyB,UAAsC;CAC1E,MAAM,EAAE,aAAa,UAAU;CAE/B,MAAM,EAAE,MAAM,sBAAsB;CACpC,MAAM,UAAU,WAAW;CAC3B,MAAM,iBAAiB,iBAAiB;CAKxC,MAAM,EAAE,iBAAiB,yBAJL,eAClB,SACA,aAAa,gBAAgB,KAAK,KAAA,CAEc,CAAW;CAC7D,MAAM,QAAQ,uBAAuB,cAAc,CAAC;CAEpD,IAAI,aAAa,WAAW,GAC1B,OAAO;CAGT,OACE,qBAAC,QAAD;EACE,WAAW,KAAK,qCAAqC,EACnD,6CAA6C,WAC/C,CAAC;EACD,eAAY;YAJd,CAME,oBAAC,QAAD;GAAM,WAAU;aAA2C;EAAY,CAAA,GACvE,oBAAC,QAAD;GAAM,WAAU;aACd,oBAAC,qBAAD,CAAsB,CAAA;EAClB,CAAA,CACF;;AAEV"}