"use strict";

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

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

function _ora() {
  const data = _interopRequireDefault(require("ora"));

  _ora = function () {
    return data;
  };

  return data;
}

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

  _constants = function () {
    return data;
  };

  return data;
}

let _loader;

const start = text => {
  if (_loader) {
    if (text) _loader.text = text;

    _loader.start();
  }

  return loader;
};

const setText = text => {
  if (_loader) _loader.text = text;
  return loader;
};

const get = () => _loader;

const stop = () => {
  if (_loader) _loader.stop();
  return loader;
};

const on = () => {
  if (!_loader) _loader = (0, _ora().default)({
    spinner: _constants().SPINNER_TYPE,
    text: ''
  });
  return loader;
};

const off = () => {
  stop();
  _loader = null;
  return loader;
};

const loader = {
  on,
  off,
  stop,
  start,
  setText,
  get
};
var _default = loader;
exports.default = _default;