'use strict';

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

var _ora;

function _load_ora() {
  return _ora = _interopRequireDefault(require('ora'));
}

var _constants;

function _load_constants() {
  return _constants = require('../../constants');
}

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

var _loader = void 0;

var start = function start(text) {
  if (_loader) {
    if (text) _loader.text = text;
    _loader.start();
  }
  return loader;
};

var setText = function setText(text) {
  if (_loader) _loader.text = text;
  return loader;
};

var get = function get() {
  return _loader;
};

var stop = function stop() {
  if (_loader) _loader.stop();
  return loader;
};

var on = function on() {
  if (!_loader) _loader = (0, (_ora || _load_ora()).default)({ spinner: (_constants || _load_constants()).SPINNER_TYPE, text: '' });
  return loader;
};

var off = function off() {
  stop();
  _loader = null;
  return loader;
};

var loader = {
  on,
  off,
  stop,
  start,
  setText,
  get
};

exports.default = loader;