UNPKG

@minix-iot/ui

Version:

基于Vue的移动端轻量级UI组件库

36,304 lines 1.05 MB
/*!
 * @minix-iot/ui v0.2.4 - minixui.js, dc9ed75a2341bf39c26c, Wed Nov 24 2021 14:20:43 GMT+0800 (中国标准时间)
 * (c) 2017-2020 JDC
 * Released under the MIT License.
 */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory(require("vue"));
	else if(typeof define === 'function' && define.amd)
		define("minixui", ["vue"], factory);
	else if(typeof exports === 'object')
		exports["minixui"] = factory(require("vue"));
	else
		root["minixui"] = factory(root["Vue"]);
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__3__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "./";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 70);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

function _defineProperty(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;
}

module.exports = _defineProperty;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 1 */
/***/ (function(module, exports) {

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

module.exports = _classCallCheck;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 2 */
/***/ (function(module, exports) {

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);
  }
}

function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
}

module.exports = _createClass;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = __WEBPACK_EXTERNAL_MODULE__3__;

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

var arrayWithoutHoles = __webpack_require__(61);

var iterableToArray = __webpack_require__(62);

var unsupportedIterableToArray = __webpack_require__(9);

var nonIterableSpread = __webpack_require__(63);

function _toConsumableArray(arr) {
  return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
}

module.exports = _toConsumableArray;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 5 */
/***/ (function(module, exports) {

function _typeof(obj) {
  "@babel/helpers - typeof";

  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    module.exports = _typeof = function _typeof(obj) {
      return typeof obj;
    };

    module.exports["default"] = module.exports, module.exports.__esModule = true;
  } else {
    module.exports = _typeof = function _typeof(obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };

    module.exports["default"] = module.exports, module.exports.__esModule = true;
  }

  return _typeof(obj);
}

module.exports = _typeof;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

var arrayWithHoles = __webpack_require__(64);

var iterableToArrayLimit = __webpack_require__(65);

var unsupportedIterableToArray = __webpack_require__(9);

var nonIterableRest = __webpack_require__(66);

function _slicedToArray(arr, i) {
  return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
}

module.exports = _slicedToArray;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 7 */
/***/ (function(module, exports) {

function _extends() {
  module.exports = _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;
  };

  module.exports["default"] = module.exports, module.exports.__esModule = true;
  return _extends.apply(this, arguments);
}

module.exports = _extends;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 8 */
/***/ (function(module, exports) {

function _arrayLikeToArray(arr, len) {
  if (len == null || len > arr.length) len = arr.length;

  for (var i = 0, arr2 = new Array(len); i < len; i++) {
    arr2[i] = arr[i];
  }

  return arr2;
}

module.exports = _arrayLikeToArray;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

var arrayLikeToArray = __webpack_require__(8);

function _unsupportedIterableToArray(o, minLen) {
  if (!o) return;
  if (typeof o === "string") return arrayLikeToArray(o, minLen);
  var n = Object.prototype.toString.call(o).slice(8, -1);
  if (n === "Object" && o.constructor) n = o.constructor.name;
  if (n === "Map" || n === "Set") return Array.from(o);
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
}

module.exports = _unsupportedIterableToArray;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 31 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 41 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 48 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 50 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 53 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),
/* 56 */
/***/ (function(module) {

module.exports = JSON.parse("{\"a\":\"0.2.4\"}");

/***/ }),
/* 57 */
/***/ (function(module) {

module.exports = JSON.parse("{\"a\":[{\"name\":\"Icon\",\"version\":\"1.0.0\",\"sort\":\"5\",\"chnName\":\"图标\",\"type\":\"component\",\"showDemo\":true,\"desc\":\"网页小图标。\",\"author\":\"zoiew\"},{\"name\":\"Switch\",\"version\":\"1.0.0\",\"sort\":\"1\",\"chnName\":\"开关\",\"type\":\"component\",\"showDemo\":true,\"desc\":\"滑动开关,通过点击使按钮左右滑动,同时触发对应的开关状态\",\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"Button\",\"sort\":\"5\",\"chnName\":\"按钮\",\"desc\":\"各式各样的按钮\",\"type\":\"component\",\"showDemo\":true,\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"ButtonGroup\",\"chnName\":\"按钮组\",\"desc\":\"用于页面底部的按钮组\",\"type\":\"component\",\"sort\":\"5\",\"showDemo\":true,\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"Lazyload\",\"chnName\":\"图片懒加载\",\"desc\":\"图片懒加载\",\"type\":\"component\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"Popup\",\"type\":\"component\",\"chnName\":\"弹出层\",\"desc\":\"弹出层容器,用于展示弹窗、信息提示等\",\"sort\":\"5\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Cell\",\"type\":\"component\",\"chnName\":\"单元格\",\"desc\":\"单元格\",\"sort\":\"1\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Badge\",\"type\":\"component\",\"chnName\":\"徽标\",\"desc\":\"徽标\",\"sort\":\"1\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"PullRefresh\",\"type\":\"component\",\"chnName\":\"下拉刷新\",\"desc\":\"下拉刷新\",\"sort\":\"5\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"NavBar\",\"type\":\"component\",\"chnName\":\"导航栏\",\"desc\":\"导航栏\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"SearchBar\",\"type\":\"component\",\"chnName\":\"搜索栏\",\"desc\":\"搜索栏\",\"sort\":\"2\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Tag\",\"type\":\"component\",\"chnName\":\"标记\",\"desc\":\"标记\",\"sort\":\"1\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"NoticeBar\",\"type\":\"component\",\"chnName\":\"通知栏\",\"desc\":\"通知栏\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Overlay\",\"type\":\"component\",\"chnName\":\"蒙层\",\"desc\":\"蒙层\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Modal\",\"type\":\"component\",\"chnName\":\"模态框\",\"desc\":\"模态框\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Dialog\",\"type\":\"component\",\"chnName\":\"对话框\",\"desc\":\"对话框\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Empty\",\"type\":\"component\",\"chnName\":\"空白提示\",\"desc\":\"空白提示\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"ScrollView\",\"type\":\"component\",\"chnName\":\"滚动视图\",\"desc\":\"滚动视图\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Checkbox\",\"type\":\"component\",\"chnName\":\"单选框\",\"desc\":\"单选框\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Radio\",\"type\":\"component\",\"chnName\":\"多选框\",\"desc\":\"多选框\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Picker\",\"type\":\"component\",\"chnName\":\"选择器\",\"desc\":\"选择器\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Rate\",\"type\":\"component\",\"chnName\":\"评分\",\"desc\":\"评分\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"PickerColumn\",\"type\":\"component\",\"chnName\":\"选择器列\",\"desc\":\"选择器列\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"DateTimePicker\",\"type\":\"component\",\"chnName\":\"日期时间选择器\",\"desc\":\"日期时间选择器\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Mask\",\"type\":\"component\",\"chnName\":\"活动运营推广框\",\"desc\":\"活动运营推广框\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"ActionSheet\",\"type\":\"component\",\"chnName\":\"动作清单\",\"desc\":\"动作清单\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Toast\",\"type\":\"component\",\"chnName\":\"轻提示\",\"desc\":\"轻提示\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"TabBar\",\"type\":\"component\",\"chnName\":\"标签栏\",\"desc\":\"标签栏\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"TabBarItem\",\"type\":\"component\",\"chnName\":\"标签栏项\",\"desc\":\"标签栏项\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Tab\",\"type\":\"component\",\"chnName\":\"标签页\",\"desc\":\"标签页\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"TabPane\",\"type\":\"component\",\"chnName\":\"标签页页面组件\",\"desc\":\"标签页页面组件\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"name\":\"Catalog\",\"sort\":\"5\",\"chnName\":\"目录栏\",\"desc\":\"目录标题栏\",\"type\":\"component\",\"showDemo\":true,\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"Slider\",\"type\":\"component\",\"chnName\":\"滑块\",\"desc\":\"滑块\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"SliderScale\",\"type\":\"component\",\"chnName\":\"滑块刻度\",\"desc\":\"滑块刻度\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"PullRefresh\",\"type\":\"component\",\"chnName\":\"下拉刷新\",\"desc\":\"下拉刷新\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Loading\",\"type\":\"component\",\"chnName\":\"加载\",\"desc\":\"加载\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Swiper\",\"type\":\"component\",\"chnName\":\"轮播\",\"desc\":\"轮播\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"SwiperItem\",\"type\":\"component\",\"chnName\":\"轮播项\",\"desc\":\"轮播项\",\"sort\":\"4\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"List\",\"type\":\"component\",\"chnName\":\"列表\",\"desc\":\"列表\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Steps\",\"type\":\"component\",\"chnName\":\"步骤条\",\"desc\":\"步骤条\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Step\",\"type\":\"component\",\"chnName\":\"列表\",\"desc\":\"步骤项\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"ChartLine\",\"type\":\"component\",\"chnName\":\"折线图\",\"desc\":\"折线图\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"ChartColumn\",\"type\":\"component\",\"chnName\":\"柱状图\",\"desc\":\"柱状图\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"ChartPie\",\"type\":\"component\",\"chnName\":\"饼图\",\"desc\":\"饼图\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Sticky\",\"type\":\"component\",\"chnName\":\"粘性布局\",\"desc\":\"粘性布局\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"minxinFeng\",\"showTest\":true},{\"version\":\"1.0.0\",\"name\":\"Collapse\",\"chnName\":\"折叠面板\",\"desc\":\"折叠面板\",\"type\":\"component\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"zoiew\"},{\"version\":\"1.0.0\",\"name\":\"CollapseItem\",\"type\":\"component\",\"chnName\":\"折叠项\",\"desc\":\"折叠项\",\"sort\":\"0\",\"showDemo\":true,\"author\":\"zoiew\",\"showTest\":true}]}");

/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}var normalMerge=["attrs","props","domProps"],toArrayMerge=["class","style","directives"],functionalMerge=["on","nativeOn"],mergeJsxProps=function(a){return a.reduce(function(c,a){for(var b in a)if(!c[b])c[b]=a[b];else if(-1!==normalMerge.indexOf(b))c[b]=_extends({},c[b],a[b]);else if(-1!==toArrayMerge.indexOf(b)){var d=c[b]instanceof Array?c[b]:[c[b]],e=a[b]instanceof Array?a[b]:[a[b]];c[b]=d.concat(e)}else if(-1!==functionalMerge.indexOf(b)){for(var f in a[b])if(c[b][f]){var g=c[b][f]instanceof Array?c[b][f]:[c[b][f]],h=a[b][f]instanceof Array?a[b][f]:[a[b][f]];c[b][f]=g.concat(h)}else c[b][f]=a[b][f];}else if("hook"==b)for(var i in a[b])c[b][i]=c[b][i]?mergeFn(c[b][i],a[b][i]):a[b][i];else c[b]=a[b];return c},{})},mergeFn=function(a,b){return function(){a&&a.apply(this,arguments),b&&b.apply(this,arguments)}};module.exports=mergeJsxProps;


/***/ }),
/* 59 */
/***/ (function(module, exports, __webpack_require__) {

var setPrototypeOf = __webpack_require__(67);

var isNativeReflectConstruct = __webpack_require__(68);

function _construct(Parent, args, Class) {
  if (isNativeReflectConstruct()) {
    module.exports = _construct = Reflect.construct;
    module.exports["default"] = module.exports, module.exports.__esModule = true;
  } else {
    module.exports = _construct = function _construct(Parent, args, Class) {
      var a = [null];
      a.push.apply(a, args);
      var Constructor = Function.bind.apply(Parent, a);
      var instance = new Constructor();
      if (Class) setPrototypeOf(instance, Class.prototype);
      return instance;
    };

    module.exports["default"] = module.exports, module.exports.__esModule = true;
  }

  return _construct.apply(null, arguments);
}

module.exports = _construct;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function(global) {(function (global, factory) {
     true ? factory(exports) :
    undefined;
})(this, (function (exports) { 'use strict';

    var isArrayLike = function (value) {
      /**
       * isArrayLike([1, 2, 3]) => true
       * isArrayLike(document.body.children) => true
       * isArrayLike('abc') => true
       * isArrayLike(Function) => false
       */
      return value !== null && typeof value !== 'function' && isFinite(value.length);
    };

    var filter = function (arr, func) {
      if (!isArrayLike(arr)) {
        return arr;
      }

      var result = [];

      for (var index = 0; index < arr.length; index++) {
        var value = arr[index];

        if (func(value, index)) {
          result.push(value);
        }
      }

      return result;
    };

    var toString$3 = {}.toString;

    var isType$1 = function (value, type) {
      return toString$3.call(value) === '[object ' + type + ']';
    };

    /**
     * 是否为函数
     * @param  {*} fn 对象
     * @return {Boolean}  是否函数
     */
    var isFunction$1 = (function (value) {
      return isType$1(value, 'Function');
    });

    // isFinite,
    var isNil$1 = function (value) {
      /**
       * isNil(null) => true
       * isNil() => true
       */
      return value === null || value === undefined;
    };

    var isArray$1 = (function (value) {
      return Array.isArray ? Array.isArray(value) : isType$1(value, 'Array');
    });

    var isObject$1 = (function (value) {
      /**
       * isObject({}) => true
       * isObject([1, 2, 3]) => true
       * isObject(Function) => true
       * isObject(null) => false
       */
      var type = typeof value;
      return value !== null && type === 'object' || type === 'function';
    });

    function each$1(elements, func) {
      if (!elements) {
        return;
      }

      var rst;

      if (isArray$1(elements)) {
        for (var i = 0, len = elements.length; i < len; i++) {
          rst = func(elements[i], i);

          if (rst === false) {
            break;
          }
        }
      } else if (isObject$1(elements)) {
        for (var k in elements) {
          if (elements.hasOwnProperty(k)) {
            rst = func(elements[k], k);

            if (rst === false) {
              break;
            }
          }
        }
      }
    }

    var keys = Object.keys ? function (obj) {
      return Object.keys(obj);
    } : function (obj) {
      var result = [];
      each$1(obj, function (value, key) {
        if (!(isFunction$1(obj) && key === 'prototype')) {
          result.push(key);
        }
      });
      return result;
    };

    function isMatch(obj, attrs) {
      var _keys = keys(attrs);

      var length = _keys.length;
      if (isNil$1(obj)) return !length;

      for (var i = 0; i < length; i += 1) {
        var key = _keys[i];

        if (attrs[key] !== obj[key] || !(key in obj)) {
          return false;
        }
      }

      return true;
    }

    var isObjectLike = function (value) {
      /**
       * isObjectLike({}) => true
       * isObjectLike([1, 2, 3]) => true
       * isObjectLike(Function) => false
       * isObjectLike(null) => false
       */
      return typeof value === 'object' && value !== null;
    };

    var isPlainObject = function (value) {
      /**
       * isObjectLike(new Foo) => false
       * isObjectLike([1, 2, 3]) => false
       * isObjectLike({ x: 0, y: 0 }) => true
       * isObjectLike(Object.create(null)) => true
       */
      if (!isObjectLike(value) || !isType$1(value, 'Object')) {
        return false;
      }

      if (Object.getPrototypeOf(value) === null) {
        return true;
      }

      var proto = value;

      while (Object.getPrototypeOf(proto) !== null) {
        proto = Object.getPrototypeOf(proto);
      }

      return Object.getPrototypeOf(value) === proto;
    };

    function find(arr, predicate) {
      if (!isArray$1(arr)) return null;

      var _predicate;

      if (isFunction$1(predicate)) {
        _predicate = predicate;
      }

      if (isPlainObject(predicate)) {
        _predicate = function (a) {
          return isMatch(a, predicate);
        };
      }

      if (_predicate) {
        for (var i = 0; i < arr.length; i += 1) {
          if (_predicate(arr[i])) {
            return arr[i];
          }
        }
      }

      return null;
    }

    /**
     * @param {Array} arr The array to iterate over.
     * @return {*} Returns the maximum value.
     * @example
     *
     * max([1, 2]);
     * // => 2
     *
     * max([]);
     * // => undefined
     *
     * const data = new Array(1250010).fill(1).map((d,idx) => idx);
     *
     * max(data);
     * // => 1250010
     * // Math.max(...data) will encounter "Maximum call stack size exceeded" error
     */

    var getMax = (function (arr) {
      if (!isArray$1(arr)) {
        return undefined;
      }

      return arr.reduce(function (prev, curr) {
        return Math.max(prev, curr);
      }, arr[0]);
    });

    /**
     * @param {Array} arr The array to iterate over.
     * @return {*} Returns the minimum value.
     * @example
     *
     * min([1, 2]);
     * // => 1
     *
     * min([]);
     * // => undefined
     *
     * const data = new Array(1250010).fill(1).map((d,idx) => idx);
     *
     * min(data);
     * // => 1250010
     * // Math.min(...data) will encounter "Maximum call stack size exceeded" error
     */

    var getMin = (function (arr) {
      if (!isArray$1(arr)) {
        return undefined;
      }

      return arr.reduce(function (prev, curr) {
        return Math.min(prev, curr);
      }, arr[0]);
    });

    var getRange$1 = function (values) {
      // 存在 NaN 时,min,max 判定会出问题
      var filterValues = values.filter(function (v) {
        return !isNaN(v);
      });

      if (!filterValues.length) {
        // 如果没有数值则直接返回0
        return {
          min: 0,
          max: 0
        };
      }

      if (isArray$1(values[0])) {
        var tmp = [];

        for (var i = 0; i < values.length; i++) {
          tmp = tmp.concat(values[i]);
        }

        filterValues = tmp;
      }

      var max = getMax(filterValues);
      var min = getMin(filterValues);
      return {
        min: min,
        max: max
      };
    };

    var isString = (function (str) {
      return isType$1(str, 'String');
    });

    function uniq(arr, cache) {
      if (cache === void 0) {
        cache = new Map();
      }

      var r = [];

      if (Array.isArray(arr)) {
        for (var i = 0, len = arr.length; i < len; i++) {
          var item = arr[i]; // 加一个 cache,提升性能

          if (!cache.has(item)) {
            r.push(item);
            cache.set(item, true);
          }
        }
      }

      return r;
    }

    function head(o) {
      if (isArrayLike(o)) {
        return o[0];
      }

      return undefined;
    }

    function last(o) {
      if (isArrayLike(o)) {
        var arr = o;
        return arr[arr.length - 1];
      }

      return undefined;
    }

    var fixedBase = function (v, base) {
      var str = base.toString();
      var index = str.indexOf('.');

      if (index === -1) {
        return Math.round(v);
      }

      var length = str.substr(index + 1).length;

      if (length > 20) {
        length = 20;
      }

      return parseFloat(v.toFixed(length));
    };

    /**
     * 判断是否数字
     * @return {Boolean} 是否数字
     */

    var isNumber = function (value) {
      return isType$1(value, 'Number');
    };

    var values$1 = Object.values ? function (obj) {
      return Object.values(obj);
    } : function (obj) {
      var result = [];
      each$1(obj, function (value, key) {
        if (!(isFunction$1(obj) && key === 'prototype')) {
          result.push(value);
        }
      });
      return result;
    };

    var toString$2 = (function (value) {
      if (isNil$1(value)) return '';
      return value.toString();
    });

    var lowerFirst = function (value) {
      var str = toString$2(value);
      return str.charAt(0).toLowerCase() + str.substring(1);
    };

    function substitute(str, o) {
      if (!str || !o) {
        return str;
      }

      return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
        if (match.charAt(0) === '\\') {
          return match.slice(1);
        }

        return o[name] === undefined ? '' : o[name];
      });
    }

    var upperFirst = function (value) {
      var str = toString$2(value);
      return str.charAt(0).toUpperCase() + str.substring(1);
    };

    var toString$1 = {}.toString;

    var getType = function (value) {
      return toString$1.call(value).replace(/^\[object /, '').replace(/]$/, '');
    };

    /**
     * 是否是布尔类型
     *
     * @param {Object} value 测试的值
     * @return {Boolean}
     */

    var isBoolean = function (value) {
      return isType$1(value, 'Boolean');
    };

    var isDate = function (value) {
      return isType$1(value, 'Date');
    };

    var objectProto = Object.prototype;

    var isPrototype = function (value) {
      var Ctor = value && value.constructor;
      var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
      return value === proto;
    };

    // FIXME: Mutable param should be forbidden in static lang.
    function _mix$1(dist, obj) {
      for (var key in obj) {
        if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
          dist[key] = obj[key];
        }
      }
    }

    function mix$1(dist, src1, src2, src3) {
      if (src1) _mix$1(dist, src1);
      if (src2) _mix$1(dist, src2);
      if (src3) _mix$1(dist, src3);
      return dist;
    }

    /**
     * _.memoize(calColor);
     * _.memoize(calColor, (...args) => args[0]);
     * @param f
     * @param resolver
     */

    var memoize = (function (f, resolver) {
      if (!isFunction$1(f)) {
        throw new TypeError('Expected a function');
      }

      var memoized = function () {
        var args = [];

        for (var _i = 0; _i < arguments.length; _i++) {
          args[_i] = arguments[_i];
        } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key


        var key = resolver ? resolver.apply(this, args) : args[0];
        var cache = memoized.cache;

        if (cache.has(key)) {
          return cache.get(key);
        }

        var result = f.apply(this, args); // 缓存起来

        cache.set(key, result);
        return result;
      };

      memoized.cache = new Map();
      return memoized;
    });

    var MAX_MIX_LEVEL = 5;

    function _deepMix(dist, src, level, maxLevel) {
      level = level || 0;
      maxLevel = maxLevel || MAX_MIX_LEVEL;

      for (var key in src) {
        if (src.hasOwnProperty(key)) {
          var value = src[key];

          if (value !== null && isPlainObject(value)) {
            if (!isPlainObject(dist[key])) {
              dist[key] = {};
            }

            if (level < maxLevel) {
              _deepMix(dist[key], value, level + 1, maxLevel);
            } else {
              dist[key] = src[key];
            }
          } else if (isArray$1(value)) {
            dist[key] = [];
            dist[key] = dist[key].concat(value);
          } else if (value !== undefined) {
            dist[key] = value;
          }
        }
      }
    } // todo 重写


    var deepMix = function (rst) {
      var args = [];

      for (var _i = 1; _i < arguments.length; _i++) {
        args[_i - 1] = arguments[_i];
      }

      for (var i = 0; i < args.length; i += 1) {
        _deepMix(rst, args[i]);
      }

      return rst;
    };

    var indexOf = function (arr, obj) {
      if (!isArrayLike(arr)) {
        return -1;
      }

      var m = Array.prototype.indexOf;

      if (m) {
        return m.call(arr, obj);
      }

      var index = -1;

      for (var i = 0; i < arr.length; i++) {
        if (arr[i] === obj) {
          index = i;
          break;
        }
      }

      return index;
    };

    var hasOwnProperty = Object.prototype.hasOwnProperty;

    function isEmpty(value) {
      /**
       * isEmpty(null) => true
       * isEmpty() => true
       * isEmpty(true) => true
       * isEmpty(1) => true
       * isEmpty([1, 2, 3]) => false
       * isEmpty('abc') => false
       * isEmpty({ a: 1 }) => false
       */
      if (isNil$1(value)) {
        return true;
      }

      if (isArrayLike(value)) {
        return !value.length;
      }

      var type = getType(value);

      if (type === 'Map' || type === 'Set') {
        return !value.size;
      }

      if (isPrototype(value)) {
        return !Object.keys(value).length;
      }

      for (var key in value) {
        if (hasOwnProperty.call(value, key)) {
          return false;
        }
      }

      return true;
    }

    var isEqual$1 = function (value, other) {
      if (value === other) {
        return true;
      }

      if (!value || !other) {
        return false;
      }

      if (isString(value) || isString(other)) {
        return false;
      }

      if (isArrayLike(value) || isArrayLike(other)) {
        if (value.length !== other.length) {
          return false;
        }

        var rst = true;

        for (var i = 0; i < value.length; i++) {
          rst = isEqual$1(value[i], other[i]);

          if (!rst) {
            break;
          }
        }

        return rst;
      }

      if (isObjectLike(value) || isObjectLike(other)) {
        var valueKeys = Object.keys(value);
        var otherKeys = Object.keys(other);

        if (valueKeys.length !== otherKeys.length) {
          return false;
        }

        var rst = true;

        for (var i = 0; i < valueKeys.length; i++) {
          rst = isEqual$1(value[valueKeys[i]], other[valueKeys[i]]);

          if (!rst) {
            break;
          }
        }

        return rst;
      }

      return false;
    };

    var map$1 = function (arr, func) {
      if (!isArrayLike(arr)) {
        // @ts-ignore
        return arr;
      }

      var result = [];

      for (var index = 0; index < arr.length; index++) {
        var value = arr[index];
        result.push(func(value, index));
      }

      return result;
    };

    function size(o) {
      if (isNil$1(o)) {
        return 0;
      }

      if (isArrayLike(o)) {
        return o.length;
      }

      return Object.keys(o).length;
    }

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */

    /* global Reflect, Promise */
    var extendStatics = function (d, b) {
      extendStatics = Object.setPrototypeOf || {
        __proto__: []
      } instanceof Array && function (d, b) {
        d.__proto__ = b;
      } || function (d, b) {
        for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
      };

      return extendStatics(d, b);
    };

    function __extends(d, b) {
      if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
      extendStatics(d, b);

      function __() {
        this.constructor = d;
      }

      d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }
    /** @deprecated */

    function __spreadArrays() {
      for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;

      for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];

      return r;
    }

    var ctx;
    /**
     * 计算文本的宽度
     */

    memoize(function (text, font) {
      if (font === void 0) {
        font = {};
      }

      var fontSize = font.fontSize,
          fontFamily = font.fontFamily,
          fontWeight = font.fontWeight,
          fontStyle = font.fontStyle,
          fontVariant = font.fontVariant;

      if (!ctx) {
        ctx = document.createElement('canvas').getContext('2d');
      }

      ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
      return ctx.measureText(isString(text) ? text : '').width;
    }, function (text, font) {
      if (font === void 0) {
        font = {};
      }

      return __spreadArrays([text], values$1(font)).join('');
    });

    function merge$1(dataArray) {
      var rst = [];

      for (var i = 0, len = dataArray.length; i < len; i++) {
        rst = rst.concat(dataArray[i]);
      }

      return rst;
    }

    function values(data, name) {
      var rst = [];
      var tmpMap = {};

      for (var i = 0, len = data.length; i < len; i++) {
        var obj = data[i];
        var value = obj[name];

        if (!isNil$1(value)) {
          if (!isArray$1(value)) {
            if (!tmpMap[value]) {
              rst.push(value);
              tmpMap[value] = true;
            }
          } else {
            each$1(value, function (val) {
              if (!tmpMap[val]) {
                rst.push(val);
                tmpMap[val] = true;
              }
            });
          }
        }
      }

      return rst;
    }

    function firstValue(data, name) {
      var rst = null;

      for (var i = 0, len = data.length; i < len; i++) {
        var obj = data[i];
        var value = obj[name];

        if (!isNil$1(value)) {
          if (isArray$1(value)) {
            rst = value[0];
          } else {
            rst = value;
          }

          break;
        }
      }

      return rst;
    }

    function groupToMap(data, fields) {
      if (!fields) {
        return {
          0: data
        };
      }

      var callback = function callback(row) {
        var unique = '_';

        for (var i = 0, l = fields.length; i < l; i++) {
          unique += row[fields[i]] && row[fields[i]].toString();
        }

        return unique;
      };

      var groups = {};

      for (var i = 0, len = data.length; i < len; i++) {
        var row = data[i];
        var key = callback(row);

        if (groups[key]) {
          groups[key].push(row);
        } else {
          groups[key] = [row];
        }
      }

      return groups;
    }

    function group(data, fields, appendConditions) {
      if (appendConditions === void 0) {
        appendConditions = {};
      }

      if (!fields) {
        return [data];
      }

      var groups = groupToMap(data, fields);
      var array = [];

      if (fields.length === 1 && appendConditions[fields[0]]) {
        var _values = appendConditions[fields[0]];
        each$1(_values, function (value) {
          value = '_' + value;
          array.push(groups[value]);
        });
      } else {
        for (var i in groups) {
          array.push(groups[i]);
        }
      }

      return array;
    }

    function remove(arr, obj) {
      if (!arr) {
        return;
      }

      var index = arr.indexOf(obj);

      if (index !== -1) {
        arr.splice(index, 1);
      }
    }

    function getRange(values) {
      if (!values.length) {
        return {
          min: 0,
          max: 0
        };
      }

      var max = Math.max.apply(null, values);
      var min = Math.min.apply(null, values);
      return {
        min: min,
        max: max
      };
    }

    var array = /*#__PURE__*/Object.freeze({
        __proto__: null,
        merge: merge$1,
        values: values,
        firstValue: firstValue,
        group: group,
        groupToMap: groupToMap,
        remove: remove,
        getRange: getRange
    });

    /**
     * Detects support for options object argument in addEventListener.
     * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
     * @private
     */

    var supportsEventListenerOptions = function () {
      var supports = false;

      try {
        var options = Object.defineProperty({}, 'passive', {
          get: function get() {
            supports = true;
          }
        });
        window.addEventListener('e', null, options);
      } catch (e) {// continue regardless of error
      }

      return supports;
    }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
    // https://github.com/chartjs/Chart.js/issues/4287


    var eventListenerOptions = supportsEventListenerOptions ? {
      passive: true
    } : false;
    /* global wx, my */
    // weixin miniprogram

    var isWx = typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function'; // ant miniprogram

    var isMy = typeof my === 'object' && typeof my.getSystemInfoSync === 'function'; // in node

    var isNode = typeof global && !typeof window; // in browser

    var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined';

    function isCanvasElement(el) {
      if (!el || typeof el !== 'object') return false;

      if (el.nodeType === 1 && el.nodeName) {
        // HTMLCanvasElement
        return true;
      } // CanvasElement


      return !!el.isCanvasElement;
    }

    function getPixelRatio() {
      return window && window.devicePixelRatio || 1;
    }

    function getStyle$1(el, property) {
      return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
    }

    function getWidth(el) {
      var width = getStyle$1(el, 'width');

      if (width === 'auto') {
        width = el.offsetWidth;
      }

      return parseFloat(width);
    }

    function getHeight(el) {
      var height = getStyle$1(el, 'height');

      if (height === 'auto') {
        height = el.offsetHeight;
      }

      return parseFloat(height);
    }

    function getDomById(id) {
      if (!id) {
        return null;
      }

      return document.getElementById(id);
    }

    function getRelativePosition(point, canvas) {
      var canvasDom = canvas.get('el');
      if (!canvasDom) return point;

      var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
          top = _canvasDom$getBoundin.top,
          left = _canvasDom$getBoundin.left;

      var paddingLeft = parseFloat(getStyle$1(canvasDom, 'padding-left'));
      var paddingTop = parseFloat(getStyle$1(canvasDom, 'padding-top'));
      var mouseX = point.x - left - paddingLeft;
      var mouseY = point.y - top - paddingTop;
      return {
        x: mouseX,
        y: mouseY
      };
    }

    function addEventListener(source, type, listener) {
      source.addEventListener(type, listener, eventListenerOptions);
    }

    function removeEventListener(source, type, listener) {
      source.removeEventListener(type, listener, eventListenerOptions);
    }

    function landscapePoint(point, canvas) {
      var landscape = canvas.get('landscape');

      if (!landscape) {
        return point;
      }

      if (isFunction$1(landscape)) {
        return landscape(point, canvas);
      } // 默认顺时针旋转90度


      var height = canvas.get('height');
      var x = point.y;
      var y = height - point.x;
      return {
        x: x,
        y: y
      };
    }

    function convertPoints(ev, canvas) {
      var touches = ev.touches; // 认为是mouse事件

      if (!touches) {
        var point = getRelativePosition({
          x: ev.clientX,
          y: ev.clientY
        }, canvas);
        return [landscapePoint(point, canvas)];
      } // 单指 touchend 后,touchs 会变空,最后的触点要从changedTouches里拿


      if (!touches.length) {
        // 为了防止万一,加个空逻辑
        touches = ev.changedTouches || [];
      }

      var points = [];

      for (var i = 0, len = touches.length; i < len; i++) {
        var touch = touches[i]; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置

        var x = touch.x,
            y = touch.y,
            clientX = touch.clientX,
            clientY = touch.clientY;

        var _point = void 0; // 小程序环境会有x,y


        if (isNumber(x) || isNumber(y)) {
          _point = {
            x: x,
            y: y
          };
        } else {
          // 浏览器环境再计算下canvas的相对位置
          _point = getRelativePosition({
            x: clientX,
            y: clientY
          }, canvas);
        }

        points.push(landscapePoint(_point, canvas));
      }

      return points;
    }

    function createEvent(event, chart) {
      var canvas = chart.get('canvas');
      var points = convertPoints(event, canvas); // touchend会没有points

      var point = points[0] || {};
      return {
        type: event.type,
        chart: chart,
        "native": event,
        x: point.x,
        y: point.y
      };
    }

    function measureText(text, font, ctx) {
      if (!ctx) {
        ctx = document.createElement('canvas').getContext('2d');
      }

      ctx.font = font || '12px sans-serif';
      return ctx.measureText(text);
    }

    /**
     * @fileOverview Utility for F2
     * @author dxq613 @gmail.com
     * @author sima.zhang1990@gmail.com
     */

    function isObjectValueEqual(a, b) {
      // for vue.js
      a = Object.assign({}, a);
      b = Object.assign({}, b);
      var aProps = Object.getOwnPropertyNames(a);
      var bProps = Object.getOwnPropertyNames(b);

      if (aProps.length !== bProps.length) {
        return false;
      }

      for (var i = 0, len = aProps.length; i < len; i++) {
        var propName = aProps[i];

        if (a[propName] !== b[propName]) {
          return false;
        }
      }

      return true;
    }

    function parsePadding(padding) {
      var top;
      var right;
      var bottom;
      var left;

      if (isNumber(padding) || isString(padding)) {
        top = bottom = left = right = padding;
      } else if (isArray$1(padding)) {
        top = padding[0];
        right = !isNil$1(padding[1]) ? padding[1] : padding[0];
        bottom = !isNil$1(padding[2]) ? padding[2] : padding[0];
        left = !isNil$1(padding[3]) ? padding[3] : right;
      }

      return [top, right, bottom, left];
    }

    function directionEnabled(mode, dir) {
      if (mode === undefined) {
        return true;
      } else if (typeof mode === 'string') {
        return mode.indexOf(dir) !== -1;
      }

      return false;
    }

    function toTimeStamp$1(value) {
      if (isString(value)) {
        if (value.indexOf('T') > 0) {
          value = new Date(value).getTime();
        } else {
          // new Date('2010/01/10') 和 new Date('2010-01-10') 的差别在于:
          // 如果仅有年月日时,前者是带有时区的: Fri Jan 10 2020 02:40:13 GMT+0800 (中国标准时间)
          // 后者会格式化成 Sun Jan 10 2010 08:00:00 GMT+0800 (中国标准时间)
          value = new Date(value.replace(/-/gi, '/')).getTime();
        }
      }

      if (isDate(value)) {
        value = value.getTime();
      }

      return value;
    }

    var Util = /*#__PURE__*/Object.freeze({
        __proto__: null,
        Array: array,
        upperFirst: upperFirst,
        lowerFirst: lowerFirst,
        isString: isString,
        isNumber: isNumber,
        isBoolean: isBoolean,
        isFunction: isFunction$1,
        isDate: isDate,
        isArray: isArray$1,
        isNil: isNil$1,
        isObject: isObject$1,
        isPlainObject: isPlainObject,
        isEqual: isEqual$1,
        deepMix: deepMix,
        mix: mix$1,
        each: each$1,
        uniq: uniq,
        find: find,
        isObjectValueEqual: isObjectValueEqual,
        parsePadding: parsePadding,
        directionEnabled: directionEnabled,
        toTimeStamp: toTimeStamp$1,
        substitute: substitute,
        isWx: isWx,
        isMy: isMy,
        isNode: isNode,
        isBrowser: isBrowser,
        isCanvasElement: isCanvasElement,
        getPixelRatio: getPixelRatio,
        getStyle: getStyle$1,
        getWidth: getWidth,
        getHeight: getHeight,
        getDomById: getDomById,
        getRelativePosition: getRelativePosition,
        addEventListener: addEventListener,
        removeEventListener: removeEventListener,
        createEvent: createEvent,
        convertPoints: convertPoints,
        measureText: measureText
    });

    /**
     * @fileOverview default theme
     * @author dxq613@gail.com
     */
    var color1 = '#E8E8E8'; // color of axis-line and axis-grid

    var color2 = '#808080'; // color of axis label

    var defaultAxis = {
      label: {
        fill: color2,
        fontSize: 10
      },
      line: {
        stroke: color1,
        lineWidth: 1
      },
      grid: {
        type: 'line',
        stroke: color1,
        lineWidth: 1,
        lineDash: [2]
      },
      tickLine: null,
      labelOffset: 7.5
    };
    var Theme = {
      fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
      defaultColor: '#1890FF',
      pixelRatio: 1,
      padding: 'auto',
      appendPadding: 15,
      colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
      shapes: {
        line: ['line', 'dash'],
        point: ['circle', 'hollowCircle']
      },
      sizes: [4, 10],
      axis: {
        common: defaultAxis,
        // common axis configuration
        bottom: mix$1({}, defaultAxis, {
          grid: null
        }),
        left: mix$1({}, defaultAxis, {
          line: null
        }),
        right: mix$1({}, defaultAxis, {
          line: null
        }),
        circle: mix$1({}, defaultAxis, {
          line: null
        }),
        radius: mix$1({}, defaultAxis, {
          labelOffset: 4
        })
      },
      shape: {
        line: {
          lineWidth: 2,
          lineJoin: 'round',
          lineCap: 'round'
        },
        point: {
          lineWidth: 0,
          size: 3
        },
        area: {
          fillOpacity: 0.1
        }
      },
      _defaultAxis: defaultAxis
    };

    var lang = {
      general: {
        title: '这是一个图表,',
        withTitle: '这是一个关于“{title}”的图表。'
      },
      coord: {
        cartesian: 'X轴是{xLabel}Y轴是{yLabel}' // polar: '弧度是{xLabel}半径是{yLabel}'

      },
      scale: {
        linear: '数值型,数据最小值为{min},最大值为{max};',
        cat: '分类型, 分类类型有:{values};',
        timeCat: '时间型,时间范围从{start}到{end};'
      },
      geometry: {
        prefix: '共有{count}种分类组成,',
        oneData: '第{index}类是{name},数据是{values};',
        partData: '第{index}类是{name},共有{count}项数据,前{part}项是{values};',
        allData: '第{index}类是{name},有{count}项数据,分别是{values};'
      },
      legend: {
        prefix: '图例分类有:'
      }
    };

    var Global = {
      version: '3.8.10-beta.1',
      scales: {},
      widthRatio: {
        column: 1 / 2,
        rose: 0.999999,
        multiplePie: 3 / 4
      },
      lineDash: [4, 4],
      lang: lang
    };

    Global.setTheme = function (theme) {
      deepMix(Global, theme);
    };

    Global.setTheme(Theme);

    function _defineProperty(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;
    }

    function _extends() {
      _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;
      };

      return _extends.apply(this, arguments);
    }

    function _inheritsLoose$3(subClass, superClass) {
      subClass.prototype = Object.create(superClass.prototype);
      subClass.prototype.constructor = subClass;

      _setPrototypeOf(subClass, superClass);
    }

    function _setPrototypeOf(o, p) {
      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
        o.__proto__ = p;
        return o;
      };

      return _setPrototypeOf(o, p);
    }

    function _assertThisInitialized(self) {
      if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }

      return self;
    }

    var EVENT_AFTER_INIT = 'afterinit';
    var EVENT_BEFORE_RENDER = 'beforerender';
    var EVENT_AFTER_RENDER = 'afterrender';
    var EVENT_BEFORE_DATA_CHANGE = 'beforedatachange';
    var EVENT_AFTER_DATA_CHANGE = 'afterdatachange';
    var EVENT_AFTER_SIZE_CHANGE = '_aftersizechange';
    var EVENT_AFTER_GEOM_INIT = '_aftergeominit';
    var EVENT_BEFORE_GEOM_DRAW = 'beforegeomdraw';
    var EVENT_AFTER_GEOM_DRAW = 'aftergeomdraw';
    var EVENT_CLEAR = 'clear';
    var EVENT_CLEAR_INNER = 'clearinner';
    var EVENT_REPAINT = 'repaint';

    // 实现简单的事件机制

    var EventEmit = /*#__PURE__*/function () {
      function EventEmit() {
        this.__events = {};
      }

      var _proto = EventEmit.prototype;

      _proto.on = function on(type, listener) {
        if (!type || !listener) {
          return;
        }

        var events = this.__events[type] || [];
        events.push(listener);
        this.__events[type] = events;
      };

      _proto.emit = function emit(type, e) {
        var _this = this;

        if (isObject$1(type)) {
          e = type;
          type = e && e.type;
        }

        if (!type) {
          return;
        }

        var events = this.__events[type];

        if (!events || !events.length) {
          return;
        }

        events.forEach(function (listener) {
          listener.call(_this, e);
        });
      };

      _proto.off = function off(type, listener) {
        var __events = this.__events;
        var events = __events[type];

        if (!events || !events.length) {
          return;
        } // 如果没有指定方法,则删除所有项


        if (!listener) {
          delete __events[type];
          return;
        } // 删除指定的 listener


        for (var i = 0, len = events.length; i < len; i++) {
          if (events[i] === listener) {
            events.splice(i, 1);
            i--;
          }
        }
      };

      return EventEmit;
    }();

    var Base$2 = /*#__PURE__*/function (_Emit) {
      _inheritsLoose$3(Base, _Emit);

      var _proto = Base.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {};
      };

      function Base(cfg) {
        var _this;

        _this = _Emit.call(this) || this;
        var attrs = {};

        var defaultCfg = _this.getDefaultCfg();

        _this._attrs = attrs;
        mix$1(attrs, defaultCfg, cfg);
        return _this;
      }

      _proto.get = function get(name) {
        return this._attrs[name];
      };

      _proto.set = function set(name, value) {
        this._attrs[name] = value;
      };

      _proto.destroy = function destroy() {
        this._attrs = {};
        this.destroyed = true;
      };

      return Base;
    }(EventEmit);

    var Plot = /*#__PURE__*/function () {
      function Plot(cfg) {
        mix$1(this, cfg);

        this._init();
      }

      var _proto = Plot.prototype;

      _proto._init = function _init() {
        var self = this;
        var start = self.start;
        var end = self.end;
        var xMin = Math.min(start.x, end.x);
        var xMax = Math.max(start.x, end.x);
        var yMin = Math.min(start.y, end.y);
        var yMax = Math.max(start.y, end.y);
        this.tl = {
          x: xMin,
          y: yMin
        };
        this.tr = {
          x: xMax,
          y: yMin
        };
        this.bl = {
          x: xMin,
          y: yMax
        };
        this.br = {
          x: xMax,
          y: yMax
        };
        this.width = xMax - xMin;
        this.height = yMax - yMin;
      }
      /**
       * reset
       * @param  {Object} start start point
       * @param  {Object} end end point
       */
      ;

      _proto.reset = function reset(start, end) {
        this.start = start;
        this.end = end;

        this._init();
      }
      /**
       * check the point is in the range of plot
       * @param  {Number}  x x value
       * @param  {[type]}  y y value
       * @return {Boolean} return the result
       */
      ;

      _proto.isInRange = function isInRange(x, y) {
        if (isObject$1(x)) {
          y = x.y;
          x = x.x;
        }

        var tl = this.tl;
        var br = this.br;
        return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
      };

      return Plot;
    }();

    var Matrix = {
      generateDefault: function generateDefault() {
        return [1, 0, 0, 1, 0, 0];
      },
      isChanged: function isChanged(m) {
        return m[0] !== 1 || m[1] !== 0 || m[2] !== 0 || m[3] !== 1 || m[4] !== 0 || m[5] !== 0;
      },
      multiply: function multiply(m1, m2) {
        var m11 = m1[0] * m2[0] + m1[2] * m2[1];
        var m12 = m1[1] * m2[0] + m1[3] * m2[1];
        var m21 = m1[0] * m2[2] + m1[2] * m2[3];
        var m22 = m1[1] * m2[2] + m1[3] * m2[3];
        var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
        var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
        return [m11, m12, m21, m22, dx, dy];
      },
      scale: function scale(out, m, v) {
        out[0] = m[0] * v[0];
        out[1] = m[1] * v[0];
        out[2] = m[2] * v[1];
        out[3] = m[3] * v[1];
        out[4] = m[4];
        out[5] = m[5];
        return out;
      },
      rotate: function rotate(out, m, radian) {
        var c = Math.cos(radian);
        var s = Math.sin(radian);
        var m11 = m[0] * c + m[2] * s;
        var m12 = m[1] * c + m[3] * s;
        var m21 = m[0] * -s + m[2] * c;
        var m22 = m[1] * -s + m[3] * c;
        out[0] = m11;
        out[1] = m12;
        out[2] = m21;
        out[3] = m22;
        out[4] = m[4];
        out[5] = m[5];
        return out;
      },
      translate: function translate(out, m, v) {
        out[0] = m[0];
        out[1] = m[1];
        out[2] = m[2];
        out[3] = m[3];
        out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
        out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
        return out;
      },
      transform: function transform(m, actions) {
        var out = [].concat(m);

        for (var i = 0, len = actions.length; i < len; i++) {
          var action = actions[i];

          switch (action[0]) {
            case 't':
              Matrix.translate(out, out, [action[1], action[2]]);
              break;

            case 's':
              Matrix.scale(out, out, [action[1], action[2]]);
              break;

            case 'r':
              Matrix.rotate(out, out, action[1]);
              break;
          }
        }

        return out;
      }
    };

    /**
     * 2 Dimensional Vector
     * @module vector2
     */
    var Vector2 = {
      /**
       * Creates a new, empty vector2
       *
       * @return {vector2} a new 2D vector
       */
      create: function create() {
        return [0, 0];
      },

      /**
       * Calculates the length of a vector2
       *
       * @param {vector2} v vector to calculate length of
       * @return {Number} length of v
       */
      length: function length(v) {
        var x = v[0];
        var y = v[1];
        return Math.sqrt(x * x + y * y);
      },

      /**
       * Normalize a vector2
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v vector to normalize
       * @return {vector2} out
       */
      normalize: function normalize(out, v) {
        var len = this.length(v);

        if (len === 0) {
          out[0] = 0;
          out[1] = 0;
        } else {
          out[0] = v[0] / len;
          out[1] = v[1] / len;
        }

        return out;
      },

      /**
       * Adds two vector2's
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {vector2} out
       */
      add: function add(out, v1, v2) {
        out[0] = v1[0] + v2[0];
        out[1] = v1[1] + v2[1];
        return out;
      },

      /**
       * Subtracts vector v2 from vector v1
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {vector2} out
       */
      sub: function sub(out, v1, v2) {
        out[0] = v1[0] - v2[0];
        out[1] = v1[1] - v2[1];
        return out;
      },

      /**
       * Scales a vector2 by a scalar number
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v the vector to scale
       * @param {Number} s amount to scale the vector by
       * @return {vector2} out
       */
      scale: function scale(out, v, s) {
        out[0] = v[0] * s;
        out[1] = v[1] * s;
        return out;
      },

      /**
       * Calculates the dot product of two vector2's
       *
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {Number} dot product of v1 and v2
       */
      dot: function dot(v1, v2) {
        return v1[0] * v2[0] + v1[1] * v2[1];
      },

      /**
       * Calculates the direction of two vector2's
       *
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {Boolean} the direction of v1 and v2
       */
      direction: function direction(v1, v2) {
        return v1[0] * v2[1] - v2[0] * v1[1];
      },

      /**
       * Calculates the angle of two vector2's
       *
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {Number} angle of v1 and v2
       */
      angle: function angle(v1, v2) {
        var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
        return Math.acos(theta);
      },

      /**
       * Calculates the angle of two vector2's with direction
       *
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @param {Boolean} direction the direction of two vector2's
       * @return {Number} angle of v1 and v2
       */
      angleTo: function angleTo(v1, v2, direction) {
        var angle = this.angle(v1, v2);
        var angleLargeThanPI = this.direction(v1, v2) >= 0;

        if (direction) {
          if (angleLargeThanPI) {
            return Math.PI * 2 - angle;
          }

          return angle;
        }

        if (angleLargeThanPI) {
          return angle;
        }

        return Math.PI * 2 - angle;
      },

      /**
       * whether a vector2 is zero vector
       *
       * @param  {vector2} v vector to calculate
       * @return {Boolean}   is or not a zero vector
       */
      zero: function zero(v) {
        return v[0] === 0 && v[1] === 0;
      },

      /**
       * Calculates the euclidian distance between two vector2's
       *
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {Number} distance between a and b
       */
      distance: function distance(v1, v2) {
        var x = v2[0] - v1[0];
        var y = v2[1] - v1[1];
        return Math.sqrt(x * x + y * y);
      },

      /**
       * Creates a new vector2 initialized with values from an existing vector
       *
       * @param {vector2} v vector to clone
       * @return {Array} a new 2D vector
       */
      clone: function clone(v) {
        return [v[0], v[1]];
      },

      /**
       * Return the minimum of two vector2's
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {vector2} out
       */
      min: function min(out, v1, v2) {
        out[0] = Math.min(v1[0], v2[0]);
        out[1] = Math.min(v1[1], v2[1]);
        return out;
      },

      /**
       * Return the maximum of two vector2's
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v1 the first operand
       * @param {vector2} v2 the second operand
       * @return {vector2} out
       */
      max: function max(out, v1, v2) {
        out[0] = Math.max(v1[0], v2[0]);
        out[1] = Math.max(v1[1], v2[1]);
        return out;
      },

      /**
       * Transforms the vector2 with a mat2d
       *
       * @param {vector2} out the receiving vector
       * @param {vector2} v the vector to transform
       * @param {mat2d} m matrix to transform with
       * @return {vector2} out
       */
      transformMat2d: function transformMat2d(out, v, m) {
        var x = v[0];
        var y = v[1];
        out[0] = m[0] * x + m[2] * y + m[4];
        out[1] = m[1] * x + m[3] * y + m[5];
        return out;
      }
    };

    var defaultMatrix = [1, 0, 0, 1, 0, 0];

    var Base$1 = /*#__PURE__*/function () {
      var _proto = Base.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {};

      function Base(cfg) {
        this._initDefaultCfg();

        mix$1(this, cfg);
        var start;
        var end;

        if (this.plot) {
          start = this.plot.bl;
          end = this.plot.tr;
          this.start = start;
          this.end = end;
        } else {
          start = this.start;
          end = this.end;
        }

        this.init(start, end);
      }

      _proto._scale = function _scale(s1, s2) {
        var matrix = this.matrix;
        var center = this.center;
        Matrix.translate(matrix, matrix, [center.x, center.y]);
        Matrix.scale(matrix, matrix, [s1, s2]);
        Matrix.translate(matrix, matrix, [-center.x, -center.y]);
      };

      _proto.init = function init(start, end) {
        this.matrix = [].concat(defaultMatrix); // 设置中心点

        this.center = {
          x: (end.x - start.x) / 2 + start.x,
          y: (end.y - start.y) / 2 + start.y
        };

        if (this.scale) {
          this._scale(this.scale[0], this.scale[1]);
        }
      };

      _proto.convertPoint = function convertPoint(point) {
        var _this$_convertPoint = this._convertPoint(point),
            x = _this$_convertPoint.x,
            y = _this$_convertPoint.y;

        if (!Matrix.isChanged(this.matrix)) {
          return {
            x: x,
            y: y
          };
        }

        var vector = [x, y];
        Vector2.transformMat2d(vector, vector, this.matrix);
        return {
          x: vector[0],
          y: vector[1]
        };
      };

      _proto.invertPoint = function invertPoint(point) {
        return this._invertPoint(point);
      };

      _proto._convertPoint = function _convertPoint(point) {
        return point;
      };

      _proto._invertPoint = function _invertPoint(point) {
        return point;
      };

      _proto.reset = function reset(plot) {
        this.plot = plot;
        var bl = plot.bl,
            tr = plot.tr;
        this.start = bl;
        this.end = tr;
        this.init(bl, tr);
      };

      return Base;
    }();

    var Cartesian = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Cartesian, _Base);

      function Cartesian() {
        return _Base.apply(this, arguments) || this;
      }

      var _proto = Cartesian.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'cartesian';
        this.transposed = false;
        this.isRect = true;
      };

      _proto.init = function init(start, end) {
        _Base.prototype.init.call(this, start, end);

        this.x = {
          start: start.x,
          end: end.x
        };
        this.y = {
          start: start.y,
          end: end.y
        };
      };

      _proto._convertPoint = function _convertPoint(point) {
        var self = this;
        var transposed = self.transposed;
        var xDim = transposed ? 'y' : 'x';
        var yDim = transposed ? 'x' : 'y';
        var x = self.x;
        var y = self.y;
        return {
          x: x.start + (x.end - x.start) * point[xDim],
          y: y.start + (y.end - y.start) * point[yDim]
        };
      };

      _proto._invertPoint = function _invertPoint(point) {
        var self = this;
        var transposed = self.transposed;
        var xDim = transposed ? 'y' : 'x';
        var yDim = transposed ? 'x' : 'y';
        var x = self.x;
        var y = self.y;
        var rst = {};
        rst[xDim] = (point.x - x.start) / (x.end - x.start);
        rst[yDim] = (point.y - y.start) / (y.end - y.start);
        return rst;
      };

      return Cartesian;
    }(Base$1);

    Base$1.Cartesian = Cartesian;
    Base$1.Rect = Cartesian;

    /**
     * @fileOverview the Attribute base class
     */

    function toScaleString(scale, value) {
      if (isString(value)) {
        return value;
      }

      return scale.invert(scale.scale(value));
    }
    /**
     * 所有视觉通道属性的基类
     * @class Attr
     */


    var AttributeBase = /*#__PURE__*/function () {
      function AttributeBase(cfg) {
        var _this = this;

        /**
         * 属性的类型
         * @type {String}
         */
        this.type = 'base';
        /**
         * 属性的名称
         * @type {String}
         */

        this.name = null;
        /**
         * 回调函数
         * @type {Function}
         */

        this.method = null;
        /**
         * 备选的值数组
         * @type {Array}
         */

        this.values = [];
        /**
         * 属性内部的度量
         * @type {Array}
         */

        this.scales = [];
        /**
         * 是否通过线性取值, 如果未指定,则根据数值的类型判定
         * @type {Boolean}
         */

        this.linear = null;
        /**
         * 当用户设置的 callback 返回 null 时, 应该返回默认 callback 中的值
         */

        var mixedCallback = null;
        var defaultCallback = this.callback;

        if (cfg.callback) {
          var userCallback = cfg.callback;

          mixedCallback = function mixedCallback() {
            for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
              params[_key] = arguments[_key];
            }

            var ret = userCallback.apply(void 0, params);

            if (isNil$1(ret)) {
              ret = defaultCallback.apply(_this, params);
            }

            return ret;
          };
        }

        mix$1(this, cfg);

        if (mixedCallback) {
          mix$1(this, {
            callback: mixedCallback
          });
        }
      } // 获取属性值,将值映射到视觉通道


      var _proto = AttributeBase.prototype;

      _proto._getAttrValue = function _getAttrValue(scale, value) {
        var values = this.values;

        if (scale.isCategory && !this.linear) {
          var index = scale.translate(value);
          return values[index % values.length];
        }

        var percent = scale.scale(value);
        return this.getLinearValue(percent);
      }
      /**
       * 如果进行线性映射,返回对应的映射值
       * @protected
       * @param  {Number} percent 百分比
       * @return {*}  颜色值、形状、大小等
       */
      ;

      _proto.getLinearValue = function getLinearValue(percent) {
        var values = this.values;
        var steps = values.length - 1;
        var step = Math.floor(steps * percent);
        var leftPercent = steps * percent - step;
        var start = values[step];
        var end = step === steps ? start : values[step + 1];
        var rstValue = start + (end - start) * leftPercent;
        return rstValue;
      }
      /**
       * 默认的回调函数
       * @param {*} value 回调函数的值
       * @type {Function}
       * @return {Array} 返回映射后的值
       */
      ;

      _proto.callback = function callback(value) {
        var self = this;
        var scale = self.scales[0];
        var rstValue = null;

        if (scale.type === 'identity') {
          rstValue = scale.value;
        } else {
          rstValue = self._getAttrValue(scale, value);
        }

        return rstValue;
      }
      /**
       * 根据度量获取属性名
       * @return {Array} dims of this Attribute
       */
      ;

      _proto.getNames = function getNames() {
        var scales = this.scales;
        var names = this.names;
        var length = Math.min(scales.length, names.length);
        var rst = [];

        for (var i = 0; i < length; i++) {
          rst.push(names[i]);
        }

        return rst;
      }
      /**
       * 根据度量获取维度名
       * @return {Array} dims of this Attribute
       */
      ;

      _proto.getFields = function getFields() {
        var scales = this.scales;
        var rst = [];
        each$1(scales, function (scale) {
          rst.push(scale.field);
        });
        return rst;
      }
      /**
       * 根据名称获取度量
       * @param  {String} name the name of scale
       * @return {Scale} scale
       */
      ;

      _proto.getScale = function getScale(name) {
        var scales = this.scales;
        var names = this.names;
        var index = names.indexOf(name);
        return scales[index];
      }
      /**
       * 映射数据
       * @param {*} param1...paramn 多个数值
       * @return {Array} 映射的值组成的数组
       */
      ;

      _proto.mapping = function mapping() {
        var scales = this.scales;
        var callback = this.callback;

        for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
          params[_key2] = arguments[_key2];
        }

        var values = params;

        if (callback) {
          for (var i = 0, len = params.length; i < len; i++) {
            params[i] = this._toOriginParam(params[i], scales[i]);
          }

          values = callback.apply(this, params);
        }

        values = [].concat(values);
        return values;
      } // 原始的参数
      ;

      _proto._toOriginParam = function _toOriginParam(param, scale) {
        var rst = param;

        if (!scale.isLinear) {
          if (isArray$1(param)) {
            rst = [];

            for (var i = 0, len = param.length; i < len; i++) {
              rst.push(toScaleString(scale, param[i]));
            }
          } else {
            rst = toScaleString(scale, param);
          }
        }

        return rst;
      };

      return AttributeBase;
    }();

    var Position = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Position, _Base);

      function Position(cfg) {
        var _this;

        _this = _Base.call(this, cfg) || this;
        _this.names = ['x', 'y'];
        _this.type = 'position';
        return _this;
      }

      var _proto = Position.prototype;

      _proto.mapping = function mapping(x, y) {
        var scales = this.scales;
        var coord = this.coord;
        var scaleX = scales[0];
        var scaleY = scales[1];
        var rstX;
        var rstY;
        var obj;

        if (isNil$1(x) || isNil$1(y)) {
          return [];
        }

        if (isArray$1(y) && isArray$1(x)) {
          rstX = [];
          rstY = [];

          for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
            obj = coord.convertPoint({
              x: scaleX.scale(x[i]),
              y: scaleY.scale(y[j])
            });
            rstX.push(obj.x);
            rstY.push(obj.y);
          }
        } else if (isArray$1(y)) {
          x = scaleX.scale(x);
          rstY = [];
          each$1(y, function (yVal) {
            yVal = scaleY.scale(yVal);
            obj = coord.convertPoint({
              x: x,
              y: yVal
            });

            if (rstX && rstX !== obj.x) {
              if (!isArray$1(rstX)) {
                rstX = [rstX];
              }

              rstX.push(obj.x);
            } else {
              rstX = obj.x;
            }

            rstY.push(obj.y);
          });
        } else if (isArray$1(x)) {
          y = scaleY.scale(y);
          rstX = [];
          each$1(x, function (xVal) {
            xVal = scaleX.scale(xVal);
            obj = coord.convertPoint({
              x: xVal,
              y: y
            });

            if (rstY && rstY !== obj.y) {
              if (!isArray$1(rstY)) {
                rstY = [rstY];
              }

              rstY.push(obj.y);
            } else {
              rstY = obj.y;
            }

            rstX.push(obj.x);
          });
        } else {
          x = scaleX.scale(x);
          y = scaleY.scale(y);
          var point = coord.convertPoint({
            x: x,
            y: y
          });
          rstX = point.x;
          rstY = point.y;
        }

        return [rstX, rstY];
      };

      return Position;
    }(AttributeBase);

    var Shape$2 = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Shape, _Base);

      function Shape(cfg) {
        var _this;

        _this = _Base.call(this, cfg) || this;
        _this.names = ['shape'];
        _this.type = 'shape';
        _this.gradient = null;
        return _this;
      }
      /**
       * @override
       */


      var _proto = Shape.prototype;

      _proto.getLinearValue = function getLinearValue(percent) {
        var values = this.values;
        var index = Math.round((values.length - 1) * percent);
        return values[index];
      };

      return Shape;
    }(AttributeBase);

    var Size = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Size, _Base);

      function Size(cfg) {
        var _this;

        _this = _Base.call(this, cfg) || this;
        _this.names = ['size'];
        _this.type = 'size';
        _this.gradient = null;
        return _this;
      }

      return Size;
    }(AttributeBase);

    function getValue(start, end, percent, index) {
      var value = start[index] + (end[index] - start[index]) * percent;
      return value;
    } // convert to hex


    function arr2hex(arr) {
      return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
    }

    function toRGBValue(value) {
      value = Math.round(value);
      value = value.toString(16);

      if (value.length === 1) {
        value = '0' + value;
      }

      return value;
    }

    function calColor(colors, percent) {
      var steps = colors.length - 1;
      var step = Math.floor(steps * percent);
      var left = steps * percent - step;
      var start = colors[step];
      var end = step === steps ? start : colors[step + 1];
      var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
      return rgb;
    }

    function hex2arr(str) {
      var arr = [];
      arr.push(parseInt(str.substr(1, 2), 16));
      arr.push(parseInt(str.substr(3, 2), 16));
      arr.push(parseInt(str.substr(5, 2), 16));
      return arr;
    }

    var colorCache = {
      black: '#000000',
      blue: '#0000ff',
      grey: '#808080',
      green: '#008000',
      orange: '#ffa500',
      pink: '#ffc0cb',
      purple: '#800080',
      red: '#ff0000',
      white: '#ffffff',
      yellow: '#ffff00'
    };
    /**
     * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
     * @param  {String} color color value
     * @return {String} Returns a hexadecimal string
     */

    function toHex(color) {
      if (colorCache[color]) {
        return colorCache[color];
      }

      if (color[0] === '#') {
        if (color.length === 7) {
          return color;
        }

        var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
          return '#' + r + r + g + g + b + b;
        }); // hex3 to hex6

        colorCache[color] = hex;
        return hex;
      } // rgb/rgba to hex


      var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
      rst.shift();
      rst = arr2hex(rst);
      colorCache[color] = rst;
      return rst;
    }
    /**
     * handle the gradient color
     * @param  {Array} colors the colors
     * @return {String} return the color value
     */


    function gradient(colors) {
      var points = [];

      if (isString(colors)) {
        colors = colors.split('-');
      }

      each$1(colors, function (color) {
        if (color.indexOf('#') === -1) {
          color = toHex(color);
        }

        points.push(hex2arr(color));
      });
      return function (percent) {
        return calColor(points, percent);
      };
    }

    var Color = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Color, _Base);

      function Color(cfg) {
        var _this;

        _this = _Base.call(this, cfg) || this;
        _this.names = ['color'];
        _this.type = 'color';
        _this.gradient = null;

        if (isString(_this.values)) {
          _this.linear = true;
        }

        return _this;
      }
      /**
       * @override
       */


      var _proto = Color.prototype;

      _proto.getLinearValue = function getLinearValue(percent) {
        var gradient$1 = this.gradient;

        if (!gradient$1) {
          var values = this.values;
          gradient$1 = gradient(values);
          this.gradient = gradient$1;
        }

        return gradient$1(percent);
      };

      return Color;
    }(AttributeBase);

    var Attr = /*#__PURE__*/Object.freeze({
        __proto__: null,
        Position: Position,
        Shape: Shape$2,
        Size: Size,
        Color: Color
    });

    var Shape$1 = {};
    var ShapeBase = {
      _coord: null,

      /**
       * draw the shape
       * @param {Object} cfg options
       * @param {Object} container container to store the shapes
       */
      draw: function draw(cfg, container) {
        if (this.drawShape) {
          this.drawShape(cfg, container);
        }
      },

      /**
       * set the coordinate instance
       * @param {Coord} coord coordinate instance
       */
      setCoord: function setCoord(coord) {
        this._coord = coord;
      },

      /**
       * convert the normalized value to the canvas position
       * @param  {point} point the point to convert
       * @return {point} point return the result
       */
      parsePoint: function parsePoint(point) {
        var coord = this._coord;

        if (coord.isPolar) {
          if (point.x === 1) point.x = 0.9999999;
          if (point.y === 1) point.y = 0.9999999;
        }

        return coord.convertPoint(point);
      },

      /**
       * convert the normalized value to the canvas position
       * @param  {points} points the array that store the points
       * @return {points} points return the result
       */
      parsePoints: function parsePoints(points) {
        if (!points) return false;
        var self = this;
        var rst = [];
        points.forEach(function (point) {
          rst.push(self.parsePoint(point));
        });
        return rst;
      }
    };
    var ShapeFactoryBase = {
      defaultShapeType: null,
      setCoord: function setCoord(coord) {
        this._coord = coord;
      },
      getShape: function getShape(type) {
        var self = this;

        if (isArray$1(type)) {
          type = type[0];
        }

        var shape = self[type] || self[self.defaultShapeType];
        shape._coord = self._coord;
        return shape;
      },
      getShapePoints: function getShapePoints(type, cfg) {
        var shape = this.getShape(type);
        var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
        var points = fn(cfg);
        return points;
      },
      getDefaultPoints: function getDefaultPoints() {
        return [];
      },
      drawShape: function drawShape(type, cfg, container) {
        var shape = this.getShape(type);

        if (!cfg.color) {
          cfg.color = Global.colors[0];
        }

        return shape.draw(cfg, container);
      }
    };

    Shape$1.registerFactory = function (factoryName, cfg) {
      var className = upperFirst(factoryName);
      var geomObj = mix$1({}, ShapeFactoryBase, cfg);
      Shape$1[className] = geomObj;
      geomObj.name = factoryName;
      return geomObj;
    };

    Shape$1.registerShape = function (factoryName, shapeType, cfg) {
      var className = upperFirst(factoryName);
      var factory = Shape$1[className];
      var shapeObj = mix$1({}, ShapeBase, cfg);
      factory[shapeType] = shapeObj;
      return shapeObj;
    };

    Shape$1.registShape = Shape$1.registerShape;

    Shape$1.getShapeFactory = function (factoryName) {
      var self = this;
      factoryName = factoryName || 'point';
      var className = upperFirst(factoryName);
      return self[className];
    };

    function _mix(dist, obj) {
      for (var key in obj) {
        if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
          dist[key] = obj[key];
        }
      }
    }

    var mix = function mix(dist, src1, src2, src3) {
      if (src1) _mix(dist, src1);
      if (src2) _mix(dist, src2);
      if (src3) _mix(dist, src3);
      return dist;
    };

    var mix_1 = mix;

    var Adjust = /*#__PURE__*/function () {
      var _proto = Adjust.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
      };

      function Adjust(cfg) {
        this._initDefaultCfg();

        mix_1(this, cfg);
      }
      /**
       * @override
       */


      _proto.processAdjust = function processAdjust()
      /* dataArray */
      {};

      return Adjust;
    }();

    var base = Adjust;

    function generateScaleAria(scale) {
      var type = scale.type,
          values = scale.values;

      if (type === 'linear') {
        return substitute(lang.scale.linear, scale);
      }

      if (type === 'cat') {
        return substitute(lang.scale.cat, {
          values: values.slice(0, 10).join(' ')
        });
      }

      if (type === 'timeCat') {
        var start = scale.getText(values[0]);
        var end = scale.getText(values[values.length - 1]);
        return substitute(lang.scale.timeCat, {
          start: start,
          end: end
        });
      }

      return '';
    }
    function generateCoordAria(coord, xScale, yScale) {
      var type = coord.type;

      if (!lang.coord[type]) {
        return '';
      }

      return substitute(lang.coord[type], {
        xLabel: generateScaleAria(xScale),
        yLabel: generateScaleAria(yScale)
      });
    }

    var GROUP_ATTRS = ['color', 'size', 'shape'];
    var FIELD_ORIGIN = '_origin';
    var FIELD_ORIGIN_Y = '_originY';

    function parseFields(field) {
      if (isArray$1(field)) {
        return field;
      }

      if (isString(field)) {
        return field.split('*');
      }

      return [field];
    }
    /**
     * The parent class for Geometry
     * @class Geom
     */


    var Geom = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Geom, _Base);

      function Geom() {
        return _Base.apply(this, arguments) || this;
      }

      var _proto = Geom.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          /**
           * geometry type
           * @type {String}
           */
          type: null,

          /**
           * the data of geometry
           * @type {Array}
           */
          data: null,

          /**
           * the attrs of geo,etry
           * @type {Object}
           */
          attrs: {},
          scales: {},

          /**
           * group for storing the shapes
           * @type {Canvas}
           */
          container: null,

          /**
           * style options
           * @type {Object}
           */
          styleOptions: null,
          chart: null,
          shapeType: '',

          /**
           * wether to generate key points for each shape
           * @protected
           * @type {Boolean}
           */
          generatePoints: false,
          attrOptions: {},
          sortable: false,
          startOnZero: true,
          visible: true,
          connectNulls: false,
          // 是否丢弃没有值的分组。
          ignoreEmptyGroup: false,
          // 是否已经初始化
          isInit: false
        };
      };

      _proto.init = function init() {
        var self = this;
        var isInit = self.get('isInit');

        if (isInit) {
          return;
        }

        self._initAttrs();

        self._processData();

        self.set('isInit', true);
      };

      _proto._getGroupScales = function _getGroupScales() {
        var self = this;
        var scales = [];
        each$1(GROUP_ATTRS, function (attrName) {
          var attr = self.getAttr(attrName);

          if (attr) {
            var attrScales = attr.scales;
            each$1(attrScales, function (scale) {
              if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
                scales.push(scale);
              }
            });
          }
        });
        return scales;
      };

      _proto._groupData = function _groupData(data) {
        var self = this;
        var colDefs = self.get('colDefs');

        var groupScales = self._getGroupScales();

        if (groupScales.length) {
          var appendConditions = {};
          var names = [];
          each$1(groupScales, function (scale) {
            var field = scale.field;
            names.push(field);

            if (colDefs && colDefs[field] && colDefs[field].values) {
              // users have defined
              appendConditions[scale.field] = colDefs[field].values;
            }
          });
          return group(data, names, appendConditions);
        }

        return [data];
      };

      _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
        var options = this.get('attrOptions');
        options[attrName] = attrCfg;
        var attrs = this.get('attrs'); // 说明已经初始化过了

        if (Object.keys(attrs).length) {
          this._createAttr(attrName, attrCfg);
        }
      };

      _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
        var attrCfg = {};
        attrCfg.field = field;

        if (cfg) {
          if (isFunction$1(cfg)) {
            attrCfg.callback = cfg;
          } else {
            attrCfg.values = cfg;
          }
        } else {
          attrCfg.values = defaultValues;
        }

        this._setAttrOptions(attrName, attrCfg);
      };

      _proto._createAttr = function _createAttr(type, option) {
        var self = this;
        var attrs = self.get('attrs');
        var coord = self.get('coord');
        var className = upperFirst(type);
        var fields = parseFields(option.field);

        if (type === 'position') {
          option.coord = coord;
        }

        var scales = [];

        for (var i = 0, len = fields.length; i < len; i++) {
          var field = fields[i];

          var scale = self._createScale(field);

          scales.push(scale);
        }

        if (type === 'position') {
          var yScale = scales[1]; // 饼图的处理,但是还不知道为啥

          if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
            if (yScale.values.length) {
              yScale.change({
                nice: false,
                min: 0,
                max: Math.max.apply(null, yScale.values)
              });
            }
          }
        }

        option.scales = scales;
        var attr = new Attr[className](option);
        attrs[type] = attr;
        return attr;
      };

      _proto._initAttrs = function _initAttrs() {
        var self = this;
        var attrOptions = self.get('attrOptions');

        for (var type in attrOptions) {
          if (attrOptions.hasOwnProperty(type)) {
            this._createAttr(type, attrOptions[type]);
          }
        }
      };

      _proto._createScale = function _createScale(field) {
        var scales = this.get('scales');
        var scale = scales[field];

        if (!scale) {
          scale = this.get('chart').createScale(field);
          scales[field] = scale;
        }

        return scale;
      };

      _proto._processData = function _processData() {
        var self = this;
        var data = this.get('data');
        var dataArray = [];

        var groupedArray = this._groupData(data);

        if (this.get('ignoreEmptyGroup')) {
          var yScale = this.getYScale();
          groupedArray = groupedArray.filter(function (group) {
            return group.some(function (item) {
              return typeof item[yScale.field] !== 'undefined';
            });
          });
        }

        for (var i = 0, len = groupedArray.length; i < len; i++) {
          var subData = groupedArray[i];

          var tempData = self._saveOrigin(subData);

          if (this.hasAdjust('dodge')) {
            self._numberic(tempData);
          }

          dataArray.push(tempData);
        }

        if (self.get('adjust')) {
          self._adjustData(dataArray);
        }

        if (self.get('sortable')) {
          self._sort(dataArray);
        }

        self.emit('afterprocessdata', {
          dataArray: dataArray
        });
        self.set('mappingData', dataArray);
        self.set('dataArray', dataArray);
        return dataArray;
      };

      _proto._saveOrigin = function _saveOrigin(data) {
        var rst = [];

        for (var i = 0, len = data.length; i < len; i++) {
          var origin = data[i];
          var obj = {};

          for (var k in origin) {
            obj[k] = origin[k];
          }

          obj[FIELD_ORIGIN] = origin;
          rst.push(obj);
        }

        return rst;
      };

      _proto._numberic = function _numberic(data) {
        var positionAttr = this.getAttr('position');
        var scales = positionAttr.scales;

        for (var j = 0, len = data.length; j < len; j++) {
          var obj = data[j];
          var count = Math.min(2, scales.length);

          for (var i = 0; i < count; i++) {
            var scale = scales[i];

            if (scale.isCategory) {
              var field = scale.field;
              obj[field] = scale.translate(obj[field]);
            }
          }
        }
      };

      _proto._adjustData = function _adjustData(dataArray) {
        var self = this;
        var adjust = self.get('adjust');

        if (adjust) {
          var adjustType = upperFirst(adjust.type);

          if (!base[adjustType]) {
            throw new Error('not support such adjust : ' + adjust);
          }

          var xScale = self.getXScale();
          var yScale = self.getYScale();
          var cfg = mix$1({
            xField: xScale.field,
            yField: yScale.field
          }, adjust);
          var adjustObject = new base[adjustType](cfg);
          adjustObject.processAdjust(dataArray);

          if (adjustType === 'Stack') {
            self._updateStackRange(yScale.field, yScale, dataArray);
          }
        }
      };

      _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
        var mergeArray = merge$1(dataArray);
        var min = scale.min;
        var max = scale.max;

        for (var i = 0, len = mergeArray.length; i < len; i++) {
          var obj = mergeArray[i];
          var tmpMin = Math.min.apply(null, obj[field]);
          var tmpMax = Math.max.apply(null, obj[field]);

          if (tmpMin < min) {
            min = tmpMin;
          }

          if (tmpMax > max) {
            max = tmpMax;
          }
        }

        if (min < scale.min || max > scale.max) {
          scale.change({
            min: min,
            max: max
          });
        }
      };

      _proto._sort = function _sort(mappedArray) {
        var self = this;
        var xScale = self.getXScale();
        var field = xScale.field,
            type = xScale.type;

        if (type !== 'identity' && xScale.values.length > 1) {
          each$1(mappedArray, function (itemArr) {
            itemArr.sort(function (obj1, obj2) {
              if (type === 'timeCat') {
                return toTimeStamp$1(obj1[FIELD_ORIGIN][field]) - toTimeStamp$1(obj2[FIELD_ORIGIN][field]);
              }

              return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
            });
          });
        }

        self.set('hasSorted', true);
        self.set('dataArray', mappedArray);
      };

      _proto.paint = function paint() {
        var self = this;
        var dataArray = self.get('mappingData');
        var mappedArray = [];
        var shapeFactory = self.getShapeFactory();
        shapeFactory.setCoord(self.get('coord'));

        self._beforeMapping(dataArray);

        for (var i = 0, len = dataArray.length; i < len; i++) {
          var data = dataArray[i];

          if (data.length) {
            var mappedData = self._mapping(data);

            mappedArray.push(mappedData);
            self.draw(mappedData, shapeFactory);
          }
        }

        self.set('dataArray', mappedArray);
        this.generateAria();
      };

      _proto.getShapeFactory = function getShapeFactory() {
        var shapeFactory = this.get('shapeFactory');

        if (!shapeFactory) {
          var shapeType = this.get('shapeType');
          shapeFactory = Shape$1.getShapeFactory(shapeType);
          this.set('shapeFactory', shapeFactory);
        }

        return shapeFactory;
      };

      _proto._mapping = function _mapping(data) {
        var self = this;
        var attrs = self.get('attrs');
        var yField = self.getYScale().field; // 用来缓存转换的值,减少mapping耗时

        var mappedCache = {};
        var mappedData = new Array(data.length);

        for (var k in attrs) {
          if (attrs.hasOwnProperty(k)) {
            var attr = attrs[k];
            var names = attr.names;
            var scales = attr.scales;

            for (var i = 0, len = data.length; i < len; i++) {
              var record = data[i];

              var mappedRecord = _extends({}, record, mappedData[i]);

              mappedRecord[FIELD_ORIGIN_Y] = record[yField]; // 获取视觉属性对应的value值
              // 位置的缓存命中率低,还是每次单独计算

              if (attr.type === 'position') {
                var values = self._getAttrValues(attr, record);

                for (var j = 0, _len = values.length; j < _len; j++) {
                  var val = values[j];
                  var name = names[j];
                  mappedRecord[name] = isArray$1(val) && val.length === 1 ? val[0] : val;
                }
              } else {
                // 除了position其他都只有一项
                var _name = names[0];
                var field = scales[0].field;
                var value = record[field];
                var key = "" + _name + value;
                var _values = mappedCache[key];

                if (!_values) {
                  _values = self._getAttrValues(attr, record);
                  mappedCache[key] = _values;
                }

                mappedRecord[_name] = _values[0];
              } // 设置新数组


              mappedData[i] = mappedRecord;
            }
          }
        }

        return mappedData;
      };

      _proto._getAttrValues = function _getAttrValues(attr, record) {
        var scales = attr.scales;
        var params = [];

        for (var i = 0, len = scales.length; i < len; i++) {
          var scale = scales[i];
          var field = scale.field;

          if (scale.type === 'identity') {
            params.push(scale.value);
          } else {
            params.push(record[field]);
          }
        }

        var values = attr.mapping.apply(attr, params);
        return values;
      };

      _proto.getAttrValue = function getAttrValue(attrName, record) {
        var attr = this.getAttr(attrName);
        var rst = null;

        if (attr) {
          var values = this._getAttrValues(attr, record);

          rst = values[0];
        }

        return rst;
      };

      _proto._beforeMapping = function _beforeMapping(dataArray) {
        var self = this;

        if (self.get('generatePoints')) {
          self._generatePoints(dataArray);
        }
      };

      _proto.isInCircle = function isInCircle() {
        var coord = this.get('coord');
        return coord && coord.isPolar;
      };

      _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
        if (!fields) {
          return cfg;
        }

        var tmpCfg = {};
        var params = fields.map(function (field) {
          return origin[field];
        });
        each$1(cfg, function (v, k) {
          if (isFunction$1(v)) {
            tmpCfg[k] = v.apply(null, params);
          } else {
            tmpCfg[k] = v;
          }
        });
        return tmpCfg;
      };

      _proto.getDrawCfg = function getDrawCfg(obj) {
        var self = this;
        var isInCircle = self.isInCircle();
        var cfg = {
          origin: obj,
          x: obj.x,
          y: obj.y,
          color: obj.color,
          size: obj.size,
          shape: obj.shape,
          isInCircle: isInCircle,
          opacity: obj.opacity
        };
        var styleOptions = self.get('styleOptions');

        if (styleOptions && styleOptions.style) {
          cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
        }

        if (self.get('generatePoints')) {
          cfg.points = obj.points;
          cfg.nextPoints = obj.nextPoints;
        }

        if (isInCircle) {
          cfg.center = self.get('coord').center;
        }

        return cfg;
      };

      _proto.draw = function draw(data, shapeFactory) {
        var self = this;
        var container = self.get('container');
        var yScale = self.getYScale();
        each$1(data, function (obj, index) {
          if (yScale && isNil$1(obj._origin[yScale.field])) {
            return;
          }

          obj.index = index;
          var cfg = self.getDrawCfg(obj);
          var shape = obj.shape;
          self.drawShape(shape, obj, cfg, container, shapeFactory);
        });
      };

      _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
        var gShape = shapeFactory.drawShape(shape, cfg, container);

        if (gShape) {
          each$1([].concat(gShape), function (s) {
            s.set('origin', shapeData);
          });
        }
      };

      _proto._generatePoints = function _generatePoints(dataArray) {
        var self = this;
        var shapeFactory = self.getShapeFactory();
        var shapeAttr = self.getAttr('shape');
        each$1(dataArray, function (data) {
          for (var i = 0, len = data.length; i < len; i++) {
            var obj = data[i];
            var cfg = self.createShapePointsCfg(obj);
            var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
            var points = shapeFactory.getShapePoints(shape, cfg);
            obj.points = points;
          }
        }); // 添加nextPoints

        each$1(dataArray, function (data, index) {
          var nextData = dataArray[index + 1];

          if (nextData) {
            data[0].nextPoints = nextData[0].points;
          }
        });
      } // 生成无障碍文本
      ;

      _proto.generateAria = function generateAria() {
        var container = this.get('container');
        var aria = container.get('aria');

        if (!aria) {
          return;
        }

        var ariaLables = [];
        var coord = this.get('coord');
        var xScale = this.getXScale();
        var yScale = this.getYScale();
        var coordAriaLabel = generateCoordAria(coord, xScale, yScale);
        ariaLables.push(coordAriaLabel);
        var _lang$geometry = lang.geometry,
            prefix = _lang$geometry.prefix,
            oneData = _lang$geometry.oneData,
            partData = _lang$geometry.partData,
            allData = _lang$geometry.allData;
        var dataArray = this.get('dataArray');
        var count = dataArray.length; // 只处理一个,不然太复杂

        var groupScale = this._getGroupScales()[0];

        if (groupScale) {
          var prefixLabel = substitute(prefix, {
            count: count
          });
          ariaLables.push(prefixLabel);
          each$1(dataArray, function (data, index) {
            var len = data.length;
            if (!len) return;
            var firstObj = data[0]._origin;

            if (len === 1) {
              ariaLables.push(substitute(oneData, {
                index: index + 1,
                count: len,
                name: firstObj[groupScale.field],
                values: firstObj[yScale.field]
              }));
            } else {
              var template = len > 5 ? partData : allData;
              var values = data.slice(0, 5).map(function (record) {
                var _origin = record._origin;
                var xValue = xScale.getText(_origin[xScale.field]);
                var yValue = yScale.getText(_origin[yScale.field]);
                return xValue + ":" + yValue;
              });
              ariaLables.push(substitute(template, {
                index: index + 1,
                count: len,
                part: 3,
                name: firstObj[groupScale.field],
                values: values.join(' ')
              }));
            }
          });
        }

        container.set('ariaLabel', ariaLables.join(''));
      }
      /**
       * get the info of each shape
       * @protected
       * @param  {Object} obj the data item
       * @return {Object} cfg return the result
       */
      ;

      _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
        var xScale = this.getXScale();
        var yScale = this.getYScale();

        var x = this._normalizeValues(obj[xScale.field], xScale);

        var y;

        if (yScale) {
          y = this._normalizeValues(obj[yScale.field], yScale);
        } else {
          y = obj.y ? obj.y : 0.1;
        }

        return {
          x: x,
          y: y,
          y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
        };
      };

      _proto.getYMinValue = function getYMinValue() {
        var yScale = this.getYScale();
        var min = yScale.min,
            max = yScale.max;
        var value;

        if (this.get('startOnZero')) {
          if (max <= 0 && min <= 0) {
            value = max;
          } else {
            value = min >= 0 ? min : 0;
          }
        } else {
          value = min;
        }

        return value;
      };

      _proto._normalizeValues = function _normalizeValues(values, scale) {
        var rst = [];

        if (isArray$1(values)) {
          for (var i = 0, len = values.length; i < len; i++) {
            var v = values[i];
            rst.push(scale.scale(v));
          }
        } else {
          rst = scale.scale(values);
        }

        return rst;
      };

      _proto.getAttr = function getAttr(name) {
        return this.get('attrs')[name];
      };

      _proto.getXScale = function getXScale() {
        return this.getAttr('position').scales[0];
      };

      _proto.getYScale = function getYScale() {
        return this.getAttr('position').scales[1];
      };

      _proto.hasAdjust = function hasAdjust(adjust) {
        return this.get('adjust') && this.get('adjust').type === adjust;
      };

      _proto._getSnap = function _getSnap(scale, item, arr) {
        var i = 0;
        var values;
        var yField = this.getYScale().field; // 叠加的维度

        if (this.hasAdjust('stack') && scale.field === yField) {
          values = [];
          arr.forEach(function (obj) {
            values.push(obj[FIELD_ORIGIN_Y]);
          });

          for (var len = values.length; i < len; i++) {
            if (values[0][0] > item) {
              break;
            }

            if (values[values.length - 1][1] <= item) {
              i = values.length - 1;
              break;
            }

            if (values[i][0] <= item && values[i][1] > item) {
              break;
            }
          }
        } else {
          values = scale.values;
          values.sort(function (a, b) {
            return a - b;
          });

          for (var _len2 = values.length; i < _len2; i++) {
            // 如果只有1个点直接返回第1个点
            if (_len2 <= 1) {
              break;
            } // 第1个点和第2个点之间


            if ((values[0] + values[1]) / 2 > item) {
              break;
            } // 中间的点


            if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
              break;
            } // 最后2个点


            if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
              i = values.length - 1;
              break;
            }
          }
        }

        var result = values[i];
        return result;
      };

      _proto.getSnapRecords = function getSnapRecords(point) {
        var self = this;
        var coord = self.get('coord');
        var xScale = self.getXScale();
        var yScale = self.getYScale();
        var xfield = xScale.field;
        var dataArray = self.get('dataArray');

        if (!this.get('hasSorted')) {
          this._sort(dataArray);
        }

        var rst = [];
        var invertPoint = coord.invertPoint(point);
        var invertPointX = invertPoint.x;

        if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
          invertPointX = xScale.rangeMin();
        }

        var xValue = xScale.invert(invertPointX);

        if (!xScale.isCategory) {
          xValue = self._getSnap(xScale, xValue);
        }

        var tmp = [];
        dataArray.forEach(function (data) {
          data.forEach(function (obj) {
            var originValue = isNil$1(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];

            if (self._isEqual(originValue, xValue, xScale)) {
              tmp.push(obj);
            }
          });
        }); // special for pie chart

        if (this.hasAdjust('stack') && coord.isPolar && coord.transposed) {
          if (invertPointX >= 0 && invertPointX <= 1) {
            var yValue = yScale.invert(invertPoint.y);
            yValue = self._getSnap(yScale, yValue, tmp);
            tmp.forEach(function (obj) {
              if (isArray$1(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
                rst.push(obj);
              }
            });
          }
        } else {
          rst = tmp;
        }

        return rst;
      };

      _proto.getRecords = function getRecords(value) {
        var _this = this;

        var xScale = this.getXScale();
        var dataArray = this.get('dataArray');
        var xfield = xScale.field;
        return dataArray.map(function (data) {
          for (var len = data.length, i = len - 1; i >= 0; i--) {
            var obj = data[i];
            var originValue = isNil$1(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];

            if (_this._isEqual(originValue, value, xScale)) {
              return obj;
            }
          }

          return null;
        });
      };

      _proto._isEqual = function _isEqual(originValue, value, scale) {
        if (scale.type === 'timeCat') {
          return toTimeStamp$1(originValue) === value;
        }

        return value === originValue;
      };

      _proto.position = function position(field) {
        this._setAttrOptions('position', {
          field: field
        });

        return this;
      };

      _proto.color = function color(field, values) {
        this._createAttrOption('color', field, values, Global.colors);

        return this;
      };

      _proto.size = function size(field, values) {
        this._createAttrOption('size', field, values, Global.sizes);

        return this;
      };

      _proto.shape = function shape(field, values) {
        var type = this.get('type');
        var shapes = Global.shapes[type] || [];

        this._createAttrOption('shape', field, values, shapes);

        return this;
      };

      _proto.style = function style(field, cfg) {
        var styleOptions = this.get('styleOptions');

        if (!styleOptions) {
          styleOptions = {};
          this.set('styleOptions', styleOptions);
        }

        if (isObject$1(field)) {
          cfg = field;
          field = null;
        }

        var fields;

        if (field) {
          fields = parseFields(field);
        }

        styleOptions.fields = fields;
        styleOptions.style = cfg;
        return this;
      };

      _proto.adjust = function adjust(type) {
        if (isString(type)) {
          type = {
            type: type
          };
        }

        this.set('adjust', type);
        return this;
      };

      _proto.animate = function animate(cfg) {
        this.set('animateCfg', cfg);
        return this;
      };

      _proto.changeData = function changeData(data) {
        this.set('data', data); // 改变数据后,情况度量,因为需要重新实例化

        this.set('scales', {});
        if (!this.get('isInit')) return;
        this.set('isInit', false);
        this.init();
      };

      _proto.clearInner = function clearInner() {
        var container = this.get('container');

        if (container) {
          container.clear(); // container.setMatrix([ 1, 0, 0, 1, 0, 0 ]);
        }
      };

      _proto.reset = function reset() {
        this.set('isInit', false);
        this.set('attrs', {});
        this.set('attrOptions', {});
        this.set('adjust', null);
        this.clearInner();
      };

      _proto.clear = function clear() {
        this.clearInner();
      };

      _proto.destroy = function destroy() {
        this.set('isInit', false);
        this.clear();

        _Base.prototype.destroy.call(this);
      };

      _proto._display = function _display(visible) {
        this.set('visible', visible);
        var container = this.get('container');
        var canvas = container.get('canvas');
        container.set('visible', visible);
        canvas.draw();
      };

      _proto.show = function show() {
        this._display(true);
      };

      _proto.hide = function hide() {
        this._display(false);
      };

      return Geom;
    }(Base$2);

    var methodCache = {};
    /**
     * 获取计算 ticks 的方法
     * @param key 键值
     * @returns 计算 ticks 的方法
     */

    function getTickMethod(key) {
      return methodCache[key];
    }
    /**
     * 注册计算 ticks 的方法
     * @param key 键值
     * @param method 方法
     */

    function registerTickMethod(key, method) {
      methodCache[key] = method;
    }

    var Scale = function () {
      function Scale(cfg) {
        /**
         * 度量的类型
         */
        this.type = 'base';
        /**
         * 是否分类类型的度量
         */

        this.isCategory = false;
        /**
         * 是否线性度量,有linear, time 度量
         */

        this.isLinear = false;
        /**
         * 是否连续类型的度量,linear,time,log, pow, quantile, quantize 都支持
         */

        this.isContinuous = false;
        /**
         * 是否是常量的度量,传入和传出一致
         */

        this.isIdentity = false;
        this.values = [];
        this.range = [0, 1];
        this.ticks = [];
        this.__cfg__ = cfg;
        this.initCfg();
        this.init();
      } // 对于原始值的必要转换,如分类、时间字段需转换成数值,用transform/map命名可能更好


      Scale.prototype.translate = function (v) {
        return v;
      };
      /** 重新初始化 */


      Scale.prototype.change = function (cfg) {
        // 覆盖配置项,而不替代
        mix$1(this.__cfg__, cfg);
        this.init();
      };

      Scale.prototype.clone = function () {
        return this.constructor(this.__cfg__);
      };
      /** 获取坐标轴需要的ticks */


      Scale.prototype.getTicks = function () {
        var _this = this;

        return map$1(this.ticks, function (tick, idx) {
          if (isObject$1(tick)) {
            // 仅当符合Tick类型时才有意义
            return tick;
          }

          return {
            text: _this.getText(tick, idx),
            tickValue: tick,
            value: _this.scale(tick)
          };
        });
      };
      /** 获取Tick的格式化结果 */


      Scale.prototype.getText = function (value, key) {
        var formatter = this.formatter;
        var res = formatter ? formatter(value, key) : value;

        if (isNil$1(res) || !isFunction$1(res.toString)) {
          return '';
        }

        return res.toString();
      }; // 获取配置项中的值,当前 scale 上的值可能会被修改


      Scale.prototype.getConfig = function (key) {
        return this.__cfg__[key];
      }; // scale初始化


      Scale.prototype.init = function () {
        mix$1(this, this.__cfg__);
        this.setDomain();

        if (isEmpty(this.getConfig('ticks'))) {
          this.ticks = this.calculateTicks();
        }
      }; // 子类上覆盖某些属性,不能直接在类上声明,否则会被覆盖


      Scale.prototype.initCfg = function () {};

      Scale.prototype.setDomain = function () {};

      Scale.prototype.calculateTicks = function () {
        var tickMethod = this.tickMethod;
        var ticks = [];

        if (isString(tickMethod)) {
          var method = getTickMethod(tickMethod);

          if (!method) {
            throw new Error('There is no method to to calculate ticks!');
          }

          ticks = method(this);
        } else if (isFunction$1(tickMethod)) {
          ticks = tickMethod(this);
        }

        return ticks;
      }; // range 的最小值


      Scale.prototype.rangeMin = function () {
        return this.range[0];
      }; // range 的最大值


      Scale.prototype.rangeMax = function () {
        return this.range[1];
      };
      /** 定义域转 0~1 */


      Scale.prototype.calcPercent = function (value, min, max) {
        if (isNumber(value)) {
          return (value - min) / (max - min);
        }

        return NaN;
      };
      /** 0~1转定义域 */


      Scale.prototype.calcValue = function (percent, min, max) {
        return min + percent * (max - min);
      };

      return Scale;
    }();

    /**
     * 分类度量
     * @class
     */

    var Category$1 = function (_super) {
      __extends(Category, _super);

      function Category() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'cat';
        _this.isCategory = true;
        return _this;
      }

      Category.prototype.buildIndexMap = function () {
        if (!this.translateIndexMap) {
          this.translateIndexMap = new Map(); // 重新构建缓存

          for (var i = 0; i < this.values.length; i++) {
            this.translateIndexMap.set(this.values[i], i);
          }
        }
      };

      Category.prototype.translate = function (value) {
        // 按需构建 map
        this.buildIndexMap(); // 找得到

        var idx = this.translateIndexMap.get(value);

        if (idx === undefined) {
          idx = isNumber(value) ? value : NaN;
        }

        return idx;
      };

      Category.prototype.scale = function (value) {
        var order = this.translate(value); // 分类数据允许 0.5 范围内调整
        // if (order < this.min - 0.5 || order > this.max + 0.5) {
        //   return NaN;
        // }

        var percent = this.calcPercent(order, this.min, this.max);
        return this.calcValue(percent, this.rangeMin(), this.rangeMax());
      };

      Category.prototype.invert = function (scaledValue) {
        var domainRange = this.max - this.min;
        var percent = this.calcPercent(scaledValue, this.rangeMin(), this.rangeMax());
        var idx = Math.round(domainRange * percent) + this.min;

        if (idx < this.min || idx > this.max) {
          return NaN;
        }

        return this.values[idx];
      };

      Category.prototype.getText = function (value) {
        var args = [];

        for (var _i = 1; _i < arguments.length; _i++) {
          args[_i - 1] = arguments[_i];
        }

        var v = value; // value为index

        if (isNumber(value) && !this.values.includes(value)) {
          v = this.values[v];
        }

        return _super.prototype.getText.apply(this, __spreadArrays([v], args));
      }; // 复写属性


      Category.prototype.initCfg = function () {
        this.tickMethod = 'cat';
      }; // 设置 min, max


      Category.prototype.setDomain = function () {
        // 用户有可能设置 min
        if (isNil$1(this.getConfig('min'))) {
          this.min = 0;
        }

        if (isNil$1(this.getConfig('max'))) {
          var size = this.values.length;
          this.max = size > 1 ? size - 1 : size;
        } // scale.init 的时候清除缓存


        if (this.translateIndexMap) {
          this.translateIndexMap = undefined;
        }
      };

      return Category;
    }(Scale);

    var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
    var twoDigitsOptional = "[1-9]\\d?";
    var twoDigits = "\\d\\d";
    var threeDigits = "\\d{3}";
    var fourDigits = "\\d{4}";
    var word = "[^\\s]+";
    var literal = /\[([^]*?)\]/gm;

    function shorten(arr, sLen) {
      var newArr = [];

      for (var i = 0, len = arr.length; i < len; i++) {
        newArr.push(arr[i].substr(0, sLen));
      }

      return newArr;
    }

    var monthUpdate = function (arrName) {
      return function (v, i18n) {
        var lowerCaseArr = i18n[arrName].map(function (v) {
          return v.toLowerCase();
        });
        var index = lowerCaseArr.indexOf(v.toLowerCase());

        if (index > -1) {
          return index;
        }

        return null;
      };
    };

    function assign(origObj) {
      var args = [];

      for (var _i = 1; _i < arguments.length; _i++) {
        args[_i - 1] = arguments[_i];
      }

      for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
        var obj = args_1[_a];

        for (var key in obj) {
          // @ts-ignore ex
          origObj[key] = obj[key];
        }
      }

      return origObj;
    }

    var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var monthNamesShort = shorten(monthNames, 3);
    var dayNamesShort = shorten(dayNames, 3);
    var defaultI18n = {
      dayNamesShort: dayNamesShort,
      dayNames: dayNames,
      monthNamesShort: monthNamesShort,
      monthNames: monthNames,
      amPm: ["am", "pm"],
      DoFn: function (dayOfMonth) {
        return dayOfMonth + ["th", "st", "nd", "rd"][dayOfMonth % 10 > 3 ? 0 : (dayOfMonth - dayOfMonth % 10 !== 10 ? 1 : 0) * dayOfMonth % 10];
      }
    };
    var globalI18n = assign({}, defaultI18n);

    var setGlobalDateI18n = function (i18n) {
      return globalI18n = assign(globalI18n, i18n);
    };

    var regexEscape = function (str) {
      return str.replace(/[|\\{()[^$+*?.-]/g, "\\$&");
    };

    var pad = function (val, len) {
      if (len === void 0) {
        len = 2;
      }

      val = String(val);

      while (val.length < len) {
        val = "0" + val;
      }

      return val;
    };

    var formatFlags = {
      D: function (dateObj) {
        return String(dateObj.getDate());
      },
      DD: function (dateObj) {
        return pad(dateObj.getDate());
      },
      Do: function (dateObj, i18n) {
        return i18n.DoFn(dateObj.getDate());
      },
      d: function (dateObj) {
        return String(dateObj.getDay());
      },
      dd: function (dateObj) {
        return pad(dateObj.getDay());
      },
      ddd: function (dateObj, i18n) {
        return i18n.dayNamesShort[dateObj.getDay()];
      },
      dddd: function (dateObj, i18n) {
        return i18n.dayNames[dateObj.getDay()];
      },
      M: function (dateObj) {
        return String(dateObj.getMonth() + 1);
      },
      MM: function (dateObj) {
        return pad(dateObj.getMonth() + 1);
      },
      MMM: function (dateObj, i18n) {
        return i18n.monthNamesShort[dateObj.getMonth()];
      },
      MMMM: function (dateObj, i18n) {
        return i18n.monthNames[dateObj.getMonth()];
      },
      YY: function (dateObj) {
        return pad(String(dateObj.getFullYear()), 4).substr(2);
      },
      YYYY: function (dateObj) {
        return pad(dateObj.getFullYear(), 4);
      },
      h: function (dateObj) {
        return String(dateObj.getHours() % 12 || 12);
      },
      hh: function (dateObj) {
        return pad(dateObj.getHours() % 12 || 12);
      },
      H: function (dateObj) {
        return String(dateObj.getHours());
      },
      HH: function (dateObj) {
        return pad(dateObj.getHours());
      },
      m: function (dateObj) {
        return String(dateObj.getMinutes());
      },
      mm: function (dateObj) {
        return pad(dateObj.getMinutes());
      },
      s: function (dateObj) {
        return String(dateObj.getSeconds());
      },
      ss: function (dateObj) {
        return pad(dateObj.getSeconds());
      },
      S: function (dateObj) {
        return String(Math.round(dateObj.getMilliseconds() / 100));
      },
      SS: function (dateObj) {
        return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
      },
      SSS: function (dateObj) {
        return pad(dateObj.getMilliseconds(), 3);
      },
      a: function (dateObj, i18n) {
        return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
      },
      A: function (dateObj, i18n) {
        return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
      },
      ZZ: function (dateObj) {
        var offset = dateObj.getTimezoneOffset();
        return (offset > 0 ? "-" : "+") + pad(Math.floor(Math.abs(offset) / 60) * 100 + Math.abs(offset) % 60, 4);
      },
      Z: function (dateObj) {
        var offset = dateObj.getTimezoneOffset();
        return (offset > 0 ? "-" : "+") + pad(Math.floor(Math.abs(offset) / 60), 2) + ":" + pad(Math.abs(offset) % 60, 2);
      }
    };

    var monthParse = function (v) {
      return +v - 1;
    };

    var emptyDigits = [null, twoDigitsOptional];
    var emptyWord = [null, word];
    var amPm = ["isPm", word, function (v, i18n) {
      var val = v.toLowerCase();

      if (val === i18n.amPm[0]) {
        return 0;
      } else if (val === i18n.amPm[1]) {
        return 1;
      }

      return null;
    }];
    var timezoneOffset = ["timezoneOffset", "[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?", function (v) {
      var parts = (v + "").match(/([+-]|\d\d)/gi);

      if (parts) {
        var minutes = +parts[1] * 60 + parseInt(parts[2], 10);
        return parts[0] === "+" ? minutes : -minutes;
      }

      return 0;
    }];
    var parseFlags = {
      D: ["day", twoDigitsOptional],
      DD: ["day", twoDigits],
      Do: ["day", twoDigitsOptional + word, function (v) {
        return parseInt(v, 10);
      }],
      M: ["month", twoDigitsOptional, monthParse],
      MM: ["month", twoDigits, monthParse],
      YY: ["year", twoDigits, function (v) {
        var now = new Date();
        var cent = +("" + now.getFullYear()).substr(0, 2);
        return +("" + (+v > 68 ? cent - 1 : cent) + v);
      }],
      h: ["hour", twoDigitsOptional, undefined, "isPm"],
      hh: ["hour", twoDigits, undefined, "isPm"],
      H: ["hour", twoDigitsOptional],
      HH: ["hour", twoDigits],
      m: ["minute", twoDigitsOptional],
      mm: ["minute", twoDigits],
      s: ["second", twoDigitsOptional],
      ss: ["second", twoDigits],
      YYYY: ["year", fourDigits],
      S: ["millisecond", "\\d", function (v) {
        return +v * 100;
      }],
      SS: ["millisecond", twoDigits, function (v) {
        return +v * 10;
      }],
      SSS: ["millisecond", threeDigits],
      d: emptyDigits,
      dd: emptyDigits,
      ddd: emptyWord,
      dddd: emptyWord,
      MMM: ["month", word, monthUpdate("monthNamesShort")],
      MMMM: ["month", word, monthUpdate("monthNames")],
      a: amPm,
      A: amPm,
      ZZ: timezoneOffset,
      Z: timezoneOffset
    }; // Some common format strings

    var globalMasks = {
      default: "ddd MMM DD YYYY HH:mm:ss",
      shortDate: "M/D/YY",
      mediumDate: "MMM D, YYYY",
      longDate: "MMMM D, YYYY",
      fullDate: "dddd, MMMM D, YYYY",
      isoDate: "YYYY-MM-DD",
      isoDateTime: "YYYY-MM-DDTHH:mm:ssZ",
      shortTime: "HH:mm",
      mediumTime: "HH:mm:ss",
      longTime: "HH:mm:ss.SSS"
    };

    var setGlobalDateMasks = function (masks) {
      return assign(globalMasks, masks);
    };
    /***
     * Format a date
     * @method format
     * @param {Date|number} dateObj
     * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
     * @returns {string} Formatted date string
     */


    var format = function (dateObj, mask, i18n) {
      if (mask === void 0) {
        mask = globalMasks["default"];
      }

      if (i18n === void 0) {
        i18n = {};
      }

      if (typeof dateObj === "number") {
        dateObj = new Date(dateObj);
      }

      if (Object.prototype.toString.call(dateObj) !== "[object Date]" || isNaN(dateObj.getTime())) {
        throw new Error("Invalid Date pass to format");
      }

      mask = globalMasks[mask] || mask;
      var literals = []; // Make literals inactive by replacing them with @@@

      mask = mask.replace(literal, function ($0, $1) {
        literals.push($1);
        return "@@@";
      });
      var combinedI18nSettings = assign(assign({}, globalI18n), i18n); // Apply formatting rules

      mask = mask.replace(token, function ($0) {
        return formatFlags[$0](dateObj, combinedI18nSettings);
      }); // Inline literal values back into the formatted value

      return mask.replace(/@@@/g, function () {
        return literals.shift();
      });
    };
    /**
     * Parse a date string into a Javascript Date object /
     * @method parse
     * @param {string} dateStr Date string
     * @param {string} format Date parse format
     * @param {i18n} I18nSettingsOptional Full or subset of I18N settings
     * @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
     */


    function parse(dateStr, format, i18n) {
      if (i18n === void 0) {
        i18n = {};
      }

      if (typeof format !== "string") {
        throw new Error("Invalid format in fecha parse");
      } // Check to see if the format is actually a mask


      format = globalMasks[format] || format; // Avoid regular expression denial of service, fail early for really long strings
      // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS

      if (dateStr.length > 1000) {
        return null;
      } // Default to the beginning of the year.


      var today = new Date();
      var dateInfo = {
        year: today.getFullYear(),
        month: 0,
        day: 1,
        hour: 0,
        minute: 0,
        second: 0,
        millisecond: 0,
        isPm: null,
        timezoneOffset: null
      };
      var parseInfo = [];
      var literals = []; // Replace all the literals with @@@. Hopefully a string that won't exist in the format

      var newFormat = format.replace(literal, function ($0, $1) {
        literals.push(regexEscape($1));
        return "@@@";
      });
      var specifiedFields = {};
      var requiredFields = {}; // Change every token that we find into the correct regex

      newFormat = regexEscape(newFormat).replace(token, function ($0) {
        var info = parseFlags[$0];
        var field = info[0],
            regex = info[1],
            requiredField = info[3]; // Check if the person has specified the same field twice. This will lead to confusing results.

        if (specifiedFields[field]) {
          throw new Error("Invalid format. " + field + " specified twice in format");
        }

        specifiedFields[field] = true; // Check if there are any required fields. For instance, 12 hour time requires AM/PM specified

        if (requiredField) {
          requiredFields[requiredField] = true;
        }

        parseInfo.push(info);
        return "(" + regex + ")";
      }); // Check all the required fields are present

      Object.keys(requiredFields).forEach(function (field) {
        if (!specifiedFields[field]) {
          throw new Error("Invalid format. " + field + " is required in specified format");
        }
      }); // Add back all the literals after

      newFormat = newFormat.replace(/@@@/g, function () {
        return literals.shift();
      }); // Check if the date string matches the format. If it doesn't return null

      var matches = dateStr.match(new RegExp(newFormat, "i"));

      if (!matches) {
        return null;
      }

      var combinedI18nSettings = assign(assign({}, globalI18n), i18n); // For each match, call the parser function for that date part

      for (var i = 1; i < matches.length; i++) {
        var _a = parseInfo[i - 1],
            field = _a[0],
            parser = _a[2];
        var value = parser ? parser(matches[i], combinedI18nSettings) : +matches[i]; // If the parser can't make sense of the value, return null

        if (value == null) {
          return null;
        }

        dateInfo[field] = value;
      }

      if (dateInfo.isPm === 1 && dateInfo.hour != null && +dateInfo.hour !== 12) {
        dateInfo.hour = +dateInfo.hour + 12;
      } else if (dateInfo.isPm === 0 && +dateInfo.hour === 12) {
        dateInfo.hour = 0;
      }

      var dateWithoutTZ = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
      var validateFields = [["month", "getMonth"], ["day", "getDate"], ["hour", "getHours"], ["minute", "getMinutes"], ["second", "getSeconds"]];

      for (var i = 0, len = validateFields.length; i < len; i++) {
        // Check to make sure the date field is within the allowed range. Javascript dates allows values
        // outside the allowed range. If the values don't match the value was invalid
        if (specifiedFields[validateFields[i][0]] && dateInfo[validateFields[i][0]] !== dateWithoutTZ[validateFields[i][1]]()) {
          return null;
        }
      }

      if (dateInfo.timezoneOffset == null) {
        return dateWithoutTZ;
      }

      return new Date(Date.UTC(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute - dateInfo.timezoneOffset, dateInfo.second, dateInfo.millisecond));
    }

    var fecha = {
      format: format,
      parse: parse,
      defaultI18n: defaultI18n,
      setGlobalDateI18n: setGlobalDateI18n,
      setGlobalDateMasks: setGlobalDateMasks
    };

    var fecha1 = /*#__PURE__*/Object.freeze({
        __proto__: null,
        'default': fecha,
        assign: assign,
        format: format,
        parse: parse,
        defaultI18n: defaultI18n,
        setGlobalDateI18n: setGlobalDateI18n,
        setGlobalDateMasks: setGlobalDateMasks
    });

    /**
     * 二分右侧查找
     * https://github.com/d3/d3-array/blob/master/src/bisector.js
     */

    function bisector (getter) {
      /**
       * x: 目标值
       * lo: 起始位置
       * hi: 结束位置
       */
      return function (a, x, _lo, _hi) {
        var lo = isNil$1(_lo) ? 0 : _lo;
        var hi = isNil$1(_hi) ? a.length : _hi;

        while (lo < hi) {
          var mid = lo + hi >>> 1;

          if (getter(a[mid]) > x) {
            hi = mid;
          } else {
            lo = mid + 1;
          }
        }

        return lo;
      };
    }

    var FORMAT_METHOD = 'format';
    function timeFormat(time, mask) {
      var method = fecha1[FORMAT_METHOD] || fecha[FORMAT_METHOD];
      return method(time, mask);
    }
    /**
     * 转换成时间戳
     * @param value 时间值
     */

    function toTimeStamp(value) {
      if (isString(value)) {
        if (value.indexOf('T') > 0) {
          value = new Date(value).getTime();
        } else {
          // new Date('2010/01/10') 和 new Date('2010-01-10') 的差别在于:
          // 如果仅有年月日时,前者是带有时区的: Fri Jan 10 2020 02:40:13 GMT+0800 (中国标准时间)
          // 后者会格式化成 Sun Jan 10 2010 08:00:00 GMT+0800 (中国标准时间)
          value = new Date(value.replace(/-/gi, '/')).getTime();
        }
      }

      if (isDate(value)) {
        value = value.getTime();
      }

      return value;
    }
    var SECOND = 1000;
    var MINUTE = 60 * SECOND;
    var HOUR = 60 * MINUTE;
    var DAY = 24 * HOUR;
    var MONTH = DAY * 31;
    var YEAR = DAY * 365;
    var intervals = [['HH:mm:ss', SECOND], ['HH:mm:ss', SECOND * 10], ['HH:mm:ss', SECOND * 30], ['HH:mm', MINUTE], ['HH:mm', MINUTE * 10], ['HH:mm', MINUTE * 30], ['HH', HOUR], ['HH', HOUR * 6], ['HH', HOUR * 12], ['YYYY-MM-DD', DAY], ['YYYY-MM-DD', DAY * 4], ['YYYY-WW', DAY * 7], ['YYYY-MM', MONTH], ['YYYY-MM', MONTH * 4], ['YYYY-MM', MONTH * 6], ['YYYY', DAY * 380]];
    function getTickInterval(min, max, tickCount) {
      var target = (max - min) / tickCount;
      var idx = bisector(function (o) {
        return o[1];
      })(intervals, target) - 1;
      var interval = intervals[idx];

      if (idx < 0) {
        interval = intervals[0];
      } else if (idx >= intervals.length) {
        interval = last(intervals);
      }

      return interval;
    }

    /**
     * 时间分类度量
     * @class
     */

    var TimeCat$1 = function (_super) {
      __extends(TimeCat, _super);

      function TimeCat() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'timeCat';
        return _this;
      }
      /**
       * @override
       */


      TimeCat.prototype.translate = function (value) {
        value = toTimeStamp(value);
        var index = this.values.indexOf(value);

        if (index === -1) {
          if (isNumber(value) && value < this.values.length) {
            index = value;
          } else {
            index = NaN;
          }
        }

        return index;
      };
      /**
       * 由于时间类型数据需要转换一下,所以复写 getText
       * @override
       */


      TimeCat.prototype.getText = function (value, tickIndex) {
        var index = this.translate(value);

        if (index > -1) {
          var result = this.values[index];
          var formatter = this.formatter;
          result = formatter ? formatter(result, tickIndex) : timeFormat(result, this.mask);
          return result;
        }

        return value;
      };

      TimeCat.prototype.initCfg = function () {
        this.tickMethod = 'time-cat';
        this.mask = 'YYYY-MM-DD';
        this.tickCount = 7; // 一般时间数据会显示 7, 14, 30 天的数字
      };

      TimeCat.prototype.setDomain = function () {
        var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳

        each$1(values, function (v, i) {
          values[i] = toTimeStamp(v);
        });
        values.sort(function (v1, v2) {
          return v1 - v2;
        });

        _super.prototype.setDomain.call(this);
      };

      return TimeCat;
    }(Category$1);

    /**
     * 连续度量的基类
     * @class
     */

    var Continuous = function (_super) {
      __extends(Continuous, _super);

      function Continuous() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.isContinuous = true;
        return _this;
      }

      Continuous.prototype.scale = function (value) {
        if (isNil$1(value)) {
          return NaN;
        }

        var rangeMin = this.rangeMin();
        var rangeMax = this.rangeMax();
        var max = this.max;
        var min = this.min;

        if (max === min) {
          return rangeMin;
        }

        var percent = this.getScalePercent(value);
        return rangeMin + percent * (rangeMax - rangeMin);
      };

      Continuous.prototype.init = function () {
        _super.prototype.init.call(this); // init 完成后保证 min, max 包含 ticks 的范围


        var ticks = this.ticks;
        var firstTick = head(ticks);
        var lastTick = last(ticks);

        if (firstTick < this.min) {
          this.min = firstTick;
        }

        if (lastTick > this.max) {
          this.max = lastTick;
        } // strict-limit 方式


        if (!isNil$1(this.minLimit)) {
          this.min = firstTick;
        }

        if (!isNil$1(this.maxLimit)) {
          this.max = lastTick;
        }
      };

      Continuous.prototype.setDomain = function () {
        var _a = getRange$1(this.values),
            min = _a.min,
            max = _a.max;

        if (isNil$1(this.min)) {
          this.min = min;
        }

        if (isNil$1(this.max)) {
          this.max = max;
        }

        if (this.min > this.max) {
          this.min = min;
          this.max = max;
        }
      };

      Continuous.prototype.calculateTicks = function () {
        var _this = this;

        var ticks = _super.prototype.calculateTicks.call(this);

        if (!this.nice) {
          ticks = filter(ticks, function (tick) {
            return tick >= _this.min && tick <= _this.max;
          });
        }

        return ticks;
      }; // 计算原始值值占的百分比


      Continuous.prototype.getScalePercent = function (value) {
        var max = this.max;
        var min = this.min;
        return (value - min) / (max - min);
      };

      Continuous.prototype.getInvertPercent = function (value) {
        return (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
      };

      return Continuous;
    }(Scale);

    /**
     * 线性度量
     * @class
     */

    var Linear$1 = function (_super) {
      __extends(Linear, _super);

      function Linear() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'linear';
        _this.isLinear = true;
        return _this;
      }

      Linear.prototype.invert = function (value) {
        var percent = this.getInvertPercent(value);
        return this.min + percent * (this.max - this.min);
      };

      Linear.prototype.initCfg = function () {
        this.tickMethod = 'wilkinson-extended';
        this.nice = false;
      };

      return Linear;
    }(Continuous);

    // 虽然数学上 b 不支持负数,但是这里需要支持 负数

    function calBase(a, b) {
      var e = Math.E;
      var value;

      if (b >= 0) {
        value = Math.pow(e, Math.log(b) / a); // 使用换底公式求底
      } else {
        value = Math.pow(e, Math.log(-b) / a) * -1; // 使用换底公式求底
      }

      return value;
    }
    function log(a, b) {
      if (a === 1) {
        return 1;
      }

      return Math.log(b) / Math.log(a);
    }
    function getLogPositiveMin(values, base, max) {
      if (isNil$1(max)) {
        max = Math.max.apply(null, values);
      }

      var positiveMin = max;
      each$1(values, function (value) {
        if (value > 0 && value < positiveMin) {
          positiveMin = value;
        }
      });

      if (positiveMin === max) {
        positiveMin = max / base;
      }

      if (positiveMin > 1) {
        positiveMin = 1;
      }

      return positiveMin;
    }

    /**
     * Log 度量,处理非均匀分布
     */

    var Log = function (_super) {
      __extends(Log, _super);

      function Log() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'log';
        return _this;
      }
      /**
       * @override
       */


      Log.prototype.invert = function (value) {
        var base = this.base;
        var max = log(base, this.max);
        var rangeMin = this.rangeMin();
        var range = this.rangeMax() - rangeMin;
        var min;
        var positiveMin = this.positiveMin;

        if (positiveMin) {
          if (value === 0) {
            return 0;
          }

          min = log(base, positiveMin / base);
          var appendPercent = 1 / (max - min) * range; // 0 到 positiveMin的占比

          if (value < appendPercent) {
            // 落到 0 - positiveMin 之间
            return value / appendPercent * positiveMin;
          }
        } else {
          min = log(base, this.min);
        }

        var percent = (value - rangeMin) / range;
        var tmp = percent * (max - min) + min;
        return Math.pow(base, tmp);
      };

      Log.prototype.initCfg = function () {
        this.tickMethod = 'log';
        this.base = 10;
        this.tickCount = 6;
        this.nice = true;
      }; // 设置


      Log.prototype.setDomain = function () {
        _super.prototype.setDomain.call(this);

        var min = this.min;

        if (min < 0) {
          throw new Error('When you use log scale, the minimum value must be greater than zero!');
        }

        if (min === 0) {
          this.positiveMin = getLogPositiveMin(this.values, this.base, this.max);
        }
      }; // 根据当前值获取占比


      Log.prototype.getScalePercent = function (value) {
        var max = this.max;
        var min = this.min;

        if (max === min) {
          return 0;
        } // 如果值小于等于0,则按照0处理


        if (value <= 0) {
          return 0;
        }

        var base = this.base;
        var positiveMin = this.positiveMin; // 如果min == 0, 则根据比0大的最小值,计算比例关系。这个最小值作为坐标轴上的第二个tick,第一个是0但是不显示

        if (positiveMin) {
          min = positiveMin * 1 / base;
        }

        var percent; // 如果数值小于次小值,那么就计算 value / 次小值 占整体的比例

        if (value < positiveMin) {
          percent = value / positiveMin / (log(base, max) - log(base, min));
        } else {
          percent = (log(base, value) - log(base, min)) / (log(base, max) - log(base, min));
        }

        return percent;
      };

      return Log;
    }(Continuous);

    /**
     * Pow 度量,处理非均匀分布
     */

    var Pow = function (_super) {
      __extends(Pow, _super);

      function Pow() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'pow';
        return _this;
      }
      /**
       * @override
       */


      Pow.prototype.invert = function (value) {
        var percent = this.getInvertPercent(value);
        var exponent = this.exponent;
        var max = calBase(exponent, this.max);
        var min = calBase(exponent, this.min);
        var tmp = percent * (max - min) + min;
        var factor = tmp >= 0 ? 1 : -1;
        return Math.pow(tmp, exponent) * factor;
      };

      Pow.prototype.initCfg = function () {
        this.tickMethod = 'pow';
        this.exponent = 2;
        this.tickCount = 5;
        this.nice = true;
      }; // 获取度量计算时,value占的定义域百分比


      Pow.prototype.getScalePercent = function (value) {
        var max = this.max;
        var min = this.min;

        if (max === min) {
          return 0;
        }

        var exponent = this.exponent;
        var percent = (calBase(exponent, value) - calBase(exponent, min)) / (calBase(exponent, max) - calBase(exponent, min));
        return percent;
      };

      return Pow;
    }(Continuous);

    /**
     * 时间度量
     * @class
     */

    var Time = function (_super) {
      __extends(Time, _super);

      function Time() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'time';
        return _this;
      }
      /**
       * @override
       */


      Time.prototype.getText = function (value, index) {
        var numberValue = this.translate(value);
        var formatter = this.formatter;
        return formatter ? formatter(numberValue, index) : timeFormat(numberValue, this.mask);
      };
      /**
       * @override
       */


      Time.prototype.scale = function (value) {
        var v = value;

        if (isString(v) || isDate(v)) {
          v = this.translate(v);
        }

        return _super.prototype.scale.call(this, v);
      };
      /**
       * 将时间转换成数字
       * @override
       */


      Time.prototype.translate = function (v) {
        return toTimeStamp(v);
      };

      Time.prototype.initCfg = function () {
        this.tickMethod = 'time-pretty';
        this.mask = 'YYYY-MM-DD';
        this.tickCount = 7;
        this.nice = false;
      };

      Time.prototype.setDomain = function () {
        var values = this.values; // 是否设置了 min, max,而不是直接取 this.min, this.max

        var minConfig = this.getConfig('min');
        var maxConfig = this.getConfig('max'); // 如果设置了 min,max 则转换成时间戳

        if (!isNil$1(minConfig) || !isNumber(minConfig)) {
          this.min = this.translate(this.min);
        }

        if (!isNil$1(maxConfig) || !isNumber(maxConfig)) {
          this.max = this.translate(this.max);
        } // 没有设置 min, max 时


        if (values && values.length) {
          // 重新计算最大最小值
          var timeStamps_1 = [];
          var min_1 = Infinity; // 最小值

          var secondMin_1 = min_1; // 次小值

          var max_1 = 0; // 使用一个循环,计算min,max,secondMin

          each$1(values, function (v) {
            var timeStamp = toTimeStamp(v);

            if (isNaN(timeStamp)) {
              throw new TypeError("Invalid Time: " + v + " in time scale!");
            }

            if (min_1 > timeStamp) {
              secondMin_1 = min_1;
              min_1 = timeStamp;
            } else if (secondMin_1 > timeStamp) {
              secondMin_1 = timeStamp;
            }

            if (max_1 < timeStamp) {
              max_1 = timeStamp;
            }

            timeStamps_1.push(timeStamp);
          }); // 存在多个值时,设置最小间距

          if (values.length > 1) {
            this.minTickInterval = secondMin_1 - min_1;
          }

          if (isNil$1(minConfig)) {
            this.min = min_1;
          }

          if (isNil$1(maxConfig)) {
            this.max = max_1;
          }
        }
      };

      return Time;
    }(Linear$1);

    /**
     * 分段度量
     */

    var Quantize = function (_super) {
      __extends(Quantize, _super);

      function Quantize() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'quantize';
        return _this;
      }

      Quantize.prototype.invert = function (value) {
        var ticks = this.ticks;
        var length = ticks.length;
        var percent = this.getInvertPercent(value);
        var minIndex = Math.floor(percent * (length - 1)); // 最后一个

        if (minIndex >= length - 1) {
          return last(ticks);
        } // 超出左边界, 则取第一个


        if (minIndex < 0) {
          return head(ticks);
        }

        var minTick = ticks[minIndex];
        var nextTick = ticks[minIndex + 1]; // 比当前值小的 tick 在度量上的占比

        var minIndexPercent = minIndex / (length - 1);
        var maxIndexPercent = (minIndex + 1) / (length - 1);
        return minTick + (percent - minIndexPercent) / (maxIndexPercent - minIndexPercent) * (nextTick - minTick);
      };

      Quantize.prototype.initCfg = function () {
        this.tickMethod = 'r-pretty';
        this.tickCount = 5;
        this.nice = true;
      };

      Quantize.prototype.calculateTicks = function () {
        var ticks = _super.prototype.calculateTicks.call(this);

        if (!this.nice) {
          // 如果 nice = false ,补充 min, max
          if (last(ticks) !== this.max) {
            ticks.push(this.max);
          }

          if (head(ticks) !== this.min) {
            ticks.unshift(this.min);
          }
        }

        return ticks;
      }; // 计算当前值在刻度中的占比


      Quantize.prototype.getScalePercent = function (value) {
        var ticks = this.ticks; // 超出左边界

        if (value < head(ticks)) {
          return 0;
        } // 超出右边界


        if (value > last(ticks)) {
          return 1;
        }

        var minIndex = 0;
        each$1(ticks, function (tick, index) {
          if (value >= tick) {
            minIndex = index;
          } else {
            return false;
          }
        });
        return minIndex / (ticks.length - 1);
      };

      return Quantize;
    }(Continuous);

    var Quantile = function (_super) {
      __extends(Quantile, _super);

      function Quantile() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'quantile';
        return _this;
      }

      Quantile.prototype.initCfg = function () {
        this.tickMethod = 'quantile';
        this.tickCount = 5;
        this.nice = true;
      };

      return Quantile;
    }(Quantize);

    var map = {};

    function getClass(key) {
      return map[key];
    }

    function registerClass(key, cls) {
      if (getClass(key)) {
        throw new Error("type '" + key + "' existed.");
      }

      map[key] = cls;
    }

    /**
     * identity scale原则上是定义域和值域一致,scale/invert方法也是一致的
     * 参考R的实现:https://github.com/r-lib/scales/blob/master/R/pal-identity.r
     * 参考d3的实现(做了下转型):https://github.com/d3/d3-scale/blob/master/src/identity.js
     */

    var Identity$1 = function (_super) {
      __extends(Identity, _super);

      function Identity() {
        var _this = _super !== null && _super.apply(this, arguments) || this;

        _this.type = 'identity';
        _this.isIdentity = true;
        return _this;
      }

      Identity.prototype.calculateTicks = function () {
        return this.values;
      };

      Identity.prototype.scale = function (value) {
        // 如果传入的值不等于 identity 的值,则直接返回,用于一维图时的 dodge
        if (this.values[0] !== value && isNumber(value)) {
          return value;
        }

        return this.range[0];
      };

      Identity.prototype.invert = function (value) {
        var range = this.range;

        if (value < range[0] || value > range[1]) {
          return NaN;
        }

        return this.values[0];
      };

      return Identity;
    }(Scale);

    var DEFAULT_Q = [1, 5, 2, 2.5, 4, 3];
    var eps = Number.EPSILON * 100;

    function mod(n, m) {
      return (n % m + m) % m;
    }

    function simplicity(q, Q, j, lmin, lmax, lstep) {
      var n = size(Q);
      var i = indexOf(Q, q);
      var v = 0;
      var m = mod(lmin, lstep);

      if ((m < eps || lstep - m < eps) && lmin <= 0 && lmax >= 0) {
        v = 1;
      }

      return 1 - i / (n - 1) - j + v;
    }

    function simplicityMax(q, Q, j) {
      var n = size(Q);
      var i = indexOf(Q, q);
      var v = 1;
      return 1 - i / (n - 1) - j + v;
    }

    function density(k, m, dMin, dMax, lMin, lMax) {
      var r = (k - 1) / (lMax - lMin);
      var rt = (m - 1) / (Math.max(lMax, dMax) - Math.min(dMin, lMin));
      return 2 - Math.max(r / rt, rt / r);
    }

    function densityMax(k, m) {
      if (k >= m) {
        return 2 - (k - 1) / (m - 1);
      }

      return 1;
    }

    function coverage(dMin, dMax, lMin, lMax) {
      var range = dMax - dMin;
      return 1 - 0.5 * (Math.pow(dMax - lMax, 2) + Math.pow(dMin - lMin, 2)) / Math.pow(0.1 * range, 2);
    }

    function coverageMax(dMin, dMax, span) {
      var range = dMax - dMin;

      if (span > range) {
        var half = (span - range) / 2;
        return 1 - Math.pow(half, 2) / Math.pow(0.1 * range, 2);
      }

      return 1;
    }

    function legibility() {
      return 1;
    } // 解决 js 计算精度问题


    function prettyNumber$1(n) {
      return n < 1e-15 ? n : parseFloat(n.toFixed(15));
    }
    /**
     * An Extension of Wilkinson's Algorithm for Position Tick Labels on Axes
     * https://www.yuque.com/preview/yuque/0/2019/pdf/185317/1546999150858-45c3b9c2-4e86-4223-bf1a-8a732e8195ed.pdf
     * @param dMin 最小值
     * @param dMax 最大值
     * @param m tick个数
     * @param onlyLoose 是否允许扩展min、max,不绝对强制,例如[3, 97]
     * @param Q nice numbers集合
     * @param w 四个优化组件的权重
     */


    function extended(dMin, dMax, m, onlyLoose, Q, w) {
      if (m === void 0) {
        m = 5;
      }

      if (onlyLoose === void 0) {
        onlyLoose = true;
      }

      if (Q === void 0) {
        Q = DEFAULT_Q;
      }

      if (w === void 0) {
        w = [0.25, 0.2, 0.5, 0.05];
      } // nan 也会导致异常


      if (Number.isNaN(dMin) || Number.isNaN(dMax) || typeof dMin !== 'number' || typeof dMax !== 'number' || !m) {
        return {
          min: 0,
          max: 0,
          ticks: []
        };
      } // js 极大值极小值问题,差值小于 1e-15 会导致计算出错


      if (dMax - dMin < 1e-15 || m === 1) {
        return {
          min: dMin,
          max: dMax,
          ticks: [dMin]
        };
      }

      var best = {
        score: -2,
        lmin: 0,
        lmax: 0,
        lstep: 0
      };
      var j = 1;

      while (j < Infinity) {
        for (var i = 0; i < Q.length; i += 1) {
          var q = Q[i];
          var sm = simplicityMax(q, Q, j);

          if (w[0] * sm + w[1] + w[2] + w[3] < best.score) {
            j = Infinity;
            break;
          }

          var k = 2;

          while (k < Infinity) {
            var dm = densityMax(k, m);

            if (w[0] * sm + w[1] + w[2] * dm + w[3] < best.score) {
              break;
            }

            var delta = (dMax - dMin) / (k + 1) / j / q;
            var z = Math.ceil(Math.log10(delta));

            while (z < Infinity) {
              var step = j * q * Math.pow(10, z);
              var cm = coverageMax(dMin, dMax, step * (k - 1));

              if (w[0] * sm + w[1] * cm + w[2] * dm + w[3] < best.score) {
                break;
              }

              var minStart = Math.floor(dMax / step) * j - (k - 1) * j;
              var maxStart = Math.ceil(dMin / step) * j;

              if (minStart <= maxStart) {
                var count = maxStart - minStart;

                for (var i_1 = 0; i_1 <= count; i_1 += 1) {
                  var start = minStart + i_1;
                  var lMin = start * (step / j);
                  var lMax = lMin + step * (k - 1);
                  var lStep = step;
                  var s = simplicity(q, Q, j, lMin, lMax, lStep);
                  var c = coverage(dMin, dMax, lMin, lMax);
                  var g = density(k, m, dMin, dMax, lMin, lMax);
                  var l = legibility();
                  var score = w[0] * s + w[1] * c + w[2] * g + w[3] * l;

                  if (score > best.score && (!onlyLoose || lMin <= dMin && lMax >= dMax)) {
                    best.lmin = lMin;
                    best.lmax = lMax;
                    best.lstep = lStep;
                    best.score = score;
                  }
                }
              }

              z += 1;
            }

            k += 1;
          }
        }

        j += 1;
      }

      var lmax = best.lmax,
          lmin = best.lmin,
          lstep = best.lstep;
      var tickCount = Math.floor((lmax - lmin) / lstep) + 1;
      var ticks = new Array(tickCount);

      for (var i = 0; i < tickCount; i++) {
        ticks[i] = prettyNumber$1(lmin + i * lstep);
      }

      return {
        min: Math.min(dMin, head(ticks)),
        max: Math.max(dMax, last(ticks)),
        ticks: ticks
      };
    }

    /**
     * 计算分类 ticks
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function calculateCatTicks(cfg) {
      var values = cfg.values,
          tickInterval = cfg.tickInterval,
          tickCount = cfg.tickCount;
      var ticks = values;

      if (isNumber(tickInterval)) {
        return filter(ticks, function (__, i) {
          return i % tickInterval === 0;
        });
      }

      var min = cfg.min,
          max = cfg.max;

      if (isNil$1(min)) {
        min = 0;
      }

      if (isNil$1(max)) {
        max = values.length - 1;
      }

      if (isNumber(tickCount) && tickCount < max - min) {
        // 简单过滤,部分情况下小数的倍数也可以是整数
        // tslint:disable-next-line: no-shadowed-variable
        var ticks_1 = extended(min, max, tickCount, false, [1, 2, 5, 3, 4, 7, 6, 8, 9]).ticks;
        var valid = filter(ticks_1, function (tick) {
          return tick >= min && tick <= max;
        });
        return valid.map(function (index) {
          return values[index];
        });
      }

      return values.slice(min, max + 1);
    }

    function d3Linear(cfg) {
      var min = cfg.min,
          max = cfg.max,
          nice = cfg.nice,
          tickCount = cfg.tickCount;
      var linear = new D3Linear();
      linear.domain([min, max]);

      if (nice) {
        linear.nice(tickCount);
      }

      return linear.ticks(tickCount);
    }
    var DEFAULT_COUNT$1 = 5;
    var e10 = Math.sqrt(50);
    var e5 = Math.sqrt(10);
    var e2 = Math.sqrt(2); // https://github.com/d3/d3-scale

    var D3Linear = function () {
      function D3Linear() {
        this._domain = [0, 1];
      }

      D3Linear.prototype.domain = function (domain) {
        if (domain) {
          this._domain = Array.from(domain, Number);
          return this;
        }

        return this._domain.slice();
      };

      D3Linear.prototype.nice = function (count) {
        var _a, _b;

        if (count === void 0) {
          count = DEFAULT_COUNT$1;
        }

        var d = this._domain.slice();

        var i0 = 0;
        var i1 = this._domain.length - 1;
        var start = this._domain[i0];
        var stop = this._domain[i1];
        var step;

        if (stop < start) {
          _a = [stop, start], start = _a[0], stop = _a[1];
          _b = [i1, i0], i0 = _b[0], i1 = _b[1];
        }

        step = tickIncrement(start, stop, count);

        if (step > 0) {
          start = Math.floor(start / step) * step;
          stop = Math.ceil(stop / step) * step;
          step = tickIncrement(start, stop, count);
        } else if (step < 0) {
          start = Math.ceil(start * step) / step;
          stop = Math.floor(stop * step) / step;
          step = tickIncrement(start, stop, count);
        }

        if (step > 0) {
          d[i0] = Math.floor(start / step) * step;
          d[i1] = Math.ceil(stop / step) * step;
          this.domain(d);
        } else if (step < 0) {
          d[i0] = Math.ceil(start * step) / step;
          d[i1] = Math.floor(stop * step) / step;
          this.domain(d);
        }

        return this;
      };

      D3Linear.prototype.ticks = function (count) {
        if (count === void 0) {
          count = DEFAULT_COUNT$1;
        }

        return d3ArrayTicks(this._domain[0], this._domain[this._domain.length - 1], count || DEFAULT_COUNT$1);
      };

      return D3Linear;
    }();

    function d3ArrayTicks(start, stop, count) {
      var reverse;
      var i = -1;
      var n;
      var ticks;
      var step;
      stop = +stop, start = +start, count = +count;

      if (start === stop && count > 0) {
        return [start];
      } // tslint:disable-next-line


      if (reverse = stop < start) {
        n = start, start = stop, stop = n;
      } // tslint:disable-next-line


      if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) {
        return [];
      }

      if (step > 0) {
        start = Math.ceil(start / step);
        stop = Math.floor(stop / step);
        ticks = new Array(n = Math.ceil(stop - start + 1));

        while (++i < n) {
          ticks[i] = (start + i) * step;
        }
      } else {
        start = Math.floor(start * step);
        stop = Math.ceil(stop * step);
        ticks = new Array(n = Math.ceil(start - stop + 1));

        while (++i < n) {
          ticks[i] = (start - i) / step;
        }
      }

      if (reverse) {
        ticks.reverse();
      }

      return ticks;
    }

    function tickIncrement(start, stop, count) {
      var step = (stop - start) / Math.max(0, count);
      var power = Math.floor(Math.log(step) / Math.LN10);
      var error = step / Math.pow(10, power);
      return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
    }

    function snapMultiple(v, base, snapType) {
      var div;

      if (snapType === 'ceil') {
        div = Math.ceil(v / base);
      } else if (snapType === 'floor') {
        div = Math.floor(v / base);
      } else {
        div = Math.round(v / base);
      }

      return div * base;
    }

    function intervalTicks(min, max, interval) {
      // 变成 interval 的倍数
      var minTick = snapMultiple(min, interval, 'floor');
      var maxTick = snapMultiple(max, interval, 'ceil'); // 统一小数位数

      minTick = fixedBase(minTick, interval);
      maxTick = fixedBase(maxTick, interval);
      var ticks = [];

      for (var i = minTick; i <= maxTick; i = i + interval) {
        var tickValue = fixedBase(i, interval); // 防止浮点数加法出现问题

        ticks.push(tickValue);
      }

      return {
        min: minTick,
        max: maxTick,
        ticks: ticks
      };
    }

    /**
     * 按照给定的 minLimit/maxLimit/tickCount 均匀计算出刻度 ticks
     *
     * @param cfg Scale 配置项
     * @return ticks
     */

    function strictLimit(cfg, defaultMin, defaultMax) {
      var _a;

      var minLimit = cfg.minLimit,
          maxLimit = cfg.maxLimit,
          min = cfg.min,
          max = cfg.max,
          _b = cfg.tickCount,
          tickCount = _b === void 0 ? 5 : _b;
      var tickMin = isNil$1(minLimit) ? isNil$1(defaultMin) ? min : defaultMin : minLimit;
      var tickMax = isNil$1(maxLimit) ? isNil$1(defaultMax) ? max : defaultMax : maxLimit;

      if (tickMin > tickMax) {
        _a = [tickMin, tickMax], tickMax = _a[0], tickMin = _a[1];
      }

      if (tickCount <= 2) {
        return [tickMin, tickMax];
      }

      var step = (tickMax - tickMin) / (tickCount - 1);
      var ticks = [];

      for (var i = 0; i < tickCount; i++) {
        ticks.push(tickMin + step * i);
      }

      return ticks;
    }

    function d3LinearTickMethod(cfg) {
      var min = cfg.min,
          max = cfg.max,
          tickInterval = cfg.tickInterval,
          minLimit = cfg.minLimit,
          maxLimit = cfg.maxLimit;
      var ticks = d3Linear(cfg);

      if (!isNil$1(minLimit) || !isNil$1(maxLimit)) {
        return strictLimit(cfg, head(ticks), last(ticks));
      }

      if (tickInterval) {
        return intervalTicks(min, max, tickInterval).ticks;
      }

      return ticks;
    }

    /**
     * 计算线性的 ticks,使用 wilkinson extended 方法
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function linear$1(cfg) {
      var min = cfg.min,
          max = cfg.max,
          tickCount = cfg.tickCount,
          nice = cfg.nice,
          tickInterval = cfg.tickInterval,
          minLimit = cfg.minLimit,
          maxLimit = cfg.maxLimit;
      var ticks = extended(min, max, tickCount, nice).ticks;

      if (!isNil$1(minLimit) || !isNil$1(maxLimit)) {
        return strictLimit(cfg, head(ticks), last(ticks));
      }

      if (tickInterval) {
        return intervalTicks(min, max, tickInterval).ticks;
      }

      return ticks;
    }

    /**
     * 计算 log 的 ticks,考虑 min = 0 的场景
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function calculateLogTicks(cfg) {
      var base = cfg.base,
          tickCount = cfg.tickCount,
          min = cfg.min,
          max = cfg.max,
          values = cfg.values;
      var minTick;
      var maxTick = log(base, max);

      if (min > 0) {
        minTick = Math.floor(log(base, min));
      } else {
        var positiveMin = getLogPositiveMin(values, base, max);
        minTick = Math.floor(log(base, positiveMin));
      }

      var count = maxTick - minTick;
      var avg = Math.ceil(count / tickCount);
      var ticks = [];

      for (var i = minTick; i < maxTick + avg; i = i + avg) {
        ticks.push(Math.pow(base, i));
      }

      if (min <= 0) {
        // 最小值 <= 0 时显示 0
        ticks.unshift(0);
      }

      return ticks;
    }

    function prettyNumber(n) {
      return n < 1e-15 ? n : parseFloat(n.toFixed(15));
    }

    function pretty(min, max, n) {
      if (n === void 0) {
        n = 5;
      }

      if (min === max) {
        return {
          max: max,
          min: min,
          ticks: [min]
        };
      }
      /*
        R pretty:
        https://svn.r-project.org/R/trunk/src/appl/pretty.c
        https://www.rdocumentation.org/packages/base/versions/3.5.2/topics/pretty
        */


      var h = 1.5; // high.u.bias

      var h5 = 0.5 + 1.5 * h; // u5.bias
      // 反正我也不会调参,跳过所有判断步骤

      var d = max - min;
      var c = d / n; // 当d非常小的时候触发,但似乎没什么用
      // const min_n = Math.floor(n / 3);
      // const shrink_sml = Math.pow(2, 5);
      // if (Math.log10(d) < -2) {
      //   c = (_.max([ Math.abs(max), Math.abs(min) ]) * shrink_sml) / min_n;
      // }

      var base = Math.pow(10, Math.floor(Math.log10(c)));
      var unit = base;

      if (2 * base - c < h * (c - unit)) {
        unit = 2 * base;

        if (5 * base - c < h5 * (c - unit)) {
          unit = 5 * base;

          if (10 * base - c < h * (c - unit)) {
            unit = 10 * base;
          }
        }
      }

      var nu = Math.ceil(max / unit);
      var ns = Math.floor(min / unit);
      var hi = Math.max(nu * unit, max);
      var lo = Math.min(ns * unit, min);
      var size = Math.floor((hi - lo) / unit) + 1;
      var ticks = new Array(size);

      for (var i = 0; i < size; i++) {
        ticks[i] = prettyNumber(lo + i * unit);
      }

      return {
        min: lo,
        max: hi,
        ticks: ticks
      };
    }

    /**
     * 计算 Pow 的 ticks
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function calculatePowTicks(cfg) {
      var exponent = cfg.exponent,
          tickCount = cfg.tickCount;
      var max = Math.ceil(calBase(exponent, cfg.max));
      var min = Math.floor(calBase(exponent, cfg.min));
      var ticks = pretty(min, max, tickCount).ticks;
      return ticks.map(function (tick) {
        var factor = tick >= 0 ? 1 : -1;
        return Math.pow(tick, exponent) * factor;
      });
    }

    /**
     * 计算几分位 https://github.com/simple-statistics/simple-statistics/blob/master/src/quantile_sorted.js
     * @param x  数组
     * @param p  百分比
     */
    function quantileSorted(x, p) {
      var idx = x.length * p;
      /*if (x.length === 0) { // 当前场景这些条件不可能命中
        throw new Error('quantile requires at least one value.');
      } else if (p < 0 || p > 1) {
        throw new Error('quantiles must be between 0 and 1');
      } else */

      if (p === 1) {
        // If p is 1, directly return the last element
        return x[x.length - 1];
      } else if (p === 0) {
        // If p is 0, directly return the first element
        return x[0];
      } else if (idx % 1 !== 0) {
        // If p is not integer, return the next element in array
        return x[Math.ceil(idx) - 1];
      } else if (x.length % 2 === 0) {
        // If the list has even-length, we'll take the average of this number
        // and the next value, if there is one
        return (x[idx - 1] + x[idx]) / 2;
      } else {
        // Finally, in the simple case of an integer value
        // with an odd-length list, return the x value at the index.
        return x[idx];
      }
    }

    function calculateTicks(cfg) {
      var tickCount = cfg.tickCount,
          values = cfg.values;

      if (!values || !values.length) {
        return [];
      }

      var sorted = values.slice().sort(function (a, b) {
        return a - b;
      });
      var ticks = [];

      for (var i = 0; i < tickCount; i++) {
        var p = i / (tickCount - 1);
        ticks.push(quantileSorted(sorted, p));
      }

      return ticks;
    }

    /**
     * 计算线性的 ticks,使用 R's pretty 方法
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function linearPretty(cfg) {
      var min = cfg.min,
          max = cfg.max,
          tickCount = cfg.tickCount,
          tickInterval = cfg.tickInterval,
          minLimit = cfg.minLimit,
          maxLimit = cfg.maxLimit;
      var ticks = pretty(min, max, tickCount).ticks;

      if (!isNil$1(minLimit) || !isNil$1(maxLimit)) {
        return strictLimit(cfg, head(ticks), last(ticks));
      }

      if (tickInterval) {
        return intervalTicks(min, max, tickInterval).ticks;
      }

      return ticks;
    }

    function calculateTimeTicks(cfg) {
      var min = cfg.min,
          max = cfg.max,
          minTickInterval = cfg.minTickInterval;
      var tickInterval = cfg.tickInterval;
      var tickCount = cfg.tickCount; // 指定 tickInterval 后 tickCount 不生效,需要重新计算

      if (tickInterval) {
        tickCount = Math.ceil((max - min) / tickInterval);
      } else {
        tickInterval = getTickInterval(min, max, tickCount)[1];
        var count = (max - min) / tickInterval;
        var ratio = count / tickCount;

        if (ratio > 1) {
          tickInterval = tickInterval * Math.ceil(ratio);
        } // 如果设置了最小间距,则使用最小间距


        if (minTickInterval && tickInterval < minTickInterval) {
          tickInterval = minTickInterval;
        }
      }

      var ticks = [];

      for (var i = min; i < max + tickInterval; i += tickInterval) {
        ticks.push(i);
      }

      return ticks;
    }

    /**
     * 计算时间分类的 ticks, 保头,保尾
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */

    function calculateTimeCatTicks(cfg) {
      var ticks = calculateCatTicks(cfg);
      var lastValue = last(cfg.values);

      if (lastValue !== last(ticks)) {
        ticks.push(lastValue);
      }

      return ticks;
    }

    function getYear(date) {
      return new Date(date).getFullYear();
    }

    function createYear(year) {
      return new Date(year, 0, 1).getTime();
    }

    function getMonth(date) {
      return new Date(date).getMonth();
    }

    function diffMonth(min, max) {
      var minYear = getYear(min);
      var maxYear = getYear(max);
      var minMonth = getMonth(min);
      var maxMonth = getMonth(max);
      return (maxYear - minYear) * 12 + (maxMonth - minMonth) % 12;
    }

    function creatMonth(year, month) {
      return new Date(year, month, 1).getTime();
    }

    function diffDay(min, max) {
      return Math.ceil((max - min) / DAY);
    }

    function diffHour(min, max) {
      return Math.ceil((max - min) / HOUR);
    }

    function diffMinus(min, max) {
      return Math.ceil((max - min) / (60 * 1000));
    }
    /**
     * 计算 time 的 ticks,对 month, year 进行 pretty 处理
     * @param cfg 度量的配置项
     * @returns 计算后的 ticks
     */


    function timePretty(cfg) {
      var min = cfg.min,
          max = cfg.max,
          minTickInterval = cfg.minTickInterval,
          tickCount = cfg.tickCount;
      var tickInterval = cfg.tickInterval;
      var ticks = []; // 指定 tickInterval 后 tickCount 不生效,需要重新计算

      if (!tickInterval) {
        tickInterval = (max - min) / tickCount; // 如果设置了最小间距,则使用最小间距

        if (minTickInterval && tickInterval < minTickInterval) {
          tickInterval = minTickInterval;
        }
      }

      var minYear = getYear(min); // 如果间距大于 1 年,则将开始日期从整年开始

      if (tickInterval > YEAR) {
        var maxYear = getYear(max);
        var yearInterval = Math.ceil(tickInterval / YEAR);

        for (var i = minYear; i <= maxYear + yearInterval; i = i + yearInterval) {
          ticks.push(createYear(i));
        }
      } else if (tickInterval > MONTH) {
        // 大于月时
        var monthInterval = Math.ceil(tickInterval / MONTH);
        var mmMoth = getMonth(min);
        var dMonths = diffMonth(min, max);

        for (var i = 0; i <= dMonths + monthInterval; i = i + monthInterval) {
          ticks.push(creatMonth(minYear, i + mmMoth));
        }
      } else if (tickInterval > DAY) {
        // 大于天
        var date = new Date(min);
        var year = date.getFullYear();
        var month = date.getMonth();
        var mday = date.getDate();
        var day = Math.ceil(tickInterval / DAY);
        var ddays = diffDay(min, max);

        for (var i = 0; i < ddays + day; i = i + day) {
          ticks.push(new Date(year, month, mday + i).getTime());
        }
      } else if (tickInterval > HOUR) {
        // 大于小时
        var date = new Date(min);
        var year = date.getFullYear();
        var month = date.getMonth();
        var day = date.getDate();
        var hour = date.getHours();
        var hours = Math.ceil(tickInterval / HOUR);
        var dHours = diffHour(min, max);

        for (var i = 0; i <= dHours + hours; i = i + hours) {
          ticks.push(new Date(year, month, day, hour + i).getTime());
        }
      } else if (tickInterval > MINUTE) {
        // 大于分钟
        var dMinus = diffMinus(min, max);
        var minutes = Math.ceil(tickInterval / MINUTE);

        for (var i = 0; i <= dMinus + minutes; i = i + minutes) {
          ticks.push(min + i * MINUTE);
        }
      } else {
        // 小于分钟
        var interval = tickInterval;

        if (interval < SECOND) {
          interval = SECOND;
        }

        var minSecond = Math.floor(min / SECOND) * SECOND;
        var dSeconds = Math.ceil((max - min) / SECOND);
        var seconds = Math.ceil(interval / SECOND);

        for (var i = 0; i < dSeconds + seconds; i = i + seconds) {
          ticks.push(minSecond + i * SECOND);
        }
      } // 最好是能从算法能解决这个问题,但是如果指定了 tickInterval,计算 ticks,也只能这么算,所以
      // 打印警告提示


      if (ticks.length >= 512) {
        console.warn("Notice: current ticks length(" + ticks.length + ") >= 512, may cause performance issues, even out of memory. Because of the configure \"tickInterval\"(in milliseconds, current is " + tickInterval + ") is too small, increase the value to solve the problem!");
      }

      return ticks;
    }

    registerTickMethod('cat', calculateCatTicks);
    registerTickMethod('time-cat', calculateTimeCatTicks);
    registerTickMethod('wilkinson-extended', linear$1);
    registerTickMethod('r-pretty', linearPretty);
    registerTickMethod('time', calculateTimeTicks);
    registerTickMethod('time-pretty', timePretty);
    registerTickMethod('log', calculateLogTicks);
    registerTickMethod('pow', calculatePowTicks);
    registerTickMethod('quantile', calculateTicks);
    registerTickMethod('d3-linear', d3LinearTickMethod);

    registerClass('cat', Category$1);
    registerClass('category', Category$1);
    registerClass('identity', Identity$1);
    registerClass('linear', Linear$1);
    registerClass('log', Log);
    registerClass('pow', Pow);
    registerClass('time', Time);
    registerClass('timeCat', TimeCat$1);
    registerClass('quantize', Quantize);
    registerClass('quantile', Quantile);

    // cat平均算法,保头保尾
    var CatTick = (function (cfg) {
      var values = cfg.values,
          tickCount = cfg.tickCount;

      if (!tickCount) {
        return values;
      }

      if (values.length <= 1) {
        return values;
      } // 获取间隔步长, 最小是1


      var step = parseInt(values.length / (tickCount - 1)) || 1;
      var ticks = []; // 按间隔数取对应节点

      for (var index = 0; index < values.length; index = index + step) {
        ticks.push(values[index]);
      }

      var last = values[values.length - 1]; // 如果最后一个tick不等于原数据的最后一个

      if (ticks[ticks.length - 1] !== last) {
        if (ticks.length >= tickCount) {
          // 如果当前的tick个数满足要求
          ticks[ticks.length - 1] = last;
        } else {
          // 不满足tickCount则直接加入最后一个
          ticks.push(last);
        }
      }

      return ticks;
    });

    // 认为是nice的刻度
    var SNAP_COUNT_ARRAY = [1, 1.2, 1.5, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
    var DEFAULT_COUNT = 5; // 默认刻度值

    var LinearTick = (function (cfg) {
      var _ref = cfg || {},
          tickCount = _ref.tickCount,
          tickInterval = _ref.tickInterval;

      var _ref2 = cfg || {},
          min = _ref2.min,
          max = _ref2.max;

      min = isNaN(min) ? 0 : min;
      max = isNaN(max) ? 0 : max;
      var count = tickCount && tickCount >= 2 ? tickCount : DEFAULT_COUNT; // 计算interval, 优先取tickInterval

      var interval = tickInterval || getBestInterval({
        tickCount: count,
        max: max,
        min: min
      }); // 通过interval计算最小tick

      var minTick = Math.floor(min / interval) * interval; // 如果指定了tickInterval, count 需要根据指定的tickInterval来算计

      if (tickInterval) {
        var intervalCount = Math.abs(Math.ceil((max - minTick) / tickInterval)) + 1; // tickCount 作为最小 count 处理

        count = Math.max(count, intervalCount);
      }

      var ticks = [];
      var tickLength = 0;
      var fixedLength = getFixedLength(interval);

      while (tickLength < count) {
        ticks.push(toFixed(minTick + tickLength * interval, fixedLength));
        tickLength++;
      }

      return ticks;
    });
    var DECIMAL_LENGTH = 12;

    function getFactor(number) {
      // 取正数
      number = Math.abs(number);
      var factor = 1;

      if (number === 0) {
        return factor;
      } // 小于1,逐渐放大


      if (number < 1) {
        var count = 0;

        while (number < 1) {
          factor = factor / 10;
          number = number * 10;
          count++;
        } // 浮点数计算出现问题


        if (factor.toString().length > DECIMAL_LENGTH) {
          factor = parseFloat(factor.toFixed(count));
        }

        return factor;
      } // 大于10逐渐缩小


      while (number > 10) {
        factor = factor * 10;
        number = number / 10;
      }

      return factor;
    } // 获取最佳匹配刻度


    function getBestInterval(_ref3) {
      var tickCount = _ref3.tickCount,
          min = _ref3.min,
          max = _ref3.max;

      // 如果最大最小相等,则直接按1处理
      if (min === max) {
        return 1 * getFactor(max);
      } // 1.计算平均刻度间隔


      var avgInterval = (max - min) / (tickCount - 1); // 2.数据标准归一化 映射到[1-10]区间

      var factor = getFactor(avgInterval);
      var calInterval = avgInterval / factor;
      var calMax = max / factor;
      var calMin = min / factor; // 根据平均值推算最逼近刻度值

      var similarityIndex = 0;

      for (var index = 0; index < SNAP_COUNT_ARRAY.length; index++) {
        var item = SNAP_COUNT_ARRAY[index];

        if (calInterval <= item) {
          similarityIndex = index;
          break;
        }
      }

      var similarityInterval = getInterval(similarityIndex, tickCount, calMin, calMax); // 小数点位数还原到数据的位数, 因为similarityIndex有可能是小数,所以需要保留similarityIndex自己的小数位数

      var fixedLength = getFixedLength(similarityInterval) + getFixedLength(factor);
      return toFixed(similarityInterval * factor, fixedLength);
    }

    function getInterval(startIndex, tickCount, min, max) {
      var verify = false;
      var interval = SNAP_COUNT_ARRAY[startIndex]; // 刻度值校验,如果不满足,循环下去

      for (var i = startIndex; i < SNAP_COUNT_ARRAY.length; i++) {
        if (intervalIsVerify({
          interval: SNAP_COUNT_ARRAY[i],
          tickCount: tickCount,
          max: max,
          min: min
        })) {
          // 有符合条件的interval
          interval = SNAP_COUNT_ARRAY[i];
          verify = true;
          break;
        }
      } // 如果不满足, 依次缩小10倍,再计算


      if (!verify) {
        return 10 * getInterval(0, tickCount, min / 10, max / 10);
      }

      return interval;
    } // 刻度是否满足展示需求


    function intervalIsVerify(_ref4) {
      var interval = _ref4.interval,
          tickCount = _ref4.tickCount,
          max = _ref4.max,
          min = _ref4.min;
      var minTick = Math.floor(min / interval) * interval;

      if (minTick + (tickCount - 1) * interval >= max) {
        return true;
      }

      return false;
    } // 计算小数点应该保留的位数


    function getFixedLength(num) {
      var str = num.toString();
      var index = str.indexOf('.');
      var indexOfExp = str.indexOf('e-');
      var length = indexOfExp >= 0 ? parseInt(str.substr(indexOfExp + 2), 10) : str.substr(index + 1).length;

      if (length > 20) {
        // 最多保留20位小数
        length = 20;
      }

      return length;
    } // @antv/util fixedbase不支持科学计数法的判断,需要提mr


    function toFixed(v, length) {
      return parseFloat(v.toFixed(length));
    }

    var Linear = getClass('linear');
    var Identity = getClass('identity');
    var Category = getClass('category');
    var TimeCat = getClass('timeCat'); // 覆盖0.3.x的 cat 方法

    registerTickMethod('cat', CatTick);
    registerTickMethod('time-cat', CatTick); // 覆盖linear 度量的tick算法

    registerTickMethod('wilkinson-extended', LinearTick);
    Scale.Linear = Linear;
    Scale.Identity = Identity;
    Scale.Category = Category;
    Scale.Cat = Category;
    Scale.TimeCat = TimeCat;

    function isFullCircle(coord) {
      if (!coord.isPolar) {
        return false;
      }

      var startAngle = coord.startAngle;
      var endAngle = coord.endAngle;

      if (!isNil$1(startAngle) && !isNil$1(endAngle) && endAngle - startAngle < Math.PI * 2) {
        return false;
      }

      return true;
    }

    function clearObj(obj) {
      Object.keys(obj).forEach(function (key) {
        delete obj[key];
      });
    }

    var ScaleController = /*#__PURE__*/function () {
      function ScaleController(cfg) {
        // defs 列定义
        this.defs = {}; // 已经实例化的scale

        this.scales = {};
        mix$1(this, cfg);
      }

      var _proto = ScaleController.prototype;

      _proto.setFieldDef = function setFieldDef(field, cfg) {
        var defs = this.defs;

        if (isObject$1(field)) {
          mix$1(defs, field);
        } else {
          defs[field] = cfg;
        } // 因为可能同时变更多个scale,所以要把所有已实例化的scale都更新下


        this.updateScales();
      };

      _proto._getDef = function _getDef(field) {
        var defs = this.defs;
        var def = null;

        if (Global.scales[field] || defs[field]) {
          def = mix$1({}, Global.scales[field]);
          each$1(defs[field], function (v, k) {
            if (isNil$1(v)) {
              delete def[k];
            } else {
              def[k] = v;
            }
          });
        }

        return def;
      };

      _proto._getDefaultType = function _getDefaultType(field, data, def) {
        if (def && def.type) {
          return def.type;
        }

        var type = 'linear';
        var value = firstValue(data, field);

        if (isArray$1(value)) {
          value = value[0];
        }

        if (isString(value)) {
          type = 'cat';
        }

        return type;
      };

      _proto._getScaleDef = function _getScaleDef(type, field, data, def) {
        var values$1;

        if (def && def.values) {
          values$1 = def.values;
        } else {
          values$1 = values(data, field);
        }

        var cfg = {
          field: field,
          values: values$1
        };

        if (type !== 'cat' && type !== 'timeCat') {
          if (!def || !(def.min && def.max)) {
            var _Array$getRange = getRange(values$1),
                min = _Array$getRange.min,
                max = _Array$getRange.max;

            cfg.min = min;
            cfg.max = max;
            cfg.nice = true;
          }
        } else {
          cfg.isRounding = false; // used for tickCount calculation
        }

        return cfg;
      } // 调整range,为了让图形居中
      ;

      _proto._adjustRange = function _adjustRange(type, cfg) {
        var range = cfg.range,
            values = cfg.values; // 如果是线性, 或者有自定义range都不处理

        if (type === 'linear' || range || !values) {
          return cfg;
        }

        var count = values.length; // 单只有一条数据时,在中间显示

        if (count === 1) {
          cfg.range = [0.5, 1];
        } else {
          var chart = this.chart;
          var coord = chart.get('coord');
          var widthRatio = Global.widthRatio.multiplePie;
          var offset = 0;

          if (isFullCircle(coord)) {
            if (!coord.transposed) {
              cfg.range = [0, 1 - 1 / count];
            } else {
              offset = 1 / count * widthRatio;
              cfg.range = [offset / 2, 1 - offset / 2];
            }
          } else {
            // 为了让图形居中,所以才设置range
            offset = 1 / count * 0.5; // 这里可能用0.25会更合理

            cfg.range = [offset, 1 - offset];
          }
        }

        return cfg;
      };

      _proto._getScaleCfg = function _getScaleCfg(field, data) {
        var self = this;

        var def = self._getDef(field);

        if (!data || !data.length) {
          if (def && def.type) {
            def.field = field;
            return {
              type: def.type,
              cfg: def
            };
          }

          return {
            type: 'identity',
            cfg: {
              value: field,
              field: field.toString(),
              values: [field]
            }
          };
        }

        var firstObj = data[0];
        var firstValue$1 = firstObj[field];

        if (firstValue$1 === null) {
          firstValue$1 = firstValue(data, field);
        }

        if (isNumber(field) || isNil$1(firstValue$1) && !def) {
          return {
            type: 'identity',
            cfg: {
              value: field,
              field: field.toString(),
              values: [field]
            }
          };
        }

        var type = self._getDefaultType(field, data, def);

        var cfg = self._getScaleDef(type, field, data, def);

        def && mix$1(cfg, def);
        cfg = this._adjustRange(type, cfg);
        return {
          type: type,
          cfg: cfg
        };
      };

      _proto.createScale = function createScale(field, data) {
        var scales = this.scales;

        var _this$_getScaleCfg = this._getScaleCfg(field, data),
            type = _this$_getScaleCfg.type,
            cfg = _this$_getScaleCfg.cfg;

        var scale = scales[field]; // 如果已经存在,且类型相等时直接返回

        if (scale && scale.type === type) {
          scale.change(cfg);
          return scale;
        }

        var Scale = getClass(type);
        var newScale = new Scale(cfg);
        scales[field] = newScale;
        return newScale;
      };

      _proto._updateScale = function _updateScale(scale) {
        var field = scale.field; // 因为每个field的数据都会不同

        var data = this.chart._getScaleData(field);

        var _this$_getScaleCfg2 = this._getScaleCfg(field, data),
            cfg = _this$_getScaleCfg2.cfg;

        scale.change(cfg);
      };

      _proto.updateScales = function updateScales() {
        var _this = this;

        var scales = this.scales; // 修改完列定义后,需要更新已经实例化的scale
        // 如果是还没有实例化的,在geom初始化的时候会被实例化,所以这里可以不用更新

        each$1(scales, function (scale) {
          _this._updateScale(scale);
        });
      } // 调整scale从0开始
      ;

      _proto.adjustStartZero = function adjustStartZero(scale) {
        var defs = this.defs;
        var field = scale.field,
            min = scale.min,
            max = scale.max; // 如果有定义,则不处理

        if (defs[field] && defs[field].min) {
          return;
        }

        if (min > 0) {
          scale.change({
            min: 0
          });
        } else if (max < 0) {
          scale.change({
            max: 0
          });
        }
      };

      _proto.clear = function clear() {
        // this.defs = {};
        // this.scales = {};
        clearObj(this.defs);
        clearObj(this.scales);
        this.data = null;
      };

      return ScaleController;
    }();

    var Abastract = /*#__PURE__*/function () {
      var _proto = Abastract.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        /**
         * ticks
         * @type {Array}
         */
        this.ticks = [];
        /**
         * the configuration for tickLine
         * @type {Object}
         */

        this.tickLine = {};
        /**
         * the direction of ticks, 1 means clockwise
         * @type {Number}
         */

        this.offsetFactor = 1;
        /**
         * the top container
         * @type {container}
         */

        this.frontContainer = null;
        /**
         * the back container
         * @type {[type]}
         */

        this.backContainer = null;
        /**
         * points for draw grid line
         * @type {Array}
         */

        this.gridPoints = [];
      };

      function Abastract(cfg) {
        this._initDefaultCfg();

        mix$1(this, cfg);
        this.draw();
      }

      _proto.draw = function draw() {
        var line = this.line,
            tickLine = this.tickLine,
            label = this.label,
            grid = this.grid;
        grid && this.drawGrid(grid); // draw the grid lines

        tickLine && this.drawTicks(tickLine); // draw the tickLine

        line && this.drawLine(line); // draw axis line

        label && this.drawLabels(); // draw ticks
      };

      _proto.drawTicks = function drawTicks(tickCfg) {
        var self = this;
        var ticks = self.ticks;
        var length = tickCfg.length;
        var container = self.getContainer(tickCfg.top);
        each$1(ticks, function (tick) {
          var start = self.getOffsetPoint(tick.value);
          var end = self.getSidePoint(start, length);
          var shape = container.addShape('line', {
            className: 'axis-tick',
            attrs: mix$1({
              x1: start.x,
              y1: start.y,
              x2: end.x,
              y2: end.y
            }, tickCfg)
          });
          shape._id = self._id + '-ticks';
        });
      };

      _proto.drawLabels = function drawLabels() {
        var self = this;
        var labelOffset = self.labelOffset;
        var labels = self.labels;
        each$1(labels, function (labelShape) {
          var container = self.getContainer(labelShape.get('top'));
          var start = self.getOffsetPoint(labelShape.get('value'));

          var _self$getSidePoint = self.getSidePoint(start, labelOffset),
              x = _self$getSidePoint.x,
              y = _self$getSidePoint.y;

          labelShape.attr(mix$1({
            x: x,
            y: y
          }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
          labelShape._id = self._id + '-' + labelShape.attr('text');
          container.add(labelShape);
        });
      };

      _proto.drawLine = function drawLine() {};

      _proto.drawGrid = function drawGrid(grid) {
        var self = this;
        var gridPoints = self.gridPoints,
            ticks = self.ticks;
        var gridCfg = grid;
        var count = gridPoints.length;
        each$1(gridPoints, function (subPoints, index) {
          if (isFunction$1(grid)) {
            var tick = ticks[index] || {};
            var executedGrid = grid(tick.text, index, count);
            gridCfg = executedGrid ? mix$1({}, Global._defaultAxis.grid, executedGrid) : null;
          }

          if (gridCfg) {
            var type = gridCfg.type; // has two types: 'line' and 'arc'

            var points = subPoints.points;
            var container = self.getContainer(gridCfg.top);
            var shape;

            if (type === 'arc') {
              var center = self.center,
                  startAngle = self.startAngle,
                  endAngle = self.endAngle;
              var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
              shape = container.addShape('Arc', {
                className: 'axis-grid',
                attrs: mix$1({
                  x: center.x,
                  y: center.y,
                  startAngle: startAngle,
                  endAngle: endAngle,
                  r: radius
                }, gridCfg)
              });
            } else {
              shape = container.addShape('Polyline', {
                className: 'axis-grid',
                attrs: mix$1({
                  points: points
                }, gridCfg)
              });
            }

            shape._id = subPoints._id;
          }
        });
      };

      _proto.getOffsetPoint = function getOffsetPoint() {};

      _proto.getAxisVector = function getAxisVector() {};

      _proto.getOffsetVector = function getOffsetVector(point, offset) {
        var self = this;
        var axisVector = self.getAxisVector(point);
        var normal = Vector2.normalize([], axisVector);
        var factor = self.offsetFactor;
        var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
        return Vector2.scale([], verticalVector, offset);
      };

      _proto.getSidePoint = function getSidePoint(point, offset) {
        var self = this;
        var offsetVector = self.getOffsetVector(point, offset);
        return {
          x: point.x + offsetVector[0],
          y: point.y + offsetVector[1]
        };
      };

      _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
        var self = this;
        var offsetVector = self.getOffsetVector(point, offset);
        var align;
        var baseLine;

        if (offsetVector[0] > 0) {
          align = 'left';
        } else if (offsetVector[0] < 0) {
          align = 'right';
        } else {
          align = 'center';
        }

        if (offsetVector[1] > 0) {
          baseLine = 'top';
        } else if (offsetVector[1] < 0) {
          baseLine = 'bottom';
        } else {
          baseLine = 'middle';
        }

        return {
          textAlign: align,
          textBaseline: baseLine
        };
      };

      _proto.getContainer = function getContainer(isTop) {
        var frontContainer = this.frontContainer,
            backContainer = this.backContainer;
        return isTop ? frontContainer : backContainer;
      };

      return Abastract;
    }();

    var Line$3 = /*#__PURE__*/function (_Abstract) {
      _inheritsLoose$3(Line, _Abstract);

      function Line() {
        return _Abstract.apply(this, arguments) || this;
      }

      var _proto = Line.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        _Abstract.prototype._initDefaultCfg.call(this);

        this.start = null;
        this.end = null;
      };

      _proto.getOffsetPoint = function getOffsetPoint(value) {
        var start = this.start,
            end = this.end;
        return {
          x: start.x + (end.x - start.x) * value,
          y: start.y + (end.y - start.y) * value
        };
      };

      _proto.getAxisVector = function getAxisVector() {
        var start = this.start,
            end = this.end;
        return [end.x - start.x, end.y - start.y];
      };

      _proto.drawLine = function drawLine(lineCfg) {
        var container = this.getContainer(lineCfg.top);
        var start = this.start,
            end = this.end;
        container.addShape('line', {
          className: 'axis-line',
          attrs: mix$1({
            x1: start.x,
            y1: start.y,
            x2: end.x,
            y2: end.y
          }, lineCfg)
        });
      };

      return Line;
    }(Abastract);

    Abastract.Line = Line$3;

    function formatTicks(ticks) {
      var tmp = ticks.slice(0);

      if (tmp.length > 0) {
        var first = tmp[0];
        var last = tmp[tmp.length - 1];

        if (first.value !== 0) {
          tmp.unshift({
            value: 0
          });
        }

        if (last.value !== 1) {
          tmp.push({
            value: 1
          });
        }
      }

      return tmp;
    }

    var AxisController = /*#__PURE__*/function () {
      function AxisController(cfg) {
        this.axisCfg = {};
        this.frontPlot = null;
        this.backPlot = null;
        this.axes = {}; // store the axes's options

        mix$1(this, cfg);
      }

      var _proto = AxisController.prototype;

      _proto._isHide = function _isHide(field) {
        var axisCfg = this.axisCfg;
        return !axisCfg || axisCfg[field] === false;
      };

      _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
        var position = '';
        var field = scale.field;
        var axisCfg = this.axisCfg;

        if (axisCfg[field] && axisCfg[field].position) {
          position = axisCfg[field].position;
        } else if (dimType === 'x') {
          position = transposed ? 'left' : 'bottom';
        } else if (dimType === 'y') {
          position = index ? 'right' : 'left';

          if (transposed) {
            position = 'bottom';
          }
        }

        return position;
      };

      _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
        var start;
        var end;
        var factor = 1; // Mark clockwise or counterclockwise

        if (dimType === 'x') {
          start = {
            x: 0,
            y: 0
          };
          end = {
            x: 1,
            y: 0
          };
        } else {
          if (position === 'right') {
            // there will be several y axes
            start = {
              x: 1,
              y: 0
            };
            end = {
              x: 1,
              y: 1
            };
          } else {
            start = {
              x: 0,
              y: 0
            };
            end = {
              x: 0,
              y: 1
            };
            factor = -1;
          }
        }

        if (coord.transposed) {
          factor *= -1;
        }

        return {
          offsetFactor: factor,
          start: coord.convertPoint(start),
          end: coord.convertPoint(end)
        };
      };

      _proto._getCircleCfg = function _getCircleCfg(coord) {
        return {
          startAngle: coord.startAngle,
          endAngle: coord.endAngle,
          center: coord.center,
          radius: coord.circleRadius
        };
      };

      _proto._getRadiusCfg = function _getRadiusCfg(coord) {
        var transposed = coord.transposed;
        var start;
        var end;

        if (transposed) {
          start = {
            x: 0,
            y: 0
          };
          end = {
            x: 1,
            y: 0
          };
        } else {
          start = {
            x: 0,
            y: 0
          };
          end = {
            x: 0,
            y: 1
          };
        }

        return {
          offsetFactor: -1,
          start: coord.convertPoint(start),
          end: coord.convertPoint(end)
        };
      };

      _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
        var _this = this;

        var self = this;
        var axisCfg = this.axisCfg;
        var ticks = scale.getTicks();
        var cfg = deepMix({
          ticks: ticks,
          frontContainer: this.frontPlot,
          backContainer: this.backPlot
        }, defaultCfg, axisCfg[scale.field]);
        var labels = [];
        var label = cfg.label;
        var count = ticks.length;
        var maxWidth = 0;
        var maxHeight = 0;
        var labelCfg = label;
        each$1(ticks, function (tick, index) {
          if (isFunction$1(label)) {
            var executedLabel = label(tick.text, index, count);
            labelCfg = executedLabel ? mix$1({}, Global._defaultAxis.label, executedLabel) : null;
          }

          if (labelCfg) {
            var textStyle = {};

            if (labelCfg.textAlign) {
              textStyle.textAlign = labelCfg.textAlign;
            }

            if (labelCfg.textBaseline) {
              textStyle.textBaseline = labelCfg.textBaseline;
            }

            var container = labelCfg.top ? _this.frontPlot : _this.backPlot;
            var axisLabel = container.addShape('text', {
              className: 'axis-label',
              aria: false,
              attrs: mix$1({
                x: 0,
                y: 0,
                text: tick.text,
                fontFamily: self.chart.get('canvas').get('fontFamily')
              }, labelCfg),
              value: tick.value,
              textStyle: textStyle,
              top: labelCfg.top,
              context: self.chart.get('canvas').get('context')
            });
            labels.push(axisLabel);

            var _axisLabel$getBBox = axisLabel.getBBox(),
                width = _axisLabel$getBBox.width,
                height = _axisLabel$getBBox.height;

            maxWidth = Math.max(maxWidth, width);
            maxHeight = Math.max(maxHeight, height);
          }
        });
        cfg.labels = labels;
        cfg.maxWidth = maxWidth;
        cfg.maxHeight = maxHeight;
        return cfg;
      };

      _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
        if (index === void 0) {
          index = '';
        }

        var self = this;
        var coordType = coord.type;
        var transposed = coord.transposed;
        var type;
        var key;
        var defaultCfg;

        if (coordType === 'cartesian' || coordType === 'rect') {
          var position = self._getLinePosition(scale, dimType, index, transposed);

          defaultCfg = Global.axis[position];
          defaultCfg.position = position;
          type = 'Line';
          key = position;
        } else {
          if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
            defaultCfg = Global.axis.circle;
            type = 'Circle';
            key = 'circle';
          } else {
            defaultCfg = Global.axis.radius;
            type = 'Line';
            key = 'radius';
          }
        }

        var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);

        cfg.type = type;
        cfg.dimType = dimType;
        cfg.verticalScale = verticalScale;
        cfg.index = index;
        this.axes[key] = cfg;
      };

      _proto.createAxis = function createAxis(coord, xScale, yScales) {
        var self = this;

        if (xScale && !self._isHide(xScale.field)) {
          self._createAxis(coord, xScale, yScales[0], 'x');
        }

        each$1(yScales, function (yScale, index) {
          if (!self._isHide(yScale.field)) {
            self._createAxis(coord, yScale, xScale, 'y', index);
          }
        });
        var axes = this.axes;
        var chart = self.chart;

        if (chart._isAutoPadding()) {
          var userPadding = parsePadding(chart.get('padding'));
          var appendPadding = parsePadding(chart.get('appendPadding'));
          var legendRange = chart.get('legendRange') || {
            top: 0,
            right: 0,
            bottom: 0,
            left: 0
          };
          var padding = [userPadding[0] === 'auto' ? legendRange.top + appendPadding[0] * 2 : userPadding[0], userPadding[1] === 'auto' ? legendRange.right + appendPadding[1] : userPadding[1], userPadding[2] === 'auto' ? legendRange.bottom + appendPadding[2] : userPadding[2], userPadding[3] === 'auto' ? legendRange.left + appendPadding[3] : userPadding[3]];

          if (coord.isPolar) {
            var circleAxis = axes.circle;

            if (circleAxis) {
              var maxHeight = circleAxis.maxHeight,
                  maxWidth = circleAxis.maxWidth,
                  labelOffset = circleAxis.labelOffset;
              padding[0] += maxHeight + labelOffset;
              padding[1] += maxWidth + labelOffset;
              padding[2] += maxHeight + labelOffset;
              padding[3] += maxWidth + labelOffset;
            }
          } else {
            if (axes.right && userPadding[1] === 'auto') {
              var _axes$right = axes.right,
                  _maxWidth = _axes$right.maxWidth,
                  _labelOffset = _axes$right.labelOffset;
              padding[1] += _maxWidth + _labelOffset;
            }

            if (axes.left && userPadding[3] === 'auto') {
              var _axes$left = axes.left,
                  _maxWidth2 = _axes$left.maxWidth,
                  _labelOffset2 = _axes$left.labelOffset;
              padding[3] += _maxWidth2 + _labelOffset2;
            }

            if (axes.bottom && userPadding[2] === 'auto') {
              var _axes$bottom = axes.bottom,
                  _maxHeight = _axes$bottom.maxHeight,
                  _labelOffset3 = _axes$bottom.labelOffset;
              padding[2] += _maxHeight + _labelOffset3;
            }
          }

          chart.set('_padding', padding);

          chart._updateLayout(padding);
        }

        each$1(axes, function (axis) {
          var type = axis.type,
              grid = axis.grid,
              verticalScale = axis.verticalScale,
              ticks = axis.ticks,
              dimType = axis.dimType,
              position = axis.position,
              index = axis.index;
          var appendCfg;

          if (coord.isPolar) {
            if (type === 'Line') {
              appendCfg = self._getRadiusCfg(coord);
            } else if (type === 'Circle') {
              appendCfg = self._getCircleCfg(coord);
            }
          } else {
            appendCfg = self._getLineCfg(coord, dimType, position);
          }

          if (grid && verticalScale) {
            var gridPoints = [];
            var verticalTicks = formatTicks(verticalScale.getTicks());
            each$1(ticks, function (tick) {
              var subPoints = [];
              each$1(verticalTicks, function (verticalTick) {
                var x = dimType === 'x' ? tick.value : verticalTick.value;
                var y = dimType === 'x' ? verticalTick.value : tick.value;

                if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
                  var point = coord.convertPoint({
                    x: x,
                    y: y
                  });
                  subPoints.push(point);
                }
              });
              gridPoints.push({
                points: subPoints,
                _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
              });
            });
            axis.gridPoints = gridPoints;

            if (coord.isPolar) {
              axis.center = coord.center;
              axis.startAngle = coord.startAngle;
              axis.endAngle = coord.endAngle;
            }
          }

          appendCfg._id = 'axis-' + dimType;

          if (!isNil$1(index)) {
            appendCfg._id = 'axis-' + dimType + index;
          }

          new Abastract[type](mix$1(axis, appendCfg));
        });
      };

      _proto.clear = function clear() {
        this.axes = {};
        this.frontPlot.clear();
        this.backPlot.clear();
      };

      return AxisController;
    }();

    var calcDirection = function calcDirection(start, end) {
      var xDistance = end.x - start.x;
      var yDistance = end.y - start.y; // x 的距离大于y 说明是横向,否则就是纵向

      if (Math.abs(xDistance) > Math.abs(yDistance)) {
        return xDistance > 0 ? 'right' : 'left';
      }

      return yDistance > 0 ? 'down' : 'up';
    }; // 计算2点之间的距离


    var calcDistance = function calcDistance(point1, point2) {
      var xDistance = Math.abs(point2.x - point1.x);
      var yDistance = Math.abs(point2.y - point1.y);
      return Math.sqrt(xDistance * xDistance + yDistance * yDistance);
    };

    var getCenter = function getCenter(point1, point2) {
      var x = point1.x + (point2.x - point1.x) / 2;
      var y = point1.y + (point2.y - point1.y) / 2;
      return {
        x: x,
        y: y
      };
    };

    var PRESS_DELAY = 250;

    var EventController = /*#__PURE__*/function () {
      function EventController(_ref) {
        var _this = this;

        var canvas = _ref.canvas,
            el = _ref.el;

        _defineProperty(this, "_click", function (ev) {
          var points = convertPoints(ev, _this.canvas);
          ev.points = points;

          _this.emitEvent('click', ev);
        });

        _defineProperty(this, "_start", function (ev) {
          var points = convertPoints(ev, _this.canvas);

          if (!points) {
            return;
          }

          ev.points = points;

          _this.emitEvent('touchstart', ev); // 防止上次的内容没有清理掉,重新reset下


          _this.reset(); // 记录touch start 的时间


          _this.startTime = Date.now(); // 记录touch start 的点

          _this.startPoints = points;

          if (points.length > 1) {
            _this.startDistance = calcDistance(points[0], points[1]);
            _this.center = getCenter(points[0], points[1]);
          } else {
            // 如果touchstart后停顿250ms, 则也触发press事件
            _this.pressTimeout = setTimeout(function () {
              // 这里固定触发press事件
              var eventType = 'press';
              var direction = 'none';
              ev.direction = direction;

              _this.emitStart(eventType, ev);

              _this.emitEvent(eventType, ev);

              _this.eventType = eventType;
              _this.direction = direction;
            }, PRESS_DELAY);
          }
        });

        _defineProperty(this, "_move", function (ev) {
          var points = convertPoints(ev, _this.canvas);
          if (!points) return;

          _this.clearPressTimeout();

          ev.points = points;

          _this.emitEvent('touchmove', ev);

          var startPoints = _this.startPoints;
          if (!startPoints) return; // 多指触控

          if (points.length > 1) {
            // touchstart的距离
            var startDistance = _this.startDistance;
            var currentDistance = calcDistance(points[0], points[1]);
            ev.zoom = currentDistance / startDistance;
            ev.center = _this.center; // 触发缩放事件

            _this.emitStart('pinch', ev);

            _this.emitEvent('pinch', ev);
          } else {
            var deltaX = points[0].x - startPoints[0].x;
            var deltaY = points[0].y - startPoints[0].y;
            var direction = _this.direction || calcDirection(startPoints[0], points[0]);
            _this.direction = direction; // 获取press或者pan的事件类型
            // press 按住滑动, pan表示平移
            // 如果start后立刻move,则触发pan, 如果有停顿,则触发press

            var eventType = _this.getEventType(points);

            ev.direction = direction;
            ev.deltaX = deltaX;
            ev.deltaY = deltaY;

            _this.emitStart(eventType, ev);

            _this.emitEvent(eventType, ev); // 记录最后2次move的时间和坐标,为了给swipe事件用


            var prevMoveTime = _this.lastMoveTime;
            var now = Date.now(); // 最后2次的时间间隔一定要大于0,否则swipe没发计算

            if (now - prevMoveTime > 0) {
              _this.prevMoveTime = prevMoveTime;
              _this.prevMovePoints = _this.lastMovePoints;
              _this.lastMoveTime = now;
              _this.lastMovePoints = points;
            }
          }
        });

        _defineProperty(this, "_end", function (ev) {
          var points = convertPoints(ev, _this.canvas);
          ev.points = points;

          _this.emitEnd(ev);

          _this.emitEvent('touchend', ev); // swipe事件处理, 在touchend之后触发


          var lastMoveTime = _this.lastMoveTime;
          var now = Date.now(); // 做这个判断是为了最后一次touchmove后到end前,还有一个停顿的过程
          // 100 是拍的一个值,理论这个值会很短,一般不卡顿的话在10ms以内

          if (now - lastMoveTime < 100) {
            var prevMoveTime = _this.prevMoveTime || _this.startTime;
            var intervalTime = lastMoveTime - prevMoveTime; // 时间间隔一定要大于0, 否则计算没意义

            if (intervalTime > 0) {
              var prevMovePoints = _this.prevMovePoints || _this.startPoints;
              var lastMovePoints = _this.lastMovePoints; // move速率

              var velocity = calcDistance(prevMovePoints[0], lastMovePoints[0]) / intervalTime; // 0.3 是参考hammerjs的设置

              if (velocity > 0.3) {
                ev.velocity = velocity;
                ev.direction = calcDirection(prevMovePoints[0], lastMovePoints[0]);

                _this.emitEvent('swipe', ev);
              }
            }
          }

          _this.reset();

          var touches = ev.touches; // 当多指只释放了1指时也会触发end, 这时重新触发一次start

          if (touches && touches.length > 0) {
            _this._start(ev);
          }
        });

        _defineProperty(this, "_cancel", function (ev) {
          _this.emitEvent('touchcancel', ev);

          _this.reset();
        });

        // canvasEl
        this.canvas = canvas;
        this.delegateEvent(el); // 用来记录当前触发的事件

        this.processEvent = {};
      }

      var _proto = EventController.prototype;

      _proto.delegateEvent = function delegateEvent(canvasEl) {
        // 代理这几个事件
        canvasEl.addEventListener('click', this._click);
        canvasEl.addEventListener('touchstart', this._start);
        canvasEl.addEventListener('touchmove', this._move);
        canvasEl.addEventListener('touchend', this._end);
        canvasEl.addEventListener('touchcancel', this._cancel);
      };

      _proto.emitEvent = function emitEvent(type, ev) {
        var canvas = this.canvas;
        canvas.emit(type, ev);
      };

      _proto.getEventType = function getEventType(points) {
        var eventType = this.eventType,
            canvas = this.canvas,
            startTime = this.startTime,
            startPoints = this.startPoints;

        if (eventType) {
          return eventType;
        }

        var type;
        var panEventListeners = canvas.__events.pan; // 如果没有pan事件的监听,默认都是press

        if (!panEventListeners || !panEventListeners.length) {
          type = 'press';
        } else {
          // 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
          var now = Date.now();

          if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], points[0]) < 10) {
            type = 'press';
          } else {
            type = 'pan';
          }
        }

        this.eventType = type;
        return type;
      };

      _proto.enable = function enable(eventType) {
        this.processEvent[eventType] = true;
      } // 是否进行中的事件
      ;

      _proto.isProcess = function isProcess(eventType) {
        return this.processEvent[eventType];
      } // 触发start事件
      ;

      _proto.emitStart = function emitStart(type, ev) {
        if (this.isProcess(type)) {
          return;
        }

        this.enable(type);
        this.emitEvent(type + "start", ev);
      } // 触发end事件
      ;

      _proto.emitEnd = function emitEnd(ev) {
        var _this2 = this;

        var processEvent = this.processEvent;
        Object.keys(processEvent).forEach(function (type) {
          _this2.emitEvent(type + "end", ev);

          delete processEvent[type];
        });
      };

      _proto.clearPressTimeout = function clearPressTimeout() {
        if (this.pressTimeout) {
          clearTimeout(this.pressTimeout);
          this.pressTimeout = 0;
        }
      };

      _proto.reset = function reset() {
        this.clearPressTimeout();
        this.startTime = 0;
        this.startPoints = null;
        this.startDistance = 0;
        this.direction = null;
        this.eventType = null;
        this.pinch = false;
        this.prevMoveTime = 0;
        this.prevMovePoints = null;
        this.lastMoveTime = 0;
        this.lastMovePoints = null;
      };

      return EventController;
    }();

    var CanvasElement = /*#__PURE__*/function (_EventEmit) {
      _inheritsLoose$3(CanvasElement, _EventEmit);

      function CanvasElement(ctx) {
        var _this;

        _this = _EventEmit.call(this) || this;
        _this.context = ctx; // canvas实际的宽高 (width/height) * pixelRatio

        _this.width = 0;
        _this.height = 0;
        _this.style = {};
        _this.currentStyle = {};
        _this.attrs = {}; // 用来标识是CanvasElement实例

        _this.isCanvasElement = true;
        return _this;
      }

      var _proto = CanvasElement.prototype;

      _proto.getContext = function getContext() {
        return this.context;
      };

      _proto.getBoundingClientRect = function getBoundingClientRect() {
        var width = this.width;
        var height = this.height; // 默认都处理成可视窗口的顶部位置

        return {
          top: 0,
          right: width,
          bottom: height,
          left: 0
        };
      };

      _proto.setAttribute = function setAttribute(key, value) {
        this.attrs[key] = value;
      };

      _proto.addEventListener = function addEventListener(type, listener) {
        this.on(type, listener);
      };

      _proto.removeEventListener = function removeEventListener(type, listener) {
        this.off(type, listener);
      };

      _proto.dispatchEvent = function dispatchEvent(type, e) {
        this.emit(type, e);
      };

      return CanvasElement;
    }(EventEmit);

    function supportEventListener(canvas) {
      if (!canvas) {
        return false;
      } // 非 HTMLCanvasElement


      if (canvas.nodeType !== 1 || !canvas.nodeName || canvas.nodeName.toLowerCase() !== 'canvas') {
        return false;
      } // 微信小程序canvas.getContext('2d')时也是CanvasRenderingContext2D
      // 也会有ctx.canvas, 而且nodeType也是1,所以还要在看下是否支持addEventListener


      var support = false;

      try {
        canvas.addEventListener('eventTest', function () {
          support = true;
        });
        canvas.dispatchEvent(new Event('eventTest'));
      } catch (error) {
        support = false;
      }

      return support;
    }

    var CanvasElement$1 = {
      create: function create(ctx) {
        if (!ctx) {
          return null;
        }

        if (supportEventListener(ctx.canvas)) {
          return ctx.canvas;
        }

        return new CanvasElement(ctx);
      }
    };

    function _mod(n, m) {
      return (n % m + m) % m;
    }

    function _addStop(steps, gradient) {
      each$1(steps, function (item) {
        item = item.split(':');
        gradient.addColorStop(Number(item[0]), item[1]);
      });
    } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'


    function _parseLineGradient(color, shape, context) {
      var arr = color.split(' ');
      var angle = arr[0].slice(2, arr[0].length - 1);
      angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
      var steps = arr.slice(1);

      var _shape$getBBox = shape.getBBox(),
          minX = _shape$getBBox.minX,
          minY = _shape$getBBox.minY,
          maxX = _shape$getBBox.maxX,
          maxY = _shape$getBBox.maxY;

      var start;
      var end;

      if (angle >= 0 && angle < 0.5 * Math.PI) {
        start = {
          x: minX,
          y: minY
        };
        end = {
          x: maxX,
          y: maxY
        };
      } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
        start = {
          x: maxX,
          y: minY
        };
        end = {
          x: minX,
          y: maxY
        };
      } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
        start = {
          x: maxX,
          y: maxY
        };
        end = {
          x: minX,
          y: minY
        };
      } else {
        start = {
          x: minX,
          y: maxY
        };
        end = {
          x: maxX,
          y: minY
        };
      }

      var tanTheta = Math.tan(angle);
      var tanTheta2 = tanTheta * tanTheta;
      var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
      var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
      var gradient = context.createLinearGradient(start.x, start.y, x, y);

      _addStop(steps, gradient);

      return gradient;
    } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'


    function _parseRadialGradient(color, shape, context) {
      var arr = color.split(' ');
      var circleCfg = arr[0].slice(2, arr[0].length - 1);
      circleCfg = circleCfg.split(',');
      var fx = parseFloat(circleCfg[0]);
      var fy = parseFloat(circleCfg[1]);
      var fr = parseFloat(circleCfg[2]);
      var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color

      if (fr === 0) {
        var _color = steps[steps.length - 1];
        return _color.split(':')[1];
      }

      var _shape$getBBox2 = shape.getBBox(),
          width = _shape$getBBox2.width,
          height = _shape$getBBox2.height,
          minX = _shape$getBBox2.minX,
          minY = _shape$getBBox2.minY;

      var r = Math.sqrt(width * width + height * height) / 2;
      var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);

      _addStop(steps, gradient);

      return gradient;
    }

    function parseStyle(color, shape, context) {
      if (color[1] === '(') {
        try {
          var firstCode = color[0];

          if (firstCode === 'l') {
            return _parseLineGradient(color, shape, context);
          } else if (firstCode === 'r') {
            return _parseRadialGradient(color, shape, context);
          }
        } catch (ev) {
          console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
          console.error(ev);
        }
      }

      return color;
    }

    var ALIAS_ATTRS_MAP = {
      stroke: 'strokeStyle',
      fill: 'fillStyle',
      opacity: 'globalAlpha'
    };
    var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'shadow' // 兼容支付宝小程序
    ];
    var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];

    var Element = /*#__PURE__*/function () {
      var _proto = Element.prototype;

      _proto._initProperties = function _initProperties() {
        this._attrs = {
          zIndex: 0,
          visible: true,
          destroyed: false
        };
      };

      function Element(cfg) {
        this._initProperties();

        mix$1(this._attrs, cfg);
        var attrs = this._attrs.attrs;

        if (attrs) {
          this.initAttrs(attrs);
        }

        this.initTransform();
      }

      _proto.get = function get(name) {
        return this._attrs[name];
      };

      _proto.set = function set(name, value) {
        this._attrs[name] = value;
      };

      _proto.isGroup = function isGroup() {
        return this.get('isGroup');
      };

      _proto.isShape = function isShape() {
        return this.get('isShape');
      };

      _proto.initAttrs = function initAttrs(attrs) {
        this.attr(mix$1(this.getDefaultAttrs(), attrs));
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {};
      };

      _proto._setAttr = function _setAttr(name, value) {
        var attrs = this._attrs.attrs;

        if (name === 'clip') {
          value = this._setAttrClip(value);
        } else {
          var alias = ALIAS_ATTRS_MAP[name];

          if (alias) {
            attrs[alias] = value;
          }
        }

        attrs[name] = value;
      };

      _proto._getAttr = function _getAttr(name) {
        return this._attrs.attrs[name];
      } // _afterAttrsSet() {}
      ;

      _proto._setAttrClip = function _setAttrClip(clip) {
        if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
          if (clip.get('canvas') === null) {
            clip = Object.assign({}, clip);
          }

          clip.set('parent', this.get('parent'));
          clip.set('context', this.get('context'));
          return clip;
        }

        return null;
      };

      _proto.attr = function attr(name, value) {
        var self = this;
        if (self.get('destroyed')) return null;
        var argumentsLen = arguments.length;

        if (argumentsLen === 0) {
          return self._attrs.attrs;
        }

        if (isObject$1(name)) {
          this._attrs.bbox = null;

          for (var k in name) {
            self._setAttr(k, name[k]);
          }

          if (self._afterAttrsSet) {
            self._afterAttrsSet();
          }

          return self;
        }

        if (argumentsLen === 2) {
          this._attrs.bbox = null;

          self._setAttr(name, value);

          if (self._afterAttrsSet) {
            self._afterAttrsSet();
          }

          return self;
        }

        return self._getAttr(name);
      };

      _proto.getParent = function getParent() {
        return this.get('parent');
      };

      _proto.draw = function draw(context) {
        if (this.get('destroyed')) {
          return;
        }

        if (this.get('visible')) {
          this.setContext(context);
          this.drawInner(context);
          this.restoreContext(context);
        }
      };

      _proto.setContext = function setContext(context) {
        var clip = this._attrs.attrs.clip;
        context.save();

        if (clip) {
          clip.resetTransform(context);
          clip.createPath(context);
          context.clip();
        }

        this.resetContext(context);
        this.resetTransform(context);
      };

      _proto.restoreContext = function restoreContext(context) {
        context.restore();
      };

      _proto.resetContext = function resetContext(context) {
        var elAttrs = this._attrs.attrs;

        for (var k in elAttrs) {
          if (SHAPE_ATTRS.indexOf(k) > -1) {
            var v = elAttrs[k];

            if ((k === 'fillStyle' || k === 'strokeStyle') && v) {
              v = parseStyle(v, this, context);
            }

            if (k === 'lineDash' && context.setLineDash && isArray$1(v)) {
              context.setLineDash(v);
            } else {
              context[k] = v;
            }
          }
        }
      };

      _proto.hasFill = function hasFill() {
        return this.get('canFill') && this._attrs.attrs.fillStyle;
      };

      _proto.hasStroke = function hasStroke() {
        return this.get('canStroke') && this._attrs.attrs.strokeStyle;
      };

      _proto.drawInner = function drawInner() {};

      _proto.show = function show() {
        this.set('visible', true);
        return this;
      };

      _proto.hide = function hide() {
        this.set('visible', false);
        return this;
      };

      _proto.isVisible = function isVisible() {
        return this.get('visible');
      };

      _proto.getAriaLabel = function getAriaLabel() {
        var _this$_attrs = this._attrs,
            destroyed = _this$_attrs.destroyed,
            visible = _this$_attrs.visible,
            isShape = _this$_attrs.isShape,
            aria = _this$_attrs.aria;

        if (destroyed || !visible || isShape && !aria) {
          return;
        }

        return this._getAriaLabel();
      };

      _proto._getAriaLabel = function _getAriaLabel() {
        return this._attrs.ariaLabel;
      };

      _proto._removeFromParent = function _removeFromParent() {
        var parent = this.get('parent');

        if (parent) {
          var children = parent.get('children');
          remove(children, this);
        }

        return this;
      };

      _proto.remove = function remove(destroy) {
        if (destroy) {
          this.destroy();
        } else {
          this._removeFromParent();
        }
      };

      _proto.destroy = function destroy() {
        var destroyed = this.get('destroyed');

        if (destroyed) {
          return null;
        }

        this._removeFromParent();

        this._attrs = {};
        this.set('destroyed', true);
      };

      _proto.getBBox = function getBBox() {
        return {
          minX: 0,
          maxX: 0,
          minY: 0,
          maxY: 0,
          width: 0,
          height: 0
        };
      };

      _proto.initTransform = function initTransform() {
        var attrs = this._attrs.attrs || {};

        if (!attrs.matrix) {
          attrs.matrix = [1, 0, 0, 1, 0, 0];
        }

        this._attrs.attrs = attrs;
      };

      _proto.getMatrix = function getMatrix() {
        return this._attrs.attrs.matrix;
      };

      _proto.setMatrix = function setMatrix(m) {
        this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
      };

      _proto.transform = function transform(actions) {
        var matrix = this._attrs.attrs.matrix;
        this._attrs.attrs.matrix = Matrix.transform(matrix, actions);
        return this;
      };

      _proto.setTransform = function setTransform(actions) {
        this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
        return this.transform(actions);
      };

      _proto.translate = function translate(x, y) {
        var matrix = this._attrs.attrs.matrix;
        Matrix.translate(matrix, matrix, [x, y]);
      };

      _proto.rotate = function rotate(rad) {
        var matrix = this._attrs.attrs.matrix;
        Matrix.rotate(matrix, matrix, rad);
      };

      _proto.scale = function scale(sx, sy) {
        var matrix = this._attrs.attrs.matrix;
        Matrix.scale(matrix, matrix, [sx, sy]);
      };

      _proto.moveTo = function moveTo(x, y) {
        var cx = this._attrs.x || 0;
        var cy = this._attrs.y || 0;
        this.translate(x - cx, y - cy);
        this.set('x', x);
        this.set('y', y);
      };

      _proto.apply = function apply(v) {
        var m = this._attrs.attrs.matrix;
        Vector2.transformMat2d(v, v, m);
        return this;
      };

      _proto.resetTransform = function resetTransform(context) {
        var mo = this._attrs.attrs.matrix;

        if (Matrix.isChanged(mo)) {
          context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
        }
      };

      _proto.isDestroyed = function isDestroyed() {
        return this.get('destroyed');
      };

      return Element;
    }();

    var Shape = /*#__PURE__*/function (_Element) {
      _inheritsLoose$3(Shape, _Element);

      function Shape() {
        return _Element.apply(this, arguments) || this;
      }

      var _proto = Shape.prototype;

      _proto._initProperties = function _initProperties() {
        this._attrs = {
          zIndex: 0,
          visible: true,
          destroyed: false,
          isShape: true,
          attrs: {}
        };
      };

      _proto.getType = function getType() {
        return this._attrs.type;
      };

      _proto.drawInner = function drawInner(context) {
        var self = this;
        var attrs = self.get('attrs');
        self.createPath(context);
        var originOpacity = context.globalAlpha;

        if (self.hasFill()) {
          var fillOpacity = attrs.fillOpacity;

          if (!isNil$1(fillOpacity) && fillOpacity !== 1) {
            context.globalAlpha = fillOpacity;
            context.fill();
            context.globalAlpha = originOpacity;
          } else {
            context.fill();
          }
        }

        if (self.hasStroke()) {
          var lineWidth = attrs.lineWidth;

          if (lineWidth > 0) {
            var strokeOpacity = attrs.strokeOpacity;

            if (!isNil$1(strokeOpacity) && strokeOpacity !== 1) {
              context.globalAlpha = strokeOpacity;
            }

            context.stroke();
          }
        }
      };

      _proto.getBBox = function getBBox() {
        var bbox = this._attrs.bbox;

        if (!bbox) {
          bbox = this.calculateBox();

          if (bbox) {
            bbox.x = bbox.minX;
            bbox.y = bbox.minY;
            bbox.width = bbox.maxX - bbox.minX;
            bbox.height = bbox.maxY - bbox.minY;
          }

          this._attrs.bbox = bbox;
        }

        return bbox;
      };

      _proto.calculateBox = function calculateBox() {
        return null;
      };

      _proto.createPath = function createPath() {};

      return Shape;
    }(Element);

    function parseRadius(radius, width, height) {
      radius = parsePadding(radius); // 都为0

      if (!radius[0] && !radius[1] && !radius[2] && !radius[3]) {
        return radius;
      }

      var minWidth = Math.max(radius[0] + radius[1], radius[2] + radius[3]);
      var minHeight = Math.max(radius[0] + radius[3], radius[1] + radius[2]);
      var scale = Math.min(width / minWidth, height / minHeight);

      if (scale < 1) {
        return radius.map(function (r) {
          return r * scale;
        });
      }

      return radius;
    }

    var Rect$2 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Rect, _Shape);

      function Rect() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Rect.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'rect';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x: 0,
          y: 0,
          width: 0,
          height: 0,
          radius: 0,
          lineWidth: 0
        };
      };

      _proto.createRadiusPath = function createRadiusPath(context, x, y, width, height, radius) {
        radius = parseRadius(radius, width, height);
        context.moveTo(x + radius[0], y);
        context.lineTo(x + width - radius[1], y);
        context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
        context.lineTo(x + width, y + height - radius[2]);
        context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
        context.lineTo(x + radius[3], y + height);
        context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
        context.lineTo(x, y + radius[0]);
        context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
        context.closePath();
      };

      _proto.createPath = function createPath(context) {
        var self = this;
        var attrs = self.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            width = attrs.width,
            height = attrs.height,
            radius = attrs.radius;
        context.beginPath();

        if (!radius || !(width * height)) {
          context.rect(x, y, width, height);
        } else {
          this.createRadiusPath(context, x, y, width, height, radius);
        }
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            width = attrs.width,
            height = attrs.height;
        return {
          minX: x,
          minY: y,
          maxX: x + width,
          maxY: y + height
        };
      };

      return Rect;
    }(Shape);

    var imageCaches = {};

    var ImageShape = /*#__PURE__*/function (_Rect) {
      _inheritsLoose$3(ImageShape, _Rect);

      function ImageShape() {
        return _Rect.apply(this, arguments) || this;
      }

      var _proto = ImageShape.prototype;

      _proto._initProperties = function _initProperties() {
        _Rect.prototype._initProperties.call(this);

        this._attrs.canFill = false;
        this._attrs.canStroke = false;
        this._attrs.loading = false;
        this._attrs.image = null;
        this._attrs.type = 'image';
      };

      _proto.draw = function draw(context) {
        var _this = this;

        // 如果图片还在loading中直接返回,等下次绘制
        if (this.get('loading')) {
          return;
        } // 如果已经有image对象,直接绘制,会调用createPath绘制


        var image = this.get('image');

        if (image) {
          _Rect.prototype.draw.call(this, context);

          return;
        }

        var attrs = this.get('attrs');
        var src = attrs.src;

        if (src && window.Image) {
          var cacheImage = this.get('cacheImage'); // 如果有缓存,则直接从缓存中拿

          if (cacheImage && imageCaches[src]) {
            this.set('image', imageCaches[src]);
            this.draw(context);
            return;
          }

          this.set('loading', true);

          var _image = new Image(); // 设置跨域, 等同于 image.crossOrigin = 'anonymous'


          _image.crossOrigin = '';

          _image.onload = function () {
            _this.set('loading', false);

            _this.set('image', _image);

            _this.draw(context);
          }; // src 一定要在 crossOrigin 之后,否则 toDataURL 就会报 SecurityError


          _image.src = src; // 设置全局缓存

          if (cacheImage) {
            imageCaches[src] = _image;
          }
        }
      };

      _proto.createPath = function createPath(context) {
        var image = this.get('image');
        this.drawImage(context, image);
      };

      _proto.drawImage = function drawImage(context, image) {
        var _this$_attrs = this._attrs,
            attrs = _this$_attrs.attrs,
            destroyed = _this$_attrs.destroyed;

        if (destroyed) {
          return;
        }

        var x = attrs.x,
            y = attrs.y,
            width = attrs.width,
            height = attrs.height,
            sx = attrs.sx,
            sy = attrs.sy,
            swidth = attrs.swidth,
            sheight = attrs.sheight,
            radius = attrs.radius,
            fillOpacity = attrs.fillOpacity;

        if (radius) {
          context.save();
          this.createRadiusPath(context, x, y, width, height, radius);
          context.clip();
        } // 设置透明度


        var originOpacity = context.globalAlpha;

        if (!isNil$1(fillOpacity)) {
          context.globalAlpha = fillOpacity;
        }

        if (!isNil$1(sx) && !isNil$1(sy) && !isNil$1(swidth) && !isNil$1(sheight)) {
          context.drawImage(image, sx, sy, swidth, sheight, x, y, width, height);
        } else {
          context.drawImage(image, x, y, width, height);
        }

        context.globalAlpha = originOpacity;

        if (radius) {
          // 因为 save 和 restore 会一定程度上影响绘图性能,所以只在必要是调用
          context.restore();
        }
      };

      return ImageShape;
    }(Rect$2);

    var Circle$1 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Circle, _Shape);

      function Circle() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Circle.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'circle';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x: 0,
          y: 0,
          r: 0,
          lineWidth: 0
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            r = attrs.r;
        context.beginPath();
        context.arc(x, y, r, 0, Math.PI * 2, false);
        context.closePath();
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            r = attrs.r;
        return {
          minX: x - r,
          maxX: x + r,
          minY: y - r,
          maxY: y + r
        };
      };

      return Circle;
    }(Shape);

    var start = Vector2.create();
    var end = Vector2.create();
    var extremity = Vector2.create();

    function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
      var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
      var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
      return {
        x: x,
        y: y
      };
    } // cubic helper formula at T distance


    function CubicN(T, a, b, c, d) {
      var t2 = T * T;
      var t3 = t2 * T;
      return a + (-a * 3 + T * (3 * a - a * T)) * T + (3 * b + T * (-6 * b + b * 3 * T)) * T + (c * 3 - c * 3 * T) * t2 + d * t3;
    }

    function cubicBezierBounds(c) {
      var minX = Infinity;
      var maxX = -Infinity;
      var minY = Infinity;
      var maxY = -Infinity;
      var s = {
        x: c[0],
        y: c[1]
      };
      var c1 = {
        x: c[2],
        y: c[3]
      };
      var c2 = {
        x: c[4],
        y: c[5]
      };
      var e = {
        x: c[6],
        y: c[7]
      };

      for (var t = 0; t < 100; t++) {
        var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);

        if (pt.x < minX) {
          minX = pt.x;
        }

        if (pt.x > maxX) {
          maxX = pt.x;
        }

        if (pt.y < minY) {
          minY = pt.y;
        }

        if (pt.y > maxY) {
          maxY = pt.y;
        }
      }

      return {
        minX: minX,
        minY: minY,
        maxX: maxX,
        maxY: maxY
      };
    }

    function getBBoxFromPoints(points, lineWidth) {
      if (points.length === 0) {
        return;
      }

      var p = points[0];
      var left = p.x;
      var right = p.x;
      var top = p.y;
      var bottom = p.y;
      var len = points.length;

      for (var i = 1; i < len; i++) {
        p = points[i];
        left = Math.min(left, p.x);
        right = Math.max(right, p.x);
        top = Math.min(top, p.y);
        bottom = Math.max(bottom, p.y);
      }

      lineWidth = lineWidth / 2 || 0;
      return {
        minX: left - lineWidth,
        minY: top - lineWidth,
        maxX: right + lineWidth,
        maxY: bottom + lineWidth
      };
    }

    function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
      lineWidth = lineWidth / 2 || 0;
      return {
        minX: Math.min(x0, x1) - lineWidth,
        minY: Math.min(y0, y1) - lineWidth,
        maxX: Math.max(x0, x1) + lineWidth,
        maxY: Math.max(y0, y1) + lineWidth
      };
    }

    function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
      var diff = Math.abs(startAngle - endAngle);

      if (diff % (Math.PI * 2) < 1e-4 && diff > 1e-4) {
        // Is a circle
        return {
          minX: x - r,
          minY: y - r,
          maxX: x + r,
          maxY: y + r
        };
      }

      start[0] = Math.cos(startAngle) * r + x;
      start[1] = Math.sin(startAngle) * r + y;
      end[0] = Math.cos(endAngle) * r + x;
      end[1] = Math.sin(endAngle) * r + y;
      var min = [0, 0];
      var max = [0, 0];
      Vector2.min(min, start, end);
      Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]

      startAngle = startAngle % (Math.PI * 2);

      if (startAngle < 0) {
        startAngle = startAngle + Math.PI * 2;
      }

      endAngle = endAngle % (Math.PI * 2);

      if (endAngle < 0) {
        endAngle = endAngle + Math.PI * 2;
      }

      if (startAngle > endAngle && !anticlockwise) {
        endAngle += Math.PI * 2;
      } else if (startAngle < endAngle && anticlockwise) {
        startAngle += Math.PI * 2;
      }

      if (anticlockwise) {
        var tmp = endAngle;
        endAngle = startAngle;
        startAngle = tmp;
      }

      for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
        if (angle > startAngle) {
          extremity[0] = Math.cos(angle) * r + x;
          extremity[1] = Math.sin(angle) * r + y;
          Vector2.min(min, extremity, min);
          Vector2.max(max, extremity, max);
        }
      }

      return {
        minX: min[0],
        minY: min[1],
        maxX: max[0],
        maxY: max[1]
      };
    }

    function getBBoxFromBezierGroup(points, lineWidth) {
      var minX = Infinity;
      var maxX = -Infinity;
      var minY = Infinity;
      var maxY = -Infinity;

      for (var i = 0, len = points.length; i < len; i++) {
        var bbox = cubicBezierBounds(points[i]);

        if (bbox.minX < minX) {
          minX = bbox.minX;
        }

        if (bbox.maxX > maxX) {
          maxX = bbox.maxX;
        }

        if (bbox.minY < minY) {
          minY = bbox.minY;
        }

        if (bbox.maxY > maxY) {
          maxY = bbox.maxY;
        }
      }

      lineWidth = lineWidth / 2 || 0;
      return {
        minX: minX - lineWidth,
        minY: minY - lineWidth,
        maxX: maxX + lineWidth,
        maxY: maxY + lineWidth
      };
    }

    var Line$2 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Line, _Shape);

      function Line() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Line.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canStroke = true;
        this._attrs.type = 'line';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x1: 0,
          y1: 0,
          x2: 0,
          y2: 0,
          lineWidth: 1
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs');
        var x1 = attrs.x1,
            y1 = attrs.y1,
            x2 = attrs.x2,
            y2 = attrs.y2;
        context.beginPath();
        context.moveTo(x1, y1);
        context.lineTo(x2, y2);
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x1 = attrs.x1,
            y1 = attrs.y1,
            x2 = attrs.x2,
            y2 = attrs.y2,
            lineWidth = attrs.lineWidth;
        return getBBoxFromLine(x1, y1, x2, y2, lineWidth);
      };

      return Line;
    }(Shape);

    var Polygon$1 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Polygon, _Shape);

      function Polygon() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Polygon.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'polygon';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          points: null,
          lineWidth: 0
        };
      };

      _proto.createPath = function createPath(context) {
        var self = this;
        var attrs = self.get('attrs');
        var points = attrs.points;
        context.beginPath();

        for (var i = 0, len = points.length; i < len; i++) {
          var point = points[i];

          if (i === 0) {
            context.moveTo(point.x, point.y);
          } else {
            context.lineTo(point.x, point.y);
          }
        }

        context.closePath();
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var points = attrs.points;
        return getBBoxFromPoints(points);
      };

      return Polygon;
    }(Shape);

    /**
     * @fileOverview convert the line to curve
     * @author dxq613@gmail.com
     */

    function getPoint(v) {
      return [v.x, v.y];
    }

    function smoothBezier(points, smooth, isLoop, constraint) {
      var cps = [];
      var prevPoint;
      var nextPoint;
      var hasConstraint = !!constraint;
      var min;
      var max;
      var point;
      var len;
      var l;
      var i;

      if (hasConstraint) {
        min = [Infinity, Infinity];
        max = [-Infinity, -Infinity];

        for (i = 0, l = points.length; i < l; i++) {
          point = getPoint(points[i]);
          Vector2.min(min, min, point);
          Vector2.max(max, max, point);
        }

        Vector2.min(min, min, constraint[0]);
        Vector2.max(max, max, constraint[1]);
      }

      for (i = 0, len = points.length; i < len; i++) {
        point = getPoint(points[i]);

        if (isLoop) {
          prevPoint = getPoint(points[i ? i - 1 : len - 1]);
          nextPoint = getPoint(points[(i + 1) % len]);
        } else {
          if (i === 0 || i === len - 1) {
            cps.push([point[0], point[1]]);
            continue;
          } else {
            prevPoint = getPoint(points[i - 1]);
            nextPoint = getPoint(points[i + 1]);
          }
        }

        var v = Vector2.sub([], nextPoint, prevPoint);
        Vector2.scale(v, v, smooth);
        var d0 = Vector2.distance(point, prevPoint);
        var d1 = Vector2.distance(point, nextPoint);
        var sum = d0 + d1;

        if (sum !== 0) {
          d0 /= sum;
          d1 /= sum;
        }

        var v1 = Vector2.scale([], v, -d0);
        var v2 = Vector2.scale([], v, d1);
        var cp0 = Vector2.add([], point, v1);
        var cp1 = Vector2.add([], point, v2);

        if (hasConstraint) {
          Vector2.max(cp0, cp0, min);
          Vector2.min(cp0, cp0, max);
          Vector2.max(cp1, cp1, min);
          Vector2.min(cp1, cp1, max);
        }

        cps.push([cp0[0], cp0[1]]);
        cps.push([cp1[0], cp1[1]]);
      }

      if (isLoop) {
        cps.push(cps.shift());
      }

      return cps;
    }

    function catmullRom2bezier(pointList, z, constraint) {
      var isLoop = !!z;
      var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
      var len = pointList.length;
      var d1 = [];
      var cp1;
      var cp2;
      var p;

      for (var i = 0; i < len - 1; i++) {
        cp1 = controlPointList[i * 2];
        cp2 = controlPointList[i * 2 + 1];
        p = pointList[i + 1];
        d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
      }

      if (isLoop) {
        cp1 = controlPointList[len];
        cp2 = controlPointList[len + 1];
        p = pointList[0];
        d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
      }

      return d1;
    }

    function _filterPoints(points) {
      var filteredPoints = [];

      for (var i = 0, len = points.length; i < len; i++) {
        var point = points[i];

        if (!isNaN(point.x) && !isNaN(point.y)) {
          filteredPoints.push(point);
        }
      }

      return filteredPoints;
    }

    var Polyline = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Polyline, _Shape);

      function Polyline() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Polyline.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'polyline';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          points: null,
          lineWidth: 1,
          smooth: false
        };
      };

      _proto.createPath = function createPath(context) {
        var self = this;
        var attrs = self.get('attrs');
        var points = attrs.points,
            smooth = attrs.smooth;

        var filteredPoints = _filterPoints(points);

        context.beginPath();

        if (filteredPoints.length) {
          context.moveTo(filteredPoints[0].x, filteredPoints[0].y);

          if (smooth) {
            var constaint = [[0, 0], [1, 1]];
            var sps = catmullRom2bezier(filteredPoints, false, constaint);

            for (var i = 0, n = sps.length; i < n; i++) {
              var sp = sps[i];
              context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
            }
          } else {
            var _i;

            var l;

            for (_i = 1, l = filteredPoints.length - 1; _i < l; _i++) {
              context.lineTo(filteredPoints[_i].x, filteredPoints[_i].y);
            }

            context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
          }
        }
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var points = attrs.points,
            smooth = attrs.smooth,
            lineWidth = attrs.lineWidth;

        var filteredPoints = _filterPoints(points);

        if (smooth) {
          var newPoints = [];
          var constaint = [[0, 0], [1, 1]];
          var sps = catmullRom2bezier(filteredPoints, false, constaint);

          for (var i = 0, n = sps.length; i < n; i++) {
            var sp = sps[i];

            if (i === 0) {
              newPoints.push([filteredPoints[0].x, filteredPoints[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
            } else {
              var lastPoint = sps[i - 1];
              newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
            }
          }

          return getBBoxFromBezierGroup(newPoints, lineWidth);
        }

        return getBBoxFromPoints(filteredPoints, lineWidth);
      };

      return Polyline;
    }(Shape);

    var Arc$1 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Arc, _Shape);

      function Arc() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Arc.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canStroke = true;
        this._attrs.canFill = true;
        this._attrs.type = 'arc';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x: 0,
          y: 0,
          r: 0,
          startAngle: 0,
          endAngle: Math.PI * 2,
          anticlockwise: false,
          lineWidth: 1
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            r = attrs.r,
            startAngle = attrs.startAngle,
            endAngle = attrs.endAngle,
            anticlockwise = attrs.anticlockwise;
        context.beginPath();

        if (startAngle !== endAngle) {
          context.arc(x, y, r, startAngle, endAngle, anticlockwise);
        }
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            r = attrs.r,
            startAngle = attrs.startAngle,
            endAngle = attrs.endAngle,
            anticlockwise = attrs.anticlockwise;
        return getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
      };

      return Arc;
    }(Shape);

    var Sector = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Sector, _Shape);

      function Sector() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Sector.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'sector';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x: 0,
          y: 0,
          lineWidth: 0,
          r: 0,
          r0: 0,
          startAngle: 0,
          endAngle: Math.PI * 2,
          anticlockwise: false
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            startAngle = attrs.startAngle,
            endAngle = attrs.endAngle,
            r = attrs.r,
            r0 = attrs.r0,
            anticlockwise = attrs.anticlockwise;
        context.beginPath();
        var unitX = Math.cos(startAngle);
        var unitY = Math.sin(startAngle);
        context.moveTo(unitX * r0 + x, unitY * r0 + y);
        context.lineTo(unitX * r + x, unitY * r + y); // 当扇形的角度非常小的时候,就不进行弧线的绘制;或者整个只有1个扇形时,会出现end<0的情况不绘制

        if (Math.abs(endAngle - startAngle) > 0.0001 || startAngle === 0 && endAngle < 0) {
          context.arc(x, y, r, startAngle, endAngle, anticlockwise);
          context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);

          if (r0 !== 0) {
            context.arc(x, y, r0, endAngle, startAngle, !anticlockwise);
          }
        }

        context.closePath();
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            r = attrs.r,
            r0 = attrs.r0,
            startAngle = attrs.startAngle,
            endAngle = attrs.endAngle,
            anticlockwise = attrs.anticlockwise;
        var outerBBox = getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
        var innerBBox = getBBoxFromArc(x, y, r0, startAngle, endAngle, anticlockwise);
        return {
          minX: Math.min(outerBBox.minX, innerBBox.minX),
          minY: Math.min(outerBBox.minY, innerBBox.minY),
          maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
          maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
        };
      };

      return Sector;
    }(Shape);

    var Rect$1 = {
      calcRotatedBox: function calcRotatedBox(_ref) {
        var width = _ref.width,
            height = _ref.height,
            rotate = _ref.rotate;
        var absRotate = Math.abs(rotate);
        return {
          width: Math.abs(width * Math.cos(absRotate) + height * Math.sin(absRotate)),
          height: Math.abs(height * Math.cos(absRotate) + width * Math.sin(absRotate))
        };
      }
    };

    var textWidthCacheCounter = 0;
    var textWidthCache = {};
    var TEXT_CACHE_MAX = 5000;

    var Text$1 = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Text, _Shape);

      function Text() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Text.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'text';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          lineWidth: 0,
          lineCount: 1,
          fontSize: 12,
          fontFamily: 'sans-serif',
          fontStyle: 'normal',
          fontWeight: 'normal',
          fontVariant: 'normal',
          textAlign: 'start',
          textBaseline: 'bottom',
          lineHeight: null,
          textArr: null
        };
      };

      _proto._getFontStyle = function _getFontStyle() {
        var attrs = this._attrs.attrs;
        var fontSize = attrs.fontSize,
            fontFamily = attrs.fontFamily,
            fontWeight = attrs.fontWeight,
            fontStyle = attrs.fontStyle,
            fontVariant = attrs.fontVariant;
        return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
      };

      _proto._afterAttrsSet = function _afterAttrsSet() {
        var attrs = this._attrs.attrs;
        attrs.font = this._getFontStyle();

        if (attrs.text) {
          var text = attrs.text;
          var textArr = null;
          var lineCount = 1;

          if (isString(text) && text.indexOf('\n') !== -1) {
            textArr = text.split('\n');
            lineCount = textArr.length;
          }

          attrs.lineCount = lineCount;
          attrs.textArr = textArr;
        }

        this.set('attrs', attrs);
      };

      _proto._getTextHeight = function _getTextHeight() {
        var attrs = this._attrs.attrs;

        if (attrs.height) {
          return attrs.height;
        }

        var lineCount = attrs.lineCount;
        var fontSize = attrs.fontSize * 1;

        if (lineCount > 1) {
          var spaceingY = this._getSpaceingY();

          return fontSize * lineCount + spaceingY * (lineCount - 1);
        }

        return fontSize;
      };

      _proto._getSpaceingY = function _getSpaceingY() {
        var attrs = this._attrs.attrs;
        var lineHeight = attrs.lineHeight;
        var fontSize = attrs.fontSize * 1;
        return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
      };

      _proto.drawInner = function drawInner(context) {
        var self = this;
        var attrs = self._attrs.attrs;
        var text = attrs.text;
        var x = attrs.x;
        var y = attrs.y;

        if (isNil$1(text) || isNaN(x) || isNaN(y)) {
          // text will be 0
          return;
        }

        var textArr = attrs.textArr;
        var fontSize = attrs.fontSize * 1;

        var spaceingY = self._getSpaceingY();

        if (attrs.rotate) {
          // do rotation
          context.translate(x, y);
          context.rotate(attrs.rotate);
          x = 0;
          y = 0;
        }

        var textBaseline = attrs.textBaseline;
        var height;

        if (textArr) {
          height = self._getTextHeight();
        }

        var subY; // context.beginPath();

        if (self.hasFill()) {
          var fillOpacity = attrs.fillOpacity;

          if (!isNil$1(fillOpacity) && fillOpacity !== 1) {
            context.globalAlpha = fillOpacity;
          }

          if (textArr) {
            for (var i = 0, len = textArr.length; i < len; i++) {
              var subText = textArr[i];
              subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;

              if (textBaseline === 'middle') {
                subY += height - fontSize - (height - fontSize) / 2;
              }

              if (textBaseline === 'top') {
                subY += height - fontSize;
              }

              context.fillText(subText, x, subY);
            }
          } else {
            context.fillText(text, x, y);
          }
        }

        if (self.hasStroke()) {
          if (textArr) {
            for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
              var _subText = textArr[_i];
              subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;

              if (textBaseline === 'middle') {
                subY += height - fontSize - (height - fontSize) / 2;
              }

              if (textBaseline === 'top') {
                subY += height - fontSize;
              }

              context.strokeText(_subText, x, subY);
            }
          } else {
            context.strokeText(text, x, y);
          }
        }
      };

      _proto._getAriaLabel = function _getAriaLabel() {
        return this._attrs.attrs.text;
      };

      _proto.calculateBox = function calculateBox() {
        var self = this;
        var attrs = self._attrs.attrs;
        var x = attrs.x,
            y = attrs.y,
            textAlign = attrs.textAlign,
            textBaseline = attrs.textBaseline;

        var width = self._getTextWidth(); // attrs.width


        if (!width) {
          return {
            minX: x,
            minY: y,
            maxX: x,
            maxY: y
          };
        }

        var height = self._getTextHeight(); // attrs.height


        if (attrs.rotate) {
          var rotatedBox = Rect$1.calcRotatedBox({
            width: width,
            height: height,
            rotate: attrs.rotate
          });
          width = rotatedBox.width;
          height = rotatedBox.height;
        }

        var point = {
          x: x,
          y: y - height
        }; // default textAlign: start, textBaseline: bottom

        if (textAlign) {
          if (textAlign === 'end' || textAlign === 'right') {
            point.x -= width;
          } else if (textAlign === 'center') {
            point.x -= width / 2;
          }
        }

        if (textBaseline) {
          if (textBaseline === 'top') {
            point.y += height;
          } else if (textBaseline === 'middle') {
            point.y += height / 2;
          }
        }

        return {
          minX: point.x,
          minY: point.y,
          maxX: point.x + width,
          maxY: point.y + height
        };
      };

      _proto._getTextWidth = function _getTextWidth() {
        var attrs = this._attrs.attrs;

        if (attrs.width) {
          return attrs.width;
        }

        var text = attrs.text;
        var context = this.get('context');
        if (isNil$1(text)) return undefined;
        var font = attrs.font;
        var textArr = attrs.textArr;
        var key = text + '' + font;

        if (textWidthCache[key]) {
          return textWidthCache[key];
        }

        var width = 0;

        if (textArr) {
          for (var i = 0, length = textArr.length; i < length; i++) {
            var subText = textArr[i];
            width = Math.max(width, measureText(subText, font, context).width);
          }
        } else {
          width = measureText(text, font, context).width;
        }

        if (textWidthCacheCounter > TEXT_CACHE_MAX) {
          textWidthCacheCounter = 0;
          textWidthCache = {};
        }

        textWidthCacheCounter++;
        textWidthCache[key] = width;
        return width;
      };

      return Text;
    }(Shape);

    var Custom = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Custom, _Shape);

      function Custom() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Custom.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.createPath = null;
        this._attrs.type = 'custom';
      };

      _proto.createPath = function createPath(context) {
        var createPath = this.get('createPath');
        createPath && createPath.call(this, context);
      };

      _proto.calculateBox = function calculateBox() {
        var calculateBox = this.get('calculateBox');
        return calculateBox && calculateBox.call(this);
      };

      return Custom;
    }(Shape);

    var SYMBOLS = {
      circle: function circle(x, y, r, ctx) {
        ctx.arc(x, y, r, 0, Math.PI * 2, false);
      },
      square: function square(x, y, r, ctx) {
        ctx.moveTo(x - r, y - r);
        ctx.lineTo(x + r, y - r);
        ctx.lineTo(x + r, y + r);
        ctx.lineTo(x - r, y + r);
        ctx.closePath();
      }
    };

    var Marker = /*#__PURE__*/function (_Shape) {
      _inheritsLoose$3(Marker, _Shape);

      function Marker() {
        return _Shape.apply(this, arguments) || this;
      }

      var _proto = Marker.prototype;

      _proto._initProperties = function _initProperties() {
        _Shape.prototype._initProperties.call(this);

        this._attrs.canFill = true;
        this._attrs.canStroke = true;
        this._attrs.type = 'marker';
      };

      _proto.getDefaultAttrs = function getDefaultAttrs() {
        return {
          x: 0,
          y: 0,
          lineWidth: 0
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            radius = attrs.radius;
        var symbol = attrs.symbol || 'circle';
        var method;

        if (isFunction$1(symbol)) {
          method = symbol;
        } else {
          method = SYMBOLS[symbol];
        }

        context.beginPath();
        method(x, y, radius, context, this);
      };

      _proto.calculateBox = function calculateBox() {
        var attrs = this.get('attrs');
        var x = attrs.x,
            y = attrs.y,
            radius = attrs.radius;
        return {
          minX: x - radius,
          minY: y - radius,
          maxX: x + radius,
          maxY: y + radius
        };
      };

      return Marker;
    }(Shape);

    Shape.Rect = Rect$2;
    Shape.Image = ImageShape;
    Shape.Circle = Circle$1;
    Shape.Line = Line$2;
    Shape.Polygon = Polygon$1;
    Shape.Polyline = Polyline;
    Shape.Arc = Arc$1;
    Shape.Sector = Sector;
    Shape.Text = Text$1;
    Shape.Custom = Custom;
    Shape.Marker = Marker;

    var SHAPE_MAP = {};
    var INDEX = '_INDEX';

    function getComparer(compare) {
      return function (left, right) {
        var result = compare(left, right);
        return result === 0 ? left[INDEX] - right[INDEX] : result;
      };
    }

    var Container = {
      getGroupClass: function getGroupClass() {},
      getChildren: function getChildren() {
        return this.get('children');
      },
      addShape: function addShape(type, cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        var shapeType = SHAPE_MAP[type];

        if (!shapeType) {
          shapeType = upperFirst(type);
          SHAPE_MAP[type] = shapeType;
        }

        var shape = new Shape[shapeType](cfg);
        this.add(shape);
        return shape;
      },
      addGroup: function addGroup(cfg) {
        var groupClass = this.getGroupClass();
        var rst = new groupClass(cfg);
        this.add(rst);
        return rst;
      },
      contain: function contain(item) {
        var children = this.get('children');
        return children.indexOf(item) > -1;
      },
      sort: function sort() {
        var children = this.get('children');

        for (var i = 0, len = children.length; i < len; i++) {
          var child = children[i];
          child[INDEX] = i;
        }

        children.sort(getComparer(function (obj1, obj2) {
          return obj1.get('zIndex') - obj2.get('zIndex');
        }));
        return this;
      },
      drawChildren: function drawChildren(context) {
        var children = this.get('children');

        for (var i = 0, len = children.length; i < len; i++) {
          var child = children[i];
          child.draw(context);
        }

        return this;
      },
      clear: function clear() {
        var children = this.get('children');

        while (children.length !== 0) {
          children[children.length - 1].remove(true);
        }

        return this;
      },
      add: function add(items) {
        var self = this;
        var children = self.get('children');

        if (!isArray$1(items)) {
          items = [items];
        }

        for (var i = 0, len = items.length; i < len; i++) {
          var item = items[i];
          var parent = item.get('parent');

          if (parent) {
            var descendants = parent.get('children');
            remove(descendants, item);
          }

          self._setEvn(item);

          children.push(item);
        }

        return self;
      },
      _setEvn: function _setEvn(item) {
        var self = this;
        var _self$_attrs = self._attrs,
            context = _self$_attrs.context,
            canvas = _self$_attrs.canvas,
            aria = _self$_attrs.aria;
        var _item$_attrs = item._attrs,
            isGroup = _item$_attrs.isGroup,
            type = _item$_attrs.type;
        item._attrs.parent = self;
        item._attrs.context = context;
        item._attrs.canvas = canvas; // 是否需要无障碍处理

        if (aria && item._attrs.aria !== false) {
          item._attrs.aria = aria;
        }

        if (type === 'text' && canvas && canvas.get('fontFamily')) {
          item._attrs.attrs.fontFamily = item._attrs.attrs.fontFamily || canvas.get('fontFamily');
        }

        var clip = item._attrs.attrs.clip;

        if (clip) {
          clip._attrs.parent = self;
          clip._attrs.context = context;
          clip._attrs.canvas = canvas;
        }

        if (isGroup) {
          var children = item._attrs.children;

          for (var i = 0, len = children.length; i < len; i++) {
            item._setEvn(children[i]);
          }
        }
      },
      _getAriaLabel: function _getAriaLabel() {
        var _this$_attrs = this._attrs,
            aria = _this$_attrs.aria,
            ariaLabel = _this$_attrs.ariaLabel,
            children = _this$_attrs.children; // 主动关闭

        if (!aria) return;
        var childAriaLabels = [];

        if (children && children.length) {
          for (var i = 0, len = children.length; i < len; i++) {
            var _childAriaLabel = children[i].getAriaLabel();

            if (_childAriaLabel) {
              childAriaLabels.push(_childAriaLabel);
            }
          }
        }

        var childAriaLabel = childAriaLabels.join(' '); // 2个都有时拼接成完整句子

        if (ariaLabel && childAriaLabel) {
          return ariaLabel + " " + childAriaLabel + " ";
        } // 只有1个,或者都没有


        return ariaLabel || childAriaLabel;
      }
    };

    var Group = /*#__PURE__*/function (_Rect) {
      _inheritsLoose$3(Group, _Rect);

      function Group() {
        return _Rect.apply(this, arguments) || this;
      }

      var _proto = Group.prototype;

      _proto._initProperties = function _initProperties() {
        this._attrs = {
          type: 'group',
          zIndex: 0,
          visible: true,
          destroyed: false,
          isGroup: true,
          canFill: true,
          canStroke: true,
          attrs: {},
          children: []
        };
      };

      _proto.getBBox = function getBBox() {
        var self = this;
        var minX = Infinity;
        var maxX = -Infinity;
        var minY = Infinity;
        var maxY = -Infinity;
        var children = self.get('children');

        for (var i = 0, length = children.length; i < length; i++) {
          var child = children[i];

          if (child.get('visible')) {
            var box = child.getBBox();

            if (!box) {
              continue;
            }

            var leftTop = [box.minX, box.minY];
            var leftBottom = [box.minX, box.maxY];
            var rightTop = [box.maxX, box.minY];
            var rightBottom = [box.maxX, box.maxY];
            var matrix = child.attr('matrix');
            Vector2.transformMat2d(leftTop, leftTop, matrix);
            Vector2.transformMat2d(leftBottom, leftBottom, matrix);
            Vector2.transformMat2d(rightTop, rightTop, matrix);
            Vector2.transformMat2d(rightBottom, rightBottom, matrix);
            minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
            maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
            minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
            maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
          }
        }

        return {
          minX: minX,
          minY: minY,
          maxX: maxX,
          maxY: maxY,
          x: minX,
          y: minY,
          width: maxX - minX,
          height: maxY - minY
        };
      };

      _proto.createPath = function createPath(context) {
        var attrs = this.get('attrs'); // 只有在有fillStyle或strokeStyle 时才需要绘制

        if (!attrs.fillStyle && !attrs.strokeStyle) {
          return;
        }

        _Rect.prototype.createPath.call(this, context);
      };

      _proto.drawInner = function drawInner(context) {
        _Rect.prototype.drawInner.call(this, context);

        this.drawChildren(context);
      };

      _proto.destroy = function destroy() {
        if (this.get('destroyed')) {
          return;
        }

        this.clear();

        _Rect.prototype.destroy.call(this);
      };

      return Group;
    }(Rect$2);

    mix$1(Group.prototype, Container, {
      getGroupClass: function getGroupClass() {
        return Group;
      }
    });

    var requestAnimationFrame = typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
      return setTimeout(fn, 16);
    };

    var Canvas = /*#__PURE__*/function (_EventEmit) {
      _inheritsLoose$3(Canvas, _EventEmit);

      var _proto = Canvas.prototype;

      _proto.get = function get(name) {
        return this._attrs[name];
      };

      _proto.set = function set(name, value) {
        this._attrs[name] = value;
      };

      function Canvas(cfg) {
        var _this;

        _this = _EventEmit.call(this) || this;
        var title = cfg.title;
        var ariaLabel = title ? substitute(lang.general.withTitle, {
          title: title
        }) : lang.general.title;
        _this._attrs = mix$1({
          type: 'canvas',
          children: [],
          ariaLabel: ariaLabel
        }, cfg);

        _this._initPixelRatio();

        _this._initCanvas();

        return _this;
      }

      _proto._initPixelRatio = function _initPixelRatio() {
        var pixelRatio = this.get('pixelRatio');

        if (!pixelRatio) {
          this.set('pixelRatio', getPixelRatio());
        }
      };

      _proto.beforeDraw = function beforeDraw() {
        var context = this._attrs.context;
        var el = this._attrs.el;
        context && context.clearRect && context.clearRect(0, 0, el.width, el.height);
      };

      _proto._initCanvas = function _initCanvas() {
        var self = this;
        var el = self.get('el');
        var context = self.get('context');

        if (!el && !context) {
          throw new Error('Please specify the id, el or context of the chart!');
        }

        var canvas;

        if (el) {
          // DOMElement or String
          canvas = isString(el) ? getDomById(el) : el;
        } else {
          // 说明没有指定el
          canvas = CanvasElement$1.create(context);
        }

        if (context && canvas && !canvas.getContext) {
          canvas.getContext = function () {
            return context;
          };
        }

        var width = self.get('width');

        if (!width) {
          width = getWidth(canvas);
        }

        var height = self.get('height');

        if (!height) {
          height = getHeight(canvas);
        }

        self.set('canvas', this);
        self.set('el', canvas);
        self.set('context', context || canvas.getContext('2d'));
        self.changeSize(width, height); // 初始化事件控制器

        var eventController = new EventController({
          canvas: this,
          el: canvas
        });
        self.set('eventController', eventController);
      };

      _proto.changeSize = function changeSize(width, height) {
        var pixelRatio = this.get('pixelRatio');
        var canvasDOM = this.get('el'); // HTMLCanvasElement or canvasElement
        // 浏览器环境设置style样式

        if (canvasDOM.style) {
          canvasDOM.style.width = width + 'px';
          canvasDOM.style.height = height + 'px';
        }

        if (isCanvasElement(canvasDOM)) {
          canvasDOM.width = width * pixelRatio;
          canvasDOM.height = height * pixelRatio;

          if (pixelRatio !== 1) {
            var ctx = this.get('context');
            ctx.scale(pixelRatio, pixelRatio);
          }
        }

        this.set('width', width);
        this.set('height', height);
      };

      _proto.getWidth = function getWidth() {
        var pixelRatio = this.get('pixelRatio');
        var width = this.get('width');
        return width * pixelRatio;
      };

      _proto.getHeight = function getHeight() {
        var pixelRatio = this.get('pixelRatio');
        var height = this.get('height');
        return height * pixelRatio;
      };

      _proto.getPointByClient = function getPointByClient(clientX, clientY) {
        var el = this.get('el');
        var bbox = el.getBoundingClientRect();
        var width = bbox.right - bbox.left;
        var height = bbox.bottom - bbox.top;
        return {
          x: (clientX - bbox.left) * (el.width / width),
          y: (clientY - bbox.top) * (el.height / height)
        };
      };

      _proto._beginDraw = function _beginDraw() {
        this._attrs.toDraw = true;
      };

      _proto._endDraw = function _endDraw() {
        this._attrs.toDraw = false;
      };

      _proto.draw = function draw() {
        var self = this;

        function drawInner() {
          self.set('animateHandler', requestAnimationFrame(function () {
            self.set('animateHandler', undefined);

            if (self.get('toDraw')) {
              drawInner();
            }
          }));
          self.beforeDraw();

          try {
            var context = self._attrs.context;
            self.drawChildren(context); // 支付宝,微信小程序,需要调context.draw才能完成绘制, 所以这里直接判断是否有.draw方法

            if (context.draw) {
              context.draw();
            } // 设置无障碍文本


            self.setAriaLabel();
          } catch (ev) {
            console.warn('error in draw canvas, detail as:');
            console.warn(ev);

            self._endDraw();
          }

          self._endDraw();
        }

        if (self.get('destroyed')) {
          return;
        }

        if (self.get('animateHandler')) {
          this._beginDraw();
        } else {
          drawInner();
        }
      } // 设置无障碍文本
      ;

      _proto.setAriaLabel = function setAriaLabel() {
        var el = this._attrs.el;

        var ariaLabel = this._getAriaLabel();

        if (ariaLabel && el.setAttribute) {
          el.setAttribute('aria-label', ariaLabel);
        }
      };

      _proto.destroy = function destroy() {
        if (this.get('destroyed')) {
          return;
        } // 需要清理 canvas 画布内容,否则会导致 spa 应用 ios 下 canvas 白屏
        // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12
        // https://github.com/antvis/F2/issues/630


        var el = this.get('el');
        el.width = 0;
        el.height = 0;
        this.clear();
        this._attrs = {};
        this.set('destroyed', true);
      };

      _proto.isDestroyed = function isDestroyed() {
        return this.get('destroyed');
      };

      return Canvas;
    }(EventEmit);

    mix$1(Canvas.prototype, Container, {
      getGroupClass: function getGroupClass() {
        return Group;
      }
    });

    var engines = {};

    function registerEngine(name, engine) {
      engines[name] = engine;
    }

    function getEngine(name) {
      var G = engines[name];

      if (G) {
        return G;
      }

      return {
        Canvas: Canvas,
        Group: Group,
        Shape: Shape
      };
    }

    function createCanvas(cfg) {
      var renderer = cfg.renderer;
      var G = getEngine(renderer);
      return new G.Canvas(cfg);
    }

    var G = /*#__PURE__*/Object.freeze({
        __proto__: null,
        registerEngine: registerEngine,
        getEngine: getEngine,
        createCanvas: createCanvas,
        Canvas: Canvas,
        Group: Group,
        Shape: Shape,
        Matrix: Matrix,
        Vector2: Vector2
    });

    function getClip(coord) {
      var start = coord.start;
      var end = coord.end;
      var width = end.x - start.x;
      var height = Math.abs(end.y - start.y);
      var margin = 10;
      var clip;

      if (coord.isPolar) {
        var circleRadius = coord.circleRadius,
            center = coord.center,
            startAngle = coord.startAngle,
            endAngle = coord.endAngle;
        clip = new Shape.Sector({
          attrs: {
            x: center.x,
            y: center.y,
            r: circleRadius,
            r0: 0,
            startAngle: startAngle,
            endAngle: endAngle
          }
        });
      } else {
        clip = new Shape.Rect({
          attrs: {
            x: start.x,
            y: end.y - margin,
            width: width,
            height: height + 2 * margin
          }
        });
      }

      clip.isClip = true;
      return clip;
    }

    function isPointInPlot(point, plot) {
      var x = point.x,
          y = point.y;
      var tl = plot.tl,
          tr = plot.tr,
          br = plot.br;
      return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
    }

    var Helper = /*#__PURE__*/Object.freeze({
        __proto__: null,
        getClip: getClip,
        isPointInPlot: isPointInPlot
    });

    function compare(a, b) {
      return a - b;
    }

    function _isScaleExist(scales, compareScale) {
      var flag = false;
      each$1(scales, function (scale) {
        var scaleValues = [].concat(scale.values);
        var compareScaleValues = [].concat(compareScale.values);

        if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
          flag = true;
          return;
        }
      });
      return flag;
    }

    var Chart = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Chart, _Base);

      Chart.initPlugins = function initPlugins() {
        return {
          _plugins: [],
          _cacheId: 0,
          register: function register(plugins) {
            var p = this._plugins;
            [].concat(plugins).forEach(function (plugin) {
              if (p.indexOf(plugin) === -1) {
                p.push(plugin);
              }
            });
            this._cacheId++;
          },
          unregister: function unregister(plugins) {
            var p = this._plugins;
            [].concat(plugins).forEach(function (plugin) {
              var idx = p.indexOf(plugin);

              if (idx !== -1) {
                p.splice(idx, 1);
              }
            });
            this._cacheId++;
          },
          clear: function clear() {
            this._plugins = [];
            this._cacheId++;
          },
          count: function count() {
            return this._plugins.length;
          },
          getAll: function getAll() {
            return this._plugins;
          },
          notify: function notify(chart, hook, args) {
            var descriptors = this.descriptors(chart);
            var ilen = descriptors.length;
            var i;
            var descriptor;
            var plugin;
            var params;
            var method;

            for (i = 0; i < ilen; ++i) {
              descriptor = descriptors[i];
              plugin = descriptor.plugin;
              method = plugin[hook];

              if (typeof method === 'function') {
                params = [chart].concat(args || []);

                if (method.apply(plugin, params) === false) {
                  return false;
                }
              }
            }

            return true;
          },
          descriptors: function descriptors(chart) {
            var cache = chart._plugins || (chart._plugins = {});

            if (cache.id === this._cacheId) {
              return cache.descriptors;
            }

            var plugins = [];
            var descriptors = [];

            this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
              var idx = plugins.indexOf(plugin);

              if (idx !== -1) {
                return;
              }

              plugins.push(plugin);
              descriptors.push({
                plugin: plugin
              });
            });

            cache.descriptors = descriptors;
            cache.id = this._cacheId;
            return descriptors;
          }
        };
      };

      var _proto = Chart.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          /**
           * the id of canvas
           * @type {String}
           */
          id: null,

          /** 图表渲染引擎 */
          renderer: 'canvas',
          rendered: false,

          /**
           * padding
           * @type {Array|Number}
           */
          padding: Global.padding,

          /**
           * data
           * @type {Array}
           */
          data: null,

          /**
           * scales of chart
           * @type {Object}
           */
          scales: {},

          /**
           * @private
           * geometry instances
           * @type {Array}
           */
          geoms: [],

          /**
           * scale configuration
           * @type {Object}
           */
          colDefs: null,
          pixelRatio: Global.pixelRatio,

          /**
           * filter options
           * @type {Object}
           */
          filters: null,
          appendPadding: Global.appendPadding
        };
      };

      _proto._syncYScales = function _syncYScales() {
        var syncY = this.get('syncY');

        if (!syncY) {
          return;
        }

        var geoms = this.get('geoms');
        var syncScales = [];
        var min = [];
        var max = [];
        each$1(geoms, function (geom) {
          var yScale = geom.getYScale();

          if (yScale.isLinear) {
            syncScales.push(yScale);
            min.push(yScale.min);
            max.push(yScale.max);
          }
        });
        min = Math.min.apply(null, min);
        max = Math.max.apply(null, max);
        each$1(syncScales, function (scale) {
          scale.change({
            min: min
          });
          scale.change({
            max: max
          });
        });
      };

      _proto._getFieldsForLegend = function _getFieldsForLegend() {
        var fields = [];
        var geoms = this.get('geoms');
        each$1(geoms, function (geom) {
          var attrOptions = geom.get('attrOptions');
          var attrCfg = attrOptions.color;

          if (attrCfg && attrCfg.field && isString(attrCfg.field)) {
            var arr = attrCfg.field.split('*');
            each$1(arr, function (item) {
              if (fields.indexOf(item) === -1) {
                fields.push(item);
              }
            });
          }
        });
        return fields;
      };

      _proto._getScaleData = function _getScaleData(field) {
        var data = this.get('data');
        var filteredData = this.get('filteredData');

        if (filteredData.length) {
          var legendFields = this._getFieldsForLegend();

          if (legendFields.indexOf(field) === -1) {
            data = filteredData;
          }
        }

        return data;
      } // _updateScales() {
      //   const scaleController = this.get('scaleController');
      //   scaleController.updateScales();
      //   this._adjustScale();
      // }
      ;

      _proto._adjustScale = function _adjustScale() {
        var self = this;
        var scaleController = self.get('scaleController'); // 看起来是为了让柱状图最小或最大都默认从0开始

        var geoms = this.get('geoms');

        for (var i = 0; i < geoms.length; i++) {
          var geom = geoms[i];

          if (geom.get('type') === 'interval') {
            var yScale = geom.getYScale();
            scaleController.adjustStartZero(yScale);
          }
        }
      };

      _proto._removeGeoms = function _removeGeoms() {
        var geoms = this.get('geoms');

        while (geoms.length > 0) {
          var geom = geoms.shift();
          geom.destroy();
        }
      };

      _proto._clearGeoms = function _clearGeoms() {
        var geoms = this.get('geoms');

        for (var i = 0, length = geoms.length; i < length; i++) {
          var geom = geoms[i];
          geom.clear();
        }
      };

      _proto._clearInner = function _clearInner() {
        this._clearGeoms();

        Chart.plugins.notify(this, 'clearInner');
        this.emit(EVENT_CLEAR_INNER);
        this.get('axisController') && this.get('axisController').clear();
      };

      _proto._initFilteredData = function _initFilteredData() {
        var filters = this.get('filters');
        var data = this.get('data') || [];

        if (filters) {
          data = data.filter(function (obj) {
            var rst = true;
            each$1(filters, function (fn, k) {
              if (fn) {
                rst = fn(obj[k], obj);

                if (!rst) {
                  return false;
                }
              }
            });
            return rst;
          });
        }

        this.set('filteredData', data);
      };

      _proto._changeGeomsData = function _changeGeomsData() {
        var geoms = this.get('geoms');
        var data = this.get('filteredData');

        for (var i = 0, length = geoms.length; i < length; i++) {
          var geom = geoms[i];
          geom.changeData(data);
        }
      };

      _proto._initGeom = function _initGeom(geom) {
        if (geom.get('isInit')) {
          return;
        }

        var coord = this.get('coord');
        var data = this.get('filteredData');
        var colDefs = this.get('colDefs');
        var middlePlot = this.get('middlePlot');
        geom.set('chart', this);
        geom.set('container', middlePlot.addGroup());
        geom.set('data', data);
        geom.set('coord', coord);
        geom.set('colDefs', colDefs);
        geom.init();
        this.emit(EVENT_AFTER_GEOM_INIT, geom);
      };

      _proto._initGeoms = function _initGeoms() {
        var geoms = this.get('geoms');

        for (var i = 0, length = geoms.length; i < length; i++) {
          this._initGeom(geoms[i]);
        }
      };

      _proto._initCoord = function _initCoord() {
        var plot = this.get('plotRange');
        var coordCfg = mix$1({
          type: 'cartesian'
        }, this.get('coordCfg'), {
          plot: plot
        });
        var type = coordCfg.type;
        var C = Base$1[upperFirst(type)];
        var coord = new C(coordCfg);
        this.set('coord', coord);
      };

      _proto._initLayout = function _initLayout() {
        var padding = this.get('_padding');

        if (!padding) {
          padding = this.get('margin') || this.get('padding');
          padding = parsePadding(padding);
        }

        var top = padding[0] === 'auto' ? 0 : padding[0];
        var right = padding[1] === 'auto' ? 0 : padding[1];
        var bottom = padding[2] === 'auto' ? 0 : padding[2];
        var left = padding[3] === 'auto' ? 0 : padding[3];
        var width = this.get('width');
        var height = this.get('height');
        var start = {
          x: left,
          y: top
        };
        var end = {
          x: width - right,
          y: height - bottom
        };
        var plot = this.get('plot');

        if (plot) {
          plot.reset(start, end);
          return;
        }

        var newPlot = new Plot({
          start: start,
          end: end
        });
        this.set('plotRange', newPlot);
        this.set('plot', newPlot);
      };

      _proto._initCanvas = function _initCanvas() {
        var self = this;

        try {
          var canvas = createCanvas({
            renderer: self.get('renderer'),
            el: self.get('el') || self.get('id'),
            context: self.get('context'),
            pixelRatio: self.get('pixelRatio'),
            width: self.get('width'),
            height: self.get('height'),
            fontFamily: Global.fontFamily,
            aria: self.get('aria'),
            title: self.get('title'),
            landscape: self.get('landscape')
          });
          self.set('canvas', canvas);
          self.set('el', canvas.get('el'));
          self.set('width', canvas.get('width'));
          self.set('height', canvas.get('height'));
        } catch (error) {
          throw error;
        }

        Chart.plugins.notify(self, 'afterCanvasInit');
      };

      _proto._initLayers = function _initLayers() {
        var canvas = this.get('canvas');
        this.set('backPlot', canvas.addGroup());
        this.set('middlePlot', canvas.addGroup({
          zIndex: 10
        }));
        this.set('frontPlot', canvas.addGroup({
          zIndex: 20
        }));
      };

      _proto._initEvents = function _initEvents() {
        var _this2 = this;

        // 数据更新后的一些更新
        this.on(EVENT_AFTER_DATA_CHANGE, function () {
          // 数据更新后,重新设置filterdata
          _this2._initFilteredData(); // 更新geoms里的数据


          _this2._changeGeomsData();
        }); // 大小变化后的一些更新

        this.on(EVENT_AFTER_SIZE_CHANGE, function () {
          _this2._initLayout(); // layout变化后,坐标轴也需要做相应的变化


          var coord = _this2.get('coord');

          if (coord) {
            coord.reset(_this2.get('plot'));
          }
        });
      };

      _proto._initScaleController = function _initScaleController() {
        var scaleController = new ScaleController({
          chart: this
        }); // 让colDefs 和 scaleController.defs 用同一个对象,这样就不用考虑同步的问题

        this.set('colDefs', scaleController.defs); // 已经实例化的scales 也保持统一个对象

        this.set('scales', scaleController.scales);
        this.set('scaleController', scaleController);
      };

      _proto._clearScaleController = function _clearScaleController() {
        var scaleController = this.get('scaleController');
        scaleController.clear();
      };

      _proto._init = function _init() {
        var self = this;

        self._initCanvas();

        self._initLayout();

        self._initLayers();

        self._initEvents();

        self._initScaleController();

        self.set('axisController', new AxisController({
          frontPlot: self.get('frontPlot').addGroup({
            className: 'axisContainer'
          }),
          backPlot: self.get('backPlot').addGroup({
            className: 'axisContainer'
          }),
          chart: self
        }));
        Chart.plugins.notify(self, 'init');
      };

      function Chart(cfg) {
        var _this;

        _this = _Base.call(this, cfg) || this;

        var self = _assertThisInitialized(_this);

        each$1(Geom, function (geomConstructor, className) {
          var methodName = lowerFirst(className);

          self[methodName] = function (cfg) {
            var geom = new geomConstructor(cfg);
            self.addGeom(geom);
            return geom;
          };
        });

        self._init();

        return _this;
      }

      _proto.init = function init() {
        // 初始filterData
        this._initFilteredData(); // initialization coordinate instance


        this._initCoord();

        Chart.plugins.notify(this, 'beforeGeomInit'); // init all geometry instances

        this._initGeoms(); // 多 Y 轴的情况时,统一 Y 轴的数值范围。


        this._syncYScales(); // do some adjust for data


        this._adjustScale();

        this.emit(EVENT_AFTER_INIT);
      }
      /**
       * set data and some scale configuration
       * @chainable
       * @param  {Array} data the dataset to visualize
       * @param  {Object} colDefs the configuration for scales
       * @return {Chart} return the chart instance
       */
      ;

      _proto.source = function source(data, colDefs) {
        this.set('data', data);

        if (colDefs) {
          this.scale(colDefs);
        }

        return this;
      };

      _proto.scale = function scale(field, cfg) {
        var scaleController = this.get('scaleController');
        scaleController.setFieldDef(field, cfg);
        return this;
      }
      /**
       * configure the axis
       * @chainable
       * @param  {String|Boolean} field the field name of data
       * @param  {Object} cfg configuration for axis
       * @return {Chart} return the chart instance
       */
      ;

      _proto.axis = function axis(field, cfg) {
        var axisController = this.get('axisController');

        if (!field) {
          axisController.axisCfg = null;
        } else {
          axisController.axisCfg = axisController.axisCfg || {};
          axisController.axisCfg[field] = cfg;
        }

        return this;
      }
      /**
       * configure the coordinate
       * @chainable
       * @param  {String} type set the type of coodinate
       * @param  {Object} cfg configuration for coordinate
       * @return {Chart} return the chart instance
       */
      ;

      _proto.coord = function coord(type, cfg) {
        var coordCfg;

        if (isObject$1(type)) {
          coordCfg = type;
        } else {
          coordCfg = cfg || {};
          coordCfg.type = type || 'cartesian';
        }

        this.set('coordCfg', coordCfg);
        return this;
      };

      _proto.filter = function filter(field, condition) {
        var filters = this.get('filters') || {};
        filters[field] = condition;
        this.set('filters', filters); // 如果已经render过,则再重新触发一次change

        if (this.get('rendered')) {
          this.emit(EVENT_AFTER_DATA_CHANGE, this.get('data'));
        }
      }
      /**
       * render the chart
       * @chainable
       * @return {Chart} return the chart instance
       */
      ;

      _proto.render = function render() {
        var rendered = this.get('rendered');
        var canvas = this.get('canvas');
        var geoms = this.get('geoms'); // 已经渲染过

        if (rendered) {
          this._initGeoms();

          this._adjustScale();
        } else {
          this.init();
          this.set('rendered', true);
        }

        this.emit(EVENT_BEFORE_RENDER);
        Chart.plugins.notify(this, 'beforeGeomDraw');

        this._renderAxis();

        var middlePlot = this.get('middlePlot');

        if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
          var coord = this.get('coord');
          var clip = getClip(coord);
          clip.set('canvas', middlePlot.get('canvas'));
          middlePlot.attr('clip', clip);
        }

        this.emit(EVENT_BEFORE_GEOM_DRAW);

        for (var i = 0, length = geoms.length; i < length; i++) {
          var geom = geoms[i];
          geom.paint();
        }

        this.emit(EVENT_AFTER_GEOM_DRAW);
        Chart.plugins.notify(this, 'afterGeomDraw');
        canvas.sort();
        this.get('frontPlot').sort();
        Chart.plugins.notify(this, 'beforeCanvasDraw');
        canvas.draw();
        this.emit(EVENT_AFTER_RENDER);
        return this;
      }
      /**
       * clear the chart, include geometris and all the shapes
       * @chainable
       * @return {Chart} return the chart
       */
      ;

      _proto.clear = function clear() {
        Chart.plugins.notify(this, 'clear');
        this.emit(EVENT_CLEAR);

        this._clearInner();

        this._removeGeoms();

        this._clearScaleController();

        this.set('legendItems', null);
        this.set('filters', null);
        this.set('isUpdate', false);
        this.set('_padding', null);
        this.set('rendered', false);
        var canvas = this.get('canvas');
        canvas.draw();
        return this;
      };

      _proto.repaint = function repaint() {
        // 如果在没有render之前就repaint的,就直接return退出
        var rendered = this.get('rendered');

        if (!rendered) {
          return;
        }

        this.set('isUpdate', true);
        this.set('legendItems', null);
        Chart.plugins.notify(this, 'repaint');

        this._clearInner();

        this.emit(EVENT_REPAINT);
        this.render();
      };

      _proto.changeData = function changeData(data) {
        this.emit(EVENT_BEFORE_DATA_CHANGE, data);
        this.set('data', data);
        Chart.plugins.notify(this, 'changeData');
        this.emit(EVENT_AFTER_DATA_CHANGE, data);
        this.set('_padding', null);
        this.repaint();
      };

      _proto.changeSize = function changeSize(width, height) {
        if (width) {
          this.set('width', width);
        } else {
          width = this.get('width');
        }

        if (height) {
          this.set('height', height);
        } else {
          height = this.get('height');
        }

        var canvas = this.get('canvas');
        canvas.changeSize(width, height);
        this.emit(EVENT_AFTER_SIZE_CHANGE, {
          width: width,
          height: height
        });
        this.repaint();
        return this;
      };

      _proto.destroy = function destroy() {
        this.clear();
        var canvas = this.get('canvas');
        canvas.destroy();
        Chart.plugins.notify(this, 'afterCanvasDestroyed');

        if (this._interactions) {
          each$1(this._interactions, function (interaction) {
            interaction.destroy();
          });
        }

        _Base.prototype.destroy.call(this);
      }
      /**
       * calculate dataset's position on canvas
       * @param  {Object} record the dataset
       * @return {Object} return the position
       */
      ;

      _proto.getPosition = function getPosition(record) {
        var self = this;
        var coord = self.get('coord');
        var xScale = self.getXScale();
        var xField = xScale.field;
        var yScales = self.getYScales(); // default first

        var yScale = yScales[0];
        var yField = yScale.field;

        for (var i = 0, len = yScales.length; i < len; i++) {
          var scale = yScales[i];
          var field = scale.field;

          if (record[field]) {
            yScale = scale;
            yField = field;
            break;
          }
        }

        var x = xScale.scale(record[xField]);
        var y = yScale.scale(record[yField]);
        return coord.convertPoint({
          x: x,
          y: y
        });
      }
      /**
       * get the data item of the point
       * @param  {Object} point canvas position
       * @return {Object} return the data item
       */
      ;

      _proto.getRecord = function getRecord(point) {
        var self = this;
        var coord = self.get('coord');
        var xScale = self.getXScale();
        var yScale = self.getYScales()[0];
        var invertPoint = coord.invertPoint(point);
        var record = {};
        record[xScale.field] = xScale.invert(invertPoint.x);
        record[yScale.field] = yScale.invert(invertPoint.y);
        return record;
      }
      /**
       * get the dataset of the point
       * @param  {Object} point canvas position
       * @return {Array} return the dataset
      **/
      ;

      _proto.getSnapRecords = function getSnapRecords(point) {
        var geom = this.get('geoms')[0];
        var data = [];

        if (geom) {
          // need to judge
          data = geom.getSnapRecords(point);
        }

        return data;
      }
      /**
       * creat scale instances
       * @param  {String} field field name of data
       * @return {Scale} return the scale
       */
      ;

      _proto.createScale = function createScale(field) {
        var data = this._getScaleData(field);

        var scaleController = this.get('scaleController');
        return scaleController.createScale(field, data);
      }
      /**
       * @protected
       * add geometry instance to geoms
       * @param {Geom} geom geometry instance
       */
      ;

      _proto.addGeom = function addGeom(geom) {
        var geoms = this.get('geoms');
        geoms.push(geom);
      }
      /**
       * get the scale of x axis
       * @return {Scale} return the scale
       */
      ;

      _proto.getXScale = function getXScale() {
        var self = this;
        var geoms = self.get('geoms');
        var xScale = geoms[0].getXScale();
        return xScale;
      }
      /**
       * get the scale of y axis
       * @return {Array} return the scale
       */
      ;

      _proto.getYScales = function getYScales() {
        var geoms = this.get('geoms');
        var rst = [];
        each$1(geoms, function (geom) {
          var yScale = geom.getYScale();

          if (rst.indexOf(yScale) === -1) {
            rst.push(yScale);
          }
        });
        return rst;
      };

      _proto.getLegendItems = function getLegendItems() {
        if (this.get('legendItems')) {
          return this.get('legendItems');
        }

        var legendItems = {};
        var scales = [];
        var geoms = this.get('geoms');
        each$1(geoms, function (geom) {
          var colorAttr = geom.getAttr('color');

          if (colorAttr) {
            var scale = colorAttr.getScale('color'); // 只支持分类图例

            if (scale.isCategory && !_isScaleExist(scales, scale)) {
              scales.push(scale);
              var field = scale.field;
              var ticks = scale.getTicks();
              var items = [];
              each$1(ticks, function (tick) {
                var text = tick.text;
                var name = text;
                var scaleValue = tick.value;
                var value = scale.invert(scaleValue);
                var color = colorAttr.mapping(value).join('') || Global.defaultColor;
                var marker = {
                  fill: color,
                  radius: 3,
                  symbol: 'circle',
                  stroke: '#fff'
                };
                items.push({
                  name: name,
                  // for display
                  dataValue: value,
                  // the origin value
                  checked: true,
                  marker: marker
                });
              });
              legendItems[field] = items;
            }
          }
        });
        this.set('legendItems', legendItems);
        return legendItems;
      } // register the plugins
      ;

      _proto.registerPlugins = function registerPlugins(plugins) {
        var self = this;
        var chartPlugins = self.get('plugins') || [];

        if (!isArray$1(chartPlugins)) {
          chartPlugins = [chartPlugins];
        }

        [].concat(plugins).forEach(function (plugin) {
          if (chartPlugins.indexOf(plugin) === -1) {
            plugin.init && plugin.init(self); // init

            chartPlugins.push(plugin);
          }
        });
        Chart.plugins._cacheId++;
        self.set('plugins', chartPlugins);
      };

      _proto._renderAxis = function _renderAxis() {
        var axisController = this.get('axisController');
        var xScale = this.getXScale();
        var yScales = this.getYScales();
        var coord = this.get('coord');
        Chart.plugins.notify(this, 'beforeRenderAxis');
        axisController.createAxis(coord, xScale, yScales);
      };

      _proto._isAutoPadding = function _isAutoPadding() {
        if (this.get('_padding')) {
          return false;
        }

        var padding = this.get('padding');

        if (isArray$1(padding)) {
          return padding.indexOf('auto') !== -1;
        }

        return padding === 'auto';
      };

      _proto._updateLayout = function _updateLayout(padding) {
        var width = this.get('width');
        var height = this.get('height');
        var start = {
          x: padding[3],
          y: padding[0]
        };
        var end = {
          x: width - padding[1],
          y: height - padding[2]
        };
        var plot = this.get('plot');
        var coord = this.get('coord');
        plot.reset(start, end);
        coord.reset(plot);
      }
      /**
       * 是否为横屏展示
       *
       * @param {Boolean} landscape 是否为横屏
       */
      ;

      _proto.landscape = function landscape(_landscape) {
        var canvas = this.get('canvas');
        canvas.set('landscape', _landscape);
      };

      return Chart;
    }(Base$2);

    Chart.plugins = Chart.initPlugins();

    var track = function track() {
      return null;
    };

    Global.version;

    /**
     * @fileOverview shape util
     * @author dxq613@gmail.com
     */

    function splitPoints(obj) {
      var points = [];
      var x = obj.x;
      var y = obj.y;
      y = isArray$1(y) ? y : [y];
      y.forEach(function (yItem, index) {
        var point = {
          x: isArray$1(x) ? x[index] : x,
          y: yItem
        };
        points.push(point);
      });
      return points;
    }

    function splitArray(data, yField, connectNulls) {
      if (!data.length) return [];
      var arr = [];
      var tmp = [];
      var yValue;
      each$1(data, function (obj) {
        yValue = obj._origin ? obj._origin[yField] : obj[yField];

        if (connectNulls) {
          if (!isNil$1(yValue)) {
            tmp.push(obj);
          }
        } else {
          if (isArray$1(yValue) && isNil$1(yValue[0]) || isNil$1(yValue)) {
            if (tmp.length) {
              arr.push(tmp);
              tmp = [];
            }
          } else {
            tmp.push(obj);
          }
        }
      });

      if (tmp.length) {
        arr.push(tmp);
      }

      return arr;
    }

    var SHAPES$2 = ['circle', 'hollowCircle', 'rect'];
    Shape$1.registerFactory('point', {
      defaultShapeType: 'circle',
      getDefaultPoints: function getDefaultPoints(pointInfo) {
        return splitPoints(pointInfo);
      }
    });

    function getPointsCfg(cfg) {
      var style = {
        lineWidth: 0,
        stroke: cfg.color,
        fill: cfg.color
      };

      if (cfg.size) {
        style.size = cfg.size;
      }

      mix$1(style, cfg.style);
      return mix$1({}, Global.shape.point, style);
    }

    function drawShape$1(cfg, container, shape) {
      if (cfg.size === 0) return;
      var pointCfg = getPointsCfg(cfg);
      var size = pointCfg.r || pointCfg.size;
      var x = cfg.x;
      var y = !isArray$1(cfg.y) ? [cfg.y] : cfg.y;

      if (shape === 'hollowCircle') {
        pointCfg.lineWidth = 1;
        pointCfg.fill = null;
      }

      for (var i = 0, len = y.length; i < len; i++) {
        if (shape === 'rect') {
          return container.addShape('Rect', {
            className: 'point',
            attrs: mix$1({
              x: x - size,
              y: y[i] - size,
              width: size * 2,
              height: size * 2
            }, pointCfg)
          });
        }

        return container.addShape('Circle', {
          className: 'point',
          attrs: mix$1({
            x: x,
            y: y[i],
            r: size
          }, pointCfg)
        });
      }
    }

    each$1(SHAPES$2, function (shapeType) {
      Shape$1.registerShape('point', shapeType, {
        draw: function draw(cfg, container) {
          return drawShape$1(cfg, container, shapeType);
        }
      });
    });

    var Point$1 = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Point, _Geom);

      function Point() {
        return _Geom.apply(this, arguments) || this;
      }

      var _proto = Point.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'point';
        cfg.shapeType = 'point';
        cfg.generatePoints = false;
        return cfg;
      };

      _proto.draw = function draw(data, shapeFactory) {
        var self = this;
        var container = self.get('container');
        each$1(data, function (obj) {
          var shape = obj.shape;
          var cfg = self.getDrawCfg(obj);

          if (isArray$1(obj.y)) {
            var hasStack = self.hasAdjust('stack');
            each$1(obj.y, function (y, idx) {
              cfg.y = y;

              if (!hasStack || idx !== 0) {
                self.drawShape(shape, obj, cfg, container, shapeFactory);
              }
            });
          } else if (!isNil$1(obj.y)) {
            self.drawShape(shape, obj, cfg, container, shapeFactory);
          }
        });
      };

      return Point;
    }(Geom);

    Geom.Point = Point$1;

    Shape$1.registerFactory('line', {
      defaultShapeType: 'line'
    });

    function getStyle(cfg) {
      var style = {
        strokeStyle: cfg.color
      };

      if (cfg.size >= 0) {
        style.lineWidth = cfg.size;
      }

      mix$1(style, cfg.style);
      return mix$1({}, Global.shape.line, style);
    }

    function drawLines(cfg, container, style, smooth) {
      var points = cfg.points;

      if (points.length && isArray$1(points[0].y)) {
        var topPoints = [];
        var bottomPoints = [];

        for (var i = 0, len = points.length; i < len; i++) {
          var point = points[i];
          var tmp = splitPoints(point);
          bottomPoints.push(tmp[0]);
          topPoints.push(tmp[1]);
        }

        if (cfg.isInCircle) {
          topPoints.push(topPoints[0]);
          bottomPoints.push(bottomPoints[0]);
        }

        if (cfg.isStack) {
          return container.addShape('Polyline', {
            className: 'line',
            attrs: mix$1({
              points: topPoints,
              smooth: smooth
            }, style)
          });
        }

        var topShape = container.addShape('Polyline', {
          className: 'line',
          attrs: mix$1({
            points: topPoints,
            smooth: smooth
          }, style)
        });
        var bottomShape = container.addShape('Polyline', {
          className: 'line',
          attrs: mix$1({
            points: bottomPoints,
            smooth: smooth
          }, style)
        });
        return [topShape, bottomShape];
      }

      if (cfg.isInCircle) {
        points.push(points[0]);
      }

      return container.addShape('Polyline', {
        className: 'line',
        attrs: mix$1({
          points: points,
          smooth: smooth
        }, style)
      });
    }

    var SHAPES$1 = ['line', 'smooth', 'dash'];
    each$1(SHAPES$1, function (shapeType) {
      Shape$1.registerShape('line', shapeType, {
        draw: function draw(cfg, container) {
          var smooth = shapeType === 'smooth';
          var style = getStyle(cfg);

          if (shapeType === 'dash') {
            style.lineDash = Global.lineDash;
          }

          return drawLines(cfg, container, style, smooth);
        }
      });
    });

    var Path = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Path, _Geom);

      function Path() {
        return _Geom.apply(this, arguments) || this;
      }

      var _proto = Path.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'path';
        cfg.shapeType = 'line';
        return cfg;
      };

      _proto.getDrawCfg = function getDrawCfg(obj) {
        var cfg = _Geom.prototype.getDrawCfg.call(this, obj);

        cfg.isStack = this.hasAdjust('stack');
        return cfg;
      };

      _proto.draw = function draw(data, shapeFactory) {
        var self = this;
        var container = self.get('container');
        var yScale = self.getYScale();
        var connectNulls = self.get('connectNulls');
        var splitArrayObj = splitArray(data, yScale.field, connectNulls);
        var cfg = this.getDrawCfg(data[0]);
        cfg.origin = data;
        each$1(splitArrayObj, function (subData, splitedIndex) {
          cfg.splitedIndex = splitedIndex;
          cfg.points = subData;
          self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
        });
      };

      return Path;
    }(Geom);

    Geom.Path = Path;

    var Line$1 = /*#__PURE__*/function (_Path) {
      _inheritsLoose$3(Line, _Path);

      function Line() {
        return _Path.apply(this, arguments) || this;
      }

      var _proto = Line.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Path.prototype.getDefaultCfg.call(this);

        cfg.type = 'line';
        cfg.sortable = true;
        return cfg;
      };

      return Line;
    }(Path);

    Geom.Line = Line$1;

    function equals(v1, v2) {
      return Math.abs(v1 - v2) < 0.00001;
    }

    function notEmpty(value) {
      return !isNaN(value) && !isNil$1(value);
    }

    function filterPoints(points) {
      var filteredPoints = []; // filter the point which x or y is NaN

      for (var i = 0, len = points.length; i < len; i++) {
        var point = points[i];

        if (notEmpty(point.x) && notEmpty(point.y)) {
          filteredPoints.push(point);
        }
      }

      return filteredPoints;
    }

    function equalsCenter(points, center) {
      var eqls = true;
      each$1(points, function (point) {
        if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
          eqls = false;
          return false;
        }
      });
      return eqls;
    }

    function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
      var shape;
      var points = topPoints.concat(bottomPoints);

      if (isSmooth) {
        shape = container.addShape('Custom', {
          className: 'area',
          attrs: mix$1({
            points: points
          }, style),
          createPath: function createPath(context) {
            var constaint = [[0, 0], [1, 1]];
            var points = filterPoints(this._attrs.attrs.points);
            var pointsLen = points.length;
            var topPoints = points.slice(0, pointsLen / 2);
            var bottomPoints = points.slice(pointsLen / 2, pointsLen);
            var topSps = catmullRom2bezier(topPoints, false, constaint);
            context.beginPath();
            context.moveTo(topPoints[0].x, topPoints[0].y);

            for (var i = 0, n = topSps.length; i < n; i++) {
              var sp = topSps[i];
              context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
            }

            if (bottomPoints.length) {
              var bottomSps = catmullRom2bezier(bottomPoints, false, constaint);
              context.lineTo(bottomPoints[0].x, bottomPoints[0].y);

              for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
                var _sp = bottomSps[_i];
                context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
              }
            }

            context.closePath();
          },
          calculateBox: function calculateBox() {
            var points = filterPoints(this._attrs.attrs.points);
            return getBBoxFromPoints(points);
          }
        });
      } else {
        shape = container.addShape('Polyline', {
          className: 'area',
          attrs: mix$1({
            points: points
          }, style)
        });
      }

      return shape;
    }

    function drawShape(cfg, container, isSmooth) {
      var self = this;
      var points = cfg.points;
      var topPoints = [];
      var bottomPoints = [];
      each$1(points, function (point) {
        bottomPoints.push(point[0]);
        topPoints.push(point[1]);
      });
      var style = mix$1({
        fillStyle: cfg.color
      }, Global.shape.area, cfg.style);
      bottomPoints.reverse();
      topPoints = self.parsePoints(topPoints);
      bottomPoints = self.parsePoints(bottomPoints);

      if (cfg.isInCircle) {
        topPoints.push(topPoints[0]);
        bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);

        if (equalsCenter(bottomPoints, cfg.center)) {
          bottomPoints = [];
        }
      }

      return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
    }

    Shape$1.registerFactory('area', {
      defaultShapeType: 'area',
      getDefaultPoints: function getDefaultPoints(obj) {
        var x = obj.x;
        var y = obj.y;
        var y0 = obj.y0;
        y = isArray$1(y) ? y : [y0, y];
        var points = [];
        points.push({
          x: x,
          y: y[0]
        }, {
          x: x,
          y: y[1]
        });
        return points;
      }
    });
    var SHAPES = ['area', 'smooth'];
    each$1(SHAPES, function (shapeType) {
      Shape$1.registerShape('area', shapeType, {
        draw: function draw(cfg, container) {
          var smooth = shapeType === 'smooth';
          return drawShape.call(this, cfg, container, smooth);
        }
      });
    });

    var Area = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Area, _Geom);

      function Area() {
        return _Geom.apply(this, arguments) || this;
      }

      var _proto = Area.prototype;

      /**
       * get the default configuration
       * @protected
       * @return {Object} return the result
       */
      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'area';
        cfg.shapeType = 'area';
        cfg.generatePoints = true;
        cfg.sortable = true;
        return cfg;
      };

      _proto.draw = function draw(data, shapeFactory) {
        var self = this;
        var container = self.get('container');
        var cfg = this.getDrawCfg(data[0]);
        var yScale = self.getYScale();
        var connectNulls = self.get('connectNulls');
        var splitArrayfn = splitArray(data, yScale.field, connectNulls);
        cfg.origin = data;
        each$1(splitArrayfn, function (subData, splitedIndex) {
          cfg.splitedIndex = splitedIndex;
          var points = subData.map(function (obj) {
            return obj.points;
          });
          cfg.points = points;
          self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
        });
      };

      return Area;
    }(Geom);

    Geom.Area = Area;

    /**
     * @fileOverview Utility for calculate the with ratui in x axis
     * @author sima.zhang1990@gmail.com
     * @author dxq613@gmail.com
     */
    var SizeMixin = {
      initEvent: function initEvent() {
        var _this = this;

        var chart = this.get('chart');

        if (!chart) {
          return;
        }

        chart.on(EVENT_AFTER_SIZE_CHANGE, function () {
          _this.set('_width', null);
        });
      },
      getDefaultSize: function getDefaultSize() {
        var defaultSize = this.get('defaultSize');

        if (!defaultSize) {
          var coord = this.get('coord');
          var xScale = this.getXScale();
          var dataArray = this.get('dataArray');
          var values = uniq(xScale.values);
          var count = values.length;
          var range = xScale.range;
          var normalizeSize = 1 / count;
          var widthRatio = 1;

          if (coord && coord.isPolar) {
            if (coord.transposed && count > 1) {
              widthRatio = Global.widthRatio.multiplePie;
            } else {
              widthRatio = Global.widthRatio.rose;
            }
          } else {
            if (xScale.isLinear) {
              normalizeSize *= range[1] - range[0];
            }

            widthRatio = Global.widthRatio.column;
          }

          normalizeSize *= widthRatio;

          if (this.hasAdjust('dodge')) {
            normalizeSize = normalizeSize / dataArray.length;
          }

          defaultSize = normalizeSize;
          this.set('defaultSize', defaultSize);
        }

        return defaultSize;
      },
      getDimWidth: function getDimWidth(dimName) {
        var coord = this.get('coord');
        var start = coord.convertPoint({
          x: 0,
          y: 0
        });
        var end = coord.convertPoint({
          x: dimName === 'x' ? 1 : 0,
          y: dimName === 'x' ? 0 : 1
        });
        var width = 0;

        if (start && end) {
          width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
        }

        return width;
      },
      _getWidth: function _getWidth() {
        var width = this.get('_width');

        if (!width) {
          var coord = this.get('coord');

          if (coord && coord.isPolar && !coord.transposed) {
            width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
          } else {
            width = this.getDimWidth('x');
          }

          this.set('_width', width);
        }

        return width;
      },
      _toNormalizedSize: function _toNormalizedSize(size) {
        var width = this._getWidth();

        return size / width;
      },
      _toCoordSize: function _toCoordSize(normalizeSize) {
        var width = this._getWidth();

        return width * normalizeSize;
      },
      getNormalizedSize: function getNormalizedSize(obj) {
        var size = this.getAttrValue('size', obj);

        if (isNil$1(size)) {
          size = this.getDefaultSize();
        } else {
          size = this._toNormalizedSize(size);
        }

        return size;
      },
      getSize: function getSize(obj) {
        var size = this.getAttrValue('size', obj);

        if (isNil$1(size)) {
          var normalizeSize = this.getDefaultSize();
          size = this._toCoordSize(normalizeSize);
        }

        return size;
      }
    };

    function getRectPoints(cfg) {
      var x = cfg.x,
          y = cfg.y,
          y0 = cfg.y0,
          size = cfg.size;
      var ymin = y0;
      var ymax = y;

      if (isArray$1(y)) {
        ymax = y[1];
        ymin = y[0];
      }

      var xmin;
      var xmax;

      if (isArray$1(x)) {
        xmin = x[0];
        xmax = x[1];
      } else {
        xmin = x - size / 2;
        xmax = x + size / 2;
      }

      return [{
        x: xmin,
        y: ymin
      }, {
        x: xmin,
        y: ymax
      }, {
        x: xmax,
        y: ymax
      }, {
        x: xmax,
        y: ymin
      }];
    }

    function getRectRange(points) {
      var xValues = [];
      var yValues = [];

      for (var i = 0, len = points.length; i < len; i++) {
        var point = points[i];
        xValues.push(point.x);
        yValues.push(point.y);
      }

      var xMin = Math.min.apply(null, xValues);
      var yMin = Math.min.apply(null, yValues);
      var xMax = Math.max.apply(null, xValues);
      var yMax = Math.max.apply(null, yValues);
      return {
        x: xMin,
        y: yMin,
        width: xMax - xMin,
        height: yMax - yMin
      };
    }

    function getMiddlePoint(a, b) {
      var x = (a.x - b.x) / 2 + b.x;
      var y = (a.y - b.y) / 2 + b.y;
      return {
        x: x,
        y: y
      };
    }

    Shape$1.registerFactory('interval', {
      defaultShapeType: 'rect',
      getDefaultPoints: function getDefaultPoints(cfg) {
        return getRectPoints(cfg);
      }
    });
    Shape$1.registerShape('interval', 'rect', {
      draw: function draw(cfg, container) {
        var points = this.parsePoints(cfg.points);
        var style = mix$1({
          fill: cfg.color
        }, Global.shape.interval, cfg.style);

        if (cfg.isInCircle) {
          var newPoints = points.slice(0);

          if (this._coord.transposed) {
            newPoints = [points[0], points[3], points[2], points[1]];
          }

          var _cfg$center = cfg.center,
              x = _cfg$center.x,
              y = _cfg$center.y;
          var v = [1, 0];
          var v0 = [newPoints[0].x - x, newPoints[0].y - y];
          var v1 = [newPoints[1].x - x, newPoints[1].y - y];
          var v2 = [newPoints[2].x - x, newPoints[2].y - y];
          var startAngle = Vector2.angleTo(v, v1);
          var endAngle = Vector2.angleTo(v, v2);
          var r0 = Vector2.length(v0);
          var r = Vector2.length(v1);

          if (startAngle >= 1.5 * Math.PI) {
            startAngle = startAngle - 2 * Math.PI;
          }

          if (endAngle >= 1.5 * Math.PI) {
            endAngle = endAngle - 2 * Math.PI;
          }

          return container.addShape('Sector', {
            className: 'interval',
            attrs: mix$1({
              x: x,
              y: y,
              r: r,
              r0: r0,
              startAngle: startAngle,
              endAngle: endAngle
            }, style)
          });
        }

        var rectCfg = getRectRange(points);
        return container.addShape('rect', {
          className: 'interval',
          attrs: mix$1(rectCfg, style)
        });
      }
    }); // 金字塔 和 漏斗图

    ['pyramid', 'funnel'].forEach(function (shapeType) {
      Shape$1.registerShape('interval', shapeType, {
        getPoints: function getPoints(cfg) {
          cfg.size = cfg.size * 2; // 漏斗图的 size 是柱状图的两倍

          return getRectPoints(cfg);
        },
        draw: function draw(cfg, container) {
          var points = this.parsePoints(cfg.points);
          var nextPoints = this.parsePoints(cfg.nextPoints);
          var polygonPoints = null;

          if (nextPoints) {
            polygonPoints = [points[0], points[1], nextPoints[1], nextPoints[0]];
          } else {
            polygonPoints = [points[0], points[1]]; // pyramid 顶部是三角形,所以取中心点就好了,funnel顶部是长方形

            if (shapeType === 'pyramid') {
              polygonPoints.push(getMiddlePoint(points[2], points[3]));
            } else {
              polygonPoints.push(points[2], points[3]);
            }
          }

          var attrs = mix$1({
            fill: cfg.color,
            points: polygonPoints
          }, Global.shape.interval, cfg.style);
          return container.addShape('polygon', {
            className: 'interval',
            attrs: attrs
          });
        }
      });
    });

    var Interval = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Interval, _Geom);

      var _proto = Interval.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'interval';
        cfg.shapeType = 'interval';
        cfg.generatePoints = true;
        return cfg;
      };

      function Interval(cfg) {
        var _this;

        _this = _Geom.call(this, cfg) || this;
        mix$1(_assertThisInitialized(_this), SizeMixin);
        return _this;
      }

      _proto.init = function init() {
        _Geom.prototype.init.call(this); // 绑定事件


        this.initEvent();
      };

      _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
        var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);

        cfg.size = this.getNormalizedSize(obj);
        return cfg;
      };

      _proto.clearInner = function clearInner() {
        _Geom.prototype.clearInner.call(this);

        this.set('defaultSize', null);
      };

      return Interval;
    }(Geom);

    Geom.Interval = Interval;

    Shape$1.registerFactory('polygon', {
      defaultShapeType: 'polygon',
      getDefaultPoints: function getDefaultPoints(pointInfo) {
        var points = [];
        var x = pointInfo.x,
            y = pointInfo.y;

        for (var i = 0, len = x.length; i < len; i++) {
          points.push({
            x: x[i],
            y: y[i]
          });
        }

        return points;
      }
    });
    Shape$1.registerShape('polygon', 'polygon', {
      draw: function draw(cfg, container) {
        var points = this.parsePoints(cfg.points);
        var style = mix$1({
          fill: cfg.color,
          points: points
        }, cfg.style);
        return container.addShape('Polygon', {
          className: 'polygon',
          attrs: style
        });
      }
    });

    var Polygon = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Polygon, _Geom);

      function Polygon() {
        return _Geom.apply(this, arguments) || this;
      }

      var _proto = Polygon.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'polygon';
        cfg.shapeType = 'polygon';
        cfg.generatePoints = true;
        return cfg;
      };

      _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
        var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);

        var self = this;
        var x = cfg.x;
        var y = cfg.y;
        var temp;

        if (!(isArray$1(x) && isArray$1(y))) {
          var xScale = self.getXScale();
          var yScale = self.getYScale();
          var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
          var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
          var xOffset = 0.5 * 1 / xCount;
          var yOffset = 0.5 * 1 / yCount;

          if (xScale.isCategory && yScale.isCategory) {
            x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
            y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
          } else if (isArray$1(x)) {
            temp = x;
            x = [temp[0], temp[0], temp[1], temp[1]];
            y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
          } else if (isArray$1(y)) {
            temp = y;
            y = [temp[0], temp[1], temp[1], temp[0]];
            x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
          }

          cfg.x = x;
          cfg.y = y;
        }

        return cfg;
      };

      return Polygon;
    }(Geom);

    Geom.Polygon = Polygon;

    function _sortValue(value) {
      var sorted = value.sort(function (a, b) {
        return a < b ? 1 : -1;
      });
      var length = sorted.length;

      if (length < 4) {
        var min = sorted[length - 1];

        for (var i = 0; i < 4 - length; i++) {
          sorted.push(min);
        }
      }

      return sorted;
    } // from left bottom corner, and clockwise


    function getCandlePoints(x, y, width) {
      var yValues = _sortValue(y);

      var points = [{
        x: x,
        y: yValues[0]
      }, {
        x: x,
        y: yValues[1]
      }, {
        x: x - width / 2,
        y: yValues[2]
      }, {
        x: x - width / 2,
        y: yValues[1]
      }, {
        x: x + width / 2,
        y: yValues[1]
      }, {
        x: x + width / 2,
        y: yValues[2]
      }, {
        x: x,
        y: yValues[2]
      }, {
        x: x,
        y: yValues[3]
      }];
      return points;
    }

    Shape$1.registerFactory('schema', {});
    Shape$1.registerShape('schema', 'candle', {
      getPoints: function getPoints(cfg) {
        return getCandlePoints(cfg.x, cfg.y, cfg.size);
      },
      draw: function draw(cfg, container) {
        var points = this.parsePoints(cfg.points);
        var style = mix$1({
          stroke: cfg.color,
          fill: cfg.color,
          lineWidth: 1
        }, cfg.style);
        return container.addShape('Custom', {
          className: 'schema',
          attrs: style,
          createPath: function createPath(ctx) {
            ctx.beginPath();
            ctx.moveTo(points[0].x, points[0].y);
            ctx.lineTo(points[1].x, points[1].y);
            ctx.moveTo(points[2].x, points[2].y);

            for (var i = 3; i < 6; i++) {
              ctx.lineTo(points[i].x, points[i].y);
            }

            ctx.closePath();
            ctx.moveTo(points[6].x, points[6].y);
            ctx.lineTo(points[7].x, points[7].y);
          }
        });
      }
    });

    var Schema = /*#__PURE__*/function (_Geom) {
      _inheritsLoose$3(Schema, _Geom);

      var _proto = Schema.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        var cfg = _Geom.prototype.getDefaultCfg.call(this);

        cfg.type = 'schema';
        cfg.shapeType = 'schema';
        cfg.generatePoints = true;
        return cfg;
      };

      function Schema(cfg) {
        var _this;

        _this = _Geom.call(this, cfg) || this;
        mix$1(_assertThisInitialized(_this), SizeMixin);
        return _this;
      }

      _proto.init = function init() {
        _Geom.prototype.init.call(this); // 绑定事件


        this.initEvent();
      };

      _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
        var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);

        cfg.size = this.getNormalizedSize(obj);
        return cfg;
      };

      _proto.clearInner = function clearInner() {
        _Geom.prototype.clearInner.call(this);

        this.set('defaultSize', null);
      };

      return Schema;
    }(Geom);

    Geom.Schema = Schema;

    var toString = {}.toString;

    var isType = function isType(value, type) {
      return toString.call(value) === '[object ' + type + ']';
    };

    var isType_1 = isType;

    var isArray = Array.isArray ? Array.isArray : function (value) {
      return isType_1(value, 'Array');
    };
    var isArray_1 = isArray;

    // isFinite,
    var isNil = function isNil(value) {
      /**
       * isNil(null) => true
       * isNil() => true
       */
      return value === null || value === undefined;
    };

    var isNil_1 = isNil;

    function _inheritsLoose$2(subClass, superClass) {
      subClass.prototype = Object.create(superClass.prototype);
      subClass.prototype.constructor = subClass;
      subClass.__proto__ = superClass;
    }

    var Stack = /*#__PURE__*/function (_Adjust) {
      _inheritsLoose$2(Stack, _Adjust);

      function Stack() {
        return _Adjust.apply(this, arguments) || this;
      }

      var _proto = Stack.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.xField = null; // 调整对应的 x 方向对应的字段名称

        this.yField = null; // 调整对应的 y 方向对应的字段名称
      };

      _proto.processAdjust = function processAdjust(dataArray) {
        this.processStack(dataArray);
      };

      _proto.processStack = function processStack(dataArray) {
        var self = this;
        var xField = self.xField;
        var yField = self.yField;
        var count = dataArray.length;
        var stackCache = {
          positive: {},
          negative: {}
        }; // 层叠顺序翻转

        if (self.reverseOrder) {
          dataArray = dataArray.slice(0).reverse();
        }

        for (var i = 0; i < count; i++) {
          var data = dataArray[i];

          for (var j = 0, len = data.length; j < len; j++) {
            var item = data[j];
            var x = item[xField] || 0;
            var y = item[yField];
            var xkey = x.toString();
            y = isArray_1(y) ? y[1] : y;

            if (!isNil_1(y)) {
              var direction = y >= 0 ? 'positive' : 'negative';

              if (!stackCache[direction][xkey]) {
                stackCache[direction][xkey] = 0;
              }

              item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
              stackCache[direction][xkey] += y;
            }
          }
        }
      };

      return Stack;
    }(base);

    base.Stack = Stack;

    var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
      return typeof obj;
    } : function (obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };

    var isObject = function isObject(value) {
      /**
       * isObject({}) => true
       * isObject([1, 2, 3]) => true
       * isObject(Function) => true
       * isObject(null) => false
       */
      var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
      return value !== null && type === 'object' || type === 'function';
    };

    var isObject_1 = isObject;

    var each = function each(elements, func) {
      if (!elements) {
        return;
      }

      var rst = void 0;

      if (isArray_1(elements)) {
        for (var i = 0, len = elements.length; i < len; i++) {
          rst = func(elements[i], i);

          if (rst === false) {
            break;
          }
        }
      } else if (isObject_1(elements)) {
        for (var k in elements) {
          if (elements.hasOwnProperty(k)) {
            rst = func(elements[k], k);

            if (rst === false) {
              break;
            }
          }
        }
      }
    };

    var each_1 = each;

    function _inheritsLoose$1(subClass, superClass) {
      subClass.prototype = Object.create(superClass.prototype);
      subClass.prototype.constructor = subClass;
      subClass.__proto__ = superClass;
    }

    var MARGIN_RATIO = 1 / 2;
    var DODGE_RATIO = 1 / 2;

    var Dodge = /*#__PURE__*/function (_Adjust) {
      _inheritsLoose$1(Dodge, _Adjust);

      function Dodge() {
        return _Adjust.apply(this, arguments) || this;
      }

      var _proto = Dodge.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        /**
         * 调整过程中,2个数据的间距
         * @type {Number}
         */
        this.marginRatio = MARGIN_RATIO;
        /**
         * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
         * @type {Number}
         */

        this.dodgeRatio = DODGE_RATIO;
        this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
      };

      _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
        var self = this;
        var pre = range.pre;
        var next = range.next;
        var tickLength = next - pre;
        var width = tickLength * self.dodgeRatio / count;
        var margin = self.marginRatio * width;
        var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
        return (pre + next) / 2 + offset;
      };

      _proto.processAdjust = function processAdjust(dataArray) {
        var self = this;
        var count = dataArray.length;
        var xField = self.xField;
        each_1(dataArray, function (data, index) {
          for (var i = 0, len = data.length; i < len; i++) {
            var obj = data[i];
            var value = obj[xField];
            var range = {
              pre: len === 1 ? value - 1 : value - 0.5,
              next: len === 1 ? value + 1 : value + 0.5
            };
            var dodgeValue = self.getDodgeOffset(range, index, count);
            obj[xField] = dodgeValue;
          }
        });
      };

      return Dodge;
    }(base);

    base.Dodge = Dodge;

    /**
     * 是否为函数
     * @param  {*} fn 对象
     * @return {Boolean}  是否函数
     */

    var isFunction = function isFunction(value) {
      return isType_1(value, 'Function');
    };

    var isFunction_1 = isFunction;

    /**
     * @param {Array} arr The array to iterate over.
     * @param {Function} [fn] The iteratee invoked per element.
     * @return {*} Returns the maximum value.
     * @example
     *
     * var objects = [{ 'n': 1 }, { 'n': 2 }];
     *
     * maxBy(objects, function(o) { return o.n; });
     * // => { 'n': 2 }
     *
     * maxBy(objects, 'n');
     * // => { 'n': 2 }
     */

    var maxBy = function maxBy(arr, fn) {
      if (!isArray_1(arr)) {
        return undefined;
      }

      var max = arr[0];
      var maxData = void 0;

      if (isFunction_1(fn)) {
        maxData = fn(arr[0]);
      } else {
        maxData = arr[0][fn];
      }

      var data = void 0;
      each_1(arr, function (val) {
        if (isFunction_1(fn)) {
          data = fn(val);
        } else {
          data = val[fn];
        }

        if (data > maxData) {
          max = val;
          maxData = data;
        }
      });
      return max;
    };

    var maxBy_1 = maxBy;

    var merge = function merge(dataArray) {
      var rst = [];

      for (var i = 0; i < dataArray.length; i++) {
        rst = rst.concat(dataArray[i]);
      }

      return rst;
    };

    var merge_1 = merge;

    function _inheritsLoose(subClass, superClass) {
      subClass.prototype = Object.create(superClass.prototype);
      subClass.prototype.constructor = subClass;
      subClass.__proto__ = superClass;
    }

    var ArrayUtil = {
      merge: merge_1
    };

    var Symmetric = /*#__PURE__*/function (_Adjust) {
      _inheritsLoose(Symmetric, _Adjust);

      function Symmetric() {
        return _Adjust.apply(this, arguments) || this;
      }

      var _proto = Symmetric.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.xField = null; // 调整对应的 x 方向对应的字段名称

        this.yField = null; // 调整对应的 y 方向对应的字段名称

        this.cacheMax = null; // 缓存的最大值

        this.adjustNames = ['y']; // Only support stack y

        this.groupFields = null; // 参与分组的数据维度
      }; // 获取最大的y值


      _proto._getMax = function _getMax(dim) {
        var self = this;
        var mergeData = self.mergeData;
        var maxRecord = maxBy_1(mergeData, function (obj) {
          var value = obj[dim];

          if (isArray_1(value)) {
            return Math.max.apply(null, value);
          }

          return value;
        });
        var maxValue = maxRecord[dim];
        var max = isArray_1(maxValue) ? Math.max.apply(null, maxValue) : maxValue;
        return max;
      }; // 获取每个字段最大的值


      _proto._getXValuesMax = function _getXValuesMax() {
        var self = this;
        var yField = self.yField;
        var xField = self.xField;
        var cache = {};
        var mergeData = self.mergeData;
        each_1(mergeData, function (obj) {
          var xValue = obj[xField];
          var yValue = obj[yField];
          var max = isArray_1(yValue) ? Math.max.apply(null, yValue) : yValue;
          cache[xValue] = cache[xValue] || 0;

          if (cache[xValue] < max) {
            cache[xValue] = max;
          }
        });
        return cache;
      }; // 入口函数


      _proto.processAdjust = function processAdjust(dataArray) {
        var self = this;
        var mergeData = ArrayUtil.merge(dataArray);
        self.mergeData = mergeData;

        self._processSymmetric(dataArray);

        self.mergeData = null;
      }; // 处理对称


      _proto._processSymmetric = function _processSymmetric(dataArray) {
        var self = this;
        var xField = self.xField;
        var yField = self.yField;

        var max = self._getMax(yField);

        var first = dataArray[0][0];
        var cache;

        if (first && isArray_1(first[yField])) {
          cache = self._getXValuesMax();
        }

        each_1(dataArray, function (data) {
          each_1(data, function (obj) {
            var value = obj[yField];
            var offset;

            if (isArray_1(value)) {
              var xValue = obj[xField];
              var valueMax = cache[xValue];
              offset = (max - valueMax) / 2;
              var tmp = [];
              /* eslint-disable no-loop-func */

              each_1(value, function (subVal) {
                // 多个字段
                tmp.push(offset + subVal);
              });
              /* eslint-enable no-loop-func */

              obj[yField] = tmp;
            } else {
              offset = (max - value) / 2;
              obj[yField] = [offset, value + offset];
            }
          });
        });
      };

      return Symmetric;
    }(base);

    base.Symmetric = Symmetric;

    var Polar = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Polar, _Base);

      function Polar() {
        return _Base.apply(this, arguments) || this;
      }

      var _proto = Polar.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'polar';
        this.startAngle = -Math.PI / 2;
        this.endAngle = Math.PI * 3 / 2;
        this.inner = 0;
        this.innerRadius = 0; // alias

        this.isPolar = true;
        this.transposed = false;
        this.center = null;
        this.radius = null; // relative, 0 ~ 1
      };

      _proto.init = function init(start, end) {
        _Base.prototype.init.call(this, start, end);

        var self = this;
        var inner = self.inner || self.innerRadius;
        var width = Math.abs(end.x - start.x);
        var height = Math.abs(end.y - start.y);
        var maxRadius;
        var center;

        if (self.startAngle === -Math.PI && self.endAngle === 0) {
          maxRadius = Math.min(width / 2, height);
          center = {
            x: (start.x + end.x) / 2,
            y: start.y
          };
        } else {
          maxRadius = Math.min(width, height) / 2;
          center = {
            x: (start.x + end.x) / 2,
            y: (start.y + end.y) / 2
          };
        }

        var radius = self.radius;

        if (radius > 0 && radius <= 1) {
          maxRadius = maxRadius * radius;
        }

        this.x = {
          start: self.startAngle,
          end: self.endAngle
        };
        this.y = {
          start: maxRadius * inner,
          end: maxRadius
        };
        this.center = center;
        this.circleRadius = maxRadius; // the radius value in px
      };

      _proto._convertPoint = function _convertPoint(point) {
        var self = this;
        var center = self.center;
        var transposed = self.transposed;
        var xDim = transposed ? 'y' : 'x';
        var yDim = transposed ? 'x' : 'y';
        var x = self.x;
        var y = self.y;
        var angle = x.start + (x.end - x.start) * point[xDim];
        var radius = y.start + (y.end - y.start) * point[yDim];
        return {
          x: center.x + Math.cos(angle) * radius,
          y: center.y + Math.sin(angle) * radius
        };
      };

      _proto._invertPoint = function _invertPoint(point) {
        var self = this;
        var center = self.center,
            transposed = self.transposed,
            x = self.x,
            y = self.y;
        var xDim = transposed ? 'y' : 'x';
        var yDim = transposed ? 'x' : 'y';
        var m = [1, 0, 0, 1, 0, 0];
        Matrix.rotate(m, m, x.start);
        var startV = [1, 0];
        Vector2.transformMat2d(startV, startV, m);
        startV = [startV[0], startV[1]];
        var pointV = [point.x - center.x, point.y - center.y];

        if (Vector2.zero(pointV)) {
          return {
            x: 0,
            y: 0
          };
        }

        var theta = Vector2.angleTo(startV, pointV, x.end < x.start);

        if (Math.abs(theta - Math.PI * 2) < 0.001) {
          theta = 0;
        }

        var l = Vector2.length(pointV);
        var percentX = theta / (x.end - x.start);
        percentX = x.end - x.start > 0 ? percentX : -percentX;
        var percentY = (l - y.start) / (y.end - y.start);
        var rst = {};
        rst[xDim] = percentX;
        rst[yDim] = percentY;
        return rst;
      };

      return Polar;
    }(Base$1);

    Base$1.Polar = Polar;

    var Circle = /*#__PURE__*/function (_Abstract) {
      _inheritsLoose$3(Circle, _Abstract);

      function Circle() {
        return _Abstract.apply(this, arguments) || this;
      }

      var _proto = Circle.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        _Abstract.prototype._initDefaultCfg.call(this);

        this.startAngle = -Math.PI / 2; // start angle,in radian

        this.endAngle = Math.PI * 3 / 2; // end angle, in radian

        this.radius = null; // radius

        this.center = null; // center
      };

      _proto.getOffsetPoint = function getOffsetPoint(value) {
        var startAngle = this.startAngle,
            endAngle = this.endAngle;
        var angle = startAngle + (endAngle - startAngle) * value;
        return this._getCirclePoint(angle);
      };

      _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
        var self = this;
        var center = self.center;
        radius = radius || self.radius;
        return {
          x: center.x + Math.cos(angle) * radius,
          y: center.y + Math.sin(angle) * radius
        };
      };

      _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
        var self = this;
        var offsetVector = self.getOffsetVector(point, offset);
        var align;
        var baseLine = 'middle';

        if (offsetVector[0] > 0) {
          align = 'left';
        } else if (offsetVector[0] < 0) {
          align = 'right';
        } else {
          align = 'center';

          if (offsetVector[1] > 0) {
            baseLine = 'top';
          } else if (offsetVector[1] < 0) {
            baseLine = 'bottom';
          }
        }

        return {
          textAlign: align,
          textBaseline: baseLine
        };
      };

      _proto.getAxisVector = function getAxisVector(point) {
        var center = this.center;
        var factor = this.offsetFactor;
        return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
      };

      _proto.drawLine = function drawLine(lineCfg) {
        var center = this.center,
            radius = this.radius,
            startAngle = this.startAngle,
            endAngle = this.endAngle;
        var container = this.getContainer(lineCfg.top);
        container.addShape('arc', {
          className: 'axis-line',
          attrs: mix$1({
            x: center.x,
            y: center.y,
            r: radius,
            startAngle: startAngle,
            endAngle: endAngle
          }, lineCfg)
        });
      };

      return Circle;
    }(Abastract);

    Abastract.Circle = Circle;

    var KEYWORDS_PERCENT = {
      min: 0,
      median: 0.5,
      max: 1
    };

    var GuideBase = /*#__PURE__*/function () {
      var _proto = GuideBase.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {};

      function GuideBase(cfg) {
        this._initDefaultCfg();

        deepMix(this, cfg);
      }

      _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
        var rst;

        if (isNil$1(KEYWORDS_PERCENT[val])) {
          rst = scale.scale(val);
        } else {
          rst = KEYWORDS_PERCENT[val];
        }

        return rst;
      };

      _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
        var xPercent = parseFloat(position[0]) / 100;
        var yPercent = parseFloat(position[1]) / 100;
        var start = coord.start;
        var end = coord.end;
        var width = Math.abs(start.x - end.x);
        var height = Math.abs(start.y - end.y);
        var x = width * xPercent + Math.min(start.x, end.x);
        var y = height * yPercent + Math.min(start.y, end.y);
        return {
          x: x,
          y: y
        };
      };

      _proto.parsePoint = function parsePoint(coord, position) {
        var self = this;
        var xScale = self.xScale;
        var yScales = self.yScales;

        if (isFunction$1(position)) {
          position = position(xScale, yScales); // position 必须是对象
        } // 如果数据格式是 ['50%', '50%'] 的格式
        // fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590


        if (isString(position[0]) && position[0].indexOf('%') !== -1 && !isNaN(position[0].slice(0, -1))) {
          return this.parsePercentPoint(coord, position);
        }

        var x = self._getNormalizedValue(position[0], xScale);

        var y = self._getNormalizedValue(position[1], yScales[0]);

        var point = coord.convertPoint({
          x: x,
          y: y
        });

        if (self.limitInPlot) {
          // limit in chart plotRange
          if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
            return point;
          }

          return null;
        }

        return point;
      }
      /**
       * render the guide component
       * @param  {Coord} coord  coordinate instance
       * @param  {Canvas.Group} group the container
       */
      ;

      _proto.render = function render() {};

      _proto.repaint = function repaint() {
        this.remove();
        var coord = this.coord,
            container = this.container,
            canvas = this.canvas;

        if (container && !container.isDestroyed()) {
          this.render(coord, container);
          canvas.draw();
        }
      };

      _proto.remove = function remove() {
        var element = this.element;
        element && element.remove(true);
      };

      _proto.changeVisible = function changeVisible(visible) {
        var self = this;
        self.visible = visible;
        var element = self.element;
        if (!element) return;

        if (element.set) {
          element.set('visible', visible);
        } else {
          element.style.display = visible ? '' : 'none';
        }
      };

      return GuideBase;
    }();

    var Arc = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Arc, _GuideBase);

      function Arc() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Arc.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'arc';
        /**
         * start point
         * @type {Array | Function}
         */

        this.start = [];
        /**
         * end point
         * @type {Array | Function}
         */

        this.end = [];
        /**
         * style configuration
         * @type {Object}
         */

        this.style = {
          stroke: '#999',
          lineWidth: 1
        };
      };

      _proto.render = function render(coord, container) {
        var self = this;
        var start = self.parsePoint(coord, self.start);
        var end = self.parsePoint(coord, self.end);

        if (!start || !end) {
          return;
        }

        var coordCenter = coord.center;
        var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
        var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
        var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
        var shape = container.addShape('arc', {
          className: 'guide-arc',
          attrs: mix$1({
            x: coordCenter.x,
            y: coordCenter.y,
            r: radius,
            startAngle: startAngle,
            endAngle: endAngle
          }, self.style)
        });
        self.element = shape;
        return shape;
      };

      return Arc;
    }(GuideBase);

    GuideBase.Arc = Arc;

    function getOffsetFromAlign(alignX, alignY, width, height) {
      var result = [];

      if (alignX === 'left' && alignY === 'top') {
        result[0] = 0;
        result[1] = 0;
      } else if (alignX === 'right' && alignY === 'top') {
        result[0] = -width;
        result[1] = 0;
      } else if (alignX === 'left' && alignY === 'bottom') {
        result[0] = 0;
        result[1] = Math.floor(-height);
      } else if (alignX === 'right' && alignY === 'bottom') {
        result[0] = Math.floor(-width);
        result[1] = Math.floor(-height);
      } else if (alignX === 'right' && alignY === 'middle') {
        result[0] = Math.floor(-width);
        result[1] = Math.floor(-height / 2);
      } else if (alignX === 'left' && alignY === 'middle') {
        result[0] = 0;
        result[1] = Math.floor(-height / 2);
      } else if (alignX === 'center' && alignY === 'bottom') {
        result[0] = Math.floor(-width / 2);
        result[1] = Math.floor(-height);
      } else if (alignX === 'center' && alignY === 'top') {
        result[0] = Math.floor(-width / 2);
        result[1] = 0;
      } else {
        result[0] = Math.floor(-width / 2);
        result[1] = Math.floor(-height / 2);
      }

      return result;
    }

    function modifyCSS(DOM, CSS) {
      for (var key in CSS) {
        if (CSS.hasOwnProperty(key)) {
          DOM.style[key] = CSS[key];
        }
      }

      return DOM;
    }

    function createDom(str) {
      var container = document.createElement('div');
      str = str.replace(/(^\s*)|(\s*$)/g, '');
      container.innerHTML = '' + str;
      return container.childNodes[0];
    }

    var Html = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Html, _GuideBase);

      function Html() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Html.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'html';
        /**
         * dom position
         * @type {Object | Array}
         */

        this.position = null;
        /**
          * alignment for horizontal direction,can be 'left','center','right'
          * @type {String}
          */

        this.alignX = 'center';
        /**
          * alignment for vertical direction,can be 'top', 'middle', 'bottom'
          * @type {String}
          */

        this.alignY = 'middle';
        /**
          * offset for horizontal direction
          * @type {Number}
          */

        this.offsetX = null;
        /**
          * offset for vertical direction
          * @type {Number}
          */

        this.offsetY = null;
        /**
        * the html string
        *@type {String | Function}
        */

        this.html = null;
      } // override paint
      ;

      _proto.render = function render(coord, container) {
        var self = this;
        var position = self.parsePoint(coord, self.position);

        if (!position) {
          return;
        }

        var myNode = createDom(self.html);
        myNode = modifyCSS(myNode, {
          position: 'absolute',
          top: Math.floor(position.y) + 'px',
          left: Math.floor(position.x) + 'px',
          visibility: 'hidden'
        });
        var canvasDom = container.get('canvas').get('el');
        var parentNode = canvasDom.parentNode;
        parentNode = modifyCSS(parentNode, {
          position: 'relative'
        });
        var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
        parentNode.appendChild(wrapperNode);
        wrapperNode.appendChild(myNode);
        var canvasOffsetTop = canvasDom.offsetTop;
        var canvasOffsetLeft = canvasDom.offsetLeft;
        var alignX = self.alignX,
            alignY = self.alignY,
            offsetX = self.offsetX,
            offsetY = self.offsetY;
        var width = getWidth(myNode);
        var height = getHeight(myNode);
        var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
        position.x = position.x + newOffset[0] + canvasOffsetLeft;
        position.y = position.y + newOffset[1] + canvasOffsetTop;

        if (offsetX) {
          position.x += offsetX;
        }

        if (offsetY) {
          position.y += offsetY;
        }

        modifyCSS(myNode, {
          top: Math.floor(position.y) + 'px',
          left: Math.floor(position.x) + 'px',
          visibility: 'visible'
        });
        self.element = wrapperNode;
      };

      _proto.remove = function remove() {
        var element = this.element;
        element && element.parentNode && element.parentNode.removeChild(element);
      };

      return Html;
    }(GuideBase);

    GuideBase.Html = Html;

    var Line = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Line, _GuideBase);

      function Line() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Line.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'line';
        this.start = [];
        this.end = [];
        this.style = {
          stroke: '#000',
          lineWidth: 1
        };
      };

      _proto.render = function render(coord, container) {
        var points = [];
        points[0] = this.parsePoint(coord, this.start);
        points[1] = this.parsePoint(coord, this.end);

        if (!points[0] || !points[1]) {
          return;
        }

        var shape = container.addShape('Line', {
          className: 'guide-line',
          attrs: mix$1({
            x1: points[0].x,
            y1: points[0].y,
            x2: points[1].x,
            y2: points[1].y
          }, this.style)
        });
        this.element = shape;
        return shape;
      };

      return Line;
    }(GuideBase);

    GuideBase.Line = Line;

    var Rect = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Rect, _GuideBase);

      function Rect() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Rect.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'rect';
        this.start = [];
        this.end = [];
        this.style = {
          fill: '#CCD7EB',
          opacity: 0.4
        };
      };

      _proto.render = function render(coord, container) {
        var start = this.parsePoint(coord, this.start);
        var end = this.parsePoint(coord, this.end);

        if (!start || !end) {
          return;
        }

        var shape = container.addShape('rect', {
          className: 'guide-rect',
          attrs: mix$1({
            x: Math.min(start.x, end.x),
            y: Math.min(start.y, end.y),
            width: Math.abs(end.x - start.x),
            height: Math.abs(start.y - end.y)
          }, this.style)
        });
        this.element = shape;
        return shape;
      };

      return Rect;
    }(GuideBase);

    GuideBase.Rect = Rect;

    var Text = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Text, _GuideBase);

      function Text() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Text.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'text';
        /**
         * the position of text
         * @type {Function | Array}
         */

        this.position = null;
        /**
         * the display content
         * @type {String}
         */

        this.content = null;
        /**
         * style configuration for text
         * @type {Object}
         */

        this.style = {
          fill: '#000'
        };
        /**
         * offset of horizontal direction
         * @type {Number}
         */

        this.offsetX = 0;
        /**
         * offset of vertical direction
         * @type {Number}
         */

        this.offsetY = 0;
      };

      _proto.render = function render(coord, container) {
        var position = this.position;
        var point = this.parsePoint(coord, position);

        if (!point) {
          return;
        }

        var content = this.content,
            style = this.style,
            offsetX = this.offsetX,
            offsetY = this.offsetY;

        if (offsetX) {
          point.x += offsetX;
        }

        if (offsetY) {
          point.y += offsetY;
        }

        var shape = container.addShape('text', {
          className: 'guide-text',
          attrs: mix$1({
            x: point.x,
            y: point.y,
            text: content
          }, style)
        });
        this.element = shape;
        return shape;
      };

      return Text;
    }(GuideBase);

    GuideBase.Text = Text;

    var Tag = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Tag, _GuideBase);

      function Tag() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Tag.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'tag';
        this.position = null;
        this.content = null;
        this.direct = 'tl';
        this.autoAdjust = true;
        this.offsetX = 0;
        this.offsetY = 0;
        this.side = 4;
        this.background = {
          padding: 5,
          radius: 2,
          fill: '#1890FF'
        };
        this.textStyle = {
          fontSize: 12,
          fill: '#fff',
          textAlign: 'center',
          textBaseline: 'middle'
        };
        this.withPoint = true;
        this.pointStyle = {
          fill: '#1890FF',
          r: 3,
          lineWidth: 1,
          stroke: '#fff'
        };
      };

      _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
        var direct = this.direct;
        var side = this.side;
        var canvas = container.get('canvas');
        var clientWidth = canvas.get('width');
        var clientHeight = canvas.get('height');
        var x = point.x,
            y = point.y;
        var vertical = direct[0];
        var horizontal = direct[1]; // adjust for vertical direction

        if (vertical === 't' && y - side - tagHeight < 0) {
          vertical = 'b';
        } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
          vertical = 't';
        } // adjust for horizontal direction


        var diff = vertical === 'c' ? side : 0;

        if (horizontal === 'l' && x - diff - tagWidth < 0) {
          horizontal = 'r';
        } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
          horizontal = 'l';
        } else if (horizontal === 'c') {
          if (tagWidth / 2 + x + diff > clientWidth) {
            horizontal = 'l';
          } else if (x - tagWidth / 2 - diff < 0) {
            horizontal = 'r';
          }
        }

        direct = vertical + horizontal;
        return direct;
      };

      _proto.render = function render(coord, container) {
        var position = this.parsePoint(coord, this.position);

        if (!position) {
          return;
        } // 数据不在显示范围内时,x/y 会为NaN


        if (isNaN(position.x) || isNaN(position.y)) {
          return;
        }

        var content = this.content,
            background = this.background,
            textStyle = this.textStyle;
        var shapes = [];
        var wrapperContainer = container.addGroup({
          className: 'guide-tag'
        });

        if (this.withPoint) {
          var pointShape = wrapperContainer.addShape('Circle', {
            className: 'guide-tag-point',
            attrs: mix$1({
              x: position.x,
              y: position.y
            }, this.pointStyle)
          });
          shapes.push(pointShape);
        }

        var tagContainer = wrapperContainer.addGroup(); // create a text shape

        var tagText = tagContainer.addShape('text', {
          className: 'guide-tag-text',
          zIndex: 1,
          attrs: mix$1({
            x: 0,
            y: 0,
            text: content
          }, textStyle)
        });
        shapes.push(tagText); // create background box

        var textBBox = tagText.getBBox();
        var padding = parsePadding(background.padding);
        var tagWidth = textBBox.width + padding[1] + padding[3];
        var tagHeight = textBBox.height + padding[0] + padding[2];
        var yMin = textBBox.minY - padding[0];
        var xMin = textBBox.minX - padding[3];
        var tagBg = tagContainer.addShape('rect', {
          className: 'guide-tag-bg',
          zIndex: -1,
          attrs: mix$1({
            x: xMin,
            y: yMin,
            width: tagWidth,
            height: tagHeight
          }, background)
        });
        shapes.push(tagBg);
        var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
        var side = this.side;
        var x = position.x + this.offsetX;
        var y = position.y + this.offsetY;
        var arrowPoints;
        var radius = parsePadding(background.radius);

        if (direct === 'tl') {
          arrowPoints = [{
            x: tagWidth + xMin - side - 1,
            y: tagHeight + yMin - 1
          }, // 这个 1 是为了防止出现白边
          {
            x: tagWidth + xMin,
            y: tagHeight + yMin - 1
          }, {
            x: tagWidth + xMin,
            y: tagHeight + side + yMin
          }];
          radius[2] = 0;
          x = x - tagWidth;
          y = y - side - tagHeight;
        } else if (direct === 'cl') {
          arrowPoints = [{
            x: tagWidth + xMin - 1,
            y: (tagHeight - side) / 2 + yMin - 1
          }, {
            x: tagWidth + xMin - 1,
            y: (tagHeight + side) / 2 + yMin + 1
          }, {
            x: tagWidth + side + xMin,
            y: tagHeight / 2 + yMin
          }];
          x = x - tagWidth - side;
          y = y - tagHeight / 2;
        } else if (direct === 'bl') {
          arrowPoints = [{
            x: tagWidth + xMin,
            y: -side + yMin
          }, {
            x: tagWidth + xMin - side - 1,
            y: yMin + 1
          }, {
            x: tagWidth + xMin,
            y: yMin + 1
          }];
          radius[1] = 0;
          x = x - tagWidth;
          y = y + side;
        } else if (direct === 'bc') {
          arrowPoints = [{
            x: tagWidth / 2 + xMin,
            y: -side + yMin
          }, {
            x: (tagWidth - side) / 2 + xMin - 1,
            y: yMin + 1
          }, {
            x: (tagWidth + side) / 2 + xMin + 1,
            y: yMin + 1
          }];
          x = x - tagWidth / 2;
          y = y + side;
        } else if (direct === 'br') {
          arrowPoints = [{
            x: xMin,
            y: yMin - side
          }, {
            x: xMin,
            y: yMin + 1
          }, {
            x: xMin + side + 1,
            y: yMin + 1
          }];
          radius[0] = 0;
          y = y + side;
        } else if (direct === 'cr') {
          arrowPoints = [{
            x: xMin - side,
            y: tagHeight / 2 + yMin
          }, {
            x: xMin + 1,
            y: (tagHeight - side) / 2 + yMin - 1
          }, {
            x: xMin + 1,
            y: (tagHeight + side) / 2 + yMin + 1
          }];
          x = x + side;
          y = y - tagHeight / 2;
        } else if (direct === 'tr') {
          arrowPoints = [{
            x: xMin,
            y: tagHeight + side + yMin
          }, {
            x: xMin,
            y: tagHeight + yMin - 1
          }, {
            x: side + xMin + 1,
            y: tagHeight + yMin - 1
          }];
          radius[3] = 0;
          y = y - tagHeight - side;
        } else if (direct === 'tc') {
          arrowPoints = [{
            x: (tagWidth - side) / 2 + xMin - 1,
            y: tagHeight + yMin - 1
          }, {
            x: (tagWidth + side) / 2 + xMin + 1,
            y: tagHeight + yMin - 1
          }, {
            x: tagWidth / 2 + xMin,
            y: tagHeight + side + yMin
          }];
          x = x - tagWidth / 2;
          y = y - tagHeight - side;
        }

        var sideShape = tagContainer.addShape('Polygon', {
          className: 'guide-tag-side',
          zIndex: 0,
          attrs: {
            points: arrowPoints,
            fill: background.fill
          }
        });
        shapes.push(sideShape);
        tagBg.attr('radius', radius);
        tagContainer.moveTo(x - xMin, y - yMin);
        tagContainer.sort();
        this.element = wrapperContainer;
        return shapes;
      };

      return Tag;
    }(GuideBase);

    GuideBase.Tag = Tag;

    var Point = /*#__PURE__*/function (_GuideBase) {
      _inheritsLoose$3(Point, _GuideBase);

      function Point() {
        return _GuideBase.apply(this, arguments) || this;
      }

      var _proto = Point.prototype;

      _proto._initDefaultCfg = function _initDefaultCfg() {
        this.type = 'point';
        this.position = null;
        this.offsetX = 0;
        this.offsetY = 0;
        this.style = {
          fill: '#1890FF',
          r: 3,
          lineWidth: 1,
          stroke: '#fff'
        };
      };

      _proto.render = function render(coord, container) {
        var position = this.parsePoint(coord, this.position);
        if (!position) return null;
        var shape = container.addShape('Circle', {
          className: 'guide-point',
          attrs: mix$1({
            x: position.x + this.offsetX,
            y: position.y + this.offsetY
          }, this.style)
        });
        this.element = shape;
        return shape;
      };

      return Point;
    }(GuideBase);

    GuideBase.Point = Point;

    var MARKER_RADIUS = 3;

    var List = /*#__PURE__*/function () {
      var _proto = List.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          showTitle: false,

          /**
           * title string
           * @type {?String}
           */
          title: null,

          /**
           * items array
           * @type {?Array}
           */
          items: null,

          /**
           * offset between title and items
           * @type {Number}
           */
          titleGap: 12,

          /**
           * offset between each item
           * @type {Number}
           */
          itemGap: 10,

          /**
           * the offset between each item in vertical direaction
           * @type {Number}
           */
          itemMarginBottom: 12,

          /**
           * the formatter for item text
           * @type {[type]}
           */
          itemFormatter: null,
          itemWidth: null,

          /**
           * offset between marker and text
           * @type {Number}
           */
          wordSpace: 6,
          x: 0,
          y: 0,
          layout: 'horizontal',

          /**
           * the join string of `name` and `value`
           * @type {String}
           */
          joinString: ': '
        };
      };

      function List(cfg) {
        deepMix(this, this.getDefaultCfg(), cfg);

        this._init();

        this._renderTitle();

        this._renderItems();
      }

      _proto._init = function _init() {
        var parent = this.parent;
        if (!parent) return;
        var container = parent.addGroup({
          zIndex: this.zIndex || 0
        });
        this.container = container;
        var wrapper = container.addGroup();
        this.wrapper = wrapper;
        var itemsGroup = wrapper.addGroup({
          className: 'itemsGroup'
        });
        this.itemsGroup = itemsGroup;
      };

      _proto._renderTitle = function _renderTitle(title) {
        title = title || this.title;
        var titleShape = this.titleShape;
        var titleHeight = 0;

        if (this.showTitle && title) {
          if (titleShape && !titleShape.get('destroyed')) {
            titleShape.attr('text', title);
          } else {
            var wrapper = this.wrapper,
                titleStyle = this.titleStyle;
            titleShape = wrapper.addShape('text', {
              className: 'title',
              attrs: mix$1({
                x: 0,
                y: 0,
                text: title
              }, titleStyle)
            });
            this.titleShape = titleShape;
          }

          titleHeight = titleShape.getBBox().height + this.titleGap;
        }

        this._titleHeight = titleHeight;
      };

      _proto._renderItems = function _renderItems(items) {
        var self = this;
        items = items || self.items;

        if (!items) {
          return;
        }

        if (self.reversed) {
          items.reverse();
        }

        each$1(items, function (item, index) {
          self._addItem(item, index);
        });

        if (items.length > 1) {
          this._adjustItems();
        }

        this._renderBackground();
      };

      _proto._renderBackground = function _renderBackground() {
        var background = this.background;

        if (background) {
          var container = this.container;
          var wrapper = this.wrapper;

          var _wrapper$getBBox = wrapper.getBBox(),
              minX = _wrapper$getBBox.minX,
              minY = _wrapper$getBBox.minY,
              width = _wrapper$getBBox.width,
              height = _wrapper$getBBox.height;

          var padding = background.padding || [0, 0, 0, 0];
          padding = parsePadding(padding);
          var attrs = mix$1({
            x: minX - padding[3],
            y: minY - padding[0],
            width: width + padding[1] + padding[3],
            height: height + padding[0] + padding[2]
          }, background);
          var backShape = this.backShape;

          if (backShape) {
            backShape.attr(attrs);
          } else {
            backShape = container.addShape('Rect', {
              zIndex: -1,
              attrs: attrs
            });
          }

          this.backShape = backShape;
          container.sort();
        }
      };

      _proto._addItem = function _addItem(item) {
        var itemsGroup = this.itemsGroup;
        var itemGroup = itemsGroup.addGroup({
          name: item.name,
          value: item.value,
          dataValue: item.dataValue,
          checked: item.checked
        });
        var unCheckStyle = this.unCheckStyle,
            unCheckColor = this.unCheckColor,
            nameStyle = this.nameStyle,
            valueStyle = this.valueStyle,
            wordSpace = this.wordSpace;
        var marker = item.marker,
            value = item.value;
        var startX = 0;

        if (unCheckColor) {
          unCheckStyle.fill = unCheckColor;
        }

        if (marker) {
          var radius = marker.radius || MARKER_RADIUS;
          var markerAttrs = mix$1({
            x: radius,
            y: this._titleHeight
          }, marker);

          if (item.checked === false) {
            mix$1(markerAttrs, unCheckStyle);
          }

          var markerShape = itemGroup.addShape('marker', {
            className: 'item-marker',
            attrs: markerAttrs
          });
          startX += markerShape.getBBox().width + wordSpace;
        }

        var nameText;
        var name = item.name;

        if (name) {
          var joinString = this.joinString || '';
          name = value ? name + joinString : name;
          nameText = itemGroup.addShape('text', {
            className: 'name',
            attrs: mix$1({
              x: startX,
              y: this._titleHeight,
              text: this._formatItemValue(name)
            }, nameStyle, item.checked === false ? unCheckStyle : null)
          });
        }

        if (value) {
          var valueX = startX;

          if (nameText) {
            valueX += nameText.getBBox().width;
          }

          itemGroup.addShape('text', {
            className: 'value',
            attrs: mix$1({
              x: valueX,
              y: this._titleHeight,
              text: value
            }, valueStyle, item.checked === false ? unCheckStyle : null)
          });
        }

        return itemGroup;
      };

      _proto._formatItemValue = function _formatItemValue(value) {
        var formatter = this.itemFormatter;

        if (formatter) {
          value = formatter.call(this, value);
        }

        return value;
      };

      _proto._getMaxItemWidth = function _getMaxItemWidth() {
        var width;
        var itemWidth = this.itemWidth;

        if (isNumber(itemWidth) || isNil$1(itemWidth)) {
          return itemWidth;
        }

        if (itemWidth === 'auto') {
          var itemsGroup = this.itemsGroup;
          var children = itemsGroup.get('children');
          var count = children.length;
          var maxItemWidth = 0;

          for (var i = 0; i < count; i++) {
            var _children$i$getBBox = children[i].getBBox(),
                _width = _children$i$getBBox.width;

            maxItemWidth = Math.max(maxItemWidth, _width);
          }

          var maxLength = this.maxLength;
          var itemGap = this.itemGap;
          var twoAvgWidth = (maxLength - itemGap) / 2;
          var threeAvgWidth = (maxLength - itemGap * 2) / 3;

          if (count === 2) {
            width = Math.max(maxItemWidth, twoAvgWidth);
          } else {
            // 1. max <= 3Avg, 3Avg
            // 2. 3Avg < max && max < 2avg, 2avg
            // 3. max > 2avg, max, one column
            if (maxItemWidth <= threeAvgWidth) {
              width = threeAvgWidth;
            } else if (maxItemWidth <= twoAvgWidth) {
              width = twoAvgWidth;
            } else {
              width = maxItemWidth;
            }
          }

          return width;
        }
      };

      _proto._adjustHorizontal = function _adjustHorizontal() {
        var maxLength = this.maxLength,
            itemsGroup = this.itemsGroup;
        var children = itemsGroup.get('children');
        var itemGap = this.itemGap,
            itemMarginBottom = this.itemMarginBottom;
        var titleHeight = this._titleHeight;
        var row = 0;
        var rowWidth = 0;
        var width;
        var height;

        var itemWidth = this._getMaxItemWidth();

        var legendHitBoxes = [];

        for (var i = 0, len = children.length; i < len; i++) {
          var child = children[i];
          var box = child.getBBox();
          var childHeight = box.height;
          var childWidth = box.width;
          width = itemWidth || childWidth;
          height = childHeight + itemMarginBottom;

          if (width - (maxLength - rowWidth) > 0.0001) {
            row++;
            rowWidth = 0;
          }

          child.moveTo(rowWidth, row * height);
          legendHitBoxes.push({
            x: rowWidth,
            y: row * height + titleHeight - childHeight / 2,
            width: childWidth * 1.375,
            height: childHeight * 1.375
          });
          rowWidth += width + itemGap;
        }

        this.legendHitBoxes = legendHitBoxes;
        return;
      };

      _proto._adjustVertical = function _adjustVertical() {
        var maxLength = this.maxLength,
            itemsGroup = this.itemsGroup;
        var itemGap = this.itemGap,
            itemMarginBottom = this.itemMarginBottom,
            itemWidth = this.itemWidth;
        var titleHeight = this._titleHeight;
        var children = itemsGroup.get('children');
        var colHeight = 0;
        var width;
        var height;
        var maxItemWidth = 0;
        var totalWidth = 0;
        var legendHitBoxes = [];

        for (var i = 0, length = children.length; i < length; i++) {
          var child = children[i];
          var bbox = child.getBBox();
          width = bbox.width;
          height = bbox.height;

          if (isNumber(itemWidth)) {
            maxItemWidth = itemWidth + itemGap;
          } else if (width > maxItemWidth) {
            maxItemWidth = width + itemGap;
          }

          if (maxLength - colHeight < height) {
            colHeight = 0;
            totalWidth += maxItemWidth;
            child.moveTo(totalWidth, 0);
            legendHitBoxes.push({
              x: totalWidth,
              y: titleHeight - height / 2,
              width: width * 1.375,
              height: height * 1.375
            });
          } else {
            child.moveTo(totalWidth, colHeight);
            legendHitBoxes.push({
              x: totalWidth,
              y: colHeight - height / 2 + titleHeight,
              width: width * 1.375,
              height: height * 1.375
            });
          }

          colHeight += height + itemMarginBottom;
        }

        this.legendHitBoxes = legendHitBoxes;
        return;
      };

      _proto._adjustItems = function _adjustItems() {
        var layout = this.layout;

        if (layout === 'horizontal') {
          this._adjustHorizontal();
        } else {
          this._adjustVertical();
        }
      };

      _proto.moveTo = function moveTo(x, y) {
        this.x = x;
        this.y = y;
        var container = this.container;
        container && container.moveTo(x, y);
        return this;
      };

      _proto.setItems = function setItems(items) {
        this.clearItems();

        this._renderItems(items);
      };

      _proto.setTitle = function setTitle(title) {
        this._renderTitle(title);
      };

      _proto.clearItems = function clearItems() {
        var itemsGroup = this.itemsGroup;
        itemsGroup.clear();
      };

      _proto.getWidth = function getWidth() {
        var container = this.container;
        var bbox = container.getBBox();
        return bbox.width;
      };

      _proto.getHeight = function getHeight() {
        var container = this.container;
        var bbox = container.getBBox();
        return bbox.height;
      };

      _proto.show = function show() {
        var container = this.container;
        container.show();
      };

      _proto.hide = function hide() {
        var container = this.container;
        container.hide();
      };

      _proto.clear = function clear() {
        var container = this.container;
        container.clear();
        container.remove(true);
      };

      return List;
    }();

    var TextBox = /*#__PURE__*/function () {
      var _proto = TextBox.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          x: 0,
          y: 0,
          content: '',
          textStyle: {
            fontSize: 12,
            fill: '#fff',
            textAlign: 'center',
            textBaseline: 'middle',
            fontFamily: 'Arial'
          },
          background: {
            radius: 1,
            fill: 'rgba(0, 0, 0, 0.65)',
            padding: [3, 5]
          },
          width: 0,
          height: 0,
          className: ''
        };
      };

      function TextBox(cfg) {
        deepMix(this, this.getDefaultCfg(), cfg);

        this._init();

        var content = this.content,
            x = this.x,
            y = this.y;

        if (!isNil$1(content)) {
          this.updateContent(content);
        }

        this.updatePosition(x, y);
      }

      _proto._init = function _init() {
        var content = this.content,
            textStyle = this.textStyle,
            background = this.background,
            className = this.className,
            visible = this.visible,
            context = this.context;
        var container = new Group({
          context: context,
          className: className,
          zIndex: 0,
          visible: visible
        });
        var text = container.addShape('Text', {
          className: className + '-text',
          zIndex: 1,
          attrs: mix$1({
            text: content,
            x: 0,
            y: 0
          }, textStyle)
        });
        var backgroundShape = container.addShape('Rect', {
          className: className + '-bg',
          zIndex: -1,
          attrs: mix$1({
            x: 0,
            y: 0,
            width: 0,
            height: 0
          }, background)
        });
        container.sort();
        this.container = container;
        this.textShape = text;
        this.backgroundShape = backgroundShape;
      };

      _proto._getBBox = function _getBBox() {
        var textShape = this.textShape;
        var background = this.background;
        var textBBox = textShape.getBBox();
        var padding = parsePadding(background.padding);
        var width = textBBox.width + padding[1] + padding[3];
        var height = textBBox.height + padding[0] + padding[2];
        var x = textBBox.minX - padding[3];
        var y = textBBox.minY - padding[0];
        return {
          x: x,
          y: y,
          width: width,
          height: height
        };
      };

      _proto.updateContent = function updateContent(text) {
        var textShape = this.textShape,
            backgroundShape = this.backgroundShape;

        if (!isNil$1(text)) {
          if (!isObject$1(text)) {
            text = {
              text: text
            };
          }

          textShape.attr(text); // update box shape

          var _this$_getBBox = this._getBBox(),
              x = _this$_getBBox.x,
              y = _this$_getBBox.y,
              tipWidth = _this$_getBBox.width,
              tipHeight = _this$_getBBox.height;

          var width = this.width || tipWidth;
          var height = this.height || tipHeight;
          backgroundShape.attr({
            x: x,
            y: y,
            width: width,
            height: height
          });
          this._width = width;
          this._height = height;
          this.content = text.text;
        }
      };

      _proto.updatePosition = function updatePosition(x, y) {
        var container = this.container;

        var _this$_getBBox2 = this._getBBox(),
            xMin = _this$_getBBox2.x,
            yMin = _this$_getBBox2.y;

        container.moveTo(x - xMin, y - yMin);
        this.x = x - xMin;
        this.y = y - yMin;
      };

      _proto.getWidth = function getWidth() {
        return this._width;
      };

      _proto.getHeight = function getHeight() {
        return this._height;
      };

      _proto.show = function show() {
        this.container.show();
      };

      _proto.hide = function hide() {
        this.container.hide();
      };

      _proto.clear = function clear() {
        var container = this.container;
        container.clear();
        container.remove(true);
        this.container = null;
        this.textShape = null;
        this.backgroundShape = null;
      };

      return TextBox;
    }();

    var GAP = 4;
    /**
     * TODOList:
     * 1. 移除 fixed 参数
     */

    var Tooltip$1 = /*#__PURE__*/function () {
      var _proto = Tooltip.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          /**
           * wether show the crosshairs
           * @type {Object}
           */
          showCrosshairs: false,

          /**
           * the style for crosshairs
           * @type {Object}
           */
          crosshairsStyle: {
            stroke: 'rgba(0, 0, 0, 0.25)',
            lineWidth: 1
          },

          /**
           * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
           */
          crosshairsType: 'y',

          /**
           * show or hide the x axis tip
           */
          showXTip: false,

          /**
           * show or hide the y axis tip
           */
          showYTip: false,
          xTip: null,
          xTipBackground: {
            radius: 1,
            fill: 'rgba(0, 0, 0, 0.65)',
            padding: [3, 5]
          },
          xTipTextStyle: {
            fontSize: 12,
            fill: '#fff',
            textAlign: 'center',
            textBaseline: 'middle'
          },
          yTip: null,
          yTipBackground: {
            radius: 1,
            fill: 'rgba(0, 0, 0, 0.65)',
            padding: [3, 5]
          },
          yTipTextStyle: {
            fontSize: 12,
            fill: '#fff',
            textAlign: 'center',
            textBaseline: 'middle'
          },

          /**
           * the style for tooltip container's background
           * @type {Object}
           */
          background: null,

          /**
           * layout, can be horizontal or vertical
           * @type {String}
           */
          layout: 'horizontal',
          offsetX: 0,
          offsetY: 0
        };
      };

      function Tooltip(cfg) {
        deepMix(this, this.getDefaultCfg(), cfg);
        var frontPlot = this.frontPlot,
            custom = this.custom;

        if (!custom) {
          // custom means user do customize
          var container = new List(mix$1({
            parent: frontPlot,
            zIndex: 3
          }, cfg));
          this.container = container;
          var fixed = this.fixed,
              background = this.background;

          if (!fixed) {
            this.tooltipArrow = frontPlot.addShape('Polygon', {
              className: 'tooltip-arrow',
              visible: false,
              zIndex: 2,
              attrs: mix$1({
                points: []
              }, background)
            });
          }
        }

        if (this.showXTip) {
          var xTipBackground = this.xTipBackground,
              xTipTextStyle = this.xTipTextStyle;
          var xTipBox = new TextBox({
            context: frontPlot.get('context'),
            className: 'xTip',
            background: xTipBackground,
            textStyle: xTipTextStyle,
            visible: false
          });
          frontPlot.add(xTipBox.container);
          this.xTipBox = xTipBox;
        }

        if (this.showYTip) {
          var yTipBackground = this.yTipBackground,
              yTipTextStyle = this.yTipTextStyle;
          var yTipBox = new TextBox({
            context: frontPlot.get('context'),
            className: 'yTip',
            background: yTipBackground,
            textStyle: yTipTextStyle,
            visible: false
          });
          frontPlot.add(yTipBox.container);
          this.yTipBox = yTipBox;
        }

        if (this.showCrosshairs) {
          this._renderCrosshairs();
        }

        frontPlot.sort();
      }

      _proto.setContent = function setContent(title, items) {
        this.title = title;
        this.items = items;

        if (!this.custom) {
          var container = this.container;
          container.setTitle(title);
          container.setItems(items);
        }
      };

      _proto.setYTipContent = function setYTipContent(val) {
        var yTip = this.yTip;

        if (isFunction$1(yTip)) {
          val = yTip(val);
        } else {
          val = mix$1({
            text: val
          }, yTip);
        }

        this.yTipBox && this.yTipBox.updateContent(val);
      };

      _proto.setYTipPosition = function setYTipPosition(pos) {
        var plotRange = this.plotRange;
        var crosshairsShapeX = this.crosshairsShapeX;

        if (this.showYTip) {
          var yTipBox = this.yTipBox;
          var yTipHeight = yTipBox.getHeight();
          var yTipWidth = yTipBox.getWidth();
          var posX = plotRange.tl.x - yTipWidth;
          var posY = pos - yTipHeight / 2;

          if (posY <= plotRange.tl.y) {
            posY = plotRange.tl.y;
          }

          if (posY + yTipHeight >= plotRange.br.y) {
            posY = plotRange.br.y - yTipHeight;
          }

          if (posX < 0) {
            posX = plotRange.tl.x;
            crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
          }

          yTipBox.updatePosition(posX, posY);
        }
      };

      _proto.setXTipContent = function setXTipContent(val) {
        var xTip = this.xTip;

        if (isFunction$1(xTip)) {
          val = xTip(val);
        } else {
          val = mix$1({
            text: val
          }, xTip);
        }

        this.xTipBox && this.xTipBox.updateContent(val);
      };

      _proto.setXTipPosition = function setXTipPosition(pos) {
        var showXTip = this.showXTip,
            canvas = this.canvas,
            plotRange = this.plotRange,
            xTipBox = this.xTipBox,
            crosshairsShapeY = this.crosshairsShapeY;

        if (showXTip) {
          // const el = canvas.get('el');
          // const canvasHeight = Util.getHeight(el);
          var canvasHeight = canvas.get('height');
          var xTipWidth = xTipBox.getWidth();
          var xTipHeight = xTipBox.getHeight();
          var posX = pos - xTipWidth / 2;
          var posY = plotRange.br.y;

          if (posX <= plotRange.tl.x) {
            posX = plotRange.tl.x;
          }

          if (posX + xTipWidth >= plotRange.tr.x) {
            posX = plotRange.tr.x - xTipWidth;
          }

          if (canvasHeight - posY < xTipHeight) {
            posY -= xTipHeight;
          }

          xTipBox.updatePosition(posX, posY);
          crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
        }
      };

      _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
        this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
      };

      _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
        this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
      };

      _proto.setPosition = function setPosition(items) {
        var container = this.container,
            plotRange = this.plotRange,
            offsetX = this.offsetX,
            offsetY = this.offsetY,
            fixed = this.fixed,
            tooltipArrow = this.tooltipArrow;

        if (!container) {
          return;
        }

        var containerBBox = container.container.getBBox();
        var minX = containerBBox.minX,
            minY = containerBBox.minY,
            width = containerBBox.width,
            height = containerBBox.height;
        var tl = plotRange.tl,
            tr = plotRange.tr;
        var posX = 0;
        var posY = tl.y - height - GAP + offsetY;

        if (posY < 0) {
          posY = 0;
        }

        if (fixed) {
          var x = (tl.x + tr.x) / 2;
          posX = x - width / 2 + offsetX;
        } else {
          var _x;

          if (items.length > 1) {
            _x = (items[0].x + items[items.length - 1].x) / 2;
          } else {
            _x = items[0].x;
          }

          posX = _x - width / 2 + offsetX;

          if (posX < tl.x) {
            posX = tl.x;
          }

          if (posX + width > tr.x) {
            posX = tr.x - width;
          }

          if (tooltipArrow) {
            var arrowY = posY + height;
            tooltipArrow.attr('points', [{
              x: _x - 3,
              y: arrowY
            }, {
              x: _x + 3,
              y: arrowY
            }, {
              x: _x,
              y: arrowY + GAP
            }]);
            var backShape = container.backShape;
            var radius = parsePadding(backShape.attr('radius'));

            if (_x === tl.x) {
              radius[3] = 0;
              tooltipArrow.attr('points', [{
                x: tl.x,
                y: arrowY
              }, {
                x: tl.x + GAP,
                y: arrowY
              }, {
                x: tl.x,
                y: arrowY + GAP
              }]);
            } else if (_x === tr.x) {
              radius[2] = 0;
              tooltipArrow.attr('points', [{
                x: tr.x - GAP,
                y: arrowY
              }, {
                x: tr.x,
                y: arrowY
              }, {
                x: tr.x,
                y: arrowY + GAP
              }]);
            }

            backShape.attr('radius', radius);
          }
        }

        container.moveTo(posX - minX, posY - minY);
      };

      _proto.setMarkers = function setMarkers(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        var self = this;
        var _cfg = cfg,
            items = _cfg.items,
            style = _cfg.style,
            type = _cfg.type;

        var markerGroup = self._getMarkerGroup(type);

        if (type === 'circle') {
          for (var i = 0, length = items.length; i < length; i++) {
            var item = items[i];
            markerGroup.addShape('marker', {
              className: 'tooltip-circle-marker',
              attrs: mix$1({
                x: item.x,
                y: item.y,
                stroke: item.color
              }, style)
            });
          }
        } else {
          markerGroup.addShape('rect', {
            className: 'tooltip-rect-marker',
            attrs: style
          });
        }
      };

      _proto.clearMarkers = function clearMarkers() {
        var markerGroup = this.markerGroup;
        markerGroup && markerGroup.clear();
      };

      _proto.show = function show() {
        var crosshairsShapeX = this.crosshairsShapeX;
        var crosshairsShapeY = this.crosshairsShapeY;
        var markerGroup = this.markerGroup;
        var container = this.container;
        var tooltipArrow = this.tooltipArrow;
        var xTipBox = this.xTipBox;
        var yTipBox = this.yTipBox;
        var canvas = this.canvas;
        crosshairsShapeX && crosshairsShapeX.show();
        crosshairsShapeY && crosshairsShapeY.show();
        markerGroup && markerGroup.show();
        container && container.show();
        tooltipArrow && tooltipArrow.show();
        xTipBox && xTipBox.show();
        yTipBox && yTipBox.show();
        canvas.draw();
      };

      _proto.hide = function hide() {
        var crosshairsShapeX = this.crosshairsShapeX;
        var crosshairsShapeY = this.crosshairsShapeY;
        var markerGroup = this.markerGroup;
        var container = this.container;
        var tooltipArrow = this.tooltipArrow;
        var xTipBox = this.xTipBox;
        var yTipBox = this.yTipBox;
        crosshairsShapeX && crosshairsShapeX.hide();
        crosshairsShapeY && crosshairsShapeY.hide();
        markerGroup && markerGroup.hide();
        container && container.hide();
        tooltipArrow && tooltipArrow.hide();
        xTipBox && xTipBox.hide();
        yTipBox && yTipBox.hide();
      };

      _proto.destroy = function destroy() {
        var crosshairsShapeX = this.crosshairsShapeX;
        var crosshairsShapeY = this.crosshairsShapeY;
        var markerGroup = this.markerGroup;
        var container = this.container;
        var tooltipArrow = this.tooltipArrow;
        var xTipBox = this.xTipBox;
        var yTipBox = this.yTipBox;
        crosshairsShapeX && crosshairsShapeX.remove(true);
        crosshairsShapeY && crosshairsShapeY.remove(true);
        markerGroup && markerGroup.remove(true);
        tooltipArrow && tooltipArrow.remove(true);
        container && container.clear();
        xTipBox && xTipBox.clear();
        yTipBox && yTipBox.clear();
        this.destroyed = true;
      };

      _proto._getMarkerGroup = function _getMarkerGroup(type) {
        var markerGroup = this.markerGroup;

        if (!markerGroup) {
          if (type === 'circle') {
            markerGroup = this.frontPlot.addGroup({
              zIndex: 1
            });
            this.frontPlot.sort();
          } else {
            markerGroup = this.backPlot.addGroup();
          }

          this.markerGroup = markerGroup;
        } else {
          markerGroup.clear();
        }

        return markerGroup;
      };

      _proto._renderCrosshairs = function _renderCrosshairs() {
        var crosshairsType = this.crosshairsType,
            crosshairsStyle = this.crosshairsStyle,
            frontPlot = this.frontPlot,
            plotRange = this.plotRange;
        var tl = plotRange.tl,
            br = plotRange.br;

        if (directionEnabled(crosshairsType, 'x')) {
          this.crosshairsShapeX = frontPlot.addShape('Line', {
            className: 'tooltip-crosshairs-x',
            zIndex: 0,
            visible: false,
            attrs: mix$1({
              x1: tl.x,
              y1: 0,
              x2: br.x,
              y2: 0
            }, crosshairsStyle)
          });
        }

        if (directionEnabled(crosshairsType, 'y')) {
          this.crosshairsShapeY = frontPlot.addShape('Line', {
            className: 'tooltip-crosshairs-y',
            zIndex: 0,
            visible: false,
            attrs: mix$1({
              x1: 0,
              y1: br.y,
              x2: 0,
              y2: tl.y
            }, crosshairsStyle)
          });
        }
      };

      return Tooltip;
    }();

    Global.tooltip = deepMix({
      triggerOn: 'press',
      triggerOff: 'pressend',
      alwaysShow: false,
      showTitle: false,
      showCrosshairs: false,
      crosshairsStyle: {
        stroke: 'rgba(0, 0, 0, 0.25)',
        lineWidth: 1
      },
      showTooltipMarker: true,
      background: {
        radius: 1,
        fill: 'rgba(0, 0, 0, 0.65)',
        padding: [3, 5]
      },
      titleStyle: {
        fontSize: 12,
        fill: '#fff',
        textAlign: 'start',
        textBaseline: 'top'
      },
      nameStyle: {
        fontSize: 12,
        fill: 'rgba(255, 255, 255, 0.65)',
        textAlign: 'start',
        textBaseline: 'middle'
      },
      valueStyle: {
        fontSize: 12,
        fill: '#fff',
        textAlign: 'start',
        textBaseline: 'middle'
      },
      showItemMarker: true,
      itemMarkerStyle: {
        radius: 3,
        symbol: 'circle',
        lineWidth: 1,
        stroke: '#fff'
      },
      layout: 'horizontal',
      snap: false
    }, Global.tooltip || {});

    function _getTooltipValueScale(geom) {
      var colorAttr = geom.getAttr('color');

      if (colorAttr) {
        var colorScale = colorAttr.getScale(colorAttr.type);

        if (colorScale.isLinear) {
          return colorScale;
        }
      }

      var xScale = geom.getXScale();
      var yScale = geom.getYScale();

      if (yScale) {
        return yScale;
      }

      return xScale;
    }

    function getTooltipName(geom, origin) {
      var name;
      var nameScale;

      var groupScales = geom._getGroupScales();

      if (groupScales.length) {
        each$1(groupScales, function (scale) {
          nameScale = scale;
          return false;
        });
      }

      if (nameScale) {
        var field = nameScale.field;
        name = nameScale.getText(origin[field]);
      } else {
        var valueScale = _getTooltipValueScale(geom);

        name = valueScale.alias || valueScale.field;
      }

      return name;
    }

    function getTooltipValue(geom, origin) {
      var scale = _getTooltipValueScale(geom);

      return scale.getText(origin[scale.field]);
    }

    function getTooltipTitle(geom, origin) {
      var position = geom.getAttr('position');
      var field = position.getFields()[0];
      var scale = geom.get('scales')[field];
      return scale.getText(origin[scale.field]);
    }

    function _indexOfArray(items, item) {
      var rst = -1;
      each$1(items, function (sub, index) {
        if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
          rst = index;
          return false;
        }
      });
      return rst;
    }

    function _uniqItems(items) {
      var tmp = [];
      each$1(items, function (item) {
        var index = _indexOfArray(tmp, item);

        if (index === -1) {
          tmp.push(item);
        } else {
          tmp[index] = item;
        }
      });
      return tmp;
    }

    function isEqual(arr1, arr2) {
      return JSON.stringify(arr1) === JSON.stringify(arr2);
    }

    var TooltipController = /*#__PURE__*/function () {
      function TooltipController(cfg) {
        var _this = this;

        _defineProperty(this, "handleShowEvent", function (ev) {
          var chart = _this.chart;
          if (!_this.enable) return;
          var plot = chart.get('plotRange');
          var point = createEvent(ev, chart);

          if (!isPointInPlot(point, plot) && !_this._tooltipCfg.alwaysShow) {
            // not in chart plot
            _this.hideTooltip();

            return;
          }

          var lastTimeStamp = _this.timeStamp;
          var timeStamp = +new Date();

          if (timeStamp - lastTimeStamp > 16) {
            _this.showTooltip(point);

            _this.timeStamp = timeStamp;
          }
        });

        _defineProperty(this, "handleHideEvent", function () {
          if (!_this.enable) return;

          _this.hideTooltip();
        });

        this.enable = true;
        this.cfg = {};
        this.tooltip = null;
        this.chart = null;
        this.timeStamp = 0;
        mix$1(this, cfg);
        var _chart = this.chart;

        var canvas = _chart.get('canvas');

        this.canvas = canvas;
        this.canvasDom = canvas.get('el');
      }

      var _proto = TooltipController.prototype;

      _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
        var self = this;
        var chart = self.chart;
        var defaultCfg = mix$1({}, Global.tooltip);
        var geoms = chart.get('geoms');
        var shapes = [];
        each$1(geoms, function (geom) {
          var type = geom.get('type');

          if (shapes.indexOf(type) === -1) {
            shapes.push(type);
          }
        });
        var coordType = chart.get('coord').type;

        if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
          if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
            mix$1(defaultCfg, {
              showCrosshairs: true
            });
          }
        }

        return defaultCfg;
      };

      _proto._getMaxLength = function _getMaxLength(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        var _cfg = cfg,
            layout = _cfg.layout,
            plotRange = _cfg.plotRange;
        return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
      };

      _proto.render = function render() {
        var self = this;

        if (self.tooltip) {
          return;
        }

        var chart = self.chart;
        var canvas = chart.get('canvas');
        var frontPlot = chart.get('frontPlot').addGroup({
          className: 'tooltipContainer',
          zIndex: 10
        });
        var backPlot = chart.get('backPlot').addGroup({
          className: 'tooltipContainer'
        });
        var plotRange = chart.get('plotRange');
        var coord = chart.get('coord');

        var defaultCfg = self._setCrosshairsCfg();

        var cfg = self.cfg; // 通过 chart.tooltip() 接口传入的 tooltip 配置项

        var tooltipCfg = deepMix({
          plotRange: plotRange,
          frontPlot: frontPlot,
          backPlot: backPlot,
          canvas: canvas,
          fixed: coord.transposed || coord.isPolar
        }, defaultCfg, cfg); // 创建 tooltip 实例需要的配置,不应该修改 this.cfg,即用户传入的配置

        tooltipCfg.maxLength = self._getMaxLength(tooltipCfg);
        this._tooltipCfg = tooltipCfg;
        var tooltip = new Tooltip$1(tooltipCfg);
        self.tooltip = tooltip; // 需要保持tooltip一直显示

        if (tooltipCfg.alwaysShow && self.prePoint) {
          this.showTooltip(self.prePoint);
        }

        self.bindEvents();
      };

      _proto.clear = function clear() {
        var tooltip = this.tooltip;

        if (tooltip) {
          tooltip.destroy();
          this.unBindEvents();
        }

        this.tooltip = null;
        this._lastActive = null;
      };

      _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        var _cfg2 = cfg,
            type = _cfg2.type,
            items = _cfg2.items;
        var tooltipCfg = this._tooltipCfg;

        if (type === 'rect') {
          var x;
          var y;
          var width;
          var height;
          var chart = this.chart;

          var _chart$get = chart.get('plotRange'),
              tl = _chart$get.tl,
              br = _chart$get.br;

          var coord = chart.get('coord');
          var firstItem = items[0];
          var lastItem = items[items.length - 1];
          var intervalWidth = firstItem.width;

          if (coord.transposed) {
            x = tl.x;
            y = lastItem.y - intervalWidth * 0.75;
            width = br.x - tl.x;
            height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
          } else {
            x = firstItem.x - intervalWidth * 0.75;
            y = tl.y;
            width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
            height = br.y - tl.y;
          }

          cfg.style = mix$1({
            x: x,
            y: y,
            width: width,
            height: height,
            fill: '#CCD6EC',
            opacity: 0.3
          }, tooltipCfg.tooltipMarkerStyle);
        } else {
          cfg.style = mix$1({
            radius: 4,
            fill: '#fff',
            lineWidth: 2
          }, tooltipCfg.tooltipMarkerStyle);
        }

        return cfg;
      };

      _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
        if (tooltipMarkerCfg === void 0) {
          tooltipMarkerCfg = {};
        }

        this.prePoint = point;
        var lastActive = this._lastActive;
        var tooltip = this.tooltip;
        var cfg = this._tooltipCfg;
        items = _uniqItems(items);
        var chart = this.chart;
        var coord = chart.get('coord');
        var yScale = chart.getYScales()[0];
        var snap = cfg.snap;

        if (snap === false && yScale.isLinear) {
          var invertPoint = coord.invertPoint(point);
          var plot = chart.get('plotRange');
          var tip;
          var pos;

          if (isPointInPlot(point, plot)) {
            if (coord.transposed) {
              tip = yScale.invert(invertPoint.x);
              pos = point.x;
              tooltip.setXTipContent(tip);
              tooltip.setXTipPosition(pos);
              tooltip.setYCrosshairPosition(pos);
            } else {
              tip = yScale.invert(invertPoint.y);
              pos = point.y;
              tooltip.setYTipContent(tip);
              tooltip.setYTipPosition(pos);
              tooltip.setXCrosshairPosition(pos);
            }
          }
        }

        if (cfg.onShow) {
          cfg.onShow({
            x: point.x,
            y: point.y,
            tooltip: tooltip,
            items: items,
            tooltipMarkerCfg: tooltipMarkerCfg
          });
        }

        if (isEqual(lastActive, items)) {
          if (snap === false && (directionEnabled(cfg.crosshairsType, 'y') || cfg.showYTip)) {
            var canvas = this.chart.get('canvas');
            canvas.draw();
          }

          return;
        }

        this._lastActive = items;
        var onChange = cfg.onChange;

        if (onChange) {
          onChange({
            x: point.x,
            y: point.y,
            tooltip: tooltip,
            items: items,
            tooltipMarkerCfg: tooltipMarkerCfg
          });
        }

        var first = items[0];
        var title = first.title || first.name;
        var xTipPosX = first.x;

        if (items.length > 1) {
          xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
        }

        tooltip.setContent(title, items, coord.transposed);
        tooltip.setPosition(items, point);

        if (coord.transposed) {
          var yTipPosY = first.y;

          if (items.length > 1) {
            yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
          }

          tooltip.setYTipContent(title);
          tooltip.setYTipPosition(yTipPosY);
          tooltip.setXCrosshairPosition(yTipPosY);

          if (snap) {
            tooltip.setXTipContent(first.value);
            tooltip.setXTipPosition(xTipPosX);
            tooltip.setYCrosshairPosition(xTipPosX);
          }
        } else {
          tooltip.setXTipContent(title);
          tooltip.setXTipPosition(xTipPosX);
          tooltip.setYCrosshairPosition(xTipPosX);

          if (snap) {
            tooltip.setYTipContent(first.value);
            tooltip.setYTipPosition(first.y);
            tooltip.setXCrosshairPosition(first.y);
          }
        }

        var markerItems = tooltipMarkerCfg.items;

        if (cfg.showTooltipMarker && markerItems.length) {
          tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
          tooltip.setMarkers(tooltipMarkerCfg);
        } else {
          tooltip.clearMarkers();
        }

        tooltip.show();
      };

      _proto.showTooltip = function showTooltip(point) {
        var self = this;
        var chart = self.chart;
        var tooltipMarkerType;
        var tooltipMarkerItems = [];
        var items = [];
        var cfg = self._tooltipCfg;
        var showItemMarker = cfg.showItemMarker,
            itemMarkerStyle = cfg.itemMarkerStyle,
            alwaysShow = cfg.alwaysShow;
        var marker;

        if (showItemMarker) {
          marker = itemMarkerStyle;
        }

        var geoms = chart.get('geoms');
        var coord = chart.get('coord');
        each$1(geoms, function (geom) {
          if (geom.get('visible')) {
            var type = geom.get('type');
            var records = geom.getSnapRecords(point);
            var adjust = geom.get('adjust'); // 漏斗图和金子塔图tooltip位置有问题,暂时不开放显示

            if (type === 'interval' && adjust && adjust.type === 'symmetric') {
              return;
            }

            each$1(records, function (record) {
              var x = record.x,
                  y = record.y,
                  _origin = record._origin,
                  color = record.color;

              if ((x || !isNaN(x)) && (y || !isNaN(y))) {
                var tooltipItem = {
                  x: x,
                  y: isArray$1(y) ? y[1] : y,
                  color: color || Global.defaultColor,
                  origin: _origin,
                  name: getTooltipName(geom, _origin),
                  value: getTooltipValue(geom, _origin),
                  title: getTooltipTitle(geom, _origin)
                };

                if (marker) {
                  tooltipItem.marker = mix$1({
                    fill: color || Global.defaultColor
                  }, marker);
                }

                items.push(tooltipItem);

                if (['line', 'area', 'path'].indexOf(type) !== -1) {
                  tooltipMarkerType = 'circle';
                  tooltipMarkerItems.push(tooltipItem);
                } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
                  tooltipMarkerType = 'rect';
                  tooltipItem.width = geom.getSize(record._origin);
                  tooltipMarkerItems.push(tooltipItem);
                }
              }
            });
          }
        });

        if (items.length) {
          var tooltipMarkerCfg = {
            items: tooltipMarkerItems,
            type: tooltipMarkerType
          };

          self._setTooltip(point, items, tooltipMarkerCfg);

          return;
        }

        if (!alwaysShow) {
          self.hideTooltip();
        }
      };

      _proto.hideTooltip = function hideTooltip() {
        var cfg = this._tooltipCfg;
        this._lastActive = null;
        var tooltip = this.tooltip;

        if (tooltip) {
          tooltip.hide();

          if (cfg.onHide) {
            cfg.onHide({
              tooltip: tooltip
            });
          }

          var canvas = this.chart.get('canvas');
          canvas.draw();
        }
      };

      _proto._handleEvent = function _handleEvent(methodName, method, action) {
        var canvas = this.canvas;
        each$1([].concat(methodName), function (aMethod) {
          if (action === 'bind') {
            canvas.on(aMethod, method);
          } else {
            canvas.off(aMethod, method);
          }
        });
      };

      _proto.bindEvents = function bindEvents() {
        var cfg = this._tooltipCfg;
        var triggerOn = cfg.triggerOn,
            triggerOff = cfg.triggerOff,
            alwaysShow = cfg.alwaysShow;
        triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'bind'); // 如果 !alwaysShow, 则在手势离开后就隐藏

        if (!alwaysShow) {
          this._handleEvent(triggerOff, this.handleHideEvent, 'bind');
        }
      };

      _proto.unBindEvents = function unBindEvents() {
        var cfg = this._tooltipCfg;
        var triggerOn = cfg.triggerOn,
            triggerOff = cfg.triggerOff,
            alwaysShow = cfg.alwaysShow;
        triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'unBind');

        if (!alwaysShow) {
          this._handleEvent(triggerOff, this.handleHideEvent, 'unBind');
        }
      };

      return TooltipController;
    }();

    function init$2(chart) {
      var tooltipController = new TooltipController({
        chart: chart
      });
      chart.set('tooltipController', tooltipController);

      chart.tooltip = function (enable, cfg) {
        if (isObject$1(enable)) {
          cfg = enable;
          enable = true;
        }

        tooltipController.enable = enable;

        if (cfg) {
          tooltipController.cfg = cfg;
        }

        return this;
      };
    }

    function afterGeomDraw$2(chart) {
      var tooltipController = chart.get('tooltipController');
      tooltipController.render();

      chart.showTooltip = function (point) {
        tooltipController.showTooltip(point);
        return this;
      };

      chart.hideTooltip = function () {
        tooltipController.hideTooltip();
        return this;
      };
    }

    function clearInner$1(chart) {
      var tooltipController = chart.get('tooltipController');
      tooltipController.clear();
    }
    var tooltip = {
      init: init$2,
      afterGeomDraw: afterGeomDraw$2,
      clearInner: clearInner$1
    };

    var Tooltip = /*#__PURE__*/Object.freeze({
        __proto__: null,
        init: init$2,
        afterGeomDraw: afterGeomDraw$2,
        clearInner: clearInner$1,
        'default': tooltip
    });

    Global.guide = deepMix({
      line: {
        style: {
          stroke: '#a3a3a3',
          lineWidth: 1
        },
        top: true
      },
      text: {
        style: {
          fill: '#787878',
          textAlign: 'center',
          textBaseline: 'middle'
        },
        offsetX: 0,
        offsetY: 0,
        top: true
      },
      rect: {
        style: {
          fill: '#fafafa'
        },
        top: false
      },
      arc: {
        style: {
          stroke: '#a3a3a3'
        },
        top: true
      },
      html: {
        offsetX: 0,
        offsetY: 0,
        alignX: 'center',
        alignY: 'middle'
      },
      tag: {
        top: true,
        offsetX: 0,
        offsetY: 0,
        side: 4,
        background: {
          padding: 5,
          radius: 2,
          fill: '#1890FF'
        },
        textStyle: {
          fontSize: 12,
          fill: '#fff',
          textAlign: 'center',
          textBaseline: 'middle'
        }
      },
      point: {
        top: true,
        offsetX: 0,
        offsetY: 0,
        style: {
          fill: '#fff',
          r: 3,
          lineWidth: 2,
          stroke: '#1890ff'
        }
      }
    }, Global.guide || {});

    var GuideController = /*#__PURE__*/function () {
      function GuideController(cfg) {
        this.guides = [];
        this.xScale = null;
        this.yScales = null;
        this.guideShapes = [];
        mix$1(this, cfg);
      }

      var _proto = GuideController.prototype;

      _proto._toString = function _toString(position) {
        if (isFunction$1(position)) {
          position = position(this.xScale, this.yScales);
        }

        position = position.toString();
        return position;
      };

      _proto._getId = function _getId(shape, guide) {
        var id = guide.id;

        if (!id) {
          var type = guide.type;

          if (type === 'arc' || type === 'line' || type === 'rect') {
            id = this._toString(guide.start) + '-' + this._toString(guide.end);
          } else {
            id = this._toString(guide.position);
          }
        }

        return id;
      };

      _proto.paint = function paint(coord) {
        var self = this;
        var chart = self.chart,
            guides = self.guides,
            xScale = self.xScale,
            yScales = self.yScales;
        var guideShapes = [];
        each$1(guides, function (guide, idx) {
          guide.xScale = xScale;
          guide.yScales = yScales;
          var container;

          if (guide.type === 'regionFilter') {
            // TODO: RegionFilter support animation
            guide.chart = chart;
          } else {
            container = guide.top ? self.frontPlot : self.backPlot;
          }

          guide.coord = coord;
          guide.container = container;
          guide.canvas = chart.get('canvas');
          var shape = guide.render(coord, container);

          if (shape) {
            var id = self._getId(shape, guide);

            [].concat(shape).forEach(function (s) {
              s._id = s.get('className') + '-' + id;
              s.set('index', idx);
              guideShapes.push(s);
            });
          }
        });
        self.guideShapes = guideShapes;
      };

      _proto.clear = function clear() {
        this.reset();
        this.guides = [];
        return this;
      };

      _proto.reset = function reset() {
        var guides = this.guides;
        each$1(guides, function (guide) {
          guide.remove();
        });
      };

      _proto._createGuide = function _createGuide(type, cfg) {
        var ClassName = upperFirst(type);
        var guide = new GuideBase[ClassName](deepMix({}, Global.guide[type], cfg));
        this.guides.push(guide);
        return guide;
      };

      _proto.line = function line(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('line', cfg);
      };

      _proto.text = function text(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('text', cfg);
      };

      _proto.arc = function arc(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('arc', cfg);
      };

      _proto.html = function html(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('html', cfg);
      };

      _proto.rect = function rect(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('rect', cfg);
      };

      _proto.tag = function tag(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('tag', cfg);
      };

      _proto.point = function point(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('point', cfg);
      };

      _proto.regionFilter = function regionFilter(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        return this._createGuide('regionFilter', cfg);
      };

      return GuideController;
    }();

    function init$1(chart) {
      var guideController = new GuideController({
        frontPlot: chart.get('frontPlot').addGroup({
          zIndex: 20,
          className: 'guideContainer'
        }),
        backPlot: chart.get('backPlot').addGroup({
          className: 'guideContainer'
        })
      });
      chart.set('guideController', guideController);
      /**
       * 为图表添加 guide
       * @return {GuideController} 返回 guide 控制器
       */

      chart.guide = function () {
        return guideController;
      };
    }

    function afterGeomDraw$1(chart) {
      var guideController = chart.get('guideController');

      if (!guideController.guides.length) {
        return;
      }

      var xScale = chart.getXScale();
      var yScales = chart.getYScales();
      var coord = chart.get('coord');
      guideController.xScale = xScale;
      guideController.yScales = yScales;
      guideController.chart = chart; // for regionFilter

      guideController.paint(coord);
    }

    function clear(chart) {
      chart.get('guideController').clear();
    }

    function repaint(chart) {
      chart.get('guideController').reset();
    }
    var guide = {
      init: init$1,
      afterGeomDraw: afterGeomDraw$1,
      clear: clear,
      repaint: repaint
    };

    var Guide = /*#__PURE__*/Object.freeze({
        __proto__: null,
        init: init$1,
        afterGeomDraw: afterGeomDraw$1,
        clear: clear,
        repaint: repaint,
        'default': guide
    });

    var LEGEND_GAP = 12;
    var MARKER_SIZE = 3;
    var DEFAULT_CFG = {
      itemMarginBottom: 12,
      itemGap: 10,
      showTitle: false,
      titleStyle: {
        fontSize: 12,
        fill: '#808080',
        textAlign: 'start',
        textBaseline: 'top'
      },
      nameStyle: {
        fill: '#808080',
        fontSize: 12,
        textAlign: 'start',
        textBaseline: 'middle'
      },
      valueStyle: {
        fill: '#000000',
        fontSize: 12,
        textAlign: 'start',
        textBaseline: 'middle'
      },
      unCheckStyle: {
        fill: '#bfbfbf'
      },
      itemWidth: 'auto',
      wordSpace: 6,
      selectedMode: 'multiple' // 'multiple' or 'single'

    }; // Register the default configuration for Legend

    Global.legend = deepMix({
      common: DEFAULT_CFG,
      // common legend configuration
      right: mix$1({
        position: 'right',
        layout: 'vertical'
      }, DEFAULT_CFG),
      left: mix$1({
        position: 'left',
        layout: 'vertical'
      }, DEFAULT_CFG),
      top: mix$1({
        position: 'top',
        layout: 'horizontal'
      }, DEFAULT_CFG),
      bottom: mix$1({
        position: 'bottom',
        layout: 'horizontal'
      }, DEFAULT_CFG)
    }, Global.legend || {});

    function getPaddingByPos(pos, appendPadding) {
      var padding = 0;
      appendPadding = parsePadding(appendPadding);

      switch (pos) {
        case 'top':
          padding = appendPadding[0];
          break;

        case 'right':
          padding = appendPadding[1];
          break;

        case 'bottom':
          padding = appendPadding[2];
          break;

        case 'left':
          padding = appendPadding[3];
          break;
      }

      return padding;
    }

    var LegendController = /*#__PURE__*/function () {
      function LegendController(cfg) {
        var _this = this;

        _defineProperty(this, "handleEvent", function (ev) {
          var self = _this;

          function findItem(x, y) {
            var result = null;
            var legends = self.legends;
            each$1(legends, function (legendItems) {
              each$1(legendItems, function (legend) {
                var itemsGroup = legend.itemsGroup,
                    legendHitBoxes = legend.legendHitBoxes;
                var children = itemsGroup.get('children');

                if (children.length) {
                  var legendPosX = legend.x;
                  var legendPosY = legend.y;
                  each$1(legendHitBoxes, function (box, index) {
                    if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
                      // inbox
                      result = {
                        clickedItem: children[index],
                        clickedLegend: legend
                      };
                      return false;
                    }
                  });
                }
              });
            });
            return result;
          }

          var chart = self.chart;

          var _createEvent = createEvent(ev, chart),
              x = _createEvent.x,
              y = _createEvent.y;

          var clicked = findItem(x, y);

          if (clicked && clicked.clickedLegend.clickable !== false) {
            var clickedItem = clicked.clickedItem,
                clickedLegend = clicked.clickedLegend;

            if (clickedLegend.onClick) {
              ev.clickedItem = clickedItem;
              clickedLegend.onClick(ev);
            } else if (!clickedLegend.custom) {
              var checked = clickedItem.get('checked');
              var value = clickedItem.get('dataValue');
              var filteredVals = clickedLegend.filteredVals,
                  field = clickedLegend.field,
                  selectedMode = clickedLegend.selectedMode;
              var isSingeSelected = selectedMode === 'single';

              if (isSingeSelected) {
                chart.filter(field, function (val) {
                  return val === value;
                });
              } else {
                if (checked) {
                  filteredVals.push(value);
                } else {
                  remove(filteredVals, value);
                }

                chart.filter(field, function (val) {
                  return filteredVals.indexOf(val) === -1;
                });
              }

              chart.repaint();
            }
          }
        });

        this.legendCfg = {};
        this.enable = true;
        this.position = 'top';
        mix$1(this, cfg);
        var _chart = this.chart;
        this.canvasDom = _chart.get('canvas').get('el');
        this.clear();
      }

      var _proto = LegendController.prototype;

      _proto.addLegend = function addLegend(scale, items, filteredVals) {
        var self = this;
        var legendCfg = self.legendCfg;
        var field = scale.field;
        var fieldCfg = legendCfg[field];

        if (fieldCfg === false) {
          return null;
        }

        if (fieldCfg && fieldCfg.custom) {
          self.addCustomLegend(field);
        } else {
          var position = legendCfg.position || self.position;

          if (fieldCfg && fieldCfg.position) {
            position = fieldCfg.position;
          }

          if (scale.isCategory) {
            self._addCategoryLegend(scale, items, position, filteredVals);
          }
        }
      };

      _proto.addCustomLegend = function addCustomLegend(field) {
        var self = this;
        var legendCfg = self.legendCfg;

        if (field && legendCfg[field]) {
          legendCfg = legendCfg[field];
        }

        var position = legendCfg.position || self.position;
        var legends = self.legends;
        legends[position] = legends[position] || [];
        var items = legendCfg.items;

        if (!items) {
          return null;
        }

        var container = self.container;
        each$1(items, function (item) {
          if (!isPlainObject(item.marker)) {
            item.marker = {
              symbol: item.marker || 'circle',
              fill: item.fill,
              radius: MARKER_SIZE
            };
          } else {
            item.marker.radius = item.marker.radius || MARKER_SIZE;
          }

          item.checked = isNil$1(item.checked) ? true : item.checked;
          item.name = item.name || item.value;
        });
        var legend = new List(deepMix({}, Global.legend[position], legendCfg, {
          maxLength: self._getMaxLength(position),
          items: items,
          parent: container
        }));
        legends[position].push(legend);
      };

      _proto.clear = function clear() {
        var legends = this.legends;
        each$1(legends, function (legendItems) {
          each$1(legendItems, function (legend) {
            legend.clear();
          });
        });
        this.legends = {};
        this.unBindEvents();
      };

      _proto._isFiltered = function _isFiltered(scale, values, value) {
        var rst = false;
        each$1(values, function (val) {
          rst = rst || scale.getText(val) === scale.getText(value);

          if (rst) {
            return false;
          }
        });
        return rst;
      };

      _proto._getMaxLength = function _getMaxLength(position) {
        var chart = this.chart;
        var appendPadding = parsePadding(chart.get('appendPadding'));
        return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
      };

      _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filteredVals) {
        var self = this;
        var legendCfg = self.legendCfg,
            legends = self.legends,
            container = self.container,
            chart = self.chart;
        var field = scale.field;
        legends[position] = legends[position] || [];
        var symbol = 'circle';

        if (legendCfg[field] && legendCfg[field].marker) {
          symbol = legendCfg[field].marker;
        } else if (legendCfg.marker) {
          symbol = legendCfg.marker;
        }

        each$1(items, function (item) {
          if (isPlainObject(symbol)) {
            mix$1(item.marker, symbol);
          } else {
            item.marker.symbol = symbol;
          }

          if (filteredVals) {
            item.checked = !self._isFiltered(scale, filteredVals, item.dataValue);
          }
        });
        var legendItems = chart.get('legendItems');
        legendItems[field] = items;
        var lastCfg = deepMix({}, Global.legend[position], legendCfg[field] || legendCfg, {
          maxLength: self._getMaxLength(position),
          items: items,
          field: field,
          filteredVals: filteredVals,
          parent: container
        });

        if (lastCfg.showTitle) {
          deepMix(lastCfg, {
            title: scale.alias || scale.field
          });
        }

        var legend = new List(lastCfg);
        legends[position].push(legend);
        return legend;
      };

      _proto._alignLegend = function _alignLegend(legend, pre, position) {
        var self = this;
        var _self$plotRange = self.plotRange,
            tl = _self$plotRange.tl,
            bl = _self$plotRange.bl;
        var chart = self.chart;
        var offsetX = legend.offsetX || 0;
        var offsetY = legend.offsetY || 0;
        var chartWidth = chart.get('width');
        var chartHeight = chart.get('height');
        var appendPadding = parsePadding(chart.get('appendPadding'));
        var legendHeight = legend.getHeight();
        var legendWidth = legend.getWidth();
        var x = 0;
        var y = 0;

        if (position === 'left' || position === 'right') {
          var verticalAlign = legend.verticalAlign || 'middle';
          var height = Math.abs(tl.y - bl.y);
          x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
          y = (height - legendHeight) / 2 + tl.y;

          if (verticalAlign === 'top') {
            y = tl.y;
          } else if (verticalAlign === 'bottom') {
            y = bl.y - legendHeight;
          }

          if (pre) {
            y = pre.get('y') - legendHeight - LEGEND_GAP;
          }
        } else {
          var align = legend.align || 'left';
          x = appendPadding[3];

          if (align === 'center') {
            x = chartWidth / 2 - legendWidth / 2;
          } else if (align === 'right') {
            x = chartWidth - (legendWidth + appendPadding[1]);
          }

          y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;

          if (pre) {
            var preWidth = pre.getWidth();
            x = pre.x + preWidth + LEGEND_GAP;
          }
        }

        if (position === 'bottom' && offsetY > 0) {
          offsetY = 0;
        }

        if (position === 'right' && offsetX > 0) {
          offsetX = 0;
        }

        legend.moveTo(x + offsetX, y + offsetY);
      };

      _proto.alignLegends = function alignLegends() {
        var self = this;
        var legends = self.legends;
        each$1(legends, function (legendItems, position) {
          each$1(legendItems, function (legend, index) {
            var pre = legendItems[index - 1];

            self._alignLegend(legend, pre, position);
          });
        });
        return self;
      };

      _proto.bindEvents = function bindEvents() {
        var legendCfg = this.legendCfg;
        var triggerOn = legendCfg.triggerOn || 'touchstart';
        addEventListener(this.canvasDom, triggerOn, this.handleEvent);
      };

      _proto.unBindEvents = function unBindEvents() {
        var legendCfg = this.legendCfg;
        var triggerOn = legendCfg.triggerOn || 'touchstart';
        removeEventListener(this.canvasDom, triggerOn, this.handleEvent);
      };

      return LegendController;
    }();

    function init(chart) {
      var legendController = new LegendController({
        container: chart.get('backPlot').addGroup(),
        plotRange: chart.get('plotRange'),
        chart: chart
      });
      chart.set('legendController', legendController);

      chart.legend = function (field, cfg) {
        var legendCfg = legendController.legendCfg;
        legendController.enable = true;

        if (isBoolean(field)) {
          legendController.enable = field;
          legendCfg = cfg || {};
        } else if (isObject$1(field)) {
          legendCfg = field;
        } else {
          legendCfg[field] = cfg;
        }

        legendController.legendCfg = legendCfg;
        return this;
      };
    }

    function beforeGeomDraw(chart) {
      var legendController = chart.get('legendController');
      if (!legendController.enable) return null; // legend is not displayed

      var legendCfg = legendController.legendCfg,
          container = legendController.container;

      if (legendCfg && legendCfg.custom) {
        legendController.addCustomLegend();
      } else {
        var legendItems = chart.getLegendItems();
        var scales = chart.get('scales');
        var filters = chart.get('filters');
        each$1(legendItems, function (items, field) {
          var scale = scales[field];
          var values = scale.values;
          var filteredVals;

          if (filters && filters[field]) {
            filteredVals = values.filter(function (v) {
              return !filters[field](v);
            });
          } else {
            filteredVals = [];
          }

          legendController.addLegend(scale, items, filteredVals);
        });
      }

      if (legendCfg && legendCfg.clickable !== false) {
        legendController.bindEvents();
      }

      var legends = legendController.legends;
      var legendRange = {
        top: 0,
        right: 0,
        bottom: 0,
        left: 0
      };
      each$1(legends, function (legendItems, position) {
        var padding = 0;
        each$1(legendItems, function (legend) {
          var width = legend.getWidth();
          var height = legend.getHeight();

          if (position === 'top' || position === 'bottom') {
            padding = Math.max(padding, height);

            if (legend.offsetY > 0) {
              padding += legend.offsetY;
            }
          } else {
            padding = Math.max(padding, width);

            if (legend.offsetX > 0) {
              padding += legend.offsetX;
            }
          }
        });
        legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
      });
      chart.set('legendRange', legendRange);

      if (Object.keys(legends).length) {
        container.set('ariaLabel', lang.legend.prefix);
      } else {
        container.set('ariaLabel', null);
      }
    }

    function afterGeomDraw(chart) {
      var legendController = chart.get('legendController');
      legendController.alignLegends();
    }

    function clearInner(chart) {
      var legendController = chart.get('legendController');
      legendController.clear();
      chart.set('legendRange', null);
    }
    var legend = {
      init: init,
      beforeGeomDraw: beforeGeomDraw,
      afterGeomDraw: afterGeomDraw,
      clearInner: clearInner
    };

    var Legend = /*#__PURE__*/Object.freeze({
        __proto__: null,
        init: init,
        beforeGeomDraw: beforeGeomDraw,
        afterGeomDraw: afterGeomDraw,
        clearInner: clearInner,
        'default': legend
    });

    var clock = typeof performance === 'object' && performance.now ? performance : Date;

    var Timeline = /*#__PURE__*/function () {
      function Timeline() {
        this.anims = [];
        this.time = null;
        this.playing = false;
        this.canvas = [];
      }

      var _proto = Timeline.prototype;

      _proto.play = function play() {
        var self = this;
        self.time = clock.now();
        self.playing = true;

        function step() {
          if (self.playing) {
            requestAnimationFrame(step);
            self.update();
          }
        }

        requestAnimationFrame(step);
      };

      _proto.stop = function stop() {
        this.playing = false;
        this.time = null;
        this.canvas = [];
      };

      _proto.pushAnim = function pushAnim(animInfo) {
        // 先启动动画
        if (!this.playing) {
          this.play();
        }

        var delay = animInfo.delay,
            duration = animInfo.duration;
        var startTime = this.time + delay;
        var endTime = startTime + duration;
        animInfo.startTime = startTime;
        animInfo.endTime = endTime;
        this.anims.push(animInfo);
      };

      _proto.update = function update() {
        var currentTime = clock.now();
        this.canvas = [];

        if (!this.anims.length) {
          this.stop();
          return;
        }

        for (var i = 0; i < this.anims.length; i++) {
          var propertyAnim = this.anims[i];

          if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
            continue;
          }

          var shape = propertyAnim.shape; // shape

          if (shape.get('destroyed')) {
            this.anims.splice(i, 1);
            i--;
            continue;
          }

          var startState = propertyAnim.startState,
              endState = propertyAnim.endState,
              interpolate = propertyAnim.interpolate,
              duration = propertyAnim.duration;

          if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
            propertyAnim.hasStarted = true;

            if (propertyAnim.onStart) {
              propertyAnim.onStart();
            }
          }

          var t = (currentTime - propertyAnim.startTime) / duration;
          t = Math.max(0, Math.min(t, 1));
          t = propertyAnim.easing(t);

          if (propertyAnim.onFrame) {
            propertyAnim.onFrame(t);
          } else {
            for (var key in interpolate) {
              var diff = interpolate[key];
              var value = diff(t);
              var newValue = void 0;

              if (key === 'points') {
                newValue = [];
                var aLen = Math.max(startState.points.length, endState.points.length);

                for (var j = 0; j < aLen; j += 2) {
                  newValue.push({
                    x: value[j],
                    y: value[j + 1]
                  });
                }
              } else {
                newValue = value;
              }

              shape._attrs.attrs[key] = newValue;
              shape._attrs.bbox = null; // should clear calculated bbox
            }
          }

          var canvas = shape.get('canvas');

          if (this.canvas.indexOf(canvas) === -1) {
            this.canvas.push(canvas);
          }

          if (propertyAnim.onUpdate) {
            propertyAnim.onUpdate(t);
          }

          if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
            propertyAnim.hasEnded = true;

            if (propertyAnim.onEnd) {
              propertyAnim.onEnd();
            }
          }

          if (t === 1) {
            // end
            this.anims.splice(i, 1);
            i--;
          }
        }

        this.canvas.map(function (c) {
          c.draw();
          return c;
        });
        this.time = clock.now();
      };

      return Timeline;
    }();

    function linear(k) {
      return k;
    }

    function quadraticIn(k) {
      return k * k;
    }

    function quadraticOut(k) {
      return k * (2 - k);
    }

    function quadraticInOut(k) {
      if ((k *= 2) < 1) {
        return 0.5 * k * k;
      }

      return -0.5 * (--k * (k - 2) - 1);
    }

    function cubicIn(k) {
      return k * k * k;
    }

    function cubicOut(k) {
      return --k * k * k + 1;
    }

    function cubicInOut(k) {
      if ((k *= 2) < 1) {
        return 0.5 * k * k * k;
      }

      return 0.5 * ((k -= 2) * k * k + 2);
    }

    function elasticIn(k) {
      var s;
      var a = 0.1;
      var p = 0.4;
      if (k === 0) return 0;
      if (k === 1) return 1;

      if (!a || a < 1) {
        a = 1;
        s = p / 4;
      } else {
        s = p / (2 * Math.PI) * Math.asin(1 / a);
      }

      return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
    }

    function elasticOut(k) {
      var s;
      var a = 0.1;
      var p = 0.4;
      if (k === 0) return 0;
      if (k === 1) return 1;

      if (!a || a < 1) {
        a = 1;
        s = p / 4;
      } else {
        s = p / (2 * Math.PI) * Math.asin(1 / a);
      }

      return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
    }

    function elasticInOut(k) {
      var s;
      var a = 0.1;
      var p = 0.4;
      if (k === 0) return 0;
      if (k === 1) return 1;

      if (!a || a < 1) {
        a = 1;
        s = p / 4;
      } else {
        s = p / (2 * Math.PI) * Math.asin(1 / a);
      }

      if ((k *= 2) < 1) {
        return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
      }

      return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
    }

    function backIn(k) {
      var s = 1.70158;
      return k * k * ((s + 1) * k - s);
    }

    function backOut(k) {
      var s = 1.70158;
      return (k = k - 1) * k * ((s + 1) * k + s) + 1;
    }

    function backInOut(k) {
      var s = 1.70158 * 1.525;

      if ((k *= 2) < 1) {
        return 0.5 * (k * k * ((s + 1) * k - s));
      }

      return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
    }

    function bounceIn(k) {
      return 1 - bounceOut(1 - k);
    }

    function bounceOut(k) {
      if ((k /= 1) < 1 / 2.75) {
        return 7.5625 * k * k;
      } else if (k < 2 / 2.75) {
        return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
      } else if (k < 2.5 / 2.75) {
        return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
      }

      return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
    }

    function bounceInOut(k) {
      if (k < 0.5) {
        return bounceIn(k * 2) * 0.5;
      }

      return bounceOut(k * 2 - 1) * 0.5 + 0.5;
    }

    var Easing = /*#__PURE__*/Object.freeze({
        __proto__: null,
        linear: linear,
        quadraticIn: quadraticIn,
        quadraticOut: quadraticOut,
        quadraticInOut: quadraticInOut,
        cubicIn: cubicIn,
        cubicOut: cubicOut,
        cubicInOut: cubicInOut,
        elasticIn: elasticIn,
        elasticOut: elasticOut,
        elasticInOut: elasticInOut,
        backIn: backIn,
        backOut: backOut,
        backInOut: backInOut,
        bounceIn: bounceIn,
        bounceOut: bounceOut,
        bounceInOut: bounceInOut
    });

    function plainArray(arr) {
      var result = [];

      for (var i = 0, len = arr.length; i < len; i++) {
        if (arr[i]) {
          result.push(arr[i].x);
          result.push(arr[i].y);
        }
      }

      return result;
    }

    function interpolateNumber(a, b) {
      a = +a;
      b -= a;
      return function (t) {
        return a + b * t;
      };
    }

    function interpolateArray(a, b) {
      var nb = b ? b.length : 0;
      var na = a ? Math.min(nb, a.length) : 0;
      var x = new Array(na);
      var c = new Array(nb);
      var i;

      for (i = 0; i < na; ++i) {
        x[i] = interpolateNumber(a[i], b[i]);
      }

      for (; i < nb; ++i) {
        c[i] = b[i];
      }

      return function (t) {
        for (i = 0; i < na; ++i) {
          c[i] = x[i](t);
        }

        return c;
      };
    }

    var Animator = /*#__PURE__*/function () {
      function Animator(shape, source, timeline) {
        this.hasStarted = false;
        this.hasEnded = false;
        this.shape = shape;
        this.source = source;
        this.timeline = timeline;
        this.animate = null;
      } // delay, attrs, duration, easing


      var _proto = Animator.prototype;

      _proto.to = function to(cfg) {
        if (cfg === void 0) {
          cfg = {};
        }

        var delay = cfg.delay || 0;
        var attrs = cfg.attrs || {};
        var duration = cfg.duration || 1000;
        var easing; // 缓动函数

        if (typeof cfg.easing === 'function') {
          easing = cfg.easing;
        } else {
          easing = Easing[cfg.easing] || linear;
        }

        var animInfo = {
          shape: this.shape,
          delay: delay,
          duration: duration,
          easing: easing
        };
        var interpolate = {}; // 差值函数

        for (var attrName in attrs) {
          var startValue = this.source[attrName];
          var endValue = attrs[attrName];

          if (attrName === 'points') {
            startValue = plainArray(startValue);
            endValue = plainArray(endValue);
            interpolate.points = interpolateArray(startValue, endValue);
            this.source.points = startValue;
            attrs.points = endValue;
          } else if (attrName === 'matrix') {
            interpolate.matrix = interpolateArray(startValue, endValue);
          } else {
            interpolate[attrName] = interpolateNumber(startValue, endValue);
          }
        }

        animInfo.interpolate = interpolate;
        animInfo.startState = this.source;
        animInfo.endState = attrs;
        this.timeline.pushAnim(animInfo);
        this.animate = animInfo;
        return this;
      };

      _proto.onFrame = function onFrame(callback) {
        // 自定义每一帧动画的动作
        if (this.animate) {
          this.animate.onFrame = function (frame) {
            callback(frame);
          };
        }

        return this;
      };

      _proto.onStart = function onStart(callback) {
        if (this.animate) {
          this.animate.onStart = function () {
            callback();
          };
        }

        return this;
      };

      _proto.onUpdate = function onUpdate(callback) {
        if (this.animate) {
          this.animate.onUpdate = function (frame) {
            callback(frame);
          };
        }

        return this;
      };

      _proto.onEnd = function onEnd(callback) {
        if (this.animate) {
          this.animate.onEnd = function () {
            callback();
          };
        }

        return this;
      };

      return Animator;
    }();

    var defaultAnimationCfg = {
      appear: {
        duration: 450,
        easing: 'quadraticOut'
      },
      // 'appear' animation options
      update: {
        duration: 300,
        easing: 'quadraticOut'
      },
      // 'update' animation options
      enter: {
        duration: 300,
        easing: 'quadraticOut'
      },
      // 'enter' animation options
      leave: {
        duration: 350,
        easing: 'quadraticIn'
      } // 'leave' animation options

    };
    var Animate = {
      defaultCfg: {},
      Action: {},
      getAnimation: function getAnimation(geomType, coord, animationType) {
        var geomAnimateCfg = this.defaultCfg[geomType];

        if (geomAnimateCfg) {
          var animation = geomAnimateCfg[animationType];

          if (isFunction$1(animation)) {
            return animation(coord);
          }
        }

        return false;
      },
      getAnimateCfg: function getAnimateCfg(geomType, animationType) {
        var defaultCfg = defaultAnimationCfg[animationType];
        var geomConfig = this.defaultCfg[geomType];

        if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
          return deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
        }

        return defaultCfg;
      },
      registerAnimation: function registerAnimation(animationName, animationFun) {
        var _extends2;

        if (!this.Action) {
          this.Action = {};
        }

        this.Action = _extends({}, this.Action, (_extends2 = {}, _extends2[animationName] = animationFun, _extends2));
      }
    };

    /**
     * Utility
     * @author sima.zhang1990@gmail.com
     */

    function getCoordInfo(coord) {
      var start = coord.start;
      var end = coord.end;
      return {
        start: start,
        end: end,
        width: end.x - start.x,
        height: Math.abs(end.y - start.y)
      };
    }

    function getScaledMatrix(shape, v, direct) {
      var scaledMatrix;
      shape.apply(v);
      var x = v[0];
      var y = v[1];

      if (direct === 'x') {
        shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
        var matrix = shape.getMatrix();
        scaledMatrix = Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
      } else if (direct === 'y') {
        shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);

        var _matrix = shape.getMatrix();

        scaledMatrix = Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
      } else if (direct === 'xy') {
        shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);

        var _matrix2 = shape.getMatrix();

        scaledMatrix = Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
      }

      return scaledMatrix;
    }

    function getAnimateParam(animateCfg, index, id) {
      var result = {};

      if (animateCfg.delay) {
        result.delay = isFunction$1(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
      }

      result.easing = animateCfg.easing;
      result.duration = animateCfg.duration;
      result.delay = animateCfg.delay;
      return result;
    }

    function doAnimation(shape, endState, animateCfg, callback) {
      var id = shape._id;
      var index = shape.get('index');

      var _getAnimateParam = getAnimateParam(animateCfg, index, id),
          easing = _getAnimateParam.easing,
          delay = _getAnimateParam.delay,
          duration = _getAnimateParam.duration;

      var anim = shape.animate().to({
        attrs: endState,
        duration: duration,
        delay: delay,
        easing: easing
      });

      if (callback) {
        anim.onEnd(function () {
          callback();
        });
      }
    }

    /**
     * Animation functions for shape
     * @author sima.zhang1990@gmail.com
     */
    /*
    function waveIn(shape, animateCfg, coord) {
      const clip = Helpers.getClip(coord);
      clip.set('canvas', shape.get('canvas'));
      shape.attr('clip', clip);
      const onEnd = function() {
        shape.attr('clip', null);
        clip.remove(true);
      };
      Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
    }

    function scaleInX(shape, animateCfg) {
      const box = shape.getBBox();
      const points = shape.get('origin').points;
      let x;
      const y = (box.minY + box.maxY) / 2;

      if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
        x = box.maxX;
      } else {
        x = box.minX;
      }
      const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
      Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
    }

    function scaleInY(shape, animateCfg) {
      const box = shape.getBBox();
      const points = shape.get('origin').points;
      const x = (box.minX + box.maxX) / 2;
      let y;

      if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
        y = box.maxY;
      } else {
        y = box.minY;
      }
      const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
      Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
    }
    */

    function fadeIn(shape, animateCfg) {
      var fillOpacity = isNil$1(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
      var strokeOpacity = isNil$1(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
      shape.attr('fillOpacity', 0);
      shape.attr('strokeOpacity', 0);
      var endState = {
        fillOpacity: fillOpacity,
        strokeOpacity: strokeOpacity
      };
      doAnimation(shape, endState, animateCfg);
    }

    var ShapeAction = /*#__PURE__*/Object.freeze({
        __proto__: null,
        fadeIn: fadeIn
    });

    /**
     * Group animate functions
     * @author sima.zhang1990@gmail.com
     */

    function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
      var _getCoordInfo = getCoordInfo(coord),
          start = _getCoordInfo.start,
          end = _getCoordInfo.end,
          width = _getCoordInfo.width,
          height = _getCoordInfo.height;

      var x;
      var y;
      var clip = new Shape.Rect({
        attrs: {
          x: start.x,
          y: end.y,
          width: width,
          height: height
        }
      });

      if (type === 'y') {
        x = start.x + width / 2;
        y = zeroY.y < start.y ? zeroY.y : start.y;
      } else if (type === 'x') {
        x = zeroY.x > start.x ? zeroY.x : start.x;
        y = start.y + height / 2;
      } else if (type === 'xy') {
        if (coord.isPolar) {
          x = coord.center.x;
          y = coord.center.y;
        } else {
          x = (start.x + end.x) / 2;
          y = (start.y + end.y) / 2;
        }
      }

      var endMatrix = getScaledMatrix(clip, [x, y], type);
      clip.isClip = true;
      clip.endState = {
        matrix: endMatrix
      };
      clip.set('canvas', container.get('canvas'));
      container.attr('clip', clip);

      var onEnd = function onEnd() {
        container.attr('clip', null);
        clip.remove(true);
      };

      doAnimation(clip, clip.endState, animateCfg, onEnd);
    }

    function _shapeScale(container, animateCfg, type) {
      var shapes = container.get('children');
      var x;
      var y;
      var endMatrix;

      for (var i = 0, len = shapes.length; i < len; i++) {
        var shape = shapes[i];
        var box = shape.getBBox();
        x = (box.minX + box.maxX) / 2;
        y = (box.minY + box.maxY) / 2;
        endMatrix = getScaledMatrix(shape, [x, y], type);
        doAnimation(shape, {
          matrix: endMatrix
        }, animateCfg);
      }
    }

    function groupScaleInX(container, animateCfg, coord, zeroY) {
      _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
    }

    function groupScaleInY(container, animateCfg, coord, zeroY) {
      _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
    }

    function groupScaleInXY(container, animateCfg, coord, zeroY) {
      _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
    }

    function shapesScaleInX(container, animateCfg) {
      _shapeScale(container, animateCfg, 'x');
    }

    function shapesScaleInY(container, animateCfg) {
      _shapeScale(container, animateCfg, 'y');
    }

    function shapesScaleInXY(container, animateCfg) {
      _shapeScale(container, animateCfg, 'xy');
    }

    function groupWaveIn(container, animateCfg, coord) {
      var clip = getClip(coord);
      clip.set('canvas', container.get('canvas'));
      container.attr('clip', clip);

      var onEnd = function onEnd() {
        container.attr('clip', null);
        clip.remove(true);
      };

      var endState = {};

      if (coord.isPolar) {
        var startAngle = coord.startAngle,
            endAngle = coord.endAngle;
        endState.endAngle = endAngle;
        clip.attr('endAngle', startAngle);
      } else {
        var start = coord.start,
            end = coord.end;
        var width = Math.abs(start.x - end.x);
        var height = Math.abs(start.y - end.y);

        if (coord.isTransposed) {
          clip.attr('height', 0);
          endState.height = height;
        } else {
          clip.attr('width', 0);
          endState.width = width;
        }
      }

      doAnimation(clip, endState, animateCfg, onEnd);
    }

    var GroupAction = /*#__PURE__*/Object.freeze({
        __proto__: null,
        groupWaveIn: groupWaveIn,
        groupScaleInX: groupScaleInX,
        groupScaleInY: groupScaleInY,
        groupScaleInXY: groupScaleInXY,
        shapesScaleInX: shapesScaleInX,
        shapesScaleInY: shapesScaleInY,
        shapesScaleInXY: shapesScaleInXY
    });

    /**
     * Handle the detail animations
     * @author sima.zhang1990@gmail.com
     */
    var timeline;

    Element.prototype.animate = function () {
      var attrs = mix$1({}, this.get('attrs'));
      return new Animator(this, attrs, timeline);
    };

    Chart.prototype.animate = function (cfg) {
      this.set('animate', cfg);
      return this;
    };

    Animate.Action = ShapeAction;
    Animate.defaultCfg = {
      interval: {
        enter: function enter(coord) {
          if (coord.isPolar && coord.transposed) {
            // for pie chart
            return function (shape) {
              shape.set('zIndex', -1);
              var container = shape.get('parent');
              container.sort();
            };
          }

          return fadeIn;
        }
      },
      area: {
        enter: function enter(coord) {
          if (coord.isPolar) return null;
          return fadeIn;
        }
      },
      line: {
        enter: function enter(coord) {
          if (coord.isPolar) return null;
          return fadeIn;
        }
      },
      path: {
        enter: function enter(coord) {
          if (coord.isPolar) return null;
          return fadeIn;
        }
      }
    };
    var GROUP_ANIMATION = {
      line: function line(coord) {
        if (coord.isPolar) {
          return groupScaleInXY;
        }

        return groupWaveIn;
      },
      area: function area(coord) {
        if (coord.isPolar) {
          return groupScaleInXY;
        }

        return groupWaveIn;
      },
      path: function path(coord) {
        if (coord.isPolar) {
          return groupScaleInXY;
        }

        return groupWaveIn;
      },
      point: function point() {
        return shapesScaleInXY;
      },
      interval: function interval(coord) {
        var result;

        if (coord.isPolar) {
          // polar coodinate
          result = groupScaleInXY;

          if (coord.transposed) {
            // pie chart
            result = groupWaveIn;
          }
        } else {
          result = coord.transposed ? groupScaleInX : groupScaleInY;
        }

        return result;
      },
      schema: function schema() {
        return groupWaveIn;
      }
    };

    function diff(fromAttrs, toAttrs) {
      var endState = {};

      for (var k in toAttrs) {
        if (isNumber(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
          endState[k] = toAttrs[k];
        } else if (isArray$1(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
          endState[k] = toAttrs[k];
        }
      }

      return endState;
    } // Add a unique id identifier to each shape


    function _getShapeId(geom, dataObj, geomIdx) {
      var type = geom.get('type');
      var id = 'geom' + geomIdx + '-' + type;
      var xScale = geom.getXScale();
      var yScale = geom.getYScale();
      var xField = xScale.field || 'x';
      var yField = yScale.field || 'y';
      var yVal = dataObj[yField];
      var xVal;

      if (xScale.isIdentity) {
        xVal = xScale.value;
      } else {
        xVal = dataObj[xField];
      }

      if (type === 'interval' || type === 'schema') {
        id += '-' + xVal;
      } else if (type === 'line' || type === 'area' || type === 'path') {
        id += '-' + type;
      } else {
        id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
      }

      var groupScales = geom._getGroupScales();

      each$1(groupScales, function (groupScale) {
        var field = groupScale.field;

        if (groupScale.type !== 'identity') {
          id += '-' + dataObj[field];
        }
      });
      return id;
    } // get geometry's shapes


    function getShapes(geoms, chart, coord) {
      var shapes = [];
      each$1(geoms, function (geom, geomIdx) {
        var geomContainer = geom.get('container');
        var geomShapes = geomContainer.get('children');
        var type = geom.get('type');
        var animateCfg = isNil$1(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');

        if (animateCfg !== false) {
          each$1(geomShapes, function (shape, index) {
            if (shape.get('className') === type) {
              shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
              shape.set('coord', coord);
              shape.set('animateCfg', animateCfg);
              shape.set('index', index);
              shapes.push(shape);
            }
          });
        }

        geom.set('shapes', geomShapes);
      });
      return shapes;
    }

    function cache(shapes) {
      var rst = {};

      for (var i = 0, len = shapes.length; i < len; i++) {
        var shape = shapes[i];
        if (!shape._id || shape.isClip) continue;
        var id = shape._id;
        rst[id] = {
          _id: id,
          type: shape.get('type'),
          // the type of shape
          attrs: mix$1({}, shape._attrs.attrs),
          // the graphics attributes of shape
          className: shape.get('className'),
          geomType: shape.get('className'),
          index: shape.get('index'),
          coord: shape.get('coord'),
          animateCfg: shape.get('animateCfg')
        };
      }

      return rst;
    }

    function getAnimate(geomType, coord, animationType, animationName) {
      var result;

      if (isFunction$1(animationName)) {
        result = animationName;
      } else if (isString(animationName)) {
        result = Animate.Action[animationName];
      } else {
        result = Animate.getAnimation(geomType, coord, animationType);
      }

      return result;
    }

    function getAnimateCfg(geomType, animationType, animateCfg) {
      if (animateCfg === false || isObject$1(animateCfg) && animateCfg[animationType] === false) {
        return false;
      }

      var defaultCfg = Animate.getAnimateCfg(geomType, animationType);

      if (animateCfg && animateCfg[animationType]) {
        return deepMix({}, defaultCfg, animateCfg[animationType]);
      }

      return defaultCfg;
    }

    function addAnimate(cache, shapes, canvas) {
      var animate;
      var animateCfg; // the order of animation: leave -> update -> enter

      var updateShapes = [];
      var newShapes = [];
      each$1(shapes, function (shape) {
        var result = cache[shape._id];

        if (!result) {
          newShapes.push(shape);
        } else {
          shape.set('cacheShape', result);
          updateShapes.push(shape);
          delete cache[shape._id];
        }
      }); // first do the leave animation

      each$1(cache, function (deletedShape) {
        var className = deletedShape.className,
            coord = deletedShape.coord,
            _id = deletedShape._id,
            attrs = deletedShape.attrs,
            index = deletedShape.index,
            type = deletedShape.type;
        animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
        if (animateCfg === false) return true;
        animate = getAnimate(className, coord, 'leave', animateCfg.animation);

        if (isFunction$1(animate)) {
          var tempShape = canvas.addShape(type, {
            attrs: attrs,
            index: index,
            canvas: canvas,
            className: className
          });
          tempShape._id = _id;
          animate(tempShape, animateCfg, coord);
        }
      }); // then do the update animation

      each$1(updateShapes, function (updateShape) {
        var className = updateShape.get('className');
        animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
        if (animateCfg === false) return true;
        var coord = updateShape.get('coord');
        var cacheAttrs = updateShape.get('cacheShape').attrs;
        var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换

        if (Object.keys(endState).length) {
          animate = getAnimate(className, coord, 'update', animateCfg.animation);

          if (isFunction$1(animate)) {
            animate(updateShape, animateCfg, coord);
          } else {
            var startState = {};
            each$1(endState, function (value, key) {
              startState[key] = cacheAttrs[key];
            });
            updateShape.attr(startState);
            updateShape.animate().to({
              attrs: endState,
              duration: animateCfg.duration,
              easing: animateCfg.easing,
              delay: animateCfg.delay
            }).onEnd(function () {
              updateShape.set('cacheShape', null);
            });
          }
        }
      }); // last, enter animation

      each$1(newShapes, function (newShape) {
        // 新图形元素的进场元素
        var className = newShape.get('className');
        var coord = newShape.get('coord');
        animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
        if (animateCfg === false) return true;
        animate = getAnimate(className, coord, 'enter', animateCfg.animation);

        if (isFunction$1(animate)) {
          if (className === 'interval' && coord.isPolar && coord.transposed) {
            var index = newShape.get('index');
            var lastShape = updateShapes[index - 1];
            animate(newShape, animateCfg, lastShape);
          } else {
            animate(newShape, animateCfg, coord);
          }
        }
      });
    }

    function _getAnimateCfgByShapeType(type, chart) {
      if (!type) {
        return null;
      }

      var animateCfg = chart.get('animate');

      if (type.indexOf('guide-tag') > -1) {
        type = 'guide-tag';
      }

      if (isObject$1(animateCfg)) {
        return animateCfg[type];
      }

      if (animateCfg === false) {
        return false;
      }

      return null;
    }

    function afterCanvasInit() {
      timeline = new Timeline();
      timeline.play();
    }

    function beforeCanvasDraw(chart) {
      if (chart.get('animate') === false) {
        return;
      }

      var isUpdate = chart.get('isUpdate');
      var canvas = chart.get('canvas');
      var coord = chart.get('coord');
      var geoms = chart.get('geoms');
      var caches = canvas.get('caches') || [];

      if (caches.length === 0) {
        isUpdate = false;
      }

      var cacheShapes = getShapes(geoms, chart, coord);

      var _chart$get = chart.get('axisController'),
          frontPlot = _chart$get.frontPlot,
          backPlot = _chart$get.backPlot;

      var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
      var guideShapes = [];

      if (chart.get('guideController')) {
        guideShapes = chart.get('guideController').guideShapes;
      }

      var componentShapes = [];
      axisShapes.concat(guideShapes).forEach(function (s) {
        var className = s.get('className');

        var animateCfg = _getAnimateCfgByShapeType(className, chart);

        s.set('coord', coord);
        s.set('animateCfg', animateCfg);
        componentShapes.push(s);
        cacheShapes.push(s);
      });
      canvas.set('caches', cache(cacheShapes));

      if (isUpdate) {
        addAnimate(caches, cacheShapes, canvas);
      } else {
        // do the appear animation
        var animateCfg;
        var animate;
        each$1(geoms, function (geom) {
          var type = geom.get('type');
          var geomCfg = isNil$1(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');

          if (geomCfg !== false) {
            animateCfg = getAnimateCfg(type, 'appear', geomCfg);
            animate = getAnimate(type, coord, 'appear', animateCfg.animation);

            if (isFunction$1(animate)) {
              var shapes = geom.get('shapes');
              each$1(shapes, function (shape) {
                animate(shape, animateCfg, coord);
              });
            } else if (GROUP_ANIMATION[type]) {
              // do the default animation
              animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
              var yScale = geom.getYScale();
              var zeroY = coord.convertPoint({
                x: 0,
                y: yScale.scale(geom.getYMinValue())
              });
              var container = geom.get('container');
              animate && animate(container, animateCfg, coord, zeroY);
            }
          }
        }); // do the animation of components

        each$1(componentShapes, function (shape) {
          var animateCfg = shape.get('animateCfg');
          var className = shape.get('className');

          if (animateCfg && animateCfg.appear) {
            // if user configure
            var defaultCfg = Animate.getAnimateCfg(className, 'appear');
            var appearCfg = deepMix({}, defaultCfg, animateCfg.appear);

            var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);

            if (isFunction$1(_animate)) {
              _animate(shape, appearCfg, coord);
            }
          }
        });
      }
    }

    function afterCanvasDestroyed() {
      timeline.stop();
    }
    var detail = {
      afterCanvasInit: afterCanvasInit,
      beforeCanvasDraw: beforeCanvasDraw,
      afterCanvasDestroyed: afterCanvasDestroyed
    };

    var Animation = /*#__PURE__*/Object.freeze({
        __proto__: null,
        afterCanvasInit: afterCanvasInit,
        beforeCanvasDraw: beforeCanvasDraw,
        afterCanvasDestroyed: afterCanvasDestroyed,
        'default': detail
    });

    Chart._Interactions = {};

    Chart.registerInteraction = function (type, constructor) {
      Chart._Interactions[type] = constructor;
    };

    Chart.getInteraction = function (type) {
      return Chart._Interactions[type];
    };

    Chart.prototype.interaction = function (type, cfg) {
      var interactions = this._interactions || {};

      if (interactions[type]) {
        // if reprated, destroy last
        interactions[type].destroy();
      }

      var Ctor = Chart.getInteraction(type);
      var interact = new Ctor(cfg, this);
      interactions[type] = interact;
      this._interactions = interactions;
      return this;
    };

    Chart.prototype.clearInteraction = function (type) {
      var interactions = this._interactions;
      if (!interactions) return;

      if (type) {
        interactions[type] && interactions[type].destroy();
        delete interactions[type];
      } else {
        each$1(interactions, function (interaction, key) {
          interaction.destroy();
          delete interactions[key];
        });
      }

      return this;
    };

    function isValuesEqual(values, newValues) {
      if (values.length !== newValues.length) {
        return false;
      }

      var lastIndex = values.length - 1;
      return values[0] === newValues[0] && values[lastIndex] === newValues[lastIndex];
    } // 不同交互之间共享的上下文


    var defaultRange = [0, 1];

    var Context = /*#__PURE__*/function () {
      // 最开始的原始值
      // 当前显示的范围
      // 缩放最小的点数
      // 最小的缩放比例, 默认通过minCount计算
      // minScale = 0.01;
      // 交互开始时,ticks个数,主要为了每次缩放后,更新ticks个数
      // lastTickCount;
      function Context(chart) {
        var _this = this;

        _defineProperty(this, "chart", null);

        _defineProperty(this, "values", null);

        _defineProperty(this, "range", defaultRange);

        _defineProperty(this, "startRange", defaultRange);

        _defineProperty(this, "minCount", 10);

        _defineProperty(this, "_afterinit", function () {
          // 初始化value值
          var scale = _this.getPinchScale(); // 记录原始全量数据


          var values = [].concat(scale.values);
          _this.values = values; // 最小的缩放比例

          if (!_this.minScale) {
            _this.minScale = _this.minCount / values.length;
          } // 初始化的时候有设置range,则初始化成默认比例


          if (_this.range !== defaultRange) {
            _this.updateRange(_this.range);

            _this.updateTicks();
          }
        });

        _defineProperty(this, "_afterdatachange", function () {
          _this.updateRange(_this.range);
        });

        this.chart = chart;

        this._initEvent(chart);
      }

      var _proto = Context.prototype;

      _proto._initEvent = function _initEvent(chart) {
        // 在整体初始化后还需要设置一些初始状态
        chart.on(EVENT_AFTER_INIT, this._afterinit);
        chart.on(EVENT_AFTER_DATA_CHANGE, this._afterdatachange);
      } // 缩放的主轴scale
      ;

      _proto.getPinchScale = function getPinchScale() {
        var chart = this.chart; // 默认缩放x轴

        var scale = chart.getXScale();
        return scale;
      } // 跟随轴的scale
      ;

      _proto.getFollowScale = function getFollowScale() {
        var chart = this.chart; // 默认缩放x轴

        var scales = chart.getYScales() || [];
        return scales[0];
      };

      _proto.start = function start() {
        var range = this.range;
        var scale = this.getPinchScale();
        var start = range[0],
            end = range[1]; // 记录交互起始的范围

        this.startRange = [start, end]; // 记录开始时的ticks个数

        this.lastTickCount = scale.tickCount;
      };

      _proto.doZoom = function doZoom(leftScale, rightScale, zoom) {
        var range = this.startRange,
            minScale = this.minScale;
        var start = range[0],
            end = range[1];
        var zoomOffset = 1 - zoom;
        var rangeLen = end - start;
        var rangeOffset = rangeLen * zoomOffset;
        var leftOffset = rangeOffset * leftScale;
        var rightOffset = rangeOffset * rightScale;
        var newStart = Math.max(0, start - leftOffset);
        var newEnd = Math.min(1, end + rightOffset);
        var newRange = [newStart, newEnd]; // 如果已经到了最小比例,则不能再继续再放大

        if (newEnd - newStart < minScale) {
          return;
        }

        this.updateRange(newRange);
      };

      _proto.doMove = function doMove(ratio) {
        // 不管是0, 还是其他,都不用处理
        if (!ratio) return;
        var range = this.startRange;
        var start = range[0],
            end = range[1];
        var rangeLen = end - start;
        var rangeOffset = rangeLen * ratio;
        var newStart = start - rangeOffset;
        var newEnd = end - rangeOffset; // 处理边界值

        var newRange;

        if (newStart < 0) {
          newRange = [0, rangeLen];
        } else if (newEnd > 1) {
          newRange = [1 - rangeLen, 1];
        } else {
          newRange = [newStart, newEnd];
        }

        this.updateRange(newRange);
      };

      _proto.updateRange = function updateRange(range) {
        var values = this.values; // 0, 1 的范围之间

        var start = range[0],
            end = range[1]; // start 不能小于0

        start = Math.max(0, start); // end 不能大于1

        end = Math.min(1, end); // 设置当前的范围

        this.range = [start, end];
        var len = values.length;
        var valueStart = start * len;
        var valueEnd = end * len; // 从原始数据里截取需要显示的数据

        var newValues = values.slice(valueStart, valueEnd);
        this.repaint(newValues);
      };

      _proto.repaint = function repaint(newValues) {
        var chart = this.chart;
        var scale = this.getPinchScale();
        var currentValues = scale.values,
            ticks = scale.ticks; // 如果新数组和当前显示的数组相同,则不更新

        if (isValuesEqual(currentValues, newValues)) {
          return;
        } // 更新主轴values


        this.updateScale(scale, {
          ticks: ticks,
          values: newValues
        });
        this.updateFollowScale(scale, newValues);
        chart.repaint();
      };

      _proto.updateFollowScale = function updateFollowScale(pinchScale, pinchValues) {
        var chart = this.chart;
        var followScale = this.getFollowScale();
        var pinchField = pinchScale.field,
            pinchScaleType = pinchScale.type;
        var followField = followScale.field; // 根据主轴的value值,找到所有从轴的value值

        var values = []; // 转成map,让查找性能更高

        var pinchValueMap = {};
        pinchValues.forEach(function (item) {
          pinchValueMap[item] = true;
        });
        var data = chart.get('data');
        data.forEach(function (item) {
          if (pinchScaleType === 'timeCat') {
            var value = toTimeStamp$1(item[pinchField]);

            if (pinchValueMap[value]) {
              values.push(item[followField]);
            }
          }
        });

        var _getRange = getRange(values),
            min = _getRange.min,
            max = _getRange.max;

        this.updateScale(followScale, {
          min: min,
          max: max,
          nice: true
        });
      };

      _proto.updateScale = function updateScale(scale, cfg) {
        if (!scale) {
          return;
        }

        scale.change(cfg);
      } // 上一次的tick个数
      ;

      _proto.updateTicks = function updateTicks() {
        var chart = this.chart,
            values = this.values;
        var scale = this.getPinchScale();
        var currentValues = scale.values,
            tickCount = scale.tickCount; // 根据当前数据的比例,和定义的tickCount计算应该需要多少个ticks

        var newTickCount = Math.round(tickCount * values.length / currentValues.length);
        var catTicks = getTickMethod('cat');
        var ticks = catTicks({
          tickCount: newTickCount,
          values: values
        });
        this.updateScale(scale, {
          ticks: ticks,
          values: currentValues
        }); // 更新完后,需要重新绘制一次

        chart.repaint();
      };

      _proto.destroy = function destroy() {
        var chart = this.chart;
        chart.off(EVENT_AFTER_INIT, this._afterinit);
        chart.off(EVENT_AFTER_DATA_CHANGE, this._afterdatachange);
      };

      return Context;
    }();

    var Base = /*#__PURE__*/function () {
      var _proto = Base.prototype;

      // 交互的上下文
      _proto.getDefaultCfg = function getDefaultCfg() {
        return {};
      };

      _proto.getInteractionContext = function getInteractionContext(chart) {
        var interactionContext = chart.get('interactionContext');

        if (interactionContext) {
          return interactionContext;
        }

        interactionContext = new Context(chart);
        chart.set('interactionContext', interactionContext);
        return interactionContext;
      };

      function Base(cfg, chart) {
        var _this = this;

        _defineProperty(this, "type", '');

        _defineProperty(this, "startEvent", 'touchstart');

        _defineProperty(this, "processEvent", 'touchmove');

        _defineProperty(this, "endEvent", 'touchend');

        _defineProperty(this, "resetEvent", null);

        _defineProperty(this, "context", null);

        _defineProperty(this, "_start", function (ev) {
          _this.preStart && _this.preStart(ev);

          _this.start(ev);

          _this.onStart && _this.onStart(ev);
        });

        _defineProperty(this, "_process", function (ev) {
          _this.preProcess && _this.preProcess(ev);

          _this.process(ev);

          _this.onProcess && _this.onProcess(ev);
        });

        _defineProperty(this, "_end", function (ev) {
          _this.preEnd && _this.preEnd(ev);

          _this.end(ev);

          _this.onEnd && _this.onEnd(ev);
        });

        _defineProperty(this, "_reset", function (ev) {
          _this.preReset && _this.preReset(ev);

          _this.reset(ev);

          _this.onReset && _this.onReset(ev);
        });

        mix$1(this, this.getDefaultCfg(), cfg);
        this.context = this.getInteractionContext(chart);
        this.chart = chart; // 只处理range, 暂时先这么处理后面再看情况调整

        var range = this.range;

        if (range) {
          this.context.range = range;
        }

        this._bindEvents(chart);
      }

      _proto._bindEvents = function _bindEvents(chart) {
        var startEvent = this.startEvent,
            processEvent = this.processEvent,
            endEvent = this.endEvent,
            resetEvent = this.resetEvent;
        var canvas = chart.get('canvas'); // 统一绑定事件

        canvas.on(startEvent, this._start);
        canvas.on(processEvent, this._process);
        canvas.on(endEvent, this._end);
        canvas.on(resetEvent, this._reset);
      };

      _proto._clearEvents = function _clearEvents() {
        var chart = this.chart,
            startEvent = this.startEvent,
            processEvent = this.processEvent,
            endEvent = this.endEvent,
            resetEvent = this.resetEvent;
        var canvas = chart.get('canvas'); // 统一绑定事件

        canvas.off(startEvent, this._start);
        canvas.off(processEvent, this._process);
        canvas.off(endEvent, this._end);
        canvas.off(resetEvent, this._start);
      };

      // override
      _proto.start = function start() {} // override
      ;

      _proto.process = function process() {} // override
      ;

      _proto.end = function end() {} // override
      ;

      _proto.reset = function reset() {};

      _proto.destroy = function destroy() {
        this.context.destroy();

        this._clearEvents();
      };

      return Base;
    }();

    var Pan = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Pan, _Base);

      function Pan() {
        return _Base.apply(this, arguments) || this;
      }

      var _proto = Pan.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          type: 'pan',
          startEvent: 'panstart',
          processEvent: 'pan',
          endEvent: 'panend'
        };
      };

      _proto.start = function start() {
        var context = this.context;
        context.start();
      };

      _proto.process = function process(e) {
        var direction = e.direction,
            deltaX = e.deltaX;

        if (direction === 'up' || direction === 'down') {
          return;
        }

        e.preventDefault && e.preventDefault();
        var context = this.context;
        var chart = context.chart;
        var coord = chart.get('coord');
        var start = coord.start,
            end = coord.end;
        var coordWidth = end.x - start.x;
        var ratio = deltaX / coordWidth;
        context.doMove(ratio);
      };

      return Pan;
    }(Base);

    var Pinch = /*#__PURE__*/function (_Base) {
      _inheritsLoose$3(Pinch, _Base);

      var _proto = Pinch.prototype;

      _proto.getDefaultCfg = function getDefaultCfg() {
        return {
          type: 'pinch',
          startEvent: 'pinchstart',
          processEvent: 'pinch',
          endEvent: 'pinchend'
        };
      };

      function Pinch(cfg, chart) {
        var _this;

        _this = _Base.call(this, cfg, chart) || this;

        var _assertThisInitialize = _assertThisInitialized(_this),
            context = _assertThisInitialize.context;

        mix$1(context, cfg);
        return _this;
      }

      _proto.start = function start() {
        var context = this.context;
        context.start();
      };

      _proto.process = function process(e) {
        e.preventDefault && e.preventDefault();
        var zoom = e.zoom,
            center = e.center;
        var context = this.context;
        var chart = context.chart;
        var coord = chart.get('coord');
        var start = coord.start,
            end = coord.end;
        var coordWidth = end.x - start.x;
        var leftLen = Math.abs(center.x - start.x);
        var rightLen = Math.abs(end.x - center.x); // 计算左右缩放的比例

        var leftScale = leftLen / coordWidth;
        var rightScale = rightLen / coordWidth;
        context.doZoom(leftScale, rightScale, zoom);
      };

      _proto.end = function end() {
        // 缩放完成后再更新ticks
        var context = this.context;
        context.updateTicks();
      };

      return Pinch;
    }(Base);

    Chart.registerInteraction('pan', Pan);
    Chart.registerInteraction('pinch', Pinch);

    /**
     * Default, without interactins
     */
    var Component = {
      // 为了兼容之前版本
      Marker: Shape.Marker,
      Tooltip: Tooltip$1
    }; // register plugins

    Chart.plugins.register([Tooltip, Legend, Guide, Animation]); // 默认添加交互
    var index = {
      Component: Component,
      Global: Global,
      Chart: Chart,
      Shape: Shape$1,
      G: G,
      Util: Util,
      Helper: Helper,
      track: track,
      Animate: Animate
    };

    exports.Animate = Animate;
    exports.Chart = Chart;
    exports.Component = Component;
    exports.G = G;
    exports.Global = Global;
    exports.Helper = Helper;
    exports.Shape = Shape$1;
    exports.Util = Util;
    exports["default"] = index;
    exports.track = track;

    Object.defineProperty(exports, '__esModule', { value: true });

}));

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(69)))

/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {

var arrayLikeToArray = __webpack_require__(8);

function _arrayWithoutHoles(arr) {
  if (Array.isArray(arr)) return arrayLikeToArray(arr);
}

module.exports = _arrayWithoutHoles;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 62 */
/***/ (function(module, exports) {

function _iterableToArray(iter) {
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}

module.exports = _iterableToArray;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 63 */
/***/ (function(module, exports) {

function _nonIterableSpread() {
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

module.exports = _nonIterableSpread;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 64 */
/***/ (function(module, exports) {

function _arrayWithHoles(arr) {
  if (Array.isArray(arr)) return arr;
}

module.exports = _arrayWithHoles;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 65 */
/***/ (function(module, exports) {

function _iterableToArrayLimit(arr, i) {
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

  if (_i == null) return;
  var _arr = [];
  var _n = true;
  var _d = false;

  var _s, _e;

  try {
    for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
      _arr.push(_s.value);

      if (i && _arr.length === i) break;
    }
  } catch (err) {
    _d = true;
    _e = err;
  } finally {
    try {
      if (!_n && _i["return"] != null) _i["return"]();
    } finally {
      if (_d) throw _e;
    }
  }

  return _arr;
}

module.exports = _iterableToArrayLimit;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 66 */
/***/ (function(module, exports) {

function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

module.exports = _nonIterableRest;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 67 */
/***/ (function(module, exports) {

function _setPrototypeOf(o, p) {
  module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
    o.__proto__ = p;
    return o;
  };

  module.exports["default"] = module.exports, module.exports.__esModule = true;
  return _setPrototypeOf(o, p);
}

module.exports = _setPrototypeOf;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 68 */
/***/ (function(module, exports) {

function _isNativeReflectConstruct() {
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  if (Reflect.construct.sham) return false;
  if (typeof Proxy === "function") return true;

  try {
    Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
    return true;
  } catch (e) {
    return false;
  }
}

module.exports = _isNativeReflectConstruct;
module.exports["default"] = module.exports, module.exports.__esModule = true;

/***/ }),
/* 69 */
/***/ (function(module, exports) {

var g;

// This works in non-strict mode
g = (function() {
	return this;
})();

try {
	// This works if eval is allowed (see CSP)
	g = g || new Function("return this")();
} catch (e) {
	// This works if the window reference is available
	if (typeof window === "object") g = window;
}

// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}

module.exports = g;


/***/ }),
/* 70 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(0);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// EXTERNAL MODULE: ./package.json
var package_0 = __webpack_require__(56);

// EXTERNAL MODULE: ./src/config.json
var config = __webpack_require__(57);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
var helpers_typeof = __webpack_require__(5);
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/extends.js
var helpers_extends = __webpack_require__(7);
var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);

// EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(3);
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default = /*#__PURE__*/__webpack_require__.n(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_);

// CONCATENATED MODULE: ./src/locales/lang/zn-CH.js

var zn_CH_lang = {
  lang: {
    okBtnTxt: '确 定',
    cancelBtnTxt: '取 消',
    calendar: {
      loadPrevMonth: '加载上一个月',
      noMoreMonth: '没有更早月份~',
      start: '开始',
      end: '结束',
      title: '选择日期',
      week: '日,一,二,三,四,五,六',
      monthTitle: '{year}年{month}月',
      year: '年',
      month: '月',
      day: '日',
      hour: '时',
      minute: '分',
      second: '秒',
      morning: '上午',
      afternoon: '下午'
    },
    menu: {
      resetBtnTxt: '重置'
    },
    searchbar: {
      placeText: '请输入内容...',
      textInfo: '搜索'
    },
    shortpassword: {
      tip1: '输入数字密码',
      tip2: '忘记密码'
    },
    steps: {
      step: '步骤',
      stepDesc: '步骤描述'
    },
    uploader: {
      xmlError: '对不起,您的浏览器不支持本组件!',
      typeError: '不支持上传该类型文件',
      limitError: '文件大小超过限制'
    }
  }
};
external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang = 'zn-CH';
/* harmony default export */ var zn_CH = (zn_CH_lang);
// CONCATENATED MODULE: ./src/locales/index.js




var defaultMessages = {};
var merged = false;

var locales_vueI18nHandler = function vueI18nHandler() {
  var vuei18n = Object.getPrototypeOf(this || external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a).$t;

  if (typeof vuei18n === 'function' && !!external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.locale) {
    if (!merged) {
      merged = true;
      external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.locale(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang, extends_default()(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang === 'zn-CH' ? zn_CH : {}, external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.locale(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang) || {}, defaultMessages));
    }

    return vuei18n.apply(this, arguments);
  }
};

function i18n(keysStr, params) {
  var value = locales_vueI18nHandler.apply(this, arguments);
  if (value !== null && value !== undefined) return value;

  var message = extends_default()({}, external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang === 'zn-CH' ? zn_CH : {}, defaultMessages);

  var keys = keysStr && keysStr.split('.') || [];
  var result = null;

  if (keys.length) {
    for (var i = 0; i < keys.length; i++) {
      var key = keys[i];

      if (key && message[key]) {
        message = message[key];
        result = message;
      } else {
        result = null;
        break;
      }
    }
  }

  return simpleTemplate(result, params);
}

function locale(lang, messages) {
  if (typeof_default()(lang) === 'object') {
    messages = lang;
    lang = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang;
  }

  external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.config.lang = lang;

  extends_default()(defaultMessages, messages);
}

function getArgType(arg) {
  return Object.prototype.toString.call(arg).toLowerCase().match(/\s(\w+)/)[1];
}

function simpleTemplate(templ, conf) {
  var pars = templ && templ.match(/{.+?}/g);

  if (pars && conf) {
    pars = pars.map(function (p) {
      return p.replace(/\{\s*(\w+|\d+).*?\}/, '$1');
    });
    pars.forEach(function (c, i) {
      var reg = new RegExp('{\\s*' + c + '\\s*(?:=\\s*(\\S*?))?\\s*?}', 'g');
      templ = templ.replace(reg, function (a, b) {
        return getArgType(conf[c]) == 'function' ? conf[c]() : conf[c] !== undefined ? conf[c] : b ? b : a;
      });
    });
  }

  return templ;
}


// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js
var toConsumableArray = __webpack_require__(4);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(1);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(2);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);

// CONCATENATED MODULE: ./src/utils/extensions/vue.js





function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }


var vue_VueExtension = /*#__PURE__*/function () {
  function VueExtension() {
    classCallCheck_default()(this, VueExtension);
  }

  createClass_default()(VueExtension, null, [{
    key: "WithInstall",
    value: function WithInstall(component, componentFunc) {
      if (typeof_default()(component) !== 'object' && !component.name) {
        throw new Error('could not install,because it is not a vue component!');
      }

      component.install = function (vue) {
        vue.component(component.name, component);

        if (componentFunc) {
          vue.prototype["$".concat(component.name.replace('mx-', ''))] = componentFunc;
        }
      };
    }
  }, {
    key: "SortChildren",
    value: function SortChildren(children, parent) {
      var componentOptions = parent.$vnode.componentOptions;

      if (!componentOptions || !componentOptions.children || !componentOptions.children.length) {
        return;
      }

      var vnodes = this.FlattenVNode(componentOptions.children);
      children.sort(function (a, b) {
        return vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode);
      });
      return children;
    }
  }, {
    key: "FlattenVNode",
    value: function FlattenVNode(vnodes) {
      return this.TraverseVNode(vnodes);
    }
  }, {
    key: "TraverseVNode",
    value: function TraverseVNode(vnodes) {
      var res = [];

      var _iterator = _createForOfIteratorHelper(vnodes),
          _step;

      try {
        for (_iterator.s(); !(_step = _iterator.n()).done;) {
          var vnode = _step.value;
          res.push(vnode);

          if (vnode.componentInstance) {
            res.push.apply(res, toConsumableArray_default()(this.TraverseVNode(vnode.componentInstance.$children.map(function (x) {
              return x.$vnode;
            }))));
          }

          if (vnode.children) {
            res.push.apply(res, toConsumableArray_default()(this.TraverseVNode(vnode.children)));
          }
        }
      } catch (err) {
        _iterator.e(err);
      } finally {
        _iterator.f();
      }

      return res;
    }
  }, {
    key: "InvokeComponent",
    value: function InvokeComponent(buildWrapperOptionsFunc) {
      var allowMultipleInstance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var queue = [];

      var createInstance = function createInstance() {
        var unmount = function unmount() {
          instance.$destroy();
          document.body.removeChild(instance.$el);
          queue = queue.filter(function (x) {
            return x !== instance;
          });
        };

        var options = buildWrapperOptionsFunc(unmount);
        var instance = new external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a(options);
        var root = document.createElement('div');
        document.body.appendChild(root);
        instance.$mount(root);
        return instance;
      };

      var getIntance = function getIntance() {
        if (!queue.length || allowMultipleInstance) {
          queue.push(createInstance());
        }

        return queue[queue.length - 1];
      };

      return function (invokeOptions) {
        getIntance().open(invokeOptions);
      };
    }
  }]);

  return VueExtension;
}();
// CONCATENATED MODULE: ./src/utils/namespace.js



var namespace_Namespace = /*#__PURE__*/function () {
  function Namespace(name) {
    classCallCheck_default()(this, Namespace);

    this._name = name;
  }

  createClass_default()(Namespace, [{
    key: "name",
    get: function get() {
      return "".concat(Namespace.ROOT, "-").concat(this._name);
    } // 衍生名称空间
    // css 子/组合类名

  }, {
    key: "derive",
    value: function derive(name, mods) {
      if (name && typeof name !== 'string') {
        mods = name;
        name = '';
      }

      name = name ? this.sub(name) : this.name;
      return "".concat(name).concat(this.mod(name, mods));
    } // 子名称空间
    // css 子类名

  }, {
    key: "sub",
    value: function sub(name) {
      var names = Array.isArray(name) ? name : [name];
      return names.reduce(function (ret, item) {
        return "".concat(ret, "-").concat(item);
      }, names.length ? this.name : '');
    } // 名称空间模式
    // css 组合类名

  }, {
    key: "mod",
    value: function mod(name, mods) {
      var _this = this;

      if (!mods) {
        return '';
      }

      if (typeof mods === 'string') {
        return " ".concat(name, "--").concat(mods);
      }

      if (Array.isArray(mods)) {
        return mods.reduce(function (ret, item) {
          return ret + _this.mod(name, item);
        }, '');
      }

      return Object.keys(mods).reduce(function (ret, key) {
        return ret + (mods[key] ? _this.mod(name, key) : '');
      }, '');
    }
  }], [{
    key: "Create",
    value: function Create(name) {
      return new Namespace(name);
    }
  }]);

  return Namespace;
}();

defineProperty_default()(namespace_Namespace, "ROOT", 'mx');
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(6);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// CONCATENATED MODULE: ./src/utils/color.js





function color_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = color_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function color_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return color_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return color_arrayLikeToArray(o, minLen); }

function color_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

var color_Color = /*#__PURE__*/function () {
  function Color(channels, alpha) {
    classCallCheck_default()(this, Color);

    this._channels = channels;
    this._alpha = alpha;
  }

  createClass_default()(Color, [{
    key: "r",
    get: function get() {
      return this._channels[0];
    }
  }, {
    key: "g",
    get: function get() {
      return this._channels[1];
    }
  }, {
    key: "b",
    get: function get() {
      return this._channels[2];
    }
  }, {
    key: "a",
    get: function get() {
      return this._alpha;
    }
  }, {
    key: "luminosity",
    get: function get() {
      var rgb = this._channels;
      var lum = [];

      var _iterator = color_createForOfIteratorHelper(rgb.entries()),
          _step;

      try {
        for (_iterator.s(); !(_step = _iterator.n()).done;) {
          var _step$value = slicedToArray_default()(_step.value, 2),
              i = _step$value[0],
              element = _step$value[1];

          var chan = element / 255;
          lum[i] = chan <= 0.03928 ? chan / 12.92 : Math.pow((chan + 0.055) / 1.055, 2.4);
        }
      } catch (err) {
        _iterator.e(err);
      } finally {
        _iterator.f();
      }

      return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
    }
  }, {
    key: "isDark",
    get: function get() {
      return this.luminosity < 0.5;
    }
  }, {
    key: "isLight",
    get: function get() {
      return !this.isDark;
    }
  }, {
    key: "isNone",
    get: function get() {
      return !this._channels || !this._channels.length;
    }
  }, {
    key: "toString",
    value: function toString() {
      if (this.isNone) {
        return '';
      }

      return Number.isNaN(this._alpha) ? "rgb(".concat(this._channels.map(function (x) {
        return Math.round(x);
      }).join(','), ")") : "rgba(".concat([this._channels, this._alpha].map(function (x) {
        return Math.round(x);
      }).join(','), ")");
    }
  }], [{
    key: "FromHex",
    value: function FromHex(color) {
      var parseNormal = function parseNormal(color) {
        var matches = color.match(Color.REG_HEX);
        var channels = [0, 0, 0];
        var colorString = matches[1];

        for (var i = 0; i < 3; i++) {
          channels[i] = parseInt(colorString.slice(i * 2, i * 2 + 2), 16);
        }

        var alpha = matches[2] ? parseFloat(matches[2], 16) / 255 : NaN;
        return {
          channels: channels,
          alpha: alpha
        };
      };

      var parseAbbr = function parseAbbr(color) {
        var matches = color.match(Color.REG_HEX_ABBR);
        var match = matches[1];
        var channels = [0, 0, 0];

        for (var i = 0; i < 3; i++) {
          channels[i] = parseInt(match[i] + match[i], 16);
        }

        var alpha = match[4] ? parseFloat(match[4], 16) / 255 : NaN;
        return {
          channels: channels,
          alpha: alpha
        };
      };

      if (!color.startsWith('#')) {
        return new Color(null, NaN);
      }

      var _ref = color.length > 5 ? parseNormal(color) : parseAbbr(color),
          channels = _ref.channels,
          alpha = _ref.alpha;

      return new Color(channels, alpha);
    }
  }, {
    key: "Mix",
    value: function Mix(color1, color2, weight) {
      var p = weight === undefined ? 0.5 : weight;
      var w = 2 * p - 1;
      var a = (color1.a || 1) - (color2.a || 1);
      var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;
      var w2 = 1 - w1;
      var r = w1 * color1.r + w2 * color2.r;
      var g = w1 * color1.g + w2 * color2.g;
      var b = w1 * color1.b + w2 * color2.b;
      var alpha = color1.a * p + color2.a * (1 - p);
      return new Color([r, g, b], alpha);
    }
  }, {
    key: "Shift",
    value: function Shift(color, weight) {
      return weight > 0 ? Color.Shade(color, weight) : Color.Tint(color, -weight);
    }
  }, {
    key: "Tint",
    value: function Tint(color, weight) {
      return Color.Mix(Color.WHITE, color, weight);
    }
  }, {
    key: "Shade",
    value: function Shade(color, weight) {
      return Color.Mix(Color.BLACK, color, weight);
    }
  }]);

  return Color;
}();

defineProperty_default()(color_Color, "WHITE", new color_Color([255, 255, 255], 1));

defineProperty_default()(color_Color, "BLACK", new color_Color([0, 0, 0], 1));

defineProperty_default()(color_Color, "REG_HEX", /^#([a-f0-9]{6})([a-f0-9]{2})?$/i);

defineProperty_default()(color_Color, "REG_HEX_ABBR", /^#([a-f0-9]{3,4})$/i);
// CONCATENATED MODULE: ./src/packages/badge/badge.jsx



var namespace = namespace_Namespace.Create('badge');
/* harmony default export */ var badge_badge = ({
  name: namespace.name,
  props: {
    tag: {
      type: String,
      default: 'div'
    },
    theme: {
      type: String,
      default: 'red'
    },
    dot: {
      type: Boolean,
      default: false
    },
    max: {
      type: Number
    },
    content: {
      type: Number | String
    },
    color: {
      type: String
    },
    offset: {
      type: Array
    },
    small: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    cls: function cls() {
      return namespace.derive([this.theme, {
        dot: this.dot,
        fixed: !!this.$slots.default,
        small: this.small
      }]);
    },
    wrapperCls: function wrapperCls() {
      return namespace.derive('wrapper');
    },
    style: function style() {
      var style = {};

      if (this.color) {
        style.backgroundColor = this.color;
        var clr = color_Color.FromHex(this.color);
        style.color = clr.isDark ? color_Color.WHITE : color_Color.BLACK;
      }

      if (this.offset) {
        var _this$offset = slicedToArray_default()(this.offset, 2),
            x = _this$offset[0],
            y = _this$offset[1];

        if (this.$slots.default) {
          style.top = "".concat(y, "px");
          style.right = "".concat(-x, "px");
        } else {
          style.marginLeft = "".concat(x, "px");
          style.marginTop = "".concat(y, "px");
        }
      }

      return style;
    },
    hasContent: function hasContent() {
      return this.$slots.content || !!this.content;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderContent = function renderContent() {
      if (_this.dot) {
        return;
      }

      if (_this.$slots.content) {
        return _this.$slots.content;
      }

      var _this$$props = _this.$props,
          max = _this$$props.max,
          content = _this$$props.content;

      if (max && !Number.isNaN(Number(content)) && content > max) {
        return "".concat(max, "+");
      }

      return _this.content;
    };

    var renderBadge = function renderBadge() {
      if (_this.hasContent || _this.dot) {
        return h("div", {
          "class": _this.cls,
          "style": _this.style
        }, [renderContent()]);
      }
    };

    if (this.$slots.default) {
      var tag = this.tag;
      return h(tag, {
        "class": this.wrapperCls
      }, [this.$slots.default, renderBadge()]);
    }

    return renderBadge();
  }
});
// CONCATENATED MODULE: ./src/packages/icon/icon.jsx


var icon_namespace = namespace_Namespace.Create('icon');
/* harmony default export */ var icon = ({
  name: icon_namespace.name,
  components: {
    Badge: badge_badge
  },
  props: {
    tag: {
      type: String,
      default: 'i'
    },
    dot: {
      type: Boolean,
      default: false
    },
    badge: {
      type: String | Number
    },
    name: {
      type: String,
      required: true
    },
    size: {
      type: Number | String
    },
    color: {
      type: String
    },
    round: {
      type: Boolean,
      default: false
    },
    classPrefix: {
      type: String,
      default: 'mx-icon'
    },
    theme: {
      type: String
    },
    offset: {
      type: Array
    }
  },
  computed: {
    imgCls: function imgCls() {
      return icon_namespace.derive('img');
    },
    isImgIcon: function isImgIcon() {
      return this.name.includes('/');
    },
    style: function style() {
      var style = {};

      if (this.color) {
        style[this.isImgIcon ? 'backgroundColor' : 'color'] = this.color;
      }

      if (this.size) {
        style.fontSize = "".concat(this.size, "px");
      }

      if (this.round) {
        style.borderRadius = '50%';
      }

      return style;
    }
  },
  methods: {
    onClick: function onClick(e) {
      this.$emit('click', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var _this$$props = this.$props,
        tag = _this$$props.tag,
        dot = _this$$props.dot,
        badge = _this$$props.badge,
        name = _this$$props.name,
        classPrefix = _this$$props.classPrefix;

    var renderIcon = function renderIcon() {
      return h(tag, {
        "class": [classPrefix, _this.isImgIcon ? '' : "".concat(classPrefix, "-").concat(name), _this.isImgIcon && 'mx-icon--img', _this.theme && "mx-icon--".concat(_this.theme)],
        "style": _this.style,
        "on": {
          "click": _this.onClick
        }
      }, [_this.isImgIcon && h("img", {
        "class": _this.imgCls,
        "attrs": {
          "src": name
        }
      })]);
    };

    if (dot || badge) {
      return h(badge_badge, {
        "attrs": {
          "dot": dot,
          "content": badge,
          "offset": this.offset,
          "small": true
        }
      }, [renderIcon()]);
    }

    return renderIcon();
  }
});
// EXTERNAL MODULE: ./src/packages/icon/icon.scss
var icon_icon = __webpack_require__(10);

// CONCATENATED MODULE: ./src/packages/icon/index.js



vue_VueExtension.WithInstall(icon);
/* harmony default export */ var packages_icon = (icon);
// CONCATENATED MODULE: ./src/utils/extensions/dom.js


var dom_DOMExtension = /*#__PURE__*/function () {
  function DOMExtension() {
    classCallCheck_default()(this, DOMExtension);
  }

  createClass_default()(DOMExtension, null, [{
    key: "IsWindow",
    value: function IsWindow(el) {
      return el === window;
    }
  }, {
    key: "IsElement",
    value: function IsElement(node) {
      return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.ELEMENT_NODE;
    }
  }, {
    key: "IsHidden",
    value: function IsHidden(el) {
      if (el) {
        return false;
      }

      var style = widnow.getComputedStyle(el);
      var isHidden = style.getPropertyValue('display') === 'none';
      var isParentHidden = el.offsetParent === null && style.getPropertyValue('position') !== 'fixed';
      return isHidden || isParentHidden;
    }
  }, {
    key: "GetScrollTop",
    value: function GetScrollTop(el) {
      return Math.max('scrollTop' in el ? el.scrollTop : el.scrollY, 0);
    }
  }, {
    key: "GetBoundingClientRect",
    value: function GetBoundingClientRect(el) {
      if (el !== null && el !== void 0 && el.getBoundingClientRect) {
        return el.getBoundingClientRect();
      }

      if (this.IsWindow(el)) {
        return new DOMRect(0, 0, el.innerWidth, el.innerHeight);
      }

      return new DOMRect(0, 0, 0, 0);
    }
  }, {
    key: "GetScrollParent",
    value: function GetScrollParent(el) {
      var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
      var node = el;

      while (node && node !== root && this.IsElement(node)) {
        var overflowY = window.getComputedStyle(node).getPropertyValue('overflow-y');

        if (/scroll|auto/i.test(overflowY) && node.scrollHeight > node.offsetHeight) {
          return node;
        }

        node = node.parentNode;
      }

      return root;
    }
  }, {
    key: "stopPropagation",
    value: function stopPropagation(e) {
      e === null || e === void 0 ? void 0 : e.stopPropagation();
    }
  }, {
    key: "PreventDefault",
    value: function PreventDefault(e) {
      var stopPropagation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

      if (typeof (e === null || e === void 0 ? void 0 : e.cancelable) !== 'boolean' || e !== null && e !== void 0 && e.cancelable) {
        e.preventDefault();
      }

      if (stopPropagation) {
        e.stopPropagation();
      }
    }
  }, {
    key: "AddEventListener",
    value: function AddEventListener(target, type, listener, options) {
      if (!target || !(target instanceof EventTarget)) {
        return;
      }

      target.addEventListener(type, listener, options);
    }
  }, {
    key: "RemoveEventListener",
    value: function RemoveEventListener(target, type, listener) {
      if (!target || !(target instanceof EventTarget)) {
        return;
      }

      target.removeEventListener(type, listener);
    }
  }]);

  return DOMExtension;
}();
// CONCATENATED MODULE: ./src/packages/switch/switch.jsx


var switch_namespace = namespace_Namespace.Create('switch');
/* harmony default export */ var switch_switch = ({
  name: switch_namespace.name,
  props: {
    theme: {
      type: String,
      default: 'brand'
    },
    value: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    loading: {
      type: Boolean,
      default: false
    },
    color: {
      type: String,
      default: ''
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  computed: {
    cls: function cls() {
      return switch_namespace.derive([this.theme, {
        disabled: this.disabled,
        active: this.value
      }]);
    },
    style: function style() {
      var style = {};

      if (this.value && this.color) {
        style.backgroundColor = this.color;
        style.borderColor = this.color;
      }

      return style;
    },
    circleCls: function circleCls() {
      return switch_namespace.derive('circle', {
        active: this.value
      });
    }
  },
  methods: {
    toggle: function toggle(e) {
      dom_DOMExtension.StopPropogation(e);

      if (this.disabled) {
        return;
      }

      this.$emit('change', !this.value);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("div", {
      "class": this.cls,
      "style": this.style,
      "on": {
        "click": function click($event) {
          $event.stopPropagation();
          return _this.toggle($event);
        }
      }
    }, [h("div", {
      "class": this.circleCls
    })]);
  }
});
// EXTERNAL MODULE: ./src/packages/switch/switch.scss
var packages_switch_switch = __webpack_require__(11);

// CONCATENATED MODULE: ./src/packages/switch/index.js



vue_VueExtension.WithInstall(switch_switch);
/* harmony default export */ var packages_switch = (switch_switch);
// CONCATENATED MODULE: ./src/packages/loading/loading.jsx

var loading_namespace = namespace_Namespace.Create('loading');
/* harmony default export */ var loading = ({
  name: loading_namespace.name,
  props: {
    type: {
      type: String,
      default: 'circular'
    },
    size: {
      type: Number | String
    },
    theme: {
      type: String,
      default: 'loading-gray'
    },
    color: {
      type: String
    },
    textColor: {
      type: String
    },
    textSize: {
      type: Number | String
    },
    vertical: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    cls: function cls() {
      return loading_namespace.derive([this.theme, {
        vertical: this.vertical
      }]);
    },
    spinnerCls: function spinnerCls() {
      return loading_namespace.derive('spinner', [this.type]);
    },
    spinnerStyle: function spinnerStyle() {
      var style = {};

      if (this.color) {
        style.color = this.color;
      }

      if (this.size) {
        style.width = "".concat(this.size, "px");
        style.height = "".concat(this.size, "px");
      }

      return style;
    },
    textCls: function textCls() {
      return loading_namespace.derive('text', {
        vertical: this.vertical
      });
    },
    textStyle: function textStyle() {
      var _this$textColor;

      var style = {};
      style.color = (_this$textColor = this.textColor) !== null && _this$textColor !== void 0 ? _this$textColor : this.color;

      if (this.textSize) {
        style.fontSize = "".concat(this.textSize, "px");
      }

      return style;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var Circular = h("svg", {
      "class": loading_namespace.derive('circular'),
      "attrs": {
        "viewBox": "25 25 50 50"
      }
    }, [h("circle", {
      "attrs": {
        "cx": "50",
        "cy": "50",
        "r": "20",
        "fill": "none"
      }
    })]);
    var Spinner = Array(8).fill(null).map(function (_, index) {
      return h("i", {
        "class": loading_namespace.derive('line', [String(index + 1)])
      });
    });

    var renderText = function renderText() {
      if (_this.$slots.default) {
        return h("span", {
          "class": _this.textCls,
          "style": _this.textStyle
        }, [_this.$slots.default]);
      }
    };

    return h("div", {
      "class": this.cls
    }, [h("span", {
      "class": this.spinnerCls,
      "style": this.spinnerStyle
    }, [this.type === 'circular' && Circular, this.type === 'spinner' && Spinner]), renderText()]);
  }
});
// CONCATENATED MODULE: ./src/packages/button/button.jsx




var button_namespace = namespace_Namespace.Create('button');
/* harmony default export */ var button_button = ({
  name: button_namespace.name,
  components: {
    Icon: icon,
    Loading: loading
  },
  props: {
    tag: {
      type: String,
      default: 'button'
    },
    type: {
      type: String,
      default: 'fill'
    },
    theme: {
      type: String,
      default: 'brand'
    },
    size: {
      type: String,
      default: 'middle'
    },
    color: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: ''
    },
    iconPrefix: {
      type: String
    },
    disabled: {
      type: Boolean,
      default: false
    },
    loading: {
      type: Boolean,
      default: false
    },
    round: {
      type: Boolean,
      default: true
    },
    iconPosition: {
      type: String,
      default: 'left'
    },
    loadingType: {
      type: String,
      default: 'spinner'
    }
  },
  data: function data() {
    return {
      active: false
    };
  },
  computed: {
    cls: function cls() {
      return button_namespace.derive([this.theme, this.type, this.size, {
        round: this.round,
        disabled: this.disabled,
        active: this.active,
        loading: this.loading
      }]);
    },
    iconCls: function iconCls() {
      return button_namespace.derive('icon', [this.size, this.iconPosition]);
    },
    loadingCls: function loadingCls() {
      return button_namespace.derive('loading', [this.iconPosition]);
    },
    style: function style() {
      var style = {};

      if (this.color) {
        var color = color_Color.FromHex(this.color);

        switch (this.type) {
          case 'fill':
            style.color = color.isDark ? color_Color.WHITE : color_Color.BLACK;
            style.backgroundColor = this.active ? color_Color.Shift(color, 0.1) : color;
            break;

          case 'weak':
            var background = color_Color.Shift(color, -0.85);
            style.color = color;
            style.backgroundColor = this.active ? color_Color.Shift(background, 0.1) : background;
            break;

          case 'plain':
            style.color = color;
            style.borderColor = color;
            this.active && (style.backgroundColor = color_Color.Shift(color, -0.85));
            break;

          case 'text':
            style.color = this.active ? color_Color.Shift(color, 0.1) : color;
            break;
        }
      }

      return style;
    }
  },
  methods: {
    onClick: function onClick(e) {
      if (this.loading || this.disabled) {
        return;
      }

      this.$emit('click', e);
    },
    onTouchStart: function onTouchStart() {
      if (this.loading || this.disabled) {
        return;
      }

      this.active = true;
    },
    onTouchEnd: function onTouchEnd() {
      if (this.loading || this.disabled) {
        return;
      }

      this.active = false;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderLoading = function renderLoading() {
      if (_this.$slots.loading) {
        return _this.$slots.loading;
      }

      return h(loading, {
        "class": _this.loadingCls,
        "attrs": {
          "type": _this.loadingType,
          "size": 18
        }
      });
    };

    var renderIcon = function renderIcon() {
      if (_this.loading) {
        return renderLoading();
      }

      if (_this.icon) {
        return h(icon, {
          "attrs": {
            "name": _this.icon,
            "classPrefix": _this.iconPrefix
          },
          "class": _this.iconCls
        });
      }
    };

    var tag = this.$props.tag;
    return h(tag, {
      "class": this.cls,
      "style": this.style,
      "on": {
        "click": this.onClick,
        "touchstart": this.onTouchStart,
        "touchend": this.onTouchEnd,
        "touchcancel": this.onTouchEnd
      }
    }, [this.iconPosition === 'left' && renderIcon(), this.$slots.default, this.iconPosition === 'right' && renderIcon()]);
  }
});
// EXTERNAL MODULE: ./src/packages/button/button.scss
var packages_button_button = __webpack_require__(12);

// CONCATENATED MODULE: ./src/packages/button/index.js



vue_VueExtension.WithInstall(button_button);
/* harmony default export */ var packages_button = (button_button);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/packages/buttongroup/buttongroup.vue?vue&type=template&id=729b14f3&
var buttongroupvue_type_template_id_729b14f3_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.cls},[_vm._t("default")],2)}
var staticRenderFns = []


// CONCATENATED MODULE: ./src/packages/buttongroup/buttongroup.vue?vue&type=template&id=729b14f3&

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/packages/buttongroup/buttongroup.vue?vue&type=script&lang=js&
//
//
//
//
//
/* harmony default export */ var buttongroupvue_type_script_lang_js_ = ({
  name: 'mx-button-group',
  props: {
    shape: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: ''
    }
  },
  data: function data() {
    return {
      cls: ''
    };
  },
  mounted: function mounted() {
    this.cls = "mx-button-group ".concat(this.shape, " ").concat(this.type);
  }
});
// CONCATENATED MODULE: ./src/packages/buttongroup/buttongroup.vue?vue&type=script&lang=js&
 /* harmony default export */ var buttongroup_buttongroupvue_type_script_lang_js_ = (buttongroupvue_type_script_lang_js_); 
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* globals __VUE_SSR_CONTEXT__ */

// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.

function normalizeComponent (
  scriptExports,
  render,
  staticRenderFns,
  functionalTemplate,
  injectStyles,
  scopeId,
  moduleIdentifier, /* server only */
  shadowMode /* vue-cli only */
) {
  // Vue.extend constructor export interop
  var options = typeof scriptExports === 'function'
    ? scriptExports.options
    : scriptExports

  // render functions
  if (render) {
    options.render = render
    options.staticRenderFns = staticRenderFns
    options._compiled = true
  }

  // functional template
  if (functionalTemplate) {
    options.functional = true
  }

  // scopedId
  if (scopeId) {
    options._scopeId = 'data-v-' + scopeId
  }

  var hook
  if (moduleIdentifier) { // server build
    hook = function (context) {
      // 2.3 injection
      context =
        context || // cached call
        (this.$vnode && this.$vnode.ssrContext) || // stateful
        (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
      // 2.2 with runInNewContext: true
      if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
        context = __VUE_SSR_CONTEXT__
      }
      // inject component styles
      if (injectStyles) {
        injectStyles.call(this, context)
      }
      // register component module identifier for async chunk inferrence
      if (context && context._registeredComponents) {
        context._registeredComponents.add(moduleIdentifier)
      }
    }
    // used by ssr in case component is cached and beforeCreate
    // never gets called
    options._ssrRegister = hook
  } else if (injectStyles) {
    hook = shadowMode
      ? function () {
        injectStyles.call(
          this,
          (options.functional ? this.parent : this).$root.$options.shadowRoot
        )
      }
      : injectStyles
  }

  if (hook) {
    if (options.functional) {
      // for template-only hot-reload because in that case the render fn doesn't
      // go through the normalizer
      options._injectStyles = hook
      // register for functional component in vue file
      var originalRender = options.render
      options.render = function renderWithStyleInjection (h, context) {
        hook.call(context)
        return originalRender(h, context)
      }
    } else {
      // inject component registration as beforeCreate hook
      var existing = options.beforeCreate
      options.beforeCreate = existing
        ? [].concat(existing, hook)
        : [hook]
    }
  }

  return {
    exports: scriptExports,
    options: options
  }
}

// CONCATENATED MODULE: ./src/packages/buttongroup/buttongroup.vue





/* normalize component */

var buttongroup_component = normalizeComponent(
  buttongroup_buttongroupvue_type_script_lang_js_,
  buttongroupvue_type_template_id_729b14f3_render,
  staticRenderFns,
  false,
  null,
  null,
  null
  
)

/* harmony default export */ var buttongroup = (buttongroup_component.exports);
// EXTERNAL MODULE: ./src/packages/buttongroup/buttongroup.scss
var buttongroup_buttongroup = __webpack_require__(13);

// CONCATENATED MODULE: ./src/packages/buttongroup/index.js



buttongroup.install = function (Vue) {
  Vue.component(buttongroup.name, buttongroup);
};

/* harmony default export */ var packages_buttongroup = (buttongroup);
// CONCATENATED MODULE: ./node_modules/vue-lazyload/vue-lazyload.esm.js
/*!
 * Vue-Lazyload.js v1.3.3
 * (c) 2019 Awe <hilongjw@gmail.com>
 * Released under the MIT License.
 */
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  return typeof obj;
} : function (obj) {
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};











var vue_lazyload_esm_classCallCheck = function (instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};

var vue_lazyload_esm_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;
  };
}();

/*!
 * is-primitive <https://github.com/jonschlinkert/is-primitive>
 *
 * Copyright (c) 2014-2015, Jon Schlinkert.
 * Licensed under the MIT License.
 */

// see http://jsperf.com/testing-value-is-primitive/7

var isPrimitive = function isPrimitive(value) {
  return value == null || typeof value !== 'function' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object';
};

/*!
 * assign-symbols <https://github.com/jonschlinkert/assign-symbols>
 *
 * Copyright (c) 2015, Jon Schlinkert.
 * Licensed under the MIT License.
 */

var assignSymbols = function assignSymbols(receiver, objects) {
  if (receiver === null || typeof receiver === 'undefined') {
    throw new TypeError('expected first argument to be an object.');
  }

  if (typeof objects === 'undefined' || typeof Symbol === 'undefined') {
    return receiver;
  }

  if (typeof Object.getOwnPropertySymbols !== 'function') {
    return receiver;
  }

  var isEnumerable = Object.prototype.propertyIsEnumerable;
  var target = Object(receiver);
  var len = arguments.length,
      i = 0;

  while (++i < len) {
    var provider = Object(arguments[i]);
    var names = Object.getOwnPropertySymbols(provider);

    for (var j = 0; j < names.length; j++) {
      var key = names[j];

      if (isEnumerable.call(provider, key)) {
        target[key] = provider[key];
      }
    }
  }
  return target;
};

var vue_lazyload_esm_toString = Object.prototype.toString;

/**
 * Get the native `typeof` a value.
 *
 * @param  {*} `val`
 * @return {*} Native javascript type
 */

var kindOf = function kindOf(val) {
  var type = typeof val === 'undefined' ? 'undefined' : _typeof(val);

  // primitivies
  if (type === 'undefined') {
    return 'undefined';
  }
  if (val === null) {
    return 'null';
  }
  if (val === true || val === false || val instanceof Boolean) {
    return 'boolean';
  }
  if (type === 'string' || val instanceof String) {
    return 'string';
  }
  if (type === 'number' || val instanceof Number) {
    return 'number';
  }

  // functions
  if (type === 'function' || val instanceof Function) {
    if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') {
      return 'generatorfunction';
    }
    return 'function';
  }

  // array
  if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
    return 'array';
  }

  // check for instances of RegExp and Date before calling `toString`
  if (val instanceof RegExp) {
    return 'regexp';
  }
  if (val instanceof Date) {
    return 'date';
  }

  // other objects
  type = vue_lazyload_esm_toString.call(val);

  if (type === '[object RegExp]') {
    return 'regexp';
  }
  if (type === '[object Date]') {
    return 'date';
  }
  if (type === '[object Arguments]') {
    return 'arguments';
  }
  if (type === '[object Error]') {
    return 'error';
  }
  if (type === '[object Promise]') {
    return 'promise';
  }

  // buffer
  if (isBuffer(val)) {
    return 'buffer';
  }

  // es6: Map, WeakMap, Set, WeakSet
  if (type === '[object Set]') {
    return 'set';
  }
  if (type === '[object WeakSet]') {
    return 'weakset';
  }
  if (type === '[object Map]') {
    return 'map';
  }
  if (type === '[object WeakMap]') {
    return 'weakmap';
  }
  if (type === '[object Symbol]') {
    return 'symbol';
  }

  if (type === '[object Map Iterator]') {
    return 'mapiterator';
  }
  if (type === '[object Set Iterator]') {
    return 'setiterator';
  }
  if (type === '[object String Iterator]') {
    return 'stringiterator';
  }
  if (type === '[object Array Iterator]') {
    return 'arrayiterator';
  }

  // typed arrays
  if (type === '[object Int8Array]') {
    return 'int8array';
  }
  if (type === '[object Uint8Array]') {
    return 'uint8array';
  }
  if (type === '[object Uint8ClampedArray]') {
    return 'uint8clampedarray';
  }
  if (type === '[object Int16Array]') {
    return 'int16array';
  }
  if (type === '[object Uint16Array]') {
    return 'uint16array';
  }
  if (type === '[object Int32Array]') {
    return 'int32array';
  }
  if (type === '[object Uint32Array]') {
    return 'uint32array';
  }
  if (type === '[object Float32Array]') {
    return 'float32array';
  }
  if (type === '[object Float64Array]') {
    return 'float64array';
  }

  // must be a plain object
  return 'object';
};

/**
 * If you need to support Safari 5-7 (8-10 yr-old browser),
 * take a look at https://github.com/feross/is-buffer
 */

function isBuffer(val) {
  return val.constructor && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
}

function vue_lazyload_esm_assign(target /*, objects*/) {
  target = target || {};
  var len = arguments.length,
      i = 0;
  if (len === 1) {
    return target;
  }
  while (++i < len) {
    var val = arguments[i];
    if (isPrimitive(target)) {
      target = val;
    }
    if (isObject$1(val)) {
      extend(target, val);
    }
  }
  return target;
}

/**
 * Shallow extend
 */

function extend(target, obj) {
  assignSymbols(target, obj);

  for (var key in obj) {
    if (key !== '__proto__' && hasOwn(obj, key)) {
      var val = obj[key];
      if (isObject$1(val)) {
        if (kindOf(target[key]) === 'undefined' && kindOf(val) === 'function') {
          target[key] = val;
        }
        target[key] = vue_lazyload_esm_assign(target[key] || {}, val);
      } else {
        target[key] = val;
      }
    }
  }
  return target;
}

/**
 * Returns true if the object is a plain object or a function.
 */

function isObject$1(obj) {
  return kindOf(obj) === 'object' || kindOf(obj) === 'function';
}

/**
 * Returns true if the given `key` is an own property of `obj`.
 */

function hasOwn(obj, key) {
  return Object.prototype.hasOwnProperty.call(obj, key);
}

/**
 * Expose `assign`
 */

var assignDeep = vue_lazyload_esm_assign;

var inBrowser = typeof window !== 'undefined';
var hasIntersectionObserver = checkIntersectionObserver();

function checkIntersectionObserver() {
  if (inBrowser && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
    // Minimal polyfill for Edge 15's lack of `isIntersecting`
    // See: https://github.com/w3c/IntersectionObserver/issues/211
    if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
      Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
        get: function get$$1() {
          return this.intersectionRatio > 0;
        }
      });
    }
    return true;
  }
  return false;
}

var modeType = {
  event: 'event',
  observer: 'observer'

  // CustomEvent polyfill
};var CustomEvent = function () {
  if (!inBrowser) return;
  if (typeof window.CustomEvent === 'function') return window.CustomEvent;
  function CustomEvent(event, params) {
    params = params || { bubbles: false, cancelable: false, detail: undefined };
    var evt = document.createEvent('CustomEvent');
    evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
    return evt;
  }
  CustomEvent.prototype = window.Event.prototype;
  return CustomEvent;
}();

function remove(arr, item) {
  if (!arr.length) return;
  var index = arr.indexOf(item);
  if (index > -1) return arr.splice(index, 1);
}

function some(arr, fn) {
  var has = false;
  for (var i = 0, len = arr.length; i < len; i++) {
    if (fn(arr[i])) {
      has = true;
      break;
    }
  }
  return has;
}

function getBestSelectionFromSrcset(el, scale) {
  if (el.tagName !== 'IMG' || !el.getAttribute('data-srcset')) return;

  var options = el.getAttribute('data-srcset');
  var result = [];
  var container = el.parentNode;
  var containerWidth = container.offsetWidth * scale;

  var spaceIndex = void 0;
  var tmpSrc = void 0;
  var tmpWidth = void 0;

  options = options.trim().split(',');

  options.map(function (item) {
    item = item.trim();
    spaceIndex = item.lastIndexOf(' ');
    if (spaceIndex === -1) {
      tmpSrc = item;
      tmpWidth = 999998;
    } else {
      tmpSrc = item.substr(0, spaceIndex);
      tmpWidth = parseInt(item.substr(spaceIndex + 1, item.length - spaceIndex - 2), 10);
    }
    result.push([tmpWidth, tmpSrc]);
  });

  result.sort(function (a, b) {
    if (a[0] < b[0]) {
      return 1;
    }
    if (a[0] > b[0]) {
      return -1;
    }
    if (a[0] === b[0]) {
      if (b[1].indexOf('.webp', b[1].length - 5) !== -1) {
        return 1;
      }
      if (a[1].indexOf('.webp', a[1].length - 5) !== -1) {
        return -1;
      }
    }
    return 0;
  });
  var bestSelectedSrc = '';
  var tmpOption = void 0;

  for (var i = 0; i < result.length; i++) {
    tmpOption = result[i];
    bestSelectedSrc = tmpOption[1];
    var next = result[i + 1];
    if (next && next[0] < containerWidth) {
      bestSelectedSrc = tmpOption[1];
      break;
    } else if (!next) {
      bestSelectedSrc = tmpOption[1];
      break;
    }
  }

  return bestSelectedSrc;
}

function find(arr, fn) {
  var item = void 0;
  for (var i = 0, len = arr.length; i < len; i++) {
    if (fn(arr[i])) {
      item = arr[i];
      break;
    }
  }
  return item;
}

var getDPR = function getDPR() {
  var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  return inBrowser ? window.devicePixelRatio || scale : scale;
};

function supportWebp() {
  if (!inBrowser) return false;

  var support = true;
  var d = document;

  try {
    var el = d.createElement('object');
    el.type = 'image/webp';
    el.style.visibility = 'hidden';
    el.innerHTML = '!';
    d.body.appendChild(el);
    support = !el.offsetWidth;
    d.body.removeChild(el);
  } catch (err) {
    support = false;
  }

  return support;
}

function throttle(action, delay) {
  var timeout = null;
  var lastRun = 0;
  return function () {
    if (timeout) {
      return;
    }
    var elapsed = Date.now() - lastRun;
    var context = this;
    var args = arguments;
    var runCallback = function runCallback() {
      lastRun = Date.now();
      timeout = false;
      action.apply(context, args);
    };
    if (elapsed >= delay) {
      runCallback();
    } else {
      timeout = setTimeout(runCallback, delay);
    }
  };
}

function testSupportsPassive() {
  if (!inBrowser) return;
  var support = false;
  try {
    var opts = Object.defineProperty({}, 'passive', {
      get: function get$$1() {
        support = true;
      }
    });
    window.addEventListener('test', null, opts);
  } catch (e) {}
  return support;
}

var supportsPassive = testSupportsPassive();

var _ = {
  on: function on(el, type, func) {
    var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

    if (supportsPassive) {
      el.addEventListener(type, func, {
        capture: capture,
        passive: true
      });
    } else {
      el.addEventListener(type, func, capture);
    }
  },
  off: function off(el, type, func) {
    var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

    el.removeEventListener(type, func, capture);
  }
};

var loadImageAsync = function loadImageAsync(item, resolve, reject) {
  var image = new Image();
  if (!item || !item.src) {
    var err = new Error('image src is required');
    return reject(err);
  }

  image.src = item.src;

  image.onload = function () {
    resolve({
      naturalHeight: image.naturalHeight,
      naturalWidth: image.naturalWidth,
      src: image.src
    });
  };

  image.onerror = function (e) {
    reject(e);
  };
};

var vue_lazyload_esm_style = function style(el, prop) {
  return typeof getComputedStyle !== 'undefined' ? getComputedStyle(el, null).getPropertyValue(prop) : el.style[prop];
};

var overflow = function overflow(el) {
  return vue_lazyload_esm_style(el, 'overflow') + vue_lazyload_esm_style(el, 'overflow-y') + vue_lazyload_esm_style(el, 'overflow-x');
};

var scrollParent = function scrollParent(el) {
  if (!inBrowser) return;
  if (!(el instanceof HTMLElement)) {
    return window;
  }

  var parent = el;

  while (parent) {
    if (parent === document.body || parent === document.documentElement) {
      break;
    }

    if (!parent.parentNode) {
      break;
    }

    if (/(scroll|auto)/.test(overflow(parent))) {
      return parent;
    }

    parent = parent.parentNode;
  }

  return window;
};

function isObject(obj) {
  return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
}

function ObjectKeys(obj) {
  if (!(obj instanceof Object)) return [];
  if (Object.keys) {
    return Object.keys(obj);
  } else {
    var keys = [];
    for (var key in obj) {
      if (obj.hasOwnProperty(key)) {
        keys.push(key);
      }
    }
    return keys;
  }
}

function ArrayFrom(arrLike) {
  var len = arrLike.length;
  var list = [];
  for (var i = 0; i < len; i++) {
    list.push(arrLike[i]);
  }
  return list;
}

function noop() {}

var ImageCache = function () {
  function ImageCache(_ref) {
    var max = _ref.max;
    vue_lazyload_esm_classCallCheck(this, ImageCache);

    this.options = {
      max: max || 100
    };
    this._caches = [];
  }

  vue_lazyload_esm_createClass(ImageCache, [{
    key: 'has',
    value: function has(key) {
      return this._caches.indexOf(key) > -1;
    }
  }, {
    key: 'add',
    value: function add(key) {
      if (this.has(key)) return;
      this._caches.push(key);
      if (this._caches.length > this.options.max) {
        this.free();
      }
    }
  }, {
    key: 'free',
    value: function free() {
      this._caches.shift();
    }
  }]);
  return ImageCache;
}();

// el: {
//     state,
//     src,
//     error,
//     loading
// }

var ReactiveListener = function () {
  function ReactiveListener(_ref) {
    var el = _ref.el,
        src = _ref.src,
        error = _ref.error,
        loading = _ref.loading,
        bindType = _ref.bindType,
        $parent = _ref.$parent,
        options = _ref.options,
        elRenderer = _ref.elRenderer,
        imageCache = _ref.imageCache;
    vue_lazyload_esm_classCallCheck(this, ReactiveListener);

    this.el = el;
    this.src = src;
    this.error = error;
    this.loading = loading;
    this.bindType = bindType;
    this.attempt = 0;

    this.naturalHeight = 0;
    this.naturalWidth = 0;

    this.options = options;

    this.rect = null;

    this.$parent = $parent;
    this.elRenderer = elRenderer;
    this._imageCache = imageCache;
    this.performanceData = {
      init: Date.now(),
      loadStart: 0,
      loadEnd: 0
    };

    this.filter();
    this.initState();
    this.render('loading', false);
  }

  /*
   * init listener state
   * @return
   */


  vue_lazyload_esm_createClass(ReactiveListener, [{
    key: 'initState',
    value: function initState() {
      if ('dataset' in this.el) {
        this.el.dataset.src = this.src;
      } else {
        this.el.setAttribute('data-src', this.src);
      }

      this.state = {
        loading: false,
        error: false,
        loaded: false,
        rendered: false
      };
    }

    /*
     * record performance
     * @return
     */

  }, {
    key: 'record',
    value: function record(event) {
      this.performanceData[event] = Date.now();
    }

    /*
     * update image listener data
     * @param  {String} image uri
     * @param  {String} loading image uri
     * @param  {String} error image uri
     * @return
     */

  }, {
    key: 'update',
    value: function update(_ref2) {
      var src = _ref2.src,
          loading = _ref2.loading,
          error = _ref2.error;

      var oldSrc = this.src;
      this.src = src;
      this.loading = loading;
      this.error = error;
      this.filter();
      if (oldSrc !== this.src) {
        this.attempt = 0;
        this.initState();
      }
    }

    /*
     * get el node rect
     * @return
     */

  }, {
    key: 'getRect',
    value: function getRect() {
      this.rect = this.el.getBoundingClientRect();
    }

    /*
     *  check el is in view
     * @return {Boolean} el is in view
     */

  }, {
    key: 'checkInView',
    value: function checkInView() {
      this.getRect();
      return this.rect.top < window.innerHeight * this.options.preLoad && this.rect.bottom > this.options.preLoadTop && this.rect.left < window.innerWidth * this.options.preLoad && this.rect.right > 0;
    }

    /*
     * listener filter
     */

  }, {
    key: 'filter',
    value: function filter() {
      var _this = this;

      ObjectKeys(this.options.filter).map(function (key) {
        _this.options.filter[key](_this, _this.options);
      });
    }

    /*
     * render loading first
     * @params cb:Function
     * @return
     */

  }, {
    key: 'renderLoading',
    value: function renderLoading(cb) {
      var _this2 = this;

      this.state.loading = true;
      loadImageAsync({
        src: this.loading
      }, function (data) {
        _this2.render('loading', false);
        _this2.state.loading = false;
        cb();
      }, function () {
        // handler `loading image` load failed
        cb();
        _this2.state.loading = false;
        if (!_this2.options.silent) console.warn('VueLazyload log: load failed with loading image(' + _this2.loading + ')');
      });
    }

    /*
     * try load image and  render it
     * @return
     */

  }, {
    key: 'load',
    value: function load() {
      var _this3 = this;

      var onFinish = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;

      if (this.attempt > this.options.attempt - 1 && this.state.error) {
        if (!this.options.silent) console.log('VueLazyload log: ' + this.src + ' tried too more than ' + this.options.attempt + ' times');
        onFinish();
        return;
      }
      if (this.state.rendered && this.state.loaded) return;
      if (this._imageCache.has(this.src)) {
        this.state.loaded = true;
        this.render('loaded', true);
        this.state.rendered = true;
        return onFinish();
      }

      this.renderLoading(function () {
        _this3.attempt++;

        _this3.options.adapter['beforeLoad'] && _this3.options.adapter['beforeLoad'](_this3, _this3.options);
        _this3.record('loadStart');

        loadImageAsync({
          src: _this3.src
        }, function (data) {
          _this3.naturalHeight = data.naturalHeight;
          _this3.naturalWidth = data.naturalWidth;
          _this3.state.loaded = true;
          _this3.state.error = false;
          _this3.record('loadEnd');
          _this3.render('loaded', false);
          _this3.state.rendered = true;
          _this3._imageCache.add(_this3.src);
          onFinish();
        }, function (err) {
          !_this3.options.silent && console.error(err);
          _this3.state.error = true;
          _this3.state.loaded = false;
          _this3.render('error', false);
        });
      });
    }

    /*
     * render image
     * @param  {String} state to render // ['loading', 'src', 'error']
     * @param  {String} is form cache
     * @return
     */

  }, {
    key: 'render',
    value: function render(state, cache) {
      this.elRenderer(this, state, cache);
    }

    /*
     * output performance data
     * @return {Object} performance data
     */

  }, {
    key: 'performance',
    value: function performance() {
      var state = 'loading';
      var time = 0;

      if (this.state.loaded) {
        state = 'loaded';
        time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1000;
      }

      if (this.state.error) state = 'error';

      return {
        src: this.src,
        state: state,
        time: time
      };
    }

    /*
     * $destroy
     * @return
     */

  }, {
    key: '$destroy',
    value: function $destroy() {
      this.el = null;
      this.src = null;
      this.error = null;
      this.loading = null;
      this.bindType = null;
      this.attempt = 0;
    }
  }]);
  return ReactiveListener;
}();

var DEFAULT_URL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
var DEFAULT_EVENTS = ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove'];
var DEFAULT_OBSERVER_OPTIONS = {
  rootMargin: '0px',
  threshold: 0
};

var Lazy = function (Vue) {
  return function () {
    function Lazy(_ref) {
      var preLoad = _ref.preLoad,
          error = _ref.error,
          throttleWait = _ref.throttleWait,
          preLoadTop = _ref.preLoadTop,
          dispatchEvent = _ref.dispatchEvent,
          loading = _ref.loading,
          attempt = _ref.attempt,
          _ref$silent = _ref.silent,
          silent = _ref$silent === undefined ? true : _ref$silent,
          scale = _ref.scale,
          listenEvents = _ref.listenEvents,
          hasbind = _ref.hasbind,
          filter = _ref.filter,
          adapter = _ref.adapter,
          observer = _ref.observer,
          observerOptions = _ref.observerOptions;
      vue_lazyload_esm_classCallCheck(this, Lazy);

      this.version = '1.3.3';
      this.mode = modeType.event;
      this.ListenerQueue = [];
      this.TargetIndex = 0;
      this.TargetQueue = [];
      this.options = {
        silent: silent,
        dispatchEvent: !!dispatchEvent,
        throttleWait: throttleWait || 200,
        preLoad: preLoad || 1.3,
        preLoadTop: preLoadTop || 0,
        error: error || DEFAULT_URL,
        loading: loading || DEFAULT_URL,
        attempt: attempt || 3,
        scale: scale || getDPR(scale),
        ListenEvents: listenEvents || DEFAULT_EVENTS,
        hasbind: false,
        supportWebp: supportWebp(),
        filter: filter || {},
        adapter: adapter || {},
        observer: !!observer,
        observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
      };
      this._initEvent();
      this._imageCache = new ImageCache({ max: 200 });
      this.lazyLoadHandler = throttle(this._lazyLoadHandler.bind(this), this.options.throttleWait);

      this.setMode(this.options.observer ? modeType.observer : modeType.event);
    }

    /**
     * update config
     * @param  {Object} config params
     * @return
     */


    vue_lazyload_esm_createClass(Lazy, [{
      key: 'config',
      value: function config() {
        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

        assignDeep(this.options, options);
      }

      /**
       * output listener's load performance
       * @return {Array}
       */

    }, {
      key: 'performance',
      value: function performance() {
        var list = [];

        this.ListenerQueue.map(function (item) {
          list.push(item.performance());
        });

        return list;
      }

      /*
       * add lazy component to queue
       * @param  {Vue} vm lazy component instance
       * @return
       */

    }, {
      key: 'addLazyBox',
      value: function addLazyBox(vm) {
        this.ListenerQueue.push(vm);
        if (inBrowser) {
          this._addListenerTarget(window);
          this._observer && this._observer.observe(vm.el);
          if (vm.$el && vm.$el.parentNode) {
            this._addListenerTarget(vm.$el.parentNode);
          }
        }
      }

      /*
       * add image listener to queue
       * @param  {DOM} el
       * @param  {object} binding vue directive binding
       * @param  {vnode} vnode vue directive vnode
       * @return
       */

    }, {
      key: 'add',
      value: function add(el, binding, vnode) {
        var _this = this;

        if (some(this.ListenerQueue, function (item) {
          return item.el === el;
        })) {
          this.update(el, binding);
          return Vue.nextTick(this.lazyLoadHandler);
        }

        var _valueFormatter2 = this._valueFormatter(binding.value),
            src = _valueFormatter2.src,
            loading = _valueFormatter2.loading,
            error = _valueFormatter2.error;

        Vue.nextTick(function () {
          src = getBestSelectionFromSrcset(el, _this.options.scale) || src;
          _this._observer && _this._observer.observe(el);

          var container = Object.keys(binding.modifiers)[0];
          var $parent = void 0;

          if (container) {
            $parent = vnode.context.$refs[container];
            // if there is container passed in, try ref first, then fallback to getElementById to support the original usage
            $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
          }

          if (!$parent) {
            $parent = scrollParent(el);
          }

          var newListener = new ReactiveListener({
            bindType: binding.arg,
            $parent: $parent,
            el: el,
            loading: loading,
            error: error,
            src: src,
            elRenderer: _this._elRenderer.bind(_this),
            options: _this.options,
            imageCache: _this._imageCache
          });

          _this.ListenerQueue.push(newListener);

          if (inBrowser) {
            _this._addListenerTarget(window);
            _this._addListenerTarget($parent);
          }

          _this.lazyLoadHandler();
          Vue.nextTick(function () {
            return _this.lazyLoadHandler();
          });
        });
      }

      /**
      * update image src
      * @param  {DOM} el
      * @param  {object} vue directive binding
      * @return
      */

    }, {
      key: 'update',
      value: function update(el, binding, vnode) {
        var _this2 = this;

        var _valueFormatter3 = this._valueFormatter(binding.value),
            src = _valueFormatter3.src,
            loading = _valueFormatter3.loading,
            error = _valueFormatter3.error;

        src = getBestSelectionFromSrcset(el, this.options.scale) || src;

        var exist = find(this.ListenerQueue, function (item) {
          return item.el === el;
        });
        if (!exist) {
          this.add(el, binding, vnode);
        } else {
          exist.update({
            src: src,
            loading: loading,
            error: error
          });
        }
        if (this._observer) {
          this._observer.unobserve(el);
          this._observer.observe(el);
        }
        this.lazyLoadHandler();
        Vue.nextTick(function () {
          return _this2.lazyLoadHandler();
        });
      }

      /**
      * remove listener form list
      * @param  {DOM} el
      * @return
      */

    }, {
      key: 'remove',
      value: function remove$$1(el) {
        if (!el) return;
        this._observer && this._observer.unobserve(el);
        var existItem = find(this.ListenerQueue, function (item) {
          return item.el === el;
        });
        if (existItem) {
          this._removeListenerTarget(existItem.$parent);
          this._removeListenerTarget(window);
          remove(this.ListenerQueue, existItem);
          existItem.$destroy();
        }
      }

      /*
       * remove lazy components form list
       * @param  {Vue} vm Vue instance
       * @return
       */

    }, {
      key: 'removeComponent',
      value: function removeComponent(vm) {
        if (!vm) return;
        remove(this.ListenerQueue, vm);
        this._observer && this._observer.unobserve(vm.el);
        if (vm.$parent && vm.$el.parentNode) {
          this._removeListenerTarget(vm.$el.parentNode);
        }
        this._removeListenerTarget(window);
      }
    }, {
      key: 'setMode',
      value: function setMode(mode) {
        var _this3 = this;

        if (!hasIntersectionObserver && mode === modeType.observer) {
          mode = modeType.event;
        }

        this.mode = mode; // event or observer

        if (mode === modeType.event) {
          if (this._observer) {
            this.ListenerQueue.forEach(function (listener) {
              _this3._observer.unobserve(listener.el);
            });
            this._observer = null;
          }

          this.TargetQueue.forEach(function (target) {
            _this3._initListen(target.el, true);
          });
        } else {
          this.TargetQueue.forEach(function (target) {
            _this3._initListen(target.el, false);
          });
          this._initIntersectionObserver();
        }
      }

      /*
      *** Private functions ***
      */

      /*
       * add listener target
       * @param  {DOM} el listener target
       * @return
       */

    }, {
      key: '_addListenerTarget',
      value: function _addListenerTarget(el) {
        if (!el) return;
        var target = find(this.TargetQueue, function (target) {
          return target.el === el;
        });
        if (!target) {
          target = {
            el: el,
            id: ++this.TargetIndex,
            childrenCount: 1,
            listened: true
          };
          this.mode === modeType.event && this._initListen(target.el, true);
          this.TargetQueue.push(target);
        } else {
          target.childrenCount++;
        }
        return this.TargetIndex;
      }

      /*
       * remove listener target or reduce target childrenCount
       * @param  {DOM} el or window
       * @return
       */

    }, {
      key: '_removeListenerTarget',
      value: function _removeListenerTarget(el) {
        var _this4 = this;

        this.TargetQueue.forEach(function (target, index) {
          if (target.el === el) {
            target.childrenCount--;
            if (!target.childrenCount) {
              _this4._initListen(target.el, false);
              _this4.TargetQueue.splice(index, 1);
              target = null;
            }
          }
        });
      }

      /*
       * add or remove eventlistener
       * @param  {DOM} el DOM or Window
       * @param  {boolean} start flag
       * @return
       */

    }, {
      key: '_initListen',
      value: function _initListen(el, start) {
        var _this5 = this;

        this.options.ListenEvents.forEach(function (evt) {
          return _[start ? 'on' : 'off'](el, evt, _this5.lazyLoadHandler);
        });
      }
    }, {
      key: '_initEvent',
      value: function _initEvent() {
        var _this6 = this;

        this.Event = {
          listeners: {
            loading: [],
            loaded: [],
            error: []
          }
        };

        this.$on = function (event, func) {
          if (!_this6.Event.listeners[event]) _this6.Event.listeners[event] = [];
          _this6.Event.listeners[event].push(func);
        };

        this.$once = function (event, func) {
          var vm = _this6;
          function on() {
            vm.$off(event, on);
            func.apply(vm, arguments);
          }
          _this6.$on(event, on);
        };

        this.$off = function (event, func) {
          if (!func) {
            if (!_this6.Event.listeners[event]) return;
            _this6.Event.listeners[event].length = 0;
            return;
          }
          remove(_this6.Event.listeners[event], func);
        };

        this.$emit = function (event, context, inCache) {
          if (!_this6.Event.listeners[event]) return;
          _this6.Event.listeners[event].forEach(function (func) {
            return func(context, inCache);
          });
        };
      }

      /**
       * find nodes which in viewport and trigger load
       * @return
       */

    }, {
      key: '_lazyLoadHandler',
      value: function _lazyLoadHandler() {
        var _this7 = this;

        var freeList = [];
        this.ListenerQueue.forEach(function (listener, index) {
          if (!listener.el || !listener.el.parentNode) {
            freeList.push(listener);
          }
          var catIn = listener.checkInView();
          if (!catIn) return;
          listener.load();
        });
        freeList.forEach(function (item) {
          remove(_this7.ListenerQueue, item);
          item.$destroy();
        });
      }
      /**
      * init IntersectionObserver
      * set mode to observer
      * @return
      */

    }, {
      key: '_initIntersectionObserver',
      value: function _initIntersectionObserver() {
        var _this8 = this;

        if (!hasIntersectionObserver) return;
        this._observer = new IntersectionObserver(this._observerHandler.bind(this), this.options.observerOptions);
        if (this.ListenerQueue.length) {
          this.ListenerQueue.forEach(function (listener) {
            _this8._observer.observe(listener.el);
          });
        }
      }

      /**
      * init IntersectionObserver
      * @return
      */

    }, {
      key: '_observerHandler',
      value: function _observerHandler(entries, observer) {
        var _this9 = this;

        entries.forEach(function (entry) {
          if (entry.isIntersecting) {
            _this9.ListenerQueue.forEach(function (listener) {
              if (listener.el === entry.target) {
                if (listener.state.loaded) return _this9._observer.unobserve(listener.el);
                listener.load();
              }
            });
          }
        });
      }

      /**
      * set element attribute with image'url and state
      * @param  {object} lazyload listener object
      * @param  {string} state will be rendered
      * @param  {bool} inCache  is rendered from cache
      * @return
      */

    }, {
      key: '_elRenderer',
      value: function _elRenderer(listener, state, cache) {
        if (!listener.el) return;
        var el = listener.el,
            bindType = listener.bindType;


        var src = void 0;
        switch (state) {
          case 'loading':
            src = listener.loading;
            break;
          case 'error':
            src = listener.error;
            break;
          default:
            src = listener.src;
            break;
        }

        if (bindType) {
          el.style[bindType] = 'url("' + src + '")';
        } else if (el.getAttribute('src') !== src) {
          el.setAttribute('src', src);
        }

        el.setAttribute('lazy', state);

        this.$emit(state, listener, cache);
        this.options.adapter[state] && this.options.adapter[state](listener, this.options);

        if (this.options.dispatchEvent) {
          var event = new CustomEvent(state, {
            detail: listener
          });
          el.dispatchEvent(event);
        }
      }

      /**
      * generate loading loaded error image url
      * @param {string} image's src
      * @return {object} image's loading, loaded, error url
      */

    }, {
      key: '_valueFormatter',
      value: function _valueFormatter(value) {
        var src = value;
        var loading = this.options.loading;
        var error = this.options.error;

        // value is object
        if (isObject(value)) {
          if (!value.src && !this.options.silent) console.error('Vue Lazyload warning: miss src with ' + value);
          src = value.src;
          loading = value.loading || this.options.loading;
          error = value.error || this.options.error;
        }
        return {
          src: src,
          loading: loading,
          error: error
        };
      }
    }]);
    return Lazy;
  }();
};

var LazyComponent = (function (lazy) {
  return {
    props: {
      tag: {
        type: String,
        default: 'div'
      }
    },
    render: function render(h) {
      if (this.show === false) {
        return h(this.tag);
      }
      return h(this.tag, null, this.$slots.default);
    },
    data: function data() {
      return {
        el: null,
        state: {
          loaded: false
        },
        rect: {},
        show: false
      };
    },
    mounted: function mounted() {
      this.el = this.$el;
      lazy.addLazyBox(this);
      lazy.lazyLoadHandler();
    },
    beforeDestroy: function beforeDestroy() {
      lazy.removeComponent(this);
    },

    methods: {
      getRect: function getRect() {
        this.rect = this.$el.getBoundingClientRect();
      },
      checkInView: function checkInView() {
        this.getRect();
        return inBrowser && this.rect.top < window.innerHeight * lazy.options.preLoad && this.rect.bottom > 0 && this.rect.left < window.innerWidth * lazy.options.preLoad && this.rect.right > 0;
      },
      load: function load() {
        this.show = true;
        this.state.loaded = true;
        this.$emit('show', this);
      },
      destroy: function destroy() {
        return this.$destroy;
      }
    }
  };
});

var LazyContainerMananger = function () {
  function LazyContainerMananger(_ref) {
    var lazy = _ref.lazy;
    vue_lazyload_esm_classCallCheck(this, LazyContainerMananger);

    this.lazy = lazy;
    lazy.lazyContainerMananger = this;
    this._queue = [];
  }

  vue_lazyload_esm_createClass(LazyContainerMananger, [{
    key: 'bind',
    value: function bind(el, binding, vnode) {
      var container = new LazyContainer$1({ el: el, binding: binding, vnode: vnode, lazy: this.lazy });
      this._queue.push(container);
    }
  }, {
    key: 'update',
    value: function update(el, binding, vnode) {
      var container = find(this._queue, function (item) {
        return item.el === el;
      });
      if (!container) return;
      container.update({ el: el, binding: binding, vnode: vnode });
    }
  }, {
    key: 'unbind',
    value: function unbind(el, binding, vnode) {
      var container = find(this._queue, function (item) {
        return item.el === el;
      });
      if (!container) return;
      container.clear();
      remove(this._queue, container);
    }
  }]);
  return LazyContainerMananger;
}();

var defaultOptions = {
  selector: 'img'
};

var LazyContainer$1 = function () {
  function LazyContainer(_ref2) {
    var el = _ref2.el,
        binding = _ref2.binding,
        vnode = _ref2.vnode,
        lazy = _ref2.lazy;
    vue_lazyload_esm_classCallCheck(this, LazyContainer);

    this.el = null;
    this.vnode = vnode;
    this.binding = binding;
    this.options = {};
    this.lazy = lazy;

    this._queue = [];
    this.update({ el: el, binding: binding });
  }

  vue_lazyload_esm_createClass(LazyContainer, [{
    key: 'update',
    value: function update(_ref3) {
      var _this = this;

      var el = _ref3.el,
          binding = _ref3.binding;

      this.el = el;
      this.options = assignDeep({}, defaultOptions, binding.value);

      var imgs = this.getImgs();
      imgs.forEach(function (el) {
        _this.lazy.add(el, assignDeep({}, _this.binding, {
          value: {
            src: 'dataset' in el ? el.dataset.src : el.getAttribute('data-src'),
            error: ('dataset' in el ? el.dataset.error : el.getAttribute('data-error')) || _this.options.error,
            loading: ('dataset' in el ? el.dataset.loading : el.getAttribute('data-loading')) || _this.options.loading
          }
        }), _this.vnode);
      });
    }
  }, {
    key: 'getImgs',
    value: function getImgs() {
      return ArrayFrom(this.el.querySelectorAll(this.options.selector));
    }
  }, {
    key: 'clear',
    value: function clear() {
      var _this2 = this;

      var imgs = this.getImgs();
      imgs.forEach(function (el) {
        return _this2.lazy.remove(el);
      });

      this.vnode = null;
      this.binding = null;
      this.lazy = null;
    }
  }]);
  return LazyContainer;
}();

var LazyImage = (function (lazyManager) {
  return {
    props: {
      src: [String, Object],
      tag: {
        type: String,
        default: 'img'
      }
    },
    render: function render(h) {
      return h(this.tag, {
        attrs: {
          src: this.renderSrc
        }
      }, this.$slots.default);
    },
    data: function data() {
      return {
        el: null,
        options: {
          src: '',
          error: '',
          loading: '',
          attempt: lazyManager.options.attempt
        },
        state: {
          loaded: false,
          error: false,
          attempt: 0
        },
        rect: {},
        renderSrc: ''
      };
    },

    watch: {
      src: function src() {
        this.init();
        lazyManager.addLazyBox(this);
        lazyManager.lazyLoadHandler();
      }
    },
    created: function created() {
      this.init();
      this.renderSrc = this.options.loading;
    },
    mounted: function mounted() {
      this.el = this.$el;
      lazyManager.addLazyBox(this);
      lazyManager.lazyLoadHandler();
    },
    beforeDestroy: function beforeDestroy() {
      lazyManager.removeComponent(this);
    },

    methods: {
      init: function init() {
        var _lazyManager$_valueFo = lazyManager._valueFormatter(this.src),
            src = _lazyManager$_valueFo.src,
            loading = _lazyManager$_valueFo.loading,
            error = _lazyManager$_valueFo.error;

        this.state.loaded = false;
        this.options.src = src;
        this.options.error = error;
        this.options.loading = loading;
        this.renderSrc = this.options.loading;
      },
      getRect: function getRect() {
        this.rect = this.$el.getBoundingClientRect();
      },
      checkInView: function checkInView() {
        this.getRect();
        return inBrowser && this.rect.top < window.innerHeight * lazyManager.options.preLoad && this.rect.bottom > 0 && this.rect.left < window.innerWidth * lazyManager.options.preLoad && this.rect.right > 0;
      },
      load: function load() {
        var _this = this;

        var onFinish = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;

        if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
          if (!lazyManager.options.silent) console.log('VueLazyload log: ' + this.options.src + ' tried too more than ' + this.options.attempt + ' times');
          onFinish();
          return;
        }
        var src = this.options.src;
        loadImageAsync({ src: src }, function (_ref) {
          var src = _ref.src;

          _this.renderSrc = src;
          _this.state.loaded = true;
        }, function (e) {
          _this.state.attempt++;
          _this.renderSrc = _this.options.error;
          _this.state.error = true;
        });
      }
    }
  };
});

var vue_lazyload_esm_index = {
  /*
  * install function
  * @param  {Vue} Vue
  * @param  {object} options  lazyload options
  */
  install: function install(Vue) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

    var LazyClass = Lazy(Vue);
    var lazy = new LazyClass(options);
    var lazyContainer = new LazyContainerMananger({ lazy: lazy });

    var isVue2 = Vue.version.split('.')[0] === '2';

    Vue.prototype.$Lazyload = lazy;

    if (options.lazyComponent) {
      Vue.component('lazy-component', LazyComponent(lazy));
    }

    if (options.lazyImage) {
      Vue.component('lazy-image', LazyImage(lazy));
    }

    if (isVue2) {
      Vue.directive('lazy', {
        bind: lazy.add.bind(lazy),
        update: lazy.update.bind(lazy),
        componentUpdated: lazy.lazyLoadHandler.bind(lazy),
        unbind: lazy.remove.bind(lazy)
      });
      Vue.directive('lazy-container', {
        bind: lazyContainer.bind.bind(lazyContainer),
        componentUpdated: lazyContainer.update.bind(lazyContainer),
        unbind: lazyContainer.unbind.bind(lazyContainer)
      });
    } else {
      Vue.directive('lazy', {
        bind: lazy.lazyLoadHandler.bind(lazy),
        update: function update(newValue, oldValue) {
          assignDeep(this.vm.$refs, this.vm.$els);
          lazy.add(this.el, {
            modifiers: this.modifiers || {},
            arg: this.arg,
            value: newValue,
            oldValue: oldValue
          }, {
            context: this.vm
          });
        },
        unbind: function unbind() {
          lazy.remove(this.el);
        }
      });

      Vue.directive('lazy-container', {
        update: function update(newValue, oldValue) {
          lazyContainer.update(this.el, {
            modifiers: this.modifiers || {},
            arg: this.arg,
            value: newValue,
            oldValue: oldValue
          }, {
            context: this.vm
          });
        },
        unbind: function unbind() {
          lazyContainer.unbind(this.el);
        }
      });
    }
  }
};

/* harmony default export */ var vue_lazyload_esm = (vue_lazyload_esm_index);

// EXTERNAL MODULE: ./src/packages/lazyload/lazyload.scss
var lazyload = __webpack_require__(14);

// CONCATENATED MODULE: ./src/packages/lazyload/index.js

vue_lazyload_esm.name = 'vue-lazyload';

/* harmony default export */ var packages_lazyload = (vue_lazyload_esm);
// CONCATENATED MODULE: ./src/packages/overlay/overlay.jsx


function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }



var overlay_namespace = namespace_Namespace.Create('overlay');
/* harmony default export */ var overlay = ({
  name: overlay_namespace.name,
  props: {
    show: {
      type: Boolean,
      default: false
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: true
    },
    duration: {
      type: Number,
      default: 0.36
    },
    customStyle: {
      type: Object,
      default: function _default() {}
    }
  },
  computed: {
    cls: function cls() {
      return overlay_namespace.derive();
    },
    style: function style() {
      var res = _objectSpread({
        zIndex: this.zIndex,
        animationDuration: "".concat(this.duration, "s")
      }, this.customStyle);

      return res;
    }
  },
  methods: {
    onTouchMove: function onTouchMove(e) {
      if (this.lockScroll) {
        dom_DOMExtension.PreventDefault(e, false);
      }
    },
    onClick: function onClick(e) {
      this.$emit('click', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("transition", {
      "attrs": {
        "name": "mx-fade"
      }
    }, [this.show && h("div", {
      "class": this.cls,
      "style": this.style,
      "on": {
        "touchMove": function touchMove($event) {
          $event.stopPropagation();
          return _this.onTouchMove($event);
        },
        "click": function click($event) {
          $event.stopPropagation();
          return _this.onClick($event);
        }
      }
    }, [this.$slots.default])]);
  }
});
// CONCATENATED MODULE: ./src/packages/popup/popup.jsx



var popup_namespace = namespace_Namespace.Create('popup');
/* harmony default export */ var popup = ({
  name: popup_namespace.name,
  components: {
    Overlay: overlay
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: true
    },
    duration: {
      type: Number,
      default: 0.36
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    background: {
      type: String
    },
    round: {
      type: Boolean,
      default: false
    },
    position: {
      type: String,
      default: 'bottom'
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    },
    safeAreaInsetBottom: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    cls: function cls() {
      var _namespace$derive;

      return popup_namespace.derive((_namespace$derive = {
        round: this.round
      }, defineProperty_default()(_namespace$derive, this.position, this.position), defineProperty_default()(_namespace$derive, 'safe-area-inset-bottom', this.safeAreaInsetBottom), _namespace$derive));
    },
    style: function style() {
      var res = {
        zIndex: this.zIndex
      };

      if (this.background) {
        res.background = this.background;
      }

      if (this.duration) {
        var key = this.position === 'center' ? 'animationDuration' : 'transitionDuration';
        res[key] = "".concat(this.duration, "s");
      }

      return res;
    },
    transitionName: function transitionName() {
      return popup_namespace.derive("slide-".concat(this.position));
    }
  },
  methods: {
    onClickOverlay: function onClickOverlay(e) {
      if (this.closeOnClickOveraly) {
        this.close(e);
      }
    },
    close: function close(e) {
      this.$emit('close', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderOverlay = function renderOverlay() {
      if (_this.overlay) {
        return h(overlay, {
          "attrs": {
            "show": _this.show,
            "z-index": _this.zIndex,
            "lock-scroll": _this.lockScroll,
            "duration": _this.duration,
            "overlay-style": _this.overlayStyle
          },
          "on": {
            "click": _this.onClickOverlay
          }
        });
      }
    };

    var renderPopup = function renderPopup() {
      return h("transition", {
        "attrs": {
          "name": _this.transitionName
        }
      }, [_this.show && h("div", {
        "class": _this.cls,
        "style": _this.style
      }, [_this.$slots.default])]);
    };

    return h("div", [renderOverlay(), renderPopup()]);
  }
});
// EXTERNAL MODULE: ./src/packages/popup/popup.scss
var popup_popup = __webpack_require__(15);

// CONCATENATED MODULE: ./src/packages/popup/index.js



vue_VueExtension.WithInstall(popup);
/* harmony default export */ var packages_popup = (popup);
// CONCATENATED MODULE: ./src/packages/tag/tag.jsx


var tag_namespace = namespace_Namespace.Create('tag');
/* harmony default export */ var tag_tag = ({
  name: tag_namespace.name,
  props: {
    theme: {
      type: String,
      default: 'brand'
    },
    size: {
      type: String,
      default: 'middle'
    },
    round: {
      type: Boolean,
      default: true
    },
    plain: {
      type: Boolean,
      default: false
    },
    mark: {
      type: Boolean,
      default: false
    },
    color: {
      type: String
    },
    textColor: {
      type: String
    }
  },
  computed: {
    cls: function cls() {
      return tag_namespace.derive([this.theme, this.size, {
        round: this.round,
        plain: this.plain,
        mark: this.mark
      }]);
    },
    style: function style() {
      var style = {};

      if (this.color) {
        if (this.plain) {
          style.borderColor = this.color;
          style.color = this.color;
        } else {
          var clr = color_Color.FromHex(this.color);
          style.backgroundColor = this.color;
          style.color = clr.isDark ? color_Color.WHITE : color_Color.BLACK;
        }
      }

      if (this.textColor) {
        style.color = this.textColor;
      }

      return style;
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("span", {
      "class": this.cls,
      "style": this.style
    }, [this.$slots.default]);
  }
});
// CONCATENATED MODULE: ./src/packages/cell/cell.jsx


var _components;





var cell_namespace = namespace_Namespace.Create('cell');
/* harmony default export */ var cell = ({
  name: cell_namespace.name,
  components: (_components = {
    Icon: icon
  }, defineProperty_default()(_components, switch_switch.name, switch_switch), defineProperty_default()(_components, "Tag", tag_tag), _components),
  props: {
    value: {
      type: Boolean,
      default: false
    },
    theme: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: ''
    },
    iconShape: {
      type: String,
      default: 'square'
    },
    iconColor: {
      type: String,
      default: ''
    },
    iconSize: {
      type: String,
      default: ''
    },
    iconDot: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: 'small'
    },
    title: {
      type: String | Number,
      required: true
    },
    subtitle: {
      type: String,
      default: ''
    },
    tags: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    desc: {
      type: String,
      default: ''
    },
    stamp: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: 'normal'
    },
    card: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  data: function data() {
    return {
      active: false,
      bodyHeaderStyle: '',
      collapse: false
    };
  },
  computed: {
    valueInner: {
      get: function get() {
        return this.value;
      },
      set: function set(val) {
        this.$emit('change', val);
      }
    },
    cls: function cls() {
      return cell_namespace.derive({
        disabled: this.disabled,
        collapse: this.collapse
      });
    },
    headerCls: function headerCls() {
      return cell_namespace.derive('header', [this.size, {
        active: this.active
      }]);
    },
    headerLeftCls: function headerLeftCls() {
      return cell_namespace.derive('header-left', {
        pdr: this.icon || this.$slots.left || this.isRadio
      });
    },
    iconCls: function iconCls() {
      return cell_namespace.derive('icon');
    },
    headerRightWrapperCls: function headerRightWrapperCls() {
      return cell_namespace.derive('header-right-wrapper');
    },
    headerRightCls: function headerRightCls() {
      return cell_namespace.derive('header-right', {
        stamp: this.stamp
      });
    },
    prefixCls: function prefixCls() {
      return cell_namespace.derive('header-right-prefix');
    },
    middleCls: function middleCls() {
      return cell_namespace.derive('header-right-middle', {
        prefix: this.desc || this.$slots.desc
      });
    },
    suffixCls: function suffixCls() {
      return cell_namespace.derive('header-right-suffix');
    },
    spliterCls: function spliterCls() {
      return cell_namespace.derive('spliter', {
        card: this.card
      });
    },
    titleCls: function titleCls() {
      return cell_namespace.derive('title', {
        mgb: this.subtitle || this.$slots.subtitle
      });
    },
    titleTextCls: function titleTextCls() {
      return cell_namespace.derive('title-text');
    },
    titleTagCls: function titleTagCls() {
      return cell_namespace.derive('title-tag');
    },
    subtitleCls: function subtitleCls() {
      return cell_namespace.derive('subtitle');
    },
    descCls: function descCls() {
      return cell_namespace.derive('desc', [{
        more: !this.icon
      }]);
    },
    stampCls: function stampCls() {
      return cell_namespace.derive('stamp', {
        small: this.size === 'large'
      });
    },
    linkCls: function linkCls() {
      return cell_namespace.derive('arrow');
    },
    collapseCls: function collapseCls() {
      return cell_namespace.derive('collapse', {
        collapse: this.collapse
      });
    },
    bodyCls: function bodyCls() {
      return cell_namespace.derive('body');
    },
    isSmall: function isSmall() {
      return this.size === 'small';
    },
    isSwitch: function isSwitch() {
      return this.type === 'switch';
    },
    isLink: function isLink() {
      return this.type === 'link';
    },
    isCollapse: function isCollapse() {
      return this.type === 'collapse';
    },
    iconSizeDict: function iconSizeDict() {
      return {
        small: 20,
        middle: 28,
        large: 32,
        super: 48
      };
    },
    iconSizePixel: function iconSizePixel() {
      var size = this.iconSize ? this.iconSize : this.size;

      if (this.size === 'small') {
        return this.iconSizeDict.small;
      }

      return this.iconSizeDict[size];
    },
    isIconRound: function isIconRound() {
      return this.iconShape !== 'square';
    },
    switchTheme: function switchTheme() {
      return this.theme || 'brand';
    },
    transitionName: function transitionName() {
      return cell_namespace.derive('slide');
    }
  },
  methods: {
    onClick: function onClick() {
      this.$emit('click');
    },
    onTouchStart: function onTouchStart() {
      if (this.disabled) {
        return;
      }

      this.active = true;
    },
    onTouchEnd: function onTouchEnd() {
      if (this.disabled) {
        return;
      }

      this.active = false;
    },
    onArrowClick: function onArrowClick() {
      console.log('click');

      if (this.type === 'link') {
        return;
      }

      this.collapse = !this.collapse;

      if (!this.bodyHeaderStyle) {
        var width = this.$refs.hLeft.clientWidth;
        this.bodyHeaderStyle = "width: ".concat(width, "px");
      }
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderHeaderLeft = function renderHeaderLeft() {
      if (_this.$slots.left) {
        return _this.$slots.left;
      }

      return _this.icon && h(icon, {
        "class": _this.iconCls,
        "attrs": {
          "theme": _this.theme,
          "name": _this.icon,
          "dot": _this.iconDot,
          "color": _this.iconColor,
          "size": _this.iconSizePixel,
          "round": _this.isIconRound
        }
      });
    };

    var renderPrefix = function renderPrefix() {
      return h("div", {
        "class": _this.prefixCls
      }, [h("div", {
        "class": _this.titleCls
      }, [renderTitle()]), h("div", {
        "class": _this.subtitleCls
      }, [renderSubtitle()])]);
    };

    var renderTitle = function renderTitle() {
      if (_this.$slots.title) {
        return _this.$slots.title;
      }

      return [h("div", {
        "class": _this.titleTextCls
      }, [_this.title]), renderTags()];
    };

    var renderTags = function renderTags() {
      return _this.tags.map(function (x) {
        return h(tag_tag, {
          "attrs": {
            "theme": "gray"
          }
        }, [x]);
      });
    };

    var renderSubtitle = function renderSubtitle() {
      if (_this.$slots.subtitle) {
        return _this.$slots.subtitle;
      }

      return !_this.isSmall && _this.subtitle;
    };

    var renderMiddle = function renderMiddle() {
      return h("div", {
        "class": _this.middleCls
      }, [_this.$slots.desc || h("div", {
        "class": _this.descCls
      }, [_this.desc])]);
    };

    var renderSuffix = function renderSuffix() {
      return h("div", {
        "class": _this.suffixCls
      }, [_this.$slots.suffix || _this.stamp && h("div", {
        "class": _this.stampCls
      }, [_this.stamp]) || _this.isSwitch && h("mx-switch", {
        "attrs": {
          "theme": _this.switchTheme
        },
        "model": {
          value: _this.valueInner,
          callback: function callback($$v) {
            _this.valueInner = $$v;
          }
        }
      }) || _this.isLink && h(icon, {
        "attrs": {
          "name": "arrow-right",
          "size": 10
        }
      }) || _this.isCollapse && h("div", {
        "class": _this.collapseCls,
        "on": {
          "click": _this.onArrowClick
        }
      }, [h(icon, {
        "attrs": {
          "name": "arrow-right",
          "size": 10
        }
      })])]);
    };

    var renderHeader = function renderHeader() {
      return h("div", {
        "class": _this.headerCls,
        "on": {
          "click": _this.onClick,
          "touchstart": _this.onTouchStart,
          "touchend": _this.onTouchEnd,
          "touchcancel": _this.onTouchEnd
        }
      }, [h("div", {
        "class": _this.headerLeftCls,
        "ref": "hLeft"
      }, [renderHeaderLeft()]), h("div", {
        "class": _this.headerRightWrapperCls
      }, [h("div", {
        "class": _this.headerRightCls
      }, [renderPrefix(), renderMiddle(), renderSuffix()]), h("div", {
        "class": _this.spliterCls
      })])]);
    };

    var renderBody = function renderBody() {
      return h("Transition", {
        "attrs": {
          "name": _this.transitionName
        }
      }, [_this.collapse && h("div", {
        "class": _this.bodyCls
      }, [_this.$slots.body || [h("div", {
        "style": _this.bodyHeaderStyle
      }, [_this.$slots['body-header']]), h("div", [_this.$slots['body-content']])]])]);
    };

    return h("div", {
      "class": this.cls
    }, [renderHeader(), renderBody()]);
  }
});
// EXTERNAL MODULE: ./src/packages/cell/cell.scss
var cell_cell = __webpack_require__(16);

// CONCATENATED MODULE: ./src/packages/cell/index.js



vue_VueExtension.WithInstall(cell);
/* harmony default export */ var packages_cell = (cell);
// CONCATENATED MODULE: ./src/packages/navbar/navbar.jsx


var navbar_namespace = namespace_Namespace.Create('nav-bar');
/* harmony default export */ var navbar = ({
  name: navbar_namespace.name,
  components: {
    Icon: icon
  },
  data: function data() {
    return {
      offsetWidth: -1
    };
  },
  props: {
    title: {
      type: String | Array,
      required: true
    },
    subtitle: {
      type: String
    },
    leftText: {
      type: String
    },
    leftArrow: {
      type: Boolean,
      default: true
    },
    rightText: {
      type: String
    },
    more: {
      type: Boolean,
      default: true
    },
    fixed: {
      type: Boolean,
      default: false
    },
    zIndex: {
      type: Number | String,
      default: 1030
    },
    border: {
      type: Boolean,
      default: false
    },
    background: {
      type: String
    },
    iconColor: {
      type: String
    },
    titleColor: {
      type: String
    },
    subtitleColor: {
      type: String
    },
    safeAreaInsetTop: {
      type: Boolean,
      default: false
    },
    returnIcon: {
      type: String,
      default: 'icon_backleft'
    }
  },
  computed: {
    cls: function cls() {
      return navbar_namespace.derive({
        fixed: this.fixed,
        'safe-area-inset-top': this.safeAreaInsetTop,
        'border-bottom': this.border
      });
    },
    style: function style() {
      var style = {};

      if (this.fixed) {
        style.zIndex = this.zIndex;
      }

      if (this.background) {
        style.background = this.background;
      }

      return style;
    },
    contentCls: function contentCls() {
      return navbar_namespace.derive('content');
    },
    leftCls: function leftCls() {
      return navbar_namespace.derive('left');
    },
    titleContainerCls: function titleContainerCls() {
      return navbar_namespace.derive('title-container');
    },
    titleCls: function titleCls() {
      return navbar_namespace.derive('title', {
        small: this.subtitle || this.$slots.subtitle
      });
    },
    titleItemContainerCls: function titleItemContainerCls() {
      return navbar_namespace.derive('title-item-container');
    },
    titleItemCls: function titleItemCls() {
      return navbar_namespace.derive('title-item');
    },
    lineCls: function lineCls() {
      return navbar_namespace.derive('title-bottom-line');
    },
    titleStyle: function titleStyle() {
      var style = {};

      if (this.titleColor) {
        style.color = this.titleColor;
      }

      return style;
    },
    subtitleCls: function subtitleCls() {
      return navbar_namespace.derive('subtitle');
    },
    subtitleStyle: function subtitleStyle() {
      var style = {};

      if (this.subtitleColor) {
        style.color = this.subtitleColor;
      }

      return style;
    },
    rightCls: function rightCls() {
      return navbar_namespace.derive('right');
    },
    arrowCls: function arrowCls() {
      return navbar_namespace.derive('arrow');
    },
    textCls: function textCls() {
      return navbar_namespace.derive('text');
    },
    moreCls: function moreCls() {
      return navbar_namespace.derive('more');
    },
    hasLeft: function hasLeft() {
      return this.leftText || this.leftArrow || this.$slots.left;
    },
    hasRight: function hasRight() {
      return this.rightText || this.more || this.$slots.right;
    }
  },
  methods: {
    onLeftClick: function onLeftClick(e) {
      this.$emit('left-click', e);
    },
    onRightClick: function onRightClick(e) {
      this.$emit('right-click', e);
    },
    onItemClick: function onItemClick(e) {
      var _this = this;

      var el = e.target;
      var indexVal = el.className.split('-');
      this.$emit('change', indexVal[indexVal.length - 1]);
      this.$refs.line.style.transform = "translateX(".concat(el.offsetLeft + el.offsetWidth / 4, "px)");
      this.title.forEach(function (item, index) {
        var elCls = "item-title-".concat(index);

        if (elCls !== el.className) {
          _this.$refs[elCls].style['font-weight'] = 'normal';
        }
      });
      el.style['font-weight'] = 600;
    }
  },
  mounted: function mounted() {
    var _this2 = this;

    if (Object.prototype.toString.call(this.title) === '[object Array]') {
      this.offsetWidth = this.$refs['item-title-0'].offsetWidth;
      this.$nextTick(function () {
        _this2.$refs['line'].style.width = _this2.offsetWidth / 2 + 'px';
        _this2.$refs['item-title-0'].style['font-weight'] = 600;
        _this2.$refs['line'].style.transform = "translateX(".concat(_this2.$refs['item-title-0'].offsetLeft + _this2.offsetWidth / 4, "px)");
      });
    }
  },
  render: function render() {
    var _this3 = this;

    var h = arguments[0];

    var renderLeft = function renderLeft() {
      if (_this3.$slots.left) {
        return _this3.$slots.left;
      }

      return [_this3.leftArrow && h(icon, {
        "class": _this3.arrowCls,
        "attrs": {
          "name": _this3.returnIcon,
          "color": _this3.iconColor,
          "size": "20"
        }
      }), _this3.leftText && h("span", {
        "class": _this3.textCls
      }, [_this3.leftText])];
    };

    var renderRight = function renderRight() {
      if (_this3.$slots.right) {
        return _this3.$slots.right;
      }

      return [_this3.rightText && h("span", {
        "class": _this3.textCls
      }, [_this3.rightText]), _this3.more && h(icon, {
        "class": _this3.moreCls,
        "attrs": {
          "name": "more",
          "color": _this3.iconColor,
          "size": "20"
        }
      })];
    };

    var titleItem = function titleItem() {
      return _this3.title.map(function (item, index) {
        return h("div", {
          "ref": "item-title-".concat(index),
          "on": {
            "click": _this3.onItemClick
          },
          "class": "item-title-".concat(index)
        }, [item]);
      });
    };

    var renderTitle = function renderTitle() {
      return [_this3.$slots.title || Object.prototype.toString.call(_this3.title) === '[object Array]' && h("div", {
        "class": _this3.titleItemContainerCls
      }, [h("div", {
        "class": _this3.titleItemCls
      }, [titleItem()]), h("transition", [h("div", {
        "ref": "line",
        "class": _this3.lineCls
      })])]) || h("div", {
        "class": _this3.titleCls,
        "style": _this3.titleStyle
      }, [_this3.title]), _this3.$slots.subtitle || _this3.subtitle && h("div", {
        "class": _this3.subtitleCls,
        "style": _this3.subtitleStyle
      }, [_this3.subtitle])];
    };

    return h("div", {
      "class": this.cls,
      "style": this.style
    }, [h("div", {
      "class": this.contentCls
    }, [this.hasLeft && h("div", {
      "class": this.leftCls,
      "on": {
        "click": this.onLeftClick
      }
    }, [renderLeft()]), h("div", {
      "class": this.titleContainerCls
    }, [renderTitle()]), this.hasRight && h("div", {
      "class": this.rightCls,
      "on": {
        "click": this.onRightClick
      }
    }, [renderRight()])])]);
  }
});
// EXTERNAL MODULE: ./src/packages/navbar/navbar.scss
var navbar_navbar = __webpack_require__(17);

// CONCATENATED MODULE: ./src/packages/navbar/index.js



vue_VueExtension.WithInstall(navbar);
/* harmony default export */ var packages_navbar = (navbar);
// EXTERNAL MODULE: ./src/packages/tag/tag.scss
var packages_tag_tag = __webpack_require__(18);

// CONCATENATED MODULE: ./src/packages/tag/index.js



vue_VueExtension.WithInstall(tag_tag);
/* harmony default export */ var packages_tag = (tag_tag);
// CONCATENATED MODULE: ./src/packages/noticebar/noticebar.jsx


var noticebar_namespace = namespace_Namespace.Create('notice-bar');
/* harmony default export */ var noticebar = ({
  name: noticebar_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    text: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: 'normal'
    },
    theme: {
      type: String,
      default: 'yellow'
    },
    buttonText: {
      type: String,
      default: ''
    },
    show: {
      type: Boolean,
      default: true
    },
    icon: {
      type: String,
      default: 'info'
    },
    scrollable: {
      type: Boolean,
      default: false
    },
    delay: {
      type: Number,
      default: 1
    },
    speed: {
      type: Number,
      default: 60
    }
  },
  model: {
    prop: 'show',
    event: 'close'
  },
  computed: {
    cls: function cls() {
      return noticebar_namespace.derive([this.theme]);
    },
    leftCls: function leftCls() {
      return noticebar_namespace.derive('left');
    },
    middleCls: function middleCls() {
      return noticebar_namespace.derive('middle');
    },
    rightCls: function rightCls() {
      return noticebar_namespace.derive('right');
    },
    textCls: function textCls() {
      return noticebar_namespace.derive('text');
    },
    btnCls: function btnCls() {
      return noticebar_namespace.derive('btn');
    },
    isButton: function isButton() {
      return this.type === 'button';
    },
    isClose: function isClose() {
      return this.type === 'close';
    }
  },
  methods: {
    onClose: function onClose() {
      this.$emit('close', false);
    },
    onButtonClick: function onButtonClick(e) {
      this.$emit('button-click', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderLeft = function renderLeft() {
      return h("div", {
        "class": _this.leftCls
      }, [_this.$slots.left || h(icon, {
        "attrs": {
          "name": _this.icon,
          "theme": _this.theme,
          "size": "16"
        }
      })]);
    };

    var renderMiddle = function renderMiddle() {
      return h("div", {
        "class": _this.middleCls
      }, [_this.$slots.middle || h("div", {
        "class": _this.textCls
      }, [_this.text])]);
    };

    var renderRight = function renderRight() {
      return h("div", {
        "class": _this.rightCls
      }, [_this.$slots.right || _this.isButton && h("div", {
        "class": _this.btnCls,
        "on": {
          "click": function click($event) {
            $event.stopPropagation();
            return _this.onButtonClick($event);
          }
        }
      }, [_this.buttonText]) || _this.isClose && h(icon, {
        "attrs": {
          "name": "close-fill",
          "size": "12",
          "theme": _this.theme
        },
        "on": {
          "click": _this.onClose
        }
      })]);
    };

    if (this.show) {
      return h("div", {
        "class": this.cls
      }, [renderLeft(), renderMiddle(), renderRight()]);
    }
  }
});
// EXTERNAL MODULE: ./src/packages/noticebar/noticebar.scss
var noticebar_noticebar = __webpack_require__(19);

// CONCATENATED MODULE: ./src/packages/noticebar/index.js



vue_VueExtension.WithInstall(noticebar);
/* harmony default export */ var packages_noticebar = (noticebar);
// EXTERNAL MODULE: ./src/packages/overlay/overlay.scss
var overlay_overlay = __webpack_require__(20);

// CONCATENATED MODULE: ./src/packages/overlay/index.js



vue_VueExtension.WithInstall(overlay);
/* harmony default export */ var packages_overlay = (overlay);
// CONCATENATED MODULE: ./src/packages/modal/modal.jsx


var modal_namespace = namespace_Namespace.Create('modal');
/* harmony default export */ var modal = ({
  name: modal_namespace.name,
  components: {
    Popup: popup
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: false
    },
    duration: {
      type: Number,
      default: 0.36
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    round: {
      type: Boolean,
      default: false
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    cls: function cls() {
      var res = [modal_namespace.derive()];
      return res;
    }
  },
  methods: {
    onClose: function onClose() {
      this.$emit('close');
    }
  },
  render: function render() {
    var h = arguments[0];
    return h(popup, {
      "attrs": {
        "show": this.show,
        "overlay": this.overlay,
        "z-index": this.zIndex,
        "lock-scroll": this.lockScroll,
        "duration": this.duration,
        "overlay-style": this.overlayStyle,
        "round": this.round,
        "position": "center"
      },
      "on": {
        "close": this.onClose,
        "close-on-click-overlay": this.closeOnClickOveraly
      }
    }, [h("div", {
      "class": this.cls
    }, [this.$slots.default])]);
  }
});
// EXTERNAL MODULE: ./src/packages/modal/modal.scss
var modal_modal = __webpack_require__(21);

// CONCATENATED MODULE: ./src/packages/modal/index.js



vue_VueExtension.WithInstall(modal);
/* harmony default export */ var packages_modal = (modal);
// CONCATENATED MODULE: ./src/packages/dialog/dialog.jsx




var dialog_namespace = namespace_Namespace.Create('dialog');
/* harmony default export */ var dialog = ({
  name: dialog_namespace.name,
  components: {
    Popup: popup
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: false
    },
    duration: {
      type: Number,
      default: 0.36
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: ''
    },
    content: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: 'confirm'
    },
    buttons: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    primary: {
      type: String,
      default: ''
    }
  },
  computed: {
    cls: function cls() {
      return dialog_namespace.derive();
    },
    headerCls: function headerCls() {
      return dialog_namespace.derive('header');
    },
    titleCls: function titleCls() {
      return dialog_namespace.derive('header-title');
    },
    bodyCls: function bodyCls() {
      return dialog_namespace.derive('body');
    },
    contentCls: function contentCls() {
      return dialog_namespace.derive('body-content');
    },
    footerCls: function footerCls() {
      return dialog_namespace.derive('footer', [this.type]);
    },
    buttonTexts: function buttonTexts() {
      var res = [];

      if (this.buttons.length === 0) {
        switch (this.type) {
          case 'confirm':
            res.push('确定');
            break;

          case 'alter':
            res.push.apply(res, ['取消', '确定']);
            break;

          case 'more':
            res.push.apply(res, ['确定', '更多', '取消']);
            break;
        }
      } else {
        res.push.apply(res, toConsumableArray_default()(this.buttons));
      }

      return res;
    }
  },
  methods: {
    emitButtonClick: function emitButtonClick(text, index) {
      this.$emit('button-click', {
        text: text,
        index: index
      }, this);
    },
    resolvePrimary: function resolvePrimary(text, index) {
      if (this.primary && text === this.primary) {
        return true;
      }

      if (!this.primary) {
        switch (this.type) {
          case 'confirm':
          case 'more':
            if (index === 0) {
              return true;
            }

            break;

          case 'alter':
            if (index === 1) {
              return true;
            }

            break;
        }
      }

      return false;
    },
    btnCls: function btnCls(text, index) {
      return dialog_namespace.derive('footer-btn', defineProperty_default()({
        primary: this.resolvePrimary(text, index)
      }, this.type, this.type));
    },
    onClose: function onClose() {
      this.$emit('close');
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderHeader = function renderHeader() {
      return h("div", {
        "class": _this.headerCls
      }, [_this.$slots.header || h("div", {
        "class": _this.titleCls
      }, [_this.title])]);
    };

    var renderBody = function renderBody() {
      var content = [_this.content && h("div", {
        "class": _this.contentCls
      }, [_this.content]), _this.$slots.default];

      if (_this.content || _this.$slots.default || _this.$slots.body) {
        return h("div", {
          "class": _this.bodyCls
        }, [_this.$slots.body || content]);
      }
    };

    var renderFooter = function renderFooter() {
      var btns = _this.buttonTexts.map(function (v, i) {
        return h("div", {
          "key": i,
          "class": _this.btnCls(v, i),
          "on": {
            "click": function click($event) {
              $event.stopPropagation();
              return function () {
                return _this.emitButtonClick(v, i);
              }($event);
            }
          }
        }, [v]);
      });

      return h("div", {
        "class": _this.footerCls
      }, [_this.$slots.footer || btns]);
    };

    return h(popup, {
      "attrs": {
        "show": this.show,
        "overlay": this.overlay,
        "zIndex": this.zIndex,
        "lockScroll": this.lockScroll,
        "duration": this.duration,
        "overlay-style": this.overlayStyle,
        "close-on-click-overlay": this.closeOnClickOveraly,
        "position": "center"
      },
      "on": {
        "close": this.onClose
      }
    }, [h("div", {
      "class": this.cls
    }, [renderHeader(), renderBody(), renderFooter()])]);
  }
});
// CONCATENATED MODULE: ./src/packages/dialog/functioncall.jsx


function functioncall_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function functioncall_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { functioncall_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { functioncall_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }



/* harmony default export */ var functioncall = (vue_VueExtension.InvokeComponent(function (unmount) {
  return {
    data: function data() {
      return {
        options: {
          show: false,
          overlay: true,
          zIndex: 1030,
          lockScroll: false,
          duration: 0.36,
          closeOnClickOveraly: true,
          title: '',
          content: '',
          type: 'confirm',
          buttons: [],
          primary: '',
          onButtonClick: null
        }
      };
    },
    methods: {
      open: function open(options) {
        this.options = functioncall_objectSpread(functioncall_objectSpread(functioncall_objectSpread({}, this.options), options), {}, {
          show: true
        });
      },
      onButtonClick: function onButtonClick(data) {
        this.options.onButtonClick(data);
        unmount();
      }
    },
    render: function render() {
      var h = arguments[0];
      return h(dialog, {
        "props": functioncall_objectSpread({}, this.options),
        "on": {
          "close": unmount,
          "button-click": this.onButtonClick
        }
      });
    }
  };
}));
// EXTERNAL MODULE: ./src/packages/dialog/dialog.scss
var dialog_dialog = __webpack_require__(22);

// CONCATENATED MODULE: ./src/packages/dialog/index.js




vue_VueExtension.WithInstall(dialog, functioncall);
/* harmony default export */ var packages_dialog = (dialog);
// EXTERNAL MODULE: ./node_modules/@vue/babel-helper-vue-jsx-merge-props/dist/helper.js
var helper = __webpack_require__(58);
var helper_default = /*#__PURE__*/__webpack_require__.n(helper);

// CONCATENATED MODULE: ./src/packages/searchbar/searchbar.jsx



var searchbar_namespace = namespace_Namespace.Create('search-bar');
/* harmony default export */ var searchbar = ({
  name: searchbar_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: ''
    },
    theme: {
      type: String,
      default: 'gray'
    },
    round: {
      type: Boolean,
      default: false
    },
    wrapperStyle: {
      type: Object | String
    },
    showPrefix: {
      type: Boolean,
      default: false
    },
    showSuffix: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  computed: {
    wrapperCls: function wrapperCls() {
      return searchbar_namespace.derive('wrapper', [this.theme]);
    },
    cls: function cls() {
      return searchbar_namespace.derive([this.theme, {
        round: this.round
      }]);
    },
    iconCls: function iconCls() {
      return searchbar_namespace.derive('icon');
    },
    contentCls: function contentCls() {
      return searchbar_namespace.derive('content');
    },
    inputCls: function inputCls() {
      return searchbar_namespace.derive('content-input', [this.theme]);
    },
    addonCls: function addonCls() {
      return searchbar_namespace.derive('addon');
    },
    prefixCls: function prefixCls() {
      return searchbar_namespace.derive('prefix');
    },
    suffixCls: function suffixCls() {
      return searchbar_namespace.derive('suffix');
    },
    valueInner: {
      get: function get() {
        return this.value;
      },
      set: function set(value) {
        this.emitChange(value);
      }
    }
  },
  methods: {
    emitChange: function emitChange(value) {
      this.$emit('change', value);
    },
    onClear: function onClear() {
      this.emitChange('');
    },
    onReturn: function onReturn(e) {
      this.$emit('return', e);
    },
    onCancel: function onCancel(e) {
      this.$emit('cancel', e);
    },
    onFocus: function onFocus(e) {
      this.$emit('focus', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderPrefix = function renderPrefix() {
      if (_this.showPrefix) {
        return h("div", {
          "class": _this.prefixCls
        }, [_this.$slots.prefix || h(icon, {
          "class": "mx-icon-return",
          "attrs": {
            "name": "arrow-left",
            "size": "16"
          },
          "on": {
            "click": _this.onReturn
          }
        })]);
      }
    };

    var renderIcon = function renderIcon() {
      return h("div", {
        "class": _this.iconCls
      }, [_this.$slots.icon || h(icon, {
        "attrs": {
          "name": "search",
          "size": "16"
        }
      })]);
    };

    var renderContent = function renderContent() {
      return h("div", {
        "class": _this.contentCls
      }, [h("input", helper_default()([{
        "on": {
          "input": function input($event) {
            if ($event.target.composing) return;
            _this.valueInner = $event.target.value;
          },
          "focus": _this.onFocus
        },
        "class": _this.inputCls,
        "attrs": {
          "type": "text",
          "placeholder": _this.placeholder
        },
        "domProps": {
          "value": _this.valueInner
        }
      }, {
        directives: [{
          name: "model",
          value: _this.valueInner,
          modifiers: {}
        }]
      }]))]);
    };

    var renderAddon = function renderAddon() {
      return h("div", {
        "class": _this.addonCls
      }, [_this.value && (_this.$slots['addon'] || h(icon, {
        "attrs": {
          "name": "close",
          "size": "16"
        },
        "on": {
          "click": _this.onClear
        }
      }))]);
    };

    var renderSuffix = function renderSuffix() {
      if (_this.showSuffix) {
        return h("div", {
          "class": _this.suffixCls
        }, [_this.$slots.action || h("div", {
          "class": searchbar_namespace.derive('suffix-cancel'),
          "on": {
            "click": _this.onCancel
          }
        }, ["\u53D6\u6D88"])]);
      }
    };

    return h("div", {
      "class": this.wrapperCls,
      "style": this.wrapperStyle
    }, [renderPrefix(), h("div", {
      "class": this.cls
    }, [renderIcon(), renderContent(), renderAddon()]), renderSuffix()]);
  }
});
// EXTERNAL MODULE: ./src/packages/searchbar/searchbar.scss
var searchbar_searchbar = __webpack_require__(23);

// CONCATENATED MODULE: ./src/packages/searchbar/index.js



vue_VueExtension.WithInstall(searchbar);
/* harmony default export */ var packages_searchbar = (searchbar);
// CONCATENATED MODULE: ./src/packages/empty/empty.jsx

var empty_namespace = namespace_Namespace.Create('empty');
/* harmony default export */ var empty = ({
  name: empty_namespace.name,
  props: {
    img: {
      type: String,
      required: true
    },
    desc: {
      type: String
    }
  },
  computed: {
    cls: function cls() {
      return empty_namespace.derive();
    },
    imgCls: function imgCls() {
      return empty_namespace.derive('img');
    },
    descCls: function descCls() {
      return empty_namespace.derive('desc');
    },
    slotCls: function slotCls() {
      return empty_namespace.derive('slot');
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls
    }, [h("img", {
      "class": this.imgCls,
      "attrs": {
        "src": this.img
      }
    }), h("div", {
      "class": this.descCls
    }, [this.desc]), h("div", {
      "class": this.slotCls
    }, [this.$slots.default])]);
  }
});
// EXTERNAL MODULE: ./src/packages/empty/empty.scss
var empty_empty = __webpack_require__(24);

// CONCATENATED MODULE: ./src/packages/empty/index.js



vue_VueExtension.WithInstall(empty);
/* harmony default export */ var packages_empty = (empty);
// CONCATENATED MODULE: ./node_modules/better-scroll/dist/better-scroll.esm.js
/*!
 * better-scroll / better-scroll
 * (c) 2016-2021 ustbhuangyi
 * Released under the MIT License.
 */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

function __spreadArrays() {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
}

var propertiesConfig$7 = [
    {
        sourceKey: 'scroller.scrollBehaviorX.currentPos',
        key: 'x'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.currentPos',
        key: 'y'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.hasScroll',
        key: 'hasHorizontalScroll'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.hasScroll',
        key: 'hasVerticalScroll'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.contentSize',
        key: 'scrollerWidth'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.contentSize',
        key: 'scrollerHeight'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.maxScrollPos',
        key: 'maxScrollX'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.maxScrollPos',
        key: 'maxScrollY'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.minScrollPos',
        key: 'minScrollX'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.minScrollPos',
        key: 'minScrollY'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.movingDirection',
        key: 'movingDirectionX'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.movingDirection',
        key: 'movingDirectionY'
    },
    {
        sourceKey: 'scroller.scrollBehaviorX.direction',
        key: 'directionX'
    },
    {
        sourceKey: 'scroller.scrollBehaviorY.direction',
        key: 'directionY'
    },
    {
        sourceKey: 'scroller.actions.enabled',
        key: 'enabled'
    },
    {
        sourceKey: 'scroller.animater.pending',
        key: 'pending'
    },
    {
        sourceKey: 'scroller.animater.stop',
        key: 'stop'
    },
    {
        sourceKey: 'scroller.scrollTo',
        key: 'scrollTo'
    },
    {
        sourceKey: 'scroller.scrollBy',
        key: 'scrollBy'
    },
    {
        sourceKey: 'scroller.scrollToElement',
        key: 'scrollToElement'
    },
    {
        sourceKey: 'scroller.resetPosition',
        key: 'resetPosition'
    }
];

function warn(msg) {
    console.error("[BScroll warn]: " + msg);
}
function assert(condition, msg) {
    if (!condition) {
        throw new Error('[BScroll] ' + msg);
    }
}

// ssr support
var better_scroll_esm_inBrowser = typeof window !== 'undefined';
var ua = better_scroll_esm_inBrowser && navigator.userAgent.toLowerCase();
var isWeChatDevTools = !!(ua && /wechatdevtools/.test(ua));
var isAndroid = ua && ua.indexOf('android') > 0;
/* istanbul ignore next */
var isIOSBadVersion = (function () {
    if (typeof ua === 'string') {
        var regex = /os (\d\d?_\d(_\d)?)/;
        var matches = regex.exec(ua);
        if (!matches)
            return false;
        var parts = matches[1].split('_').map(function (item) {
            return parseInt(item, 10);
        });
        // ios version >= 13.4 issue 982
        return !!(parts[0] === 13 && parts[1] >= 4);
    }
    return false;
})();
/* istanbul ignore next */
var better_scroll_esm_supportsPassive = false;
/* istanbul ignore next */
if (better_scroll_esm_inBrowser) {
    var EventName = 'test-passive';
    try {
        var better_scroll_esm_opts = {};
        Object.defineProperty(better_scroll_esm_opts, 'passive', {
            get: function () {
                better_scroll_esm_supportsPassive = true;
            },
        }); // https://github.com/facebook/flow/issues/285
        window.addEventListener(EventName, function () { }, better_scroll_esm_opts);
    }
    catch (e) { }
}

function getNow() {
    return window.performance &&
        window.performance.now &&
        window.performance.timing
        ? window.performance.now() + window.performance.timing.navigationStart
        : +new Date();
}
var better_scroll_esm_extend = function (target, source) {
    for (var key in source) {
        target[key] = source[key];
    }
    return target;
};
function isUndef(v) {
    return v === undefined || v === null;
}
function getDistance(x, y) {
    return Math.sqrt(x * x + y * y);
}
function between(x, min, max) {
    if (x < min) {
        return min;
    }
    if (x > max) {
        return max;
    }
    return x;
}
function findIndex(ary, fn) {
    if (ary.findIndex) {
        return ary.findIndex(fn);
    }
    var index = -1;
    ary.some(function (item, i, ary) {
        var ret = fn(item, i, ary);
        if (ret) {
            index = i;
            return ret;
        }
    });
    return index;
}

var elementStyle = (better_scroll_esm_inBrowser &&
    document.createElement('div').style);
var vendor = (function () {
    /* istanbul ignore if  */
    if (!better_scroll_esm_inBrowser) {
        return false;
    }
    var transformNames = [
        {
            key: 'standard',
            value: 'transform',
        },
        {
            key: 'webkit',
            value: 'webkitTransform',
        },
        {
            key: 'Moz',
            value: 'MozTransform',
        },
        {
            key: 'O',
            value: 'OTransform',
        },
        {
            key: 'ms',
            value: 'msTransform',
        },
    ];
    for (var _i = 0, transformNames_1 = transformNames; _i < transformNames_1.length; _i++) {
        var obj = transformNames_1[_i];
        if (elementStyle[obj.value] !== undefined) {
            return obj.key;
        }
    }
    /* istanbul ignore next  */
    return false;
})();
/* istanbul ignore next  */
function prefixStyle(style) {
    if (vendor === false) {
        return style;
    }
    if (vendor === 'standard') {
        if (style === 'transitionEnd') {
            return 'transitionend';
        }
        return style;
    }
    return vendor + style.charAt(0).toUpperCase() + style.substr(1);
}
function getElement(el) {
    return (typeof el === 'string'
        ? document.querySelector(el)
        : el);
}
function addEvent(el, type, fn, capture) {
    var useCapture = better_scroll_esm_supportsPassive
        ? {
            passive: false,
            capture: !!capture,
        }
        : !!capture;
    el.addEventListener(type, fn, useCapture);
}
function removeEvent(el, type, fn, capture) {
    el.removeEventListener(type, fn, {
        capture: !!capture,
    });
}
function better_scroll_esm_offset(el) {
    var left = 0;
    var top = 0;
    while (el) {
        left -= el.offsetLeft;
        top -= el.offsetTop;
        el = el.offsetParent;
    }
    return {
        left: left,
        top: top,
    };
}
function offsetToBody(el) {
    var rect = el.getBoundingClientRect();
    return {
        left: -(rect.left + window.pageXOffset),
        top: -(rect.top + window.pageYOffset),
    };
}
var cssVendor = vendor && vendor !== 'standard' ? '-' + vendor.toLowerCase() + '-' : '';
var transform = prefixStyle('transform');
var transition = prefixStyle('transition');
var hasPerspective = better_scroll_esm_inBrowser && prefixStyle('perspective') in elementStyle;
// fix issue #361
var hasTouch = better_scroll_esm_inBrowser && ('ontouchstart' in window || isWeChatDevTools);
var hasTransition = better_scroll_esm_inBrowser && transition in elementStyle;
var better_scroll_esm_style = {
    transform: transform,
    transition: transition,
    transitionTimingFunction: prefixStyle('transitionTimingFunction'),
    transitionDuration: prefixStyle('transitionDuration'),
    transitionDelay: prefixStyle('transitionDelay'),
    transformOrigin: prefixStyle('transformOrigin'),
    transitionEnd: prefixStyle('transitionEnd'),
    transitionProperty: prefixStyle('transitionProperty'),
};
var eventTypeMap = {
    touchstart: 1,
    touchmove: 1,
    touchend: 1,
    touchcancel: 1,
    mousedown: 2,
    mousemove: 2,
    mouseup: 2,
};
function getRect(el) {
    /* istanbul ignore if  */
    if (el instanceof window.SVGElement) {
        var rect = el.getBoundingClientRect();
        return {
            top: rect.top,
            left: rect.left,
            width: rect.width,
            height: rect.height,
        };
    }
    else {
        return {
            top: el.offsetTop,
            left: el.offsetLeft,
            width: el.offsetWidth,
            height: el.offsetHeight,
        };
    }
}
function preventDefaultExceptionFn(el, exceptions) {
    for (var i in exceptions) {
        if (exceptions[i].test(el[i])) {
            return true;
        }
    }
    return false;
}
var tagExceptionFn = preventDefaultExceptionFn;
function tap(e, eventName) {
    var ev = document.createEvent('Event');
    ev.initEvent(eventName, true, true);
    ev.pageX = e.pageX;
    ev.pageY = e.pageY;
    e.target.dispatchEvent(ev);
}
function click(e, event) {
    if (event === void 0) { event = 'click'; }
    var eventSource;
    if (e.type === 'mouseup') {
        eventSource = e;
    }
    else if (e.type === 'touchend' || e.type === 'touchcancel') {
        eventSource = e.changedTouches[0];
    }
    var posSrc = {};
    if (eventSource) {
        posSrc.screenX = eventSource.screenX || 0;
        posSrc.screenY = eventSource.screenY || 0;
        posSrc.clientX = eventSource.clientX || 0;
        posSrc.clientY = eventSource.clientY || 0;
    }
    var ev;
    var bubbles = true;
    var cancelable = true;
    var ctrlKey = e.ctrlKey, shiftKey = e.shiftKey, altKey = e.altKey, metaKey = e.metaKey;
    var pressedKeysMap = {
        ctrlKey: ctrlKey,
        shiftKey: shiftKey,
        altKey: altKey,
        metaKey: metaKey,
    };
    if (typeof MouseEvent !== 'undefined') {
        try {
            ev = new MouseEvent(event, better_scroll_esm_extend(__assign({ bubbles: bubbles,
                cancelable: cancelable }, pressedKeysMap), posSrc));
        }
        catch (e) {
            /* istanbul ignore next */
            createEvent();
        }
    }
    else {
        createEvent();
    }
    function createEvent() {
        ev = document.createEvent('Event');
        ev.initEvent(event, bubbles, cancelable);
        better_scroll_esm_extend(ev, posSrc);
    }
    // forwardedTouchEvent set to true in case of the conflict with fastclick
    ev.forwardedTouchEvent = true;
    ev._constructed = true;
    e.target.dispatchEvent(ev);
}
function dblclick(e) {
    click(e, 'dblclick');
}
function prepend(el, target) {
    var firstChild = target.firstChild;
    if (firstChild) {
        before(el, firstChild);
    }
    else {
        target.appendChild(el);
    }
}
function before(el, target) {
    var parentNode = target.parentNode;
    parentNode.insertBefore(el, target);
}
function removeChild(el, child) {
    el.removeChild(child);
}
function hasClass(el, className) {
    var reg = new RegExp('(^|\\s)' + className + '(\\s|$)');
    return reg.test(el.className);
}
function HTMLCollectionToArray(el) {
    return Array.prototype.slice.call(el, 0);
}
function getClientSize(el) {
    return {
        width: el.clientWidth,
        height: el.clientHeight,
    };
}

var ease = {
    // easeOutQuint
    swipe: {
        style: 'cubic-bezier(0.23, 1, 0.32, 1)',
        fn: function (t) {
            return 1 + --t * t * t * t * t;
        }
    },
    // easeOutQuard
    swipeBounce: {
        style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
        fn: function (t) {
            return t * (2 - t);
        }
    },
    // easeOutQuart
    bounce: {
        style: 'cubic-bezier(0.165, 0.84, 0.44, 1)',
        fn: function (t) {
            return 1 - --t * t * t * t;
        }
    }
};

var DEFAULT_INTERVAL = 1000 / 60;
var windowCompat = better_scroll_esm_inBrowser && window;
/* istanbul ignore next */
function noop$1() { }
var requestAnimationFrame = (function () {
    /* istanbul ignore if  */
    if (!better_scroll_esm_inBrowser) {
        return noop$1;
    }
    return (windowCompat.requestAnimationFrame ||
        windowCompat.webkitRequestAnimationFrame ||
        windowCompat.mozRequestAnimationFrame ||
        windowCompat.oRequestAnimationFrame ||
        // if all else fails, use setTimeout
        function (callback) {
            return window.setTimeout(callback, callback.interval || DEFAULT_INTERVAL); // make interval as precise as possible.
        });
})();
var cancelAnimationFrame = (function () {
    /* istanbul ignore if  */
    if (!better_scroll_esm_inBrowser) {
        return noop$1;
    }
    return (windowCompat.cancelAnimationFrame ||
        windowCompat.webkitCancelAnimationFrame ||
        windowCompat.mozCancelAnimationFrame ||
        windowCompat.oCancelAnimationFrame ||
        function (id) {
            window.clearTimeout(id);
        });
})();

/* istanbul ignore next */
var better_scroll_esm_noop = function (val) { };
var sharedPropertyDefinition = {
    enumerable: true,
    configurable: true,
    get: better_scroll_esm_noop,
    set: better_scroll_esm_noop,
};
var getProperty = function (obj, key) {
    var keys = key.split('.');
    for (var i = 0; i < keys.length - 1; i++) {
        obj = obj[keys[i]];
        if (typeof obj !== 'object' || !obj)
            return;
    }
    var lastKey = keys.pop();
    if (typeof obj[lastKey] === 'function') {
        return function () {
            return obj[lastKey].apply(obj, arguments);
        };
    }
    else {
        return obj[lastKey];
    }
};
var setProperty = function (obj, key, value) {
    var keys = key.split('.');
    var temp;
    for (var i = 0; i < keys.length - 1; i++) {
        temp = keys[i];
        if (!obj[temp])
            obj[temp] = {};
        obj = obj[temp];
    }
    obj[keys.pop()] = value;
};
function propertiesProxy(target, sourceKey, key) {
    sharedPropertyDefinition.get = function proxyGetter() {
        return getProperty(this, sourceKey);
    };
    sharedPropertyDefinition.set = function proxySetter(val) {
        setProperty(this, sourceKey, val);
    };
    Object.defineProperty(target, key, sharedPropertyDefinition);
}

var EventEmitter = /** @class */ (function () {
    function EventEmitter(names) {
        this.events = {};
        this.eventTypes = {};
        this.registerType(names);
    }
    EventEmitter.prototype.on = function (type, fn, context) {
        if (context === void 0) { context = this; }
        this.hasType(type);
        if (!this.events[type]) {
            this.events[type] = [];
        }
        this.events[type].push([fn, context]);
        return this;
    };
    EventEmitter.prototype.once = function (type, fn, context) {
        var _this = this;
        if (context === void 0) { context = this; }
        this.hasType(type);
        var magic = function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            _this.off(type, magic);
            var ret = fn.apply(context, args);
            if (ret === true) {
                return ret;
            }
        };
        magic.fn = fn;
        this.on(type, magic);
        return this;
    };
    EventEmitter.prototype.off = function (type, fn) {
        if (!type && !fn) {
            this.events = {};
            return this;
        }
        if (type) {
            this.hasType(type);
            if (!fn) {
                this.events[type] = [];
                return this;
            }
            var events = this.events[type];
            if (!events) {
                return this;
            }
            var count = events.length;
            while (count--) {
                if (events[count][0] === fn ||
                    (events[count][0] && events[count][0].fn === fn)) {
                    events.splice(count, 1);
                }
            }
            return this;
        }
    };
    EventEmitter.prototype.trigger = function (type) {
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        this.hasType(type);
        var events = this.events[type];
        if (!events) {
            return;
        }
        var len = events.length;
        var eventsCopy = __spreadArrays(events);
        var ret;
        for (var i = 0; i < len; i++) {
            var event_1 = eventsCopy[i];
            var fn = event_1[0], context = event_1[1];
            if (fn) {
                ret = fn.apply(context, args);
                if (ret === true) {
                    return ret;
                }
            }
        }
    };
    EventEmitter.prototype.registerType = function (names) {
        var _this = this;
        names.forEach(function (type) {
            _this.eventTypes[type] = type;
        });
    };
    EventEmitter.prototype.destroy = function () {
        this.events = {};
        this.eventTypes = {};
    };
    EventEmitter.prototype.hasType = function (type) {
        var types = this.eventTypes;
        var isType = types[type] === type;
        if (!isType) {
            warn("EventEmitter has used unknown event type: \"" + type + "\", should be oneof [" +
                ("" + Object.keys(types).map(function (_) { return JSON.stringify(_); })) +
                "]");
        }
    };
    return EventEmitter;
}());
var EventRegister = /** @class */ (function () {
    function EventRegister(wrapper, events) {
        this.wrapper = wrapper;
        this.events = events;
        this.addDOMEvents();
    }
    EventRegister.prototype.destroy = function () {
        this.removeDOMEvents();
        this.events = [];
    };
    EventRegister.prototype.addDOMEvents = function () {
        this.handleDOMEvents(addEvent);
    };
    EventRegister.prototype.removeDOMEvents = function () {
        this.handleDOMEvents(removeEvent);
    };
    EventRegister.prototype.handleDOMEvents = function (eventOperation) {
        var _this = this;
        var wrapper = this.wrapper;
        this.events.forEach(function (event) {
            eventOperation(wrapper, event.name, _this, !!event.capture);
        });
    };
    EventRegister.prototype.handleEvent = function (e) {
        var eventType = e.type;
        this.events.some(function (event) {
            if (event.name === eventType) {
                event.handler(e);
                return true;
            }
            return false;
        });
    };
    return EventRegister;
}());

var CustomOptions = /** @class */ (function () {
    function CustomOptions() {
    }
    return CustomOptions;
}());
var OptionsConstructor = /** @class */ (function (_super) {
    __extends(OptionsConstructor, _super);
    function OptionsConstructor() {
        var _this = _super.call(this) || this;
        _this.startX = 0;
        _this.startY = 0;
        _this.scrollX = false;
        _this.scrollY = true;
        _this.freeScroll = false;
        _this.directionLockThreshold = 0;
        _this.eventPassthrough = "" /* None */;
        _this.click = false;
        _this.dblclick = false;
        _this.tap = '';
        _this.bounce = {
            top: true,
            bottom: true,
            left: true,
            right: true,
        };
        _this.bounceTime = 800;
        _this.momentum = true;
        _this.momentumLimitTime = 300;
        _this.momentumLimitDistance = 15;
        _this.swipeTime = 2500;
        _this.swipeBounceTime = 500;
        _this.deceleration = 0.0015;
        _this.flickLimitTime = 200;
        _this.flickLimitDistance = 100;
        _this.resizePolling = 60;
        _this.probeType = 0 /* Default */;
        _this.stopPropagation = false;
        _this.preventDefault = true;
        _this.preventDefaultException = {
            tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/,
        };
        _this.tagException = {
            tagName: /^TEXTAREA$/,
        };
        _this.HWCompositing = true;
        _this.useTransition = true;
        _this.bindToWrapper = false;
        _this.bindToTarget = false;
        _this.disableMouse = hasTouch;
        _this.disableTouch = !hasTouch;
        _this.autoBlur = true;
        _this.autoEndDistance = 5;
        _this.outOfBoundaryDampingFactor = 1 / 3;
        _this.specifiedIndexAsContent = 0;
        _this.quadrant = 1 /* First */;
        return _this;
    }
    OptionsConstructor.prototype.merge = function (options) {
        if (!options)
            return this;
        for (var key in options) {
            if (key === 'bounce') {
                this.bounce = this.resolveBounce(options[key]);
                continue;
            }
            this[key] = options[key];
        }
        return this;
    };
    OptionsConstructor.prototype.process = function () {
        this.translateZ =
            this.HWCompositing && hasPerspective ? ' translateZ(1px)' : '';
        this.useTransition = this.useTransition && hasTransition;
        this.preventDefault = !this.eventPassthrough && this.preventDefault;
        // If you want eventPassthrough I have to lock one of the axes
        this.scrollX =
            this.eventPassthrough === "horizontal" /* Horizontal */
                ? false
                : this.scrollX;
        this.scrollY =
            this.eventPassthrough === "vertical" /* Vertical */ ? false : this.scrollY;
        // With eventPassthrough we also need lockDirection mechanism
        this.freeScroll = this.freeScroll && !this.eventPassthrough;
        // force true when freeScroll is true
        this.scrollX = this.freeScroll ? true : this.scrollX;
        this.scrollY = this.freeScroll ? true : this.scrollY;
        this.directionLockThreshold = this.eventPassthrough
            ? 0
            : this.directionLockThreshold;
        return this;
    };
    OptionsConstructor.prototype.resolveBounce = function (bounceOptions) {
        var DEFAULT_BOUNCE = {
            top: true,
            right: true,
            bottom: true,
            left: true,
        };
        var NEGATED_BOUNCE = {
            top: false,
            right: false,
            bottom: false,
            left: false,
        };
        var ret;
        if (typeof bounceOptions === 'object') {
            ret = better_scroll_esm_extend(DEFAULT_BOUNCE, bounceOptions);
        }
        else {
            ret = bounceOptions ? DEFAULT_BOUNCE : NEGATED_BOUNCE;
        }
        return ret;
    };
    return OptionsConstructor;
}(CustomOptions));

var ActionsHandler = /** @class */ (function () {
    function ActionsHandler(wrapper, options) {
        this.wrapper = wrapper;
        this.options = options;
        this.hooks = new EventEmitter([
            'beforeStart',
            'start',
            'move',
            'end',
            'click',
        ]);
        this.handleDOMEvents();
    }
    ActionsHandler.prototype.handleDOMEvents = function () {
        var _a = this.options, bindToWrapper = _a.bindToWrapper, disableMouse = _a.disableMouse, disableTouch = _a.disableTouch, click = _a.click;
        var wrapper = this.wrapper;
        var target = bindToWrapper ? wrapper : window;
        var wrapperEvents = [];
        var targetEvents = [];
        var shouldRegisterTouch = !disableTouch;
        var shouldRegisterMouse = !disableMouse;
        if (click) {
            wrapperEvents.push({
                name: 'click',
                handler: this.click.bind(this),
                capture: true,
            });
        }
        if (shouldRegisterTouch) {
            wrapperEvents.push({
                name: 'touchstart',
                handler: this.start.bind(this),
            });
            targetEvents.push({
                name: 'touchmove',
                handler: this.move.bind(this),
            }, {
                name: 'touchend',
                handler: this.end.bind(this),
            }, {
                name: 'touchcancel',
                handler: this.end.bind(this),
            });
        }
        if (shouldRegisterMouse) {
            wrapperEvents.push({
                name: 'mousedown',
                handler: this.start.bind(this),
            });
            targetEvents.push({
                name: 'mousemove',
                handler: this.move.bind(this),
            }, {
                name: 'mouseup',
                handler: this.end.bind(this),
            });
        }
        this.wrapperEventRegister = new EventRegister(wrapper, wrapperEvents);
        this.targetEventRegister = new EventRegister(target, targetEvents);
    };
    ActionsHandler.prototype.beforeHandler = function (e, type) {
        var _a = this.options, preventDefault = _a.preventDefault, stopPropagation = _a.stopPropagation, preventDefaultException = _a.preventDefaultException;
        var preventDefaultConditions = {
            start: function () {
                return (preventDefault &&
                    !preventDefaultExceptionFn(e.target, preventDefaultException));
            },
            end: function () {
                return (preventDefault &&
                    !preventDefaultExceptionFn(e.target, preventDefaultException));
            },
            move: function () {
                return preventDefault;
            },
        };
        if (preventDefaultConditions[type]()) {
            e.preventDefault();
        }
        if (stopPropagation) {
            e.stopPropagation();
        }
    };
    ActionsHandler.prototype.setInitiated = function (type) {
        if (type === void 0) { type = 0; }
        this.initiated = type;
    };
    ActionsHandler.prototype.start = function (e) {
        var _eventType = eventTypeMap[e.type];
        if (this.initiated && this.initiated !== _eventType) {
            return;
        }
        this.setInitiated(_eventType);
        // if textarea or other html tags in options.tagException is manipulated
        // do not make bs scroll
        if (tagExceptionFn(e.target, this.options.tagException)) {
            this.setInitiated();
            return;
        }
        // only allow mouse left button
        if (_eventType === 2 /* Mouse */ && e.button !== 0 /* Left */)
            return;
        if (this.hooks.trigger(this.hooks.eventTypes.beforeStart, e)) {
            return;
        }
        this.beforeHandler(e, 'start');
        var point = (e.touches ? e.touches[0] : e);
        this.pointX = point.pageX;
        this.pointY = point.pageY;
        this.hooks.trigger(this.hooks.eventTypes.start, e);
    };
    ActionsHandler.prototype.move = function (e) {
        if (eventTypeMap[e.type] !== this.initiated) {
            return;
        }
        this.beforeHandler(e, 'move');
        var point = (e.touches ? e.touches[0] : e);
        var deltaX = point.pageX - this.pointX;
        var deltaY = point.pageY - this.pointY;
        this.pointX = point.pageX;
        this.pointY = point.pageY;
        if (this.hooks.trigger(this.hooks.eventTypes.move, {
            deltaX: deltaX,
            deltaY: deltaY,
            e: e,
        })) {
            return;
        }
        // auto end when out of viewport
        var scrollLeft = document.documentElement.scrollLeft ||
            window.pageXOffset ||
            document.body.scrollLeft;
        var scrollTop = document.documentElement.scrollTop ||
            window.pageYOffset ||
            document.body.scrollTop;
        var pX = this.pointX - scrollLeft;
        var pY = this.pointY - scrollTop;
        var autoEndDistance = this.options.autoEndDistance;
        if (pX > document.documentElement.clientWidth - autoEndDistance ||
            pY > document.documentElement.clientHeight - autoEndDistance ||
            pX < autoEndDistance ||
            pY < autoEndDistance) {
            this.end(e);
        }
    };
    ActionsHandler.prototype.end = function (e) {
        if (eventTypeMap[e.type] !== this.initiated) {
            return;
        }
        this.setInitiated();
        this.beforeHandler(e, 'end');
        this.hooks.trigger(this.hooks.eventTypes.end, e);
    };
    ActionsHandler.prototype.click = function (e) {
        this.hooks.trigger(this.hooks.eventTypes.click, e);
    };
    ActionsHandler.prototype.setContent = function (content) {
        if (content !== this.wrapper) {
            this.wrapper = content;
            this.rebindDOMEvents();
        }
    };
    ActionsHandler.prototype.rebindDOMEvents = function () {
        this.wrapperEventRegister.destroy();
        this.targetEventRegister.destroy();
        this.handleDOMEvents();
    };
    ActionsHandler.prototype.destroy = function () {
        this.wrapperEventRegister.destroy();
        this.targetEventRegister.destroy();
        this.hooks.destroy();
    };
    return ActionsHandler;
}());

var translaterMetaData = {
    x: ['translateX', 'px'],
    y: ['translateY', 'px'],
};
var Translater = /** @class */ (function () {
    function Translater(content) {
        this.setContent(content);
        this.hooks = new EventEmitter(['beforeTranslate', 'translate']);
    }
    Translater.prototype.getComputedPosition = function () {
        var cssStyle = window.getComputedStyle(this.content, null);
        var matrix = cssStyle[better_scroll_esm_style.transform].split(')')[0].split(', ');
        var x = +(matrix[12] || matrix[4]) || 0;
        var y = +(matrix[13] || matrix[5]) || 0;
        return {
            x: x,
            y: y,
        };
    };
    Translater.prototype.translate = function (point) {
        var transformStyle = [];
        Object.keys(point).forEach(function (key) {
            if (!translaterMetaData[key]) {
                return;
            }
            var transformFnName = translaterMetaData[key][0];
            if (transformFnName) {
                var transformFnArgUnit = translaterMetaData[key][1];
                var transformFnArg = point[key];
                transformStyle.push(transformFnName + "(" + transformFnArg + transformFnArgUnit + ")");
            }
        });
        this.hooks.trigger(this.hooks.eventTypes.beforeTranslate, transformStyle, point);
        this.style[better_scroll_esm_style.transform] = transformStyle.join(' ');
        this.hooks.trigger(this.hooks.eventTypes.translate, point);
    };
    Translater.prototype.setContent = function (content) {
        if (this.content !== content) {
            this.content = content;
            this.style = content.style;
        }
    };
    Translater.prototype.destroy = function () {
        this.hooks.destroy();
    };
    return Translater;
}());

var Base = /** @class */ (function () {
    function Base(content, translater, options) {
        this.translater = translater;
        this.options = options;
        this.timer = 0;
        this.hooks = new EventEmitter([
            'move',
            'end',
            'beforeForceStop',
            'forceStop',
            'callStop',
            'time',
            'timeFunction',
        ]);
        this.setContent(content);
    }
    Base.prototype.translate = function (endPoint) {
        this.translater.translate(endPoint);
    };
    Base.prototype.setPending = function (pending) {
        this.pending = pending;
    };
    Base.prototype.setForceStopped = function (forceStopped) {
        this.forceStopped = forceStopped;
    };
    Base.prototype.setCallStop = function (called) {
        this.callStopWhenPending = called;
    };
    Base.prototype.setContent = function (content) {
        if (this.content !== content) {
            this.content = content;
            this.style = content.style;
            this.stop();
        }
    };
    Base.prototype.clearTimer = function () {
        if (this.timer) {
            cancelAnimationFrame(this.timer);
            this.timer = 0;
        }
    };
    Base.prototype.destroy = function () {
        this.hooks.destroy();
        cancelAnimationFrame(this.timer);
    };
    return Base;
}());

// iOS 13.6 - 14.x, window.getComputedStyle sometimes will get wrong transform value
// when bs use transition mode
// eg: translateY -100px -> -200px, when the last frame which is about to scroll to -200px
// window.getComputedStyle(this.content) will calculate transformY to be -100px(startPoint)
// it is weird
// so we should validate position caculated by 'window.getComputedStyle'
var isValidPostion = function (startPoint, endPoint, currentPos, prePos) {
    var computeDirection = function (endValue, startValue) {
        var delta = endValue - startValue;
        var direction = delta > 0
            ? -1 /* Negative */
            : delta < 0
                ? 1 /* Positive */
                : 0 /* Default */;
        return direction;
    };
    var directionX = computeDirection(endPoint.x, startPoint.x);
    var directionY = computeDirection(endPoint.y, startPoint.y);
    var deltaX = currentPos.x - prePos.x;
    var deltaY = currentPos.y - prePos.y;
    return directionX * deltaX <= 0 && directionY * deltaY <= 0;
};

var Transition = /** @class */ (function (_super) {
    __extends(Transition, _super);
    function Transition() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Transition.prototype.startProbe = function (startPoint, endPoint) {
        var _this = this;
        var prePos = startPoint;
        var probe = function () {
            var pos = _this.translater.getComputedPosition();
            if (isValidPostion(startPoint, endPoint, pos, prePos)) {
                _this.hooks.trigger(_this.hooks.eventTypes.move, pos);
            }
            // call bs.stop() should not dispatch end hook again.
            // forceStop hook will do this.
            /* istanbul ignore if  */
            if (!_this.pending) {
                if (_this.callStopWhenPending) {
                    _this.callStopWhenPending = false;
                }
                else {
                    // transition ends should dispatch end hook.
                    _this.hooks.trigger(_this.hooks.eventTypes.end, pos);
                }
            }
            prePos = pos;
            if (_this.pending) {
                _this.timer = requestAnimationFrame(probe);
            }
        };
        // when manually call bs.stop(), then bs.scrollTo()
        // we should reset callStopWhenPending to dispatch end hook
        if (this.callStopWhenPending) {
            this.setCallStop(false);
        }
        cancelAnimationFrame(this.timer);
        probe();
    };
    Transition.prototype.transitionTime = function (time) {
        if (time === void 0) { time = 0; }
        this.style[better_scroll_esm_style.transitionDuration] = time + 'ms';
        this.hooks.trigger(this.hooks.eventTypes.time, time);
    };
    Transition.prototype.transitionTimingFunction = function (easing) {
        this.style[better_scroll_esm_style.transitionTimingFunction] = easing;
        this.hooks.trigger(this.hooks.eventTypes.timeFunction, easing);
    };
    Transition.prototype.transitionProperty = function () {
        this.style[better_scroll_esm_style.transitionProperty] = better_scroll_esm_style.transform;
    };
    Transition.prototype.move = function (startPoint, endPoint, time, easingFn) {
        this.setPending(time > 0);
        this.transitionTimingFunction(easingFn);
        this.transitionProperty();
        this.transitionTime(time);
        this.translate(endPoint);
        var isRealtimeProbeType = this.options.probeType === 3 /* Realtime */;
        if (time && isRealtimeProbeType) {
            this.startProbe(startPoint, endPoint);
        }
        // if we change content's transformY in a tick
        // such as: 0 -> 50px -> 0
        // transitionend will not be triggered
        // so we forceupdate by reflow
        if (!time) {
            this._reflow = this.content.offsetHeight;
            if (isRealtimeProbeType) {
                this.hooks.trigger(this.hooks.eventTypes.move, endPoint);
            }
            this.hooks.trigger(this.hooks.eventTypes.end, endPoint);
        }
    };
    Transition.prototype.doStop = function () {
        var pending = this.pending;
        this.setForceStopped(false);
        this.setCallStop(false);
        // still in transition
        if (pending) {
            this.setPending(false);
            cancelAnimationFrame(this.timer);
            var _a = this.translater.getComputedPosition(), x = _a.x, y = _a.y;
            this.transitionTime();
            this.translate({ x: x, y: y });
            this.setForceStopped(true);
            this.setCallStop(true);
            this.hooks.trigger(this.hooks.eventTypes.forceStop, { x: x, y: y });
        }
        return pending;
    };
    Transition.prototype.stop = function () {
        var stopFromTransition = this.doStop();
        if (stopFromTransition) {
            this.hooks.trigger(this.hooks.eventTypes.callStop);
        }
    };
    return Transition;
}(Base));

var Animation = /** @class */ (function (_super) {
    __extends(Animation, _super);
    function Animation() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Animation.prototype.move = function (startPoint, endPoint, time, easingFn) {
        // time is 0
        if (!time) {
            this.translate(endPoint);
            if (this.options.probeType === 3 /* Realtime */) {
                this.hooks.trigger(this.hooks.eventTypes.move, endPoint);
            }
            this.hooks.trigger(this.hooks.eventTypes.end, endPoint);
            return;
        }
        this.animate(startPoint, endPoint, time, easingFn);
    };
    Animation.prototype.animate = function (startPoint, endPoint, duration, easingFn) {
        var _this = this;
        var startTime = getNow();
        var destTime = startTime + duration;
        var isRealtimeProbeType = this.options.probeType === 3 /* Realtime */;
        var step = function () {
            var now = getNow();
            // js animation end
            if (now >= destTime) {
                _this.translate(endPoint);
                if (isRealtimeProbeType) {
                    _this.hooks.trigger(_this.hooks.eventTypes.move, endPoint);
                }
                _this.hooks.trigger(_this.hooks.eventTypes.end, endPoint);
                return;
            }
            now = (now - startTime) / duration;
            var easing = easingFn(now);
            var newPoint = {};
            Object.keys(endPoint).forEach(function (key) {
                var startValue = startPoint[key];
                var endValue = endPoint[key];
                newPoint[key] = (endValue - startValue) * easing + startValue;
            });
            _this.translate(newPoint);
            if (isRealtimeProbeType) {
                _this.hooks.trigger(_this.hooks.eventTypes.move, newPoint);
            }
            if (_this.pending) {
                _this.timer = requestAnimationFrame(step);
            }
            // call bs.stop() should not dispatch end hook again.
            // forceStop hook will do this.
            /* istanbul ignore if  */
            if (!_this.pending) {
                if (_this.callStopWhenPending) {
                    _this.callStopWhenPending = false;
                }
                else {
                    // raf ends should dispatch end hook.
                    _this.hooks.trigger(_this.hooks.eventTypes.end, endPoint);
                }
            }
        };
        this.setPending(true);
        // when manually call bs.stop(), then bs.scrollTo()
        // we should reset callStopWhenPending to dispatch end hook
        if (this.callStopWhenPending) {
            this.setCallStop(false);
        }
        cancelAnimationFrame(this.timer);
        step();
    };
    Animation.prototype.doStop = function () {
        var pending = this.pending;
        this.setForceStopped(false);
        this.setCallStop(false);
        // still in requestFrameAnimation
        if (pending) {
            this.setPending(false);
            cancelAnimationFrame(this.timer);
            var pos = this.translater.getComputedPosition();
            this.setForceStopped(true);
            this.setCallStop(true);
            this.hooks.trigger(this.hooks.eventTypes.forceStop, pos);
        }
        return pending;
    };
    Animation.prototype.stop = function () {
        var stopFromAnimation = this.doStop();
        if (stopFromAnimation) {
            this.hooks.trigger(this.hooks.eventTypes.callStop);
        }
    };
    return Animation;
}(Base));

function createAnimater(element, translater, options) {
    var useTransition = options.useTransition;
    var animaterOptions = {};
    Object.defineProperty(animaterOptions, 'probeType', {
        enumerable: true,
        configurable: false,
        get: function () {
            return options.probeType;
        },
    });
    if (useTransition) {
        return new Transition(element, translater, animaterOptions);
    }
    else {
        return new Animation(element, translater, animaterOptions);
    }
}

var Behavior = /** @class */ (function () {
    function Behavior(wrapper, content, options) {
        this.wrapper = wrapper;
        this.options = options;
        this.hooks = new EventEmitter([
            'beforeComputeBoundary',
            'computeBoundary',
            'momentum',
            'end',
            'ignoreHasScroll'
        ]);
        this.refresh(content);
    }
    Behavior.prototype.start = function () {
        this.dist = 0;
        this.setMovingDirection(0 /* Default */);
        this.setDirection(0 /* Default */);
    };
    Behavior.prototype.move = function (delta) {
        delta = this.hasScroll ? delta : 0;
        this.setMovingDirection(delta);
        return this.performDampingAlgorithm(delta, this.options.outOfBoundaryDampingFactor);
    };
    Behavior.prototype.setMovingDirection = function (delta) {
        this.movingDirection =
            delta > 0
                ? -1 /* Negative */
                : delta < 0
                    ? 1 /* Positive */
                    : 0 /* Default */;
    };
    Behavior.prototype.setDirection = function (delta) {
        this.direction =
            delta > 0
                ? -1 /* Negative */
                : delta < 0
                    ? 1 /* Positive */
                    : 0 /* Default */;
    };
    Behavior.prototype.performDampingAlgorithm = function (delta, dampingFactor) {
        var newPos = this.currentPos + delta;
        // Slow down or stop if outside of the boundaries
        if (newPos > this.minScrollPos || newPos < this.maxScrollPos) {
            if ((newPos > this.minScrollPos && this.options.bounces[0]) ||
                (newPos < this.maxScrollPos && this.options.bounces[1])) {
                newPos = this.currentPos + delta * dampingFactor;
            }
            else {
                newPos =
                    newPos > this.minScrollPos ? this.minScrollPos : this.maxScrollPos;
            }
        }
        return newPos;
    };
    Behavior.prototype.end = function (duration) {
        var momentumInfo = {
            duration: 0
        };
        var absDist = Math.abs(this.currentPos - this.startPos);
        // start momentum animation if needed
        if (this.options.momentum &&
            duration < this.options.momentumLimitTime &&
            absDist > this.options.momentumLimitDistance) {
            var wrapperSize = (this.direction === -1 /* Negative */ && this.options.bounces[0]) ||
                (this.direction === 1 /* Positive */ && this.options.bounces[1])
                ? this.wrapperSize
                : 0;
            momentumInfo = this.hasScroll
                ? this.momentum(this.currentPos, this.startPos, duration, this.maxScrollPos, this.minScrollPos, wrapperSize, this.options)
                : { destination: this.currentPos, duration: 0 };
        }
        else {
            this.hooks.trigger(this.hooks.eventTypes.end, momentumInfo);
        }
        return momentumInfo;
    };
    Behavior.prototype.momentum = function (current, start, time, lowerMargin, upperMargin, wrapperSize, options) {
        if (options === void 0) { options = this.options; }
        var distance = current - start;
        var speed = Math.abs(distance) / time;
        var deceleration = options.deceleration, swipeBounceTime = options.swipeBounceTime, swipeTime = options.swipeTime;
        var duration = Math.min(swipeTime, (speed * 2) / deceleration);
        var momentumData = {
            destination: current + ((speed * speed) / deceleration) * (distance < 0 ? -1 : 1),
            duration: duration,
            rate: 15
        };
        this.hooks.trigger(this.hooks.eventTypes.momentum, momentumData, distance);
        if (momentumData.destination < lowerMargin) {
            momentumData.destination = wrapperSize
                ? Math.max(lowerMargin - wrapperSize / 4, lowerMargin - (wrapperSize / momentumData.rate) * speed)
                : lowerMargin;
            momentumData.duration = swipeBounceTime;
        }
        else if (momentumData.destination > upperMargin) {
            momentumData.destination = wrapperSize
                ? Math.min(upperMargin + wrapperSize / 4, upperMargin + (wrapperSize / momentumData.rate) * speed)
                : upperMargin;
            momentumData.duration = swipeBounceTime;
        }
        momentumData.destination = Math.round(momentumData.destination);
        return momentumData;
    };
    Behavior.prototype.updateDirection = function () {
        var absDist = this.currentPos - this.absStartPos;
        this.setDirection(absDist);
    };
    Behavior.prototype.refresh = function (content) {
        var _a = this.options.rect, size = _a.size, position = _a.position;
        var isWrapperStatic = window.getComputedStyle(this.wrapper, null).position === 'static';
        // Force reflow
        var wrapperRect = getRect(this.wrapper);
        // use client is more fair than offset
        this.wrapperSize = this.wrapper[size === 'width' ? 'clientWidth' : 'clientHeight'];
        this.setContent(content);
        var contentRect = getRect(this.content);
        this.contentSize = contentRect[size];
        this.relativeOffset = contentRect[position];
        /* istanbul ignore if  */
        if (isWrapperStatic) {
            this.relativeOffset -= wrapperRect[position];
        }
        this.computeBoundary();
        this.setDirection(0 /* Default */);
    };
    Behavior.prototype.setContent = function (content) {
        if (content !== this.content) {
            this.content = content;
            this.resetState();
        }
    };
    Behavior.prototype.resetState = function () {
        this.currentPos = 0;
        this.startPos = 0;
        this.dist = 0;
        this.setDirection(0 /* Default */);
        this.setMovingDirection(0 /* Default */);
        this.resetStartPos();
    };
    Behavior.prototype.computeBoundary = function () {
        this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);
        var boundary = {
            minScrollPos: 0,
            maxScrollPos: this.wrapperSize - this.contentSize
        };
        if (boundary.maxScrollPos < 0) {
            boundary.maxScrollPos -= this.relativeOffset;
            if (this.options.specifiedIndexAsContent === 0) {
                boundary.minScrollPos = -this.relativeOffset;
            }
        }
        this.hooks.trigger(this.hooks.eventTypes.computeBoundary, boundary);
        this.minScrollPos = boundary.minScrollPos;
        this.maxScrollPos = boundary.maxScrollPos;
        this.hasScroll =
            this.options.scrollable && this.maxScrollPos < this.minScrollPos;
        if (!this.hasScroll && this.minScrollPos < this.maxScrollPos) {
            this.maxScrollPos = this.minScrollPos;
            this.contentSize = this.wrapperSize;
        }
    };
    Behavior.prototype.updatePosition = function (pos) {
        this.currentPos = pos;
    };
    Behavior.prototype.getCurrentPos = function () {
        return this.currentPos;
    };
    Behavior.prototype.checkInBoundary = function () {
        var position = this.adjustPosition(this.currentPos);
        var inBoundary = position === this.getCurrentPos();
        return {
            position: position,
            inBoundary: inBoundary
        };
    };
    // adjust position when out of boundary
    Behavior.prototype.adjustPosition = function (pos) {
        if (!this.hasScroll &&
            !this.hooks.trigger(this.hooks.eventTypes.ignoreHasScroll)) {
            pos = this.minScrollPos;
        }
        else if (pos > this.minScrollPos) {
            pos = this.minScrollPos;
        }
        else if (pos < this.maxScrollPos) {
            pos = this.maxScrollPos;
        }
        return pos;
    };
    Behavior.prototype.updateStartPos = function () {
        this.startPos = this.currentPos;
    };
    Behavior.prototype.updateAbsStartPos = function () {
        this.absStartPos = this.currentPos;
    };
    Behavior.prototype.resetStartPos = function () {
        this.updateStartPos();
        this.updateAbsStartPos();
    };
    Behavior.prototype.getAbsDist = function (delta) {
        this.dist += delta;
        return Math.abs(this.dist);
    };
    Behavior.prototype.destroy = function () {
        this.hooks.destroy();
    };
    return Behavior;
}());

var _a, _b, _c, _d;
var PassthroughHandlers = (_a = {},
    _a["yes" /* Yes */] = function (e) {
        return true;
    },
    _a["no" /* No */] = function (e) {
        e.preventDefault();
        return false;
    },
    _a);
var DirectionMap = (_b = {},
    _b["horizontal" /* Horizontal */] = (_c = {},
        _c["yes" /* Yes */] = "horizontal" /* Horizontal */,
        _c["no" /* No */] = "vertical" /* Vertical */,
        _c),
    _b["vertical" /* Vertical */] = (_d = {},
        _d["yes" /* Yes */] = "vertical" /* Vertical */,
        _d["no" /* No */] = "horizontal" /* Horizontal */,
        _d),
    _b);
var DirectionLockAction = /** @class */ (function () {
    function DirectionLockAction(directionLockThreshold, freeScroll, eventPassthrough) {
        this.directionLockThreshold = directionLockThreshold;
        this.freeScroll = freeScroll;
        this.eventPassthrough = eventPassthrough;
        this.reset();
    }
    DirectionLockAction.prototype.reset = function () {
        this.directionLocked = "" /* Default */;
    };
    DirectionLockAction.prototype.checkMovingDirection = function (absDistX, absDistY, e) {
        this.computeDirectionLock(absDistX, absDistY);
        return this.handleEventPassthrough(e);
    };
    DirectionLockAction.prototype.adjustDelta = function (deltaX, deltaY) {
        if (this.directionLocked === "horizontal" /* Horizontal */) {
            deltaY = 0;
        }
        else if (this.directionLocked === "vertical" /* Vertical */) {
            deltaX = 0;
        }
        return {
            deltaX: deltaX,
            deltaY: deltaY
        };
    };
    DirectionLockAction.prototype.computeDirectionLock = function (absDistX, absDistY) {
        // If you are scrolling in one direction, lock it
        if (this.directionLocked === "" /* Default */ && !this.freeScroll) {
            if (absDistX > absDistY + this.directionLockThreshold) {
                this.directionLocked = "horizontal" /* Horizontal */; // lock horizontally
            }
            else if (absDistY >= absDistX + this.directionLockThreshold) {
                this.directionLocked = "vertical" /* Vertical */; // lock vertically
            }
            else {
                this.directionLocked = "none" /* None */; // no lock
            }
        }
    };
    DirectionLockAction.prototype.handleEventPassthrough = function (e) {
        var handleMap = DirectionMap[this.directionLocked];
        if (handleMap) {
            if (this.eventPassthrough === handleMap["yes" /* Yes */]) {
                return PassthroughHandlers["yes" /* Yes */](e);
            }
            else if (this.eventPassthrough === handleMap["no" /* No */]) {
                return PassthroughHandlers["no" /* No */](e);
            }
        }
        return false;
    };
    return DirectionLockAction;
}());

var applyQuadrantTransformation = function (deltaX, deltaY, quadrant) {
    if (quadrant === 2 /* Second */) {
        return [deltaY, -deltaX];
    }
    else if (quadrant === 3 /* Third */) {
        return [-deltaX, -deltaY];
    }
    else if (quadrant === 4 /* Forth */) {
        return [-deltaY, deltaX];
    }
    else {
        return [deltaX, deltaY];
    }
};
var ScrollerActions = /** @class */ (function () {
    function ScrollerActions(scrollBehaviorX, scrollBehaviorY, actionsHandler, animater, options) {
        this.hooks = new EventEmitter([
            'start',
            'beforeMove',
            'scrollStart',
            'scroll',
            'beforeEnd',
            'end',
            'scrollEnd',
            'contentNotMoved',
            'detectMovingDirection',
            'coordinateTransformation',
        ]);
        this.scrollBehaviorX = scrollBehaviorX;
        this.scrollBehaviorY = scrollBehaviorY;
        this.actionsHandler = actionsHandler;
        this.animater = animater;
        this.options = options;
        this.directionLockAction = new DirectionLockAction(options.directionLockThreshold, options.freeScroll, options.eventPassthrough);
        this.enabled = true;
        this.bindActionsHandler();
    }
    ScrollerActions.prototype.bindActionsHandler = function () {
        var _this = this;
        // [mouse|touch]start event
        this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start, function (e) {
            if (!_this.enabled)
                return true;
            return _this.handleStart(e);
        });
        // [mouse|touch]move event
        this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move, function (_a) {
            var deltaX = _a.deltaX, deltaY = _a.deltaY, e = _a.e;
            if (!_this.enabled)
                return true;
            var _b = applyQuadrantTransformation(deltaX, deltaY, _this.options.quadrant), transformateDeltaX = _b[0], transformateDeltaY = _b[1];
            var transformateDeltaData = {
                deltaX: transformateDeltaX,
                deltaY: transformateDeltaY,
            };
            _this.hooks.trigger(_this.hooks.eventTypes.coordinateTransformation, transformateDeltaData);
            return _this.handleMove(transformateDeltaData.deltaX, transformateDeltaData.deltaY, e);
        });
        // [mouse|touch]end event
        this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end, function (e) {
            if (!_this.enabled)
                return true;
            return _this.handleEnd(e);
        });
        // click
        this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click, function (e) {
            // handle native click event
            if (_this.enabled && !e._constructed) {
                _this.handleClick(e);
            }
        });
    };
    ScrollerActions.prototype.handleStart = function (e) {
        var timestamp = getNow();
        this.fingerMoved = false;
        this.contentMoved = false;
        this.startTime = timestamp;
        this.directionLockAction.reset();
        this.scrollBehaviorX.start();
        this.scrollBehaviorY.start();
        // force stopping last transition or animation
        this.animater.doStop();
        this.scrollBehaviorX.resetStartPos();
        this.scrollBehaviorY.resetStartPos();
        this.hooks.trigger(this.hooks.eventTypes.start, e);
    };
    ScrollerActions.prototype.handleMove = function (deltaX, deltaY, e) {
        if (this.hooks.trigger(this.hooks.eventTypes.beforeMove, e)) {
            return;
        }
        var absDistX = this.scrollBehaviorX.getAbsDist(deltaX);
        var absDistY = this.scrollBehaviorY.getAbsDist(deltaY);
        var timestamp = getNow();
        // We need to move at least momentumLimitDistance pixels
        // for the scrolling to initiate
        if (this.checkMomentum(absDistX, absDistY, timestamp)) {
            return true;
        }
        if (this.directionLockAction.checkMovingDirection(absDistX, absDistY, e)) {
            this.actionsHandler.setInitiated();
            return true;
        }
        var delta = this.directionLockAction.adjustDelta(deltaX, deltaY);
        var prevX = this.scrollBehaviorX.getCurrentPos();
        var newX = this.scrollBehaviorX.move(delta.deltaX);
        var prevY = this.scrollBehaviorY.getCurrentPos();
        var newY = this.scrollBehaviorY.move(delta.deltaY);
        if (this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)) {
            return;
        }
        if (!this.fingerMoved) {
            this.fingerMoved = true;
        }
        var positionChanged = newX !== prevX || newY !== prevY;
        if (!this.contentMoved && !positionChanged) {
            this.hooks.trigger(this.hooks.eventTypes.contentNotMoved);
        }
        if (!this.contentMoved && positionChanged) {
            this.contentMoved = true;
            this.hooks.trigger(this.hooks.eventTypes.scrollStart);
        }
        if (this.contentMoved && positionChanged) {
            this.animater.translate({
                x: newX,
                y: newY,
            });
            this.dispatchScroll(timestamp);
        }
    };
    ScrollerActions.prototype.dispatchScroll = function (timestamp) {
        // dispatch scroll in interval time
        if (timestamp - this.startTime > this.options.momentumLimitTime) {
            // refresh time and starting position to initiate a momentum
            this.startTime = timestamp;
            this.scrollBehaviorX.updateStartPos();
            this.scrollBehaviorY.updateStartPos();
            if (this.options.probeType === 1 /* Throttle */) {
                this.hooks.trigger(this.hooks.eventTypes.scroll, this.getCurrentPos());
            }
        }
        // dispatch scroll all the time
        if (this.options.probeType > 1 /* Throttle */) {
            this.hooks.trigger(this.hooks.eventTypes.scroll, this.getCurrentPos());
        }
    };
    ScrollerActions.prototype.checkMomentum = function (absDistX, absDistY, timestamp) {
        return (timestamp - this.endTime > this.options.momentumLimitTime &&
            absDistY < this.options.momentumLimitDistance &&
            absDistX < this.options.momentumLimitDistance);
    };
    ScrollerActions.prototype.handleEnd = function (e) {
        if (this.hooks.trigger(this.hooks.eventTypes.beforeEnd, e)) {
            return;
        }
        var currentPos = this.getCurrentPos();
        this.scrollBehaviorX.updateDirection();
        this.scrollBehaviorY.updateDirection();
        if (this.hooks.trigger(this.hooks.eventTypes.end, e, currentPos)) {
            return true;
        }
        currentPos = this.ensureIntegerPos(currentPos);
        this.animater.translate(currentPos);
        this.endTime = getNow();
        var duration = this.endTime - this.startTime;
        this.hooks.trigger(this.hooks.eventTypes.scrollEnd, currentPos, duration);
    };
    ScrollerActions.prototype.ensureIntegerPos = function (currentPos) {
        this.ensuringInteger = true;
        var x = currentPos.x, y = currentPos.y;
        var _a = this.scrollBehaviorX, minScrollPosX = _a.minScrollPos, maxScrollPosX = _a.maxScrollPos;
        var _b = this.scrollBehaviorY, minScrollPosY = _b.minScrollPos, maxScrollPosY = _b.maxScrollPos;
        x = x > 0 ? Math.ceil(x) : Math.floor(x);
        y = y > 0 ? Math.ceil(y) : Math.floor(y);
        x = between(x, maxScrollPosX, minScrollPosX);
        y = between(y, maxScrollPosY, minScrollPosY);
        return { x: x, y: y };
    };
    ScrollerActions.prototype.handleClick = function (e) {
        if (!preventDefaultExceptionFn(e.target, this.options.preventDefaultException)) {
            e.preventDefault();
            e.stopPropagation();
        }
    };
    ScrollerActions.prototype.getCurrentPos = function () {
        return {
            x: this.scrollBehaviorX.getCurrentPos(),
            y: this.scrollBehaviorY.getCurrentPos(),
        };
    };
    ScrollerActions.prototype.refresh = function () {
        this.endTime = 0;
    };
    ScrollerActions.prototype.destroy = function () {
        this.hooks.destroy();
    };
    return ScrollerActions;
}());

function createActionsHandlerOptions(bsOptions) {
    var options = [
        'click',
        'bindToWrapper',
        'disableMouse',
        'disableTouch',
        'preventDefault',
        'stopPropagation',
        'tagException',
        'preventDefaultException',
        'autoEndDistance',
    ].reduce(function (prev, cur) {
        prev[cur] = bsOptions[cur];
        return prev;
    }, {});
    return options;
}
function createBehaviorOptions(bsOptions, extraProp, bounces, rect) {
    var options = [
        'momentum',
        'momentumLimitTime',
        'momentumLimitDistance',
        'deceleration',
        'swipeBounceTime',
        'swipeTime',
        'outOfBoundaryDampingFactor',
        'specifiedIndexAsContent',
    ].reduce(function (prev, cur) {
        prev[cur] = bsOptions[cur];
        return prev;
    }, {});
    // add extra property
    options.scrollable = !!bsOptions[extraProp];
    options.bounces = bounces;
    options.rect = rect;
    return options;
}

function bubbling(source, target, events) {
    events.forEach(function (event) {
        var sourceEvent;
        var targetEvent;
        if (typeof event === 'string') {
            sourceEvent = targetEvent = event;
        }
        else {
            sourceEvent = event.source;
            targetEvent = event.target;
        }
        source.on(sourceEvent, function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            return target.trigger.apply(target, __spreadArrays([targetEvent], args));
        });
    });
}

function isSamePoint(startPoint, endPoint) {
    // keys of startPoint and endPoint should be equal
    var keys = Object.keys(startPoint);
    for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
        var key = keys_1[_i];
        if (startPoint[key] !== endPoint[key])
            return false;
    }
    return true;
}

var MIN_SCROLL_DISTANCE = 1;
var Scroller = /** @class */ (function () {
    function Scroller(wrapper, content, options) {
        this.wrapper = wrapper;
        this.content = content;
        this.resizeTimeout = 0;
        this.hooks = new EventEmitter([
            'beforeStart',
            'beforeMove',
            'beforeScrollStart',
            'scrollStart',
            'scroll',
            'beforeEnd',
            'scrollEnd',
            'resize',
            'touchEnd',
            'end',
            'flick',
            'scrollCancel',
            'momentum',
            'scrollTo',
            'minDistanceScroll',
            'scrollToElement',
            'beforeRefresh',
        ]);
        this.options = options;
        var _a = this.options.bounce, left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
        // direction X
        this.scrollBehaviorX = new Behavior(wrapper, content, createBehaviorOptions(options, 'scrollX', [left, right], {
            size: 'width',
            position: 'left',
        }));
        // direction Y
        this.scrollBehaviorY = new Behavior(wrapper, content, createBehaviorOptions(options, 'scrollY', [top, bottom], {
            size: 'height',
            position: 'top',
        }));
        this.translater = new Translater(this.content);
        this.animater = createAnimater(this.content, this.translater, this.options);
        this.actionsHandler = new ActionsHandler(this.options.bindToTarget ? this.content : wrapper, createActionsHandlerOptions(this.options));
        this.actions = new ScrollerActions(this.scrollBehaviorX, this.scrollBehaviorY, this.actionsHandler, this.animater, this.options);
        var resizeHandler = this.resize.bind(this);
        this.resizeRegister = new EventRegister(window, [
            {
                name: 'orientationchange',
                handler: resizeHandler,
            },
            {
                name: 'resize',
                handler: resizeHandler,
            },
        ]);
        this.registerTransitionEnd();
        this.init();
    }
    Scroller.prototype.init = function () {
        var _this = this;
        this.bindTranslater();
        this.bindAnimater();
        this.bindActions();
        // enable pointer events when scrolling ends
        this.hooks.on(this.hooks.eventTypes.scrollEnd, function () {
            _this.togglePointerEvents(true);
        });
    };
    Scroller.prototype.registerTransitionEnd = function () {
        this.transitionEndRegister = new EventRegister(this.content, [
            {
                name: better_scroll_esm_style.transitionEnd,
                handler: this.transitionEnd.bind(this),
            },
        ]);
    };
    Scroller.prototype.bindTranslater = function () {
        var _this = this;
        var hooks = this.translater.hooks;
        hooks.on(hooks.eventTypes.beforeTranslate, function (transformStyle) {
            if (_this.options.translateZ) {
                transformStyle.push(_this.options.translateZ);
            }
        });
        // disable pointer events when scrolling
        hooks.on(hooks.eventTypes.translate, function (pos) {
            var prevPos = _this.getCurrentPos();
            _this.updatePositions(pos);
            // scrollEnd will dispatch when scroll is force stopping in touchstart handler
            // so in touchend handler, don't toggle pointer-events
            if (_this.actions.ensuringInteger === true) {
                _this.actions.ensuringInteger = false;
                return;
            }
            // a valid translate
            if (pos.x !== prevPos.x || pos.y !== prevPos.y) {
                _this.togglePointerEvents(false);
            }
        });
    };
    Scroller.prototype.bindAnimater = function () {
        var _this = this;
        // reset position
        this.animater.hooks.on(this.animater.hooks.eventTypes.end, function (pos) {
            if (!_this.resetPosition(_this.options.bounceTime)) {
                _this.animater.setPending(false);
                _this.hooks.trigger(_this.hooks.eventTypes.scrollEnd, pos);
            }
        });
        bubbling(this.animater.hooks, this.hooks, [
            {
                source: this.animater.hooks.eventTypes.move,
                target: this.hooks.eventTypes.scroll,
            },
            {
                source: this.animater.hooks.eventTypes.forceStop,
                target: this.hooks.eventTypes.scrollEnd,
            },
        ]);
    };
    Scroller.prototype.bindActions = function () {
        var _this = this;
        var actions = this.actions;
        bubbling(actions.hooks, this.hooks, [
            {
                source: actions.hooks.eventTypes.start,
                target: this.hooks.eventTypes.beforeStart,
            },
            {
                source: actions.hooks.eventTypes.start,
                target: this.hooks.eventTypes.beforeScrollStart,
            },
            {
                source: actions.hooks.eventTypes.beforeMove,
                target: this.hooks.eventTypes.beforeMove,
            },
            {
                source: actions.hooks.eventTypes.scrollStart,
                target: this.hooks.eventTypes.scrollStart,
            },
            {
                source: actions.hooks.eventTypes.scroll,
                target: this.hooks.eventTypes.scroll,
            },
            {
                source: actions.hooks.eventTypes.beforeEnd,
                target: this.hooks.eventTypes.beforeEnd,
            },
        ]);
        actions.hooks.on(actions.hooks.eventTypes.end, function (e, pos) {
            _this.hooks.trigger(_this.hooks.eventTypes.touchEnd, pos);
            if (_this.hooks.trigger(_this.hooks.eventTypes.end, pos)) {
                return true;
            }
            // check if it is a click operation
            if (!actions.fingerMoved) {
                _this.hooks.trigger(_this.hooks.eventTypes.scrollCancel);
                if (_this.checkClick(e)) {
                    return true;
                }
            }
            // reset if we are outside of the boundaries
            if (_this.resetPosition(_this.options.bounceTime, ease.bounce)) {
                _this.animater.setForceStopped(false);
                return true;
            }
        });
        actions.hooks.on(actions.hooks.eventTypes.scrollEnd, function (pos, duration) {
            var deltaX = Math.abs(pos.x - _this.scrollBehaviorX.startPos);
            var deltaY = Math.abs(pos.y - _this.scrollBehaviorY.startPos);
            if (_this.checkFlick(duration, deltaX, deltaY)) {
                _this.animater.setForceStopped(false);
                _this.hooks.trigger(_this.hooks.eventTypes.flick);
                return;
            }
            if (_this.momentum(pos, duration)) {
                _this.animater.setForceStopped(false);
                return;
            }
            if (actions.contentMoved) {
                _this.hooks.trigger(_this.hooks.eventTypes.scrollEnd, pos);
            }
            if (_this.animater.forceStopped) {
                _this.animater.setForceStopped(false);
            }
        });
    };
    Scroller.prototype.checkFlick = function (duration, deltaX, deltaY) {
        var flickMinMovingDistance = 1; // distinguish flick from click
        if (this.hooks.events.flick.length > 1 &&
            duration < this.options.flickLimitTime &&
            deltaX < this.options.flickLimitDistance &&
            deltaY < this.options.flickLimitDistance &&
            (deltaY > flickMinMovingDistance || deltaX > flickMinMovingDistance)) {
            return true;
        }
    };
    Scroller.prototype.momentum = function (pos, duration) {
        var meta = {
            time: 0,
            easing: ease.swiper,
            newX: pos.x,
            newY: pos.y,
        };
        // start momentum animation if needed
        var momentumX = this.scrollBehaviorX.end(duration);
        var momentumY = this.scrollBehaviorY.end(duration);
        meta.newX = isUndef(momentumX.destination)
            ? meta.newX
            : momentumX.destination;
        meta.newY = isUndef(momentumY.destination)
            ? meta.newY
            : momentumY.destination;
        meta.time = Math.max(momentumX.duration, momentumY.duration);
        this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this);
        // when x or y changed, do momentum animation now!
        if (meta.newX !== pos.x || meta.newY !== pos.y) {
            // change easing function when scroller goes out of the boundaries
            if (meta.newX > this.scrollBehaviorX.minScrollPos ||
                meta.newX < this.scrollBehaviorX.maxScrollPos ||
                meta.newY > this.scrollBehaviorY.minScrollPos ||
                meta.newY < this.scrollBehaviorY.maxScrollPos) {
                meta.easing = ease.swipeBounce;
            }
            this.scrollTo(meta.newX, meta.newY, meta.time, meta.easing);
            return true;
        }
    };
    Scroller.prototype.checkClick = function (e) {
        var cancelable = {
            preventClick: this.animater.forceStopped,
        };
        // we scrolled less than momentumLimitDistance pixels
        if (this.hooks.trigger(this.hooks.eventTypes.checkClick)) {
            this.animater.setForceStopped(false);
            return true;
        }
        if (!cancelable.preventClick) {
            var _dblclick = this.options.dblclick;
            var dblclickTrigged = false;
            if (_dblclick && this.lastClickTime) {
                var _a = _dblclick.delay, delay = _a === void 0 ? 300 : _a;
                if (getNow() - this.lastClickTime < delay) {
                    dblclickTrigged = true;
                    dblclick(e);
                }
            }
            if (this.options.tap) {
                tap(e, this.options.tap);
            }
            if (this.options.click &&
                !preventDefaultExceptionFn(e.target, this.options.preventDefaultException)) {
                click(e);
            }
            this.lastClickTime = dblclickTrigged ? null : getNow();
            return true;
        }
        return false;
    };
    Scroller.prototype.resize = function () {
        var _this = this;
        if (!this.actions.enabled) {
            return;
        }
        // fix a scroll problem under Android condition
        /* istanbul ignore if  */
        if (isAndroid) {
            this.wrapper.scrollTop = 0;
        }
        clearTimeout(this.resizeTimeout);
        this.resizeTimeout = window.setTimeout(function () {
            _this.hooks.trigger(_this.hooks.eventTypes.resize);
        }, this.options.resizePolling);
    };
    /* istanbul ignore next */
    Scroller.prototype.transitionEnd = function (e) {
        if (e.target !== this.content || !this.animater.pending) {
            return;
        }
        var animater = this.animater;
        animater.transitionTime();
        if (!this.resetPosition(this.options.bounceTime, ease.bounce)) {
            this.animater.setPending(false);
            if (this.options.probeType !== 3 /* Realtime */) {
                this.hooks.trigger(this.hooks.eventTypes.scrollEnd, this.getCurrentPos());
            }
        }
    };
    Scroller.prototype.togglePointerEvents = function (enabled) {
        if (enabled === void 0) { enabled = true; }
        var el = this.content.children.length
            ? this.content.children
            : [this.content];
        var pointerEvents = enabled ? 'auto' : 'none';
        for (var i = 0; i < el.length; i++) {
            var node = el[i];
            // ignore BetterScroll instance's wrapper DOM
            /* istanbul ignore if  */
            if (node.isBScrollContainer) {
                continue;
            }
            node.style.pointerEvents = pointerEvents;
        }
    };
    Scroller.prototype.refresh = function (content) {
        var contentChanged = this.setContent(content);
        this.hooks.trigger(this.hooks.eventTypes.beforeRefresh);
        this.scrollBehaviorX.refresh(content);
        this.scrollBehaviorY.refresh(content);
        if (contentChanged) {
            this.translater.setContent(content);
            this.animater.setContent(content);
            this.transitionEndRegister.destroy();
            this.registerTransitionEnd();
            if (this.options.bindToTarget) {
                this.actionsHandler.setContent(content);
            }
        }
        this.actions.refresh();
        this.wrapperOffset = better_scroll_esm_offset(this.wrapper);
    };
    Scroller.prototype.setContent = function (content) {
        var contentChanged = content !== this.content;
        if (contentChanged) {
            this.content = content;
        }
        return contentChanged;
    };
    Scroller.prototype.scrollBy = function (deltaX, deltaY, time, easing) {
        if (time === void 0) { time = 0; }
        var _a = this.getCurrentPos(), x = _a.x, y = _a.y;
        easing = !easing ? ease.bounce : easing;
        deltaX += x;
        deltaY += y;
        this.scrollTo(deltaX, deltaY, time, easing);
    };
    Scroller.prototype.scrollTo = function (x, y, time, easing, extraTransform) {
        if (time === void 0) { time = 0; }
        if (easing === void 0) { easing = ease.bounce; }
        if (extraTransform === void 0) { extraTransform = {
            start: {},
            end: {},
        }; }
        var easingFn = this.options.useTransition ? easing.style : easing.fn;
        var currentPos = this.getCurrentPos();
        var startPoint = __assign({ x: currentPos.x, y: currentPos.y }, extraTransform.start);
        var endPoint = __assign({ x: x,
            y: y }, extraTransform.end);
        this.hooks.trigger(this.hooks.eventTypes.scrollTo, endPoint);
        // it is an useless move
        if (isSamePoint(startPoint, endPoint))
            return;
        var deltaX = Math.abs(endPoint.x - startPoint.x);
        var deltaY = Math.abs(endPoint.y - startPoint.y);
        // considering of browser compatibility for decimal transform value
        // force translating immediately
        if (deltaX < MIN_SCROLL_DISTANCE && deltaY < MIN_SCROLL_DISTANCE) {
            time = 0;
            this.hooks.trigger(this.hooks.eventTypes.minDistanceScroll);
        }
        this.animater.move(startPoint, endPoint, time, easingFn);
    };
    Scroller.prototype.scrollToElement = function (el, time, offsetX, offsetY, easing) {
        var targetEle = getElement(el);
        var pos = better_scroll_esm_offset(targetEle);
        var getOffset = function (offset, size, wrapperSize) {
            if (typeof offset === 'number') {
                return offset;
            }
            // if offsetX/Y are true we center the element to the screen
            return offset ? Math.round(size / 2 - wrapperSize / 2) : 0;
        };
        offsetX = getOffset(offsetX, targetEle.offsetWidth, this.wrapper.offsetWidth);
        offsetY = getOffset(offsetY, targetEle.offsetHeight, this.wrapper.offsetHeight);
        var getPos = function (pos, wrapperPos, offset, scrollBehavior) {
            pos -= wrapperPos;
            pos = scrollBehavior.adjustPosition(pos - offset);
            return pos;
        };
        pos.left = getPos(pos.left, this.wrapperOffset.left, offsetX, this.scrollBehaviorX);
        pos.top = getPos(pos.top, this.wrapperOffset.top, offsetY, this.scrollBehaviorY);
        if (this.hooks.trigger(this.hooks.eventTypes.scrollToElement, targetEle, pos)) {
            return;
        }
        this.scrollTo(pos.left, pos.top, time, easing);
    };
    Scroller.prototype.resetPosition = function (time, easing) {
        if (time === void 0) { time = 0; }
        if (easing === void 0) { easing = ease.bounce; }
        var _a = this.scrollBehaviorX.checkInBoundary(), x = _a.position, xInBoundary = _a.inBoundary;
        var _b = this.scrollBehaviorY.checkInBoundary(), y = _b.position, yInBoundary = _b.inBoundary;
        if (xInBoundary && yInBoundary) {
            return false;
        }
        /* istanbul ignore if  */
        if (isIOSBadVersion) {
            // fix ios 13.4 bouncing
            // see it in issues 982
            this.reflow();
        }
        // out of boundary
        this.scrollTo(x, y, time, easing);
        return true;
    };
    /* istanbul ignore next */
    Scroller.prototype.reflow = function () {
        this._reflow = this.content.offsetHeight;
    };
    Scroller.prototype.updatePositions = function (pos) {
        this.scrollBehaviorX.updatePosition(pos.x);
        this.scrollBehaviorY.updatePosition(pos.y);
    };
    Scroller.prototype.getCurrentPos = function () {
        return this.actions.getCurrentPos();
    };
    Scroller.prototype.enable = function () {
        this.actions.enabled = true;
    };
    Scroller.prototype.disable = function () {
        cancelAnimationFrame(this.animater.timer);
        this.actions.enabled = false;
    };
    Scroller.prototype.destroy = function () {
        var _this = this;
        var keys = [
            'resizeRegister',
            'transitionEndRegister',
            'actionsHandler',
            'actions',
            'hooks',
            'animater',
            'translater',
            'scrollBehaviorX',
            'scrollBehaviorY',
        ];
        keys.forEach(function (key) { return _this[key].destroy(); });
    };
    return Scroller;
}());

var BScrollConstructor = /** @class */ (function (_super) {
    __extends(BScrollConstructor, _super);
    function BScrollConstructor(el, options) {
        var _this = _super.call(this, [
            'refresh',
            'contentChanged',
            'enable',
            'disable',
            'beforeScrollStart',
            'scrollStart',
            'scroll',
            'scrollEnd',
            'scrollCancel',
            'touchEnd',
            'flick',
            'destroy'
        ]) || this;
        var wrapper = getElement(el);
        if (!wrapper) {
            warn('Can not resolve the wrapper DOM.');
            return _this;
        }
        _this.plugins = {};
        _this.options = new OptionsConstructor().merge(options).process();
        if (!_this.setContent(wrapper).valid) {
            return _this;
        }
        _this.hooks = new EventEmitter([
            'refresh',
            'enable',
            'disable',
            'destroy',
            'beforeInitialScrollTo',
            'contentChanged'
        ]);
        _this.init(wrapper);
        return _this;
    }
    BScrollConstructor.use = function (ctor) {
        var name = ctor.pluginName;
        var installed = BScrollConstructor.plugins.some(function (plugin) { return ctor === plugin.ctor; });
        if (installed)
            return BScrollConstructor;
        if (isUndef(name)) {
            warn("Plugin Class must specify plugin's name in static property by 'pluginName' field.");
            return BScrollConstructor;
        }
        BScrollConstructor.pluginsMap[name] = true;
        BScrollConstructor.plugins.push({
            name: name,
            applyOrder: ctor.applyOrder,
            ctor: ctor
        });
        return BScrollConstructor;
    };
    BScrollConstructor.prototype.setContent = function (wrapper) {
        var contentChanged = false;
        var valid = true;
        var content = wrapper.children[this.options.specifiedIndexAsContent];
        if (!content) {
            warn('The wrapper need at least one child element to be content element to scroll.');
            valid = false;
        }
        else {
            contentChanged = this.content !== content;
            if (contentChanged) {
                this.content = content;
            }
        }
        return {
            valid: valid,
            contentChanged: contentChanged
        };
    };
    BScrollConstructor.prototype.init = function (wrapper) {
        var _this = this;
        this.wrapper = wrapper;
        // mark wrapper to recognize bs instance by DOM attribute
        wrapper.isBScrollContainer = true;
        this.scroller = new Scroller(wrapper, this.content, this.options);
        this.scroller.hooks.on(this.scroller.hooks.eventTypes.resize, function () {
            _this.refresh();
        });
        this.eventBubbling();
        this.handleAutoBlur();
        this.enable();
        this.proxy(propertiesConfig$7);
        this.applyPlugins();
        // maybe boundary has changed, should refresh
        this.refreshWithoutReset(this.content);
        var _a = this.options, startX = _a.startX, startY = _a.startY;
        var position = {
            x: startX,
            y: startY
        };
        // maybe plugins want to control scroll position
        if (this.hooks.trigger(this.hooks.eventTypes.beforeInitialScrollTo, position)) {
            return;
        }
        this.scroller.scrollTo(position.x, position.y);
    };
    BScrollConstructor.prototype.applyPlugins = function () {
        var _this = this;
        var options = this.options;
        BScrollConstructor.plugins
            .sort(function (a, b) {
            var _a;
            var applyOrderMap = (_a = {},
                _a["pre" /* Pre */] = -1,
                _a["post" /* Post */] = 1,
                _a);
            var aOrder = a.applyOrder ? applyOrderMap[a.applyOrder] : 0;
            var bOrder = b.applyOrder ? applyOrderMap[b.applyOrder] : 0;
            return aOrder - bOrder;
        })
            .forEach(function (item) {
            var ctor = item.ctor;
            if (options[item.name] && typeof ctor === 'function') {
                _this.plugins[item.name] = new ctor(_this);
            }
        });
    };
    BScrollConstructor.prototype.handleAutoBlur = function () {
        /* istanbul ignore if  */
        if (this.options.autoBlur) {
            this.on(this.eventTypes.beforeScrollStart, function () {
                var activeElement = document.activeElement;
                if (activeElement &&
                    (activeElement.tagName === 'INPUT' ||
                        activeElement.tagName === 'TEXTAREA')) {
                    activeElement.blur();
                }
            });
        }
    };
    BScrollConstructor.prototype.eventBubbling = function () {
        bubbling(this.scroller.hooks, this, [
            this.eventTypes.beforeScrollStart,
            this.eventTypes.scrollStart,
            this.eventTypes.scroll,
            this.eventTypes.scrollEnd,
            this.eventTypes.scrollCancel,
            this.eventTypes.touchEnd,
            this.eventTypes.flick
        ]);
    };
    BScrollConstructor.prototype.refreshWithoutReset = function (content) {
        this.scroller.refresh(content);
        this.hooks.trigger(this.hooks.eventTypes.refresh, content);
        this.trigger(this.eventTypes.refresh, content);
    };
    BScrollConstructor.prototype.proxy = function (propertiesConfig) {
        var _this = this;
        propertiesConfig.forEach(function (_a) {
            var key = _a.key, sourceKey = _a.sourceKey;
            propertiesProxy(_this, sourceKey, key);
        });
    };
    BScrollConstructor.prototype.refresh = function () {
        var _a = this.setContent(this.wrapper), contentChanged = _a.contentChanged, valid = _a.valid;
        if (valid) {
            var content = this.content;
            this.refreshWithoutReset(content);
            if (contentChanged) {
                this.hooks.trigger(this.hooks.eventTypes.contentChanged, content);
                this.trigger(this.eventTypes.contentChanged, content);
            }
            this.scroller.resetPosition();
        }
    };
    BScrollConstructor.prototype.enable = function () {
        this.scroller.enable();
        this.hooks.trigger(this.hooks.eventTypes.enable);
        this.trigger(this.eventTypes.enable);
    };
    BScrollConstructor.prototype.disable = function () {
        this.scroller.disable();
        this.hooks.trigger(this.hooks.eventTypes.disable);
        this.trigger(this.eventTypes.disable);
    };
    BScrollConstructor.prototype.destroy = function () {
        this.hooks.trigger(this.hooks.eventTypes.destroy);
        this.trigger(this.eventTypes.destroy);
        this.scroller.destroy();
    };
    BScrollConstructor.prototype.eventRegister = function (names) {
        this.registerType(names);
    };
    BScrollConstructor.plugins = [];
    BScrollConstructor.pluginsMap = {};
    return BScrollConstructor;
}(EventEmitter));
function createBScroll(el, options) {
    var bs = new BScrollConstructor(el, options);
    return bs;
}
createBScroll.use = BScrollConstructor.use;
createBScroll.plugins = BScrollConstructor.plugins;
createBScroll.pluginsMap = BScrollConstructor.pluginsMap;
var BScroll = createBScroll;

var MouseWheel = /** @class */ (function () {
    function MouseWheel(scroll) {
        this.scroll = scroll;
        this.wheelEndTimer = 0;
        this.wheelMoveTimer = 0;
        this.wheelStart = false;
        this.init();
    }
    MouseWheel.prototype.init = function () {
        this.handleBScroll();
        this.handleOptions();
        this.handleHooks();
        this.registerEvent();
    };
    MouseWheel.prototype.handleBScroll = function () {
        this.scroll.registerType([
            'alterOptions',
            'mousewheelStart',
            'mousewheelMove',
            'mousewheelEnd',
        ]);
    };
    MouseWheel.prototype.handleOptions = function () {
        var userOptions = (this.scroll.options.mouseWheel === true
            ? {}
            : this.scroll.options.mouseWheel);
        var defaultOptions = {
            speed: 20,
            invert: false,
            easeTime: 300,
            discreteTime: 400,
            throttleTime: 0,
            dampingFactor: 0.1,
        };
        this.mouseWheelOpt = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    MouseWheel.prototype.handleHooks = function () {
        this.hooksFn = [];
        this.registerHooks(this.scroll.hooks, 'destroy', this.destroy);
    };
    MouseWheel.prototype.registerEvent = function () {
        this.eventRegister = new EventRegister(this.scroll.scroller.wrapper, [
            {
                name: 'wheel',
                handler: this.wheelHandler.bind(this),
            },
            {
                name: 'mousewheel',
                handler: this.wheelHandler.bind(this),
            },
            {
                name: 'DOMMouseScroll',
                handler: this.wheelHandler.bind(this),
            },
        ]);
    };
    MouseWheel.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    MouseWheel.prototype.wheelHandler = function (e) {
        if (!this.scroll.enabled) {
            return;
        }
        this.beforeHandler(e);
        // start
        if (!this.wheelStart) {
            this.wheelStartHandler(e);
            this.wheelStart = true;
        }
        // move
        var delta = this.getWheelDelta(e);
        this.wheelMoveHandler(delta);
        // end
        this.wheelEndDetector(delta);
    };
    MouseWheel.prototype.wheelStartHandler = function (e) {
        this.cleanCache();
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        scrollBehaviorX.setMovingDirection(0 /* Default */);
        scrollBehaviorY.setMovingDirection(0 /* Default */);
        scrollBehaviorX.setDirection(0 /* Default */);
        scrollBehaviorY.setDirection(0 /* Default */);
        this.scroll.trigger(this.scroll.eventTypes.alterOptions, this.mouseWheelOpt);
        this.scroll.trigger(this.scroll.eventTypes.mousewheelStart);
    };
    MouseWheel.prototype.cleanCache = function () {
        this.deltaCache = [];
    };
    MouseWheel.prototype.wheelMoveHandler = function (delta) {
        var _this = this;
        var _a = this.mouseWheelOpt, throttleTime = _a.throttleTime, dampingFactor = _a.dampingFactor;
        if (throttleTime && this.wheelMoveTimer) {
            this.deltaCache.push(delta);
        }
        else {
            var cachedDelta = this.deltaCache.reduce(function (prev, current) {
                return {
                    x: prev.x + current.x,
                    y: prev.y + current.y,
                };
            }, { x: 0, y: 0 });
            this.cleanCache();
            var _b = this.scroll.scroller, scrollBehaviorX = _b.scrollBehaviorX, scrollBehaviorY = _b.scrollBehaviorY;
            scrollBehaviorX.setMovingDirection(-delta.directionX);
            scrollBehaviorY.setMovingDirection(-delta.directionY);
            scrollBehaviorX.setDirection(delta.x);
            scrollBehaviorY.setDirection(delta.y);
            // when out of boundary, perform a damping scroll
            var newX = scrollBehaviorX.performDampingAlgorithm(Math.round(delta.x) + cachedDelta.x, dampingFactor);
            var newY = scrollBehaviorY.performDampingAlgorithm(Math.round(delta.y) + cachedDelta.x, dampingFactor);
            if (!this.scroll.trigger(this.scroll.eventTypes.mousewheelMove, {
                x: newX,
                y: newY,
            })) {
                var easeTime = this.getEaseTime();
                if (newX !== this.scroll.x || newY !== this.scroll.y) {
                    this.scroll.scrollTo(newX, newY, easeTime);
                }
            }
            if (throttleTime) {
                this.wheelMoveTimer = window.setTimeout(function () {
                    _this.wheelMoveTimer = 0;
                }, throttleTime);
            }
        }
    };
    MouseWheel.prototype.wheelEndDetector = function (delta) {
        var _this = this;
        window.clearTimeout(this.wheelEndTimer);
        this.wheelEndTimer = window.setTimeout(function () {
            _this.wheelStart = false;
            window.clearTimeout(_this.wheelMoveTimer);
            _this.wheelMoveTimer = 0;
            _this.scroll.trigger(_this.scroll.eventTypes.mousewheelEnd, delta);
        }, this.mouseWheelOpt.discreteTime);
    };
    MouseWheel.prototype.getWheelDelta = function (e) {
        var _a = this.mouseWheelOpt, speed = _a.speed, invert = _a.invert;
        var wheelDeltaX = 0;
        var wheelDeltaY = 0;
        var direction = invert ? -1 /* Negative */ : 1 /* Positive */;
        switch (true) {
            case 'deltaX' in e:
                if (e.deltaMode === 1) {
                    wheelDeltaX = -e.deltaX * speed;
                    wheelDeltaY = -e.deltaY * speed;
                }
                else {
                    wheelDeltaX = -e.deltaX;
                    wheelDeltaY = -e.deltaY;
                }
                break;
            case 'wheelDeltaX' in e:
                wheelDeltaX = (e.wheelDeltaX / 120) * speed;
                wheelDeltaY = (e.wheelDeltaY / 120) * speed;
                break;
            case 'wheelDelta' in e:
                wheelDeltaX = wheelDeltaY = (e.wheelDelta / 120) * speed;
                break;
            case 'detail' in e:
                wheelDeltaX = wheelDeltaY = (-e.detail / 3) * speed;
                break;
        }
        wheelDeltaX *= direction;
        wheelDeltaY *= direction;
        if (!this.scroll.hasVerticalScroll) {
            if (Math.abs(wheelDeltaY) > Math.abs(wheelDeltaX)) {
                wheelDeltaX = wheelDeltaY;
            }
            wheelDeltaY = 0;
        }
        if (!this.scroll.hasHorizontalScroll) {
            wheelDeltaX = 0;
        }
        var directionX = wheelDeltaX > 0
            ? -1 /* Negative */
            : wheelDeltaX < 0
                ? 1 /* Positive */
                : 0 /* Default */;
        var directionY = wheelDeltaY > 0
            ? -1 /* Negative */
            : wheelDeltaY < 0
                ? 1 /* Positive */
                : 0 /* Default */;
        return {
            x: wheelDeltaX,
            y: wheelDeltaY,
            directionX: directionX,
            directionY: directionY,
        };
    };
    MouseWheel.prototype.beforeHandler = function (e) {
        var _a = this.scroll.options, preventDefault = _a.preventDefault, stopPropagation = _a.stopPropagation, preventDefaultException = _a.preventDefaultException;
        if (preventDefault &&
            !preventDefaultExceptionFn(e.target, preventDefaultException)) {
            e.preventDefault();
        }
        if (stopPropagation) {
            e.stopPropagation();
        }
    };
    MouseWheel.prototype.getEaseTime = function () {
        var SAFE_EASETIME = 100;
        var easeTime = this.mouseWheelOpt.easeTime;
        // scrollEnd event will be triggered in every calling of scrollTo when easeTime is too small
        // easeTime needs to be greater than 100
        if (easeTime < SAFE_EASETIME) {
            warn("easeTime should be greater than 100." +
                "If mouseWheel easeTime is too small," +
                "scrollEnd will be triggered many times.");
        }
        return Math.max(easeTime, SAFE_EASETIME);
    };
    MouseWheel.prototype.destroy = function () {
        this.eventRegister.destroy();
        window.clearTimeout(this.wheelEndTimer);
        window.clearTimeout(this.wheelMoveTimer);
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
    };
    MouseWheel.pluginName = 'mouseWheel';
    MouseWheel.applyOrder = "pre" /* Pre */;
    return MouseWheel;
}());

var ObserveDOM = /** @class */ (function () {
    function ObserveDOM(scroll) {
        this.scroll = scroll;
        this.stopObserver = false;
        this.init();
    }
    ObserveDOM.prototype.init = function () {
        this.handleMutationObserver();
        this.handleHooks();
    };
    ObserveDOM.prototype.handleMutationObserver = function () {
        var _this = this;
        if (typeof MutationObserver !== 'undefined') {
            var timer_1 = 0;
            this.observer = new MutationObserver(function (mutations) {
                _this.mutationObserverHandler(mutations, timer_1);
            });
            this.startObserve(this.observer);
        }
        else {
            this.checkDOMUpdate();
        }
    };
    ObserveDOM.prototype.handleHooks = function () {
        var _this = this;
        this.hooksFn = [];
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.contentChanged, function () {
            _this.stopObserve();
            // launch a new mutationObserver
            _this.handleMutationObserver();
        });
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.enable, function () {
            if (_this.stopObserver) {
                _this.handleMutationObserver();
            }
        });
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.disable, function () {
            _this.stopObserve();
        });
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.destroy, function () {
            _this.destroy();
        });
    };
    ObserveDOM.prototype.mutationObserverHandler = function (mutations, timer) {
        var _this = this;
        if (this.shouldNotRefresh()) {
            return;
        }
        var immediateRefresh = false;
        var deferredRefresh = false;
        for (var i = 0; i < mutations.length; i++) {
            var mutation = mutations[i];
            if (mutation.type !== 'attributes') {
                immediateRefresh = true;
                break;
            }
            else {
                if (mutation.target !== this.scroll.scroller.content) {
                    deferredRefresh = true;
                    break;
                }
            }
        }
        if (immediateRefresh) {
            this.scroll.refresh();
        }
        else if (deferredRefresh) {
            // attributes changes too often
            clearTimeout(timer);
            timer = window.setTimeout(function () {
                if (!_this.shouldNotRefresh()) {
                    _this.scroll.refresh();
                }
            }, 60);
        }
    };
    ObserveDOM.prototype.startObserve = function (observer) {
        var config = {
            attributes: true,
            childList: true,
            subtree: true,
        };
        observer.observe(this.scroll.scroller.content, config);
    };
    ObserveDOM.prototype.shouldNotRefresh = function () {
        var scroller = this.scroll.scroller;
        var scrollBehaviorX = scroller.scrollBehaviorX, scrollBehaviorY = scroller.scrollBehaviorY;
        var outsideBoundaries = scrollBehaviorX.currentPos > scrollBehaviorX.minScrollPos ||
            scrollBehaviorX.currentPos < scrollBehaviorX.maxScrollPos ||
            scrollBehaviorY.currentPos > scrollBehaviorY.minScrollPos ||
            scrollBehaviorY.currentPos < scrollBehaviorY.maxScrollPos;
        return scroller.animater.pending || outsideBoundaries;
    };
    ObserveDOM.prototype.checkDOMUpdate = function () {
        var _this = this;
        var content = this.scroll.scroller.content;
        var contentRect = getRect(content);
        var oldWidth = contentRect.width;
        var oldHeight = contentRect.height;
        var check = function () {
            if (_this.stopObserver) {
                return;
            }
            contentRect = getRect(content);
            var newWidth = contentRect.width;
            var newHeight = contentRect.height;
            if (oldWidth !== newWidth || oldHeight !== newHeight) {
                _this.scroll.refresh();
            }
            oldWidth = newWidth;
            oldHeight = newHeight;
            next();
        };
        var next = function () {
            setTimeout(function () {
                check();
            }, 1000);
        };
        next();
    };
    ObserveDOM.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    ObserveDOM.prototype.stopObserve = function () {
        this.stopObserver = true;
        if (this.observer) {
            this.observer.disconnect();
        }
    };
    ObserveDOM.prototype.destroy = function () {
        this.stopObserve();
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
        this.hooksFn.length = 0;
    };
    ObserveDOM.pluginName = 'observeDOM';
    return ObserveDOM;
}());

var sourcePrefix$6 = 'plugins.pullDownRefresh';
var propertiesMap$6 = [
    {
        key: 'finishPullDown',
        name: 'finishPullDown'
    },
    {
        key: 'openPullDown',
        name: 'openPullDown'
    },
    {
        key: 'closePullDown',
        name: 'closePullDown'
    },
    {
        key: 'autoPullDownRefresh',
        name: 'autoPullDownRefresh'
    }
];
var propertiesConfig$6 = propertiesMap$6.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$6 + "." + item.name
    };
});

var PULLING_DOWN_EVENT = 'pullingDown';
var ENTER_THRESHOLD_EVENT = 'enterThreshold';
var LEAVE_THRESHOLD_EVENT = 'leaveThreshold';
var PullDown = /** @class */ (function () {
    function PullDown(scroll) {
        this.scroll = scroll;
        this.pulling = 0 /* DEFAULT */;
        this.thresholdBoundary = 0 /* DEFAULT */;
        this.init();
    }
    PullDown.prototype.setPulling = function (status) {
        this.pulling = status;
    };
    PullDown.prototype.setThresholdBoundary = function (boundary) {
        this.thresholdBoundary = boundary;
    };
    PullDown.prototype.init = function () {
        this.handleBScroll();
        this.handleOptions(this.scroll.options.pullDownRefresh);
        this.handleHooks();
        this.watch();
    };
    PullDown.prototype.handleBScroll = function () {
        this.scroll.registerType([
            PULLING_DOWN_EVENT,
            ENTER_THRESHOLD_EVENT,
            LEAVE_THRESHOLD_EVENT,
        ]);
        this.scroll.proxy(propertiesConfig$6);
    };
    PullDown.prototype.handleOptions = function (userOptions) {
        if (userOptions === void 0) { userOptions = {}; }
        userOptions = (userOptions === true ? {} : userOptions);
        var defaultOptions = {
            threshold: 90,
            stop: 40,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
        this.scroll.options.probeType = 3 /* Realtime */;
    };
    PullDown.prototype.handleHooks = function () {
        var _this = this;
        this.hooksFn = [];
        var scroller = this.scroll.scroller;
        var scrollBehaviorY = scroller.scrollBehaviorY;
        this.currentMinScrollY = this.cachedOriginanMinScrollY =
            scrollBehaviorY.minScrollPos;
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.contentChanged, function () {
            _this.finishPullDown();
        });
        this.registerHooks(scrollBehaviorY.hooks, scrollBehaviorY.hooks.eventTypes.computeBoundary, function (boundary) {
            // content is smaller than wrapper
            if (boundary.maxScrollPos > 0) {
                // allow scrolling when content is not full of wrapper
                boundary.maxScrollPos = -1;
            }
            boundary.minScrollPos = _this.currentMinScrollY;
        });
        // integrate with mousewheel
        if (this.hasMouseWheelPlugin()) {
            this.registerHooks(this.scroll, this.scroll.eventTypes.alterOptions, function (mouseWheelOptions) {
                var SANE_DISCRETE_TIME = 300;
                var SANE_EASE_TIME = 350;
                mouseWheelOptions.discreteTime = SANE_DISCRETE_TIME;
                // easeTime > discreteTime ensure goInto checkPullDown function
                mouseWheelOptions.easeTime = SANE_EASE_TIME;
            });
            this.registerHooks(this.scroll, this.scroll.eventTypes.mousewheelEnd, function () {
                // mouseWheel need trigger checkPullDown manually
                scroller.hooks.trigger(scroller.hooks.eventTypes.end);
            });
        }
    };
    PullDown.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    PullDown.prototype.hasMouseWheelPlugin = function () {
        return !!this.scroll.eventTypes.alterOptions;
    };
    PullDown.prototype.watch = function () {
        var scroller = this.scroll.scroller;
        this.watching = true;
        this.registerHooks(scroller.hooks, scroller.hooks.eventTypes.end, this.checkPullDown);
        this.registerHooks(this.scroll, this.scroll.eventTypes.scrollStart, this.resetStateBeforeScrollStart);
        this.registerHooks(this.scroll, this.scroll.eventTypes.scroll, this.checkLocationOfThresholdBoundary);
        if (this.hasMouseWheelPlugin()) {
            this.registerHooks(this.scroll, this.scroll.eventTypes.mousewheelStart, this.resetStateBeforeScrollStart);
        }
    };
    PullDown.prototype.resetStateBeforeScrollStart = function () {
        // current fetching pulldownRefresh has ended
        if (!this.isFetchingStatus()) {
            this.setPulling(1 /* MOVING */);
            this.setThresholdBoundary(0 /* DEFAULT */);
        }
    };
    PullDown.prototype.checkLocationOfThresholdBoundary = function () {
        // pulldownRefresh is in the phase of Moving
        if (this.pulling === 1 /* MOVING */) {
            var scroll_1 = this.scroll;
            // enter threshold boundary
            var enteredThresholdBoundary = this.thresholdBoundary !== 1 /* INSIDE */ &&
                this.locateInsideThresholdBoundary();
            // leave threshold boundary
            var leftThresholdBoundary = this.thresholdBoundary !== 2 /* OUTSIDE */ &&
                !this.locateInsideThresholdBoundary();
            if (enteredThresholdBoundary) {
                this.setThresholdBoundary(1 /* INSIDE */);
                scroll_1.trigger(ENTER_THRESHOLD_EVENT);
            }
            if (leftThresholdBoundary) {
                this.setThresholdBoundary(2 /* OUTSIDE */);
                scroll_1.trigger(LEAVE_THRESHOLD_EVENT);
            }
        }
    };
    PullDown.prototype.locateInsideThresholdBoundary = function () {
        return this.scroll.y <= this.options.threshold;
    };
    PullDown.prototype.unwatch = function () {
        var scroll = this.scroll;
        var scroller = scroll.scroller;
        this.watching = false;
        scroller.hooks.off(scroller.hooks.eventTypes.end, this.checkPullDown);
        scroll.off(scroll.eventTypes.scrollStart, this.resetStateBeforeScrollStart);
        scroll.off(scroll.eventTypes.scroll, this.checkLocationOfThresholdBoundary);
        if (this.hasMouseWheelPlugin()) {
            scroll.off(scroll.eventTypes.mousewheelStart, this.resetStateBeforeScrollStart);
        }
    };
    PullDown.prototype.checkPullDown = function () {
        var _a = this.options, threshold = _a.threshold, stop = _a.stop;
        // check if a real pull down action
        if (this.scroll.y < threshold) {
            return false;
        }
        if (this.pulling === 1 /* MOVING */) {
            this.modifyBehaviorYBoundary(stop);
            this.setPulling(2 /* FETCHING */);
            this.scroll.trigger(PULLING_DOWN_EVENT);
        }
        this.scroll.scrollTo(this.scroll.x, stop, this.scroll.options.bounceTime, ease.bounce);
        return this.isFetchingStatus();
    };
    PullDown.prototype.isFetchingStatus = function () {
        return this.pulling === 2 /* FETCHING */;
    };
    PullDown.prototype.modifyBehaviorYBoundary = function (stopDistance) {
        var scrollBehaviorY = this.scroll.scroller.scrollBehaviorY;
        // manually modify minScrollPos for a hang animation
        // to prevent from resetPosition
        this.cachedOriginanMinScrollY = scrollBehaviorY.minScrollPos;
        this.currentMinScrollY = stopDistance;
        scrollBehaviorY.computeBoundary();
    };
    PullDown.prototype.finishPullDown = function () {
        if (this.isFetchingStatus()) {
            var scrollBehaviorY = this.scroll.scroller.scrollBehaviorY;
            // restore minScrollY since the hang animation has ended
            this.currentMinScrollY = this.cachedOriginanMinScrollY;
            scrollBehaviorY.computeBoundary();
            this.setPulling(0 /* DEFAULT */);
            this.scroll.resetPosition(this.scroll.options.bounceTime, ease.bounce);
        }
    };
    // allow 'true' type is compat for beta version implements
    PullDown.prototype.openPullDown = function (config) {
        if (config === void 0) { config = {}; }
        this.handleOptions(config);
        if (!this.watching) {
            this.watch();
        }
    };
    PullDown.prototype.closePullDown = function () {
        this.unwatch();
    };
    PullDown.prototype.autoPullDownRefresh = function () {
        var _a = this.options, threshold = _a.threshold, stop = _a.stop;
        if (this.isFetchingStatus() || !this.watching) {
            return;
        }
        this.modifyBehaviorYBoundary(stop);
        this.scroll.trigger(this.scroll.eventTypes.scrollStart);
        this.scroll.scrollTo(this.scroll.x, threshold);
        this.setPulling(2 /* FETCHING */);
        this.scroll.trigger(PULLING_DOWN_EVENT);
        this.scroll.scrollTo(this.scroll.x, stop, this.scroll.options.bounceTime, ease.bounce);
    };
    PullDown.pluginName = 'pullDownRefresh';
    return PullDown;
}());

var sourcePrefix$5 = 'plugins.pullUpLoad';
var propertiesMap$5 = [
    {
        key: 'finishPullUp',
        name: 'finishPullUp'
    },
    {
        key: 'openPullUp',
        name: 'openPullUp'
    },
    {
        key: 'closePullUp',
        name: 'closePullUp'
    },
    {
        key: 'autoPullUpLoad',
        name: 'autoPullUpLoad'
    }
];
var propertiesConfig$5 = propertiesMap$5.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$5 + "." + item.name
    };
});

var PULL_UP_HOOKS_NAME = 'pullingUp';
var PullUp = /** @class */ (function () {
    function PullUp(scroll) {
        this.scroll = scroll;
        this.pulling = false;
        this.watching = false;
        this.init();
    }
    PullUp.prototype.init = function () {
        this.handleBScroll();
        this.handleOptions(this.scroll.options.pullUpLoad);
        this.handleHooks();
        this.watch();
    };
    PullUp.prototype.handleBScroll = function () {
        this.scroll.registerType([PULL_UP_HOOKS_NAME]);
        this.scroll.proxy(propertiesConfig$5);
    };
    PullUp.prototype.handleOptions = function (userOptions) {
        if (userOptions === void 0) { userOptions = {}; }
        userOptions = (userOptions === true ? {} : userOptions);
        var defaultOptions = {
            threshold: 0,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
        this.scroll.options.probeType = 3 /* Realtime */;
    };
    PullUp.prototype.handleHooks = function () {
        var _this = this;
        this.hooksFn = [];
        var scrollBehaviorY = this.scroll.scroller.scrollBehaviorY;
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.contentChanged, function () {
            _this.finishPullUp();
        });
        this.registerHooks(scrollBehaviorY.hooks, scrollBehaviorY.hooks.eventTypes.computeBoundary, function (boundary) {
            // content is smaller than wrapper
            if (boundary.maxScrollPos > 0) {
                // allow scrolling when content is not full of wrapper
                boundary.maxScrollPos = -1;
            }
        });
    };
    PullUp.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    PullUp.prototype.watch = function () {
        if (this.watching) {
            return;
        }
        this.watching = true;
        this.registerHooks(this.scroll, this.scroll.eventTypes.scroll, this.checkPullUp);
    };
    PullUp.prototype.unwatch = function () {
        this.watching = false;
        this.scroll.off(this.scroll.eventTypes.scroll, this.checkPullUp);
    };
    PullUp.prototype.checkPullUp = function (pos) {
        var _this = this;
        var threshold = this.options.threshold;
        if (this.scroll.movingDirectionY === 1 /* Positive */ &&
            pos.y <= this.scroll.maxScrollY + threshold) {
            this.pulling = true;
            // must reset pulling after scrollEnd
            this.scroll.once(this.scroll.eventTypes.scrollEnd, function () {
                _this.pulling = false;
            });
            this.unwatch();
            this.scroll.trigger(PULL_UP_HOOKS_NAME);
        }
    };
    PullUp.prototype.finishPullUp = function () {
        var _this = this;
        // reset Direction, fix #936
        this.scroll.scroller.scrollBehaviorY.setMovingDirection(0 /* Default */);
        if (this.pulling) {
            this.scroll.once(this.scroll.eventTypes.scrollEnd, function () {
                _this.watch();
            });
        }
        else {
            this.watch();
        }
    };
    // allow 'true' type is compat for beta version implements
    PullUp.prototype.openPullUp = function (config) {
        if (config === void 0) { config = {}; }
        this.handleOptions(config);
        this.watch();
    };
    PullUp.prototype.closePullUp = function () {
        this.unwatch();
    };
    PullUp.prototype.autoPullUpLoad = function () {
        var threshold = this.options.threshold;
        var scrollBehaviorY = this.scroll.scroller.scrollBehaviorY;
        if (this.pulling || !this.watching) {
            return;
        }
        // simulate a pullUp action
        var NEGATIVE_VALUE = -1;
        var outOfBoundaryPos = scrollBehaviorY.maxScrollPos + threshold + NEGATIVE_VALUE;
        this.scroll.scroller.scrollBehaviorY.setMovingDirection(NEGATIVE_VALUE);
        this.scroll.scrollTo(this.scroll.x, outOfBoundaryPos, this.scroll.options.bounceTime);
    };
    PullUp.pluginName = 'pullUpLoad';
    return PullUp;
}());

var EventHandler = /** @class */ (function () {
    function EventHandler(indicator, options) {
        this.indicator = indicator;
        this.options = options;
        this.hooks = new EventEmitter(['touchStart', 'touchMove', 'touchEnd']);
        this.registerEvents();
    }
    EventHandler.prototype.registerEvents = function () {
        var _a = this.options, disableMouse = _a.disableMouse, disableTouch = _a.disableTouch;
        var startEvents = [];
        var moveEvents = [];
        var endEvents = [];
        if (!disableMouse) {
            startEvents.push({
                name: 'mousedown',
                handler: this.start.bind(this),
            });
            moveEvents.push({
                name: 'mousemove',
                handler: this.move.bind(this),
            });
            endEvents.push({
                name: 'mouseup',
                handler: this.end.bind(this),
            });
        }
        if (!disableTouch) {
            startEvents.push({
                name: 'touchstart',
                handler: this.start.bind(this),
            });
            moveEvents.push({
                name: 'touchmove',
                handler: this.move.bind(this),
            });
            endEvents.push({
                name: 'touchend',
                handler: this.end.bind(this),
            }, {
                name: 'touchcancel',
                handler: this.end.bind(this),
            });
        }
        this.startEventRegister = new EventRegister(this.indicator.indicatorEl, startEvents);
        this.moveEventRegister = new EventRegister(window, moveEvents);
        this.endEventRegister = new EventRegister(window, endEvents);
    };
    EventHandler.prototype.BScrollIsDisabled = function () {
        return !this.indicator.scroll.enabled;
    };
    EventHandler.prototype.start = function (e) {
        if (this.BScrollIsDisabled()) {
            return;
        }
        var point = (e.touches ? e.touches[0] : e);
        e.preventDefault();
        e.stopPropagation();
        this.initiated = true;
        this.lastPoint = point[this.indicator.keysMap.point];
        this.hooks.trigger(this.hooks.eventTypes.touchStart);
    };
    EventHandler.prototype.move = function (e) {
        if (!this.initiated) {
            return;
        }
        var point = (e.touches ? e.touches[0] : e);
        var pointPos = point[this.indicator.keysMap.point];
        e.preventDefault();
        e.stopPropagation();
        var delta = pointPos - this.lastPoint;
        this.lastPoint = pointPos;
        this.hooks.trigger(this.hooks.eventTypes.touchMove, delta);
    };
    EventHandler.prototype.end = function (e) {
        if (!this.initiated) {
            return;
        }
        this.initiated = false;
        e.preventDefault();
        e.stopPropagation();
        this.hooks.trigger(this.hooks.eventTypes.touchEnd);
    };
    EventHandler.prototype.destroy = function () {
        this.startEventRegister.destroy();
        this.moveEventRegister.destroy();
        this.endEventRegister.destroy();
    };
    return EventHandler;
}());

var Indicator$1 = /** @class */ (function () {
    function Indicator(scroll, options) {
        this.scroll = scroll;
        this.options = options;
        this.hooksFn = [];
        this.wrapper = options.wrapper;
        this.direction = options.direction;
        this.indicatorEl = this.wrapper.children[0];
        this.keysMap = this.getKeysMap();
        this.handleFade();
        this.handleHooks();
    }
    Indicator.prototype.handleFade = function () {
        if (this.options.fade) {
            this.wrapper.style.opacity = '0';
        }
    };
    Indicator.prototype.handleHooks = function () {
        var _this = this;
        var _a = this.options, fade = _a.fade, interactive = _a.interactive, scrollbarTrackClickable = _a.scrollbarTrackClickable;
        var scroll = this.scroll;
        var scrollHooks = scroll.hooks;
        var translaterHooks = scroll.scroller.translater.hooks;
        var animaterHooks = scroll.scroller.animater.hooks;
        this.registerHooks(scrollHooks, scrollHooks.eventTypes.refresh, this.refresh);
        this.registerHooks(translaterHooks, translaterHooks.eventTypes.translate, function (pos) {
            var hasScrollKey = _this.keysMap.hasScroll;
            if (_this.scroll[hasScrollKey]) {
                _this.updatePosition(pos);
            }
        });
        this.registerHooks(animaterHooks, animaterHooks.eventTypes.time, this.transitionTime);
        this.registerHooks(animaterHooks, animaterHooks.eventTypes.timeFunction, this.transitionTimingFunction);
        if (fade) {
            this.registerHooks(scroll, scroll.eventTypes.scrollEnd, function () {
                _this.fade();
            });
            this.registerHooks(scroll, scroll.eventTypes.scrollStart, function () {
                _this.fade(true);
            });
            // for mousewheel event
            if (scroll.eventTypes.mousewheelStart &&
                scroll.eventTypes.mousewheelEnd) {
                this.registerHooks(scroll, scroll.eventTypes.mousewheelStart, function () {
                    _this.fade(true);
                });
                this.registerHooks(scroll, scroll.eventTypes.mousewheelMove, function () {
                    _this.fade(true);
                });
                this.registerHooks(scroll, scroll.eventTypes.mousewheelEnd, function () {
                    _this.fade();
                });
            }
        }
        if (interactive) {
            var _b = this.scroll.options, disableMouse = _b.disableMouse, disableTouch = _b.disableTouch;
            this.eventHandler = new EventHandler(this, {
                disableMouse: disableMouse,
                disableTouch: disableTouch,
            });
            var eventHandlerHooks = this.eventHandler.hooks;
            this.registerHooks(eventHandlerHooks, eventHandlerHooks.eventTypes.touchStart, this.startHandler);
            this.registerHooks(eventHandlerHooks, eventHandlerHooks.eventTypes.touchMove, this.moveHandler);
            this.registerHooks(eventHandlerHooks, eventHandlerHooks.eventTypes.touchEnd, this.endHandler);
        }
        if (scrollbarTrackClickable) {
            this.bindClick();
        }
    };
    Indicator.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    Indicator.prototype.bindClick = function () {
        var wrapper = this.wrapper;
        this.clickEventRegister = new EventRegister(wrapper, [
            {
                name: 'click',
                handler: this.handleClick.bind(this),
            },
        ]);
    };
    Indicator.prototype.handleClick = function (e) {
        var newPos = this.calculateclickOffsetPos(e);
        var _a = this.scroll, x = _a.x, y = _a.y;
        x = this.direction === "horizontal" /* Horizontal */ ? newPos : x;
        y = this.direction === "vertical" /* Vertical */ ? newPos : y;
        this.scroll.scrollTo(x, y, this.options.scrollbarTrackOffsetTime);
    };
    Indicator.prototype.calculateclickOffsetPos = function (e) {
        var _a = this.keysMap, poinKey = _a.point, domRectKey = _a.domRect;
        var scrollbarTrackOffsetType = this.options.scrollbarTrackOffsetType;
        var clickPointOffset = e[poinKey] - this.wrapperRect[domRectKey];
        var scrollToWhere = clickPointOffset < this.currentPos ? -1 /* Up */ : 1 /* Down */;
        var delta = 0;
        var currentPos = this.currentPos;
        if (scrollbarTrackOffsetType === "step" /* Step */) {
            delta = this.scrollInfo.baseSize * scrollToWhere;
        }
        else {
            delta = 0;
            currentPos = clickPointOffset;
        }
        return this.newPos(currentPos, delta, this.scrollInfo);
    };
    Indicator.prototype.getKeysMap = function () {
        if (this.direction === "vertical" /* Vertical */) {
            return {
                hasScroll: 'hasVerticalScroll',
                size: 'height',
                wrapperSize: 'clientHeight',
                scrollerSize: 'scrollerHeight',
                maxScrollPos: 'maxScrollY',
                pos: 'y',
                point: 'pageY',
                translateProperty: 'translateY',
                domRect: 'top',
            };
        }
        return {
            hasScroll: 'hasHorizontalScroll',
            size: 'width',
            wrapperSize: 'clientWidth',
            scrollerSize: 'scrollerWidth',
            maxScrollPos: 'maxScrollX',
            pos: 'x',
            point: 'pageX',
            translateProperty: 'translateX',
            domRect: 'left',
        };
    };
    Indicator.prototype.fade = function (visible) {
        var _a = this.options, fadeInTime = _a.fadeInTime, fadeOutTime = _a.fadeOutTime;
        var time = visible ? fadeInTime : fadeOutTime;
        var wrapper = this.wrapper;
        wrapper.style[better_scroll_esm_style.transitionDuration] = time + 'ms';
        wrapper.style.opacity = visible ? '1' : '0';
    };
    Indicator.prototype.refresh = function () {
        var hasScrollKey = this.keysMap.hasScroll;
        var scroll = this.scroll;
        var x = scroll.x, y = scroll.y;
        this.wrapperRect = this.wrapper.getBoundingClientRect();
        if (this.canScroll(scroll[hasScrollKey])) {
            var _a = this.keysMap, wrapperSizeKey = _a.wrapperSize, scrollerSizeKey = _a.scrollerSize, maxScrollPosKey = _a.maxScrollPos;
            this.scrollInfo = this.refreshScrollInfo(this.wrapper[wrapperSizeKey], scroll[scrollerSizeKey], scroll[maxScrollPosKey], this.indicatorEl[wrapperSizeKey]);
            this.updatePosition({
                x: x,
                y: y,
            });
        }
    };
    Indicator.prototype.transitionTime = function (time) {
        if (time === void 0) { time = 0; }
        this.indicatorEl.style[better_scroll_esm_style.transitionDuration] = time + 'ms';
    };
    Indicator.prototype.transitionTimingFunction = function (easing) {
        this.indicatorEl.style[better_scroll_esm_style.transitionTimingFunction] = easing;
    };
    Indicator.prototype.canScroll = function (hasScroll) {
        this.wrapper.style.display = hasScroll ? 'block' : 'none';
        return hasScroll;
    };
    Indicator.prototype.refreshScrollInfo = function (wrapperSize, scrollerSize, maxScrollPos, indicatorElSize) {
        var baseSize = Math.max(Math.round((wrapperSize * wrapperSize) / (scrollerSize || wrapperSize || 1)), this.options.minSize);
        if (this.options.isCustom) {
            baseSize = indicatorElSize;
        }
        var maxIndicatorScrollPos = wrapperSize - baseSize;
        // sizeRatio is negative
        var sizeRatio = maxIndicatorScrollPos / maxScrollPos;
        return {
            baseSize: baseSize,
            maxScrollPos: maxIndicatorScrollPos,
            minScrollPos: 0,
            sizeRatio: sizeRatio,
        };
    };
    Indicator.prototype.updatePosition = function (point) {
        var _a = this.caculatePosAndSize(point, this.scrollInfo), pos = _a.pos, size = _a.size;
        this.refreshStyle(size, pos);
        this.currentPos = pos;
    };
    Indicator.prototype.caculatePosAndSize = function (point, scrollInfo) {
        var posKey = this.keysMap.pos;
        var sizeRatio = scrollInfo.sizeRatio, baseSize = scrollInfo.baseSize, maxScrollPos = scrollInfo.maxScrollPos, minScrollPos = scrollInfo.minScrollPos;
        var minSize = this.options.minSize;
        var pos = Math.round(sizeRatio * point[posKey]);
        var size;
        // when out of boundary, slow down size reduction
        if (pos < minScrollPos) {
            size = Math.max(baseSize + pos * 3, minSize);
            pos = minScrollPos;
        }
        else if (pos > maxScrollPos) {
            size = Math.max(baseSize - (pos - maxScrollPos) * 3, minSize);
            pos = maxScrollPos + baseSize - size;
        }
        else {
            size = baseSize;
        }
        return {
            pos: pos,
            size: size,
        };
    };
    Indicator.prototype.refreshStyle = function (size, pos) {
        var _a = this.keysMap, translatePropertyKey = _a.translateProperty, sizeKey = _a.size;
        var translateZ = this.scroll.options.translateZ;
        this.indicatorEl.style[sizeKey] = size + "px";
        this.indicatorEl.style[better_scroll_esm_style.transform] = translatePropertyKey + "(" + pos + "px)" + translateZ;
    };
    Indicator.prototype.startHandler = function () {
        this.moved = false;
        this.startTime = getNow();
        this.transitionTime();
        this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.beforeScrollStart);
    };
    Indicator.prototype.moveHandler = function (delta) {
        if (!this.moved && !this.indicatorNotMoved(delta)) {
            this.moved = true;
            this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollStart);
        }
        if (this.moved) {
            var newPos = this.newPos(this.currentPos, delta, this.scrollInfo);
            this.syncBScroll(newPos);
        }
    };
    Indicator.prototype.endHandler = function () {
        if (this.moved) {
            var _a = this.scroll, x = _a.x, y = _a.y;
            this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollEnd, {
                x: x,
                y: y,
            });
        }
    };
    Indicator.prototype.indicatorNotMoved = function (delta) {
        var currentPos = this.currentPos;
        var _a = this.scrollInfo, maxScrollPos = _a.maxScrollPos, minScrollPos = _a.minScrollPos;
        var notMoved = (currentPos === minScrollPos && delta <= 0) ||
            (currentPos === maxScrollPos && delta >= 0);
        return notMoved;
    };
    Indicator.prototype.syncBScroll = function (newPos) {
        var timestamp = getNow();
        var _a = this.scroll, x = _a.x, y = _a.y, options = _a.options, scroller = _a.scroller, maxScrollY = _a.maxScrollY, minScrollY = _a.minScrollY, maxScrollX = _a.maxScrollX, minScrollX = _a.minScrollX;
        var probeType = options.probeType, momentumLimitTime = options.momentumLimitTime;
        var position = { x: x, y: y };
        if (this.direction === "vertical" /* Vertical */) {
            position.y = between(newPos, maxScrollY, minScrollY);
        }
        else {
            position.x = between(newPos, maxScrollX, minScrollX);
        }
        scroller.translater.translate(position);
        // dispatch scroll in interval time
        if (timestamp - this.startTime > momentumLimitTime) {
            this.startTime = timestamp;
            if (probeType === 1 /* Throttle */) {
                scroller.hooks.trigger(scroller.hooks.eventTypes.scroll, position);
            }
        }
        // dispatch scroll all the time
        if (probeType > 1 /* Throttle */) {
            scroller.hooks.trigger(scroller.hooks.eventTypes.scroll, position);
        }
    };
    Indicator.prototype.newPos = function (currentPos, delta, scrollInfo) {
        var maxScrollPos = scrollInfo.maxScrollPos, sizeRatio = scrollInfo.sizeRatio, minScrollPos = scrollInfo.minScrollPos;
        var newPos = currentPos + delta;
        newPos = between(newPos, minScrollPos, maxScrollPos);
        return Math.round(newPos / sizeRatio);
    };
    Indicator.prototype.destroy = function () {
        var _a = this.options, interactive = _a.interactive, scrollbarTrackClickable = _a.scrollbarTrackClickable, isCustom = _a.isCustom;
        if (interactive) {
            this.eventHandler.destroy();
        }
        if (scrollbarTrackClickable) {
            this.clickEventRegister.destroy();
        }
        if (!isCustom) {
            this.wrapper.parentNode.removeChild(this.wrapper);
        }
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
        this.hooksFn.length = 0;
    };
    return Indicator;
}());

var ScrollBar = /** @class */ (function () {
    function ScrollBar(scroll) {
        this.scroll = scroll;
        this.handleOptions();
        this.createIndicators();
        this.handleHooks();
    }
    ScrollBar.prototype.handleHooks = function () {
        var _this = this;
        var scroll = this.scroll;
        scroll.hooks.on(scroll.hooks.eventTypes.destroy, function () {
            for (var _i = 0, _a = _this.indicators; _i < _a.length; _i++) {
                var indicator = _a[_i];
                indicator.destroy();
            }
        });
    };
    ScrollBar.prototype.handleOptions = function () {
        var userOptions = (this.scroll.options.scrollbar === true
            ? {}
            : this.scroll.options.scrollbar);
        var defaultOptions = {
            fade: true,
            fadeInTime: 250,
            fadeOutTime: 500,
            interactive: false,
            customElements: [],
            minSize: 8,
            scrollbarTrackClickable: false,
            scrollbarTrackOffsetType: "step" /* Step */,
            scrollbarTrackOffsetTime: 300,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    ScrollBar.prototype.createIndicators = function () {
        var indicatorOptions;
        var scroll = this.scroll;
        var indicators = [];
        var scrollDirectionConfigKeys = ['scrollX', 'scrollY'];
        var indicatorDirections = [
            "horizontal" /* Horizontal */,
            "vertical" /* Vertical */,
        ];
        var customScrollbarEls = this.options.customElements;
        for (var i = 0; i < scrollDirectionConfigKeys.length; i++) {
            var key = scrollDirectionConfigKeys[i];
            // wanna scroll in specified direction
            if (scroll.options[key]) {
                var customElement = customScrollbarEls.shift();
                var direction = indicatorDirections[i];
                var isCustom = false;
                var scrollbarWrapper = customElement
                    ? customElement
                    : this.createScrollbarElement(direction);
                // internal scrollbar
                if (scrollbarWrapper !== customElement) {
                    scroll.wrapper.appendChild(scrollbarWrapper);
                }
                else {
                    // custom scrollbar passed by users
                    isCustom = true;
                }
                indicatorOptions = __assign(__assign({ wrapper: scrollbarWrapper, direction: direction }, this.options), { isCustom: isCustom });
                indicators.push(new Indicator$1(scroll, indicatorOptions));
            }
        }
        this.indicators = indicators;
    };
    ScrollBar.prototype.createScrollbarElement = function (direction, scrollbarTrackClickable) {
        if (scrollbarTrackClickable === void 0) { scrollbarTrackClickable = this.options.scrollbarTrackClickable; }
        var scrollbarWrapperEl = document.createElement('div');
        var scrollbarIndicatorEl = document.createElement('div');
        scrollbarWrapperEl.style.cssText =
            'position:absolute;z-index:9999;overflow:hidden;';
        scrollbarIndicatorEl.style.cssText =
            'box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px;';
        scrollbarIndicatorEl.className = 'bscroll-indicator';
        if (direction === "horizontal" /* Horizontal */) {
            scrollbarWrapperEl.style.cssText +=
                'height:7px;left:2px;right:2px;bottom:0;';
            scrollbarIndicatorEl.style.height = '100%';
            scrollbarWrapperEl.className = 'bscroll-horizontal-scrollbar';
        }
        else {
            scrollbarWrapperEl.style.cssText +=
                'width:7px;bottom:2px;top:2px;right:1px;';
            scrollbarIndicatorEl.style.width = '100%';
            scrollbarWrapperEl.className = 'bscroll-vertical-scrollbar';
        }
        if (!scrollbarTrackClickable) {
            scrollbarWrapperEl.style.cssText += 'pointer-events:none;';
        }
        scrollbarWrapperEl.appendChild(scrollbarIndicatorEl);
        return scrollbarWrapperEl;
    };
    ScrollBar.pluginName = 'scrollbar';
    return ScrollBar;
}());

var PagesMatrix = /** @class */ (function () {
    function PagesMatrix(scroll) {
        this.scroll = scroll;
        this.init();
    }
    PagesMatrix.prototype.init = function () {
        var scroller = this.scroll.scroller;
        var scrollBehaviorX = scroller.scrollBehaviorX, scrollBehaviorY = scroller.scrollBehaviorY;
        this.wrapperWidth = scrollBehaviorX.wrapperSize;
        this.wrapperHeight = scrollBehaviorY.wrapperSize;
        this.scrollerHeight = scrollBehaviorY.contentSize;
        this.scrollerWidth = scrollBehaviorX.contentSize;
        this.pages = this.buildPagesMatrix(this.wrapperWidth, this.wrapperHeight);
        this.pageLengthOfX = this.pages ? this.pages.length : 0;
        this.pageLengthOfY = this.pages && this.pages[0] ? this.pages[0].length : 0;
    };
    PagesMatrix.prototype.getPageStats = function (pageX, pageY) {
        return this.pages[pageX][pageY];
    };
    PagesMatrix.prototype.getNearestPageIndex = function (x, y) {
        var pageX = 0;
        var pageY = 0;
        var l = this.pages.length;
        for (; pageX < l - 1; pageX++) {
            if (x >= this.pages[pageX][0].cx) {
                break;
            }
        }
        l = this.pages[pageX].length;
        for (; pageY < l - 1; pageY++) {
            if (y >= this.pages[0][pageY].cy) {
                break;
            }
        }
        return {
            pageX: pageX,
            pageY: pageY,
        };
    };
    // (n x 1) matrix for horizontal scroll or
    // (1 * n) matrix for vertical scroll
    PagesMatrix.prototype.buildPagesMatrix = function (stepX, stepY) {
        var pages = [];
        var x = 0;
        var y;
        var cx;
        var cy;
        var i = 0;
        var l;
        var maxScrollPosX = this.scroll.scroller.scrollBehaviorX.maxScrollPos;
        var maxScrollPosY = this.scroll.scroller.scrollBehaviorY.maxScrollPos;
        cx = Math.round(stepX / 2);
        cy = Math.round(stepY / 2);
        while (x > -this.scrollerWidth) {
            pages[i] = [];
            l = 0;
            y = 0;
            while (y > -this.scrollerHeight) {
                pages[i][l] = {
                    x: Math.max(x, maxScrollPosX),
                    y: Math.max(y, maxScrollPosY),
                    width: stepX,
                    height: stepY,
                    cx: x - cx,
                    cy: y - cy,
                };
                y -= stepY;
                l++;
            }
            x -= stepX;
            i++;
        }
        return pages;
    };
    return PagesMatrix;
}());

var BASE_PAGE = {
    pageX: 0,
    pageY: 0,
    x: 0,
    y: 0,
};

var SlidePages = /** @class */ (function () {
    function SlidePages(scroll, slideOptions) {
        this.scroll = scroll;
        this.slideOptions = slideOptions;
        this.slideX = false;
        this.slideY = false;
        this.currentPage = better_scroll_esm_extend({}, BASE_PAGE);
    }
    SlidePages.prototype.refresh = function () {
        this.pagesMatrix = new PagesMatrix(this.scroll);
        this.checkSlideLoop();
        this.currentPage = this.getAdjustedCurrentPage();
    };
    SlidePages.prototype.getAdjustedCurrentPage = function () {
        var _a = this.currentPage, pageX = _a.pageX, pageY = _a.pageY;
        // page index should be handled
        // because page counts may reduce
        pageX = Math.min(pageX, this.pagesMatrix.pageLengthOfX - 1);
        pageY = Math.min(pageY, this.pagesMatrix.pageLengthOfY - 1);
        // loop scene should also be respected
        // because clonedNode will cause pageLength increasing
        if (this.loopX) {
            pageX = Math.min(pageX, this.pagesMatrix.pageLengthOfX - 2);
        }
        if (this.loopY) {
            pageY = Math.min(pageY, this.pagesMatrix.pageLengthOfY - 2);
        }
        var _b = this.pagesMatrix.getPageStats(pageX, pageY), x = _b.x, y = _b.y;
        return { pageX: pageX, pageY: pageY, x: x, y: y };
    };
    SlidePages.prototype.setCurrentPage = function (newPage) {
        this.currentPage = newPage;
    };
    SlidePages.prototype.getInternalPage = function (pageX, pageY) {
        if (pageX >= this.pagesMatrix.pageLengthOfX) {
            pageX = this.pagesMatrix.pageLengthOfX - 1;
        }
        else if (pageX < 0) {
            pageX = 0;
        }
        if (pageY >= this.pagesMatrix.pageLengthOfY) {
            pageY = this.pagesMatrix.pageLengthOfY - 1;
        }
        else if (pageY < 0) {
            pageY = 0;
        }
        var _a = this.pagesMatrix.getPageStats(pageX, pageY), x = _a.x, y = _a.y;
        return {
            pageX: pageX,
            pageY: pageY,
            x: x,
            y: y,
        };
    };
    SlidePages.prototype.getInitialPage = function (showFirstPage, firstInitialised) {
        if (showFirstPage === void 0) { showFirstPage = false; }
        if (firstInitialised === void 0) { firstInitialised = false; }
        var _a = this.slideOptions, startPageXIndex = _a.startPageXIndex, startPageYIndex = _a.startPageYIndex;
        var firstPageX = this.loopX ? 1 : 0;
        var firstPageY = this.loopY ? 1 : 0;
        var pageX = showFirstPage ? firstPageX : this.currentPage.pageX;
        var pageY = showFirstPage ? firstPageY : this.currentPage.pageY;
        if (firstInitialised) {
            pageX = this.loopX ? startPageXIndex + 1 : startPageXIndex;
            pageY = this.loopY ? startPageYIndex + 1 : startPageYIndex;
        }
        else {
            pageX = showFirstPage ? firstPageX : this.currentPage.pageX;
            pageY = showFirstPage ? firstPageY : this.currentPage.pageY;
        }
        var _b = this.pagesMatrix.getPageStats(pageX, pageY), x = _b.x, y = _b.y;
        return {
            pageX: pageX,
            pageY: pageY,
            x: x,
            y: y,
        };
    };
    SlidePages.prototype.getExposedPage = function (page) {
        var exposedPage = better_scroll_esm_extend({}, page);
        // only pageX or pageY need fix
        if (this.loopX) {
            exposedPage.pageX = this.fixedPage(exposedPage.pageX, this.pagesMatrix.pageLengthOfX - 2);
        }
        if (this.loopY) {
            exposedPage.pageY = this.fixedPage(exposedPage.pageY, this.pagesMatrix.pageLengthOfY - 2);
        }
        return exposedPage;
    };
    SlidePages.prototype.getExposedPageByPageIndex = function (pageIndexX, pageIndexY) {
        var page = {
            pageX: pageIndexX,
            pageY: pageIndexY,
        };
        if (this.loopX) {
            page.pageX = pageIndexX + 1;
        }
        if (this.loopY) {
            page.pageY = pageIndexY + 1;
        }
        var _a = this.pagesMatrix.getPageStats(page.pageX, page.pageY), x = _a.x, y = _a.y;
        return {
            x: x,
            y: y,
            pageX: pageIndexX,
            pageY: pageIndexY,
        };
    };
    SlidePages.prototype.getWillChangedPage = function (page) {
        page = better_scroll_esm_extend({}, page);
        // Page need fix
        if (this.loopX) {
            page.pageX = this.fixedPage(page.pageX, this.pagesMatrix.pageLengthOfX - 2);
            page.x = this.pagesMatrix.getPageStats(page.pageX + 1, 0).x;
        }
        if (this.loopY) {
            page.pageY = this.fixedPage(page.pageY, this.pagesMatrix.pageLengthOfY - 2);
            page.y = this.pagesMatrix.getPageStats(0, page.pageY + 1).y;
        }
        return page;
    };
    SlidePages.prototype.fixedPage = function (page, realPageLen) {
        var pageIndex = [];
        for (var i = 0; i < realPageLen; i++) {
            pageIndex.push(i);
        }
        pageIndex.unshift(realPageLen - 1);
        pageIndex.push(0);
        return pageIndex[page];
    };
    SlidePages.prototype.getPageStats = function () {
        return this.pagesMatrix.getPageStats(this.currentPage.pageX, this.currentPage.pageY);
    };
    SlidePages.prototype.getValidPageIndex = function (x, y) {
        var lastX = this.pagesMatrix.pageLengthOfX - 1;
        var lastY = this.pagesMatrix.pageLengthOfY - 1;
        var firstX = 0;
        var firstY = 0;
        if (this.loopX) {
            x += 1;
            firstX = firstX + 1;
            lastX = lastX - 1;
        }
        if (this.loopY) {
            y += 1;
            firstY = firstY + 1;
            lastY = lastY - 1;
        }
        x = between(x, firstX, lastX);
        y = between(y, firstY, lastY);
        return {
            pageX: x,
            pageY: y,
        };
    };
    SlidePages.prototype.nextPageIndex = function () {
        return this.getPageIndexByDirection("positive" /* Positive */);
    };
    SlidePages.prototype.prevPageIndex = function () {
        return this.getPageIndexByDirection("negative" /* Negative */);
    };
    SlidePages.prototype.getNearestPage = function (x, y) {
        var pageIndex = this.pagesMatrix.getNearestPageIndex(x, y);
        var pageX = pageIndex.pageX, pageY = pageIndex.pageY;
        var newX = this.pagesMatrix.getPageStats(pageX, 0).x;
        var newY = this.pagesMatrix.getPageStats(0, pageY).y;
        return {
            x: newX,
            y: newY,
            pageX: pageX,
            pageY: pageY,
        };
    };
    SlidePages.prototype.getPageByDirection = function (page, directionX, directionY) {
        var pageX = page.pageX, pageY = page.pageY;
        if (pageX === this.currentPage.pageX) {
            pageX = between(pageX + directionX, 0, this.pagesMatrix.pageLengthOfX - 1);
        }
        if (pageY === this.currentPage.pageY) {
            pageY = between(pageY + directionY, 0, this.pagesMatrix.pageLengthOfY - 1);
        }
        var x = this.pagesMatrix.getPageStats(pageX, 0).x;
        var y = this.pagesMatrix.getPageStats(0, pageY).y;
        return {
            x: x,
            y: y,
            pageX: pageX,
            pageY: pageY,
        };
    };
    SlidePages.prototype.resetLoopPage = function () {
        if (this.loopX) {
            if (this.currentPage.pageX === 0) {
                return {
                    pageX: this.pagesMatrix.pageLengthOfX - 2,
                    pageY: this.currentPage.pageY,
                };
            }
            if (this.currentPage.pageX === this.pagesMatrix.pageLengthOfX - 1) {
                return {
                    pageX: 1,
                    pageY: this.currentPage.pageY,
                };
            }
        }
        if (this.loopY) {
            if (this.currentPage.pageY === 0) {
                return {
                    pageX: this.currentPage.pageX,
                    pageY: this.pagesMatrix.pageLengthOfY - 2,
                };
            }
            if (this.currentPage.pageY === this.pagesMatrix.pageLengthOfY - 1) {
                return {
                    pageX: this.currentPage.pageX,
                    pageY: 1,
                };
            }
        }
    };
    SlidePages.prototype.getPageIndexByDirection = function (direction) {
        var x = this.currentPage.pageX;
        var y = this.currentPage.pageY;
        if (this.slideX) {
            x = direction === "negative" /* Negative */ ? x - 1 : x + 1;
        }
        if (this.slideY) {
            y = direction === "negative" /* Negative */ ? y - 1 : y + 1;
        }
        return {
            pageX: x,
            pageY: y,
        };
    };
    SlidePages.prototype.checkSlideLoop = function () {
        this.wannaLoop = this.slideOptions.loop;
        if (this.pagesMatrix.pageLengthOfX > 1) {
            this.slideX = true;
        }
        else {
            this.slideX = false;
        }
        if (this.pagesMatrix.pages[0] && this.pagesMatrix.pageLengthOfY > 1) {
            this.slideY = true;
        }
        else {
            this.slideY = false;
        }
        this.loopX = this.wannaLoop && this.slideX;
        this.loopY = this.wannaLoop && this.slideY;
        if (this.slideX && this.slideY) {
            warn('slide does not support two direction at the same time.');
        }
    };
    return SlidePages;
}());

var sourcePrefix$4 = 'plugins.slide';
var propertiesMap$4 = [
    {
        key: 'next',
        name: 'next',
    },
    {
        key: 'prev',
        name: 'prev',
    },
    {
        key: 'goToPage',
        name: 'goToPage',
    },
    {
        key: 'getCurrentPage',
        name: 'getCurrentPage',
    },
    {
        key: 'startPlay',
        name: 'startPlay',
    },
    {
        key: 'pausePlay',
        name: 'pausePlay',
    },
];
var propertiesConfig$4 = propertiesMap$4.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$4 + "." + item.name,
    };
});

var samePage = function (p1, p2) {
    return p1.pageX === p2.pageX && p1.pageY === p2.pageY;
};
var Slide = /** @class */ (function () {
    function Slide(scroll) {
        this.scroll = scroll;
        this.cachedClonedPageDOM = [];
        this.resetLooping = false;
        this.autoplayTimer = 0;
        if (!this.satisfyInitialization()) {
            return;
        }
        this.init();
    }
    Slide.prototype.satisfyInitialization = function () {
        if (this.scroll.scroller.content.children.length <= 0) {
            warn("slide need at least one slide page to be initialised." +
                "please check your DOM layout.");
            return false;
        }
        return true;
    };
    Slide.prototype.init = function () {
        this.willChangeToPage = better_scroll_esm_extend({}, BASE_PAGE);
        this.handleBScroll();
        this.handleOptions();
        this.handleHooks();
        this.createPages();
    };
    Slide.prototype.createPages = function () {
        this.pages = new SlidePages(this.scroll, this.options);
    };
    Slide.prototype.handleBScroll = function () {
        this.scroll.registerType(['slideWillChange', 'slidePageChanged']);
        this.scroll.proxy(propertiesConfig$4);
    };
    Slide.prototype.handleOptions = function () {
        var userOptions = (this.scroll.options.slide === true
            ? {}
            : this.scroll.options.slide);
        var defaultOptions = {
            loop: true,
            threshold: 0.1,
            speed: 400,
            easing: ease.bounce,
            listenFlick: true,
            autoplay: true,
            interval: 3000,
            startPageXIndex: 0,
            startPageYIndex: 0,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    Slide.prototype.handleLoop = function (prevSlideContent) {
        var loop = this.options.loop;
        var slideContent = this.scroll.scroller.content;
        var currentSlidePagesLength = slideContent.children.length;
        // only should respect loop scene
        if (loop) {
            if (slideContent !== prevSlideContent) {
                this.resetLoopChangedStatus();
                this.removeClonedSlidePage(prevSlideContent);
                currentSlidePagesLength > 1 &&
                    this.cloneFirstAndLastSlidePage(slideContent);
            }
            else {
                // many pages reduce to one page
                if (currentSlidePagesLength === 3 && this.initialised) {
                    this.removeClonedSlidePage(slideContent);
                    this.moreToOnePageInLoop = true;
                    this.oneToMorePagesInLoop = false;
                }
                else if (currentSlidePagesLength > 1) {
                    // one page increases to many page
                    if (this.initialised && this.cachedClonedPageDOM.length === 0) {
                        this.oneToMorePagesInLoop = true;
                        this.moreToOnePageInLoop = false;
                    }
                    else {
                        this.removeClonedSlidePage(slideContent);
                        this.resetLoopChangedStatus();
                    }
                    this.cloneFirstAndLastSlidePage(slideContent);
                }
                else {
                    this.resetLoopChangedStatus();
                }
            }
        }
    };
    Slide.prototype.resetLoopChangedStatus = function () {
        this.moreToOnePageInLoop = false;
        this.oneToMorePagesInLoop = false;
    };
    Slide.prototype.handleHooks = function () {
        var _this = this;
        var scrollHooks = this.scroll.hooks;
        var scrollerHooks = this.scroll.scroller.hooks;
        var listenFlick = this.options.listenFlick;
        this.prevContent = this.scroll.scroller.content;
        this.hooksFn = [];
        // scroll
        this.registerHooks(this.scroll, this.scroll.eventTypes.beforeScrollStart, this.pausePlay);
        this.registerHooks(this.scroll, this.scroll.eventTypes.scrollEnd, this.modifyCurrentPage);
        this.registerHooks(this.scroll, this.scroll.eventTypes.scrollEnd, this.startPlay);
        // for mousewheel event
        if (this.scroll.eventTypes.mousewheelMove) {
            this.registerHooks(this.scroll, this.scroll.eventTypes.mousewheelMove, function () {
                // prevent default action of mousewheelMove
                return true;
            });
            this.registerHooks(this.scroll, this.scroll.eventTypes.mousewheelEnd, function (delta) {
                if (delta.directionX === 1 /* Positive */ ||
                    delta.directionY === 1 /* Positive */) {
                    _this.next();
                }
                if (delta.directionX === -1 /* Negative */ ||
                    delta.directionY === -1 /* Negative */) {
                    _this.prev();
                }
            });
        }
        // scrollHooks
        this.registerHooks(scrollHooks, scrollHooks.eventTypes.refresh, this.refreshHandler);
        this.registerHooks(scrollHooks, scrollHooks.eventTypes.destroy, this.destroy);
        // scroller
        this.registerHooks(scrollerHooks, scrollerHooks.eventTypes.beforeRefresh, function () {
            _this.handleLoop(_this.prevContent);
            _this.setSlideInlineStyle();
        });
        this.registerHooks(scrollerHooks, scrollerHooks.eventTypes.momentum, this.modifyScrollMetaHandler);
        this.registerHooks(scrollerHooks, scrollerHooks.eventTypes.scroll, this.scrollHandler);
        // a click operation will clearTimer, so restart a new one
        this.registerHooks(scrollerHooks, scrollerHooks.eventTypes.checkClick, this.startPlay);
        if (listenFlick) {
            this.registerHooks(scrollerHooks, scrollerHooks.eventTypes.flick, this.flickHandler);
        }
    };
    Slide.prototype.startPlay = function () {
        var _this = this;
        var _a = this.options, interval = _a.interval, autoplay = _a.autoplay;
        if (autoplay) {
            clearTimeout(this.autoplayTimer);
            this.autoplayTimer = window.setTimeout(function () {
                _this.next();
            }, interval);
        }
    };
    Slide.prototype.pausePlay = function () {
        if (this.options.autoplay) {
            clearTimeout(this.autoplayTimer);
        }
    };
    Slide.prototype.setSlideInlineStyle = function () {
        var styleConfigurations = [
            {
                direction: 'scrollX',
                sizeType: 'offsetWidth',
                styleType: 'width',
            },
            {
                direction: 'scrollY',
                sizeType: 'offsetHeight',
                styleType: 'height',
            },
        ];
        var _a = this.scroll.scroller, slideContent = _a.content, slideWrapper = _a.wrapper;
        var scrollOptions = this.scroll.options;
        styleConfigurations.forEach(function (_a) {
            var direction = _a.direction, sizeType = _a.sizeType, styleType = _a.styleType;
            // wanna scroll in this direction
            if (scrollOptions[direction]) {
                var size = slideWrapper[sizeType];
                var children = slideContent.children;
                var length_1 = children.length;
                for (var i = 0; i < length_1; i++) {
                    var slidePageDOM = children[i];
                    slidePageDOM.style[styleType] = size + 'px';
                }
                slideContent.style[styleType] = size * length_1 + 'px';
            }
        });
    };
    Slide.prototype.next = function (time, easing) {
        var _a = this.pages.nextPageIndex(), pageX = _a.pageX, pageY = _a.pageY;
        this.goTo(pageX, pageY, time, easing);
    };
    Slide.prototype.prev = function (time, easing) {
        var _a = this.pages.prevPageIndex(), pageX = _a.pageX, pageY = _a.pageY;
        this.goTo(pageX, pageY, time, easing);
    };
    Slide.prototype.goToPage = function (pageX, pageY, time, easing) {
        var pageIndex = this.pages.getValidPageIndex(pageX, pageY);
        this.goTo(pageIndex.pageX, pageIndex.pageY, time, easing);
    };
    Slide.prototype.getCurrentPage = function () {
        return this.exposedPage || this.pages.getInitialPage(false, true);
    };
    Slide.prototype.setCurrentPage = function (page) {
        this.pages.setCurrentPage(page);
        this.exposedPage = this.pages.getExposedPage(page);
    };
    Slide.prototype.nearestPage = function (x, y) {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var maxScrollPosX = scrollBehaviorX.maxScrollPos, minScrollPosX = scrollBehaviorX.minScrollPos;
        var maxScrollPosY = scrollBehaviorY.maxScrollPos, minScrollPosY = scrollBehaviorY.minScrollPos;
        return this.pages.getNearestPage(between(x, maxScrollPosX, minScrollPosX), between(y, maxScrollPosY, minScrollPosY));
    };
    Slide.prototype.satisfyThreshold = function (x, y) {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var satisfied = true;
        if (Math.abs(x - scrollBehaviorX.absStartPos) <= this.thresholdX &&
            Math.abs(y - scrollBehaviorY.absStartPos) <= this.thresholdY) {
            satisfied = false;
        }
        return satisfied;
    };
    Slide.prototype.refreshHandler = function (content) {
        var _this = this;
        if (!this.satisfyInitialization()) {
            return;
        }
        this.pages.refresh();
        this.computeThreshold();
        var contentChanged = (this.contentChanged = this.prevContent !== content);
        if (contentChanged) {
            this.prevContent = content;
        }
        var initPage = this.pages.getInitialPage(this.oneToMorePagesInLoop || this.moreToOnePageInLoop, contentChanged || !this.initialised);
        if (this.initialised) {
            this.goTo(initPage.pageX, initPage.pageY, 0);
        }
        else {
            this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.beforeInitialScrollTo, function (position) {
                _this.initialised = true;
                position.x = initPage.x;
                position.y = initPage.y;
            });
        }
        this.startPlay();
    };
    Slide.prototype.computeThreshold = function () {
        var threshold = this.options.threshold;
        // Integer
        if (threshold % 1 === 0) {
            this.thresholdX = threshold;
            this.thresholdY = threshold;
        }
        else {
            // decimal
            var _a = this.pages.getPageStats(), width = _a.width, height = _a.height;
            this.thresholdX = Math.round(width * threshold);
            this.thresholdY = Math.round(height * threshold);
        }
    };
    Slide.prototype.cloneFirstAndLastSlidePage = function (slideContent) {
        var children = slideContent.children;
        var preprendDOM = children[children.length - 1].cloneNode(true);
        var appendDOM = children[0].cloneNode(true);
        prepend(preprendDOM, slideContent);
        slideContent.appendChild(appendDOM);
        this.cachedClonedPageDOM = [preprendDOM, appendDOM];
    };
    Slide.prototype.removeClonedSlidePage = function (slideContent) {
        // maybe slideContent has removed from DOM Tree
        var slidePages = (slideContent && slideContent.children) || [];
        if (slidePages.length) {
            this.cachedClonedPageDOM.forEach(function (el) {
                removeChild(slideContent, el);
            });
        }
        this.cachedClonedPageDOM = [];
    };
    Slide.prototype.modifyCurrentPage = function (point) {
        var _a = this.getCurrentPage(), prevExposedPageX = _a.pageX, prevExposedPageY = _a.pageY;
        var newPage = this.nearestPage(point.x, point.y);
        this.setCurrentPage(newPage);
        /* istanbul ignore if */
        if (this.contentChanged) {
            this.contentChanged = false;
            return true;
        }
        var _b = this.getCurrentPage(), currentExposedPageX = _b.pageX, currentExposedPageY = _b.pageY;
        this.pageWillChangeTo(newPage);
        // loop is true, and one page becomes many pages when call bs.refresh
        if (this.oneToMorePagesInLoop) {
            this.oneToMorePagesInLoop = false;
            return true;
        }
        // loop is true, and many page becomes one page when call bs.refresh
        // if prevPage > 0, dispatch slidePageChanged and scrollEnd events
        /* istanbul ignore if */
        if (this.moreToOnePageInLoop &&
            prevExposedPageX === 0 &&
            prevExposedPageY === 0) {
            this.moreToOnePageInLoop = false;
            return true;
        }
        if (prevExposedPageX !== currentExposedPageX ||
            prevExposedPageY !== currentExposedPageY) {
            // only trust pageX & pageY when loop is true
            var page = this.pages.getExposedPageByPageIndex(currentExposedPageX, currentExposedPageY);
            this.scroll.trigger(this.scroll.eventTypes.slidePageChanged, page);
        }
        // triggered by resetLoop
        if (this.resetLooping) {
            this.resetLooping = false;
            return;
        }
        var changePage = this.pages.resetLoopPage();
        if (changePage) {
            this.resetLooping = true;
            this.goTo(changePage.pageX, changePage.pageY, 0);
            // stop user's scrollEnd
            // since it is a seamless scroll
            return true;
        }
    };
    Slide.prototype.goTo = function (pageX, pageY, time, easing) {
        var newPage = this.pages.getInternalPage(pageX, pageY);
        var scrollEasing = easing || this.options.easing || ease.bounce;
        var x = newPage.x, y = newPage.y;
        var deltaX = x - this.scroll.scroller.scrollBehaviorX.currentPos;
        var deltaY = y - this.scroll.scroller.scrollBehaviorY.currentPos;
        /* istanbul ignore if */
        if (!deltaX && !deltaY) {
            this.scroll.scroller.togglePointerEvents(true);
            return;
        }
        time = time === undefined ? this.getEaseTime(deltaX, deltaY) : time;
        this.scroll.scroller.scrollTo(x, y, time, scrollEasing);
    };
    Slide.prototype.flickHandler = function () {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var currentPosX = scrollBehaviorX.currentPos, startPosX = scrollBehaviorX.startPos, directionX = scrollBehaviorX.direction;
        var currentPosY = scrollBehaviorY.currentPos, startPosY = scrollBehaviorY.startPos, directionY = scrollBehaviorY.direction;
        var _b = this.pages.currentPage, pageX = _b.pageX, pageY = _b.pageY;
        var time = this.getEaseTime(currentPosX - startPosX, currentPosY - startPosY);
        this.goTo(pageX + directionX, pageY + directionY, time);
    };
    Slide.prototype.getEaseTime = function (deltaX, deltaY) {
        return (this.options.speed ||
            Math.max(Math.max(Math.min(Math.abs(deltaX), 1000), Math.min(Math.abs(deltaY), 1000)), 300));
    };
    Slide.prototype.modifyScrollMetaHandler = function (scrollMeta) {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY, animater = _a.animater;
        var newX = scrollMeta.newX;
        var newY = scrollMeta.newY;
        var newPage = this.satisfyThreshold(newX, newY) || animater.forceStopped
            ? this.pages.getPageByDirection(this.nearestPage(newX, newY), scrollBehaviorX.direction, scrollBehaviorY.direction)
            : this.pages.currentPage;
        scrollMeta.time = this.getEaseTime(scrollMeta.newX - newPage.x, scrollMeta.newY - newPage.y);
        scrollMeta.newX = newPage.x;
        scrollMeta.newY = newPage.y;
        scrollMeta.easing = this.options.easing || ease.bounce;
    };
    Slide.prototype.scrollHandler = function (_a) {
        var x = _a.x, y = _a.y;
        if (this.satisfyThreshold(x, y)) {
            var newPage = this.nearestPage(x, y);
            this.pageWillChangeTo(newPage);
        }
    };
    Slide.prototype.pageWillChangeTo = function (newPage) {
        var changeToPage = this.pages.getWillChangedPage(newPage);
        if (!samePage(this.willChangeToPage, changeToPage)) {
            this.willChangeToPage = changeToPage;
            this.scroll.trigger(this.scroll.eventTypes.slideWillChange, this.willChangeToPage);
        }
    };
    Slide.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    Slide.prototype.destroy = function () {
        var slideContent = this.scroll.scroller.content;
        var _a = this.options, loop = _a.loop, autoplay = _a.autoplay;
        if (loop) {
            this.removeClonedSlidePage(slideContent);
        }
        if (autoplay) {
            clearTimeout(this.autoplayTimer);
        }
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            if (hooks.eventTypes[hooksName]) {
                hooks.off(hooksName, handlerFn);
            }
        });
        this.hooksFn.length = 0;
    };
    Slide.pluginName = 'slide';
    return Slide;
}());

var sourcePrefix$3 = 'plugins.wheel';
var propertiesMap$3 = [
    {
        key: 'wheelTo',
        name: 'wheelTo',
    },
    {
        key: 'getSelectedIndex',
        name: 'getSelectedIndex',
    },
    {
        key: 'restorePosition',
        name: 'restorePosition',
    },
];
var propertiesConfig$3 = propertiesMap$3.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$3 + "." + item.name,
    };
});

var WHEEL_INDEX_CHANGED_EVENT_NAME = 'wheelIndexChanged';
var CONSTANTS = {
    rate: 4
};
var Wheel = /** @class */ (function () {
    function Wheel(scroll) {
        this.scroll = scroll;
        this.init();
    }
    Wheel.prototype.init = function () {
        this.handleBScroll();
        this.handleOptions();
        this.handleHooks();
        // init boundary for Wheel
        this.refreshBoundary();
        this.setSelectedIndex(this.options.selectedIndex);
    };
    Wheel.prototype.handleBScroll = function () {
        this.scroll.proxy(propertiesConfig$3);
        this.scroll.registerType([WHEEL_INDEX_CHANGED_EVENT_NAME]);
    };
    Wheel.prototype.handleOptions = function () {
        var userOptions = (this.scroll.options.wheel === true
            ? {}
            : this.scroll.options.wheel);
        var defaultOptions = {
            wheelWrapperClass: 'wheel-scroll',
            wheelItemClass: 'wheel-item',
            rotate: 25,
            adjustTime: 400,
            selectedIndex: 0,
            wheelDisabledItemClass: 'wheel-disabled-item'
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    Wheel.prototype.handleHooks = function () {
        var _this = this;
        var scroll = this.scroll;
        var scroller = this.scroll.scroller;
        var actionsHandler = scroller.actionsHandler, scrollBehaviorX = scroller.scrollBehaviorX, scrollBehaviorY = scroller.scrollBehaviorY, animater = scroller.animater;
        var prevContent = scroller.content;
        // BScroll
        scroll.on(scroll.eventTypes.scrollEnd, function (position) {
            var index = _this.findNearestValidWheel(position.y).index;
            if (scroller.animater.forceStopped && !_this.isAdjustingPosition) {
                _this.target = _this.items[index];
                // since stopped from an animation.
                // prevent user's scrollEnd callback triggered twice
                return true;
            }
            else {
                _this.setSelectedIndex(index);
                if (_this.isAdjustingPosition) {
                    _this.isAdjustingPosition = false;
                }
            }
        });
        // BScroll.hooks
        this.scroll.hooks.on(this.scroll.hooks.eventTypes.refresh, function (content) {
            if (content !== prevContent) {
                prevContent = content;
                _this.setSelectedIndex(_this.options.selectedIndex, true);
            }
            // rotate all wheel-items
            // because position may not change
            _this.rotateX(_this.scroll.y);
            // check we are stop at a disable item or not
            _this.wheelTo(_this.selectedIndex, 0);
        });
        this.scroll.hooks.on(this.scroll.hooks.eventTypes.beforeInitialScrollTo, function (position) {
            // selectedIndex has higher priority than bs.options.startY
            position.x = 0;
            position.y = -(_this.selectedIndex * _this.itemHeight);
        });
        // Scroller
        scroller.hooks.on(scroller.hooks.eventTypes.checkClick, function () {
            var index = HTMLCollectionToArray(_this.items).indexOf(_this.target);
            if (index === -1)
                return true;
            _this.wheelTo(index, _this.options.adjustTime, ease.swipe);
            return true;
        });
        scroller.hooks.on(scroller.hooks.eventTypes.scrollTo, function (endPoint) {
            endPoint.y = _this.findNearestValidWheel(endPoint.y).y;
        });
        // when content is scrolling
        // click wheel-item DOM repeatedly and crazily will cause scrollEnd not triggered
        // so reset forceStopped
        scroller.hooks.on(scroller.hooks.eventTypes.minDistanceScroll, function () {
            var animater = scroller.animater;
            if (animater.forceStopped === true) {
                animater.forceStopped = false;
            }
        });
        scroller.hooks.on(scroller.hooks.eventTypes.scrollToElement, function (el, pos) {
            if (!hasClass(el, _this.options.wheelItemClass)) {
                return true;
            }
            else {
                pos.top = _this.findNearestValidWheel(pos.top).y;
            }
        });
        // ActionsHandler
        actionsHandler.hooks.on(actionsHandler.hooks.eventTypes.beforeStart, function (e) {
            _this.target = e.target;
        });
        // ScrollBehaviorX
        // Wheel has no x direction now
        scrollBehaviorX.hooks.on(scrollBehaviorX.hooks.eventTypes.computeBoundary, function (boundary) {
            boundary.maxScrollPos = 0;
            boundary.minScrollPos = 0;
        });
        // ScrollBehaviorY
        scrollBehaviorY.hooks.on(scrollBehaviorY.hooks.eventTypes.computeBoundary, function (boundary) {
            _this.items = _this.scroll.scroller.content.children;
            _this.checkWheelAllDisabled();
            _this.itemHeight =
                _this.items.length > 0
                    ? scrollBehaviorY.contentSize / _this.items.length
                    : 0;
            boundary.maxScrollPos = -_this.itemHeight * (_this.items.length - 1);
            boundary.minScrollPos = 0;
        });
        scrollBehaviorY.hooks.on(scrollBehaviorY.hooks.eventTypes.momentum, function (momentumInfo) {
            momentumInfo.rate = CONSTANTS.rate;
            momentumInfo.destination = _this.findNearestValidWheel(momentumInfo.destination).y;
        });
        scrollBehaviorY.hooks.on(scrollBehaviorY.hooks.eventTypes.end, function (momentumInfo) {
            var validWheel = _this.findNearestValidWheel(scrollBehaviorY.currentPos);
            momentumInfo.destination = validWheel.y;
            momentumInfo.duration = _this.options.adjustTime;
        });
        // Animater
        animater.hooks.on(animater.hooks.eventTypes.time, function (time) {
            _this.transitionDuration(time);
        });
        animater.hooks.on(animater.hooks.eventTypes.timeFunction, function (easing) {
            _this.timeFunction(easing);
        });
        // bs.stop() to make wheel stop at a correct position when pending
        animater.hooks.on(animater.hooks.eventTypes.callStop, function () {
            var index = _this.findNearestValidWheel(_this.scroll.y).index;
            _this.isAdjustingPosition = true;
            _this.wheelTo(index, 0);
        });
        // Translater
        animater.translater.hooks.on(animater.translater.hooks.eventTypes.translate, function (endPoint) {
            _this.rotateX(endPoint.y);
        });
    };
    Wheel.prototype.refreshBoundary = function () {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY, content = _a.content;
        scrollBehaviorX.refresh(content);
        scrollBehaviorY.refresh(content);
    };
    Wheel.prototype.setSelectedIndex = function (index, contentChanged) {
        if (contentChanged === void 0) { contentChanged = false; }
        var prevSelectedIndex = this.selectedIndex;
        this.selectedIndex = index;
        // if content DOM changed, should not trigger event
        if (prevSelectedIndex !== index && !contentChanged) {
            this.scroll.trigger(WHEEL_INDEX_CHANGED_EVENT_NAME, index);
        }
    };
    Wheel.prototype.getSelectedIndex = function () {
        return this.selectedIndex;
    };
    Wheel.prototype.wheelTo = function (index, time, ease) {
        if (index === void 0) { index = 0; }
        if (time === void 0) { time = 0; }
        var y = -index * this.itemHeight;
        this.scroll.scrollTo(0, y, time, ease);
    };
    Wheel.prototype.restorePosition = function () {
        // bs is scrolling
        var isPending = this.scroll.pending;
        if (isPending) {
            var selectedIndex = this.getSelectedIndex();
            this.scroll.scroller.animater.clearTimer();
            this.wheelTo(selectedIndex, 0);
        }
    };
    Wheel.prototype.transitionDuration = function (time) {
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].style[better_scroll_esm_style.transitionDuration] =
                time + 'ms';
        }
    };
    Wheel.prototype.timeFunction = function (easing) {
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].style[better_scroll_esm_style.transitionTimingFunction] = easing;
        }
    };
    Wheel.prototype.rotateX = function (y) {
        var _a = this.options.rotate, rotate = _a === void 0 ? 25 : _a;
        for (var i = 0; i < this.items.length; i++) {
            var deg = rotate * (y / this.itemHeight + i);
            // Too small value is invalid in some phones, issue 1026
            var SafeDeg = deg.toFixed(3);
            this.items[i].style[better_scroll_esm_style.transform] = "rotateX(" + SafeDeg + "deg)";
        }
    };
    Wheel.prototype.findNearestValidWheel = function (y) {
        y = y > 0 ? 0 : y < this.scroll.maxScrollY ? this.scroll.maxScrollY : y;
        var currentIndex = Math.abs(Math.round(-y / this.itemHeight));
        var cacheIndex = currentIndex;
        var items = this.items;
        var wheelDisabledItemClassName = this.options
            .wheelDisabledItemClass;
        // implement web native select element
        // first, check whether there is a enable item whose index is smaller than currentIndex
        // then, check whether there is a enable item whose index is bigger than currentIndex
        // otherwise, there are all disabled items, just keep currentIndex unchange
        while (currentIndex >= 0) {
            if (!hasClass(items[currentIndex], wheelDisabledItemClassName)) {
                break;
            }
            currentIndex--;
        }
        if (currentIndex < 0) {
            currentIndex = cacheIndex;
            while (currentIndex <= items.length - 1) {
                if (!hasClass(items[currentIndex], wheelDisabledItemClassName)) {
                    break;
                }
                currentIndex++;
            }
        }
        // keep it unchange when all the items are disabled
        if (currentIndex === items.length) {
            currentIndex = cacheIndex;
        }
        // when all the items are disabled, selectedIndex should always be -1
        return {
            index: this.wheelItemsAllDisabled ? -1 : currentIndex,
            y: -currentIndex * this.itemHeight
        };
    };
    Wheel.prototype.checkWheelAllDisabled = function () {
        var wheelDisabledItemClassName = this.options.wheelDisabledItemClass;
        var items = this.items;
        this.wheelItemsAllDisabled = true;
        for (var i = 0; i < items.length; i++) {
            if (!hasClass(items[i], wheelDisabledItemClassName)) {
                this.wheelItemsAllDisabled = false;
                break;
            }
        }
    };
    Wheel.pluginName = 'wheel';
    return Wheel;
}());

var sourcePrefix$2 = 'plugins.zoom';
var propertiesMap$2 = [
    {
        key: 'zoomTo',
        name: 'zoomTo'
    }
];
var propertiesConfig$2 = propertiesMap$2.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$2 + "." + item.name
    };
});

var TWO_FINGERS = 2;
var RAW_SCALE = 1;
var Zoom = /** @class */ (function () {
    function Zoom(scroll) {
        this.scroll = scroll;
        this.scale = RAW_SCALE;
        this.prevScale = 1;
        this.init();
    }
    Zoom.prototype.init = function () {
        this.handleBScroll();
        this.handleOptions();
        this.handleHooks();
        this.tryInitialZoomTo(this.zoomOpt);
    };
    Zoom.prototype.zoomTo = function (scale, x, y, bounceTime) {
        var _a = this.resolveOrigin(x, y), originX = _a.originX, originY = _a.originY;
        var origin = {
            x: originX,
            y: originY,
            baseScale: this.scale,
        };
        this._doZoomTo(scale, origin, bounceTime, true);
    };
    Zoom.prototype.handleBScroll = function () {
        this.scroll.proxy(propertiesConfig$2);
        this.scroll.registerType([
            'beforeZoomStart',
            'zoomStart',
            'zooming',
            'zoomEnd',
        ]);
    };
    Zoom.prototype.handleOptions = function () {
        var userOptions = (this.scroll.options.zoom === true
            ? {}
            : this.scroll.options.zoom);
        var defaultOptions = {
            start: 1,
            min: 1,
            max: 4,
            initialOrigin: [0, 0],
            minimalZoomDistance: 5,
            bounceTime: 800,
        };
        this.zoomOpt = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    Zoom.prototype.handleHooks = function () {
        var _this = this;
        var scroll = this.scroll;
        var scroller = this.scroll.scroller;
        this.wrapper = this.scroll.scroller.wrapper;
        this.setTransformOrigin(this.scroll.scroller.content);
        var scrollBehaviorX = scroller.scrollBehaviorX;
        var scrollBehaviorY = scroller.scrollBehaviorY;
        this.hooksFn = [];
        // BScroll
        this.registerHooks(scroll.hooks, scroll.hooks.eventTypes.contentChanged, function (content) {
            _this.setTransformOrigin(content);
            _this.scale = RAW_SCALE;
            _this.tryInitialZoomTo(_this.zoomOpt);
        });
        this.registerHooks(scroll.hooks, scroll.hooks.eventTypes.beforeInitialScrollTo, function () {
            // if perform a zoom action, we should prevent initial scroll when initialised
            if (_this.zoomOpt.start !== RAW_SCALE) {
                return true;
            }
        });
        // enlarge boundary
        this.registerHooks(scrollBehaviorX.hooks, scrollBehaviorX.hooks.eventTypes.beforeComputeBoundary, function () {
            // content may change, don't cache it's size
            var contentSize = getRect(_this.scroll.scroller.content);
            scrollBehaviorX.contentSize = Math.floor(contentSize.width * _this.scale);
        });
        this.registerHooks(scrollBehaviorY.hooks, scrollBehaviorY.hooks.eventTypes.beforeComputeBoundary, function () {
            // content may change, don't cache it's size
            var contentSize = getRect(_this.scroll.scroller.content);
            scrollBehaviorY.contentSize = Math.floor(contentSize.height * _this.scale);
        });
        // touch event
        this.registerHooks(scroller.actions.hooks, scroller.actions.hooks.eventTypes.start, function (e) {
            var numberOfFingers = (e.touches && e.touches.length) || 0;
            _this.fingersOperation(numberOfFingers);
            if (numberOfFingers === TWO_FINGERS) {
                _this.zoomStart(e);
            }
        });
        this.registerHooks(scroller.actions.hooks, scroller.actions.hooks.eventTypes.beforeMove, function (e) {
            var numberOfFingers = (e.touches && e.touches.length) || 0;
            _this.fingersOperation(numberOfFingers);
            if (numberOfFingers === TWO_FINGERS) {
                _this.zoom(e);
                return true;
            }
        });
        this.registerHooks(scroller.actions.hooks, scroller.actions.hooks.eventTypes.beforeEnd, function (e) {
            var numberOfFingers = _this.fingersOperation();
            if (numberOfFingers === TWO_FINGERS) {
                _this.zoomEnd();
                return true;
            }
        });
        this.registerHooks(scroller.translater.hooks, scroller.translater.hooks.eventTypes.beforeTranslate, function (transformStyle, point) {
            var scale = point.scale ? point.scale : _this.prevScale;
            _this.prevScale = scale;
            transformStyle.push("scale(" + scale + ")");
        });
        this.registerHooks(scroller.hooks, scroller.hooks.eventTypes.scrollEnd, function () {
            if (_this.fingersOperation() === TWO_FINGERS) {
                _this.scroll.trigger(_this.scroll.eventTypes.zoomEnd, {
                    scale: _this.scale,
                });
            }
        });
        this.registerHooks(this.scroll.hooks, 'destroy', this.destroy);
    };
    Zoom.prototype.setTransformOrigin = function (content) {
        content.style[better_scroll_esm_style.transformOrigin] = '0 0';
    };
    Zoom.prototype.tryInitialZoomTo = function (options) {
        var start = options.start, initialOrigin = options.initialOrigin;
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        if (start !== RAW_SCALE) {
            // Movable plugin may wanna modify minScrollPos or maxScrollPos
            // so we force Movable to caculate them
            this.resetBoundaries([scrollBehaviorX, scrollBehaviorY]);
            this.zoomTo(start, initialOrigin[0], initialOrigin[1], 0);
        }
    };
    // getter or setter operation
    Zoom.prototype.fingersOperation = function (amounts) {
        if (typeof amounts === 'number') {
            this.numberOfFingers = amounts;
        }
        else {
            return this.numberOfFingers;
        }
    };
    Zoom.prototype._doZoomTo = function (scale, origin, time, useCurrentPos) {
        var _this = this;
        if (time === void 0) { time = this.zoomOpt.bounceTime; }
        if (useCurrentPos === void 0) { useCurrentPos = false; }
        var _a = this.zoomOpt, min = _a.min, max = _a.max;
        var fromScale = this.scale;
        var toScale = between(scale, min, max);
        (function () {
            if (time === 0) {
                _this.scroll.trigger(_this.scroll.eventTypes.zooming, {
                    scale: toScale,
                });
                return;
            }
            if (time > 0) {
                var timer_1;
                var startTime_1 = getNow();
                var endTime_1 = startTime_1 + time;
                var scheduler_1 = function () {
                    var now = getNow();
                    if (now >= endTime_1) {
                        _this.scroll.trigger(_this.scroll.eventTypes.zooming, {
                            scale: toScale,
                        });
                        cancelAnimationFrame(timer_1);
                        return;
                    }
                    var ratio = ease.bounce.fn((now - startTime_1) / time);
                    var currentScale = ratio * (toScale - fromScale) + fromScale;
                    _this.scroll.trigger(_this.scroll.eventTypes.zooming, {
                        scale: currentScale,
                    });
                    timer_1 = requestAnimationFrame(scheduler_1);
                };
                // start scheduler job
                scheduler_1();
            }
        })();
        // suppose you are zooming by two fingers
        this.fingersOperation(2);
        this._zoomTo(toScale, fromScale, origin, time, useCurrentPos);
    };
    Zoom.prototype._zoomTo = function (toScale, fromScale, origin, time, useCurrentPos) {
        if (useCurrentPos === void 0) { useCurrentPos = false; }
        var ratio = toScale / origin.baseScale;
        this.setScale(toScale);
        var scroller = this.scroll.scroller;
        var scrollBehaviorX = scroller.scrollBehaviorX, scrollBehaviorY = scroller.scrollBehaviorY;
        this.resetBoundaries([scrollBehaviorX, scrollBehaviorY]);
        // position is restrained in boundary
        var newX = this.getNewPos(origin.x, ratio, scrollBehaviorX, true, useCurrentPos);
        var newY = this.getNewPos(origin.y, ratio, scrollBehaviorY, true, useCurrentPos);
        if (scrollBehaviorX.currentPos !== Math.round(newX) ||
            scrollBehaviorY.currentPos !== Math.round(newY) ||
            toScale !== fromScale) {
            scroller.scrollTo(newX, newY, time, ease.bounce, {
                start: {
                    scale: fromScale,
                },
                end: {
                    scale: toScale,
                },
            });
        }
    };
    Zoom.prototype.resolveOrigin = function (x, y) {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var resolveFormula = {
            left: function () {
                return 0;
            },
            top: function () {
                return 0;
            },
            right: function () {
                return scrollBehaviorX.contentSize;
            },
            bottom: function () {
                return scrollBehaviorY.contentSize;
            },
            center: function (index) {
                var baseSize = index === 0
                    ? scrollBehaviorX.contentSize
                    : scrollBehaviorY.contentSize;
                return baseSize / 2;
            },
        };
        return {
            originX: typeof x === 'number' ? x : resolveFormula[x](0),
            originY: typeof y === 'number' ? y : resolveFormula[y](1),
        };
    };
    Zoom.prototype.zoomStart = function (e) {
        var firstFinger = e.touches[0];
        var secondFinger = e.touches[1];
        this.startDistance = this.getFingerDistance(e);
        this.startScale = this.scale;
        var _a = offsetToBody(this.wrapper), left = _a.left, top = _a.top;
        this.origin = {
            x: Math.abs(firstFinger.pageX + secondFinger.pageX) / 2 +
                left -
                this.scroll.x,
            y: Math.abs(firstFinger.pageY + secondFinger.pageY) / 2 +
                top -
                this.scroll.y,
            baseScale: this.startScale,
        };
        this.scroll.trigger(this.scroll.eventTypes.beforeZoomStart);
    };
    Zoom.prototype.zoom = function (e) {
        var currentDistance = this.getFingerDistance(e);
        // at least minimalZoomDistance pixels for the zoom to initiate
        if (!this.zoomed &&
            Math.abs(currentDistance - this.startDistance) <
                this.zoomOpt.minimalZoomDistance) {
            return;
        }
        // when out of boundary , perform a damping algorithm
        var endScale = this.dampingScale((currentDistance / this.startDistance) * this.startScale);
        var ratio = endScale / this.startScale;
        this.setScale(endScale);
        if (!this.zoomed) {
            this.zoomed = true;
            this.scroll.trigger(this.scroll.eventTypes.zoomStart);
        }
        var scroller = this.scroll.scroller;
        var scrollBehaviorX = scroller.scrollBehaviorX, scrollBehaviorY = scroller.scrollBehaviorY;
        var x = this.getNewPos(this.origin.x, ratio, scrollBehaviorX, false, false);
        var y = this.getNewPos(this.origin.y, ratio, scrollBehaviorY, false, false);
        this.scroll.trigger(this.scroll.eventTypes.zooming, {
            scale: this.scale,
        });
        scroller.translater.translate({ x: x, y: y, scale: endScale });
    };
    Zoom.prototype.zoomEnd = function () {
        if (!this.zoomed)
            return;
        // if out of boundary, do rebound!
        if (this.shouldRebound()) {
            this._doZoomTo(this.scale, this.origin, this.zoomOpt.bounceTime);
            return;
        }
        this.scroll.trigger(this.scroll.eventTypes.zoomEnd, { scale: this.scale });
    };
    Zoom.prototype.getFingerDistance = function (e) {
        var firstFinger = e.touches[0];
        var secondFinger = e.touches[1];
        var deltaX = Math.abs(firstFinger.pageX - secondFinger.pageX);
        var deltaY = Math.abs(firstFinger.pageY - secondFinger.pageY);
        return getDistance(deltaX, deltaY);
    };
    Zoom.prototype.shouldRebound = function () {
        var _a = this.zoomOpt, min = _a.min, max = _a.max;
        var currentScale = this.scale;
        // scale exceeded!
        if (currentScale !== between(currentScale, min, max)) {
            return true;
        }
        var _b = this.scroll.scroller, scrollBehaviorX = _b.scrollBehaviorX, scrollBehaviorY = _b.scrollBehaviorY;
        // enlarge boundaries manually when zoom is end
        this.resetBoundaries([scrollBehaviorX, scrollBehaviorY]);
        var xInBoundary = scrollBehaviorX.checkInBoundary().inBoundary;
        var yInBoundary = scrollBehaviorX.checkInBoundary().inBoundary;
        return !(xInBoundary && yInBoundary);
    };
    Zoom.prototype.dampingScale = function (scale) {
        var _a = this.zoomOpt, min = _a.min, max = _a.max;
        if (scale < min) {
            scale = 0.5 * min * Math.pow(2.0, scale / min);
        }
        else if (scale > max) {
            scale = 2.0 * max * Math.pow(0.5, max / scale);
        }
        return scale;
    };
    Zoom.prototype.setScale = function (scale) {
        this.scale = scale;
    };
    Zoom.prototype.resetBoundaries = function (scrollBehaviorPairs) {
        scrollBehaviorPairs.forEach(function (behavior) { return behavior.computeBoundary(); });
    };
    Zoom.prototype.getNewPos = function (origin, lastScale, scrollBehavior, shouldInBoundary, useCurrentPos) {
        if (useCurrentPos === void 0) { useCurrentPos = false; }
        var newPos = origin -
            origin * lastScale +
            (useCurrentPos ? scrollBehavior.currentPos : scrollBehavior.startPos);
        if (shouldInBoundary) {
            newPos = between(newPos, scrollBehavior.maxScrollPos, scrollBehavior.minScrollPos);
        }
        // maxScrollPos or minScrollPos maybe a negative or positive digital
        return newPos > 0 ? Math.floor(newPos) : Math.ceil(newPos);
    };
    Zoom.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    Zoom.prototype.destroy = function () {
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
        this.hooksFn.length = 0;
    };
    Zoom.pluginName = 'zoom';
    return Zoom;
}());

var BScrollFamily = /** @class */ (function () {
    function BScrollFamily(scroll) {
        this.ancestors = [];
        this.descendants = [];
        this.hooksManager = [];
        this.analyzed = false;
        this.selfScroll = scroll;
    }
    BScrollFamily.create = function (scroll) {
        return new BScrollFamily(scroll);
    };
    BScrollFamily.prototype.hasAncestors = function (bscrollFamily) {
        var index = findIndex(this.ancestors, function (_a) {
            var item = _a[0];
            return item === bscrollFamily;
        });
        return index > -1;
    };
    BScrollFamily.prototype.hasDescendants = function (bscrollFamily) {
        var index = findIndex(this.descendants, function (_a) {
            var item = _a[0];
            return item === bscrollFamily;
        });
        return index > -1;
    };
    BScrollFamily.prototype.addAncestor = function (bscrollFamily, distance) {
        var ancestors = this.ancestors;
        ancestors.push([bscrollFamily, distance]);
        // by ascend
        ancestors.sort(function (a, b) {
            return a[1] - b[1];
        });
    };
    BScrollFamily.prototype.addDescendant = function (bscrollFamily, distance) {
        var descendants = this.descendants;
        descendants.push([bscrollFamily, distance]);
        // by ascend
        descendants.sort(function (a, b) {
            return a[1] - b[1];
        });
    };
    BScrollFamily.prototype.removeAncestor = function (bscrollFamily) {
        var ancestors = this.ancestors;
        if (ancestors.length) {
            var index = findIndex(this.ancestors, function (_a) {
                var item = _a[0];
                return item === bscrollFamily;
            });
            if (index > -1) {
                return ancestors.splice(index, 1);
            }
        }
    };
    BScrollFamily.prototype.removeDescendant = function (bscrollFamily) {
        var descendants = this.descendants;
        if (descendants.length) {
            var index = findIndex(this.descendants, function (_a) {
                var item = _a[0];
                return item === bscrollFamily;
            });
            if (index > -1) {
                return descendants.splice(index, 1);
            }
        }
    };
    BScrollFamily.prototype.registerHooks = function (hook, eventType, handler) {
        hook.on(eventType, handler);
        this.hooksManager.push([hook, eventType, handler]);
    };
    BScrollFamily.prototype.setAnalyzed = function (flag) {
        if (flag === void 0) { flag = false; }
        this.analyzed = flag;
    };
    BScrollFamily.prototype.purge = function () {
        var _this = this;
        // remove self from graph
        this.ancestors.forEach(function (_a) {
            var bscrollFamily = _a[0];
            bscrollFamily.removeDescendant(_this);
        });
        this.descendants.forEach(function (_a) {
            var bscrollFamily = _a[0];
            bscrollFamily.removeAncestor(_this);
        });
        // remove all hook handlers
        this.hooksManager.forEach(function (_a) {
            var hooks = _a[0], eventType = _a[1], handler = _a[2];
            hooks.off(eventType, handler);
        });
        this.hooksManager = [];
    };
    return BScrollFamily;
}());

var sourcePrefix$1 = 'plugins.nestedScroll';
var propertiesMap$1 = [
    {
        key: 'purgeNestedScroll',
        name: 'purgeNestedScroll',
    },
];
var propertiesConfig$1 = propertiesMap$1.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix$1 + "." + item.name,
    };
});

var DEFAUL_GROUP_ID = 'INTERNAL_NESTED_SCROLL';
var forceScrollStopHandler = function (scrolls) {
    scrolls.forEach(function (scroll) {
        if (scroll.pending) {
            scroll.stop();
            scroll.resetPosition();
        }
    });
};
var enableScrollHander = function (scrolls) {
    scrolls.forEach(function (scroll) {
        scroll.enable();
    });
};
var disableScrollHander = function (scrolls, currentScroll) {
    scrolls.forEach(function (scroll) {
        if (scroll.hasHorizontalScroll === currentScroll.hasHorizontalScroll ||
            scroll.hasVerticalScroll === currentScroll.hasVerticalScroll) {
            scroll.disable();
        }
    });
};
var syncTouchstartData = function (scrolls) {
    scrolls.forEach(function (scroll) {
        var _a = scroll.scroller, actions = _a.actions, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        // prevent click triggering many times
        actions.fingerMoved = true;
        actions.contentMoved = false;
        actions.directionLockAction.reset();
        scrollBehaviorX.start();
        scrollBehaviorY.start();
        scrollBehaviorX.resetStartPos();
        scrollBehaviorY.resetStartPos();
        actions.startTime = +new Date();
    });
};
var isOutOfBoundary = function (scroll) {
    var hasHorizontalScroll = scroll.hasHorizontalScroll, hasVerticalScroll = scroll.hasVerticalScroll, x = scroll.x, y = scroll.y, minScrollX = scroll.minScrollX, maxScrollX = scroll.maxScrollX, minScrollY = scroll.minScrollY, maxScrollY = scroll.maxScrollY, movingDirectionX = scroll.movingDirectionX, movingDirectionY = scroll.movingDirectionY;
    var ret = false;
    var outOfLeftBoundary = x >= minScrollX && movingDirectionX === -1 /* Negative */;
    var outOfRightBoundary = x <= maxScrollX && movingDirectionX === 1 /* Positive */;
    var outOfTopBoundary = y >= minScrollY && movingDirectionY === -1 /* Negative */;
    var outOfBottomBoundary = y <= maxScrollY && movingDirectionY === 1 /* Positive */;
    if (hasVerticalScroll) {
        ret = outOfTopBoundary || outOfBottomBoundary;
    }
    else if (hasHorizontalScroll) {
        ret = outOfLeftBoundary || outOfRightBoundary;
    }
    return ret;
};
var isResettingPosition = function (scroll) {
    var hasHorizontalScroll = scroll.hasHorizontalScroll, hasVerticalScroll = scroll.hasVerticalScroll, x = scroll.x, y = scroll.y, minScrollX = scroll.minScrollX, maxScrollX = scroll.maxScrollX, minScrollY = scroll.minScrollY, maxScrollY = scroll.maxScrollY;
    var ret = false;
    var outOfLeftBoundary = x > minScrollX;
    var outOfRightBoundary = x < maxScrollX;
    var outOfTopBoundary = y > minScrollY;
    var outOfBottomBoundary = y < maxScrollY;
    if (hasVerticalScroll) {
        ret = outOfTopBoundary || outOfBottomBoundary;
    }
    else if (hasHorizontalScroll) {
        ret = outOfLeftBoundary || outOfRightBoundary;
    }
    return ret;
};
var resetPositionHandler = function (scroll) {
    scroll.scroller.reflow();
    scroll.resetPosition(0 /* Immediately */);
};
var calculateDistance = function (childNode, parentNode) {
    var distance = 0;
    var parent = childNode.parentNode;
    while (parent && parent !== parentNode) {
        distance++;
        parent = parent.parentNode;
    }
    return distance;
};
var NestedScroll = /** @class */ (function () {
    function NestedScroll(scroll) {
        var groupId = this.handleOptions(scroll);
        var instance = NestedScroll.instancesMap[groupId];
        if (!instance) {
            instance = NestedScroll.instancesMap[groupId] = this;
            instance.store = [];
            instance.hooksFn = [];
        }
        instance.init(scroll);
        return instance;
    }
    NestedScroll.getAllNestedScrolls = function () {
        var instancesMap = NestedScroll.instancesMap;
        return Object.keys(instancesMap).map(function (key) { return instancesMap[key]; });
    };
    NestedScroll.purgeAllNestedScrolls = function () {
        var nestedScrolls = NestedScroll.getAllNestedScrolls();
        nestedScrolls.forEach(function (ns) { return ns.purgeNestedScroll(); });
    };
    NestedScroll.prototype.handleOptions = function (scroll) {
        var userOptions = (scroll.options.nestedScroll === true
            ? {}
            : scroll.options.nestedScroll);
        var defaultOptions = {
            groupId: DEFAUL_GROUP_ID,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
        var groupIdType = typeof this.options.groupId;
        if (groupIdType !== 'string' && groupIdType !== 'number') {
            warn('groupId must be string or number for NestedScroll plugin');
        }
        return this.options.groupId;
    };
    NestedScroll.prototype.init = function (scroll) {
        scroll.proxy(propertiesConfig$1);
        this.addBScroll(scroll);
        this.buildBScrollGraph();
        this.analyzeBScrollGraph();
        this.ensureEventInvokeSequence();
        this.handleHooks(scroll);
    };
    NestedScroll.prototype.handleHooks = function (scroll) {
        var _this = this;
        this.registerHooks(scroll.hooks, scroll.hooks.eventTypes.destroy, function () {
            _this.deleteScroll(scroll);
        });
    };
    NestedScroll.prototype.deleteScroll = function (scroll) {
        var wrapper = scroll.wrapper;
        wrapper.isBScrollContainer = undefined;
        var store = this.store;
        var hooksFn = this.hooksFn;
        var i = findIndex(store, function (bscrollFamily) {
            return bscrollFamily.selfScroll === scroll;
        });
        if (i > -1) {
            var bscrollFamily = store[i];
            bscrollFamily.purge();
            store.splice(i, 1);
        }
        var k = findIndex(hooksFn, function (_a) {
            var hooks = _a[0];
            return hooks === scroll.hooks;
        });
        if (k > -1) {
            var _a = hooksFn[k], hooks = _a[0], eventType = _a[1], handler = _a[2];
            hooks.off(eventType, handler);
            hooksFn.splice(k, 1);
        }
    };
    NestedScroll.prototype.addBScroll = function (scroll) {
        this.store.push(BScrollFamily.create(scroll));
    };
    NestedScroll.prototype.buildBScrollGraph = function () {
        var store = this.store;
        var bf1;
        var bf2;
        var wrapper1;
        var wrapper2;
        var len = this.store.length;
        // build graph
        for (var i = 0; i < len; i++) {
            bf1 = store[i];
            wrapper1 = bf1.selfScroll.wrapper;
            for (var j = 0; j < len; j++) {
                bf2 = store[j];
                wrapper2 = bf2.selfScroll.wrapper;
                // same bs
                if (bf1 === bf2)
                    continue;
                if (!wrapper1.contains(wrapper2))
                    continue;
                // bs1 contains bs2
                var distance = calculateDistance(wrapper2, wrapper1);
                if (!bf1.hasDescendants(bf2)) {
                    bf1.addDescendant(bf2, distance);
                }
                if (!bf2.hasAncestors(bf1)) {
                    bf2.addAncestor(bf1, distance);
                }
            }
        }
    };
    NestedScroll.prototype.analyzeBScrollGraph = function () {
        this.store.forEach(function (bscrollFamily) {
            if (bscrollFamily.analyzed) {
                return;
            }
            var ancestors = bscrollFamily.ancestors, descendants = bscrollFamily.descendants, currentScroll = bscrollFamily.selfScroll;
            var beforeScrollStartHandler = function () {
                // always get the latest scroll
                var ancestorScrolls = ancestors.map(function (_a) {
                    var bscrollFamily = _a[0];
                    return bscrollFamily.selfScroll;
                });
                var descendantScrolls = descendants.map(function (_a) {
                    var bscrollFamily = _a[0];
                    return bscrollFamily.selfScroll;
                });
                forceScrollStopHandler(__spreadArrays(ancestorScrolls, descendantScrolls));
                if (isResettingPosition(currentScroll)) {
                    resetPositionHandler(currentScroll);
                }
                syncTouchstartData(ancestorScrolls);
                disableScrollHander(ancestorScrolls, currentScroll);
            };
            var touchEndHandler = function () {
                var ancestorScrolls = ancestors.map(function (_a) {
                    var bscrollFamily = _a[0];
                    return bscrollFamily.selfScroll;
                });
                var descendantScrolls = descendants.map(function (_a) {
                    var bscrollFamily = _a[0];
                    return bscrollFamily.selfScroll;
                });
                enableScrollHander(__spreadArrays(ancestorScrolls, descendantScrolls));
            };
            bscrollFamily.registerHooks(currentScroll, currentScroll.eventTypes.beforeScrollStart, beforeScrollStartHandler);
            bscrollFamily.registerHooks(currentScroll, currentScroll.eventTypes.touchEnd, touchEndHandler);
            var selfActionsHooks = currentScroll.scroller.actions.hooks;
            bscrollFamily.registerHooks(selfActionsHooks, selfActionsHooks.eventTypes.detectMovingDirection, function () {
                var ancestorScrolls = ancestors.map(function (_a) {
                    var bscrollFamily = _a[0];
                    return bscrollFamily.selfScroll;
                });
                var parentScroll = ancestorScrolls[0];
                var otherAncestorScrolls = ancestorScrolls.slice(1);
                var contentMoved = currentScroll.scroller.actions.contentMoved;
                var isTopScroll = ancestorScrolls.length === 0;
                if (contentMoved) {
                    disableScrollHander(ancestorScrolls, currentScroll);
                }
                else if (!isTopScroll) {
                    if (isOutOfBoundary(currentScroll)) {
                        disableScrollHander([currentScroll], currentScroll);
                        if (parentScroll) {
                            enableScrollHander([parentScroll]);
                        }
                        disableScrollHander(otherAncestorScrolls, currentScroll);
                        return true;
                    }
                }
            });
            bscrollFamily.setAnalyzed(true);
        });
    };
    // make sure touchmove|touchend invoke from child to parent
    NestedScroll.prototype.ensureEventInvokeSequence = function () {
        var copied = this.store.slice();
        var sequencedScroll = copied.sort(function (a, b) {
            return a.descendants.length - b.descendants.length;
        });
        sequencedScroll.forEach(function (bscrollFamily) {
            var scroll = bscrollFamily.selfScroll;
            scroll.scroller.actionsHandler.rebindDOMEvents();
        });
    };
    NestedScroll.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    NestedScroll.prototype.purgeNestedScroll = function () {
        var groupId = this.options.groupId;
        this.store.forEach(function (bscrollFamily) {
            bscrollFamily.purge();
        });
        this.store = [];
        this.hooksFn.forEach(function (_a) {
            var hooks = _a[0], eventType = _a[1], handler = _a[2];
            hooks.off(eventType, handler);
        });
        this.hooksFn = [];
        delete NestedScroll.instancesMap[groupId];
    };
    NestedScroll.pluginName = 'nestedScroll';
    NestedScroll.instancesMap = {};
    return NestedScroll;
}());

var PRE_NUM = 10;
var POST_NUM = 30;
var IndexCalculator = /** @class */ (function () {
    function IndexCalculator(wrapperHeight, tombstoneHeight) {
        this.wrapperHeight = wrapperHeight;
        this.tombstoneHeight = tombstoneHeight;
        this.lastDirection = 1 /* DOWN */;
        this.lastPos = 0;
    }
    IndexCalculator.prototype.calculate = function (pos, list) {
        var offset = pos - this.lastPos;
        this.lastPos = pos;
        var direction = this.getDirection(offset);
        // important! start index is much more important than end index.
        var start = this.calculateIndex(0, pos, list);
        var end = this.calculateIndex(start, pos + this.wrapperHeight, list);
        if (direction === 1 /* DOWN */) {
            start -= PRE_NUM;
            end += POST_NUM;
        }
        else {
            start -= POST_NUM;
            end += PRE_NUM;
        }
        if (start < 0) {
            start = 0;
        }
        return {
            start: start,
            end: end,
        };
    };
    IndexCalculator.prototype.getDirection = function (offset) {
        var direction;
        if (offset > 0) {
            direction = 1 /* DOWN */;
        }
        else if (offset < 0) {
            direction = 0 /* UP */;
        }
        else {
            return this.lastDirection;
        }
        this.lastDirection = direction;
        return direction;
    };
    IndexCalculator.prototype.calculateIndex = function (start, offset, list) {
        if (offset <= 0) {
            return start;
        }
        var i = start;
        var startPos = list[i] && list[i].pos !== -1 ? list[i].pos : 0;
        var lastPos = startPos;
        var tombstone = 0;
        while (i < list.length && list[i].pos < offset) {
            lastPos = list[i].pos;
            i++;
        }
        if (i === list.length) {
            tombstone = Math.floor((offset - lastPos) / this.tombstoneHeight);
        }
        i += tombstone;
        return i;
    };
    IndexCalculator.prototype.resetState = function () {
        this.lastDirection = 1 /* DOWN */;
        this.lastPos = 0;
    };
    return IndexCalculator;
}());

var ListItem = /** @class */ (function () {
    function ListItem() {
        this.data = null;
        this.dom = null;
        this.tombstone = null;
        this.width = 0;
        this.height = 0;
        this.pos = 0;
    }
    return ListItem;
}());
var DataManager = /** @class */ (function () {
    function DataManager(list, fetchFn, onFetchFinish) {
        this.fetchFn = fetchFn;
        this.onFetchFinish = onFetchFinish;
        this.loadedNum = 0;
        this.fetching = false;
        this.hasMore = true;
        this.list = list || [];
    }
    DataManager.prototype.update = function (end) {
        return __awaiter(this, void 0, void 0, function () {
            var len;
            return __generator(this, function (_a) {
                if (!this.hasMore) {
                    end = Math.min(end, this.list.length);
                }
                // add data placeholder
                if (end > this.list.length) {
                    len = end - this.list.length;
                    this.addEmptyData(len);
                }
                // tslint:disable-next-line: no-floating-promises
                return [2 /*return*/, this.checkToFetch(end)];
            });
        });
    };
    DataManager.prototype.add = function (data) {
        for (var i = 0; i < data.length; i++) {
            if (!this.list[this.loadedNum]) {
                this.list[this.loadedNum] = { data: data[i] };
            }
            else {
                this.list[this.loadedNum] = __assign(__assign({}, this.list[this.loadedNum]), { data: data[i] });
            }
            this.loadedNum++;
        }
        return this.list;
    };
    DataManager.prototype.addEmptyData = function (len) {
        for (var i = 0; i < len; i++) {
            this.list.push(new ListItem());
        }
        return this.list;
    };
    DataManager.prototype.fetch = function (len) {
        return __awaiter(this, void 0, void 0, function () {
            var data;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (this.fetching) {
                            return [2 /*return*/, []];
                        }
                        this.fetching = true;
                        return [4 /*yield*/, this.fetchFn(len)];
                    case 1:
                        data = _a.sent();
                        this.fetching = false;
                        return [2 /*return*/, data];
                }
            });
        });
    };
    DataManager.prototype.checkToFetch = function (end) {
        return __awaiter(this, void 0, void 0, function () {
            var min, newData, currentEnd;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!this.hasMore) {
                            return [2 /*return*/];
                        }
                        if (end <= this.loadedNum) {
                            return [2 /*return*/];
                        }
                        min = end - this.loadedNum;
                        return [4 /*yield*/, this.fetch(min)];
                    case 1:
                        newData = _a.sent();
                        if (newData instanceof Array && newData.length) {
                            this.add(newData);
                            currentEnd = this.onFetchFinish(this.list, true);
                            return [2 /*return*/, this.checkToFetch(currentEnd)];
                        }
                        else if (typeof newData === 'boolean' && newData === false) {
                            this.hasMore = false;
                            this.list.splice(this.loadedNum);
                            this.onFetchFinish(this.list, false);
                        }
                        return [2 /*return*/];
                }
            });
        });
    };
    DataManager.prototype.getList = function () {
        return this.list;
    };
    DataManager.prototype.resetState = function () {
        this.loadedNum = 0;
        this.fetching = false;
        this.hasMore = true;
        this.list = [];
    };
    return DataManager;
}());

var Tombstone = /** @class */ (function () {
    function Tombstone(create) {
        this.create = create;
        this.cached = [];
        this.width = 0;
        this.height = 0;
        this.initialed = false;
        this.getSize();
    }
    Tombstone.isTombstone = function (el) {
        if (el && el.classList) {
            return el.classList.contains('tombstone');
        }
        return false;
    };
    Tombstone.prototype.getSize = function () {
        if (!this.initialed) {
            var tombstone = this.create();
            tombstone.style.position = 'absolute';
            document.body.appendChild(tombstone);
            tombstone.style.display = '';
            this.height = tombstone.offsetHeight;
            this.width = tombstone.offsetWidth;
            document.body.removeChild(tombstone);
            this.cached.push(tombstone);
        }
    };
    Tombstone.prototype.getOne = function () {
        var tombstone = this.cached.pop();
        if (tombstone) {
            var tombstoneStyle = tombstone.style;
            tombstoneStyle.display = '';
            tombstoneStyle.opacity = '1';
            tombstoneStyle[better_scroll_esm_style.transform] = '';
            tombstoneStyle[better_scroll_esm_style.transition] = '';
            return tombstone;
        }
        return this.create();
    };
    Tombstone.prototype.recycle = function (tombstones) {
        for (var _i = 0, tombstones_1 = tombstones; _i < tombstones_1.length; _i++) {
            var tombstone = tombstones_1[_i];
            tombstone.style.display = 'none';
            this.cached.push(tombstone);
        }
        return this.cached;
    };
    Tombstone.prototype.recycleOne = function (tombstone) {
        this.cached.push(tombstone);
        return this.cached;
    };
    return Tombstone;
}());

var ANIMATION_DURATION_MS = 200;
var DomManager = /** @class */ (function () {
    function DomManager(content, renderFn, tombstone) {
        this.renderFn = renderFn;
        this.tombstone = tombstone;
        this.unusedDom = [];
        this.timers = [];
        this.setContent(content);
    }
    DomManager.prototype.update = function (list, start, end) {
        if (start >= list.length) {
            start = list.length - 1;
        }
        if (end > list.length) {
            end = list.length;
        }
        this.collectUnusedDom(list, start, end);
        this.createDom(list, start, end);
        this.cacheHeight(list, start, end);
        var _a = this.positionDom(list, start, end), startPos = _a.startPos, startDelta = _a.startDelta, endPos = _a.endPos;
        return {
            start: start,
            startPos: startPos,
            startDelta: startDelta,
            end: end,
            endPos: endPos,
        };
    };
    DomManager.prototype.collectUnusedDom = function (list, start, end) {
        // TODO optimise
        for (var i = 0; i < list.length; i++) {
            if (i === start) {
                i = end - 1;
                continue;
            }
            if (list[i].dom) {
                var dom = list[i].dom;
                if (Tombstone.isTombstone(dom)) {
                    this.tombstone.recycleOne(dom);
                    dom.style.display = 'none';
                }
                else {
                    this.unusedDom.push(dom);
                }
                list[i].dom = null;
            }
        }
        return list;
    };
    DomManager.prototype.createDom = function (list, start, end) {
        for (var i = start; i < end; i++) {
            var dom = list[i].dom;
            var data = list[i].data;
            if (dom) {
                if (Tombstone.isTombstone(dom) && data) {
                    list[i].tombstone = dom;
                    list[i].dom = null;
                }
                else {
                    continue;
                }
            }
            dom = data
                ? this.renderFn(data, this.unusedDom.pop())
                : this.tombstone.getOne();
            dom.style.position = 'absolute';
            list[i].dom = dom;
            list[i].pos = -1;
            this.content.appendChild(dom);
        }
    };
    DomManager.prototype.cacheHeight = function (list, start, end) {
        for (var i = start; i < end; i++) {
            if (list[i].data && !list[i].height) {
                list[i].height = list[i].dom.offsetHeight;
            }
        }
    };
    DomManager.prototype.positionDom = function (list, start, end) {
        var _this = this;
        var tombstoneEles = [];
        var _a = this.getStartPos(list, start, end), startPos = _a.start, startDelta = _a.delta;
        var pos = startPos;
        for (var i = start; i < end; i++) {
            var tombstone = list[i].tombstone;
            if (tombstone) {
                var tombstoneStyle = tombstone.style;
                tombstoneStyle[better_scroll_esm_style.transition] = cssVendor + "transform " + ANIMATION_DURATION_MS + "ms, opacity " + ANIMATION_DURATION_MS + "ms";
                tombstoneStyle[better_scroll_esm_style.transform] = "translateY(" + pos + "px)";
                tombstoneStyle.opacity = '0';
                list[i].tombstone = null;
                tombstoneEles.push(tombstone);
            }
            if (list[i].dom && list[i].pos !== pos) {
                list[i].dom.style[better_scroll_esm_style.transform] = "translateY(" + pos + "px)";
                list[i].pos = pos;
            }
            pos += list[i].height || this.tombstone.height;
        }
        var timerId = window.setTimeout(function () {
            _this.tombstone.recycle(tombstoneEles);
        }, ANIMATION_DURATION_MS);
        this.timers.push(timerId);
        return {
            startPos: startPos,
            startDelta: startDelta,
            endPos: pos,
        };
    };
    DomManager.prototype.getStartPos = function (list, start, end) {
        if (list[start] && list[start].pos !== -1) {
            return {
                start: list[start].pos,
                delta: 0,
            };
        }
        // TODO optimise
        var pos = list[0].pos === -1 ? 0 : list[0].pos;
        for (var i_1 = 0; i_1 < start; i_1++) {
            pos += list[i_1].height || this.tombstone.height;
        }
        var originPos = pos;
        var i;
        for (i = start; i < end; i++) {
            if (!Tombstone.isTombstone(list[i].dom) && list[i].pos !== -1) {
                pos = list[i].pos;
                break;
            }
        }
        var x = i;
        if (x < end) {
            while (x > start) {
                pos -= list[x - 1].height;
                x--;
            }
        }
        var delta = originPos - pos;
        return {
            start: pos,
            delta: delta,
        };
    };
    DomManager.prototype.removeTombstone = function () {
        var tombstones = this.content.querySelectorAll('.tombstone');
        for (var i = tombstones.length - 1; i >= 0; i--) {
            this.content.removeChild(tombstones[i]);
        }
    };
    DomManager.prototype.setContent = function (content) {
        if (content !== this.content) {
            this.content = content;
        }
    };
    DomManager.prototype.destroy = function () {
        this.removeTombstone();
        this.timers.forEach(function (id) {
            clearTimeout(id);
        });
    };
    DomManager.prototype.resetState = function () {
        this.destroy();
        this.timers = [];
        this.unusedDom = [];
    };
    return DomManager;
}());

var EXTRA_SCROLL_Y = -2000;
var InfinityScroll = /** @class */ (function () {
    function InfinityScroll(scroll) {
        this.scroll = scroll;
        this.start = 0;
        this.end = 0;
        this.init();
    }
    InfinityScroll.prototype.init = function () {
        var _this = this;
        this.handleOptions();
        var _a = this.options, fetchFn = _a.fetch, renderFn = _a.render, createTombstoneFn = _a.createTombstone;
        this.tombstone = new Tombstone(createTombstoneFn);
        this.indexCalculator = new IndexCalculator(this.scroll.scroller.scrollBehaviorY.wrapperSize, this.tombstone.height);
        this.domManager = new DomManager(this.scroll.scroller.content, renderFn, this.tombstone);
        this.dataManager = new DataManager([], fetchFn, this.onFetchFinish.bind(this));
        this.scroll.on(this.scroll.eventTypes.destroy, this.destroy, this);
        this.scroll.on(this.scroll.eventTypes.scroll, this.update, this);
        this.scroll.on(this.scroll.eventTypes.contentChanged, function (content) {
            _this.domManager.setContent(content);
            _this.indexCalculator.resetState();
            _this.domManager.resetState();
            _this.dataManager.resetState();
            _this.update({ y: 0 });
        });
        var scrollBehaviorY = this.scroll.scroller.scrollBehaviorY;
        scrollBehaviorY.hooks.on(scrollBehaviorY.hooks.eventTypes.computeBoundary, this.modifyBoundary, this);
        this.update({ y: 0 });
    };
    InfinityScroll.prototype.modifyBoundary = function (boundary) {
        // manually set position to allow scroll
        boundary.maxScrollPos = EXTRA_SCROLL_Y;
    };
    InfinityScroll.prototype.handleOptions = function () {
        // narrow down type to an object
        var infinityOptions = this.scroll.options.infinity;
        if (infinityOptions) {
            if (typeof infinityOptions.fetch !== 'function') {
                warn('Infinity plugin need fetch Function to new data.');
            }
            if (typeof infinityOptions.render !== 'function') {
                warn('Infinity plugin need render Function to render each item.');
            }
            if (typeof infinityOptions.render !== 'function') {
                warn('Infinity plugin need createTombstone Function to create tombstone.');
            }
            this.options = infinityOptions;
        }
        this.scroll.options.probeType = 3 /* Realtime */;
    };
    InfinityScroll.prototype.update = function (pos) {
        var position = Math.round(-pos.y);
        // important! calculate start/end index to render
        var _a = this.indexCalculator.calculate(position, this.dataManager.getList()), start = _a.start, end = _a.end;
        this.start = start;
        this.end = end;
        // tslint:disable-next-line: no-floating-promises
        this.dataManager.update(end);
        this.updateDom(this.dataManager.getList());
    };
    InfinityScroll.prototype.onFetchFinish = function (list, hasMore) {
        var end = this.updateDom(list).end;
        if (!hasMore) {
            this.domManager.removeTombstone();
            this.scroll.scroller.animater.stop();
            this.scroll.resetPosition();
        }
        // tslint:disable-next-line: no-floating-promises
        return end;
    };
    InfinityScroll.prototype.updateDom = function (list) {
        var _a = this.domManager.update(list, this.start, this.end), end = _a.end, startPos = _a.startPos, endPos = _a.endPos, startDelta = _a.startDelta;
        if (startDelta) {
            this.scroll.minScrollY = startDelta;
        }
        if (endPos > this.scroll.maxScrollY) {
            this.scroll.maxScrollY = -(endPos - this.scroll.scroller.scrollBehaviorY.wrapperSize);
        }
        return {
            end: end,
            startPos: startPos,
            endPos: endPos,
        };
    };
    InfinityScroll.prototype.destroy = function () {
        var _a = this.scroll.scroller, content = _a.content, scrollBehaviorY = _a.scrollBehaviorY;
        while (content.firstChild) {
            content.removeChild(content.firstChild);
        }
        this.domManager.destroy();
        this.scroll.off('scroll', this.update);
        this.scroll.off('destroy', this.destroy);
        scrollBehaviorY.hooks.off(scrollBehaviorY.hooks.eventTypes.computeBoundary);
    };
    InfinityScroll.pluginName = 'infinity';
    return InfinityScroll;
}());

var sourcePrefix = 'plugins.movable';
var propertiesMap = [
    {
        key: 'putAt',
        name: 'putAt',
    },
];
var propertiesConfig = propertiesMap.map(function (item) {
    return {
        key: item.key,
        sourceKey: sourcePrefix + "." + item.name,
    };
});

var Movable = /** @class */ (function () {
    function Movable(scroll) {
        this.scroll = scroll;
        this.handleBScroll();
        this.handleHooks();
    }
    Movable.prototype.handleBScroll = function () {
        this.scroll.proxy(propertiesConfig);
    };
    Movable.prototype.handleHooks = function () {
        var _this = this;
        this.hooksFn = [];
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var computeBoundary = function (boundary, behavior) {
            if (boundary.maxScrollPos > 0) {
                // content is smaller than wrapper
                boundary.minScrollPos = behavior.wrapperSize - behavior.contentSize;
                boundary.maxScrollPos = 0;
            }
        };
        this.registerHooks(scrollBehaviorX.hooks, scrollBehaviorX.hooks.eventTypes.ignoreHasScroll, function () { return true; });
        this.registerHooks(scrollBehaviorX.hooks, scrollBehaviorX.hooks.eventTypes.computeBoundary, function (boundary) {
            computeBoundary(boundary, scrollBehaviorX);
        });
        this.registerHooks(scrollBehaviorY.hooks, scrollBehaviorY.hooks.eventTypes.ignoreHasScroll, function () { return true; });
        this.registerHooks(scrollBehaviorY.hooks, scrollBehaviorY.hooks.eventTypes.computeBoundary, function (boundary) {
            computeBoundary(boundary, scrollBehaviorY);
        });
        this.registerHooks(this.scroll.hooks, this.scroll.hooks.eventTypes.destroy, function () {
            _this.destroy();
        });
    };
    Movable.prototype.putAt = function (x, y, time, easing) {
        if (time === void 0) { time = this.scroll.options.bounceTime; }
        if (easing === void 0) { easing = ease.bounce; }
        var position = this.resolvePostion(x, y);
        this.scroll.scrollTo(position.x, position.y, time, easing);
    };
    Movable.prototype.resolvePostion = function (x, y) {
        var _a = this.scroll.scroller, scrollBehaviorX = _a.scrollBehaviorX, scrollBehaviorY = _a.scrollBehaviorY;
        var resolveFormula = {
            left: function () {
                return 0;
            },
            top: function () {
                return 0;
            },
            right: function () {
                return scrollBehaviorX.minScrollPos;
            },
            bottom: function () {
                return scrollBehaviorY.minScrollPos;
            },
            center: function (index) {
                var baseSize = index === 0
                    ? scrollBehaviorX.minScrollPos
                    : scrollBehaviorY.minScrollPos;
                return baseSize / 2;
            },
        };
        return {
            x: typeof x === 'number' ? x : resolveFormula[x](0),
            y: typeof y === 'number' ? y : resolveFormula[y](1),
        };
    };
    Movable.prototype.destroy = function () {
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
        this.hooksFn.length = 0;
    };
    Movable.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    Movable.pluginName = 'movable';
    Movable.applyOrder = "pre" /* Pre */;
    return Movable;
}());

var isImageTag = function (el) {
    return el.tagName.toLowerCase() === 'img';
};
var ObserveImage = /** @class */ (function () {
    function ObserveImage(scroll) {
        this.scroll = scroll;
        this.refreshTimer = 0;
        this.init();
    }
    ObserveImage.prototype.init = function () {
        this.handleOptions(this.scroll.options.observeImage);
        this.bindEventsToWrapper();
    };
    ObserveImage.prototype.handleOptions = function (userOptions) {
        if (userOptions === void 0) { userOptions = {}; }
        userOptions = (userOptions === true ? {} : userOptions);
        var defaultOptions = {
            debounceTime: 100,
        };
        this.options = better_scroll_esm_extend(defaultOptions, userOptions);
    };
    ObserveImage.prototype.bindEventsToWrapper = function () {
        var wrapper = this.scroll.scroller.wrapper;
        this.imageLoadEventRegister = new EventRegister(wrapper, [
            {
                name: 'load',
                handler: this.load.bind(this),
                capture: true,
            },
        ]);
        this.imageErrorEventRegister = new EventRegister(wrapper, [
            {
                name: 'error',
                handler: this.load.bind(this),
                capture: true,
            },
        ]);
    };
    ObserveImage.prototype.load = function (e) {
        var _this = this;
        var target = e.target;
        var debounceTime = this.options.debounceTime;
        if (target && isImageTag(target)) {
            if (debounceTime === 0) {
                this.scroll.refresh();
            }
            else {
                clearTimeout(this.refreshTimer);
                this.refreshTimer = window.setTimeout(function () {
                    _this.scroll.refresh();
                }, this.options.debounceTime);
            }
        }
    };
    ObserveImage.pluginName = 'observeImage';
    return ObserveImage;
}());

var resolveRatioOption = function (ratioConfig) {
    var ret = {
        ratioX: 0,
        ratioY: 0,
    };
    /* istanbul ignore if  */
    if (!ratioConfig) {
        return ret;
    }
    if (typeof ratioConfig === 'number') {
        ret.ratioX = ret.ratioY = ratioConfig;
    }
    else if (typeof ratioConfig === 'object' && ratioConfig) {
        ret.ratioX = ratioConfig.x || 0;
        ret.ratioY = ratioConfig.y || 0;
    }
    return ret;
};
var handleBubbleAndCancelable = function (e) {
    e.preventDefault();
    e.stopPropagation();
};
var Indicator = /** @class */ (function () {
    function Indicator(scroll, options) {
        this.scroll = scroll;
        this.options = options;
        this.currentPos = {
            x: 0,
            y: 0,
        };
        this.hooksFn = [];
        this.handleDOM();
        this.handleHooks();
        this.handleInteractive();
    }
    Indicator.prototype.handleDOM = function () {
        var _a = this.options, relationElement = _a.relationElement, _b = _a.relationElementHandleElementIndex, relationElementHandleElementIndex = _b === void 0 ? 0 : _b;
        this.wrapper = relationElement;
        this.indicatorEl = this.wrapper.children[relationElementHandleElementIndex];
    };
    Indicator.prototype.handleHooks = function () {
        var _this = this;
        var scroll = this.scroll;
        var scrollHooks = scroll.hooks;
        var translaterHooks = scroll.scroller.translater.hooks;
        var animaterHooks = scroll.scroller.animater.hooks;
        this.registerHooks(scrollHooks, scrollHooks.eventTypes.refresh, this.refresh);
        this.registerHooks(translaterHooks, translaterHooks.eventTypes.translate, function (pos) {
            _this.updatePosition(pos);
        });
        this.registerHooks(animaterHooks, animaterHooks.eventTypes.time, this.transitionTime);
        this.registerHooks(animaterHooks, animaterHooks.eventTypes.timeFunction, this.transitionTimingFunction);
    };
    Indicator.prototype.transitionTime = function (time) {
        if (time === void 0) { time = 0; }
        this.indicatorEl.style[better_scroll_esm_style.transitionDuration] = time + 'ms';
    };
    Indicator.prototype.transitionTimingFunction = function (easing) {
        this.indicatorEl.style[better_scroll_esm_style.transitionTimingFunction] = easing;
    };
    Indicator.prototype.handleInteractive = function () {
        if (this.options.interactive !== false) {
            this.registerEvents();
        }
    };
    Indicator.prototype.registerHooks = function (hooks, name, handler) {
        hooks.on(name, handler, this);
        this.hooksFn.push([hooks, name, handler]);
    };
    Indicator.prototype.registerEvents = function () {
        var _a = this.scroll.options, disableMouse = _a.disableMouse, disableTouch = _a.disableTouch;
        var startEvents = [];
        var moveEvents = [];
        var endEvents = [];
        if (!disableMouse) {
            startEvents.push({
                name: 'mousedown',
                handler: this.start.bind(this),
            });
            moveEvents.push({
                name: 'mousemove',
                handler: this.move.bind(this),
            });
            endEvents.push({
                name: 'mouseup',
                handler: this.end.bind(this),
            });
        }
        if (!disableTouch) {
            startEvents.push({
                name: 'touchstart',
                handler: this.start.bind(this),
            });
            moveEvents.push({
                name: 'touchmove',
                handler: this.move.bind(this),
            });
            endEvents.push({
                name: 'touchend',
                handler: this.end.bind(this),
            }, {
                name: 'touchcancel',
                handler: this.end.bind(this),
            });
        }
        this.startEventRegister = new EventRegister(this.indicatorEl, startEvents);
        this.moveEventRegister = new EventRegister(window, moveEvents);
        this.endEventRegister = new EventRegister(window, endEvents);
    };
    Indicator.prototype.refresh = function () {
        var _a = this.scroll, x = _a.x, y = _a.y, hasHorizontalScroll = _a.hasHorizontalScroll, hasVerticalScroll = _a.hasVerticalScroll, maxBScrollX = _a.maxScrollX, maxBScrollY = _a.maxScrollY;
        var _b = resolveRatioOption(this.options.ratio), ratioX = _b.ratioX, ratioY = _b.ratioY;
        var _c = getClientSize(this.wrapper), wrapperWidth = _c.width, wrapperHeight = _c.height;
        var _d = getRect(this.indicatorEl), indicatorWidth = _d.width, indicatorHeight = _d.height;
        if (hasHorizontalScroll) {
            this.maxScrollX = wrapperWidth - indicatorWidth;
            this.translateXSign =
                this.maxScrollX > 0 ? -1 /* Positive */ : 1 /* NotPositive */;
            this.minScrollX = 0;
            // ensure positive
            this.ratioX = ratioX ? ratioX : Math.abs(this.maxScrollX / maxBScrollX);
        }
        if (hasVerticalScroll) {
            this.maxScrollY = wrapperHeight - indicatorHeight;
            this.translateYSign =
                this.maxScrollY > 0 ? -1 /* Positive */ : 1 /* NotPositive */;
            this.minScrollY = 0;
            this.ratioY = ratioY ? ratioY : Math.abs(this.maxScrollY / maxBScrollY);
        }
        this.updatePosition({
            x: x,
            y: y,
        });
    };
    Indicator.prototype.start = function (e) {
        if (this.BScrollIsDisabled()) {
            return;
        }
        var point = (e.touches ? e.touches[0] : e);
        handleBubbleAndCancelable(e);
        this.initiated = true;
        this.moved = false;
        this.lastPointX = point.pageX;
        this.lastPointY = point.pageY;
        this.startTime = getNow();
        this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.beforeScrollStart);
    };
    Indicator.prototype.BScrollIsDisabled = function () {
        return !this.scroll.enabled;
    };
    Indicator.prototype.move = function (e) {
        if (!this.initiated) {
            return;
        }
        var point = (e.touches ? e.touches[0] : e);
        var pointX = point.pageX;
        var pointY = point.pageY;
        handleBubbleAndCancelable(e);
        var deltaX = pointX - this.lastPointX;
        var deltaY = pointY - this.lastPointY;
        this.lastPointX = pointX;
        this.lastPointY = pointY;
        if (!this.moved && !this.indicatorNotMoved(deltaX, deltaY)) {
            this.moved = true;
            this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollStart);
        }
        if (this.moved) {
            var newPos = this.getBScrollPosByRatio(this.currentPos, deltaX, deltaY);
            this.syncBScroll(newPos);
        }
    };
    Indicator.prototype.end = function (e) {
        if (!this.initiated) {
            return;
        }
        this.initiated = false;
        handleBubbleAndCancelable(e);
        if (this.moved) {
            var _a = this.scroll, x = _a.x, y = _a.y;
            this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollEnd, {
                x: x,
                y: y,
            });
        }
    };
    Indicator.prototype.getBScrollPosByRatio = function (currentPos, deltaX, deltaY) {
        var currentX = currentPos.x, currentY = currentPos.y;
        var _a = this.scroll, hasHorizontalScroll = _a.hasHorizontalScroll, hasVerticalScroll = _a.hasVerticalScroll, BScrollMinScrollX = _a.minScrollX, BScrollMaxScrollX = _a.maxScrollX, BScrollMinScrollY = _a.minScrollY, BScrollMaxScrollY = _a.maxScrollY;
        var _b = this.scroll, x = _b.x, y = _b.y;
        if (hasHorizontalScroll) {
            var newPosX = between(currentX + deltaX, Math.min(this.minScrollX, this.maxScrollX), Math.max(this.minScrollX, this.maxScrollX));
            var roundX = Math.round((newPosX / this.ratioX) * this.translateXSign);
            x = between(roundX, BScrollMaxScrollX, BScrollMinScrollX);
        }
        if (hasVerticalScroll) {
            var newPosY = between(currentY + deltaY, Math.min(this.minScrollY, this.maxScrollY), Math.max(this.minScrollY, this.maxScrollY));
            var roundY = Math.round((newPosY / this.ratioY) * this.translateYSign);
            y = between(roundY, BScrollMaxScrollY, BScrollMinScrollY);
        }
        return { x: x, y: y };
    };
    Indicator.prototype.indicatorNotMoved = function (deltaX, deltaY) {
        var _a = this.currentPos, x = _a.x, y = _a.y;
        var xNotMoved = (x === this.minScrollX && deltaX <= 0) ||
            (x === this.maxScrollX && deltaX >= 0);
        var yNotMoved = (y === this.minScrollY && deltaY <= 0) ||
            (y === this.maxScrollY && deltaY >= 0);
        return xNotMoved && yNotMoved;
    };
    Indicator.prototype.syncBScroll = function (newPos) {
        var timestamp = getNow();
        var _a = this.scroll, options = _a.options, scroller = _a.scroller;
        var probeType = options.probeType, momentumLimitTime = options.momentumLimitTime;
        scroller.translater.translate(newPos);
        // dispatch scroll in interval time
        if (timestamp - this.startTime > momentumLimitTime) {
            this.startTime = timestamp;
            if (probeType === 1 /* Throttle */) {
                scroller.hooks.trigger(scroller.hooks.eventTypes.scroll, newPos);
            }
        }
        // dispatch scroll all the time
        if (probeType > 1 /* Throttle */) {
            scroller.hooks.trigger(scroller.hooks.eventTypes.scroll, newPos);
        }
    };
    Indicator.prototype.updatePosition = function (BScrollPos) {
        var newIndicatorPos = this.getIndicatorPosByRatio(BScrollPos);
        this.applyTransformProperty(newIndicatorPos);
        this.currentPos = __assign({}, newIndicatorPos);
    };
    Indicator.prototype.applyTransformProperty = function (pos) {
        var translateZ = this.scroll.options.translateZ;
        var transformProperties = [
            "translateX(" + pos.x + "px)",
            "translateY(" + pos.y + "px)",
            "" + translateZ,
        ];
        this.indicatorEl.style[better_scroll_esm_style.transform] = transformProperties.join(' ');
    };
    Indicator.prototype.getIndicatorPosByRatio = function (BScrollPos) {
        var x = BScrollPos.x, y = BScrollPos.y;
        var _a = this.scroll, hasHorizontalScroll = _a.hasHorizontalScroll, hasVerticalScroll = _a.hasVerticalScroll;
        var position = __assign({}, this.currentPos);
        if (hasHorizontalScroll) {
            var roundX = Math.round(this.ratioX * x * this.translateXSign);
            // maybe maxScrollX is negative
            position.x = between(roundX, Math.min(this.minScrollX, this.maxScrollX), Math.max(this.minScrollX, this.maxScrollX));
        }
        if (hasVerticalScroll) {
            var roundY = Math.round(this.ratioY * y * this.translateYSign);
            // maybe maxScrollY is negative
            position.y = between(roundY, Math.min(this.minScrollY, this.maxScrollY), Math.max(this.minScrollY, this.maxScrollY));
        }
        return position;
    };
    Indicator.prototype.destroy = function () {
        if (this.options.interactive !== false) {
            this.startEventRegister.destroy();
            this.moveEventRegister.destroy();
            this.endEventRegister.destroy();
        }
        this.hooksFn.forEach(function (item) {
            var hooks = item[0];
            var hooksName = item[1];
            var handlerFn = item[2];
            hooks.off(hooksName, handlerFn);
        });
        this.hooksFn.length = 0;
    };
    return Indicator;
}());

var Indicators = /** @class */ (function () {
    function Indicators(scroll) {
        this.scroll = scroll;
        this.options = [];
        this.indicators = [];
        this.handleOptions();
        this.handleHooks();
    }
    Indicators.prototype.handleOptions = function () {
        var UserIndicatorsOptions = this.scroll.options.indicators;
        assert(Array.isArray(UserIndicatorsOptions), "'indicators' must be an array.");
        for (var _i = 0, UserIndicatorsOptions_1 = UserIndicatorsOptions; _i < UserIndicatorsOptions_1.length; _i++) {
            var indicatorOptions = UserIndicatorsOptions_1[_i];
            assert(!!indicatorOptions.relationElement, "'relationElement' must be a HTMLElement.");
            this.createIndicators(indicatorOptions);
        }
    };
    Indicators.prototype.createIndicators = function (options) {
        this.indicators.push(new Indicator(this.scroll, options));
    };
    Indicators.prototype.handleHooks = function () {
        var _this = this;
        var scrollHooks = this.scroll.hooks;
        scrollHooks.on(scrollHooks.eventTypes.destroy, function () {
            for (var _i = 0, _a = _this.indicators; _i < _a.length; _i++) {
                var indicator = _a[_i];
                indicator.destroy();
            }
            _this.indicators = [];
        });
    };
    Indicators.pluginName = 'indicators';
    return Indicators;
}());

BScroll.use(MouseWheel)
    .use(ObserveDOM)
    .use(PullDown)
    .use(PullUp)
    .use(ScrollBar)
    .use(Slide)
    .use(Wheel)
    .use(Zoom)
    .use(NestedScroll)
    .use(InfinityScroll)
    .use(Movable)
    .use(ObserveImage)
    .use(Indicators);

/* harmony default export */ var better_scroll_esm = (BScroll);


// CONCATENATED MODULE: ./src/packages/scrollview/scrollview.jsx


var scrollview_namespace = namespace_Namespace.Create('scroll-view');
/* harmony default export */ var scrollview = ({
  name: scrollview_namespace.name,
  props: {
    probeType: {
      type: Number,
      default: 1
    },
    click: {
      type: Boolean,
      default: true
    },
    scrollbar: {
      type: Boolean,
      default: false
    },
    scrollX: {
      type: Boolean,
      default: false
    },
    listenScroll: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array,
      default: null
    },
    pullup: {
      type: Boolean,
      default: false
    },
    pulldown: {
      type: Boolean,
      default: false
    },
    beforeScroll: {
      type: Boolean,
      default: false
    },
    refreshDelay: {
      type: Number,
      default: 20
    }
  },
  mounted: function mounted() {
    var _this = this;

    setTimeout(function () {
      _this._initScroll();
    }, 20);
  },
  methods: {
    _initScroll: function _initScroll() {
      var _this2 = this;

      this.scroll = new better_scroll_esm(this.$refs.wrapper, {
        probeType: this.probeType,
        click: this.click,
        scrollbar: this.scrollbar,
        scrollX: this.scrollX
      }); // scroll event

      if (this.listenScroll) {
        this.scroll.on('scroll', function (pos) {
          _this2.$emit('scroll', pos);
        });
      } // scrollEnd


      if (this.pullup) {
        this.scroll.on('scrollEnd', function () {
          if (_this2.scroll.y <= _this2.scroll.maxScrollY + 50) {
            console.log('pullup');

            _this2.$emit('scrollToEnd');
          }
        });
      } // pulldown


      if (this.pulldown) {
        this.scroll.on('touchEnd', function (pos) {
          if (pos.y > 50) {
            console.log('pulldown');

            _this2.$emit('pulldown');
          }
        });
      } // start scroll event


      if (this.beforeScroll) {
        this.scroll.on('beforeScrollStart', function () {
          _this2.$emit('beforeScroll');
        });
      }
    },
    disable: function disable() {
      this.scroll && this.scroll.disable();
    },
    enable: function enable() {
      this.scroll && this.scroll.enable();
    },
    refresh: function refresh() {
      this.scroll && this.scroll.refresh();
    },
    scrollTo: function scrollTo() {
      this.scroll && this.scroll.scrollTo.apply(this.scroll, arguments);
    },
    scrollToElement: function scrollToElement() {
      this.scroll && this.scroll.scrollToElement.apply(this.scroll, arguments);
    }
  },
  watch: {
    // 监听数据变化
    data: function data() {
      var _this3 = this;

      setTimeout(function () {
        _this3.refresh();
      }, this.refreshDelay);
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "ref": "wrapper"
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/scrollview/scrollview.scss
var scrollview_scrollview = __webpack_require__(25);

// CONCATENATED MODULE: ./src/packages/scrollview/index.js



vue_VueExtension.WithInstall(scrollview);
/* harmony default export */ var packages_scrollview = (scrollview);
// CONCATENATED MODULE: ./src/utils/direction.js


var direction_Direction = function Direction() {
  classCallCheck_default()(this, Direction);
};

defineProperty_default()(direction_Direction, "NONE", '');

defineProperty_default()(direction_Direction, "HOR", 'horizental');

defineProperty_default()(direction_Direction, "VER", 'vertical');
// CONCATENATED MODULE: ./src/utils/touch.js




var touch_Touch = /*#__PURE__*/function () {
  function Touch() {
    classCallCheck_default()(this, Touch);

    this.startX = 0;
    this.startY = 0;
    this.deltaX = 0;
    this.deltaY = 0;
    this.direction = direction_Direction.NONE;
  }

  createClass_default()(Touch, [{
    key: "offsetX",
    get: function get() {
      return Math.abs(this.deltaX);
    }
  }, {
    key: "offsetY",
    get: function get() {
      return Math.abs(this.deltaY);
    }
  }, {
    key: "isHorizental",
    get: function get() {
      return this.direction === direction_Direction.HOR;
    }
  }, {
    key: "isVertical",
    get: function get() {
      return this.direction === direction_Direction.VER;
    }
  }, {
    key: "isUndetermined",
    get: function get() {
      return this.direction === direction_Direction.NONE;
    }
  }, {
    key: "resolveDirection",
    value: function resolveDirection(x, y) {
      if (x > y && x > Touch.MIN_DISTANCE) {
        return direction_Direction.HOR;
      }

      if (y > x && y > Touch.MIN_DISTANCE) {
        return direction_Direction.VER;
      }

      return direction_Direction.NONE;
    }
  }, {
    key: "reset",
    value: function reset() {
      this.startX = 0;
      this.startY = 0;
      this.deltaX = 0;
      this.deltaY = 0;
      this.direction = direction_Direction.NONE;
    }
  }, {
    key: "getTouchByEvent",
    value: function getTouchByEvent(e) {
      return e.clientX ? e : e.touches[0];
    }
  }, {
    key: "start",
    value: function start(evt) {
      var e = this.getTouchByEvent(evt);
      this.reset();
      this.startX = e.clientX;
      this.startY = e.clientY;
    }
  }, {
    key: "move",
    value: function move(evt) {
      var e = this.getTouchByEvent(evt);
      this.deltaX = e.clientX - this.startX;
      this.deltaY = e.clientY - this.startY;

      if (this.isUndetermined) {
        this.direction = this.resolveDirection(this.offsetX, this.offsetY);
      }
    }
  }], [{
    key: "IsTouchable",
    get: function get() {
      return 'ontouchstart' in window;
    }
  }, {
    key: "Create",
    value: function Create() {
      return new Touch();
    }
  }]);

  return Touch;
}();

defineProperty_default()(touch_Touch, "MIN_DISTANCE", 10);
// CONCATENATED MODULE: ./src/utils/inertia.js



var inertia_Inertia = /*#__PURE__*/function () {
  function Inertia() {
    classCallCheck_default()(this, Inertia);

    this.startTime = 0;
    this.startOffset = 0;
    this.endTime = 0;
    this.endOffset = 0;
  }

  createClass_default()(Inertia, [{
    key: "shouldActive",
    get: function get() {
      return Math.abs(this.interval) < Inertia.LIMIT_TIME && Math.abs(this.distance) > Inertia.LIMIT_DISTANCE;
    }
  }, {
    key: "interval",
    get: function get() {
      return this.endTime - this.startTime;
    }
  }, {
    key: "distance",
    get: function get() {
      return this.endOffset - this.startOffset;
    }
  }, {
    key: "speed",
    get: function get() {
      return this.distance / this.interval;
    }
  }, {
    key: "start",
    value: function start(startOffset) {
      var startTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
      this.startOffset = startOffset;
      this.startTime = startTime;
    }
  }, {
    key: "end",
    value: function end(endOffset) {
      var endTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
      this.endOffset = endOffset;
      this.endTime = endTime;
    }
  }], [{
    key: "Create",
    value: function Create() {
      return new Inertia();
    }
  }]);

  return Inertia;
}();

defineProperty_default()(inertia_Inertia, "LIMIT_TIME", 300);

defineProperty_default()(inertia_Inertia, "LIMIT_DISTANCE", 15);
// CONCATENATED MODULE: ./src/utils/extensions/math.js


var math_MathExtension = /*#__PURE__*/function () {
  function MathExtension() {
    classCallCheck_default()(this, MathExtension);
  }

  createClass_default()(MathExtension, null, [{
    key: "Clamp",
    value: function Clamp(number, min, max) {
      return Math.min(Math.max(min, number), max);
    }
  }]);

  return MathExtension;
}();
// CONCATENATED MODULE: ./src/packages/pickercolumn/pickercolumn.jsx






var pickercolumn_namespace = namespace_Namespace.Create('picker-column');
/* harmony default export */ var pickercolumn = ({
  name: pickercolumn_namespace.name,
  props: {
    readonly: {
      type: Boolean,
      default: false
    },
    itemHeight: {
      type: Number,
      required: true
    },
    visibleItemCount: {
      type: Number | String,
      required: true
    },
    defaultIndex: {
      type: Number,
      default: 0
    },
    swipeDuration: {
      type: Number,
      required: true
    },
    items: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    suffix: {
      type: String,
      default: ''
    },
    formatter: {
      type: Function,
      default: null
    }
  },
  data: function data() {
    return {
      selectedIndex: this.defaultIndex,
      offset: 0,
      duration: 0,
      moving: false,
      startOffset: 0,
      correctAfterTransition: null,
      inertia: inertia_Inertia.Create(),
      touch: touch_Touch.Create()
    };
  },
  computed: {
    wrapperCls: function wrapperCls() {
      return pickercolumn_namespace.derive('wrapper');
    },
    itemWrapperCls: function itemWrapperCls() {
      return pickercolumn_namespace.derive('item-wrapper');
    },
    cls: function cls() {
      return pickercolumn_namespace.derive();
    },
    suffixWrapperCls: function suffixWrapperCls() {
      return pickercolumn_namespace.derive('suffix-wrapper');
    },
    suffixCls: function suffixCls() {
      return pickercolumn_namespace.derive('suffix');
    },
    itemCount: function itemCount() {
      return this.items.length;
    },
    baseOffset: function baseOffset() {
      return this.itemHeight * (this.visibleItemCount - 1) / 2;
    },
    wrapperStyle: function wrapperStyle() {
      return {
        transform: "translate3d(0, ".concat(this.offset + this.baseOffset, "px, 0)"),
        transitionDuration: "".concat(this.duration, "ms"),
        transitionProperty: this.duration ? 'all' : 'none'
      };
    },
    itemStyle: function itemStyle() {
      return {
        height: "".concat(this.itemHeight, "px"),
        lineHeight: "".concat(this.itemHeight, "px")
      };
    },
    suffixStyle: function suffixStyle() {
      return {
        height: "".concat(this.itemHeight, "px"),
        lineHeight: "".concat(this.itemHeight, "px")
      };
    }
  },
  watch: {
    defaultIndex: function defaultIndex(val) {
      this.setIndex(val);
    }
  },
  created: function created() {
    this.setIndex(this.selectedIndex);
  },
  updated: function updated() {
    if (this.selectedIndex >= this.itemCount) {
      this.setIndex(this.itemCount - 1);
    }
  },
  methods: {
    getTouchInfo: function getTouchInfo(e) {
      return e.touches[0];
    },
    getValue: function getValue() {
      return this.items[this.selectedIndex];
    },
    setIndex: function setIndex(index, emitChange) {
      var _this = this;

      var nIndex = this.correctIndex(index) || 0;
      var offset = -nIndex * this.itemHeight;

      var trigger = function trigger() {
        if (nIndex !== _this.selectedIndex) {
          _this.selectedIndex = nIndex;

          if (emitChange) {
            _this.emitChange(nIndex);
          }
        }
      };

      if (this.moving && offset !== this.offset) {
        this.correctAfterTransition = trigger;
      } else {
        trigger();
      }

      this.offset = offset;
    },
    emitChange: function emitChange(index) {
      this.$emit('change', index);
    },
    correctIndex: function correctIndex(index) {
      var nIndex = math_MathExtension.Clamp(index, 0, this.itemCount);

      for (var i = nIndex; i < this.itemCount; i++) {
        if (!this.isOptionDisabled(this.items[i])) return i;
      }

      for (var _i = nIndex - 1; _i >= 0; _i--) {
        if (!this.isOptionDisabled(this.items[_i])) return _i;
      }
    },
    isOptionDisabled: function isOptionDisabled(option) {
      return typeof_default()(option) === 'object' && option.disabeld;
    },
    onTouchStart: function onTouchStart(e) {
      if (this.readonly) {
        return;
      }

      var touchInfo = this.getTouchInfo(e);
      this.touch.start(touchInfo);
      this.duration = 0;
      this.startOffset = this.offset;
      this.correctAfterTransition = null;
      this.inertia.start(this.offset);
    },
    onTouchMove: function onTouchMove(e) {
      if (this.readonly) {
        return;
      }

      dom_DOMExtension.PreventDefault(e);
      var touchInfo = this.getTouchInfo(e);
      this.touch.move(touchInfo);

      if (!this.touch.isVertical) {
        return;
      }

      this.moving = true;
      this.offset = math_MathExtension.Clamp(this.startOffset + this.touch.deltaY, -this.itemCount * this.itemHeight, this.itemHeight);
      var now = Date.now();

      if (now - this.touchStartTime > inertia_Inertia.LIMIT_TIME) {
        this.inertia.start(this.offset, now);
      }
    },
    onTouchEnd: function onTouchEnd(e) {
      var _this2 = this;

      if (this.readonly) {
        return;
      }

      this.inertia.end(this.offset);

      if (this.inertia.shouldActive) {
        this.startInertia();
      } else {
        var index = this.getIndexByOffset(this.offset);
        this.duration = 200;
        this.setIndex(index, true);
        setTimeout(function () {
          return _this2.moving = false;
        }, 0);
      }
    },
    onTransitionEnd: function onTransitionEnd() {
      this.stopInertia();
    },
    getIndexByOffset: function getIndexByOffset(offset) {
      return math_MathExtension.Clamp(Math.round(-offset / this.itemHeight), 0, this.itemCount - 1);
    },
    startInertia: function startInertia() {
      var speed = Math.abs(this.inertia.speed);
      var offset = this.offset + speed / 0.003 * (this.inertia.distance < 0 ? -1 : 1);
      var index = this.getIndexByOffset(offset);
      this.duration = this.swipeDuration;
      this.setIndex(index, true);
    },
    stopInertia: function stopInertia() {
      this.moving = false;
      this.duration = 0;

      if (this.correctAfterTransition) {
        this.correctAfterTransition();
        this.correctAfterTransition = null;
      }
    },
    onItemClick: function onItemClick(e, index) {
      if (this.moving || this.readonly) {
        return;
      }

      this.correctAfterTransition = null;
      this.duration = 200;
      this.setIndex(index, true);
    }
  },
  render: function render() {
    var _this3 = this;

    var h = arguments[0];

    var renderItems = function renderItems() {
      return _this3.items.map(function (item, i) {
        var cls = pickercolumn_namespace.derive('item', {
          selected: i === _this3.selectedIndex
        });
        return h("li", {
          "class": cls,
          "key": i,
          "style": _this3.itemStyle,
          "on": {
            "click": function click($event) {
              $event.stopPropagation();
              return function (e) {
                return _this3.onItemClick(e, i);
              }($event);
            }
          }
        }, [_this3.formatter ? _this3.formatter(item.text) : item.text]);
      });
    };

    var renderSuffix = function renderSuffix() {
      if (_this3.suffix) {
        return h("div", {
          "class": _this3.suffixWrapperCls
        }, [h("div", {
          "class": _this3.suffixCls,
          "style": _this3.suffixStyle
        }, [_this3.suffix])]);
      }
    };

    return h("div", {
      "class": this.wrapperCls
    }, [h("div", {
      "class": this.itemWrapperCls,
      "on": {
        "touchstart": this.onTouchStart,
        "touchmove": this.onTouchMove,
        "touchend": this.onTouchEnd,
        "touchcancel": this.onTouchEnd
      }
    }, [h("ul", {
      "class": this.cls,
      "style": this.wrapperStyle,
      "on": {
        "transitionend": this.onTransitionEnd
      }
    }, [renderItems()])]), renderSuffix()]);
  }
});
// CONCATENATED MODULE: ./src/packages/picker/picker.jsx


var picker_namespace = namespace_Namespace.Create('picker');
/* harmony default export */ var picker = ({
  name: picker_namespace.name,
  components: {
    PickerColumn: pickercolumn
  },
  props: {
    columns: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    itemHeight: {
      type: Number,
      default: 50
    },
    visibleItemCount: {
      type: Number,
      default: 5
    },
    swipeDuration: {
      type: Number,
      default: 800
    },
    title: {
      type: String,
      default: ''
    },
    readonly: {
      type: Boolean,
      default: false
    },
    windowPattern: {
      type: String,
      default: 'fill'
    }
  },
  computed: {
    cls: function cls() {
      return picker_namespace.derive();
    },
    headerCls: function headerCls() {
      return picker_namespace.derive('header');
    },
    titleCls: function titleCls() {
      return picker_namespace.derive('header-title');
    },
    bodyCls: function bodyCls() {
      return picker_namespace.derive('body');
    },
    bodyStyle: function bodyStyle() {
      return {
        height: "".concat(this.itemHeight * this.visibleItemCount, "px")
      };
    },
    columnContainerCls: function columnContainerCls() {
      return picker_namespace.derive('body-column-container');
    },
    maskCls: function maskCls() {
      return picker_namespace.derive('body-mask');
    },
    maskStyle: function maskStyle() {
      return {
        backgroundSize: "100% ".concat(this.itemHeight * (this.visibleItemCount - 1) / 2, "px")
      };
    },
    windowCls: function windowCls() {
      return picker_namespace.derive('body-window', [this.windowPattern]);
    },
    windowStyle: function windowStyle() {
      return {
        height: "".concat(this.itemHeight, "px")
      };
    },
    windowColumnCls: function windowColumnCls() {
      return picker_namespace.derive('body-window-column');
    },
    windowColumnSuffixCls: function windowColumnSuffixCls() {
      return picker_namespace.derive('body-window-column-suffix');
    },
    footerCls: function footerCls() {
      return picker_namespace.derive('footer');
    },
    footerBtnCls: function footerBtnCls() {
      return picker_namespace.derive('footer-btn');
    }
  },
  methods: {
    onChange: function onChange(columnIndex, selectedItemIndex) {
      var _this = this;

      var values = this.columns.map(function (_, i) {
        return _this.$refs["picker-column-".concat(i)].getValue();
      });
      this.$emit('change', values, {
        columnIndex: columnIndex,
        selectedItemIndex: selectedItemIndex
      });
    },
    onCancel: function onCancel() {
      this.$emit('cancel');
    },
    onConfirm: function onConfirm() {
      this.$emit('confirm');
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];

    var renderHeader = function renderHeader() {
      return h("div", {
        "class": _this2.headerCls
      }, [_this2.$slots.header || _this2.title && h("div", {
        "class": _this2.titleCls
      }, [_this2.title])]);
    };

    var renderBody = function renderBody() {
      var cols = _this2.columns.map(function (v, i) {
        return h(pickercolumn, {
          "key": i,
          "ref": "picker-column-".concat(i),
          "attrs": {
            "readonly": _this2.readonly,
            "items": v.items,
            "default-index": v.defaultIndex,
            "item-height": _this2.itemHeight,
            "swipeDuration": _this2.swipeDuration,
            "visible-item-count": _this2.visibleItemCount,
            "suffix": v.suffix,
            "formatter": v.formatter
          },
          "on": {
            "change": function change(selectedIndex) {
              return _this2.onChange(i, selectedIndex);
            }
          }
        });
      });

      return h("div", {
        "class": _this2.bodyCls,
        "style": _this2.bodyStyle
      }, [h("div", {
        "class": _this2.columnContainerCls
      }, [cols]), h("div", {
        "class": _this2.maskCls,
        "style": _this2.maskStyle
      }), h("div", {
        "class": _this2.windowCls,
        "style": _this2.windowStyle
      })]);
    };

    var renderFooter = function renderFooter() {
      var btns = [h("div", {
        "class": _this2.footerBtnCls,
        "on": {
          "click": _this2.onCancel
        }
      }, ["\u53D6\u6D88"]), h("div", {
        "class": _this2.footerBtnCls,
        "on": {
          "click": _this2.onConfirm
        }
      }, ["\u786E\u5B9A"])];
      return h("div", {
        "class": _this2.footerCls
      }, [_this2.$slots.footer || btns]);
    };

    return h("div", {
      "class": this.cls
    }, [renderHeader(), renderBody(), renderFooter()]);
  }
});
// EXTERNAL MODULE: ./src/packages/picker/picker.scss
var picker_picker = __webpack_require__(26);

// CONCATENATED MODULE: ./src/packages/picker/index.js



vue_VueExtension.WithInstall(picker);
/* harmony default export */ var packages_picker = (picker);
// CONCATENATED MODULE: ./src/packages/checkbox/checkbox.jsx


var checkbox_namespace = namespace_Namespace.Create('checkbox');
/* harmony default export */ var checkbox_checkbox = ({
  name: checkbox_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    text: {
      type: String,
      default: ''
    },
    theme: {
      type: String,
      default: 'brand'
    },
    color: {
      type: String,
      default: '#1989fa'
    },
    disabled: {
      type: Boolean,
      default: false
    },
    icon: {
      type: String,
      default: 'checkbox-checked'
    },
    activeIcon: {
      type: String,
      default: 'checkbox-unchecked'
    },
    iconClassPrefix: {
      type: String,
      default: 'mx-icon'
    }
  },
  computed: {
    cls: function cls() {
      return checkbox_namespace.derive([this.theme, {
        disabled: this.disabled
      }]);
    },
    contentCls: function contentCls() {
      return checkbox_namespace.derive('content');
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  methods: {
    onClick: function onClick() {
      if (this.disabled || this.$el.hasAttribute('disabled')) {
        return;
      }

      this.emitChange(!this.value);
    },
    emitChange: function emitChange(value) {
      this.$emit('change', value);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("div", {
      "class": this.cls,
      "on": {
        "click": function click($event) {
          $event.stopPropagation();
          return _this.onClick($event);
        }
      }
    }, [h(icon, {
      "attrs": {
        "name": this.value ? this.activeIcon : this.icon,
        "class-prefix": this.iconClassPrefix,
        "size": "20",
        "theme": this.theme,
        "color": this.color
      }
    }), this.$slots.default || this.text && h("div", {
      "class": this.contentCls
    }, [this.text])]);
  }
});
// EXTERNAL MODULE: ./src/packages/checkbox/checkbox.scss
var packages_checkbox_checkbox = __webpack_require__(27);

// CONCATENATED MODULE: ./src/packages/checkbox/index.js



vue_VueExtension.WithInstall(checkbox_checkbox);
/* harmony default export */ var packages_checkbox = (checkbox_checkbox);
// CONCATENATED MODULE: ./src/packages/radio/radio.jsx


var radio_namespace = namespace_Namespace.Create('radio');
/* harmony default export */ var radio_radio = ({
  name: radio_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    text: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    theme: {
      type: String,
      default: 'brand'
    },
    icon: {
      type: String,
      default: 'checked'
    },
    activeIcon: {
      type: String,
      default: 'unchecked'
    },
    iconClassPrefix: {
      type: String,
      default: 'mx-icon'
    },
    color: {
      type: String,
      default: '#1989fa'
    }
  },
  computed: {
    cls: function cls() {
      return radio_namespace.derive([this.theme, {
        disabled: this.disabled
      }]);
    },
    contentCls: function contentCls() {
      return radio_namespace.derive('content');
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  methods: {
    onClick: function onClick() {
      if (this.disabled || this.$el.hasAttribute('disabled')) {
        return;
      }

      this.emitChange(!this.value);
    },
    emitChange: function emitChange(value) {
      this.$emit('change', value);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("div", {
      "class": this.cls,
      "on": {
        "click": function click($event) {
          $event.stopPropagation();
          return _this.onClick($event);
        }
      }
    }, [h(icon, {
      "attrs": {
        "name": this.value ? this.activeIcon : this.icon,
        "class-prefix": this.iconClassPrefix,
        "size": "20",
        "theme": this.theme,
        "color": this.color
      }
    }), this.$slots.default || this.text && h("div", {
      "class": this.contentCls
    }, [this.text])]);
  }
});
// EXTERNAL MODULE: ./src/packages/radio/radio.scss
var packages_radio_radio = __webpack_require__(28);

// CONCATENATED MODULE: ./src/packages/radio/index.js



vue_VueExtension.WithInstall(radio_radio);
/* harmony default export */ var packages_radio = (radio_radio);
// CONCATENATED MODULE: ./src/packages/rate/rate.jsx


var rate_namespace = namespace_Namespace.Create('rate');
/* harmony default export */ var rate = ({
  name: rate_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    value: {
      type: Number,
      default: 0
    },
    count: {
      type: Number,
      default: 5
    },
    size: {
      type: String | Number,
      default: 'middle'
    },
    gutter: {
      type: Number,
      default: 0
    },
    color: {
      type: String,
      default: '#c7c7cc'
    },
    activeColor: {
      type: String,
      default: '#FF9500'
    },
    icon: {
      type: String,
      default: 'star-line'
    },
    activeIcon: {
      type: String,
      default: 'star'
    },
    disabled: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    touchable: {
      type: Boolean,
      default: false
    },
    allowHalf: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  data: function data() {
    return {
      rectScoreMap: []
    };
  },
  computed: {
    cls: function cls() {
      return rate_namespace.derive({
        disabled: this.disabled
      });
    },
    itemCls: function itemCls() {
      return rate_namespace.derive('item', [this.size]);
    },
    halfItemCls: function halfItemCls() {
      return rate_namespace.derive('item-half');
    },
    iconSize: function iconSize() {
      if (Number.isNaN(parseInt(this.size))) {
        var res = 16;

        switch (this.size) {
          case 'small':
            res = 16;
            break;

          case 'middle':
            res = 28;
            break;

          case 'large':
            res = 32;
            break;
        }

        return res;
      } else {
        return this.size;
      }
    },
    itemMetaList: function itemMetaList() {
      var res = [];
      var value = this.value > this.count ? this.value % this.count : this.value;

      for (var i = 0; i < this.count; i++) {
        res.push(this.getMetaByIndex(i + 1, value));
      }

      return res;
    }
  },
  methods: {
    getMetaByIndex: function getMetaByIndex(index, value) {
      var meta = {
        type: this.icon,
        color: this.color,
        isHalf: false
      };

      if (value >= index) {
        meta.type = this.activeIcon;
        meta.color = this.activeColor;
        return meta;
      }

      if (value + 0.5 >= index && this.allowHalf) {
        meta.isHalf = true;
      }

      return meta;
    },
    mapScoreWithRange: function mapScoreWithRange() {
      var res = [];

      for (var i = 0; i < this.itemMetaList.length; i++) {
        var rect = this.$refs["item_".concat(i)].getBoundingClientRect();

        if (this.allowHalf) {
          res.push({
            left: rect.left,
            score: i + 0.5
          }, {
            left: rect.left + rect.width / 2,
            score: i + 1
          });
        } else {
          res.push({
            left: rect.left,
            score: i + 1
          });
        }
      }

      this.rectScoreMap = res;
    },
    getScoreByPosition: function getScoreByPosition(left) {
      for (var index = this.rectScoreMap.length - 1; index > 0; index--) {
        var item = this.rectScoreMap[index];

        if (item.left <= left) {
          return item.score;
        }
      }

      return this.allowHalf ? 0.5 : 1;
    },
    onTouchStart: function onTouchStart(e) {
      if (this.readonly || !this.touchable || this.disabled) {
        return;
      }

      this.mapScoreWithRange();
    },
    onTouchMove: function onTouchMove(e) {
      if (this.readonly || !this.touchable || this.disabled) {
        return;
      }

      var clientX = e.touches[0].clientX;
      var score = this.getScoreByPosition(clientX);
      this.emitChange(score);
    },
    onClick: function onClick(e, i) {
      if (this.readonly || this.disabled) {
        return;
      }

      var res = i;

      if (this.allowHalf) {
        var target = e.currentTarget;
        var rect = target.getBoundingClientRect();
        var left = rect.left + rect.width / 2;
        res += e.clientX <= left ? 0.5 : 1;
      } else {
        res += 1;
      }

      this.emitChange(res);
    },
    emitChange: function emitChange(value) {
      this.$emit('change', value);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderItems = function renderItems() {
      return _this.itemMetaList.map(function (v, i) {
        return h("div", {
          "ref": "item_".concat(i),
          "class": _this.itemCls,
          "on": {
            "click": function click(e) {
              return _this.onClick(e, i);
            }
          }
        }, [h(icon, {
          "attrs": {
            "name": v.type,
            "color": v.color,
            "size": _this.iconSize
          }
        }), v.isHalf && h("div", {
          "class": _this.halfItemCls
        }, [h(icon, {
          "attrs": {
            "name": _this.activeIcon,
            "color": _this.activeColor,
            "size": _this.iconSize
          }
        })])]);
      });
    };

    return h("div", {
      "class": this.cls,
      "on": {
        "touchstart": this.onTouchStart,
        "touchmove": this.onTouchMove
      }
    }, [renderItems()]);
  }
});
// EXTERNAL MODULE: ./src/packages/rate/rate.scss
var rate_rate = __webpack_require__(29);

// CONCATENATED MODULE: ./src/packages/rate/index.js



vue_VueExtension.WithInstall(rate);
/* harmony default export */ var packages_rate = (rate);
// EXTERNAL MODULE: ./src/packages/pickercolumn/pickercolumn.scss
var pickercolumn_pickercolumn = __webpack_require__(30);

// CONCATENATED MODULE: ./src/packages/pickercolumn/index.js



vue_VueExtension.WithInstall(pickercolumn);
/* harmony default export */ var packages_pickercolumn = (pickercolumn);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/construct.js
var construct = __webpack_require__(59);
var construct_default = /*#__PURE__*/__webpack_require__.n(construct);

// CONCATENATED MODULE: ./src/utils/extensions/date.js


var date_DateExtension = /*#__PURE__*/function () {
  function DateExtension() {
    classCallCheck_default()(this, DateExtension);
  }

  createClass_default()(DateExtension, null, [{
    key: "IsLeapYearEx",
    value: function IsLeapYearEx(date) {
      return this.IsLeapYear(date.getFullYear());
    }
  }, {
    key: "IsLeapYear",
    value: function IsLeapYear(year) {
      return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
    }
  }]);

  return DateExtension;
}();
// CONCATENATED MODULE: ./src/packages/datetimepicker/datetimepicker.jsx





var namespcae = namespace_Namespace.Create('date-time-picker');
var datetimepicker_now = new Date();
/* harmony default export */ var datetimepicker = ({
  name: namespcae.name,
  components: {
    Picker: picker
  },
  props: {
    pattern: {
      type: String,
      default: 'date'
    },
    itemHeight: {
      type: Number,
      default: 50
    },
    visibleItemCount: {
      type: Number,
      default: 5
    },
    swipeDuration: {
      type: Number,
      default: 800
    },
    title: {
      type: String,
      default: ''
    },
    readonly: {
      type: Boolean,
      default: false
    },
    minDate: {
      type: Date,
      default: function _default() {
        return new Date(datetimepicker_now.getFullYear() - 10, 0, 1);
      }
    },
    maxDate: {
      type: Date,
      default: function _default() {
        return new Date(datetimepicker_now.getFullYear() + 10, 11, 31);
      }
    },
    minTime: {
      type: String,
      default: '00:00:00'
    },
    maxTime: {
      type: String,
      default: '23:59:59'
    },
    showSuffix: {
      type: Boolean,
      default: false
    },
    value: {
      type: Date | String,
      required: true
    },
    windowPattern: {
      type: String,
      default: 'fill'
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  computed: {
    isDate: function isDate() {
      return this.pattern === 'date';
    },
    isDateTime: function isDateTime() {
      return this.pattern === 'datetime';
    },
    isTime: function isTime() {
      return this.pattern === 'time';
    },
    currentYear: function currentYear() {
      return this.value.getFullYear();
    },
    currentMonth: function currentMonth() {
      return this.value.getMonth();
    },
    currentDay: function currentDay() {
      return this.value.getDate();
    },
    currentHour: function currentHour() {
      return this.value.getHours();
    },
    currentMinute: function currentMinute() {
      return this.value.getMinutes();
    },
    currentSecond: function currentSecond() {
      return this.value.getSeconds();
    },
    minYear: function minYear() {
      return this.minDate.getFullYear();
    },
    minMonth: function minMonth() {
      return this.minDate.getMonth();
    },
    minDay: function minDay() {
      return this.minDate.getDate();
    },
    minHour: function minHour() {
      return this.minDate.getHours();
    },
    minMinute: function minMinute() {
      return this.minDate.getMinutes();
    },
    minSecond: function minSecond() {
      return this.minDate.getSeconds();
    },
    maxYear: function maxYear() {
      return this.maxDate.getFullYear();
    },
    maxMonth: function maxMonth() {
      return this.maxDate.getMonth();
    },
    maxDay: function maxDay() {
      return this.maxDate.getDate();
    },
    maxtHour: function maxtHour() {
      return this.maxDate.getHours();
    },
    maxMinute: function maxMinute() {
      return this.maxDate.getMinutes();
    },
    maxSecond: function maxSecond() {
      return this.maxDate.getSeconds();
    },
    yearSuffix: function yearSuffix() {
      return this.showSuffix ? '年' : '';
    },
    monthSuffix: function monthSuffix() {
      return this.showSuffix ? '月' : '';
    },
    daySuffix: function daySuffix() {
      return this.showSuffix ? '日' : '';
    },
    hourSuffix: function hourSuffix() {
      return this.showSuffix ? '时' : '';
    },
    minuteSuffix: function minuteSuffix() {
      return this.showSuffix ? '分' : '';
    },
    secondSuffix: function secondSuffix() {
      return this.showSuffix ? '秒' : '';
    },
    timeArray: function timeArray() {
      return this.value.split(':').map(function (x) {
        return Number(x);
      });
    },
    minTimeArray: function minTimeArray() {
      return this.minTime.split(':').map(function (x) {
        return Number(x);
      });
    },
    maxTimeArray: function maxTimeArray() {
      return this.maxTime.split(':').map(function (x) {
        return Number(x);
      });
    },
    currentTimeHour: function currentTimeHour() {
      return this.timeArray[0];
    },
    currentTimeMinute: function currentTimeMinute() {
      return this.timeArray[1] || 0;
    },
    currentTimeSecond: function currentTimeSecond() {
      return this.timeArray[2] || 0;
    },
    minTimeHour: function minTimeHour() {
      return this.minTimeArray[0] || 0;
    },
    minTimeMinute: function minTimeMinute() {
      return this.minTimeArray[1] || 0;
    },
    minTimeSecond: function minTimeSecond() {
      return this.minTimeArray[2] || 0;
    },
    maxTimeHour: function maxTimeHour() {
      return this.maxTimeArray[0] || 23;
    },
    maxTimeMinute: function maxTimeMinute() {
      return this.maxTimeArray[1] || 59;
    },
    maxTimeSecond: function maxTimeSecond() {
      return this.maxTimeArray[2] || 59;
    },
    columns: function columns() {
      return this.getColumns();
    }
  },
  methods: {
    getColumns: function getColumns() {
      var res = [];

      switch (this.pattern) {
        case 'date':
          res = this.getDate();
          break;

        case 'time':
          res = this.getTimeSolely();
          break;

        case 'datetime':
          res = this.getDateTime();
          break;
      }

      return res;
    },
    getDate: function getDate() {
      return [this.getYear(), this.getMonth(), this.getDay()];
    },
    getTime: function getTime() {
      return [this.getHour(), this.getMinute(), this.getSecond()];
    },
    getDateTime: function getDateTime() {
      return [].concat(toConsumableArray_default()(this.getDate()), toConsumableArray_default()(this.getTime()));
    },
    getMaxDayByLearMonth: function getMaxDayByLearMonth(year, month) {
      var res = 0;

      switch (month + 1) {
        case 2:
          if (date_DateExtension.IsLeapYear(year)) {
            res = 29;
          } else {
            res = 28;
          }

          break;

        case 4:
        case 6:
        case 9:
        case 11:
          res = 30;
          break;

        default:
          res = 31;
          break;
      }

      return res;
    },
    getYear: function getYear() {
      var value = this.currentYear;
      var min = this.minYear;
      var max = this.maxYear;
      var suffix = this.yearSuffix;
      return this.getColumn(value, min, max, suffix, 4);
    },
    getMonth: function getMonth() {
      var value = this.currentMonth;
      var min = this.currentYear === this.minYear ? this.minMonth : 0;
      var max = this.currentYear === this.maxYear ? this.maxMonth : 11;
      var suffix = this.monthSuffix;
      return this.getColumn(value, min, max, suffix, true);
    },
    getDay: function getDay() {
      var value = this.currentDay;
      var min = this.value <= this.minDate || this.currentYear === this.minYear && this.currentMonth === this.minMonth ? this.minDay : 1;
      var max = this.value >= this.maxDate || this.currentYear === this.maxYear && this.currentMonth === this.maxMonth ? this.maxDay : this.getMaxDayByLearMonth(this.currentYear, this.currentMonth);
      var suffix = this.daySuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getHour: function getHour() {
      var value = this.currentHour;
      var min = this.value <= this.minDate || this.currentYear === this.minYear && this.currentMonth === this.minMonth && this.currentDay === this.minDay ? this.minHour : 0;
      var max = this.value >= this.maxDate || this.currentYear >= this.maxYear && this.currentMonth === this.maxMonth && this.currentDay === this.maxDay ? this.maxtHour : 23;
      var suffix = this.hourSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getMinute: function getMinute() {
      var value = this.currentMinute;
      var min = this.value <= this.minDate || this.currentYear === this.minYear && this.currentMonth === this.minMonth && this.currentDay === this.minDay && this.currentHour === this.minHour ? this.minMinute : 0;
      var max = this.value >= this.maxDate || this.currentYear === this.maxYear && this.currentMonth === this.maxMonth && this.currentDay === this.maxDay && this.currentHour === this.maxtHour ? this.maxMinute : 59;
      var suffix = this.minuteSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getSecond: function getSecond() {
      var value = this.currentMinute;
      var min = this.value <= this.minDate || this.currentYear === this.minYear && this.currentMonth === this.minMonth && this.currentDay === this.minDay && this.currentHour === this.minHour && this.currentMinute === this.minMinute ? this.minSecond : 0;
      var max = this.value >= this.maxDate || this.currentYear === this.maxYear && this.currentMonth === this.maxMonth && this.currentDay === this.maxDay && this.currentHour === this.maxtHour && this.currentMinute === this.maxMinute ? this.maxSecond : 59;
      var suffix = this.secondSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getTimeSolely: function getTimeSolely() {
      return [this.getHourSolely(), this.getMinuteSolely(), this.getSecondSolely()];
    },
    getHourSolely: function getHourSolely() {
      var value = this.currentTimeHour;
      var min = this.minTimeHour;
      var max = this.maxTimeHour;
      var suffix = this.hourSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getMinuteSolely: function getMinuteSolely() {
      var value = this.currentTimeMinute;
      var min = this.currentTimeHour === this.minTimeHour ? this.minTimeMinute : 0;
      var max = this.currentTimeHour === this.maxTimeHour ? this.maxTimeMinute : 59;
      var suffix = this.minuteSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getSecondSolely: function getSecondSolely() {
      var value = this.currentTimeSecond;
      var min = this.currentTimeHour === this.minTimeHour && this.currentTimeMinute === this.minTimeMinute ? this.minTimeSecond : 0;
      var max = this.currentTimeHour === this.maxTimeHour && this.currentTimeMinute === this.maxTimeMinute ? this.maxTimeSecond : 59;
      var suffix = this.secondSuffix;
      return this.getColumn(value, min, max, suffix);
    },
    getColumn: function getColumn(value, min, max) {
      var suffix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
      var isMonth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
      var padLength = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 2;
      var padChar = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '0';
      var items = this.generateItems(min, max, padLength, padChar, isMonth);
      var index = items.findIndex(function (x) {
        return x.value === value;
      });
      return {
        defaultIndex: index === -1 ? 0 : index,
        items: items,
        suffix: suffix
      };
    },
    generateItems: function generateItems(min, max) {
      var padLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
      var padChar = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '0';
      var isMonth = arguments.length > 4 ? arguments[4] : undefined;
      var res = [];

      for (var i = min; i <= max; i++) {
        res.push({
          text: String(isMonth ? i + 1 : i).padStart(padLength, padChar),
          value: i
        });
      }

      return res;
    },
    onChange: function onChange(values, indexs) {
      if (this.isDate || this.isDateTime) {
        var parts = values.map(function (x) {
          return x.value;
        });
        this.$emit('change', construct_default()(Date, toConsumableArray_default()(parts)));
        return;
      }

      if (this.isTime) {
        this.$emit('change', values.join(':'));
      }
    },
    onCancel: function onCancel() {
      this.$emit('cancel');
    },
    onConfirm: function onConfirm() {
      this.$emit('confirm');
    }
  },
  render: function render() {
    var h = arguments[0];
    return h(picker, {
      "attrs": {
        "readonly": this.readonly,
        "title": this.title,
        "item-height": this.itemHeight,
        "visible-item-count": this.visibleItemCount,
        "swipe-duration": this.swipeDuration,
        "window-pattern": this.windowPattern,
        "columns": this.columns
      },
      "on": {
        "change": this.onChange,
        "cancel": this.onCancel,
        "confirm": this.onConfirm
      }
    });
  }
});
// EXTERNAL MODULE: ./src/packages/datetimepicker/datetimepicker.scss
var datetimepicker_datetimepicker = __webpack_require__(31);

// CONCATENATED MODULE: ./src/packages/datetimepicker/index.js



vue_VueExtension.WithInstall(datetimepicker);
/* harmony default export */ var packages_datetimepicker = (datetimepicker);
// EXTERNAL MODULE: ./src/packages/badge/badge.scss
var packages_badge_badge = __webpack_require__(32);

// CONCATENATED MODULE: ./src/packages/badge/index.js



vue_VueExtension.WithInstall(badge_badge);
/* harmony default export */ var packages_badge = (badge_badge);
// CONCATENATED MODULE: ./src/packages/mask/mask.jsx



var mask_namespace = namespace_Namespace.Create('mask');
/* harmony default export */ var mask = ({
  name: mask_namespace.name,
  components: {
    Popup: popup,
    Icon: icon
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: false
    },
    duration: {
      type: Number,
      default: 0.36
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    },
    img: {
      type: String,
      required: true
    }
  },
  computed: {
    cls: function cls() {
      return mask_namespace.derive();
    },
    imgCls: function imgCls() {
      return mask_namespace.derive('img');
    },
    closeCls: function closeCls() {
      return mask_namespace.derive('close');
    }
  },
  methods: {
    onClose: function onClose() {
      this.$emit('close');
    },
    onImgClick: function onImgClick(e) {
      this.$emit('img-click', e);
    }
  },
  render: function render() {
    var h = arguments[0];
    return h(popup, {
      "attrs": {
        "show": this.show,
        "overlay": this.overlay,
        "z-index": this.zIndex,
        "lock-scroll": this.lockScroll,
        "duration": this.duration,
        "overlay-style": this.overlayStyle,
        "position": "center"
      },
      "on": {
        "close": this.onClose,
        "close-on-click-overlay": this.closeOnClickOveraly
      }
    }, [h("div", {
      "class": this.cls
    }, [this.img && h("img", {
      "class": this.imgCls,
      "attrs": {
        "src": this.img
      },
      "on": {
        "click": this.onImgClick
      }
    }), h("div", {
      "class": this.closeCls
    }, [this.$slots.close || h(icon, {
      "attrs": {
        "size": "35",
        "name": "close",
        "color": "#fff"
      },
      "on": {
        "click": this.onClose
      }
    })])])]);
  }
});
// EXTERNAL MODULE: ./src/packages/mask/mask.scss
var mask_mask = __webpack_require__(33);

// CONCATENATED MODULE: ./src/packages/mask/index.js



vue_VueExtension.WithInstall(mask);
/* harmony default export */ var packages_mask = (mask);
// CONCATENATED MODULE: ./src/packages/actionsheet/actionsheet.jsx



var actionsheet_namespace = namespace_Namespace.Create('action-sheet');
/* harmony default export */ var actionsheet = ({
  name: actionsheet_namespace.name,
  components: {
    Popup: popup,
    Icon: icon
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    lockScroll: {
      type: Boolean,
      default: false
    },
    duration: {
      type: Number,
      default: 0.36
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    round: {
      type: Boolean,
      default: true
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    },
    safeAreaInsetBottom: {
      type: Boolean,
      default: true
    },
    actions: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    title: {
      type: String,
      default: ''
    },
    description: {
      type: String,
      default: ''
    },
    cancelText: {
      type: String,
      default: ''
    },
    closeOnClickAction: {
      type: Boolean,
      default: true
    },
    background: {
      type: String
    }
  },
  model: {
    prop: 'show',
    event: 'close'
  },
  computed: {
    cls: function cls() {
      return actionsheet_namespace.derive();
    },
    headerCls: function headerCls() {
      return actionsheet_namespace.derive('header');
    },
    titleCls: function titleCls() {
      return actionsheet_namespace.derive('header-title');
    },
    descCls: function descCls() {
      return actionsheet_namespace.derive('header-desc');
    },
    bodyCls: function bodyCls() {
      return actionsheet_namespace.derive('body');
    },
    footerCls: function footerCls() {
      return actionsheet_namespace.derive('footer');
    },
    btnCls: function btnCls() {
      return actionsheet_namespace.derive('footer-btn');
    }
  },
  methods: {
    getActionItemCls: function getActionItemCls(item) {
      return actionsheet_namespace.derive('body-action-item', {
        disabled: item.disabled
      });
    },
    getActionItemStyle: function getActionItemStyle(item) {
      var res = {};

      if (item.color) {
        res.color = item.color;
      }

      return res;
    },
    close: function close() {
      this.$emit('close', false);
    },
    onSelectItem: function onSelectItem(item, e) {
      if (this.closeOnClickAction) {
        this.close();
      }

      this.$emit('select', item, e);
    },
    onClickCancel: function onClickCancel() {
      this.close();
    },
    onClose: function onClose() {
      this.close();
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderHeader = function renderHeader() {
      if (_this.title) {
        return h("div", {
          "class": _this.headerCls
        }, [_this.$slots.header || h("div", {
          "class": _this.titleCls
        }, [_this.title])]);
      }
    };

    var renderBody = function renderBody() {
      var _this$$scopedSlots$bo, _this$$scopedSlots;

      var acts = _this.actions.map(function (x, i) {
        return h("div", {
          "key": i,
          "class": _this.getActionItemCls(x),
          "style": _this.getActionItemStyle(x),
          "on": {
            "click": function click($event) {
              $event.stopPropagation();
              return function (e) {
                return _this.onSelectItem(x, e);
              }($event);
            }
          }
        }, [x.name]);
      });

      return h("div", {
        "class": _this.bodyCls
      }, [((_this$$scopedSlots$bo = (_this$$scopedSlots = _this.$scopedSlots).body) === null || _this$$scopedSlots$bo === void 0 ? void 0 : _this$$scopedSlots$bo.call(_this$$scopedSlots, {
        actions: _this.actions
      })) || acts]);
    };

    var renderFooter = function renderFooter() {
      if (_this.cancelText) {
        var _this$$scopedSlots$fo, _this$$scopedSlots2;

        return h("div", {
          "class": _this.footerCls,
          "on": {
            "click": function click($event) {
              $event.stopPropagation();
              return _this.onClickCancel($event);
            }
          }
        }, [((_this$$scopedSlots$fo = (_this$$scopedSlots2 = _this.$scopedSlots).footer) === null || _this$$scopedSlots$fo === void 0 ? void 0 : _this$$scopedSlots$fo.call(_this$$scopedSlots2, {
          cancelText: _this.cancelText
        })) || h("div", {
          "class": _this.btnCls
        }, [_this.cancelText])]);
      }
    };

    return h(popup, {
      "attrs": {
        "show": this.show,
        "overlay": this.overlay,
        "z-index": this.zIndex,
        "lock-scroll": this.lockScroll,
        "duration": this.duration,
        "overlay-style": this.overlayStyle,
        "round": this.round,
        "safe-area-inset-bottom": this.safeAreaInsetBottom,
        "position": "bottom",
        "background": this.background
      },
      "on": {
        "close-on-click-overlay": this.closeOnClickOveraly,
        "close": this.onClose
      }
    }, [h("div", {
      "class": this.cls
    }, [renderHeader(), renderBody(), renderFooter()])]);
  }
});
// EXTERNAL MODULE: ./src/packages/actionsheet/actionsheet.scss
var actionsheet_actionsheet = __webpack_require__(34);

// CONCATENATED MODULE: ./src/packages/actionsheet/index.js



vue_VueExtension.WithInstall(actionsheet);
/* harmony default export */ var packages_actionsheet = (actionsheet);
// CONCATENATED MODULE: ./src/packages/toast/toast.jsx




var toast_namespace = namespace_Namespace.Create('toast');
/* harmony default export */ var toast = ({
  name: toast_namespace.name,
  components: {
    Overlay: overlay,
    Icon: icon,
    Loading: loading
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    overlay: {
      type: Boolean,
      default: false
    },
    zIndex: {
      type: Number,
      default: 1030
    },
    duration: {
      type: Number,
      default: 1600
    },
    overlayStyle: {
      type: Object,
      default: function _default() {}
    },
    closeOnClickOveraly: {
      type: Boolean,
      default: true
    },
    position: {
      type: String,
      default: 'center'
    },
    message: {
      type: String,
      default: ''
    },
    theme: {
      type: String,
      default: 'dark'
    },
    icon: {
      type: String,
      default: ''
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data: function data() {
    return {
      timer: 0
    };
  },
  computed: {
    cls: function cls() {
      return toast_namespace.derive([this.theme, this.position, {
        round: this.round,
        icon: this.hasIcon && !this.message,
        it: this.hasIcon && this.message
      }]);
    },
    textCls: function textCls() {
      return toast_namespace.derive('text', [this.theme, {
        icon: this.hasIcon
      }]);
    },
    transitionName: function transitionName() {
      return toast_namespace.derive('fade');
    },
    hasIcon: function hasIcon() {
      return this.icon || this.loading;
    }
  },
  watch: {
    show: function show() {
      this.toast();
    }
  },
  methods: {
    onClickOverlay: function onClickOverlay(e) {
      if (this.closeOnClickOveraly) {
        this.close(e);
      }
    },
    onClose: function onClose(e) {
      this.close(e);
    },
    close: function close(e) {
      this.$emit('close', e);
    },
    clearTimer: function clearTimer() {
      window.clearTimeout(this.timer);
    },
    toast: function toast() {
      var _this = this;

      this.clearTimer();

      if (this.show && this.duration) {
        this.timer = window.setTimeout(function () {
          _this.close();
        }, this.duration);
      }
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];

    var renderIcon = function renderIcon() {
      if (_this2.loading) {
        return h(loading, {
          "attrs": {
            "size": "32",
            "type": "spinner"
          }
        });
      }

      if (_this2.icon) {
        return h(icon, {
          "attrs": {
            "name": _this2.icon,
            "size": "32"
          }
        });
      }
    };

    var renderOverlay = function renderOverlay() {
      if (_this2.overlay) {
        return h(overlay, {
          "attrs": {
            "show": _this2.show,
            "z-index": _this2.zIndex,
            "lock-scroll": _this2.lockScroll,
            "overlay-style": _this2.overlayStyle
          },
          "on": {
            "click": _this2.onClickOverlay
          }
        });
      }
    };

    var renderToast = function renderToast() {
      return h("transition", {
        "attrs": {
          "name": _this2.transitionName
        }
      }, [_this2.show && h("div", {
        "class": _this2.cls
      }, [renderIcon(), _this2.message && h("div", {
        "class": _this2.textCls
      }, [_this2.message])])]);
    };

    return h("div", [renderOverlay(), renderToast()]);
  }
});
// CONCATENATED MODULE: ./src/packages/toast/functioncall.jsx


function toast_functioncall_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function toast_functioncall_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { toast_functioncall_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { toast_functioncall_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }



/* harmony default export */ var toast_functioncall = (vue_VueExtension.InvokeComponent(function (unmount) {
  return {
    data: function data() {
      return {
        options: {
          show: false,
          overlay: false,
          zIndex: 1030,
          duration: 1600,
          overlayStyle: {},
          closeOnClickOveraly: true,
          position: 'center',
          message: '',
          theme: 'dark',
          icon: '',
          loading: false
        }
      };
    },
    methods: {
      open: function open(options) {
        this.options = toast_functioncall_objectSpread(toast_functioncall_objectSpread(toast_functioncall_objectSpread({}, this.options), options), {}, {
          show: true
        });
      },
      onClose: function onClose() {
        unmount();
      }
    },
    render: function render() {
      var h = arguments[0];
      return h(toast, {
        "props": toast_functioncall_objectSpread({}, this.options),
        "on": {
          "close": this.onClose
        }
      });
    }
  };
}));
// EXTERNAL MODULE: ./src/packages/toast/toast.scss
var toast_toast = __webpack_require__(35);

// CONCATENATED MODULE: ./src/packages/toast/index.js




vue_VueExtension.WithInstall(toast, toast_functioncall);
/* harmony default export */ var packages_toast = (toast);
// CONCATENATED MODULE: ./src/packages/tabbar/tabbar.jsx

var tabbar_namespace = namespace_Namespace.Create('tab-bar');
/* harmony default export */ var tabbar = ({
  name: tabbar_namespace.name,
  props: {
    value: {
      type: Number | String,
      default: 0
    },
    fixed: {
      type: Boolean,
      default: false
    },
    activeColor: {
      type: String,
      default: '#000000'
    },
    inactiveColor: {
      type: String,
      default: '#8a8a8f'
    },
    safeAreaInsetBottom: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  computed: {
    cls: function cls() {
      return tabbar_namespace.derive([{
        fixed: this.fixed,
        'safe-area-inset-bottom': this.fixed && this.safeAreaInsetBottom
      }]);
    }
  },
  methods: {
    setActive: function setActive(active) {
      this.$emit('change', active);
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/tabbar/tabbar.scss
var tabbar_tabbar = __webpack_require__(36);

// CONCATENATED MODULE: ./src/packages/tabbar/index.js



vue_VueExtension.WithInstall(tabbar);
/* harmony default export */ var packages_tabbar = (tabbar);
// CONCATENATED MODULE: ./src/packages/tabbaritem/tabbaritem.jsx


var tabbaritem_namespace = namespace_Namespace.Create('tab-bar-item');
/* harmony default export */ var tabbaritem = ({
  name: tabbaritem_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    name: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: ''
    },
    iconPrefix: {
      type: String
    },
    dot: {
      type: Boolean,
      default: false
    },
    badge: {
      type: Number | String
    },
    size: {
      type: Number,
      default: 48
    }
  },
  computed: {
    cls: function cls() {
      return tabbaritem_namespace.derive({
        active: this.active
      });
    },
    style: function style() {
      return {
        color: this.active ? this.$parent.activeColor : this.$parent.inactiveColor
      };
    },
    textCls: function textCls() {
      return tabbaritem_namespace.derive('text');
    },
    index: function index() {
      return this.$parent.$children.indexOf(this);
    },
    active: function active() {
      return this.$parent.value === (this.name || this.index);
    }
  },
  methods: {
    onClick: function onClick(e) {
      this.$parent.setActive(this.name || this.index);
      this.$emit('click', e);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderIcon = function renderIcon() {
      if (_this.$scopedSlots.icon) {
        return _this.$scopedSlots.icon({
          active: _this.active
        });
      }

      if (_this.icon) {
        return h(icon, {
          "attrs": {
            "classPrefix": _this.classPrefix,
            "name": _this.icon,
            "size": _this.size,
            "badge": _this.badge,
            "dot": _this.dot,
            "offset": [0, 5]
          }
        });
      }
    };

    return h("div", {
      "class": this.cls,
      "style": this.style,
      "on": {
        "click": this.onClick
      }
    }, [renderIcon(), h("div", {
      "class": this.textCls
    }, [this.$slots.default])]);
  }
});
// EXTERNAL MODULE: ./src/packages/tabbaritem/tabbaritem.scss
var tabbaritem_tabbaritem = __webpack_require__(37);

// CONCATENATED MODULE: ./src/packages/tabbaritem/index.js



vue_VueExtension.WithInstall(tabbaritem);
/* harmony default export */ var packages_tabbaritem = (tabbaritem);
// CONCATENATED MODULE: ./src/mixins/relation/parent.js

function mixParent(key) {
  return {
    provide: function provide() {
      return defineProperty_default()({}, key, this);
    },
    data: function data() {
      return {
        children: []
      };
    }
  };
}
// CONCATENATED MODULE: ./src/packages/tab/tab.jsx






var tab_namespace = namespace_Namespace.Create('tab');
/* harmony default export */ var tab = ({
  name: tab_namespace.name,
  mixins: [mixParent(tab_namespace.name)],
  components: {
    Badge: badge_badge,
    Icon: icon
  },
  props: {
    value: {
      type: String | Number,
      default: 0
    },
    type: {
      type: String,
      default: 'line'
    },
    position: {
      type: String,
      default: 'top'
    },
    duration: {
      type: String | Number,
      default: 0.36
    },
    lineColor: {
      type: String,
      default: '#000000'
    },
    lineSize: {
      type: String | Number,
      default: '2'
    },
    animated: {
      type: Boolean,
      default: false
    },
    headerClass: {
      type: String
    },
    titleActiveColor: {
      type: String,
      default: '#000000'
    },
    titleActiveBackground: {
      type: String,
      default: '#000000'
    },
    titleInactiveBackground: {
      type: String,
      default: '#F2F2F2'
    },
    titleInactiveColor: {
      type: String,
      default: '#8A8A8F'
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  data: function data() {
    return {
      inited: false,
      isLineInited: false
    };
  },
  computed: {
    cls: function cls() {
      return tab_namespace.derive([this.position]);
    },
    headerCls: function headerCls() {
      return [tab_namespace.derive('header', [this.position]), this.headerClass];
    },
    navCls: function navCls() {
      return tab_namespace.derive('nav', [this.position]);
    },
    navStyle: function navStyle() {
      var style = {};

      if (this.inited) {
        var nav = this.$refs.nav;
        var maxOffset = this.isHorizental ? nav.scrollWidth - nav.offsetWidth : nav.scrollHeight - nav.offsetHeight;
        var el = this.$refs["nav_button_".concat(this.value)];
        var offset = this.isHorizental ? el.offsetLeft + el.offsetWidth / 2 - nav.offsetWidth / 2 : el.offsetTop + el.offsetHeight / 2 - nav.offsetHeight / 2;
        style.transform = "translate".concat(this.isHorizental ? 'X' : 'Y', "(").concat(-math_MathExtension.Clamp(offset, 0, maxOffset), "px)");
      }

      return style;
    },
    lineCls: function lineCls() {
      return tab_namespace.derive('nav-line', [this.position]);
    },
    lineStyle: function lineStyle() {
      if (this.type !== 'line') {
        return;
      }

      var style = defineProperty_default()({
        background: this.lineColor
      }, this.isHorizental ? 'height' : 'width', "".concat(this.lineSize, "px"));

      if (this.inited) {
        var el = this.$refs["nav_button_text_".concat(this.value)];
        style[this.isHorizental ? 'width' : 'height'] = "".concat(this.isHorizental ? el.offsetWidth : el.offsetHeight, "px");
        style.transform = "translate".concat(this.isHorizental ? 'X' : 'Y', "(").concat(this.isHorizental ? el.offsetLeft : el.offsetTop, "px)");

        if (!this.isLineInited) {
          style.transitionDuration = '0s';
          this.isLineInited = true;
        }
      }

      return style;
    },
    bodyCls: function bodyCls() {
      return tab_namespace.derive('body', [this.position]);
    },
    trackCls: function trackCls() {
      return tab_namespace.derive('body-track');
    },
    trackStyle: function trackStyle() {
      var style = {
        transform: "translateX(".concat(-this.value * 100, "%)"),
        transitionDuration: !this.inited || !this.animated ? '0s' : "".concat(this.duration, "s")
      };
      return style;
    },
    buttonIconCls: function buttonIconCls() {
      return tab_namespace.derive('nav-button-text--button-icon');
    },
    isFrontHeader: function isFrontHeader() {
      return this.position === 'top' || this.position === 'left';
    },
    isRearHeader: function isRearHeader() {
      return this.position === 'bottom' || this.position === 'right';
    },
    isVertical: function isVertical() {
      return this.position === 'left' || this.position === 'right';
    },
    isHorizental: function isHorizental() {
      return this.position === 'top' || this.position === 'bottom';
    }
  },
  mounted: function mounted() {
    var _this = this;

    this.$nextTick(function () {
      return _this.inited = true;
    });
  },
  methods: {
    onButtonClick: function onButtonClick(button, index, e) {
      this.$emit('change', index);
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];

    var renderNav = function renderNav() {
      return _this2.children.map(function (x, index) {
        var _x$$scopedSlots$title, _x$$scopedSlots;

        var isActive = _this2.value === index;
        var buttonCls = tab_namespace.derive('nav-button', [_this2.position, _this2.type]);
        var textCls = tab_namespace.derive('nav-button-text', [_this2.type === 'button' ? 'button' : 'text', {
          active: isActive
        }]);
        var textStyle = {
          color: isActive ? _this2.titleActiveColor : _this2.titleInactiveColor
        };

        if (_this2.type === 'button') {
          textStyle.background = isActive ? _this2.titleActiveBackground : _this2.titleInactiveBackground;
        }

        var tag = _this2.type === 'button' ? 'div' : 'span';
        var text = h(tag, {
          "ref": "nav_button_text_".concat(index),
          "class": textCls,
          "style": textStyle
        }, [((_x$$scopedSlots$title = (_x$$scopedSlots = x.$scopedSlots).title) === null || _x$$scopedSlots$title === void 0 ? void 0 : _x$$scopedSlots$title.call(_x$$scopedSlots, {
          active: isActive
        })) || [x.icon && h(icon, {
          "class": _this2.buttonIconCls,
          "attrs": {
            "name": x.icon,
            "size": x.iconSize,
            "color": textStyle.color
          }
        }), x.title]]);
        var content = x.dot || x.badge ? h(badge_badge, {
          "attrs": {
            "dot": x.dot,
            "content": x.badge,
            "small": true
          }
        }, [text]) : text;
        return h("div", {
          "ref": "nav_button_".concat(index),
          "class": buttonCls,
          "on": {
            "click": function click(e) {
              return _this2.onButtonClick(x, index, e);
            }
          }
        }, [content]);
      });
    };

    var renderHeader = function renderHeader() {
      return h("div", {
        "ref": "header",
        "class": _this2.headerCls
      }, [h("div", {
        "ref": "nav",
        "class": _this2.navCls,
        "style": _this2.navStyle
      }, [renderNav(), _this2.type === 'line' && h("div", {
        "class": _this2.lineCls,
        "style": _this2.lineStyle
      })])]);
    };

    return h("div", {
      "class": this.cls
    }, [this.isFrontHeader && renderHeader(), h("div", {
      "class": this.bodyCls
    }, [h("div", {
      "class": this.trackCls,
      "style": this.trackStyle
    }, [this.$slots.default])]), this.isRearHeader && renderHeader()]);
  }
});
// EXTERNAL MODULE: ./src/packages/tab/tab.scss
var tab_tab = __webpack_require__(38);

// CONCATENATED MODULE: ./src/packages/tab/index.js



vue_VueExtension.WithInstall(tab);
/* harmony default export */ var packages_tab = (tab);
// CONCATENATED MODULE: ./src/mixins/relation/children.js



function mixChildren(key) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  var indexKey = options.indexKey || 'index';
  return {
    inject: defineProperty_default()({}, key, {
      default: null
    }),
    computed: defineProperty_default()({
      parent: function parent() {
        if (this.disableBindingRelation) {
          return null;
        }

        return this[key];
      }
    }, indexKey, function () {
      this.bindRelation();

      if (this.parent) {
        return this.parent.children.indexOf(this);
      }

      return null;
    }),
    watch: {
      disableBindingRelation: function disableBindingRelation(val) {
        if (!val) {
          this.bindRelation();
        }
      }
    },
    mounted: function mounted() {
      this.bindRelation();
    },
    beforeDestroy: function beforeDestroy() {
      var _this = this;

      if (this.parent) {
        this.parent.children = this.parent.children.filter(function (x) {
          return x !== _this;
        });
      }
    },
    methods: {
      bindRelation: function bindRelation() {
        if (!this.parent || this.parent.children.indexOf(this) !== -1) {
          return;
        }

        this.parent.children = vue_VueExtension.SortChildren([].concat(toConsumableArray_default()(this.parent.children), [this]), this.parent);
      }
    }
  };
}
// CONCATENATED MODULE: ./src/packages/tabpane/tabpane.jsx



var tabpane_namespace = namespace_Namespace.Create('tab-pane');
/* harmony default export */ var tabpane = ({
  name: tabpane_namespace.name,
  mixins: [mixChildren(tab_namespace.name)],
  props: {
    title: {
      type: String
    },
    disabled: {
      type: Boolean,
      default: false
    },
    dot: {
      type: Boolean,
      default: false
    },
    badge: {
      type: String | Number
    },
    icon: {
      type: String
    },
    iconSize: {
      type: String | Number,
      default: 18
    },
    titleClass: {
      type: String | Object
    },
    titleStyle: {
      type: String | Object
    }
  },
  computed: {
    cls: function cls() {
      return tabpane_namespace.derive();
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/tabpane/tabpane.scss
var tabpane_tabpane = __webpack_require__(39);

// CONCATENATED MODULE: ./src/packages/tabpane/index.js



vue_VueExtension.WithInstall(tabpane);
/* harmony default export */ var packages_tabpane = (tabpane);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/packages/catalog/catalog.vue?vue&type=template&id=2700dded&
var catalogvue_type_template_id_2700dded_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['mx-catalog', _vm.hasMargin && 'has-margin'],style:({ backgroundColor: _vm.backgroundColor })},[(!!_vm.avatarIcon)?_c('img',{staticClass:"avatar-icon",attrs:{"src":"avatarIcon","alt":"*"}}):_vm._e(),_vm._v(" "),_vm._t("default",function(){return [_vm._v("\n    "+_vm._s(_vm.title)+"\n  ")]})],2)}
var catalogvue_type_template_id_2700dded_staticRenderFns = []


// CONCATENATED MODULE: ./src/packages/catalog/catalog.vue?vue&type=template&id=2700dded&

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/packages/catalog/catalog.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
/* harmony default export */ var catalogvue_type_script_lang_js_ = ({
  name: 'mx-catalog',
  props: {
    title: {
      type: String,
      default: null
    },
    backgroundColor: {
      type: String,
      default: '#f9f9f9'
    },
    textColor: {
      type: String,
      default: '#8a8a8f'
    },
    avatarIcon: {
      type: String,
      default: ''
    },
    hasMargin: {
      type: Boolean,
      default: true
    }
  },
  data: function data() {
    return {};
  },
  methods: {}
});
// CONCATENATED MODULE: ./src/packages/catalog/catalog.vue?vue&type=script&lang=js&
 /* harmony default export */ var catalog_catalogvue_type_script_lang_js_ = (catalogvue_type_script_lang_js_); 
// CONCATENATED MODULE: ./src/packages/catalog/catalog.vue





/* normalize component */

var catalog_component = normalizeComponent(
  catalog_catalogvue_type_script_lang_js_,
  catalogvue_type_template_id_2700dded_render,
  catalogvue_type_template_id_2700dded_staticRenderFns,
  false,
  null,
  null,
  null
  
)

/* harmony default export */ var catalog = (catalog_component.exports);
// EXTERNAL MODULE: ./src/packages/catalog/catalog.scss
var catalog_catalog = __webpack_require__(40);

// CONCATENATED MODULE: ./src/packages/catalog/index.js



vue_VueExtension.WithInstall(catalog);
/* harmony default export */ var packages_catalog = (catalog);
// CONCATENATED MODULE: ./src/packages/slider/slider.jsx




var slider_namespace = namespace_Namespace.Create("slider");
/* harmony default export */ var slider = ({
  name: slider_namespace.name,
  props: {
    linear: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    value: {
      type: Number,
      default: 0
    },
    min: {
      type: Number,
      default: 0
    },
    max: {
      type: Number,
      default: 100
    },
    step: {
      type: Number,
      default: 1
    },
    trackHeight: {
      type: Number,
      default: -1
    },
    buttonSize: {
      type: Number,
      default: -1
    },
    trackColor: {
      type: String
    },
    barColor: {
      type: String
    },
    scaleColor: {
      type: String
    },
    buttonColor: {
      type: String
    },
    theme: {
      type: String,
      default: 'brand'
    },
    readonly: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  model: {
    prop: 'value',
    event: 'input'
  },
  data: function data() {
    return {
      touch: touch_Touch.Create(),
      current: 0,
      startValue: 0,
      dragStatus: ''
    };
  },
  computed: {
    wrapperCls: function wrapperCls() {
      return slider_namespace.derive('wrapper', {
        disabled: this.disabled
      });
    },
    cls: function cls() {
      return slider_namespace.derive();
    },
    trackCls: function trackCls() {
      return slider_namespace.derive('track');
    },
    barCls: function barCls() {
      return slider_namespace.derive('bar', [this.theme]);
    },
    buttonCls: function buttonCls() {
      return slider_namespace.derive('button', [this.theme]);
    },
    scaleCls: function scaleCls() {
      return slider_namespace.derive('scale-wrapper');
    },
    scaleTextCls: function scaleTextCls() {
      return slider_namespace.derive('scale-text');
    },
    sliderStyle: function sliderStyle() {
      var style = {};

      if (this.buttonSize > 0) {
        style.height = "".concat(this.buttonSize, "px");
      }

      return style;
    },
    trackStyle: function trackStyle() {
      var style = {};

      if (this.trackColor) {
        style.background = this.trackColor;
      }

      if (this.trackHeight) {
        style.height = "".concat(this.trackHeight, "px");
      }

      return style;
    },
    barStyle: function barStyle() {
      var style = {
        width: "".concat((this.value - this.min) * 100 / this.scope, "%")
      };

      if (this.dragStatus) {
        style.transition = 'none';
      }

      if (this.linear.length > 0) {
        style.background = "linear-gradient(to right, ".concat(this.linear.join(','), ")");
      }

      if (this.barColor) {
        style.background = this.barColor;
      }

      return style;
    },
    buttonStyle: function buttonStyle() {
      var style = {};

      if (this.linear.length > 0) {
        style.background = this.linear[this.linear.length - 1];
      }

      if (this.buttonColor) {
        style.background = this.buttonColor;
      }

      if (this.buttonSize > 0) {
        style.width = "".concat(this.buttonSize, "px");
        style.height = "".concat(this.buttonSize, "px");
        style.borderRadius = "".concat(this.buttonSize / 2, " px");
      }

      return style;
    },
    scaleStyle: function scaleStyle() {
      var style = {};

      if (this.scaleColor) {
        style.color = this.scaleColor;
      }

      return style;
    },
    canInteract: function canInteract() {
      return !this.disabled && !this.readonly;
    },
    scope: function scope() {
      return this.max - this.min;
    }
  },
  methods: {
    onClick: function onClick(e) {
      e.stopPropagation();

      if (!this.canInteract) {
        return;
      }

      var rect = this.$refs.slider.getBoundingClientRect();
      var delta = e.clientX - rect.left;
      var total = rect.width;
      var value = this.min + delta / total * this.scope;
      this.update(value, true);
    },
    onTouchStart: function onTouchStart(e) {
      if (!this.canInteract) {
        return;
      }

      this.touch.start(e);
      this.current = this.value;
      this.startValue = this.format(this.current);
      this.dragStatus = 'start';
    },
    onTouchMove: function onTouchMove(e) {
      if (!this.canInteract) {
        return;
      }

      if (this.dragStatus === 'start') {
        this.$emit('dragstart', e);
      }

      dom_DOMExtension.PreventDefault(e);
      this.touch.move(e);
      this.dragStatus = 'draging';
      var rect = this.$refs.slider.getBoundingClientRect();
      var delta = this.touch.deltaX;
      var total = rect.width;
      var diff = delta / total * this.scope;
      this.current = this.startValue + diff;
      this.update(this.current);
    },
    onTouchEnd: function onTouchEnd(e) {
      if (!this.canInteract) {
        return;
      }

      if (this.dragStatus === 'draging') {
        this.update(this.current, true);
        this.$emit('dragend', e);
      }

      this.dragStatus = '';
    },
    format: function format(value) {
      var min = +this.min;
      var max = +this.max;
      var step = +this.step;
      var val = math_MathExtension.Clamp(value, min, max);
      var diff = Math.round((val - min) / step) * step;
      return min + diff;
    },
    update: function update(value) {
      var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var val = this.format(value);

      if (val !== this.value) {
        this.$emit('input', val);
      }

      if (end && val !== this.startValue) {
        this.$emit('change', val);
      }
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderSlider = function renderSlider() {
      return h("div", {
        "ref": 'slider',
        "class": _this.cls,
        "style": _this.sliderStyle,
        "on": {
          "click": _this.onClick
        }
      }, [h("div", {
        "class": _this.trackCls,
        "style": _this.trackStyle
      }, [h("div", {
        "class": _this.barCls,
        "style": _this.barStyle
      }, [h("div", {
        "class": _this.buttonCls,
        "style": _this.buttonStyle,
        "on": {
          "touchstart": _this.onTouchStart,
          "touchmove": _this.onTouchMove,
          "touchend": _this.onTouchEnd,
          "touchcancel": _this.onTouchEnd,
          "click": function click(e) {
            return e.stopPropagation();
          }
        }
      })])])]);
    };

    var renderScale = function renderScale() {
      if (_this.$slots.default) {
        return h("div", {
          "class": _this.scaleCls,
          "style": _this.scaleStyle
        }, [_this.$slots.default]);
      }
    };

    return h("div", {
      "class": this.wrapperCls
    }, [renderSlider(), renderScale()]);
  }
});
// EXTERNAL MODULE: ./src/packages/slider/slider.scss
var slider_slider = __webpack_require__(41);

// CONCATENATED MODULE: ./src/packages/slider/index.js



vue_VueExtension.WithInstall(slider);
/* harmony default export */ var packages_slider = (slider);
// CONCATENATED MODULE: ./src/packages/sliderscale/sliderscale.jsx

var sliderscale_namespace = namespace_Namespace.Create('slider-scale');
/* harmony default export */ var sliderscale = ({
  name: sliderscale_namespace.name,
  props: {
    value: {
      type: Number
    }
  },
  computed: {
    cls: function cls() {
      return sliderscale_namespace.derive({
        'first-child': this.value == this.$parent.min,
        'last-child': this.value == this.$parent.max
      });
    },
    style: function style() {
      var style = {};
      var percent = (this.value - this.$parent.min) / this.$parent.scope * 100;
      style.left = "".concat(percent, "%");
      return style;
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls,
      "style": this.style
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/sliderscale/sliderscale.scss
var sliderscale_sliderscale = __webpack_require__(42);

// CONCATENATED MODULE: ./src/packages/sliderscale/index.js



vue_VueExtension.WithInstall(sliderscale);
/* harmony default export */ var packages_sliderscale = (sliderscale);
// CONCATENATED MODULE: ./src/packages/pullrefresh/pullrefresh.jsx



var pullrefresh_namespace = namespace_Namespace.Create('pull-refresh');
/* harmony default export */ var pullrefresh = ({
  name: pullrefresh_namespace.name,
  props: {
    distanceToRefresh: {
      type: Number,
      default: 50
    },
    loading: {
      type: Boolean,
      default: false
    },
    finished: {
      type: Boolean,
      default: false
    }
  },
  data: function data() {
    return {
      status: 'normal',
      isReachTop: false,
      touch: touch_Touch.Create()
    };
  },
  computed: {
    cls: function cls() {
      return pullrefresh_namespace.derive();
    },
    containerCls: function containerCls() {
      return pullrefresh_namespace.derive('container');
    },
    infoCls: function infoCls() {
      return pullrefresh_namespace.derive('info');
    },
    viewerCls: function viewerCls() {
      return pullrefresh_namespace.derive('viewer');
    },
    containerStyle: function containerStyle() {
      var distance = this.ease(this.touch.deltaY);

      if (this.isLoading) {
        distance = this.distanceToRefresh;
      }

      return "transform:translateY(".concat(distance, "px)");
    },
    infoStyle: function infoStyle() {
      return "height:".concat(this.distanceToRefresh, "px");
    },
    isPulling: function isPulling() {
      return this.status === 'pulling';
    },
    isLoosing: function isLoosing() {
      return this.status === 'loosing';
    },
    isLoading: function isLoading() {
      return this.loading;
    },
    isFinished: function isFinished() {
      return this.finished;
    },
    isTouchable: function isTouchable() {
      return !this.isLoading;
    }
  },
  methods: {
    onTouchStart: function onTouchStart(e) {
      if (!this.isTouchable) {
        return;
      }

      if (!this.isReachEdge()) {
        return;
      }

      this.touch.start(e);
    },
    onTouchMove: function onTouchMove(e) {
      if (!this.isTouchable) {
        return;
      }

      if (!this.isReachEdge()) {
        return;
      }

      if (this.touch.startY === 0) {
        this.touch.start(e);
      } else {
        this.touch.move(e);

        if (this.touch.deltaY > 0) {
          dom_DOMExtension.PreventDefault(e);

          if (this.touch.deltaY < this.distanceToRefresh) {
            this.status = 'pulling';
          } else {
            this.status = 'loosing';
          }
        }
      }
    },
    onTouchEnd: function onTouchEnd(e) {
      if (this.touch.deltaY > this.distanceToRefresh) {
        this.$emit('refresh', e);
      }

      this.touch.reset();
      this.status = 'normal';
    },
    isReachEdge: function isReachEdge() {
      return this.$refs.viewer.scrollTop === 0;
    },
    ease: function ease(deltaY) {
      var distance = deltaY < 0 ? 0 : deltaY;

      if (distance > this.distanceToRefresh) {
        if (distance < this.distanceToRefresh * 2) {
          distance = this.distanceToRefresh + (distance - this.distanceToRefresh) / 2;
        } else {
          distance = this.distanceToRefresh * 1.5 + (distance - this.distanceToRefresh * 2) / 4;
        }
      }

      return Math.round(distance);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var renderPull = function renderPull() {
      return _this.$slots.pull || h("div", ["\u4E0B\u62C9\u5237\u65B0"]);
    };

    var renderLoading = function renderLoading() {
      return (// <div>加载中...</div>
        _this.$slots.loading || h("mx-loading", {
          "attrs": {
            "type": "spinner",
            "size": 18
          }
        })
      );
    };

    var renderLoose = function renderLoose() {
      return _this.$slots.loose || h("div", ["\u91CA\u653E\u5237\u65B0"]);
    };

    var renderFinished = function renderFinished() {
      return _this.$slots.finished || h("div", ["- \u6CA1\u6709\u66F4\u591A\u5185\u5BB9\u4E86 -"]);
    };

    var renderInfo = function renderInfo() {
      return h("div", {
        "class": _this.infoCls,
        "style": _this.infoStyle
      }, [!_this.isFinished && _this.isPulling && renderPull(), !_this.isFinished && _this.isLoosing && renderLoose(), !_this.isFinished && _this.isLoading && renderLoading(), _this.isFinished && renderFinished()]);
    };

    var renderViewer = function renderViewer() {
      return h("div", {
        "ref": 'viewer',
        "class": _this.viewerCls
      }, [_this.$slots.default]);
    };

    return h("div", {
      "class": this.cls
    }, [h("div", {
      "class": this.containerCls,
      "style": this.containerStyle,
      "on": {
        "touchstart": this.onTouchStart,
        "touchmove": this.onTouchMove,
        "touchend": this.onTouchEnd,
        "touchcancel": this.onTouchEnd
      }
    }, [renderInfo(), renderViewer()])]);
  }
});
// EXTERNAL MODULE: ./src/packages/pullrefresh/pullrefresh.scss
var pullrefresh_pullrefresh = __webpack_require__(43);

// CONCATENATED MODULE: ./src/packages/pullrefresh/index.js



vue_VueExtension.WithInstall(pullrefresh);
/* harmony default export */ var packages_pullrefresh = (pullrefresh);
// EXTERNAL MODULE: ./src/packages/loading/loading.scss
var loading_loading = __webpack_require__(44);

// CONCATENATED MODULE: ./src/packages/loading/index.js



vue_VueExtension.WithInstall(loading);
/* harmony default export */ var packages_loading = (loading);
// CONCATENATED MODULE: ./src/utils/raf.js
function requestAniFrame() {
  if (typeof window !== 'undefined') {
    return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) {
      window.setTimeout(callback, 1000 / 60);
    };
  } else {
    return function (callback) {
      setTimeout(callback, 1000 / 60);
    };
  }
}

function raf(fn) {
  requestAniFrame()(fn);
}
function doubleRaf(fn) {
  raf(function () {
    return raf(fn);
  });
}
// CONCATENATED MODULE: ./src/packages/swiper/swiper.jsx







var swiper_namespace = namespace_Namespace.Create('swiper');
/* harmony default export */ var swiper = ({
  name: swiper_namespace.name,
  mixins: [mixParent(swiper_namespace.name)],
  props: {
    autoplay: {
      type: String | Number
    },
    duration: {
      type: String | Number,
      default: 500
    },
    defaultActive: {
      type: String | Number,
      default: 0
    },
    loop: {
      type: Boolean,
      default: true
    },
    showIndicator: {
      type: Boolean,
      default: true
    },
    indicatorColor: {
      type: String
    },
    vertical: {
      type: Boolean,
      default: false
    },
    swipeable: {
      type: Boolean,
      default: true
    }
  },
  data: function data() {
    return {
      rect: null,
      width: 0,
      height: 0,
      offset: 0,
      active: 0,
      swiping: false,
      touch: touch_Touch.Create(),
      touchStartTime: -1,
      autoplayTimer: -1
    };
  },
  computed: {
    cls: function cls() {
      return swiper_namespace.derive();
    },
    trackCls: function trackCls() {
      return swiper_namespace.derive('track', {
        vertical: this.vertical
      });
    },
    trackStyle: function trackStyle() {
      var style = {
        transitionDuration: "".concat(this.swiping ? 0 : this.duration, "ms"),
        transform: "translate".concat(this.vertical ? 'Y' : 'X', "(").concat(this.offset, "px)")
      };

      if (this.size) {
        style[this.vertical ? 'height' : 'width'] = this.trackSize;
      }

      return style;
    },
    indicatorsCls: function indicatorsCls() {
      return swiper_namespace.derive('indicators', {
        vertical: this.vertical
      });
    },
    activeIndicator: function activeIndicator() {
      return (this.active + this.count) % this.count;
    },
    count: function count() {
      return this.children.length;
    },
    size: function size() {
      return this[this.vertical ? 'height' : 'width'];
    },
    delta: function delta() {
      return this.vertical ? this.touch.deltaY : this.touch.deltaX;
    },
    minOffset: function minOffset() {
      if (this.rect) {
        return (this.vertical ? this.rect.height : this.rect.width) - this.size * this.count;
      }

      return 0;
    },
    maxCount: function maxCount() {
      return Math.ceil(Math.abs(this.minOffset) / this.size);
    },
    trackSize: function trackSize() {
      return this.size * this.count;
    },
    isCorrectDirection: function isCorrectDirection() {
      return this.touch.direction === (this.vertical ? direction_Direction.VER : direction_Direction.HOR);
    }
  },
  watch: {
    defaultActive: function defaultActive(val) {
      this.init(val);
    },
    count: function count() {
      this.init(this.active);
    },
    autoPlay: function autoPlay() {
      this.startAutoplay();
    }
  },
  onMounted: function onMounted() {
    this.init();
  },
  onActivated: function onActivated() {
    this.init(this.active);
  },
  onDeactivated: function onDeactivated() {
    this.stopAutoplay();
  },
  onBeforeUnmount: function onBeforeUnmount() {
    this.stopAutoplay();
  },
  methods: {
    onTouchStart: function onTouchStart(e) {
      if (!this.swipeable) {
        return;
      }

      this.touch.start(e);
      this.touchStartTime = Date.now();
      this.stopAutoplay();
      this.correctPosition();
    },
    onTouchMove: function onTouchMove(e) {
      if (this.swipeable && this.swiping) {
        this.touch.move(e);

        if (this.isCorrectDirection) {
          dom_DOMExtension.PreventDefault(e, true);
          this.move(0, this.delta);
        }
      }
    },
    onTouchEnd: function onTouchEnd(e) {
      if (!this.swipeable || !this.swiping) {
        return;
      }

      var duration = Date.now() - this.touchStartTime;
      var speed = this.delta / duration;
      var shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(this.delta) > this.size / 2;

      if (shouldSwipe && this.isCorrectDirection) {
        var offset = this.vertical ? this.touch.offsetY : this.touch.offsetX;
        var pace = 0;

        if (this.loop) {
          pace = offset > 0 ? this.delta > 0 ? -1 : 1 : 0;
        } else {
          pace = -Math[this.delta > 0 ? 'ceil' : 'floor'](this.delta / this.size);
        }

        this.move(pace, 0, true);
      } else if (this.delta) {
        this.move(0);
      }

      this.swiping = false;
      this.startAutoplay();
    },
    stopAutoplay: function stopAutoplay() {
      clearTimeout(this.autoplayTimer);
    },
    startAutoplay: function startAutoplay() {
      var _this = this;

      this.stopAutoplay();

      if (this.autoplay > 0 && this.count > 1) {
        this.autoplayTimer = setTimeout(function () {
          _this.next();

          _this.startAutoplay();
        }, +this.autoplay);
      }
    },
    prev: function prev() {
      var _this2 = this;

      this.correctPosition();
      this.touch.reset();
      doubleRaf(function () {
        _this2.swiping = false;

        _this2.move(-1, 0, true);
      });
    },
    next: function next() {
      var _this3 = this;

      this.correctPosition();
      this.touch.reset();
      doubleRaf(function () {
        _this3.swiping = false;

        _this3.move(1, 0, true);
      });
    },
    swipeTo: function swipeTo(index, options) {
      var _this4 = this;

      this.correctPosition();
      this.touch.reset();
      doubleRaf(function () {
        var targetIndex;

        if (_this4.loop && index === _this4.count) {
          targetIndex = _this4.active === 0 ? 0 : index;
        } else {
          targetIndex = index % _this4.count;
        }

        if (options.immediate) {
          doubleRaf(function () {
            _this4.swiping = false;
          });
        } else {
          _this4.swiping = false;
        }

        _this4.move(targetIndex - _this4.active, 0, true);
      });
    },
    move: function move() {
      var pace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
      var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
      var emitChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

      if (this.count <= 1) {
        return;
      }

      var active = this.$data.active;
      var targetActive = this.getTargetActive(pace);
      var targetOffset = this.getTargetOffset(targetActive, offset);

      if (this.loop) {
        if (this.children[0] && targetOffset !== this.minOffset) {
          this.children[0].setOffset(targetOffset < this.minOffset ? this.trackSize : 0);
        }

        if (this.children[this.count - 1] && targetOffset !== 0) {
          this.children[this.count - 1].setOffset(targetOffset > 0 ? -this.trackSize : 0);
        }
      }

      this.active = targetActive;
      this.offset = targetOffset;

      if (emitChange && active !== targetActive) {
        this.$emit('change', this.activeIndicator);
      }
    },
    correctPosition: function correctPosition() {
      this.swiping = true;

      if (this.active <= -1) {
        this.move(this.count);
      } else if (this.active >= this.count) {
        this.move(-this.count);
      }
    },
    getTargetActive: function getTargetActive(pace) {
      var active = this.$data.active;

      if (pace) {
        if (this.loop) {
          return math_MathExtension.Clamp(active + pace, -1, this.count);
        }

        return math_MathExtension.Clamp(active + pace, 0, this.maxCount);
      }

      return active;
    },
    getTargetOffset: function getTargetOffset(targetActive) {
      var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
      var currentPosition = targetActive * this.size;

      if (!this.loop) {
        currentPosition = Math.min(currentPosition, this.minOffset);
      }

      var targetOffset = offset - currentPosition;

      if (!this.loop) {
        targetOffset = math_MathExtension.Clamp(targetOffset, this.minOffset, 0);
      }

      return targetOffset;
    },
    isHide: function isHide(el) {
      if (!el) {
        return false;
      }

      var style = window.getComputedStyle(el);
      var hidden = style.display === 'none';
      var parentHidden = el.offsetParent === null && style.position !== 'fixed';
      return hidden || parentHidden;
    },
    init: function init() {
      var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.defaultActive;

      if (!this.$el) {
        return;
      }

      if (!this.isHide(this.$el)) {
        var rect = {
          width: this.$el.offsetWidth,
          height: this.$el.offsetHeight
        };
        this.rect = rect;
        this.width = rect.width;
        this.height = rect.height;
      }

      if (this.count) {
        active = Math.min(this.count - 1, active);
      }

      this.active = active;
      this.swiping = true;
      this.offset = this.getTargetOffset(active);
      this.children.forEach(function (child) {
        return child.setOffset(0);
      });
      this.startAutoplay();
    },
    resize: function resize() {
      this.init(this.active);
    }
  },
  render: function render() {
    var _this5 = this;

    var h = arguments[0];

    var renderDot = function renderDot(_, index) {
      var active = index === _this5.activeIndicator;
      var style = {};

      if (active) {
        style.backgroundColor = _this5.indicatorColor;
      }

      return h("i", {
        "style": style,
        "class": swiper_namespace.derive('indicator', {
          active: active
        })
      });
    };

    var renderIndicator = function renderIndicator() {
      if (_this5.$scopedSlots.indicator) {
        return _this5.$scopedSlots.indicator({
          active: _this5.activeIndicator
        });
      }

      if (_this5.showIndicator && _this5.count > 1) {
        return h("div", {
          "class": _this5.indicatorsCls
        }, [Array(_this5.count).fill(null).map(renderDot)]);
      }
    };

    return h("div", {
      "class": this.cls
    }, [h("div", {
      "class": this.trackCls,
      "style": this.trackStyle,
      "on": {
        "touchstart": this.onTouchStart,
        "touchmove": this.onTouchMove,
        "touchend": this.onTouchEnd,
        "touchcancel": this.onTouchEnd
      }
    }, [this.$slots.default]), renderIndicator()]);
  }
});
// EXTERNAL MODULE: ./src/packages/swiper/swiper.scss
var swiper_swiper = __webpack_require__(45);

// CONCATENATED MODULE: ./src/packages/swiper/index.js



vue_VueExtension.WithInstall(swiper);
/* harmony default export */ var packages_swiper = (swiper);
// CONCATENATED MODULE: ./src/packages/swiperitem/swiperitem.jsx




var swiperitem_namespace = namespace_Namespace.Create('swiper-item');
/* harmony default export */ var swiperitem = ({
  name: swiperitem_namespace.name,
  mixins: [mixChildren(swiper_namespace.name)],
  data: function data() {
    return {
      offset: 0,
      startTime: -1,
      touch: touch_Touch.Create()
    };
  },
  props: {
    duration: {
      type: Number,
      default: 200
    }
  },
  computed: {
    vertical: function vertical() {
      return this.$parent.vertical;
    },
    cls: function cls() {
      return swiperitem_namespace.derive();
    },
    style: function style() {
      var style = {};
      var vertical = this.parent.vertical;

      if (this.parent.size) {
        style[vertical ? 'height' : 'width'] = "".concat(this.parent.size, "px");
      }

      if (this.offset) {
        style.transform = "translate".concat(vertical ? 'Y' : 'X', "(").concat(this.offset, "px)");
      }

      return style;
    },
    delta: function delta() {
      return this.$parent.delta;
    }
  },
  methods: {
    setOffset: function setOffset(offset) {
      this.offset = offset;
    },
    onTouchStart: function onTouchStart(e) {
      this.touch.start(e);
      this.startTime = e.timeStamp;
    },
    onTouchMove: function onTouchMove(e) {
      this.touch.move(e);
      e.preventDefault();
    },
    onTouchEnd: function onTouchEnd(e) {
      var timeStamp = e.timeStamp - this.startTime;

      if (timeStamp < this.duration && Math.abs(this.delta) < touch_Touch.MIN_DISTANCE) {
        this.$emit('click', e);
      }
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls,
      "style": this.style,
      "on": {
        "touchmove": this.onTouchMove,
        "touchstart": this.onTouchStart,
        "touchend": this.onTouchEnd
      }
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/swiperitem/swiperitem.scss
var swiperitem_swiperitem = __webpack_require__(46);

// CONCATENATED MODULE: ./src/packages/swiperitem/index.js



vue_VueExtension.WithInstall(swiperitem);
/* harmony default export */ var packages_swiperitem = (swiperitem);
// CONCATENATED MODULE: ./src/utils/throttle.js
/**
 * @desc 函数节流
 * @param func 函数
 * @param wait 延迟执行毫秒数
 * @param type 1 表时间戳版,2 表定时器版
 */
var throttle_throttle = function throttle(func, wait, type) {
  if (type === 1) {
    var previous = 0;
  } else if (type === 2) {
    var timeout;
  }

  return function () {
    var context = this;
    var args = arguments;

    if (type === 1) {
      var now = Date.now();

      if (now - previous > wait) {
        func.apply(context, args);
        previous = now;
      }
    } else if (type === 2) {
      if (!timeout) {
        timeout = setTimeout(function () {
          timeout = null;
          func.apply(context, args);
        }, wait);
      }
    }
  };
};
// CONCATENATED MODULE: ./src/packages/list/list.jsx



var list_namespace = namespace_Namespace.Create('list');

/* harmony default export */ var list = ({
  name: list_namespace.name,
  components: {
    Loading: loading
  },
  data: function data() {
    return {
      scrollParent: null,
      check: null,
      distanceY: -1
    };
  },
  props: {
    loadingText: {
      type: String
    },
    loading: {
      type: Boolean,
      default: false
    },
    finished: {
      type: Boolean,
      default: false
    },
    finishedText: {
      type: String,
      default: '没有更多了'
    },
    error: {
      type: Boolean,
      default: false
    },
    errorText: {
      type: String,
      default: '加载失败,点击重试'
    },
    offset: {
      type: Number,
      default: 50
    },
    loadingType: {
      type: String,
      default: 'spinner'
    },
    immediateCheck: {
      type: Boolean,
      default: true
    },
    direction: {
      type: String,
      default: 'up'
    },
    laodingType: {
      type: String,
      default: 'spinner'
    }
  },
  computed: {
    cls: function cls() {
      return list_namespace.derive();
    },
    tipCls: function tipCls() {
      return list_namespace.derive(['tip']);
    }
  },
  methods: {
    getElementTop: function getElementTop(element) {
      return dom_DOMExtension.GetBoundingClientRect(element).top + dom_DOMExtension.GetScrollTop(window);
    },
    checkScroll: function checkScroll() {
      var el = this.$el; // 当前元素的上拥有滚动条元素的高度

      var scrollerEleHeight = dom_DOMExtension.GetBoundingClientRect(this.scrollParent).height; // 当前元素的高度

      var docHeight = dom_DOMExtension.GetBoundingClientRect(el).height; // 当前元素拥有滚动条上元素的滚动高度

      var scrollTop = dom_DOMExtension.GetScrollTop(this.scrollParent);
      var totalHeight = scrollTop + scrollerEleHeight;
      var isScrollFlag = false;

      if (el === this.scrollParent) {
        isScrollFlag = this.scrollParent.scrollHeight - totalHeight <= this.offset && scrollTop > this.distanceY;
      } else {
        isScrollFlag = docHeight - totalHeight <= this.offset && scrollTop > this.distanceY;
      }

      this.distanceY = scrollTop;

      if (isScrollFlag) {
        this.$emit('input', true);
        this.$emit('load');
      }
    }
  },
  mounted: function mounted() {
    this.scrollParent = dom_DOMExtension.GetScrollParent(this.$el);
    this.check = throttle_throttle(this.checkScroll, 500, 2);
    dom_DOMExtension.AddEventListener(this.scrollParent, 'scroll', this.check);

    if (this.immediateCheck) {
      this.checkScroll();
    }
  },
  destroyed: function destroyed() {
    dom_DOMExtension.RemoveEventListener(this.scrollParent, 'scroll', this.check);
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];

    var onClick = function onClick() {
      _this.$emit('input', false);

      _this.$emit('load');

      _this.checkScroll();
    };

    var renderLoadingText = function renderLoadingText() {
      if (_this.loading && !_this.finished) {
        return h("div", [_this.$slots.loading ? _this.$slots.loading : h("p", {
          "class": _this.tipCls
        }, [h("mx-loading", {
          "attrs": {
            "type": _this.laodingType
          }
        }, [_this.loadingText])])]);
      }
    };

    var renderFinishedText = function renderFinishedText() {
      if (_this.finished) {
        return h("div", [_this.$slots.finished ? _this.$slots.finished : h("p", {
          "class": _this.tipCls
        }, [_this.finishedText])]);
      }
    };

    var renderDefaultText = function renderDefaultText() {
      if (!_this.loading && !_this.finished && !_this.error) {
        return h("div", [h("p", {
          "class": _this.tipCls
        }, ["\u4E0A\u62C9\u52A0\u8F7D\u66F4\u591A"])]);
      }
    };

    var renderErrorText = function renderErrorText() {
      if (_this.error) {
        return h("div", [_this.$slots.error ? _this.$slots.error : h("p", {
          "class": _this.tipCls,
          "on": {
            "click": onClick
          }
        }, [_this.errorText])]);
      }
    };

    return h("div", {
      "class": this.cls
    }, [this.$slots.default, renderDefaultText(), renderLoadingText(), renderFinishedText(), renderErrorText()]);
  }
});
// EXTERNAL MODULE: ./src/packages/list/list.scss
var list_list = __webpack_require__(47);

// CONCATENATED MODULE: ./src/packages/list/index.js



vue_VueExtension.WithInstall(list);
/* harmony default export */ var packages_list = (list);
// CONCATENATED MODULE: ./src/packages/steps/steps.jsx

var steps_namespace = namespace_Namespace.Create('steps');
/* harmony default export */ var steps = ({
  name: steps_namespace.name,
  props: {
    theme: {
      type: String,
      default: 'brand'
    },
    active: {
      type: String | Number,
      default: 0
    },
    activeColor: {
      type: String
    },
    inactiveColor: {
      type: String
    },
    activeIcon: {
      type: String
    },
    inactiveIcon: {
      type: String
    },
    finishedIcon: {
      type: String
    },
    iconPrefix: {
      type: String,
      default: 'mx-icon'
    },
    isHorizental: {
      type: Boolean,
      default: false
    },
    titleFontSize: {
      type: String | Number
    }
  },
  computed: {
    cls: function cls() {
      return steps_namespace.derive({
        horizental: this.isHorizental
      });
    },
    containerCls: function containerCls() {
      return steps_namespace.derive('container');
    }
  },
  methods: {
    onClickStep: function onClickStep(index) {
      this.$emit('click-step', index);
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls
    }, [h("div", {
      "class": this.containerCls
    }, [this.$slots.default])]);
  }
});
// EXTERNAL MODULE: ./src/packages/steps/steps.scss
var steps_steps = __webpack_require__(48);

// CONCATENATED MODULE: ./src/packages/steps/index.js



vue_VueExtension.WithInstall(steps);
/* harmony default export */ var packages_steps = (steps);
// CONCATENATED MODULE: ./src/packages/step/step.jsx


var step_namespace = namespace_Namespace.Create('step');
/* harmony default export */ var step_step = ({
  name: step_namespace.name,
  props: {
    title: {
      type: String
    },
    desc: {
      type: String
    },
    timestamp: {
      type: String
    }
  },
  computed: {
    cls: function cls() {
      return step_namespace.derive();
    },
    contentCls: function contentCls() {
      return step_namespace.derive('content');
    },
    titleCls: function titleCls() {
      return step_namespace.derive('title', [(this.isActive || this.isFinished) && this.$parent.theme]);
    },
    titleStyle: function titleStyle() {
      var res = {};
      var size = Number.parseInt(this.$parent.titleFontSize);

      if (!Number.isNaN(size)) {
        res.lineHeight = res.fontSize = "".concat(size, "px");
      }

      return res;
    },
    descCls: function descCls() {
      return step_namespace.derive('desc');
    },
    timestampCls: function timestampCls() {
      return step_namespace.derive('timestamp');
    },
    iconContainerCls: function iconContainerCls() {
      return step_namespace.derive('icon-container');
    },
    iconCls: function iconCls() {
      return step_namespace.derive('icon', [(this.isActive || this.isFinished) && this.$parent.theme, {
        horizental: this.$parent.isHorizental
      }]);
    },
    lineCls: function lineCls() {
      return step_namespace.derive('line', {
        horizental: this.$parent.isHorizental
      });
    },
    index: function index() {
      return this.$parent.$children.indexOf(this);
    },
    isInactive: function isInactive() {
      return !(this.isActive || this.isFinished);
    },
    isActive: function isActive() {
      return this.$parent.active === this.index;
    },
    isFinished: function isFinished() {
      return this.$parent.active > this.index;
    },
    containerStyle: function containerStyle() {
      var style = {};
      var size = Number.parseInt(this.$parent.titleFontSize);

      if (!Number.isNaN(size)) {
        style.top = "".concat(size / 2, "px");
      }

      return style;
    },
    lineStyle: function lineStyle() {
      var style = {};
      var size = Number.parseInt(this.$parent.titleFontSize);

      if (!Number.isNaN(size)) {
        style.top = "".concat(size / 2, "px");
      }

      return style;
    }
  },
  data: function data() {
    return {
      inited: false
    };
  },
  mounted: function mounted() {
    var _this = this;

    this.$nextTick(function () {
      return _this.inited = true;
    });
  },
  methods: {
    onClick: function onClick() {
      var _this$$parent$onClick, _this$$parent;

      (_this$$parent$onClick = (_this$$parent = this.$parent).onClickStep) === null || _this$$parent$onClick === void 0 ? void 0 : _this$$parent$onClick.call(_this$$parent, this.index);
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];

    var renderContent = function renderContent() {
      if (_this2.$slots.content) {
        return _this2.$slots.content;
      }

      return [renderTitle(), renderDesc(), renderTimestamp()];
    };

    var renderTitle = function renderTitle() {
      return h("div", {
        "class": _this2.titleCls,
        "style": _this2.titleStyle
      }, [_this2.$slots.default || _this2.title]);
    };

    var renderDesc = function renderDesc() {
      if (_this2.$slots.desc) {
        return _this2.$slots.desc;
      }

      return _this2.desc && h("div", {
        "class": _this2.descCls
      }, [_this2.desc]);
    };

    var renderTimestamp = function renderTimestamp() {
      if (_this2.$slots.timestamp) {
        return _this2.$slots.timestamp;
      }

      return _this2.timestamp && h("div", {
        "class": _this2.timestampCls
      }, [_this2.timestamp]);
    };

    var renderIcon = function renderIcon() {
      var _this2$$parent$$props = _this2.$parent.$props,
          activeIcon = _this2$$parent$$props.activeIcon,
          inactiveIcon = _this2$$parent$$props.inactiveIcon,
          finishedIcon = _this2$$parent$$props.finishedIcon,
          activeColor = _this2$$parent$$props.activeColor,
          inActiveColor = _this2$$parent$$props.inActiveColor,
          iconPrefix = _this2$$parent$$props.iconPrefix,
          theme = _this2$$parent$$props.theme;

      if (_this2.isInactive && inactiveIcon) {
        return h(icon, {
          "attrs": {
            "name": inactiveIcon,
            "color": inActiveColor,
            "class-prefix": iconPrefix,
            "size": "10"
          }
        });
      }

      if (_this2.isActive && activeIcon) {
        return h(icon, {
          "attrs": {
            "name": activeIcon,
            "theme": theme,
            "color": activeColor,
            "class-prefix": iconPrefix,
            "size": "10"
          }
        });
      }

      if (_this2.isFinished && finishedIcon) {
        return h(icon, {
          "attrs": {
            "name": finishedIcon,
            "theme": theme,
            "color": activeColor,
            "class-prefix": iconPrefix,
            "size": "10"
          }
        });
      }

      return h("div", {
        "class": _this2.iconCls
      });
    };

    return h("div", {
      "class": this.cls,
      "on": {
        "click": this.onClick
      }
    }, [h("div", {
      "class": this.contentCls
    }, [renderContent()]), h("div", {
      "class": this.iconContainerCls,
      "style": this.containerStyle
    }, [renderIcon()]), h("div", {
      "class": this.lineCls,
      "style": this.lineStyle
    })]);
  }
});
// EXTERNAL MODULE: ./src/packages/step/step.scss
var packages_step_step = __webpack_require__(49);

// CONCATENATED MODULE: ./src/packages/step/index.js



vue_VueExtension.WithInstall(step_step);
/* harmony default export */ var packages_step = (step_step);
// EXTERNAL MODULE: ./node_modules/@antv/f2/dist/f2.js
var f2 = __webpack_require__(60);
var f2_default = /*#__PURE__*/__webpack_require__.n(f2);

// CONCATENATED MODULE: ./src/mixins/chart/mixChart.js


function mixChart_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function mixChart_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { mixChart_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { mixChart_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }


function mixChart() {
  return {
    props: {
      axis: {
        type: Object
      },
      geometry: {
        type: Object,
        required: true
      },
      data: {
        type: Array | Object,
        required: true
      },
      width: {
        type: Number
      },
      height: {
        type: Number
      },
      showTag: {
        type: Boolean,
        default: false
      }
    },
    data: function data() {
      return {
        chart: null
      };
    },
    computed: {
      isUsingYR: function isUsingYR() {
        return Array.isArray(this.data[0]);
      }
    },
    watch: {
      axis: function axis() {
        this.repaint();
      },
      geometry: function geometry() {
        this.repaint();
      },
      showTag: function showTag() {
        this.repaint();
      },
      width: function width(value) {
        this.chart.changeSize(value, null);
      },
      height: function height(value) {
        this.chart.changeSize(null, value);
      },
      data: function data() {
        this.changeSource();
      }
    },
    mounted: function mounted() {
      this.initChart();
      this.renderCoord();
      this.renderAxis();
      this.renderScale();
      this.renderTooltip();
      this.renderLegend();
      this.renderGuide();
      this.renderSource();
      this.renderGeometry();
      this.chart.render();
      this.useInteraction();
    },
    beforeDestory: function beforeDestory() {
      this.chart.destory();
    },
    methods: {
      initChart: function initChart() {
        this.chart = new f2_default.a.Chart({
          el: this.getCanvas(),
          width: this.width,
          height: this.height,
          pixelRatio: window.devicePixelRatio
        });
      },
      renderCoord: function renderCoord() {},
      renderAxis: function renderAxis() {
        this.chart.axis(this.getAxisOption());
      },
      renderScale: function renderScale() {
        var _this$axis = this.axis,
            x = _this$axis.x,
            y = _this$axis.y,
            yr = _this$axis.yr;
        x.scale && this.chart.scale(x.use, x.scale);
        y.scale && this.chart.scale(y.use, y.scale);
        yr && yr.scale && this.chart.scale(yr.use, yr.scale);
      },
      renderTooltip: function renderTooltip() {
        this.chart.tooltip(this.getTooltipOption());
      },
      renderLegend: function renderLegend() {
        this.chart.legend({
          align: 'center',
          marker: {
            radius: 4
          },
          nameStyle: {
            fill: '#8A8A8F',
            fontSize: 12
          },
          valueStyle: {
            fill: '#8A8A8F',
            fontSize: 12
          }
        });
      },
      renderGuide: function renderGuide() {
        var _this = this;

        if (this.showTag) {
          var items = this.data.flat();
          var _this$axis2 = this.axis,
              x = _this$axis2.x,
              y = _this$axis2.y,
              yr = _this$axis2.yr;
          var classifyBy = this.geometry.classifyBy;
          items.forEach(function (item) {
            var _item$y$use, _item$y$use2;

            var position = [item[x.use], (_item$y$use = item[y.use]) !== null && _item$y$use !== void 0 ? _item$y$use : item[yr.use]];
            var content = (_item$y$use2 = item[y.use]) !== null && _item$y$use2 !== void 0 ? _item$y$use2 : item[yr.use];

            _this.chart.guide().text(_this.getGuideTextOption(position, content));
          });
        }
      },
      renderSource: function renderSource() {
        this.chart.source(this.data.flat());
      },
      renderGeometry: function renderGeometry() {},
      useInteraction: function useInteraction() {},
      changeSource: function changeSource() {
        this.chart.changeSource(this.data.flat());
      },
      repaint: function repaint() {
        this.chart.clear();
        this.renderCoord();
        this.renderAxis();
        this.renderScale();
        this.renderTooltip();
        this.renderLegend();
        this.renderGuide();
        this.renderSource();
        this.renderGeometry();
        this.chart.repaint();
      },
      getCanvas: function getCanvas() {
        return this.$el;
      },
      getAxisOption: function getAxisOption() {
        var transposed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
        var option = {};
        var _this$axis3 = this.axis,
            x = _this$axis3.x,
            y = _this$axis3.y,
            yr = _this$axis3.yr;

        if (x) {
          option[x.use] = transposed ? this.getAxisYOption() : this.getAxisXOption();
        }

        if (y) {
          option[y.use] = transposed ? this.getAxisXOption() : this.getAxisYOption();
        }

        if (yr) {
          option[yr.use] = this.getAxisYOption(function (option) {
            return option.positon = 'right';
          });
        }

        return option;
      },
      getAxisXOption: function getAxisXOption() {
        var configAxis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (option) {
          return option;
        };
        var option = {
          label: {
            fill: '#8A8A8F',
            fontSize: 12
          }
        };
        configAxis(option);
        return option;
      },
      getAxisYOption: function getAxisYOption() {
        var configAxis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (option) {
          return option;
        };
        var option = {
          label: {
            fill: '#C7C7CC',
            fontSize: 10
          },
          grid: {
            stroke: '#F2F2F2',
            lineWidth: 1,
            lineDash: 0
          }
        };
        configAxis(option);
        return option;
      },
      getTooltipOption: function getTooltipOption() {
        var _this2 = this;

        var showCrosshairs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
        var option = {
          showCrosshairs: showCrosshairs,
          crosshairsStyle: {
            stroke: '#C7C7CC',
            lineWidth: 1,
            lineDash: [3, 1.2]
          },
          background: {
            fill: '#FFFFFF',
            radius: 15,
            padding: [8, 25],
            shadowOffsetX: 0,
            shadowOffsetY: 2,
            shadowBlur: 8,
            shadowColor: 'rgba(0,0,0,0.1)'
          },
          nameStyle: {
            fill: '#666666',
            fontSize: 13,
            fontFamily: 'PingFangSC-Medium',
            fontWeight: 500
          },
          valueStyle: {
            fill: '#666666',
            fontSize: 13,
            fontFamily: 'PingFangSC-Medium',
            fontWeight: 500
          }
        };

        if (this.geometry.classifyBy) {
          option.custom = true; // onchange

          option.onChange = function (obj) {
            var _this2$chart$get$lege;

            var legend = (_this2$chart$get$lege = _this2.chart.get('legendController').legends.top) === null || _this2$chart$get$lege === void 0 ? void 0 : _this2$chart$get$lege[0];

            if (!legend) {
              return;
            }

            var tooltipItems = obj.items;
            var legendItems = legend.items;
            var map = {};
            legendItems.forEach(function (item) {
              map[item.name] = mixChart_objectSpread({}, item);
            });
            tooltipItems.forEach(function (item) {
              var name = item.name;
              var value = item.value;

              if (map[name]) {
                map[name].value = value;
              }
            });
            legend === null || legend === void 0 ? void 0 : legend.setItems(Object.values(map));
          }; // onHide


          option.onHide = function () {
            var _this2$chart$get$lege2;

            var legend = (_this2$chart$get$lege2 = _this2.chart.get('legendController').legends.top) === null || _this2$chart$get$lege2 === void 0 ? void 0 : _this2$chart$get$lege2[0];
            legend === null || legend === void 0 ? void 0 : legend.setItems(_this2.chart.getLegendItems().country);
          };
        }

        return option;
      },
      getGuideTextOption: function getGuideTextOption(position, content) {
        var option = {
          position: position,
          content: content,
          style: {
            fill: '#666666',
            fontSize: 9
          },
          offsetY: -8
        };
        return option;
      },
      getLinearColor: function getLinearColor(color) {
        var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 90;

        if (Array.isArray(color)) {
          return color.map(function (x) {
            return "l(".concat(angle, ") 0:").concat(x, "FF 1:").concat(x, "00");
          });
        }

        return "l(".concat(angle, ") 0:").concat(color, "FF 1:").concat(color, "00");
      }
    }
  };
}
// CONCATENATED MODULE: ./src/packages/chartline/chartline.jsx


var chartline_namespace = namespace_Namespace.Create('chart-line');
/* harmony default export */ var chartline = ({
  name: chartline_namespace.name,
  mixins: [mixChart()],
  props: {
    showArea: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    cls: function cls() {
      return chartline_namespace.derive();
    }
  },
  methods: {
    renderTooltip: function renderTooltip() {
      this.chart.tooltip(this.getTooltipOption(true));
    },
    renderGeometry: function renderGeometry() {
      var _this = this;

      var _this$axis = this.axis,
          x = _this$axis.x,
          y = _this$axis.y,
          yr = _this$axis.yr;
      var _this$geometry = this.geometry,
          classifyBy = _this$geometry.classifyBy,
          color = _this$geometry.color;
      var geos = this.isUsingYR ? this.data : [this.data];
      geos.forEach(function (_, index) {
        var position = [x.use, _this.isUsingYR && index === geos.length - 1 ? yr === null || yr === void 0 ? void 0 : yr.use : y.use];

        var line = _this.chart.line();

        line.position(position);
        line.shape('smooth');
        classifyBy ? line.color(classifyBy, color) : line.color(color);

        if (!_this.showArea) {
          return;
        }

        var area = _this.chart.area();

        area.position(position);
        area.shape('smooth');
        classifyBy ? area.color(classifyBy, _this.getLinearColor(color)) : area.color(_this.getLinearColor(color));
      });
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("canvas", {
      "class": this.cls
    });
  }
});
// EXTERNAL MODULE: ./src/packages/chartline/chartline.scss
var chartline_chartline = __webpack_require__(50);

// CONCATENATED MODULE: ./src/packages/chartline/index.js



vue_VueExtension.WithInstall(chartline);
/* harmony default export */ var packages_chartline = (chartline);
// CONCATENATED MODULE: ./src/packages/chartcolumn/chartcolumn.jsx


var chartcolumn_namespace = namespace_Namespace.Create('chart-column');
/* harmony default export */ var chartcolumn = ({
  name: chartcolumn_namespace.name,
  mixins: [mixChart()],
  props: {
    showHorizental: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    cls: function cls() {
      return chartcolumn_namespace.derive();
    }
  },
  methods: {
    renderAxis: function renderAxis() {
      this.chart.axis(this.getAxisOption(true));
    },
    renderGeometry: function renderGeometry() {
      var _this = this;

      var _this$axis = this.axis,
          x = _this$axis.x,
          y = _this$axis.y,
          yr = _this$axis.yr;
      var _this$geometry = this.geometry,
          classifyBy = _this$geometry.classifyBy,
          color = _this$geometry.color;
      var geos = this.isUsingYR ? this.data : [this.data];
      geos.forEach(function (_, index) {
        var position = [x.use, _this.isUsingYR && index === geos.length - 1 ? yr === null || yr === void 0 ? void 0 : yr.use : y.use];

        var interval = _this.chart.interval();

        interval.position(position);
        interval.shape('smooth');
        interval.adjust('stack');
        classifyBy ? interval.color(classifyBy, color) : interval.color(color);
      });
    },
    renderCoord: function renderCoord() {
      if (this.showHorizental) {
        this.chart.coord({
          transposed: true
        });
      }
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("canvas", {
      "class": this.cls
    });
  }
});
// EXTERNAL MODULE: ./src/packages/chartcolumn/chartcolumn.scss
var chartcolumn_chartcolumn = __webpack_require__(51);

// CONCATENATED MODULE: ./src/packages/chartcolumn/index.js



vue_VueExtension.WithInstall(chartcolumn);
/* harmony default export */ var packages_chartcolumn = (chartcolumn);
// CONCATENATED MODULE: ./src/packages/chartpie/chartpie.jsx


var chartpie_namespace = namespace_Namespace.Create('chart-pie');
/* harmony default export */ var chartpie = ({
  name: chartpie_namespace.name,
  mixins: [mixChart()],
  props: {
    showRing: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    wrapperCls: function wrapperCls() {
      return chartpie_namespace.derive('wrapper');
    },
    cls: function cls() {
      return chartpie_namespace.derive();
    },
    innerCls: function innerCls() {
      return chartpie_namespace.derive('inner');
    },
    formatedData: function formatedData() {
      var _this = this;

      return Object.keys(this.data).map(function (key) {
        return {
          key: key,
          y: _this.data[key],
          x: '1'
        };
      });
    }
  },
  methods: {
    renderCoord: function renderCoord() {
      var option = {
        transposed: true
      };

      if (this.showRing) {
        option.innerRadius = 0.8;
      }

      this.chart.coord('polar', option);
    },
    renderAxis: function renderAxis() {
      this.chart.axis(false);
    },
    renderScale: function renderScale() {
      this.chart.scale(false);
    },
    renderTooltip: function renderTooltip() {
      this.chart.tooltip(false);
    },
    renderLegend: function renderLegend() {
      var _this2 = this;

      this.chart.legend({
        itemFormatter: function itemFormatter(value) {
          return "".concat(value, "  ").concat(_this2.data[value]);
        }
      });
    },
    renderSource: function renderSource() {
      this.chart.source(this.formatedData);
    },
    renderGeometry: function renderGeometry() {
      var color = this.geometry.color;
      var interval = this.chart.interval();
      interval.position(['x', 'y']);
      interval.color('key', color);
      interval.adjust('stack');
      interval.style({
        lineWidth: 5,
        stroke: '#fff',
        lineJoin: 'round',
        lineCap: 'round'
      });
    },
    changeSource: function changeSource() {
      this.chart.changeSource(this.formatedData);
    },
    getCanvas: function getCanvas() {
      return this.$refs.canvas;
    }
  },
  render: function render() {
    var _this3 = this;

    var h = arguments[0];

    var renderInnerText = function renderInnerText() {
      if (_this3.showRing) {
        return h("div", {
          "class": _this3.innerCls
        }, [_this3.$slots.default]);
      }
    };

    return h("div", {
      "class": this.wrapperCls
    }, [h("canvas", {
      "ref": "canvas",
      "class": this.cls
    }), renderInnerText()]);
  }
});
// EXTERNAL MODULE: ./src/packages/chartpie/chartpie.scss
var chartpie_chartpie = __webpack_require__(52);

// CONCATENATED MODULE: ./src/packages/chartpie/index.js



vue_VueExtension.WithInstall(chartpie);
/* harmony default export */ var packages_chartpie = (chartpie);
// CONCATENATED MODULE: ./src/packages/sticky/sticky.jsx



var namesapce = namespace_Namespace.Create('sticky');
/* harmony default export */ var sticky = ({
  name: namesapce.name,
  props: {
    position: {
      type: String,
      default: 'top'
    },
    zIndex: {
      type: Number | String,
      default: 1060
    },
    offset: {
      type: Number,
      default: 0
    },
    container: {
      type: Node
    }
  },
  data: function data() {
    return {
      fixed: false,
      width: 0,
      height: 0,
      transform: 0,
      scrollParent: null
    };
  },
  computed: {
    rootStyle: function rootStyle() {
      if (this.fixed) {
        return {
          width: "".concat(this.width, "px"),
          height: "".concat(this.height, "px")
        };
      }
    },
    cls: function cls() {
      return namesapce.derive({
        fixed: this.fixed
      });
    },
    style: function style() {
      if (!this.fixed) {
        return;
      }

      var res = defineProperty_default()({
        zIndex: this.zIndex,
        width: "".concat(this.width, "px"),
        height: "".concat(this.height, "px")
      }, this.position, "".concat(this.offset, "px"));

      if (this.transform) {
        res.transform = "translate3d(0,".concat(this.transform, "px,0)");
      }

      return res;
    }
  },
  mounted: function mounted() {
    this.scrollParent = dom_DOMExtension.GetScrollParent(this.$el);
    dom_DOMExtension.AddEventListener(this.scrollParent, 'scroll', this.onScroll);
  },
  beforeDestory: function beforeDestory() {
    dom_DOMExtension.RemoveEventListener(this.scrollParent, 'scroll', this.onScroll);
  },
  methods: {
    onScroll: function onScroll(e) {
      var _this$$props = this.$props,
          position = _this$$props.position,
          container = _this$$props.container;
      var rootRect = dom_DOMExtension.GetBoundingClientRect(this.$el);
      this.width = rootRect.width;
      this.height = rootRect.height;

      if (position === 'top') {
        if (container) {
          var containerRect = dom_DOMExtension.GetBoundingClientRect(container);
          this.fixed = this.offset > rootRect.top && containerRect.bottom > 0;
          var delta = containerRect.bottom - this.offset - this.height;
          this.transform = delta < 0 ? delta : 0;
        } else {
          this.fixed = this.offset > rootRect.top;
        }
      } else {
        var clientHeight = document.documentElement.clientHeight;

        if (container) {
          var _containerRect = dom_DOMExtension.GetBoundingClientRect(container);

          this.fixed = clientHeight - this.offset < rootRect.bottom && clientHeight > _containerRect.top;

          var _delta = clientHeight - _containerRect.top - this.height - this.offset;

          this.transform = _delta < 0 ? -_delta : 0;
        } else {
          this.fixed = clientHeight - this.offset < rootRect.bottom;
        }
      }

      this.$emit('scroll', {
        scrollTop: dom_DOMExtension.GetScrollTop(this.scrollParent),
        isFixed: this.fixed
      });
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "style": this.rootStyle
    }, [h("div", {
      "class": this.cls,
      "style": this.style
    }, [this.$slots.default])]);
  }
});
// EXTERNAL MODULE: ./src/packages/sticky/sticky.scss
var sticky_sticky = __webpack_require__(53);

// CONCATENATED MODULE: ./src/packages/sticky/index.js



vue_VueExtension.WithInstall(sticky);
/* harmony default export */ var packages_sticky = (sticky);
// CONCATENATED MODULE: ./src/utils/extensions/array.js


var array_ArrayExtension = /*#__PURE__*/function () {
  function ArrayExtension() {
    classCallCheck_default()(this, ArrayExtension);
  }

  createClass_default()(ArrayExtension, null, [{
    key: "Toggle",
    value: function Toggle(array, value) {
      var isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (item1, item2) {
        return item1 === item2;
      };
      var res = array.slice();
      var index = res.findIndex(function (x) {
        return isEqual(x, value);
      });

      if (index != -1) {
        res.splice(index, 1);
      } else {
        res.push(value);
      }

      return res;
    }
  }]);

  return ArrayExtension;
}();
// CONCATENATED MODULE: ./src/packages/collapse/collapse.jsx


var collapse_namespace = namespace_Namespace.Create('collapse');
/* harmony default export */ var collapse = ({
  name: collapse_namespace.name,
  props: {
    accordion: {
      type: Boolean,
      default: false
    },
    value: {
      type: [Number, String, Array],
      default: function _default() {
        return [];
      }
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  data: function data() {
    return {
      innerValue: this.value
    };
  },
  computed: {
    cls: function cls() {
      return collapse_namespace.derive();
    }
  },
  watch: {
    value: function value(val) {
      this.innerValue = val;
    }
  },
  methods: {
    setActive: function setActive(value) {
      this.$emit('change', value);
    },
    handleItemClick: function handleItemClick(value) {
      if (this.accordion) {
        this.innerValue = this.innerValue == value ? '' : value;
      } else {
        this.innerValue = array_ArrayExtension.Toggle(this.innerValue, value);
      }

      this.setActive(this.innerValue);
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": this.cls
    }, [this.$slots.default]);
  }
});
// EXTERNAL MODULE: ./src/packages/collapse/collapse.scss
var collapse_collapse = __webpack_require__(54);

// CONCATENATED MODULE: ./src/packages/collapse/index.js
/*
 * @Description: 
 * @Author: 唐胜建
 * @Date: 2021-11-19 14:17:12
 * @LastEditTime: 2021-11-19 14:24:24
 */



vue_VueExtension.WithInstall(collapse);
/* harmony default export */ var packages_collapse = (collapse);
// CONCATENATED MODULE: ./src/packages/collapseitem/collapseitem.jsx


var collapseitem_namespace = namespace_Namespace.Create('collapse-item');
/* harmony default export */ var collapseitem = ({
  name: collapseitem_namespace.name,
  components: {
    Icon: icon
  },
  props: {
    title: {
      type: String
    },
    name: {
      type: [String, Number],
      default: ''
    },
    value: {
      type: Number,
      default: 0
    }
  },
  data: function data() {
    return {
      height: ''
    };
  },
  computed: {
    cls: function cls() {
      return collapseitem_namespace.derive({
        active: this.isActive
      });
    },
    headerCls: function headerCls() {
      return collapseitem_namespace.derive('header');
    },
    headerTitleCls: function headerTitleCls() {
      return collapseitem_namespace.derive('header-title');
    },
    contentCls: function contentCls() {
      return collapseitem_namespace.derive('content');
    },
    iconCls: function iconCls() {
      return collapseitem_namespace.derive('icon', {
        active: this.isActive
      });
    },
    contentStyle: function contentStyle() {
      var style = {};

      if (this.isActive) {
        style.height = "".concat(this.height, "px");
      } else {
        style.height = "0px";
      }

      return style;
    },
    key: function key() {
      return this.name || this.$parent.$children.indexOf(this).toString();
    },
    isActive: function isActive() {
      var _this = this;

      var innerValue = this.$parent.$data.innerValue;
      return this.$parent.accordion ? innerValue === this.key : (innerValue === null || innerValue === void 0 ? void 0 : innerValue.findIndex(function (x) {
        return x === _this.key;
      })) != -1;
    }
  },
  mounted: function mounted() {
    this.height = this.$refs.collapseItemContentRef.offsetHeight;
  },
  methods: {
    handleItemClick: function handleItemClick() {
      this.$parent.handleItemClick(this.key);
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];

    var renderHeader = function renderHeader() {
      return h("div", {
        "class": _this2.headerCls,
        "on": {
          "click": _this2.handleItemClick
        }
      }, [renderTitle(), h(icon, {
        "class": _this2.iconCls,
        "attrs": {
          "name": "arrow-down",
          "size": 10
        }
      })]);
    };

    var renderTitle = function renderTitle() {
      if (_this2.$slots.title) {
        return _this2.$slots.title;
      }

      return h("div", {
        "class": _this2.headerTitleCls
      }, [_this2.title]);
    };

    var renderContent = function renderContent() {
      return h("div", {
        "class": _this2.contentCls,
        "style": _this2.contentStyle
      }, [h("div", {
        "ref": "collapseItemContentRef"
      }, [_this2.$slots.default])]);
    };

    return h("div", {
      "class": this.cls
    }, [renderHeader(), renderContent()]);
  }
});
// EXTERNAL MODULE: ./src/packages/collapseitem/collapseitem.scss
var collapseitem_collapseitem = __webpack_require__(55);

// CONCATENATED MODULE: ./src/packages/collapseitem/index.js
/*
 * @Description: 
 * @Author: 唐胜建
 * @Date: 2021-11-19 18:24:43
 * @LastEditTime: 2021-11-21 18:12:06
 */



vue_VueExtension.WithInstall(collapseitem);
/* harmony default export */ var packages_collapseitem = (collapseitem);
// CONCATENATED MODULE: ./src/minixui.js


function minixui_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function minixui_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { minixui_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { minixui_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
































































































var minixui_packages = {
  Icon: packages_icon,
  Switch: packages_switch,
  Button: packages_button,
  ButtonGroup: packages_buttongroup,
  Popup: packages_popup,
  Cell: packages_cell,
  Tag: packages_tag,
  NavBar: packages_navbar,
  NoticeBar: packages_noticebar,
  Overlay: packages_overlay,
  Modal: packages_modal,
  Dialog: packages_dialog,
  SearchBar: packages_searchbar,
  Empty: packages_empty,
  ScrollView: packages_scrollview,
  Checkbox: packages_checkbox,
  Radio: packages_radio,
  Rate: packages_rate,
  Picker: packages_picker,
  PickerColumn: packages_pickercolumn,
  DateTimePicker: packages_datetimepicker,
  Badge: packages_badge,
  Mask: packages_mask,
  ActionSheet: packages_actionsheet,
  Toast: packages_toast,
  TabBar: packages_tabbar,
  TabBarItem: packages_tabbaritem,
  Tab: packages_tab,
  TabPane: packages_tabpane,
  Catalog: packages_catalog,
  Slider: packages_slider,
  SliderScale: packages_sliderscale,
  PullRefresh: packages_pullrefresh,
  Loading: packages_loading,
  Swiper: packages_swiper,
  SwiperItem: packages_swiperitem,
  List: packages_list,
  Steps: packages_steps,
  Step: packages_step,
  ChartLine: packages_chartline,
  ChartColumn: packages_chartcolumn,
  ChartPie: packages_chartpie,
  Sticky: packages_sticky,
  Collapse: packages_collapse,
  CollapseItem: packages_collapseitem
};
var components = {};
var methods = {};
var filters = {};
var directives = {};
config["a" /* packages */].map(function (item) {
  var pkg = minixui_packages[item.name];
  if (!pkg) return;

  if (item.type == 'component') {
    if (pkg.name) {
      components[pkg.name] = pkg;
    } else {
      for (var n in pkg) {
        components[n] = pkg[n];
      }
    }
  } else if (item.type == 'method') {
    methods[item.name] = pkg;
  } else if (item.type == 'filter') {
    filters[item.name] = pkg;
  } else if (item.type == 'directive') {
    directives[item.name] = pkg;
  }
});

var minixui_install = function install(Vue) {
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  if (install.installed) return;

  if (opts.locale) {
    Vue.config.lang = opts.locale;
  }

  if (opts.lang) locale(Vue.config.lang, opts.lang);

  for (var cptName in methods) {
    if (Array.isArray(methods[cptName])) {
      Vue.prototype['$' + cptName.toLowerCase()] = methods[cptName][0];
      Vue.component(methods[cptName][1].name, methods[cptName][1]);
    } else {
      Vue.prototype['$' + cptName.toLowerCase()] = methods[cptName];
    }
  }

  for (var _cptName in components) {
    if (components[_cptName] && components[_cptName].name) {
      Vue.use(components[_cptName]);
    }
  }

  for (var _cptName2 in filters) {
    if (filters[_cptName2] && filters[_cptName2].name) {
      Vue.filter(_cptName2, filters[_cptName2]);
    }
  }

  for (var _cptName3 in directives) {
    if (directives[_cptName3] && directives[_cptName3].name) {
      Vue.directive(directives[_cptName3].name, directives[_cptName3]);
    }
  }

  Vue.use(packages_lazyload, {
    lazyComponent: true,
    loading: '//img12.360buyimg.com/imagetools/jfs/t1/73967/28/14561/916/5dc142e4E0666555b/bf33454553c6035e.png'
  });
};

if (typeof window !== 'undefined' && window.Vue) {
  minixui_install(window.Vue);
}

/* harmony default export */ var minixui = __webpack_exports__["default"] = (minixui_objectSpread(minixui_objectSpread(minixui_objectSpread(minixui_objectSpread({
  version: package_0["a" /* version */],
  locale: locale,
  install: minixui_install,
  Lazyload: packages_lazyload
}, components), filters), directives), methods));

/***/ })
/******/ ]);
});
//# sourceMappingURL=minixui.js.map