{"version":3,"file":"getLocalizedContent.cjs","names":["translationPlugin","deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type {\n  DeclaredLocales,\n  LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n  type DeepTransformContent,\n  type NodeProps,\n  type Plugins,\n  translationPlugin,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n * In comparison to `getContent`, this function will only apply the translation plugin.\n * It will not transform enumerations, insertions, or other content types.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getLocalizedContent = <\n  T extends ContentNode,\n  L extends LocalesValues = DeclaredLocales,\n>(\n  node: T,\n  locale: L,\n  nodeProps: NodeProps,\n  fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale\n) => {\n  const plugins: Plugins[] = [\n    translationPlugin(locale, fallback),\n    ...(nodeProps.plugins ?? []),\n  ];\n\n  return deepTransformNode(node, {\n    ...nodeProps,\n    plugins,\n  }) as DeepTransformContent<T>;\n};\n\nexport const getPerLocaleDictionary = <\n  T extends Dictionary,\n  L extends LocalesValues,\n>(\n  dictionary: T,\n  locale: L,\n  fallback?: LocalesValues\n): Dictionary => ({\n  ...dictionary,\n  locale,\n  content: getLocalizedContent(\n    dictionary.content,\n    locale,\n    {\n      dictionaryKey: dictionary.key,\n      keyPath: [],\n      plugins: [],\n    },\n    fallback\n  ),\n});\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,uBAIX,MACA,QACA,WACA,aACG;CACH,MAAM,UAAqB,CACzBA,yDAAkB,QAAQ,SAAS,EACnC,GAAI,UAAU,WAAW,EAAE,CAC5B;AAED,QAAOC,+DAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC;;AAGJ,MAAa,0BAIX,YACA,QACA,cACgB;CAChB,GAAG;CACH;CACA,SAAS,oBACP,WAAW,SACX,QACA;EACE,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,EAAE;EACZ,EACD,SACD;CACF"}