export var filterImportedDependencies = function filterImportedDependencies() {
  var importedDependencies = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var selectedDependencyEdgeNodes = arguments.length > 1 ? arguments[1] : undefined;

  if (!selectedDependencyEdgeNodes) {
    return [];
  }

  return importedDependencies.filter(function (dependency) {
    var sources = selectedDependencyEdgeNodes.sources;
    return sources.find(function (source) {
      var pathIndexMath = /\w/.exec(dependency.sourceFile);
      var pathName = dependency.sourceFile.substr(pathIndexMath && pathIndexMath.index);
      return source.indexOf(pathName) !== -1;
    });
  });
};
export var findFileNode = function findFileNode(path, filesMap, foldersMap) {
  if (foldersMap[path]) {
    path += '/index';
  }

  if (filesMap[path]) {
    return filesMap[path];
  }

  var completePath = Object.keys(filesMap).find(function (key) {
    return key.indexOf(path) === 0;
  });
  return filesMap[completePath];
}; // TODO: move to BE

export var extractExportsForImports = function extractExportsForImports(fileCode, specifiers, path) {
  /*let ast = {};
  const exports = [];
   try {
    ast = babylon.parse(fileCode, astParseConfig);
     const isDefaultImported = !!specifiers.find(({ type }) => type === 'ImportDefaultSpecifier');
    const namedImportsNames = specifiers
      .filter(({ type }) => type === 'ImportSpecifier')
      .map(({ name }) => name);
     babelTraverse.default(ast, {
      enter(path) {
        const node = path.node;
         if (isDefaultImported && node.type === 'ExportDefaultDeclaration') {
          exports.push(node);
        } else if (node.type === 'ExportNamedDeclaration') {
          const declaration =
            node.declaration &&
            node.declaration.declarations.find(d => namedImportsNames.includes(d.id.name));
          if (declaration) {
            exports.push(node);
          }
        }
      }
    });
     return exports.map(getNodeLines);
  } catch (e) {
    console.log(path, e);
    return exports;
  }*/
};