"use strict";

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

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

function _defineProperty2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _ramda() {
  const data = _interopRequireDefault(require("ramda"));

  _ramda = function () {
    return data;
  };

  return data;
}

function _command() {
  const data = _interopRequireDefault(require("../../command"));

  _command = function () {
    return data;
  };

  return data;
}

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

  _consumer = function () {
    return data;
  };

  return data;
}

function _chalkBox() {
  const data = require("../../chalk-box");

  _chalkBox = function () {
    return data;
  };

  return data;
}

function _constants() {
  const data = require("../../../constants");

  _constants = function () {
    return data;
  };

  return data;
}

class Log extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'log <id>');
    (0, _defineProperty2().default)(this, "description", `show components(s) tag history.\n  https://${_constants().BASE_DOCS_DOMAIN}/docs/cli-log.html`);
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "opts", []);
    (0, _defineProperty2().default)(this, "migration", true);
  }

  action([id]) {
    return (0, _consumer().getComponentLogs)(id).then(logs => {
      Object.keys(logs).forEach(key => logs[key].tag = key);
      return _ramda().default.reverse(_ramda().default.values(logs)).map(_ramda().default.evolve({
        date: n => new Date(parseInt(n)).toLocaleString()
      }));
    });
  }

  report(logs) {
    return logs.map(_chalkBox().paintLog).join('\n');
  }

}

exports.default = Log;