{"version":3,"file":"lib.mjs","names":[],"sources":["../../../../../../../../src/lib/propsContext/nestedPropsContext/lib.ts"],"sourcesContent":["import type { PropsContext } from \"@/lib/propsContext/types\";\nimport {\n  nestingLevelKey,\n  type NestingLevelProps,\n} from \"@/lib/propsContext/nestedPropsContext/types\";\nimport { isFlowComponentName } from \"@/lib/propsContext/isFlowComponentName\";\n\nexport function isNestingProps(\n  propsContext: unknown,\n): propsContext is NestingLevelProps {\n  return (\n    !!propsContext &&\n    typeof propsContext === \"object\" &&\n    nestingLevelKey in propsContext &&\n    typeof propsContext[nestingLevelKey] === \"number\"\n  );\n}\n\nexport function isNestingLevelKey(key: string) {\n  return key === nestingLevelKey;\n}\n\nexport const getNestingLevel = (props: unknown) => {\n  return isNestingProps(props) ? (props[nestingLevelKey] ?? 0) : 0;\n};\n\nexport const addNestingLevel = (\n  propsContext: PropsContext,\n  currentLevel = 0,\n) => {\n  const withNestingLevel: PropsContext = {\n    ...propsContext,\n  };\n\n  for (const [key, value] of Object.entries(propsContext)) {\n    if (isFlowComponentName(key) && !isNestingProps(value)) {\n      withNestingLevel[key] = {\n        ...addNestingLevel(value, currentLevel + 1),\n        [nestingLevelKey]: currentLevel,\n      };\n    }\n  }\n\n  return withNestingLevel;\n};\n"],"mappings":";;;;;AAOA,SAAgB,eACd,cACmC;CACnC,OACE,CAAC,CAAC,gBACF,OAAO,iBAAiB,YAAA,qBACL,gBACnB,OAAO,aAAA,uBAAkC;AAE7C;AAEA,SAAgB,kBAAkB,KAAa;CAC7C,OAAO,QAAQ;AACjB;AAEA,IAAa,mBAAmB,UAAmB;CACjD,OAAO,eAAe,KAAK,IAAK,MAAA,sBAA0B,IAAK;AACjE;AAEA,IAAa,mBACX,cACA,eAAe,MACZ;CACH,MAAM,mBAAiC,EACrC,GAAG,aACL;CAEA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,GACpD,IAAI,oBAAoB,GAAG,KAAK,CAAC,eAAe,KAAK,GACnD,iBAAiB,OAAO;EACtB,GAAG,gBAAgB,OAAO,eAAe,CAAC;GACzC,kBAAkB;CACrB;CAIJ,OAAO;AACT"}