var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _decode2 = _interopRequireDefault(require("./decode"));
var _encode2 = _interopRequireDefault(require("./encode"));
var _CryptoController = _interopRequireDefault(require("./CryptoController"));
var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
var _IndexedDBStorageController = _interopRequireDefault(require("./IndexedDBStorageController"));
var _InstallationController = _interopRequireDefault(require("./InstallationController"));
var ParseOp = _interopRequireWildcard(require("./ParseOp"));
var _RESTController = _interopRequireDefault(require("./RESTController"));
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
var Analytics = _interopRequireWildcard(require("./Analytics"));
var _AnonymousUtils = _interopRequireDefault(require("./AnonymousUtils"));
var Cloud = _interopRequireWildcard(require("./Cloud"));
var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
var _EventEmitter = _interopRequireDefault(require("./EventEmitter"));
var _ParseConfig = _interopRequireDefault(require("./ParseConfig"));
var _ParseError = _interopRequireDefault(require("./ParseError"));
var _FacebookUtils = _interopRequireDefault(require("./FacebookUtils"));
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
var Hooks = _interopRequireWildcard(require("./ParseHooks"));
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
var _LocalDatastore = _interopRequireDefault(require("./LocalDatastore"));
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
var Push = _interopRequireWildcard(require("./Push"));
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
var _ParseRole = _interopRequireDefault(require("./ParseRole"));
var _ParseSchema = _interopRequireDefault(require("./ParseSchema"));
var _ParseSession = _interopRequireDefault(require("./ParseSession"));
var _Storage = _interopRequireDefault(require("./Storage"));
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
var _ParseLiveQuery = _interopRequireDefault(require("./ParseLiveQuery"));
var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
var _StorageController = _interopRequireDefault(require("./StorageController"));
var _WebSocketController = _interopRequireDefault(require("./WebSocketController"));
function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var r = new WeakMap(),
    t = new WeakMap();
  return (_getRequireWildcardCache = function (e) {
    return e ? t : r;
  })(e);
}
function _interopRequireWildcard(e, r) {
  if (!r && e && e.__esModule) return e;
  if (null === e || "object" != typeof e && "function" != typeof e) return {
    default: e
  };
  var t = _getRequireWildcardCache(r);
  if (t && t.has(e)) return t.get(e);
  var n = {
      __proto__: null
    },
    a = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
    var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
    i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
  }
  return n.default = e, t && t.set(e, n), n;
}
var Parse = {
  ACL: _ParseACL.default,
  Analytics: Analytics,
  AnonymousUtils: _AnonymousUtils.default,
  Cloud: Cloud,
  CLP: _ParseCLP.default,
  CoreManager: _CoreManager.default,
  Config: _ParseConfig.default,
  Error: _ParseError.default,
  FacebookUtils: _FacebookUtils.default,
  File: _ParseFile.default,
  GeoPoint: _ParseGeoPoint.default,
  Polygon: _ParsePolygon.default,
  Installation: _ParseInstallation.default,
  LocalDatastore: _LocalDatastore.default,
  Object: _ParseObject.default,
  Op: {
    Set: ParseOp.SetOp,
    Unset: ParseOp.UnsetOp,
    Increment: ParseOp.IncrementOp,
    Add: ParseOp.AddOp,
    Remove: ParseOp.RemoveOp,
    AddUnique: ParseOp.AddUniqueOp,
    Relation: ParseOp.RelationOp
  },
  Push: Push,
  Query: _ParseQuery.default,
  Relation: _ParseRelation.default,
  Role: _ParseRole.default,
  Schema: _ParseSchema.default,
  Session: _ParseSession.default,
  Storage: _Storage.default,
  User: _ParseUser.default,
  LiveQueryClient: _LiveQueryClient.default,
  IndexedDB: undefined,
  Hooks: undefined,
  Parse: undefined,
  set EventuallyQueue(queue) {
    _CoreManager.default.setEventuallyQueue(queue);
  },
  get EventuallyQueue() {
    return _CoreManager.default.getEventuallyQueue();
  },
  initialize: function (applicationId, javaScriptKey) {
    Parse._initialize(applicationId, javaScriptKey);
  },
  _initialize: function (applicationId, javaScriptKey, masterKey, maintenanceKey) {
    _CoreManager.default.set('APPLICATION_ID', applicationId);
    _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
    _CoreManager.default.set('MAINTENANCE_KEY', maintenanceKey);
    _CoreManager.default.set('MASTER_KEY', masterKey);
    _CoreManager.default.set('USE_MASTER_KEY', false);
    _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
    _CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
    _CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
    _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
    _CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
    _CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
    _CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
    _CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
  },
  setAsyncStorage: function (storage) {
    _CoreManager.default.setAsyncStorage(storage);
  },
  setLocalDatastoreController: function (controller) {
    _CoreManager.default.setLocalDatastoreController(controller);
  },
  getServerHealth: function () {
    return _CoreManager.default.getRESTController().request('GET', 'health');
  },
  set applicationId(value) {
    _CoreManager.default.set('APPLICATION_ID', value);
  },
  get applicationId() {
    return _CoreManager.default.get('APPLICATION_ID');
  },
  set javaScriptKey(value) {
    _CoreManager.default.set('JAVASCRIPT_KEY', value);
  },
  get javaScriptKey() {
    return _CoreManager.default.get('JAVASCRIPT_KEY');
  },
  set masterKey(value) {
    _CoreManager.default.set('MASTER_KEY', value);
  },
  get masterKey() {
    return _CoreManager.default.get('MASTER_KEY');
  },
  set maintenanceKey(value) {
    _CoreManager.default.set('MAINTENANCE_KEY', value);
  },
  get maintenanceKey() {
    return _CoreManager.default.get('MAINTENANCE_KEY');
  },
  set serverURL(value) {
    _CoreManager.default.set('SERVER_URL', value);
  },
  get serverURL() {
    return _CoreManager.default.get('SERVER_URL');
  },
  set serverAuthToken(value) {
    _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  },
  get serverAuthToken() {
    return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  },
  set serverAuthType(value) {
    _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  },
  get serverAuthType() {
    return _CoreManager.default.get('SERVER_AUTH_TYPE');
  },
  set LiveQuery(liveQuery) {
    _CoreManager.default.setLiveQuery(liveQuery);
  },
  get LiveQuery() {
    return _CoreManager.default.getLiveQuery();
  },
  set liveQueryServerURL(value) {
    _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  },
  get liveQueryServerURL() {
    return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  },
  set encryptedUser(value) {
    _CoreManager.default.set('ENCRYPTED_USER', value);
  },
  get encryptedUser() {
    return _CoreManager.default.get('ENCRYPTED_USER');
  },
  set secret(value) {
    _CoreManager.default.set('ENCRYPTED_KEY', value);
  },
  get secret() {
    return _CoreManager.default.get('ENCRYPTED_KEY');
  },
  set idempotency(value) {
    _CoreManager.default.set('IDEMPOTENCY', value);
  },
  get idempotency() {
    return _CoreManager.default.get('IDEMPOTENCY');
  },
  set allowCustomObjectId(value) {
    _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  },
  get allowCustomObjectId() {
    return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  },
  _request: function () {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    return _CoreManager.default.getRESTController().request.apply(null, args);
  },
  _ajax: function () {
    for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      args[_key2] = arguments[_key2];
    }
    return _CoreManager.default.getRESTController().ajax.apply(null, args);
  },
  _decode: function (_, value) {
    return (0, _decode2.default)(value);
  },
  _encode: function (value, _, disallowObjects) {
    return (0, _encode2.default)(value, disallowObjects);
  },
  _getInstallationId: function () {
    return _CoreManager.default.getInstallationController().currentInstallationId();
  },
  enableLocalDatastore: function (polling, ms) {
    if (!this.applicationId) {
      console.log("'enableLocalDataStore' must be called after 'initialize'");
      return;
    }
    if (!this.LocalDatastore.isEnabled) {
      this.LocalDatastore.isEnabled = true;
      if (polling || typeof polling === 'undefined') {
        _CoreManager.default.getEventuallyQueue().poll(ms || 2000);
      }
    }
  },
  isLocalDatastoreEnabled: function () {
    return this.LocalDatastore.isEnabled;
  },
  dumpLocalDatastore: function () {
    if (!this.LocalDatastore.isEnabled) {
      console.log('Parse.enableLocalDatastore() must be called first');
      return Promise.resolve({});
    } else {
      return Parse.LocalDatastore._getAllContents();
    }
  },
  enableEncryptedUser: function () {
    this.encryptedUser = true;
  },
  isEncryptedUserEnabled: function () {
    return this.encryptedUser;
  }
};
_CoreManager.default.setRESTController(_RESTController.default);
Parse.Parse = Parse;
var _default = exports.default = Parse;