{"version":3,"file":"ChannelListItemTimestamp.mjs","names":[],"sources":["../../../../src/components/ChannelListItem/ChannelListItemTimestamp.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport type { LocalMessage } from 'stream-chat';\n\nimport { useTranslationContext } from '../../context/TranslationContext';\nimport { getDateString } from '../../i18n/utils';\nimport { convertTimestampToDate } from 'stream-chat';\n\nexport type ChannelListItemTimestampProps = {\n  /** Message whose `created_at` is shown. */\n  previewedMessage?: LocalMessage;\n};\n\nexport function ChannelListItemTimestamp({\n  previewedMessage,\n}: ChannelListItemTimestampProps) {\n  const { t, tDateTimeParser } = useTranslationContext();\n\n  const timestamp = previewedMessage?.created_at;\n  // `created_at` can be a wire timestamp (a number), not a `Date`, so it is converted.\n  const normalizedTimestamp =\n    timestamp != null ? convertTimestampToDate(timestamp)?.toISOString() : undefined;\n\n  const when = useMemo(\n    () =>\n      getDateString({\n        messageCreatedAt: normalizedTimestamp,\n        t,\n        tDateTimeParser,\n        timestampTranslationKey: 'timestamp.ChannelPreviewTimestamp',\n      }),\n    [normalizedTimestamp, t, tDateTimeParser],\n  );\n\n  if (!when) return null;\n\n  return (\n    <time\n      className='str-chat__channel-list-item-timestamp'\n      dateTime={normalizedTimestamp}\n    >\n      {when}\n    </time>\n  );\n}\n"],"mappings":";;;;;;AAYA,SAAgB,yBAAyB,EACvC,oBACgC;CAChC,MAAM,EAAE,GAAG,oBAAoB,sBAAsB;CAErD,MAAM,YAAY,kBAAkB;CAEpC,MAAM,sBACJ,aAAa,OAAO,uBAAuB,SAAS,CAAC,EAAE,YAAY,IAAI,KAAA;CAEzE,MAAM,OAAO,cAET,cAAc;EACZ,kBAAkB;EAClB;EACA;EACA,yBAAyB;CAC3B,CAAC,GACH;EAAC;EAAqB;EAAG;CAAe,CAC1C;CAEA,IAAI,CAAC,MAAM,OAAO;CAElB,OACE,oBAAC,QAAD;EACE,WAAU;EACV,UAAU;YAET;CACG,CAAA;AAEV"}