text: var classCallCheck = function (instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
  };
  
  var defineProperty = function (obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
    } else {
      obj[key] = value;
    }
  
    return obj;
  };
  
  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 _actionName = '_[vuex-class]_bind_class';
  
  var isFunction = function isFunction(any) {
    return typeof any === 'function';
  };
  
  var getPrototypes = function getPrototypes(obj) {
    var prototypes = [];
    var current = obj;
    while (current !== VuexClass.prototype) {
      current = Object.getPrototypeOf(current);
      prototypes.push(current);
    }
    return prototypes;
  };
  
  var getDescriptors = function getDescriptors(prototypes) {
    var descriptors = {};
    var i = prototypes.length;
    while (i--) {
      var prototype = prototypes[i];
      _extends(descriptors, Object.getOwnPropertyDescriptors(prototype));
    }
    return descriptors;
  };
  
  var throwError = function throwError(msg) {
    throw new Error('[vuex-class] ' + msg);
  };
  
  var VuexClass = function VuexClass() {
    var _this = this;
  
    classCallCheck(this, VuexClass);
  
    var descriptors = getDescriptors(getPrototypes(this));
    this.state = {};
    this.getters = {};
    this.mutations = {};
    this.actions = {};
    var _context = null;
    Object.defineProperty(this, 'context', {
      enumerable: false,
      get: function get$$1() {
        if (!_context) {
          throwError('Please call the \'new Vuex.store({ plusins: [ VuexClass.init() ] })\' method');
        }
        return _context;
      },
      set: function set$$1(context) {
        _context = context;
      }
    });
    Object.keys(descriptors).forEach(function (name) {
      var descriptor = descriptors[name];
      var newDescriptor = {};
      if (name === 'constructor' || typeof descriptor === 'undefined') return;
  
      // vuex getters
      if (isFunction(descriptor.get)) {
        newDescriptor.get = function () {
          return _this.context.getters[name];
        };
        _this.getters[name] = function () {
          return descriptor.get.call(_this);
        };
      }
  
      // vuex mutations
      if (isFunction(descriptor.set)) {
        newDescriptor.set = function (payload) {
          return _this.context.commit(name, payload);
        };
        _this.mutations[name] = function (state, payload) {
          return descriptor.set.call(_this, payload);
        };
        if (!isFunction(descriptor.get)) {
          newDescriptor.get = function () {
            return function (payload) {
              return _this.context.commit(name, payload);
            };
          };
        }
      } else if (isFunction(descriptor.value) && /^\$/.test(name)) {
        _this.mutations[name] = function (state, payload) {
          return descriptor.value.call(_this, payload);
        };
        newDescriptor.value = function (payload) {
          return _this.context.commit(name, payload);
        };
      }
  
      // vuex actions
      if (isFunction(descriptor.value) && !/^\$/.test(name)) {
        newDescriptor.value = function (payload) {
          return _this.context.dispatch(name, payload);
        };
        _this.actions[name] = function (context, payload) {
          return descriptor.value.call(_this, payload);
        };
      }
      Object.defineProperty(_this, name, newDescriptor);
    });
  
    _extends(this.actions, defineProperty({}, _actionName, {
      root: true,
      handler: function handler(context) {
        var isBind = !!_context;
        _this.context = context;
        if (isBind) return;
        Object.defineProperty(_this, 'state', {
          get: function get$$1() {
            return _this.context.state;
          },
          set: function set$$1() {
            throwError('You should not update the module state directly');
          }
        });
      }
    }));
  };
  
  
  VuexClass.init = function init() {
    return function (store) {
      VuexClass.bindClass(store);
      store.subscribe(function (mutation) {
        VuexClass.bindClass(store);
      });
    };
  };
  
  VuexClass.bindClass = function bindClass(store) {
    store.dispatch(_actionName);
  };
  
  VuexClass.mapVuexClasses = function mapVuexClasses(vuexClass, options) {
    var classes = {};
    Object.keys(options).forEach(function (name) {
      var paths = options[name].split('/');
      var i = 0;
      var current = vuexClass;
      while (i < paths.length) {
        var pathName = paths[i];
        if (pathName) {
          if (current.modules && pathName in current.modules && current.modules[pathName] instanceof VuexClass) {
            current = current.modules[pathName];
          } else {
            throwError('\'' + options[name] + '\' module is not exist');
          }
        }
        i++;
      }
      classes[name] = current;
    });
    return classes;
  };
  
  VuexClass.install = function install(Vue) {
    var isExist = function isExist(vm) {
      var vuexClass = vm.$options.vuexClass;
  
      return !!vuexClass || vuexClass instanceof VuexClass;
    };
  
    Object.defineProperty(Vue.prototype, '$vuexClass', {
      get: function get$$1() {
        return this.$root._vuexClass;
      }
    });
  
    Vue.mixin({
      beforeCreate: function beforeCreate() {
        var _$options = this.$options,
            vuexClass = _$options.vuexClass,
            mapVuexClasses = _$options.mapVuexClasses;
  
        if (isExist(this)) {
          this._vuexClass = vuexClass;
        }
        if (!mapVuexClasses) return;
        _extends(this, VuexClass.mapVuexClasses(this.$vuexClass, mapVuexClasses));
      },
      destroyed: function destroyed() {
        if (!isExist(this)) return;
        delete this._vuexClass;
      }
    });
  };
  
  export default VuexClass;
  