"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _bluebird() {
  const data = require("bluebird");

  _bluebird = function () {
    return data;
  };

  return data;
}

function _scope() {
  const data = require("../../../scope");

  _scope = function () {
    return data;
  };

  return data;
}

function _bitId() {
  const data = require("../../../bit-id");

  _bitId = function () {
    return data;
  };

  return data;
}

function _scopeGraph() {
  const data = _interopRequireDefault(require("../../../scope/graph/scope-graph"));

  _scopeGraph = function () {
    return data;
  };

  return data;
}

var _default =
/*#__PURE__*/
function () {
  var _graph = (0, _bluebird().coroutine)(function* (path, id) {
    const scope = yield (0, _scope().loadScope)(path);
    const dependencyGraph = yield _scopeGraph().default.loadLatest(scope);

    if (!id) {
      return dependencyGraph.serialize();
    }

    const bitId = yield scope.getParsedId(id);
    const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);
    return dependencyGraph.serialize(componentGraph);
  });

  function graph(_x, _x2) {
    return _graph.apply(this, arguments);
  }

  return graph;
}();

exports.default = _default;