{"version":3,"file":"translators.mjs","names":[],"sources":["../../../../../src/i18n/TranslationBuilder/notifications/translators.ts"],"sourcesContent":["import type { Notification } from 'stream-chat';\n\nimport type { NotificationTranslatorOptions } from './types';\nimport type { Translator } from '../../index';\n\nconst normalizeReason = (notification?: Notification) => {\n  const reason = notification?.metadata?.reason;\n  if (typeof reason !== 'string' || !reason.length) return undefined;\n  return reason.toLowerCase();\n};\n\nexport const translateAttachmentUploadBlocked: Translator<\n  NotificationTranslatorOptions\n> = ({ options: { notification }, t }) => {\n  const rawReason = notification?.metadata?.reason;\n  let reason = t('notification.reason.unsupportedFileType', 'unsupported file type');\n  if (typeof rawReason !== 'string')\n    reason = t('notification.reason.unknownError', 'unknown error');\n  if (rawReason === 'size_limit')\n    reason = t('notification.reason.sizeLimit', 'size limit');\n  return t(\n    'notification.attachmentUploadBlockedWithReason',\n    'Attachment upload blocked due to {{reason}}',\n    { reason },\n  );\n};\n\n// The reason and fallback `t()` calls below are spelled out instead of built by a helper: the key\n// extractor only sees keys that appear literally in a `t()` call.\nexport const translateAttachmentUploadFailed: Translator<\n  NotificationTranslatorOptions\n> = ({ options: { notification }, t }) => {\n  const reason = normalizeReason(notification);\n  return reason\n    ? t(\n        'notification.attachmentUploadFailedWithReason',\n        'Attachment upload failed due to {{reason}}',\n        { reason },\n      )\n    : t('notification.attachmentUploadFailed', 'Error uploading attachment');\n};\n\nexport const translatePollCreateFailed: Translator<NotificationTranslatorOptions> = ({\n  options: { notification },\n  t,\n}) => {\n  const reason = normalizeReason(notification);\n  return reason\n    ? t(\n        'notification.pollCreateFailedWithReason',\n        'Failed to create the poll due to {{reason}}',\n        { reason },\n      )\n    : t('notification.pollCreateFailed', 'Failed to create the poll');\n};\n\nexport const translatePollEndFailed: Translator<NotificationTranslatorOptions> = ({\n  options: { notification },\n  t,\n}) => {\n  const reason = normalizeReason(notification);\n  return reason\n    ? t(\n        'notification.pollEndFailedWithReason',\n        'Failed to end the poll due to {{reason}}',\n        { reason },\n      )\n    : t('notification.pollEndFailed', 'Failed to end the poll');\n};\n\nexport const translateBrowserAudioPlaybackError: Translator<\n  NotificationTranslatorOptions\n> = ({ t }) => t('notification.audioPlaybackError', 'Error reproducing the recording');\n\nexport const translateCommandDisabled: Translator<NotificationTranslatorOptions> = ({\n  options: { notification },\n  t,\n}) => {\n  const reason = normalizeReason(notification);\n\n  if (reason === 'editing') {\n    return t(\n      'notification.commandDisabledWhileEditing',\n      'Command not available while editing',\n    );\n  }\n\n  if (reason === 'quoted_message') {\n    return t(\n      'notification.commandDisabledWhileReplying',\n      'Command not available while replying',\n    );\n  }\n\n  return t('notification.commandDisabled', 'Command not available');\n};\n"],"mappings":";AAKA,IAAM,mBAAmB,iBAAgC;CACvD,MAAM,SAAS,cAAc,UAAU;CACvC,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,QAAQ,OAAO,KAAA;CACzD,OAAO,OAAO,YAAY;AAC5B;AAEA,IAAa,oCAER,EAAE,SAAS,EAAE,gBAAgB,QAAQ;CACxC,MAAM,YAAY,cAAc,UAAU;CAC1C,IAAI,SAAS,EAAE,2CAA2C,uBAAuB;CACjF,IAAI,OAAO,cAAc,UACvB,SAAS,EAAE,oCAAoC,eAAe;CAChE,IAAI,cAAc,cAChB,SAAS,EAAE,iCAAiC,YAAY;CAC1D,OAAO,EACL,kDACA,+CACA,EAAE,OAAO,CACX;AACF;AAIA,IAAa,mCAER,EAAE,SAAS,EAAE,gBAAgB,QAAQ;CACxC,MAAM,SAAS,gBAAgB,YAAY;CAC3C,OAAO,SACH,EACE,iDACA,8CACA,EAAE,OAAO,CACX,IACA,EAAE,uCAAuC,4BAA4B;AAC3E;AAEA,IAAa,6BAAwE,EACnF,SAAS,EAAE,gBACX,QACI;CACJ,MAAM,SAAS,gBAAgB,YAAY;CAC3C,OAAO,SACH,EACE,2CACA,+CACA,EAAE,OAAO,CACX,IACA,EAAE,iCAAiC,2BAA2B;AACpE;AAEA,IAAa,0BAAqE,EAChF,SAAS,EAAE,gBAC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