"use strict";

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

function _slugid() {
  const data = _interopRequireDefault(require("slugid"));

  _slugid = function () {
    return data;
  };

  return data;
}

function _UserSettings() {
  const data = _interopRequireDefault(require("./UserSettings"));

  _UserSettings = function () {
    return data;
  };

  return data;
}

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

function _newIdentifier(type = 'c') {
  return type + '-' + _slugid().default.v4();
}

async function clientIdAsync() {
  var clientId = await _UserSettings().default.getAsync('accessToken', null);

  if (clientId === null) {
    clientId = _newIdentifier();
    await setClientIdAsync(clientId);
  }

  return clientId;
}

async function setClientIdAsync(token) {
  await _UserSettings().default.setAsync('accessToken', token);
  return token;
}
//# sourceMappingURL=__sourcemaps__/Session.js.map