{"version":3,"file":"NewMessageNotification.mjs","names":[],"sources":["../../../../src/components/MessageList/NewMessageNotification.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useComponentContext } from '../../context/ComponentContext';\nimport { useTranslationContext } from '../../context/TranslationContext';\n\nexport type NewMessageNotificationProps = {\n  /** Label computed from `newMessageCount`; passed to a custom `NewMessageNotification`. */\n  label?: string;\n  /** Renders nothing when falsy. */\n  showNotification?: boolean;\n  /** Number of new messages since the user scrolled up. The label shows it when above 0. */\n  newMessageCount?: number;\n};\n\nconst UnMemoizedNewMessageNotification = (props: NewMessageNotificationProps) => {\n  const { newMessageCount = 0, showNotification } = props;\n\n  const { t } = useTranslationContext();\n\n  const { NewMessageNotification: CustomNewMessageNotification } = useComponentContext();\n\n  if (!showNotification) return null;\n\n  const label =\n    newMessageCount > 0\n      ? t('common.newMessages.label', {\n          count: newMessageCount,\n          defaultValue_one: '{{count}} new message',\n          defaultValue_other: '{{count}} new messages',\n        })\n      : t('messageList.newMessageNotification.newMessages.label', 'New Messages!');\n\n  if (CustomNewMessageNotification) {\n    return <CustomNewMessageNotification {...props} label={label} />;\n  }\n\n  return (\n    <div className='str-chat__new-message-notification'>\n      <div\n        aria-atomic='true'\n        aria-live='polite'\n        className='str-chat__message-notification__label'\n        data-testid='message-notification'\n        role='status'\n      >\n        {label}\n      </div>\n    </div>\n  );\n};\n\nexport const NewMessageNotification = React.memo(\n  UnMemoizedNewMessageNotification,\n) as typeof UnMemoizedNewMessageNotification;\n"],"mappings":";;;;;AAcA,IAAM,oCAAoC,UAAuC;CAC/E,MAAM,EAAE,kBAAkB,GAAG,qBAAqB;CAElD,MAAM,EAAE,MAAM,sBAAsB;CAEpC,MAAM,EAAE,wBAAwB,iCAAiC,oBAAoB;CAErF,IAAI,CAAC,kBAAkB,OAAO;CAE9B,MAAM,QACJ,kBAAkB,IACd,EAAE,4BAA4B;EAC5B,OAAO;EACP,kBAAkB;EAClB,oBAAoB;CACtB,CAAC,IACD,EAAE,wDAAwD,eAAe;CAE/E,IAAI,8BACF,OAAO,oBAAC,8BAAD;EAA8B,GAAI;EAAc;CAAQ,CAAA;CAGjE,OACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,OAAD;GACE,eAAY;GACZ,aAAU;GACV,WAAU;GACV,eAAY;GACZ,MAAK;aAEJ;EACE,CAAA;CACF,CAAA;AAET;AAEA,IAAa,yBAAyB,MAAM,KAC1C,gCACF"}