"use strict";

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

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

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

  _bluebird = function () {
    return data;
  };

  return data;
}

function _consumer() {
  const data = require("../../../consumer");

  _consumer = function () {
    return data;
  };

  return data;
}

function _loader() {
  const data = _interopRequireDefault(require("../../../cli/loader"));

  _loader = function () {
    return data;
  };

  return data;
}

function _loaderMessages() {
  const data = require("../../../cli/loader/loader-messages");

  _loaderMessages = function () {
    return data;
  };

  return data;
}

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

  _bitId = function () {
    return data;
  };

  return data;
}

function deprecate(_x) {
  return _deprecate.apply(this, arguments);
}

function _deprecate() {
  _deprecate = (0, _bluebird().coroutine)(function* ({
    ids,
    remote
  }) {
    if (remote) _loader().default.start(_loaderMessages().BEFORE_REMOTE_DEPRECATE);
    const consumer = yield (0, _consumer().loadConsumer)();
    const bitIds = getBitIds(ids, remote, consumer);
    return consumer.deprecate(bitIds, remote);
  });
  return _deprecate.apply(this, arguments);
}

function undeprecate(_x2) {
  return _undeprecate.apply(this, arguments);
}

function _undeprecate() {
  _undeprecate = (0, _bluebird().coroutine)(function* ({
    ids,
    remote
  }) {
    if (remote) _loader().default.start(_loaderMessages().BEFORE_REMOTE_UNDEPRECATE);
    const consumer = yield (0, _consumer().loadConsumer)();
    const bitIds = getBitIds(ids, remote, consumer);
    return consumer.undeprecate(bitIds, remote);
  });
  return _undeprecate.apply(this, arguments);
}

function getBitIds(ids, remote, consumer) {
  return ids.map(id => {
    return remote ? _bitId().BitId.parse(id, true) : consumer.getParsedId(id);
  });
}