'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator;

function _load_regenerator() {
  return _regenerator = _interopRequireDefault(require('babel-runtime/regenerator'));
}

var _bluebird;

function _load_bluebird() {
  return _bluebird = require('bluebird');
}

var _scope;

function _load_scope() {
  return _scope = require('../../../scope');
}

var _bitId;

function _load_bitId() {
  return _bitId = require('../../../bit-id');
}

var _scopeComponentsImporter;

function _load_scopeComponentsImporter() {
  return _scopeComponentsImporter = _interopRequireDefault(require('../../../scope/component-ops/scope-components-importer'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = function () {
  var _ref = (0, (_bluebird || _load_bluebird()).coroutine)( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee(path, id, ciProps) {
    var scope, bitId, scopeComponentsImporter, component;
    return (_regenerator || _load_regenerator()).default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return (0, (_scope || _load_scope()).loadScope)(path);

          case 2:
            scope = _context.sent;
            _context.next = 5;
            return scope.getParsedId(id);

          case 5:
            bitId = _context.sent;
            scopeComponentsImporter = (_scopeComponentsImporter || _load_scopeComponentsImporter()).default.getInstance(scope);
            _context.next = 9;
            return scopeComponentsImporter.loadComponent(bitId);

          case 9:
            component = _context.sent;
            return _context.abrupt('return', scope.sources.modifyCIProps({ source: component, ciProps }));

          case 11:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, this);
  }));

  function modifyCIProps(_x, _x2, _x3) {
    return _ref.apply(this, arguments);
  }

  return modifyCIProps;
}();