import _typeof from 'babel-runtime/helpers/typeof';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
/**
 * @文件说明: 构建iMapApi地图实例的子级对象的基类
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-03-19 23:31:37
 */

var BasicMapApi = function () {
  var _iMapApi = Symbol('iMapApi');

  var BasicMapApi = function () {
    _createClass(BasicMapApi, [{
      key: 'iMapApi',
      get: function get() {
        return this[_iMapApi];
      }
    }]);

    function BasicMapApi(iMapApi) {
      _classCallCheck(this, BasicMapApi);

      this[_iMapApi] = iMapApi;
    }

    return BasicMapApi;
  }();

  return BasicMapApi;
}();

export default BasicMapApi;

// 扩展带自定义事件的基类
export var BasicMapApiEvented = function () {
  var _evented = Symbol('Evented');

  var BasicMapApiEvented = function (_BasicMapApi) {
    _inherits(BasicMapApiEvented, _BasicMapApi);

    function BasicMapApiEvented(iMapApi) {
      _classCallCheck(this, BasicMapApiEvented);

      var _this = _possibleConstructorReturn(this, (BasicMapApiEvented.__proto__ || Object.getPrototypeOf(BasicMapApiEvented)).call(this, iMapApi));

      var _ref = iMapApi && iMapApi.exports,
          mapboxgl = _ref.mapboxgl;

      _this[_evented] = new mapboxgl.Evented();
      return _this;
    }

    /**
     * 注册绑定事件
     * @param {String} type 事件类型名
     * @param {Function} listener 回调事件函数
     */


    _createClass(BasicMapApiEvented, [{
      key: 'on',
      value: function on(type, listener) {
        return this[_evented].on(type, listener);
      }

      /**
       * 解除绑定事件
       * @param {String} type 事件类型名
       * @param {Function} listener 回调事件函数
       */

    }, {
      key: 'off',
      value: function off(type, listener) {
        return this[_evented].off(type, listener);
      }

      /**
       * 注册绑定仅只执行一次事件
       * @param {String} type 事件类型名
       * @param {Function} listener 回调事件函数
       */

    }, {
      key: 'once',
      value: function once(type, listener) {
        return this[_evented].once(type, listener);
      }

      /**
       * 驱动执行绑定的事件
       * @param {Event} event 事件类型名
       * @param {Object} properties 回调事件函数接收的数据
       */

    }, {
      key: 'fire',
      value: function fire(event, properties) {
        return this[_evented].fire(event, properties);
      }

      /**
       * 判断事件监听是否已注册
       * @param {String} type 事件类型名
       */

    }, {
      key: 'listens',
      value: function listens(type) {
        return this[_evented].listens(type);
      }
    }]);

    return BasicMapApiEvented;
  }(BasicMapApi);

  return BasicMapApiEvented;
}();

/**
 * 动态扩展Class类的Prototype属性挂接函数方法
 * @param {Object} methods 待动态添加的函数对象
 * @param {Class} prototype 待动态挂接的Class类Prototype属性
 */
export var bindPrototypeMethods = function bindPrototypeMethods(methods, prototype) {
  if ((typeof methods === 'undefined' ? 'undefined' : _typeof(methods)) === 'object') {
    Object.keys(methods).map(function (key) {
      prototype[key] = methods[key];
    });
  }
};