"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 _command() {
  const data = _interopRequireDefault(require("../../command"));

  _command = function () {
    return data;
  };

  return data;
}

function _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = function () {
    return data;
  };

  return data;
}

function _utils() {
  const data = require("../../../utils");

  _utils = function () {
    return data;
  };

  return data;
}

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

  _scope = function () {
    return data;
  };

  return data;
}

class ScopeConfig extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'scope-config');
    (0, _defineProperty2().default)(this, "description", 'scope config management');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "commands", [new ScopeConfigSet(), new ScopeConfigDel(), new ScopeConfigGet(), new ScopeConfigList()]);
    (0, _defineProperty2().default)(this, "opts", []);
    (0, _defineProperty2().default)(this, "migration", true);
  }

  action() {
    return _scope().scopeConfig.list();
  }

  report(conf) {
    return (0, _utils().objectToStringifiedTupleArray)(conf).map(tuple => {
      return tuple.join('     ');
    }).join('\n');
  }

}

exports.default = ScopeConfig;

class ScopeConfigSet extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'set <key> <val>');
    (0, _defineProperty2().default)(this, "description", 'set a scope configuration');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "private", true);
    (0, _defineProperty2().default)(this, "opts", []);
  }

  action([key, value]) {
    return _scope().scopeConfig.set(key, value);
  }

  report({
    key,
    value
  }) {
    return `${_chalk().default.yellow(key)} has been set to - ${_chalk().default.yellow(value)}`;
  }

}

class ScopeConfigGet extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'get <key>');
    (0, _defineProperty2().default)(this, "description", 'get a scope configuration');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "private", true);
    (0, _defineProperty2().default)(this, "opts", []);
  }

  action([key]) {
    return _scope().scopeConfig.get(key);
  }

  report(value) {
    return value;
  }

}

class ScopeConfigList extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'list');
    (0, _defineProperty2().default)(this, "description", 'list all scope configuration(s)');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "opts", []);
  }

  action() {
    return _scope().scopeConfig.list();
  }

  report(conf) {
    return (0, _utils().objectToStringifiedTupleArray)(conf).map(tuple => {
      return tuple.join('     ');
    }).join('\n');
  }

}

class ScopeConfigDel extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'del <key>');
    (0, _defineProperty2().default)(this, "description", 'delete given key from global configuration');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "opts", []);
  }

  action([key]) {
    return _scope().scopeConfig.del(key);
  }

  report(conf) {
    return 'deleted successfully';
  }

}