{"version":3,"file":"DateSeparator.mjs","names":[],"sources":["../../../../src/components/DateSeparator/DateSeparator.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\n\nimport { useTranslationContext } from '../../context/TranslationContext';\nimport { getDateString } from '../../i18n/utils';\n\nimport type { TimestampFormatterOptions } from '../../i18n/types';\n\nexport type DateSeparatorProps = TimestampFormatterOptions & {\n  /** Class name added to the root element. */\n  className?: string;\n  /** The date to format. */\n  date: Date;\n  /** Positions the separator absolutely at the top of its container. */\n  floating?: boolean;\n  /** Replaces the default date formatting. */\n  formatDate?: (date: Date) => string;\n  // todo: position and unread are not necessary anymore\n  /**\n   * Has no effect: every position renders the same markup.\n   * @default right\n   */\n  position?: 'left' | 'center' | 'right';\n  /** Has no effect. */\n  unread?: boolean;\n};\n\nconst UnMemoizedDateSeparator = (props: DateSeparatorProps) => {\n  const {\n    calendar,\n    className,\n    date: messageCreatedAt,\n    floating,\n    formatDate,\n    ...restTimestampFormatterOptions\n  } = props;\n\n  const { t, tDateTimeParser } = useTranslationContext();\n\n  const formattedDate = getDateString({\n    calendar,\n    ...restTimestampFormatterOptions,\n    formatDate,\n    messageCreatedAt,\n    t,\n    tDateTimeParser,\n    timestampTranslationKey: 'timestamp.DateSeparator',\n  });\n\n  return (\n    <div\n      className={clsx(\n        'str-chat__date-separator',\n        { 'str-chat__date-separator--floating': floating },\n        className,\n      )}\n      data-date={messageCreatedAt.toISOString()}\n      data-testid={floating ? 'floating-date-separator' : 'date-separator'}\n    >\n      <div className='str-chat__date-separator-date'>{formattedDate}</div>\n    </div>\n  );\n};\n\n/** A date separator between messages. */\nexport const DateSeparator = React.memo(\n  UnMemoizedDateSeparator,\n) as typeof UnMemoizedDateSeparator;\n"],"mappings":";;;;;;AA2BA,IAAM,2BAA2B,UAA8B;CAC7D,MAAM,EACJ,UACA,WACA,MAAM,kBACN,UACA,YACA,GAAG,kCACD;CAEJ,MAAM,EAAE,GAAG,oBAAoB,sBAAsB;CAErD,MAAM,gBAAgB,cAAc;EAClC;EACA,GAAG;EACH;EACA;EACA;EACA;EACA,yBAAyB;CAC3B,CAAC;CAED,OACE,oBAAC,OAAD;EACE,WAAW,KACT,4BACA,EAAE,sCAAsC,SAAS,GACjD,SACF;EACA,aAAW,iBAAiB,YAAY;EACxC,eAAa,WAAW,4BAA4B;YAEpD,oBAAC,OAAD;GAAK,WAAU;aAAiC;EAAmB,CAAA;CAChE,CAAA;AAET;;AAGA,IAAa,gBAAgB,MAAM,KACjC,uBACF"}