{"version":3,"file":"getContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getContentNodeByKeyPath = (\n  dictionaryContent: ContentNode,\n  keyPath: KeyPath[],\n  fallbackLocale?: LocalesValues\n): ContentNode => {\n  let currentValue: any = structuredClone(dictionaryContent);\n\n  for (const keyObj of keyPath) {\n    // Auto-resolve translation nodes when fallbackLocale is provided\n    if (fallbackLocale && currentValue?.nodeType === NodeTypes.TRANSLATION) {\n      currentValue = currentValue?.[NodeTypes.TRANSLATION]?.[fallbackLocale];\n    }\n\n    if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n      currentValue = currentValue?.[keyObj.key];\n    }\n\n    if (\n      keyObj.type === NodeTypes.TRANSLATION ||\n      keyObj.type === NodeTypes.CONDITION ||\n      keyObj.type === NodeTypes.ENUMERATION ||\n      keyObj.type === NodeTypes.PLURAL\n    ) {\n      currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n    }\n\n    if (\n      keyObj.type === NodeTypes.MARKDOWN ||\n      keyObj.type === NodeTypes.HTML ||\n      keyObj.type === NodeTypes.INSERTION ||\n      keyObj.type === NodeTypes.FILE\n    ) {\n      currentValue = currentValue?.[keyObj.type];\n    }\n  }\n\n  return currentValue as ContentNode;\n};\n"],"mappings":";;;;;;AAKA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAI,eAAoB,gBAAgB,kBAAkB;AAE1D,MAAK,MAAM,UAAU,SAAS;AAE5B,MAAI,kBAAkB,cAAc,aAAaA,yBAAU,YACzD,gBAAe,eAAeA,yBAAU,eAAe;AAGzD,MAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,MAChE,gBAAe,eAAe,OAAO;AAGvC,MACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,OAE1B,gBAAe,eAAe,OAAO,QAAQ,OAAO;AAGtD,MACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,KAE1B,gBAAe,eAAe,OAAO;;AAIzC,QAAO"}