{"version":3,"file":"Streami18n.mjs","names":[],"sources":["../../../src/i18n/Streami18n.ts"],"sourcesContent":["import { Streami18n as CoreStreami18n } from '@stream-io/i18n';\nimport type { Streami18nOptions as CoreStreami18nOptions } from '@stream-io/i18n';\nimport { languageNameDefaults } from 'stream-chat';\n\nimport { NotificationTranslationTopic } from './TranslationBuilder';\nimport { runtimeDefaults } from './runtimeDefaults';\nimport type { BundledKey, TranslationCatalog } from './types';\n\n/**\n * Options for {@link Streami18n}. `runtimeDefaults` and `translationBuilderTopics` are merged over\n * the SDK's own, so supplying either adds to what the SDK ships.\n */\nexport type Streami18nOptions = CoreStreami18nOptions<TranslationCatalog>;\n\n/**\n * Wrapper around [i18next](https://www.i18next.com/) for this SDK's translations. Pass an instance to\n * `<Chat i18nInstance={...}>` to control language and copy.\n *\n * Adds this SDK's bundled data and notification translation topic to the `@stream-io/i18n`\n * implementation. A partial dictionary is safe: missing keys render the English copy passed inline\n * at each call site. Type a dictionary as `TranslationDictionary` so unknown keys fail to\n * compile. `setLanguage()` publishes the new `t` to `i18n.state`, which `<Chat>` subscribes to.\n *\n * Override some English copy:\n *\n * ```ts\n * const i18n = new Streami18n({\n *   translationsForLanguage: {\n *     'emptyState.indicator.noConversationsYet.label': 'Nothing here yet',\n *   },\n * });\n * ```\n *\n * Add a language:\n *\n * ```ts\n * import 'dayjs/locale/nl';\n *\n * const i18n = new Streami18n({ language: 'nl' });\n * i18n.registerTranslation('nl', { 'typing.singleUser': '{{ typing }} is aan het typen' });\n * ```\n */\nexport class Streami18n extends CoreStreami18n<TranslationCatalog, BundledKey> {\n  constructor(options: Streami18nOptions = {}) {\n    super({\n      ...options,\n      // The `language.*` names from `stream-chat` go first, so this SDK's data and the integrator's\n      // can override an individual name.\n      runtimeDefaults: {\n        ...languageNameDefaults,\n        ...runtimeDefaults,\n        ...options.runtimeDefaults,\n      },\n      // Merged so an integrator adding a topic does not drop the `notification` topic, which would\n      // leave notifications untranslated without an error.\n      translationBuilderTopics: {\n        notification: NotificationTranslationTopic,\n        ...options.translationBuilderTopics,\n      },\n    });\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,eAAb,cAAgC,WAA+C;CAC7E,YAAY,UAA6B,CAAC,GAAG;EAC3C,MAAM;GACJ,GAAG;GAGH,iBAAiB;IACf,GAAG;IACH,GAAG;IACH,GAAG,QAAQ;GACb;GAGA,0BAA0B;IACxB,cAAc;IACd,GAAG,QAAQ;GACb;EACF,CAAC;CACH;AACF"}