text: 'use strict';
  
  Object.defineProperty(exports, '__esModule', {
    value: true
  });
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  
  var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  var _utils = require('./utils');
  
  var utils = _interopRequireWildcard(_utils);
  
  var _logger = require('./logger');
  
  var _logger2 = _interopRequireDefault(_logger);
  
  var _EventEmitter2 = require('./EventEmitter');
  
  var _EventEmitter3 = _interopRequireDefault(_EventEmitter2);
  
  var Connector = (function (_EventEmitter) {
    _inherits(Connector, _EventEmitter);
  
    function Connector(cache, store, services) {
      var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
  
      _classCallCheck(this, Connector);
  
      _get(Object.getPrototypeOf(Connector.prototype), 'constructor', this).call(this);
      this.cache = cache;
      this.store = store;
      this.services = services;
      this.options = options;
      this.logger = _logger2['default'].create('cacheConnector');
  
      this.cache && this.cache.init(services, options.cache, options);
    }
  
    _createClass(Connector, [{
      key: 'load',
      value: function load(languages, namespaces, callback) {
        var _this = this;
  
        if (!this.cache) return callback && callback();
        var options = _extends({}, this.cache.options, this.options.cache);
  
        if (typeof languages === 'string') languages = this.services.languageUtils.toResolveHierarchy(languages);
        if (typeof namespaces === 'string') namespaces = [namespaces];
  
        if (options.enabled) {
          this.cache.load(languages, function (err, data) {
            if (err) _this.logger.error('loading languages ' + languages.join(', ') + ' from cache failed', err);
            if (data) {
              for (var l in data) {
                for (var n in data[l]) {
                  if (n === 'i18nStamp') continue;
                  var bundle = data[l][n];
                  if (bundle) _this.store.addResourceBundle(l, n, bundle);
                }
              }
            }
            if (callback) callback();
          });
        } else {
          if (callback) callback();
        }
      }
    }, {
      key: 'save',
      value: function save() {
        if (this.cache && this.options.cache && this.options.cache.enabled) this.cache.save(this.store.data);
      }
    }]);
  
    return Connector;
  })(_EventEmitter3['default']);
  
  exports['default'] = Connector;
  module.exports = exports['default'];