/*!
*
* ant-design-pro v2.3.1
*
* Copyright 2015-present, Alipay, Inc.
* All rights reserved.
*
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["ant-design-pro"] = factory(require("react"), require("react-dom"));
else
root["ant-design-pro"] = factory(root["React"], root["ReactDOM"]);
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_8__) {
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, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 449);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (process.env.NODE_ENV !== 'production') {
var ReactIs = __webpack_require__(116);
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = __webpack_require__(463)(ReactIs.isElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(465)();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
(function () {
'use strict';
var hasOwn = {}.hasOwnProperty;
function classNames () {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg) && arg.length) {
var inner = classNames.apply(null, arg);
if (inner) {
classes.push(inner);
}
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
if (typeof module !== 'undefined' && module.exports) {
classNames.default = classNames;
module.exports = classNames;
} else if (true) {
// register as 'classnames', consistent with npm package name
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return classNames;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {
window.classNames = classNames;
}
}());
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof2 = __webpack_require__(66);
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self;
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _setPrototypeOf = __webpack_require__(501);
var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);
var _create = __webpack_require__(505);
var _create2 = _interopRequireDefault(_create);
var _typeof2 = __webpack_require__(66);
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass)));
}
subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
};
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return configConsumerProps; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ConfigConsumer; });
/* harmony export (immutable) */ __webpack_exports__["c"] = withConfigConsumer;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_create_react_context__ = __webpack_require__(93);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_create_react_context___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_create_react_context__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__renderEmpty__ = __webpack_require__(467);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var configConsumerProps = ['getPopupContainer', 'rootPrefixCls', 'getPrefixCls', 'renderEmpty', 'csp', 'autoInsertSpaceInButton'];
var ConfigContext = __WEBPACK_IMPORTED_MODULE_1_create_react_context___default()({
// We provide a default function for Context without provider
getPrefixCls: function getPrefixCls(suffixCls, customizePrefixCls) {
if (customizePrefixCls) return customizePrefixCls;
return "ant-".concat(suffixCls);
},
renderEmpty: __WEBPACK_IMPORTED_MODULE_2__renderEmpty__["a" /* default */]
});
var ConfigConsumer = ConfigContext.Consumer;
var ConfigProvider =
/*#__PURE__*/
function (_React$Component) {
_inherits(ConfigProvider, _React$Component);
function ConfigProvider() {
var _this;
_classCallCheck(this, ConfigProvider);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ConfigProvider).apply(this, arguments));
_this.getPrefixCls = function (suffixCls, customizePrefixCls) {
var _this$props$prefixCls = _this.props.prefixCls,
prefixCls = _this$props$prefixCls === void 0 ? 'ant' : _this$props$prefixCls;
if (customizePrefixCls) return customizePrefixCls;
return suffixCls ? "".concat(prefixCls, "-").concat(suffixCls) : prefixCls;
};
_this.renderProvider = function (context) {
var _this$props = _this.props,
children = _this$props.children,
getPopupContainer = _this$props.getPopupContainer,
renderEmpty = _this$props.renderEmpty,
csp = _this$props.csp,
autoInsertSpaceInButton = _this$props.autoInsertSpaceInButton;
var config = _extends({}, context, {
getPrefixCls: _this.getPrefixCls,
csp: csp,
autoInsertSpaceInButton: autoInsertSpaceInButton
});
if (getPopupContainer) {
config.getPopupContainer = getPopupContainer;
}
if (renderEmpty) {
config.renderEmpty = renderEmpty;
}
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](ConfigContext.Provider, {
value: config
}, children);
};
return _this;
}
_createClass(ConfigProvider, [{
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](ConfigConsumer, null, this.renderProvider);
}
}]);
return ConfigProvider;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
function withConfigConsumer(config) {
return function (Component) {
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
var SFC = function SFC(props) {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](ConfigConsumer, null, function (configProps) {
var basicPrefixCls = config.prefixCls;
var getPrefixCls = configProps.getPrefixCls;
var customizePrefixCls = props.prefixCls;
var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](Component, _extends({}, configProps, props, {
prefixCls: prefixCls
}));
});
};
var cons = Component.constructor;
var name = cons && cons.displayName || Component.name || 'Component';
SFC.displayName = "withConfigConsumer(".concat(name, ")");
return SFC;
};
}
/* unused harmony default export */ var _unused_webpack_default_export = (ConfigProvider);
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _assign = __webpack_require__(453);
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _assign2.default || 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;
};
/***/ }),
/* 8 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
/***/ }),
/* 9 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "polyfill", function() { return polyfill; });
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function componentWillMount() {
// Call this.constructor.gDSFP to support sub-classes.
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
if (state !== null && state !== undefined) {
this.setState(state);
}
}
function componentWillReceiveProps(nextProps) {
// Call this.constructor.gDSFP to support sub-classes.
// Use the setState() updater to ensure state isn't stale in certain edge cases.
function updater(prevState) {
var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
return state !== null && state !== undefined ? state : null;
}
// Binding "this" is important for shallow renderer support.
this.setState(updater.bind(this));
}
function componentWillUpdate(nextProps, nextState) {
try {
var prevProps = this.props;
var prevState = this.state;
this.props = nextProps;
this.state = nextState;
this.__reactInternalSnapshotFlag = true;
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(
prevProps,
prevState
);
} finally {
this.props = prevProps;
this.state = prevState;
}
}
// React may warn about cWM/cWRP/cWU methods being deprecated.
// Add a flag to suppress these warnings for this special case.
componentWillMount.__suppressDeprecationWarning = true;
componentWillReceiveProps.__suppressDeprecationWarning = true;
componentWillUpdate.__suppressDeprecationWarning = true;
function polyfill(Component) {
var prototype = Component.prototype;
if (!prototype || !prototype.isReactComponent) {
throw new Error('Can only polyfill class components');
}
if (
typeof Component.getDerivedStateFromProps !== 'function' &&
typeof prototype.getSnapshotBeforeUpdate !== 'function'
) {
return Component;
}
// If new component APIs are defined, "unsafe" lifecycles won't be called.
// Error if any of these lifecycles are present,
// Because they would work differently between older and newer (16.3+) versions of React.
var foundWillMountName = null;
var foundWillReceivePropsName = null;
var foundWillUpdateName = null;
if (typeof prototype.componentWillMount === 'function') {
foundWillMountName = 'componentWillMount';
} else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
foundWillMountName = 'UNSAFE_componentWillMount';
}
if (typeof prototype.componentWillReceiveProps === 'function') {
foundWillReceivePropsName = 'componentWillReceiveProps';
} else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
}
if (typeof prototype.componentWillUpdate === 'function') {
foundWillUpdateName = 'componentWillUpdate';
} else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
foundWillUpdateName = 'UNSAFE_componentWillUpdate';
}
if (
foundWillMountName !== null ||
foundWillReceivePropsName !== null ||
foundWillUpdateName !== null
) {
var componentName = Component.displayName || Component.name;
var newApiName =
typeof Component.getDerivedStateFromProps === 'function'
? 'getDerivedStateFromProps()'
: 'getSnapshotBeforeUpdate()';
throw Error(
'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
componentName +
' uses ' +
newApiName +
' but also contains the following legacy lifecycles:' +
(foundWillMountName !== null ? '\n ' + foundWillMountName : '') +
(foundWillReceivePropsName !== null
? '\n ' + foundWillReceivePropsName
: '') +
(foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') +
'\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks'
);
}
// React <= 16.2 does not support static getDerivedStateFromProps.
// As a workaround, use cWM and cWRP to invoke the new static lifecycle.
// Newer versions of React will ignore these lifecycles if gDSFP exists.
if (typeof Component.getDerivedStateFromProps === 'function') {
prototype.componentWillMount = componentWillMount;
prototype.componentWillReceiveProps = componentWillReceiveProps;
}
// React <= 16.2 does not support getSnapshotBeforeUpdate.
// As a workaround, use cWU to invoke the new lifecycle.
// Newer versions of React will ignore that lifecycle if gSBU exists.
if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
if (typeof prototype.componentDidUpdate !== 'function') {
throw new Error(
'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'
);
}
prototype.componentWillUpdate = componentWillUpdate;
var componentDidUpdate = prototype.componentDidUpdate;
prototype.componentDidUpdate = function componentDidUpdatePolyfill(
prevProps,
prevState,
maybeSnapshot
) {
// 16.3+ will not execute our will-update method;
// It will pass a snapshot value to did-update though.
// Older versions will require our polyfilled will-update value.
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
// Because for <= 15.x versions this might be a "prevContext" object.
// We also can't just check "__reactInternalSnapshot",
// Because get-snapshot might return a falsy value.
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
var snapshot = this.__reactInternalSnapshotFlag
? this.__reactInternalSnapshot
: maybeSnapshot;
componentDidUpdate.call(this, prevProps, prevState, snapshot);
};
}
return Component;
}
/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ant_design_icons_lib_dist__ = __webpack_require__(538);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ant_design_icons_lib_dist___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__ant_design_icons_lib_dist__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__ant_design_icons_react__ = __webpack_require__(273);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__IconFont__ = __webpack_require__(544);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils__ = __webpack_require__(545);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_warning__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__locale_provider_LocaleReceiver__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__twoTonePrimaryColor__ = __webpack_require__(546);
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 _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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}
return t;
};
// Initial setting
__WEBPACK_IMPORTED_MODULE_3__ant_design_icons_react__["a" /* default */].add.apply(__WEBPACK_IMPORTED_MODULE_3__ant_design_icons_react__["a" /* default */], _toConsumableArray(Object.keys(__WEBPACK_IMPORTED_MODULE_2__ant_design_icons_lib_dist__).map(function (key) {
return __WEBPACK_IMPORTED_MODULE_2__ant_design_icons_lib_dist__[key];
})));
Object(__WEBPACK_IMPORTED_MODULE_8__twoTonePrimaryColor__["b" /* setTwoToneColor */])('#1890ff');
var defaultTheme = 'outlined';
var dangerousTheme = undefined;
var Icon = function Icon(props) {
var _classNames;
var className = props.className,
type = props.type,
Component = props.component,
viewBox = props.viewBox,
spin = props.spin,
rotate = props.rotate,
tabIndex = props.tabIndex,
onClick = props.onClick,
children = props.children,
theme = props.theme,
twoToneColor = props.twoToneColor,
restProps = __rest(props, ["className", "type", "component", "viewBox", "spin", "rotate", "tabIndex", "onClick", "children", "theme", "twoToneColor"]);
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(Boolean(type || Component || children), 'Icon', 'Should have `type` prop or `component` prop or `children`.');
var classString = __WEBPACK_IMPORTED_MODULE_1_classnames___default()((_classNames = {}, _defineProperty(_classNames, "anticon", true), _defineProperty(_classNames, "anticon-".concat(type), Boolean(type)), _classNames), className);
var svgClassString = __WEBPACK_IMPORTED_MODULE_1_classnames___default()(_defineProperty({}, "anticon-spin", !!spin || type === 'loading'));
var innerNode;
var svgStyle = rotate ? {
msTransform: "rotate(".concat(rotate, "deg)"),
transform: "rotate(".concat(rotate, "deg)")
} : undefined;
var innerSvgProps = _extends({}, __WEBPACK_IMPORTED_MODULE_5__utils__["d" /* svgBaseProps */], {
className: svgClassString,
style: svgStyle,
viewBox: viewBox
});
if (!viewBox) {
delete innerSvgProps.viewBox;
} // component > children > type
if (Component) {
innerNode = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](Component, innerSvgProps, children);
}
if (children) {
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(Boolean(viewBox) || __WEBPACK_IMPORTED_MODULE_0_react__["Children"].count(children) === 1 && __WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](children) && __WEBPACK_IMPORTED_MODULE_0_react__["Children"].only(children).type === 'use', 'Icon', 'Make sure that you provide correct `viewBox`' + ' prop (default `0 0 1024 1024`) to the icon.');
innerNode = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("svg", _extends({}, innerSvgProps, {
viewBox: viewBox
}), children);
}
if (typeof type === 'string') {
var computedType = type;
if (theme) {
var themeInName = Object(__WEBPACK_IMPORTED_MODULE_5__utils__["b" /* getThemeFromTypeName */])(type);
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(!themeInName || theme === themeInName, 'Icon', "The icon name '".concat(type, "' already specify a theme '").concat(themeInName, "',") + " the 'theme' prop '".concat(theme, "' will be ignored."));
}
computedType = Object(__WEBPACK_IMPORTED_MODULE_5__utils__["e" /* withThemeSuffix */])(Object(__WEBPACK_IMPORTED_MODULE_5__utils__["c" /* removeTypeTheme */])(Object(__WEBPACK_IMPORTED_MODULE_5__utils__["a" /* alias */])(computedType)), dangerousTheme || theme || defaultTheme);
innerNode = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_3__ant_design_icons_react__["a" /* default */], {
className: svgClassString,
type: computedType,
primaryColor: twoToneColor,
style: svgStyle
});
}
var iconTabIndex = tabIndex;
if (iconTabIndex === undefined && onClick) {
iconTabIndex = -1;
}
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__locale_provider_LocaleReceiver__["a" /* default */], {
componentName: "Icon"
}, function (locale) {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("i", _extends({
"aria-label": type && "".concat(locale.icon, ": ").concat(type)
}, restProps, {
tabIndex: iconTabIndex,
onClick: onClick,
className: classString
}), innerNode);
});
};
function unstable_ChangeThemeOfIconsDangerously(theme) {
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(false, 'Icon', "You are using the unstable method 'Icon.unstable_ChangeThemeOfAllIconsDangerously', " + "make sure that all the icons with theme '".concat(theme, "' display correctly."));
dangerousTheme = theme;
}
function unstable_ChangeDefaultThemeOfIcons(theme) {
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(false, 'Icon', "You are using the unstable method 'Icon.unstable_ChangeDefaultThemeOfIcons', " + "make sure that all the icons with theme '".concat(theme, "' display correctly."));
defaultTheme = theme;
}
Icon.createFromIconfontCN = __WEBPACK_IMPORTED_MODULE_4__IconFont__["a" /* default */];
Icon.getTwoToneColor = __WEBPACK_IMPORTED_MODULE_8__twoTonePrimaryColor__["a" /* getTwoToneColor */];
Icon.setTwoToneColor = __WEBPACK_IMPORTED_MODULE_8__twoTonePrimaryColor__["b" /* setTwoToneColor */];
/* harmony default export */ __webpack_exports__["a"] = (Icon);
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(254);
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = 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;
(0, _defineProperty2.default)(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var validateFormat = function validateFormat(format) {};
if (process.env.NODE_ENV !== 'production') {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
};
}
function invariant(condition, format, a, b, c, d, e, f) {
validateFormat(format);
if (!condition) {
var error;
if (format === undefined) {
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.Immutable = factory();
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step > 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
findEntry: function(predicate, context) {
var found;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findLastEntry: function(predicate, context) {
return this.toSeq().reverse().findEntry(predicate, context);
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
// Temporary warning about using length
(function () {
try {
Object.defineProperty(IterablePrototype, 'length', {
get: function () {
if (!Iterable.noLengthWarning) {
var stack;
try {
throw new Error();
} catch (error) {
stack = error.stack;
}
if (stack.indexOf('_wrapObject') === -1) {
console && console.warn && console.warn(
'iterable.length has been deprecated, '+
'use iterable.size or iterable.count(). '+
'This warning will become a silent error in a future version. ' +
stack
);
return this.size;
}
}
}
});
} catch (e) {}
})();
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLastKey: function(predicate, context) {
return this.toSeq().reverse().findKey(predicate, context);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
lastKeyOf: function(searchValue) {
return this.findLastKey(function(value ) {return is(value, searchValue)});
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.toKeyedSeq().keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.toKeyedSeq().reverse().keyOf(searchValue);
return key === undefined ? -1 : key;
// var index =
// return this.toSeq().reverse().indexOf(searchValue);
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var key = this.toKeyedSeq().findLastKey(predicate, context);
return key === undefined ? -1 : key;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : value;
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(254);
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (obj, key, value) {
if (key in obj) {
(0, _defineProperty2.default)(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule EditorState
* @format
*
*/
var _assign = __webpack_require__(27);
var _extends = _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; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var BlockTree = __webpack_require__(379);
var ContentState = __webpack_require__(210);
var EditorBidiService = __webpack_require__(911);
var Immutable = __webpack_require__(14);
var SelectionState = __webpack_require__(88);
var OrderedSet = Immutable.OrderedSet,
Record = Immutable.Record,
Stack = Immutable.Stack;
var defaultRecord = {
allowUndo: true,
currentContent: null,
decorator: null,
directionMap: null,
forceSelection: false,
inCompositionMode: false,
inlineStyleOverride: null,
lastChangeType: null,
nativelyRenderedContent: null,
redoStack: Stack(),
selection: null,
treeMap: null,
undoStack: Stack()
};
var EditorStateRecord = Record(defaultRecord);
var EditorState = function () {
EditorState.createEmpty = function createEmpty(decorator) {
return EditorState.createWithContent(ContentState.createFromText(''), decorator);
};
EditorState.createWithContent = function createWithContent(contentState, decorator) {
var firstKey = contentState.getBlockMap().first().getKey();
return EditorState.create({
currentContent: contentState,
undoStack: Stack(),
redoStack: Stack(),
decorator: decorator || null,
selection: SelectionState.createEmpty(firstKey)
});
};
EditorState.create = function create(config) {
var currentContent = config.currentContent,
decorator = config.decorator;
var recordConfig = _extends({}, config, {
treeMap: generateNewTreeMap(currentContent, decorator),
directionMap: EditorBidiService.getDirectionMap(currentContent)
});
return new EditorState(new EditorStateRecord(recordConfig));
};
EditorState.set = function set(editorState, put) {
var map = editorState.getImmutable().withMutations(function (state) {
var existingDecorator = state.get('decorator');
var decorator = existingDecorator;
if (put.decorator === null) {
decorator = null;
} else if (put.decorator) {
decorator = put.decorator;
}
var newContent = put.currentContent || editorState.getCurrentContent();
if (decorator !== existingDecorator) {
var treeMap = state.get('treeMap');
var newTreeMap;
if (decorator && existingDecorator) {
newTreeMap = regenerateTreeForNewDecorator(newContent, newContent.getBlockMap(), treeMap, decorator, existingDecorator);
} else {
newTreeMap = generateNewTreeMap(newContent, decorator);
}
state.merge({
decorator: decorator,
treeMap: newTreeMap,
nativelyRenderedContent: null
});
return;
}
var existingContent = editorState.getCurrentContent();
if (newContent !== existingContent) {
state.set('treeMap', regenerateTreeForNewBlocks(editorState, newContent.getBlockMap(), newContent.getEntityMap(), decorator));
}
state.merge(put);
});
return new EditorState(map);
};
EditorState.prototype.toJS = function toJS() {
return this.getImmutable().toJS();
};
EditorState.prototype.getAllowUndo = function getAllowUndo() {
return this.getImmutable().get('allowUndo');
};
EditorState.prototype.getCurrentContent = function getCurrentContent() {
return this.getImmutable().get('currentContent');
};
EditorState.prototype.getUndoStack = function getUndoStack() {
return this.getImmutable().get('undoStack');
};
EditorState.prototype.getRedoStack = function getRedoStack() {
return this.getImmutable().get('redoStack');
};
EditorState.prototype.getSelection = function getSelection() {
return this.getImmutable().get('selection');
};
EditorState.prototype.getDecorator = function getDecorator() {
return this.getImmutable().get('decorator');
};
EditorState.prototype.isInCompositionMode = function isInCompositionMode() {
return this.getImmutable().get('inCompositionMode');
};
EditorState.prototype.mustForceSelection = function mustForceSelection() {
return this.getImmutable().get('forceSelection');
};
EditorState.prototype.getNativelyRenderedContent = function getNativelyRenderedContent() {
return this.getImmutable().get('nativelyRenderedContent');
};
EditorState.prototype.getLastChangeType = function getLastChangeType() {
return this.getImmutable().get('lastChangeType');
};
/**
* While editing, the user may apply inline style commands with a collapsed
* cursor, intending to type text that adopts the specified style. In this
* case, we track the specified style as an "override" that takes precedence
* over the inline style of the text adjacent to the cursor.
*
* If null, there is no override in place.
*/
EditorState.prototype.getInlineStyleOverride = function getInlineStyleOverride() {
return this.getImmutable().get('inlineStyleOverride');
};
EditorState.setInlineStyleOverride = function setInlineStyleOverride(editorState, inlineStyleOverride) {
return EditorState.set(editorState, { inlineStyleOverride: inlineStyleOverride });
};
/**
* Get the appropriate inline style for the editor state. If an
* override is in place, use it. Otherwise, the current style is
* based on the location of the selection state.
*/
EditorState.prototype.getCurrentInlineStyle = function getCurrentInlineStyle() {
var override = this.getInlineStyleOverride();
if (override != null) {
return override;
}
var content = this.getCurrentContent();
var selection = this.getSelection();
if (selection.isCollapsed()) {
return getInlineStyleForCollapsedSelection(content, selection);
}
return getInlineStyleForNonCollapsedSelection(content, selection);
};
EditorState.prototype.getBlockTree = function getBlockTree(blockKey) {
return this.getImmutable().getIn(['treeMap', blockKey]);
};
EditorState.prototype.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
var firstKey = this.getCurrentContent().getBlockMap().first().getKey();
return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
};
EditorState.prototype.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
var content = this.getCurrentContent();
var blockMap = content.getBlockMap();
var last = blockMap.last();
var end = last.getLength();
return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
};
EditorState.prototype.getDirectionMap = function getDirectionMap() {
return this.getImmutable().get('directionMap');
};
/**
* Incorporate native DOM selection changes into the EditorState. This
* method can be used when we simply want to accept whatever the DOM
* has given us to represent selection, and we do not need to re-render
* the editor.
*
* To forcibly move the DOM selection, see `EditorState.forceSelection`.
*/
EditorState.acceptSelection = function acceptSelection(editorState, selection) {
return updateSelection(editorState, selection, false);
};
/**
* At times, we need to force the DOM selection to be where we
* need it to be. This can occur when the anchor or focus nodes
* are non-text nodes, for instance. In this case, we want to trigger
* a re-render of the editor, which in turn forces selection into
* the correct place in the DOM. The `forceSelection` method
* accomplishes this.
*
* This method should be used in cases where you need to explicitly
* move the DOM selection from one place to another without a change
* in ContentState.
*/
EditorState.forceSelection = function forceSelection(editorState, selection) {
if (!selection.getHasFocus()) {
selection = selection.set('hasFocus', true);
}
return updateSelection(editorState, selection, true);
};
/**
* Move selection to the end of the editor without forcing focus.
*/
EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
var content = editorState.getCurrentContent();
var lastBlock = content.getLastBlock();
var lastKey = lastBlock.getKey();
var length = lastBlock.getLength();
return EditorState.acceptSelection(editorState, new SelectionState({
anchorKey: lastKey,
anchorOffset: length,
focusKey: lastKey,
focusOffset: length,
isBackward: false
}));
};
/**
* Force focus to the end of the editor. This is useful in scenarios
* where we want to programmatically focus the input and it makes sense
* to allow the user to continue working seamlessly.
*/
EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
return EditorState.forceSelection(afterSelectionMove, afterSelectionMove.getSelection());
};
/**
* Push the current ContentState onto the undo stack if it should be
* considered a boundary state, and set the provided ContentState as the
* new current content.
*/
EditorState.push = function push(editorState, contentState, changeType) {
if (editorState.getCurrentContent() === contentState) {
return editorState;
}
var forceSelection = changeType !== 'insert-characters';
var directionMap = EditorBidiService.getDirectionMap(contentState, editorState.getDirectionMap());
if (!editorState.getAllowUndo()) {
return EditorState.set(editorState, {
currentContent: contentState,
directionMap: directionMap,
lastChangeType: changeType,
selection: contentState.getSelectionAfter(),
forceSelection: forceSelection,
inlineStyleOverride: null
});
}
var selection = editorState.getSelection();
var currentContent = editorState.getCurrentContent();
var undoStack = editorState.getUndoStack();
var newContent = contentState;
if (selection !== currentContent.getSelectionAfter() || mustBecomeBoundary(editorState, changeType)) {
undoStack = undoStack.push(currentContent);
newContent = newContent.set('selectionBefore', selection);
} else if (changeType === 'insert-characters' || changeType === 'backspace-character' || changeType === 'delete-character') {
// Preserve the previous selection.
newContent = newContent.set('selectionBefore', currentContent.getSelectionBefore());
}
var inlineStyleOverride = editorState.getInlineStyleOverride();
// Don't discard inline style overrides for the following change types:
var overrideChangeTypes = ['adjust-depth', 'change-block-type', 'split-block'];
if (overrideChangeTypes.indexOf(changeType) === -1) {
inlineStyleOverride = null;
}
var editorStateChanges = {
currentContent: newContent,
directionMap: directionMap,
undoStack: undoStack,
redoStack: Stack(),
lastChangeType: changeType,
selection: contentState.getSelectionAfter(),
forceSelection: forceSelection,
inlineStyleOverride: inlineStyleOverride
};
return EditorState.set(editorState, editorStateChanges);
};
/**
* Make the top ContentState in the undo stack the new current content and
* push the current content onto the redo stack.
*/
EditorState.undo = function undo(editorState) {
if (!editorState.getAllowUndo()) {
return editorState;
}
var undoStack = editorState.getUndoStack();
var newCurrentContent = undoStack.peek();
if (!newCurrentContent) {
return editorState;
}
var currentContent = editorState.getCurrentContent();
var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
return EditorState.set(editorState, {
currentContent: newCurrentContent,
directionMap: directionMap,
undoStack: undoStack.shift(),
redoStack: editorState.getRedoStack().push(currentContent),
forceSelection: true,
inlineStyleOverride: null,
lastChangeType: 'undo',
nativelyRenderedContent: null,
selection: currentContent.getSelectionBefore()
});
};
/**
* Make the top ContentState in the redo stack the new current content and
* push the current content onto the undo stack.
*/
EditorState.redo = function redo(editorState) {
if (!editorState.getAllowUndo()) {
return editorState;
}
var redoStack = editorState.getRedoStack();
var newCurrentContent = redoStack.peek();
if (!newCurrentContent) {
return editorState;
}
var currentContent = editorState.getCurrentContent();
var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
return EditorState.set(editorState, {
currentContent: newCurrentContent,
directionMap: directionMap,
undoStack: editorState.getUndoStack().push(currentContent),
redoStack: redoStack.shift(),
forceSelection: true,
inlineStyleOverride: null,
lastChangeType: 'redo',
nativelyRenderedContent: null,
selection: newCurrentContent.getSelectionAfter()
});
};
/**
* Not for public consumption.
*/
function EditorState(immutable) {
_classCallCheck(this, EditorState);
this._immutable = immutable;
}
/**
* Not for public consumption.
*/
EditorState.prototype.getImmutable = function getImmutable() {
return this._immutable;
};
return EditorState;
}();
/**
* Set the supplied SelectionState as the new current selection, and set
* the `force` flag to trigger manual selection placement by the view.
*/
function updateSelection(editorState, selection, forceSelection) {
return EditorState.set(editorState, {
selection: selection,
forceSelection: forceSelection,
nativelyRenderedContent: null,
inlineStyleOverride: null
});
}
/**
* Regenerate the entire tree map for a given ContentState and decorator.
* Returns an OrderedMap that maps all available ContentBlock objects.
*/
function generateNewTreeMap(contentState, decorator) {
return contentState.getBlockMap().map(function (block) {
return BlockTree.generate(contentState, block, decorator);
}).toOrderedMap();
}
/**
* Regenerate tree map objects for all ContentBlocks that have changed
* between the current editorState and newContent. Returns an OrderedMap
* with only changed regenerated tree map objects.
*/
function regenerateTreeForNewBlocks(editorState, newBlockMap, newEntityMap, decorator) {
var contentState = editorState.getCurrentContent().set('entityMap', newEntityMap);
var prevBlockMap = contentState.getBlockMap();
var prevTreeMap = editorState.getImmutable().get('treeMap');
return prevTreeMap.merge(newBlockMap.toSeq().filter(function (block, key) {
return block !== prevBlockMap.get(key);
}).map(function (block) {
return BlockTree.generate(contentState, block, decorator);
}));
}
/**
* Generate tree map objects for a new decorator object, preserving any
* decorations that are unchanged from the previous decorator.
*
* Note that in order for this to perform optimally, decoration Lists for
* decorators should be preserved when possible to allow for direct immutable
* List comparison.
*/
function regenerateTreeForNewDecorator(content, blockMap, previousTreeMap, decorator, existingDecorator) {
return previousTreeMap.merge(blockMap.toSeq().filter(function (block) {
return decorator.getDecorations(block, content) !== existingDecorator.getDecorations(block, content);
}).map(function (block) {
return BlockTree.generate(content, block, decorator);
}));
}
/**
* Return whether a change should be considered a boundary state, given
* the previous change type. Allows us to discard potential boundary states
* during standard typing or deletion behavior.
*/
function mustBecomeBoundary(editorState, changeType) {
var lastChangeType = editorState.getLastChangeType();
return changeType !== lastChangeType || changeType !== 'insert-characters' && changeType !== 'backspace-character' && changeType !== 'delete-character';
}
function getInlineStyleForCollapsedSelection(content, selection) {
var startKey = selection.getStartKey();
var startOffset = selection.getStartOffset();
var startBlock = content.getBlockForKey(startKey);
// If the cursor is not at the start of the block, look backward to
// preserve the style of the preceding character.
if (startOffset > 0) {
return startBlock.getInlineStyleAt(startOffset - 1);
}
// The caret is at position zero in this block. If the block has any
// text at all, use the style of the first character.
if (startBlock.getLength()) {
return startBlock.getInlineStyleAt(0);
}
// Otherwise, look upward in the document to find the closest character.
return lookUpwardForInlineStyle(content, startKey);
}
function getInlineStyleForNonCollapsedSelection(content, selection) {
var startKey = selection.getStartKey();
var startOffset = selection.getStartOffset();
var startBlock = content.getBlockForKey(startKey);
// If there is a character just inside the selection, use its style.
if (startOffset < startBlock.getLength()) {
return startBlock.getInlineStyleAt(startOffset);
}
// Check if the selection at the end of a non-empty block. Use the last
// style in the block.
if (startOffset > 0) {
return startBlock.getInlineStyleAt(startOffset - 1);
}
// Otherwise, look upward in the document to find the closest character.
return lookUpwardForInlineStyle(content, startKey);
}
function lookUpwardForInlineStyle(content, fromKey) {
var lastNonEmpty = content.getBlockMap().reverse().skipUntil(function (_, k) {
return k === fromKey;
}).skip(1).skipUntil(function (block, _) {
return block.getLength();
}).first();
if (lastNonEmpty) return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
return OrderedSet();
}
module.exports = EditorState;
/***/ }),
/* 18 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__affix__ = __webpack_require__(238);
/* unused harmony reexport Affix */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__anchor__ = __webpack_require__(473);
/* unused harmony reexport Anchor */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__auto_complete__ = __webpack_require__(476);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_2__auto_complete__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__alert__ = __webpack_require__(553);
/* unused harmony reexport Alert */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__avatar__ = __webpack_require__(554);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_4__avatar__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__back_top__ = __webpack_require__(555);
/* unused harmony reexport BackTop */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__badge__ = __webpack_require__(556);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_6__badge__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__breadcrumb__ = __webpack_require__(278);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_7__breadcrumb__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__button__ = __webpack_require__(69);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_8__button__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__calendar__ = __webpack_require__(559);
/* unused harmony reexport Calendar */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__card__ = __webpack_require__(573);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return __WEBPACK_IMPORTED_MODULE_10__card__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__collapse__ = __webpack_require__(592);
/* unused harmony reexport Collapse */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__carousel__ = __webpack_require__(599);
/* unused harmony reexport Carousel */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__cascader__ = __webpack_require__(610);
/* unused harmony reexport Cascader */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__checkbox__ = __webpack_require__(85);
/* unused harmony reexport Checkbox */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__col__ = __webpack_require__(296);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return __WEBPACK_IMPORTED_MODULE_15__col__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__comment__ = __webpack_require__(616);
/* unused harmony reexport Comment */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__config_provider__ = __webpack_require__(6);
/* unused harmony reexport ConfigProvider */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__date_picker__ = __webpack_require__(617);
/* unused harmony reexport DatePicker */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__divider__ = __webpack_require__(313);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return __WEBPACK_IMPORTED_MODULE_19__divider__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__dropdown__ = __webpack_require__(179);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return __WEBPACK_IMPORTED_MODULE_20__dropdown__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__drawer__ = __webpack_require__(639);
/* unused harmony reexport Drawer */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__empty__ = __webpack_require__(244);
/* unused harmony reexport Empty */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__form__ = __webpack_require__(643);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return __WEBPACK_IMPORTED_MODULE_23__form__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__icon__ = __webpack_require__(11);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return __WEBPACK_IMPORTED_MODULE_24__icon__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__input__ = __webpack_require__(122);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return __WEBPACK_IMPORTED_MODULE_25__input__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__input_number__ = __webpack_require__(710);
/* unused harmony reexport InputNumber */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__layout__ = __webpack_require__(716);
/* unused harmony reexport Layout */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__list__ = __webpack_require__(720);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return __WEBPACK_IMPORTED_MODULE_28__list__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__locale_provider__ = __webpack_require__(729);
/* unused harmony reexport LocaleProvider */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__message__ = __webpack_require__(730);
/* unused harmony reexport message */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__menu__ = __webpack_require__(332);
/* unused harmony reexport Menu */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__modal__ = __webpack_require__(739);
/* unused harmony reexport Modal */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__statistic__ = __webpack_require__(745);
/* unused harmony reexport Statistic */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__notification__ = __webpack_require__(759);
/* unused harmony reexport notification */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_35__page_header__ = __webpack_require__(760);
/* unused harmony reexport PageHeader */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__pagination__ = __webpack_require__(192);
/* unused harmony reexport Pagination */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__popconfirm__ = __webpack_require__(761);
/* unused harmony reexport Popconfirm */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__popover__ = __webpack_require__(762);
/* unused harmony reexport Popover */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__progress__ = __webpack_require__(339);
/* unused harmony reexport Progress */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__radio__ = __webpack_require__(125);
/* unused harmony reexport Radio */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__rate__ = __webpack_require__(769);
/* unused harmony reexport Rate */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__row__ = __webpack_require__(290);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return __WEBPACK_IMPORTED_MODULE_42__row__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__select__ = __webpack_require__(96);
/* unused harmony reexport Select */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__skeleton__ = __webpack_require__(774);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return __WEBPACK_IMPORTED_MODULE_44__skeleton__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__slider__ = __webpack_require__(778);
/* unused harmony reexport Slider */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__spin__ = __webpack_require__(191);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return __WEBPACK_IMPORTED_MODULE_46__spin__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_47__steps__ = __webpack_require__(790);
/* unused harmony reexport Steps */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__switch__ = __webpack_require__(795);
/* unused harmony reexport Switch */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_49__table__ = __webpack_require__(798);
/* unused harmony reexport Table */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__transfer__ = __webpack_require__(850);
/* unused harmony reexport Transfer */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__tree__ = __webpack_require__(861);
/* unused harmony reexport Tree */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_52__tree_select__ = __webpack_require__(870);
/* unused harmony reexport TreeSelect */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__tabs__ = __webpack_require__(283);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return __WEBPACK_IMPORTED_MODULE_53__tabs__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__tag__ = __webpack_require__(312);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return __WEBPACK_IMPORTED_MODULE_54__tag__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__time_picker__ = __webpack_require__(311);
/* unused harmony reexport TimePicker */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__timeline__ = __webpack_require__(884);
/* unused harmony reexport Timeline */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__tooltip__ = __webpack_require__(59);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return __WEBPACK_IMPORTED_MODULE_57__tooltip__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__typography__ = __webpack_require__(887);
/* unused harmony reexport Typography */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__mention__ = __webpack_require__(896);
/* unused harmony reexport Mention */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__upload__ = __webpack_require__(1014);
/* unused harmony reexport Upload */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_61__version__ = __webpack_require__(1052);
/* unused harmony reexport version */
/***/ }),
/* 19 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_warning__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_warning__);
var warned = {};
/* harmony default export */ __webpack_exports__["a"] = (function (valid, component, message) {
if (!valid && !warned[message]) {
__WEBPACK_IMPORTED_MODULE_0_warning___default()(false, "[antd: ".concat(component, "] ").concat(message));
warned[message] = true;
}
});
/***/ }),
/* 20 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
function omit(obj, fields) {
var shallowCopy = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, obj);
for (var i = 0; i < fields.length; i++) {
var key = fields[i];
delete shallowCopy[key];
}
return shallowCopy;
}
/* harmony default export */ __webpack_exports__["a"] = (omit);
/***/ }),
/* 21 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return warning; });
/* harmony export (immutable) */ __webpack_exports__["d"] = format;
/* harmony export (immutable) */ __webpack_exports__["e"] = isEmptyValue;
/* unused harmony export isEmptyObject */
/* harmony export (immutable) */ __webpack_exports__["a"] = asyncMap;
/* harmony export (immutable) */ __webpack_exports__["b"] = complementError;
/* harmony export (immutable) */ __webpack_exports__["c"] = deepMerge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_typeof__ = __webpack_require__(66);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_typeof__);
var formatRegExp = /%[sdj%]/g;
var warning = function warning() {};
// don't print warning message when in production env or node runtime
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
warning = function warning(type, errors) {
if (typeof console !== 'undefined' && console.warn) {
if (errors.every(function (e) {
return typeof e === 'string';
})) {
console.warn(type, errors);
}
}
};
}
function format() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var i = 1;
var f = args[0];
var len = args.length;
if (typeof f === 'function') {
return f.apply(null, args.slice(1));
}
if (typeof f === 'string') {
var str = String(f).replace(formatRegExp, function (x) {
if (x === '%%') {
return '%';
}
if (i >= len) {
return x;
}
switch (x) {
case '%s':
return String(args[i++]);
case '%d':
return Number(args[i++]);
case '%j':
try {
return JSON.stringify(args[i++]);
} catch (_) {
return '[Circular]';
}
break;
default:
return x;
}
});
for (var arg = args[i]; i < len; arg = args[++i]) {
str += ' ' + arg;
}
return str;
}
return f;
}
function isNativeStringType(type) {
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
}
function isEmptyValue(value, type) {
if (value === undefined || value === null) {
return true;
}
if (type === 'array' && Array.isArray(value) && !value.length) {
return true;
}
if (isNativeStringType(type) && typeof value === 'string' && !value) {
return true;
}
return false;
}
function isEmptyObject(obj) {
return Object.keys(obj).length === 0;
}
function asyncParallelArray(arr, func, callback) {
var results = [];
var total = 0;
var arrLength = arr.length;
function count(errors) {
results.push.apply(results, errors);
total++;
if (total === arrLength) {
callback(results);
}
}
arr.forEach(function (a) {
func(a, count);
});
}
function asyncSerialArray(arr, func, callback) {
var index = 0;
var arrLength = arr.length;
function next(errors) {
if (errors && errors.length) {
callback(errors);
return;
}
var original = index;
index = index + 1;
if (original < arrLength) {
func(arr[original], next);
} else {
callback([]);
}
}
next([]);
}
function flattenObjArr(objArr) {
var ret = [];
Object.keys(objArr).forEach(function (k) {
ret.push.apply(ret, objArr[k]);
});
return ret;
}
function asyncMap(objArr, option, func, callback) {
if (option.first) {
var flattenArr = flattenObjArr(objArr);
return asyncSerialArray(flattenArr, func, callback);
}
var firstFields = option.firstFields || [];
if (firstFields === true) {
firstFields = Object.keys(objArr);
}
var objArrKeys = Object.keys(objArr);
var objArrLength = objArrKeys.length;
var total = 0;
var results = [];
var next = function next(errors) {
results.push.apply(results, errors);
total++;
if (total === objArrLength) {
callback(results);
}
};
objArrKeys.forEach(function (key) {
var arr = objArr[key];
if (firstFields.indexOf(key) !== -1) {
asyncSerialArray(arr, func, next);
} else {
asyncParallelArray(arr, func, next);
}
});
}
function complementError(rule) {
return function (oe) {
if (oe && oe.message) {
oe.field = oe.field || rule.fullField;
return oe;
}
return {
message: oe,
field: oe.field || rule.fullField
};
};
}
function deepMerge(target, source) {
if (source) {
for (var s in source) {
if (source.hasOwnProperty(s)) {
var value = source[s];
if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_typeof___default()(value)) === 'object' && __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_typeof___default()(target[s]) === 'object') {
target[s] = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, target[s], value);
} else {
target[s] = value;
}
}
}
}
return target;
}
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9)))
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var __DEV__ = process.env.NODE_ENV !== 'production';
var warning = function() {};
if (__DEV__) {
var printWarning = function printWarning(format, args) {
var len = arguments.length;
args = new Array(len > 1 ? len - 1 : 0);
for (var key = 1; key < len; key++) {
args[key - 1] = arguments[key];
}
var argIndex = 0;
var message = 'Warning: ' +
format.replace(/%s/g, function() {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
}
warning = function(condition, format, args) {
var len = arguments.length;
args = new Array(len > 2 ? len - 2 : 0);
for (var key = 2; key < len; key++) {
args[key - 2] = arguments[key];
}
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
'message argument'
);
}
if (!condition) {
printWarning.apply(null, [format].concat(args));
}
};
}
module.exports = warning;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 23 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/**
* @ignore
* some key-codes definition and utils from closure-library
* @author yiminghe@gmail.com
*/
var KeyCode = {
/**
* MAC_ENTER
*/
MAC_ENTER: 3,
/**
* BACKSPACE
*/
BACKSPACE: 8,
/**
* TAB
*/
TAB: 9,
/**
* NUMLOCK on FF/Safari Mac
*/
NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac
/**
* ENTER
*/
ENTER: 13,
/**
* SHIFT
*/
SHIFT: 16,
/**
* CTRL
*/
CTRL: 17,
/**
* ALT
*/
ALT: 18,
/**
* PAUSE
*/
PAUSE: 19,
/**
* CAPS_LOCK
*/
CAPS_LOCK: 20,
/**
* ESC
*/
ESC: 27,
/**
* SPACE
*/
SPACE: 32,
/**
* PAGE_UP
*/
PAGE_UP: 33, // also NUM_NORTH_EAST
/**
* PAGE_DOWN
*/
PAGE_DOWN: 34, // also NUM_SOUTH_EAST
/**
* END
*/
END: 35, // also NUM_SOUTH_WEST
/**
* HOME
*/
HOME: 36, // also NUM_NORTH_WEST
/**
* LEFT
*/
LEFT: 37, // also NUM_WEST
/**
* UP
*/
UP: 38, // also NUM_NORTH
/**
* RIGHT
*/
RIGHT: 39, // also NUM_EAST
/**
* DOWN
*/
DOWN: 40, // also NUM_SOUTH
/**
* PRINT_SCREEN
*/
PRINT_SCREEN: 44,
/**
* INSERT
*/
INSERT: 45, // also NUM_INSERT
/**
* DELETE
*/
DELETE: 46, // also NUM_DELETE
/**
* ZERO
*/
ZERO: 48,
/**
* ONE
*/
ONE: 49,
/**
* TWO
*/
TWO: 50,
/**
* THREE
*/
THREE: 51,
/**
* FOUR
*/
FOUR: 52,
/**
* FIVE
*/
FIVE: 53,
/**
* SIX
*/
SIX: 54,
/**
* SEVEN
*/
SEVEN: 55,
/**
* EIGHT
*/
EIGHT: 56,
/**
* NINE
*/
NINE: 57,
/**
* QUESTION_MARK
*/
QUESTION_MARK: 63, // needs localization
/**
* A
*/
A: 65,
/**
* B
*/
B: 66,
/**
* C
*/
C: 67,
/**
* D
*/
D: 68,
/**
* E
*/
E: 69,
/**
* F
*/
F: 70,
/**
* G
*/
G: 71,
/**
* H
*/
H: 72,
/**
* I
*/
I: 73,
/**
* J
*/
J: 74,
/**
* K
*/
K: 75,
/**
* L
*/
L: 76,
/**
* M
*/
M: 77,
/**
* N
*/
N: 78,
/**
* O
*/
O: 79,
/**
* P
*/
P: 80,
/**
* Q
*/
Q: 81,
/**
* R
*/
R: 82,
/**
* S
*/
S: 83,
/**
* T
*/
T: 84,
/**
* U
*/
U: 85,
/**
* V
*/
V: 86,
/**
* W
*/
W: 87,
/**
* X
*/
X: 88,
/**
* Y
*/
Y: 89,
/**
* Z
*/
Z: 90,
/**
* META
*/
META: 91, // WIN_KEY_LEFT
/**
* WIN_KEY_RIGHT
*/
WIN_KEY_RIGHT: 92,
/**
* CONTEXT_MENU
*/
CONTEXT_MENU: 93,
/**
* NUM_ZERO
*/
NUM_ZERO: 96,
/**
* NUM_ONE
*/
NUM_ONE: 97,
/**
* NUM_TWO
*/
NUM_TWO: 98,
/**
* NUM_THREE
*/
NUM_THREE: 99,
/**
* NUM_FOUR
*/
NUM_FOUR: 100,
/**
* NUM_FIVE
*/
NUM_FIVE: 101,
/**
* NUM_SIX
*/
NUM_SIX: 102,
/**
* NUM_SEVEN
*/
NUM_SEVEN: 103,
/**
* NUM_EIGHT
*/
NUM_EIGHT: 104,
/**
* NUM_NINE
*/
NUM_NINE: 105,
/**
* NUM_MULTIPLY
*/
NUM_MULTIPLY: 106,
/**
* NUM_PLUS
*/
NUM_PLUS: 107,
/**
* NUM_MINUS
*/
NUM_MINUS: 109,
/**
* NUM_PERIOD
*/
NUM_PERIOD: 110,
/**
* NUM_DIVISION
*/
NUM_DIVISION: 111,
/**
* F1
*/
F1: 112,
/**
* F2
*/
F2: 113,
/**
* F3
*/
F3: 114,
/**
* F4
*/
F4: 115,
/**
* F5
*/
F5: 116,
/**
* F6
*/
F6: 117,
/**
* F7
*/
F7: 118,
/**
* F8
*/
F8: 119,
/**
* F9
*/
F9: 120,
/**
* F10
*/
F10: 121,
/**
* F11
*/
F11: 122,
/**
* F12
*/
F12: 123,
/**
* NUMLOCK
*/
NUMLOCK: 144,
/**
* SEMICOLON
*/
SEMICOLON: 186, // needs localization
/**
* DASH
*/
DASH: 189, // needs localization
/**
* EQUALS
*/
EQUALS: 187, // needs localization
/**
* COMMA
*/
COMMA: 188, // needs localization
/**
* PERIOD
*/
PERIOD: 190, // needs localization
/**
* SLASH
*/
SLASH: 191, // needs localization
/**
* APOSTROPHE
*/
APOSTROPHE: 192, // needs localization
/**
* SINGLE_QUOTE
*/
SINGLE_QUOTE: 222, // needs localization
/**
* OPEN_SQUARE_BRACKET
*/
OPEN_SQUARE_BRACKET: 219, // needs localization
/**
* BACKSLASH
*/
BACKSLASH: 220, // needs localization
/**
* CLOSE_SQUARE_BRACKET
*/
CLOSE_SQUARE_BRACKET: 221, // needs localization
/**
* WIN_KEY
*/
WIN_KEY: 224,
/**
* MAC_FF_META
*/
MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91
/**
* WIN_IME
*/
WIN_IME: 229
};
/*
whether text and modified key is entered at the same time.
*/
KeyCode.isTextModifyingKeyEvent = function isTextModifyingKeyEvent(e) {
var keyCode = e.keyCode;
if (e.altKey && !e.ctrlKey || e.metaKey ||
// Function keys don't generate text
keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
return false;
}
// The following keys are quite harmless, even in combination with
// CTRL, ALT or SHIFT.
switch (keyCode) {
case KeyCode.ALT:
case KeyCode.CAPS_LOCK:
case KeyCode.CONTEXT_MENU:
case KeyCode.CTRL:
case KeyCode.DOWN:
case KeyCode.END:
case KeyCode.ESC:
case KeyCode.HOME:
case KeyCode.INSERT:
case KeyCode.LEFT:
case KeyCode.MAC_FF_META:
case KeyCode.META:
case KeyCode.NUMLOCK:
case KeyCode.NUM_CENTER:
case KeyCode.PAGE_DOWN:
case KeyCode.PAGE_UP:
case KeyCode.PAUSE:
case KeyCode.PRINT_SCREEN:
case KeyCode.RIGHT:
case KeyCode.SHIFT:
case KeyCode.UP:
case KeyCode.WIN_KEY:
case KeyCode.WIN_KEY_RIGHT:
return false;
default:
return true;
}
};
/*
whether character is entered.
*/
KeyCode.isCharacterKey = function isCharacterKey(keyCode) {
if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
return true;
}
if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
return true;
}
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
return true;
}
// Safari sends zero key code for non-latin characters.
if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
return true;
}
switch (keyCode) {
case KeyCode.SPACE:
case KeyCode.QUESTION_MARK:
case KeyCode.NUM_PLUS:
case KeyCode.NUM_MINUS:
case KeyCode.NUM_PERIOD:
case KeyCode.NUM_DIVISION:
case KeyCode.SEMICOLON:
case KeyCode.DASH:
case KeyCode.EQUALS:
case KeyCode.COMMA:
case KeyCode.PERIOD:
case KeyCode.SLASH:
case KeyCode.APOSTROPHE:
case KeyCode.SINGLE_QUOTE:
case KeyCode.OPEN_SQUARE_BRACKET:
case KeyCode.BACKSLASH:
case KeyCode.CLOSE_SQUARE_BRACKET:
return true;
default:
return false;
}
};
/* harmony default export */ __webpack_exports__["a"] = (KeyCode);
/***/ }),
/* 24 */
/***/ (function(module, exports) {
//! moment.js
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.moment = factory()
}(this, (function () { 'use strict';
var hookCallback;
function hooks () {
return hookCallback.apply(null, arguments);
}
// This is done to register the method called with moment()
// without creating circular dependencies.
function setHookCallback (callback) {
hookCallback = callback;
}
function isArray(input) {
return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}
function isObject(input) {
// IE8 will treat undefined and null as object if it wasn't for
// input != null
return input != null && Object.prototype.toString.call(input) === '[object Object]';
}
function isObjectEmpty(obj) {
if (Object.getOwnPropertyNames) {
return (Object.getOwnPropertyNames(obj).length === 0);
} else {
var k;
for (k in obj) {
if (obj.hasOwnProperty(k)) {
return false;
}
}
return true;
}
}
function isUndefined(input) {
return input === void 0;
}
function isNumber(input) {
return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
}
function isDate(input) {
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
}
function map(arr, fn) {
var res = [], i;
for (i = 0; i < arr.length; ++i) {
res.push(fn(arr[i], i));
}
return res;
}
function hasOwnProp(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
function extend(a, b) {
for (var i in b) {
if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
if (hasOwnProp(b, 'toString')) {
a.toString = b.toString;
}
if (hasOwnProp(b, 'valueOf')) {
a.valueOf = b.valueOf;
}
return a;
}
function createUTC (input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, true).utc();
}
function defaultParsingFlags() {
// We need to deep clone this object.
return {
empty : false,
unusedTokens : [],
unusedInput : [],
overflow : -2,
charsLeftOver : 0,
nullInput : false,
invalidMonth : null,
invalidFormat : false,
userInvalidated : false,
iso : false,
parsedDateParts : [],
meridiem : null,
rfc2822 : false,
weekdayMismatch : false
};
}
function getParsingFlags(m) {
if (m._pf == null) {
m._pf = defaultParsingFlags();
}
return m._pf;
}
var some;
if (Array.prototype.some) {
some = Array.prototype.some;
} else {
some = function (fun) {
var t = Object(this);
var len = t.length >>> 0;
for (var i = 0; i < len; i++) {
if (i in t && fun.call(this, t[i], i, t)) {
return true;
}
}
return false;
};
}
function isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m);
var parsedParts = some.call(flags.parsedDateParts, function (i) {
return i != null;
});
var isNowValid = !isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
!flags.invalidMonth &&
!flags.invalidWeekday &&
!flags.weekdayMismatch &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated &&
(!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
isNowValid = isNowValid &&
flags.charsLeftOver === 0 &&
flags.unusedTokens.length === 0 &&
flags.bigHour === undefined;
}
if (Object.isFrozen == null || !Object.isFrozen(m)) {
m._isValid = isNowValid;
}
else {
return isNowValid;
}
}
return m._isValid;
}
function createInvalid (flags) {
var m = createUTC(NaN);
if (flags != null) {
extend(getParsingFlags(m), flags);
}
else {
getParsingFlags(m).userInvalidated = true;
}
return m;
}
// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = hooks.momentProperties = [];
function copyConfig(to, from) {
var i, prop, val;
if (!isUndefined(from._isAMomentObject)) {
to._isAMomentObject = from._isAMomentObject;
}
if (!isUndefined(from._i)) {
to._i = from._i;
}
if (!isUndefined(from._f)) {
to._f = from._f;
}
if (!isUndefined(from._l)) {
to._l = from._l;
}
if (!isUndefined(from._strict)) {
to._strict = from._strict;
}
if (!isUndefined(from._tzm)) {
to._tzm = from._tzm;
}
if (!isUndefined(from._isUTC)) {
to._isUTC = from._isUTC;
}
if (!isUndefined(from._offset)) {
to._offset = from._offset;
}
if (!isUndefined(from._pf)) {
to._pf = getParsingFlags(from);
}
if (!isUndefined(from._locale)) {
to._locale = from._locale;
}
if (momentProperties.length > 0) {
for (i = 0; i < momentProperties.length; i++) {
prop = momentProperties[i];
val = from[prop];
if (!isUndefined(val)) {
to[prop] = val;
}
}
}
return to;
}
var updateInProgress = false;
// Moment prototype object
function Moment(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
if (!this.isValid()) {
this._d = new Date(NaN);
}
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
updateInProgress = true;
hooks.updateOffset(this);
updateInProgress = false;
}
}
function isMoment (obj) {
return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
}
function absFloor (number) {
if (number < 0) {
// -0 -> 0
return Math.ceil(number) || 0;
} else {
return Math.floor(number);
}
}
function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion,
value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
value = absFloor(coercedNumber);
}
return value;
}
// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length),
lengthDiff = Math.abs(array1.length - array2.length),
diffs = 0,
i;
for (i = 0; i < len; i++) {
if ((dontConvert && array1[i] !== array2[i]) ||
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
diffs++;
}
}
return diffs + lengthDiff;
}
function warn(msg) {
if (hooks.suppressDeprecationWarnings === false &&
(typeof console !== 'undefined') && console.warn) {
console.warn('Deprecation warning: ' + msg);
}
}
function deprecate(msg, fn) {
var firstTime = true;
return extend(function () {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(null, msg);
}
if (firstTime) {
var args = [];
var arg;
for (var i = 0; i < arguments.length; i++) {
arg = '';
if (typeof arguments[i] === 'object') {
arg += '\n[' + i + '] ';
for (var key in arguments[0]) {
arg += key + ': ' + arguments[0][key] + ', ';
}
arg = arg.slice(0, -2); // Remove trailing comma and space
} else {
arg = arguments[i];
}
args.push(arg);
}
warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
firstTime = false;
}
return fn.apply(this, arguments);
}, fn);
}
var deprecations = {};
function deprecateSimple(name, msg) {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(name, msg);
}
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
}
}
hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;
function isFunction(input) {
return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
}
function set (config) {
var prop, i;
for (i in config) {
prop = config[i];
if (isFunction(prop)) {
this[i] = prop;
} else {
this['_' + i] = prop;
}
}
this._config = config;
// Lenient ordinal parsing accepts just a number in addition to
// number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
// TODO: Remove "ordinalParse" fallback in next major release.
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
'|' + (/\d{1,2}/).source);
}
function mergeConfigs(parentConfig, childConfig) {
var res = extend({}, parentConfig), prop;
for (prop in childConfig) {
if (hasOwnProp(childConfig, prop)) {
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
res[prop] = {};
extend(res[prop], parentConfig[prop]);
extend(res[prop], childConfig[prop]);
} else if (childConfig[prop] != null) {
res[prop] = childConfig[prop];
} else {
delete res[prop];
}
}
}
for (prop in parentConfig) {
if (hasOwnProp(parentConfig, prop) &&
!hasOwnProp(childConfig, prop) &&
isObject(parentConfig[prop])) {
// make sure changes to properties don't modify parent config
res[prop] = extend({}, res[prop]);
}
}
return res;
}
function Locale(config) {
if (config != null) {
this.set(config);
}
}
var keys;
if (Object.keys) {
keys = Object.keys;
} else {
keys = function (obj) {
var i, res = [];
for (i in obj) {
if (hasOwnProp(obj, i)) {
res.push(i);
}
}
return res;
};
}
var defaultCalendar = {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
nextWeek : 'dddd [at] LT',
lastDay : '[Yesterday at] LT',
lastWeek : '[Last] dddd [at] LT',
sameElse : 'L'
};
function calendar (key, mom, now) {
var output = this._calendar[key] || this._calendar['sameElse'];
return isFunction(output) ? output.call(mom, now) : output;
}
var defaultLongDateFormat = {
LTS : 'h:mm:ss A',
LT : 'h:mm A',
L : 'MM/DD/YYYY',
LL : 'MMMM D, YYYY',
LLL : 'MMMM D, YYYY h:mm A',
LLLL : 'dddd, MMMM D, YYYY h:mm A'
};
function longDateFormat (key) {
var format = this._longDateFormat[key],
formatUpper = this._longDateFormat[key.toUpperCase()];
if (format || !formatUpper) {
return format;
}
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
return val.slice(1);
});
return this._longDateFormat[key];
}
var defaultInvalidDate = 'Invalid date';
function invalidDate () {
return this._invalidDate;
}
var defaultOrdinal = '%d';
var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
function ordinal (number) {
return this._ordinal.replace('%d', number);
}
var defaultRelativeTime = {
future : 'in %s',
past : '%s ago',
s : 'a few seconds',
ss : '%d seconds',
m : 'a minute',
mm : '%d minutes',
h : 'an hour',
hh : '%d hours',
d : 'a day',
dd : '%d days',
M : 'a month',
MM : '%d months',
y : 'a year',
yy : '%d years'
};
function relativeTime (number, withoutSuffix, string, isFuture) {
var output = this._relativeTime[string];
return (isFunction(output)) ?
output(number, withoutSuffix, string, isFuture) :
output.replace(/%d/i, number);
}
function pastFuture (diff, output) {
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}
var aliases = {};
function addUnitAlias (unit, shorthand) {
var lowerCase = unit.toLowerCase();
aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
}
function normalizeUnits(units) {
return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
}
function normalizeObjectUnits(inputObject) {
var normalizedInput = {},
normalizedProp,
prop;
for (prop in inputObject) {
if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
return normalizedInput;
}
var priorities = {};
function addUnitPriority(unit, priority) {
priorities[unit] = priority;
}
function getPrioritizedUnits(unitsObj) {
var units = [];
for (var u in unitsObj) {
units.push({unit: u, priority: priorities[u]});
}
units.sort(function (a, b) {
return a.priority - b.priority;
});
return units;
}
function zeroFill(number, targetLength, forceSign) {
var absNumber = '' + Math.abs(number),
zerosToFill = targetLength - absNumber.length,
sign = number >= 0;
return (sign ? (forceSign ? '+' : '') : '-') +
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
var formatFunctions = {};
var formatTokenFunctions = {};
// token: 'M'
// padded: ['MM', 2]
// ordinal: 'Mo'
// callback: function () { this.month() + 1 }
function addFormatToken (token, padded, ordinal, callback) {
var func = callback;
if (typeof callback === 'string') {
func = function () {
return this[callback]();
};
}
if (token) {
formatTokenFunctions[token] = func;
}
if (padded) {
formatTokenFunctions[padded[0]] = function () {
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
};
}
if (ordinal) {
formatTokenFunctions[ordinal] = function () {
return this.localeData().ordinal(func.apply(this, arguments), token);
};
}
}
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, '');
}
return input.replace(/\\/g, '');
}
function makeFormatFunction(format) {
var array = format.match(formattingTokens), i, length;
for (i = 0, length = array.length; i < length; i++) {
if (formatTokenFunctions[array[i]]) {
array[i] = formatTokenFunctions[array[i]];
} else {
array[i] = removeFormattingTokens(array[i]);
}
}
return function (mom) {
var output = '', i;
for (i = 0; i < length; i++) {
output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
}
return output;
};
}
// format date using native date object
function formatMoment(m, format) {
if (!m.isValid()) {
return m.localeData().invalidDate();
}
format = expandFormat(format, m.localeData());
formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](m);
}
function expandFormat(format, locale) {
var i = 5;
function replaceLongDateFormatTokens(input) {
return locale.longDateFormat(input) || input;
}
localFormattingTokens.lastIndex = 0;
while (i >= 0 && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
localFormattingTokens.lastIndex = 0;
i -= 1;
}
return format;
}
var match1 = /\d/; // 0 - 9
var match2 = /\d\d/; // 00 - 99
var match3 = /\d{3}/; // 000 - 999
var match4 = /\d{4}/; // 0000 - 9999
var match6 = /[+-]?\d{6}/; // -999999 - 999999
var match1to2 = /\d\d?/; // 0 - 99
var match3to4 = /\d\d\d\d?/; // 999 - 9999
var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
var match1to3 = /\d{1,3}/; // 0 - 999
var match1to4 = /\d{1,4}/; // 0 - 9999
var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
var matchUnsigned = /\d+/; // 0 - inf
var matchSigned = /[+-]?\d+/; // -inf - inf
var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
var regexes = {};
function addRegexToken (token, regex, strictRegex) {
regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
function getParseRegexForToken (token, config) {
if (!hasOwnProp(regexes, token)) {
return new RegExp(unescapeFormat(token));
}
return regexes[token](config._strict, config._locale);
}
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
}));
}
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var tokens = {};
function addParseToken (token, callback) {
var i, func = callback;
if (typeof token === 'string') {
token = [token];
}
if (isNumber(callback)) {
func = function (input, array) {
array[callback] = toInt(input);
};
}
for (i = 0; i < token.length; i++) {
tokens[token[i]] = func;
}
}
function addWeekParseToken (token, callback) {
addParseToken(token, function (input, array, config, token) {
config._w = config._w || {};
callback(input, config._w, config, token);
});
}
function addTimeToArrayFromToken(token, input, config) {
if (input != null && hasOwnProp(tokens, token)) {
tokens[token](input, config._a, config, token);
}
}
var YEAR = 0;
var MONTH = 1;
var DATE = 2;
var HOUR = 3;
var MINUTE = 4;
var SECOND = 5;
var MILLISECOND = 6;
var WEEK = 7;
var WEEKDAY = 8;
// FORMATTING
addFormatToken('Y', 0, 0, function () {
var y = this.year();
return y <= 9999 ? '' + y : '+' + y;
});
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
});
addFormatToken(0, ['YYYY', 4], 0, 'year');
addFormatToken(0, ['YYYYY', 5], 0, 'year');
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
// ALIASES
addUnitAlias('year', 'y');
// PRIORITIES
addUnitPriority('year', 1);
// PARSING
addRegexToken('Y', matchSigned);
addRegexToken('YY', match1to2, match2);
addRegexToken('YYYY', match1to4, match4);
addRegexToken('YYYYY', match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
addParseToken('YYYY', function (input, array) {
array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
});
addParseToken('YY', function (input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
addParseToken('Y', function (input, array) {
array[YEAR] = parseInt(input, 10);
});
// HELPERS
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
// HOOKS
hooks.parseTwoDigitYear = function (input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
// MOMENTS
var getSetYear = makeGetSet('FullYear', true);
function getIsLeapYear () {
return isLeapYear(this.year());
}
function makeGetSet (unit, keepTime) {
return function (value) {
if (value != null) {
set$1(this, unit, value);
hooks.updateOffset(this, keepTime);
return this;
} else {
return get(this, unit);
}
};
}
function get (mom, unit) {
return mom.isValid() ?
mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
}
function set$1 (mom, unit, value) {
if (mom.isValid() && !isNaN(value)) {
if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
}
else {
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
}
}
}
// MOMENTS
function stringGet (units) {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units]();
}
return this;
}
function stringSet (units, value) {
if (typeof units === 'object') {
units = normalizeObjectUnits(units);
var prioritized = getPrioritizedUnits(units);
for (var i = 0; i < prioritized.length; i++) {
this[prioritized[i].unit](units[prioritized[i].unit]);
}
} else {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units](value);
}
}
return this;
}
function mod(n, x) {
return ((n % x) + x) % x;
}
var indexOf;
if (Array.prototype.indexOf) {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function (o) {
// I know
var i;
for (i = 0; i < this.length; ++i) {
if (this[i] === o) {
return i;
}
}
return -1;
};
}
function daysInMonth(year, month) {
if (isNaN(year) || isNaN(month)) {
return NaN;
}
var modMonth = mod(month, 12);
year += (month - modMonth) / 12;
return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
}
// FORMATTING
addFormatToken('M', ['MM', 2], 'Mo', function () {
return this.month() + 1;
});
addFormatToken('MMM', 0, 0, function (format) {
return this.localeData().monthsShort(this, format);
});
addFormatToken('MMMM', 0, 0, function (format) {
return this.localeData().months(this, format);
});
// ALIASES
addUnitAlias('month', 'M');
// PRIORITY
addUnitPriority('month', 8);
// PARSING
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
addRegexToken('MMM', function (isStrict, locale) {
return locale.monthsShortRegex(isStrict);
});
addRegexToken('MMMM', function (isStrict, locale) {
return locale.monthsRegex(isStrict);
});
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
});
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
var month = config._locale.monthsParse(input, token, config._strict);
// if we didn't find a month name, mark the date as invalid.
if (month != null) {
array[MONTH] = month;
} else {
getParsingFlags(config).invalidMonth = input;
}
});
// LOCALES
var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
function localeMonths (m, format) {
if (!m) {
return isArray(this._months) ? this._months :
this._months['standalone'];
}
return isArray(this._months) ? this._months[m.month()] :
this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
}
var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
function localeMonthsShort (m, format) {
if (!m) {
return isArray(this._monthsShort) ? this._monthsShort :
this._monthsShort['standalone'];
}
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
function handleStrictParse(monthName, format, strict) {
var i, ii, mom, llc = monthName.toLocaleLowerCase();
if (!this._monthsParse) {
// this is not used
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
for (i = 0; i < 12; ++i) {
mom = createUTC([2000, i]);
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'MMM') {
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'MMM') {
ii = indexOf.call(this._shortMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeMonthsParse (monthName, format, strict) {
var i, mom, regex;
if (this._monthsParseExact) {
return handleStrictParse.call(this, monthName, format, strict);
}
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
}
// TODO: add sorting
// Sorting makes sure if one month (or abbr) is a prefix of another
// see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
if (strict && !this._longMonthsParse[i]) {
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
}
if (!strict && !this._monthsParse[i]) {
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
return i;
} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
return i;
} else if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
}
// MOMENTS
function setMonth (mom, value) {
var dayOfMonth;
if (!mom.isValid()) {
// No op
return mom;
}
if (typeof value === 'string') {
if (/^\d+$/.test(value)) {
value = toInt(value);
} else {
value = mom.localeData().monthsParse(value);
// TODO: Another silent failure?
if (!isNumber(value)) {
return mom;
}
}
}
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
return mom;
}
function getSetMonth (value) {
if (value != null) {
setMonth(this, value);
hooks.updateOffset(this, true);
return this;
} else {
return get(this, 'Month');
}
}
function getDaysInMonth () {
return daysInMonth(this.year(), this.month());
}
var defaultMonthsShortRegex = matchWord;
function monthsShortRegex (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsShortStrictRegex;
} else {
return this._monthsShortRegex;
}
} else {
if (!hasOwnProp(this, '_monthsShortRegex')) {
this._monthsShortRegex = defaultMonthsShortRegex;
}
return this._monthsShortStrictRegex && isStrict ?
this._monthsShortStrictRegex : this._monthsShortRegex;
}
}
var defaultMonthsRegex = matchWord;
function monthsRegex (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsStrictRegex;
} else {
return this._monthsRegex;
}
} else {
if (!hasOwnProp(this, '_monthsRegex')) {
this._monthsRegex = defaultMonthsRegex;
}
return this._monthsStrictRegex && isStrict ?
this._monthsStrictRegex : this._monthsRegex;
}
}
function computeMonthsParse () {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var shortPieces = [], longPieces = [], mixedPieces = [],
i, mom;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
shortPieces.push(this.monthsShort(mom, ''));
longPieces.push(this.months(mom, ''));
mixedPieces.push(this.months(mom, ''));
mixedPieces.push(this.monthsShort(mom, ''));
}
// Sorting makes sure if one month (or abbr) is a prefix of another it
// will match the longer piece.
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 12; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
}
for (i = 0; i < 24; i++) {
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._monthsShortRegex = this._monthsRegex;
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
}
function createDate (y, m, d, h, M, s, ms) {
// can't just apply() to create a date:
// https://stackoverflow.com/q/181348
var date;
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
date = new Date(y + 400, m, d, h, M, s, ms);
if (isFinite(date.getFullYear())) {
date.setFullYear(y);
}
} else {
date = new Date(y, m, d, h, M, s, ms);
}
return date;
}
function createUTCDate (y) {
var date;
// the Date.UTC function remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
var args = Array.prototype.slice.call(arguments);
// preserve leap years using a full 400 year cycle, then reset
args[0] = y + 400;
date = new Date(Date.UTC.apply(null, args));
if (isFinite(date.getUTCFullYear())) {
date.setUTCFullYear(y);
}
} else {
date = new Date(Date.UTC.apply(null, arguments));
}
return date;
}
// start-of-first-week - start-of-year
function firstWeekOffset(year, dow, doy) {
var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
fwd = 7 + dow - doy,
// first-week day local weekday -- which local weekday is fwd
fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
return -fwdlw + fwd - 1;
}
// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
var localWeekday = (7 + weekday - dow) % 7,
weekOffset = firstWeekOffset(year, dow, doy),
dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
resYear, resDayOfYear;
if (dayOfYear <= 0) {
resYear = year - 1;
resDayOfYear = daysInYear(resYear) + dayOfYear;
} else if (dayOfYear > daysInYear(year)) {
resYear = year + 1;
resDayOfYear = dayOfYear - daysInYear(year);
} else {
resYear = year;
resDayOfYear = dayOfYear;
}
return {
year: resYear,
dayOfYear: resDayOfYear
};
}
function weekOfYear(mom, dow, doy) {
var weekOffset = firstWeekOffset(mom.year(), dow, doy),
week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
resWeek, resYear;
if (week < 1) {
resYear = mom.year() - 1;
resWeek = week + weeksInYear(resYear, dow, doy);
} else if (week > weeksInYear(mom.year(), dow, doy)) {
resWeek = week - weeksInYear(mom.year(), dow, doy);
resYear = mom.year() + 1;
} else {
resYear = mom.year();
resWeek = week;
}
return {
week: resWeek,
year: resYear
};
}
function weeksInYear(year, dow, doy) {
var weekOffset = firstWeekOffset(year, dow, doy),
weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}
// FORMATTING
addFormatToken('w', ['ww', 2], 'wo', 'week');
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
// ALIASES
addUnitAlias('week', 'w');
addUnitAlias('isoWeek', 'W');
// PRIORITIES
addUnitPriority('week', 5);
addUnitPriority('isoWeek', 5);
// PARSING
addRegexToken('w', match1to2);
addRegexToken('ww', match1to2, match2);
addRegexToken('W', match1to2);
addRegexToken('WW', match1to2, match2);
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
week[token.substr(0, 1)] = toInt(input);
});
// HELPERS
// LOCALES
function localeWeek (mom) {
return weekOfYear(mom, this._week.dow, this._week.doy).week;
}
var defaultLocaleWeek = {
dow : 0, // Sunday is the first day of the week.
doy : 6 // The week that contains Jan 6th is the first week of the year.
};
function localeFirstDayOfWeek () {
return this._week.dow;
}
function localeFirstDayOfYear () {
return this._week.doy;
}
// MOMENTS
function getSetWeek (input) {
var week = this.localeData().week(this);
return input == null ? week : this.add((input - week) * 7, 'd');
}
function getSetISOWeek (input) {
var week = weekOfYear(this, 1, 4).week;
return input == null ? week : this.add((input - week) * 7, 'd');
}
// FORMATTING
addFormatToken('d', 0, 'do', 'day');
addFormatToken('dd', 0, 0, function (format) {
return this.localeData().weekdaysMin(this, format);
});
addFormatToken('ddd', 0, 0, function (format) {
return this.localeData().weekdaysShort(this, format);
});
addFormatToken('dddd', 0, 0, function (format) {
return this.localeData().weekdays(this, format);
});
addFormatToken('e', 0, 0, 'weekday');
addFormatToken('E', 0, 0, 'isoWeekday');
// ALIASES
addUnitAlias('day', 'd');
addUnitAlias('weekday', 'e');
addUnitAlias('isoWeekday', 'E');
// PRIORITY
addUnitPriority('day', 11);
addUnitPriority('weekday', 11);
addUnitPriority('isoWeekday', 11);
// PARSING
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
addRegexToken('dd', function (isStrict, locale) {
return locale.weekdaysMinRegex(isStrict);
});
addRegexToken('ddd', function (isStrict, locale) {
return locale.weekdaysShortRegex(isStrict);
});
addRegexToken('dddd', function (isStrict, locale) {
return locale.weekdaysRegex(isStrict);
});
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
// if we didn't get a weekday name, mark the date as invalid
if (weekday != null) {
week.d = weekday;
} else {
getParsingFlags(config).invalidWeekday = input;
}
});
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
week[token] = toInt(input);
});
// HELPERS
function parseWeekday(input, locale) {
if (typeof input !== 'string') {
return input;
}
if (!isNaN(input)) {
return parseInt(input, 10);
}
input = locale.weekdaysParse(input);
if (typeof input === 'number') {
return input;
}
return null;
}
function parseIsoWeekday(input, locale) {
if (typeof input === 'string') {
return locale.weekdaysParse(input) % 7 || 7;
}
return isNaN(input) ? null : input;
}
// LOCALES
function shiftWeekdays (ws, n) {
return ws.slice(n, 7).concat(ws.slice(0, n));
}
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
function localeWeekdays (m, format) {
var weekdays = isArray(this._weekdays) ? this._weekdays :
this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
: (m) ? weekdays[m.day()] : weekdays;
}
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
function localeWeekdaysShort (m) {
return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
: (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
}
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
function localeWeekdaysMin (m) {
return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
: (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
}
function handleStrictParse$1(weekdayName, format, strict) {
var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._shortWeekdaysParse = [];
this._minWeekdaysParse = [];
for (i = 0; i < 7; ++i) {
mom = createUTC([2000, 1]).day(i);
this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'dddd') {
ii = indexOf.call(this._weekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'dddd') {
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeWeekdaysParse (weekdayName, format, strict) {
var i, mom, regex;
if (this._weekdaysParseExact) {
return handleStrictParse$1.call(this, weekdayName, format, strict);
}
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._minWeekdaysParse = [];
this._shortWeekdaysParse = [];
this._fullWeekdaysParse = [];
}
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
}
if (!this._weekdaysParse[i]) {
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
return i;
}
}
}
// MOMENTS
function getSetDayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
if (input != null) {
input = parseWeekday(input, this.localeData());
return this.add(input - day, 'd');
} else {
return day;
}
}
function getSetLocaleDayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
return input == null ? weekday : this.add(input - weekday, 'd');
}
function getSetISODayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
// behaves the same as moment#day except
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
// as a setter, sunday should belong to the previous week.
if (input != null) {
var weekday = parseIsoWeekday(input, this.localeData());
return this.day(this.day() % 7 ? weekday : weekday - 7);
} else {
return this.day() || 7;
}
}
var defaultWeekdaysRegex = matchWord;
function weekdaysRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysStrictRegex;
} else {
return this._weekdaysRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this._weekdaysRegex = defaultWeekdaysRegex;
}
return this._weekdaysStrictRegex && isStrict ?
this._weekdaysStrictRegex : this._weekdaysRegex;
}
}
var defaultWeekdaysShortRegex = matchWord;
function weekdaysShortRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysShortStrictRegex;
} else {
return this._weekdaysShortRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysShortRegex')) {
this._weekdaysShortRegex = defaultWeekdaysShortRegex;
}
return this._weekdaysShortStrictRegex && isStrict ?
this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
}
}
var defaultWeekdaysMinRegex = matchWord;
function weekdaysMinRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysMinStrictRegex;
} else {
return this._weekdaysMinRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysMinRegex')) {
this._weekdaysMinRegex = defaultWeekdaysMinRegex;
}
return this._weekdaysMinStrictRegex && isStrict ?
this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
}
}
function computeWeekdaysParse () {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
i, mom, minp, shortp, longp;
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
minp = this.weekdaysMin(mom, '');
shortp = this.weekdaysShort(mom, '');
longp = this.weekdays(mom, '');
minPieces.push(minp);
shortPieces.push(shortp);
longPieces.push(longp);
mixedPieces.push(minp);
mixedPieces.push(shortp);
mixedPieces.push(longp);
}
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
// will match the longer piece.
minPieces.sort(cmpLenRev);
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 7; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._weekdaysShortRegex = this._weekdaysRegex;
this._weekdaysMinRegex = this._weekdaysRegex;
this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
}
// FORMATTING
function hFormat() {
return this.hours() % 12 || 12;
}
function kFormat() {
return this.hours() || 24;
}
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
});
addFormatToken('hmmss', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2);
});
addFormatToken('Hmm', 0, 0, function () {
return '' + this.hours() + zeroFill(this.minutes(), 2);
});
addFormatToken('Hmmss', 0, 0, function () {
return '' + this.hours() + zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2);
});
function meridiem (token, lowercase) {
addFormatToken(token, 0, 0, function () {
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
});
}
meridiem('a', true);
meridiem('A', false);
// ALIASES
addUnitAlias('hour', 'h');
// PRIORITY
addUnitPriority('hour', 13);
// PARSING
function matchMeridiem (isStrict, locale) {
return locale._meridiemParse;
}
addRegexToken('a', matchMeridiem);
addRegexToken('A', matchMeridiem);
addRegexToken('H', match1to2);
addRegexToken('h', match1to2);
addRegexToken('k', match1to2);
addRegexToken('HH', match1to2, match2);
addRegexToken('hh', match1to2, match2);
addRegexToken('kk', match1to2, match2);
addRegexToken('hmm', match3to4);
addRegexToken('hmmss', match5to6);
addRegexToken('Hmm', match3to4);
addRegexToken('Hmmss', match5to6);
addParseToken(['H', 'HH'], HOUR);
addParseToken(['k', 'kk'], function (input, array, config) {
var kInput = toInt(input);
array[HOUR] = kInput === 24 ? 0 : kInput;
});
addParseToken(['a', 'A'], function (input, array, config) {
config._isPm = config._locale.isPM(input);
config._meridiem = input;
});
addParseToken(['h', 'hh'], function (input, array, config) {
array[HOUR] = toInt(input);
getParsingFlags(config).bigHour = true;
});
addParseToken('hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
getParsingFlags(config).bigHour = true;
});
addParseToken('hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
getParsingFlags(config).bigHour = true;
});
addParseToken('Hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
});
addParseToken('Hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
});
// LOCALES
function localeIsPM (input) {
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
// Using charAt should be more compatible.
return ((input + '').toLowerCase().charAt(0) === 'p');
}
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
function localeMeridiem (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'pm' : 'PM';
} else {
return isLower ? 'am' : 'AM';
}
}
// MOMENTS
// Setting the hour should keep the time, because the user explicitly
// specified which hour they want. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
var getSetHour = makeGetSet('Hours', true);
var baseConfig = {
calendar: defaultCalendar,
longDateFormat: defaultLongDateFormat,
invalidDate: defaultInvalidDate,
ordinal: defaultOrdinal,
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
relativeTime: defaultRelativeTime,
months: defaultLocaleMonths,
monthsShort: defaultLocaleMonthsShort,
week: defaultLocaleWeek,
weekdays: defaultLocaleWeekdays,
weekdaysMin: defaultLocaleWeekdaysMin,
weekdaysShort: defaultLocaleWeekdaysShort,
meridiemParse: defaultLocaleMeridiemParse
};
// internal storage for locale config files
var locales = {};
var localeFamilies = {};
var globalLocale;
function normalizeLocale(key) {
return key ? key.toLowerCase().replace('_', '-') : key;
}
// pick the locale from the array
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
function chooseLocale(names) {
var i = 0, j, next, locale, split;
while (i < names.length) {
split = normalizeLocale(names[i]).split('-');
j = split.length;
next = normalizeLocale(names[i + 1]);
next = next ? next.split('-') : null;
while (j > 0) {
locale = loadLocale(split.slice(0, j).join('-'));
if (locale) {
return locale;
}
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
//the next array item is better than a shallower substring of this one
break;
}
j--;
}
i++;
}
return globalLocale;
}
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
var aliasedRequire = require;
aliasedRequire('./locale/' + name);
getSetGlobalLocale(oldLocale);
} catch (e) {}
}
return locales[name];
}
// This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
// locale key.
function getSetGlobalLocale (key, values) {
var data;
if (key) {
if (isUndefined(values)) {
data = getLocale(key);
}
else {
data = defineLocale(key, values);
}
if (data) {
// moment.duration._locale = moment._locale = data;
globalLocale = data;
}
else {
if ((typeof console !== 'undefined') && console.warn) {
//warn user if arguments are passed but the locale could not be set
console.warn('Locale ' + key + ' not found. Did you forget to load it?');
}
}
}
return globalLocale._abbr;
}
function defineLocale (name, config) {
if (config !== null) {
var locale, parentConfig = baseConfig;
config.abbr = name;
if (locales[name] != null) {
deprecateSimple('defineLocaleOverride',
'use moment.updateLocale(localeName, config) to change ' +
'an existing locale. moment.defineLocale(localeName, ' +
'config) should only be used for creating a new locale ' +
'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
parentConfig = locales[name]._config;
} else if (config.parentLocale != null) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
} else {
locale = loadLocale(config.parentLocale);
if (locale != null) {
parentConfig = locale._config;
} else {
if (!localeFamilies[config.parentLocale]) {
localeFamilies[config.parentLocale] = [];
}
localeFamilies[config.parentLocale].push({
name: name,
config: config
});
return null;
}
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
if (localeFamilies[name]) {
localeFamilies[name].forEach(function (x) {
defineLocale(x.name, x.config);
});
}
// backwards compat for now: also set the locale
// make sure we set the locale AFTER all child locales have been
// created, so we won't end up with the child locale set.
getSetGlobalLocale(name);
return locales[name];
} else {
// useful for testing
delete locales[name];
return null;
}
}
function updateLocale(name, config) {
if (config != null) {
var locale, tmpLocale, parentConfig = baseConfig;
// MERGE
tmpLocale = loadLocale(name);
if (tmpLocale != null) {
parentConfig = tmpLocale._config;
}
config = mergeConfigs(parentConfig, config);
locale = new Locale(config);
locale.parentLocale = locales[name];
locales[name] = locale;
// backwards compat for now: also set the locale
getSetGlobalLocale(name);
} else {
// pass null for config to unupdate, useful for tests
if (locales[name] != null) {
if (locales[name].parentLocale != null) {
locales[name] = locales[name].parentLocale;
} else if (locales[name] != null) {
delete locales[name];
}
}
}
return locales[name];
}
// returns locale data
function getLocale (key) {
var locale;
if (key && key._locale && key._locale._abbr) {
key = key._locale._abbr;
}
if (!key) {
return globalLocale;
}
if (!isArray(key)) {
//short-circuit everything else
locale = loadLocale(key);
if (locale) {
return locale;
}
key = [key];
}
return chooseLocale(key);
}
function listLocales() {
return keys(locales);
}
function checkOverflow (m) {
var overflow;
var a = m._a;
if (a && getParsingFlags(m).overflow === -2) {
overflow =
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
-1;
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
overflow = DATE;
}
if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
overflow = WEEK;
}
if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
overflow = WEEKDAY;
}
getParsingFlags(m).overflow = overflow;
}
return m;
}
// Pick the first defined of two or three arguments.
function defaults(a, b, c) {
if (a != null) {
return a;
}
if (b != null) {
return b;
}
return c;
}
function currentDateArray(config) {
// hooks is actually the exported moment object
var nowValue = new Date(hooks.now());
if (config._useUTC) {
return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
}
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function configFromArray (config) {
var i, date, input = [], currentDate, expectedWeekday, yearToUse;
if (config._d) {
return;
}
currentDate = currentDateArray(config);
//compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
dayOfYearFromWeekInfo(config);
}
//if the day of the year is set, figure out what it is
if (config._dayOfYear != null) {
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
getParsingFlags(config)._overflowDayOfYear = true;
}
date = createUTCDate(yearToUse, 0, config._dayOfYear);
config._a[MONTH] = date.getUTCMonth();
config._a[DATE] = date.getUTCDate();
}
// Default to current date.
// * if no year, month, day of month are given, default to today
// * if day of month is given, default month and year
// * if month is given, default only year
// * if year is given, don't default anything
for (i = 0; i < 3 && config._a[i] == null; ++i) {
config._a[i] = input[i] = currentDate[i];
}
// Zero out whatever was not defaulted, including time
for (; i < 7; i++) {
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
}
// Check for 24:00:00.000
if (config._a[HOUR] === 24 &&
config._a[MINUTE] === 0 &&
config._a[SECOND] === 0 &&
config._a[MILLISECOND] === 0) {
config._nextDay = true;
config._a[HOUR] = 0;
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
config._a[HOUR] = 24;
}
// check for mismatching day of week
if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
getParsingFlags(config).weekdayMismatch = true;
}
}
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
// TODO: We need to take the current isoWeekYear, but that depends on
// how we interpret now (local, utc, fixed offset). So create
// a now version of current config (take local/utc/offset flags, and
// create now).
weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
if (weekday < 1 || weekday > 7) {
weekdayOverflow = true;
}
} else {
dow = config._locale._week.dow;
doy = config._locale._week.doy;
var curWeek = weekOfYear(createLocal(), dow, doy);
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
// Default to current week.
week = defaults(w.w, curWeek.week);
if (w.d != null) {
// weekday -- low day numbers are considered next week
weekday = w.d;
if (weekday < 0 || weekday > 6) {
weekdayOverflow = true;
}
} else if (w.e != null) {
// local weekday -- counting starts from beginning of week
weekday = w.e + dow;
if (w.e < 0 || w.e > 6) {
weekdayOverflow = true;
}
} else {
// default to beginning of week
weekday = dow;
}
}
if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
getParsingFlags(config)._overflowWeeks = true;
} else if (weekdayOverflow != null) {
getParsingFlags(config)._overflowWeekday = true;
} else {
temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
config._a[YEAR] = temp.year;
config._dayOfYear = temp.dayOfYear;
}
}
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
var isoDates = [
['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
['GGGG-[W]WW', /\d{4}-W\d\d/, false],
['YYYY-DDD', /\d{4}-\d{3}/],
['YYYY-MM', /\d{4}-\d\d/, false],
['YYYYYYMMDD', /[+-]\d{10}/],
['YYYYMMDD', /\d{8}/],
// YYYYMM is NOT allowed by the standard
['GGGG[W]WWE', /\d{4}W\d{3}/],
['GGGG[W]WW', /\d{4}W\d{2}/, false],
['YYYYDDD', /\d{7}/]
];
// iso time formats and regexes
var isoTimes = [
['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
['HH:mm:ss', /\d\d:\d\d:\d\d/],
['HH:mm', /\d\d:\d\d/],
['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
['HHmmss', /\d\d\d\d\d\d/],
['HHmm', /\d\d\d\d/],
['HH', /\d\d/]
];
var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
// date from iso format
function configFromISO(config) {
var i, l,
string = config._i,
match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
allowTime, dateFormat, timeFormat, tzFormat;
if (match) {
getParsingFlags(config).iso = true;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(match[1])) {
dateFormat = isoDates[i][0];
allowTime = isoDates[i][2] !== false;
break;
}
}
if (dateFormat == null) {
config._isValid = false;
return;
}
if (match[3]) {
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(match[3])) {
// match[2] should be 'T' or space
timeFormat = (match[2] || ' ') + isoTimes[i][0];
break;
}
}
if (timeFormat == null) {
config._isValid = false;
return;
}
}
if (!allowTime && timeFormat != null) {
config._isValid = false;
return;
}
if (match[4]) {
if (tzRegex.exec(match[4])) {
tzFormat = 'Z';
} else {
config._isValid = false;
return;
}
}
config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
configFromStringAndFormat(config);
} else {
config._isValid = false;
}
}
// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
var result = [
untruncateYear(yearStr),
defaultLocaleMonthsShort.indexOf(monthStr),
parseInt(dayStr, 10),
parseInt(hourStr, 10),
parseInt(minuteStr, 10)
];
if (secondStr) {
result.push(parseInt(secondStr, 10));
}
return result;
}
function untruncateYear(yearStr) {
var year = parseInt(yearStr, 10);
if (year <= 49) {
return 2000 + year;
} else if (year <= 999) {
return 1900 + year;
}
return year;
}
function preprocessRFC2822(s) {
// Remove comments and folding whitespace and replace multiple-spaces with a single space
return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function checkWeekday(weekdayStr, parsedInput, config) {
if (weekdayStr) {
// TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
if (weekdayProvided !== weekdayActual) {
getParsingFlags(config).weekdayMismatch = true;
config._isValid = false;
return false;
}
}
return true;
}
var obsOffsets = {
UT: 0,
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60
};
function calculateOffset(obsOffset, militaryOffset, numOffset) {
if (obsOffset) {
return obsOffsets[obsOffset];
} else if (militaryOffset) {
// the only allowed military tz is Z
return 0;
} else {
var hm = parseInt(numOffset, 10);
var m = hm % 100, h = (hm - m) / 100;
return h * 60 + m;
}
}
// date and time from ref 2822 format
function configFromRFC2822(config) {
var match = rfc2822.exec(preprocessRFC2822(config._i));
if (match) {
var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
if (!checkWeekday(match[1], parsedArray, config)) {
return;
}
config._a = parsedArray;
config._tzm = calculateOffset(match[8], match[9], match[10]);
config._d = createUTCDate.apply(null, config._a);
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
getParsingFlags(config).rfc2822 = true;
} else {
config._isValid = false;
}
}
// date from iso format or fallback
function configFromString(config) {
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return;
}
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
configFromRFC2822(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
// Final attempt, use Input Fallback
hooks.createFromInputFallback(config);
}
hooks.createFromInputFallback = deprecate(
'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
'discouraged and will be removed in an upcoming major release. Please refer to ' +
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
function (config) {
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
}
);
// constant that refers to the ISO standard
hooks.ISO_8601 = function () {};
// constant that refers to the RFC 2822 form
hooks.RFC_2822 = function () {};
// date from string and format string
function configFromStringAndFormat(config) {
// TODO: Move this to another part of the creation flow to prevent circular deps
if (config._f === hooks.ISO_8601) {
configFromISO(config);
return;
}
if (config._f === hooks.RFC_2822) {
configFromRFC2822(config);
return;
}
config._a = [];
getParsingFlags(config).empty = true;
// This array is used to make a Date, either with `new Date` or `Date.UTC`
var string = '' + config._i,
i, parsedInput, tokens, token, skipped,
stringLength = string.length,
totalParsedInputLength = 0;
tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
// console.log('token', token, 'parsedInput', parsedInput,
// 'regex', getParseRegexForToken(token, config));
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
getParsingFlags(config).unusedInput.push(skipped);
}
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
totalParsedInputLength += parsedInput.length;
}
// don't parse if it's not a known token
if (formatTokenFunctions[token]) {
if (parsedInput) {
getParsingFlags(config).empty = false;
}
else {
getParsingFlags(config).unusedTokens.push(token);
}
addTimeToArrayFromToken(token, parsedInput, config);
}
else if (config._strict && !parsedInput) {
getParsingFlags(config).unusedTokens.push(token);
}
}
// add remaining unparsed input length to the string
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
if (string.length > 0) {
getParsingFlags(config).unusedInput.push(string);
}
// clear _12h flag if hour is <= 12
if (config._a[HOUR] <= 12 &&
getParsingFlags(config).bigHour === true &&
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = undefined;
}
getParsingFlags(config).parsedDateParts = config._a.slice(0);
getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
configFromArray(config);
checkOverflow(config);
}
function meridiemFixWrap (locale, hour, meridiem) {
var isPm;
if (meridiem == null) {
// nothing to do
return hour;
}
if (locale.meridiemHour != null) {
return locale.meridiemHour(hour, meridiem);
} else if (locale.isPM != null) {
// Fallback
isPm = locale.isPM(meridiem);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
} else {
// this is not supposed to happen
return hour;
}
}
// date from string and array of format strings
function configFromStringAndArray(config) {
var tempConfig,
bestMoment,
scoreToBeat,
i,
currentScore;
if (config._f.length === 0) {
getParsingFlags(config).invalidFormat = true;
config._d = new Date(NaN);
return;
}
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
tempConfig = copyConfig({}, config);
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
if (!isValid(tempConfig)) {
continue;
}
// if there is any input that was not parsed add a penalty for that format
currentScore += getParsingFlags(tempConfig).charsLeftOver;
//or tokens
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
getParsingFlags(tempConfig).score = currentScore;
if (scoreToBeat == null || currentScore < scoreToBeat) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
}
}
extend(config, bestMoment || tempConfig);
}
function configFromObject(config) {
if (config._d) {
return;
}
var i = normalizeObjectUnits(config._i);
config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
return obj && parseInt(obj, 10);
});
configFromArray(config);
}
function createFromConfig (config) {
var res = new Moment(checkOverflow(prepareConfig(config)));
if (res._nextDay) {
// Adding is smart enough around DST
res.add(1, 'd');
res._nextDay = undefined;
}
return res;
}
function prepareConfig (config) {
var input = config._i,
format = config._f;
config._locale = config._locale || getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
return createInvalid({nullInput: true});
}
if (typeof input === 'string') {
config._i = input = config._locale.preparse(input);
}
if (isMoment(input)) {
return new Moment(checkOverflow(input));
} else if (isDate(input)) {
config._d = input;
} else if (isArray(format)) {
configFromStringAndArray(config);
} else if (format) {
configFromStringAndFormat(config);
} else {
configFromInput(config);
}
if (!isValid(config)) {
config._d = null;
}
return config;
}
function configFromInput(config) {
var input = config._i;
if (isUndefined(input)) {
config._d = new Date(hooks.now());
} else if (isDate(input)) {
config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
config._a = map(input.slice(0), function (obj) {
return parseInt(obj, 10);
});
configFromArray(config);
} else if (isObject(input)) {
configFromObject(config);
} else if (isNumber(input)) {
// from milliseconds
config._d = new Date(input);
} else {
hooks.createFromInputFallback(config);
}
}
function createLocalOrUTC (input, format, locale, strict, isUTC) {
var c = {};
if (locale === true || locale === false) {
strict = locale;
locale = undefined;
}
if ((isObject(input) && isObjectEmpty(input)) ||
(isArray(input) && input.length === 0)) {
input = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
c._isAMomentObject = true;
c._useUTC = c._isUTC = isUTC;
c._l = locale;
c._i = input;
c._f = format;
c._strict = strict;
return createFromConfig(c);
}
function createLocal (input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, false);
}
var prototypeMin = deprecate(
'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
} else {
return createInvalid();
}
}
);
var prototypeMax = deprecate(
'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
} else {
return createInvalid();
}
}
);
// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
//
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
var res, i;
if (moments.length === 1 && isArray(moments[0])) {
moments = moments[0];
}
if (!moments.length) {
return createLocal();
}
res = moments[0];
for (i = 1; i < moments.length; ++i) {
if (!moments[i].isValid() || moments[i][fn](res)) {
res = moments[i];
}
}
return res;
}
// TODO: Use [].sort instead?
function min () {
var args = [].slice.call(arguments, 0);
return pickBy('isBefore', args);
}
function max () {
var args = [].slice.call(arguments, 0);
return pickBy('isAfter', args);
}
var now = function () {
return Date.now ? Date.now() : +(new Date());
};
var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
function isDurationValid(m) {
for (var key in m) {
if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
return false;
}
}
var unitHasDecimal = false;
for (var i = 0; i < ordering.length; ++i) {
if (m[ordering[i]]) {
if (unitHasDecimal) {
return false; // only allow non-integers for smallest unit
}
if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
unitHasDecimal = true;
}
}
}
return true;
}
function isValid$1() {
return this._isValid;
}
function createInvalid$1() {
return createDuration(NaN);
}
function Duration (duration) {
var normalizedInput = normalizeObjectUnits(duration),
years = normalizedInput.year || 0,
quarters = normalizedInput.quarter || 0,
months = normalizedInput.month || 0,
weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
days = normalizedInput.day || 0,
hours = normalizedInput.hour || 0,
minutes = normalizedInput.minute || 0,
seconds = normalizedInput.second || 0,
milliseconds = normalizedInput.millisecond || 0;
this._isValid = isDurationValid(normalizedInput);
// representation for dateAddRemove
this._milliseconds = +milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
weeks * 7;
// It is impossible to translate months into days without knowing
// which months you are are talking about, so we have to store
// it separately.
this._months = +months +
quarters * 3 +
years * 12;
this._data = {};
this._locale = getLocale();
this._bubble();
}
function isDuration (obj) {
return obj instanceof Duration;
}
function absRound (number) {
if (number < 0) {
return Math.round(-1 * number) * -1;
} else {
return Math.round(number);
}
}
// FORMATTING
function offset (token, separator) {
addFormatToken(token, 0, 0, function () {
var offset = this.utcOffset();
var sign = '+';
if (offset < 0) {
offset = -offset;
sign = '-';
}
return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
});
}
offset('Z', ':');
offset('ZZ', '');
// PARSING
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
});
// HELPERS
// timezone chunker
// '+10:00' > ['10', '00']
// '-1530' > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, string) {
var matches = (string || '').match(matcher);
if (matches === null) {
return null;
}
var chunk = matches[matches.length - 1] || [];
var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
var minutes = +(parts[1] * 60) + toInt(parts[2]);
return minutes === 0 ?
0 :
parts[0] === '+' ? minutes : -minutes;
}
// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, model) {
var res, diff;
if (model._isUTC) {
res = model.clone();
diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
res._d.setTime(res._d.valueOf() + diff);
hooks.updateOffset(res, false);
return res;
} else {
return createLocal(input).local();
}
}
function getDateOffset (m) {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
}
// HOOKS
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks.updateOffset = function () {};
// MOMENTS
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getSetOffset (input, keepLocalTime, keepMinutes) {
var offset = this._offset || 0,
localAdjust;
if (!this.isValid()) {
return input != null ? this : NaN;
}
if (input != null) {
if (typeof input === 'string') {
input = offsetFromString(matchShortOffset, input);
if (input === null) {
return this;
}
} else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
localAdjust = getDateOffset(this);
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
this.add(localAdjust, 'm');
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
addSubtract(this, createDuration(input - offset, 'm'), 1, false);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks.updateOffset(this, true);
this._changeInProgress = null;
}
}
return this;
} else {
return this._isUTC ? offset : getDateOffset(this);
}
}
function getSetZone (input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
function setOffsetToUTC (keepLocalTime) {
return this.utcOffset(0, keepLocalTime);
}
function setOffsetToLocal (keepLocalTime) {
if (this._isUTC) {
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.subtract(getDateOffset(this), 'm');
}
}
return this;
}
function setOffsetToParsedOffset () {
if (this._tzm != null) {
this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === 'string') {
var tZone = offsetFromString(matchOffset, this._i);
if (tZone != null) {
this.utcOffset(tZone);
}
else {
this.utcOffset(0, true);
}
}
return this;
}
function hasAlignedHourOffset (input) {
if (!this.isValid()) {
return false;
}
input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}
function isDaylightSavingTime () {
return (
this.utcOffset() > this.clone().month(0).utcOffset() ||
this.utcOffset() > this.clone().month(5).utcOffset()
);
}
function isDaylightSavingTimeShifted () {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
}
var c = {};
copyConfig(c, this);
c = prepareConfig(c);
if (c._a) {
var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this._isDSTShifted = this.isValid() &&
compareArrays(c._a, other.toArray()) > 0;
} else {
this._isDSTShifted = false;
}
return this._isDSTShifted;
}
function isLocal () {
return this.isValid() ? !this._isUTC : false;
}
function isUtcOffset () {
return this.isValid() ? this._isUTC : false;
}
function isUtc () {
return this.isValid() ? this._isUTC && this._offset === 0 : false;
}
// ASP.NET json date format regex
var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
function createDuration (input, key) {
var duration = input,
// matching against regexp is expensive, do it on demand
match = null,
sign,
ret,
diffRes;
if (isDuration(input)) {
duration = {
ms : input._milliseconds,
d : input._days,
M : input._months
};
} else if (isNumber(input)) {
duration = {};
if (key) {
duration[key] = input;
} else {
duration.milliseconds = input;
}
} else if (!!(match = aspNetRegex.exec(input))) {
sign = (match[1] === '-') ? -1 : 1;
duration = {
y : 0,
d : toInt(match[DATE]) * sign,
h : toInt(match[HOUR]) * sign,
m : toInt(match[MINUTE]) * sign,
s : toInt(match[SECOND]) * sign,
ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
};
} else if (!!(match = isoRegex.exec(input))) {
sign = (match[1] === '-') ? -1 : 1;
duration = {
y : parseIso(match[2], sign),
M : parseIso(match[3], sign),
w : parseIso(match[4], sign),
d : parseIso(match[5], sign),
h : parseIso(match[6], sign),
m : parseIso(match[7], sign),
s : parseIso(match[8], sign)
};
} else if (duration == null) {// checks for null or undefined
duration = {};
} else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
duration = {};
duration.ms = diffRes.milliseconds;
duration.M = diffRes.months;
}
ret = new Duration(duration);
if (isDuration(input) && hasOwnProp(input, '_locale')) {
ret._locale = input._locale;
}
return ret;
}
createDuration.fn = Duration.prototype;
createDuration.invalid = createInvalid$1;
function parseIso (inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
// inp may be undefined, so careful calling replace on it.
var res = inp && parseFloat(inp.replace(',', '.'));
// apply sign while we're at it
return (isNaN(res) ? 0 : res) * sign;
}
function positiveMomentsDifference(base, other) {
var res = {};
res.months = other.month() - base.month() +
(other.year() - base.year()) * 12;
if (base.clone().add(res.months, 'M').isAfter(other)) {
--res.months;
}
res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
return res;
}
function momentsDifference(base, other) {
var res;
if (!(base.isValid() && other.isValid())) {
return {milliseconds: 0, months: 0};
}
other = cloneWithOffset(other, base);
if (base.isBefore(other)) {
res = positiveMomentsDifference(base, other);
} else {
res = positiveMomentsDifference(other, base);
res.milliseconds = -res.milliseconds;
res.months = -res.months;
}
return res;
}
// TODO: remove 'name' arg after deprecation is removed
function createAdder(direction, name) {
return function (val, period) {
var dur, tmp;
//invert the arguments, but complain about it
if (period !== null && !isNaN(+period)) {
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
tmp = val; val = period; period = tmp;
}
val = typeof val === 'string' ? +val : val;
dur = createDuration(val, period);
addSubtract(this, dur, direction);
return this;
};
}
function addSubtract (mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
days = absRound(duration._days),
months = absRound(duration._months);
if (!mom.isValid()) {
// No op
return;
}
updateOffset = updateOffset == null ? true : updateOffset;
if (months) {
setMonth(mom, get(mom, 'Month') + months * isAdding);
}
if (days) {
set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
}
if (milliseconds) {
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (updateOffset) {
hooks.updateOffset(mom, days || months);
}
}
var add = createAdder(1, 'add');
var subtract = createAdder(-1, 'subtract');
function getCalendarFormat(myMoment, now) {
var diff = myMoment.diff(now, 'days', true);
return diff < -6 ? 'sameElse' :
diff < -1 ? 'lastWeek' :
diff < 0 ? 'lastDay' :
diff < 1 ? 'sameDay' :
diff < 2 ? 'nextDay' :
diff < 7 ? 'nextWeek' : 'sameElse';
}
function calendar$1 (time, formats) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || createLocal(),
sod = cloneWithOffset(now, this).startOf('day'),
format = hooks.calendarFormat(this, sod) || 'sameElse';
var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
}
function clone () {
return new Moment(this);
}
function isAfter (input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() > localInput.valueOf();
} else {
return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
function isBefore (input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() < localInput.valueOf();
} else {
return this.clone().endOf(units).valueOf() < localInput.valueOf();
}
}
function isBetween (from, to, units, inclusivity) {
var localFrom = isMoment(from) ? from : createLocal(from),
localTo = isMoment(to) ? to : createLocal(to);
if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
return false;
}
inclusivity = inclusivity || '()';
return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
(inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
}
function isSame (input, units) {
var localInput = isMoment(input) ? input : createLocal(input),
inputMs;
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() === localInput.valueOf();
} else {
inputMs = localInput.valueOf();
return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
function isSameOrAfter (input, units) {
return this.isSame(input, units) || this.isAfter(input, units);
}
function isSameOrBefore (input, units) {
return this.isSame(input, units) || this.isBefore(input, units);
}
function diff (input, units, asFloat) {
var that,
zoneDelta,
output;
if (!this.isValid()) {
return NaN;
}
that = cloneWithOffset(input, this);
if (!that.isValid()) {
return NaN;
}
zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
units = normalizeUnits(units);
switch (units) {
case 'year': output = monthDiff(this, that) / 12; break;
case 'month': output = monthDiff(this, that); break;
case 'quarter': output = monthDiff(this, that) / 3; break;
case 'second': output = (this - that) / 1e3; break; // 1000
case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
default: output = this - that;
}
return asFloat ? output : absFloor(output);
}
function monthDiff (a, b) {
// difference in months
var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
// b is in (anchor - 1 month, anchor + 1 month)
anchor = a.clone().add(wholeMonthDiff, 'months'),
anchor2, adjust;
if (b - anchor < 0) {
anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor - anchor2);
} else {
anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor2 - anchor);
}
//check for negative zero, return zero if negative zero
return -(wholeMonthDiff + adjust) || 0;
}
hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
function toISOString(keepOffset) {
if (!this.isValid()) {
return null;
}
var utc = keepOffset !== true;
var m = utc ? this.clone().utc() : this;
if (m.year() < 0 || m.year() > 9999) {
return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
}
if (isFunction(Date.prototype.toISOString)) {
// native implementation is ~50x faster, use it when we can
if (utc) {
return this.toDate().toISOString();
} else {
return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
}
}
return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
}
/**
* Return a human readable representation of a moment that can
* also be evaluated to get a new moment which is the same
*
* @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
*/
function inspect () {
if (!this.isValid()) {
return 'moment.invalid(/* ' + this._i + ' */)';
}
var func = 'moment';
var zone = '';
if (!this.isLocal()) {
func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
zone = 'Z';
}
var prefix = '[' + func + '("]';
var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
var datetime = '-MM-DD[T]HH:mm:ss.SSS';
var suffix = zone + '[")]';
return this.format(prefix + year + datetime + suffix);
}
function format (inputString) {
if (!inputString) {
inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
}
var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
function from (time, withoutSuffix) {
if (this.isValid() &&
((isMoment(time) && time.isValid()) ||
createLocal(time).isValid())) {
return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function fromNow (withoutSuffix) {
return this.from(createLocal(), withoutSuffix);
}
function to (time, withoutSuffix) {
if (this.isValid() &&
((isMoment(time) && time.isValid()) ||
createLocal(time).isValid())) {
return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function toNow (withoutSuffix) {
return this.to(createLocal(), withoutSuffix);
}
// If passed a locale key, it will set the locale for this
// instance. Otherwise, it will return the locale configuration
// variables for this instance.
function locale (key) {
var newLocaleData;
if (key === undefined) {
return this._locale._abbr;
} else {
newLocaleData = getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
}
return this;
}
}
var lang = deprecate(
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
function (key) {
if (key === undefined) {
return this.localeData();
} else {
return this.locale(key);
}
}
);
function localeData () {
return this._locale;
}
var MS_PER_SECOND = 1000;
var MS_PER_MINUTE = 60 * MS_PER_SECOND;
var MS_PER_HOUR = 60 * MS_PER_MINUTE;
var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
// actual modulo - handles negative numbers (for dates before 1970):
function mod$1(dividend, divisor) {
return (dividend % divisor + divisor) % divisor;
}
function localStartOfDate(y, m, d) {
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return new Date(y, m, d).valueOf();
}
}
function utcStartOfDate(y, m, d) {
// Date.UTC remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return Date.UTC(y, m, d);
}
}
function startOf (units) {
var time;
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
return this;
}
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case 'year':
time = startOfDate(this.year(), 0, 1);
break;
case 'quarter':
time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
break;
case 'month':
time = startOfDate(this.year(), this.month(), 1);
break;
case 'week':
time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
break;
case 'isoWeek':
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
break;
case 'day':
case 'date':
time = startOfDate(this.year(), this.month(), this.date());
break;
case 'hour':
time = this._d.valueOf();
time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
break;
case 'minute':
time = this._d.valueOf();
time -= mod$1(time, MS_PER_MINUTE);
break;
case 'second':
time = this._d.valueOf();
time -= mod$1(time, MS_PER_SECOND);
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function endOf (units) {
var time;
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
return this;
}
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case 'year':
time = startOfDate(this.year() + 1, 0, 1) - 1;
break;
case 'quarter':
time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
break;
case 'month':
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
break;
case 'week':
time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
break;
case 'isoWeek':
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
break;
case 'day':
case 'date':
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
break;
case 'hour':
time = this._d.valueOf();
time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
break;
case 'minute':
time = this._d.valueOf();
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
break;
case 'second':
time = this._d.valueOf();
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function valueOf () {
return this._d.valueOf() - ((this._offset || 0) * 60000);
}
function unix () {
return Math.floor(this.valueOf() / 1000);
}
function toDate () {
return new Date(this.valueOf());
}
function toArray () {
var m = this;
return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
}
function toObject () {
var m = this;
return {
years: m.year(),
months: m.month(),
date: m.date(),
hours: m.hours(),
minutes: m.minutes(),
seconds: m.seconds(),
milliseconds: m.milliseconds()
};
}
function toJSON () {
// new Date(NaN).toJSON() === null
return this.isValid() ? this.toISOString() : null;
}
function isValid$2 () {
return isValid(this);
}
function parsingFlags () {
return extend({}, getParsingFlags(this));
}
function invalidAt () {
return getParsingFlags(this).overflow;
}
function creationData() {
return {
input: this._i,
format: this._f,
locale: this._locale,
isUTC: this._isUTC,
strict: this._strict
};
}
// FORMATTING
addFormatToken(0, ['gg', 2], 0, function () {
return this.weekYear() % 100;
});
addFormatToken(0, ['GG', 2], 0, function () {
return this.isoWeekYear() % 100;
});
function addWeekYearFormatToken (token, getter) {
addFormatToken(0, [token, token.length], 0, getter);
}
addWeekYearFormatToken('gggg', 'weekYear');
addWeekYearFormatToken('ggggg', 'weekYear');
addWeekYearFormatToken('GGGG', 'isoWeekYear');
addWeekYearFormatToken('GGGGG', 'isoWeekYear');
// ALIASES
addUnitAlias('weekYear', 'gg');
addUnitAlias('isoWeekYear', 'GG');
// PRIORITY
addUnitPriority('weekYear', 1);
addUnitPriority('isoWeekYear', 1);
// PARSING
addRegexToken('G', matchSigned);
addRegexToken('g', matchSigned);
addRegexToken('GG', match1to2, match2);
addRegexToken('gg', match1to2, match2);
addRegexToken('GGGG', match1to4, match4);
addRegexToken('gggg', match1to4, match4);
addRegexToken('GGGGG', match1to6, match6);
addRegexToken('ggggg', match1to6, match6);
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
week[token.substr(0, 2)] = toInt(input);
});
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
week[token] = hooks.parseTwoDigitYear(input);
});
// MOMENTS
function getSetWeekYear (input) {
return getSetWeekYearHelper.call(this,
input,
this.week(),
this.weekday(),
this.localeData()._week.dow,
this.localeData()._week.doy);
}
function getSetISOWeekYear (input) {
return getSetWeekYearHelper.call(this,
input, this.isoWeek(), this.isoWeekday(), 1, 4);
}
function getISOWeeksInYear () {
return weeksInYear(this.year(), 1, 4);
}
function getWeeksInYear () {
var weekInfo = this.localeData()._week;
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
}
function getSetWeekYearHelper(input, week, weekday, dow, doy) {
var weeksTarget;
if (input == null) {
return weekOfYear(this, dow, doy).year;
} else {
weeksTarget = weeksInYear(input, dow, doy);
if (week > weeksTarget) {
week = weeksTarget;
}
return setWeekAll.call(this, input, week, weekday, dow, doy);
}
}
function setWeekAll(weekYear, week, weekday, dow, doy) {
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
return this;
}
// FORMATTING
addFormatToken('Q', 0, 'Qo', 'quarter');
// ALIASES
addUnitAlias('quarter', 'Q');
// PRIORITY
addUnitPriority('quarter', 7);
// PARSING
addRegexToken('Q', match1);
addParseToken('Q', function (input, array) {
array[MONTH] = (toInt(input) - 1) * 3;
});
// MOMENTS
function getSetQuarter (input) {
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
}
// FORMATTING
addFormatToken('D', ['DD', 2], 'Do', 'date');
// ALIASES
addUnitAlias('date', 'D');
// PRIORITY
addUnitPriority('date', 9);
// PARSING
addRegexToken('D', match1to2);
addRegexToken('DD', match1to2, match2);
addRegexToken('Do', function (isStrict, locale) {
// TODO: Remove "ordinalParse" fallback in next major release.
return isStrict ?
(locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
locale._dayOfMonthOrdinalParseLenient;
});
addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array) {
array[DATE] = toInt(input.match(match1to2)[0]);
});
// MOMENTS
var getSetDayOfMonth = makeGetSet('Date', true);
// FORMATTING
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
// ALIASES
addUnitAlias('dayOfYear', 'DDD');
// PRIORITY
addUnitPriority('dayOfYear', 4);
// PARSING
addRegexToken('DDD', match1to3);
addRegexToken('DDDD', match3);
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
config._dayOfYear = toInt(input);
});
// HELPERS
// MOMENTS
function getSetDayOfYear (input) {
var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
}
// FORMATTING
addFormatToken('m', ['mm', 2], 0, 'minute');
// ALIASES
addUnitAlias('minute', 'm');
// PRIORITY
addUnitPriority('minute', 14);
// PARSING
addRegexToken('m', match1to2);
addRegexToken('mm', match1to2, match2);
addParseToken(['m', 'mm'], MINUTE);
// MOMENTS
var getSetMinute = makeGetSet('Minutes', false);
// FORMATTING
addFormatToken('s', ['ss', 2], 0, 'second');
// ALIASES
addUnitAlias('second', 's');
// PRIORITY
addUnitPriority('second', 15);
// PARSING
addRegexToken('s', match1to2);
addRegexToken('ss', match1to2, match2);
addParseToken(['s', 'ss'], SECOND);
// MOMENTS
var getSetSecond = makeGetSet('Seconds', false);
// FORMATTING
addFormatToken('S', 0, 0, function () {
return ~~(this.millisecond() / 100);
});
addFormatToken(0, ['SS', 2], 0, function () {
return ~~(this.millisecond() / 10);
});
addFormatToken(0, ['SSS', 3], 0, 'millisecond');
addFormatToken(0, ['SSSS', 4], 0, function () {
return this.millisecond() * 10;
});
addFormatToken(0, ['SSSSS', 5], 0, function () {
return this.millisecond() * 100;
});
addFormatToken(0, ['SSSSSS', 6], 0, function () {
return this.millisecond() * 1000;
});
addFormatToken(0, ['SSSSSSS', 7], 0, function () {
return this.millisecond() * 10000;
});
addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
return this.millisecond() * 100000;
});
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
return this.millisecond() * 1000000;
});
// ALIASES
addUnitAlias('millisecond', 'ms');
// PRIORITY
addUnitPriority('millisecond', 16);
// PARSING
addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);
var token;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
addRegexToken(token, matchUnsigned);
}
function parseMs(input, array) {
array[MILLISECOND] = toInt(('0.' + input) * 1000);
}
for (token = 'S'; token.length <= 9; token += 'S') {
addParseToken(token, parseMs);
}
// MOMENTS
var getSetMillisecond = makeGetSet('Milliseconds', false);
// FORMATTING
addFormatToken('z', 0, 0, 'zoneAbbr');
addFormatToken('zz', 0, 0, 'zoneName');
// MOMENTS
function getZoneAbbr () {
return this._isUTC ? 'UTC' : '';
}
function getZoneName () {
return this._isUTC ? 'Coordinated Universal Time' : '';
}
var proto = Moment.prototype;
proto.add = add;
proto.calendar = calendar$1;
proto.clone = clone;
proto.diff = diff;
proto.endOf = endOf;
proto.format = format;
proto.from = from;
proto.fromNow = fromNow;
proto.to = to;
proto.toNow = toNow;
proto.get = stringGet;
proto.invalidAt = invalidAt;
proto.isAfter = isAfter;
proto.isBefore = isBefore;
proto.isBetween = isBetween;
proto.isSame = isSame;
proto.isSameOrAfter = isSameOrAfter;
proto.isSameOrBefore = isSameOrBefore;
proto.isValid = isValid$2;
proto.lang = lang;
proto.locale = locale;
proto.localeData = localeData;
proto.max = prototypeMax;
proto.min = prototypeMin;
proto.parsingFlags = parsingFlags;
proto.set = stringSet;
proto.startOf = startOf;
proto.subtract = subtract;
proto.toArray = toArray;
proto.toObject = toObject;
proto.toDate = toDate;
proto.toISOString = toISOString;
proto.inspect = inspect;
proto.toJSON = toJSON;
proto.toString = toString;
proto.unix = unix;
proto.valueOf = valueOf;
proto.creationData = creationData;
proto.year = getSetYear;
proto.isLeapYear = getIsLeapYear;
proto.weekYear = getSetWeekYear;
proto.isoWeekYear = getSetISOWeekYear;
proto.quarter = proto.quarters = getSetQuarter;
proto.month = getSetMonth;
proto.daysInMonth = getDaysInMonth;
proto.week = proto.weeks = getSetWeek;
proto.isoWeek = proto.isoWeeks = getSetISOWeek;
proto.weeksInYear = getWeeksInYear;
proto.isoWeeksInYear = getISOWeeksInYear;
proto.date = getSetDayOfMonth;
proto.day = proto.days = getSetDayOfWeek;
proto.weekday = getSetLocaleDayOfWeek;
proto.isoWeekday = getSetISODayOfWeek;
proto.dayOfYear = getSetDayOfYear;
proto.hour = proto.hours = getSetHour;
proto.minute = proto.minutes = getSetMinute;
proto.second = proto.seconds = getSetSecond;
proto.millisecond = proto.milliseconds = getSetMillisecond;
proto.utcOffset = getSetOffset;
proto.utc = setOffsetToUTC;
proto.local = setOffsetToLocal;
proto.parseZone = setOffsetToParsedOffset;
proto.hasAlignedHourOffset = hasAlignedHourOffset;
proto.isDST = isDaylightSavingTime;
proto.isLocal = isLocal;
proto.isUtcOffset = isUtcOffset;
proto.isUtc = isUtc;
proto.isUTC = isUtc;
proto.zoneAbbr = getZoneAbbr;
proto.zoneName = getZoneName;
proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
function createUnix (input) {
return createLocal(input * 1000);
}
function createInZone () {
return createLocal.apply(null, arguments).parseZone();
}
function preParsePostFormat (string) {
return string;
}
var proto$1 = Locale.prototype;
proto$1.calendar = calendar;
proto$1.longDateFormat = longDateFormat;
proto$1.invalidDate = invalidDate;
proto$1.ordinal = ordinal;
proto$1.preparse = preParsePostFormat;
proto$1.postformat = preParsePostFormat;
proto$1.relativeTime = relativeTime;
proto$1.pastFuture = pastFuture;
proto$1.set = set;
proto$1.months = localeMonths;
proto$1.monthsShort = localeMonthsShort;
proto$1.monthsParse = localeMonthsParse;
proto$1.monthsRegex = monthsRegex;
proto$1.monthsShortRegex = monthsShortRegex;
proto$1.week = localeWeek;
proto$1.firstDayOfYear = localeFirstDayOfYear;
proto$1.firstDayOfWeek = localeFirstDayOfWeek;
proto$1.weekdays = localeWeekdays;
proto$1.weekdaysMin = localeWeekdaysMin;
proto$1.weekdaysShort = localeWeekdaysShort;
proto$1.weekdaysParse = localeWeekdaysParse;
proto$1.weekdaysRegex = weekdaysRegex;
proto$1.weekdaysShortRegex = weekdaysShortRegex;
proto$1.weekdaysMinRegex = weekdaysMinRegex;
proto$1.isPM = localeIsPM;
proto$1.meridiem = localeMeridiem;
function get$1 (format, index, field, setter) {
var locale = getLocale();
var utc = createUTC().set(setter, index);
return locale[field](utc, format);
}
function listMonthsImpl (format, index, field) {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
if (index != null) {
return get$1(format, index, field, 'month');
}
var i;
var out = [];
for (i = 0; i < 12; i++) {
out[i] = get$1(format, i, field, 'month');
}
return out;
}
// ()
// (5)
// (fmt, 5)
// (fmt)
// (true)
// (true, 5)
// (true, fmt, 5)
// (true, fmt)
function listWeekdaysImpl (localeSorted, format, index, field) {
if (typeof localeSorted === 'boolean') {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
} else {
format = localeSorted;
index = format;
localeSorted = false;
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
}
var locale = getLocale(),
shift = localeSorted ? locale._week.dow : 0;
if (index != null) {
return get$1(format, (index + shift) % 7, field, 'day');
}
var i;
var out = [];
for (i = 0; i < 7; i++) {
out[i] = get$1(format, (i + shift) % 7, field, 'day');
}
return out;
}
function listMonths (format, index) {
return listMonthsImpl(format, index, 'months');
}
function listMonthsShort (format, index) {
return listMonthsImpl(format, index, 'monthsShort');
}
function listWeekdays (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
}
function listWeekdaysShort (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
}
function listWeekdaysMin (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
getSetGlobalLocale('en', {
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
output = (toInt(number % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';
return number + output;
}
});
// Side effect imports
hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
var mathAbs = Math.abs;
function abs () {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
this._days = mathAbs(this._days);
this._months = mathAbs(this._months);
data.milliseconds = mathAbs(data.milliseconds);
data.seconds = mathAbs(data.seconds);
data.minutes = mathAbs(data.minutes);
data.hours = mathAbs(data.hours);
data.months = mathAbs(data.months);
data.years = mathAbs(data.years);
return this;
}
function addSubtract$1 (duration, input, value, direction) {
var other = createDuration(input, value);
duration._milliseconds += direction * other._milliseconds;
duration._days += direction * other._days;
duration._months += direction * other._months;
return duration._bubble();
}
// supports only 2.0-style add(1, 's') or add(duration)
function add$1 (input, value) {
return addSubtract$1(this, input, value, 1);
}
// supports only 2.0-style subtract(1, 's') or subtract(duration)
function subtract$1 (input, value) {
return addSubtract$1(this, input, value, -1);
}
function absCeil (number) {
if (number < 0) {
return Math.floor(number);
} else {
return Math.ceil(number);
}
}
function bubble () {
var milliseconds = this._milliseconds;
var days = this._days;
var months = this._months;
var data = this._data;
var seconds, minutes, hours, years, monthsFromDays;
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
(milliseconds <= 0 && days <= 0 && months <= 0))) {
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
days = 0;
months = 0;
}
// The following code bubbles up values, see the tests for
// examples of what that means.
data.milliseconds = milliseconds % 1000;
seconds = absFloor(milliseconds / 1000);
data.seconds = seconds % 60;
minutes = absFloor(seconds / 60);
data.minutes = minutes % 60;
hours = absFloor(minutes / 60);
data.hours = hours % 24;
days += absFloor(hours / 24);
// convert days to months
monthsFromDays = absFloor(daysToMonths(days));
months += monthsFromDays;
days -= absCeil(monthsToDays(monthsFromDays));
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
data.days = days;
data.months = months;
data.years = years;
return this;
}
function daysToMonths (days) {
// 400 years have 146097 days (taking into account leap year rules)
// 400 years have 12 months === 4800
return days * 4800 / 146097;
}
function monthsToDays (months) {
// the reverse of daysToMonths
return months * 146097 / 4800;
}
function as (units) {
if (!this.isValid()) {
return NaN;
}
var days;
var months;
var milliseconds = this._milliseconds;
units = normalizeUnits(units);
if (units === 'month' || units === 'quarter' || units === 'year') {
days = this._days + milliseconds / 864e5;
months = this._months + daysToMonths(days);
switch (units) {
case 'month': return months;
case 'quarter': return months / 3;
case 'year': return months / 12;
}
} else {
// handle milliseconds separately because of floating point math errors (issue #1867)
days = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case 'week' : return days / 7 + milliseconds / 6048e5;
case 'day' : return days + milliseconds / 864e5;
case 'hour' : return days * 24 + milliseconds / 36e5;
case 'minute' : return days * 1440 + milliseconds / 6e4;
case 'second' : return days * 86400 + milliseconds / 1000;
// Math.floor prevents floating point math errors here
case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
default: throw new Error('Unknown unit ' + units);
}
}
}
// TODO: Use this.as('ms')?
function valueOf$1 () {
if (!this.isValid()) {
return NaN;
}
return (
this._milliseconds +
this._days * 864e5 +
(this._months % 12) * 2592e6 +
toInt(this._months / 12) * 31536e6
);
}
function makeAs (alias) {
return function () {
return this.as(alias);
};
}
var asMilliseconds = makeAs('ms');
var asSeconds = makeAs('s');
var asMinutes = makeAs('m');
var asHours = makeAs('h');
var asDays = makeAs('d');
var asWeeks = makeAs('w');
var asMonths = makeAs('M');
var asQuarters = makeAs('Q');
var asYears = makeAs('y');
function clone$1 () {
return createDuration(this);
}
function get$2 (units) {
units = normalizeUnits(units);
return this.isValid() ? this[units + 's']() : NaN;
}
function makeGetter(name) {
return function () {
return this.isValid() ? this._data[name] : NaN;
};
}
var milliseconds = makeGetter('milliseconds');
var seconds = makeGetter('seconds');
var minutes = makeGetter('minutes');
var hours = makeGetter('hours');
var days = makeGetter('days');
var months = makeGetter('months');
var years = makeGetter('years');
function weeks () {
return absFloor(this.days() / 7);
}
var round = Math.round;
var thresholds = {
ss: 44, // a few seconds to seconds
s : 45, // seconds to minute
m : 45, // minutes to hour
h : 22, // hours to day
d : 26, // days to month
M : 11 // months to year
};
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
var duration = createDuration(posNegDuration).abs();
var seconds = round(duration.as('s'));
var minutes = round(duration.as('m'));
var hours = round(duration.as('h'));
var days = round(duration.as('d'));
var months = round(duration.as('M'));
var years = round(duration.as('y'));
var a = seconds <= thresholds.ss && ['s', seconds] ||
seconds < thresholds.s && ['ss', seconds] ||
minutes <= 1 && ['m'] ||
minutes < thresholds.m && ['mm', minutes] ||
hours <= 1 && ['h'] ||
hours < thresholds.h && ['hh', hours] ||
days <= 1 && ['d'] ||
days < thresholds.d && ['dd', days] ||
months <= 1 && ['M'] ||
months < thresholds.M && ['MM', months] ||
years <= 1 && ['y'] || ['yy', years];
a[2] = withoutSuffix;
a[3] = +posNegDuration > 0;
a[4] = locale;
return substituteTimeAgo.apply(null, a);
}
// This function allows you to set the rounding function for relative time strings
function getSetRelativeTimeRounding (roundingFunction) {
if (roundingFunction === undefined) {
return round;
}
if (typeof(roundingFunction) === 'function') {
round = roundingFunction;
return true;
}
return false;
}
// This function allows you to set a threshold for relative time strings
function getSetRelativeTimeThreshold (threshold, limit) {
if (thresholds[threshold] === undefined) {
return false;
}
if (limit === undefined) {
return thresholds[threshold];
}
thresholds[threshold] = limit;
if (threshold === 's') {
thresholds.ss = limit - 1;
}
return true;
}
function humanize (withSuffix) {
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var locale = this.localeData();
var output = relativeTime$1(this, !withSuffix, locale);
if (withSuffix) {
output = locale.pastFuture(+this, output);
}
return locale.postformat(output);
}
var abs$1 = Math.abs;
function sign(x) {
return ((x > 0) - (x < 0)) || +x;
}
function toISOString$1() {
// for ISO strings we do not use the normal bubbling rules:
// * milliseconds bubble up until they become hours
// * days do not bubble at all
// * months bubble up until they become years
// This is because there is no context-free conversion between hours and days
// (think of clock changes)
// and also not between days and months (28-31 days per month)
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var seconds = abs$1(this._milliseconds) / 1000;
var days = abs$1(this._days);
var months = abs$1(this._months);
var minutes, hours, years;
// 3600 seconds -> 60 minutes -> 1 hour
minutes = absFloor(seconds / 60);
hours = absFloor(minutes / 60);
seconds %= 60;
minutes %= 60;
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
var Y = years;
var M = months;
var D = days;
var h = hours;
var m = minutes;
var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
var total = this.asSeconds();
if (!total) {
// this is the same as C#'s (Noda) and python (isodate)...
// but not other JS (goog.date)
return 'P0D';
}
var totalSign = total < 0 ? '-' : '';
var ymSign = sign(this._months) !== sign(total) ? '-' : '';
var daysSign = sign(this._days) !== sign(total) ? '-' : '';
var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
return totalSign + 'P' +
(Y ? ymSign + Y + 'Y' : '') +
(M ? ymSign + M + 'M' : '') +
(D ? daysSign + D + 'D' : '') +
((h || m || s) ? 'T' : '') +
(h ? hmsSign + h + 'H' : '') +
(m ? hmsSign + m + 'M' : '') +
(s ? hmsSign + s + 'S' : '');
}
var proto$2 = Duration.prototype;
proto$2.isValid = isValid$1;
proto$2.abs = abs;
proto$2.add = add$1;
proto$2.subtract = subtract$1;
proto$2.as = as;
proto$2.asMilliseconds = asMilliseconds;
proto$2.asSeconds = asSeconds;
proto$2.asMinutes = asMinutes;
proto$2.asHours = asHours;
proto$2.asDays = asDays;
proto$2.asWeeks = asWeeks;
proto$2.asMonths = asMonths;
proto$2.asQuarters = asQuarters;
proto$2.asYears = asYears;
proto$2.valueOf = valueOf$1;
proto$2._bubble = bubble;
proto$2.clone = clone$1;
proto$2.get = get$2;
proto$2.milliseconds = milliseconds;
proto$2.seconds = seconds;
proto$2.minutes = minutes;
proto$2.hours = hours;
proto$2.days = days;
proto$2.weeks = weeks;
proto$2.months = months;
proto$2.years = years;
proto$2.humanize = humanize;
proto$2.toISOString = toISOString$1;
proto$2.toString = toISOString$1;
proto$2.toJSON = toISOString$1;
proto$2.locale = locale;
proto$2.localeData = localeData;
proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
proto$2.lang = lang;
// Side effect imports
// FORMATTING
addFormatToken('X', 0, 0, 'unix');
addFormatToken('x', 0, 0, 'valueOf');
// PARSING
addRegexToken('x', matchSigned);
addRegexToken('X', matchTimestamp);
addParseToken('X', function (input, array, config) {
config._d = new Date(parseFloat(input, 10) * 1000);
});
addParseToken('x', function (input, array, config) {
config._d = new Date(toInt(input));
});
// Side effect imports
hooks.version = '2.24.0';
setHookCallback(createLocal);
hooks.fn = proto;
hooks.min = min;
hooks.max = max;
hooks.now = now;
hooks.utc = createUTC;
hooks.unix = createUnix;
hooks.months = listMonths;
hooks.isDate = isDate;
hooks.locale = getSetGlobalLocale;
hooks.invalid = createInvalid;
hooks.duration = createDuration;
hooks.isMoment = isMoment;
hooks.weekdays = listWeekdays;
hooks.parseZone = createInZone;
hooks.localeData = getLocale;
hooks.isDuration = isDuration;
hooks.monthsShort = listMonthsShort;
hooks.weekdaysMin = listWeekdaysMin;
hooks.defineLocale = defineLocale;
hooks.updateLocale = updateLocale;
hooks.locales = listLocales;
hooks.weekdaysShort = listWeekdaysShort;
hooks.normalizeUnits = normalizeUnits;
hooks.relativeTimeRounding = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat = getCalendarFormat;
hooks.prototype = proto;
// currently HTML5 input type only supports 24-hour formats
hooks.HTML5_FMT = {
DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', //
DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', //
DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', //
DATE: 'YYYY-MM-DD', //
TIME: 'HH:mm', //
TIME_SECONDS: 'HH:mm:ss', //
TIME_MS: 'HH:mm:ss.SSS', //
WEEK: 'GGGG-[W]WW', //
MONTH: 'YYYY-MM' //
};
return hooks;
})));
/***/ }),
/* 25 */
/***/ (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 || Function("return this")() || (1,eval)("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;
/***/ }),
/* 26 */
/***/ (function(module, exports) {
//
module.exports = function shallowEqual(objA, objB, compare, compareContext) {
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
if (ret !== void 0) {
return !!ret;
}
if (objA === objB) {
return true;
}
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
// Test for A's keys different from B.
for (var idx = 0; idx < keysA.length; idx++) {
var key = keysA[idx];
if (!bHasOwnProperty(key)) {
return false;
}
var valueA = objA[key];
var valueB = objB[key];
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
if (ret === false || (ret === void 0 && valueA !== valueB)) {
return false;
}
}
return true;
};
/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/***/ }),
/* 28 */
/***/ (function(module, exports) {
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
module.exports = isObject;
/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {
var freeGlobal = __webpack_require__(287);
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
module.exports = root;
/***/ }),
/* 30 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__ = __webpack_require__(508);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__AnimateChild__ = __webpack_require__(509);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_animate__ = __webpack_require__(261);
var defaultKey = 'rc_animate_' + Date.now();
function getChildrenFromProps(props) {
var children = props.children;
if (__WEBPACK_IMPORTED_MODULE_6_react___default.a.isValidElement(children)) {
if (!children.key) {
return __WEBPACK_IMPORTED_MODULE_6_react___default.a.cloneElement(children, {
key: defaultKey
});
}
}
return children;
}
function noop() {}
var Animate = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_inherits___default()(Animate, _React$Component);
// eslint-disable-line
function Animate(props) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default()(this, Animate);
var _this = __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_possibleConstructorReturn___default()(this, (Animate.__proto__ || Object.getPrototypeOf(Animate)).call(this, props));
_initialiseProps.call(_this);
_this.currentlyAnimatingKeys = {};
_this.keysToEnter = [];
_this.keysToLeave = [];
_this.state = {
children: Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["e" /* toArrayChildren */])(getChildrenFromProps(props))
};
_this.childrenRefs = {};
return _this;
}
__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default()(Animate, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
var showProp = this.props.showProp;
var children = this.state.children;
if (showProp) {
children = children.filter(function (child) {
return !!child.props[showProp];
});
}
children.forEach(function (child) {
if (child) {
_this2.performAppear(child.key);
}
});
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
var _this3 = this;
this.nextProps = nextProps;
var nextChildren = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["e" /* toArrayChildren */])(getChildrenFromProps(nextProps));
var props = this.props;
// exclusive needs immediate response
if (props.exclusive) {
Object.keys(this.currentlyAnimatingKeys).forEach(function (key) {
_this3.stop(key);
});
}
var showProp = props.showProp;
var currentlyAnimatingKeys = this.currentlyAnimatingKeys;
// last props children if exclusive
var currentChildren = props.exclusive ? Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["e" /* toArrayChildren */])(getChildrenFromProps(props)) : this.state.children;
// in case destroy in showProp mode
var newChildren = [];
if (showProp) {
currentChildren.forEach(function (currentChild) {
var nextChild = currentChild && Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["a" /* findChildInChildrenByKey */])(nextChildren, currentChild.key);
var newChild = void 0;
if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) {
newChild = __WEBPACK_IMPORTED_MODULE_6_react___default.a.cloneElement(nextChild || currentChild, __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty___default()({}, showProp, true));
} else {
newChild = nextChild;
}
if (newChild) {
newChildren.push(newChild);
}
});
nextChildren.forEach(function (nextChild) {
if (!nextChild || !Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["a" /* findChildInChildrenByKey */])(currentChildren, nextChild.key)) {
newChildren.push(nextChild);
}
});
} else {
newChildren = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["d" /* mergeChildren */])(currentChildren, nextChildren);
}
// need render to avoid update
this.setState({
children: newChildren
});
nextChildren.forEach(function (child) {
var key = child && child.key;
if (child && currentlyAnimatingKeys[key]) {
return;
}
var hasPrev = child && Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["a" /* findChildInChildrenByKey */])(currentChildren, key);
if (showProp) {
var showInNext = child.props[showProp];
if (hasPrev) {
var showInNow = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["b" /* findShownChildInChildrenByKey */])(currentChildren, key, showProp);
if (!showInNow && showInNext) {
_this3.keysToEnter.push(key);
}
} else if (showInNext) {
_this3.keysToEnter.push(key);
}
} else if (!hasPrev) {
_this3.keysToEnter.push(key);
}
});
currentChildren.forEach(function (child) {
var key = child && child.key;
if (child && currentlyAnimatingKeys[key]) {
return;
}
var hasNext = child && Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["a" /* findChildInChildrenByKey */])(nextChildren, key);
if (showProp) {
var showInNow = child.props[showProp];
if (hasNext) {
var showInNext = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["b" /* findShownChildInChildrenByKey */])(nextChildren, key, showProp);
if (!showInNext && showInNow) {
_this3.keysToLeave.push(key);
}
} else if (showInNow) {
_this3.keysToLeave.push(key);
}
} else if (!hasNext) {
_this3.keysToLeave.push(key);
}
});
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate() {
var keysToEnter = this.keysToEnter;
this.keysToEnter = [];
keysToEnter.forEach(this.performEnter);
var keysToLeave = this.keysToLeave;
this.keysToLeave = [];
keysToLeave.forEach(this.performLeave);
}
}, {
key: 'isValidChildByKey',
value: function isValidChildByKey(currentChildren, key) {
var showProp = this.props.showProp;
if (showProp) {
return Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["b" /* findShownChildInChildrenByKey */])(currentChildren, key, showProp);
}
return Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["a" /* findChildInChildrenByKey */])(currentChildren, key);
}
}, {
key: 'stop',
value: function stop(key) {
delete this.currentlyAnimatingKeys[key];
var component = this.childrenRefs[key];
if (component) {
component.stop();
}
}
}, {
key: 'render',
value: function render() {
var _this4 = this;
var props = this.props;
this.nextProps = props;
var stateChildren = this.state.children;
var children = null;
if (stateChildren) {
children = stateChildren.map(function (child) {
if (child === null || child === undefined) {
return child;
}
if (!child.key) {
throw new Error('must set key for children');
}
return __WEBPACK_IMPORTED_MODULE_6_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_9__AnimateChild__["a" /* default */],
{
key: child.key,
ref: function ref(node) {
_this4.childrenRefs[child.key] = node;
},
animation: props.animation,
transitionName: props.transitionName,
transitionEnter: props.transitionEnter,
transitionAppear: props.transitionAppear,
transitionLeave: props.transitionLeave
},
child
);
});
}
var Component = props.component;
if (Component) {
var passedProps = props;
if (typeof Component === 'string') {
passedProps = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({
className: props.className,
style: props.style
}, props.componentProps);
}
return __WEBPACK_IMPORTED_MODULE_6_react___default.a.createElement(
Component,
passedProps,
children
);
}
return children[0] || null;
}
}]);
return Animate;
}(__WEBPACK_IMPORTED_MODULE_6_react___default.a.Component);
Animate.isAnimate = true;
Animate.propTypes = {
component: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.any,
componentProps: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.object,
animation: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.object,
transitionName: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.object]),
transitionEnter: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,
transitionAppear: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,
exclusive: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,
transitionLeave: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,
onEnd: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,
onEnter: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,
onLeave: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,
onAppear: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,
showProp: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.string,
children: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.node
};
Animate.defaultProps = {
animation: {},
component: 'span',
componentProps: {},
transitionEnter: true,
transitionLeave: true,
transitionAppear: false,
onEnd: noop,
onEnter: noop,
onLeave: noop,
onAppear: noop
};
var _initialiseProps = function _initialiseProps() {
var _this5 = this;
this.performEnter = function (key) {
// may already remove by exclusive
if (_this5.childrenRefs[key]) {
_this5.currentlyAnimatingKeys[key] = true;
_this5.childrenRefs[key].componentWillEnter(_this5.handleDoneAdding.bind(_this5, key, 'enter'));
}
};
this.performAppear = function (key) {
if (_this5.childrenRefs[key]) {
_this5.currentlyAnimatingKeys[key] = true;
_this5.childrenRefs[key].componentWillAppear(_this5.handleDoneAdding.bind(_this5, key, 'appear'));
}
};
this.handleDoneAdding = function (key, type) {
var props = _this5.props;
delete _this5.currentlyAnimatingKeys[key];
// if update on exclusive mode, skip check
if (props.exclusive && props !== _this5.nextProps) {
return;
}
var currentChildren = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["e" /* toArrayChildren */])(getChildrenFromProps(props));
if (!_this5.isValidChildByKey(currentChildren, key)) {
// exclusive will not need this
_this5.performLeave(key);
} else if (type === 'appear') {
if (__WEBPACK_IMPORTED_MODULE_10__util_animate__["a" /* default */].allowAppearCallback(props)) {
props.onAppear(key);
props.onEnd(key, true);
}
} else if (__WEBPACK_IMPORTED_MODULE_10__util_animate__["a" /* default */].allowEnterCallback(props)) {
props.onEnter(key);
props.onEnd(key, true);
}
};
this.performLeave = function (key) {
// may already remove by exclusive
if (_this5.childrenRefs[key]) {
_this5.currentlyAnimatingKeys[key] = true;
_this5.childrenRefs[key].componentWillLeave(_this5.handleDoneLeaving.bind(_this5, key));
}
};
this.handleDoneLeaving = function (key) {
var props = _this5.props;
delete _this5.currentlyAnimatingKeys[key];
// if update on exclusive mode, skip check
if (props.exclusive && props !== _this5.nextProps) {
return;
}
var currentChildren = Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["e" /* toArrayChildren */])(getChildrenFromProps(props));
// in case state change is too fast
if (_this5.isValidChildByKey(currentChildren, key)) {
_this5.performEnter(key);
} else {
var end = function end() {
if (__WEBPACK_IMPORTED_MODULE_10__util_animate__["a" /* default */].allowLeaveCallback(props)) {
props.onLeave(key);
props.onEnd(key, false);
}
};
if (!Object(__WEBPACK_IMPORTED_MODULE_8__ChildrenUtils__["c" /* isSameChildren */])(_this5.state.children, currentChildren, props.showProp)) {
_this5.setState({
children: currentChildren
}, end);
} else {
end();
}
}
};
};
/* harmony default export */ __webpack_exports__["a"] = (Animate);
/***/ }),
/* 31 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__required__ = __webpack_require__(322);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__whitespace__ = __webpack_require__(686);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__type__ = __webpack_require__(687);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__range__ = __webpack_require__(688);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__enum__ = __webpack_require__(689);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__pattern__ = __webpack_require__(690);
/* harmony default export */ __webpack_exports__["a"] = ({
required: __WEBPACK_IMPORTED_MODULE_0__required__["a" /* default */],
whitespace: __WEBPACK_IMPORTED_MODULE_1__whitespace__["a" /* default */],
type: __WEBPACK_IMPORTED_MODULE_2__type__["a" /* default */],
range: __WEBPACK_IMPORTED_MODULE_3__range__["a" /* default */],
'enum': __WEBPACK_IMPORTED_MODULE_4__enum__["a" /* default */],
pattern: __WEBPACK_IMPORTED_MODULE_5__pattern__["a" /* default */]
});
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftModifier
* @format
*
*/
var CharacterMetadata = __webpack_require__(36);
var ContentStateInlineStyle = __webpack_require__(900);
var DraftFeatureFlags = __webpack_require__(61);
var Immutable = __webpack_require__(14);
var applyEntityToContentState = __webpack_require__(901);
var getCharacterRemovalRange = __webpack_require__(903);
var getContentStateFragment = __webpack_require__(139);
var insertFragmentIntoContentState = __webpack_require__(906);
var insertTextIntoContentState = __webpack_require__(907);
var invariant = __webpack_require__(13);
var modifyBlockForContentState = __webpack_require__(908);
var removeEntitiesAtEdges = __webpack_require__(376);
var removeRangeFromContentState = __webpack_require__(909);
var splitBlockInContentState = __webpack_require__(910);
var OrderedSet = Immutable.OrderedSet;
/**
* `DraftModifier` provides a set of convenience methods that apply
* modifications to a `ContentState` object based on a target `SelectionState`.
*
* Any change to a `ContentState` should be decomposable into a series of
* transaction functions that apply the required changes and return output
* `ContentState` objects.
*
* These functions encapsulate some of the most common transaction sequences.
*/
var DraftModifier = {
replaceText: function replaceText(contentState, rangeToReplace, text, inlineStyle, entityKey) {
var withoutEntities = removeEntitiesAtEdges(contentState, rangeToReplace);
var withoutText = removeRangeFromContentState(withoutEntities, rangeToReplace);
var character = CharacterMetadata.create({
style: inlineStyle || OrderedSet(),
entity: entityKey || null
});
return insertTextIntoContentState(withoutText, withoutText.getSelectionAfter(), text, character);
},
insertText: function insertText(contentState, targetRange, text, inlineStyle, entityKey) {
!targetRange.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Target range must be collapsed for `insertText`.') : invariant(false) : void 0;
return DraftModifier.replaceText(contentState, targetRange, text, inlineStyle, entityKey);
},
moveText: function moveText(contentState, removalRange, targetRange) {
var movedFragment = getContentStateFragment(contentState, removalRange);
var afterRemoval = DraftModifier.removeRange(contentState, removalRange, 'backward');
return DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
},
replaceWithFragment: function replaceWithFragment(contentState, targetRange, fragment) {
var withoutEntities = removeEntitiesAtEdges(contentState, targetRange);
var withoutText = removeRangeFromContentState(withoutEntities, targetRange);
return insertFragmentIntoContentState(withoutText, withoutText.getSelectionAfter(), fragment);
},
removeRange: function removeRange(contentState, rangeToRemove, removalDirection) {
var startKey = void 0,
endKey = void 0,
startBlock = void 0,
endBlock = void 0;
if (rangeToRemove.getIsBackward()) {
rangeToRemove = rangeToRemove.merge({
anchorKey: rangeToRemove.getFocusKey(),
anchorOffset: rangeToRemove.getFocusOffset(),
focusKey: rangeToRemove.getAnchorKey(),
focusOffset: rangeToRemove.getAnchorOffset(),
isBackward: false
});
}
startKey = rangeToRemove.getAnchorKey();
endKey = rangeToRemove.getFocusKey();
startBlock = contentState.getBlockForKey(startKey);
endBlock = contentState.getBlockForKey(endKey);
var startOffset = rangeToRemove.getStartOffset();
var endOffset = rangeToRemove.getEndOffset();
var startEntityKey = startBlock.getEntityAt(startOffset);
var endEntityKey = endBlock.getEntityAt(endOffset - 1);
// Check whether the selection state overlaps with a single entity.
// If so, try to remove the appropriate substring of the entity text.
if (startKey === endKey) {
if (startEntityKey && startEntityKey === endEntityKey) {
var _adjustedRemovalRange = getCharacterRemovalRange(contentState.getEntityMap(), startBlock, endBlock, rangeToRemove, removalDirection);
return removeRangeFromContentState(contentState, _adjustedRemovalRange);
}
}
var adjustedRemovalRange = rangeToRemove;
if (DraftFeatureFlags.draft_segmented_entities_behavior) {
// Adjust the selection to properly delete segemented and immutable
// entities
adjustedRemovalRange = getCharacterRemovalRange(contentState.getEntityMap(), startBlock, endBlock, rangeToRemove, removalDirection);
}
var withoutEntities = removeEntitiesAtEdges(contentState, adjustedRemovalRange);
return removeRangeFromContentState(withoutEntities, adjustedRemovalRange);
},
splitBlock: function splitBlock(contentState, selectionState) {
var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
var withoutText = removeRangeFromContentState(withoutEntities, selectionState);
return splitBlockInContentState(withoutText, withoutText.getSelectionAfter());
},
applyInlineStyle: function applyInlineStyle(contentState, selectionState, inlineStyle) {
return ContentStateInlineStyle.add(contentState, selectionState, inlineStyle);
},
removeInlineStyle: function removeInlineStyle(contentState, selectionState, inlineStyle) {
return ContentStateInlineStyle.remove(contentState, selectionState, inlineStyle);
},
setBlockType: function setBlockType(contentState, selectionState, blockType) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ type: blockType, depth: 0 });
});
},
setBlockData: function setBlockData(contentState, selectionState, blockData) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ data: blockData });
});
},
mergeBlockData: function mergeBlockData(contentState, selectionState, blockData) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ data: block.getData().merge(blockData) });
});
},
applyEntity: function applyEntity(contentState, selectionState, entityKey) {
var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
return applyEntityToContentState(withoutEntities, selectionState, entityKey);
}
};
module.exports = DraftModifier;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 33 */
/***/ (function(module, exports) {
var core = module.exports = { version: '2.6.5' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
/***/ }),
/* 34 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LocaleReceiver; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__default__ = __webpack_require__(80);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var LocaleReceiver =
/*#__PURE__*/
function (_React$Component) {
_inherits(LocaleReceiver, _React$Component);
function LocaleReceiver() {
_classCallCheck(this, LocaleReceiver);
return _possibleConstructorReturn(this, _getPrototypeOf(LocaleReceiver).apply(this, arguments));
}
_createClass(LocaleReceiver, [{
key: "getLocale",
value: function getLocale() {
var _this$props = this.props,
componentName = _this$props.componentName,
defaultLocale = _this$props.defaultLocale;
var locale = defaultLocale || __WEBPACK_IMPORTED_MODULE_2__default__["a" /* default */][componentName || 'global'];
var antLocale = this.context.antLocale;
var localeFromContext = componentName && antLocale ? antLocale[componentName] : {};
return _extends({}, typeof locale === 'function' ? locale() : locale, localeFromContext || {});
}
}, {
key: "getLocaleCode",
value: function getLocaleCode() {
var antLocale = this.context.antLocale;
var localeCode = antLocale && antLocale.locale; // Had use LocaleProvide but didn't set locale
if (antLocale && antLocale.exist && !localeCode) {
return __WEBPACK_IMPORTED_MODULE_2__default__["a" /* default */].locale;
}
return localeCode;
}
}, {
key: "render",
value: function render() {
return this.props.children(this.getLocale(), this.getLocaleCode());
}
}]);
return LocaleReceiver;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
LocaleReceiver.defaultProps = {
componentName: 'global'
};
LocaleReceiver.contextTypes = {
antLocale: __WEBPACK_IMPORTED_MODULE_1_prop_types__["object"]
};
/***/ }),
/* 35 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = toArray;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
function toArray(children) {
var ret = [];
__WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.forEach(children, function (c) {
ret.push(c);
});
return ret;
}
/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule CharacterMetadata
* @format
*
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _require = __webpack_require__(14),
Map = _require.Map,
OrderedSet = _require.OrderedSet,
Record = _require.Record;
// Immutable.map is typed such that the value for every key in the map
// must be the same type
var EMPTY_SET = OrderedSet();
var defaultRecord = {
style: EMPTY_SET,
entity: null
};
var CharacterMetadataRecord = Record(defaultRecord);
var CharacterMetadata = function (_CharacterMetadataRec) {
_inherits(CharacterMetadata, _CharacterMetadataRec);
function CharacterMetadata() {
_classCallCheck(this, CharacterMetadata);
return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
}
CharacterMetadata.prototype.getStyle = function getStyle() {
return this.get('style');
};
CharacterMetadata.prototype.getEntity = function getEntity() {
return this.get('entity');
};
CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
return this.getStyle().includes(style);
};
CharacterMetadata.applyStyle = function applyStyle(record, style) {
var withStyle = record.set('style', record.getStyle().add(style));
return CharacterMetadata.create(withStyle);
};
CharacterMetadata.removeStyle = function removeStyle(record, style) {
var withoutStyle = record.set('style', record.getStyle().remove(style));
return CharacterMetadata.create(withoutStyle);
};
CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
return CharacterMetadata.create(withEntity);
};
/**
* Use this function instead of the `CharacterMetadata` constructor.
* Since most content generally uses only a very small number of
* style/entity permutations, we can reuse these objects as often as
* possible.
*/
CharacterMetadata.create = function create(config) {
if (!config) {
return EMPTY;
}
var defaultConfig = {
style: EMPTY_SET,
entity: null
};
// Fill in unspecified properties, if necessary.
var configMap = Map(defaultConfig).merge(config);
var existing = pool.get(configMap);
if (existing) {
return existing;
}
var newCharacter = new CharacterMetadata(configMap);
pool = pool.set(configMap, newCharacter);
return newCharacter;
};
return CharacterMetadata;
}(CharacterMetadataRecord);
var EMPTY = new CharacterMetadata();
var pool = Map([[Map(defaultRecord), EMPTY]]);
CharacterMetadata.EMPTY = EMPTY;
module.exports = CharacterMetadata;
/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ContentBlockNode
* @format
*
*
* This file is a fork of ContentBlock adding support for nesting references by
* providing links to children, parent, prevSibling, and nextSibling.
*
* This is unstable and not part of the public API and should not be used by
* production systems. This file may be update/removed without notice.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CharacterMetadata = __webpack_require__(36);
var Immutable = __webpack_require__(14);
var findRangesImmutable = __webpack_require__(105);
var List = Immutable.List,
Map = Immutable.Map,
OrderedSet = Immutable.OrderedSet,
Record = Immutable.Record,
Repeat = Immutable.Repeat;
var EMPTY_SET = OrderedSet();
var defaultRecord = {
parent: null,
characterList: List(),
data: Map(),
depth: 0,
key: '',
text: '',
type: 'unstyled',
children: List(),
prevSibling: null,
nextSibling: null
};
var haveEqualStyle = function haveEqualStyle(charA, charB) {
return charA.getStyle() === charB.getStyle();
};
var haveEqualEntity = function haveEqualEntity(charA, charB) {
return charA.getEntity() === charB.getEntity();
};
var decorateCharacterList = function decorateCharacterList(config) {
if (!config) {
return config;
}
var characterList = config.characterList,
text = config.text;
if (text && !characterList) {
config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
}
return config;
};
var ContentBlockNode = function (_Record) {
_inherits(ContentBlockNode, _Record);
function ContentBlockNode() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
_classCallCheck(this, ContentBlockNode);
return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
}
ContentBlockNode.prototype.getKey = function getKey() {
return this.get('key');
};
ContentBlockNode.prototype.getType = function getType() {
return this.get('type');
};
ContentBlockNode.prototype.getText = function getText() {
return this.get('text');
};
ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
return this.get('characterList');
};
ContentBlockNode.prototype.getLength = function getLength() {
return this.getText().length;
};
ContentBlockNode.prototype.getDepth = function getDepth() {
return this.get('depth');
};
ContentBlockNode.prototype.getData = function getData() {
return this.get('data');
};
ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getStyle() : EMPTY_SET;
};
ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getEntity() : null;
};
ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
return this.get('children');
};
ContentBlockNode.prototype.getParentKey = function getParentKey() {
return this.get('parent');
};
ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
return this.get('prevSibling');
};
ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
return this.get('nextSibling');
};
ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
};
ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
};
return ContentBlockNode;
}(Record(defaultRecord));
module.exports = ContentBlockNode;
/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {var now = __webpack_require__(468)
, root = typeof window === 'undefined' ? global : window
, vendors = ['moz', 'webkit']
, suffix = 'AnimationFrame'
, raf = root['request' + suffix]
, caf = root['cancel' + suffix] || root['cancelRequest' + suffix]
for(var i = 0; !raf && i < vendors.length; i++) {
raf = root[vendors[i] + 'Request' + suffix]
caf = root[vendors[i] + 'Cancel' + suffix]
|| root[vendors[i] + 'CancelRequest' + suffix]
}
// Some versions of FF have rAF but not cAF
if(!raf || !caf) {
var last = 0
, id = 0
, queue = []
, frameDuration = 1000 / 60
raf = function(callback) {
if(queue.length === 0) {
var _now = now()
, next = Math.max(0, frameDuration - (_now - last))
last = next + _now
setTimeout(function() {
var cp = queue.slice(0)
// Clear queue here to prevent
// callbacks from appending listeners
// to the current frame's queue
queue.length = 0
for(var i = 0; i < cp.length; i++) {
if(!cp[i].cancelled) {
try{
cp[i].callback(last)
} catch(e) {
setTimeout(function() { throw e }, 0)
}
}
}
}, Math.round(next))
}
queue.push({
handle: ++id,
callback: callback,
cancelled: false
})
return id
}
caf = function(handle) {
for(var i = 0; i < queue.length; i++) {
if(queue[i].handle === handle) {
queue[i].cancelled = true
}
}
}
}
module.exports = function(fn) {
// Wrap in a new function to prevent
// `cancel` potentially being assigned
// to the native rAF function
return raf.call(root, fn)
}
module.exports.cancel = function() {
caf.apply(root, arguments)
}
module.exports.polyfill = function(object) {
if (!object) {
object = root;
}
object.requestAnimationFrame = raf
object.cancelAnimationFrame = caf
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25)))
/***/ }),
/* 39 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = addEventListenerWrap;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_add_dom_event_listener__ = __webpack_require__(470);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_add_dom_event_listener___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_add_dom_event_listener__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_dom__);
function addEventListenerWrap(target, eventType, cb, option) {
/* eslint camelcase: 2 */
var callback = __WEBPACK_IMPORTED_MODULE_1_react_dom___default.a.unstable_batchedUpdates ? function run(e) {
__WEBPACK_IMPORTED_MODULE_1_react_dom___default.a.unstable_batchedUpdates(cb, e);
} : cb;
return __WEBPACK_IMPORTED_MODULE_0_add_dom_event_listener___default()(target, eventType, callback, option);
}
/***/ }),
/* 40 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return tuple; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return tupleNum; });
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
var tuple = function tuple() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args;
};
var tupleNum = function tupleNum() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return args;
};
/***/ }),
/* 41 */
/***/ (function(module, exports) {
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
module.exports = isArray;
/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var nullthrows = function nullthrows(x) {
if (x != null) {
return x;
}
throw new Error("Got unexpected null or undefined");
};
module.exports = nullthrows;
/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Applicator = (function () {
function Applicator() {
}
return Applicator;
}());
exports.Applicator = Applicator;
//# sourceMappingURL=Applicator.js.map
/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {
var store = __webpack_require__(154)('wks');
var uid = __webpack_require__(113);
var Symbol = __webpack_require__(54).Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.create = exports.connect = exports.Provider = undefined;
var _Provider2 = __webpack_require__(511);
var _Provider3 = _interopRequireDefault(_Provider2);
var _connect2 = __webpack_require__(512);
var _connect3 = _interopRequireDefault(_connect2);
var _create2 = __webpack_require__(513);
var _create3 = _interopRequireDefault(_create2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.Provider = _Provider3.default;
exports.connect = _connect3.default;
exports.create = _create3.default;
/***/ }),
/* 46 */
/***/ (function(module, exports) {
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
module.exports = isObjectLike;
/***/ }),
/* 47 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["h"] = findPopupContainer;
/* harmony export (immutable) */ __webpack_exports__["r"] = toTitle;
/* unused harmony export toArray */
/* harmony export (immutable) */ __webpack_exports__["g"] = createRef;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return UNSELECTABLE_STYLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return UNSELECTABLE_ATTRIBUTE; });
/* harmony export (immutable) */ __webpack_exports__["i"] = flatToHierarchy;
/* unused harmony export resetAriaId */
/* harmony export (immutable) */ __webpack_exports__["l"] = generateAriaId;
/* harmony export (immutable) */ __webpack_exports__["o"] = isLabelInValue;
/* harmony export (immutable) */ __webpack_exports__["q"] = parseSimpleTreeData;
/* harmony export (immutable) */ __webpack_exports__["p"] = isPosRelated;
/* harmony export (immutable) */ __webpack_exports__["c"] = cleanEntity;
/* harmony export (immutable) */ __webpack_exports__["m"] = getFilterTree;
/* harmony export (immutable) */ __webpack_exports__["j"] = formatInternalValue;
/* unused harmony export getLabel */
/* harmony export (immutable) */ __webpack_exports__["k"] = formatSelectorValue;
/* harmony export (immutable) */ __webpack_exports__["e"] = convertDataToTree;
/* harmony export (immutable) */ __webpack_exports__["f"] = convertTreeToEntities;
/* harmony export (immutable) */ __webpack_exports__["n"] = getHalfCheckedKeys;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return conductCheck; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_warning__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_warning__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_tree_es_util__ = __webpack_require__(204);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rc_util_es_Children_toArray__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rc_util_es_Dom_class__ = __webpack_require__(877);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SelectNode__ = __webpack_require__(205);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__strategies__ = __webpack_require__(206);
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
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; }
var warnDeprecatedLabel = false; // =================== DOM =====================
function findPopupContainer(node, prefixClass) {
var current = node;
while (current) {
if (Object(__WEBPACK_IMPORTED_MODULE_4_rc_util_es_Dom_class__["a" /* hasClass */])(current, prefixClass)) {
return current;
}
current = current.parentNode;
}
return null;
} // =================== MISC ====================
function toTitle(title) {
if (typeof title === 'string') {
return title;
}
return null;
}
function toArray(data) {
if (data === undefined || data === null) return [];
return Array.isArray(data) ? data : [data];
} // Shallow copy of React 16.3 createRef api
function createRef() {
var func = function setRef(node) {
func.current = node;
};
return func;
} // =============== Legacy ===============
var UNSELECTABLE_STYLE = {
userSelect: 'none',
WebkitUserSelect: 'none'
};
var UNSELECTABLE_ATTRIBUTE = {
unselectable: 'unselectable'
};
/**
* Convert position list to hierarchy structure.
* This is little hack since use '-' to split the position.
*/
function flatToHierarchy(positionList) {
if (!positionList.length) {
return [];
}
var entrances = {}; // Prepare the position map
var posMap = {};
var parsedList = positionList.slice().map(function (entity) {
var clone = _objectSpread({}, entity, {
fields: entity.pos.split('-')
});
delete clone.children;
return clone;
});
parsedList.forEach(function (entity) {
posMap[entity.pos] = entity;
});
parsedList.sort(function (a, b) {
return a.fields.length - b.fields.length;
}); // Create the hierarchy
parsedList.forEach(function (entity) {
var parentPos = entity.fields.slice(0, -1).join('-');
var parentEntity = posMap[parentPos];
if (!parentEntity) {
entrances[entity.pos] = entity;
} else {
parentEntity.children = parentEntity.children || [];
parentEntity.children.push(entity);
} // Some time position list provide `key`, we don't need it
delete entity.key;
delete entity.fields;
});
return Object.keys(entrances).map(function (key) {
return entrances[key];
});
} // =============== Accessibility ===============
var ariaId = 0;
function resetAriaId() {
ariaId = 0;
}
function generateAriaId(prefix) {
ariaId += 1;
return "".concat(prefix, "_").concat(ariaId);
}
function isLabelInValue(props) {
var treeCheckable = props.treeCheckable,
treeCheckStrictly = props.treeCheckStrictly,
labelInValue = props.labelInValue;
if (treeCheckable && treeCheckStrictly) {
return true;
}
return labelInValue || false;
} // =================== Tree ====================
function parseSimpleTreeData(treeData, _ref) {
var id = _ref.id,
pId = _ref.pId,
rootPId = _ref.rootPId;
var keyNodes = {};
var rootNodeList = []; // Fill in the map
var nodeList = treeData.map(function (node) {
var clone = _objectSpread({}, node);
var key = clone[id];
keyNodes[key] = clone;
clone.key = clone.key || key;
return clone;
}); // Connect tree
nodeList.forEach(function (node) {
var parentKey = node[pId];
var parent = keyNodes[parentKey]; // Fill parent
if (parent) {
parent.children = parent.children || [];
parent.children.push(node);
} // Fill root tree node
if (parentKey === rootPId || !parent && rootPId === null) {
rootNodeList.push(node);
}
});
return rootNodeList;
}
/**
* Detect if position has relation.
* e.g. 1-2 related with 1-2-3
* e.g. 1-3-2 related with 1
* e.g. 1-2 not related with 1-21
*/
function isPosRelated(pos1, pos2) {
var fields1 = pos1.split('-');
var fields2 = pos2.split('-');
var minLen = Math.min(fields1.length, fields2.length);
for (var i = 0; i < minLen; i += 1) {
if (fields1[i] !== fields2[i]) {
return false;
}
}
return true;
}
/**
* This function is only used on treeNode check (none treeCheckStrictly but has searchInput).
* We convert entity to { node, pos, children } format.
* This is legacy bug but we still need to do with it.
* @param entity
*/
function cleanEntity(_ref2) {
var node = _ref2.node,
pos = _ref2.pos,
children = _ref2.children;
var instance = {
node: node,
pos: pos
};
if (children) {
instance.children = children.map(cleanEntity);
}
return instance;
}
/**
* Get a filtered TreeNode list by provided treeNodes.
* [Legacy] Since `Tree` use `key` as map but `key` will changed by React,
* we have to convert `treeNodes > data > treeNodes` to keep the key.
* Such performance hungry!
*/
function getFilterTree(treeNodes, searchValue, filterFunc, valueEntities) {
if (!searchValue) {
return null;
}
function mapFilteredNodeToData(node) {
if (!node) return null;
var match = false;
if (filterFunc(searchValue, node)) {
match = true;
}
var children = Object(__WEBPACK_IMPORTED_MODULE_3_rc_util_es_Children_toArray__["a" /* default */])(node.props.children).map(mapFilteredNodeToData).filter(function (n) {
return n;
});
if (children.length || match) {
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_5__SelectNode__["a" /* default */], _extends({}, node.props, {
key: valueEntities[node.props.value].key
}), children);
}
return null;
}
return treeNodes.map(mapFilteredNodeToData).filter(function (node) {
return node;
});
} // =================== Value ===================
/**
* Convert value to array format to make logic simplify.
*/
function formatInternalValue(value, props) {
var valueList = toArray(value); // Parse label in value
if (isLabelInValue(props)) {
return valueList.map(function (val) {
if (typeof val !== 'object' || !val) {
return {
value: '',
label: ''
};
}
return val;
});
}
return valueList.map(function (val) {
return {
value: val
};
});
}
function getLabel(wrappedValue, entity, treeNodeLabelProp) {
if (wrappedValue.label) {
return wrappedValue.label;
}
if (entity && entity.node.props) {
return entity.node.props[treeNodeLabelProp];
} // Since value without entity will be in missValueList.
// This code will never reached, but we still need this in case.
return wrappedValue.value;
}
/**
* Convert internal state `valueList` to user needed value list.
* This will return an array list. You need check if is not multiple when return.
*
* `allCheckedNodes` is used for `treeCheckStrictly`
*/
function formatSelectorValue(valueList, props, valueEntities) {
var treeNodeLabelProp = props.treeNodeLabelProp,
treeCheckable = props.treeCheckable,
treeCheckStrictly = props.treeCheckStrictly,
showCheckedStrategy = props.showCheckedStrategy; // Will hide some value if `showCheckedStrategy` is set
if (treeCheckable && !treeCheckStrictly) {
var values = {};
valueList.forEach(function (wrappedValue) {
values[wrappedValue.value] = wrappedValue;
});
var hierarchyList = flatToHierarchy(valueList.map(function (_ref3) {
var value = _ref3.value;
return valueEntities[value];
}));
if (showCheckedStrategy === __WEBPACK_IMPORTED_MODULE_6__strategies__["c" /* SHOW_PARENT */]) {
// Only get the parent checked value
return hierarchyList.map(function (_ref4) {
var value = _ref4.node.props.value;
return {
label: getLabel(values[value], valueEntities[value], treeNodeLabelProp),
value: value
};
});
}
if (showCheckedStrategy === __WEBPACK_IMPORTED_MODULE_6__strategies__["b" /* SHOW_CHILD */]) {
// Only get the children checked value
var targetValueList = []; // Find the leaf children
var traverse = function traverse(_ref5) {
var value = _ref5.node.props.value,
children = _ref5.children;
if (!children || children.length === 0) {
targetValueList.push({
label: getLabel(values[value], valueEntities[value], treeNodeLabelProp),
value: value
});
return;
}
children.forEach(function (entity) {
traverse(entity);
});
};
hierarchyList.forEach(function (entity) {
traverse(entity);
});
return targetValueList;
}
}
return valueList.map(function (wrappedValue) {
return {
label: getLabel(wrappedValue, valueEntities[wrappedValue.value], treeNodeLabelProp),
value: wrappedValue.value
};
});
}
/**
* Use `rc-tree` convertDataToTree to convert treeData to TreeNodes.
* This will change the label to title value
*/
function processProps(props) {
var title = props.title,
label = props.label,
key = props.key,
value = props.value;
var cloneProps = _objectSpread({}, props); // Warning user not to use deprecated label prop.
if (label && !title) {
if (!warnDeprecatedLabel) {
__WEBPACK_IMPORTED_MODULE_1_warning___default()(false, "'label' in treeData is deprecated. Please use 'title' instead.");
warnDeprecatedLabel = true;
}
cloneProps.title = label;
}
if (!key) {
cloneProps.key = value;
}
return cloneProps;
}
function convertDataToTree(treeData) {
return Object(__WEBPACK_IMPORTED_MODULE_2_rc_tree_es_util__["g" /* convertDataToTree */])(treeData, {
processProps: processProps
});
}
/**
* Use `rc-tree` convertTreeToEntities for entities calculation.
* We have additional entities of `valueEntities`
*/
function initWrapper(wrapper) {
return _objectSpread({}, wrapper, {
valueEntities: {}
});
}
function processEntity(entity, wrapper) {
var value = entity.node.props.value;
entity.value = value; // This should be empty, or will get error message.
var currentEntity = wrapper.valueEntities[value];
if (currentEntity) {
__WEBPACK_IMPORTED_MODULE_1_warning___default()(false, "Conflict! value of node '".concat(entity.key, "' (").concat(value, ") has already used by node '").concat(currentEntity.key, "'."));
}
wrapper.valueEntities[value] = entity;
}
function convertTreeToEntities(treeNodes) {
return Object(__WEBPACK_IMPORTED_MODULE_2_rc_tree_es_util__["h" /* convertTreeToEntities */])(treeNodes, {
initWrapper: initWrapper,
processEntity: processEntity
});
}
/**
* https://github.com/ant-design/ant-design/issues/13328
* We need calculate the half check key when searchValue is set.
*/
// TODO: This logic may better move to rc-tree
function getHalfCheckedKeys(valueList, valueEntities) {
var values = {}; // Fill checked keys
valueList.forEach(function (_ref6) {
var value = _ref6.value;
values[value] = false;
}); // Fill half checked keys
valueList.forEach(function (_ref7) {
var value = _ref7.value;
var current = valueEntities[value];
while (current && current.parent) {
var parentValue = current.parent.value;
if (parentValue in values) break;
values[parentValue] = true;
current = current.parent;
}
}); // Get half keys
return Object.keys(values).filter(function (value) {
return values[value];
}).map(function (value) {
return valueEntities[value].key;
});
}
var conductCheck = __WEBPACK_IMPORTED_MODULE_2_rc_tree_es_util__["e" /* conductCheck */];
/***/ }),
/* 48 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
var UserAgentData = __webpack_require__(921);
var VersionRange = __webpack_require__(924);
var mapObject = __webpack_require__(925);
var memoizeStringOnly = __webpack_require__(926);
/**
* Checks to see whether `name` and `version` satisfy `query`.
*
* @param {string} name Name of the browser, device, engine or platform
* @param {?string} version Version of the browser, engine or platform
* @param {string} query Query of form "Name [range expression]"
* @param {?function} normalizer Optional pre-processor for range expression
* @return {boolean}
*/
function compare(name, version, query, normalizer) {
// check for exact match with no version
if (name === query) {
return true;
}
// check for non-matching names
if (!query.startsWith(name)) {
return false;
}
// full comparison with version
var range = query.slice(name.length);
if (version) {
range = normalizer ? normalizer(range) : range;
return VersionRange.contains(range, version);
}
return false;
}
/**
* Normalizes `version` by stripping any "NT" prefix, but only on the Windows
* platform.
*
* Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
*
* @param {string} version
* @return {string}
*/
function normalizePlatformVersion(version) {
if (UserAgentData.platformName === 'Windows') {
return version.replace(/^\s*NT/, '');
}
return version;
}
/**
* Provides client-side access to the authoritative PHP-generated User Agent
* information supplied by the server.
*/
var UserAgent = {
/**
* Check if the User Agent browser matches `query`.
*
* `query` should be a string like "Chrome" or "Chrome > 33".
*
* Valid browser names include:
*
* - ACCESS NetFront
* - AOL
* - Amazon Silk
* - Android
* - BlackBerry
* - BlackBerry PlayBook
* - Chrome
* - Chrome for iOS
* - Chrome frame
* - Facebook PHP SDK
* - Facebook for iOS
* - Firefox
* - IE
* - IE Mobile
* - Mobile Safari
* - Motorola Internet Browser
* - Nokia
* - Openwave Mobile Browser
* - Opera
* - Opera Mini
* - Opera Mobile
* - Safari
* - UIWebView
* - Unknown
* - webOS
* - etc...
*
* An authoritative list can be found in the PHP `BrowserDetector` class and
* related classes in the same file (see calls to `new UserAgentBrowser` here:
* https://fburl.com/50728104).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isBrowser: function isBrowser(query) {
return compare(UserAgentData.browserName, UserAgentData.browserFullVersion, query);
},
/**
* Check if the User Agent browser uses a 32 or 64 bit architecture.
*
* @note Function results are memoized
*
* @param {string} query Query of the form "32" or "64".
* @return {boolean}
*/
isBrowserArchitecture: function isBrowserArchitecture(query) {
return compare(UserAgentData.browserArchitecture, null, query);
},
/**
* Check if the User Agent device matches `query`.
*
* `query` should be a string like "iPhone" or "iPad".
*
* Valid device names include:
*
* - Kindle
* - Kindle Fire
* - Unknown
* - iPad
* - iPhone
* - iPod
* - etc...
*
* An authoritative list can be found in the PHP `DeviceDetector` class and
* related classes in the same file (see calls to `new UserAgentDevice` here:
* https://fburl.com/50728332).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name"
* @return {boolean}
*/
isDevice: function isDevice(query) {
return compare(UserAgentData.deviceName, null, query);
},
/**
* Check if the User Agent rendering engine matches `query`.
*
* `query` should be a string like "WebKit" or "WebKit >= 537".
*
* Valid engine names include:
*
* - Gecko
* - Presto
* - Trident
* - WebKit
* - etc...
*
* An authoritative list can be found in the PHP `RenderingEngineDetector`
* class related classes in the same file (see calls to `new
* UserAgentRenderingEngine` here: https://fburl.com/50728617).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isEngine: function isEngine(query) {
return compare(UserAgentData.engineName, UserAgentData.engineVersion, query);
},
/**
* Check if the User Agent platform matches `query`.
*
* `query` should be a string like "Windows" or "iOS 5 - 6".
*
* Valid platform names include:
*
* - Android
* - BlackBerry OS
* - Java ME
* - Linux
* - Mac OS X
* - Mac OS X Calendar
* - Mac OS X Internet Account
* - Symbian
* - SymbianOS
* - Windows
* - Windows Mobile
* - Windows Phone
* - iOS
* - iOS Facebook Integration Account
* - iOS Facebook Social Sharing UI
* - webOS
* - Chrome OS
* - etc...
*
* An authoritative list can be found in the PHP `PlatformDetector` class and
* related classes in the same file (see calls to `new UserAgentPlatform`
* here: https://fburl.com/50729226).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isPlatform: function isPlatform(query) {
return compare(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion);
},
/**
* Check if the User Agent platform is a 32 or 64 bit architecture.
*
* @note Function results are memoized
*
* @param {string} query Query of the form "32" or "64".
* @return {boolean}
*/
isPlatformArchitecture: function isPlatformArchitecture(query) {
return compare(UserAgentData.platformArchitecture, null, query);
}
};
module.exports = mapObject(UserAgent, memoizeStringOnly);
/***/ }),
/* 49 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["__extends"] = __extends;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
/* harmony export (immutable) */ __webpack_exports__["__rest"] = __rest;
/* harmony export (immutable) */ __webpack_exports__["__decorate"] = __decorate;
/* harmony export (immutable) */ __webpack_exports__["__param"] = __param;
/* harmony export (immutable) */ __webpack_exports__["__metadata"] = __metadata;
/* harmony export (immutable) */ __webpack_exports__["__awaiter"] = __awaiter;
/* harmony export (immutable) */ __webpack_exports__["__generator"] = __generator;
/* harmony export (immutable) */ __webpack_exports__["__exportStar"] = __exportStar;
/* harmony export (immutable) */ __webpack_exports__["__values"] = __values;
/* harmony export (immutable) */ __webpack_exports__["__read"] = __read;
/* harmony export (immutable) */ __webpack_exports__["__spread"] = __spread;
/* harmony export (immutable) */ __webpack_exports__["__await"] = __await;
/* harmony export (immutable) */ __webpack_exports__["__asyncGenerator"] = __asyncGenerator;
/* harmony export (immutable) */ __webpack_exports__["__asyncDelegator"] = __asyncDelegator;
/* harmony export (immutable) */ __webpack_exports__["__asyncValues"] = __asyncValues;
/* harmony export (immutable) */ __webpack_exports__["__makeTemplateObject"] = __makeTemplateObject;
/* harmony export (immutable) */ __webpack_exports__["__importStar"] = __importStar;
/* harmony export (immutable) */ __webpack_exports__["__importDefault"] = __importDefault;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* 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 (b.hasOwnProperty(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 __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(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 __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/***/ }),
/* 50 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["e"] = getTodayTime;
/* harmony export (immutable) */ __webpack_exports__["d"] = getTitleString;
/* harmony export (immutable) */ __webpack_exports__["f"] = getTodayTimeStr;
/* harmony export (immutable) */ __webpack_exports__["b"] = getMonthName;
/* harmony export (immutable) */ __webpack_exports__["h"] = syncTime;
/* harmony export (immutable) */ __webpack_exports__["c"] = getTimeConfig;
/* unused harmony export isTimeValidByConfig */
/* unused harmony export isTimeValid */
/* harmony export (immutable) */ __webpack_exports__["g"] = isAllowedDate;
/* harmony export (immutable) */ __webpack_exports__["a"] = formatDate;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_moment__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_moment___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_moment__);
var defaultDisabledTime = {
disabledHours: function disabledHours() {
return [];
},
disabledMinutes: function disabledMinutes() {
return [];
},
disabledSeconds: function disabledSeconds() {
return [];
}
};
function getTodayTime(value) {
var today = __WEBPACK_IMPORTED_MODULE_1_moment___default()();
today.locale(value.locale()).utcOffset(value.utcOffset());
return today;
}
function getTitleString(value) {
return value.format('LL');
}
function getTodayTimeStr(value) {
var today = getTodayTime(value);
return getTitleString(today);
}
function getMonthName(month) {
var locale = month.locale();
var localeData = month.localeData();
return localeData[locale === 'zh-cn' ? 'months' : 'monthsShort'](month);
}
function syncTime(from, to) {
if (!__WEBPACK_IMPORTED_MODULE_1_moment___default.a.isMoment(from) || !__WEBPACK_IMPORTED_MODULE_1_moment___default.a.isMoment(to)) return;
to.hour(from.hour());
to.minute(from.minute());
to.second(from.second());
}
function getTimeConfig(value, disabledTime) {
var disabledTimeConfig = disabledTime ? disabledTime(value) : {};
disabledTimeConfig = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, defaultDisabledTime, disabledTimeConfig);
return disabledTimeConfig;
}
function isTimeValidByConfig(value, disabledTimeConfig) {
var invalidTime = false;
if (value) {
var hour = value.hour();
var minutes = value.minute();
var seconds = value.second();
var disabledHours = disabledTimeConfig.disabledHours();
if (disabledHours.indexOf(hour) === -1) {
var disabledMinutes = disabledTimeConfig.disabledMinutes(hour);
if (disabledMinutes.indexOf(minutes) === -1) {
var disabledSeconds = disabledTimeConfig.disabledSeconds(hour, minutes);
invalidTime = disabledSeconds.indexOf(seconds) !== -1;
} else {
invalidTime = true;
}
} else {
invalidTime = true;
}
}
return !invalidTime;
}
function isTimeValid(value, disabledTime) {
var disabledTimeConfig = getTimeConfig(value, disabledTime);
return isTimeValidByConfig(value, disabledTimeConfig);
}
function isAllowedDate(value, disabledDate, disabledTime) {
if (disabledDate) {
if (disabledDate(value)) {
return false;
}
}
if (disabledTime) {
if (!isTimeValid(value, disabledTime)) {
return false;
}
}
return true;
}
function formatDate(value, format) {
if (!value) {
return '';
}
if (Array.isArray(format)) {
format = format[0];
}
return value.format(format);
}
/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule generateRandomKey
* @format
*
*/
var seenKeys = {};
var MULTIPLIER = Math.pow(2, 24);
function generateRandomKey() {
var key = void 0;
while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
key = Math.floor(Math.random() * MULTIPLIER).toString(32);
}
seenKeys[key] = true;
return key;
}
module.exports = generateRandomKey;
/***/ }),
/* 52 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* eslint eqeqeq: 0 */
function computeHeight(node) {
var totalHeight = parseInt(getComputedStyle(node).height, 10);
var padding = parseInt(getComputedStyle(node).paddingTop, 10) + parseInt(getComputedStyle(node).paddingBottom, 10);
return totalHeight - padding;
}
function getAutoHeight(n) {
if (!n) {
return 0;
}
var node = n;
var height = computeHeight(node);
while (!height) {
node = node.parentNode;
if (node) {
height = computeHeight(node);
} else {
break;
}
}
return height;
}
var autoHeight = function autoHeight() {
return function (WrappedComponent) {
return function (_React$Component) {
_inherits(_class2, _React$Component);
function _class2() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, _class2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = _class2.__proto__ || Object.getPrototypeOf(_class2)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
computedHeight: 0
}, _this.handleRoot = function (node) {
_this.root = node;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(_class2, [{
key: 'componentDidMount',
value: function componentDidMount() {
var height = this.props.height;
if (!height) {
var h = getAutoHeight(this.root);
// eslint-disable-next-line
this.setState({ computedHeight: h });
}
}
}, {
key: 'render',
value: function render() {
var height = this.props.height;
var computedHeight = this.state.computedHeight;
var h = height || computedHeight;
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'div',
{ ref: this.handleRoot },
h > 0 && __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(WrappedComponent, _extends({}, this.props, { height: h }))
);
}
}]);
return _class2;
}(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component);
};
};
/* harmony default export */ __webpack_exports__["a"] = (autoHeight);
/***/ }),
/* 53 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(54);
var core = __webpack_require__(33);
var ctx = __webpack_require__(148);
var hide = __webpack_require__(76);
var has = __webpack_require__(64);
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var IS_WRAP = type & $export.W;
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
var expProto = exports[PROTOTYPE];
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
var key, own, out;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if (own && has(exports, key)) continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function (C) {
var F = function (a, b, c) {
if (this instanceof C) {
switch (arguments.length) {
case 0: return new C();
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if (IS_PROTO) {
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ }),
/* 54 */
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self
// eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(77);
var IE8_DOM_DEFINE = __webpack_require__(239);
var toPrimitive = __webpack_require__(149);
var dP = Object.defineProperty;
exports.f = __webpack_require__(63) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if (IE8_DOM_DEFINE) try {
return dP(O, P, Attributes);
} catch (e) { /* empty */ }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
/***/ }),
/* 56 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = interopDefault;
// https://github.com/moment/moment/issues/3650
function interopDefault(m) {
return m["default"] || m;
}
/***/ }),
/* 57 */
/***/ (function(module, exports, __webpack_require__) {
var Symbol = __webpack_require__(97),
getRawTag = __webpack_require__(586),
objectToString = __webpack_require__(587);
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
module.exports = baseGetTag;
/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {
var baseGetTag = __webpack_require__(57),
isObject = __webpack_require__(28);
/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
module.exports = isFunction;
/***/ }),
/* 59 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_tooltip__ = __webpack_require__(735);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__placements__ = __webpack_require__(738);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__config_provider__ = __webpack_require__(6);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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); }
var splitObject = function splitObject(obj, keys) {
var picked = {};
var omitted = _extends({}, obj);
keys.forEach(function (key) {
if (obj && key in obj) {
picked[key] = obj[key];
delete omitted[key];
}
});
return {
picked: picked,
omitted: omitted
};
};
var Tooltip =
/*#__PURE__*/
function (_React$Component) {
_inherits(Tooltip, _React$Component);
function Tooltip(props) {
var _this;
_classCallCheck(this, Tooltip);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Tooltip).call(this, props));
_this.onVisibleChange = function (visible) {
var onVisibleChange = _this.props.onVisibleChange;
if (!('visible' in _this.props)) {
_this.setState({
visible: _this.isNoTitle() ? false : visible
});
}
if (onVisibleChange && !_this.isNoTitle()) {
onVisibleChange(visible);
}
}; // 动态设置动画点
_this.onPopupAlign = function (domNode, align) {
var placements = _this.getPlacements(); // 当前返回的位置
var placement = Object.keys(placements).filter(function (key) {
return placements[key].points[0] === align.points[0] && placements[key].points[1] === align.points[1];
})[0];
if (!placement) {
return;
} // 根据当前坐标设置动画点
var rect = domNode.getBoundingClientRect();
var transformOrigin = {
top: '50%',
left: '50%'
};
if (placement.indexOf('top') >= 0 || placement.indexOf('Bottom') >= 0) {
transformOrigin.top = "".concat(rect.height - align.offset[1], "px");
} else if (placement.indexOf('Top') >= 0 || placement.indexOf('bottom') >= 0) {
transformOrigin.top = "".concat(-align.offset[1], "px");
}
if (placement.indexOf('left') >= 0 || placement.indexOf('Right') >= 0) {
transformOrigin.left = "".concat(rect.width - align.offset[0], "px");
} else if (placement.indexOf('right') >= 0 || placement.indexOf('Left') >= 0) {
transformOrigin.left = "".concat(-align.offset[0], "px");
}
domNode.style.transformOrigin = "".concat(transformOrigin.left, " ").concat(transformOrigin.top);
};
_this.saveTooltip = function (node) {
_this.tooltip = node;
};
_this.renderTooltip = function (_ref) {
var getContextPopupContainer = _ref.getPopupContainer,
getPrefixCls = _ref.getPrefixCls;
var _assertThisInitialize = _assertThisInitialized(_this),
props = _assertThisInitialize.props,
state = _assertThisInitialize.state;
var customizePrefixCls = props.prefixCls,
title = props.title,
overlay = props.overlay,
openClassName = props.openClassName,
getPopupContainer = props.getPopupContainer,
getTooltipContainer = props.getTooltipContainer;
var children = props.children;
var prefixCls = getPrefixCls('tooltip', customizePrefixCls);
var visible = state.visible; // Hide tooltip when there is no title
if (!('visible' in props) && _this.isNoTitle()) {
visible = false;
}
var child = _this.getDisabledCompatibleChildren(__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](children) ? children : __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", null, children));
var childProps = child.props;
var childCls = __WEBPACK_IMPORTED_MODULE_3_classnames___default()(childProps.className, _defineProperty({}, openClassName || "".concat(prefixCls, "-open"), true));
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_2_rc_tooltip__["a" /* default */], _extends({}, _this.props, {
prefixCls: prefixCls,
getTooltipContainer: getPopupContainer || getTooltipContainer || getContextPopupContainer,
ref: _this.saveTooltip,
builtinPlacements: _this.getPlacements(),
overlay: overlay || title || '',
visible: visible,
onVisibleChange: _this.onVisibleChange,
onPopupAlign: _this.onPopupAlign
}), visible ? Object(__WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"])(child, {
className: childCls
}) : child);
};
_this.state = {
visible: !!props.visible || !!props.defaultVisible
};
return _this;
}
_createClass(Tooltip, [{
key: "getPopupDomNode",
value: function getPopupDomNode() {
return this.tooltip.getPopupDomNode();
}
}, {
key: "getPlacements",
value: function getPlacements() {
var _this$props = this.props,
builtinPlacements = _this$props.builtinPlacements,
arrowPointAtCenter = _this$props.arrowPointAtCenter,
autoAdjustOverflow = _this$props.autoAdjustOverflow;
return builtinPlacements || Object(__WEBPACK_IMPORTED_MODULE_4__placements__["a" /* default */])({
arrowPointAtCenter: arrowPointAtCenter,
verticalArrowShift: 8,
autoAdjustOverflow: autoAdjustOverflow
});
} // Fix Tooltip won't hide at disabled button
// mouse events don't trigger at disabled button in Chrome
// https://github.com/react-component/tooltip/issues/18
}, {
key: "getDisabledCompatibleChildren",
value: function getDisabledCompatibleChildren(element) {
if ((element.type.__ANT_BUTTON || element.type === 'button') && element.props.disabled) {
// Pick some layout related style properties up to span
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
var _splitObject = splitObject(element.props.style, ['position', 'left', 'right', 'top', 'bottom', 'float', 'display', 'zIndex']),
picked = _splitObject.picked,
omitted = _splitObject.omitted;
var spanStyle = _extends({
display: 'inline-block'
}, picked, {
cursor: 'not-allowed',
width: element.props.block ? '100%' : null
});
var buttonStyle = _extends({}, omitted, {
pointerEvents: 'none'
});
var child = Object(__WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"])(element, {
style: buttonStyle,
className: null
});
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
style: spanStyle,
className: element.props.className
}, child);
}
return element;
}
}, {
key: "isNoTitle",
value: function isNoTitle() {
var _this$props2 = this.props,
title = _this$props2.title,
overlay = _this$props2.overlay;
return !title && !overlay; // overlay for old version compatibility
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_5__config_provider__["a" /* ConfigConsumer */], null, this.renderTooltip);
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(nextProps) {
if ('visible' in nextProps) {
return {
visible: nextProps.visible
};
}
return null;
}
}]);
return Tooltip;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Tooltip.defaultProps = {
placement: 'top',
transitionName: 'zoom-big-fast',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
arrowPointAtCenter: false,
autoAdjustOverflow: true
};
Object(__WEBPACK_IMPORTED_MODULE_1_react_lifecycles_compat__["polyfill"])(Tooltip);
/* harmony default export */ __webpack_exports__["a"] = (Tooltip);
/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Draft
* @format
*
*/
var AtomicBlockUtils = __webpack_require__(898);
var BlockMapBuilder = __webpack_require__(104);
var CharacterMetadata = __webpack_require__(36);
var CompositeDraftDecorator = __webpack_require__(914);
var ContentBlock = __webpack_require__(72);
var ContentState = __webpack_require__(210);
var DefaultDraftBlockRenderMap = __webpack_require__(213);
var DefaultDraftInlineStyle = __webpack_require__(382);
var DraftEditor = __webpack_require__(915);
var DraftEditorBlock = __webpack_require__(384);
var DraftEntity = __webpack_require__(140);
var DraftModifier = __webpack_require__(32);
var DraftEntityInstance = __webpack_require__(380);
var EditorState = __webpack_require__(17);
var KeyBindingUtil = __webpack_require__(220);
var RichTextEditorUtil = __webpack_require__(399);
var SelectionState = __webpack_require__(88);
var convertFromDraftStateToRaw = __webpack_require__(976);
var convertFromHTMLToContentBlocks = __webpack_require__(397);
var convertFromRawToDraftState = __webpack_require__(979);
var generateRandomKey = __webpack_require__(51);
var getDefaultKeyBinding = __webpack_require__(400);
var getVisibleSelectionRect = __webpack_require__(984);
var DraftPublic = {
Editor: DraftEditor,
EditorBlock: DraftEditorBlock,
EditorState: EditorState,
CompositeDecorator: CompositeDraftDecorator,
Entity: DraftEntity,
EntityInstance: DraftEntityInstance,
BlockMapBuilder: BlockMapBuilder,
CharacterMetadata: CharacterMetadata,
ContentBlock: ContentBlock,
ContentState: ContentState,
SelectionState: SelectionState,
AtomicBlockUtils: AtomicBlockUtils,
KeyBindingUtil: KeyBindingUtil,
Modifier: DraftModifier,
RichUtils: RichTextEditorUtil,
DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap,
DefaultDraftInlineStyle: DefaultDraftInlineStyle,
convertFromHTML: convertFromHTMLToContentBlocks,
convertFromRaw: convertFromRawToDraftState,
convertToRaw: convertFromDraftStateToRaw,
genKey: generateRandomKey,
getDefaultKeyBinding: getDefaultKeyBinding,
getVisibleSelectionRect: getVisibleSelectionRect
};
module.exports = DraftPublic;
/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftFeatureFlags
* @format
*
*/
var DraftFeatureFlags = __webpack_require__(899);
module.exports = DraftFeatureFlags;
/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {
(function webpackUniversalModuleDefinition(root, factory) {
if(true)
module.exports = factory(__webpack_require__(0));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["BizCharts"] = factory(require("react"));
else
root["BizCharts"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_41__) {
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;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 527);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The util method based on the lodash.
* @author dxq613@gmail.com
* @see https://github.com/lodash/lodash
*/
var Utils = __webpack_require__(160);
var G = __webpack_require__(23);
var Util = Utils.mix({}, Utils, {
assign: Utils.mix,
// simple mix
merge: Utils.deepMix,
// deep mix
cloneDeep: Utils.clone,
isFinite: isFinite,
isNaN: isNaN,
snapEqual: Utils.isNumberEqual,
remove: Utils.pull,
inArray: Utils.contains,
/**
* 将用户输入的 padding 转换成 [top, right, bottom, right] 的模式
* @param {Number|Array} padding 输入的padding
* @return {Array} 四个padding 值
*/
toAllPadding: function toAllPadding(padding) {
var top = 0;
var left = 0;
var right = 0;
var bottom = 0;
if (Util.isNumber(padding) || Util.isString(padding)) {
top = left = right = bottom = padding;
} else if (Util.isArray(padding)) {
top = padding[0];
right = !Util.isNil(padding[1]) ? padding[1] : padding[0];
bottom = !Util.isNil(padding[2]) ? padding[2] : padding[0];
left = !Util.isNil(padding[3]) ? padding[3] : right;
} else if (Util.isObject(padding)) {
top = padding.top || 0;
right = padding.right || 0;
bottom = padding.bottom || 0;
left = padding.left || 0;
}
return [top, right, bottom, left];
},
getClipByRange: function getClipByRange(plotRange) {
var tl = plotRange.tl,
br = plotRange.br;
var clip = new G.Rect({
attrs: {
x: tl.x,
y: tl.y,
width: br.x - tl.x,
height: br.y - tl.y
}
});
return clip;
}
});
Util.Array = {
groupToMap: Utils.groupToMap,
group: Utils.group,
merge: Utils.merge,
values: Utils.valuesOfKey,
getRange: Utils.getRange,
firstValue: Utils.firstValue,
remove: Utils.pull
};
module.exports = Util;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var CommonUtil = __webpack_require__(143);
var Util = {};
CommonUtil.merge(Util, CommonUtil, {
mixin: function mixin(c, mixins) {
var Param = c.CFG ? 'CFG' : 'ATTRS';
if (c && mixins) {
c._mixins = mixins;
c[Param] = c[Param] || {};
var temp = {};
Util.each(mixins, function (mixin) {
Util.augment(c, mixin);
var attrs = mixin[Param];
if (attrs) {
Util.merge(temp, attrs);
}
});
c[Param] = Util.merge(temp, c[Param]);
}
}
});
module.exports = Util;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(38);
var isArray = __webpack_require__(4);
var each = function each(elements, func) {
if (!elements) {
return;
}
var rst = void 0;
if (isArray(elements)) {
for (var i = 0, len = elements.length; i < len; i++) {
rst = func(elements[i], i);
if (rst === false) {
break;
}
}
} else if (isObject(elements)) {
for (var k in elements) {
if (elements.hasOwnProperty(k)) {
rst = func(elements[k], k);
if (rst === false) {
break;
}
}
}
}
};
module.exports = each;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The util method based on the lodash.
* @author dxq613@gmail.com
*/
var G = __webpack_require__(35);
var Utils = __webpack_require__(160);
var Util = Utils.mix({
assign: Utils.mix,
isFinite: isFinite,
isNaN: isNaN,
Group: G.Group,
Event: G.Event
}, Utils);
module.exports = Util;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(16);
var isArray = Array.isArray ? Array.isArray : function (value) {
return isType(value, 'Array');
};
module.exports = isArray;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 全局变量
* @author dxq613
*/
var Util = __webpack_require__(0);
var Theme = __webpack_require__(125);
var Global = {
version: '3.5.1',
renderer: 'canvas',
// trackable: false,
trackingInfo: {},
animate: true,
widthRatio: {
// 宽度所占的分类的比例
column: 1 / 2,
// 一般的柱状图占比 1/2
rose: 0.9999999,
// 玫瑰图柱状占比 1
multiplePie: 1 / 1.3 // 多层的饼图、环图
},
// 折线图、区域图、path 当只有一个数据时,是否显示成点
showSinglePoint: false,
connectNulls: false,
scales: {},
registerTheme: function registerTheme(name, theme) {
Theme[name] = theme;
},
setTheme: function setTheme(theme) {
var newTheme = {};
if (Util.isObject(theme)) {
newTheme = theme;
} else if (Util.indexOf(Object.keys(Theme), theme) !== -1) {
newTheme = Theme[theme];
} else {
newTheme = Theme.default;
}
Util.deepMix(Global, newTheme);
}
};
Global.setTheme('default');
module.exports = Global;
/***/ }),
/* 6 */
/***/ (function(module, exports) {
// isFinite,
var isNil = function isNil(value) {
/**
* isNil(null) => true
* isNil() => true
*/
return value === null || value === undefined;
};
module.exports = isNil;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var isPointInPath = __webpack_require__(315);
var Element = __webpack_require__(126);
var Inside = __webpack_require__(70);
var Shape = function Shape(cfg) {
Shape.superclass.constructor.call(this, cfg);
};
Shape.ATTRS = {};
Util.extend(Shape, Element);
var ARRAY_ATTRS = {
matrix: 'matrix',
path: 'path',
points: 'points',
lineDash: 'lineDash'
};
function _cloneArrayAttr(arr) {
var result = [];
for (var i = 0; i < arr.length; i++) {
if (Util.isArray(arr[i])) {
result.push([].concat(arr[i]));
} else {
result.push(arr[i]);
}
}
return result;
}
Util.augment(Shape, isPointInPath, {
isShape: true,
drawInner: function drawInner(context) {
var self = this;
var attrs = self._attrs;
self.createPath(context);
var originOpacity = context.globalAlpha;
if (self.hasFill()) {
var fillOpacity = attrs.fillOpacity;
if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
context.globalAlpha = fillOpacity;
context.fill();
context.globalAlpha = originOpacity;
} else {
context.fill();
}
}
if (self.hasStroke()) {
var lineWidth = self._attrs.lineWidth;
if (lineWidth > 0) {
var strokeOpacity = attrs.strokeOpacity;
if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
context.globalAlpha = strokeOpacity;
}
context.stroke();
}
}
self.afterPath(context);
},
afterPath: function afterPath() {},
/**
* 击中图形时是否进行包围盒判断
* @return {Boolean} [description]
*/
isHitBox: function isHitBox() {
return true;
},
/**
* 节点是否能够被击中
* @param {Number} x x坐标
* @param {Number} y y坐标
* @return {Boolean} 是否在图形中
*/
isHit: function isHit(x, y) {
var self = this;
var v = [x, y, 1];
self.invert(v); // canvas
if (self.isHitBox()) {
var box = self.getBBox();
if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) {
return false;
}
}
var clip = self._attrs.clip;
if (clip) {
clip.invert(v, self.get('canvas'));
if (clip.isPointInPath(v[0], v[1])) {
return self.isPointInPath(v[0], v[1]);
}
} else {
return self.isPointInPath(v[0], v[1]);
}
return false;
},
/**
* @protected
* 计算包围盒
* @return {Object} 包围盒
*/
calculateBox: function calculateBox() {
return null;
},
// 获取拾取时线的宽度,需要考虑附加的线的宽度
getHitLineWidth: function getHitLineWidth() {
var attrs = this._attrs; // if (!attrs.stroke) {
// return 0;
// }
var lineAppendWidth = attrs.lineAppendWidth || 0;
var lineWidth = attrs.lineWidth || 0;
return lineWidth + lineAppendWidth;
},
// 清除当前的矩阵
clearTotalMatrix: function clearTotalMatrix() {
this._cfg.totalMatrix = null;
this._cfg.region = null;
},
clearBBox: function clearBBox() {
this._cfg.box = null;
this._cfg.region = null;
},
getBBox: function getBBox() {
var box = this._cfg.box; // 延迟计算
if (!box) {
box = this.calculateBox();
if (box) {
box.x = box.minX;
box.y = box.minY;
box.width = box.maxX - box.minX;
box.height = box.maxY - box.minY;
}
this._cfg.box = box;
}
return box;
},
clone: function clone() {
var self = this;
var clone = null;
var _attrs = self._attrs;
var attrs = {};
Util.each(_attrs, function (i, k) {
if (ARRAY_ATTRS[k] && Util.isArray(_attrs[k])) {
attrs[k] = _cloneArrayAttr(_attrs[k]);
} else {
attrs[k] = _attrs[k];
}
});
clone = new self.constructor({
attrs: attrs
}); // zIndex也是绘图属性,但是在cfg中,特殊处理
clone._cfg.zIndex = self._cfg.zIndex;
return clone;
}
});
module.exports = Shape;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview 所有 Geometry 的基类
* @author dxq613@gmail.com
*/
var Attr = __webpack_require__(61);
var Adjust = __webpack_require__(221);
var Base = __webpack_require__(113);
var Util = __webpack_require__(0);
var Global = __webpack_require__(5);
var Labels = __webpack_require__(288);
var Shape = __webpack_require__(9);
var TooltipMixin = __webpack_require__(294);
var ActiveMixin = __webpack_require__(292);
var SelectMixin = __webpack_require__(293);
var parseFields = __webpack_require__(307);
var GROUP_ATTRS = ['color', 'shape', 'size'];
var FIELD_ORIGIN = '_origin'; // 转换成对象的数组 [{type: 'adjust'}]
function parseAdjusts(adjusts) {
// 如果是字符串或者对象转换成数组
if (Util.isString(adjusts) || Util.isPlainObject(adjusts)) {
adjusts = [adjusts];
}
Util.each(adjusts, function (adjust, index) {
if (!Util.isObject(adjust)) {
adjusts[index] = {
type: adjust
};
}
});
return adjusts;
}
/**
* 几何标记
* @class Geom
*/
var GeomBase =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(GeomBase, _Base);
var _proto = GeomBase.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
return {
/**
* 标记 _id 用于区分执行动画
* @type {String}
*/
_id: null,
/**
* 类型
* @type {String}
*/
type: 'base',
/**
* 坐标系
* @type {Object}
*/
coord: null,
/**
* 属性映射集
* @protected
* @type {Object}
*/
attrs: {},
/**
* 所属的View
* @type {View}
*/
view: null,
/**
* 几何标记显示的数据
* @type {Array}
*/
data: [],
/**
* 相关的度量
* @type {Object}
*/
scales: {},
/**
* 绘图容器
* @type {Object}
*/
container: null,
/**
* 文本容器
* @type {Object}
*/
labelContainer: null,
/**
* 图形容器
* @type {Object}
*/
shapeContainer: null,
/**
* 几何标记的一些配置项,用于延迟生成图表
* @type {Object}
*/
attrOptions: {},
// 样式配置项
styleOptions: null,
// 选中时的配置项
selectedOptions: null,
// active 时的配置项
activedOptions: null,
/**
* 某些类存在默认的adjust,不能更改 adjust
* @type {Boolean}
*/
hasDefaultAdjust: false,
// 数据调整类型
adjusts: null,
/**
* 使用形状的类型
* @protected
* @type {String}
*/
shapeType: null,
/**
* 是否生成多个点来绘制图形
* @protected
* @type {Boolean}
*/
generatePoints: false,
/**
* 数据是否进行排序
* @type {Boolean}
*/
sortable: false,
labelCfg: null,
/**
* 是否共享 tooltip
* @type {Boolean}
*/
shareTooltip: true,
tooltipCfg: null,
/**
* 是否执行动画,默认执行
* @type {Boolean}
*/
animate: true,
/**
* 动画配置
* @type {[type]}
*/
animateCfg: null,
visible: true
};
};
function GeomBase(cfg) {
var _this;
_this = _Base.call(this, cfg) || this;
_this.viewTheme = _this.get('viewTheme');
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), TooltipMixin, ActiveMixin, SelectMixin);
if (_this.get('container')) {
_this._initContainer();
}
_this._initOptions();
return _this;
} // 初始化时对配置项的格式化
_proto._initOptions = function _initOptions() {
var adjusts = this.get('adjusts');
if (adjusts) {
adjusts = parseAdjusts(adjusts);
this.set('adjusts', adjusts);
}
};
_proto._createScale = function _createScale(field, data) {
var scales = this.get('scales');
var scale = scales[field];
if (!scale) {
scale = this.get('view').createScale(field, data);
scales[field] = scale;
}
return scale;
};
_proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
var options = this.get('attrOptions');
options[attrName] = attrCfg;
};
_proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
var attrCfg = {};
attrCfg.field = field;
if (cfg) {
if (Util.isFunction(cfg)) {
attrCfg.callback = cfg;
} else {
attrCfg.values = cfg;
}
} else if (attrName !== 'color') {
attrCfg.values = defaultValues;
}
this._setAttrOptions(attrName, attrCfg);
};
/**
* 位置属性映射
* @chainable
* @param {String} field 字段名
* @return {Geom} geom 当前几何标记
*/
_proto.position = function position(field) {
this._setAttrOptions('position', {
field: field
});
return this;
};
/**
* 颜色属性映射
* @chainable
* @param {String} field 字段名
* @param {Array|Function} values 颜色的数组或者回调函数
* @return {Geom} geom 当前几何标记
*/
_proto.color = function color(field, values) {
var viewTheme = this.viewTheme || Global;
this._createAttrOption('color', field, values, viewTheme.colors);
return this;
};
/**
* 大小属性映射
* @chainable
* @param {String} field 字段名
* @param {Array|Function} values 大小的数组或者回调函数
* @return {Geom} geom 当前几何标记
*/
_proto.size = function size(field, values) {
var viewTheme = this.viewTheme || Global;
this._createAttrOption('size', field, values, viewTheme.sizes);
return this;
};
/**
* 形状属性映射
* @chainable
* @param {String} field 字段名
* @param {Array|Function} values 大小的数组或者回调函数
* @return {Geom} geom 当前几何标记
*/
_proto.shape = function shape(field, values) {
var viewTheme = this.viewTheme || Global;
var type = this.get('type');
var shapes = viewTheme.shapes[type] || [];
this._createAttrOption('shape', field, values, shapes);
return this;
};
/**
* 透明度属性映射
* @chainable
* @param {String} field 字段名
* @param {Array|Function} values 透明度的数组或者回调函数
* @return {Geom} geom 当前几何标记
*/
_proto.opacity = function opacity(field, values) {
var viewTheme = this.viewTheme || Global;
this._createAttrOption('opacity', field, values, viewTheme.opacities);
return this;
};
_proto.style = function style(field, cfg) {
var styleOptions = this.get('styleOptions');
if (!styleOptions) {
styleOptions = {};
this.set('styleOptions', styleOptions);
}
if (Util.isObject(field)) {
cfg = field;
field = null;
}
var fields;
if (field) {
fields = parseFields(field);
}
styleOptions.fields = fields;
styleOptions.style = cfg;
return this;
};
_proto.label = function label(field, callback, cfg) {
var self = this;
var labelCfg = self.get('labelCfg'); // const scales = Util.map(self.get('labelCfg').fields, field => self._createScale(field));
if (!labelCfg) {
labelCfg = {};
self.set('labelCfg', labelCfg);
}
var fields;
if (field) {
fields = parseFields(field);
}
labelCfg.fields = fields; // 如果存在回调函数
if (Util.isFunction(callback)) {
if (!cfg) {
cfg = {};
}
labelCfg.callback = callback;
} else if (Util.isObject(callback)) {
// 如果没有设置回调函数
cfg = callback;
}
labelCfg.globalCfg = cfg;
return this;
};
_proto.tooltip = function tooltip(field, cfg) {
var tooltipCfg = this.get('tooltipCfg');
if (!tooltipCfg) {
tooltipCfg = {};
}
if (field === false) {
// geom 关闭 tooltip
this.set('tooltipCfg', false);
} else {
var tooltipFields;
if (field) {
tooltipFields = parseFields(field);
}
tooltipCfg.fields = tooltipFields;
tooltipCfg.cfg = cfg;
}
this.set('tooltipCfg', tooltipCfg);
return this;
};
_proto.animate = function animate(cfg) {
this.set('animateCfg', cfg);
return this;
};
/**
* 是否允许使用默认的图形激活交互
* @param {Boolean} enable 是否允许激活开关
* @param {Object} cfg 激活的配置项
* @return {Geom} 返回 geom 自身
*/
_proto.active = function active(enable, cfg) {
if (enable === false) {
this.set('allowActive', false);
} else if (Util.isObject(enable)) {
this.set('allowActive', true);
this.set('activedOptions', enable);
} else {
this.set('allowActive', true);
this.set('activedOptions', cfg);
}
return this;
};
/**
* 对 geometry 进行数据调整
* @chainable
* @param {String|Array|null} adjusts 数据调整的类型
* @return {Object} geometry 对象
*/
_proto.adjust = function adjust(adjusts) {
if (!this.get('hasDefaultAdjust')) {
if (adjusts) {
adjusts = parseAdjusts(adjusts);
}
this.set('adjusts', adjusts);
}
return this;
};
/**
* 设置图形的选中模式
* @param {Boolean|Object} enable 布尔类型用于模式开关,对象类型用于配置
* @param {Object} cfg 选中配置项
* @return {Geom} 返回 geom 自身
*/
_proto.select = function select(enable, cfg) {
if (enable === false) {
this.set('allowSelect', false);
} else if (Util.isObject(enable)) {
this.set('allowSelect', true);
this.set('selectedOptions', enable);
} else {
this.set('allowSelect', true);
this.set('selectedOptions', cfg);
}
return this;
};
_proto.hasAdjust = function hasAdjust(adjustType) {
var self = this;
var adjusts = self.get('adjusts');
if (!adjustType) {
return false;
}
var rst = false;
Util.each(adjusts, function (adjust) {
if (adjust.type === adjustType) {
rst = true;
return false;
}
});
return rst;
};
_proto.hasStack = function hasStack() {
var isStacked = this.get('isStacked');
if (Util.isNil(isStacked)) {
isStacked = this.hasAdjust('stack');
this.set('isStacked', isStacked);
}
return isStacked;
};
_proto.isInCircle = function isInCircle() {
var coord = this.get('coord');
return coord && coord.isPolar;
};
_proto._initContainer = function _initContainer() {
var self = this;
var shapeContainer = self.get('shapeContainer');
if (!shapeContainer) {
var container = self.get('container');
var view = self.get('view');
var viewId = view && view.get('_id');
shapeContainer = container.addGroup({
viewId: viewId,
visible: self.get('visible')
});
self.set('shapeContainer', shapeContainer);
}
};
_proto.init = function init() {
var self = this;
self._initContainer();
self._initAttrs();
if (self.get('tooltipCfg') && self.get('tooltipCfg').fields) {
var tooltipFields = self.get('tooltipCfg').fields;
Util.each(tooltipFields, function (field) {
self._createScale(field);
});
}
var dataArray = self._processData();
if (self.get('adjusts')) {
self._adjust(dataArray);
}
self.set('dataArray', dataArray);
}; // step 1: init attrs
_proto._initAttrs = function _initAttrs() {
var self = this;
var attrs = self.get('attrs');
var attrOptions = self.get('attrOptions');
var coord = self.get('coord');
var viewTheme = self.viewTheme || Global;
var isPie = false;
for (var type in attrOptions) {
if (attrOptions.hasOwnProperty(type)) {
var option = attrOptions[type];
var className = Util.upperFirst(type);
var fields = parseFields(option.field);
if (type === 'position') {
option.coord = coord; // 饼图坐标系下,填充一维
if (fields.length === 1 && coord.type === 'theta') {
fields.unshift('1');
isPie = true;
}
}
var scales = [];
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var scale = self._createScale(field);
if (type === 'color' && Util.isNil(option.values)) {
// 设置 color 的默认色值
if (scale.values.length <= 8) {
option.values = isPie ? viewTheme.colors_pie : viewTheme.colors;
} else if (scale.values.length <= 16) {
option.values = isPie ? viewTheme.colors_pie_16 : viewTheme.colors_16;
} else {
option.values = viewTheme.colors_24;
}
if (Util.isNil(option.values)) {
option.values = viewTheme.colors; // 防止主题没有声明诸如 colors_pie 的属性
}
}
scales.push(scale);
} // 饼图需要填充满整个空间
if (coord.type === 'theta' && type === 'position' && scales.length > 1) {
var yScale = scales[1];
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;
}
}
}; // step 2: 处理数据
_proto._processData = function _processData() {
var self = this;
var data = this.get('data');
var dataArray = [];
var groupedArray = this._groupData(data);
for (var i = 0; i < groupedArray.length; i++) {
var subData = groupedArray[i];
var tempData = self._saveOrigin(subData);
self._numberic(tempData);
dataArray.push(tempData);
}
return dataArray;
}; // step 2.1 数据分组
_proto._groupData = function _groupData(data) {
var groupScales = this._getGroupScales();
var fields = groupScales.map(function (scale) {
return scale.field;
});
return Util.Array.group(data, fields);
}; // step 2.2 数据调整前保存原始数据
_proto._saveOrigin = function _saveOrigin(data) {
var rst = [];
for (var i = 0; i < data.length; i++) {
var origin = data[i];
var obj = {};
for (var k in origin) {
obj[k] = origin[k];
} // const obj = Util.mix({}, origin);
obj[FIELD_ORIGIN] = origin;
rst.push(obj);
}
return rst;
}; // step 2.3 将分类数据翻译成数据, 仅对位置相关的度量进行数字化处理
_proto._numberic = function _numberic(data) {
var positionAttr = this.getAttr('position');
var scales = positionAttr.scales;
for (var j = 0; j < data.length; j++) {
var obj = data[j];
for (var i = 0; i < Math.min(2, scales.length); i++) {
var scale = scales[i];
if (scale.isCategory) {
var field = scale.field;
obj[field] = scale.translate(obj[field]);
}
}
}
};
_proto._getGroupScales = function _getGroupScales() {
var self = this;
var scales = self.get('groupScales');
if (!scales) {
scales = [];
var attrs = self.get('attrs');
Util.each(attrs, function (attr) {
if (GROUP_ATTRS.indexOf(attr.type) !== -1) {
var attrScales = attr.scales;
Util.each(attrScales, function (scale) {
if (scale.isCategory && Util.indexOf(scales, scale) === -1) {
scales.push(scale);
}
});
}
});
self.set('groupScales', scales);
}
return scales;
};
_proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
var mergeArray = Util.Array.merge(dataArray);
var min = scale.min;
var max = scale.max;
for (var i = 0; i < mergeArray.length; 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
});
}
}; // step 2.2 调整数据
_proto._adjust = function _adjust(dataArray) {
var self = this;
var adjusts = self.get('adjusts');
var viewTheme = this.viewTheme || Global;
var yScale = self.getYScale();
var xScale = self.getXScale();
var xField = xScale.field;
var yField = yScale ? yScale.field : null;
Util.each(adjusts, function (adjust) {
var adjustCfg = Util.mix({
xField: xField,
yField: yField
}, adjust);
var adjustType = Util.upperFirst(adjust.type);
if (adjustType === 'Dodge') {
var adjustNames = [];
if (xScale.isCategory || xScale.isIdentity) {
adjustNames.push('x');
} else if (!yScale) {
adjustNames.push('y');
} else {
throw new Error('dodge is not support linear attribute, please use category attribute!');
}
adjustCfg.adjustNames = adjustNames;
adjustCfg.dodgeRatio = viewTheme.widthRatio.column;
/* if (self.isInCircle()) {
adjustCfg.dodgeRatio = 1;
adjustCfg.marginRatio = 0;
}*/
} else if (adjustType === 'Stack') {
var coord = self.get('coord');
if (!yScale) {
// 一维的情况下获取高度和默认size
adjustCfg.height = coord.getHeight();
var size = self.getDefaultValue('size') || 3;
adjustCfg.size = size;
} // 不进行 transpose 时,用户又没有设置这个参数时,默认从上向下
if (!coord.isTransposed && Util.isNil(adjustCfg.reverseOrder)) {
adjustCfg.reverseOrder = true;
}
}
var adjustElement = new Adjust[adjustType](adjustCfg);
adjustElement.processAdjust(dataArray);
if (adjustType === 'Stack' && yScale) {
self._updateStackRange(yField, yScale, dataArray);
}
});
};
/**
* @internal 设置coord,通常外部容器变化时,coord 会发生变化
* @param {Object} coord 坐标系
*/
_proto.setCoord = function setCoord(coord) {
this.set('coord', coord);
var position = this.getAttr('position');
var shapeContainer = this.get('shapeContainer');
shapeContainer.setMatrix(coord.matrix);
if (position) {
position.coord = coord;
}
}; // step 3 绘制
_proto.paint = function paint() {
var self = this;
var dataArray = self.get('dataArray');
var mappedArray = [];
var shapeFactory = self.getShapeFactory();
shapeFactory.setCoord(self.get('coord'));
self.set('shapeFactory', shapeFactory);
var shapeContainer = self.get('shapeContainer');
self._beforeMapping(dataArray);
for (var i = 0; i < dataArray.length; i++) {
var data = dataArray[i];
var index = i;
data = self._mapping(data);
mappedArray.push(data);
self.draw(data, shapeContainer, shapeFactory, index);
}
if (self.get('labelCfg')) {
self._addLabels(Util.union.apply(null, mappedArray), shapeContainer.get('children'));
}
if (!self.get('sortable')) {
self._sort(mappedArray); // 便于数据的查找,需要对数据进行排序,用于 geom.findPoint()
} else {
self.set('dataArray', mappedArray);
}
};
_proto._sort = function _sort(mappedArray) {
var self = this;
var xScale = self.getXScale();
var xField = xScale.field;
Util.each(mappedArray, function (itemArr) {
itemArr.sort(function (obj1, obj2) {
return xScale.translate(obj1[FIELD_ORIGIN][xField]) - xScale.translate(obj2[FIELD_ORIGIN][xField]);
});
});
self.set('dataArray', mappedArray);
}; // step 3.1 before mapping
_proto._beforeMapping = function _beforeMapping(dataArray) {
var self = this;
if (self.get('sortable')) {
var xScale = self.getXScale();
var field = xScale.field;
Util.each(dataArray, function (data) {
data.sort(function (v1, v2) {
return xScale.translate(v1[field]) - xScale.translate(v2[field]);
});
});
}
if (self.get('generatePoints')) {
Util.each(dataArray, function (data) {
self._generatePoints(data);
});
Util.each(dataArray, function (data, index) {
var nextData = dataArray[index + 1];
if (nextData) {
data[0].nextPoints = nextData[0].points;
}
});
}
}; // step 3.2 add labels
_proto._addLabels = function _addLabels(points, shapes) {
var self = this;
var type = self.get('type');
var viewTheme = self.get('viewTheme') || Global;
var coord = self.get('coord');
var C = Labels.getLabelsClass(coord.type, type);
var container = self.get('container');
var scales = Util.map(self.get('labelCfg').fields, function (field) {
return self._createScale(field);
});
var labelContainer = container.addGroup(C, {
_id: this.get('_id'),
labelCfg: Util.mix({
scales: scales
}, self.get('labelCfg')),
coord: coord,
geom: self,
geomType: type,
viewTheme: viewTheme,
visible: self.get('visible')
});
labelContainer.showLabels(points, shapes);
self.set('labelContainer', labelContainer);
};
/**
* @protected
* 获取图形的工厂类
* @return {Object} 工厂类对象
*/
_proto.getShapeFactory = function getShapeFactory() {
var shapeFactory = this.get('shapeFactory');
if (!shapeFactory) {
var shapeType = this.get('shapeType');
shapeFactory = Shape.getShapeFactory(shapeType);
this.set('shapeFactory', shapeFactory);
}
return shapeFactory;
}; // step 3.2 generate points
_proto._generatePoints = function _generatePoints(data) {
var self = this;
var shapeFactory = self.getShapeFactory();
var shapeAttr = self.getAttr('shape');
for (var i = 0; i < data.length; 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;
}
};
/**
* 获取图形对应点的配置项
* @protected
* @param {Object} obj 数据对象
* @return {Object} cfg 获取图形对应点的配置项
*/
_proto.createShapePointsCfg = function createShapePointsCfg(obj) {
var xScale = this.getXScale();
var yScale = this.getYScale();
var x = this._normalizeValues(obj[xScale.field], xScale);
var y; // 存在没有 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
};
};
/**
* @protected
* 如果y轴的最小值小于0则返回0,否则返回最小值
* @return {Number} y轴上的最小值
*/
_proto.getYMinValue = function getYMinValue() {
var yScale = this.getYScale();
var min = yScale.min,
max = yScale.max;
var value;
if (min >= 0) {
value = min;
} else if (max <= 0) {
// 当值全位于负区间时,需要保证 ymin 在区域内,不可为 0
value = max;
} else {
value = 0;
}
return value;
}; // 将数据归一化
_proto._normalizeValues = function _normalizeValues(values, scale) {
var rst = [];
if (Util.isArray(values)) {
for (var i = 0; i < values.length; i++) {
var v = values[i];
rst.push(scale.scale(v));
}
} else {
rst = scale.scale(values);
}
return rst;
}; // step 3.2 mapping
_proto._mapping = function _mapping(data) {
var self = this;
var attrs = self.get('attrs');
var mappedData = [];
for (var i = 0; i < data.length; i++) {
var record = data[i];
var newRecord = {};
newRecord[FIELD_ORIGIN] = record[FIELD_ORIGIN];
newRecord.points = record.points;
newRecord.nextPoints = record.nextPoints;
for (var k in attrs) {
if (attrs.hasOwnProperty(k)) {
var attr = attrs[k];
var names = attr.names;
var values = self._getAttrValues(attr, record);
if (names.length > 1) {
// position 之类的生成多个字段的属性
for (var j = 0; j < values.length; j++) {
var val = values[j];
var name = names[j];
newRecord[name] = Util.isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值
}
} else {
newRecord[names[0]] = values.length === 1 ? values[0] : values;
}
}
}
mappedData.push(newRecord);
}
return mappedData;
}; // 获取属性映射的值
_proto._getAttrValues = function _getAttrValues(attr, record) {
var scales = attr.scales;
var params = [];
for (var i = 0; i < scales.length; 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.getDefaultValue = function getDefaultValue(attrName) {
var value = this.get(attrName);
var attr = this.getAttr(attrName);
if (attr) {
var scale = attr.getScale(attrName);
if (scale.type === 'identity') {
value = scale.value;
}
}
return value;
};
/**
* step 3.3 draw
* @protected
* @param {Array} data 绘制图形
* @param {Object} container 绘图容器
* @param {Object} shapeFactory 绘制图形的工厂类
* @param {Number} index 每个 shape 的索引值
*/
_proto.draw = function draw(data, container, shapeFactory, index) {
var self = this;
for (var i = 0; i < data.length; i++) {
var obj = data[i];
self.drawPoint(obj, container, shapeFactory, index + i);
}
};
_proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
if (!fields) {
return cfg;
}
var tmpCfg = {};
var params = fields.map(function (field) {
return origin[field];
});
Util.each(cfg, function (v, k) {
if (Util.isFunction(v)) {
tmpCfg[k] = v.apply(null, params);
} else {
tmpCfg[k] = v;
}
});
return tmpCfg;
};
_proto._getShapeId = function _getShapeId(dataObj) {
var id = this.get('_id');
var keyFields = this.get('keyFields');
if (keyFields && keyFields.length > 0) {
Util.each(keyFields, function (key) {
id += '-' + dataObj[key];
});
} else {
var type = this.get('type');
var xScale = this.getXScale();
var yScale = this.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 += '-' + xVal + '-' + yVal;
}
var groupScales = this._getGroupScales();
if (!Util.isEmpty(groupScales)) {
Util.each(groupScales, function (groupScale) {
var field = groupScale.field;
if (groupScale.type !== 'identity') {
id += '-' + dataObj[field];
}
});
}
}
return id;
};
_proto.getDrawCfg = function getDrawCfg(obj) {
var self = this;
var cfg = {
origin: obj,
x: obj.x,
y: obj.y,
color: obj.color,
size: obj.size,
shape: obj.shape,
isInCircle: self.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 (self.get('animate')) {
// _id 字段仅用于动画
cfg._id = self._getShapeId(obj[FIELD_ORIGIN]);
}
return cfg;
};
_proto.appendShapeInfo = function appendShapeInfo(shape, index) {
if (shape) {
shape.setSilent('index', index);
shape.setSilent('coord', this.get('coord'));
if (this.get('animate') && this.get('animateCfg')) {
shape.setSilent('animateCfg', this.get('animateCfg'));
}
}
};
_proto._applyViewThemeShapeStyle = function _applyViewThemeShapeStyle(cfg, shape, shapeFactory) {
// applying view theme
var self = this;
var viewTheme = self.viewTheme || Global;
var shapeName = shapeFactory.name;
if (shape) {
if (shape && (shape.indexOf('hollow') > -1 || shape.indexOf('liquid') > -1)) {
shapeName = "hollow" + Util.upperFirst(shapeName);
}
} else if (shapeFactory.defaultShapeType.indexOf('hollow') > -1) {
shapeName = "hollow" + Util.upperFirst(shapeName);
}
var defaultStyle = viewTheme.shape[shapeName] || {};
cfg.style = Util.mix({}, defaultStyle, cfg.style);
};
_proto.drawPoint = function drawPoint(obj, container, shapeFactory, index) {
var self = this;
var shape = obj.shape;
var cfg = self.getDrawCfg(obj);
self._applyViewThemeShapeStyle(cfg, shape, shapeFactory);
var geomShape = shapeFactory.drawShape(shape, cfg, container);
self.appendShapeInfo(geomShape, index);
};
/**
* 获取属性
* @protected
* @param {String} name 属性名
* @return {Scale} 度量
*/
_proto.getAttr = function getAttr(name) {
return this.get('attrs')[name];
};
/**
* 获取 x 对应的度量
* @return {Scale} x 对应的度量
*/
_proto.getXScale = function getXScale() {
return this.getAttr('position').scales[0];
};
/**
* 获取 y 对应的度量
* @return {Scale} y 对应的度量
*/
_proto.getYScale = function getYScale() {
return this.getAttr('position').scales[1];
};
_proto.getShapes = function getShapes() {
var result = [];
var shapeContainer = this.get('shapeContainer');
var children = shapeContainer.get('children');
Util.each(children, function (child) {
if (child.get('origin')) {
// 过滤 label
result.push(child);
}
});
return result;
};
_proto.getAttrsForLegend = function getAttrsForLegend() {
var attrs = this.get('attrs');
var rst = [];
Util.each(attrs, function (attr) {
if (GROUP_ATTRS.indexOf(attr.type) !== -1) {
rst.push(attr);
}
});
return rst;
};
_proto.getFieldsForLegend = function getFieldsForLegend() {
var fields = [];
var attrOptions = this.get('attrOptions');
Util.each(GROUP_ATTRS, function (attrName) {
var attrCfg = attrOptions[attrName];
if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
fields = fields.concat(attrCfg.field.split('*'));
}
});
return Util.uniq(fields);
};
_proto.changeVisible = function changeVisible(visible, stopDraw) {
var me = this;
me.set('visible', visible);
var shapeContainer = this.get('shapeContainer');
if (shapeContainer) {
shapeContainer.set('visible', visible);
}
var labelContainer = this.get('labelContainer');
if (labelContainer) {
labelContainer.set('visible', visible);
}
if (!stopDraw && shapeContainer) {
var canvas = shapeContainer.get('canvas');
canvas.draw();
}
};
_proto.reset = function reset() {
this.set('attrOptions', {});
this.clearInner();
};
_proto.clearInner = function clearInner() {
this.clearActivedShapes();
this.clearSelected();
var shapeContainer = this.get('shapeContainer');
shapeContainer && shapeContainer.clear(); // 由于 Labels 对应的模块需要生成group,所以这个地方需要删除
var labelContainer = this.get('labelContainer');
labelContainer && labelContainer.remove();
this.set('attrs', {});
this.set('groupScales', null); // if (!this.get('hasDefaultAdjust')) {
// this.set('adjusts', null);
// }
this.set('labelContainer', null);
this.set('xDistance', null);
this.set('isStacked', null);
};
_proto.clear = function clear() {
this.clearInner();
this.set('scales', {});
};
_proto.destroy = function destroy() {
this.clear();
var shapeContainer = this.get('shapeContainer');
shapeContainer && shapeContainer.remove();
this.offEvents();
_Base.prototype.destroy.call(this);
};
_proto.bindEvents = function bindEvents() {
if (this.get('view')) {
this._bindActiveAction();
this._bindSelectedAction();
}
};
_proto.offEvents = function offEvents() {
if (this.get('view')) {
this._offActiveAction();
this._offSelectedAction();
}
};
return GeomBase;
}(Base);
module.exports = GeomBase;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 工厂类,管理各种类型的 shape
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var PathUtil = __webpack_require__(25);
var GPath = Util.PathUtil;
var Shape = {};
var ShapeBase = {
_coord: null,
/**
* 绘制图形
* @param {Object} cfg 配置项
* @param {Object} container 容器
* @return {Object} shape 创建的 shape
*/
draw: function draw(cfg, container) {
if (this.drawShape) {
return this.drawShape(cfg, container);
}
return null;
},
/**
* 获取绘制图形需要的点, 可以不定义,则使用默认的
getPoints(cfg) {
if (this.getShapePoints) {
return this.getShapePoints(cfg);
}
return null;
},*/
/**
* 设置坐标系
* @param {Coord} coord 坐标系
*/
setCoord: function setCoord(coord) {
this._coord = coord;
},
/**
* 0~1 path 转 画布 path
* @param {path} path 路径
* @param {Boolean} islineToArc 是否转换成圆弧
* @return {path} path 转换到画布坐标的path
*/
parsePath: function parsePath(path, islineToArc) {
var coord = this._coord;
path = GPath.parsePathString(path);
if (coord.isPolar && islineToArc !== false) {
path = PathUtil.convertPolarPath(coord, path);
} else {
path = PathUtil.convertNormalPath(coord, path);
}
return path;
},
/**
* 0~1 point 转 画布 point
* @param {point} point 节点
* @return {point} point 转换后的点
*/
parsePoint: function parsePoint(point) {
var coord = this._coord;
return coord.convertPoint(point);
},
/**
* 0~1 points 转 画布 points
* @param {points} points 节点集合
* @return {points} points 转换后的多个节点
*/
parsePoints: function parsePoints(points) {
var coord = this._coord;
var rst = [];
Util.each(points, function (point) {
rst.push(coord.convertPoint(point));
});
return rst;
}
};
var ShapeFactoryBase = {
defaultShapeType: null,
setCoord: function setCoord(coord) {
this._coord = coord;
},
getShape: function getShape(type) {
var self = this;
if (Util.isArray(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()
/* cfg */
{
return [];
},
getMarkerCfg: function getMarkerCfg(type, cfg) {
var shape = this.getShape(type);
if (!shape.getMarkerCfg) {
var defaultShapeType = this.defaultShapeType;
shape = this.getShape(defaultShapeType);
}
return shape.getMarkerCfg(cfg);
},
getSelectedCfg: function getSelectedCfg()
/* type, cfg */
{
return {};
},
drawShape: function drawShape(type, cfg, container) {
var shape = this.getShape(type);
var gShape = shape.draw(cfg, container);
if (gShape) {
gShape.setSilent('origin', cfg.origin);
gShape._id = cfg.yIndex ? cfg._id + cfg.yIndex : cfg._id;
gShape.name = this.name;
}
return gShape;
}
}; // 注册 Geometry 获取图形的入口
Shape.registerFactory = function (factoryName, cfg) {
var className = Util.upperFirst(factoryName);
var geomObj = Util.assign({}, ShapeFactoryBase, cfg);
Shape[className] = geomObj;
geomObj.name = factoryName;
return geomObj;
}; // 注册图形
Shape.registerShape = function (factoryName, shapeType, cfg) {
var className = Util.upperFirst(factoryName);
var factory = Shape[className];
var shapeObj = Util.assign({}, ShapeBase, cfg);
factory[shapeType] = shapeObj;
return shapeObj;
}; // 获得Geom 对应的 shapeFactory
Shape.getShapeFactory = function (factoryName) {
var self = this;
factoryName = factoryName || 'point';
var className = Util.upperFirst(factoryName);
return self[className];
};
module.exports = Shape;
/***/ }),
/* 10 */
/***/ (function(module, exports) {
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;
};
module.exports = mix;
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 判断是否数字
* @return {Boolean} 是否数字
*/
var isType = __webpack_require__(16);
var isNumber = function isNumber(value) {
return isType(value, 'Number');
};
module.exports = isNumber;
/***/ }),
/* 12 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__color__ = __webpack_require__(83);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return __WEBPACK_IMPORTED_MODULE_0__color__["h"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_0__color__["g"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_0__color__["f"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__lab__ = __webpack_require__(425);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_1__lab__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_1__lab__["a"]; });
/* unused harmony reexport lch */
/* unused harmony reexport gray */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__cubehelix__ = __webpack_require__(424);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_2__cubehelix__["a"]; });
/***/ }),
/* 13 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export CREATED */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return SCHEDULED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return STARTING; });
/* unused harmony export STARTED */
/* unused harmony export RUNNING */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ENDING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return ENDED; });
/* harmony export (immutable) */ __webpack_exports__["g"] = init;
/* harmony export (immutable) */ __webpack_exports__["e"] = set;
/* harmony export (immutable) */ __webpack_exports__["f"] = get;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_dispatch__ = __webpack_require__(427);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_d3_timer__ = __webpack_require__(96);
var emptyOn = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_dispatch__["a" /* dispatch */])("start", "end", "cancel", "interrupt");
var emptyTween = [];
var CREATED = 0;
var SCHEDULED = 1;
var STARTING = 2;
var STARTED = 3;
var RUNNING = 4;
var ENDING = 5;
var ENDED = 6;
/* harmony default export */ __webpack_exports__["h"] = (function(node, name, id, index, group, timing) {
var schedules = node.__transition;
if (!schedules) node.__transition = {};
else if (id in schedules) return;
create(node, id, {
name: name,
index: index, // For context during callback.
group: group, // For context during callback.
on: emptyOn,
tween: emptyTween,
time: timing.time,
delay: timing.delay,
duration: timing.duration,
ease: timing.ease,
timer: null,
state: CREATED
});
});
function init(node, id) {
var schedule = get(node, id);
if (schedule.state > CREATED) throw new Error("too late; already scheduled");
return schedule;
}
function set(node, id) {
var schedule = get(node, id);
if (schedule.state > STARTED) throw new Error("too late; already running");
return schedule;
}
function get(node, id) {
var schedule = node.__transition;
if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found");
return schedule;
}
function create(node, id, self) {
var schedules = node.__transition,
tween;
// Initialize the self timer when the transition is created.
// Note the actual delay is not known until the first callback!
schedules[id] = self;
self.timer = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_timer__["timer"])(schedule, 0, self.time);
function schedule(elapsed) {
self.state = SCHEDULED;
self.timer.restart(start, self.delay, self.time);
// If the elapsed delay is less than our first sleep, start immediately.
if (self.delay <= elapsed) start(elapsed - self.delay);
}
function start(elapsed) {
var i, j, n, o;
// If the state is not SCHEDULED, then we previously errored on start.
if (self.state !== SCHEDULED) return stop();
for (i in schedules) {
o = schedules[i];
if (o.name !== self.name) continue;
// While this element already has a starting transition during this frame,
// defer starting an interrupting transition until that transition has a
// chance to tick (and possibly end); see d3/d3-transition#54!
if (o.state === STARTED) return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_timer__["timeout"])(start);
// Interrupt the active transition, if any.
if (o.state === RUNNING) {
o.state = ENDED;
o.timer.stop();
o.on.call("interrupt", node, node.__data__, o.index, o.group);
delete schedules[i];
}
// Cancel any pre-empted transitions.
else if (+i < id) {
o.state = ENDED;
o.timer.stop();
o.on.call("cancel", node, node.__data__, o.index, o.group);
delete schedules[i];
}
}
// Defer the first tick to end of the current frame; see d3/d3#1576.
// Note the transition may be canceled after start and before the first tick!
// Note this must be scheduled before the start event; see d3/d3-transition#16!
// Assuming this is successful, subsequent callbacks go straight to tick.
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_timer__["timeout"])(function() {
if (self.state === STARTED) {
self.state = RUNNING;
self.timer.restart(tick, self.delay, self.time);
tick(elapsed);
}
});
// Dispatch the start event.
// Note this must be done before the tween are initialized.
self.state = STARTING;
self.on.call("start", node, node.__data__, self.index, self.group);
if (self.state !== STARTING) return; // interrupted
self.state = STARTED;
// Initialize the tween, deleting null tween.
tween = new Array(n = self.tween.length);
for (i = 0, j = -1; i < n; ++i) {
if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
tween[++j] = o;
}
}
tween.length = j + 1;
}
function tick(elapsed) {
var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1),
i = -1,
n = tween.length;
while (++i < n) {
tween[i].call(node, t);
}
// Dispatch the end event.
if (self.state === ENDING) {
self.on.call("end", node, node.__data__, self.index, self.group);
stop();
}
}
function stop() {
self.state = ENDED;
self.timer.stop();
delete schedules[id];
for (var i in schedules) return; // eslint-disable-line no-unused-vars
delete node.__transition;
}
}
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 是否为函数
* @param {*} fn 对象
* @return {Boolean} 是否函数
*/
var isType = __webpack_require__(16);
var isFunction = function isFunction(value) {
return isType(value, 'Function');
};
module.exports = isFunction;
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(16);
var isString = function isString(str) {
return isType(str, 'String');
};
module.exports = isString;
/***/ }),
/* 16 */
/***/ (function(module, exports) {
var toString = {}.toString;
var isType = function isType(value, type) {
return toString.call(value) === '[object ' + type + ']';
};
module.exports = isType;
/***/ }),
/* 17 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return root; });
/* harmony export (immutable) */ __webpack_exports__["b"] = Selection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__select__ = __webpack_require__(490);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__selectAll__ = __webpack_require__(491);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__filter__ = __webpack_require__(478);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__data__ = __webpack_require__(472);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__enter__ = __webpack_require__(210);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__exit__ = __webpack_require__(477);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__join__ = __webpack_require__(481);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__merge__ = __webpack_require__(483);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__order__ = __webpack_require__(486);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__sort__ = __webpack_require__(493);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__call__ = __webpack_require__(469);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__nodes__ = __webpack_require__(485);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__node__ = __webpack_require__(484);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__size__ = __webpack_require__(492);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__empty__ = __webpack_require__(476);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__each__ = __webpack_require__(475);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__attr__ = __webpack_require__(468);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__style__ = __webpack_require__(212);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__property__ = __webpack_require__(487);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__classed__ = __webpack_require__(470);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__text__ = __webpack_require__(494);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__html__ = __webpack_require__(479);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__raise__ = __webpack_require__(488);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__lower__ = __webpack_require__(482);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__append__ = __webpack_require__(467);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__insert__ = __webpack_require__(480);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__remove__ = __webpack_require__(489);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__clone__ = __webpack_require__(471);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__datum__ = __webpack_require__(473);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__on__ = __webpack_require__(92);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__dispatch__ = __webpack_require__(474);
var root = [null];
function Selection(groups, parents) {
this._groups = groups;
this._parents = parents;
}
function selection() {
return new Selection([[document.documentElement]], root);
}
Selection.prototype = selection.prototype = {
constructor: Selection,
select: __WEBPACK_IMPORTED_MODULE_0__select__["a" /* default */],
selectAll: __WEBPACK_IMPORTED_MODULE_1__selectAll__["a" /* default */],
filter: __WEBPACK_IMPORTED_MODULE_2__filter__["a" /* default */],
data: __WEBPACK_IMPORTED_MODULE_3__data__["a" /* default */],
enter: __WEBPACK_IMPORTED_MODULE_4__enter__["a" /* default */],
exit: __WEBPACK_IMPORTED_MODULE_5__exit__["a" /* default */],
join: __WEBPACK_IMPORTED_MODULE_6__join__["a" /* default */],
merge: __WEBPACK_IMPORTED_MODULE_7__merge__["a" /* default */],
order: __WEBPACK_IMPORTED_MODULE_8__order__["a" /* default */],
sort: __WEBPACK_IMPORTED_MODULE_9__sort__["a" /* default */],
call: __WEBPACK_IMPORTED_MODULE_10__call__["a" /* default */],
nodes: __WEBPACK_IMPORTED_MODULE_11__nodes__["a" /* default */],
node: __WEBPACK_IMPORTED_MODULE_12__node__["a" /* default */],
size: __WEBPACK_IMPORTED_MODULE_13__size__["a" /* default */],
empty: __WEBPACK_IMPORTED_MODULE_14__empty__["a" /* default */],
each: __WEBPACK_IMPORTED_MODULE_15__each__["a" /* default */],
attr: __WEBPACK_IMPORTED_MODULE_16__attr__["a" /* default */],
style: __WEBPACK_IMPORTED_MODULE_17__style__["b" /* default */],
property: __WEBPACK_IMPORTED_MODULE_18__property__["a" /* default */],
classed: __WEBPACK_IMPORTED_MODULE_19__classed__["a" /* default */],
text: __WEBPACK_IMPORTED_MODULE_20__text__["a" /* default */],
html: __WEBPACK_IMPORTED_MODULE_21__html__["a" /* default */],
raise: __WEBPACK_IMPORTED_MODULE_22__raise__["a" /* default */],
lower: __WEBPACK_IMPORTED_MODULE_23__lower__["a" /* default */],
append: __WEBPACK_IMPORTED_MODULE_24__append__["a" /* default */],
insert: __WEBPACK_IMPORTED_MODULE_25__insert__["a" /* default */],
remove: __WEBPACK_IMPORTED_MODULE_26__remove__["a" /* default */],
clone: __WEBPACK_IMPORTED_MODULE_27__clone__["a" /* default */],
datum: __WEBPACK_IMPORTED_MODULE_28__datum__["a" /* default */],
on: __WEBPACK_IMPORTED_MODULE_29__on__["c" /* default */],
dispatch: __WEBPACK_IMPORTED_MODULE_30__dispatch__["a" /* default */]
};
/* harmony default export */ __webpack_exports__["a"] = (selection);
/***/ }),
/* 18 */
/***/ (function(module, exports) {
module.exports = {
FONT_FAMILY: '"-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto,"Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",SimSun, "sans-serif"'
};
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Helper = __webpack_require__(102);
var Component = __webpack_require__(34);
var KEYWORDS = ['min', 'max', 'median', 'start', 'end'];
var Guide =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Guide, _Component);
function Guide() {
return _Component.apply(this, arguments) || this;
}
var _proto = Guide.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Component.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
xScales: null,
yScales: null,
el: null
});
};
_proto.render = function render() {};
/**
* clear container
* @override
*/
_proto.clear = function clear() {
var self = this;
var el = self.get('el');
el && el.remove();
};
/**
* show or hide
* @protected
* @param {Boolean} visible true means show, false means hide
*/
_proto.changeVisible = function changeVisible(visible) {
var self = this;
self.set('visible', visible);
var el = self.get('el');
if (!el) return;
if (el.set) {
el.set('visible', visible);
} else {
el.style.display = visible ? '' : 'none';
}
};
/**
* calculate the canvas coordinate value
* @protected
* @param {Coordinate} coord the instance of Coordinate class
* @param {Object | Array | Function} position the value need to convert
* @return {Object} return the result
*/
_proto.parsePoint = function parsePoint(coord, position) {
var self = this;
var xScales = self.get('xScales');
var yScales = self.get('yScales');
if (Util.isFunction(position)) {
position = position(xScales, yScales);
}
var x;
var y; // 如果数据格式是 ['50%', '50%'] 的格式
if (Util.isArray(position) && Util.isString(position[0]) && position[0].indexOf('%') !== -1) {
return this._parsePercentPoint(coord, position);
}
if (Util.isArray(position)) {
// Array,suuport for mixing of keyword, percent and value
x = self._getNormalizedValue(position[0], Helper.getFirstScale(xScales));
y = self._getNormalizedValue(position[1], Helper.getFirstScale(yScales));
} else {
for (var field in position) {
var value = position[field];
if (xScales[field]) {
x = self._getNormalizedValue(value, xScales[field]);
}
if (yScales[field]) {
y = self._getNormalizedValue(value, yScales[field], 'y');
}
}
}
if (!Util.isNil(x) && !Util.isNil(y)) {
return coord.convert({
x: x,
y: y
});
}
};
/**
* Normalized the value
* @param {String | Number} val param
* @param {Scale} scale the instance of Scale
* @return {Number} return the normalized value
*/
_proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
var result;
if (Util.indexOf(KEYWORDS, val) !== -1) {
// keyword
var scaleValue;
if (val === 'start') {
// the start of coordinate
result = 0;
} else if (val === 'end') {
result = 1;
} else if (val === 'median') {
scaleValue = scale.isCategory ? (scale.values.length - 1) / 2 : (scale.min + scale.max) / 2;
result = scale.scale(scaleValue);
} else {
if (scale.isCategory) {
scaleValue = val === 'min' ? 0 : scale.values.length - 1;
} else {
scaleValue = scale[val];
}
result = scale.scale(scaleValue);
}
} else {
// 数值
result = scale.scale(val);
}
return result;
};
_proto._parsePercentPoint = function _parsePercentPoint(coord, position) {
var xPercent = parseFloat(position[0]) / 100;
var yPercent = parseFloat(position[1]) / 100;
var start = coord.start,
end = coord.end;
var topLeft = {
x: Math.min(start.x, end.x),
y: Math.min(start.y, end.y)
};
var x = coord.width * xPercent + topLeft.x;
var y = coord.height * yPercent + topLeft.y;
return {
x: x,
y: y
};
};
return Guide;
}(Component);
module.exports = Guide;
/***/ }),
/* 20 */
/***/ (function(module, exports) {
var isArrayLike = function isArrayLike(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);
};
module.exports = isArrayLike;
/***/ }),
/* 21 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__create__ = __webpack_require__(463);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return __WEBPACK_IMPORTED_MODULE_0__create__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__creator__ = __webpack_require__(57);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "creator", function() { return __WEBPACK_IMPORTED_MODULE_1__creator__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__local__ = __webpack_require__(464);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "local", function() { return __WEBPACK_IMPORTED_MODULE_2__local__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__matcher__ = __webpack_require__(208);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "matcher", function() { return __WEBPACK_IMPORTED_MODULE_3__matcher__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__mouse__ = __webpack_require__(465);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mouse", function() { return __WEBPACK_IMPORTED_MODULE_4__mouse__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__namespace__ = __webpack_require__(90);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "namespace", function() { return __WEBPACK_IMPORTED_MODULE_5__namespace__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__namespaces__ = __webpack_require__(91);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "namespaces", function() { return __WEBPACK_IMPORTED_MODULE_6__namespaces__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__point__ = __webpack_require__(58);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clientPoint", function() { return __WEBPACK_IMPORTED_MODULE_7__point__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__select__ = __webpack_require__(209);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "select", function() { return __WEBPACK_IMPORTED_MODULE_8__select__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__selectAll__ = __webpack_require__(466);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "selectAll", function() { return __WEBPACK_IMPORTED_MODULE_9__selectAll__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__selection_index__ = __webpack_require__(17);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "selection", function() { return __WEBPACK_IMPORTED_MODULE_10__selection_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__selector__ = __webpack_require__(93);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "selector", function() { return __WEBPACK_IMPORTED_MODULE_11__selector__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__selectorAll__ = __webpack_require__(213);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "selectorAll", function() { return __WEBPACK_IMPORTED_MODULE_12__selectorAll__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__selection_style__ = __webpack_require__(212);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "style", function() { return __WEBPACK_IMPORTED_MODULE_13__selection_style__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__touch__ = __webpack_require__(495);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "touch", function() { return __WEBPACK_IMPORTED_MODULE_14__touch__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__touches__ = __webpack_require__(496);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "touches", function() { return __WEBPACK_IMPORTED_MODULE_15__touches__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__window__ = __webpack_require__(95);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "window", function() { return __WEBPACK_IMPORTED_MODULE_16__window__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__selection_on__ = __webpack_require__(92);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "event", function() { return __WEBPACK_IMPORTED_MODULE_17__selection_on__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "customEvent", function() { return __WEBPACK_IMPORTED_MODULE_17__selection_on__["b"]; });
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview shape 的辅助方法
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var ShapeUtil = {
splitPoints: function splitPoints(obj) {
var points = [];
var x = obj.x;
var y = obj.y;
y = Util.isArray(y) ? y : [y];
Util.each(y, function (yItem, index) {
var point = {
x: Util.isArray(x) ? x[index] : x,
y: yItem
};
points.push(point);
});
return points;
},
addFillAttrs: function addFillAttrs(attrs, cfg) {
if (cfg.color) {
attrs.fill = cfg.color;
}
if (Util.isNumber(cfg.opacity)) {
attrs.opacity = attrs.fillOpacity = cfg.opacity;
}
},
addStrokeAttrs: function addStrokeAttrs(attrs, cfg) {
if (cfg.color) {
attrs.stroke = cfg.color;
}
if (Util.isNumber(cfg.opacity)) {
attrs.opacity = attrs.strokeOpacity = cfg.opacity;
}
}
};
module.exports = ShapeUtil;
/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {
var G = __webpack_require__(35);
module.exports = G;
/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(41);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var BaseComponent = function (_Component) {
_inherits(BaseComponent, _Component);
function BaseComponent(props, name) {
_classCallCheck(this, BaseComponent);
var _this = _possibleConstructorReturn(this, (BaseComponent.__proto__ || Object.getPrototypeOf(BaseComponent)).call(this, props));
_this.getParentInfo = function () {
return {
id: _this.id,
name: _this.name
};
};
_this.name = name;
return _this;
}
_createClass(BaseComponent, [{
key: 'getChildContext',
value: function getChildContext() {
return {
addElement: this.context.addElement,
updateElement: this.context.updateElement,
deleteElement: this.context.deleteElement,
createId: this.context.createId,
getParentInfo: this.getParentInfo,
getViewId: this.context.getViewId
};
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
var context = this.context;
this.id = context.createId();
context.addElement(this.name, this.id, this.props, context.getParentInfo(), context.getViewId());
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
this.context.updateElement(this.name, this.id, nextProps, this.context.getParentInfo(), this.context.getViewId());
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.context.deleteElement(this.name, this.id);
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
if (children) {
if (children.length) {
children = _react2.default.createElement(
'div',
null,
children
);
}
} else {
children = null;
}
return children;
}
}]);
return BaseComponent;
}(_react.Component);
BaseComponent.contextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
BaseComponent.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
function generateBaseTypedComponent(name) {
var TypedComponent = function (_BaseComponent) {
_inherits(TypedComponent, _BaseComponent);
function TypedComponent(props) {
_classCallCheck(this, TypedComponent);
return _possibleConstructorReturn(this, (TypedComponent.__proto__ || Object.getPrototypeOf(TypedComponent)).call(this, props, name));
}
_createClass(TypedComponent, [{
key: 'getChildContext',
value: function getChildContext() {
return {
addElement: this.context.addElement,
updateElement: this.context.updateElement,
deleteElement: this.context.deleteElement,
createId: this.context.createId,
getParentInfo: this.getParentInfo,
getViewId: this.context.getViewId
};
}
}]);
return TypedComponent;
}(BaseComponent);
TypedComponent.contextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
TypedComponent.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
return TypedComponent;
}
BaseComponent.generateBaseTypedComponent = generateBaseTypedComponent;
exports.default = BaseComponent;
/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 计算path 使用的工具方法
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var Spline = __webpack_require__(308);
function points2path(points, isInCircle) {
if (!points.length) {
return [];
}
var path = [];
for (var i = 0, length = points.length; i < length; i++) {
var item = points[i];
if (i === 0) {
path.push(['M', item.x, item.y]);
} else {
path.push(['L', item.x, item.y]);
}
}
if (isInCircle) {
path.push(['Z']);
}
return path;
}
function _getPointRadius(coord, point) {
var center = coord.getCenter();
var r = Math.sqrt(Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2));
return r;
}
function convertArr(arr, coord) {
var len = arr.length;
var tmp = [arr[0]];
for (var i = 1; i < len; i = i + 2) {
var point = coord.convertPoint({
x: arr[i],
y: arr[i + 1]
});
tmp.push(point.x, point.y);
}
return tmp;
}
function _convertPolarPath(pre, cur, coord) {
// const radius = coord.getRadius();
// const inner = coord.innerRadius || 0;
// let innerRadius = inner * radius;
var transposed = coord.isTransposed;
var startAngle = coord.startAngle;
var endAngle = coord.endAngle;
var prePoint = {
x: pre[1],
y: pre[2]
};
var curPoint = {
x: cur[1],
y: cur[2]
};
var rst = []; // innerRadius = innerRadius || 0;
var xDim = transposed ? 'y' : 'x';
var angleRange = Math.abs(curPoint[xDim] - prePoint[xDim]) * (endAngle - startAngle);
var direction = curPoint[xDim] >= prePoint[xDim] ? 1 : 0; // 圆弧的方向
var flag = angleRange > Math.PI ? 1 : 0; // 大弧还是小弧标志位
var convertPoint = coord.convertPoint(curPoint);
var r = _getPointRadius(coord, convertPoint);
if (r >= 0.5) {
// 小于1像素的圆在图像上无法识别
if (angleRange === Math.PI * 2) {
var middlePoint = {
x: (curPoint.x + prePoint.x) / 2,
y: (curPoint.y + prePoint.y) / 2
};
var middleConvertPoint = coord.convertPoint(middlePoint);
rst.push(['A', r, r, 0, flag, direction, middleConvertPoint.x, middleConvertPoint.y]);
rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]);
} else {
rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]);
}
}
return rst;
} // 当存在整体的圆时,去除圆前面和后面的线,防止出现直线穿过整个圆的情形
function filterFullCirleLine(path) {
Util.each(path, function (subPath, index) {
var cur = subPath;
if (cur[0].toLowerCase() === 'a') {
var pre = path[index - 1];
var next = path[index + 1];
if (next && next[0].toLowerCase() === 'a') {
if (pre && pre[0].toLowerCase() === 'l') {
pre[0] = 'M';
}
} else if (pre && pre[0].toLowerCase() === 'a') {
if (next && next[0].toLowerCase() === 'l') {
next[0] = 'M';
}
}
}
});
}
var PathUtil = {
// 线的path
getLinePath: function getLinePath(points, isInCircle) {
return points2path(points, isInCircle);
},
// get spline: 限定了范围的平滑线
getSplinePath: function getSplinePath(points, isInCircle, constaint) {
var data = [];
var first = points[0];
var prePoint = null;
if (points.length <= 2) {
return PathUtil.getLinePath(points, isInCircle);
}
Util.each(points, function (point) {
if (!prePoint || !(prePoint.x === point.x && prePoint.y === point.y)) {
data.push(point.x);
data.push(point.y);
prePoint = point;
}
});
constaint = constaint || [// 范围
[0, 0], [1, 1]];
var splinePath = Spline.catmullRom2bezier(data, isInCircle, constaint);
splinePath.unshift(['M', first.x, first.y]);
return splinePath;
},
getPointRadius: function getPointRadius(coord, point) {
var result = _getPointRadius(coord, point);
return result;
},
getPointAngle: function getPointAngle(coord, point) {
var center = coord.getCenter();
var angle = Math.atan2(point.y - center.y, point.x - center.x);
return angle;
},
convertNormalPath: function convertNormalPath(coord, path) {
var tmp = [];
Util.each(path, function (subPath) {
var action = subPath[0];
switch (action.toLowerCase()) {
case 'm':
case 'l':
case 'c':
tmp.push(convertArr(subPath, coord));
break;
case 'z':
default:
tmp.push(subPath);
break;
}
});
return tmp;
},
convertPolarPath: function convertPolarPath(coord, path) {
var tmp = [];
var pre;
var cur;
var transposed;
var equals;
Util.each(path, function (subPath, index) {
var action = subPath[0];
switch (action.toLowerCase()) {
case 'm':
case 'c':
case 'q':
tmp.push(convertArr(subPath, coord));
break;
case 'l':
pre = path[index - 1];
cur = subPath;
transposed = coord.isTransposed; // 是否半径相同,转换成圆弧
equals = transposed ? pre[pre.length - 2] === cur[1] : pre[pre.length - 1] === cur[2];
if (equals) {
tmp = tmp.concat(_convertPolarPath(pre, cur, coord));
} else {
// y 不相等,所以直接转换
tmp.push(convertArr(subPath, coord));
}
break;
case 'z':
default:
tmp.push(subPath);
break;
}
});
filterFullCirleLine(tmp); // 过滤多余的直线
return tmp;
}
};
module.exports = PathUtil;
/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {
var mix = __webpack_require__(10);
var each = __webpack_require__(2);
var isObject = __webpack_require__(38);
var isNil = __webpack_require__(6);
var Scale =
/*#__PURE__*/
function () {
var _proto = Scale.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
this.type = 'base';
/**
* 格式化函数,输出文本或者tick时的格式化函数
* @type {Function}
*/
this.formatter = null;
/**
* 输出的值域
* @type {Array}
*/
this.range = [0, 1];
/**
* 度量的标记
* @type {Array}
*/
this.ticks = null;
/**
* 参与度量计算的值,可选项
* @type {Array}
*/
this.values = [];
};
function Scale(cfg) {
this._initDefaultCfg();
mix(this, cfg);
this.init();
}
/**
* 度量初始化
* @protected
*/
_proto.init = function init() {}
/**
* 获取该度量的ticks,返回的是多个对象,
* - text: tick 的文本
* - value: 对应的度量转换后的值
*
* [
* {text: 0,value:0}
* {text: 1,value:0.2}
* {text: 2,value:0.4}
* {text: 3,value:0.6}
* {text: 4,value:0.8}
* {text: 5,value:1}
* ]
*
* @param {Number} count 输出tick的个数的近似值,默认是 10
* @return {Array} 返回 ticks 数组
*/
;
_proto.getTicks = function getTicks() {
var self = this;
var ticks = self.ticks;
var rst = [];
each(ticks, function (tick) {
var obj;
if (isObject(tick)) {
obj = tick;
} else {
obj = {
text: self.getText(tick),
tickValue: tick,
value: self.scale(tick)
};
}
rst.push(obj);
});
return rst;
}
/**
* 获取格式化后的文本
* @param {*} value 输入的数据
* @param {*} key 字段的 key
* @return {String} 格式化的文本
*/
;
_proto.getText = function getText(value, key) {
var formatter = this.formatter;
value = formatter ? formatter(value, key) : value;
if (isNil(value) || !value.toString) {
value = '';
}
return value.toString();
}
/**
* 输出的值域最小值
* @protected
* @return {Number} 返回最小的值
*/
;
_proto.rangeMin = function rangeMin() {
return this.range[0];
}
/**
* 输出的值域最大值
* @protected
* @return {Number} 返回最大的值
*/
;
_proto.rangeMax = function rangeMax() {
var range = this.range;
return range[range.length - 1];
}
/**
* 度量转换后的结果,翻转回输入域
* @param {Number} value 需要翻转的数值
* @return {*} 度量的输入值
*/
;
_proto.invert = function invert(value) {
return value;
}
/**
* 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
* @param {*} value 传入的值
* @return {Number} 转换的值
*/
;
_proto.translate = function translate(value) {
return value;
}
/**
* 进行度量转换
* @param {*} value 输入值
* @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
*/
;
_proto.scale = function scale(value) {
return value;
}
/**
* 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
* @return {Scale} 克隆的度量
*/
;
_proto.clone = function clone() {
var self = this;
var constr = self.constructor;
var cfg = {};
each(self, function (v, k) {
cfg[k] = self[k];
});
return new constr(cfg);
}
/**
* 更改度量的属性信息
* @param {Object} info 属性信息
* @chainable
* @return {Scale} 返回自身的引用
*/
;
_proto.change = function change(info) {
this.ticks = null;
mix(this, info);
this.init();
return this;
};
return Scale;
}();
module.exports = Scale;
/***/ }),
/* 27 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = Transition;
/* harmony export (immutable) */ __webpack_exports__["a"] = transition;
/* harmony export (immutable) */ __webpack_exports__["c"] = newId;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__attr__ = __webpack_require__(504);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__attrTween__ = __webpack_require__(505);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__delay__ = __webpack_require__(506);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__duration__ = __webpack_require__(507);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ease__ = __webpack_require__(508);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__filter__ = __webpack_require__(510);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__merge__ = __webpack_require__(511);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__on__ = __webpack_require__(512);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__remove__ = __webpack_require__(513);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__select__ = __webpack_require__(514);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__selectAll__ = __webpack_require__(515);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__selection__ = __webpack_require__(516);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__style__ = __webpack_require__(517);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__styleTween__ = __webpack_require__(518);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__text__ = __webpack_require__(519);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__transition__ = __webpack_require__(520);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__tween__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__end__ = __webpack_require__(509);
var id = 0;
function Transition(groups, parents, name, id) {
this._groups = groups;
this._parents = parents;
this._name = name;
this._id = id;
}
function transition(name) {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_selection__["selection"])().transition(name);
}
function newId() {
return ++id;
}
var selection_prototype = __WEBPACK_IMPORTED_MODULE_0_d3_selection__["selection"].prototype;
Transition.prototype = transition.prototype = {
constructor: Transition,
select: __WEBPACK_IMPORTED_MODULE_10__select__["a" /* default */],
selectAll: __WEBPACK_IMPORTED_MODULE_11__selectAll__["a" /* default */],
filter: __WEBPACK_IMPORTED_MODULE_6__filter__["a" /* default */],
merge: __WEBPACK_IMPORTED_MODULE_7__merge__["a" /* default */],
selection: __WEBPACK_IMPORTED_MODULE_12__selection__["a" /* default */],
transition: __WEBPACK_IMPORTED_MODULE_16__transition__["a" /* default */],
call: selection_prototype.call,
nodes: selection_prototype.nodes,
node: selection_prototype.node,
size: selection_prototype.size,
empty: selection_prototype.empty,
each: selection_prototype.each,
on: __WEBPACK_IMPORTED_MODULE_8__on__["a" /* default */],
attr: __WEBPACK_IMPORTED_MODULE_1__attr__["a" /* default */],
attrTween: __WEBPACK_IMPORTED_MODULE_2__attrTween__["a" /* default */],
style: __WEBPACK_IMPORTED_MODULE_13__style__["a" /* default */],
styleTween: __WEBPACK_IMPORTED_MODULE_14__styleTween__["a" /* default */],
text: __WEBPACK_IMPORTED_MODULE_15__text__["a" /* default */],
remove: __WEBPACK_IMPORTED_MODULE_9__remove__["a" /* default */],
tween: __WEBPACK_IMPORTED_MODULE_17__tween__["a" /* default */],
delay: __WEBPACK_IMPORTED_MODULE_3__delay__["a" /* default */],
duration: __WEBPACK_IMPORTED_MODULE_4__duration__["a" /* default */],
ease: __WEBPACK_IMPORTED_MODULE_5__ease__["a" /* default */],
end: __WEBPACK_IMPORTED_MODULE_18__end__["a" /* default */]
};
/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (true) {
var ReactIs = __webpack_require__(218);
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = __webpack_require__(524)(ReactIs.isElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = require('./factoryWithThrowingShims')();
}
/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
Axis: __webpack_require__(234),
Component: __webpack_require__(62),
Guide: __webpack_require__(242),
Label: __webpack_require__(246),
Legend: __webpack_require__(252),
Tooltip: __webpack_require__(257)
};
/***/ }),
/* 30 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = hue;
/* harmony export (immutable) */ __webpack_exports__["c"] = gamma;
/* harmony export (immutable) */ __webpack_exports__["a"] = nogamma;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(203);
function linear(a, d) {
return function(t) {
return a + t * d;
};
}
function exponential(a, b, y) {
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
return Math.pow(a + t * b, y);
};
}
function hue(a, b) {
var d = b - a;
return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
}
function gamma(y) {
return (y = +y) === 1 ? nogamma : function(a, b) {
return b - a ? exponential(a, b, y) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
};
}
function nogamma(a, b) {
var d = b - a;
return d ? linear(a, d) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
}
/***/ }),
/* 31 */
/***/ (function(module, exports, __webpack_require__) {
var mix = __webpack_require__(10);
var Adjust =
/*#__PURE__*/
function () {
var _proto = Adjust.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
};
function Adjust(cfg) {
this._initDefaultCfg();
mix(this, cfg);
}
/**
* @override
*/
_proto.processAdjust = function processAdjust()
/* dataArray */
{};
return Adjust;
}();
module.exports = Adjust;
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview the Attribute base class
*/
var isString = __webpack_require__(15);
var isArray = __webpack_require__(4);
var isNil = __webpack_require__(6);
var mix = __webpack_require__(10);
var each = __webpack_require__(2);
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(ret)) {
ret = defaultCallback.apply(_this, params);
}
return ret;
};
}
mix(this, cfg);
if (mixedCallback) {
mix(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(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(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;
}();
module.exports = AttributeBase;
/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Component = __webpack_require__(34);
var Util = __webpack_require__(3);
var Grid = __webpack_require__(101);
var Label = __webpack_require__(103);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var Axis =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Axis, _Component);
function Axis() {
return _Component.apply(this, arguments) || this;
}
var _proto = Axis.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Component.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 用于动画,唯一标识的 id
* @type {[type]}
*/
_id: null,
zIndex: 4,
/**
* 坐标轴上的坐标点
* @type {Array}
*/
ticks: null,
/**
* 坐标轴线的配置信息,如果设置成null,则不显示轴线
* @type {Object}
*/
line: null,
/**
* 坐标轴刻度线的配置,如果设置成null,则不显示刻度线
* @type {Object}
*/
tickLine: null,
/**
* 次刻度线个数配置
* @type {Number}
*/
subTickCount: 0,
/**
* 次刻度线样式配置
* @type {Object}
*/
subTickLine: null,
/**
* 网格线配置,如果值为 null,则不显示
* @type {Object}
*/
grid: null,
/**
* 坐标轴文本配置
* @type {Object}
*/
label: {
offset: 0,
offsetX: 0,
offsetY: 0,
textStyle: {},
// 坐标轴文本样式
autoRotate: true,
autoHide: false,
formatter: null // 坐标轴文本格式化回调函数
},
labelItems: [],
/**
* 坐标轴标题配置
* @type {Object}
*/
title: {
autoRotate: true,
// 文本是否自动旋转
textStyle: {} // 坐标轴标题样式
},
autoPaint: true
});
};
_proto.beforeRender = function beforeRender() {
var self = this;
var title = self.get('title');
var label = self.get('label');
var grid = self.get('grid');
if (title) {
self.set('title', Util.deepMix({
autoRotate: true,
textStyle: {
fontSize: 12,
fill: '#ccc',
textBaseline: 'middle',
fontFamily: FONT_FAMILY,
textAlign: 'center'
},
offset: 48
}, title));
}
if (label) {
self.set('label', Util.deepMix({
autoRotate: true,
autoHide: true,
textStyle: {
fontSize: 12,
fill: '#ccc',
textBaseline: 'middle',
fontFamily: FONT_FAMILY
},
offset: 10
}, label));
}
if (grid) {
self.set('grid', Util.deepMix({
lineStyle: {
lineWidth: 1,
stroke: '#C0D0E0'
}
}, grid));
}
};
_proto.render = function render() {
var self = this;
self.beforeRender();
var labelCfg = self.get('label');
if (labelCfg) {
self.renderLabels();
}
if (self.get('autoPaint')) {
self.paint();
}
if (!Util.isNil(self.get('title'))) {
self.renderTitle();
}
self.get('group').sort();
};
_proto.renderLabels = function renderLabels() {
var self = this;
var group = self.get('group');
var labelCfg = self.get('label');
var labelRenderer = new Label();
self.set('labelRenderer', labelRenderer);
labelRenderer.set('labelCfg', labelCfg);
var cfgs2copy = ['formatter', 'htmlTemplate', 'labelLine', 'textStyle', 'useHtml'];
Util.each(cfgs2copy, function (cfg) {
if (labelCfg[cfg]) {
labelRenderer.set(cfg, labelCfg[cfg]);
}
});
labelRenderer.set('coord', self.get('coord'));
labelRenderer.set('group', group.addGroup());
labelRenderer.set('canvas', self.get('canvas'));
};
_proto._parseTicks = function _parseTicks(ticks) {
ticks = ticks || [];
var ticksLength = ticks.length;
for (var i = 0; i < ticksLength; i++) {
var item = ticks[i];
if (!Util.isObject(item)) {
ticks[i] = this.parseTick(item, i, ticksLength);
}
}
this.set('ticks', ticks);
return ticks;
};
_proto._addTickItem = function _addTickItem(index, point, length, type) {
if (type === void 0) {
type = '';
}
var tickItems = this.get('tickItems');
var subTickItems = this.get('subTickItems');
var end = this.getTickEnd(point, length, index);
var cfg = {
x1: point.x,
y1: point.y,
x2: end.x,
y2: end.y
};
if (!tickItems) {
tickItems = [];
}
if (!subTickItems) {
subTickItems = [];
}
if (type === 'sub') {
subTickItems.push(cfg);
} else {
tickItems.push(cfg);
}
this.set('tickItems', tickItems);
this.set('subTickItems', subTickItems);
};
_proto._renderLine = function _renderLine() {
var self = this;
var lineCfg = self.get('line');
var path;
if (lineCfg) {
path = self.getLinePath();
lineCfg = Util.mix({
path: path
}, lineCfg);
var group = self.get('group');
var lineShape = group.addShape('path', {
attrs: lineCfg
});
lineShape.name = 'axis-line';
self.get('appendInfo') && lineShape.setSilent('appendInfo', self.get('appendInfo'));
self.set('lineShape', lineShape);
}
};
_proto._processCatTicks = function _processCatTicks() {
var self = this;
var labelCfg = self.get('label');
var tickLineCfg = self.get('tickLine');
var ticks = self.get('ticks');
ticks = self._parseTicks(ticks);
var new_ticks = self._getNormalizedTicks(ticks);
for (var i = 0; i < new_ticks.length; i += 3) {
var p = self.getTickPoint(new_ticks[i]);
var p0 = self.getTickPoint(new_ticks[i + 1]);
var p1 = self.getTickPoint(new_ticks[i + 2]);
var index = Math.floor(i / 3);
var tick = ticks[index];
if (tickLineCfg) {
if (index === 0) {
self._addTickItem(index, p0, tickLineCfg.length);
}
self._addTickItem(index, p1, tickLineCfg.length);
}
if (labelCfg) {
self.addLabel(tick, p, index);
}
}
};
_proto._getNormalizedTicks = function _getNormalizedTicks(ticks) {
var tickSeg = 0;
if (ticks.length > 1) {
tickSeg = (ticks[1].value - ticks[0].value) / 2;
}
var points = [];
for (var i = 0; i < ticks.length; i++) {
var tick = ticks[i];
var p = tick.value;
var p0 = tick.value - tickSeg;
var p1 = tick.value + tickSeg;
points.push(p, p0, p1);
}
var range = Util.arrayUtil.getRange(points);
return points.map(function (p) {
var norm = (p - range.min) / (range.max - range.min);
return norm;
});
};
_proto.addLabel = function addLabel(tick, point, index) {
var self = this;
var labelItems = self.get('labelItems');
var labelRenderer = self.get('labelRenderer');
var label = Util.deepMix({}, self.get('label'));
var rst;
if (labelRenderer) {
var offset = self.get('_labelOffset');
if (!Util.isNil(self.get('label').offset)) {
offset = self.get('label').offset;
}
var vector = self.getSideVector(offset, point, index);
point = {
x: point.x + vector[0] + label.offsetX,
y: point.y + vector[1] + label.offsetY
};
label.text = tick.text;
label.x = point.x;
label.y = point.y;
label.point = point;
label.textAlign = self.getTextAnchor(vector);
if (point.rotate) {
label.rotate = point.rotate;
}
labelItems.push(label);
}
return rst;
};
_proto._processTicks = function _processTicks() {
var self = this;
var labelCfg = self.get('label');
var subTickCount = self.get('subTickCount');
var tickLineCfg = self.get('tickLine');
var ticks = self.get('ticks');
ticks = self._parseTicks(ticks);
Util.each(ticks, function (tick, index) {
var tickPoint = self.getTickPoint(tick.value, index);
if (tickLineCfg) {
self._addTickItem(index, tickPoint, tickLineCfg.length);
}
if (labelCfg) {
self.addLabel(tick, tickPoint, index);
}
});
if (subTickCount) {
// 如果有设置次级分点,添加次级tick
var subTickLineCfg = self.get('subTickLine');
Util.each(ticks, function (tick, index) {
if (index > 0) {
var diff = tick.value - ticks[index - 1].value;
diff = diff / (self.get('subTickCount') + 1);
for (var i = 1; i <= subTickCount; i++) {
var subTick = {
text: '',
value: index ? ticks[index - 1].value + i * diff : i * diff
};
var tickPoint = self.getTickPoint(subTick.value);
var subTickLength = void 0;
if (subTickLineCfg && subTickLineCfg.length) {
subTickLength = subTickLineCfg.length;
} else {
subTickLength = parseInt(tickLineCfg.length * (3 / 5), 10);
}
self._addTickItem(i - 1, tickPoint, subTickLength, 'sub');
}
}
});
}
};
_proto._addTickLine = function _addTickLine(ticks, lineCfg) {
var self = this;
var cfg = Util.mix({}, lineCfg);
var path = [];
Util.each(ticks, function (item) {
path.push(['M', item.x1, item.y1]);
path.push(['L', item.x2, item.y2]);
});
delete cfg.length;
cfg.path = path;
var group = self.get('group');
var tickShape = group.addShape('path', {
attrs: cfg
});
tickShape.name = 'axis-ticks';
tickShape._id = self.get('_id') + '-ticks';
tickShape.set('coord', self.get('coord'));
self.get('appendInfo') && tickShape.setSilent('appendInfo', self.get('appendInfo'));
};
_proto._renderTicks = function _renderTicks() {
var self = this;
var tickItems = self.get('tickItems');
var subTickItems = self.get('subTickItems');
if (!Util.isEmpty(tickItems)) {
var tickLineCfg = self.get('tickLine');
self._addTickLine(tickItems, tickLineCfg);
}
if (!Util.isEmpty(subTickItems)) {
var subTickLineCfg = self.get('subTickLine') || self.get('tickLine');
self._addTickLine(subTickItems, subTickLineCfg);
}
};
_proto._renderGrid = function _renderGrid() {
var grid = this.get('grid');
if (!grid) {
return;
}
grid.coord = this.get('coord');
grid.appendInfo = this.get('appendInfo');
var group = this.get('group');
this.set('gridGroup', group.addGroup(Grid, grid));
};
_proto._renderLabels = function _renderLabels() {
var self = this;
var labelRenderer = self.get('labelRenderer');
var labelItems = self.get('labelItems');
if (labelRenderer) {
labelRenderer.set('items', labelItems);
labelRenderer._dryDraw();
}
};
_proto.paint = function paint() {
var self = this;
var tickLineCfg = self.get('tickLine');
var alignWithLabel = true;
if (tickLineCfg && tickLineCfg.hasOwnProperty('alignWithLabel')) {
alignWithLabel = tickLineCfg.alignWithLabel;
}
self._renderLine();
var type = self.get('type');
var isCat = type === 'cat' || type === 'timeCat';
if (isCat && alignWithLabel === false) {
self._processCatTicks();
} else {
self._processTicks();
}
self._renderTicks();
self._renderGrid();
self._renderLabels();
var labelCfg = this.get('label');
if (labelCfg && labelCfg.autoRotate) {
self.autoRotateLabels();
}
if (labelCfg && labelCfg.autoHide) {
self.autoHideLabels();
}
};
_proto.parseTick = function parseTick(tick, index, length) {
return {
text: tick,
value: index / (length - 1)
};
};
_proto.getTextAnchor = function getTextAnchor(vector) {
var ratio = Math.abs(vector[1] / vector[0]);
var align;
if (ratio >= 1) {
// 上面或者下面
align = 'center';
} else {
if (vector[0] > 0) {
// 右侧
align = 'start';
} else {
// 左侧
align = 'end';
}
}
return align;
};
_proto.getMaxLabelWidth = function getMaxLabelWidth(labelRenderer) {
var labels = labelRenderer.getLabels();
var max = 0;
Util.each(labels, function (label) {
var bbox = label.getBBox();
var width = bbox.width;
if (max < width) {
max = width;
}
});
return max;
};
_proto.getMaxLabelHeight = function getMaxLabelHeight(labelRenderer) {
var labels = labelRenderer.getLabels();
var max = 0;
Util.each(labels, function (label) {
var bbox = label.getBBox();
var height = bbox.height;
if (max < height) {
max = height;
}
});
return max;
};
_proto.destroy = function destroy() {
var self = this;
if (!self.destroyed) {
_Component.prototype.destroy.call(this);
var gridGroup = self.get('gridGroup');
gridGroup && gridGroup.remove();
var labelRenderer = this.get('labelRenderer');
labelRenderer && labelRenderer.destroy();
var group = self.get('group');
group.destroy();
self.destroyed = true;
}
};
_proto.clear = function clear() {
var self = this;
var group = self.get('group');
if (!group.get('destroyed') && group.get('children').length) {
var gridGroup = self.get('gridGroup');
gridGroup && gridGroup.clear();
var labelRenderer = this.get('labelRenderer');
labelRenderer && labelRenderer.clear();
var _group = self.get('group');
_group.clear();
}
};
/**
* 旋转文本
* @abstract
* @return {[type]} [description]
*/
_proto.autoRotateLabels = function autoRotateLabels() {};
/**
* 文本自动防遮罩
* @abstract
* @return {[type]} [description]
*/
_proto.autoHideLabels = function autoHideLabels() {};
/**
* 渲染标题
* @abstract
* @return {[type]} [description]
*/
_proto.renderTitle = function renderTitle() {};
/**
* 获取坐标轴线的 path
* @abstract
* @return {[type]} [description]
*/
_proto.getLinePath = function getLinePath() {};
/**
* 获取 tick 在画布上的位置
* @abstract
* @return {[type]} [description]
*/
_proto.getTickPoint = function getTickPoint() {};
/**
* 获取标示坐标点的线的终点
* @abstract
* @return {[type]} [description]
*/
_proto.getTickEnd = function getTickEnd() {};
/**
* 获取距离坐标轴的向量
* @abstract
* @return {[type]} [description]
*/
_proto.getSideVector = function getSideVector() {};
return Axis;
}(Component);
module.exports = Axis;
/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(62);
var Component =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Component, _Base);
function Component() {
return _Base.apply(this, arguments) || this;
}
var _proto = Component.prototype;
// 配置
_proto.getDefaultCfg = function getDefaultCfg() {
return {
// 顶层标志位
_id: null,
// 用于动画
// 容器
canvas: null,
container: null,
// html,可选
group: null,
// G Group,可选
// 交互属性
capture: false,
// props
coord: null,
offset: [0, 0],
plotRange: null,
// BBox
position: [0, 0],
visible: true,
zIndex: 1
};
}; // 基础生命周期
_proto._init = function _init() {};
_proto.clear = function clear() {};
_proto.destroy = function destroy() {}; // 绘图
_proto.beforeRender = function beforeRender() {};
_proto.render = function render() {}; // 初始化、绑事件和绘图
_proto.afterRender = function afterRender() {};
_proto.beforeDraw = function beforeDraw() {};
_proto.draw = function draw() {}; // 单纯更新视图
_proto.afterDraw = function afterDraw() {}; // visibility
_proto.show = function show() {};
_proto.hide = function hide() {}; // props operating syntactic sugar
_proto.setOffset = function setOffset() {};
_proto.setPosition = function setPosition() {};
_proto.setVisible = function setVisible() {};
_proto.setZIndex = function setZIndex() {};
return Component;
}(Base);
module.exports = Component;
/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
Canvas: __webpack_require__(312),
Group: __webpack_require__(127),
Shape: __webpack_require__(7),
Arc: __webpack_require__(129),
Circle: __webpack_require__(130),
Dom: __webpack_require__(131),
Ellipse: __webpack_require__(132),
Fan: __webpack_require__(133),
Image: __webpack_require__(134),
Line: __webpack_require__(135),
Marker: __webpack_require__(68),
Path: __webpack_require__(138),
Polygon: __webpack_require__(139),
Polyline: __webpack_require__(140),
Rect: __webpack_require__(141),
Text: __webpack_require__(142),
PathSegment: __webpack_require__(47),
PathUtil: __webpack_require__(71),
Event: __webpack_require__(128),
// version, etc.
version: '3.3.6'
};
/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
var regexDot = /[^\s\,]+/ig;
var numColorCache = {};
module.exports = {
parseRadius: function parseRadius(radius) {
var r1 = 0,
r2 = 0,
r3 = 0,
r4 = 0;
if (Util.isArray(radius)) {
if (radius.length === 1) {
r1 = r2 = r3 = r4 = radius[0];
} else if (radius.length === 2) {
r1 = r3 = radius[0];
r2 = r4 = radius[1];
} else if (radius.length === 3) {
r1 = radius[0];
r2 = r4 = radius[1];
r3 = radius[2];
} else {
r1 = radius[0];
r2 = radius[1];
r3 = radius[2];
r4 = radius[3];
}
} else {
r1 = r2 = r3 = r4 = radius;
}
return {
r1: r1,
r2: r2,
r3: r3,
r4: r4
};
},
parsePath: function parsePath(path) {
path = path || [];
if (Util.isArray(path)) {
return path;
}
if (Util.isString(path)) {
path = path.match(regexTags);
Util.each(path, function (item, index) {
item = item.match(regexDot);
if (item[0].length > 1) {
var tag = item[0].charAt(0);
item.splice(1, 0, item[0].substr(1));
item[0] = tag;
}
Util.each(item, function (sub, i) {
if (!isNaN(sub)) {
item[i] = +sub;
}
});
path[index] = item;
});
return path;
}
},
numberToColor: function numberToColor(num) {
// 增加缓存
var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};
/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {
var isNil = __webpack_require__(6);
function toString(value) {
if (isNil(value)) return '';
return value.toString();
}
module.exports = toString;
/***/ }),
/* 38 */
/***/ (function(module, exports) {
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';
};
module.exports = isObject;
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
var isObjectLike = __webpack_require__(80);
var isType = __webpack_require__(16);
var isPlainObject = function isPlainObject(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(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;
};
module.exports = isPlainObject;
/***/ }),
/* 40 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = hue;
/* harmony export (immutable) */ __webpack_exports__["c"] = gamma;
/* harmony export (immutable) */ __webpack_exports__["a"] = nogamma;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(196);
function linear(a, d) {
return function(t) {
return a + t * d;
};
}
function exponential(a, b, y) {
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
return Math.pow(a + t * b, y);
};
}
function hue(a, b) {
var d = b - a;
return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
}
function gamma(y) {
return (y = +y) === 1 ? nogamma : function(a, b) {
return b - a ? exponential(a, b, y) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
};
}
function nogamma(a, b) {
var d = b - a;
return d ? linear(a, d) : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
}
/***/ }),
/* 41 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_41__;
/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/**
* @fileOverview the base class of Coordinate
* @author sima.zhang
*/
var MatrixUtil = __webpack_require__(52);
var mix = __webpack_require__(10);
var mat3 = MatrixUtil.mat3;
var vec3 = MatrixUtil.vec3;
var Coord =
/*#__PURE__*/
function () {
_createClass(Coord, [{
key: "getDefaultCfg",
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
value: function getDefaultCfg() {
return {
/**
* Mark x y is transposed.
* @type {Boolean}
*/
isTransposed: false,
/**
* The matrix of coordinate
* @type {Array}
*/
matrix: [1, 0, 0, 0, 1, 0, 0, 0, 1]
};
}
}]);
function Coord(cfg) {
_classCallCheck(this, Coord);
var defaultCfg = this.getDefaultCfg();
mix(this, defaultCfg, cfg);
this.init();
}
_createClass(Coord, [{
key: "init",
value: function init() {
var start = this.start;
var end = this.end;
var center = {
x: (start.x + end.x) / 2,
y: (start.y + end.y) / 2
};
this.center = center;
this.width = Math.abs(end.x - start.x);
this.height = Math.abs(end.y - start.y);
}
}, {
key: "_swapDim",
value: function _swapDim(dim) {
var dimRange = this[dim];
if (dimRange) {
var tmp = dimRange.start;
dimRange.start = dimRange.end;
dimRange.end = tmp;
}
}
}, {
key: "getCenter",
value: function getCenter() {
return this.center;
}
}, {
key: "getWidth",
value: function getWidth() {
return this.width;
}
}, {
key: "getHeight",
value: function getHeight() {
return this.height;
}
}, {
key: "convertDim",
value: function convertDim(percent, dim) {
var _this$dim = this[dim],
start = _this$dim.start,
end = _this$dim.end;
return start + percent * (end - start);
}
}, {
key: "invertDim",
value: function invertDim(value, dim) {
var _this$dim2 = this[dim],
start = _this$dim2.start,
end = _this$dim2.end;
return (value - start) / (end - start);
}
/**
* 将归一化的坐标点数据转换为画布坐标
* @override
* @param {Object} point 归一化的坐标点
* @return {Object} 返回画布坐标
*/
}, {
key: "convertPoint",
value: function convertPoint(point) {
return point;
}
/**
* 将画布坐标转换为归一化的坐标点数据
* @override
* @param {Object} point 画布坐标点数据
* @return {Object} 归一化后的数据点
*/
}, {
key: "invertPoint",
value: function invertPoint(point) {
return point;
}
/**
* 将坐标点进行矩阵变换
* @param {Number} x 对应 x 轴画布坐标
* @param {Number} y 对应 y 轴画布坐标
* @param {Number} tag 默认为 0,可取值 0, 1
* @return {Array} 返回变换后的三阶向量 [x, y, z]
*/
}, {
key: "applyMatrix",
value: function applyMatrix(x, y) {
var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var matrix = this.matrix;
var vector = [x, y, tag];
vec3.transformMat3(vector, vector, matrix);
return vector;
}
/**
* 将坐标点进行矩阵逆变换
* @param {Number} x 对应 x 轴画布坐标
* @param {Number} y 对应 y 轴画布坐标
* @param {Number} tag 默认为 0,可取值 0, 1
* @return {Array} 返回矩阵逆变换后的三阶向量 [x, y, z]
*/
}, {
key: "invertMatrix",
value: function invertMatrix(x, y) {
var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var matrix = this.matrix;
var inversedMatrix = mat3.invert([], matrix);
var vector = [x, y, tag];
vec3.transformMat3(vector, vector, inversedMatrix);
return vector;
}
/**
* 将归一化的坐标点数据转换为画布坐标,并根据坐标系当前矩阵进行变换
* @param {Object} point 归一化的坐标点
* @return {Object} 返回进行矩阵变换后的画布坐标
*/
}, {
key: "convert",
value: function convert(point) {
var _this$convertPoint = this.convertPoint(point),
x = _this$convertPoint.x,
y = _this$convertPoint.y;
var vector = this.applyMatrix(x, y, 1);
return {
x: vector[0],
y: vector[1]
};
}
/**
* 将进行过矩阵变换画布坐标转换为归一化坐标
* @param {Object} point 画布坐标
* @return {Object} 返回归一化的坐标点
*/
}, {
key: "invert",
value: function invert(point) {
var vector = this.invertMatrix(point.x, point.y, 1);
return this.invertPoint({
x: vector[0],
y: vector[1]
});
}
/**
* 坐标系旋转变换
* @param {Number} radian 旋转弧度
* @return {Object} 返回坐标系对象
*/
}, {
key: "rotate",
value: function rotate(radian) {
var matrix = this.matrix;
var center = this.center;
mat3.translate(matrix, matrix, [-center.x, -center.y]);
mat3.rotate(matrix, matrix, radian);
mat3.translate(matrix, matrix, [center.x, center.y]);
return this;
}
/**
* 坐标系反射变换
* @param {String} dim 反射维度
* @return {Object} 返回坐标系对象
*/
}, {
key: "reflect",
value: function reflect(dim) {
switch (dim) {
case 'x':
this._swapDim('x');
break;
case 'y':
this._swapDim('y');
break;
default:
this._swapDim('y');
}
return this;
}
/**
* 坐标系比例变换
* @param {Number} s1 x 方向缩放比例
* @param {Number} s2 y 方向缩放比例
* @return {Object} 返回坐标系对象
*/
}, {
key: "scale",
value: function scale(s1, s2) {
var matrix = this.matrix;
var center = this.center;
mat3.translate(matrix, matrix, [-center.x, -center.y]);
mat3.scale(matrix, matrix, [s1, s2]);
mat3.translate(matrix, matrix, [center.x, center.y]);
return this;
}
/**
* 坐标系平移变换
* @param {Number} x x 方向平移像素
* @param {Number} y y 方向平移像素
* @return {Object} 返回坐标系对象
*/
}, {
key: "translate",
value: function translate(x, y) {
var matrix = this.matrix;
mat3.translate(matrix, matrix, [x, y]);
return this;
}
/**
* 将坐标系 x y 两个轴进行转置
* @return {Object} 返回坐标系对象
*/
}, {
key: "transpose",
value: function transpose() {
this.isTransposed = !this.isTransposed;
return this;
}
}]);
return Coord;
}();
module.exports = Coord;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlLmpzIl0sIm5hbWVzIjpbIk1hdHJpeFV0aWwiLCJyZXF1aXJlIiwibWl4IiwibWF0MyIsInZlYzMiLCJDb29yZCIsImlzVHJhbnNwb3NlZCIsIm1hdHJpeCIsImNmZyIsImRlZmF1bHRDZmciLCJnZXREZWZhdWx0Q2ZnIiwiaW5pdCIsInN0YXJ0IiwiZW5kIiwiY2VudGVyIiwieCIsInkiLCJ3aWR0aCIsIk1hdGgiLCJhYnMiLCJoZWlnaHQiLCJkaW0iLCJkaW1SYW5nZSIsInRtcCIsInBlcmNlbnQiLCJ2YWx1ZSIsInBvaW50IiwidGFnIiwidmVjdG9yIiwidHJhbnNmb3JtTWF0MyIsImludmVyc2VkTWF0cml4IiwiaW52ZXJ0IiwiY29udmVydFBvaW50IiwiYXBwbHlNYXRyaXgiLCJpbnZlcnRNYXRyaXgiLCJpbnZlcnRQb2ludCIsInJhZGlhbiIsInRyYW5zbGF0ZSIsInJvdGF0ZSIsIl9zd2FwRGltIiwiczEiLCJzMiIsInNjYWxlIiwibW9kdWxlIiwiZXhwb3J0cyJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7QUFBQTs7OztBQUlBLElBQU1BLFVBQVUsR0FBR0MsT0FBTyxDQUFDLHdCQUFELENBQTFCOztBQUNBLElBQU1DLEdBQUcsR0FBR0QsT0FBTyxDQUFDLG9CQUFELENBQW5COztBQUVBLElBQU1FLElBQUksR0FBR0gsVUFBVSxDQUFDRyxJQUF4QjtBQUNBLElBQU1DLElBQUksR0FBR0osVUFBVSxDQUFDSSxJQUF4Qjs7SUFFTUMsSzs7Ozs7O0FBQ0o7Ozs7O29DQUtnQjtBQUNkLGFBQU87QUFDTDs7OztBQUlBQyxRQUFBQSxZQUFZLEVBQUUsS0FMVDs7QUFNTDs7OztBQUlBQyxRQUFBQSxNQUFNLEVBQUUsQ0FBRSxDQUFGLEVBQUssQ0FBTCxFQUFRLENBQVIsRUFBVyxDQUFYLEVBQWMsQ0FBZCxFQUFpQixDQUFqQixFQUFvQixDQUFwQixFQUF1QixDQUF2QixFQUEwQixDQUExQjtBQVZILE9BQVA7QUFZRDs7O0FBRUQsaUJBQVlDLEdBQVosRUFBaUI7QUFBQTs7QUFDZixRQUFNQyxVQUFVLEdBQUcsS0FBS0MsYUFBTCxFQUFuQjtBQUNBUixJQUFBQSxHQUFHLENBQUMsSUFBRCxFQUFPTyxVQUFQLEVBQW1CRCxHQUFuQixDQUFIO0FBQ0EsU0FBS0csSUFBTDtBQUNEOzs7OzJCQUVNO0FBQ0wsVUFBTUMsS0FBSyxHQUFHLEtBQUtBLEtBQW5CO0FBQ0EsVUFBTUMsR0FBRyxHQUFHLEtBQUtBLEdBQWpCO0FBQ0EsVUFBTUMsTUFBTSxHQUFHO0FBQ2JDLFFBQUFBLENBQUMsRUFBRSxDQUFDSCxLQUFLLENBQUNHLENBQU4sR0FBVUYsR0FBRyxDQUFDRSxDQUFmLElBQW9CLENBRFY7QUFFYkMsUUFBQUEsQ0FBQyxFQUFFLENBQUNKLEtBQUssQ0FBQ0ksQ0FBTixHQUFVSCxHQUFHLENBQUNHLENBQWYsSUFBb0I7QUFGVixPQUFmO0FBS0EsV0FBS0YsTUFBTCxHQUFjQSxNQUFkO0FBQ0EsV0FBS0csS0FBTCxHQUFhQyxJQUFJLENBQUNDLEdBQUwsQ0FBU04sR0FBRyxDQUFDRSxDQUFKLEdBQVFILEtBQUssQ0FBQ0csQ0FBdkIsQ0FBYjtBQUNBLFdBQUtLLE1BQUwsR0FBY0YsSUFBSSxDQUFDQyxHQUFMLENBQVNOLEdBQUcsQ0FBQ0csQ0FBSixHQUFRSixLQUFLLENBQUNJLENBQXZCLENBQWQ7QUFDRDs7OzZCQUVRSyxHLEVBQUs7QUFDWixVQUFNQyxRQUFRLEdBQUcsS0FBS0QsR0FBTCxDQUFqQjs7QUFDQSxVQUFJQyxRQUFKLEVBQWM7QUFDWixZQUFNQyxHQUFHLEdBQUdELFFBQVEsQ0FBQ1YsS0FBckI7QUFDQVUsUUFBQUEsUUFBUSxDQUFDVixLQUFULEdBQWlCVSxRQUFRLENBQUNULEdBQTFCO0FBQ0FTLFFBQUFBLFFBQVEsQ0FBQ1QsR0FBVCxHQUFlVSxHQUFmO0FBQ0Q7QUFDRjs7O2dDQUVXO0FBQ1YsYUFBTyxLQUFLVCxNQUFaO0FBQ0Q7OzsrQkFFVTtBQUNULGFBQU8sS0FBS0csS0FBWjtBQUNEOzs7Z0NBRVc7QUFDVixhQUFPLEtBQUtHLE1BQVo7QUFDRDs7OytCQUVVSSxPLEVBQVNILEcsRUFBSztBQUFBLHNCQUNBLEtBQUtBLEdBQUwsQ0FEQTtBQUFBLFVBQ2ZULEtBRGUsYUFDZkEsS0FEZTtBQUFBLFVBQ1JDLEdBRFEsYUFDUkEsR0FEUTtBQUV2QixhQUFPRCxLQUFLLEdBQUdZLE9BQU8sSUFBSVgsR0FBRyxHQUFHRCxLQUFWLENBQXRCO0FBQ0Q7Ozs4QkFFU2EsSyxFQUFPSixHLEVBQUs7QUFBQSx1QkFDRyxLQUFLQSxHQUFMLENBREg7QUFBQSxVQUNaVCxLQURZLGNBQ1pBLEtBRFk7QUFBQSxVQUNMQyxHQURLLGNBQ0xBLEdBREs7QUFFcEIsYUFBTyxDQUFDWSxLQUFLLEdBQUdiLEtBQVQsS0FBbUJDLEdBQUcsR0FBR0QsS0FBekIsQ0FBUDtBQUNEO0FBRUQ7Ozs7Ozs7OztpQ0FNYWMsSyxFQUFPO0FBQ2xCLGFBQU9BLEtBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs7Z0NBTVlBLEssRUFBTztBQUNqQixhQUFPQSxLQUFQO0FBQ0Q7QUFFRDs7Ozs7Ozs7OztnQ0FPWVgsQyxFQUFHQyxDLEVBQVk7QUFBQSxVQUFUVyxHQUFTLHVFQUFILENBQUc7QUFDekIsVUFBTXBCLE1BQU0sR0FBRyxLQUFLQSxNQUFwQjtBQUNBLFVBQU1xQixNQUFNLEdBQUcsQ0FBRWIsQ0FBRixFQUFLQyxDQUFMLEVBQVFXLEdBQVIsQ0FBZjtBQUNBdkIsTUFBQUEsSUFBSSxDQUFDeUIsYUFBTCxDQUFtQkQsTUFBbkIsRUFBMkJBLE1BQTNCLEVBQW1DckIsTUFBbkM7QUFDQSxhQUFPcUIsTUFBUDtBQUNEO0FBRUQ7Ozs7Ozs7Ozs7aUNBT2FiLEMsRUFBR0MsQyxFQUFZO0FBQUEsVUFBVFcsR0FBUyx1RUFBSCxDQUFHO0FBQzFCLFVBQU1wQixNQUFNLEdBQUcsS0FBS0EsTUFBcEI7QUFDQSxVQUFNdUIsY0FBYyxHQUFHM0IsSUFBSSxDQUFDNEIsTUFBTCxDQUFZLEVBQVosRUFBZ0J4QixNQUFoQixDQUF2QjtBQUNBLFVBQU1xQixNQUFNLEdBQUcsQ0FBRWIsQ0FBRixFQUFLQyxDQUFMLEVBQVFXLEdBQVIsQ0FBZjtBQUNBdkIsTUFBQUEsSUFBSSxDQUFDeUIsYUFBTCxDQUFtQkQsTUFBbkIsRUFBMkJBLE1BQTNCLEVBQW1DRSxjQUFuQztBQUNBLGFBQU9GLE1BQVA7QUFDRDtBQUVEOzs7Ozs7Ozs0QkFLUUYsSyxFQUFPO0FBQUEsK0JBQ0ksS0FBS00sWUFBTCxDQUFrQk4sS0FBbEIsQ0FESjtBQUFBLFVBQ0xYLENBREssc0JBQ0xBLENBREs7QUFBQSxVQUNGQyxDQURFLHNCQUNGQSxDQURFOztBQUViLFVBQU1ZLE1BQU0sR0FBRyxLQUFLSyxXQUFMLENBQWlCbEIsQ0FBakIsRUFBb0JDLENBQXBCLEVBQXVCLENBQXZCLENBQWY7QUFDQSxhQUFPO0FBQ0xELFFBQUFBLENBQUMsRUFBRWEsTUFBTSxDQUFDLENBQUQsQ0FESjtBQUVMWixRQUFBQSxDQUFDLEVBQUVZLE1BQU0sQ0FBQyxDQUFEO0FBRkosT0FBUDtBQUlEO0FBRUQ7Ozs7Ozs7OzJCQUtPRixLLEVBQU87QUFDWixVQUFNRSxNQUFNLEdBQUcsS0FBS00sWUFBTCxDQUFrQlIsS0FBSyxDQUFDWCxDQUF4QixFQUEyQlcsS0FBSyxDQUFDVixDQUFqQyxFQUFvQyxDQUFwQyxDQUFmO0FBQ0EsYUFBTyxLQUFLbUIsV0FBTCxDQUFpQjtBQUN0QnBCLFFBQUFBLENBQUMsRUFBRWEsTUFBTSxDQUFDLENBQUQsQ0FEYTtBQUV0QlosUUFBQUEsQ0FBQyxFQUFFWSxNQUFNLENBQUMsQ0FBRDtBQUZhLE9BQWpCLENBQVA7QUFJRDtBQUVEOzs7Ozs7OzsyQkFLT1EsTSxFQUFRO0FBQ2IsVUFBTTdCLE1BQU0sR0FBRyxLQUFLQSxNQUFwQjtBQUNBLFVBQU1PLE1BQU0sR0FBRyxLQUFLQSxNQUFwQjtBQUNBWCxNQUFBQSxJQUFJLENBQUNrQyxTQUFMLENBQWU5QixNQUFmLEVBQXVCQSxNQUF2QixFQUErQixDQUFFLENBQUNPLE1BQU0sQ0FBQ0MsQ0FBVixFQUFhLENBQUNELE1BQU0sQ0FBQ0UsQ0FBckIsQ0FBL0I7QUFDQWIsTUFBQUEsSUFBSSxDQUFDbUMsTUFBTCxDQUFZL0IsTUFBWixFQUFvQkEsTUFBcEIsRUFBNEI2QixNQUE1QjtBQUNBakMsTUFBQUEsSUFBSSxDQUFDa0MsU0FBTCxDQUFlOUIsTUFBZixFQUF1QkEsTUFBdkIsRUFBK0IsQ0FBRU8sTUFBTSxDQUFDQyxDQUFULEVBQVlELE1BQU0sQ0FBQ0UsQ0FBbkIsQ0FBL0I7QUFDQSxhQUFPLElBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs0QkFLUUssRyxFQUFLO0FBQ1gsY0FBUUEsR0FBUjtBQUNFLGFBQUssR0FBTDtBQUNFLGVBQUtrQixRQUFMLENBQWMsR0FBZDs7QUFDQTs7QUFDRixhQUFLLEdBQUw7QUFDRSxlQUFLQSxRQUFMLENBQWMsR0FBZDs7QUFDQTs7QUFDRjtBQUNFLGVBQUtBLFFBQUwsQ0FBYyxHQUFkOztBQVJKOztBQVVBLGFBQU8sSUFBUDtBQUNEO0FBRUQ7Ozs7Ozs7OzswQkFNTUMsRSxFQUFJQyxFLEVBQUk7QUFDWixVQUFNbEMsTUFBTSxHQUFHLEtBQUtBLE1BQXBCO0FBQ0EsVUFBTU8sTUFBTSxHQUFHLEtBQUtBLE1BQXBCO0FBQ0FYLE1BQUFBLElBQUksQ0FBQ2tDLFNBQUwsQ0FBZTlCLE1BQWYsRUFBdUJBLE1BQXZCLEVBQStCLENBQUUsQ0FBQ08sTUFBTSxDQUFDQyxDQUFWLEVBQWEsQ0FBQ0QsTUFBTSxDQUFDRSxDQUFyQixDQUEvQjtBQUNBYixNQUFBQSxJQUFJLENBQUN1QyxLQUFMLENBQVduQyxNQUFYLEVBQW1CQSxNQUFuQixFQUEyQixDQUFFaUMsRUFBRixFQUFNQyxFQUFOLENBQTNCO0FBQ0F0QyxNQUFBQSxJQUFJLENBQUNrQyxTQUFMLENBQWU5QixNQUFmLEVBQXVCQSxNQUF2QixFQUErQixDQUFFTyxNQUFNLENBQUNDLENBQVQsRUFBWUQsTUFBTSxDQUFDRSxDQUFuQixDQUEvQjtBQUNBLGFBQU8sSUFBUDtBQUNEO0FBRUQ7Ozs7Ozs7Ozs4QkFNVUQsQyxFQUFHQyxDLEVBQUc7QUFDZCxVQUFNVCxNQUFNLEdBQUcsS0FBS0EsTUFBcEI7QUFDQUosTUFBQUEsSUFBSSxDQUFDa0MsU0FBTCxDQUFlOUIsTUFBZixFQUF1QkEsTUFBdkIsRUFBK0IsQ0FBRVEsQ0FBRixFQUFLQyxDQUFMLENBQS9CO0FBQ0EsYUFBTyxJQUFQO0FBQ0Q7QUFFRDs7Ozs7OztnQ0FJWTtBQUNWLFdBQUtWLFlBQUwsR0FBb0IsQ0FBQyxLQUFLQSxZQUExQjtBQUNBLGFBQU8sSUFBUDtBQUNEOzs7Ozs7QUFHSHFDLE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQnZDLEtBQWpCIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAZmlsZU92ZXJ2aWV3IHRoZSBiYXNlIGNsYXNzIG9mIENvb3JkaW5hdGVcbiAqIEBhdXRob3Igc2ltYS56aGFuZ1xuICovXG5jb25zdCBNYXRyaXhVdGlsID0gcmVxdWlyZSgnQGFudHYvdXRpbC9saWIvbWF0cml4LycpO1xuY29uc3QgbWl4ID0gcmVxdWlyZSgnQGFudHYvdXRpbC9saWIvbWl4Jyk7XG5cbmNvbnN0IG1hdDMgPSBNYXRyaXhVdGlsLm1hdDM7XG5jb25zdCB2ZWMzID0gTWF0cml4VXRpbC52ZWMzO1xuXG5jbGFzcyBDb29yZCB7XG4gIC8qKlxuICAgKiDojrflj5bpu5jorqTnmoTphY3nva7lsZ7mgKdcbiAgICogQHByb3RlY3RlZFxuICAgKiBAcmV0dXJuIHtPYmplY3R9IOm7mOiupOWxnuaAp1xuICAgKi9cbiAgZ2V0RGVmYXVsdENmZygpIHtcbiAgICByZXR1cm4ge1xuICAgICAgLyoqXG4gICAgICAgKiBNYXJrIHggeSBpcyB0cmFuc3Bvc2VkLlxuICAgICAgICogQHR5cGUge0Jvb2xlYW59XG4gICAgICAgKi9cbiAgICAgIGlzVHJhbnNwb3NlZDogZmFsc2UsXG4gICAgICAvKipcbiAgICAgICAqIFRoZSBtYXRyaXggb2YgY29vcmRpbmF0ZVxuICAgICAgICogQHR5cGUge0FycmF5fVxuICAgICAgICovXG4gICAgICBtYXRyaXg6IFsgMSwgMCwgMCwgMCwgMSwgMCwgMCwgMCwgMSBdXG4gICAgfTtcbiAgfVxuXG4gIGNvbnN0cnVjdG9yKGNmZykge1xuICAgIGNvbnN0IGRlZmF1bHRDZmcgPSB0aGlzLmdldERlZmF1bHRDZmcoKTtcbiAgICBtaXgodGhpcywgZGVmYXVsdENmZywgY2ZnKTtcbiAgICB0aGlzLmluaXQoKTtcbiAgfVxuXG4gIGluaXQoKSB7XG4gICAgY29uc3Qgc3RhcnQgPSB0aGlzLnN0YXJ0O1xuICAgIGNvbnN0IGVuZCA9IHRoaXMuZW5kO1xuICAgIGNvbnN0IGNlbnRlciA9IHtcbiAgICAgIHg6IChzdGFydC54ICsgZW5kLngpIC8gMixcbiAgICAgIHk6IChzdGFydC55ICsgZW5kLnkpIC8gMlxuICAgIH07XG5cbiAgICB0aGlzLmNlbnRlciA9IGNlbnRlcjtcbiAgICB0aGlzLndpZHRoID0gTWF0aC5hYnMoZW5kLnggLSBzdGFydC54KTtcbiAgICB0aGlzLmhlaWdodCA9IE1hdGguYWJzKGVuZC55IC0gc3RhcnQueSk7XG4gIH1cblxuICBfc3dhcERpbShkaW0pIHtcbiAgICBjb25zdCBkaW1SYW5nZSA9IHRoaXNbZGltXTtcbiAgICBpZiAoZGltUmFuZ2UpIHtcbiAgICAgIGNvbnN0IHRtcCA9IGRpbVJhbmdlLnN0YXJ0O1xuICAgICAgZGltUmFuZ2Uuc3RhcnQgPSBkaW1SYW5nZS5lbmQ7XG4gICAgICBkaW1SYW5nZS5lbmQgPSB0bXA7XG4gICAgfVxuICB9XG5cbiAgZ2V0Q2VudGVyKCkge1xuICAgIHJldHVybiB0aGlzLmNlbnRlcjtcbiAgfVxuXG4gIGdldFdpZHRoKCkge1xuICAgIHJldHVybiB0aGlzLndpZHRoO1xuICB9XG5cbiAgZ2V0SGVpZ2h0KCkge1xuICAgIHJldHVybiB0aGlzLmhlaWdodDtcbiAgfVxuXG4gIGNvbnZlcnREaW0ocGVyY2VudCwgZGltKSB7XG4gICAgY29uc3QgeyBzdGFydCwgZW5kIH0gPSB0aGlzW2RpbV07XG4gICAgcmV0dXJuIHN0YXJ0ICsgcGVyY2VudCAqIChlbmQgLSBzdGFydCk7XG4gIH1cblxuICBpbnZlcnREaW0odmFsdWUsIGRpbSkge1xuICAgIGNvbnN0IHsgc3RhcnQsIGVuZCB9ID0gdGhpc1tkaW1dO1xuICAgIHJldHVybiAodmFsdWUgLSBzdGFydCkgLyAoZW5kIC0gc3RhcnQpO1xuICB9XG5cbiAgLyoqXG4gICAqIOWwhuW9kuS4gOWMlueahOWdkOagh+eCueaVsOaNrui9rOaNouS4uueUu+W4g+WdkOagh1xuICAgKiBAb3ZlcnJpZGVcbiAgICogQHBhcmFtICB7T2JqZWN0fSBwb2ludCDlvZLkuIDljJbnmoTlnZDmoIfngrlcbiAgICogQHJldHVybiB7T2JqZWN0fSAgICAgICDov5Tlm57nlLvluIPlnZDmoIdcbiAgICovXG4gIGNvbnZlcnRQb2ludChwb2ludCkge1xuICAgIHJldHVybiBwb2ludDtcbiAgfVxuXG4gIC8qKlxuICAgKiDlsIbnlLvluIPlnZDmoIfovazmjaLkuLrlvZLkuIDljJbnmoTlnZDmoIfngrnmlbDmja5cbiAgICogQG92ZXJyaWRlXG4gICAqIEBwYXJhbSAge09iamVjdH0gcG9pbnQg55S75biD5Z2Q5qCH54K55pWw5o2uXG4gICAqIEByZXR1cm4ge09iamVjdH0gICAgICAg5b2S5LiA5YyW5ZCO55qE5pWw5o2u54K5XG4gICAqL1xuICBpbnZlcnRQb2ludChwb2ludCkge1xuICAgIHJldHVybiBwb2ludDtcbiAgfVxuXG4gIC8qKlxuICAgKiDlsIblnZDmoIfngrnov5vooYznn6npmLXlj5jmjaJcbiAgICogQHBhcmFtICB7TnVtYmVyfSB4ICAg5a+55bqUIHgg6L2055S75biD5Z2Q5qCHXG4gICAqIEBwYXJhbSAge051bWJlcn0geSAgIOWvueW6lCB5IOi9tOeUu+W4g+WdkOagh1xuICAgKiBAcGFyYW0gIHtOdW1iZXJ9IHRhZyDpu5jorqTkuLogMO+8jOWPr+WPluWAvCAwLCAxXG4gICAqIEByZXR1cm4ge0FycmF5fSAgICAg6L+U5Zue5Y+Y5o2i5ZCO55qE5LiJ6Zi25ZCR6YePIFt4LCB5LCB6XVxuICAgKi9cbiAgYXBwbHlNYXRyaXgoeCwgeSwgdGFnID0gMCkge1xuICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMubWF0cml4O1xuICAgIGNvbnN0IHZlY3RvciA9IFsgeCwgeSwgdGFnIF07XG4gICAgdmVjMy50cmFuc2Zvcm1NYXQzKHZlY3RvciwgdmVjdG9yLCBtYXRyaXgpO1xuICAgIHJldHVybiB2ZWN0b3I7XG4gIH1cblxuICAvKipcbiAgICog5bCG5Z2Q5qCH54K56L+b6KGM55+p6Zi16YCG5Y+Y5o2iXG4gICAqIEBwYXJhbSAge051bWJlcn0geCAgIOWvueW6lCB4IOi9tOeUu+W4g+WdkOagh1xuICAgKiBAcGFyYW0gIHtOdW1iZXJ9IHkgICDlr7nlupQgeSDovbTnlLvluIPlnZDmoIdcbiAgICogQHBhcmFtICB7TnVtYmVyfSB0YWcg6buY6K6k5Li6IDDvvIzlj6/lj5blgLwgMCwgMVxuICAgKiBAcmV0dXJuIHtBcnJheX0gICAgIOi/lOWbnuefqemYtemAhuWPmOaNouWQjueahOS4iemYtuWQkemHjyBbeCwgeSwgel1cbiAgICovXG4gIGludmVydE1hdHJpeCh4LCB5LCB0YWcgPSAwKSB7XG4gICAgY29uc3QgbWF0cml4ID0gdGhpcy5tYXRyaXg7XG4gICAgY29uc3QgaW52ZXJzZWRNYXRyaXggPSBtYXQzLmludmVydChbXSwgbWF0cml4KTtcbiAgICBjb25zdCB2ZWN0b3IgPSBbIHgsIHksIHRhZyBdO1xuICAgIHZlYzMudHJhbnNmb3JtTWF0Myh2ZWN0b3IsIHZlY3RvciwgaW52ZXJzZWRNYXRyaXgpO1xuICAgIHJldHVybiB2ZWN0b3I7XG4gIH1cblxuICAvKipcbiAgICog5bCG5b2S5LiA5YyW55qE5Z2Q5qCH54K55pWw5o2u6L2s5o2i5Li655S75biD5Z2Q5qCH77yM5bm25qC55o2u5Z2Q5qCH57O75b2T5YmN55+p6Zi16L+b6KGM5Y+Y5o2iXG4gICAqIEBwYXJhbSAge09iamVjdH0gcG9pbnQg5b2S5LiA5YyW55qE5Z2Q5qCH54K5XG4gICAqIEByZXR1cm4ge09iamVjdH0gICAgICAg6L+U5Zue6L+b6KGM55+p6Zi15Y+Y5o2i5ZCO55qE55S75biD5Z2Q5qCHXG4gICAqL1xuICBjb252ZXJ0KHBvaW50KSB7XG4gICAgY29uc3QgeyB4LCB5IH0gPSB0aGlzLmNvbnZlcnRQb2ludChwb2ludCk7XG4gICAgY29uc3QgdmVjdG9yID0gdGhpcy5hcHBseU1hdHJpeCh4LCB5LCAxKTtcbiAgICByZXR1cm4ge1xuICAgICAgeDogdmVjdG9yWzBdLFxuICAgICAgeTogdmVjdG9yWzFdXG4gICAgfTtcbiAgfVxuXG4gIC8qKlxuICAgKiDlsIbov5vooYzov4fnn6npmLXlj5jmjaLnlLvluIPlnZDmoIfovazmjaLkuLrlvZLkuIDljJblnZDmoIdcbiAgICogQHBhcmFtICB7T2JqZWN0fSBwb2ludCDnlLvluIPlnZDmoIdcbiAgICogQHJldHVybiB7T2JqZWN0fSAgICAgICDov5Tlm57lvZLkuIDljJbnmoTlnZDmoIfngrlcbiAgICovXG4gIGludmVydChwb2ludCkge1xuICAgIGNvbnN0IHZlY3RvciA9IHRoaXMuaW52ZXJ0TWF0cml4KHBvaW50LngsIHBvaW50LnksIDEpO1xuICAgIHJldHVybiB0aGlzLmludmVydFBvaW50KHtcbiAgICAgIHg6IHZlY3RvclswXSxcbiAgICAgIHk6IHZlY3RvclsxXVxuICAgIH0pO1xuICB9XG5cbiAgLyoqXG4gICAqIOWdkOagh+ezu+aXi+i9rOWPmOaNolxuICAgKiBAcGFyYW0gIHtOdW1iZXJ9IHJhZGlhbiDml4vovazlvKfluqZcbiAgICogQHJldHVybiB7T2JqZWN0fSAgICAgICAg6L+U5Zue5Z2Q5qCH57O75a+56LGhXG4gICAqL1xuICByb3RhdGUocmFkaWFuKSB7XG4gICAgY29uc3QgbWF0cml4ID0gdGhpcy5tYXRyaXg7XG4gICAgY29uc3QgY2VudGVyID0gdGhpcy5jZW50ZXI7XG4gICAgbWF0My50cmFuc2xhdGUobWF0cml4LCBtYXRyaXgsIFsgLWNlbnRlci54LCAtY2VudGVyLnkgXSk7XG4gICAgbWF0My5yb3RhdGUobWF0cml4LCBtYXRyaXgsIHJhZGlhbik7XG4gICAgbWF0My50cmFuc2xhdGUobWF0cml4LCBtYXRyaXgsIFsgY2VudGVyLngsIGNlbnRlci55IF0pO1xuICAgIHJldHVybiB0aGlzO1xuICB9XG5cbiAgLyoqXG4gICAqIOWdkOagh+ezu+WPjeWwhOWPmOaNolxuICAgKiBAcGFyYW0gIHtTdHJpbmd9IGRpbSDlj43lsITnu7TluqZcbiAgICogQHJldHVybiB7T2JqZWN0fSAgICAg6L+U5Zue5Z2Q5qCH57O75a+56LGhXG4gICAqL1xuICByZWZsZWN0KGRpbSkge1xuICAgIHN3aXRjaCAoZGltKSB7XG4gICAgICBjYXNlICd4JzpcbiAgICAgICAgdGhpcy5fc3dhcERpbSgneCcpO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgJ3knOlxuICAgICAgICB0aGlzLl9zd2FwRGltKCd5Jyk7XG4gICAgICAgIGJyZWFrO1xuICAgICAgZGVmYXVsdDpcbiAgICAgICAgdGhpcy5fc3dhcERpbSgneScpO1xuICAgIH1cbiAgICByZXR1cm4gdGhpcztcbiAgfVxuXG4gIC8qKlxuICAgKiDlnZDmoIfns7vmr5Tkvovlj5jmjaJcbiAgICogQHBhcmFtICB7TnVtYmVyfSBzMSB4IOaWueWQkee8qeaUvuavlOS+i1xuICAgKiBAcGFyYW0gIHtOdW1iZXJ9IHMyIHkg5pa55ZCR57yp5pS+5q+U5L6LXG4gICAqIEByZXR1cm4ge09iamVjdH0gICAg6L+U5Zue5Z2Q5qCH57O75a+56LGhXG4gICAqL1xuICBzY2FsZShzMSwgczIpIHtcbiAgICBjb25zdCBtYXRyaXggPSB0aGlzLm1hdHJpeDtcbiAgICBjb25zdCBjZW50ZXIgPSB0aGlzLmNlbnRlcjtcbiAgICBtYXQzLnRyYW5zbGF0ZShtYXRyaXgsIG1hdHJpeCwgWyAtY2VudGVyLngsIC1jZW50ZXIueSBdKTtcbiAgICBtYXQzLnNjYWxlKG1hdHJpeCwgbWF0cml4LCBbIHMxLCBzMiBdKTtcbiAgICBtYXQzLnRyYW5zbGF0ZShtYXRyaXgsIG1hdHJpeCwgWyBjZW50ZXIueCwgY2VudGVyLnkgXSk7XG4gICAgcmV0dXJuIHRoaXM7XG4gIH1cblxuICAvKipcbiAgICog5Z2Q5qCH57O75bmz56e75Y+Y5o2iXG4gICAqIEBwYXJhbSAge051bWJlcn0geCB4IOaWueWQkeW5s+enu+WDj+e0oFxuICAgKiBAcGFyYW0gIHtOdW1iZXJ9IHkgeSDmlrnlkJHlubPnp7vlg4/ntKBcbiAgICogQHJldHVybiB7T2JqZWN0fSAgIOi/lOWbnuWdkOagh+ezu+WvueixoVxuICAgKi9cbiAgdHJhbnNsYXRlKHgsIHkpIHtcbiAgICBjb25zdCBtYXRyaXggPSB0aGlzLm1hdHJpeDtcbiAgICBtYXQzLnRyYW5zbGF0ZShtYXRyaXgsIG1hdHJpeCwgWyB4LCB5IF0pO1xuICAgIHJldHVybiB0aGlzO1xuICB9XG5cbiAgLyoqXG4gICAqIOWwhuWdkOagh+ezuyB4IHkg5Lik5Liq6L206L+b6KGM6L2s572uXG4gICAqIEByZXR1cm4ge09iamVjdH0g6L+U5Zue5Z2Q5qCH57O75a+56LGhXG4gICAqL1xuICB0cmFuc3Bvc2UoKSB7XG4gICAgdGhpcy5pc1RyYW5zcG9zZWQgPSAhdGhpcy5pc1RyYW5zcG9zZWQ7XG4gICAgcmV0dXJuIHRoaXM7XG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSBDb29yZDtcbiJdfQ==
/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview facets of chart
* @author dxq613@gmail.com
*/
var Global = __webpack_require__(5);
var Util = __webpack_require__(0);
var assign = Util.assign;
var isNil = Util.isNil;
var isArray = Util.isArray;
var cloneDeep = Util.cloneDeep; // 绑定事件
var wrapBehavior = Util.wrapBehavior; // 获取绑定的事件
var getWrapBehavior = Util.getWrapBehavior;
var Base =
/*#__PURE__*/
function () {
var _proto = Base.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
chart: null,
group: null,
/**
* 是否默认显示每个分面的title
* @type {Boolean}
*/
showTitle: true,
/**
* 是否自动修改坐标轴的信息
* @type {Boolean}
*/
autoSetAxis: true,
/**
* View 的内边框
* @type {Number|Array}
*/
padding: 10,
/**
* 遍历每个view 的回调函数
* @type {Function}
*/
eachView: null,
/**
* 分面的字段名列表
* @type {Array}
*/
fields: [],
/**
* 列值的的标题
* @type {Object}
*/
colTitle: {
offsetY: -15,
style: {
fontSize: 14,
textAlign: 'center',
fill: '#666',
fontFamily: Global.fontFamily
}
},
rowTitle: {
offsetX: 15,
style: {
fontSize: 14,
textAlign: 'center',
rotate: 90,
fill: '#666',
fontFamily: Global.fontFamily
}
}
};
};
function Base(cfg) {
var defaultCfg = this.getDefaultCfg();
assign(this, defaultCfg, cfg);
this.init();
}
_proto.init = function init() {
if (!this.chart) {
throw new Error('Facets Error: please specify the chart!');
}
this._bindEvent();
this.initContainer();
if (this.chart.get('data')) {
this.initViews();
}
};
_proto.initContainer = function initContainer() {
var chart = this.chart;
var frontPlot = chart.get('frontPlot');
var group = frontPlot.addGroup();
this.group = group;
};
_proto.initViews = function initViews() {
var chart = this.chart;
var data = chart.get('data');
var eachView = this.eachView;
var facets = this.generateFacets(data);
for (var i = 0; i < facets.length; i++) {
var facet = facets[i];
var region = facet.region;
var view = chart.view({
start: region.start,
end: region.end,
padding: this.padding
});
view.source(facet.data);
this.beforeProcessView(view, facet);
if (eachView) {
eachView(view, facet);
}
this.afterProcessView(view, facet);
facet.view = view;
}
this.facets = facets;
};
/**
* 处理 view 前
* @protected
*/
_proto.beforeProcessView = function beforeProcessView()
/* view, facet */
{};
/**
* 处理view
* @param {Object} view 视图
* @param {Object} facet 分面信息
* @protected
*/
_proto.afterProcessView = function afterProcessView(view, facet) {
if (this.autoSetAxis) {
this.processAxis(view, facet);
}
};
_proto.processAxis = function processAxis(view, facet) {
var viewOptions = view.get('options');
var geoms = view.get('geoms');
if ((!viewOptions.coord.type || viewOptions.coord.type === 'rect') && geoms.length) {
var field = geoms[0].get('attrOptions').position.field;
var fields = isArray(field) ? field : field.split('*').map(function (str) {
return str.trim();
});
var xField = fields[0];
var yField = fields[1];
if (isNil(viewOptions.axes)) {
viewOptions.axes = {};
}
var axes = viewOptions.axes;
if (axes !== false) {
if (xField && axes[xField] !== false) {
axes[xField] = axes[xField] || {};
this.setXAxis(xField, axes, facet);
}
if (yField && axes[yField] !== false) {
axes[yField] = axes[yField] || {};
this.setYAxis(yField, axes, facet);
}
}
}
};
_proto.setXAxis = function setXAxis()
/* xField, axes, facet */
{};
_proto.setYAxis = function setYAxis()
/* yField, axes, facet */
{}; // 默认显示各列的标题
_proto.renderTitle = function renderTitle(view, facet) {
this.drawColTitle(view, facet);
};
_proto.getScaleText = function getScaleText(field, value, view) {
var rst;
if (field) {
var scales = view.get('scales');
var scale = scales[field];
if (!scale) {
scale = view.createScale(field);
}
rst = scale.getText(value);
} else {
rst = value;
}
return rst;
};
_proto.drawColTitle = function drawColTitle(view, facet) {
var text = this.getScaleText(facet.colField, facet.colValue, view);
var colTextCfg = assign({
position: ['50%', '0%'],
content: text
}, this.colTitle);
view.guide().text(colTextCfg);
};
_proto.drawRowTitle = function drawRowTitle(view, facet) {
var text = this.getScaleText(facet.rowField, facet.rowValue, view);
var rowTextCfg = assign({
position: ['100%', '50%'],
content: text
}, cloneDeep(this.rowTitle));
view.guide().text(rowTextCfg);
};
/**
* 数据过滤器
* @protected
* @param {Array} conditions 过滤条件
* @return {Function} 过滤函数
*/
_proto.getFilter = function getFilter(conditions) {
var filter = function filter(obj) {
var filtered = true;
conditions.forEach(function (cond) {
var field = cond.field;
var value = cond.value; // const values = cond.values;
var tmp = true;
if (!isNil(value) && field) {
tmp = obj[field] === value;
}
filtered = filtered && tmp;
});
return filtered;
};
return filter;
};
/**
* 获取字段对应的值
* @protected
* @param {String} field 字段名
* @param {Array} data 数据
* @return {Array} 字段对应的值
*/
_proto.getFieldValues = function getFieldValues(field, data) {
var rst = [];
var tmpMap = {};
for (var i = 0; i < data.length; i++) {
var obj = data[i];
var value = obj[field];
if (!isNil(value) && !tmpMap[value]) {
rst.push(value);
tmpMap[value] = true;
}
}
return rst;
};
_proto.getRegion = function getRegion(rows, cols, xIndex, yIndex) {
var xWidth = 1 / cols; // x轴方向的每个分面的偏移
var yWidth = 1 / rows; // y轴方向的每个分面的偏移
var start = {
x: xWidth * xIndex,
y: yWidth * yIndex
};
var end = {
x: start.x + xWidth,
y: start.y + yWidth
};
return {
start: start,
end: end
};
};
/**
* 生成分面
* @protected
* @return {Array} 多个分面集合
*/
_proto.generateFacets = function generateFacets()
/* data */
{
return [];
};
_proto._bindEvent = function _bindEvent() {
var chart = this.chart;
chart.on('afterchangedata', wrapBehavior(this, 'onDataChange'));
chart.on('beforeclear', wrapBehavior(this, 'onClear'));
chart.on('beforedestroy', wrapBehavior(this, 'destroy'));
chart.on('beforepaint', wrapBehavior(this, 'onPaint'));
chart.on('setdata', wrapBehavior(this, 'onDataChange'));
};
_proto._clearEvent = function _clearEvent() {
var chart = this.chart;
if (chart) {
chart.off('afterchangedata', getWrapBehavior(this, 'onDataChange'));
chart.off('beforeclear', getWrapBehavior(this, 'onClear'));
chart.off('beforedestroy', getWrapBehavior(this, 'destroy'));
chart.off('beforepaint', getWrapBehavior(this, 'onPaint'));
chart.off('setdata', getWrapBehavior(this, 'onDataChange'));
}
};
_proto._clearFacets = function _clearFacets() {
var facets = this.facets;
var chart = this.chart;
if (facets) {
for (var i = 0; i < facets.length; i++) {
var facet = facets[i];
chart.removeView(facet.view);
}
}
this.facets = null;
};
_proto.onClear = function onClear() {
this.onRemove();
};
_proto.onPaint = function onPaint() {
if (this.showTitle) {
var facets = this.facets;
for (var i = 0; i < facets.length; i++) {
var facet = facets[i];
var view = facet.view;
this.renderTitle(view, facet);
}
}
};
_proto.onDataChange = function onDataChange() {
this._clearFacets();
this.initViews();
};
_proto.onRemove = function onRemove() {
this._clearFacets();
this._clearEvent();
this.group && this.group.remove();
this.chart = null;
this.facets = null;
this.group = null;
};
_proto.destroy = function destroy() {
this.onRemove();
this.destroyed = true;
};
return Base;
}();
module.exports = Base;
/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
function circlePoint(cx, cy, r, angle) {
return {
x: Math.cos(angle) * r + cx,
y: Math.sin(angle) * r + cy
};
}
function angleNearTo(angle, min, max, out) {
var v1;
var v2;
if (out) {
if (angle < min) {
v1 = min - angle;
v2 = Math.PI * 2 - max + angle;
} else if (angle > max) {
v1 = Math.PI * 2 - angle + min;
v2 = angle - max;
}
} else {
v1 = angle - min;
v2 = max - angle;
}
return v1 > v2 ? max : min;
}
function nearAngle(angle, startAngle, endAngle, clockwise) {
var plus = 0;
if (endAngle - startAngle >= Math.PI * 2) {
plus = Math.PI * 2;
}
startAngle = Util.mod(startAngle, Math.PI * 2);
endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
angle = Util.mod(angle, Math.PI * 2);
if (clockwise) {
if (startAngle >= endAngle) {
if (angle > endAngle && angle < startAngle) {
return angle;
}
return angleNearTo(angle, endAngle, startAngle, true);
}
if (angle < startAngle || angle > endAngle) {
return angle;
}
return angleNearTo(angle, startAngle, endAngle);
}
if (startAngle <= endAngle) {
if (startAngle < angle && angle < endAngle) {
return angle;
}
return angleNearTo(angle, startAngle, endAngle, true);
}
if (angle > startAngle || angle < endAngle) {
return angle;
}
return angleNearTo(angle, endAngle, startAngle);
}
function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) {
var v = [x, y];
var v0 = [cx, cy];
var v1 = [1, 0];
var subv = Util.vec2.subtract([], v, v0);
var angle = Util.vec2.angleTo(v1, subv);
angle = nearAngle(angle, startAngle, endAngle, clockwise);
var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
if (out) {
out.x = vpoint[0];
out.y = vpoint[1];
}
var d = Util.vec2.distance(vpoint, v);
return d;
}
function arcBox(cx, cy, r, startAngle, endAngle, clockwise) {
var angleRight = 0;
var angleBottom = Math.PI / 2;
var angleLeft = Math.PI;
var angleTop = Math.PI * 3 / 2;
var points = [];
var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
if (angle === angleRight) {
points.push(circlePoint(cx, cy, r, angleRight));
}
angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
if (angle === angleBottom) {
points.push(circlePoint(cx, cy, r, angleBottom));
}
angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
if (angle === angleLeft) {
points.push(circlePoint(cx, cy, r, angleLeft));
}
angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
if (angle === angleTop) {
points.push(circlePoint(cx, cy, r, angleTop));
}
points.push(circlePoint(cx, cy, r, startAngle));
points.push(circlePoint(cx, cy, r, endAngle));
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
Util.each(points, function (point) {
if (minX > point.x) {
minX = point.x;
}
if (maxX < point.x) {
maxX = point.x;
}
if (minY > point.y) {
minY = point.y;
}
if (maxY < point.y) {
maxY = point.y;
}
});
return {
minX: minX,
minY: minY,
maxX: maxX,
maxY: maxY
};
}
module.exports = {
nearAngle: nearAngle,
projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) {
var rst = {};
arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst);
return rst;
},
pointDistance: arcProjectPoint,
box: arcBox
};
/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {
var vec2 = __webpack_require__(1).vec2;
module.exports = {
at: function at(p1, p2, t) {
return (p2 - p1) * t + p1;
},
pointDistance: function pointDistance(x1, y1, x2, y2, x, y) {
var d = [x2 - x1, y2 - y1];
if (vec2.exactEquals(d, [0, 0])) {
return NaN;
}
var u = [-d[1], d[0]];
vec2.normalize(u, u);
var a = [x - x1, y - y1];
return Math.abs(vec2.dot(a, u));
},
box: function box(x1, y1, x2, y2, lineWidth) {
var halfWidth = lineWidth / 2;
var minX = Math.min(x1, x2);
var maxX = Math.max(x1, x2);
var minY = Math.min(y1, y2);
var maxY = Math.max(y1, y2);
return {
minX: minX - halfWidth,
minY: minY - halfWidth,
maxX: maxX + halfWidth,
maxY: maxY + halfWidth
};
},
len: function len(x1, y1, x2, y2) {
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
};
/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {
var Format = __webpack_require__(36);
var PathSegment = __webpack_require__(47);
var PI = Math.PI;
var sin = Math.sin;
var cos = Math.cos;
var atan2 = Math.atan2;
var DEFAULT_LENGTH = 10;
var DEFAULT_ANGLE = PI / 3;
function _addArrow(ctx, attrs, x1, y1, x2, y2, isStart) {
var leftX;
var leftY;
var rightX;
var rightY;
var offsetX;
var offsetY;
var angle;
if (!attrs.fill) {
// 闭合的不绘制箭头
var arrowLength = attrs.arrowLength || DEFAULT_LENGTH;
var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧
// Calculate angle
angle = atan2(y1 - y2, x1 - x2);
/* // Adjust angle correctly
angle -= PI;*/
// Calculate offset to place arrow at edge of path
offsetX = Math.abs(attrs.lineWidth * cos(angle)) / 2;
offsetY = Math.abs(attrs.lineWidth * sin(angle)) / 2;
if (isStart) {
offsetX = -offsetX;
offsetY = -offsetY;
} // Calculate coordinates for left half of arrow
leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
leftY = y2 + arrowLength * sin(angle + arrowAngle / 2); // Calculate coordinates for right half of arrow
rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
ctx.beginPath(); // Draw left half of arrow
ctx.moveTo(leftX - offsetX, leftY - offsetY);
ctx.lineTo(x2 - offsetX, y2 - offsetY); // Draw right half of arrow
ctx.lineTo(rightX - offsetX, rightY - offsetY); // Visually connect arrow to path
ctx.moveTo(x2 - offsetX, y2 - offsetY);
ctx.lineTo(x2 + offsetX, y2 + offsetY); // Move back to end of path
ctx.moveTo(x2, y2);
ctx.stroke();
}
}
function parsePath(attrs) {
var segments = [];
var pathArray = Format.parsePath(attrs.path);
var preSegment;
if (!Array.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
return false;
}
var count = pathArray.length;
for (var i = 0; i < pathArray.length; i++) {
var item = pathArray[i];
preSegment = new PathSegment(item, preSegment, i === count - 1);
segments.push(preSegment);
}
return segments;
}
function _addCustomizedArrow(ctx, attrs, x1, y1, x2, y2, isStart) {
var shape = isStart ? attrs.startArrow : attrs.endArrow;
var d = shape.d;
var deg = 0;
var x = x2 - x1;
var y = y2 - y1;
var tan = Math.atan(x / y);
if (y === 0 && x < 0) {
deg = Math.PI;
} else if (x > 0 && y > 0) {
deg = Math.PI / 2 - tan;
} else if (x < 0 && y < 0) {
deg = -Math.PI / 2 - tan;
} else if (x >= 0 && y < 0) {
deg = -tan - Math.PI / 2;
} else if (x <= 0 && y > 0) {
deg = Math.PI / 2 - tan;
}
var path = parsePath(shape);
if (!path) {
return;
}
if (d) {
if (isStart) {
x2 = x2 + Math.sin(Math.abs(tan)) * d;
y2 = y2 + Math.cos(Math.abs(tan)) * d - 0.5 * ctx.lineWidth;
} else {
x2 = x2 - Math.sin(Math.abs(tan)) * d;
y2 = y2 - Math.cos(Math.abs(tan)) * d + 0.5 * ctx.lineWidth;
}
}
ctx.save();
ctx.beginPath();
ctx.translate(x2, y2);
ctx.rotate(deg);
for (var i = 0; i < path.length; i++) {
path[i].draw(ctx);
}
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.fillStyle = ctx.strokeStyle;
ctx.fill();
ctx.restore();
}
module.exports = {
addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
if (typeof attrs.startArrow === 'object') {
_addCustomizedArrow(ctx, attrs, x1, y1, x2, y2, true);
} else if (attrs.startArrow) {
_addArrow(ctx, attrs, x1, y1, x2, y2, true);
}
},
addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
if (typeof attrs.endArrow === 'object') {
_addCustomizedArrow(ctx, attrs, x1, y1, x2, y2, false);
} else if (attrs.endArrow) {
_addArrow(ctx, attrs, x1, y1, x2, y2, false);
}
}
};
/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Inside = __webpack_require__(70);
var Cubic = __webpack_require__(69);
var Quadratic = __webpack_require__(137);
var Ellipse = __webpack_require__(136);
var vec3 = Util.vec3;
var mat3 = Util.mat3;
var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z'];
function toAbsolute(x, y, curPoint) {
// 获取绝对坐标
return {
x: curPoint.x + x,
y: curPoint.y + y
};
}
function toSymmetry(point, center) {
// 点对称
return {
x: center.x + (center.x - point.x),
y: center.y + (center.y - point.y)
};
}
function vMag(v) {
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
}
function vRatio(u, v) {
return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
}
function vAngle(u, v) {
return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
}
function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) {
var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2);
var x1 = point1.x;
var y1 = point1.y;
var x2 = point2.x;
var y2 = point2.y;
var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0;
var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
if (lambda > 1) {
rx *= Math.sqrt(lambda);
ry *= Math.sqrt(lambda);
}
var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);
var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);
if (fa === fs) {
f *= -1;
}
if (isNaN(f)) {
f = 0;
}
var cxp = f * rx * yp / ry;
var cyp = f * -ry * xp / rx;
var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
var u = [(xp - cxp) / rx, (yp - cyp) / ry];
var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
var dTheta = vAngle(u, v);
if (vRatio(u, v) <= -1) {
dTheta = Math.PI;
}
if (vRatio(u, v) >= 1) {
dTheta = 0;
}
if (fs === 0 && dTheta > 0) {
dTheta = dTheta - 2 * Math.PI;
}
if (fs === 1 && dTheta < 0) {
dTheta = dTheta + 2 * Math.PI;
}
return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];
}
var PathSegment = function PathSegment(item, preSegment, isLast) {
this.preSegment = preSegment;
this.isLast = isLast;
this.init(item, preSegment);
};
Util.augment(PathSegment, {
init: function init(item, preSegment) {
var command = item[0];
preSegment = preSegment || {
endPoint: {
x: 0,
y: 0
}
};
var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
var cmd = relative ? command.toUpperCase() : command;
var p = item;
var point1;
var point2;
var point3;
var point;
var preEndPoint = preSegment.endPoint;
var p1 = p[1];
var p2 = p[2];
switch (cmd) {
default:
break;
case 'M':
if (relative) {
point = toAbsolute(p1, p2, preEndPoint);
} else {
point = {
x: p1,
y: p2
};
}
this.command = 'M';
this.params = [preEndPoint, point];
this.subStart = point;
this.endPoint = point;
break;
case 'L':
if (relative) {
point = toAbsolute(p1, p2, preEndPoint);
} else {
point = {
x: p1,
y: p2
};
}
this.command = 'L';
this.params = [preEndPoint, point];
this.subStart = preSegment.subStart;
this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'H':
if (relative) {
point = toAbsolute(p1, 0, preEndPoint);
} else {
point = {
x: p1,
y: preEndPoint.y
};
}
this.command = 'L';
this.params = [preEndPoint, point];
this.subStart = preSegment.subStart;
this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'V':
if (relative) {
point = toAbsolute(0, p1, preEndPoint);
} else {
point = {
x: preEndPoint.x,
y: p1
};
}
this.command = 'L';
this.params = [preEndPoint, point];
this.subStart = preSegment.subStart;
this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'Q':
if (relative) {
point1 = toAbsolute(p1, p2, preEndPoint);
point2 = toAbsolute(p[3], p[4], preEndPoint);
} else {
point1 = {
x: p1,
y: p2
};
point2 = {
x: p[3],
y: p[4]
};
}
this.command = 'Q';
this.params = [preEndPoint, point1, point2];
this.subStart = preSegment.subStart;
this.endPoint = point2;
this.endTangent = function () {
return [point2.x - point1.x, point2.y - point1.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
break;
case 'T':
if (relative) {
point2 = toAbsolute(p1, p2, preEndPoint);
} else {
point2 = {
x: p1,
y: p2
};
}
if (preSegment.command === 'Q') {
point1 = toSymmetry(preSegment.params[1], preEndPoint);
this.command = 'Q';
this.params = [preEndPoint, point1, point2];
this.subStart = preSegment.subStart;
this.endPoint = point2;
this.endTangent = function () {
return [point2.x - point1.x, point2.y - point1.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
} else {
this.command = 'TL';
this.params = [preEndPoint, point2];
this.subStart = preSegment.subStart;
this.endPoint = point2;
this.endTangent = function () {
return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
};
}
break;
case 'C':
if (relative) {
point1 = toAbsolute(p1, p2, preEndPoint);
point2 = toAbsolute(p[3], p[4], preEndPoint);
point3 = toAbsolute(p[5], p[6], preEndPoint);
} else {
point1 = {
x: p1,
y: p2
};
point2 = {
x: p[3],
y: p[4]
};
point3 = {
x: p[5],
y: p[6]
};
}
this.command = 'C';
this.params = [preEndPoint, point1, point2, point3];
this.subStart = preSegment.subStart;
this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
break;
case 'S':
if (relative) {
point2 = toAbsolute(p1, p2, preEndPoint);
point3 = toAbsolute(p[3], p[4], preEndPoint);
} else {
point2 = {
x: p1,
y: p2
};
point3 = {
x: p[3],
y: p[4]
};
}
if (preSegment.command === 'C') {
point1 = toSymmetry(preSegment.params[2], preEndPoint);
this.command = 'C';
this.params = [preEndPoint, point1, point2, point3];
this.subStart = preSegment.subStart;
this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
} else {
this.command = 'SQ';
this.params = [preEndPoint, point2, point3];
this.subStart = preSegment.subStart;
this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {
return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
};
}
break;
case 'A':
{
var rx = p1;
var ry = p2;
var psi = p[3];
var fa = p[4];
var fs = p[5];
if (relative) {
point = toAbsolute(p[6], p[7], preEndPoint);
} else {
point = {
x: p[6],
y: p[7]
};
}
this.command = 'A';
var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi);
this.params = params;
var start = preSegment.subStart;
this.subStart = start;
this.endPoint = point;
var startAngle = params[5] % (Math.PI * 2);
if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
startAngle = 0;
}
var endAngle = params[6] % (Math.PI * 2);
if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
endAngle = 0;
}
var d = 0.001;
this.startTangent = function () {
if (fs === 0) {
d *= -1;
}
var dx = params[3] * Math.cos(startAngle - d) + params[1];
var dy = params[4] * Math.sin(startAngle - d) + params[2];
return [dx - start.x, dy - start.y];
};
this.endTangent = function () {
var endAngle = params[6];
if (endAngle - Math.PI * 2 < 0.0001) {
endAngle = 0;
}
var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];
var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];
return [preEndPoint.x - dx, preEndPoint.y - dy];
};
break;
}
case 'Z':
{
this.command = 'Z';
this.params = [preEndPoint, preSegment.subStart];
this.subStart = preSegment.subStart;
this.endPoint = preSegment.subStart;
}
}
},
isInside: function isInside(x, y, lineWidth) {
var self = this;
var command = self.command;
var params = self.params;
var box = self.box;
if (box) {
if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
return false;
}
}
switch (command) {
default:
break;
case 'M':
return false;
case 'TL':
case 'L':
case 'Z':
return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
case 'SQ':
case 'Q':
return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
case 'C':
{
return Inside.cubicline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, params[3].x, params[3].y, lineWidth, x, y);
}
case 'A':
{
var p = params;
var cx = p[1];
var cy = p[2];
var rx = p[3];
var ry = p[4];
var theta = p[5];
var dTheta = p[6];
var psi = p[7];
var fs = p[8];
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
p = [x, y, 1];
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
mat3.translate(m, m, [-cx, -cy]);
mat3.rotate(m, m, -psi);
mat3.scale(m, m, [1 / scaleX, 1 / scaleY]);
vec3.transformMat3(p, p, m);
return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]);
}
}
return false;
},
draw: function draw(context) {
var command = this.command;
var params = this.params;
var point1;
var point2;
var point3;
switch (command) {
default:
break;
case 'M':
context.moveTo(params[1].x, params[1].y);
break;
case 'TL':
case 'L':
context.lineTo(params[1].x, params[1].y);
break;
case 'SQ':
case 'Q':
point1 = params[1];
point2 = params[2];
context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y);
break;
case 'C':
point1 = params[1];
point2 = params[2];
point3 = params[3];
context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
break;
case 'A':
{
var p = params;
var p1 = p[1];
var p2 = p[2];
var cx = p1;
var cy = p2;
var rx = p[3];
var ry = p[4];
var theta = p[5];
var dTheta = p[6];
var psi = p[7];
var fs = p[8];
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
context.translate(cx, cy);
context.rotate(psi);
context.scale(scaleX, scaleY);
context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);
context.scale(1 / scaleX, 1 / scaleY);
context.rotate(-psi);
context.translate(-cx, -cy);
break;
}
case 'Z':
context.closePath();
break;
}
},
getBBox: function getBBox(lineWidth) {
var halfWidth = lineWidth / 2;
var params = this.params;
var yDims;
var xDims;
var i;
var l;
switch (this.command) {
default:
case 'M':
case 'Z':
break;
case 'TL':
case 'L':
this.box = {
minX: Math.min(params[0].x, params[1].x) - halfWidth,
maxX: Math.max(params[0].x, params[1].x) + halfWidth,
minY: Math.min(params[0].y, params[1].y) - halfWidth,
maxY: Math.max(params[0].y, params[1].y) + halfWidth
};
break;
case 'SQ':
case 'Q':
xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
for (i = 0, l = xDims.length; i < l; i++) {
xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
}
xDims.push(params[0].x, params[2].x);
yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
for (i = 0, l = yDims.length; i < l; i++) {
yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
}
yDims.push(params[0].y, params[2].y);
this.box = {
minX: Math.min.apply(Math, xDims) - halfWidth,
maxX: Math.max.apply(Math, xDims) + halfWidth,
minY: Math.min.apply(Math, yDims) - halfWidth,
maxY: Math.max.apply(Math, yDims) + halfWidth
};
break;
case 'C':
xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
for (i = 0, l = xDims.length; i < l; i++) {
xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
}
yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
for (i = 0, l = yDims.length; i < l; i++) {
yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
}
xDims.push(params[0].x, params[3].x);
yDims.push(params[0].y, params[3].y);
this.box = {
minX: Math.min.apply(Math, xDims) - halfWidth,
maxX: Math.max.apply(Math, xDims) + halfWidth,
minY: Math.min.apply(Math, yDims) - halfWidth,
maxY: Math.max.apply(Math, yDims) + halfWidth
};
break;
case 'A':
{
// todo 待优化
var p = params;
var cx = p[1];
var cy = p[2];
var rx = p[3];
var ry = p[4];
var theta = p[5];
var dTheta = p[6];
var psi = p[7];
var fs = p[8];
var start = theta;
var end = theta + dTheta;
var xDim = Ellipse.xExtrema(psi, rx, ry);
var minX = Infinity;
var maxX = -Infinity;
var xs = [start, end];
for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
var xAngle = xDim + i;
if (fs === 1) {
if (start < xAngle && xAngle < end) {
xs.push(xAngle);
}
} else {
if (end < xAngle && xAngle < start) {
xs.push(xAngle);
}
}
}
for (i = 0, l = xs.length; i < l; i++) {
var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
if (x < minX) {
minX = x;
}
if (x > maxX) {
maxX = x;
}
}
var yDim = Ellipse.yExtrema(psi, rx, ry);
var minY = Infinity;
var maxY = -Infinity;
var ys = [start, end];
for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
var yAngle = yDim + i;
if (fs === 1) {
if (start < yAngle && yAngle < end) {
ys.push(yAngle);
}
} else {
if (end < yAngle && yAngle < start) {
ys.push(yAngle);
}
}
}
for (i = 0, l = ys.length; i < l; i++) {
var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
if (y < minY) {
minY = y;
}
if (y > maxY) {
maxY = y;
}
}
this.box = {
minX: minX - halfWidth,
maxX: maxX + halfWidth,
minY: minY - halfWidth,
maxY: maxY + halfWidth
};
break;
}
}
}
});
module.exports = PathSegment;
/***/ }),
/* 48 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The measurement of linear data scale function
* @author dxq613@gmail.com
*/
var isNil = __webpack_require__(6);
var each = __webpack_require__(2);
var Base = __webpack_require__(26);
var numberAuto = __webpack_require__(335);
/**
* 线性度量
* @class Scale.Linear
*/
var Linear =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Linear, _Base);
function Linear() {
return _Base.apply(this, arguments) || this;
}
var _proto = Linear.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Base.prototype._initDefaultCfg.call(this);
var self = this;
self.type = 'linear';
self.isLinear = true;
/**
* 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
* @type {Boolean}
* @default false
*/
self.nice = false;
/**
* min value of the scale
* @type {Number}
* @default null
*/
self.min = null;
/**
* min value limitted of the scale
* @type {Number}
* @default null
*/
self.minLimit = null;
/**
* max value of the scale
* @type {Number}
* @default null
*/
self.max = null;
/**
* max value limitted of the scale
* @type {Number}
* @default null
*/
self.maxLimit = null;
/**
* 自动生成标记时的个数
* @type {Number}
* @default null
*/
self.tickCount = null;
/**
* 坐标轴点之间的间距,指的是真实数据的差值
* @type {Number}
* @default null
*/
self.tickInterval = null;
/**
* 坐标轴点之间的最小间距,指的是真实数据的差值
* @type {Number}
* @default null
*/
self.minTickInterval = null;
/**
* 用于计算坐标点时逼近的数组
* @type {Array}
*/
self.snapArray = null;
}
/**
* @protected
* @override
*/
;
_proto.init = function init() {
var self = this;
if (!self.ticks) {
self.min = self.translate(self.min);
self.max = self.translate(self.max);
self.initTicks();
} else {
var ticks = self.ticks;
var firstValue = self.translate(ticks[0]);
var lastValue = self.translate(ticks[ticks.length - 1]);
if (isNil(self.min) || self.min > firstValue) {
self.min = firstValue;
}
if (isNil(self.max) || self.max < lastValue) {
self.max = lastValue;
}
}
}
/**
* 计算坐标点
* @protected
* @return {Array} 计算完成的坐标点
*/
;
_proto.calculateTicks = function calculateTicks() {
var min = this.min,
max = this.max,
minLimit = this.minLimit,
maxLimit = this.maxLimit,
tickCount = this.tickCount,
tickInterval = this.tickInterval,
minTickInterval = this.minTickInterval,
snapArray = this.snapArray;
if (tickCount === 1) {
throw new Error('linear scale\'tickCount should not be 1');
}
if (max < min) {
throw new Error("max: " + max + " should not be less than min: " + min);
}
var tmp = numberAuto({
min: min,
max: max,
minLimit: minLimit,
maxLimit: maxLimit,
minCount: tickCount,
maxCount: tickCount,
interval: tickInterval,
minTickInterval: minTickInterval,
snapArray: snapArray
});
return tmp.ticks;
} // 初始化ticks
;
_proto.initTicks = function initTicks() {
var self = this;
var calTicks = self.calculateTicks();
if (self.nice) {
// 如果需要优化显示的tick
self.ticks = calTicks;
self.min = calTicks[0];
self.max = calTicks[calTicks.length - 1];
} else {
var ticks = [];
each(calTicks, function (tick) {
if (tick >= self.min && tick <= self.max) {
ticks.push(tick);
}
}); // 如果 ticks 为空,直接输入最小值、最大值
if (!ticks.length) {
ticks.push(self.min);
ticks.push(self.max);
}
self.ticks = ticks;
}
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
if (isNil(value)) {
return NaN;
}
var max = this.max;
var min = this.min;
if (max === min) {
return 0;
}
var percent = (value - min) / (max - min);
var rangeMin = this.rangeMin();
var rangeMax = this.rangeMax();
return rangeMin + percent * (rangeMax - rangeMin);
}
/**
* @override
*/
;
_proto.invert = function invert(value) {
var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
return this.min + percent * (this.max - this.min);
};
return Linear;
}(Base);
Base.Linear = Linear;
module.exports = Linear;
/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(20);
var indexOf = Array.prototype.indexOf;
var contains = function contains(arr, value) {
if (!isArrayLike(arr)) {
return false;
}
return indexOf.call(arr, value) > -1;
};
module.exports = contains;
/***/ }),
/* 50 */
/***/ (function(module, exports) {
var merge = function merge(dataArray) {
var rst = [];
for (var i = 0; i < dataArray.length; i++) {
rst = rst.concat(dataArray[i]);
}
return rst;
};
module.exports = merge;
/***/ }),
/* 51 */
/***/ (function(module, exports) {
var PRECISION = 0.00001; // numbers less than this is considered as 0
module.exports = function isNumberEqual(a, b) {
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PRECISION;
return Math.abs(a - b) < precision;
};
/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
mat3: __webpack_require__(79),
vec2: __webpack_require__(168),
vec3: __webpack_require__(169),
transform: __webpack_require__(167)
};
/***/ }),
/* 53 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(20);
function toArray(value) {
return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
}
module.exports = toArray;
/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }; /**
* util function
*/
var _core = __webpack_require__(65);
/* eslint-disable no-self-compare */
function is(x, y) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y;
}
return x !== x && y !== y; // NaN == NaN
}
function length(obj) {
if (_core.Util.isArray(obj)) {
return obj.length;
} else if (_core.Util.isObject(obj)) {
return Object.keys(obj).length;
}
return 0;
}
exports.default = _core.Util.mix({}, _core.Util, {
shallowEqual: function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
return false;
}
if (_core.Util.isArray(objA) !== _core.Util.isArray(objB)) {
return false;
}
if (length(objA) !== length(objB)) {
return false;
}
var ret = true;
_core.Util.each(objA, function (v, k) {
if (!is(v, objB[k])) {
ret = false;
return ret;
}
return true;
});
return ret;
},
without: function without(objA) {
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var ret = {};
_core.Util.each(objA, function (v, k) {
if (_core.Util.indexOf(keys, k) === -1) {
ret[k] = v;
}
});
return ret;
},
length: length
});
/***/ }),
/* 55 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return a = +a, b -= a, function(t) {
return a + b * t;
};
});
/***/ }),
/* 56 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return a = +a, b -= a, function(t) {
return a + b * t;
};
});
/***/ }),
/* 57 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__namespace__ = __webpack_require__(90);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__namespaces__ = __webpack_require__(91);
function creatorInherit(name) {
return function() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri === __WEBPACK_IMPORTED_MODULE_1__namespaces__["b" /* xhtml */] && document.documentElement.namespaceURI === __WEBPACK_IMPORTED_MODULE_1__namespaces__["b" /* xhtml */]
? document.createElement(name)
: document.createElementNS(uri, name);
};
}
function creatorFixed(fullname) {
return function() {
return this.ownerDocument.createElementNS(fullname.space, fullname.local);
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
var fullname = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__namespace__["a" /* default */])(name);
return (fullname.local
? creatorFixed
: creatorInherit)(fullname);
});
/***/ }),
/* 58 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(node, event) {
var svg = node.ownerSVGElement || node;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
point.x = event.clientX, point.y = event.clientY;
point = point.matrixTransform(node.getScreenCTM().inverse());
return [point.x, point.y];
}
var rect = node.getBoundingClientRect();
return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
});
/***/ }),
/* 59 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = tweenValue;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
function tweenRemove(id, name) {
var tween0, tween1;
return function() {
var schedule = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id),
tween = schedule.tween;
// If this node shared tween with the previous node,
// just assign the updated shared tween and we’re done!
// Otherwise, copy-on-write.
if (tween !== tween0) {
tween1 = tween0 = tween;
for (var i = 0, n = tween1.length; i < n; ++i) {
if (tween1[i].name === name) {
tween1 = tween1.slice();
tween1.splice(i, 1);
break;
}
}
}
schedule.tween = tween1;
};
}
function tweenFunction(id, name, value) {
var tween0, tween1;
if (typeof value !== "function") throw new Error;
return function() {
var schedule = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id),
tween = schedule.tween;
// If this node shared tween with the previous node,
// just assign the updated shared tween and we’re done!
// Otherwise, copy-on-write.
if (tween !== tween0) {
tween1 = (tween0 = tween).slice();
for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
if (tween1[i].name === name) {
tween1[i] = t;
break;
}
}
if (i === n) tween1.push(t);
}
schedule.tween = tween1;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
var id = this._id;
name += "";
if (arguments.length < 2) {
var tween = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(this.node(), id).tween;
for (var i = 0, n = tween.length, t; i < n; ++i) {
if ((t = tween[i]).name === name) {
return t.value;
}
}
return null;
}
return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value));
});
function tweenValue(transition, name, value) {
var id = transition._id;
transition.each(function() {
var schedule = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id);
(schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
});
return function(node) {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(node, id).value[name];
};
}
/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _core = __webpack_require__(65);
var _core2 = _interopRequireDefault(_core);
var _util = __webpack_require__(54);
var _util2 = _interopRequireDefault(_util);
var _themes = __webpack_require__(423);
var _themes2 = _interopRequireDefault(_themes);
var _components = __webpack_require__(417);
var components = _interopRequireWildcard(_components);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// G2.Global.animate = false;
var BizCharts = _util2.default.mix(components, {
G2: _core2.default,
Util: _util2.default,
Shape: _core.Shape,
Animate: _core.Animate,
PathUtil: _core.PathUtil,
track: function track() {},
setTheme: function setTheme(theme) {
var themeObj = theme;
if (typeof theme === 'string' && _themes2.default[theme]) {
themeObj = _themes2.default[theme];
}
_core2.default.Global.setTheme(themeObj);
}
});
exports.default = BizCharts;
module.exports = BizCharts;
/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
Position: __webpack_require__(229),
Color: __webpack_require__(227),
Shape: __webpack_require__(230),
Size: __webpack_require__(231),
Opacity: __webpack_require__(228),
ColorUtil: __webpack_require__(100)
};
/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview Chart、View、Geometry 的基类
* @author dxq613@gmail.com
*/
var EventEmitter = __webpack_require__(98);
var Util = __webpack_require__(3);
var Base =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(Base, _EventEmitter);
var _proto = Base.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {};
};
function Base(cfg) {
var _this;
_this = _EventEmitter.call(this) || this;
var self = _assertThisInitialized(_assertThisInitialized(_this));
var attrs = {
visible: true
};
var defaultCfg = self.getDefaultCfg();
self._attrs = attrs;
Util.deepMix(attrs, defaultCfg, cfg);
return _this;
}
_proto.get = function get(name) {
return this._attrs[name];
};
_proto.set = function set(name, value) {
this._attrs[name] = value;
};
/**
* @protected
* @param {Boolean} visible 是否可见
* 显示、隐藏
*/
_proto.changeVisible = function changeVisible()
/* visible */
{};
_proto.destroy = function destroy() {
var self = this;
self._attrs = {};
self.removeAllListeners();
self.destroyed = true;
};
return Base;
}(EventEmitter);
module.exports = Base;
/***/ }),
/* 63 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The base class of continuous legend
* @author sima.zhang
*/
var Util = __webpack_require__(3);
var Legend = __webpack_require__(105);
var Slider = __webpack_require__(255);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var TRIGGER_WIDTH = 8;
var Event = Util.Event;
var Group = Util.Group;
var Continuous =
/*#__PURE__*/
function (_Legend) {
_inheritsLoose(Continuous, _Legend);
function Continuous() {
return _Legend.apply(this, arguments) || this;
}
var _proto = Continuous.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Legend.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 类型
* @type {String}
*/
type: 'continuous-legend',
/**
* 子项
* @type {Array}
*/
items: null,
/**
* 布局方式
* horizontal 水平
* vertical 垂直
* @type {String}
*/
layout: 'vertical',
/**
* 宽度
* @type {Number}
*/
width: 20,
/**
* 高度
* @type {Number}
*/
height: 156,
/**
* 默认文本图形属性
* @type {ATTRS}
*/
textStyle: {
fill: '#333',
textAlign: 'center',
textBaseline: 'middle',
stroke: '#fff',
lineWidth: 5,
fontFamily: FONT_FAMILY
},
hoverTextStyle: {
fill: 'rgba(0,0,0,0.25)'
},
/**
* 连续图例是否可滑动
* @type {Boolean}
*/
slidable: true,
/**
* 两头滑块的样式
* @type {object}
*/
triggerAttr: {
fill: '#fff',
// shadowOffsetX: -2,
// shadowOffsetY: 2,
shadowBlur: 10,
shadowColor: 'rgba(0,0,0,0.65)',
radius: 2
},
/**
* slider 的范围
* @type {array}}
*/
_range: [0, 100],
/**
* 中间 bar 背景灰色
* @type {ATTRS}
*/
middleBackgroundStyle: {
fill: '#D9D9D9'
},
/**
* 文本与图例间距
* @type {Number}
*/
textOffset: 4,
/**
* line segment to seperate the unslidable slider blocks
* @type {object}
*/
lineStyle: {
lineWidth: 1,
stroke: '#fff'
},
/**
* the pointer while activate the legend by mouse hovering or called by outside
* @type {object}
*/
pointerStyle: {
// color: '#ccc',
fill: 'rgb(230, 230, 230)'
}
});
};
_proto._calStartPoint = function _calStartPoint() {
var start = {
x: 10,
y: this.get('titleGap') - TRIGGER_WIDTH
};
var titleShape = this.get('titleShape');
if (titleShape) {
var titleBox = titleShape.getBBox();
start.y += titleBox.height;
}
return start;
};
_proto.beforeRender = function beforeRender() {
var items = this.get('items');
if (!Util.isArray(items) || Util.isEmpty(items)) {
return;
}
_Legend.prototype.beforeRender.call(this);
this.set('firstItem', items[0]);
this.set('lastItem', items[items.length - 1]);
};
_proto._formatItemValue = function _formatItemValue(value) {
var formatter = this.get('formatter') || this.get('itemFormatter');
if (formatter) {
value = formatter.call(this, value);
}
return value;
};
_proto.render = function render() {
_Legend.prototype.render.call(this);
if (this.get('slidable')) {
this._renderSlider();
} else {
this._renderUnslidable();
}
};
_proto._renderSlider = function _renderSlider() {
var minHandleElement = new Group();
var maxHandleElement = new Group();
var backgroundElement = new Group();
var start = this._calStartPoint();
var group = this.get('group');
var slider = group.addGroup(Slider, {
minHandleElement: minHandleElement,
maxHandleElement: maxHandleElement,
backgroundElement: backgroundElement,
layout: this.get('layout'),
range: this.get('_range'),
width: this.get('width'),
height: this.get('height')
});
slider.translate(start.x, start.y);
this.set('slider', slider);
var shape = this._renderSliderShape();
shape.attr('clip', slider.get('middleHandleElement'));
this._renderTrigger();
}; // the middle bar
_proto._addMiddleBar = function _addMiddleBar(parent, name, attrs) {
// background of the middle bar
parent.addShape(name, {
attrs: Util.mix({}, attrs, this.get('middleBackgroundStyle'))
}); // frontground of the middle bar
return parent.addShape(name, {
attrs: attrs
});
};
_proto._renderTrigger = function _renderTrigger() {
var min = this.get('firstItem');
var max = this.get('lastItem');
var layout = this.get('layout');
var textStyle = this.get('textStyle');
var triggerAttr = this.get('triggerAttr');
var minBlockAttr = Util.mix({}, triggerAttr);
var maxBlockAttr = Util.mix({}, triggerAttr);
var minTextAttr = Util.mix({
text: this._formatItemValue(min.value) + ''
}, textStyle);
var maxTextAttr = Util.mix({
text: this._formatItemValue(max.value) + ''
}, textStyle);
if (layout === 'vertical') {
this._addVerticalTrigger('min', minBlockAttr, minTextAttr);
this._addVerticalTrigger('max', maxBlockAttr, maxTextAttr);
} else {
this._addHorizontalTrigger('min', minBlockAttr, minTextAttr);
this._addHorizontalTrigger('max', maxBlockAttr, maxTextAttr);
}
};
_proto._addVerticalTrigger = function _addVerticalTrigger(type, blockAttr, textAttr) {
var slider = this.get('slider');
var trigger = slider.get(type + 'HandleElement');
var width = this.get('width');
var button = trigger.addShape('rect', {
attrs: Util.mix({
x: width / 2 - TRIGGER_WIDTH - 2,
y: type === 'min' ? 0 : -TRIGGER_WIDTH,
width: 2 * TRIGGER_WIDTH + 2,
height: TRIGGER_WIDTH
}, blockAttr)
});
var text = trigger.addShape('text', {
attrs: Util.mix(textAttr, {
x: width + this.get('textOffset'),
y: type === 'max' ? -4 : 4,
textAlign: 'start',
lineHeight: 1,
textBaseline: 'middle'
})
});
var layout = this.get('layout');
var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize';
button.attr('cursor', trigerCursor);
text.attr('cursor', trigerCursor);
this.set(type + 'ButtonElement', button);
this.set(type + 'TextElement', text);
};
_proto._addHorizontalTrigger = function _addHorizontalTrigger(type, blockAttr, textAttr) {
var slider = this.get('slider');
var trigger = slider.get(type + 'HandleElement');
var button = trigger.addShape('rect', {
attrs: Util.mix({
x: type === 'min' ? -TRIGGER_WIDTH : 0,
y: -TRIGGER_WIDTH - this.get('height') / 2,
width: TRIGGER_WIDTH,
height: 2 * TRIGGER_WIDTH
}, blockAttr)
});
var text = trigger.addShape('text', {
attrs: Util.mix(textAttr, {
x: type === 'min' ? -TRIGGER_WIDTH - 4 : TRIGGER_WIDTH + 4,
y: TRIGGER_WIDTH / 2 + this.get('textOffset') + 10,
textAlign: type === 'min' ? 'end' : 'start',
textBaseline: 'middle'
})
});
var layout = this.get('layout');
var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize';
button.attr('cursor', trigerCursor);
text.attr('cursor', trigerCursor);
this.set(type + 'ButtonElement', button);
this.set(type + 'TextElement', text);
};
_proto._bindEvents = function _bindEvents() {
var _this = this;
if (this.get('slidable')) {
var slider = this.get('slider');
slider.on('sliderchange', function (ev) {
var range = ev.range;
var firstItemValue = _this.get('firstItem').value;
var lastItemValue = _this.get('lastItem').value;
var minValue = firstItemValue + range[0] / 100 * (lastItemValue - firstItemValue);
var maxValue = firstItemValue + range[1] / 100 * (lastItemValue - firstItemValue);
_this._updateElement(minValue, maxValue);
var itemFiltered = new Event('itemfilter', ev, true, true);
itemFiltered.range = [minValue, maxValue];
_this.emit('itemfilter', itemFiltered);
});
}
if (this.get('hoverable')) {
this.get('group').on('mousemove', Util.wrapBehavior(this, '_onMouseMove'));
this.get('group').on('mouseleave', Util.wrapBehavior(this, '_onMouseLeave'));
}
}; // update the text of min and max trigger
_proto._updateElement = function _updateElement(min, max) {
var minTextElement = this.get('minTextElement');
var maxTextElement = this.get('maxTextElement');
if (max > 1) {
// 对于大于 1 的值,默认显示为整数
min = parseInt(min, 10);
max = parseInt(max, 10);
}
minTextElement.attr('text', this._formatItemValue(min) + '');
maxTextElement.attr('text', this._formatItemValue(max) + '');
};
_proto._onMouseLeave = function _onMouseLeave() {
var hoverPointer = this.get('group').findById('hoverPointer');
hoverPointer && hoverPointer.destroy();
var hoverText = this.get('group').findById('hoverText');
hoverText && hoverText.destroy();
this.get('canvas').draw();
}; // activate the legend while mouse moving
_proto._onMouseMove = function _onMouseMove(ev) {
var height = this.get('height');
var width = this.get('width');
var items = this.get('items');
var el = this.get('canvas').get('el');
var el_bbox = el.getBoundingClientRect();
var bbox = this.get('group').getBBox();
var value;
if (this.get('layout') === 'vertical') {
var valuePadding = 5;
if (this.get('type') === 'color-legend') {
valuePadding = 30;
}
var titleOffset = this.get('titleGap');
var titleShape = this.get('titleShape');
if (titleShape) titleOffset += titleShape.getBBox().maxY - titleShape.getBBox().minY;
var currentPage = ev.clientY || ev.event.clientY;
currentPage = currentPage - el_bbox.y - this.get('group').attr('matrix')[7] + bbox.y - valuePadding + titleOffset;
value = items[0].value + (1 - currentPage / height) * (items[items.length - 1].value - items[0].value);
} else {
var _currentPage = ev.clientX || ev.event.clientX;
_currentPage = _currentPage - el_bbox.x - this.get('group').attr('matrix')[6];
value = items[0].value + _currentPage / width * (items[items.length - 1].value - items[0].value);
}
value = value.toFixed(2);
this.activate(value);
this.emit('mousehover', {
value: value
});
}; // activated by mouse moving or being called
_proto.activate = function activate(value) {
if (!value) {
return;
}
var hoverPointer = this.get('group').findById('hoverPointer');
var hoverText = this.get('group').findById('hoverText');
var items = this.get('items');
if (value < items[0].value || value > items[items.length - 1].value) {
return;
}
var height = this.get('height');
var width = this.get('width');
var titleShape = this.get('titleShape');
var titleGap = this.get('titleGap');
var points = [];
var page = (value - items[0].value) / (items[items.length - 1].value - items[0].value);
var textStyle;
if (this.get('layout') === 'vertical') {
// revise the offset
var paddingY = 0,
paddingX = 0;
if (this.get('type') === 'color-legend') {
paddingY = titleGap;
if (titleShape) paddingY += titleShape.getBBox().height;
}
if (this.get('slidable')) {
if (this.get('type') === 'color-legend') {
paddingY -= 13;
} else {
paddingY = titleGap - 15;
if (titleShape) paddingY += titleShape.getBBox().height;
}
paddingX += 10;
}
page = (1 - page) * height;
points = [[paddingX, page + paddingY], [paddingX - 10, page + paddingY - 5], [paddingX - 10, page + paddingY + 5]];
textStyle = Util.mix({}, {
x: width + this.get('textOffset') / 2 + paddingX,
y: page + paddingY,
text: this._formatItemValue(value) + '' // 以字符串格式展示
}, this.get('textStyle'), {
textAlign: 'start'
});
} else {
var _paddingY = 0,
_paddingX = 0;
if (this.get('type') === 'color-legend') {
_paddingY = titleGap;
if (titleShape) _paddingY += titleShape.getBBox().height;
}
if (this.get('slidable')) {
if (this.get('type') === 'color-legend') {
// hoverPointer三角形的高
_paddingY -= 7;
} else {
_paddingY = titleGap;
if (!titleShape) _paddingY -= 7;
}
_paddingX += 10;
}
page *= width;
points = [[page + _paddingX, _paddingY], [page + _paddingX - 5, _paddingY - 10], [page + _paddingX + 5, _paddingY - 10]];
textStyle = Util.mix({}, {
x: page - 5,
y: height + this.get('textOffset') + _paddingY,
text: this._formatItemValue(value) + '' // 以字符串格式展示
}, this.get('textStyle'));
}
var hoverTextStyle = Util.mix(textStyle, this.get('hoverTextStyle'));
if (!hoverText) {
// mouse enter the legend, add hoverText
hoverText = this.get('group').addShape('text', {
attrs: hoverTextStyle
});
hoverText.set('id', 'hoverText');
} else {
// mouse move, update hoverText
hoverText.attr(hoverTextStyle);
}
if (!hoverPointer) {
// mouse enter the legend, add hoverPointer
hoverPointer = this.get('group').addShape('Polygon', {
attrs: Util.mix({
points: points
}, this.get('pointerStyle'))
});
hoverPointer.set('id', 'hoverPointer');
} else {
// mouse move, update hoverPointer
hoverPointer.attr(Util.mix({
points: points
}, this.get('pointerStyle')));
}
this.get('canvas').draw();
};
_proto.deactivate = function deactivate() {
var hoverPointer = this.get('group').findById('hoverPointer');
hoverPointer && hoverPointer.destroy();
var hoverText = this.get('group').findById('hoverText');
hoverText && hoverText.destroy();
this.get('canvas').draw();
};
return Continuous;
}(Legend);
module.exports = Continuous;
/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Component = __webpack_require__(62);
var Util = __webpack_require__(3);
var Tooltip =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Tooltip, _Component);
function Tooltip() {
return _Component.apply(this, arguments) || this;
}
var _proto = Tooltip.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Component.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* tooltip container
* @type {Dom / String}
*/
/**
* 右下角坐标
* @type {Number}
*/
x: 0,
/**
* y 右下角坐标
* @type {Number}
*/
y: 0,
/**
* tooltip 记录项
* @type {Array}
*/
items: null,
/**
* tooltip 标题
* @type {Array}
*/
titleContent: null,
/**
* 是否展示 title
* @type {Boolean}
*/
showTitle: true,
/**
* 视图范围
* @type {Object}
*/
plotRange: null,
/**
* x轴上,移动到位置的偏移量
* @type {Number}
*/
offset: 10,
// TODO:支持xy两个方向上的offset
/**
* 时间戳
* @type {Number}
*/
timeStamp: 0,
/**
* 将 tooltip 展示在指定区域内
* @type {Boolean}
*/
inPlot: true,
/**
* tooltip 辅助线配置
* @type {Object}
*/
crosshairs: null
});
};
_proto.isContentChange = function isContentChange(title, items) {
var titleContent = this.get('titleContent');
var lastItems = this.get('items');
var isChanged = !(title === titleContent && lastItems.length === items.length);
if (!isChanged) {
Util.each(items, function (item, index) {
var preItem = lastItems[index];
for (var key in item) {
if (item.hasOwnProperty(key)) {
if (!Util.isObject(item[key]) && item[key] !== preItem[key]) {
isChanged = true;
break;
}
}
}
if (isChanged) {
return false;
}
});
}
return isChanged;
};
_proto.setContent = function setContent(title, items) {
var timeStamp = new Date().valueOf();
this.set('items', items);
this.set('titleContent', title);
this.set('timeStamp', timeStamp);
this.render();
return this;
};
_proto.setPosition = function setPosition(x, y) {
this.set('x', x);
this.set('y', y);
};
_proto.render = function render() {};
_proto.clear = function clear() {};
_proto.show = function show() {
this.set('visible', true);
};
_proto.hide = function hide() {
this.set('visible', false);
};
_proto.destroy = function destroy() {};
return Tooltip;
}(Component);
module.exports = Tooltip;
/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {
var Scale = __webpack_require__(147);
var G = __webpack_require__(23);
var Animate = __webpack_require__(112);
var Chart = __webpack_require__(114);
var Global = __webpack_require__(5);
var Shape = __webpack_require__(9);
var Util = __webpack_require__(0);
var G2 = {
// version
version: Global.version,
// visual encoding
Animate: Animate,
Chart: Chart,
Global: Global,
Scale: Scale,
Shape: Shape,
Util: Util,
// render engine
G: G,
DomUtil: Util.DomUtil,
MatrixUtil: Util.MatrixUtil,
PathUtil: Util.PathUtil
}; // G2.track = function(enable) {
// Global.trackable = enable;
// };
// require('./track');
G2.track = function () {
console.warn('G2 tracks nothing ;-)');
}; // 保证两个版本共存
if (typeof window !== 'undefined') {
if (window.G2) {
console.warn("There are multiple versions of G2. Version " + G2.version + "'s reference is 'window.G2_3'");
} else {
window.G2 = G2;
}
}
module.exports = G2;
/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var _require = __webpack_require__(23),
Group = _require.Group;
var _require2 = __webpack_require__(29),
Label = _require2.Label; // const visualCenter = require('@antv/component/lib/label/utils/visual-center');
var Global = __webpack_require__(5);
var Util = __webpack_require__(0);
var IGNORE_ARR = ['line', 'point', 'path'];
var ORIGIN = '_origin';
function avg(arr) {
var sum = 0;
Util.each(arr, function (value) {
sum += value;
});
return sum / arr.length;
} // 计算多边形重心: https://en.wikipedia.org/wiki/Centroid#Of_a_polygon
function getCentroid(xs, ys) {
if (Util.isNumber(xs) && Util.isNumber(ys)) {
return [xs, ys];
}
var i = -1,
x = 0,
y = 0;
var former,
current = xs.length - 1;
var diff,
k = 0;
while (++i < xs.length) {
former = current;
current = i;
k += diff = xs[former] * ys[current] - xs[current] * ys[former];
x += (xs[former] + xs[current]) * diff;
y += (ys[former] + ys[current]) * diff;
}
k *= 3;
return [x / k, y / k];
}
var GeomLabels =
/*#__PURE__*/
function (_Group) {
_inheritsLoose(GeomLabels, _Group);
function GeomLabels() {
return _Group.apply(this, arguments) || this;
}
var _proto = GeomLabels.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
label: Global.label,
/**
* 用户传入的文本配置信息
* @type {Object}
*/
labelCfg: null,
/**
* 所在的坐标系
* @type {Object}
*/
coord: null,
/**
* 图表的类型
* @type {String}
*/
geomType: null,
zIndex: 6
};
};
_proto._renderUI = function _renderUI() {
_Group.prototype._renderUI.call(this);
this.initLabelsCfg();
var labelsGroup = this.addGroup();
var lineGroup = this.addGroup({
elCls: 'x-line-group'
});
var labelRenderer = this.get('labelRenderer');
this.set('labelsGroup', labelsGroup);
this.set('lineGroup', lineGroup);
this.get('labelRenderer').set('group', labelsGroup);
labelRenderer.set('group', labelsGroup);
labelRenderer.set('lineGroup', lineGroup);
}; // 初始化labels的配置项
_proto.initLabelsCfg = function initLabelsCfg() {
var self = this;
var labelRenderer = new Label();
var labels = self.getDefaultLabelCfg();
var labelCfg = self.get('labelCfg'); // Util.merge(labels, labelCfg.cfg);
Util.deepMix(labels, labelCfg.globalCfg || labelCfg.cfg);
labelRenderer.set('config', false);
if (labels.labelLine) {
labelRenderer.set('labelLine', labels.labelLine);
}
labelRenderer.set('coord', self.get('coord'));
this.set('labelRenderer', labelRenderer);
self.set('label', labels);
};
/**
* @protected
* 默认的文本样式
* @return {Object} default label config
*/
_proto.getDefaultLabelCfg = function getDefaultLabelCfg() {
var self = this;
var labelCfg = self.get('labelCfg').cfg || self.get('labelCfg').globalCfg;
var geomType = self.get('geomType');
var viewTheme = self.get('viewTheme') || Global;
if (geomType === 'polygon' || labelCfg && labelCfg.offset < 0 && Util.indexOf(IGNORE_ARR, geomType) === -1) {
return Util.deepMix({}, self.get('label'), viewTheme.innerLabels, labelCfg);
}
return Util.deepMix({}, self.get('label'), viewTheme.label, labelCfg);
};
/**
* @protected
* 获取labels
* @param {Array} points points
* @param {Array} shapes shapes
* @return {Array} label items
*/
_proto.getLabelsItems = function getLabelsItems(points, shapes) {
var self = this;
var items = [];
var geom = self.get('geom');
var coord = self.get('coord');
self._getLabelCfgs(points, shapes);
var labelCfg = self.get('labelItemCfgs'); // 获取label相关的x,y的值,获取具体的x,y,防止存在数组
Util.each(points, function (point, i) {
var origin = point[ORIGIN];
var label = labelCfg[i];
if (!label) {
items.push(null);
return;
}
if (!Util.isArray(label.text)) {
label.text = [label.text];
}
var total = label.length;
Util.each(label.text, function (sub, subIndex) {
if (Util.isNil(sub) || sub === '') {
items.push(null);
return;
}
var obj = self.getLabelPoint(label, point, subIndex);
obj = Util.mix({}, label, obj);
if (!obj.textAlign) {
obj.textAlign = self.getLabelAlign(obj, subIndex, total);
}
if (geom) {
obj._id = geom._getShapeId(origin) + '-glabel-' + subIndex + '-' + obj.text;
}
obj.coord = coord;
items.push(obj);
});
});
return items;
};
/* /!*
* @protected
* 如果发生冲突则会调整文本的位置
* @param {Array} items 文本的集合
* @param {Array} shapes 关联形状
* @return {Array} adjusted items
*!/
adjustItems(items, shapes) {
// 多边形shape的label位于其可视中心
if (this.get('geomType') === 'polygon') {
let index,
shape,
path,
center,
points;
Util.each(items, (item, i) => {
if (!item) return;
shape = shapes[ i ];
path = shape.attr('path');
points = [[]];
index = 0;
path.forEach((segment, i) => {
if (segment[ 0 ] === 'z' || segment[ 0 ] === 'Z' && i !== path.length - 1) {
points.push([]);
index += 1;
}
if (segment.length === 3) {
points[ index ].push([ segment[ 1 ], segment[ 2 ] ]);
}
});
center = visualCenter(points);
item.x = center.x;
item.y = center.y;
});
}
return items;
}
*/
_proto.adjustItems = function adjustItems(items) {
Util.each(items, function (item) {
if (!item) {
return;
}
if (item.offsetX) {
item.x += item.offsetX;
}
if (item.offsetY) {
item.y += item.offsetY;
}
});
return items;
};
/**
* drawing lines to labels
* @param {Array} items labels
* @param {Object} labelLine configuration for label lines
*/
_proto.drawLines = function drawLines(items) {
var self = this;
Util.each(items, function (point) {
if (!point) {
return;
}
if (point.offset > 0) {
self.lineToLabel(point);
}
});
}; // 定义连接线
_proto.lineToLabel = function lineToLabel() {};
/**
* @protected
* 获取文本的位置信息
* @param {Array} labelCfg labels
* @param {Object} point point
* @param {Number} index index
* @return {Object} point
*/
_proto.getLabelPoint = function getLabelPoint(labelCfg, point, index) {
var self = this;
var coord = self.get('coord');
var total = labelCfg.text.length;
function getDimValue(value, idx) {
if (Util.isArray(value)) {
if (labelCfg.text.length === 1) {
// 如果仅一个label,多个y,取最后一个y
if (value.length <= 2) {
value = value[value.length - 1]; // value = value[0];
} else {
value = avg(value);
}
} else {
value = value[idx];
}
}
return value;
}
var label = {
text: labelCfg.text[index]
}; // 多边形场景,多用于地图
if (point && this.get('geomType') === 'polygon') {
var centroid = getCentroid(point.x, point.y); // 多边形的场景也有 x 和 y 只是数字的情况,譬如当 x 和 y 都是分类字段的时候 @see #1184
label.x = centroid[0];
label.y = centroid[1];
} else {
label.x = getDimValue(point.x, index);
label.y = getDimValue(point.y, index);
} // get nearest point of the shape as the label line start point
if (point && point.nextPoints && (point.shape === 'funnel' || point.shape === 'pyramid')) {
var maxX = -Infinity;
point.nextPoints.forEach(function (p) {
p = coord.convert(p);
if (p.x > maxX) {
maxX = p.x;
}
});
label.x = (label.x + maxX) / 2;
} // sharp edge of the pyramid
if (point.shape === 'pyramid' && !point.nextPoints && point.points) {
point.points.forEach(function (p) {
p = coord.convert(p);
if (Util.isArray(p.x) && point.x.indexOf(p.x) === -1 || Util.isNumber(p.x) && point.x !== p.x) {
label.x = (label.x + p.x) / 2;
}
});
}
if (labelCfg.position) {
self.setLabelPosition(label, point, index, labelCfg.position);
}
var offsetPoint = self.getLabelOffset(labelCfg, index, total);
if (labelCfg.offsetX) {
offsetPoint.x += labelCfg.offsetX;
}
if (labelCfg.offsetY) {
offsetPoint.y += labelCfg.offsetY;
}
self.transLabelPoint(label);
label.start = {
x: label.x,
y: label.y
};
label.x += offsetPoint.x;
label.y += offsetPoint.y;
label.color = point.color;
return label;
};
_proto.setLabelPosition = function setLabelPosition() {};
_proto.transLabelPoint = function transLabelPoint(point) {
var self = this;
var coord = self.get('coord');
var tmpPoint = coord.applyMatrix(point.x, point.y, 1);
point.x = tmpPoint[0];
point.y = tmpPoint[1];
};
_proto.getOffsetVector = function getOffsetVector(point) {
var self = this;
var offset = point.offset || 0;
var coord = self.get('coord');
var vector;
if (coord.isTransposed) {
// 如果x,y翻转,则偏移x
vector = coord.applyMatrix(offset, 0);
} else {
// 否则,偏转y
vector = coord.applyMatrix(0, offset);
}
return vector;
}; // 获取默认的偏移量
_proto.getDefaultOffset = function getDefaultOffset(point) {
var self = this;
var offset = 0;
var coord = self.get('coord');
var vector = self.getOffsetVector(point);
if (coord.isTransposed) {
// 如果x,y翻转,则偏移x
offset = vector[0];
} else {
// 否则,偏转y
offset = vector[1];
}
return offset;
}; // 获取文本的偏移位置,x,y
_proto.getLabelOffset = function getLabelOffset(point, index, total) {
var self = this;
var offset = self.getDefaultOffset(point);
var coord = self.get('coord');
var transposed = coord.isTransposed;
var yField = transposed ? 'x' : 'y';
var factor = transposed ? 1 : -1; // y 方向上越大,像素的坐标越小,所以transposed时将系数变成
var offsetPoint = {
x: 0,
y: 0
};
if (index > 0 || total === 1) {
// 判断是否小于0
offsetPoint[yField] = offset * factor;
} else {
offsetPoint[yField] = offset * factor * -1;
}
return offsetPoint;
};
_proto.getLabelAlign = function getLabelAlign(point, index, total) {
var self = this;
var align = 'center';
var coord = self.get('coord');
if (coord.isTransposed) {
var offset = self.getDefaultOffset(point); // var vector = coord.applyMatrix(offset,0);
if (offset < 0) {
align = 'right';
} else if (offset === 0) {
align = 'center';
} else {
align = 'left';
}
if (total > 1 && index === 0) {
if (align === 'right') {
align = 'left';
} else if (align === 'left') {
align = 'right';
}
}
}
return align;
};
_proto._getLabelValue = function _getLabelValue(origin, scales) {
if (!Util.isArray(scales)) {
scales = [scales];
}
var text = [];
Util.each(scales, function (scale) {
var value = origin[scale.field];
if (Util.isArray(value)) {
var tmp = [];
Util.each(value, function (subVal) {
tmp.push(scale.getText(subVal));
});
value = tmp;
} else {
value = scale.getText(value);
}
if (Util.isNil(value) || value === '') {
text.push(null);
}
text.push(value);
});
return text;
}; // 获取每个label的配置
_proto._getLabelCfgs = function _getLabelCfgs(points) {
var self = this;
var labelCfg = this.get('labelCfg');
var scales = labelCfg.scales;
var defaultCfg = this.get('label');
var viewTheme = self.get('viewTheme') || Global;
var cfgs = [];
if (labelCfg.globalCfg && labelCfg.globalCfg.type) {
self.set('type', labelCfg.globalCfg.type);
}
Util.each(points, function (point, i) {
var cfg = {};
var origin = point[ORIGIN];
var originText = self._getLabelValue(origin, scales);
if (labelCfg.callback) {
// callback中应使用原始数据,而不是数据字符串
var originValues = scales.map(function (scale) {
return origin[scale.field];
});
cfg = labelCfg.callback.apply(null, originValues);
}
if (!cfg && cfg !== 0) {
cfgs.push(null);
return;
}
if (Util.isString(cfg) || Util.isNumber(cfg)) {
cfg = {
text: cfg
};
} else {
cfg.text = cfg.content || originText[0];
delete cfg.content;
}
cfg = Util.mix({}, defaultCfg, labelCfg.globalCfg || {}, cfg); // 兼容旧的源数据写在item.point中
point.point = origin;
if (cfg.htmlTemplate) {
cfg.useHtml = true;
cfg.text = cfg.htmlTemplate.call(null, cfg.text, point, i);
delete cfg.htmlTemplate;
}
if (cfg.formatter) {
cfg.text = cfg.formatter.call(null, cfg.text, point, i);
delete cfg.formatter;
}
if (cfg.label) {
// 兼容有些直接写在labelCfg.label的配置
var label = cfg.label;
delete cfg.label;
cfg = Util.mix(cfg, label);
}
if (cfg.textStyle) {
// 兼容旧写法,globalCfg的offset优先级高
delete cfg.textStyle.offset;
var textStyle = cfg.textStyle;
if (Util.isFunction(textStyle)) {
cfg.textStyle = textStyle.call(null, cfg.text, point, i);
}
}
if (cfg.labelLine) {
cfg.labelLine = Util.mix({}, defaultCfg.labelLine, cfg.labelLine);
} // 因为 defaultCfg.textStyle 有可能是函数,所以这里可能没有把主题的 label 样式合进来
cfg.textStyle = Util.mix({}, defaultCfg.textStyle, viewTheme.label.textStyle, cfg.textStyle);
delete cfg.items;
cfgs.push(cfg);
});
this.set('labelItemCfgs', cfgs);
};
_proto.showLabels = function showLabels(points, shapes) {
var self = this;
var labelRenderer = self.get('labelRenderer');
var items = self.getLabelsItems(points, shapes);
shapes = [].concat(shapes);
var type = self.get('type');
items = self.adjustItems(items, shapes);
self.drawLines(items);
labelRenderer.set('items', items.filter(function (item, i) {
if (!item) {
shapes.splice(i, 1);
return false;
}
return true;
}));
if (type) {
labelRenderer.set('shapes', shapes);
labelRenderer.set('type', type);
labelRenderer.set('points', points);
}
labelRenderer.set('canvas', this.get('canvas'));
labelRenderer.draw();
};
_proto.destroy = function destroy() {
this.get('labelRenderer').destroy(); // 清理文本
_Group.prototype.destroy.call(this);
};
return GeomLabels;
}(Group); // Util.assign(GeomLabels.prototype, Labels.LabelslabelRenderer);
module.exports = GeomLabels;
/***/ }),
/* 67 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 需要计算所占x轴上的宽度的辅助类
* @author sima.zhang1990@gmail.com
* @author dxq613@gmail.com
*/
var Global = __webpack_require__(5);
var Util = __webpack_require__(0); // 已经排序后的数据查找距离最小的
function findMinDistance(arr, scale) {
var count = arr.length; // 日期类型的 values 经常上文本类型,所以需要转换一下
if (Util.isString(arr[0])) {
arr = arr.map(function (v) {
return scale.translate(v);
});
}
var distance = arr[1] - arr[0];
for (var i = 2; i < count; i++) {
var tmp = arr[i] - arr[i - 1];
if (distance > tmp) {
distance = tmp;
}
}
return distance;
}
var SizeMixin = {
getDefaultSize: function getDefaultSize() {
var defaultSize = this.get('defaultSize');
var viewTheme = this.get('viewTheme') || Global;
if (!defaultSize) {
var coord = this.get('coord');
var xScale = this.getXScale();
var xValues = xScale.values;
var dataArray = this.get('dataArray');
var count;
if (xScale.isLinear && xValues.length > 1) {
xValues.sort();
var interval = findMinDistance(xValues, xScale);
count = (xScale.max - xScale.min) / interval;
if (xValues.length > count) {
count = xValues.length;
}
} else {
count = xValues.length;
}
var range = xScale.range;
var normalizeSize = 1 / count;
var widthRatio = 1;
if (this.isInCircle()) {
if (coord.isTransposed && count > 1) {
// 极坐标下多层环图
widthRatio = viewTheme.widthRatio.multiplePie;
} else {
widthRatio = viewTheme.widthRatio.rose;
}
/* if (dataArray.length > 1) {
normalizeSize *= (range[1] - range[0]);
} */
} else {
if (xScale.isLinear) {
normalizeSize *= range[1] - range[0];
}
widthRatio = viewTheme.widthRatio.column; // 柱状图要除以2
}
normalizeSize *= widthRatio;
if (this.hasAdjust('dodge')) {
var dodgeCount = this._getDodgeCount(dataArray);
normalizeSize = normalizeSize / dodgeCount;
}
defaultSize = normalizeSize;
this.set('defaultSize', defaultSize);
}
return defaultSize;
},
_getDodgeCount: function _getDodgeCount(dataArray) {
var adjusts = this.get('adjusts');
var dodgeBy;
var count = dataArray.length;
Util.each(adjusts, function (adjust) {
if (adjust.type === 'dodge') {
dodgeBy = adjust.dodgeBy;
}
});
if (dodgeBy) {
var mergeData = Util.Array.merge(dataArray);
var values = Util.Array.values(mergeData, dodgeBy);
count = values.length;
}
return count;
},
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 coord = this.get('coord');
var width; // x轴的长度
if (this.isInCircle() && !coord.isTransposed) {
// 极坐标下 width 为弧长
width = (coord.endAngle - coord.startAngle) * coord.radius;
} else {
width = this.getDimWidth('x'); // 不需要判断transpose
}
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 (Util.isNil(size)) {
size = this.getDefaultSize();
} else {
size = this._toNormalizedSize(size);
}
return size;
},
getSize: function getSize(obj) {
var size = this.getAttrValue('size', obj);
if (Util.isNil(size)) {
var normalizeSize = this.getDefaultSize();
size = this._toCoordSize(normalizeSize);
}
return size;
}
};
module.exports = SizeMixin;
/***/ }),
/* 68 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Format = __webpack_require__(36);
var PathSegment = __webpack_require__(47);
var Marker = function Marker(cfg) {
Marker.superclass.constructor.call(this, cfg);
};
Marker.Symbols = {
// 圆
circle: function circle(x, y, r) {
return [['M', x, y], ['m', -r, 0], ['a', r, r, 0, 1, 0, r * 2, 0], ['a', r, r, 0, 1, 0, -r * 2, 0]];
},
// 正方形
square: function square(x, y, r) {
return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];
},
// 菱形
diamond: function diamond(x, y, r) {
return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];
},
// 三角形
triangle: function triangle(x, y, r) {
var diffY = r * Math.sin(1 / 3 * Math.PI);
return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];
},
// 倒三角形
'triangle-down': function triangleDown(x, y, r) {
var diffY = r * Math.sin(1 / 3 * Math.PI);
return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];
}
};
Marker.ATTRS = {
path: null,
lineWidth: 1
};
Util.extend(Marker, Shape);
Util.augment(Marker, {
type: 'marker',
canFill: true,
canStroke: true,
getDefaultAttrs: function getDefaultAttrs() {
return {
x: 0,
y: 0,
lineWidth: 1
};
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.radius;
var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2 + r;
return {
minX: cx - halfWidth,
minY: cy - halfWidth,
maxX: cx + halfWidth,
maxY: cy + halfWidth
};
},
_getPath: function _getPath() {
var attrs = this._attrs;
var x = attrs.x;
var y = attrs.y;
var r = attrs.radius || attrs.r;
var symbol = attrs.symbol || 'circle';
var method;
if (Util.isFunction(symbol)) {
method = symbol;
} else {
method = Marker.Symbols[symbol];
}
if (!method) {
console.warn(symbol + " marker is not supported.");
return null;
}
return method(x, y, r);
},
createPath: function createPath(context) {
var segments = this._cfg.segments;
if (segments && !this._cfg.hasUpdate) {
context.beginPath();
for (var i = 0; i < segments.length; i++) {
segments[i].draw(context);
}
return;
}
var path = Format.parsePath(this._getPath());
context.beginPath();
var preSegment;
segments = [];
for (var _i = 0; _i < path.length; _i++) {
var item = path[_i];
preSegment = new PathSegment(item, preSegment, _i === path.length - 1);
segments.push(preSegment);
preSegment.draw(context);
}
this._cfg.segments = segments;
this._cfg.hasUpdate = false;
}
});
module.exports = Marker;
/***/ }),
/* 69 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var vec2 = Util.vec2;
function cubicAt(p0, p1, p2, p3, t) {
var onet = 1 - t;
return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
}
function cubicDerivativeAt(p0, p1, p2, p3, t) {
var onet = 1 - t;
return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
}
function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
var t;
var interval = 0.005;
var d = Infinity;
var _t;
var v1;
var d1;
var d2;
var v2;
var prev;
var next;
var EPSILON = 0.0001;
var v0 = [x, y];
for (_t = 0; _t < 1; _t += 0.05) {
v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
d1 = vec2.squaredDistance(v0, v1);
if (d1 < d) {
t = _t;
d = d1;
}
}
d = Infinity;
for (var i = 0; i < 32; i++) {
if (interval < EPSILON) {
break;
}
prev = t - interval;
next = t + interval;
v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
d1 = vec2.squaredDistance(v0, v1);
if (prev >= 0 && d1 < d) {
t = prev;
d = d1;
} else {
v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
d2 = vec2.squaredDistance(v0, v2);
if (next <= 1 && d2 < d) {
t = next;
d = d2;
} else {
interval *= 0.5;
}
}
}
if (out) {
out.x = cubicAt(x1, x2, x3, x4, t);
out.y = cubicAt(y1, y2, y3, y4, t);
}
return Math.sqrt(d);
}
function cubicExtrema(p0, p1, p2, p3) {
var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3;
var b = 6 * p1 - 12 * p2 + 6 * p3;
var c = 3 * p2 - 3 * p3;
var extrema = [];
var t1;
var t2;
var discSqrt;
if (Util.isNumberEqual(a, 0)) {
if (!Util.isNumberEqual(b, 0)) {
t1 = -c / b;
if (t1 >= 0 && t1 <= 1) {
extrema.push(t1);
}
}
} else {
var disc = b * b - 4 * a * c;
if (Util.isNumberEqual(disc, 0)) {
extrema.push(-b / (2 * a));
} else if (disc > 0) {
discSqrt = Math.sqrt(disc);
t1 = (-b + discSqrt) / (2 * a);
t2 = (-b - discSqrt) / (2 * a);
if (t1 >= 0 && t1 <= 1) {
extrema.push(t1);
}
if (t2 >= 0 && t2 <= 1) {
extrema.push(t2);
}
}
}
return extrema;
}
function base3(t, p1, p2, p3, p4) {
var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
return t * t2 - 3 * p1 + 3 * p2;
}
function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
if (Util.isNil(z)) {
z = 1;
}
z = z > 1 ? 1 : z < 0 ? 0 : z;
var z2 = z / 2;
var n = 12;
var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
var sum = 0;
for (var i = 0; i < n; i++) {
var ct = z2 * Tvalues[i] + z2;
var xbase = base3(ct, x1, x2, x3, x4);
var ybase = base3(ct, y1, y2, y3, y4);
var comb = xbase * xbase + ybase * ybase;
sum += Cvalues[i] * Math.sqrt(comb);
}
return z2 * sum;
}
module.exports = {
at: cubicAt,
derivativeAt: cubicDerivativeAt,
projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) {
var rst = {};
cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst);
return rst;
},
pointDistance: cubicProjectPoint,
extrema: cubicExtrema,
len: cubiclLen
};
/***/ }),
/* 70 */
/***/ (function(module, exports, __webpack_require__) {
var Line = __webpack_require__(45);
var Quadratic = __webpack_require__(137);
var Cubic = __webpack_require__(69);
var Arc = __webpack_require__(44);
module.exports = {
line: function line(x1, y1, x2, y2, lineWidth, x, y) {
var box = Line.box(x1, y1, x2, y2, lineWidth);
if (!this.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
return false;
}
var d = Line.pointDistance(x1, y1, x2, y2, x, y);
if (isNaN(d)) {
return false;
}
return d <= lineWidth / 2;
},
polyline: function polyline(points, lineWidth, x, y) {
var l = points.length - 1;
if (l < 1) {
return false;
}
for (var i = 0; i < l; i++) {
var x1 = points[i][0];
var y1 = points[i][1];
var x2 = points[i + 1][0];
var y2 = points[i + 1][1];
if (this.line(x1, y1, x2, y2, lineWidth, x, y)) {
return true;
}
}
return false;
},
cubicline: function cubicline(x1, y1, x2, y2, x3, y3, x4, y4, lineWidth, x, y) {
return Cubic.pointDistance(x1, y1, x2, y2, x3, y3, x4, y4, x, y) <= lineWidth / 2;
},
quadraticline: function quadraticline(x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
return Quadratic.pointDistance(x1, y1, x2, y2, x3, y3, x, y) <= lineWidth / 2;
},
arcline: function arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y) {
return Arc.pointDistance(cx, cy, r, startAngle, endAngle, clockwise, x, y) <= lineWidth / 2;
},
rect: function rect(rx, ry, width, height, x, y) {
return rx <= x && x <= rx + width && ry <= y && y <= ry + height;
},
circle: function circle(cx, cy, r, x, y) {
return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(r, 2);
},
box: function box(minX, maxX, minY, maxY, x, y) {
return minX <= x && x <= maxX && minY <= y && y <= maxY;
}
};
/***/ }),
/* 71 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(143);
var SPACES = "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029";
var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig'); // Parses given path string into an array of arrays of path segments
var parsePathString = function parsePathString(pathString) {
if (!pathString) {
return null;
}
if (typeof pathString === typeof []) {
return pathString;
}
var paramCounts = {
a: 7,
c: 6,
o: 2,
h: 1,
l: 2,
m: 2,
r: 4,
q: 4,
s: 4,
t: 2,
v: 1,
u: 3,
z: 0
};
var data = [];
String(pathString).replace(PATH_COMMAND, function (a, b, c) {
var params = [];
var name = b.toLowerCase();
c.replace(PATH_VALUES, function (a, b) {
b && params.push(+b);
});
if (name === 'm' && params.length > 2) {
data.push([b].concat(params.splice(0, 2)));
name = 'l';
b = b === 'm' ? 'l' : 'L';
}
if (name === 'o' && params.length === 1) {
data.push([b, params[0]]);
}
if (name === 'r') {
data.push([b].concat(params));
} else {
while (params.length >= paramCounts[name]) {
data.push([b].concat(params.splice(0, paramCounts[name])));
if (!paramCounts[name]) {
break;
}
}
}
});
return data;
}; // http://schepers.cc/getting-to-the-point
var catmullRom2bezier = function catmullRom2bezier(crp, z) {
var d = [];
for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
var p = [{
x: +crp[i - 2],
y: +crp[i - 1]
}, {
x: +crp[i],
y: +crp[i + 1]
}, {
x: +crp[i + 2],
y: +crp[i + 3]
}, {
x: +crp[i + 4],
y: +crp[i + 5]
}];
if (z) {
if (!i) {
p[0] = {
x: +crp[iLen - 2],
y: +crp[iLen - 1]
};
} else if (iLen - 4 === i) {
p[3] = {
x: +crp[0],
y: +crp[1]
};
} else if (iLen - 2 === i) {
p[2] = {
x: +crp[0],
y: +crp[1]
};
p[3] = {
x: +crp[2],
y: +crp[3]
};
}
} else {
if (iLen - 4 === i) {
p[3] = p[2];
} else if (!i) {
p[0] = {
x: +crp[i],
y: +crp[i + 1]
};
}
}
d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
}
return d;
};
var ellipsePath = function ellipsePath(x, y, rx, ry, a) {
var res = [];
if (a === null && ry === null) {
ry = rx;
}
x = +x;
y = +y;
rx = +rx;
ry = +ry;
if (a !== null) {
var rad = Math.PI / 180;
var x1 = x + rx * Math.cos(-ry * rad);
var x2 = x + rx * Math.cos(-a * rad);
var y1 = y + rx * Math.sin(-ry * rad);
var y2 = y + rx * Math.sin(-a * rad);
res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
} else {
res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
}
return res;
};
var pathToAbsolute = function pathToAbsolute(pathArray) {
pathArray = parsePathString(pathArray);
if (!pathArray || !pathArray.length) {
return [['M', 0, 0]];
}
var res = [];
var x = 0;
var y = 0;
var mx = 0;
var my = 0;
var start = 0;
var pa0;
var dots;
if (pathArray[0][0] === 'M') {
x = +pathArray[0][1];
y = +pathArray[0][2];
mx = x;
my = y;
start++;
res[0] = ['M', x, y];
}
var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
res.push(r = []);
pa = pathArray[i];
pa0 = pa[0];
if (pa0 !== pa0.toUpperCase()) {
r[0] = pa0.toUpperCase();
switch (r[0]) {
case 'A':
r[1] = pa[1];
r[2] = pa[2];
r[3] = pa[3];
r[4] = pa[4];
r[5] = pa[5];
r[6] = +pa[6] + x;
r[7] = +pa[7] + y;
break;
case 'V':
r[1] = +pa[1] + y;
break;
case 'H':
r[1] = +pa[1] + x;
break;
case 'R':
dots = [x, y].concat(pa.slice(1));
for (var j = 2, jj = dots.length; j < jj; j++) {
dots[j] = +dots[j] + x;
dots[++j] = +dots[j] + y;
}
res.pop();
res = res.concat(catmullRom2bezier(dots, crz));
break;
case 'O':
res.pop();
dots = ellipsePath(x, y, pa[1], pa[2]);
dots.push(dots[0]);
res = res.concat(dots);
break;
case 'U':
res.pop();
res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
r = ['U'].concat(res[res.length - 1].slice(-2));
break;
case 'M':
mx = +pa[1] + x;
my = +pa[2] + y;
break;
// for lint
default:
for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
r[_j] = +pa[_j] + (_j % 2 ? x : y);
}
}
} else if (pa0 === 'R') {
dots = [x, y].concat(pa.slice(1));
res.pop();
res = res.concat(catmullRom2bezier(dots, crz));
r = ['R'].concat(pa.slice(-2));
} else if (pa0 === 'O') {
res.pop();
dots = ellipsePath(x, y, pa[1], pa[2]);
dots.push(dots[0]);
res = res.concat(dots);
} else if (pa0 === 'U') {
res.pop();
res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
r = ['U'].concat(res[res.length - 1].slice(-2));
} else {
for (var k = 0, kk = pa.length; k < kk; k++) {
r[k] = pa[k];
}
}
pa0 = pa0.toUpperCase();
if (pa0 !== 'O') {
switch (r[0]) {
case 'Z':
x = +mx;
y = +my;
break;
case 'H':
x = r[1];
break;
case 'V':
y = r[1];
break;
case 'M':
mx = r[r.length - 2];
my = r[r.length - 1];
break;
// for lint
default:
x = r[r.length - 2];
y = r[r.length - 1];
}
}
}
return res;
};
var l2c = function l2c(x1, y1, x2, y2) {
return [x1, y1, x2, y2, x2, y2];
};
var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
var _13 = 1 / 3;
var _23 = 2 / 3;
return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
};
var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
// for more information of where this math came from visit:
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
if (rx === ry) {
rx += 1;
}
var _120 = Math.PI * 120 / 180;
var rad = Math.PI / 180 * (+angle || 0);
var res = [];
var xy;
var f1;
var f2;
var cx;
var cy;
var rotate = function rotate(x, y, rad) {
var X = x * Math.cos(rad) - y * Math.sin(rad);
var Y = x * Math.sin(rad) + y * Math.cos(rad);
return {
x: X,
y: Y
};
};
if (!recursive) {
xy = rotate(x1, y1, -rad);
x1 = xy.x;
y1 = xy.y;
xy = rotate(x2, y2, -rad);
x2 = xy.x;
y2 = xy.y;
if (x1 === x2 && y1 === y2) {
// 若弧的起始点和终点重叠则错开一点
x2 += 1;
y2 += 1;
} // const cos = Math.cos(Math.PI / 180 * angle);
// const sin = Math.sin(Math.PI / 180 * angle);
var x = (x1 - x2) / 2;
var y = (y1 - y2) / 2;
var h = x * x / (rx * rx) + y * y / (ry * ry);
if (h > 1) {
h = Math.sqrt(h);
rx = h * rx;
ry = h * ry;
}
var rx2 = rx * rx;
var ry2 = ry * ry;
var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
cx = k * rx * y / ry + (x1 + x2) / 2;
cy = k * -ry * x / rx + (y1 + y2) / 2;
f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
f1 = x1 < cx ? Math.PI - f1 : f1;
f2 = x2 < cx ? Math.PI - f2 : f2;
f1 < 0 && (f1 = Math.PI * 2 + f1);
f2 < 0 && (f2 = Math.PI * 2 + f2);
if (sweep_flag && f1 > f2) {
f1 = f1 - Math.PI * 2;
}
if (!sweep_flag && f2 > f1) {
f2 = f2 - Math.PI * 2;
}
} else {
f1 = recursive[0];
f2 = recursive[1];
cx = recursive[2];
cy = recursive[3];
}
var df = f2 - f1;
if (Math.abs(df) > _120) {
var f2old = f2;
var x2old = x2;
var y2old = y2;
f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
x2 = cx + rx * Math.cos(f2);
y2 = cy + ry * Math.sin(f2);
res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
}
df = f2 - f1;
var c1 = Math.cos(f1);
var s1 = Math.sin(f1);
var c2 = Math.cos(f2);
var s2 = Math.sin(f2);
var t = Math.tan(df / 4);
var hx = 4 / 3 * rx * t;
var hy = 4 / 3 * ry * t;
var m1 = [x1, y1];
var m2 = [x1 + hx * s1, y1 - hy * c1];
var m3 = [x2 + hx * s2, y2 - hy * c2];
var m4 = [x2, y2];
m2[0] = 2 * m1[0] - m2[0];
m2[1] = 2 * m1[1] - m2[1];
if (recursive) {
return [m2, m3, m4].concat(res);
}
res = [m2, m3, m4].concat(res).join().split(',');
var newres = [];
for (var i = 0, ii = res.length; i < ii; i++) {
newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
}
return newres;
};
var pathTocurve = function pathTocurve(path, path2) {
var p = pathToAbsolute(path);
var p2 = path2 && pathToAbsolute(path2);
var attrs = {
x: 0,
y: 0,
bx: 0,
by: 0,
X: 0,
Y: 0,
qx: null,
qy: null
};
var attrs2 = {
x: 0,
y: 0,
bx: 0,
by: 0,
X: 0,
Y: 0,
qx: null,
qy: null
};
var pcoms1 = []; // path commands of original path p
var pcoms2 = []; // path commands of original path p2
var pfirst = ''; // temporary holder for original path command
var pcom = ''; // holder for previous path command of original path
var ii;
var processPath = function processPath(path, d, pcom) {
var nx, ny;
if (!path) {
return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
}
!(path[0] in {
T: 1,
Q: 1
}) && (d.qx = d.qy = null);
switch (path[0]) {
case 'M':
d.X = path[1];
d.Y = path[2];
break;
case 'A':
path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
break;
case 'S':
if (pcom === 'C' || pcom === 'S') {
// In "S" case we have to take into account, if the previous command is C/S.
nx = d.x * 2 - d.bx; // And reflect the previous
ny = d.y * 2 - d.by; // command's control point relative to the current point.
} else {
// or some else or nothing
nx = d.x;
ny = d.y;
}
path = ['C', nx, ny].concat(path.slice(1));
break;
case 'T':
if (pcom === 'Q' || pcom === 'T') {
// In "T" case we have to take into account, if the previous command is Q/T.
d.qx = d.x * 2 - d.qx; // And make a reflection similar
d.qy = d.y * 2 - d.qy; // to case "S".
} else {
// or something else or nothing
d.qx = d.x;
d.qy = d.y;
}
path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
break;
case 'Q':
d.qx = path[1];
d.qy = path[2];
path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
break;
case 'L':
path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
break;
case 'H':
path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
break;
case 'V':
path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
break;
case 'Z':
path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
break;
default:
break;
}
return path;
};
var fixArc = function fixArc(pp, i) {
if (pp[i].length > 7) {
pp[i].shift();
var pi = pp[i];
while (pi.length) {
pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
p2 && (pcoms2[i] = 'A'); // the same as above
pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
}
pp.splice(i, 1);
ii = Math.max(p.length, p2 && p2.length || 0);
}
};
var fixM = function fixM(path1, path2, a1, a2, i) {
if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
path2.splice(i, 0, ['M', a2.x, a2.y]);
a1.bx = 0;
a1.by = 0;
a1.x = path1[i][1];
a1.y = path1[i][2];
ii = Math.max(p.length, p2 && p2.length || 0);
}
};
ii = Math.max(p.length, p2 && p2.length || 0);
for (var i = 0; i < ii; i++) {
p[i] && (pfirst = p[i][0]); // save current path command
if (pfirst !== 'C') {
// C is not saved yet, because it may be result of conversion
pcoms1[i] = pfirst; // Save current path command
i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
}
p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
// which may produce multiple C:s
// so we have to make sure that C is also C in original path
fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
if (p2) {
// the same procedures is done to p2
p2[i] && (pfirst = p2[i][0]);
if (pfirst !== 'C') {
pcoms2[i] = pfirst;
i && (pcom = pcoms2[i - 1]);
}
p2[i] = processPath(p2[i], attrs2, pcom);
if (pcoms2[i] !== 'A' && pfirst === 'C') {
pcoms2[i] = 'C';
}
fixArc(p2, i);
}
fixM(p, p2, attrs, attrs2, i);
fixM(p2, p, attrs2, attrs, i);
var seg = p[i];
var seg2 = p2 && p2[i];
var seglen = seg.length;
var seg2len = p2 && seg2.length;
attrs.x = seg[seglen - 2];
attrs.y = seg[seglen - 1];
attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
attrs2.x = p2 && seg2[seg2len - 2];
attrs2.y = p2 && seg2[seg2len - 1];
}
return p2 ? [p, p2] : p;
};
var p2s = /,?([a-z]),?/gi;
var parsePathArray = function parsePathArray(path) {
return path.join(',').replace(p2s, '$1');
};
var base3 = function base3(t, p1, p2, p3, p4) {
var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
return t * t2 - 3 * p1 + 3 * p2;
};
var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
if (z === null) {
z = 1;
}
z = z > 1 ? 1 : z < 0 ? 0 : z;
var z2 = z / 2;
var n = 12;
var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
var sum = 0;
for (var i = 0; i < n; i++) {
var ct = z2 * Tvalues[i] + z2;
var xbase = base3(ct, x1, x2, x3, x4);
var ybase = base3(ct, y1, y2, y3, y4);
var comb = xbase * xbase + ybase * ybase;
sum += Cvalues[i] * Math.sqrt(comb);
}
return z2 * sum;
};
var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
var tvalues = [];
var bounds = [[], []];
var a;
var b;
var c;
var t;
for (var i = 0; i < 2; ++i) {
if (i === 0) {
b = 6 * x0 - 12 * x1 + 6 * x2;
a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
c = 3 * x1 - 3 * x0;
} else {
b = 6 * y0 - 12 * y1 + 6 * y2;
a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
c = 3 * y1 - 3 * y0;
}
if (Math.abs(a) < 1e-12) {
if (Math.abs(b) < 1e-12) {
continue;
}
t = -c / b;
if (t > 0 && t < 1) {
tvalues.push(t);
}
continue;
}
var b2ac = b * b - 4 * c * a;
var sqrtb2ac = Math.sqrt(b2ac);
if (b2ac < 0) {
continue;
}
var t1 = (-b + sqrtb2ac) / (2 * a);
if (t1 > 0 && t1 < 1) {
tvalues.push(t1);
}
var t2 = (-b - sqrtb2ac) / (2 * a);
if (t2 > 0 && t2 < 1) {
tvalues.push(t2);
}
}
var j = tvalues.length;
var jlen = j;
var mt;
while (j--) {
t = tvalues[j];
mt = 1 - t;
bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
}
bounds[0][jlen] = x0;
bounds[1][jlen] = y0;
bounds[0][jlen + 1] = x3;
bounds[1][jlen + 1] = y3;
bounds[0].length = bounds[1].length = jlen + 2;
return {
min: {
x: Math.min.apply(0, bounds[0]),
y: Math.min.apply(0, bounds[1])
},
max: {
x: Math.max.apply(0, bounds[0]),
y: Math.max.apply(0, bounds[1])
}
};
};
var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
return;
}
var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
if (!denominator) {
return;
}
var px = nx / denominator;
var py = ny / denominator;
var px2 = +px.toFixed(2);
var py2 = +py.toFixed(2);
if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
return;
}
return {
x: px,
y: py
};
};
var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
};
var rectPath = function rectPath(x, y, w, h, r) {
if (r) {
return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
}
var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
res.parsePathArray = parsePathArray;
return res;
};
var box = function box(x, y, width, height) {
if (x === null) {
x = y = width = height = 0;
}
if (y === null) {
y = x.y;
width = x.width;
height = x.height;
x = x.x;
}
return {
x: x,
y: y,
width: width,
w: width,
height: height,
h: height,
x2: x + width,
y2: y + height,
cx: x + width / 2,
cy: y + height / 2,
r1: Math.min(width, height) / 2,
r2: Math.max(width, height) / 2,
r0: Math.sqrt(width * width + height * height) / 2,
path: rectPath(x, y, width, height),
vb: [x, y, width, height].join(' ')
};
};
var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
bbox1 = box(bbox1);
bbox2 = box(bbox2);
return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
};
var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
if (!Util.isArray(p1x)) {
p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
}
var bbox = curveDim.apply(null, p1x);
return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
};
var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
var t1 = 1 - t;
var t13 = Math.pow(t1, 3);
var t12 = Math.pow(t1, 2);
var t2 = t * t;
var t3 = t2 * t;
var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
var ax = t1 * p1x + t * c1x;
var ay = t1 * p1y + t * c1y;
var cx = t1 * c2x + t * p2x;
var cy = t1 * c2y + t * p2y;
var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI; // (mx > nx || my < ny) && (alpha += 180);
return {
x: x,
y: y,
m: {
x: mx,
y: my
},
n: {
x: nx,
y: ny
},
start: {
x: ax,
y: ay
},
end: {
x: cx,
y: cy
},
alpha: alpha
};
};
var interHelper = function interHelper(bez1, bez2, justCount) {
var bbox1 = bezierBBox(bez1);
var bbox2 = bezierBBox(bez2);
if (!isBBoxIntersect(bbox1, bbox2)) {
return justCount ? 0 : [];
}
var l1 = bezlen.apply(0, bez1);
var l2 = bezlen.apply(0, bez2);
var n1 = ~~(l1 / 8);
var n2 = ~~(l2 / 8);
var dots1 = [];
var dots2 = [];
var xy = {};
var res = justCount ? 0 : [];
for (var i = 0; i < n1 + 1; i++) {
var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
dots1.push({
x: d.x,
y: d.y,
t: i / n1
});
}
for (var _i = 0; _i < n2 + 1; _i++) {
var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
dots2.push({
x: _d.x,
y: _d.y,
t: _i / n2
});
}
for (var _i2 = 0; _i2 < n1; _i2++) {
for (var j = 0; j < n2; j++) {
var di = dots1[_i2];
var di1 = dots1[_i2 + 1];
var dj = dots2[j];
var dj1 = dots2[j + 1];
var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
if (is) {
if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
continue;
}
xy[is.x.toFixed(4)] = is.y.toFixed(4);
var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
if (justCount) {
res++;
} else {
res.push({
x: is.x,
y: is.y,
t1: t1,
t2: t2
});
}
}
}
}
}
return res;
};
var interPathHelper = function interPathHelper(path1, path2, justCount) {
path1 = pathTocurve(path1);
path2 = pathTocurve(path2);
var x1;
var y1;
var x2;
var y2;
var x1m;
var y1m;
var x2m;
var y2m;
var bez1;
var bez2;
var res = justCount ? 0 : [];
for (var i = 0, ii = path1.length; i < ii; i++) {
var pi = path1[i];
if (pi[0] === 'M') {
x1 = x1m = pi[1];
y1 = y1m = pi[2];
} else {
if (pi[0] === 'C') {
bez1 = [x1, y1].concat(pi.slice(1));
x1 = bez1[6];
y1 = bez1[7];
} else {
bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
x1 = x1m;
y1 = y1m;
}
for (var j = 0, jj = path2.length; j < jj; j++) {
var pj = path2[j];
if (pj[0] === 'M') {
x2 = x2m = pj[1];
y2 = y2m = pj[2];
} else {
if (pj[0] === 'C') {
bez2 = [x2, y2].concat(pj.slice(1));
x2 = bez2[6];
y2 = bez2[7];
} else {
bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
x2 = x2m;
y2 = y2m;
}
var intr = interHelper(bez1, bez2, justCount);
if (justCount) {
res += intr;
} else {
for (var k = 0, kk = intr.length; k < kk; k++) {
intr[k].segment1 = i;
intr[k].segment2 = j;
intr[k].bez1 = bez1;
intr[k].bez2 = bez2;
}
res = res.concat(intr);
}
}
}
}
}
return res;
};
var pathIntersection = function pathIntersection(path1, path2) {
return interPathHelper(path1, path2);
};
function decasteljau(points, t) {
var left = [];
var right = [];
function recurse(points, t) {
if (points.length === 1) {
left.push(points[0]);
right.push(points[0]);
} else {
var middlePoints = [];
for (var i = 0; i < points.length - 1; i++) {
if (i === 0) {
left.push(points[0]);
}
if (i === points.length - 2) {
right.push(points[i + 1]);
}
middlePoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
}
recurse(middlePoints, t);
}
}
if (points.length) {
recurse(points, t);
}
return {
left: left,
right: right.reverse()
};
}
function splitCurve(start, end, count) {
var points = [[start[1], start[2]]];
count = count || 2;
var segments = [];
if (end[0] === 'A') {
points.push(end[6]);
points.push(end[7]);
} else if (end[0] === 'C') {
points.push([end[1], end[2]]);
points.push([end[3], end[4]]);
points.push([end[5], end[6]]);
} else if (end[0] === 'S' || end[0] === 'Q') {
points.push([end[1], end[2]]);
points.push([end[3], end[4]]);
} else {
points.push([end[1], end[2]]);
}
var leftSegments = points;
var t = 1 / count;
for (var i = 0; i < count - 1; i++) {
var rt = t / (1 - t * i);
var split = decasteljau(leftSegments, rt);
segments.push(split.left);
leftSegments = split.right;
}
segments.push(leftSegments);
var result = segments.map(function (segment) {
var cmd = [];
if (segment.length === 4) {
cmd.push('C');
cmd = cmd.concat(segment[2]);
}
if (segment.length >= 3) {
if (segment.length === 3) {
cmd.push('Q');
}
cmd = cmd.concat(segment[1]);
}
if (segment.length === 2) {
cmd.push('L');
}
cmd = cmd.concat(segment[segment.length - 1]);
return cmd;
});
return result;
}
var splitSegment = function splitSegment(start, end, count) {
if (count === 1) {
return [[].concat(start)];
}
var segments = [];
if (end[0] === 'L' || end[0] === 'C' || end[0] === 'Q') {
segments = segments.concat(splitCurve(start, end, count));
} else {
var temp = [].concat(start);
if (temp[0] === 'M') {
temp[0] = 'L';
}
for (var i = 0; i <= count - 1; i++) {
segments.push(temp);
}
}
return segments;
};
var fillPath = function fillPath(source, target) {
if (source.length === 1) {
return source;
}
var sourceLen = source.length - 1;
var targetLen = target.length - 1;
var ratio = sourceLen / targetLen;
var segmentsToFill = [];
if (source.length === 1 && source[0][0] === 'M') {
for (var i = 0; i < targetLen - sourceLen; i++) {
source.push(source[0]);
}
return source;
}
for (var _i3 = 0; _i3 < targetLen; _i3++) {
var index = Math.floor(ratio * _i3);
segmentsToFill[index] = (segmentsToFill[index] || 0) + 1;
}
var filled = segmentsToFill.reduce(function (filled, count, i) {
if (i === sourceLen) {
return filled.concat(source[sourceLen]);
}
return filled.concat(splitSegment(source[i], source[i + 1], count));
}, []);
filled.unshift(source[0]);
if (target[targetLen] === 'Z' || target[targetLen] === 'z') {
filled.push('Z');
}
return filled;
};
var isEqual = function isEqual(obj1, obj2) {
if (obj1.length !== obj2.length) {
return false;
}
var result = true;
Util.each(obj1, function (item, i) {
if (item !== obj2[i]) {
result = false;
return false;
}
});
return result;
};
function getMinDiff(del, add, modify) {
var type = null;
var min = modify;
if (add < min) {
min = add;
type = 'add';
}
if (del < min) {
min = del;
type = 'del';
}
return {
type: type,
min: min
};
}
/*
* https://en.wikipedia.org/wiki/Levenshtein_distance
* 计算两条path的编辑距离
*/
var levenshteinDistance = function levenshteinDistance(source, target) {
var sourceLen = source.length;
var targetLen = target.length;
var sourceSegment, targetSegment;
var temp = 0;
if (sourceLen === 0 || targetLen === 0) {
return null;
}
var dist = [];
for (var i = 0; i <= sourceLen; i++) {
dist[i] = [];
dist[i][0] = {
min: i
};
}
for (var j = 0; j <= targetLen; j++) {
dist[0][j] = {
min: j
};
}
for (var _i4 = 1; _i4 <= sourceLen; _i4++) {
sourceSegment = source[_i4 - 1];
for (var _j2 = 1; _j2 <= targetLen; _j2++) {
targetSegment = target[_j2 - 1];
if (isEqual(sourceSegment, targetSegment)) {
temp = 0;
} else {
temp = 1;
}
var del = dist[_i4 - 1][_j2].min + 1;
var add = dist[_i4][_j2 - 1].min + 1;
var modify = dist[_i4 - 1][_j2 - 1].min + temp;
dist[_i4][_j2] = getMinDiff(del, add, modify);
}
}
return dist;
};
var fillPathByDiff = function fillPathByDiff(source, target) {
var diffMatrix = levenshteinDistance(source, target);
var sourceLen = source.length;
var targetLen = target.length;
var changes = [];
var index = 1;
var minPos = 1; // 如果source和target不是完全不相等
if (diffMatrix[sourceLen][targetLen] !== sourceLen) {
// 获取从source到target所需改动
for (var i = 1; i <= sourceLen; i++) {
var min = diffMatrix[i][i].min;
minPos = i;
for (var j = index; j <= targetLen; j++) {
if (diffMatrix[i][j].min < min) {
min = diffMatrix[i][j].min;
minPos = j;
}
}
index = minPos;
if (diffMatrix[i][index].type) {
changes.push({
index: i - 1,
type: diffMatrix[i][index].type
});
}
} // 对source进行增删path
for (var _i5 = changes.length - 1; _i5 >= 0; _i5--) {
index = changes[_i5].index;
if (changes[_i5].type === 'add') {
source.splice(index, 0, [].concat(source[index]));
} else {
source.splice(index, 1);
}
}
} // source尾部补齐
sourceLen = source.length;
var diff = targetLen - sourceLen;
if (sourceLen < targetLen) {
for (var _i6 = 0; _i6 < diff; _i6++) {
if (source[sourceLen - 1][0] === 'z' || source[sourceLen - 1][0] === 'Z') {
source.splice(sourceLen - 2, 0, source[sourceLen - 2]);
} else {
source.push(source[sourceLen - 1]);
}
sourceLen += 1;
}
}
return source;
}; // 将两个点均分成count个点
function _splitPoints(points, former, count) {
var result = [].concat(points);
var index;
var t = 1 / (count + 1);
var formerEnd = _getSegmentPoints(former)[0];
for (var i = 1; i <= count; i++) {
t *= i;
index = Math.floor(points.length * t);
if (index === 0) {
result.unshift([formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
} else {
result.splice(index, 0, [formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
}
}
return result;
}
/*
* 抽取pathSegment中的关键点
* M,L,A,Q,H,V一个端点
* Q, S抽取一个端点,一个控制点
* C抽取一个端点,两个控制点
*/
function _getSegmentPoints(segment) {
var points = [];
switch (segment[0]) {
case 'M':
points.push([segment[1], segment[2]]);
break;
case 'L':
points.push([segment[1], segment[2]]);
break;
case 'A':
points.push([segment[6], segment[7]]);
break;
case 'Q':
points.push([segment[3], segment[4]]);
points.push([segment[1], segment[2]]);
break;
case 'T':
points.push([segment[1], segment[2]]);
break;
case 'C':
points.push([segment[5], segment[6]]);
points.push([segment[1], segment[2]]);
points.push([segment[3], segment[4]]);
break;
case 'S':
points.push([segment[3], segment[4]]);
points.push([segment[1], segment[2]]);
break;
case 'H':
points.push([segment[1], segment[1]]);
break;
case 'V':
points.push([segment[1], segment[1]]);
break;
default:
}
return points;
}
var formatPath = function formatPath(fromPath, toPath) {
if (fromPath.length <= 1) {
return fromPath;
}
var points;
for (var i = 0; i < toPath.length; i++) {
if (fromPath[i][0] !== toPath[i][0]) {
// 获取fromPath的pathSegment的端点,根据toPath的指令对其改造
points = _getSegmentPoints(fromPath[i]);
switch (toPath[i][0]) {
case 'M':
fromPath[i] = ['M'].concat(points[0]);
break;
case 'L':
fromPath[i] = ['L'].concat(points[0]);
break;
case 'A':
fromPath[i] = [].concat(toPath[i]);
fromPath[i][6] = points[0][0];
fromPath[i][7] = points[0][1];
break;
case 'Q':
if (points.length < 2) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 1);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['Q'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
case 'T':
fromPath[i] = ['T'].concat(points[0]);
break;
case 'C':
if (points.length < 3) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 2);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['C'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
case 'S':
if (points.length < 2) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 1);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['S'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
default:
fromPath[i] = toPath[i];
}
}
}
return fromPath;
};
module.exports = {
parsePathString: parsePathString,
parsePathArray: parsePathArray,
pathTocurve: pathTocurve,
pathToAbsolute: pathToAbsolute,
catmullRomToBezier: catmullRom2bezier,
rectPath: rectPath,
fillPath: fillPath,
fillPathByDiff: fillPathByDiff,
formatPath: formatPath,
intersection: pathIntersection
};
/***/ }),
/* 72 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setMatrixArrayType = setMatrixArrayType;
exports.toRadian = toRadian;
exports.equals = equals;
/**
* Common utilities
* @module glMatrix
*/
// Configuration Constants
var EPSILON = exports.EPSILON = 0.000001;
var ARRAY_TYPE = exports.ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
var RANDOM = exports.RANDOM = Math.random;
/**
* Sets the type of array used when creating new vectors and matrices
*
* @param {Type} type Array type, such as Float32Array or Array
*/
function setMatrixArrayType(type) {
exports.ARRAY_TYPE = ARRAY_TYPE = type;
}
var degree = Math.PI / 180;
/**
* Convert Degree To Radian
*
* @param {Number} a Angle in Degrees
*/
function toRadian(a) {
return a * degree;
}
/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @param {Number} a The first number to test.
* @param {Number} b The second number to test.
* @returns {Boolean} True if the numbers are approximately equal, false otherwise.
*/
function equals(a, b) {
return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
}
/***/ }),
/* 73 */
/***/ (function(module, exports, __webpack_require__) {
var isNil = __webpack_require__(6);
var isArray = __webpack_require__(4);
var each = __webpack_require__(2);
module.exports = function valuesOfKey(data, name) {
var rst = [];
var tmpMap = {};
for (var i = 0; i < data.length; i++) {
var obj = data[i];
var value = obj[name];
if (!isNil(value)) {
if (!isArray(value)) {
value = [value];
}
each(value, function (val) {
if (!tmpMap[val]) {
rst.push(val);
tmpMap[val] = true;
}
});
}
}
return rst;
};
/***/ }),
/* 74 */
/***/ (function(module, exports, __webpack_require__) {
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 isArray = __webpack_require__(4);
var clone = function clone(obj) {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
return obj;
}
var rst = void 0;
if (isArray(obj)) {
rst = [];
for (var i = 0, l = obj.length; i < l; i++) {
if (_typeof(obj[i]) === 'object' && obj[i] != null) {
rst[i] = clone(obj[i]);
} else {
rst[i] = obj[i];
}
}
} else {
rst = {};
for (var k in obj) {
if (_typeof(obj[k]) === 'object' && obj[k] != null) {
rst[k] = clone(obj[k]);
} else {
rst[k] = obj[k];
}
}
}
return rst;
};
module.exports = clone;
/***/ }),
/* 75 */
/***/ (function(module, exports, __webpack_require__) {
var isPlainObject = __webpack_require__(39);
var isArray = __webpack_require__(4);
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(value)) {
dist[key] = [];
dist[key] = dist[key].concat(value);
} else if (value !== undefined) {
dist[key] = value;
}
}
}
}
var deepMix = function deepMix() {
var args = new Array(arguments.length);
var length = args.length;
for (var i = 0; i < length; i++) {
args[i] = arguments[i];
}
var rst = args[0];
for (var _i = 1; _i < length; _i++) {
_deepMix(rst, args[_i]);
}
return rst;
};
module.exports = deepMix;
/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isArrayLike = __webpack_require__(20);
var filter = function filter(arr, func) {
if (!isArrayLike(arr)) {
return arr;
}
var result = [];
each(arr, function (value, index) {
if (func(value, index)) {
result.push(value);
}
});
return result;
};
module.exports = filter;
/***/ }),
/* 77 */
/***/ (function(module, exports, __webpack_require__) {
var isObjectLike = __webpack_require__(80);
var isArrayLike = __webpack_require__(20);
var isString = __webpack_require__(15);
var isEqual = function isEqual(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(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(value[valueKeys[_i]], other[valueKeys[_i]]);
if (!_rst) {
break;
}
}
return _rst;
}
return false;
};
module.exports = isEqual;
/***/ }),
/* 78 */
/***/ (function(module, exports) {
var clamp = function clamp(a, min, max) {
if (a < min) {
return min;
} else if (a > max) {
return max;
}
return a;
};
module.exports = clamp;
/***/ }),
/* 79 */
/***/ (function(module, exports, __webpack_require__) {
var mat3 = __webpack_require__(332);
mat3.translate = function (out, a, v) {
var transMat = new Array(9);
mat3.fromTranslation(transMat, v);
return mat3.multiply(out, transMat, a);
};
mat3.rotate = function (out, a, rad) {
var rotateMat = new Array(9);
mat3.fromRotation(rotateMat, rad);
return mat3.multiply(out, rotateMat, a);
};
mat3.scale = function (out, a, v) {
var scaleMat = new Array(9);
mat3.fromScaling(scaleMat, v);
return mat3.multiply(out, scaleMat, a);
};
module.exports = mat3;
/***/ }),
/* 80 */
/***/ (function(module, exports) {
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 isObjectLike = function isObjectLike(value) {
/**
* isObjectLike({}) => true
* isObjectLike([1, 2, 3]) => true
* isObjectLike(Function) => false
* isObjectLike(null) => false
*/
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
};
module.exports = isObjectLike;
/***/ }),
/* 81 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var deleteFuncMap = {
Chart: 'deleteChart',
Coord: 'deleteCoord',
Geom: 'deleteGeom',
Axis: 'deleteAxis',
Tooltip: 'deleteTooltip',
Legend: 'deleteLegend',
Label: 'deleteLabel',
View: 'deleteView',
Guide: 'deleteGuide',
GuideLine: 'deleteTypedGuide',
GuideImage: 'deleteTypedGuide',
GuideText: 'deleteTypedGuide',
GuideRegion: 'deleteTypedGuide',
GuideHtml: 'deleteTypedGuide',
GuideArc: 'deleteTypedGuide',
GuideRegionFilter: 'deleteTypedGuide',
GuideDataMarker: 'deleteTypedGuide',
GuideDataRegion: 'deleteTypedGuide',
Facet: 'deleteFacet'
};
var iMerge = {
merge: function merge(config, deleteInfos, elementInfos, clear) {
this.mergeDelete(config, deleteInfos, elementInfos);
this.mergeUpdate(config, clear);
},
mergeDelete: function mergeDelete(config, deleteInfos, elementInfos) {
var _this = this;
Object.keys(deleteInfos).forEach(function (id) {
var funName = deleteFuncMap[elementInfos[id].name];
var deleteConfigContainer = config;
if (elementInfos[id].viewId) {
deleteConfigContainer = config.views[elementInfos[id].viewId];
}
if (_this[funName]) {
_this[funName](deleteConfigContainer, id, elementInfos[id].parentInfo.id);
}
});
},
deleteAxis: function deleteAxis(config, id) {
if (!config) return;
delete config.axises[id];
},
deleteTooltip: function deleteTooltip(config) {
if (!config) return;
delete config.tooltip;
},
deleteCoord: function deleteCoord(config) {
if (!config) return;
delete config.coord;
},
deleteLegend: function deleteLegend(config, id) {
if (!config) return;
delete config.legends[id];
},
deleteGuide: function deleteGuide(config) {
if (!config) return;
delete config.guide;
},
deleteGeom: function deleteGeom(config, id) {
if (!config || !config.geoms) return;
delete config.geoms[id];
},
deleteLabel: function deleteLabel(config, id, parentId) {
if (!config || !config.geoms || !config.geoms[parentId]) return;
delete config.geoms[parentId].label;
},
deleteFacet: function deleteFacet(config) {
if (!config) return;
delete config.facet;
},
deleteTypedGuide: function deleteTypedGuide(config, id) {
if (!config || !config.guide) return;
delete config.guide.elements[id];
},
deleteView: function deleteView(config, id) {
if (!config) return;
delete config.views[id];
},
mergeUpdate: function mergeUpdate(config, clear) {
this.mergeChart(config, clear);
this.mergeAxises(config, clear);
this.mergeCoord(config, clear);
this.mergeGeoms(config.geoms, clear);
this.mergeLegends(config.legends, clear);
this.mergeTooltip(config, clear);
this.mergeViews(config.views, clear);
this.mergeGuide(config.guide, clear);
},
mergeChart: function mergeChart(config, clear) {
if (config.chart && config.chart.updateProps) {
config.chart.props = config.chart.updateProps;
}
if (clear) {
delete config.chart.g2Instance;
}
},
mergeAxises: function mergeAxises(config, clear) {
var axises = config.axises;
if (!axises == null) {
return;
}
for (var id in axises) {
if (axises[id] && axises[id].updateProps) {
axises[id].props = axises[id].updateProps;
}
if (clear) {
delete axises[id].g2Instance;
}
}
},
mergeTooltip: function mergeTooltip(config, clear) {
if (!config.tooltip) return;
if (clear) {
delete config.tooltip.g2Instance;
}
if (config.tooltip.updateProps) {
config.tooltip.props = config.tooltip.updateProps;
}
},
mergeCoord: function mergeCoord(config, clear) {
if (!config.coord) return;
if (clear) delete config.coord.g2Instance;
if (config.coord.updateProps) {
config.coord.props = config.coord.updateProps;
}
},
mergeLegends: function mergeLegends(legends, clear) {
if (!legends) return;
for (var id in legends) {
if (legends[id]) {
var legendConfig = legends[id];
if (clear) {
delete legendConfig.g2Instance;
}
if (legendConfig.updateProps) legendConfig.props = legendConfig.updateProps;
}
}
},
mergeGeoms: function mergeGeoms(geoms, clear) {
if (geoms == null) return;
for (var id in geoms) {
if (geoms[id]) {
if (clear) {
delete geoms[id].g2Instance;
if (geoms[id].label && geoms[id].label.g2Instance) {
if (geoms[id].label.updateProps) {
geoms[id].label.props = geoms[id].label.updateProps;
}
delete geoms[id].label.g2Instance;
}
}
if (geoms[id].updateProps) geoms[id].props = geoms[id].updateProps;
}
}
},
mergeGuide: function mergeGuide(guide, clear) {
if (guide == null) return;
var guides = guide.elements;
for (var id in guides) {
if (guides[id]) {
if (clear) {
delete guides[id].g2Instance;
}
if (guides[id].updateProps) {
guides[id].props = guides[id].updateProps;
}
}
}
},
mergeView: function mergeView(view, clear) {
if (!view) return;
// merge self
if (clear && view.g2Instance) {
delete view.g2Instance;
}
if (view.updateProps) {
view.props = view.updateProps;
}
this.mergeCoord(view, clear);
this.mergeAxises(view, clear);
this.mergeGeoms(view.geoms, clear);
this.mergeGuide(view.guide, clear);
},
mergeViews: function mergeViews(views, clear) {
if (views == null) return;
for (var id in views) {
if (views[id]) {
this.mergeView(views[id], clear);
}
}
}
};
exports.default = iMerge;
/***/ }),
/* 82 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Prop = exports.Util = undefined;
var _util = __webpack_require__(54);
var _util2 = _interopRequireDefault(_util);
var _prop = __webpack_require__(422);
var _prop2 = _interopRequireDefault(_prop);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.Util = _util2.default;
exports.Prop = _prop2.default;
/***/ }),
/* 83 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = Color;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return darker; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return brighter; });
/* harmony export (immutable) */ __webpack_exports__["h"] = color;
/* harmony export (immutable) */ __webpack_exports__["b"] = rgbConvert;
/* harmony export (immutable) */ __webpack_exports__["g"] = rgb;
/* harmony export (immutable) */ __webpack_exports__["a"] = Rgb;
/* unused harmony export hslConvert */
/* harmony export (immutable) */ __webpack_exports__["f"] = hsl;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(84);
function Color() {}
var darker = 0.7;
var brighter = 1 / darker;
var reI = "\\s*([+-]?\\d+)\\s*",
reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
reHex3 = /^#([0-9a-f]{3})$/,
reHex6 = /^#([0-9a-f]{6})$/,
reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
var named = {
aliceblue: 0xf0f8ff,
antiquewhite: 0xfaebd7,
aqua: 0x00ffff,
aquamarine: 0x7fffd4,
azure: 0xf0ffff,
beige: 0xf5f5dc,
bisque: 0xffe4c4,
black: 0x000000,
blanchedalmond: 0xffebcd,
blue: 0x0000ff,
blueviolet: 0x8a2be2,
brown: 0xa52a2a,
burlywood: 0xdeb887,
cadetblue: 0x5f9ea0,
chartreuse: 0x7fff00,
chocolate: 0xd2691e,
coral: 0xff7f50,
cornflowerblue: 0x6495ed,
cornsilk: 0xfff8dc,
crimson: 0xdc143c,
cyan: 0x00ffff,
darkblue: 0x00008b,
darkcyan: 0x008b8b,
darkgoldenrod: 0xb8860b,
darkgray: 0xa9a9a9,
darkgreen: 0x006400,
darkgrey: 0xa9a9a9,
darkkhaki: 0xbdb76b,
darkmagenta: 0x8b008b,
darkolivegreen: 0x556b2f,
darkorange: 0xff8c00,
darkorchid: 0x9932cc,
darkred: 0x8b0000,
darksalmon: 0xe9967a,
darkseagreen: 0x8fbc8f,
darkslateblue: 0x483d8b,
darkslategray: 0x2f4f4f,
darkslategrey: 0x2f4f4f,
darkturquoise: 0x00ced1,
darkviolet: 0x9400d3,
deeppink: 0xff1493,
deepskyblue: 0x00bfff,
dimgray: 0x696969,
dimgrey: 0x696969,
dodgerblue: 0x1e90ff,
firebrick: 0xb22222,
floralwhite: 0xfffaf0,
forestgreen: 0x228b22,
fuchsia: 0xff00ff,
gainsboro: 0xdcdcdc,
ghostwhite: 0xf8f8ff,
gold: 0xffd700,
goldenrod: 0xdaa520,
gray: 0x808080,
green: 0x008000,
greenyellow: 0xadff2f,
grey: 0x808080,
honeydew: 0xf0fff0,
hotpink: 0xff69b4,
indianred: 0xcd5c5c,
indigo: 0x4b0082,
ivory: 0xfffff0,
khaki: 0xf0e68c,
lavender: 0xe6e6fa,
lavenderblush: 0xfff0f5,
lawngreen: 0x7cfc00,
lemonchiffon: 0xfffacd,
lightblue: 0xadd8e6,
lightcoral: 0xf08080,
lightcyan: 0xe0ffff,
lightgoldenrodyellow: 0xfafad2,
lightgray: 0xd3d3d3,
lightgreen: 0x90ee90,
lightgrey: 0xd3d3d3,
lightpink: 0xffb6c1,
lightsalmon: 0xffa07a,
lightseagreen: 0x20b2aa,
lightskyblue: 0x87cefa,
lightslategray: 0x778899,
lightslategrey: 0x778899,
lightsteelblue: 0xb0c4de,
lightyellow: 0xffffe0,
lime: 0x00ff00,
limegreen: 0x32cd32,
linen: 0xfaf0e6,
magenta: 0xff00ff,
maroon: 0x800000,
mediumaquamarine: 0x66cdaa,
mediumblue: 0x0000cd,
mediumorchid: 0xba55d3,
mediumpurple: 0x9370db,
mediumseagreen: 0x3cb371,
mediumslateblue: 0x7b68ee,
mediumspringgreen: 0x00fa9a,
mediumturquoise: 0x48d1cc,
mediumvioletred: 0xc71585,
midnightblue: 0x191970,
mintcream: 0xf5fffa,
mistyrose: 0xffe4e1,
moccasin: 0xffe4b5,
navajowhite: 0xffdead,
navy: 0x000080,
oldlace: 0xfdf5e6,
olive: 0x808000,
olivedrab: 0x6b8e23,
orange: 0xffa500,
orangered: 0xff4500,
orchid: 0xda70d6,
palegoldenrod: 0xeee8aa,
palegreen: 0x98fb98,
paleturquoise: 0xafeeee,
palevioletred: 0xdb7093,
papayawhip: 0xffefd5,
peachpuff: 0xffdab9,
peru: 0xcd853f,
pink: 0xffc0cb,
plum: 0xdda0dd,
powderblue: 0xb0e0e6,
purple: 0x800080,
rebeccapurple: 0x663399,
red: 0xff0000,
rosybrown: 0xbc8f8f,
royalblue: 0x4169e1,
saddlebrown: 0x8b4513,
salmon: 0xfa8072,
sandybrown: 0xf4a460,
seagreen: 0x2e8b57,
seashell: 0xfff5ee,
sienna: 0xa0522d,
silver: 0xc0c0c0,
skyblue: 0x87ceeb,
slateblue: 0x6a5acd,
slategray: 0x708090,
slategrey: 0x708090,
snow: 0xfffafa,
springgreen: 0x00ff7f,
steelblue: 0x4682b4,
tan: 0xd2b48c,
teal: 0x008080,
thistle: 0xd8bfd8,
tomato: 0xff6347,
turquoise: 0x40e0d0,
violet: 0xee82ee,
wheat: 0xf5deb3,
white: 0xffffff,
whitesmoke: 0xf5f5f5,
yellow: 0xffff00,
yellowgreen: 0x9acd32
};
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, {
displayable: function() {
return this.rgb().displayable();
},
hex: function() {
return this.rgb().hex();
},
toString: function() {
return this.rgb() + "";
}
});
function color(format) {
var m;
format = (format + "").trim().toLowerCase();
return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1)) // #f00
: (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
: (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
: named.hasOwnProperty(format) ? rgbn(named[format])
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
: null;
}
function rgbn(n) {
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
}
function rgba(r, g, b, a) {
if (a <= 0) r = g = b = NaN;
return new Rgb(r, g, b, a);
}
function rgbConvert(o) {
if (!(o instanceof Color)) o = color(o);
if (!o) return new Rgb;
o = o.rgb();
return new Rgb(o.r, o.g, o.b, o.opacity);
}
function rgb(r, g, b, opacity) {
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
}
function Rgb(r, g, b, opacity) {
this.r = +r;
this.g = +g;
this.b = +b;
this.opacity = +opacity;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
brighter: function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
darker: function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
rgb: function() {
return this;
},
displayable: function() {
return (0 <= this.r && this.r <= 255)
&& (0 <= this.g && this.g <= 255)
&& (0 <= this.b && this.b <= 255)
&& (0 <= this.opacity && this.opacity <= 1);
},
hex: function() {
return "#" + hex(this.r) + hex(this.g) + hex(this.b);
},
toString: function() {
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
return (a === 1 ? "rgb(" : "rgba(")
+ Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
+ Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
+ Math.max(0, Math.min(255, Math.round(this.b) || 0))
+ (a === 1 ? ")" : ", " + a + ")");
}
}));
function hex(value) {
value = Math.max(0, Math.min(255, Math.round(value) || 0));
return (value < 16 ? "0" : "") + value.toString(16);
}
function hsla(h, s, l, a) {
if (a <= 0) h = s = l = NaN;
else if (l <= 0 || l >= 1) h = s = NaN;
else if (s <= 0) h = NaN;
return new Hsl(h, s, l, a);
}
function hslConvert(o) {
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
if (!(o instanceof Color)) o = color(o);
if (!o) return new Hsl;
if (o instanceof Hsl) return o;
o = o.rgb();
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
min = Math.min(r, g, b),
max = Math.max(r, g, b),
h = NaN,
s = max - min,
l = (max + min) / 2;
if (s) {
if (r === max) h = (g - b) / s + (g < b) * 6;
else if (g === max) h = (b - r) / s + 2;
else h = (r - g) / s + 4;
s /= l < 0.5 ? max + min : 2 - max - min;
h *= 60;
} else {
s = l > 0 && l < 1 ? 0 : h;
}
return new Hsl(h, s, l, o.opacity);
}
function hsl(h, s, l, opacity) {
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
}
function Hsl(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
brighter: function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
darker: function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
rgb: function() {
var h = this.h % 360 + (this.h < 0) * 360,
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
l = this.l,
m2 = l + (l < 0.5 ? l : 1 - l) * s,
m1 = 2 * l - m2;
return new Rgb(
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
hsl2rgb(h, m1, m2),
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
this.opacity
);
},
displayable: function() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
&& (0 <= this.l && this.l <= 1)
&& (0 <= this.opacity && this.opacity <= 1);
}
}));
/* From FvD 13.37, CSS Color Module Level 3 */
function hsl2rgb(h, m1, m2) {
return (h < 60 ? m1 + (m2 - m1) * h / 60
: h < 180 ? m2
: h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
: m1) * 255;
}
/***/ }),
/* 84 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = extend;
/* harmony default export */ __webpack_exports__["a"] = (function(constructor, factory, prototype) {
constructor.prototype = factory.prototype = prototype;
prototype.constructor = constructor;
});
function extend(parent, definition) {
var prototype = Object.create(parent.prototype);
for (var key in definition) prototype[key] = definition[key];
return prototype;
}
/***/ }),
/* 85 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = basis;
function basis(t1, v0, v1, v2, v3) {
var t2 = t1 * t1, t3 = t2 * t1;
return ((1 - 3 * t1 + 3 * t2 - t3) * v0
+ (4 - 6 * t2 + 3 * t3) * v1
+ (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
+ t3 * v3) / 6;
}
/* harmony default export */ __webpack_exports__["a"] = (function(values) {
var n = values.length - 1;
return function(t) {
var i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
v1 = values[i],
v2 = values[i + 1],
v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
return basis((t - i / n) * n, v0, v1, v2, v3);
};
});
/***/ }),
/* 86 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(199);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(194);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(197);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(198);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(200);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(196);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var t = typeof b, c;
return b == null || t === "boolean" ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b)
: (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */]
: t === "string" ? ((c = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */])
: b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]
: b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */]
: Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */]
: typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */]
: __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b);
});
/***/ }),
/* 87 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = basis;
function basis(t1, v0, v1, v2, v3) {
var t2 = t1 * t1, t3 = t2 * t1;
return ((1 - 3 * t1 + 3 * t2 - t3) * v0
+ (4 - 6 * t2 + 3 * t3) * v1
+ (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
+ t3 * v3) / 6;
}
/* harmony default export */ __webpack_exports__["a"] = (function(values) {
var n = values.length - 1;
return function(t) {
var i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
v1 = values[i],
v2 = values[i + 1],
v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
return basis((t - i / n) * n, v0, v1, v2, v3);
};
});
/***/ }),
/* 88 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(89);
/* unused harmony reexport interpolate */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__array__ = __webpack_require__(201);
/* unused harmony reexport interpolateArray */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basis__ = __webpack_require__(87);
/* unused harmony reexport interpolateBasis */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__basisClosed__ = __webpack_require__(202);
/* unused harmony reexport interpolateBasisClosed */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__date__ = __webpack_require__(204);
/* unused harmony reexport interpolateDate */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__discrete__ = __webpack_require__(450);
/* unused harmony reexport interpolateDiscrete */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__hue__ = __webpack_require__(453);
/* unused harmony reexport interpolateHue */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__number__ = __webpack_require__(56);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_7__number__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__object__ = __webpack_require__(205);
/* unused harmony reexport interpolateObject */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__round__ = __webpack_require__(457);
/* unused harmony reexport interpolateRound */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__string__ = __webpack_require__(207);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_10__string__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__transform_index__ = __webpack_require__(459);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_11__transform_index__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_11__transform_index__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__zoom__ = __webpack_require__(461);
/* unused harmony reexport interpolateZoom */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__rgb__ = __webpack_require__(206);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_13__rgb__["a"]; });
/* unused harmony reexport interpolateRgbBasis */
/* unused harmony reexport interpolateRgbBasisClosed */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__hsl__ = __webpack_require__(452);
/* unused harmony reexport interpolateHsl */
/* unused harmony reexport interpolateHslLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__lab__ = __webpack_require__(454);
/* unused harmony reexport interpolateLab */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__hcl__ = __webpack_require__(451);
/* unused harmony reexport interpolateHcl */
/* unused harmony reexport interpolateHclLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__cubehelix__ = __webpack_require__(449);
/* unused harmony reexport interpolateCubehelix */
/* unused harmony reexport interpolateCubehelixLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__piecewise__ = __webpack_require__(455);
/* unused harmony reexport piecewise */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__quantize__ = __webpack_require__(456);
/* unused harmony reexport quantize */
/***/ }),
/* 89 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(206);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(201);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(204);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(56);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(205);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(207);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(203);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var t = typeof b, c;
return b == null || t === "boolean" ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b)
: (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */]
: t === "string" ? ((c = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */])
: b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]
: b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */]
: Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */]
: typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */]
: __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b);
});
/***/ }),
/* 90 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__namespaces__ = __webpack_require__(91);
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
var prefix = name += "", i = prefix.indexOf(":");
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
return __WEBPACK_IMPORTED_MODULE_0__namespaces__["a" /* default */].hasOwnProperty(prefix) ? {space: __WEBPACK_IMPORTED_MODULE_0__namespaces__["a" /* default */][prefix], local: name} : name;
});
/***/ }),
/* 91 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return xhtml; });
var xhtml = "http://www.w3.org/1999/xhtml";
/* harmony default export */ __webpack_exports__["a"] = ({
svg: "http://www.w3.org/2000/svg",
xhtml: xhtml,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
});
/***/ }),
/* 92 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return event; });
/* harmony export (immutable) */ __webpack_exports__["b"] = customEvent;
var filterEvents = {};
var event = null;
if (typeof document !== "undefined") {
var element = document.documentElement;
if (!("onmouseenter" in element)) {
filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
}
}
function filterContextListener(listener, index, group) {
listener = contextListener(listener, index, group);
return function(event) {
var related = event.relatedTarget;
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
listener.call(this, event);
}
};
}
function contextListener(listener, index, group) {
return function(event1) {
var event0 = event; // Events can be reentrant (e.g., focus).
event = event1;
try {
listener.call(this, this.__data__, index, group);
} finally {
event = event0;
}
};
}
function parseTypenames(typenames) {
return typenames.trim().split(/^|\s+/).map(function(t) {
var name = "", i = t.indexOf(".");
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
return {type: t, name: name};
});
}
function onRemove(typename) {
return function() {
var on = this.__on;
if (!on) return;
for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
this.removeEventListener(o.type, o.listener, o.capture);
} else {
on[++i] = o;
}
}
if (++i) on.length = i;
else delete this.__on;
};
}
function onAdd(typename, value, capture) {
var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
return function(d, i, group) {
var on = this.__on, o, listener = wrap(value, i, group);
if (on) for (var j = 0, m = on.length; j < m; ++j) {
if ((o = on[j]).type === typename.type && o.name === typename.name) {
this.removeEventListener(o.type, o.listener, o.capture);
this.addEventListener(o.type, o.listener = listener, o.capture = capture);
o.value = value;
return;
}
}
this.addEventListener(typename.type, listener, capture);
o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
if (!on) this.__on = [o];
else on.push(o);
};
}
/* harmony default export */ __webpack_exports__["c"] = (function(typename, value, capture) {
var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
if (arguments.length < 2) {
var on = this.node().__on;
if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
for (i = 0, o = on[j]; i < n; ++i) {
if ((t = typenames[i]).type === o.type && t.name === o.name) {
return o.value;
}
}
}
return;
}
on = value ? onAdd : onRemove;
if (capture == null) capture = false;
for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
return this;
});
function customEvent(event1, listener, that, args) {
var event0 = event;
event1.sourceEvent = event;
event = event1;
try {
return listener.apply(that, args);
} finally {
event = event0;
}
}
/***/ }),
/* 93 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function none() {}
/* harmony default export */ __webpack_exports__["a"] = (function(selector) {
return selector == null ? none : function() {
return this.querySelector(selector);
};
});
/***/ }),
/* 94 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__selection_on__ = __webpack_require__(92);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var current = __WEBPACK_IMPORTED_MODULE_0__selection_on__["a" /* event */], source;
while (source = current.sourceEvent) current = source;
return current;
});
/***/ }),
/* 95 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(node) {
return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView; // node is a Document
});
/***/ }),
/* 96 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(97);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return __WEBPACK_IMPORTED_MODULE_0__timer__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timer", function() { return __WEBPACK_IMPORTED_MODULE_0__timer__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timerFlush", function() { return __WEBPACK_IMPORTED_MODULE_0__timer__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__timeout__ = __webpack_require__(498);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return __WEBPACK_IMPORTED_MODULE_1__timeout__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__interval__ = __webpack_require__(497);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interval", function() { return __WEBPACK_IMPORTED_MODULE_2__interval__["a"]; });
/***/ }),
/* 97 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = now;
/* harmony export (immutable) */ __webpack_exports__["d"] = Timer;
/* harmony export (immutable) */ __webpack_exports__["b"] = timer;
/* harmony export (immutable) */ __webpack_exports__["c"] = timerFlush;
var frame = 0, // is an animation frame pending?
timeout = 0, // is a timeout pending?
interval = 0, // are any timers active?
pokeDelay = 1000, // how frequently we check for clock skew
taskHead,
taskTail,
clockLast = 0,
clockNow = 0,
clockSkew = 0,
clock = typeof performance === "object" && performance.now ? performance : Date,
setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
function now() {
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
}
function clearNow() {
clockNow = 0;
}
function Timer() {
this._call =
this._time =
this._next = null;
}
Timer.prototype = timer.prototype = {
constructor: Timer,
restart: function(callback, delay, time) {
if (typeof callback !== "function") throw new TypeError("callback is not a function");
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
if (!this._next && taskTail !== this) {
if (taskTail) taskTail._next = this;
else taskHead = this;
taskTail = this;
}
this._call = callback;
this._time = time;
sleep();
},
stop: function() {
if (this._call) {
this._call = null;
this._time = Infinity;
sleep();
}
}
};
function timer(callback, delay, time) {
var t = new Timer;
t.restart(callback, delay, time);
return t;
}
function timerFlush() {
now(); // Get the current time, if not already set.
++frame; // Pretend we’ve set an alarm, if we haven’t already.
var t = taskHead, e;
while (t) {
if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
t = t._next;
}
--frame;
}
function wake() {
clockNow = (clockLast = clock.now()) + clockSkew;
frame = timeout = 0;
try {
timerFlush();
} finally {
frame = 0;
nap();
clockNow = 0;
}
}
function poke() {
var now = clock.now(), delay = now - clockLast;
if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
}
function nap() {
var t0, t1 = taskHead, t2, time = Infinity;
while (t1) {
if (t1._call) {
if (time > t1._time) time = t1._time;
t0 = t1, t1 = t1._next;
} else {
t2 = t1._next, t1._next = null;
t1 = t0 ? t0._next = t2 : taskHead = t2;
}
}
taskTail = t0;
sleep(time);
}
function sleep(time) {
if (frame) return; // Soonest alarm already set, or will be.
if (timeout) timeout = clearTimeout(timeout);
var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
if (delay > 24) {
if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
if (interval) interval = clearInterval(interval);
} else {
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
frame = 1, setFrame(wake);
}
}
/***/ }),
/* 98 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/*!
* EventEmitter v5.1.0 - git.io/ee
* Unlicense - http://unlicense.org/
* Oliver Caldwell - http://oli.me.uk/
* @preserve
*/
;(function (exports) {
'use strict';
/**
* Class for managing events.
* Can be extended to provide event functionality in other classes.
*
* @class EventEmitter Manages event registering and emitting.
*/
function EventEmitter() {}
// Shortcuts to improve speed and size
var proto = EventEmitter.prototype;
var originalGlobalValue = exports.EventEmitter;
/**
* Finds the index of the listener for the event in its storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
* @return {Number} Index of the specified listener, -1 if not found
* @api private
*/
function indexOfListener(listeners, listener) {
var i = listeners.length;
while (i--) {
if (listeners[i].listener === listener) {
return i;
}
}
return -1;
}
/**
* Alias a method while keeping the context correct, to allow for overwriting of target method.
*
* @param {String} name The name of the target method.
* @return {Function} The aliased method
* @api private
*/
function alias(name) {
return function aliasClosure() {
return this[name].apply(this, arguments);
};
}
/**
* Returns the listener array for the specified event.
* Will initialise the event object and listener arrays if required.
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
* Each property in the object response is an array of listener functions.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Function[]|Object} All listener functions for the event.
*/
proto.getListeners = function getListeners(evt) {
var events = this._getEvents();
var response;
var key;
// Return a concatenated array of all matching events if
// the selector is a regular expression.
if (evt instanceof RegExp) {
response = {};
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
response[key] = events[key];
}
}
}
else {
response = events[evt] || (events[evt] = []);
}
return response;
};
/**
* Takes a list of listener objects and flattens it into a list of listener functions.
*
* @param {Object[]} listeners Raw listener objects.
* @return {Function[]} Just the listener functions.
*/
proto.flattenListeners = function flattenListeners(listeners) {
var flatListeners = [];
var i;
for (i = 0; i < listeners.length; i += 1) {
flatListeners.push(listeners[i].listener);
}
return flatListeners;
};
/**
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Object} All listener functions for an event in an object.
*/
proto.getListenersAsObject = function getListenersAsObject(evt) {
var listeners = this.getListeners(evt);
var response;
if (listeners instanceof Array) {
response = {};
response[evt] = listeners;
}
return response || listeners;
};
function isValidListener (listener) {
if (typeof listener === 'function' || listener instanceof RegExp) {
return true
} else if (listener && typeof listener === 'object') {
return isValidListener(listener.listener)
} else {
return false
}
}
/**
* Adds a listener function to the specified event.
* The listener will not be added if it is a duplicate.
* If the listener returns true then it will be removed after it is called.
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListener = function addListener(evt, listener) {
if (!isValidListener(listener)) {
throw new TypeError('listener must be a function');
}
var listeners = this.getListenersAsObject(evt);
var listenerIsWrapped = typeof listener === 'object';
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
listeners[key].push(listenerIsWrapped ? listener : {
listener: listener,
once: false
});
}
}
return this;
};
/**
* Alias of addListener
*/
proto.on = alias('addListener');
/**
* Semi-alias of addListener. It will add a listener that will be
* automatically removed after its first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addOnceListener = function addOnceListener(evt, listener) {
return this.addListener(evt, {
listener: listener,
once: true
});
};
/**
* Alias of addOnceListener.
*/
proto.once = alias('addOnceListener');
/**
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
* You need to tell it what event names should be matched by a regex.
*
* @param {String} evt Name of the event to create.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvent = function defineEvent(evt) {
this.getListeners(evt);
return this;
};
/**
* Uses defineEvent to define multiple events.
*
* @param {String[]} evts An array of event names to define.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvents = function defineEvents(evts) {
for (var i = 0; i < evts.length; i += 1) {
this.defineEvent(evts[i]);
}
return this;
};
/**
* Removes a listener function from the specified event.
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
*
* @param {String|RegExp} evt Name of the event to remove the listener from.
* @param {Function} listener Method to remove from the event.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListener = function removeListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var index;
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
index = indexOfListener(listeners[key], listener);
if (index !== -1) {
listeners[key].splice(index, 1);
}
}
}
return this;
};
/**
* Alias of removeListener
*/
proto.off = alias('removeListener');
/**
* Adds listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
* You can also pass it a regular expression to add the array of listeners to all events that match it.
* Yeah, this function does quite a bit. That's probably a bad thing.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListeners = function addListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(false, evt, listeners);
};
/**
* Removes listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be removed.
* You can also pass it a regular expression to remove the listeners from all events that match it.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListeners = function removeListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(true, evt, listeners);
};
/**
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
* The first argument will determine if the listeners are removed (true) or added (false).
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be added/removed.
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
*
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
var i;
var value;
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
// If evt is an object then pass each of its properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
// Pass the single listener straight through to the singular method
if (typeof value === 'function') {
single.call(this, i, value);
}
else {
// Otherwise pass back to the multiple function
multiple.call(this, i, value);
}
}
}
}
else {
// So evt must be a string
// And listeners must be an array of listeners
// Loop over it and pass each one to the multiple method
i = listeners.length;
while (i--) {
single.call(this, evt, listeners[i]);
}
}
return this;
};
/**
* Removes all listeners from a specified event.
* If you do not specify an event then all listeners will be removed.
* That means every event will be emptied.
* You can also pass a regex to remove all events that match it.
*
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeEvent = function removeEvent(evt) {
var type = typeof evt;
var events = this._getEvents();
var key;
// Remove different things depending on the state of evt
if (type === 'string') {
// Remove all listeners for the specified event
delete events[evt];
}
else if (evt instanceof RegExp) {
// Remove all events matching the regex.
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
delete events[key];
}
}
}
else {
// Remove all listeners in all events
delete this._events;
}
return this;
};
/**
* Alias of removeEvent.
*
* Added to mirror the node API.
*/
proto.removeAllListeners = alias('removeEvent');
/**
* Emits an event of your choice.
* When emitted, every listener attached to that event will be executed.
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
* So they will not arrive within the array on the other side, they will be separate.
* You can also pass a regular expression to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {Array} [args] Optional array of arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emitEvent = function emitEvent(evt, args) {
var listenersMap = this.getListenersAsObject(evt);
var listeners;
var listener;
var i;
var key;
var response;
for (key in listenersMap) {
if (listenersMap.hasOwnProperty(key)) {
listeners = listenersMap[key].slice(0);
for (i = 0; i < listeners.length; i++) {
// If the listener returns true then it shall be removed from the event
// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[i];
if (listener.once === true) {
this.removeListener(evt, listener.listener);
}
response = listener.listener.apply(this, args || []);
if (response === this._getOnceReturnValue()) {
this.removeListener(evt, listener.listener);
}
}
}
}
return this;
};
/**
* Alias of emitEvent
*/
proto.trigger = alias('emitEvent');
/**
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {...*} Optional additional arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emit = function emit(evt) {
var args = Array.prototype.slice.call(arguments, 1);
return this.emitEvent(evt, args);
};
/**
* Sets the current value to check against when executing listeners. If a
* listeners return value matches the one set here then it will be removed
* after execution. This value defaults to true.
*
* @param {*} value The new value to check for when executing listeners.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.setOnceReturnValue = function setOnceReturnValue(value) {
this._onceReturnValue = value;
return this;
};
/**
* Fetches the current value to check against when executing listeners. If
* the listeners return value matches this one then it should be removed
* automatically. It will return true by default.
*
* @return {*|Boolean} The current value to check for or the default, true.
* @api private
*/
proto._getOnceReturnValue = function _getOnceReturnValue() {
if (this.hasOwnProperty('_onceReturnValue')) {
return this._onceReturnValue;
}
else {
return true;
}
};
/**
* Fetches the events object and creates one if required.
*
* @return {Object} The events storage object.
* @api private
*/
proto._getEvents = function _getEvents() {
return this._events || (this._events = {});
};
/**
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
*
* @return {Function} Non conflicting EventEmitter class.
*/
EventEmitter.noConflict = function noConflict() {
exports.EventEmitter = originalGlobalValue;
return EventEmitter;
};
// Expose the class either via AMD, CommonJS or the global object
if (true) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
return EventEmitter;
}.call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
else if (typeof module === 'object' && module.exports){
module.exports = EventEmitter;
}
else {
exports.EventEmitter = EventEmitter;
}
}(this || {}));
/***/ }),
/* 99 */
/***/ (function(module, exports, __webpack_require__) {
var DEFAULT_Y = 0; // 默认的y的值
var each = __webpack_require__(2);
var ArrayUtil = {
values: __webpack_require__(73)
};
module.exports = {
/**
* 对应的维度是否可以调整
* @protected
* @param {String} dimName 可以调整的维度 x,y
* @return {Boolean} 是否可以调整
*/
isAdjust: function isAdjust(dimName) {
return this.adjustNames.indexOf(dimName) >= 0;
},
/**
* @protected
* 获取可调整度量对应的值
* @param {Frame} mergeData 数据
* @return {Object} 值的映射
*/
_getDimValues: function _getDimValues(mergeData) {
var self = this;
var valuesMap = {};
var dims = [];
if (self.xField && self.isAdjust('x')) {
dims.push(self.xField);
}
if (self.yField && self.isAdjust('y')) {
dims.push(self.yField);
}
each(dims, function (dim) {
var values = ArrayUtil.values(mergeData, dim);
values.sort(function (v1, v2) {
return v1 - v2;
});
valuesMap[dim] = values;
});
if (!self.yField && self.isAdjust('y')) {
// 只有一维的情况下,同时调整y
var dim = 'y';
var values = [DEFAULT_Y, 1]; // 默认分布在y轴的 0.1 与 0.2 之间
valuesMap[dim] = values;
}
return valuesMap;
},
adjustData: function adjustData(dataArray, mergeData) {
var self = this;
var valuesMap = self._getDimValues(mergeData);
each(dataArray, function (data, index) {
// 遍历所有数据集合
each(valuesMap, function (values, dim) {
// 根据不同的度量分别调整位置
self.adjustDim(dim, values, data, dataArray.length, index);
});
});
},
getAdjustRange: function getAdjustRange(dim, key, values) {
var self = this;
var index = values.indexOf(key);
var length = values.length;
var pre;
var next;
if (!self.yField && self.isAdjust('y')) {
pre = 0;
next = 1;
} else if (length > 1) {
pre = index === 0 ? values[0] : values[index - 1];
next = index === length - 1 ? values[length - 1] : values[index + 1];
if (index !== 0) {
pre += (key - pre) / 2;
} else {
pre -= (next - key) / 2;
}
if (index !== length - 1) {
next -= (next - key) / 2;
} else {
next += (key - values[length - 2]) / 2;
}
} else {
pre = key === 0 ? 0 : key - 0.5;
next = key === 0 ? 1 : key + 0.5;
}
return {
pre: pre,
next: next
};
},
/**
* 对数据进行分组
* @param {Array} data 数据
* @param {String} dim 分组的字段
* @return {Object} 分组的键值对映射
*/
groupData: function groupData(data, dim) {
var groups = {};
each(data, function (record) {
var value = record[dim];
if (value === undefined) {
value = record[dim] = DEFAULT_Y;
}
if (!groups[value]) {
groups[value] = [];
}
groups[value].push(record);
});
return groups;
}
};
/***/ }),
/* 100 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 颜色计算的辅助方法
* @author dxq613@gmail.com
*/
var isNumber = __webpack_require__(11);
var isString = __webpack_require__(15);
var each = __webpack_require__(2); // const RGB_REG = /rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
var RGB_REG = /rgba?\(([\s.,0-9]+)\)/; // 创建辅助 tag 取颜色
function createTmp() {
var i = document.createElement('i');
i.title = 'Web Colour Picker';
i.style.display = 'none';
document.body.appendChild(i);
return i;
} // 获取颜色之间的插值
function getValue(start, end, percent, index) {
var value = start[index] + (end[index] - start[index]) * percent;
return value;
} // 数组转换成颜色
function arr2rgb(arr) {
return '#' + toHex(arr[0]) + toHex(arr[1]) + toHex(arr[2]);
} // 将数值从 0-255 转换成16进制字符串
function toHex(value) {
value = Math.round(value);
value = value.toString(16);
if (value.length === 1) {
value = '0' + value;
}
return value;
}
function calColor(colors, percent) {
if (isNaN(percent) || !isNumber(percent) || percent < 0) {
percent = 0;
}
if (percent > 1) {
percent = 1;
}
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 = arr2rgb([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
return rgb;
} // rgb 颜色转换成数组
function rgb2arr(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 = {};
var iEl = null;
var ColorUtil = {
/**
* 将颜色转换到 rgb 的格式
* @param {String} color 颜色
* @return {String} 将颜色转换到 '#ffffff' 的格式
*/
toRGB: function toRGB(color) {
// 如果已经是 rgb的格式
if (color[0] === '#' && color.length === 7) {
return color;
}
if (!iEl) {
// 防止防止在页头报错
iEl = createTmp();
}
var rst;
if (colorCache[color]) {
rst = colorCache[color];
} else {
iEl.style.color = color;
rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color');
var matchs = RGB_REG.exec(rst);
var cArray = matchs[1].split(/\s*,\s*/);
rst = arr2rgb(cArray);
colorCache[color] = rst;
}
return rst;
},
rgb2arr: rgb2arr,
/**
* 获取渐变函数
* @param {Array} colors 多个颜色
* @return {String} 颜色值
*/
gradient: function gradient(colors) {
var points = [];
if (isString(colors)) {
colors = colors.split('-');
}
each(colors, function (color) {
if (color.indexOf('#') === -1) {
color = ColorUtil.toRGB(color);
}
points.push(rgb2arr(color));
});
return function (percent) {
return calColor(points, percent);
};
}
};
module.exports = ColorUtil;
/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var _require = __webpack_require__(35),
Group = _require.Group;
var Util = __webpack_require__(3);
var Grid =
/*#__PURE__*/
function (_Group) {
_inheritsLoose(Grid, _Group);
function Grid() {
return _Group.apply(this, arguments) || this;
}
var _proto = Grid.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
// const cfg = super.getDefaultCfg();
return {
zIndex: 1,
/**
* 栅格线的类型
* - line 不封闭的线
* - polygon 封闭的多边形
* @type {String}
*/
type: 'line',
/**
* 线的样式配置
* @type {Object}
*/
lineStyle: null,
/**
* 线集合的配置
* @type {Array}
*/
items: null,
/**
* 为网格设置交替的背景色,指定一个值则先渲染奇数层,两个值则交替渲染
* @type {String | Array}
*/
alternateColor: null,
matrix: null,
/**
* 是否隐藏第一条网格线,默认为 false
* @type {Boolean}
*/
hideFirstLine: false,
/**
* 是否隐藏最后一条网格线,默认为 false
* @type {Boolean}
*/
hideLastLine: false,
/**
* 0基线不在轴线上时,是否强调0基线
* @type {Boolean}
*/
hightLightZero: false,
/**
* 0基线样式
* @type {Object}
*/
zeroLineStyle: {
stroke: '#595959',
lineDash: [0, 0]
}
};
};
_proto._renderUI = function _renderUI() {
_Group.prototype._renderUI.call(this);
this._drawLines();
};
_proto._drawLines = function _drawLines() {
var self = this;
var lineStyle = self.get('lineStyle');
var items = self.get('items');
if (items && items.length) {
self._precessItems(items);
self._drawGridLines(items, lineStyle);
}
};
_proto._precessItems = function _precessItems(items) {
var self = this;
var preItem;
Util.each(items, function (item, index) {
if (preItem && self.get('alternateColor')) {
self._drawAlternativeBg(item, preItem, index);
}
preItem = item;
});
};
_proto._drawGridLines = function _drawGridLines(items, lineStyle) {
var self = this;
var type = this.get('type');
var gridLine;
var path;
var cfg;
var points;
var itemsLength = items.length;
if (type === 'line' || type === 'polygon') {
Util.each(items, function (item, idx) {
if (self.get('hideFirstLine') && idx === 0) {
// 不展示第一条网格线
return;
}
if (self.get('hideLastLine') && idx === itemsLength - 1) {
// 不展示最后一条网格线
return;
}
points = item.points;
path = [];
if (type === 'line') {
path.push(['M', points[0].x, points[0].y]);
path.push(['L', points[points.length - 1].x, points[points.length - 1].y]);
} else {
Util.each(points, function (point, index) {
if (index === 0) {
path.push(['M', point.x, point.y]);
} else {
path.push(['L', point.x, point.y]);
}
});
}
if (self._drawZeroLine(type, idx)) {
cfg = Util.mix({}, self.get('zeroLineStyle'), {
path: path
});
} else {
cfg = Util.mix({}, lineStyle, {
path: path
});
}
gridLine = self.addShape('path', {
attrs: cfg
});
gridLine.name = 'axis-grid';
gridLine._id = item._id;
gridLine.set('coord', self.get('coord'));
self.get('appendInfo') && gridLine.setSilent('appendInfo', self.get('appendInfo'));
});
} else {
Util.each(items, function (item, idx) {
if (self.get('hideFirstLine') && idx === 0) {
// 不展示第一条网格线
return;
}
if (self.get('hideLastLine') && idx === itemsLength - 1) {
// 不展示最后一条网格线
return;
}
points = item.points;
path = [];
Util.each(points, function (point, index) {
var radius = point.radius;
if (index === 0) {
path.push(['M', point.x, point.y]);
} else {
path.push(['A', radius, radius, 0, 0, point.flag, point.x, point.y]);
}
});
cfg = Util.mix({}, lineStyle, {
path: path
});
gridLine = self.addShape('path', {
attrs: cfg
});
gridLine.name = 'axis-grid';
gridLine._id = item._id;
gridLine.set('coord', self.get('coord'));
self.get('appendInfo') && gridLine.setSilent('appendInfo', self.get('appendInfo'));
});
}
};
_proto._drawZeroLine = function _drawZeroLine(type, idx) {
var self = this;
var tickValues = self.get('tickValues');
if (type === 'line' && tickValues) {
if (tickValues[idx] === 0 && self.get('hightLightZero')) {
return true;
}
}
return false;
};
_proto._drawAlternativeBg = function _drawAlternativeBg(item, preItem, index) {
var self = this;
var alternateColor = self.get('alternateColor');
var attrs;
var oddColor;
var evenColor;
if (Util.isString(alternateColor)) {
oddColor = alternateColor;
} else if (Util.isArray(alternateColor)) {
oddColor = alternateColor[0];
evenColor = alternateColor[1];
}
if (index % 2 === 0) {
if (evenColor) {
attrs = self._getBackItem(preItem.points, item.points, evenColor);
}
} else if (oddColor) {
attrs = self._getBackItem(preItem.points, item.points, oddColor);
}
var shape = self.addShape('Path', {
attrs: attrs
});
shape.name = 'axis-grid-rect';
shape._id = item._id && item._id.replace('grid', 'grid-rect');
shape.set('coord', self.get('coord'));
self.get('appendInfo') && shape.setSilent('appendInfo', self.get('appendInfo'));
};
_proto._getBackItem = function _getBackItem(start, end, bgColor) {
var path = [];
var type = this.get('type');
if (type === 'line') {
path.push(['M', start[0].x, start[0].y]);
path.push(['L', start[start.length - 1].x, start[start.length - 1].y]);
path.push(['L', end[end.length - 1].x, end[end.length - 1].y]);
path.push(['L', end[0].x, end[0].y]);
path.push(['Z']);
} else if (type === 'polygon') {
Util.each(start, function (subItem, index) {
if (index === 0) {
path.push(['M', subItem.x, subItem.y]);
} else {
path.push(['L', subItem.x, subItem.y]);
}
});
for (var i = end.length - 1; i >= 0; i--) {
path.push(['L', end[i].x, end[i].y]);
}
path.push(['Z']);
} else {
var flag = start[0].flag;
Util.each(start, function (subItem, index) {
var radius = subItem.radius;
if (index === 0) {
path.push(['M', subItem.x, subItem.y]);
} else {
path.push(['A', radius, radius, 0, 0, subItem.flag, subItem.x, subItem.y]);
}
});
for (var j = end.length - 1; j >= 0; j--) {
var endSubItem = end[j];
var endRadius = endSubItem.radius;
if (j === end.length - 1) {
path.push(['M', endSubItem.x, endSubItem.y]);
} else {
path.push(['A', endRadius, endRadius, 0, 0, flag === 1 ? 0 : 1, endSubItem.x, endSubItem.y]);
}
}
}
return {
fill: bgColor,
path: path
};
};
return Grid;
}(Group);
module.exports = Grid;
/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(3);
module.exports = {
getFirstScale: function getFirstScale(scales) {
var firstScale;
Util.each(scales, function (scale) {
if (scale) {
firstScale = scale;
return false;
}
});
return firstScale;
}
};
/***/ }),
/* 103 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var DomUtil = Util.DomUtil;
var Component = __webpack_require__(34);
var positionAdjust = __webpack_require__(248);
var spirialAdjust = __webpack_require__(249);
var bboxAdjust = __webpack_require__(247);
var LAYOUTS = {
scatter: positionAdjust,
map: spirialAdjust,
treemap: bboxAdjust
};
var Label =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Label, _Component);
function Label() {
return _Component.apply(this, arguments) || this;
}
var _proto = Label.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Component.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'label',
/**
* label类型
* @type {(String)}
*/
type: 'default',
/**
* 默认文本样式
* @type {Array}
*/
textStyle: null,
/**
* 文本显示格式化回调函数
* @type {Function}
*/
formatter: null,
/**
* 显示的文本集合
* @type {Array}
*/
items: null,
/**
* 是否使用html渲染label
* @type {String}
*/
useHtml: false,
/**
* html 渲染时用的容器的模板,必须存在 class = "g-labels"
* @type {String}
*/
containerTpl: '',
/**
* html 渲染时单个 label 的模板,必须存在 class = "g-label"
* @type {String}
*/
itemTpl: '{text}
',
/**
* label牵引线定义
* @type {String || Object}
*/
labelLine: false,
/**
* label牵引线容器
* @type Object
*/
lineGroup: null,
/**
* 需添加label的shape
* @type Object
*/
shapes: null,
/**
* 默认为true。为false时指定直接用items渲染文本,不进行config
* @type Object
*/
config: true,
/**
* 是否进行拾取
* @type Object
*/
capture: true
});
};
/*
* 清空label容器
*/
_proto.clear = function clear() {
var group = this.get('group');
var container = this.get('container');
if (group && !group.get('destroyed')) {
group.clear();
}
if (container) {
container.innerHTML = '';
}
_Component.prototype.clear.call(this);
};
/**
* 销毁group
*/
_proto.destroy = function destroy() {
var group = this.get('group');
var container = this.get('container');
if (!group.destroy) {
group.destroy();
}
if (container) {
container.innerHTML = '';
}
};
/**
* label绘制全过程
*/
_proto.render = function render() {
this.clear();
this._init();
this.beforeDraw();
this.draw();
this.afterDraw();
};
_proto._dryDraw = function _dryDraw() {
var self = this;
var items = self.get('items');
var children = self.getLabels();
var count = children.length;
Util.each(items, function (item, index) {
if (index < count) {
var label = children[index];
self.changeLabel(label, item);
} else {
var labelShape = self._addLabel(item, index);
if (labelShape) {
labelShape._id = item._id;
labelShape.set('coord', item.coord);
}
}
});
for (var i = count - 1; i >= items.length; i--) {
children[i].remove();
}
self._adjustLabels();
if (self.get('labelLine') || !self.get('config')) {
self.drawLines();
}
};
/**
* 更新label
* 1. 将items与group中的children对比,更新/新增/删除labels
* 2. labels布局优化
* 3. 画label连接线
* 4. 绘制到画布
*/
_proto.draw = function draw() {
this._dryDraw();
this.get('canvas').draw();
};
/*
* 更新label
* oldLabel shape或label dom
* newLabel label data
* index items中的下标
*/
_proto.changeLabel = function changeLabel(oldLabel, newLabel) {
if (!oldLabel) {
return;
}
if (oldLabel.tagName) {
var node = this._createDom(newLabel);
oldLabel.innerHTML = node.innerHTML;
this._setCustomPosition(newLabel, oldLabel);
} else {
oldLabel._id = newLabel._id;
oldLabel.attr('text', newLabel.text);
if (oldLabel.attr('x') !== newLabel.x || oldLabel.attr('y') !== newLabel.y) {
oldLabel.resetMatrix();
if (newLabel.textStyle.rotate) {
oldLabel.rotateAtStart(newLabel.textStyle.rotate);
delete newLabel.textStyle.rotate;
}
oldLabel.attr(newLabel);
}
}
};
/**
* 显示label
*/
_proto.show = function show() {
var group = this.get('group');
var container = this.get('container');
if (group) {
group.show();
}
if (container) {
container.style.opacity = 1;
}
};
/**
* 隐藏label
*/
_proto.hide = function hide() {
var group = this.get('group');
var container = this.get('container');
if (group) {
group.hide();
}
if (container) {
container.style.opacity = 0;
}
};
/**
* 画label连接线
*/
_proto.drawLines = function drawLines() {
var self = this;
var lineStyle = self.get('labelLine');
if (typeof lineStyle === 'boolean') {
self.set('labelLine', {});
}
var lineGroup = self.get('lineGroup');
if (!lineGroup || lineGroup.get('destroyed')) {
lineGroup = self.get('group').addGroup({
elCls: 'x-line-group'
});
self.set('lineGroup', lineGroup);
} else {
lineGroup.clear();
}
Util.each(self.get('items'), function (label) {
self.lineToLabel(label, lineGroup);
});
};
_proto.lineToLabel = function lineToLabel(label, lineGroup) {
var self = this;
if (!self.get('config') && !label.labelLine) {
return;
}
var lineStyle = label.labelLine || self.get('labelLine');
var capture = typeof label.capture === 'undefined' ? self.get('capture') : label.capture;
var path = lineStyle.path;
if (path && Util.isFunction(lineStyle.path)) {
path = lineStyle.path(label);
}
if (!path) {
var start = label.start || {
x: label.x - label._offset.x,
y: label.y - label._offset.y
};
path = [['M', start.x, start.y], ['L', label.x, label.y]];
}
var stroke = label.color;
if (!stroke) {
if (label.textStyle && label.textStyle.fill) {
stroke = label.textStyle.fill;
} else {
stroke = '#000';
}
}
var lineShape = lineGroup.addShape('path', {
attrs: Util.mix({
path: path,
fill: null,
stroke: stroke
}, lineStyle),
capture: capture
}); // label 对应线的动画关闭
lineShape.name = self.get('name'); // generate labelLine id according to label id
lineShape._id = label._id && label._id.replace('glabel', 'glabelline');
lineShape.set('coord', self.get('coord'));
}; // 根据type对label布局
_proto._adjustLabels = function _adjustLabels() {
var self = this;
var type = self.get('type');
var labels = self.getLabels();
var shapes = self.get('shapes');
var layout = LAYOUTS[type];
if (type === 'default' || !layout) {
return;
}
layout(labels, shapes);
};
/**
* 获取当前所有label实例
* @return {Array} 当前label实例
*/
_proto.getLabels = function getLabels() {
var container = this.get('container');
if (container) {
return Util.toArray(container.childNodes);
}
return this.get('group').get('children');
}; // 先计算label的所有配置项,然后生成label实例
_proto._addLabel = function _addLabel(item, index) {
var cfg = item;
if (this.get('config')) {
cfg = this._getLabelCfg(item, index);
}
return this._createText(cfg);
};
_proto._getLabelCfg = function _getLabelCfg(item, index) {
var textStyle = this.get('textStyle') || {};
var formatter = this.get('formatter');
var htmlTemplate = this.get('htmlTemplate');
if (!Util.isObject(item)) {
var tmp = item;
item = {};
item.text = tmp;
}
if (Util.isFunction(textStyle)) {
textStyle = textStyle(item.text, item, index);
}
if (formatter) {
item.text = formatter(item.text, item, index);
}
if (htmlTemplate) {
item.useHtml = true;
if (Util.isFunction(htmlTemplate)) {
item.text = htmlTemplate(item.text, item, index);
}
}
if (Util.isNil(item.text)) {
item.text = '';
}
item.text = item.text + ''; // ? 为什么转换为字符串
var cfg = Util.mix({}, item, {
textStyle: textStyle
}, {
x: item.x || 0,
y: item.y || 0
});
return cfg;
};
/**
* label初始化,主要针对html容器
*/
_proto._init = function _init() {
if (!this.get('group')) {
var group = this.get('canvas').addGroup({
id: 'label-group'
});
this.set('group', group);
}
};
_proto.initHtmlContainer = function initHtmlContainer() {
var container = this.get('container');
if (!container) {
var containerTpl = this.get('containerTpl');
var wrapper = this.get('canvas').get('el').parentNode;
container = DomUtil.createDom(containerTpl);
wrapper.style.position = 'relative';
wrapper.appendChild(container);
this.set('container', container);
} else if (Util.isString(container)) {
container = document.getElementById(container);
if (container) {
this.set('container', container);
}
}
return container;
}; // 分html dom和G shape两种情况生成label实例
_proto._createText = function _createText(cfg) {
var container = this.get('container');
var capture = typeof cfg.capture === 'undefined' ? this.get('capture') : cfg.capture;
var labelShape;
if (cfg.useHtml || cfg.htmlTemplate) {
if (!container) {
container = this.initHtmlContainer();
}
var node = this._createDom(cfg);
container.appendChild(node);
this._setCustomPosition(cfg, node);
} else {
var name = this.get('name');
var origin = cfg.point;
var group = this.get('group');
delete cfg.point; // 临时解决,否则影响动画
var rotate = cfg.rotate; // textStyle中的rotate虽然可以正常画出,但是在做动画的时候可能会导致动画异常。移出,在定义好shape后通过transform实现效果。
if (cfg.textStyle) {
if (cfg.textStyle.rotate) {
rotate = cfg.textStyle.rotate;
delete cfg.textStyle.rotate;
}
cfg = Util.mix({
x: cfg.x,
y: cfg.y,
textAlign: cfg.textAlign,
text: cfg.text
}, cfg.textStyle);
}
labelShape = group.addShape('text', {
attrs: cfg,
capture: capture
});
if (rotate) {
// rotate是用角度定义的,转换为弧度
if (Math.abs(rotate) > Math.PI * 2) {
rotate = rotate / 180 * Math.PI;
}
labelShape.transform([['t', -cfg.x, -cfg.y], ['r', rotate], ['t', cfg.x, cfg.y]]);
}
labelShape.setSilent('origin', origin || cfg);
labelShape.name = name; // 用于事件标注
this.get('appendInfo') && labelShape.setSilent('appendInfo', this.get('appendInfo'));
return labelShape;
}
};
_proto._createDom = function _createDom(cfg) {
var itemTpl = this.get('itemTpl');
var str = Util.substitute(itemTpl, {
text: cfg.text
});
return DomUtil.createDom(str);
}; // 根据文本对齐方式确定dom位置
_proto._setCustomPosition = function _setCustomPosition(cfg, htmlDom) {
var textAlign = cfg.textAlign || 'left';
var top = cfg.y;
var left = cfg.x;
var width = DomUtil.getOuterWidth(htmlDom);
var height = DomUtil.getOuterHeight(htmlDom);
top = top - height / 2;
if (textAlign === 'center') {
left = left - width / 2;
} else if (textAlign === 'right') {
left = left - width;
}
htmlDom.style.top = parseInt(top, 10) + 'px';
htmlDom.style.left = parseInt(left, 10) + 'px';
};
return Label;
}(Component);
module.exports = Label;
/***/ }),
/* 104 */
/***/ (function(module, exports) {
var Greedy =
/*#__PURE__*/
function () {
function Greedy() {
this.bitmap = [];
}
var _proto = Greedy.prototype;
_proto.hasGap = function hasGap(bbox) {
var hasGap = true;
var bitmap = this.bitmap;
var minX = Math.floor(bbox.minX);
var maxX = Math.ceil(bbox.maxX);
var minY = Math.floor(bbox.minY);
var maxY = Math.ceil(bbox.maxY) - 1;
for (var i = minX; i < maxX; i++) {
if (!bitmap[i]) {
bitmap[i] = [];
continue;
}
if (i === minX || i === maxX - 1) {
for (var j = minY; j <= maxY; j++) {
if (bitmap[i][j]) {
hasGap = false;
break;
}
}
} else {
if (bitmap[i][minY] || bitmap[i][maxY]) {
hasGap = false;
break;
}
}
}
return hasGap;
};
_proto.fillGap = function fillGap(bbox) {
var bitmap = this.bitmap;
var minX = Math.floor(bbox.minX);
var maxX = Math.ceil(bbox.maxX) - 1;
var minY = Math.floor(bbox.minY);
var maxY = Math.ceil(bbox.maxY) - 1;
for (var i = minX; i <= maxX; i++) {
for (var j = minY; j < maxY; j += 8) {
if (!bitmap[i]) {
bitmap[i] = [];
}
bitmap[i][j] = true;
}
bitmap[i][maxY] = true;
}
for (var _i = minY; _i <= maxY; _i++) {
bitmap[minX][_i] = true;
bitmap[maxX][_i] = true;
}
};
return Greedy;
}();
module.exports = Greedy;
/***/ }),
/* 105 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Component = __webpack_require__(34);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var Legend =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Legend, _Component);
var _proto = Legend.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
/**
* Group 容器
* @type {Object}
*/
container: null,
/**
* 图例标题配置
* @type {Object}
*/
title: null,
/**
* 图例项文本格式化
* @type {Function}
*/
formatter: null,
/**
* 鼠标 hover 到图例上的默认交互是否开启
* @type {Boolean}
*/
hoverable: true,
/**
* TODO:rename
* 图例标题距离图例项的距离
* @type {Number}
*/
titleGap: 15,
/**
* legend 相对于 container 的位置
* @type {Array}
*/
position: [0, 0],
/**
* legend 在 position 位置上的偏移量
* @type {Array}
*/
offset: [0, 0],
/**
* legend 在 position 位置上沿 x 轴的偏移量。若同时设置了 offset 和 offsetX, 以 offsetX 为准
* @type {Number}
*/
offsetX: null,
/**
* legend 在 position 位置上沿 y 轴的偏移量。若同时设置了 offset 和 offsetY, 以 offsetY 为准
* @type {Number}
*/
offsetY: null
};
};
function Legend(cfg) {
var _this;
_this = _Component.call(this, cfg) || this;
_this._init();
_this.beforeRender();
_this.render();
_this._adjustPositionOffset();
_this._bindEvents();
return _this;
}
_proto._init = function _init() {
var group = this.get('group');
var container = this.get('container');
this.set('canvas', container.get('canvas'));
var position = this.get('position');
if (!group) group = container.addGroup({
x: 0 - position[0],
y: 0 - position[1]
});
this.set('group', group);
};
_proto._adjustPositionOffset = function _adjustPositionOffset() {
var position = this.get('position');
var offset = this.get('offset');
var offsetX = this.get('offsetX');
var offsetY = this.get('offsetY');
if (!Util.isArray(offset)) {
var layout = this.get('layout');
offset = layout === 'vertical' ? [offset, 0] : [0, offset];
}
if (offsetX) offset[0] = offsetX;
if (offsetY) offset[1] = offsetY;
var bbox = this.get('group').getBBox();
this.move(-bbox.minX + position[0] + offset[0], -bbox.minY + position[1] + offset[1]);
};
_proto.beforeRender = function beforeRender() {
var group = this.get('group');
var itemsGroup = group.addGroup();
this.set('itemsGroup', itemsGroup);
};
_proto.render = function render() {
this._renderTitle();
}; // render the title of the legend
_proto._renderTitle = function _renderTitle() {
var title = this.get('title');
var titleGap = this.get('titleGap');
titleGap = titleGap || 0;
if (title && title.text) {
var group = this.get('group');
var titleShape = group.addShape('text', {
attrs: Util.mix({
x: 0,
y: 0 - titleGap,
fill: '#333',
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}, title)
});
titleShape.name = 'legend-title';
this.get('appendInfo') && titleShape.setSilent('appendInfo', this.get('appendInfo'));
this.set('titleShape', titleShape);
}
}; // return the count of checked items
_proto.getCheckedCount = function getCheckedCount() {
var itemsGroup = this.get('itemsGroup');
var items = itemsGroup.get('children');
var checkedArr = Util.filter(items, function (item) {
return item.get('checked');
});
return checkedArr.length;
}; // set items for the legend
_proto.setItems = function setItems(items) {
this.set('items', items);
this.clear();
this.render();
}; // add an item into the legend
_proto.addItem = function addItem(item) {
var items = this.get('items');
items.push(item);
this.clear();
this.render();
}; // clear all the items of the legend
_proto.clear = function clear() {
var itemsGroup = this.get('itemsGroup');
itemsGroup.clear();
var group = this.get('group');
group.clear();
this.beforeRender();
}; // destroy the legend
_proto.destroy = function destroy() {
var group = this.get('group');
group.destroy();
this._attrs = {};
this.removeAllListeners();
this.destroyed = true;
}; // return the width of the legend
_proto.getWidth = function getWidth() {
var bbox = this.get('group').getBBox();
return bbox.width;
}; // return the height of the legend
_proto.getHeight = function getHeight() {
var bbox = this.get('group').getBBox();
return bbox.height;
};
_proto.move = function move(x, y) {
this.get('group').move(x, y);
};
_proto.draw = function draw() {
this.get('canvas').draw();
};
return Legend;
}(Component);
module.exports = Legend;
/***/ }),
/* 106 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Category = __webpack_require__(107);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var DomUtil = Util.DomUtil;
var Group = Util.Group;
var CONTAINER_CLASS = 'g2-legend';
var TITLE_CLASS = 'g2-legend-title';
var LIST_CLASS = 'g2-legend-list';
var ITEM_CLASS = 'g2-legend-list-item';
var TEXT_CLASS = 'g2-legend-text';
var MARKER_CLASS = 'g2-legend-marker'; // find a dom node from the chidren of the node with className.
function findNodeByClass(node, className) {
return node.getElementsByClassName(className)[0];
}
function getParentNode(node, className) {
var nodeClass = node.className;
if (Util.isNil(nodeClass)) {
return node;
}
nodeClass = nodeClass.split(' ');
if (nodeClass.indexOf(className) > -1) {
return node;
}
if (node.parentNode) {
if (node.parentNode.className === CONTAINER_CLASS) {
return node.parentNode;
}
return getParentNode(node.parentNode, className);
}
return null;
}
function findItem(items, refer) {
var rst = null;
var value = refer instanceof Group ? refer.get('value') : refer;
Util.each(items, function (item) {
if (item.value === value) {
rst = item;
return false;
}
});
return rst;
}
var CatHtml =
/*#__PURE__*/
function (_Category) {
_inheritsLoose(CatHtml, _Category);
function CatHtml() {
return _Category.apply(this, arguments) || this;
}
var _proto = CatHtml.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Category.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* type 标识
* @type {String}
*/
type: 'category-legend',
/**
* html 容器
* @type {DOM}
*/
container: null,
/**
* 使用html时的外层模板
* @type {String}
*/
containerTpl: '',
/**
* html 模板
* @type {String|Function}
*/
itemTpl: '' + '' + '{value}',
/**
* html style
* @type {Attrs}
*/
legendStyle: {},
/**
* 图例文字样式
* @type {ATTRS}
*/
textStyle: {
fill: '#333',
fontSize: 12,
textAlign: 'middle',
textBaseline: 'top',
fontFamily: FONT_FAMILY
},
/**
* 当文本太长时是否进行缩略
* @type {Boolean}
*/
abridgeText: false,
/**
* abridgeText 为 true 时,鼠标放置在 item 上时显示全称的悬浮 div 的 html 模板
* @type {String}
*/
tipTpl: '',
/**
* abridgeText 为 true 时,鼠标放置在 item 上时显示全称的悬浮 div 的样式
* @type {Attrs}
*/
tipStyle: {
display: 'none',
fontSize: '12px',
backgroundColor: '#fff',
position: 'absolute',
width: 'auto',
height: 'auto',
padding: '3px',
boxShadow: '2px 2px 5px #888'
},
/**
* useHtml 为 true 时生效,用于自动定位
* @type {[type]}
*/
autoPosition: true
});
};
_proto._init = function _init() {
return;
};
_proto.beforeRender = function beforeRender() {
return;
};
_proto.render = function render() {
this._renderHTML();
}; // user interaction
_proto._bindEvents = function _bindEvents() {
var _this = this;
var legendWrapper = this.get('legendWrapper');
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS);
if (this.get('hoverable')) {
itemListDom.onmousemove = function (ev) {
return _this._onMousemove(ev);
};
itemListDom.onmouseout = function (ev) {
return _this._onMouseleave(ev);
};
}
if (this.get('clickable')) {
itemListDom.onclick = function (ev) {
return _this._onClick(ev);
};
}
}; // mouse move listener of an item
// when mouse over an item, reduce the opacity of the other items.
_proto._onMousemove = function _onMousemove(ev) {
var items = this.get('items');
var target = ev.target;
var targetClass = target.className;
targetClass = targetClass.split(' ');
if (targetClass.indexOf(CONTAINER_CLASS) > -1 || targetClass.indexOf(LIST_CLASS) > -1) {
return;
}
var parentDom = getParentNode(target, ITEM_CLASS);
var hoveredItem = findItem(items, parentDom.getAttribute('data-value'));
if (hoveredItem) {
// change the opacity of other items
this.deactivate();
this.activate(parentDom.getAttribute('data-value'));
this.emit('itemhover', {
item: hoveredItem,
currentTarget: parentDom,
checked: hoveredItem.checked
});
} else if (!hoveredItem) {
// restore the opacity of all the items
this.deactivate();
this.emit('itemunhover', ev);
}
return;
}; // mouse leave listener of an item
_proto._onMouseleave = function _onMouseleave(ev) {
// restore the opacity of all the items when mouse leave
this.deactivate();
this.emit('itemunhover', ev);
return;
}; // the click listener of an item
_proto._onClick = function _onClick(ev) {
var _this2 = this;
var legendWrapper = this.get('legendWrapper');
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS);
var unCheckedColor = this.get('unCheckColor');
var items = this.get('items');
var mode = this.get('selectedMode');
var childNodes = itemListDom.childNodes;
var target = ev.target;
var targetClass = target.className;
targetClass = targetClass.split(' ');
if (targetClass.indexOf(CONTAINER_CLASS) > -1 || targetClass.indexOf(LIST_CLASS) > -1) {
return;
}
var parentDom = getParentNode(target, ITEM_CLASS);
var textDom = findNodeByClass(parentDom, TEXT_CLASS);
var markerDom = findNodeByClass(parentDom, MARKER_CLASS);
var clickedItem = findItem(items, parentDom.getAttribute('data-value'));
if (!clickedItem) {
return;
}
var domClass = parentDom.className;
var originColor = parentDom.getAttribute('data-color');
if (mode === 'single') {
// 单选模式
// update checked status
clickedItem.checked = true; // 其他图例项全部置灰
Util.each(childNodes, function (child) {
if (child !== parentDom) {
var childMarkerDom = findNodeByClass(child, MARKER_CLASS);
childMarkerDom.style.backgroundColor = unCheckedColor;
child.className = child.className.replace('checked', 'unChecked');
child.style.color = unCheckedColor;
var childItem = findItem(items, child.getAttribute('data-value'));
childItem.checked = false;
} else {
if (textDom) {
textDom.style.color = _this2.get('textStyle').fill;
}
if (markerDom) {
markerDom.style.backgroundColor = originColor;
}
parentDom.className = domClass.replace('unChecked', 'checked');
}
});
} else {
// 混合模式
var clickedItemChecked = domClass.indexOf('checked') !== -1; // domClass.includes('checked');
var count = 0;
Util.each(childNodes, function (child) {
if (child.className.indexOf('checked') !== -1) {
// .includes('checked')
count++;
}
});
if (!this.get('allowAllCanceled') && clickedItemChecked && count === 1) {
this.emit('clicklastitem', {
item: clickedItem,
currentTarget: parentDom,
checked: mode === 'single' ? true : clickedItem.checked
});
return;
} // 在判断最后一个图例后再更新checked状态,防止点击最后一个图例item时图例样式没有变化但是checked状态改变了 fix #422
clickedItem.checked = !clickedItem.checked;
if (clickedItemChecked) {
if (markerDom) {
markerDom.style.backgroundColor = unCheckedColor;
}
parentDom.className = domClass.replace('checked', 'unChecked');
parentDom.style.color = unCheckedColor;
} else {
if (markerDom) {
markerDom.style.backgroundColor = originColor;
}
parentDom.className = domClass.replace('unChecked', 'checked');
parentDom.style.color = this.get('textStyle').fill;
}
}
this.emit('itemclick', {
item: clickedItem,
currentTarget: parentDom,
checked: mode === 'single' ? true : clickedItem.checked
});
return;
}; // activate an item by reduce the opacity of other items.
// it is reserved for bi-direction interaction between charts / graph and legend
_proto.activate = function activate(value) {
var _this3 = this;
var self = this;
var items = self.get('items');
var item = findItem(items, value);
var legendWrapper = self.get('legendWrapper');
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS);
var childNodes = itemListDom.childNodes;
childNodes.forEach(function (child) {
var childMarkerDom = findNodeByClass(child, MARKER_CLASS);
var childItem = findItem(items, child.getAttribute('data-value'));
if (_this3.get('highlight')) {
if (childItem === item && childItem.checked) {
childMarkerDom.style.border = '1px solid #333';
return;
}
} else {
if (childItem === item) {
childMarkerDom.style.opacity = self.get('activeOpacity');
} else {
if (childItem.checked) childMarkerDom.style.opacity = self.get('inactiveOpacity');
}
} // if (childItem !== item && childItem.checked) {
// if (this.get('highlight')) {
// childMarkerDom.style.border = '1px solid #fff';
// } else childMarkerDom.style.opacity = 0.5;
// } else {
// if (this.get('highlight')) {
// childMarkerDom.style.border = '1px solid #333';
// } else childMarkerDom.style.opacity = 1;
// }
});
return;
}; // restore the opacity of items
// it is reserved for bi-direction interaction between charts / graph and legend
_proto.deactivate = function deactivate() {
var _this4 = this;
var self = this;
var legendWrapper = self.get('legendWrapper');
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS);
var childNodes = itemListDom.childNodes;
childNodes.forEach(function (child) {
var childMarkerDom = findNodeByClass(child, MARKER_CLASS);
if (_this4.get('highlight')) {
childMarkerDom.style.border = '1px solid #fff';
} else {
childMarkerDom.style.opacity = self.get('inactiveOpacity');
}
});
return;
};
_proto._renderHTML = function _renderHTML() {
var _this5 = this;
// const canvas = this.get('canvas');
var container = this.get('container'); // const outterNode = container.parentNode;
var title = this.get('title');
var containerTpl = this.get('containerTpl');
var legendWrapper = DomUtil.createDom(containerTpl);
var titleDom = findNodeByClass(legendWrapper, TITLE_CLASS);
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS); // ul
var unCheckedColor = this.get('unCheckColor');
var LEGEND_STYLE = Util.deepMix({}, {
CONTAINER_CLASS: {
height: 'auto',
width: 'auto',
position: 'absolute',
overflowY: 'auto',
fontSize: '12px',
fontFamily: FONT_FAMILY,
lineHeight: '20px',
color: '#8C8C8C'
},
TITLE_CLASS: {
marginBottom: this.get('titleGap') + 'px',
fontSize: '12px',
color: '#333',
// 默认样式
textBaseline: 'middle',
fontFamily: FONT_FAMILY
},
LIST_CLASS: {
listStyleType: 'none',
margin: 0,
padding: 0,
textAlign: 'center'
},
LIST_ITEM_CLASS: {
cursor: 'pointer',
marginBottom: '5px',
marginRight: '24px'
},
MARKER_CLASS: {
width: '9px',
height: '9px',
borderRadius: '50%',
display: 'inline-block',
marginRight: '4px',
verticalAlign: 'middle'
}
}, this.get('legendStyle')); // fix:IE 9 兼容问题,先加入 legendWrapper
// let container = this.get('container');
if (/^\#/.test(container) || typeof container === 'string' && container.constructor === String) {
// 如果传入 dom 节点的 id
var id = container.replace('#', '');
container = document.getElementById(id);
container.appendChild(legendWrapper);
} else {
var _position = this.get('position');
var rangeStyle = {};
if (_position === 'left' || _position === 'right') {
rangeStyle = {
maxHeight: (this.get('maxLength') || container.offsetHeight) + 'px'
};
} else {
rangeStyle = {
maxWidth: (this.get('maxLength') || container.offsetWidth) + 'px'
};
}
DomUtil.modifyCSS(legendWrapper, Util.mix({}, LEGEND_STYLE.CONTAINER_CLASS, rangeStyle, this.get(CONTAINER_CLASS)));
container.appendChild(legendWrapper);
}
DomUtil.modifyCSS(itemListDom, Util.mix({}, LEGEND_STYLE.LIST_CLASS, this.get(LIST_CLASS))); // render title
if (titleDom) {
if (title && title.text) {
titleDom.innerHTML = title.text;
DomUtil.modifyCSS(titleDom, Util.mix({}, LEGEND_STYLE.TITLE_CLASS, this.get(TITLE_CLASS), title));
} else {
legendWrapper.removeChild(titleDom);
}
} // 开始渲染图例项
var items = this.get('items');
var itemTpl = this.get('itemTpl');
var position = this.get('position');
var layout = this.get('layout');
var itemDisplay = position === 'right' || position === 'left' || layout === 'vertical' ? 'block' : 'inline-block';
var itemStyle = Util.mix({}, LEGEND_STYLE.LIST_ITEM_CLASS, {
display: itemDisplay
}, this.get(ITEM_CLASS));
var markerStyle = Util.mix({}, LEGEND_STYLE.MARKER_CLASS, this.get(MARKER_CLASS));
Util.each(items, function (item, index) {
var checked = item.checked;
var value = _this5._formatItemValue(item.value);
var markerColor = item.marker.fill || item.marker.stroke;
var color = checked ? markerColor : unCheckedColor;
var domStr;
if (Util.isFunction(itemTpl)) {
domStr = itemTpl(value, color, checked, index);
} else {
domStr = itemTpl;
}
var itemDiv = Util.substitute(domStr, Util.mix({}, item, {
index: index,
checked: checked ? 'checked' : 'unChecked',
value: value,
color: color,
originColor: markerColor,
// @2018-07-09 by blue.lb 修复如果legend值中存在双引号"时, 导致的无法点击触发legend正常操作bug
originValue: item.value.replace(/\"/g, '"')
})); // li
var itemDom = DomUtil.createDom(itemDiv);
itemDom.style.color = _this5.get('textStyle').fill;
var markerDom = findNodeByClass(itemDom, MARKER_CLASS);
var textDom = findNodeByClass(itemDom, TEXT_CLASS);
DomUtil.modifyCSS(itemDom, itemStyle);
markerDom && DomUtil.modifyCSS(markerDom, markerStyle); // textDom && DomUtil.modifyCSS(textDom, this.get('textStyle'));
if (!checked) {
itemDom.style.color = unCheckedColor;
if (markerDom) {
markerDom.style.backgroundColor = unCheckedColor;
}
}
itemListDom.appendChild(itemDom); // abridge the text if the width of the text exceeds the width of the item
if (_this5.get('abridgeText')) {
var text = value; // const itemWidth = parseFloat(this.get(ITEM_CLASS).width.substr(0, this.get(ITEM_CLASS).width.length - 2));
var itemWidth = itemDom.offsetWidth;
var fs = _this5.get('textStyle').fontSize;
if (isNaN(fs)) {
// 6.5pt = 6.5 * 1/72 * 96 = 8.6px
if (fs.indexOf('pt') !== -1) fs = parseFloat(fs.substr(0, fs.length - 2)) * 1 / 72 * 96;else if (fs.indexOf('px') !== -1) fs = parseFloat(fs.substr(0, fs.length - 2));
}
var textWidth = fs * text.length;
var letterNum = Math.floor(itemWidth / fs);
if (itemWidth < 2 * fs) {
// unable to contain '...'
text = '';
} else if (itemWidth < textWidth) {
// replace the tail as '...
if (letterNum > 1) text = text.substr(0, letterNum - 1) + '...';
}
textDom.innerText = text; // show the text tip while mouse hovering an item
itemDom.addEventListener('mouseover', function () {
var tipDom = findNodeByClass(legendWrapper.parentNode, 'textTip');
tipDom.style.display = 'block';
tipDom.style.left = itemDom.offsetLeft + itemDom.offsetWidth + 'px';
tipDom.style.top = itemDom.offsetTop + 15 + 'px';
tipDom.innerText = value;
}); // hide the text tip while mouse leave the item
itemDom.addEventListener('mouseout', function () {
var tipDom = findNodeByClass(legendWrapper.parentNode, 'textTip');
tipDom.style.display = 'none';
});
}
}); // append the tip div as a brother node of legend dom
if (this.get('abridgeText')) {
var tipTpl = this.get('tipTpl');
var tipDom = DomUtil.createDom(tipTpl);
var tipDomStyle = this.get('tipStyle');
DomUtil.modifyCSS(tipDom, tipDomStyle);
legendWrapper.parentNode.appendChild(tipDom); // hide the tip while mouse entering the tip dom
tipDom.addEventListener('mouseover', function () {
tipDom.style.display = 'none';
});
}
this.set('legendWrapper', legendWrapper);
};
_proto._adjustPositionOffset = function _adjustPositionOffset() {
var position = this.get('position');
var offset = this.get('offset');
var offsetX = this.get('offsetX');
var offsetY = this.get('offsetY');
if (offsetX) offset[0] = offsetX;
if (offsetY) offset[1] = offsetY;
var legendWrapper = this.get('legendWrapper');
legendWrapper.style.left = position[0] + 'px';
legendWrapper.style.top = position[1] + 'px';
legendWrapper.style.marginLeft = offset[0] + 'px';
legendWrapper.style.marginTop = offset[1] + 'px';
};
_proto.getWidth = function getWidth() {
return DomUtil.getOuterWidth(this.get('legendWrapper'));
};
_proto.getHeight = function getHeight() {
return DomUtil.getOuterHeight(this.get('legendWrapper'));
};
_proto.move = function move(x, y) {
if (!/^\#/.test(this.get('container'))) {
DomUtil.modifyCSS(this.get('legendWrapper'), {
left: x + 'px',
top: y + 'px'
});
this.set('x', x);
this.set('y', y);
} else {
_Category.prototype.move.call(this, x, y);
}
};
_proto.destroy = function destroy() {
var legendWrapper = this.get('legendWrapper');
if (legendWrapper && legendWrapper.parentNode) {
legendWrapper.parentNode.removeChild(legendWrapper);
}
};
return CatHtml;
}(Category);
module.exports = CatHtml;
/***/ }),
/* 107 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Legend = __webpack_require__(105);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY; // const DomUtil = Util.DomUtil;
var Event = Util.Event;
var Group = Util.Group; // const Global = require('../../global');
// const CONTAINER_CLASS = 'g2-legend';
function findItem(items, refer) {
var rst = null;
var value = refer instanceof Group || refer.name === 'legendGroup' ? refer.get('value') : refer;
Util.each(items, function (item) {
if (item.value === value) {
rst = item;
return false;
}
});
return rst;
}
function findShapeByName(group, name) {
return group.findBy(function (node) {
return node.name === name;
});
}
var Category =
/*#__PURE__*/
function (_Legend) {
_inheritsLoose(Category, _Legend);
function Category() {
return _Legend.apply(this, arguments) || this;
}
var _proto = Category.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Legend.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* type标识
* @type {String}
*/
type: 'category-legend',
/**
* 子项集合
* @type {Array}
*/
items: null,
/**
* TODO:rename
* 图例项水平方向的间距
* @type {Number}
*/
itemGap: 5,
/**
* TODO:rename
* 图例项垂直方向的间距
* @type {Number}
*/
itemMarginBottom: 8,
/**
* 图例项图组
* @type {Group}
*/
itemsGroup: null,
/**
* 布局方式: horizontal,vertical
* @type {String}
*/
layout: 'horizontal',
/**
* 是否允许全部取消,默认 false,即必须保留一个被选中
* @type {Boolean}
*/
allowAllCanceled: false,
/**
* 边框内边距
* @type {Array}
*/
backPadding: [0, 0, 0, 0],
/**
* 图例项取消选中的颜色
* @type {String}
*/
unCheckColor: '#ccc',
/**
* 图例背景层属性设置
* @type {Obejct}
*/
background: {
fill: '#fff',
fillOpacity: 0
},
/**
* 图例项的宽度,当图例有很多图例项,并且用户想要这些图例项在同一平面内垂直对齐,此时这个属性可帮用户实现此效果
* @type {Number}
*/
itemWidth: null,
/**
* 图例文字样式
* @type {ATTRS}
*/
textStyle: {
fill: '#333',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
fontFamily: FONT_FAMILY
},
/**
* marker 和文字的距离
* @type {Number}
*/
_wordSpaceing: 8,
/**
* 图例项是否可点击,默认为 true
* @type {Boolean}
*/
clickable: true,
/**
* TODO: rename
* 图例项的选择模式,多选和单选 multiple、single
* @type {String}
*/
selectedMode: 'multiple',
/**
* 图例项的顺序是否要逆序,默认为 false
* @type {Boolean}
*/
reversed: false,
/**
* 是否自动换行
* @type {Boolean}
*/
autoWrap: true,
/**
* 是否以增加 border 的方式高亮 hover 的 item。若为 false ,则降低其他 item 的透明度。
* @type {Boolean}
*/
highlight: false,
/**
* 非highlight方式下,鼠标hover到legend样式
* @type {Number}
*/
activeOpacity: 0.7,
/**
* 非highlight方式下,非鼠标hover到的legend样式
* @type {Number}
*/
inactiveOpacity: 1
});
}; // rendering
_proto.render = function render() {
_Legend.prototype.render.call(this);
this._renderItems();
this.get('autoWrap') && this._adjustItems(); // 默认自动换行
}; // user iteraction
_proto._bindEvents = function _bindEvents() {
if (this.get('hoverable')) {
this.get('group').on('mousemove', Util.wrapBehavior(this, '_onMousemove'));
this.get('group').on('mouseleave', Util.wrapBehavior(this, '_onMouseleave'));
}
if (this.get('clickable')) {
this.get('group').on('click', Util.wrapBehavior(this, '_onClick'));
}
}; // return the target's parent legend object
_proto._getLegendItem = function _getLegendItem(target) {
var item = target.get('parent');
if (item && item.name === 'legendGroup') {
return item;
}
return null;
}; // activate an item by reduce the opacity of other items.
// it is reserved for bi-direction interaction between charts / graph and legend
_proto.activate = function activate(value) {
var _this = this;
var self = this;
var itemsGroup = self.get('itemsGroup');
var children = itemsGroup.get('children');
var markerItem = void 0;
children.forEach(function (child) {
markerItem = findShapeByName(child, 'legend-marker');
if (!markerItem) return;
var checked = child.get('checked');
if (_this.get('highlight')) {
// change stroke color
if (child.get('value') === value && checked) {
markerItem.attr('stroke', '#333');
} else {
markerItem.attr('stroke', null);
}
} else {
// change opacity
if (child.get('value') === value) {
markerItem.attr('fillOpacity', self.get('activeOpacity'));
}
}
});
this.get('canvas').draw();
return;
}; // restore the opacity of items
// it is reserved for bi-direction interaction between charts / graph and legend
_proto.deactivate = function deactivate() {
var _this2 = this;
var self = this;
var itemsGroup = self.get('itemsGroup');
var children = itemsGroup.get('children');
var markerItem = void 0;
var unCheckColor = this.get('unCheckColor');
children.forEach(function (child) {
markerItem = findShapeByName(child, 'legend-marker');
if (!markerItem) return;
if (_this2.get('highlight')) {
var oriStroke = markerItem.get('oriStroke');
var checked = child.get('checked');
if (oriStroke && !checked) oriStroke = unCheckColor;else oriStroke = '';
markerItem.attr('stroke', oriStroke);
} else {
markerItem.attr('fillOpacity', self.get('inactiveOpacity'));
}
});
this.get('canvas').draw();
return;
}; // mouse move listener of an item
// when mouse over an item, reduce the opacity of the other items.
_proto._onMousemove = function _onMousemove(ev) {
var item = this._getLegendItem(ev.currentTarget);
if (item && item.get('checked')) {
var items = this.get('items');
var itemhover = new Event('itemhover', ev, true, true);
itemhover.item = findItem(items, item);
itemhover.checked = item.get('checked');
itemhover.currentTarget = ev.currentTarget; // change the opacity of other items
this.deactivate();
this.activate(item.get('value'));
this.emit('itemhover', itemhover);
} else {
this.deactivate();
this.emit('itemunhover', ev);
}
this.get('canvas').draw();
return;
}; // mouse leave listener of an item
_proto._onMouseleave = function _onMouseleave(ev) {
this.deactivate();
this.get('canvas').draw();
this.emit('itemunhover', ev);
return;
}; // the click listener of an item
_proto._onClick = function _onClick(ev) {
var clickedItem = this._getLegendItem(ev.currentTarget);
var items = this.get('items');
if (clickedItem && !clickedItem.get('destroyed')) {
var checked = clickedItem.get('checked');
var mode = this.get('selectedMode');
var item = findItem(items, clickedItem);
var itemclick = new Event('itemclick', ev, true, true);
itemclick.item = item;
itemclick.currentTarget = clickedItem;
itemclick.appendInfo = ev.currentTarget.get('appendInfo');
itemclick.checked = mode === 'single' ? true : !checked;
if (!this.get('allowAllCanceled') && checked && this.getCheckedCount() === 1) {
this.emit('clicklastitem', itemclick);
return;
}
var unCheckColor = this.get('unCheckColor');
var checkColor = this.get('textStyle').fill;
var markerItem = void 0;
var textItem = void 0;
var legendItem = void 0;
if (mode === 'single') {
var itemsGroup = this.get('itemsGroup');
var children = itemsGroup.get('children');
Util.each(children, function (child) {
markerItem = findShapeByName(child, 'legend-marker');
textItem = findShapeByName(child, 'legend-text');
legendItem = findShapeByName(child, 'legend-item');
if (child !== clickedItem) {
if (markerItem.attr('fill')) {
markerItem.attr('fill', unCheckColor);
}
if (markerItem.attr('stroke')) {
markerItem.attr('stroke', unCheckColor);
}
textItem.attr('fill', unCheckColor);
markerItem.setSilent('checked', false);
textItem.setSilent('checked', false);
legendItem.setSilent('checked', false);
child.setSilent('checked', false);
} else {
if (markerItem.attr('fill')) {
item && item.marker && markerItem.attr('fill', item.marker.fill);
}
if (markerItem.attr('stroke')) {
item && item.marker && markerItem.attr('stroke', item.marker.stroke);
}
textItem.attr('fill', checkColor);
markerItem.setSilent('checked', true);
textItem.setSilent('checked', true);
legendItem.setSilent('checked', true);
child.setSilent('checked', true);
}
});
} else {
markerItem = findShapeByName(clickedItem, 'legend-marker');
textItem = findShapeByName(clickedItem, 'legend-text');
legendItem = findShapeByName(clickedItem, 'legend-item');
if (markerItem.attr('fill')) {
item && item.marker && markerItem.attr('fill', checked ? unCheckColor : item.marker.fill);
}
if (markerItem.attr('stroke')) {
item && item.marker && markerItem.attr('stroke', checked ? unCheckColor : item.marker.stroke);
}
textItem.attr('fill', checked ? unCheckColor : checkColor);
clickedItem.setSilent('checked', !checked);
markerItem.setSilent('checked', !checked);
textItem.setSilent('checked', !checked);
legendItem.setSilent('checked', !checked);
}
this.emit('itemclick', itemclick);
}
this.get('canvas').draw();
return;
}; // render the items
_proto._renderItems = function _renderItems() {
var _this3 = this;
var items = this.get('items');
if (this.get('reversed')) {
items.reverse();
}
Util.each(items, function (item, index) {
_this3._addItem(item, index);
});
if (this.get('highlight')) {
var itemsGroup = this.get('itemsGroup');
var children = itemsGroup.get('children');
var markerItem = void 0;
children.forEach(function (child) {
markerItem = findShapeByName(child, 'legend-marker');
var oriStroke = markerItem.get('oriStroke');
if (!oriStroke) {
if (markerItem.attr('stroke')) markerItem.set('oriStroke', markerItem.attr('stroke'));else markerItem.set('oriStroke', '');
}
});
}
}; // format the item value
_proto._formatItemValue = function _formatItemValue(value) {
var formatter = this.get('formatter') || this.get('itemFormatter');
if (formatter) {
value = formatter.call(this, value);
}
return value;
}; // find x of next item
_proto._getNextX = function _getNextX() {
var layout = this.get('layout');
var itemGap = this.get('itemGap');
var itemsGroup = this.get('itemsGroup');
var itemWidth = this.get('itemWidth');
var children = itemsGroup.get('children');
var nextX = 0;
if (layout === 'horizontal') {
// 水平布局
Util.each(children, function (v) {
nextX += (itemWidth ? itemWidth : v.getBBox().width) + itemGap;
});
}
return nextX;
}; // find y of next item
_proto._getNextY = function _getNextY() {
var itemMarginBottom = this.get('itemMarginBottom');
var titleGap = this.get('titleShape') ? this.get('titleGap') : 0;
var layout = this.get('layout');
var itemsGroup = this.get('itemsGroup');
var titleShape = this.get('titleShape');
var children = itemsGroup.get('children');
var nextY = titleGap;
if (titleShape) {
nextY += titleShape.getBBox().height;
}
if (layout === 'vertical') {
// 竖直布局
Util.each(children, function (v) {
nextY += v.getBBox().height + itemMarginBottom;
});
}
return nextY;
}; // add an item to the canvas
_proto._addItem = function _addItem(item) {
var itemsGroup = this.get('itemsGroup');
var x = this._getNextX();
var y = this._getNextY();
var unCheckColor = this.get('unCheckColor');
var itemGroup = itemsGroup.addGroup({
x: x,
y: y,
value: item.value,
checked: item.checked
}); // @2018-10-20 by blue.lb 需要设置viewId,否则在emit的时候,parent获取不到viewId
itemGroup.set('viewId', this.get('viewId'));
var textStyle = this.get('textStyle');
var wordSpace = this.get('_wordSpaceing');
var startX = 0;
if (item.marker) {
// 如果有marker添加marker
var markerAttrs = Util.mix({}, item.marker, {
x: item.marker.radius + x,
y: y
});
if (!item.checked) {
if (markerAttrs.fill) {
markerAttrs.fill = unCheckColor;
}
if (markerAttrs.stroke) {
markerAttrs.stroke = unCheckColor;
}
}
var markerShape = itemGroup.addShape('marker', {
type: 'marker',
attrs: markerAttrs
});
markerShape.attr('cursor', 'pointer');
markerShape.name = 'legend-marker';
startX += markerShape.getBBox().width + wordSpace;
}
var textAttrs = Util.mix({}, {
fill: '#333',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}, textStyle, {
x: startX + x,
y: y,
text: this._formatItemValue(item.value)
});
if (!item.checked) {
Util.mix(textAttrs, {
fill: unCheckColor
});
}
var textShape = itemGroup.addShape('text', {
attrs: textAttrs
});
textShape.attr('cursor', 'pointer');
textShape.name = 'legend-text';
this.get('appendInfo') && textShape.setSilent('appendInfo', this.get('appendInfo')); // 添加一个包围矩形,用于事件支持
var bbox = itemGroup.getBBox();
var itemWidth = this.get('itemWidth');
var wrapperShape = itemGroup.addShape('rect', {
attrs: {
x: x,
y: y - bbox.height / 2,
fill: '#fff',
fillOpacity: 0,
width: itemWidth || bbox.width,
height: bbox.height
}
});
wrapperShape.attr('cursor', 'pointer');
wrapperShape.setSilent('origin', item); // 保存图例项相关的数据,便于事件操作
wrapperShape.name = 'legend-item';
this.get('appendInfo') && wrapperShape.setSilent('appendInfo', this.get('appendInfo'));
itemGroup.name = 'legendGroup';
return itemGroup;
}; // auto break the line for horizontal layout
_proto._adjustHorizontal = function _adjustHorizontal() {
var itemsGroup = this.get('itemsGroup');
var children = itemsGroup.get('children');
var maxLength = this.get('maxLength');
var itemGap = this.get('itemGap');
var itemMarginBottom = this.get('itemMarginBottom');
var titleGap = this.get('titleShape') ? this.get('titleGap') : 0;
var row = 0;
var rowLength = 0;
var width = void 0;
var height = void 0;
var box = void 0;
var itemWidth = this.get('itemWidth');
if (itemsGroup.getBBox().width > maxLength) {
Util.each(children, function (child) {
box = child.getBBox();
width = itemWidth || box.width;
height = box.height + itemMarginBottom;
if (maxLength - rowLength < width) {
row++;
rowLength = 0;
}
child.move(rowLength, row * height + titleGap);
rowLength += width + itemGap;
});
}
return;
}; // auto break the column for vertical layout
_proto._adjustVertical = function _adjustVertical() {
var itemsGroup = this.get('itemsGroup');
var titleShape = this.get('titleShape');
var children = itemsGroup.get('children');
var maxLength = this.get('maxLength'); // 垂直布局,则 maxLength 代表容器的高度
var itemGap = this.get('itemGap');
var itemMarginBottom = this.get('itemMarginBottom');
var titleGap = this.get('titleGap');
var titleHeight = titleShape ? titleShape.getBBox().height + titleGap : 0;
var itemWidth = this.get('itemWidth');
var colLength = titleHeight;
var width = void 0;
var height = void 0;
var box = void 0;
var maxItemWidth = 0;
var totalLength = 0;
if (itemsGroup.getBBox().height > maxLength) {
Util.each(children, function (v) {
box = v.getBBox();
width = box.width;
height = box.height;
if (itemWidth) {
maxItemWidth = itemWidth + itemGap;
} else if (width > maxItemWidth) {
maxItemWidth = width + itemGap;
}
if (maxLength - colLength < height) {
colLength = titleHeight;
totalLength += maxItemWidth;
v.move(totalLength, titleHeight);
} else {
v.move(totalLength, colLength);
}
colLength += height + itemMarginBottom;
});
}
return;
}; // automatically break the line / column while the width / height exceeds maxLength
_proto._adjustItems = function _adjustItems() {
var layout = this.get('layout');
if (layout === 'horizontal') {
this._adjustHorizontal();
} else {
this._adjustVertical();
}
};
_proto.getWidth = function getWidth() {
return _Legend.prototype.getWidth.call(this);
};
_proto.getHeight = function getHeight() {
return _Legend.prototype.getHeight.call(this);
};
_proto.move = function move(x, y) {
_Legend.prototype.move.call(this, x, y);
};
return Category;
}(Legend);
module.exports = Category;
/***/ }),
/* 108 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var G = __webpack_require__(35);
var Crosshair = __webpack_require__(109);
var MarkerGroupMixin = __webpack_require__(110);
var PositionMixin = __webpack_require__(111);
var Tooltip = __webpack_require__(64);
var Util = __webpack_require__(3);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var DomUtil = Util.DomUtil;
var MatrixUtil = Util.MatrixUtil;
var CanvasTooltip =
/*#__PURE__*/
function (_Tooltip) {
_inheritsLoose(CanvasTooltip, _Tooltip);
var _proto = CanvasTooltip.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Tooltip.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 默认背景板样式
* @type {Object}
*/
boardStyle: {
x: 0,
y: 0,
width: 100,
height: 100,
fill: 'rgba(255, 255, 255, 0.9)',
radius: 4,
stroke: '#e2e2e2',
lineWidth: 1
},
/**
* 默认title样式
* @type {Object}
*/
titleStyle: {
fontFamily: FONT_FAMILY,
text: '',
textBaseline: 'top',
fontSize: 12,
fill: 'rgb(87, 87, 87)',
lineHeight: 20,
padding: 20
},
/**
* 默认marker样式
* @type {Object}
*/
markerStyle: {
radius: 4
},
/**
* 默认name样式
* @type {Object}
*/
nameStyle: {
fontFamily: FONT_FAMILY,
fontSize: 12,
fill: 'rgb(87, 87, 87)',
textBaseline: 'middle',
textAlign: 'start',
padding: 8
},
/**
* 默认value样式
* @type {Object}
*/
valueStyle: {
fontFamily: FONT_FAMILY,
fontSize: 12,
fill: 'rgb(87, 87, 87)',
textBaseline: 'middle',
textAlign: 'start',
padding: 30
},
/**
* 默认padding值
* @type {Object}
*/
padding: {
top: 20,
right: 20,
bottom: 20,
left: 20
},
/**
* 默认item之间的gap
* @type {Number}
*/
itemGap: 10,
/**
* 默认tooltip位置移动动画的时长
* @type {Number}
*/
animationDuration: 200
});
};
function CanvasTooltip(cfg) {
var _this;
_this = _Tooltip.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), PositionMixin);
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), MarkerGroupMixin); // crosshair
var crosshair = _this.get('crosshairs');
if (crosshair) {
var plot = crosshair.type === 'rect' ? _this.get('backPlot') : _this.get('frontPlot');
var crosshairGroup = new Crosshair(Util.mix({
plot: plot,
plotRange: _this.get('plotRange'),
canvas: _this.get('canvas')
}, _this.get('crosshairs')));
crosshairGroup.hide();
_this.set('crosshairGroup', crosshairGroup);
}
_this._init_();
if (_this.get('items')) {
_this.render();
}
return _this;
}
_proto._init_ = function _init_() {
var self = this;
var padding = self.get('padding');
var parent = self.get('frontPlot'); // marker group
var markerGroup = parent.addGroup({
capture: false
});
self.set('markerGroup', markerGroup); // container
var container = parent.addGroup();
container.hide();
self.set('container', container); // board
var board = container.addShape('rect', {
attrs: Util.mix({}, self.get('boardStyle'))
});
self.set('board', board); // title
var titleStyle = self.get('titleStyle');
if (self.get('showTitle')) {
var titleShape = container.addShape('text', {
attrs: Util.mix({
x: padding.left,
y: padding.top
}, titleStyle)
});
self.set('titleShape', titleShape);
titleShape.name = 'tooltip-title';
} // items
var itemsGroup = container.addGroup();
itemsGroup.move(padding.left, padding.top + titleStyle.lineHeight + titleStyle.padding);
self.set('itemsGroup', itemsGroup);
};
_proto.render = function render() {
var self = this;
self.clear();
var container = self.get('container');
var board = self.get('board');
var showTitle = self.get('showTitle');
var titleContent = self.get('titleContent');
var titleShape = this.get('titleShape');
var itemsGroup = this.get('itemsGroup');
var items = self.get('items');
var padding = self.get('padding');
if (titleShape && showTitle) {
titleShape.attr('text', titleContent);
}
if (itemsGroup) {
var itemGap = self.get('itemGap');
var x = 0;
var y = 0;
Util.each(items, function (item) {
var itemGroup = self._addItem(item);
itemGroup.move(x, y);
itemsGroup.add(itemGroup);
var itemHeight = itemGroup.getBBox().height;
y += itemHeight + itemGap;
});
} // update board based on bbox
var bbox = container.getBBox();
var width = bbox.width + padding.right;
var height = bbox.height + padding.bottom;
board.attr('width', width);
board.attr('height', height); // align value text to right
self._alignToRight(width);
};
_proto.clear = function clear() {
var titleShape = this.get('titleShape');
var itemsGroup = this.get('itemsGroup');
var board = this.get('board');
titleShape.text = '';
itemsGroup.clear();
board.attr('width', 0);
board.attr('height', 0);
};
_proto.show = function show() {
var container = this.get('container');
container.show();
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.show();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.show();
_Tooltip.prototype.show.call(this);
this.get('canvas').draw();
};
_proto.hide = function hide() {
var container = this.get('container');
container.hide();
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.hide();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.hide();
_Tooltip.prototype.hide.call(this);
this.get('canvas').draw();
};
_proto.destroy = function destroy() {
var container = this.get('container');
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.destroy();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.remove();
_Tooltip.prototype.destroy.call(this);
container.remove();
};
_proto.setPosition = function setPosition(x, y, target) {
var container = this.get('container');
var outterNode = this.get('canvas').get('el');
var viewWidth = DomUtil.getWidth(outterNode);
var viewHeight = DomUtil.getHeight(outterNode);
var bbox = container.getBBox();
var containerWidth = bbox.width;
var containerHeight = bbox.height;
var endx = x;
var endy = y;
var position;
if (this.get('position')) {
var _containerWidth = bbox.width;
var _containerHeight = bbox.height;
position = this._calcTooltipPosition(x, y, this.get('position'), _containerWidth, _containerHeight, target);
x = position[0];
y = position[1];
} else {
position = this._constraintPositionInBoundary(x, y, containerWidth, containerHeight, viewWidth, viewHeight);
x = position[0];
y = position[1];
}
if (this.get('inPlot')) {
// tooltip 必须限制在绘图区域内
var plotRange = this.get('plotRange');
position = this._constraintPositionInPlot(x, y, containerWidth, containerHeight, plotRange, this.get('enterable'));
x = position[0];
y = position[1];
}
var markerItems = this.get('markerItems');
if (!Util.isEmpty(markerItems)) {
endx = markerItems[0].x;
endy = markerItems[0].y;
}
var ulMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];
var mat = MatrixUtil.transform(ulMatrix, [['t', x, y]]);
container.stopAnimate();
container.animate({
matrix: mat
}, this.get('animationDuration'));
var crosshairGroup = this.get('crosshairGroup');
if (crosshairGroup) {
var items = this.get('items');
crosshairGroup.setPosition(endx, endy, items);
}
_Tooltip.prototype.setPosition.call(this, x, y);
};
_proto._addItem = function _addItem(item) {
var group = new G.Group();
var markerRadius = this.get('markerStyle').radius; // marker
if (item.marker) {
var markerAttrs = Util.mix({}, item.marker, {
x: item.marker.radius / 2,
y: 0
});
group.addShape('marker', {
attrs: markerAttrs
});
markerRadius = item.marker.radius;
} // name
var nameStyle = this.get('nameStyle');
group.addShape('text', {
attrs: Util.mix({
x: markerRadius + nameStyle.padding,
y: 0,
text: item.name
}, nameStyle)
}); // value
var valueStyle = this.get('valueStyle');
group.addShape('text', {
attrs: Util.mix({
x: group.getBBox().width + valueStyle.padding,
y: 0,
text: item.value
}, valueStyle)
});
return group;
};
_proto._alignToRight = function _alignToRight(width) {
var _this2 = this;
var itemsGroup = this.get('itemsGroup');
var groups = itemsGroup.get('children');
Util.each(groups, function (g) {
var children = g.get('children');
var valueText = children[2];
var w = valueText.getBBox().width;
var x = width - w - _this2.get('padding').right * 2;
valueText.attr('x', x);
});
};
return CanvasTooltip;
}(Tooltip);
module.exports = CanvasTooltip;
/***/ }),
/* 109 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Component = __webpack_require__(34);
var Util = __webpack_require__(3);
var Crosshair =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Crosshair, _Component);
var _proto = Crosshair.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Component.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* crosshair的类型
* @type {String}
*/
type: null,
/**
* 画在哪层视图
* @type {G-Element}
*/
plot: null,
/**
* x轴上,移动到位置的偏移量
* @type {Number}
*/
plotRange: null,
/**
* 默认rect crosshair样式
* @type {Object}
*/
rectStyle: {
fill: '#CCD6EC',
opacity: 0.3
},
/**
* 默认line crosshair样式
* @type {Object}
*/
lineStyle: {
stroke: 'rgba(0, 0, 0, 0.25)',
lineWidth: 1
},
isTransposed: false
});
};
function Crosshair(cfg) {
var _this;
_this = _Component.call(this, cfg) || this;
_this._init_();
_this.render();
return _this;
}
_proto._init_ = function _init_() {
var self = this;
var plot = self.get('plot');
var group;
if (self.type === 'rect') {
group = plot.addGroup({
zIndex: 0
});
} else {
group = plot.addGroup();
}
this.set('container', group);
};
_proto._addLineShape = function _addLineShape(attrs, type) {
var container = this.get('container');
var shape = container.addShape('line', {
capture: false,
attrs: attrs
}); // shape.hide();
this.set('crossLineShape' + type, shape);
return shape;
};
_proto._renderHorizontalLine = function _renderHorizontalLine(canvas, plotRange) {
var style = Util.mix(this.get('lineStyle'), this.get('style'));
var attrs = Util.mix({
x1: plotRange ? plotRange.bl.x : canvas.get('width'),
y1: 0,
x2: plotRange ? plotRange.br.x : 0,
y2: 0
}, style);
this._addLineShape(attrs, 'X');
};
_proto._renderVerticalLine = function _renderVerticalLine(canvas, plotRange) {
var style = Util.mix(this.get('lineStyle'), this.get('style'));
var attrs = Util.mix({
x1: 0,
y1: plotRange ? plotRange.bl.y : canvas.get('height'),
x2: 0,
y2: plotRange ? plotRange.tl.y : 0
}, style);
this._addLineShape(attrs, 'Y');
};
_proto._renderBackground = function _renderBackground(canvas, plotRange) {
var style = Util.mix(this.get('rectStyle'), this.get('style'));
var container = this.get('container');
var attrs = Util.mix({
x: plotRange ? plotRange.tl.x : 0,
y: plotRange ? plotRange.tl.y : canvas.get('height'),
width: plotRange ? plotRange.br.x - plotRange.bl.x : canvas.get('width'),
height: plotRange ? Math.abs(plotRange.tl.y - plotRange.bl.y) : canvas.get('height')
}, style);
var shape = container.addShape('rect', {
attrs: attrs,
capture: false
}); // shape.hide();
this.set('crosshairsRectShape', shape);
return shape;
};
_proto._updateRectShape = function _updateRectShape(items) {
var offset;
var crosshairsRectShape = this.get('crosshairsRectShape');
var isTransposed = this.get('isTransposed');
var firstItem = items[0];
var lastItem = items[items.length - 1];
var dim = isTransposed ? 'y' : 'x';
var attr = isTransposed ? 'height' : 'width';
var startDim = firstItem[dim];
if (items.length > 1 && firstItem[dim] > lastItem[dim]) {
startDim = lastItem[dim];
}
if (this.get('width')) {
// 用户定义了 width
crosshairsRectShape.attr(dim, startDim - this.get('crosshairs').width / 2);
crosshairsRectShape.attr(attr, this.get('width'));
} else {
if (Util.isArray(firstItem.point[dim]) && !firstItem.size) {
// 直方图
var width = firstItem.point[dim][1] - firstItem.point[dim][0];
crosshairsRectShape.attr(dim, firstItem.point[dim][0]);
crosshairsRectShape.attr(attr, width);
} else {
offset = 3 * firstItem.size / 4;
crosshairsRectShape.attr(dim, startDim - offset);
if (items.length === 1) {
crosshairsRectShape.attr(attr, 3 * firstItem.size / 2);
} else {
crosshairsRectShape.attr(attr, Math.abs(lastItem[dim] - firstItem[dim]) + 2 * offset);
}
}
}
};
_proto.render = function render() {
var canvas = this.get('canvas');
var plotRange = this.get('plotRange');
var isTransposed = this.get('isTransposed');
this.clear();
switch (this.get('type')) {
case 'x':
this._renderHorizontalLine(canvas, plotRange);
break;
case 'y':
this._renderVerticalLine(canvas, plotRange);
break;
case 'cross':
this._renderHorizontalLine(canvas, plotRange);
this._renderVerticalLine(canvas, plotRange);
break;
case 'rect':
this._renderBackground(canvas, plotRange);
break;
default:
isTransposed ? this._renderHorizontalLine(canvas, plotRange) : this._renderVerticalLine(canvas, plotRange);
}
};
_proto.show = function show() {
var container = this.get('container');
_Component.prototype.show.call(this);
container.show();
};
_proto.hide = function hide() {
var container = this.get('container');
_Component.prototype.hide.call(this);
container.hide();
};
_proto.clear = function clear() {
var container = this.get('container');
this.set('crossLineShapeX', null);
this.set('crossLineShapeY', null);
this.set('crosshairsRectShape', null);
_Component.prototype.clear.call(this);
container.clear();
};
_proto.destroy = function destroy() {
var container = this.get('container');
_Component.prototype.destroy.call(this);
container.remove();
};
_proto.setPosition = function setPosition(x, y, items) {
var crossLineShapeX = this.get('crossLineShapeX');
var crossLineShapeY = this.get('crossLineShapeY');
var crosshairsRectShape = this.get('crosshairsRectShape');
if (crossLineShapeY && !crossLineShapeY.get('destroyed')) {
// 第一次进入时,画布需要单独绘制,所以需要先设定corss的位置
crossLineShapeY.move(x, 0);
}
if (crossLineShapeX && !crossLineShapeX.get('destroyed')) {
crossLineShapeX.move(0, y);
}
if (crosshairsRectShape && !crosshairsRectShape.get('destroyed')) {
this._updateRectShape(items);
}
};
return Crosshair;
}(Component);
module.exports = Crosshair;
/***/ }),
/* 110 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(3);
var MarkerGroupMixin = {
setMarkers: function setMarkers(markerItems, markerCfg) {
var self = this;
var markerGroup = self.get('markerGroup');
var frontPlot = self.get('frontPlot');
if (!markerGroup) {
markerGroup = frontPlot.addGroup({
zIndex: 1,
capture: false // 不进行拾取
});
self.set('markerGroup', markerGroup);
} else {
markerGroup.clear();
}
Util.each(markerItems, function (item) {
markerGroup.addShape('marker', {
color: item.color,
attrs: Util.mix({
fill: item.color,
symbol: 'circle',
shadowColor: item.color
}, markerCfg, {
x: item.x,
y: item.y
})
});
});
this.set('markerItems', markerItems);
},
clearMarkers: function clearMarkers() {
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.clear();
}
};
module.exports = MarkerGroupMixin;
/***/ }),
/* 111 */
/***/ (function(module, exports) {
var GAP = 20;
var PositionMixin = {
_calcTooltipPosition: function _calcTooltipPosition(x, y, position, containerWidth, containerHeight, target) {
var rectWidth = 0;
var rectHeight = 0;
var gap = 20;
if (target) {
var rect = target.getBBox();
rectWidth = rect.width;
rectHeight = rect.height;
x = rect.x;
y = rect.y;
gap = 5;
}
switch (position) {
case 'inside':
x = x + rectWidth / 2 - containerWidth / 2;
y = y + rectHeight / 2 - containerHeight / 2;
break;
case 'top':
x = x + rectWidth / 2 - containerWidth / 2;
y = y - containerHeight - gap;
break;
case 'left':
x = x - containerWidth - gap;
y = y + rectHeight / 2 - containerHeight / 2;
break;
case 'right':
x = x + rectWidth + gap;
y = y + rectHeight / 2 - containerHeight / 2;
break;
case 'bottom':
default:
x = x + rectWidth / 2 - containerWidth / 2;
y = y + rectHeight + gap;
break;
}
return [x, y];
},
_constraintPositionInBoundary: function _constraintPositionInBoundary(x, y, width, height, viewWidth, viewHeight) {
if (x + width + GAP > viewWidth) {
x -= width + GAP;
x = x < 0 ? 0 : x;
} else if (x + GAP < 0) {
x = GAP;
} else {
x += GAP;
}
if (y + height + GAP > viewHeight) {
y -= height + GAP;
y = y < 0 ? 0 : y;
} else if (y + GAP < 0) {
y = GAP;
} else {
y += GAP;
}
return [x, y];
},
_constraintPositionInPlot: function _constraintPositionInPlot(x, y, width, height, plotRange, onlyHorizontal) {
if (x + width > plotRange.tr.x) {
x -= width + 2 * GAP;
}
if (x < plotRange.tl.x) {
x = plotRange.tl.x;
}
if (!onlyHorizontal) {
if (y + height > plotRange.bl.y) {
y -= height + 2 * GAP;
}
if (y < plotRange.tl.y) {
y = plotRange.tl.y;
}
}
return [x, y];
}
};
module.exports = PositionMixin;
/***/ }),
/* 112 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview Default animation configuration for geoms
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var Action = __webpack_require__(264);
var defaultAnimationCfg = {
appear: {
duration: 450,
easing: 'easeQuadOut'
},
// 初始入场动画配置
update: {
duration: 450,
easing: 'easeQuadInOut'
},
// 更新时发生变更的动画配置
enter: {
duration: 400,
easing: 'easeQuadInOut',
delay: 100
},
// 更新时新增元素的入场动画配置
leave: {
duration: 350,
easing: 'easeQuadIn' // 更新时销毁动画配置
}
};
var Animate = {
line: {
appear: function appear() {
return Action.appear.clipIn;
},
enter: function enter() {
return Action.enter.clipIn;
},
leave: function leave() {
return Action.leave.lineWidthOut;
}
},
path: {
appear: function appear() {
return Action.appear.clipIn;
},
enter: function enter() {
return Action.enter.clipIn;
},
leave: function leave() {
return Action.leave.lineWidthOut;
}
},
area: {
appear: function appear() {
return Action.appear.clipIn;
},
enter: function enter() {
return Action.enter.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
cfg: {
appear: {
duration: 500,
easing: 'easeQuadOut'
},
update: {
duration: 450,
easing: 'easeQuadInOut'
},
enter: {
duration: 600,
delay: 150,
easing: 'easeQuadInOut'
},
leave: {
easing: 'easeQuadOut',
duration: 350
}
}
},
polygon: {
appear: function appear() {
return Action.appear.zoomIn;
},
enter: function enter() {
return Action.enter.zoomIn;
},
leave: function leave() {
return Action.leave.zoomOut;
}
},
edge: {
appear: function appear() {
return Action.appear.pathIn;
},
enter: function enter() {
return Action.enter.pathIn;
},
leave: function leave() {
return Action.leave.pathOut;
}
},
interval: {
appear: function appear(coord) {
var result;
if (coord.isPolar) {
result = Action.appear.zoomIn;
if (coord.isTransposed || coord.type === 'theta') {
result = Action.appear.fanIn;
}
} else if (coord.isRect) {
result = coord.isTransposed ? Action.appear.scaleInX : Action.appear.scaleInY;
} else {
result = Action.appear.zoomIn;
}
return result;
},
enter: function enter(coord) {
if (coord.isRect || coord.isTransposed || coord.type === 'theta') {
return Action.enter.fadeIn;
}
return Action.enter.zoomIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
update: function update(coord) {
if (coord.type === 'theta') {
return Action.update.fanIn;
}
}
},
point: {
appear: function appear() {
return Action.appear.zoomIn;
},
enter: function enter() {
return Action.enter.zoomIn;
},
leave: function leave() {
return Action.leave.zoomOut;
}
},
schema: {
appear: function appear() {
return Action.appear.clipIn;
},
enter: function enter() {
return Action.enter.clipIn;
},
leave: function leave() {
return Action.leave.lineWidthOut;
}
},
contour: null,
heatmap: null,
label: {
appear: function appear() {
return Action.appear.fadeIn;
},
enter: function enter() {
return Action.enter.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
cfg: {
appear: {
duration: 900
}
}
},
'axis-label': {
enter: function enter() {
return Action.appear.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
update: function update(coord) {
if (coord.isPolar) {
return Action.appear.fadeIn;
}
}
},
'axis-ticks': {
enter: function enter() {
return Action.appear.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
update: function update(coord) {
if (coord.isPolar) {
return Action.appear.fadeIn;
}
}
},
'axis-grid': {
enter: function enter() {
return Action.appear.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
update: function update(coord) {
if (coord.isPolar) {
return Action.appear.fadeIn;
}
}
},
'axis-grid-rect': {
enter: function enter() {
return Action.appear.fadeIn;
},
leave: function leave() {
return Action.leave.fadeOut;
},
update: function update() {
return Action.leave.fadeIn;
}
},
labelLine: {
appear: function appear() {
return Action.appear.pathIn;
},
enter: function enter() {
return Action.enter.pathIn;
},
leave: function leave() {
return Action.leave.pathOut;
}
}
};
Animate.Action = Action;
Animate.defaultCfg = defaultAnimationCfg; // 获取动画
Animate.getAnimation = function (geomType, coord, animationType) {
var geomAnimateCfg = this[geomType];
if (geomAnimateCfg) {
var animation = geomAnimateCfg[animationType];
if (Util.isFunction(animation)) {
return animation(coord);
}
}
return false;
}; // 获取动画配置
Animate.getAnimateCfg = function (geomType, animationType) {
var defaultCfg = defaultAnimationCfg[animationType];
if (this[geomType] && this[geomType].cfg && this[geomType].cfg[animationType]) {
return Util.deepMix({}, defaultCfg, this[geomType].cfg[animationType]);
}
return defaultCfg;
}; // 注册动画
Animate.registerAnimation = function (animationType, animationName, animationFun) {
if (!this.Action[animationType]) {
this.Action[animationType] = {};
}
this.Action[animationType][animationName] = animationFun;
};
module.exports = Animate;
/***/ }),
/* 113 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview Chart、View、Geometry 的基类
* @author dxq613@gmail.com
*/
var EventEmitter = __webpack_require__(98);
var Util = __webpack_require__(0);
var Base =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(Base, _EventEmitter);
var _proto = Base.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {};
};
function Base(cfg) {
var _this;
_this = _EventEmitter.call(this) || this;
var attrs = {
visible: true
};
var defaultCfg = _this.getDefaultCfg();
_this._attrs = attrs;
Util.assign(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.show = function show() {
var visible = this.get('visible');
if (!visible) {
this.set('visible', true);
this.changeVisible(true);
}
};
_proto.hide = function hide() {
var visible = this.get('visible');
if (visible) {
this.set('visible', false);
this.changeVisible(false);
}
};
/**
* @protected
* @param {Boolean} visible 是否可见
* 显示、隐藏
*/
_proto.changeVisible = function changeVisible()
/* visible */
{};
_proto.destroy = function destroy() {
this._attrs = {};
this.removeAllListeners();
this.destroyed = true;
};
return Base;
}(EventEmitter);
module.exports = Base;
/***/ }),
/* 114 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview G2 图表的入口文件
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var View = __webpack_require__(273);
var G = __webpack_require__(23);
var Canvas = G.Canvas;
var DomUtil = Util.DomUtil;
var Global = __webpack_require__(5);
var Plot = __webpack_require__(277);
var Controller = __webpack_require__(115);
var mergeBBox = __webpack_require__(117);
var bboxOfBackPlot = __webpack_require__(116);
var plotRange2BBox = __webpack_require__(118);
var AUTO_STR = 'auto';
function _isScaleExist(scales, compareScale) {
var flag = false;
Util.each(scales, function (scale) {
var scaleValues = [].concat(scale.values);
var compareScaleValues = [].concat(compareScale.values);
if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort().toString() === compareScaleValues.sort().toString()) {
flag = true;
return;
}
});
return flag;
}
function isEqualArray(arr1, arr2) {
return Util.isEqualWith(arr1, arr2, function (v1, v2) {
return v1 === v2;
});
}
/**
* 图表的入口
* @class Chart
*/
var Chart =
/*#__PURE__*/
function (_View) {
_inheritsLoose(Chart, _View);
function Chart() {
return _View.apply(this, arguments) || this;
}
var _proto = Chart.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var viewCfg = _View.prototype.getDefaultCfg.call(this);
return Util.mix(viewCfg, {
id: null,
forceFit: false,
container: null,
wrapperEl: null,
canvas: null,
width: 500,
height: 500,
pixelRatio: null,
backPlot: null,
frontPlot: null,
plotBackground: null,
padding: Global.plotCfg.padding,
background: null,
autoPaddingAppend: 5,
limitInPlot: false,
renderer: Global.renderer,
// renderer: 'svg',
views: []
});
};
_proto.init = function init() {
var self = this;
var viewTheme = self.get('viewTheme');
self._initCanvas();
self._initPlot();
self._initEvents();
_View.prototype.init.call(this);
var tooltipController = new Controller.Tooltip({
chart: self,
viewTheme: viewTheme,
options: {}
});
self.set('tooltipController', tooltipController);
var legendController = new Controller.Legend({
chart: self,
viewTheme: viewTheme
});
self.set('legendController', legendController);
self.set('_id', 'chart'); // 防止同用户设定的 id 同名
self.emit('afterinit'); // 初始化完毕
};
_proto._isAutoPadding = function _isAutoPadding() {
var padding = this.get('padding');
if (Util.isArray(padding)) {
return padding.indexOf(AUTO_STR) !== -1;
}
return padding === AUTO_STR;
};
_proto._getAutoPadding = function _getAutoPadding() {
var padding = this.get('padding'); // 图例在最前面的一层
var frontPlot = this.get('frontPlot');
var frontBBox = frontPlot.getBBox(); // 坐标轴在最后面的一层
var backPlot = this.get('backPlot');
var backBBox = bboxOfBackPlot(backPlot, plotRange2BBox(this.get('plotRange')));
var box = mergeBBox(frontBBox, backBBox);
var outter = [0 - box.minY, // 上面超出的部分
box.maxX - this.get('width'), // 右边超出的部分
box.maxY - this.get('height'), // 下边超出的部分
0 - box.minX]; // 如果原始的 padding 内部存在 'auto' 则替换对应的边
var autoPadding = Util.toAllPadding(padding);
for (var i = 0; i < autoPadding.length; i++) {
if (autoPadding[i] === AUTO_STR) {
var tmp = Math.max(0, outter[i]);
autoPadding[i] = tmp + this.get('autoPaddingAppend');
}
}
return autoPadding;
}; // 初始化画布
_proto._initCanvas = function _initCanvas() {
var container = this.get('container');
var id = this.get('id'); // 如果未设置 container 使用 ID, 兼容 2.x 版本
if (!container && id) {
container = id;
this.set('container', id);
}
var width = this.get('width');
var height = this.get('height');
if (Util.isString(container)) {
container = document.getElementById(container);
if (!container) {
throw new Error('Please specify the container for the chart!');
}
this.set('container', container);
}
var wrapperEl = DomUtil.createDom('');
container.appendChild(wrapperEl);
this.set('wrapperEl', wrapperEl);
if (this.get('forceFit')) {
width = DomUtil.getWidth(container, width);
this.set('width', width);
}
var renderer = this.get('renderer');
var canvas = new Canvas({
containerDOM: wrapperEl,
width: width,
height: height,
// NOTICE: 有问题找青湳
pixelRatio: renderer === 'svg' ? 1 : this.get('pixelRatio'),
renderer: renderer
});
this.set('canvas', canvas);
}; // 初始化绘图区间
_proto._initPlot = function _initPlot() {
var self = this;
self._initPlotBack(); // 最底层的是背景相关的 group
var canvas = self.get('canvas');
var backPlot = canvas.addGroup({
zIndex: 1
}); // 图表最后面的容器
var plotContainer = canvas.addGroup({
zIndex: 0
}); // 图表所在的容器
var frontPlot = canvas.addGroup({
zIndex: 3
}); // 图表前面的容器
self.set('backPlot', backPlot);
self.set('middlePlot', plotContainer);
self.set('frontPlot', frontPlot);
}; // 初始化背景
_proto._initPlotBack = function _initPlotBack() {
var self = this;
var canvas = self.get('canvas');
var viewTheme = self.get('viewTheme');
var plot = canvas.addGroup(Plot, {
padding: this.get('padding'),
plotBackground: Util.mix({}, viewTheme.plotBackground, self.get('plotBackground')),
background: Util.mix({}, viewTheme.background, self.get('background'))
});
self.set('plot', plot);
self.set('plotRange', plot.get('plotRange'));
};
_proto._initEvents = function _initEvents() {
if (this.get('forceFit')) {
window.addEventListener('resize', Util.wrapBehavior(this, '_initForceFitEvent'));
}
};
_proto._initForceFitEvent = function _initForceFitEvent() {
var timer = setTimeout(Util.wrapBehavior(this, 'forceFit'), 200);
clearTimeout(this.get('resizeTimer'));
this.set('resizeTimer', timer);
}; // 绘制图例
_proto._renderLegends = function _renderLegends() {
var options = this.get('options');
var legendOptions = options.legends;
if (Util.isNil(legendOptions) || legendOptions !== false) {
// 没有关闭图例
var legendController = this.get('legendController');
legendController.options = legendOptions || {};
legendController.plotRange = this.get('plotRange');
if (legendOptions && legendOptions.custom) {
// 用户自定义图例
legendController.addCustomLegend();
} else {
var geoms = this.getAllGeoms();
var scales = [];
Util.each(geoms, function (geom) {
var view = geom.get('view');
var attrs = geom.getAttrsForLegend();
Util.each(attrs, function (attr) {
var type = attr.type;
var scale = attr.getScale(type);
if (scale.field && scale.type !== 'identity' && !_isScaleExist(scales, scale)) {
scales.push(scale);
var filteredValues = view.getFilteredOutValues(scale.field);
legendController.addLegend(scale, attr, geom, filteredValues);
}
});
}); // 双轴的情况
var yScales = this.getYScales();
if (scales.length === 0 && yScales.length > 1) {
legendController.addMixedLegend(yScales, geoms);
}
}
legendController.alignLegends();
}
}; // 绘制 tooltip
_proto._renderTooltips = function _renderTooltips() {
var options = this.get('options');
if (Util.isNil(options.tooltip) || options.tooltip !== false) {
// 用户没有关闭 tooltip
var tooltipController = this.get('tooltipController');
tooltipController.options = options.tooltip || {};
tooltipController.renderTooltip();
}
};
/**
* 获取所有的几何标记
* @return {Array} 所有的几何标记
*/
_proto.getAllGeoms = function getAllGeoms() {
var geoms = [];
geoms = geoms.concat(this.get('geoms'));
var views = this.get('views');
Util.each(views, function (view) {
geoms = geoms.concat(view.get('geoms'));
});
return geoms;
};
/**
* 自适应宽度
* @chainable
* @return {Chart} 图表对象
*/
_proto.forceFit = function forceFit() {
var self = this;
if (!self || self.destroyed) {
return;
}
var container = self.get('container');
var oldWidth = self.get('width');
var width = DomUtil.getWidth(container, oldWidth);
if (width !== 0 && width !== oldWidth) {
var height = self.get('height');
self.changeSize(width, height);
}
return self;
};
_proto.resetPlot = function resetPlot() {
var plot = this.get('plot');
var padding = this.get('padding');
if (!isEqualArray(padding, plot.get('padding'))) {
// 重置 padding,仅当padding 发生更改
plot.set('padding', padding);
plot.repaint();
}
};
/**
* 改变大小
* @param {Number} width 图表宽度
* @param {Number} height 图表高度
* @return {Chart} 图表对象
*/
_proto.changeSize = function changeSize(width, height) {
var self = this;
var canvas = self.get('canvas');
canvas.changeSize(width, height);
var plot = this.get('plot');
self.set('width', width);
self.set('height', height); // change size 时重新计算边框
plot.repaint(); // 保持边框不变,防止自动 padding 时绘制多遍
this.set('keepPadding', true);
self.repaint();
this.set('keepPadding', false);
this.emit('afterchangesize');
return self;
};
/**
* 改变宽度
* @param {Number} width 图表宽度
* @return {Chart} 图表对象
*/
_proto.changeWidth = function changeWidth(width) {
return this.changeSize(width, this.get('height'));
};
/**
* 改变宽度
* @param {Number} height 图表高度
* @return {Chart} 图表对象
*/
_proto.changeHeight = function changeHeight(height) {
return this.changeSize(this.get('width'), height);
};
/**
* 创建一个视图
* @param {Object} cfg 视图的配置项
* @return {View} 视图对象
*/
_proto.view = function view(cfg) {
cfg = cfg || {};
cfg.theme = this.get('theme');
cfg.parent = this;
cfg.backPlot = this.get('backPlot');
cfg.middlePlot = this.get('middlePlot');
cfg.frontPlot = this.get('frontPlot');
cfg.canvas = this.get('canvas');
if (Util.isNil(cfg.animate)) {
cfg.animate = this.get('animate');
}
cfg.options = Util.mix({}, this._getSharedOptions(), cfg.options);
var view = new View(cfg);
view.set('_id', 'view' + this.get('views').length); // 标识 ID,防止同用户设定的 id 重名
this.get('views').push(view);
this.emit('addview', {
view: view
});
return view;
}; // isShapeInView() {
// return true;
// }
_proto.removeView = function removeView(view) {
var views = this.get('views');
Util.Array.remove(views, view);
view.destroy();
};
_proto._getSharedOptions = function _getSharedOptions() {
var options = this.get('options');
var sharedOptions = {};
Util.each(['scales', 'coord', 'axes'], function (name) {
sharedOptions[name] = Util.cloneDeep(options[name]);
});
return sharedOptions;
};
/**
* @override
* 当前chart 的范围
*/
_proto.getViewRegion = function getViewRegion() {
var plotRange = this.get('plotRange');
return {
start: plotRange.bl,
end: plotRange.tr
};
};
/**
* 设置图例配置信息
* @param {String|Object} field 字段名
* @param {Object} [cfg] 图例的配置项
* @return {Chart} 当前的图表对象
*/
_proto.legend = function legend(field, cfg) {
var options = this.get('options');
if (!options.legends) {
options.legends = {};
}
var legends = {};
if (field === false) {
options.legends = false;
} else if (Util.isObject(field)) {
legends = field;
} else if (Util.isString(field)) {
legends[field] = cfg;
} else {
legends = cfg;
}
Util.mix(options.legends, legends);
return this;
};
/**
* 设置提示信息
* @param {String|Object} visible 是否可见
* @param {Object} [cfg] 提示信息的配置项
* @return {Chart} 当前的图表对象
*/
_proto.tooltip = function tooltip(visible, cfg) {
var options = this.get('options');
if (!options.tooltip) {
options.tooltip = {};
}
if (visible === false) {
options.tooltip = false;
} else if (Util.isObject(visible)) {
Util.mix(options.tooltip, visible);
} else {
Util.mix(options.tooltip, cfg);
}
return this;
};
/**
* 清空图表
* @return {Chart} 当前的图表对象
*/
_proto.clear = function clear() {
this.emit('beforeclear');
var views = this.get('views');
while (views.length > 0) {
var view = views.shift();
view.destroy();
}
_View.prototype.clear.call(this);
var canvas = this.get('canvas');
this.resetPlot();
canvas.draw();
this.emit('afterclear');
return this;
};
_proto.clearInner = function clearInner() {
var views = this.get('views');
Util.each(views, function (view) {
view.clearInner();
});
var tooltipController = this.get('tooltipController');
tooltipController && tooltipController.clear();
if (!this.get('keepLegend')) {
var legendController = this.get('legendController');
legendController && legendController.clear();
}
_View.prototype.clearInner.call(this);
}; // chart 除了view 上绘制的组件外,还会绘制图例和 tooltip
_proto.drawComponents = function drawComponents() {
_View.prototype.drawComponents.call(this); // 一般是点击图例时,仅仅隐藏某些选项,而不销毁图例
if (!this.get('keepLegend')) {
this._renderLegends(); // 渲染图例
}
};
/**
* 绘制图表
* @override
*/
_proto.render = function render() {
var self = this; // 需要自动计算边框,则重新设置
if (!self.get('keepPadding') && self._isAutoPadding()) {
self.beforeRender(); // 初始化各个 view 和 绘制
self.drawComponents();
var autoPadding = self._getAutoPadding();
var plot = self.get('plot'); // 在计算出来的边框不一致的情况,重新改变边框
if (!isEqualArray(plot.get('padding'), autoPadding)) {
plot.set('padding', autoPadding);
plot.repaint();
}
}
var middlePlot = self.get('middlePlot');
if (self.get('limitInPlot') && !middlePlot.attr('clip')) {
var clip = Util.getClipByRange(self.get('plotRange')); // TODO Polar coord
middlePlot.attr('clip', clip); // clip.attr('fill', 'grey');
// clip.attr('opacity', 0.5);
// middlePlot.add(clip);
}
_View.prototype.render.call(this);
self._renderTooltips(); // 渲染 tooltip
};
_proto.repaint = function repaint() {
// 重绘时需要判定当前的 padding 是否发生过改变,如果发生过改变进行调整
// 需要判定是否使用了自动 padding
if (!this.get('keepPadding')) {
this.resetPlot();
}
_View.prototype.repaint.call(this);
};
/**
* @override
* 显示或者隐藏
*/
_proto.changeVisible = function changeVisible(visible) {
var wrapperEl = this.get('wrapperEl');
var visibleStr = visible ? '' : 'none';
wrapperEl.style.display = visibleStr;
};
/**
* 返回图表的 dataUrl 用于生成图片
* @return {String} dataUrl 路径
*/
_proto.toDataURL = function toDataURL() {
var chart = this;
var canvas = chart.get('canvas');
var renderer = chart.get('renderer');
var canvasDom = canvas.get('el');
var dataURL = '';
if (renderer === 'svg') {
var clone = canvasDom.cloneNode(true);
var svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
var svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
svgDoc.replaceChild(clone, svgDoc.documentElement);
var svgData = new XMLSerializer().serializeToString(svgDoc);
dataURL = 'data:image/svg+xml;charset=utf8,' + encodeURIComponent(svgData);
} else if (renderer === 'canvas') {
dataURL = canvasDom.toDataURL('image/png');
}
return dataURL;
};
/**
* 图表导出功能
* @param {String} [name] 图片的名称,默认为 chart(.png|.svg)
*/
_proto.downloadImage = function downloadImage(name) {
var chart = this;
var link = document.createElement('a');
var renderer = chart.get('renderer');
var filename = (name || 'chart') + (renderer === 'svg' ? '.svg' : '.png');
var canvas = chart.get('canvas');
canvas.get('timeline').stopAllAnimations();
setTimeout(function () {
var dataURL = chart.toDataURL();
if (window.Blob && window.URL && renderer !== 'svg') {
var arr = dataURL.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
var blobObj = new Blob([u8arr], {
type: mime
});
if (window.navigator.msSaveBlob) {
window.navigator.msSaveBlob(blobObj, filename);
} else {
link.addEventListener('click', function () {
link.download = filename;
link.href = window.URL.createObjectURL(blobObj);
});
}
} else {
link.addEventListener('click', function () {
link.download = filename;
link.href = dataURL;
});
}
var e = document.createEvent('MouseEvents');
e.initEvent('click', false, false);
link.dispatchEvent(e);
}, 16);
};
/**
* 根据坐标点显示对应的 tooltip
* @param {Object} point 画布上的点
* @return {Chart} 返回 chart 实例
*/
_proto.showTooltip = function showTooltip(point) {
var views = this.getViewsByPoint(point);
if (views.length) {
var tooltipController = this.get('tooltipController');
tooltipController.showTooltip(point, views);
}
return this;
};
/**
* 隐藏 tooltip
* @return {Chart} 返回 chart 实例
*/
_proto.hideTooltip = function hideTooltip() {
var tooltipController = this.get('tooltipController');
tooltipController.hideTooltip();
return this;
};
/**
* 根据传入的画布坐标,获取该处的 tooltip 上的记录信息
* @param {Object} point 画布坐标点
* @return {Array} 返回结果
*/
_proto.getTooltipItems = function getTooltipItems(point) {
var self = this;
var views = self.getViewsByPoint(point);
var rst = [];
Util.each(views, function (view) {
var geoms = view.get('geoms');
Util.each(geoms, function (geom) {
var dataArray = geom.get('dataArray');
var items = [];
Util.each(dataArray, function (data) {
var tmpPoint = geom.findPoint(point, data);
if (tmpPoint) {
var subItems = geom.getTipItems(tmpPoint);
items = items.concat(subItems);
}
});
rst = rst.concat(items);
});
});
return rst;
};
/**
* @override
* 销毁图表
*/
_proto.destroy = function destroy() {
this.emit('beforedestroy');
clearTimeout(this.get('resizeTimer'));
var canvas = this.get('canvas');
var wrapperEl = this.get('wrapperEl');
wrapperEl.parentNode.removeChild(wrapperEl);
_View.prototype.destroy.call(this);
canvas.destroy();
window.removeEventListener('resize', Util.getWrapBehavior(this, '_initForceFitEvent'));
this.emit('afterdestroy');
};
return Chart;
}(View);
module.exports = Chart;
/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
Scale: __webpack_require__(271),
Coord: __webpack_require__(267),
Axis: __webpack_require__(266),
Guide: __webpack_require__(269),
Legend: __webpack_require__(270),
Tooltip: __webpack_require__(272),
Event: __webpack_require__(268)
};
/***/ }),
/* 116 */
/***/ (function(module, exports, __webpack_require__) {
var G = __webpack_require__(23);
var Util = __webpack_require__(0);
var mergeBBox = __webpack_require__(117);
function applyMatrix(point, matrix, tag) {
if (tag === void 0) {
tag = 1;
}
var vector = [point.x, point.y, tag];
Util.vec3.transformMat3(vector, vector, matrix);
return {
x: vector[0],
y: vector[1]
};
}
function getTitleBBox(title) {
var bbox = title.getBBox();
var leftTop = {
x: bbox.minX,
y: bbox.minY
};
var rightBottom = {
x: bbox.maxX,
y: bbox.maxY
};
var matrix = title.attr('matrix');
leftTop = applyMatrix(leftTop, matrix);
rightBottom = applyMatrix(rightBottom, matrix);
return {
minX: leftTop.x,
minY: leftTop.y,
maxX: rightBottom.x,
maxY: rightBottom.y
};
}
module.exports = function BBoxOfBackPlot(backPlot, defaultBBox) {
var bbox = defaultBBox;
Util.each(backPlot.get('children'), function (element) {
if (element instanceof G.Group && element.get('children').length || element instanceof G.Path) {
bbox = mergeBBox(bbox, element.getBBox());
} else if (element instanceof G.Text) {
// title
var elementBBox = getTitleBBox(element);
var dx = Math.abs(elementBBox.maxX - elementBBox.minX);
var dy = Math.abs(elementBBox.maxY - elementBBox.minY);
if (dx < dy) {
bbox = mergeBBox(bbox, Util.mix(bbox, {
minX: Math.min(bbox.minX, elementBBox.minX),
maxX: Math.max(bbox.maxX, elementBBox.maxX)
}));
} else {
bbox = mergeBBox(bbox, Util.mix(bbox, {
minY: Math.min(bbox.minY, elementBBox.minY),
maxY: Math.max(bbox.maxY, elementBBox.maxY)
}));
}
}
});
return bbox;
};
/***/ }),
/* 117 */
/***/ (function(module, exports) {
module.exports = function mergeBBox(box1, box2) {
return {
minX: Math.min(box1.minX, box2.minX),
minY: Math.min(box1.minY, box2.minY),
maxX: Math.max(box1.maxX, box2.maxX),
maxY: Math.max(box1.maxY, box2.maxY)
};
};
/***/ }),
/* 118 */
/***/ (function(module, exports) {
module.exports = function plotRange2BBox(plotRange) {
return {
minX: plotRange.tl.x,
minY: plotRange.tl.y,
maxX: plotRange.br.x,
maxY: plotRange.br.y
};
};
/***/ }),
/* 119 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview list facets, support cols
*/
var Base = __webpack_require__(43);
/**
* 用于生成分面的类
* @class Facets.List
*/
var List =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(List, _Base);
function List() {
return _Base.apply(this, arguments) || this;
}
var _proto = List.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
cfg.type = 'list';
cfg.cols = null; // 用户不设置时就显示一行
return cfg;
};
_proto.generateFacets = function generateFacets(data) {
var self = this;
var fields = self.fields;
var colField = fields[0];
if (!colField) {
throw 'Please specify for the field for facet!';
}
var colValues = self.getFieldValues(colField, data);
var count = colValues.length;
var cols = self.cols || count;
var rows = parseInt((count + cols - 1) / cols);
var rst = [];
colValues.forEach(function (xVal, index) {
var row = parseInt(index / cols);
var col = index % cols;
var conditions = [{
field: colField,
value: xVal,
values: colValues
}];
var filter = self.getFilter(conditions);
var subData = data.filter(filter);
var facet = {
type: self.type,
count: count,
colValue: xVal,
colField: colField,
rowField: null,
rowValue: xVal,
colIndex: col,
rowIndex: row,
cols: cols,
rows: rows,
data: subData,
region: self.getRegion(rows, cols, col, row)
};
rst.push(facet);
});
return rst;
}; // 设置 x 坐标轴的文本、title 是否显示
_proto.setXAxis = function setXAxis(xField, axes, facet) {
// 当是最后一行或者下面没有 view 时文本不显示
if (facet.rowIndex !== facet.rows - 1 && facet.cols * facet.rowIndex + facet.colIndex + 1 + facet.cols <= facet.count) {
axes[xField].label = null;
axes[xField].title = null;
}
}; // 设置 y 坐标轴的文本、title 是否显示
_proto.setYAxis = function setYAxis(yField, axes, facet) {
if (facet.colIndex !== 0) {
axes[yField].title = null;
axes[yField].label = null;
}
};
return List;
}(Base);
module.exports = List;
/***/ }),
/* 120 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 分面的基类
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(43);
/**
* 矩形的 facet 有以下属性:
* - colField 列的字段
* - rowField 行的字段
* - colValue 列字段的值
* - rowValue 行字段的值
* - cols 列数
* - rows 行数
* - colIndex 列的序号
* - rowIndex 行的序号
*/
/**
* 用于生成分面的类
* @class Facets.Rect
*/
var Rect =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Rect, _Base);
function Rect() {
return _Base.apply(this, arguments) || this;
}
var _proto = Rect.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
cfg.type = 'rect';
return cfg;
};
_proto.generateFacets = function generateFacets(data) {
var self = this;
var fields = self.fields; // var defs = self.defs;
var rst = [];
var rows = 1;
var cols = 1;
var colField = fields[0];
var rowField = fields[1];
var colValues = [''];
var rowValues = [''];
if (colField) {
colValues = self.getFieldValues(colField, data);
cols = colValues.length;
}
if (rowField) {
rowValues = self.getFieldValues(rowField, data);
rows = rowValues.length;
} // 获取每个维度对应的frame
colValues.forEach(function (xVal, xIndex) {
rowValues.forEach(function (yVal, yIndex) {
var conditions = [{
field: colField,
value: xVal,
values: colValues
}, {
field: rowField,
value: yVal,
values: rowValues
}];
var filter = self.getFilter(conditions);
var subData = data.filter(filter);
var facet = {
type: self.type,
colValue: xVal,
rowValue: yVal,
colField: colField,
rowField: rowField,
colIndex: xIndex,
rowIndex: yIndex,
cols: cols,
rows: rows,
data: subData,
region: self.getRegion(rows, cols, xIndex, yIndex)
};
rst.push(facet);
});
});
return rst;
}; // 设置 x 坐标轴的文本、title 是否显示
_proto.setXAxis = function setXAxis(xField, axes, facet) {
if (facet.rowIndex !== facet.rows - 1) {
axes[xField].title = null;
axes[xField].label = null;
} else if (facet.colIndex !== parseInt((facet.cols - 1) / 2)) {
axes[xField].title = null;
}
}; // 设置 y 坐标轴的文本、title 是否显示
_proto.setYAxis = function setYAxis(yField, axes, facet) {
if (facet.colIndex !== 0) {
axes[yField].title = null;
axes[yField].label = null;
} else if (facet.rowIndex !== parseInt((facet.rows - 1) / 2)) {
axes[yField].title = null;
}
};
_proto.renderTitle = function renderTitle(view, facet) {
if (facet.rowIndex === 0) {
this.drawColTitle(view, facet);
}
if (facet.colIndex === facet.cols - 1) {
this.drawRowTitle(view, facet);
}
};
return Rect;
}(Base);
module.exports = Rect;
/***/ }),
/* 121 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Labels = __webpack_require__(66);
var PathUtil = __webpack_require__(25);
var Util = __webpack_require__(0);
var PolarLabels =
/*#__PURE__*/
function (_Labels) {
_inheritsLoose(PolarLabels, _Labels);
function PolarLabels() {
return _Labels.apply(this, arguments) || this;
}
var _proto = PolarLabels.prototype;
_proto.getPointRauis = function getPointRauis(coord, point) {
return PathUtil.getPointRadius(coord, point);
};
_proto.getCirclePoint = function getCirclePoint(angle, offset, point) {
var self = this;
var coord = self.get('coord');
var center = coord.getCenter();
var labelEmit = self._isEmitLabels();
var r = self.getPointRauis(coord, point);
if (r === 0) {
return null;
}
if (coord.isTransposed && r > offset && !labelEmit) {
var appendAngle = Math.asin(offset / (2 * r));
angle = angle + appendAngle * 2;
} else {
r = r + offset;
}
return {
x: center.x + r * Math.cos(angle),
y: center.y + r * Math.sin(angle),
angle: angle,
r: r
};
};
_proto.getArcPoint = function getArcPoint(point, index) {
var self = this;
var outerPoint; // 圆弧上的中点
// var coord = self.get('coord');
index = index || 0;
if (Util.isArray(point.x) || Util.isArray(point.y)) {
outerPoint = {
x: Util.isArray(point.x) ? point.x[index] : point.x,
y: Util.isArray(point.y) ? point.y[index] : point.y
};
} else {
outerPoint = point;
}
self.transLabelPoint(outerPoint);
return outerPoint;
}; // 获取点所在的角度
_proto.getPointAngle = function getPointAngle(point) {
var self = this;
var coord = self.get('coord');
return PathUtil.getPointAngle(coord, point);
}; // 获取中心的位置
_proto.getMiddlePoint = function getMiddlePoint(points) {
var self = this;
var coord = self.get('coord');
var count = points.length;
var middlePoint = {
x: 0,
y: 0
};
Util.each(points, function (point) {
middlePoint.x += point.x;
middlePoint.y += point.y;
});
middlePoint.x /= count;
middlePoint.y /= count;
middlePoint = coord.convert(middlePoint);
return middlePoint;
}; // 是否居中
_proto._isToMiddle = function _isToMiddle(point) {
return point.x.length > 2;
};
/**
* @protected
* 获取文本的位置信息
* @param {Array} label labels
* @param {Object} point point
* @param {Number} index index
* @return {Object} point
*/
_proto.getLabelPoint = function getLabelPoint(label, point, index) {
// if (Util.isNil(point.x)) return;
var self = this;
var text = label.text[index];
var factor = 1;
var arcPoint;
if (self._isToMiddle(point)) {
arcPoint = self.getMiddlePoint(point.points);
} else {
if (label.text.length === 1 && index === 0) {
index = 1;
} else if (index === 0) {
factor = -1;
}
arcPoint = self.getArcPoint(point, index);
}
var offset = self.getDefaultOffset(label);
offset = offset * factor;
var middleAngle = self.getPointAngle(arcPoint);
var labelPoint = self.getCirclePoint(middleAngle, offset, arcPoint);
if (!labelPoint) {
labelPoint = {
text: ''
};
} else {
labelPoint.text = text;
labelPoint.angle = middleAngle;
labelPoint.color = point.color;
}
if (label.autoRotate || typeof label.autoRotate === 'undefined') {
var rotate = labelPoint.textStyle ? labelPoint.textStyle.rotate : null;
if (!rotate) {
rotate = labelPoint.rotate || self.getLabelRotate(middleAngle, offset, point);
}
labelPoint.rotate = rotate;
}
labelPoint.start = {
x: arcPoint.x,
y: arcPoint.y
};
return labelPoint;
};
_proto._isEmitLabels = function _isEmitLabels() {
var labels = this.get('label');
return labels.labelEmit;
};
/**
* @protected
* 获取文本旋转的方向
* @param {Number} angle angle
* @return {Number} angle
*/
_proto.getLabelRotate = function getLabelRotate(angle) {
var self = this;
var rotate;
rotate = angle * 180 / Math.PI;
rotate += 90;
if (self._isEmitLabels()) {
rotate -= 90;
}
if (rotate) {
if (rotate > 90) {
rotate = rotate - 180;
} else if (rotate < -90) {
rotate = rotate + 180;
}
}
return rotate / 180 * Math.PI;
}; // override
_proto.getLabelAlign = function getLabelAlign(point) {
var self = this;
var coord = self.get('coord');
var align;
if (self._isEmitLabels()) {
if (point.angle <= Math.PI / 2 && point.angle > -Math.PI / 2) {
align = 'left';
} else {
align = 'right';
}
} else if (!coord.isTransposed) {
align = 'center';
} else {
var center = coord.getCenter();
var offset = self.getDefaultOffset(point);
if (Math.abs(point.x - center.x) < 1) {
align = 'center';
} else if (point.angle > Math.PI || point.angle <= 0) {
if (offset > 0) {
align = 'left';
} else {
align = 'right';
}
} else {
if (offset > 0) {
align = 'right';
} else {
align = 'left';
}
}
}
return align;
};
return PolarLabels;
}(Labels);
module.exports = PolarLabels;
/***/ }),
/* 122 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 分割数据用于处理存在 null 值的折线图、区域图
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var Global = __webpack_require__(5);
module.exports = {
splitData: function splitData(data) {
var viewTheme = this.get('viewTheme') || Global;
if (!data.length) return [];
var arr = [];
var tmp = [];
var yScale = this.getYScale();
var yDim = yScale.field;
var yValue;
Util.each(data, function (obj) {
yValue = obj._origin ? obj._origin[yDim] : obj[yDim];
if (viewTheme.connectNulls) {
// 如果忽视 Null 直接连接节点,则将 value = null 的数据过滤掉
if (!Util.isNil(yValue)) {
tmp.push(obj);
}
} else {
if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
if (tmp.length) {
arr.push(tmp);
tmp = [];
}
} else {
tmp.push(obj);
}
}
});
if (tmp.length) {
arr.push(tmp);
}
return arr;
}
};
/***/ }),
/* 123 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview 路径图,无序的线图
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var SplitMixin = __webpack_require__(122);
var Util = __webpack_require__(0);
var Path =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Path, _GeomBase);
var _proto = Path.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'path';
cfg.shapeType = 'line';
return cfg;
};
function Path(cfg) {
var _this;
_this = _GeomBase.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), SplitMixin);
return _this;
}
_proto.getDrawCfg = function getDrawCfg(obj) {
var cfg = _GeomBase.prototype.getDrawCfg.call(this, obj);
cfg.isStack = this.hasStack();
return cfg;
};
_proto.draw = function draw(data, container, shapeFactory, index) {
var self = this;
var splitArray = this.splitData(data);
var cfg = this.getDrawCfg(data[0]);
self._applyViewThemeShapeStyle(cfg, cfg.shape, shapeFactory);
cfg.origin = data; // path,line 等图的origin 是整个序列
Util.each(splitArray, function (subData, splitedIndex) {
if (!Util.isEmpty(subData)) {
cfg.splitedIndex = splitedIndex; // 传入分割片段索引 用于生成id
cfg.points = subData;
var geomShape = shapeFactory.drawShape(cfg.shape, cfg, container);
self.appendShapeInfo(geomShape, index + splitedIndex);
}
});
};
return Path;
}(GeomBase);
GeomBase.Path = Path;
module.exports = Path;
/***/ }),
/* 124 */
/***/ (function(module, exports) {
var _html, _tooltip;
/**
* @fileOverview G2 3.0 default theme
* @author sima.zhang
*/
var DEFAULT_COLOR = '#1890FF';
var COLOR_PLATE_8 = ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'];
var COLOR_PLATE_16 = ['#1890FF', '#41D9C7', '#2FC25B', '#FACC14', '#E6965C', '#223273', '#7564CC', '#8543E0', '#5C8EE6', '#13C2C2', '#5CA3E6', '#3436C7', '#B381E6', '#F04864', '#D598D9'];
var COLOR_PLATE_24 = ['#1890FF', '#66B5FF', '#41D9C7', '#2FC25B', '#6EDB8F', '#9AE65C', '#FACC14', '#E6965C', '#57AD71', '#223273', '#738AE6', '#7564CC', '#8543E0', '#A877ED', '#5C8EE6', '#13C2C2', '#70E0E0', '#5CA3E6', '#3436C7', '#8082FF', '#DD81E6', '#F04864', '#FA7D92', '#D598D9'];
var COLOR_PIE = ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'];
var COLOR_PIE_16 = ['#1890FF', '#73C9E6', '#13C2C2', '#6CD9B3', '#2FC25B', '#9DD96C', '#FACC14', '#E6965C', '#F04864', '#D66BCA', '#8543E0', '#8E77ED', '#3436C7', '#737EE6', '#223273', '#7EA2E6'];
var FONT_FAMILY = '"-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto,"Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",SimSun, "sans-serif"'; // tooltip 相关 dom 的 css 类名
var TOOLTIP_CONTAINER_CLASS = 'g2-tooltip';
var TOOLTIP_TITLE_CLASS = 'g2-tooltip-title';
var TOOLTIP_LIST_CLASS = 'g2-tooltip-list';
var TOOLTIP_LIST_ITEM_CLASS = 'g2-tooltip-list-item';
var TOOLTIP_MARKER_CLASS = 'g2-tooltip-marker';
var TOOLTIP_VALUE_CLASS = 'g2-tooltip-value'; // html 渲染的 legend 相关 dom 的 css 类型
var LEGEND_CONTAINER_CLASS = 'g2-legend';
var LEGEND_TITLE_CLASS = 'g2-legend-title';
var LEGEND_LIST_CLASS = 'g2-legend-list';
var LEGEND_LIST_ITEM_CLASS = 'g2-legend-list-item';
var LEGEND_MARKER_CLASS = 'g2-legend-marker';
var Theme = {
defaultColor: DEFAULT_COLOR,
// 默认主题色
plotCfg: {
padding: [20, 20, 95, 80]
},
fontFamily: FONT_FAMILY,
defaultLegendPosition: 'bottom',
// 默认图例的展示位置
colors: COLOR_PLATE_8,
colors_16: COLOR_PLATE_16,
colors_24: COLOR_PLATE_24,
colors_pie: COLOR_PIE,
colors_pie_16: COLOR_PIE_16,
shapes: {
point: ['hollowCircle', 'hollowSquare', 'hollowDiamond', 'hollowBowtie', 'hollowTriangle', 'hollowHexagon', 'cross', 'tick', 'plus', 'hyphen', 'line'],
line: ['line', 'dash', 'dot'],
area: ['area']
},
sizes: [1, 10],
opacities: [0.1, 0.9],
axis: {
top: {
// zIndex: 1, // 默认上下方向的坐标轴位于左右坐标轴的上方
position: 'top',
title: null,
label: {
offset: 16,
textStyle: {
fill: '#545454',
fontSize: 12,
lineHeight: 16,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
},
autoRotate: true
},
line: {
lineWidth: 1,
stroke: '#BFBFBF'
},
tickLine: {
lineWidth: 1,
stroke: '#BFBFBF',
length: 4,
alignWithLabel: true
}
},
bottom: {
position: 'bottom',
title: null,
label: {
offset: 16,
autoRotate: true,
textStyle: {
fill: '#545454',
fontSize: 12,
lineHeight: 16,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}
},
line: {
lineWidth: 1,
stroke: '#BFBFBF'
},
tickLine: {
lineWidth: 1,
stroke: '#BFBFBF',
length: 4,
alignWithLabel: true
}
},
left: {
position: 'left',
title: null,
label: {
offset: 8,
autoRotate: true,
textStyle: {
fill: '#545454',
fontSize: 12,
lineHeight: 16,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}
},
line: null,
tickLine: null,
grid: {
zIndex: -1,
lineStyle: {
stroke: '#E9E9E9',
lineWidth: 1,
lineDash: [3, 3]
},
hideFirstLine: true
}
},
right: {
position: 'right',
title: null,
label: {
offset: 8,
autoRotate: true,
textStyle: {
fill: '#545454',
fontSize: 12,
lineHeight: 16,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}
},
line: null,
tickLine: null,
grid: {
lineStyle: {
stroke: '#E9E9E9',
lineWidth: 1,
lineDash: [3, 3]
},
hideFirstLine: true
}
},
circle: {
zIndex: 1,
title: null,
label: {
offset: 8,
textStyle: {
fill: '#545454',
fontSize: 12,
lineHeight: 16,
fontFamily: FONT_FAMILY
}
},
line: {
lineWidth: 1,
stroke: '#BFBFBF'
},
tickLine: {
lineWidth: 1,
stroke: '#BFBFBF',
length: 4,
alignWithLabel: true
},
grid: {
lineStyle: {
stroke: '#E9E9E9',
lineWidth: 1,
lineDash: [3, 3]
},
hideFirstLine: true
}
},
radius: {
zIndex: 0,
label: {
offset: 12,
textStyle: {
fill: '#545454',
fontSize: 12,
textBaseline: 'middle',
lineHeight: 16,
fontFamily: FONT_FAMILY
}
},
line: {
lineWidth: 1,
stroke: '#BFBFBF'
},
tickLine: {
lineWidth: 1,
stroke: '#BFBFBF',
length: 4,
alignWithLabel: true
},
grid: {
lineStyle: {
stroke: '#E9E9E9',
lineWidth: 1,
lineDash: [3, 3]
},
type: 'circle'
}
},
helix: {
grid: null,
label: null,
title: null,
line: {
lineWidth: 1,
stroke: '#BFBFBF'
},
tickLine: {
lineWidth: 1,
length: 4,
stroke: '#BFBFBF',
alignWithLabel: true
}
}
},
label: {
offset: 20,
textStyle: {
fill: '#545454',
fontSize: 12,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}
},
treemapLabels: {
offset: 10,
textStyle: {
fill: '#fff',
fontSize: 12,
textBaseline: 'top',
fontStyle: 'bold',
fontFamily: FONT_FAMILY
}
},
innerLabels: {
textStyle: {
fill: '#fff',
fontSize: 12,
textBaseline: 'middle',
fontFamily: FONT_FAMILY
}
},
// 在theta坐标系下的饼图文本内部的样式
thetaLabels: {
labelHeight: 14,
offset: 30 // 在theta坐标系下的饼图文本的样式
},
legend: {
right: {
position: 'right',
layout: 'vertical',
itemMarginBottom: 8,
// layout 为 vertical 时各个图例项的间距
width: 16,
height: 156,
title: null,
legendStyle: {
LIST_CLASS: {
textAlign: 'left'
}
},
textStyle: {
fill: '#8C8C8C',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
lineHeight: 0,
fontFamily: FONT_FAMILY
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
left: {
position: 'left',
layout: 'vertical',
itemMarginBottom: 8,
width: 16,
height: 156,
title: null,
textStyle: {
fill: '#8C8C8C',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
lineHeight: 20,
fontFamily: FONT_FAMILY
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
top: {
position: 'top',
offset: [0, 6],
layout: 'horizontal',
title: null,
itemGap: 10,
width: 156,
height: 16,
textStyle: {
fill: '#8C8C8C',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
lineHeight: 20,
fontFamily: FONT_FAMILY
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
bottom: {
position: 'bottom',
offset: [0, 6],
layout: 'horizontal',
title: null,
itemGap: 10,
width: 156,
height: 16,
textStyle: {
fill: '#8C8C8C',
fontSize: 12,
textAlign: 'start',
textBaseline: 'middle',
lineHeight: 20,
fontFamily: FONT_FAMILY
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
// 定义 html 渲染图例的样式
html: (_html = {}, _html["" + LEGEND_CONTAINER_CLASS] = {
height: 'auto',
width: 'auto',
position: 'absolute',
overflow: 'auto',
fontSize: '12px',
fontFamily: FONT_FAMILY,
lineHeight: '20px',
color: '#8C8C8C'
}, _html["" + LEGEND_TITLE_CLASS] = {
marginBottom: '4px'
}, _html["" + LEGEND_LIST_CLASS] = {
listStyleType: 'none',
margin: 0,
padding: 0
}, _html["" + LEGEND_LIST_ITEM_CLASS] = {
cursor: 'pointer',
marginBottom: '5px',
marginRight: '24px'
}, _html["" + LEGEND_MARKER_CLASS] = {
width: '9px',
height: '9px',
borderRadius: '50%',
display: 'inline-block',
marginRight: '8px',
verticalAlign: 'middle'
}, _html),
// 不能滑动的连续图例样式
gradient: {
textStyle: {
fill: '#8C8C8C',
fontSize: 12,
textAlign: 'center',
textBaseline: 'middle',
lineHeight: 20,
fontFamily: FONT_FAMILY
},
// 图例项文本的样式
lineStyle: {
lineWidth: 1,
stroke: '#fff'
},
unCheckColor: '#bfbfbf'
},
margin: [0, 5, 24, 5],
// 图例跟四个边的坐标轴、绘图区域的间距
legendMargin: 24 // 图例之间的间距
},
tooltip: (_tooltip = {
useHtml: true,
crosshairs: false,
offset: 15
}, _tooltip["" + TOOLTIP_CONTAINER_CLASS] = {
position: 'absolute',
visibility: 'hidden',
// @2018-07-25 by blue.lb 这里去掉浮动,火狐上存在样式错位
// whiteSpace: 'nowrap',
zIndex: 8,
transition: 'visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)',
backgroundColor: 'rgba(255, 255, 255, 0.9)',
boxShadow: '0px 0px 10px #aeaeae',
borderRadius: '3px',
color: 'rgb(87, 87, 87)',
fontSize: '12px',
fontFamily: FONT_FAMILY,
lineHeight: '20px',
padding: '10px 10px 6px 10px'
}, _tooltip["" + TOOLTIP_TITLE_CLASS] = {
marginBottom: '4px'
}, _tooltip["" + TOOLTIP_LIST_CLASS] = {
margin: 0,
listStyleType: 'none',
padding: 0
}, _tooltip["" + TOOLTIP_LIST_ITEM_CLASS] = {
marginBottom: '4px'
}, _tooltip["" + TOOLTIP_MARKER_CLASS] = {
width: '5px',
height: '5px',
borderRadius: '50%',
display: 'inline-block',
marginRight: '8px'
}, _tooltip["" + TOOLTIP_VALUE_CLASS] = {
display: 'inline-block',
float: 'right',
marginLeft: '30px'
}, _tooltip),
tooltipMarker: {
symbol: function symbol(x, y, r) {
return [['M', x, y], ['m', -r, 0], ['a', r, r, 0, 1, 0, r * 2, 0], ['a', r, r, 0, 1, 0, -r * 2, 0]];
},
stroke: '#fff',
shadowBlur: 10,
shadowOffsetX: 0,
shadowOffSetY: 0,
shadowColor: 'rgba(0,0,0,0.09)',
lineWidth: 2,
radius: 4
},
// 提示信息在折线图、区域图上形成点的样式
tooltipCrosshairsRect: {
type: 'rect',
rectStyle: {
fill: '#CCD6EC',
opacity: 0.3
}
},
// tooltip 辅助背景框样式
tooltipCrosshairsLine: {
lineStyle: {
stroke: 'rgba(0, 0, 0, 0.25)',
lineWidth: 1
}
},
shape: {
point: {
lineWidth: 1,
fill: DEFAULT_COLOR,
radius: 4
},
hollowPoint: {
fill: '#fff',
lineWidth: 1,
stroke: DEFAULT_COLOR,
radius: 3
},
interval: {
lineWidth: 0,
fill: DEFAULT_COLOR,
fillOpacity: 0.85
},
hollowInterval: {
fill: '#fff',
stroke: DEFAULT_COLOR,
fillOpacity: 0,
lineWidth: 2
},
area: {
lineWidth: 0,
fill: DEFAULT_COLOR,
fillOpacity: 0.6
},
polygon: {
lineWidth: 0,
fill: DEFAULT_COLOR,
fillOpacity: 1
},
hollowPolygon: {
fill: '#fff',
stroke: DEFAULT_COLOR,
fillOpacity: 0,
lineWidth: 2
},
hollowArea: {
fill: '#fff',
stroke: DEFAULT_COLOR,
fillOpacity: 0,
lineWidth: 2
},
line: {
stroke: DEFAULT_COLOR,
lineWidth: 2,
fill: null
},
edge: {
stroke: DEFAULT_COLOR,
lineWidth: 1,
fill: null
},
schema: {
stroke: DEFAULT_COLOR,
lineWidth: 1,
fill: null
}
},
guide: {
line: {
lineStyle: {
stroke: 'rgba(0, 0, 0, .65)',
lineDash: [2, 2],
lineWidth: 1
},
text: {
position: 'start',
autoRotate: true,
style: {
fill: 'rgba(0, 0, 0, .45)',
fontSize: 12,
textAlign: 'start',
fontFamily: FONT_FAMILY,
textBaseline: 'bottom'
}
}
},
text: {
style: {
fill: 'rgba(0,0,0,.5)',
fontSize: 12,
textBaseline: 'middle',
textAlign: 'start',
fontFamily: FONT_FAMILY
}
},
region: {
style: {
lineWidth: 0,
// 辅助框的边框宽度
fill: '#000',
// 辅助框填充的颜色
fillOpacity: 0.04 // 辅助框的背景透明度
// 辅助框的图形样式属性
}
},
html: {
alignX: 'middle',
alignY: 'middle'
},
dataRegion: {
style: {
region: {
lineWidth: 0,
fill: '#000000',
opacity: 0.04
},
text: {
textAlign: 'center',
textBaseline: 'bottom',
fontSize: 12,
fill: 'rgba(0, 0, 0, .65)'
}
}
},
dataMarker: {
top: true,
style: {
point: {
r: 3,
fill: '#FFFFFF',
stroke: '#1890FF',
lineWidth: 2
},
line: {
stroke: '#A3B1BF',
lineWidth: 1
},
text: {
fill: 'rgba(0, 0, 0, .65)',
opacity: 1,
fontSize: 12,
textAlign: 'start'
}
},
display: {
point: true,
line: true,
text: true
},
lineLength: 20,
direction: 'upward',
autoAdjust: true
}
},
pixelRatio: null
};
module.exports = Theme;
/***/ }),
/* 125 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview Theme entry
* @author sima.zhang
*/
var Theme = {
default: __webpack_require__(124),
dark: __webpack_require__(311)
};
module.exports = Theme;
/***/ }),
/* 126 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Attribute = __webpack_require__(314);
var Transform = __webpack_require__(317);
var Animate = __webpack_require__(313);
var EventEmitter = __webpack_require__(98);
var Element = function Element(cfg) {
this._cfg = {
zIndex: 0,
capture: true,
visible: true,
destroyed: false
}; // 配置存放地
Util.assign(this._cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
this.initAttrs(this._cfg.attrs); // 初始化绘图属性
this._cfg.attrs = {};
this.initTransform(); // 初始化变换
this.init(); // 类型初始化
};
Element.CFG = {
/**
* 唯一标示
* @type {Number}
*/
id: null,
/**
* Z轴的层叠关系,Z值越大离用户越近
* @type {Number}
*/
zIndex: 0,
/**
* Canvas对象
* @type: {Object}
*/
canvas: null,
/**
* 父元素指针
* @type {Object}
*/
parent: null,
/**
* 用来设置当前对象是否能被捕捉
* true 能
* false 不能
* 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
* 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
* @type {Boolean}
**/
capture: true,
/**
* 画布的上下文
* @type {Object}
*/
context: null,
/**
* 是否显示
* @type {Boolean}
*/
visible: true,
/**
* 是否被销毁
* @type: {Boolean}
*/
destroyed: false
};
Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
init: function init() {
this.setSilent('animable', true);
this.setSilent('animating', false); // 初始时不处于动画状态
},
getParent: function getParent() {
return this._cfg.parent;
},
/**
* 获取默认的配置信息
* @protected
* @return {Object} 默认的属性
*/
getDefaultCfg: function getDefaultCfg() {
return {};
},
set: function set(name, value) {
if (name === 'zIndex' && this._beforeSetZIndex) {
this._beforeSetZIndex(value);
}
if (name === 'loading' && this._beforeSetLoading) {
this._beforeSetLoading(value);
}
this._cfg[name] = value;
return this;
},
// deprecated
setSilent: function setSilent(name, value) {
this._cfg[name] = value;
},
get: function get(name) {
return this._cfg[name];
},
show: function show() {
this._cfg.visible = true;
return this;
},
hide: function hide() {
this._cfg.visible = false;
return this;
},
remove: function remove(destroy, delayRemove) {
var cfg = this._cfg;
var parent = cfg.parent;
var el = cfg.el;
if (parent) {
Util.remove(parent.get('children'), this);
}
if (el) {
if (delayRemove) {
parent && parent._cfg.tobeRemoved.push(el);
} else {
el.parentNode.removeChild(el);
}
}
if (destroy || destroy === undefined) {
this.destroy();
}
return this;
},
destroy: function destroy() {
var destroyed = this.get('destroyed');
if (destroyed) {
return;
}
this._attrs = null;
this.removeEvent(); // 移除所有的事件
this._cfg = {
destroyed: true
};
},
toFront: function toFront() {
var cfg = this._cfg;
var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;
var el = cfg.el;
var index = children.indexOf(this);
children.splice(index, 1);
children.push(this);
if (el) {
el.parentNode.removeChild(el);
cfg.el = null;
}
},
toBack: function toBack() {
var cfg = this._cfg;
var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;
var el = cfg.el;
var index = children.indexOf(this);
children.splice(index, 1);
children.unshift(this);
if (el) {
var parentNode = el.parentNode;
parentNode.removeChild(el);
parentNode.insertBefore(el, parentNode.firstChild);
}
},
_beforeSetZIndex: function _beforeSetZIndex(zIndex) {
var parent = this._cfg.parent;
this._cfg.zIndex = zIndex;
if (!Util.isNil(parent)) {
parent.sort();
}
var el = this._cfg.el;
if (el) {
var children = parent._cfg.children;
var index = children.indexOf(this);
var parentNode = el.parentNode;
parentNode.removeChild(el);
if (index === children.length - 1) {
parentNode.appendChild(el);
} else {
parentNode.insertBefore(el, parentNode.childNodes[index]);
}
}
return zIndex;
},
_setAttrs: function _setAttrs(attrs) {
this.attr(attrs);
return attrs;
},
setZIndex: function setZIndex(zIndex) {
this._cfg.zIndex = zIndex;
return this._beforeSetZIndex(zIndex);
},
clone: function clone() {
return Util.clone(this);
},
getBBox: function getBBox() {}
});
module.exports = Element;
/***/ }),
/* 127 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Element = __webpack_require__(126);
var Shape = __webpack_require__(331);
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;
};
}
function find(children, x, y) {
var rst;
for (var i = children.length - 1; i >= 0; i--) {
var child = children[i];
if (child._cfg.visible && child._cfg.capture) {
if (child.isGroup) {
rst = child.getShape(x, y);
} else if (child.isHit(x, y)) {
rst = child;
}
}
if (rst) {
break;
}
}
return rst;
}
var Group = function Group(cfg) {
Group.superclass.constructor.call(this, cfg);
this.set('children', []);
this.set('tobeRemoved', []);
this._beforeRenderUI();
this._renderUI();
this._bindUI();
};
function initClassCfgs(c) {
if (c._cfg || c === Group) {
return;
}
var superCon = c.superclass.constructor;
if (superCon && !superCon._cfg) {
initClassCfgs(superCon);
}
c._cfg = {};
Util.merge(c._cfg, superCon._cfg);
Util.merge(c._cfg, c.CFG);
}
Util.extend(Group, Element);
Util.augment(Group, {
isGroup: true,
type: 'group',
canFill: true,
canStroke: true,
getDefaultCfg: function getDefaultCfg() {
initClassCfgs(this.constructor);
return Util.merge({}, this.constructor._cfg);
},
_beforeRenderUI: function _beforeRenderUI() {},
_renderUI: function _renderUI() {},
_bindUI: function _bindUI() {},
addShape: function addShape(type, cfg) {
var canvas = this.get('canvas');
cfg = cfg || {};
var shapeType = SHAPE_MAP[type];
if (!shapeType) {
shapeType = Util.upperFirst(type);
SHAPE_MAP[type] = shapeType;
}
if (cfg.attrs && canvas) {
var attrs = cfg.attrs;
if (type === 'text') {
// 临时解决
var topFontFamily = canvas.get('fontFamily');
if (topFontFamily) {
attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;
}
}
}
cfg.canvas = canvas;
cfg.type = type;
var rst = new Shape[shapeType](cfg);
this.add(rst);
return rst;
},
/** 添加图组
* @param {Function|Object|undefined} param 图组类
* @param {Object} cfg 配置项
* @return {Object} rst 图组
*/
addGroup: function addGroup(param, cfg) {
var canvas = this.get('canvas');
var rst;
cfg = Util.merge({}, cfg);
if (Util.isFunction(param)) {
if (cfg) {
cfg.canvas = canvas;
cfg.parent = this;
rst = new param(cfg);
} else {
rst = new param({
canvas: canvas,
parent: this
});
}
this.add(rst);
} else if (Util.isObject(param)) {
param.canvas = canvas;
rst = new Group(param);
this.add(rst);
} else if (param === undefined) {
rst = new Group();
this.add(rst);
} else {
return false;
}
return rst;
},
/** 绘制背景
* @param {Array} padding 内边距
* @param {Attrs} attrs 图形属性
* @param {Shape} backShape 背景图形
* @return {Object} 背景层对象
*/
renderBack: function renderBack(padding, attrs) {
var backShape = this.get('backShape');
var innerBox = this.getBBox(); // const parent = this.get('parent'); // getParent
Util.merge(attrs, {
x: innerBox.minX - padding[3],
y: innerBox.minY - padding[0],
width: innerBox.width + padding[1] + padding[3],
height: innerBox.height + padding[0] + padding[2]
});
if (backShape) {
backShape.attr(attrs);
} else {
backShape = this.addShape('rect', {
zIndex: -1,
attrs: attrs
});
}
this.set('backShape', backShape);
this.sort();
return backShape;
},
removeChild: function removeChild(item, destroy) {
if (arguments.length >= 2) {
if (this.contain(item)) {
item.remove(destroy);
}
} else {
if (arguments.length === 1) {
if (Util.isBoolean(item)) {
destroy = item;
} else {
if (this.contain(item)) {
item.remove(true);
}
return this;
}
}
if (arguments.length === 0) {
destroy = true;
}
Group.superclass.remove.call(this, destroy);
}
return this;
},
/**
* 向组中添加shape或者group
* @param {Object} items 图形或者分组
* @return {Object} group 本尊
*/
add: function add(items) {
var self = this;
var children = self.get('children');
if (Util.isArray(items)) {
Util.each(items, function (item) {
var parent = item.get('parent');
if (parent) {
parent.removeChild(item, false);
}
self._setCfgProperty(item);
});
self._cfg.children = children.concat(items);
} else {
var item = items;
var parent = item.get('parent');
if (parent) {
parent.removeChild(item, false);
}
self._setCfgProperty(item);
children.push(item);
}
return self;
},
_setCfgProperty: function _setCfgProperty(item) {
var cfg = this._cfg;
item.set('parent', this);
item.set('canvas', cfg.canvas);
if (cfg.timeline) {
item.set('timeline', cfg.timeline);
}
},
contain: function contain(item) {
var children = this.get('children');
return children.indexOf(item) > -1;
},
getChildByIndex: function getChildByIndex(index) {
var children = this.get('children');
return children[index];
},
getFirst: function getFirst() {
return this.getChildByIndex(0);
},
getLast: function getLast() {
var lastIndex = this.get('children').length - 1;
return this.getChildByIndex(lastIndex);
},
getBBox: function getBBox() {
var self = this;
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
var children = self.get('children');
if (children.length > 0) {
Util.each(children, function (child) {
if (child.get('visible')) {
if (child.isGroup && child.get('children').length === 0) {
return;
}
var _box = child.getBBox();
if (!_box) {
return true;
}
var leftTop = [_box.minX, _box.minY, 1];
var leftBottom = [_box.minX, _box.maxY, 1];
var rightTop = [_box.maxX, _box.minY, 1];
var rightBottom = [_box.maxX, _box.maxY, 1];
child.apply(leftTop);
child.apply(leftBottom);
child.apply(rightTop);
child.apply(rightBottom);
var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
if (boxMinX < minX) {
minX = boxMinX;
}
if (boxMaxX > maxX) {
maxX = boxMaxX;
}
if (boxMinY < minY) {
minY = boxMinY;
}
if (boxMaxY > maxY) {
maxY = boxMaxY;
}
}
});
} else {
minX = 0;
maxX = 0;
minY = 0;
maxY = 0;
}
var box = {
minX: minX,
minY: minY,
maxX: maxX,
maxY: maxY
};
box.x = box.minX;
box.y = box.minY;
box.width = box.maxX - box.minX;
box.height = box.maxY - box.minY;
return box;
},
getCount: function getCount() {
return this.get('children').length;
},
sort: function sort() {
var children = this.get('children'); // 稳定排序
Util.each(children, function (child, index) {
child[INDEX] = index;
return child;
});
children.sort(getComparer(function (obj1, obj2) {
return obj1.get('zIndex') - obj2.get('zIndex');
}));
return this;
},
findById: function findById(id) {
return this.find(function (item) {
return item.get('id') === id;
});
},
/**
* 根据查找函数查找分组或者图形
* @param {Function} fn 匹配函数
* @return {Canvas.Base} 分组或者图形
*/
find: function find(fn) {
if (Util.isString(fn)) {
return this.findById(fn);
}
var children = this.get('children');
var rst = null;
Util.each(children, function (item) {
if (fn(item)) {
rst = item;
} else if (item.find) {
rst = item.find(fn);
}
if (rst) {
return false;
}
});
return rst;
},
/**
* @param {Function} fn filter mathod
* @return {Array} all the matching shapes and groups
*/
findAll: function findAll(fn) {
var children = this.get('children');
var rst = [];
var childRst = [];
Util.each(children, function (item) {
if (fn(item)) {
rst.push(item);
}
if (item.findAllBy) {
childRst = item.findAllBy(fn);
rst = rst.concat(childRst);
}
});
return rst;
},
/**
* @Deprecated
* @param {Function} fn filter method
* @return {Object} found shape or group
*/
findBy: function findBy(fn) {
var children = this.get('children');
var rst = null;
Util.each(children, function (item) {
if (fn(item)) {
rst = item;
} else if (item.findBy) {
rst = item.findBy(fn);
}
if (rst) {
return false;
}
});
return rst;
},
/**
* @Deprecated
* @param {Function} fn filter mathod
* @return {Array} all the matching shapes and groups
*/
findAllBy: function findAllBy(fn) {
var children = this.get('children');
var rst = [];
var childRst = [];
Util.each(children, function (item) {
if (fn(item)) {
rst.push(item);
}
if (item.findAllBy) {
childRst = item.findAllBy(fn);
rst = rst.concat(childRst);
}
});
return rst;
},
getShape: function getShape(x, y) {
var self = this;
var clip = self._attrs.clip;
var children = self._cfg.children;
var rst;
if (clip) {
var v = [x, y, 1];
clip.invert(v, self.get('canvas')); // 已经在外面转换
if (clip.isPointInPath(v[0], v[1])) {
rst = find(children, x, y);
}
} else {
rst = find(children, x, y);
}
return rst;
},
clearTotalMatrix: function clearTotalMatrix() {
var m = this.get('totalMatrix');
if (m) {
this.setSilent('totalMatrix', null);
var children = this._cfg.children;
for (var i = 0; i < children.length; i++) {
var child = children[i];
child.clearTotalMatrix();
}
}
},
clear: function clear(delayRemove) {
var children = this._cfg.children;
for (var i = children.length - 1; i >= 0; i--) {
children[i].remove(true, delayRemove);
}
this._cfg.children = [];
return this;
},
destroy: function destroy() {
if (this.get('destroyed')) {
return;
}
this.clear();
Group.superclass.destroy.call(this);
},
clone: function clone() {
var self = this;
var children = self._cfg.children;
var clone = new Group();
Util.each(children, function (child) {
clone.add(child.clone());
});
return clone;
}
});
module.exports = Group;
/***/ }),
/* 128 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Event = function Event(type, event, bubbles, cancelable) {
this.type = type; // 事件类型
this.target = null; // 目标
this.currentTarget = null; // 当前目标
this.bubbles = bubbles; // 冒泡
this.cancelable = cancelable; // 是否能够阻止
this.timeStamp = new Date().getTime(); // 时间戳
this.defaultPrevented = false; // 阻止默认
this.propagationStopped = false; // 阻止冒泡
this.removed = false; // 是否被移除
this.event = event; // 触发的原生事件
};
Util.augment(Event, {
preventDefault: function preventDefault() {
this.defaultPrevented = this.cancelable && true;
},
stopPropagation: function stopPropagation() {
this.propagationStopped = true;
},
remove: function remove() {
this.remove = true;
},
clone: function clone() {
return Util.clone(this);
},
toString: function toString() {
return '[Event (type=' + this.type + ')]';
}
});
module.exports = Event;
/***/ }),
/* 129 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var ArcMath = __webpack_require__(44);
var Arrow = __webpack_require__(46);
function _getArcX(x, radius, angle) {
return x + radius * Math.cos(angle);
}
function _getArcY(y, radius, angle) {
return y + radius * Math.sin(angle);
}
var Arc = function Arc(cfg) {
Arc.superclass.constructor.call(this, cfg);
};
Arc.ATTRS = {
x: 0,
y: 0,
r: 0,
startAngle: 0,
endAngle: 0,
clockwise: false,
lineWidth: 1,
startArrow: false,
endArrow: false
};
Util.extend(Arc, Shape);
Util.augment(Arc, {
canStroke: true,
type: 'arc',
getDefaultAttrs: function getDefaultAttrs() {
return {
x: 0,
y: 0,
r: 0,
startAngle: 0,
endAngle: 0,
clockwise: false,
lineWidth: 1,
startArrow: false,
endArrow: false
};
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
var x = attrs.x,
y = attrs.y,
r = attrs.r,
startAngle = attrs.startAngle,
endAngle = attrs.endAngle,
clockwise = attrs.clockwise;
var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2;
var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise);
box.minX -= halfWidth;
box.minY -= halfWidth;
box.maxX += halfWidth;
box.maxY += halfWidth;
return box;
},
getStartTangent: function getStartTangent() {
var attrs = this._attrs;
var x = attrs.x,
y = attrs.y,
startAngle = attrs.startAngle,
r = attrs.r,
clockwise = attrs.clockwise;
var diff = Math.PI / 180;
if (clockwise) {
diff *= -1;
}
var result = [];
var x1 = _getArcX(x, r, startAngle + diff);
var y1 = _getArcY(y, r, startAngle + diff);
var x2 = _getArcX(x, r, startAngle);
var y2 = _getArcY(y, r, startAngle);
result.push([x1, y1]);
result.push([x2, y2]);
return result;
},
getEndTangent: function getEndTangent() {
var attrs = this._attrs;
var x = attrs.x,
y = attrs.y,
endAngle = attrs.endAngle,
r = attrs.r,
clockwise = attrs.clockwise;
var diff = Math.PI / 180;
var result = [];
if (clockwise) {
diff *= -1;
}
var x1 = _getArcX(x, r, endAngle + diff);
var y1 = _getArcY(y, r, endAngle + diff);
var x2 = _getArcX(x, r, endAngle);
var y2 = _getArcY(y, r, endAngle);
result.push([x2, y2]);
result.push([x1, y1]);
return result;
},
createPath: function createPath(context) {
var attrs = this._attrs;
var x = attrs.x,
y = attrs.y,
r = attrs.r,
startAngle = attrs.startAngle,
endAngle = attrs.endAngle,
clockwise = attrs.clockwise;
context = context || self.get('context');
context.beginPath();
context.arc(x, y, r, startAngle, endAngle, clockwise);
},
afterPath: function afterPath(context) {
var attrs = this._attrs;
context = context || this.get('context');
if (attrs.startArrow) {
var startPoints = this.getStartTangent();
Arrow.addStartArrow(context, attrs, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]);
}
if (attrs.endArrow) {
var endPoints = this.getEndTangent();
Arrow.addEndArrow(context, attrs, endPoints[0][0], endPoints[0][1], endPoints[1][0], endPoints[1][1]);
}
}
});
module.exports = Arc;
/***/ }),
/* 130 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Circle = function Circle(cfg) {
Circle.superclass.constructor.call(this, cfg);
};
Circle.ATTRS = {
x: 0,
y: 0,
r: 0,
lineWidth: 1
};
Util.extend(Circle, Shape);
Util.augment(Circle, {
canFill: true,
canStroke: true,
type: 'circle',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1
};
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.r;
var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2 + r;
return {
minX: cx - halfWidth,
minY: cy - halfWidth,
maxX: cx + halfWidth,
maxY: cy + halfWidth
};
},
createPath: function createPath(context) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.r;
context.beginPath();
context.arc(cx, cy, r, 0, Math.PI * 2, false);
context.closePath();
}
});
module.exports = Circle;
/***/ }),
/* 131 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Dom = function Dom(cfg) {
Dom.superclass.constructor.call(this, cfg);
};
Util.extend(Dom, Shape);
Util.augment(Dom, {
canFill: true,
canStroke: true,
type: 'dom',
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var x = attrs.x;
var y = attrs.y;
var width = attrs.width;
var height = attrs.height;
var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2;
return {
minX: x - halfWidth,
minY: y - halfWidth,
maxX: x + width + halfWidth,
maxY: y + height + halfWidth
};
}
});
module.exports = Dom;
/***/ }),
/* 132 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Ellipse = function Ellipse(cfg) {
Ellipse.superclass.constructor.call(this, cfg);
};
Ellipse.ATTRS = {
x: 0,
y: 0,
rx: 1,
ry: 1,
lineWidth: 1
};
Util.extend(Ellipse, Shape);
Util.augment(Ellipse, {
canFill: true,
canStroke: true,
type: 'ellipse',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1
};
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var rx = attrs.rx;
var ry = attrs.ry;
var lineWidth = this.getHitLineWidth();
var halfXWidth = rx + lineWidth / 2;
var halfYWidth = ry + lineWidth / 2;
return {
minX: cx - halfXWidth,
minY: cy - halfYWidth,
maxX: cx + halfXWidth,
maxY: cy + halfYWidth
};
},
createPath: function createPath(context) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var rx = attrs.rx;
var ry = attrs.ry;
context = context || self.get('context');
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
Util.mat3.scale(m, m, [scaleX, scaleY]);
Util.mat3.translate(m, m, [cx, cy]);
context.beginPath();
context.save();
context.transform(m[0], m[1], m[3], m[4], m[6], m[7]);
context.arc(0, 0, r, 0, Math.PI * 2);
context.restore();
context.closePath();
}
});
module.exports = Ellipse;
/***/ }),
/* 133 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var ArcMath = __webpack_require__(44);
var Fan = function Fan(cfg) {
Fan.superclass.constructor.call(this, cfg);
};
Fan.ATTRS = {
x: 0,
y: 0,
rs: 0,
re: 0,
startAngle: 0,
endAngle: 0,
clockwise: false,
lineWidth: 1
};
Util.extend(Fan, Shape);
Util.augment(Fan, {
canFill: true,
canStroke: true,
type: 'fan',
getDefaultAttrs: function getDefaultAttrs() {
return {
clockwise: false,
lineWidth: 1,
rs: 0,
re: 0
};
},
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var cx = attrs.x;
var cy = attrs.y;
var rs = attrs.rs;
var re = attrs.re;
var startAngle = attrs.startAngle;
var endAngle = attrs.endAngle;
var clockwise = attrs.clockwise;
var lineWidth = this.getHitLineWidth();
var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);
var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);
var minX = Math.min(boxs.minX, boxe.minX);
var minY = Math.min(boxs.minY, boxe.minY);
var maxX = Math.max(boxs.maxX, boxe.maxX);
var maxY = Math.max(boxs.maxY, boxe.maxY);
var halfWidth = lineWidth / 2;
return {
minX: minX - halfWidth,
minY: minY - halfWidth,
maxX: maxX + halfWidth,
maxY: maxY + halfWidth
};
},
createPath: function createPath(context) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var rs = attrs.rs;
var re = attrs.re;
var startAngle = attrs.startAngle;
var endAngle = attrs.endAngle;
var clockwise = attrs.clockwise;
var ssp = {
x: Math.cos(startAngle) * rs + cx,
y: Math.sin(startAngle) * rs + cy
};
var sep = {
x: Math.cos(startAngle) * re + cx,
y: Math.sin(startAngle) * re + cy
};
var esp = {
x: Math.cos(endAngle) * rs + cx,
y: Math.sin(endAngle) * rs + cy
};
context = context || self.get('context');
context.beginPath();
context.moveTo(ssp.x, ssp.y);
context.lineTo(sep.x, sep.y);
context.arc(cx, cy, re, startAngle, endAngle, clockwise);
context.lineTo(esp.x, esp.y);
context.arc(cx, cy, rs, endAngle, startAngle, !clockwise);
context.closePath();
}
});
module.exports = Fan;
/***/ }),
/* 134 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var CImage = function CImage(cfg) {
CImage.superclass.constructor.call(this, cfg);
};
CImage.ATTRS = {
x: 0,
y: 0,
img: undefined,
width: 0,
height: 0,
sx: null,
sy: null,
swidth: null,
sheight: null
};
Util.extend(CImage, Shape);
Util.augment(CImage, {
type: 'image',
isHitBox: function isHitBox() {
return false;
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
if (!this._cfg.attrs || this._cfg.attrs.img !== attrs.img) {
this._setAttrImg();
}
var x = attrs.x;
var y = attrs.y;
var width = attrs.width;
var height = attrs.height;
return {
minX: x,
minY: y,
maxX: x + width,
maxY: y + height
};
},
_beforeSetLoading: function _beforeSetLoading(loading) {
var canvas = this.get('canvas');
if (loading === false && this.get('toDraw') === true) {
this._cfg.loading = false;
canvas.draw();
}
return loading;
},
_setAttrImg: function _setAttrImg() {
var self = this;
var attrs = self._attrs;
var img = attrs.img;
if (Util.isString(img)) {
var image = new Image();
image.onload = function () {
if (self.get('destroyed')) return false;
self.attr('imgSrc', img);
self.attr('img', image);
var callback = self.get('callback');
if (callback) {
callback.call(self);
}
self.set('loading', false);
};
image.src = img;
image.crossOrigin = 'Anonymous';
self.set('loading', true);
} else if (img instanceof Image) {
if (!attrs.width) {
self.attr('width', img.width);
}
if (!attrs.height) {
self.attr('height', img.height);
}
return img;
} else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
if (!attrs.width) {
self.attr('width', Number(img.getAttribute('width')));
}
if (!attrs.height) {
self.attr('height', Number(img.getAttribute('height')));
}
return img;
} else if (img instanceof ImageData) {
if (!attrs.width) {
self.attr('width', img.width);
}
if (!attrs.height) {
self.attr('height', img.height);
}
return img;
} else {
return null;
}
},
drawInner: function drawInner(context) {
if (this._cfg.hasUpdate) {
this._setAttrImg();
}
if (this.get('loading')) {
this.set('toDraw', true);
return;
}
this._drawImage(context);
this._cfg.hasUpdate = false;
},
_drawImage: function _drawImage(context) {
var attrs = this._attrs;
var x = attrs.x;
var y = attrs.y;
var image = attrs.img;
var width = attrs.width;
var height = attrs.height;
var sx = attrs.sx;
var sy = attrs.sy;
var swidth = attrs.swidth;
var sheight = attrs.sheight;
this.set('toDraw', false);
var img = image;
if (img instanceof ImageData) {
img = new Image();
img.src = image;
}
if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {
context.drawImage(img, x, y, width, height);
return;
}
if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {
context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);
return;
}
}
return;
}
});
module.exports = CImage;
/***/ }),
/* 135 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Arrow = __webpack_require__(46);
var LineMath = __webpack_require__(45);
var Line = function Line(cfg) {
Line.superclass.constructor.call(this, cfg);
};
Line.ATTRS = {
x1: 0,
y1: 0,
x2: 0,
y2: 0,
lineWidth: 1,
startArrow: false,
endArrow: false
};
Util.extend(Line, Shape);
Util.augment(Line, {
canStroke: true,
type: 'line',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1,
startArrow: false,
endArrow: false
};
},
calculateBox: function calculateBox() {
var attrs = this._attrs;
var x1 = attrs.x1,
y1 = attrs.y1,
x2 = attrs.x2,
y2 = attrs.y2;
var lineWidth = this.getHitLineWidth();
return LineMath.box(x1, y1, x2, y2, lineWidth);
},
createPath: function createPath(context) {
var attrs = this._attrs;
var x1 = attrs.x1,
y1 = attrs.y1,
x2 = attrs.x2,
y2 = attrs.y2;
context = context || self.get('context');
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
},
afterPath: function afterPath(context) {
var attrs = this._attrs;
var x1 = attrs.x1,
y1 = attrs.y1,
x2 = attrs.x2,
y2 = attrs.y2;
context = context || this.get('context');
if (attrs.startArrow) {
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
}
if (attrs.endArrow) {
Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);
}
},
getPoint: function getPoint(t) {
var attrs = this._attrs;
return {
x: LineMath.at(attrs.x1, attrs.x2, t),
y: LineMath.at(attrs.y1, attrs.y2, t)
};
}
});
module.exports = Line;
/***/ }),
/* 136 */
/***/ (function(module, exports) {
module.exports = {
xAt: function xAt(psi, rx, ry, cx, t) {
return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx;
},
yAt: function yAt(psi, rx, ry, cy, t) {
return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy;
},
xExtrema: function xExtrema(psi, rx, ry) {
return Math.atan(-ry / rx * Math.tan(psi));
},
yExtrema: function yExtrema(psi, rx, ry) {
return Math.atan(ry / (rx * Math.tan(psi)));
}
};
/***/ }),
/* 137 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var vec2 = Util.vec2;
function quadraticAt(p0, p1, p2, t) {
var onet = 1 - t;
return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
}
function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
var t;
var interval = 0.005;
var d = Infinity;
var d1;
var v1;
var v2;
var _t;
var d2;
var i;
var EPSILON = 0.0001;
var v0 = [x, y];
for (_t = 0; _t < 1; _t += 0.05) {
v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
d1 = vec2.squaredDistance(v0, v1);
if (d1 < d) {
t = _t;
d = d1;
}
}
d = Infinity;
for (i = 0; i < 32; i++) {
if (interval < EPSILON) {
break;
}
var prev = t - interval;
var next = t + interval;
v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
d1 = vec2.squaredDistance(v0, v1);
if (prev >= 0 && d1 < d) {
t = prev;
d = d1;
} else {
v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
d2 = vec2.squaredDistance(v0, v2);
if (next <= 1 && d2 < d) {
t = next;
d = d2;
} else {
interval *= 0.5;
}
}
}
if (out) {
out.x = quadraticAt(x1, x2, x3, t);
out.y = quadraticAt(y1, y2, y3, t);
}
return Math.sqrt(d);
}
function quadraticExtrema(p0, p1, p2) {
var a = p0 + p2 - 2 * p1;
if (Util.isNumberEqual(a, 0)) {
return [0.5];
}
var rst = (p0 - p1) / a;
if (rst <= 1 && rst >= 0) {
return [rst];
}
return [];
}
module.exports = {
at: quadraticAt,
projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) {
var rst = {};
quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst);
return rst;
},
pointDistance: quadraticProjectPoint,
extrema: quadraticExtrema
};
/***/ }),
/* 138 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var PathSegment = __webpack_require__(47);
var Format = __webpack_require__(36);
var Arrow = __webpack_require__(46);
var PathUtil = __webpack_require__(71);
var CubicMath = __webpack_require__(69);
var Path = function Path(cfg) {
Path.superclass.constructor.call(this, cfg);
};
Path.ATTRS = {
path: null,
lineWidth: 1,
startArrow: false,
endArrow: false
};
Util.extend(Path, Shape);
Util.augment(Path, {
canFill: true,
canStroke: true,
type: 'path',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1,
startArrow: false,
endArrow: false
};
},
_afterSetAttrPath: function _afterSetAttrPath(path) {
var self = this;
if (Util.isNil(path)) {
self.setSilent('segments', null);
self.setSilent('box', undefined);
return;
}
var pathArray = Format.parsePath(path);
var preSegment;
var segments = [];
if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
return;
}
var count = pathArray.length;
for (var i = 0; i < pathArray.length; i++) {
var item = pathArray[i];
preSegment = new PathSegment(item, preSegment, i === count - 1);
segments.push(preSegment);
}
self.setSilent('segments', segments);
self.setSilent('tCache', null);
self.setSilent('box', null);
},
calculateBox: function calculateBox() {
var self = this;
var segments = self.get('segments');
if (!segments) {
return null;
}
var lineWidth = this.getHitLineWidth();
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
Util.each(segments, function (segment) {
segment.getBBox(lineWidth);
var box = segment.box;
if (box) {
if (box.minX < minX) {
minX = box.minX;
}
if (box.maxX > maxX) {
maxX = box.maxX;
}
if (box.minY < minY) {
minY = box.minY;
}
if (box.maxY > maxY) {
maxY = box.maxY;
}
}
});
if (minX === Infinity || minY === Infinity) {
return {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
};
}
return {
minX: minX,
minY: minY,
maxX: maxX,
maxY: maxY
};
},
_setTcache: function _setTcache() {
var totalLength = 0;
var tempLength = 0;
var tCache = [];
var segmentT;
var segmentL;
var segmentN;
var l;
var curve = this._cfg.curve;
if (!curve) {
return;
}
Util.each(curve, function (segment, i) {
segmentN = curve[i + 1];
l = segment.length;
if (segmentN) {
totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
}
});
Util.each(curve, function (segment, i) {
segmentN = curve[i + 1];
l = segment.length;
if (segmentN) {
segmentT = [];
segmentT[0] = tempLength / totalLength;
segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
tempLength += segmentL;
segmentT[1] = tempLength / totalLength;
tCache.push(segmentT);
}
});
this._cfg.tCache = tCache;
},
_calculateCurve: function _calculateCurve() {
var self = this;
var attrs = self._attrs;
var path = attrs.path;
this._cfg.curve = PathUtil.pathTocurve(path);
},
getStartTangent: function getStartTangent() {
var segments = this.get('segments');
var startPoint, endPoint, tangent, result;
if (segments.length > 1) {
startPoint = segments[0].endPoint;
endPoint = segments[1].endPoint;
tangent = segments[1].startTangent;
result = [];
if (Util.isFunction(tangent)) {
var v = tangent();
result.push([startPoint.x - v[0], startPoint.y - v[1]]);
result.push([startPoint.x, startPoint.y]);
} else {
result.push([endPoint.x, endPoint.y]);
result.push([startPoint.x, startPoint.y]);
}
}
return result;
},
getEndTangent: function getEndTangent() {
var segments = this.get('segments');
var segmentsLen = segments.length;
var startPoint, endPoint, tangent, result;
if (segmentsLen > 1) {
startPoint = segments[segmentsLen - 2].endPoint;
endPoint = segments[segmentsLen - 1].endPoint;
tangent = segments[segmentsLen - 1].endTangent;
result = [];
if (Util.isFunction(tangent)) {
var v = tangent();
result.push([endPoint.x - v[0], endPoint.y - v[1]]);
result.push([endPoint.x, endPoint.y]);
} else {
result.push([startPoint.x, startPoint.y]);
result.push([endPoint.x, endPoint.y]);
}
}
return result;
},
getPoint: function getPoint(t) {
var tCache = this._cfg.tCache;
var subt;
var index;
if (!tCache) {
this._calculateCurve();
this._setTcache();
tCache = this._cfg.tCache;
}
var curve = this._cfg.curve;
if (!tCache) {
if (curve) {
return {
x: curve[0][1],
y: curve[0][2]
};
}
return null;
}
Util.each(tCache, function (v, i) {
if (t >= v[0] && t <= v[1]) {
subt = (t - v[0]) / (v[1] - v[0]);
index = i;
}
});
var seg = curve[index];
if (Util.isNil(seg) || Util.isNil(index)) {
return null;
}
var l = seg.length;
var nextSeg = curve[index + 1];
return {
x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
};
},
createPath: function createPath(context) {
var self = this;
var segments = self.get('segments');
if (!Util.isArray(segments)) {
return;
}
context = context || self.get('context');
context.beginPath();
var segmentsLen = segments.length;
for (var i = 0; i < segmentsLen; i++) {
segments[i].draw(context);
}
},
afterPath: function afterPath(context) {
var self = this;
var attrs = self._attrs;
var segments = self.get('segments');
var path = attrs.path;
context = context || self.get('context');
if (!Util.isArray(segments)) {
return;
}
if (segments.length === 1) {
return;
}
if (!attrs.startArrow && !attrs.endArrow) {
return;
}
if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {
// 闭合路径不绘制箭头
return;
}
var startPoints = self.getStartTangent();
Arrow.addStartArrow(context, attrs, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]);
var endPoints = self.getEndTangent();
Arrow.addEndArrow(context, attrs, endPoints[0][0], endPoints[0][1], endPoints[1][0], endPoints[1][1]);
}
});
module.exports = Path;
/***/ }),
/* 139 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Polygon = function Polygon(cfg) {
Polygon.superclass.constructor.call(this, cfg);
};
Polygon.ATTRS = {
points: null,
lineWidth: 1
};
Util.extend(Polygon, Shape);
Util.augment(Polygon, {
canFill: true,
canStroke: true,
type: 'polygon',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1
};
},
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var points = attrs.points;
var lineWidth = this.getHitLineWidth();
if (!points || points.length === 0) {
return null;
}
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
Util.each(points, function (point) {
var x = point[0];
var y = point[1];
if (x < minX) {
minX = x;
}
if (x > maxX) {
maxX = x;
}
if (y < minY) {
minY = y;
}
if (y > maxY) {
maxY = y;
}
});
var halfWidth = lineWidth / 2;
return {
minX: minX - halfWidth,
minY: minY - halfWidth,
maxX: maxX + halfWidth,
maxY: maxY + halfWidth
};
},
createPath: function createPath(context) {
var self = this;
var attrs = self._attrs;
var points = attrs.points;
if (points.length < 2) {
return;
}
context = context || self.get('context');
context.beginPath();
Util.each(points, function (point, index) {
if (index === 0) {
context.moveTo(point[0], point[1]);
} else {
context.lineTo(point[0], point[1]);
}
});
context.closePath();
}
});
module.exports = Polygon;
/***/ }),
/* 140 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var Arrow = __webpack_require__(46);
var LineMath = __webpack_require__(45);
var Polyline = function Polyline(cfg) {
Polyline.superclass.constructor.call(this, cfg);
};
Polyline.ATTRS = {
points: null,
lineWidth: 1,
startArrow: false,
endArrow: false,
tCache: null
};
Util.extend(Polyline, Shape);
Util.augment(Polyline, {
canStroke: true,
type: 'polyline',
tCache: null,
// 缓存各点的t
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1,
startArrow: false,
endArrow: false
};
},
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var lineWidth = this.getHitLineWidth();
var points = attrs.points;
if (!points || points.length === 0) {
return null;
}
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
Util.each(points, function (point) {
var x = point[0];
var y = point[1];
if (x < minX) {
minX = x;
}
if (x > maxX) {
maxX = x;
}
if (y < minY) {
minY = y;
}
if (y > maxY) {
maxY = y;
}
});
var halfWidth = lineWidth / 2;
return {
minX: minX - halfWidth,
minY: minY - halfWidth,
maxX: maxX + halfWidth,
maxY: maxY + halfWidth
};
},
_setTcache: function _setTcache() {
var self = this;
var attrs = self._attrs;
var points = attrs.points;
var totalLength = 0;
var tempLength = 0;
var tCache = [];
var segmentT;
var segmentL;
if (!points || points.length === 0) {
return;
}
Util.each(points, function (p, i) {
if (points[i + 1]) {
totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
}
});
if (totalLength <= 0) {
return;
}
Util.each(points, function (p, i) {
if (points[i + 1]) {
segmentT = [];
segmentT[0] = tempLength / totalLength;
segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
tempLength += segmentL;
segmentT[1] = tempLength / totalLength;
tCache.push(segmentT);
}
});
this.tCache = tCache;
},
createPath: function createPath(context) {
var self = this;
var attrs = self._attrs;
var points = attrs.points;
var l;
var i;
if (points.length < 2) {
return;
}
context = context || self.get('context');
context.beginPath();
context.moveTo(points[0][0], points[0][1]);
for (i = 1, l = points.length - 1; i < l; i++) {
context.lineTo(points[i][0], points[i][1]);
}
context.lineTo(points[l][0], points[l][1]);
},
getStartTangent: function getStartTangent() {
var points = this.__attrs.points;
var result = [];
result.push([points[1][0], points[1][1]]);
result.push([points[0][0], points[0][1]]);
return result;
},
getEndTangent: function getEndTangent() {
var points = this.__attrs.points;
var l = points.length - 1;
var result = [];
result.push([points[l - 1][0], points[l - 1][1]]);
result.push([points[l][0], points[l][1]]);
return result;
},
afterPath: function afterPath(context) {
var self = this;
var attrs = self._attrs;
var points = attrs.points;
var l = points.length - 1;
context = context || self.get('context');
if (attrs.startArrow) {
Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]);
}
if (attrs.endArrow) {
Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);
}
},
getPoint: function getPoint(t) {
var attrs = this._attrs;
var points = attrs.points;
var tCache = this.tCache;
var subt;
var index;
if (!tCache) {
this._setTcache();
tCache = this.tCache;
}
Util.each(tCache, function (v, i) {
if (t >= v[0] && t <= v[1]) {
subt = (t - v[0]) / (v[1] - v[0]);
index = i;
}
});
return {
x: LineMath.at(points[index][0], points[index + 1][0], subt),
y: LineMath.at(points[index][1], points[index + 1][1], subt)
};
}
});
module.exports = Polyline;
/***/ }),
/* 141 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var _require = __webpack_require__(36),
parseRadius = _require.parseRadius;
var Shape = __webpack_require__(7);
var Rect = function Rect(cfg) {
Rect.superclass.constructor.call(this, cfg);
};
Rect.ATTRS = {
x: 0,
y: 0,
width: 0,
height: 0,
radius: 0,
lineWidth: 1
};
Util.extend(Rect, Shape);
Util.augment(Rect, {
canFill: true,
canStroke: true,
type: 'rect',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1,
radius: 0
};
},
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var x = attrs.x;
var y = attrs.y;
var width = attrs.width;
var height = attrs.height;
var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2;
return {
minX: x - halfWidth,
minY: y - halfWidth,
maxX: x + width + halfWidth,
maxY: y + height + halfWidth
};
},
createPath: function createPath(context) {
var self = this;
var attrs = self._attrs;
var x = attrs.x;
var y = attrs.y;
var width = attrs.width;
var height = attrs.height;
var radius = attrs.radius;
context = context || self.get('context');
context.beginPath();
if (radius === 0) {
// 改成原生的rect方法
context.rect(x, y, width, height);
} else {
var r = parseRadius(radius);
context.moveTo(x + r.r1, y);
context.lineTo(x + width - r.r2, y);
r.r2 !== 0 && context.arc(x + width - r.r2, y + r.r2, r.r2, -Math.PI / 2, 0);
context.lineTo(x + width, y + height - r.r3);
r.r3 !== 0 && context.arc(x + width - r.r3, y + height - r.r3, r.r3, 0, Math.PI / 2);
context.lineTo(x + r.r4, y + height);
r.r4 !== 0 && context.arc(x + r.r4, y + height - r.r4, r.r4, Math.PI / 2, Math.PI);
context.lineTo(x, y + r.r1);
r.r1 !== 0 && context.arc(x + r.r1, y + r.r1, r.r1, Math.PI, Math.PI * 1.5);
context.closePath();
}
}
});
module.exports = Rect;
/***/ }),
/* 142 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Shape = __webpack_require__(7);
var CText = function CText(cfg) {
CText.superclass.constructor.call(this, cfg);
};
CText.ATTRS = {
x: 0,
y: 0,
text: null,
fontSize: 12,
fontFamily: 'sans-serif',
fontStyle: 'normal',
fontWeight: 'normal',
fontVariant: 'normal',
textAlign: 'start',
textBaseline: 'bottom',
lineHeight: null,
textArr: null
};
Util.extend(CText, Shape);
Util.augment(CText, {
canFill: true,
canStroke: true,
type: 'text',
getDefaultAttrs: function getDefaultAttrs() {
return {
lineWidth: 1,
lineCount: 1,
fontSize: 12,
fontFamily: 'sans-serif',
fontStyle: 'normal',
fontWeight: 'normal',
fontVariant: 'normal',
textAlign: 'start',
textBaseline: 'bottom'
};
},
initTransform: function initTransform() {
var fontSize = this._attrs.fontSize;
if (fontSize && +fontSize < 12) {
// 小于 12 像素的文本进行 scale 处理
this.transform([['t', -1 * this._attrs.x, -1 * this._attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this._attrs.x, this._attrs.y]]);
}
},
_assembleFont: function _assembleFont() {
// var self = this;
var attrs = this._attrs;
var fontSize = attrs.fontSize;
var fontFamily = attrs.fontFamily;
var fontWeight = attrs.fontWeight;
var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
// self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
},
_setAttrText: function _setAttrText() {
var attrs = this._attrs;
var text = attrs.text;
var textArr = null;
if (Util.isString(text) && text.indexOf('\n') !== -1) {
textArr = text.split('\n');
var lineCount = textArr.length;
attrs.lineCount = lineCount;
}
attrs.textArr = textArr;
},
_getTextHeight: function _getTextHeight() {
var attrs = this._attrs;
var lineCount = attrs.lineCount;
var fontSize = attrs.fontSize * 1;
if (lineCount > 1) {
var spaceingY = this._getSpaceingY();
return fontSize * lineCount + spaceingY * (lineCount - 1);
}
return fontSize;
},
isHitBox: function isHitBox() {
return false;
},
calculateBox: function calculateBox() {
var self = this;
var attrs = self._attrs;
var cfg = this._cfg;
if (!cfg.attrs || cfg.hasUpdate) {
this._assembleFont();
this._setAttrText();
}
if (!attrs.textArr) {
this._setAttrText();
}
var x = attrs.x;
var y = attrs.y;
var width = self.measureText(); // attrs.width
if (!width) {
// 如果width不存在,四点共其实点
return {
minX: x,
minY: y,
maxX: x,
maxY: y
};
}
var height = self._getTextHeight(); // attrs.height
var textAlign = attrs.textAlign;
var textBaseline = attrs.textBaseline;
var lineWidth = self.getHitLineWidth();
var point = {
x: x,
y: y - height
};
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;
}
}
this.set('startPoint', point);
var halfWidth = lineWidth / 2;
return {
minX: point.x - halfWidth,
minY: point.y - halfWidth,
maxX: point.x + width + halfWidth,
maxY: point.y + height + halfWidth
};
},
_getSpaceingY: function _getSpaceingY() {
var attrs = this._attrs;
var lineHeight = attrs.lineHeight;
var fontSize = attrs.fontSize * 1;
return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
},
drawInner: function drawInner(context) {
var self = this;
var attrs = self._attrs;
var cfg = this._cfg;
if (!cfg.attrs || cfg.hasUpdate) {
this._assembleFont();
this._setAttrText();
}
context.font = attrs.font;
var text = attrs.text;
if (!text) {
return;
}
var textArr = attrs.textArr;
var x = attrs.x;
var y = attrs.y;
context.beginPath();
if (self.hasStroke()) {
var strokeOpacity = attrs.strokeOpacity;
if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
context.globalAlpha = strokeOpacity;
}
if (textArr) {
self._drawTextArr(context, false);
} else {
context.strokeText(text, x, y);
}
context.globalAlpha = 1;
}
if (self.hasFill()) {
var fillOpacity = attrs.fillOpacity;
if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
context.globalAlpha = fillOpacity;
}
if (textArr) {
self._drawTextArr(context, true);
} else {
context.fillText(text, x, y);
}
}
cfg.hasUpdate = false;
},
_drawTextArr: function _drawTextArr(context, fill) {
var textArr = this._attrs.textArr;
var textBaseline = this._attrs.textBaseline;
var fontSize = this._attrs.fontSize * 1;
var spaceingY = this._getSpaceingY();
var x = this._attrs.x;
var y = this._attrs.y;
var box = this.getBBox();
var height = box.maxY - box.minY;
var subY;
Util.each(textArr, function (subText, index) {
subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
if (textBaseline === 'top') subY += height - fontSize;
if (fill) {
context.fillText(subText, x, subY);
} else {
context.strokeText(subText, x, subY);
}
});
},
measureText: function measureText() {
var self = this;
var attrs = self._attrs;
var text = attrs.text;
var font = attrs.font;
var textArr = attrs.textArr;
var measureWidth;
var width = 0;
if (Util.isNil(text)) return undefined;
var context = document.createElement('canvas').getContext('2d');
context.save();
context.font = font;
if (textArr) {
Util.each(textArr, function (subText) {
measureWidth = context.measureText(subText).width;
if (width < measureWidth) {
width = measureWidth;
}
context.restore();
});
} else {
width = context.measureText(text).width;
context.restore();
}
return width;
}
});
module.exports = CText;
/***/ }),
/* 143 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
isFunction: __webpack_require__(14),
isObject: __webpack_require__(38),
isBoolean: __webpack_require__(185),
isNil: __webpack_require__(6),
isString: __webpack_require__(15),
isArray: __webpack_require__(4),
isNumber: __webpack_require__(11),
isEmpty: __webpack_require__(161),
// isBlank
uniqueId: __webpack_require__(188),
clone: __webpack_require__(74),
deepMix: __webpack_require__(75),
assign: __webpack_require__(10),
// simpleMix
merge: __webpack_require__(75),
// mix
upperFirst: __webpack_require__(183),
// ucfirst
each: __webpack_require__(2),
isEqual: __webpack_require__(77),
toArray: __webpack_require__(53),
extend: __webpack_require__(156),
augment: __webpack_require__(152),
remove: __webpack_require__(150),
isNumberEqual: __webpack_require__(51),
toRadian: __webpack_require__(166),
toDegree: __webpack_require__(164),
mod: __webpack_require__(163),
clamp: __webpack_require__(78),
createDom: __webpack_require__(153),
modifyCSS: __webpack_require__(154),
requestAnimationFrame: __webpack_require__(155),
getRatio: function getRatio() {
return window.devicePixelRatio ? window.devicePixelRatio : 2;
},
mat3: __webpack_require__(79),
vec2: __webpack_require__(168),
vec3: __webpack_require__(169),
transform: __webpack_require__(167)
};
/***/ }),
/* 144 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 计算分类的的坐标点
* @author dxq613@gmail.com
*/
var each = __webpack_require__(2);
var MAX_COUNT = 8;
var SUB_COUNT = 4; // 控制个数不能过小
function getSimpleArray(data) {
var arr = [];
each(data, function (sub) {
arr = arr.concat(sub);
});
return arr;
}
function getGreatestFactor(count, number) {
var i;
for (i = number; i > 0; i--) {
if (count % i === 0) {
break;
}
} // 如果是素数,没有可以整除的数字
if (i === 1) {
for (i = number; i > 0; i--) {
if ((count - 1) % i === 0) {
break;
}
}
}
return i;
}
module.exports = function (info) {
var rst = {};
var ticks = [];
var isRounding = info.isRounding;
var categories = getSimpleArray(info.data);
var length = categories.length;
var maxCount = info.maxCount || MAX_COUNT;
var tickCount;
if (isRounding) {
// 取整操作
tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
if (tickCount === 2) {
tickCount = maxCount;
} else if (tickCount < maxCount - SUB_COUNT) {
tickCount = maxCount - SUB_COUNT;
}
} else {
tickCount = maxCount;
}
if (!isRounding && length <= tickCount + tickCount / 2) {
ticks = [].concat(categories);
} else {
var step = parseInt(length / (tickCount - 1), 10);
var groups = categories.map(function (e, i) {
return i % step === 0 ? categories.slice(i, i + step) : null;
}).filter(function (e) {
return e;
});
for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
ticks.push(groups[i][0]);
}
if (categories.length) {
ticks.unshift(categories[0]);
var last = categories[length - 1];
if (ticks.indexOf(last) === -1) {
ticks.push(last);
}
}
}
rst.categories = categories;
rst.ticks = ticks;
return rst;
};
/***/ }),
/* 145 */
/***/ (function(module, exports) {
/**
* @fileOverview 计算方法
* @author dxq613@gmail.com
*/
// 如果小数点后面超过 10 位浮点数时进行一下处理
var DECIMAL_LENGTH = 12; // 获取系数
function getFactor(v) {
var factor = 1;
if (v === Infinity || v === -Infinity) {
throw new Error('Not support Infinity!');
}
if (v < 1) {
var count = 0;
while (v < 1) {
factor = factor / 10;
v = v * 10;
count++;
} // 浮点数计算出现问题
if (factor.toString().length > DECIMAL_LENGTH) {
factor = parseFloat(factor.toFixed(count));
}
} else {
while (v > 10) {
factor = factor * 10;
v = v / 10;
}
}
return factor;
} // 取小于当前值的
function arrayFloor(values, value) {
var length = values.length;
if (length === 0) {
return NaN;
}
var pre = values[0];
if (value < values[0]) {
return NaN;
}
if (value >= values[length - 1]) {
return values[length - 1];
}
for (var i = 1; i < values.length; i++) {
if (value < values[i]) {
break;
}
pre = values[i];
}
return pre;
} // 大于当前值的第一个
function arrayCeiling(values, value) {
var length = values.length;
if (length === 0) {
return NaN;
} // var pre = values[0];
var rst;
if (value > values[length - 1]) {
return NaN;
}
if (value < values[0]) {
return values[0];
}
for (var i = 1; i < values.length; i++) {
if (value <= values[i]) {
rst = values[i];
break;
}
}
return rst;
}
var Util = {
// 获取逼近的数值
snapFactorTo: function snapFactorTo(v, arr, snapType) {
// 假设 v = -512,isFloor = true
if (isNaN(v)) {
return NaN;
}
var factor = 1; // 计算系数
if (v !== 0) {
if (v < 0) {
factor = -1;
}
v = v * factor; // v = 512
var tmpFactor = getFactor(v);
factor = factor * tmpFactor; // factor = -100
v = v / tmpFactor; // v = 5.12
}
if (snapType === 'floor') {
v = Util.snapFloor(arr, v); // v = 5
} else if (snapType === 'ceil') {
v = Util.snapCeiling(arr, v); // v = 6
} else {
v = Util.snapTo(arr, v); // 四舍五入 5
}
var rst = parseFloat((v * factor).toPrecision(DECIMAL_LENGTH)); // 如果出现浮点数计算问题,需要处理一下
// 如果出现浮点数计算问题,需要处理一下
if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
var decimalVal = parseInt(1 / factor);
var symbol = factor > 0 ? 1 : -1;
rst = v / decimalVal * symbol;
}
return rst;
},
// 获取逼近的倍数
snapMultiple: 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;
},
/**
* 获取逼近的值,用于对齐数据
* @param {Array} values 数据集合
* @param {Number} value 数值
* @return {Number} 逼近的值
*/
snapTo: function snapTo(values, value) {
// 这里假定values是升序排列
var floorVal = arrayFloor(values, value);
var ceilingVal = arrayCeiling(values, value);
if (isNaN(floorVal) || isNaN(ceilingVal)) {
if (values[0] >= value) {
return values[0];
}
var last = values[values.length - 1];
if (last <= value) {
return last;
}
}
if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
return floorVal;
}
return ceilingVal;
},
/**
* 获取逼近的最小值,用于对齐数据
* @param {Array} values 数据集合
* @param {Number} value 数值
* @return {Number} 逼近的最小值
*/
snapFloor: function snapFloor(values, value) {
// 这里假定values是升序排列
return arrayFloor(values, value);
},
/**
* 获取逼近的最大值,用于对齐数据
* @param {Array} values 数据集合
* @param {Number} value 数值
* @return {Number} 逼近的最大值
*/
snapCeiling: function snapCeiling(values, value) {
// 这里假定values是升序排列
return arrayCeiling(values, value);
},
fixedBase: function fixedBase(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));
}
};
module.exports = Util;
/***/ }),
/* 146 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(26);
var catAuto = __webpack_require__(144);
var each = __webpack_require__(2);
var isNumber = __webpack_require__(11);
var isString = __webpack_require__(15);
var Category =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Category, _Base);
function Category() {
return _Base.apply(this, arguments) || this;
}
var _proto = Category.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Base.prototype._initDefaultCfg.call(this);
this.type = 'cat';
/**
* 是否分类度量
* @type {Boolean}
*/
this.isCategory = true;
this.isRounding = true; // 是否进行取整操作
}
/**
* @override
*/
;
_proto.init = function init() {
var self = this;
var values = self.values;
var tickCount = self.tickCount;
each(values, function (v, i) {
values[i] = v.toString();
});
if (!self.ticks) {
var ticks = values;
if (tickCount) {
var temp = catAuto({
maxCount: tickCount,
data: values,
isRounding: self.isRounding
});
ticks = temp.ticks;
}
this.ticks = ticks;
}
}
/**
* @override
*/
;
_proto.getText = function getText(value) {
if (this.values.indexOf(value) === -1 && isNumber(value)) {
value = this.values[Math.round(value)];
}
return _Base.prototype.getText.call(this, value);
}
/**
* @override
*/
;
_proto.translate = function translate(value) {
var index = this.values.indexOf(value);
if (index === -1 && isNumber(value)) {
index = value;
} else if (index === -1) {
index = NaN;
}
return index;
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
var rangeMin = this.rangeMin();
var rangeMax = this.rangeMax();
var percent;
if (isString(value) || this.values.indexOf(value) !== -1) {
value = this.translate(value);
}
if (this.values.length > 1) {
percent = value / (this.values.length - 1);
} else {
percent = value;
}
return rangeMin + percent * (rangeMax - rangeMin);
}
/**
* @override
*/
;
_proto.invert = function invert(value) {
if (isString(value)) {
// 如果已经是字符串
return value;
}
var min = this.rangeMin();
var max = this.rangeMax(); // 归一到 范围内
if (value < min) {
value = min;
}
if (value > max) {
value = max;
}
var percent = (value - min) / (max - min);
var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
index = index || 0;
return this.values[index];
};
return Category;
}(Base);
Base.Cat = Category;
module.exports = Category;
/***/ }),
/* 147 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview Scale entry, used to reference all the scales
* @author dxq613@gmail.com
*/
var lowerFirst = __webpack_require__(181);
var Base = __webpack_require__(26);
Base.Linear = __webpack_require__(48);
Base.Identity = __webpack_require__(337);
Base.Cat = __webpack_require__(146);
Base.Time = __webpack_require__(341);
Base.TimeCat = __webpack_require__(340);
Base.Log = __webpack_require__(338);
Base.Pow = __webpack_require__(339);
var _loop = function _loop(k) {
if (Base.hasOwnProperty(k)) {
var methodName = lowerFirst(k);
Base[methodName] = function (cfg) {
return new Base[k](cfg);
};
}
};
for (var k in Base) {
_loop(k);
}
var CAT_ARR = ['cat', 'timeCat'];
Base.isCategory = function (type) {
return CAT_ARR.indexOf(type) >= 0;
};
module.exports = Base;
/***/ }),
/* 148 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 提取公共代码到util方法
* @author dxq613@gmail.com
*/
var isString = __webpack_require__(15);
var isDate = __webpack_require__(186);
module.exports = {
toTimeStamp: function toTimeStamp(value) {
if (isString(value)) {
if (value.indexOf('T') > 0) {
value = new Date(value).getTime();
} else {
value = new Date(value.replace(/-/ig, '/')).getTime();
}
}
if (isDate(value)) {
value = value.getTime();
}
return value;
}
};
/***/ }),
/* 149 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(20);
var splice = Array.prototype.splice;
var pullAt = function pullAt(arr, indexes) {
if (!isArrayLike(arr)) {
return [];
}
var length = arr ? indexes.length : 0;
var last = length - 1;
while (length--) {
var previous = void 0;
var index = indexes[length];
if (length === last || index !== previous) {
previous = index;
splice.call(arr, index, 1);
}
}
return arr;
};
module.exports = pullAt;
/***/ }),
/* 150 */
/***/ (function(module, exports) {
var arrPrototype = Array.prototype;
var splice = arrPrototype.splice;
var indexOf = arrPrototype.indexOf;
var slice = arrPrototype.slice;
var pull = function pull(arr) {
var values = slice.call(arguments, 1);
for (var i = 0; i < values.length; i++) {
var value = values[i];
var fromIndex = -1;
while ((fromIndex = indexOf.call(arr, value)) > -1) {
splice.call(arr, fromIndex, 1);
}
}
return arr;
};
module.exports = pull;
/***/ }),
/* 151 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var contains = __webpack_require__(49);
var uniq = function uniq(arr) {
var resultArr = [];
each(arr, function (item) {
if (!contains(resultArr, item)) {
resultArr.push(item);
}
});
return resultArr;
};
module.exports = uniq;
/***/ }),
/* 152 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(14);
var toArray = __webpack_require__(53);
var mix = __webpack_require__(10);
var augment = function augment(c) {
var args = toArray(arguments);
for (var i = 1; i < args.length; i++) {
var obj = args[i];
if (isFunction(obj)) {
obj = obj.prototype;
}
mix(c.prototype, obj);
}
};
module.exports = augment;
/***/ }),
/* 153 */
/***/ (function(module, exports) {
/**
* 创建DOM 节点
* @param {String} str Dom 字符串
* @return {HTMLElement} DOM 节点
*/
var TABLE = document.createElement('table');
var TABLE_TR = document.createElement('tr');
var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
var CONTAINERS = {
tr: document.createElement('tbody'),
tbody: TABLE,
thead: TABLE,
tfoot: TABLE,
td: TABLE_TR,
th: TABLE_TR,
'*': document.createElement('div')
};
module.exports = function createDom(str) {
var name = FRAGMENT_REG.test(str) && RegExp.$1;
if (!(name in CONTAINERS)) {
name = '*';
}
var container = CONTAINERS[name];
str = str.replace(/(^\s*)|(\s*$)/g, '');
container.innerHTML = '' + str;
var dom = container.childNodes[0];
container.removeChild(dom);
return dom;
};
/***/ }),
/* 154 */
/***/ (function(module, exports) {
module.exports = function modifyCSS(dom, css) {
if (dom) {
for (var key in css) {
if (css.hasOwnProperty(key)) {
dom.style[key] = css[key];
}
}
}
return dom;
};
/***/ }),
/* 155 */
/***/ (function(module, exports) {
module.exports = function requestAnimationFrame(fn) {
var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
return setTimeout(fn, 16);
};
return method(fn);
};
/***/ }),
/* 156 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(14);
var mix = __webpack_require__(10);
var extend = function extend(subclass, superclass, overrides, staticOverrides) {
// 如果只提供父类构造函数,则自动生成子类构造函数
if (!isFunction(superclass)) {
overrides = superclass;
superclass = subclass;
subclass = function subclass() {};
}
var create = Object.create ? function (proto, c) {
return Object.create(proto, {
constructor: {
value: c
}
});
} : function (proto, c) {
function Tmp() {}
Tmp.prototype = proto;
var o = new Tmp();
o.constructor = c;
return o;
};
var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
subclass.superclass = create(superclass.prototype, superclass);
mix(superObj, overrides);
mix(subclass, staticOverrides);
return subclass;
};
module.exports = extend;
/***/ }),
/* 157 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isArray = __webpack_require__(4);
var hasOwnProperty = Object.prototype.hasOwnProperty;
var groupBy = function groupBy(data, condition) {
if (!condition || !isArray(data)) {
return data;
}
var result = {};
var key = null;
each(data, function (item) {
key = condition(item);
if (hasOwnProperty.call(result, key)) {
result[key].push(item);
} else {
result[key] = [item];
}
});
return result;
};
module.exports = groupBy;
/***/ }),
/* 158 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(14);
var isArray = __webpack_require__(4);
var groupBy = __webpack_require__(157);
var groupToMap = function groupToMap(data, condition) {
if (!condition) {
return {
0: data
};
}
if (!isFunction(condition)) {
var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
condition = function condition(row) {
var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
for (var i = 0, l = paramsCondition.length; i < l; i++) {
unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
}
return unique;
};
}
var groups = groupBy(data, condition);
return groups;
};
module.exports = groupToMap;
/***/ }),
/* 159 */
/***/ (function(module, exports, __webpack_require__) {
var groupToMap = __webpack_require__(158);
var group = function group(data, condition) {
if (!condition) {
return [data];
}
var groups = groupToMap(data, condition);
var array = [];
for (var i in groups) {
array.push(groups[i]);
}
return array;
};
module.exports = group;
/***/ }),
/* 160 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var mix = __webpack_require__(10);
// collections
var DOMUtil = __webpack_require__(362);
var arrayUtil = __webpack_require__(348);
var eventUtil = __webpack_require__(364);
var formatUtil = __webpack_require__(366);
var mathUtil = __webpack_require__(374);
var matrixUtil = __webpack_require__(52);
var objectUtil = __webpack_require__(385);
var pathUtil = __webpack_require__(389);
var stringUtil = __webpack_require__(393);
var typeUtil = __webpack_require__(398);
var util = {
// collections
DOMUtil: DOMUtil,
DomUtil: DOMUtil,
MatrixUtil: matrixUtil,
PathUtil: pathUtil,
arrayUtil: arrayUtil,
domUtil: DOMUtil,
eventUtil: eventUtil,
formatUtil: formatUtil,
mathUtil: mathUtil,
matrixUtil: matrixUtil,
objectUtil: objectUtil,
stringUtil: stringUtil,
pathUtil: pathUtil,
typeUtil: typeUtil,
// others
augment: __webpack_require__(152),
clone: __webpack_require__(74),
debounce: __webpack_require__(353),
deepMix: __webpack_require__(75),
each: each,
extend: __webpack_require__(156),
filter: __webpack_require__(76),
group: __webpack_require__(159),
groupBy: __webpack_require__(157),
groupToMap: __webpack_require__(158),
indexOf: __webpack_require__(370),
isEmpty: __webpack_require__(161),
isEqual: __webpack_require__(77),
isEqualWith: __webpack_require__(371),
map: __webpack_require__(372),
mix: mix,
pick: __webpack_require__(392),
throttle: __webpack_require__(397),
toArray: __webpack_require__(53),
toString: __webpack_require__(37),
uniqueId: __webpack_require__(188)
};
each([DOMUtil, arrayUtil, eventUtil, formatUtil, mathUtil, matrixUtil, objectUtil, pathUtil, stringUtil, typeUtil], function (collection) {
mix(util, collection);
});
module.exports = util;
/***/ }),
/* 161 */
/***/ (function(module, exports, __webpack_require__) {
var isNil = __webpack_require__(6);
var isArrayLike = __webpack_require__(20);
var getType = __webpack_require__(184);
var isPrototype = __webpack_require__(187);
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(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;
}
module.exports = isEmpty;
/***/ }),
/* 162 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var isFunction = __webpack_require__(14);
var each = __webpack_require__(2);
/**
* @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(arr)) {
return undefined;
}
var max = arr[0];
var maxData = void 0;
if (isFunction(fn)) {
maxData = fn(arr[0]);
} else {
maxData = arr[0][fn];
}
var data = void 0;
each(arr, function (val) {
if (isFunction(fn)) {
data = fn(val);
} else {
data = val[fn];
}
if (data > maxData) {
max = val;
maxData = data;
}
});
return max;
};
module.exports = maxBy;
/***/ }),
/* 163 */
/***/ (function(module, exports) {
var mod = function mod(n, m) {
return (n % m + m) % m;
};
module.exports = mod;
/***/ }),
/* 164 */
/***/ (function(module, exports) {
var DEGREE = 180 / Math.PI;
var toDegree = function toDegree(radian) {
return DEGREE * radian;
};
module.exports = toDegree;
/***/ }),
/* 165 */
/***/ (function(module, exports) {
module.exports = parseInt;
/***/ }),
/* 166 */
/***/ (function(module, exports) {
var RADIAN = Math.PI / 180;
var toRadian = function toRadian(degree) {
return RADIAN * degree;
};
module.exports = toRadian;
/***/ }),
/* 167 */
/***/ (function(module, exports, __webpack_require__) {
var clone = __webpack_require__(74);
var each = __webpack_require__(2);
var mat3 = __webpack_require__(79);
module.exports = function transform(m, ts) {
m = clone(m);
each(ts, function (t) {
switch (t[0]) {
case 't':
mat3.translate(m, m, [t[1], t[2]]);
break;
case 's':
mat3.scale(m, m, [t[1], t[2]]);
break;
case 'r':
mat3.rotate(m, m, t[1]);
break;
case 'm':
mat3.multiply(m, m, t[1]);
break;
default:
return false;
}
});
return m;
};
/***/ }),
/* 168 */
/***/ (function(module, exports, __webpack_require__) {
var vec2 = __webpack_require__(333);
var clamp = __webpack_require__(78);
vec2.angle = function (v1, v2) {
var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
return Math.acos(clamp(theta, -1, 1));
};
/**
* 向量 v1 到 向量 v2 夹角的方向
* @param {Array} v1 向量
* @param {Array} v2 向量
* @return {Boolean} >= 0 顺时针 < 0 逆时针
*/
vec2.direction = function (v1, v2) {
return v1[0] * v2[1] - v2[0] * v1[1];
};
vec2.angleTo = function (v1, v2, direct) {
var angle = vec2.angle(v1, v2);
var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
if (direct) {
if (angleLargeThanPI) {
return Math.PI * 2 - angle;
}
return angle;
}
if (angleLargeThanPI) {
return angle;
}
return Math.PI * 2 - angle;
};
vec2.vertical = function (out, v, flag) {
if (flag) {
out[0] = v[1];
out[1] = -1 * v[0];
} else {
out[0] = -1 * v[1];
out[1] = v[0];
}
return out;
};
module.exports = vec2;
/***/ }),
/* 169 */
/***/ (function(module, exports, __webpack_require__) {
var vec3 = __webpack_require__(334);
module.exports = vec3;
/***/ }),
/* 170 */
/***/ (function(module, exports) {
module.exports = function (obj, key) {
return obj.hasOwnProperty(key);
};
/***/ }),
/* 171 */
/***/ (function(module, exports, __webpack_require__) {
var keys = __webpack_require__(172);
var isNil = __webpack_require__(6);
function isMatch(obj, attrs) {
var _keys = keys(attrs);
var length = _keys.length;
if (isNil(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;
}
module.exports = isMatch;
/***/ }),
/* 172 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isFunction = __webpack_require__(14);
var keys = Object.keys ? function (obj) {
return Object.keys(obj);
} : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(key);
}
});
return result;
};
module.exports = keys;
/***/ }),
/* 173 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isFunction = __webpack_require__(14);
var values = Object.values ? function (obj) {
return Object.values(obj);
} : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(value);
}
});
return result;
};
module.exports = values;
/***/ }),
/* 174 */
/***/ (function(module, exports) {
// http://schepers.cc/getting-to-the-point
module.exports = function catmullRom2bezier(crp, z) {
var d = [];
for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
var p = [{
x: +crp[i - 2],
y: +crp[i - 1]
}, {
x: +crp[i],
y: +crp[i + 1]
}, {
x: +crp[i + 2],
y: +crp[i + 3]
}, {
x: +crp[i + 4],
y: +crp[i + 5]
}];
if (z) {
if (!i) {
p[0] = {
x: +crp[iLen - 2],
y: +crp[iLen - 1]
};
} else if (iLen - 4 === i) {
p[3] = {
x: +crp[0],
y: +crp[1]
};
} else if (iLen - 2 === i) {
p[2] = {
x: +crp[0],
y: +crp[1]
};
p[3] = {
x: +crp[2],
y: +crp[3]
};
}
} else {
if (iLen - 4 === i) {
p[3] = p[2];
} else if (!i) {
p[0] = {
x: +crp[i],
y: +crp[i + 1]
};
}
}
d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
}
return d;
};
/***/ }),
/* 175 */
/***/ (function(module, exports) {
var p2s = /,?([a-z]),?/gi;
module.exports = function parsePathArray(path) {
return path.join(',').replace(p2s, '$1');
};
/***/ }),
/* 176 */
/***/ (function(module, exports) {
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 SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
// Parses given path string into an array of arrays of path segments
module.exports = function parsePathString(pathString) {
if (!pathString) {
return null;
}
if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
return pathString;
}
var paramCounts = {
a: 7,
c: 6,
o: 2,
h: 1,
l: 2,
m: 2,
r: 4,
q: 4,
s: 4,
t: 2,
v: 1,
u: 3,
z: 0
};
var data = [];
String(pathString).replace(PATH_COMMAND, function (a, b, c) {
var params = [];
var name = b.toLowerCase();
c.replace(PATH_VALUES, function (a, b) {
b && params.push(+b);
});
if (name === 'm' && params.length > 2) {
data.push([b].concat(params.splice(0, 2)));
name = 'l';
b = b === 'm' ? 'l' : 'L';
}
if (name === 'o' && params.length === 1) {
data.push([b, params[0]]);
}
if (name === 'r') {
data.push([b].concat(params));
} else {
while (params.length >= paramCounts[name]) {
data.push([b].concat(params.splice(0, paramCounts[name])));
if (!paramCounts[name]) {
break;
}
}
}
});
return data;
};
/***/ }),
/* 177 */
/***/ (function(module, exports, __webpack_require__) {
var parsePathString = __webpack_require__(176);
var catmullRom2bezier = __webpack_require__(174);
function ellipsePath(x, y, rx, ry, a) {
var res = [];
if (a === null && ry === null) {
ry = rx;
}
x = +x;
y = +y;
rx = +rx;
ry = +ry;
if (a !== null) {
var rad = Math.PI / 180;
var x1 = x + rx * Math.cos(-ry * rad);
var x2 = x + rx * Math.cos(-a * rad);
var y1 = y + rx * Math.sin(-ry * rad);
var y2 = y + rx * Math.sin(-a * rad);
res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
} else {
res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
}
return res;
}
module.exports = function pathToAbsolute(pathArray) {
pathArray = parsePathString(pathArray);
if (!pathArray || !pathArray.length) {
return [['M', 0, 0]];
}
var res = [];
var x = 0;
var y = 0;
var mx = 0;
var my = 0;
var start = 0;
var pa0 = void 0;
var dots = void 0;
if (pathArray[0][0] === 'M') {
x = +pathArray[0][1];
y = +pathArray[0][2];
mx = x;
my = y;
start++;
res[0] = ['M', x, y];
}
var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
res.push(r = []);
pa = pathArray[i];
pa0 = pa[0];
if (pa0 !== pa0.toUpperCase()) {
r[0] = pa0.toUpperCase();
switch (r[0]) {
case 'A':
r[1] = pa[1];
r[2] = pa[2];
r[3] = pa[3];
r[4] = pa[4];
r[5] = pa[5];
r[6] = +pa[6] + x;
r[7] = +pa[7] + y;
break;
case 'V':
r[1] = +pa[1] + y;
break;
case 'H':
r[1] = +pa[1] + x;
break;
case 'R':
dots = [x, y].concat(pa.slice(1));
for (var j = 2, jj = dots.length; j < jj; j++) {
dots[j] = +dots[j] + x;
dots[++j] = +dots[j] + y;
}
res.pop();
res = res.concat(catmullRom2bezier(dots, crz));
break;
case 'O':
res.pop();
dots = ellipsePath(x, y, pa[1], pa[2]);
dots.push(dots[0]);
res = res.concat(dots);
break;
case 'U':
res.pop();
res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
r = ['U'].concat(res[res.length - 1].slice(-2));
break;
case 'M':
mx = +pa[1] + x;
my = +pa[2] + y;
break; // for lint
default:
for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
r[_j] = +pa[_j] + (_j % 2 ? x : y);
}
}
} else if (pa0 === 'R') {
dots = [x, y].concat(pa.slice(1));
res.pop();
res = res.concat(catmullRom2bezier(dots, crz));
r = ['R'].concat(pa.slice(-2));
} else if (pa0 === 'O') {
res.pop();
dots = ellipsePath(x, y, pa[1], pa[2]);
dots.push(dots[0]);
res = res.concat(dots);
} else if (pa0 === 'U') {
res.pop();
res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
r = ['U'].concat(res[res.length - 1].slice(-2));
} else {
for (var k = 0, kk = pa.length; k < kk; k++) {
r[k] = pa[k];
}
}
pa0 = pa0.toUpperCase();
if (pa0 !== 'O') {
switch (r[0]) {
case 'Z':
x = +mx;
y = +my;
break;
case 'H':
x = r[1];
break;
case 'V':
y = r[1];
break;
case 'M':
mx = r[r.length - 2];
my = r[r.length - 1];
break; // for lint
default:
x = r[r.length - 2];
y = r[r.length - 1];
}
}
}
return res;
};
/***/ }),
/* 178 */
/***/ (function(module, exports, __webpack_require__) {
var pathToAbsolute = __webpack_require__(177);
var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
// for more information of where this math came from visit:
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
if (rx === ry) {
rx += 1;
}
var _120 = Math.PI * 120 / 180;
var rad = Math.PI / 180 * (+angle || 0);
var res = [];
var xy = void 0;
var f1 = void 0;
var f2 = void 0;
var cx = void 0;
var cy = void 0;
var rotate = function rotate(x, y, rad) {
var X = x * Math.cos(rad) - y * Math.sin(rad);
var Y = x * Math.sin(rad) + y * Math.cos(rad);
return {
x: X,
y: Y
};
};
if (!recursive) {
xy = rotate(x1, y1, -rad);
x1 = xy.x;
y1 = xy.y;
xy = rotate(x2, y2, -rad);
x2 = xy.x;
y2 = xy.y;
if (x1 === x2 && y1 === y2) {
// 若弧的起始点和终点重叠则错开一点
x2 += 1;
y2 += 1;
}
// const cos = Math.cos(Math.PI / 180 * angle);
// const sin = Math.sin(Math.PI / 180 * angle);
var x = (x1 - x2) / 2;
var y = (y1 - y2) / 2;
var h = x * x / (rx * rx) + y * y / (ry * ry);
if (h > 1) {
h = Math.sqrt(h);
rx = h * rx;
ry = h * ry;
}
var rx2 = rx * rx;
var ry2 = ry * ry;
var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
cx = k * rx * y / ry + (x1 + x2) / 2;
cy = k * -ry * x / rx + (y1 + y2) / 2;
f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
f1 = x1 < cx ? Math.PI - f1 : f1;
f2 = x2 < cx ? Math.PI - f2 : f2;
f1 < 0 && (f1 = Math.PI * 2 + f1);
f2 < 0 && (f2 = Math.PI * 2 + f2);
if (sweep_flag && f1 > f2) {
f1 = f1 - Math.PI * 2;
}
if (!sweep_flag && f2 > f1) {
f2 = f2 - Math.PI * 2;
}
} else {
f1 = recursive[0];
f2 = recursive[1];
cx = recursive[2];
cy = recursive[3];
}
var df = f2 - f1;
if (Math.abs(df) > _120) {
var f2old = f2;
var x2old = x2;
var y2old = y2;
f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
x2 = cx + rx * Math.cos(f2);
y2 = cy + ry * Math.sin(f2);
res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
}
df = f2 - f1;
var c1 = Math.cos(f1);
var s1 = Math.sin(f1);
var c2 = Math.cos(f2);
var s2 = Math.sin(f2);
var t = Math.tan(df / 4);
var hx = 4 / 3 * rx * t;
var hy = 4 / 3 * ry * t;
var m1 = [x1, y1];
var m2 = [x1 + hx * s1, y1 - hy * c1];
var m3 = [x2 + hx * s2, y2 - hy * c2];
var m4 = [x2, y2];
m2[0] = 2 * m1[0] - m2[0];
m2[1] = 2 * m1[1] - m2[1];
if (recursive) {
return [m2, m3, m4].concat(res);
}
res = [m2, m3, m4].concat(res).join().split(',');
var newres = [];
for (var i = 0, ii = res.length; i < ii; i++) {
newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
}
return newres;
};
var l2c = function l2c(x1, y1, x2, y2) {
return [x1, y1, x2, y2, x2, y2];
};
var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
var _13 = 1 / 3;
var _23 = 2 / 3;
return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
};
module.exports = function pathTocurve(path, path2) {
var p = pathToAbsolute(path);
var p2 = path2 && pathToAbsolute(path2);
var attrs = {
x: 0,
y: 0,
bx: 0,
by: 0,
X: 0,
Y: 0,
qx: null,
qy: null
};
var attrs2 = {
x: 0,
y: 0,
bx: 0,
by: 0,
X: 0,
Y: 0,
qx: null,
qy: null
};
var pcoms1 = []; // path commands of original path p
var pcoms2 = []; // path commands of original path p2
var pfirst = ''; // temporary holder for original path command
var pcom = ''; // holder for previous path command of original path
var ii = void 0;
var processPath = function processPath(path, d, pcom) {
var nx = void 0,
ny = void 0;
if (!path) {
return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
}!(path[0] in {
T: 1,
Q: 1
}) && (d.qx = d.qy = null);
switch (path[0]) {
case 'M':
d.X = path[1];
d.Y = path[2];
break;
case 'A':
path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
break;
case 'S':
if (pcom === 'C' || pcom === 'S') {
// In "S" case we have to take into account, if the previous command is C/S.
nx = d.x * 2 - d.bx; // And reflect the previous
ny = d.y * 2 - d.by; // command's control point relative to the current point.
} else {
// or some else or nothing
nx = d.x;
ny = d.y;
}
path = ['C', nx, ny].concat(path.slice(1));
break;
case 'T':
if (pcom === 'Q' || pcom === 'T') {
// In "T" case we have to take into account, if the previous command is Q/T.
d.qx = d.x * 2 - d.qx; // And make a reflection similar
d.qy = d.y * 2 - d.qy; // to case "S".
} else {
// or something else or nothing
d.qx = d.x;
d.qy = d.y;
}
path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
break;
case 'Q':
d.qx = path[1];
d.qy = path[2];
path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
break;
case 'L':
path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
break;
case 'H':
path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
break;
case 'V':
path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
break;
case 'Z':
path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
break;
default:
break;
}
return path;
};
var fixArc = function fixArc(pp, i) {
if (pp[i].length > 7) {
pp[i].shift();
var pi = pp[i];
while (pi.length) {
pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
p2 && (pcoms2[i] = 'A'); // the same as above
pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
}
pp.splice(i, 1);
ii = Math.max(p.length, p2 && p2.length || 0);
}
};
var fixM = function fixM(path1, path2, a1, a2, i) {
if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
path2.splice(i, 0, ['M', a2.x, a2.y]);
a1.bx = 0;
a1.by = 0;
a1.x = path1[i][1];
a1.y = path1[i][2];
ii = Math.max(p.length, p2 && p2.length || 0);
}
};
ii = Math.max(p.length, p2 && p2.length || 0);
for (var i = 0; i < ii; i++) {
p[i] && (pfirst = p[i][0]); // save current path command
if (pfirst !== 'C') {
// C is not saved yet, because it may be result of conversion
pcoms1[i] = pfirst; // Save current path command
i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
}
p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
// which may produce multiple C:s
// so we have to make sure that C is also C in original path
fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
if (p2) {
// the same procedures is done to p2
p2[i] && (pfirst = p2[i][0]);
if (pfirst !== 'C') {
pcoms2[i] = pfirst;
i && (pcom = pcoms2[i - 1]);
}
p2[i] = processPath(p2[i], attrs2, pcom);
if (pcoms2[i] !== 'A' && pfirst === 'C') {
pcoms2[i] = 'C';
}
fixArc(p2, i);
}
fixM(p, p2, attrs, attrs2, i);
fixM(p2, p, attrs2, attrs, i);
var seg = p[i];
var seg2 = p2 && p2[i];
var seglen = seg.length;
var seg2len = p2 && seg2.length;
attrs.x = seg[seglen - 2];
attrs.y = seg[seglen - 1];
attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
attrs2.x = p2 && seg2[seg2len - 2];
attrs2.y = p2 && seg2[seg2len - 1];
}
return p2 ? [p, p2] : p;
};
/***/ }),
/* 179 */
/***/ (function(module, exports, __webpack_require__) {
var parsePathArray = __webpack_require__(175);
module.exports = function rectPath(x, y, w, h, r) {
if (r) {
return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
}
var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
res.parsePathArray = parsePathArray;
return res;
};
/***/ }),
/* 180 */
/***/ (function(module, exports, __webpack_require__) {
var toString = __webpack_require__(37);
var lowerCase = function lowerCase(str) {
return toString(str).toLowerCase();
};
module.exports = lowerCase;
/***/ }),
/* 181 */
/***/ (function(module, exports, __webpack_require__) {
var toString = __webpack_require__(37);
var lowerFirst = function lowerFirst(value) {
var str = toString(value);
return str.charAt(0).toLowerCase() + str.substring(1);
};
module.exports = lowerFirst;
/***/ }),
/* 182 */
/***/ (function(module, exports, __webpack_require__) {
var toString = __webpack_require__(37);
var upperCase = function upperCase(str) {
return toString(str).toUpperCase();
};
module.exports = upperCase;
/***/ }),
/* 183 */
/***/ (function(module, exports, __webpack_require__) {
var toString = __webpack_require__(37);
var upperFirst = function upperFirst(value) {
var str = toString(value);
return str.charAt(0).toUpperCase() + str.substring(1);
};
module.exports = upperFirst;
/***/ }),
/* 184 */
/***/ (function(module, exports) {
var toString = {}.toString;
var getType = function getType(value) {
return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
};
module.exports = getType;
/***/ }),
/* 185 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 是否是布尔类型
*
* @param {Object} value 测试的值
* @return {Boolean}
*/
var isType = __webpack_require__(16);
var isBoolean = function isBoolean(value) {
return isType(value, 'Boolean');
};
module.exports = isBoolean;
/***/ }),
/* 186 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(16);
var isDate = function isDate(value) {
return isType(value, 'Date');
};
module.exports = isDate;
/***/ }),
/* 187 */
/***/ (function(module, exports) {
var objectProto = Object.prototype;
var isPrototype = function isPrototype(value) {
var Ctor = value && value.constructor;
var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
return value === proto;
};
module.exports = isPrototype;
/***/ }),
/* 188 */
/***/ (function(module, exports) {
var uniqueId = function () {
var map = {};
return function (prefix) {
prefix = prefix || 'g';
if (!map[prefix]) {
map[prefix] = 1;
} else {
map[prefix] += 1;
}
return prefix + map[prefix];
};
}();
module.exports = uniqueId;
/***/ }),
/* 189 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
COORD_FUNC_PROPS: ['rotate', 'scale', 'reflect', 'transpose'],
GEOM_FUNC_PROPS: ['position', 'color', 'size', 'shape', 'opacity', 'tooltip', 'style', 'animate', 'active', 'select', 'sets']
};
/***/ }),
/* 190 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _util = __webpack_require__(54);
var _util2 = _interopRequireDefault(_util);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* prop function
*/
var chartItemEvents = [{ prop: 'onPlotMove', event: 'plotmove' }, { prop: 'onPlotEnter', event: 'plotenter' }, { prop: 'onPlotLeave', event: 'plotleave' }, { prop: 'onPlotClick', event: 'plotclick' }, { prop: 'onPlotDblClick', event: 'plotdblclick' }, { prop: 'onItemSelected', event: 'itemselected' }, { prop: 'onItemUnselected', event: 'itemunselected' }, { prop: 'onItemSelectedChange', event: 'itemselectedchange' }, { prop: 'onTooltipChange', event: 'tooltip:change' }, { prop: 'onTooltipShow', event: 'tooltip:show' }, { prop: 'onTooltipHide', event: 'tooltip:hide' }];
var baseEventNames = ['mouseenter', 'mousemove', 'mouseleave', 'click', 'dblclick', 'mousedown', 'mouseup', 'touchstart', 'touchmove', 'touchend'];
var baseEventsPostfix = ['Mouseenter', 'Mousemove', 'Mouseleave', 'Click', 'Dblclick', 'Mousedown', 'Mouseup', 'Touchstart', 'Touchmove', 'Touchend'];
var shapes = ['point', 'area', 'line', 'path', 'interval', 'schema', 'polygon', 'edge', 'axis-title', 'axis-label', 'axis-ticks', 'axis-line', 'axis-grid', 'legend-title', 'legend-item', 'legend-marker', 'legend-text', 'guide-text', 'guide-region', 'guide-line', 'guide-image', 'label'];
var shapesEvtNamePrefix = ['onPoint', 'onArea', 'onLine', 'onPath', 'onInterval', 'onSchema', 'onPolygon', 'onEdge', 'onAxisTitle', 'onAxisLabel', 'onAxisTicks', 'onAxisLine', 'onAxisGrid', 'onLegendTitle', 'onLegendItem', 'onLegendMarker', 'onLegendText', 'onGuideText', 'onGuideRegion', 'onGuideLine', 'onGuideImage', 'onLabel'];
var shapeEvents = [];
for (var i = 0; i < shapes.length; i += 1) {
for (var j = 0; j < baseEventNames.length; j += 1) {
shapeEvents.push({
prop: '' + shapesEvtNamePrefix[i] + baseEventsPostfix[j],
event: shapes[i] + ':' + baseEventNames[j]
});
}
}
var chartEvents = chartItemEvents.concat(shapeEvents);
function genBaseEvents() {
return [{ prop: 'onMouseEnter', event: 'mouseenter' }, { prop: 'onMouseMove', event: 'mousemove' }, { prop: 'onMouseLeave', event: 'mouseleave' }, { prop: 'onClick', event: 'click' }, { prop: 'onDblClick', event: 'dblclick' }, { prop: 'onMouseDown', event: 'mousedown' }, { prop: 'onMouseUp', event: 'mouseup' }, { prop: 'onTouchStart', event: 'touchstart' }, { prop: 'onTouchMove', event: 'touchmove' }, { prop: 'onTouchEnd', event: 'touchend' }];
}
function genItemBaseEvents(type) {
var geomEvents = genBaseEvents();
_util2.default.map(geomEvents, function (key) {
var event = key.event;
key.event = type + ':' + event;
return key;
});
return geomEvents;
}
var baseEvents = genBaseEvents();
var baseEventObjectTypes = {
onMouseEnter: _propTypes2.default.object,
onMouseMove: _propTypes2.default.object,
onMouseLeave: _propTypes2.default.object,
onClick: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.func]),
onDblClick: _propTypes2.default.object,
onMouseDown: _propTypes2.default.object,
onMouseUp: _propTypes2.default.object,
onTouchStart: _propTypes2.default.object,
onTouchMove: _propTypes2.default.object,
onTouchEnd: _propTypes2.default.object
};
var baseEventFuncTypes = {
onMouseEnter: _propTypes2.default.func,
onMouseMove: _propTypes2.default.func,
onMouseLeave: _propTypes2.default.func,
onClick: _propTypes2.default.func,
onDblClick: _propTypes2.default.func,
onMouseDown: _propTypes2.default.func,
onMouseUp: _propTypes2.default.func,
onTouchStart: _propTypes2.default.func,
onTouchMove: _propTypes2.default.func,
onTouchEnd: _propTypes2.default.func
};
function bindEvents(chart) {
var EVENTS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = arguments[2];
_util2.default.each(EVENTS, function (key) {
var prop = key.prop,
event = key.event;
var fns = props[prop];
if (_util2.default.isFunction(fns)) {
chart.on(event, fns);
} else if (_util2.default.isObject(fns)) {
for (var name in fns) {
if (fns[name] !== undefined) {
chart.on(name + ':' + event, fns[name]);
}
}
}
});
}
function bindBaseEvents(chart, props) {
bindEvents(chart, baseEvents, props);
}
function updateEvents(chart) {
var EVENTS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = arguments[2];
var nextProps = arguments[3];
_util2.default.each(EVENTS, function (key) {
var prop = key.prop,
event = key.event;
var fns = props[prop];
var nextFns = nextProps[prop];
var name = void 0;
if (!_util2.default.shallowEqual(fns, nextFns)) {
if (_util2.default.isFunction(fns) && _util2.default.isFunction(nextFns)) {
chart.off(event, fns);
chart.on(event, nextFns);
} else if (_util2.default.isObject(fns) && _util2.default.isObject(nextFns)) {
for (name in fns) {
if (Object.prototype.hasOwnProperty.call(fns, name)) {
chart.off(name + ':' + event, fns[name]);
}
}
for (name in nextFns) {
if (Object.prototype.hasOwnProperty.call(nextFns, name)) {
chart.on(name + ':' + event, nextFns[name]);
}
}
}
}
});
}
function updateBaseEvents(chart, props, nextProps) {
updateEvents(chart, baseEvents, props, nextProps);
}
function unbindEvents(chart) {
var EVENTS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = arguments[2];
_util2.default.each(EVENTS, function (key) {
var prop = key.prop,
event = key.event;
var fns = props[prop];
if (_util2.default.isFunction(fns)) {
chart.off(event, fns);
} else if (_util2.default.isObject(fns)) {
for (var name in fns) {
if (Object.prototype.hasOwnProperty.call(fns, name)) {
chart.off(name + ':' + event, fns[name]);
}
}
}
});
}
function unbindBaseEvents(chart, props) {
unbindEvents(chart, baseEvents, props);
}
exports.default = {
baseEventObjectTypes: baseEventObjectTypes,
baseEventFuncTypes: baseEventFuncTypes,
genBaseEvents: genBaseEvents,
genItemBaseEvents: genItemBaseEvents,
bindEvents: bindEvents,
bindBaseEvents: bindBaseEvents,
updateEvents: updateEvents,
updateBaseEvents: updateBaseEvents,
unbindEvents: unbindEvents,
unbindBaseEvents: unbindBaseEvents,
chartEvents: chartEvents
};
/***/ }),
/* 191 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _core = __webpack_require__(65);
var G2 = _interopRequireWildcard(_core);
var _shared = __webpack_require__(82);
var _common = __webpack_require__(189);
var _common2 = _interopRequireDefault(_common);
var _event = __webpack_require__(190);
var _event2 = _interopRequireDefault(_event);
var _configMerge = __webpack_require__(81);
var _configMerge2 = _interopRequireDefault(_configMerge);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var COORD_FUNC_PROPS = _common2.default.COORD_FUNC_PROPS;
var GEOM_FUNC_PROPS = _common2.default.GEOM_FUNC_PROPS;
exports.default = {
createChart: function createChart(config) {
var chartConfig = config.chart;
var chart = new G2.Chart(chartConfig.props);
chartConfig.g2Instance = chart;
return chart;
},
executeChartConfig: function executeChartConfig(chart, config) {
var chartConfig = config.chart;
var props = chartConfig.props;
chart.coord('rect', {});
chart.source(props.data, props.scale);
if (!config.facet && !props.axis || !config.facet || props.axis === false) {
chart.axis(false);
}
chart.legend(false);
chart.tooltip(false);
if (props.filter) {
props.filter.forEach(function (filterArg) {
chart.filter(filterArg[0], filterArg[1]);
});
}
_event2.default.bindEvents(chart, _event2.default.chartEvents, props);
_event2.default.bindBaseEvents(chart, props);
},
coord: function coord(chart, config) {
var coordConfig = config.coord;
if (!coordConfig || coordConfig.g2Instance) {
return;
}
var _coordConfig$props = coordConfig.props,
type = _coordConfig$props.type,
others = _objectWithoutProperties(_coordConfig$props, ['type']);
var coordIns = chart.coord(type || 'rect', _shared.Util.without(others, COORD_FUNC_PROPS));
_shared.Prop.init(COORD_FUNC_PROPS, others, function (value, key) {
if (key === 'reflect') {
_shared.Util.each(value, function (v) {
return coordIns[key](v);
});
} else {
coordIns[key].apply(coordIns, _toConsumableArray(value));
}
});
coordConfig.g2Instance = coordIns;
},
createLabel: function createLabel(geom, labelConfig) {
if (!labelConfig || labelConfig.g2Instance) {
return;
}
var _labelConfig$props = labelConfig.props,
content = _labelConfig$props.content,
labelOthers = _objectWithoutProperties(_labelConfig$props, ['content']);
if (content) {
if (_shared.Util.isArray(content)) {
labelConfig.g2Instance = geom.label(content[0], content[1], labelOthers);
} else {
labelConfig.g2Instance = geom.label(content, labelOthers);
}
}
},
createGeom: function createGeom(chart, geomConfig) {
if (geomConfig.g2Instance) {
if (geomConfig.label) {
this.createLabel(geomConfig.g2Instance, geomConfig.label);
}
return;
}
var props = geomConfig.props;
var geom = chart[props.type || 'interval']();
if (props.adjust) {
geom.adjust(props.adjust);
}
_shared.Prop.init(GEOM_FUNC_PROPS, props, function (value, key) {
geom[key].apply(geom, _toConsumableArray(value));
});
geomConfig.g2Instance = geom;
// create label
this.createLabel(geom, geomConfig.label);
},
geoms: function geoms(chart, config) {
var geoms = config.geoms;
if (!geoms) {
return;
}
for (var id in geoms) {
if (Object.prototype.hasOwnProperty.call(geoms, id)) {
this.createGeom(chart, geoms[id]);
}
}
},
legends: function legends(chart, config) {
var legends = config.legends;
for (var id in legends) {
if (legends[id]) {
var legendConfig = legends[id];
if (legendConfig.g2Instance) {
return;
}
var _legendConfig$props = legendConfig.props,
name = _legendConfig$props.name,
visible = _legendConfig$props.visible,
cfg = _objectWithoutProperties(_legendConfig$props, ['name', 'visible']);
var relVisible = visible;
if (!Object.prototype.hasOwnProperty.call(legendConfig.props, 'visible')) {
relVisible = true;
}
var arg = !relVisible ? relVisible : cfg;
legendConfig.g2Instance = chart.legend.apply(chart, _toConsumableArray(name ? [name, arg] : [arg]));
}
}
},
tooltip: function tooltip(chart, config) {
var tooltipConfig = config.tooltip;
if (!tooltipConfig || tooltipConfig.g2Instance) {
return;
}
tooltipConfig.g2Instance = chart.tooltip(_extends({}, tooltipConfig.props));
},
createAxis: function createAxis(chart, axisConfig) {
if (axisConfig.g2Instance) {
return;
}
var _axisConfig$props = axisConfig.props,
name = _axisConfig$props.name,
visible = _axisConfig$props.visible,
others = _objectWithoutProperties(_axisConfig$props, ['name', 'visible']);
if (visible || !Object.prototype.hasOwnProperty.call(axisConfig.props, 'visible')) {
axisConfig.g2Instance = chart.axis(name, others);
} else {
axisConfig.g2Instance = chart.axis(name, false);
}
},
axises: function axises(chart, config) {
var axises = config.axises;
for (var id in axises) {
if (axises[id]) {
this.createAxis(chart, axises[id]);
}
}
},
views: function views(chart, config) {
var views = config.views;
for (var id in views) {
if (views[id]) {
this.createView(chart, views[id]);
}
}
},
createView: function createView(chart, viewConfig) {
if (viewConfig.parentInfo.name === 'Facet') {
return;
}
if (viewConfig.g2Instance) {
if (viewConfig.filter) {
viewConfig.filter.forEach(function (filterArg) {
viewConfig.g2Instance.filter(filterArg[0], filterArg[1]);
});
}
this.coord(viewConfig.g2Instance, viewConfig);
this.axises(viewConfig.g2Instance, viewConfig);
this.geoms(viewConfig.g2Instance, viewConfig);
this.guide(viewConfig.g2Instance, viewConfig.guide);
return;
}
/*
Others object must exclude geoms property.
Because geoms property will cover the g2 view' inner geoms property.
*/
/* eslint-disable no-unused-vars */
var _viewConfig$props = viewConfig.props,
scale = _viewConfig$props.scale,
data = _viewConfig$props.data,
instance = _viewConfig$props.instance,
axis = _viewConfig$props.axis,
filter = _viewConfig$props.filter,
geoms = _viewConfig$props.geoms,
others = _objectWithoutProperties(_viewConfig$props, ['scale', 'data', 'instance', 'axis', 'filter', 'geoms']);
/* eslint-enable */
var view = void 0;
if (instance) {
view = instance;
} else {
view = chart.view(_extends({}, others));
}
if (data) {
view.source(data, scale);
}
if (scale) {
view.scale(scale);
}
if (filter) {
filter.forEach(function (filterArg) {
view.filter(filterArg[0], filterArg[1]);
});
}
if (!(axis === true || instance)) {
view.axis(false);
}
viewConfig.g2Instance = view;
this.coord(view, viewConfig);
this.axises(view, viewConfig);
this.geoms(view, viewConfig);
this.guide(view, viewConfig.guide);
},
facetView: function facetView(view, viewConfig) {
/* eslint-disable no-unused-vars */
var _viewConfig$props2 = viewConfig.props,
scale = _viewConfig$props2.scale,
data = _viewConfig$props2.data,
axis = _viewConfig$props2.axis,
geoms = _viewConfig$props2.geoms,
others = _objectWithoutProperties(_viewConfig$props2, ['scale', 'data', 'axis', 'geoms']);
/* eslint-enable */
if (data) {
view.source(data, scale);
}
if (scale) {
view.scale(scale);
}
if (axis === false) {
view.axis(false);
}
this.coord(view, viewConfig);
this.axises(view, viewConfig);
this.geoms(view, viewConfig);
this.guide(view, viewConfig.guide);
_configMerge2.default.mergeView(viewConfig, true);
},
guide: function guide(chart, _guide) {
if (!_guide) {
return;
}
var guides = _guide.elements;
for (var id in guides) {
if (guides[id]) {
var guideConfig = guides[id];
if (!guideConfig.g2Instance) {
/* eslint-disable no-unused-vars */
var _guideConfig$props = guideConfig.props,
type = _guideConfig$props.type,
others = _objectWithoutProperties(_guideConfig$props, ['type']);
/* eslint-enable */
guideConfig.g2Instance = chart.guide()[guideConfig.type](others);
}
}
}
},
facet: function facet(chart, config) {
var _this = this;
var facetConfig = config.facet;
if (!facetConfig || facetConfig.g2Instance) {
return;
}
var _facetConfig$props = facetConfig.props,
children = _facetConfig$props.children,
type = _facetConfig$props.type,
others = _objectWithoutProperties(_facetConfig$props, ['children', 'type']);
if (!children) {
chart.facet(type, others);
return;
}
var views = config.views;
var facetView = null;
for (var id in views) {
if (views[id] && views[id].parentInfo.name === 'Facet' && views[id].parentInfo.id === facetConfig.id) {
// facet view
facetView = views[id];
break;
}
}
if (facetView) {
_configMerge2.default.mergeView(facetView, true);
others.eachView = function (view) {
_this.facetView(view, facetView);
};
chart.facet(type, others);
}
},
synchronizeG2Add: function synchronizeG2Add(chart, config) {
this.coord(chart, config);
this.axises(chart, config);
this.legends(chart, config);
this.tooltip(chart, config);
this.geoms(chart, config);
this.facet(chart, config);
this.views(chart, config);
// this.synchronizeG2Views(chart, config);
this.guide(chart, config.guide);
},
synchronizeG2Views: function synchronizeG2Views(chart, config) {
var views = config.views;
for (var id in views) {
if (views[id]) {
this.synchronizeG2View(views[id].g2Instance, views[id]);
}
}
},
synchronizeG2View: function synchronizeG2View(view, viewConfig) {
/*
Others object must exclude geoms property.
Because geoms property will cover the g2 view' inner geoms property.
*/
view.clear();
this.clearViewG2Instance(viewConfig);
/* eslint-disable no-unused-vars */
var _viewConfig$props3 = viewConfig.props,
scale = _viewConfig$props3.scale,
data = _viewConfig$props3.data,
instance = _viewConfig$props3.instance,
axis = _viewConfig$props3.axis,
geoms = _viewConfig$props3.geoms,
others = _objectWithoutProperties(_viewConfig$props3, ['scale', 'data', 'instance', 'axis', 'geoms']);
/* eslint-enable */
if (data) {
view.source(data, scale);
}
if (scale) {
view.scale(scale);
}
if (!(axis === true || instance)) {
view.axis(false);
}
this.coord(view, viewConfig);
this.axises(view, viewConfig);
this.geoms(view, viewConfig);
this.guide(view, viewConfig.guide);
},
clearViewG2Instance: function clearViewG2Instance(viewConfig) {
if (viewConfig.coord) {
delete viewConfig.coord.g2Instance;
}
if (viewConfig.axises) {
Object.keys(viewConfig.axises).forEach(function (id) {
delete viewConfig.axises[id].g2Instance;
});
}
if (viewConfig.geoms) {
Object.keys(viewConfig.geoms).forEach(function (id) {
delete viewConfig.geoms[id].g2Instance;
if (viewConfig.geoms[id].label) {
delete viewConfig.geoms[id].label.g2Instance;
}
});
}
if (viewConfig.guide && viewConfig.guide.elements) {
Object.keys(viewConfig.guide.elements).forEach(function (id) {
delete viewConfig.guide.elements[id].g2Instance;
});
}
}
};
/***/ }),
/* 192 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return deg2rad; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return rad2deg; });
var deg2rad = Math.PI / 180;
var rad2deg = 180 / Math.PI;
/***/ }),
/* 193 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__linear__ = __webpack_require__(434);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeLinear", function() { return __WEBPACK_IMPORTED_MODULE_0__linear__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__quad__ = __webpack_require__(436);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuad", function() { return __WEBPACK_IMPORTED_MODULE_1__quad__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadIn", function() { return __WEBPACK_IMPORTED_MODULE_1__quad__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadOut", function() { return __WEBPACK_IMPORTED_MODULE_1__quad__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadInOut", function() { return __WEBPACK_IMPORTED_MODULE_1__quad__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__cubic__ = __webpack_require__(431);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubic", function() { return __WEBPACK_IMPORTED_MODULE_2__cubic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicIn", function() { return __WEBPACK_IMPORTED_MODULE_2__cubic__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicOut", function() { return __WEBPACK_IMPORTED_MODULE_2__cubic__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicInOut", function() { return __WEBPACK_IMPORTED_MODULE_2__cubic__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__poly__ = __webpack_require__(435);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePoly", function() { return __WEBPACK_IMPORTED_MODULE_3__poly__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyIn", function() { return __WEBPACK_IMPORTED_MODULE_3__poly__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyOut", function() { return __WEBPACK_IMPORTED_MODULE_3__poly__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyInOut", function() { return __WEBPACK_IMPORTED_MODULE_3__poly__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sin__ = __webpack_require__(437);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSin", function() { return __WEBPACK_IMPORTED_MODULE_4__sin__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinIn", function() { return __WEBPACK_IMPORTED_MODULE_4__sin__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinOut", function() { return __WEBPACK_IMPORTED_MODULE_4__sin__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinInOut", function() { return __WEBPACK_IMPORTED_MODULE_4__sin__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__exp__ = __webpack_require__(433);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExp", function() { return __WEBPACK_IMPORTED_MODULE_5__exp__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpIn", function() { return __WEBPACK_IMPORTED_MODULE_5__exp__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpOut", function() { return __WEBPACK_IMPORTED_MODULE_5__exp__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpInOut", function() { return __WEBPACK_IMPORTED_MODULE_5__exp__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__circle__ = __webpack_require__(430);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircle", function() { return __WEBPACK_IMPORTED_MODULE_6__circle__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleIn", function() { return __WEBPACK_IMPORTED_MODULE_6__circle__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleOut", function() { return __WEBPACK_IMPORTED_MODULE_6__circle__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleInOut", function() { return __WEBPACK_IMPORTED_MODULE_6__circle__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__bounce__ = __webpack_require__(429);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounce", function() { return __WEBPACK_IMPORTED_MODULE_7__bounce__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceIn", function() { return __WEBPACK_IMPORTED_MODULE_7__bounce__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceOut", function() { return __WEBPACK_IMPORTED_MODULE_7__bounce__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceInOut", function() { return __WEBPACK_IMPORTED_MODULE_7__bounce__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__back__ = __webpack_require__(428);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBack", function() { return __WEBPACK_IMPORTED_MODULE_8__back__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackIn", function() { return __WEBPACK_IMPORTED_MODULE_8__back__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackOut", function() { return __WEBPACK_IMPORTED_MODULE_8__back__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackInOut", function() { return __WEBPACK_IMPORTED_MODULE_8__back__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__elastic__ = __webpack_require__(432);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElastic", function() { return __WEBPACK_IMPORTED_MODULE_9__elastic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticIn", function() { return __WEBPACK_IMPORTED_MODULE_9__elastic__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticOut", function() { return __WEBPACK_IMPORTED_MODULE_9__elastic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticInOut", function() { return __WEBPACK_IMPORTED_MODULE_9__elastic__["c"]; });
/***/ }),
/* 194 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(86);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var nb = b ? b.length : 0,
na = a ? Math.min(nb, a.length) : 0,
x = new Array(na),
c = new Array(nb),
i;
for (i = 0; i < na; ++i) x[i] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(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;
};
});
/***/ }),
/* 195 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(85);
/* harmony default export */ __webpack_exports__["a"] = (function(values) {
var n = values.length;
return function(t) {
var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
v0 = values[(i + n - 1) % n],
v1 = values[i % n],
v2 = values[(i + 1) % n],
v3 = values[(i + 2) % n];
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__basis__["b" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
};
});
/***/ }),
/* 196 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return function() {
return x;
};
});
/***/ }),
/* 197 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var d = new Date;
return a = +a, b -= a, function(t) {
return d.setTime(a + b * t), d;
};
});
/***/ }),
/* 198 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(86);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var i = {},
c = {},
k;
if (a === null || typeof a !== "object") a = {};
if (b === null || typeof b !== "object") b = {};
for (k in b) {
if (k in a) {
i[k] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
} else {
c[k] = b[k];
}
}
return function(t) {
for (k in i) c[k] = i[k](t);
return c;
};
});
/***/ }),
/* 199 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rgbBasis; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return rgbBasisClosed; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(85);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(195);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(40);
/* harmony default export */ __webpack_exports__["a"] = ((function rgbGamma(y) {
var color = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__color__["c" /* gamma */])(y);
function rgb(start, end) {
var r = color((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(start)).r, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(end)).r),
g = color(start.g, end.g),
b = color(start.b, end.b),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.r = r(t);
start.g = g(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
rgb.gamma = rgbGamma;
return rgb;
})(1));
function rgbSpline(spline) {
return function(colors) {
var n = colors.length,
r = new Array(n),
g = new Array(n),
b = new Array(n),
i, color;
for (i = 0; i < n; ++i) {
color = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(colors[i]);
r[i] = color.r || 0;
g[i] = color.g || 0;
b[i] = color.b || 0;
}
r = spline(r);
g = spline(g);
b = spline(b);
color.opacity = 1;
return function(t) {
color.r = r(t);
color.g = g(t);
color.b = b(t);
return color + "";
};
};
}
var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["a" /* default */]);
var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
/***/ }),
/* 200 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(55);
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
reB = new RegExp(reA.source, "g");
function zero(b) {
return function() {
return b;
};
}
function one(b) {
return function(t) {
return b(t) + "";
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
am, // current match in a
bm, // current match in b
bs, // string preceding current number in b, if any
i = -1, // index in s
s = [], // string constants and placeholders
q = []; // number interpolators
// Coerce inputs to strings.
a = a + "", b = b + "";
// Interpolate pairs of numbers in a & b.
while ((am = reA.exec(a))
&& (bm = reB.exec(b))) {
if ((bs = bm.index) > bi) { // a string precedes the next number in b
bs = b.slice(bi, bs);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
}
if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
if (s[i]) s[i] += bm; // coalesce with previous string
else s[++i] = bm;
} else { // interpolate non-matching numbers
s[++i] = null;
q.push({i: i, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm)});
}
bi = reB.lastIndex;
}
// Add remains of b.
if (bi < b.length) {
bs = b.slice(bi);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
}
// Special optimization for only a single match.
// Otherwise, interpolate each of the numbers and rejoin the string.
return s.length < 2 ? (q[0]
? one(q[0].x)
: zero(b))
: (b = q.length, function(t) {
for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
return s.join("");
});
});
/***/ }),
/* 201 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(89);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var nb = b ? b.length : 0,
na = a ? Math.min(nb, a.length) : 0,
x = new Array(na),
c = new Array(nb),
i;
for (i = 0; i < na; ++i) x[i] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(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;
};
});
/***/ }),
/* 202 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(87);
/* harmony default export */ __webpack_exports__["a"] = (function(values) {
var n = values.length;
return function(t) {
var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
v0 = values[(i + n - 1) % n],
v1 = values[i % n],
v2 = values[(i + 1) % n],
v3 = values[(i + 2) % n];
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__basis__["b" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
};
});
/***/ }),
/* 203 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return function() {
return x;
};
});
/***/ }),
/* 204 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var d = new Date;
return a = +a, b -= a, function(t) {
return d.setTime(a + b * t), d;
};
});
/***/ }),
/* 205 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(89);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var i = {},
c = {},
k;
if (a === null || typeof a !== "object") a = {};
if (b === null || typeof b !== "object") b = {};
for (k in b) {
if (k in a) {
i[k] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
} else {
c[k] = b[k];
}
}
return function(t) {
for (k in i) c[k] = i[k](t);
return c;
};
});
/***/ }),
/* 206 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export rgbBasis */
/* unused harmony export rgbBasisClosed */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(87);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(202);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(30);
/* harmony default export */ __webpack_exports__["a"] = ((function rgbGamma(y) {
var color = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__color__["c" /* gamma */])(y);
function rgb(start, end) {
var r = color((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(start)).r, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(end)).r),
g = color(start.g, end.g),
b = color(start.b, end.b),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.r = r(t);
start.g = g(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
rgb.gamma = rgbGamma;
return rgb;
})(1));
function rgbSpline(spline) {
return function(colors) {
var n = colors.length,
r = new Array(n),
g = new Array(n),
b = new Array(n),
i, color;
for (i = 0; i < n; ++i) {
color = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* rgb */])(colors[i]);
r[i] = color.r || 0;
g[i] = color.g || 0;
b[i] = color.b || 0;
}
r = spline(r);
g = spline(g);
b = spline(b);
color.opacity = 1;
return function(t) {
color.r = r(t);
color.g = g(t);
color.b = b(t);
return color + "";
};
};
}
var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["a" /* default */]);
var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
/***/ }),
/* 207 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(56);
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
reB = new RegExp(reA.source, "g");
function zero(b) {
return function() {
return b;
};
}
function one(b) {
return function(t) {
return b(t) + "";
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
am, // current match in a
bm, // current match in b
bs, // string preceding current number in b, if any
i = -1, // index in s
s = [], // string constants and placeholders
q = []; // number interpolators
// Coerce inputs to strings.
a = a + "", b = b + "";
// Interpolate pairs of numbers in a & b.
while ((am = reA.exec(a))
&& (bm = reB.exec(b))) {
if ((bs = bm.index) > bi) { // a string precedes the next number in b
bs = b.slice(bi, bs);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
}
if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
if (s[i]) s[i] += bm; // coalesce with previous string
else s[++i] = bm;
} else { // interpolate non-matching numbers
s[++i] = null;
q.push({i: i, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm)});
}
bi = reB.lastIndex;
}
// Add remains of b.
if (bi < b.length) {
bs = b.slice(bi);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
}
// Special optimization for only a single match.
// Otherwise, interpolate each of the numbers and rejoin the string.
return s.length < 2 ? (q[0]
? one(q[0].x)
: zero(b))
: (b = q.length, function(t) {
for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
return s.join("");
});
});
/***/ }),
/* 208 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(selector) {
return function() {
return this.matches(selector);
};
});
/***/ }),
/* 209 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__selection_index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function(selector) {
return typeof selector === "string"
? new __WEBPACK_IMPORTED_MODULE_0__selection_index__["b" /* Selection */]([[document.querySelector(selector)]], [document.documentElement])
: new __WEBPACK_IMPORTED_MODULE_0__selection_index__["b" /* Selection */]([[selector]], __WEBPACK_IMPORTED_MODULE_0__selection_index__["c" /* root */]);
});
/***/ }),
/* 210 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = EnterNode;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sparse__ = __webpack_require__(211);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return new __WEBPACK_IMPORTED_MODULE_1__index__["b" /* Selection */](this._enter || this._groups.map(__WEBPACK_IMPORTED_MODULE_0__sparse__["a" /* default */]), this._parents);
});
function EnterNode(parent, datum) {
this.ownerDocument = parent.ownerDocument;
this.namespaceURI = parent.namespaceURI;
this._next = null;
this._parent = parent;
this.__data__ = datum;
}
EnterNode.prototype = {
constructor: EnterNode,
appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
querySelector: function(selector) { return this._parent.querySelector(selector); },
querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
};
/***/ }),
/* 211 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(update) {
return new Array(update.length);
});
/***/ }),
/* 212 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = styleValue;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__window__ = __webpack_require__(95);
function styleRemove(name) {
return function() {
this.style.removeProperty(name);
};
}
function styleConstant(name, value, priority) {
return function() {
this.style.setProperty(name, value, priority);
};
}
function styleFunction(name, value, priority) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.style.removeProperty(name);
else this.style.setProperty(name, v, priority);
};
}
/* harmony default export */ __webpack_exports__["b"] = (function(name, value, priority) {
return arguments.length > 1
? this.each((value == null
? styleRemove : typeof value === "function"
? styleFunction
: styleConstant)(name, value, priority == null ? "" : priority))
: styleValue(this.node(), name);
});
function styleValue(node, name) {
return node.style.getPropertyValue(name)
|| __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__window__["a" /* default */])(node).getComputedStyle(node, null).getPropertyValue(name);
}
/***/ }),
/* 213 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function empty() {
return [];
}
/* harmony default export */ __webpack_exports__["a"] = (function(selector) {
return selector == null ? empty : function() {
return this.querySelectorAll(selector);
};
});
/***/ }),
/* 214 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__transition_schedule__ = __webpack_require__(13);
/* harmony default export */ __webpack_exports__["a"] = (function(node, name) {
var schedules = node.__transition,
schedule,
active,
empty = true,
i;
if (!schedules) return;
name = name == null ? null : name + "";
for (i in schedules) {
if ((schedule = schedules[i]).name !== name) { empty = false; continue; }
active = schedule.state > __WEBPACK_IMPORTED_MODULE_0__transition_schedule__["a" /* STARTING */] && schedule.state < __WEBPACK_IMPORTED_MODULE_0__transition_schedule__["b" /* ENDING */];
schedule.state = __WEBPACK_IMPORTED_MODULE_0__transition_schedule__["c" /* ENDED */];
schedule.timer.stop();
schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
delete schedules[i];
}
if (empty) delete node.__transition;
});
/***/ }),
/* 215 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_d3_interpolate__ = __webpack_require__(88);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
var c;
return (typeof b === "number" ? __WEBPACK_IMPORTED_MODULE_1_d3_interpolate__["b" /* interpolateNumber */]
: b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */] ? __WEBPACK_IMPORTED_MODULE_1_d3_interpolate__["c" /* interpolateRgb */]
: (c = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1_d3_interpolate__["c" /* interpolateRgb */])
: __WEBPACK_IMPORTED_MODULE_1_d3_interpolate__["d" /* interpolateString */])(a, b);
});
/***/ }),
/* 216 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) {
'use strict';
/**
* Parse or format dates
* @class fecha
*/
var fecha = {};
var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
var twoDigits = /\d\d?/;
var threeDigits = /\d{3}/;
var fourDigits = /\d{4}/;
var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
var literal = /\[([^]*?)\]/gm;
var noop = function () {
};
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;
}
function monthUpdate(arrName) {
return function (d, v, i18n) {
var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
if (~index) {
d.month = index;
}
};
}
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) {
val = '0' + val;
}
return val;
}
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);
fecha.i18n = {
dayNamesShort: dayNamesShort,
dayNames: dayNames,
monthNamesShort: monthNamesShort,
monthNames: monthNames,
amPm: ['am', 'pm'],
DoFn: function DoFn(D) {
return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
}
};
var formatFlags = {
D: function(dateObj) {
return dateObj.getDate();
},
DD: function(dateObj) {
return pad(dateObj.getDate());
},
Do: function(dateObj, i18n) {
return i18n.DoFn(dateObj.getDate());
},
d: function(dateObj) {
return 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 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 String(dateObj.getFullYear()).substr(2);
},
YYYY: function(dateObj) {
return pad(dateObj.getFullYear(), 4);
},
h: function(dateObj) {
return dateObj.getHours() % 12 || 12;
},
hh: function(dateObj) {
return pad(dateObj.getHours() % 12 || 12);
},
H: function(dateObj) {
return dateObj.getHours();
},
HH: function(dateObj) {
return pad(dateObj.getHours());
},
m: function(dateObj) {
return dateObj.getMinutes();
},
mm: function(dateObj) {
return pad(dateObj.getMinutes());
},
s: function(dateObj) {
return dateObj.getSeconds();
},
ss: function(dateObj) {
return pad(dateObj.getSeconds());
},
S: function(dateObj) {
return 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 o = dateObj.getTimezoneOffset();
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
}
};
var parseFlags = {
D: [twoDigits, function (d, v) {
d.day = v;
}],
Do: [new RegExp(twoDigits.source + word.source), function (d, v) {
d.day = parseInt(v, 10);
}],
M: [twoDigits, function (d, v) {
d.month = v - 1;
}],
YY: [twoDigits, function (d, v) {
var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
}],
h: [twoDigits, function (d, v) {
d.hour = v;
}],
m: [twoDigits, function (d, v) {
d.minute = v;
}],
s: [twoDigits, function (d, v) {
d.second = v;
}],
YYYY: [fourDigits, function (d, v) {
d.year = v;
}],
S: [/\d/, function (d, v) {
d.millisecond = v * 100;
}],
SS: [/\d{2}/, function (d, v) {
d.millisecond = v * 10;
}],
SSS: [threeDigits, function (d, v) {
d.millisecond = v;
}],
d: [twoDigits, noop],
ddd: [word, noop],
MMM: [word, monthUpdate('monthNamesShort')],
MMMM: [word, monthUpdate('monthNames')],
a: [word, function (d, v, i18n) {
var val = v.toLowerCase();
if (val === i18n.amPm[0]) {
d.isPm = false;
} else if (val === i18n.amPm[1]) {
d.isPm = true;
}
}],
ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
if (v === 'Z') v = '+00:00';
var parts = (v + '').match(/([\+\-]|\d\d)/gi), minutes;
if (parts) {
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
}
}]
};
parseFlags.dd = parseFlags.d;
parseFlags.dddd = parseFlags.ddd;
parseFlags.DD = parseFlags.D;
parseFlags.mm = parseFlags.m;
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
parseFlags.MM = parseFlags.M;
parseFlags.ss = parseFlags.s;
parseFlags.A = parseFlags.a;
// Some common format strings
fecha.masks = {
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',
shortTime: 'HH:mm',
mediumTime: 'HH:mm:ss',
longTime: 'HH:mm:ss.SSS'
};
/***
* Format a date
* @method format
* @param {Date|number} dateObj
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
*/
fecha.format = function (dateObj, mask, i18nSettings) {
var i18n = i18nSettings || fecha.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 in fecha.format');
}
mask = fecha.masks[mask] || mask || fecha.masks['default'];
var literals = [];
// Make literals inactive by replacing them with ??
mask = mask.replace(literal, function($0, $1) {
literals.push($1);
return '??';
});
// Apply formatting rules
mask = mask.replace(token, function ($0) {
return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
});
// Inline literal values back into the formatted value
return mask.replace(/\?\?/g, function() {
return literals.shift();
});
};
/**
* Parse a date string into an object, changes - into /
* @method parse
* @param {string} dateStr Date string
* @param {string} format Date parse format
* @returns {Date|boolean}
*/
fecha.parse = function (dateStr, format, i18nSettings) {
var i18n = i18nSettings || fecha.i18n;
if (typeof format !== 'string') {
throw new Error('Invalid format in fecha.parse');
}
format = fecha.masks[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 false;
}
var isValid = true;
var dateInfo = {};
format.replace(token, function ($0) {
if (parseFlags[$0]) {
var info = parseFlags[$0];
var index = dateStr.search(info[0]);
if (!~index) {
isValid = false;
} else {
dateStr.replace(info[0], function (result) {
info[1](dateInfo, result, i18n);
dateStr = dateStr.substr(index + result.length);
return result;
});
}
}
return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
});
if (!isValid) {
return false;
}
var today = new Date();
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
dateInfo.hour = +dateInfo.hour + 12;
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
dateInfo.hour = 0;
}
var date;
if (dateInfo.timezoneOffset != null) {
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
} else {
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
}
return date;
};
/* istanbul ignore next */
if (typeof module !== 'undefined' && module.exports) {
module.exports = fecha;
} else if (true) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
return fecha;
}.call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {
main.fecha = fecha;
}
})(this);
/***/ }),
/* 217 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/* 218 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
if (false) {
module.exports = require('./cjs/react-is.production.min.js');
} else {
module.exports = __webpack_require__(525);
}
/***/ }),
/* 219 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = function() {};
if (true) {
warning = function(condition, format, args) {
var len = arguments.length;
args = new Array(len > 2 ? len - 2 : 0);
for (var key = 2; key < len; key++) {
args[key - 2] = arguments[key];
}
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
'message argument'
);
}
if (format.length < 10 || (/^[s\W]*$/).test(format)) {
throw new Error(
'The warning format should be able to uniquely identify this ' +
'warning. Please, use a more descriptive format than: ' + format
);
}
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' +
format.replace(/%s/g, function() {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch(x) {}
}
};
}
module.exports = warning;
/***/ }),
/* 220 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Adjust = __webpack_require__(31);
var each = __webpack_require__(2);
var MARGIN_RATIO = 1 / 2;
var DODGE_RATIO = 1 / 2;
var Dodge =
/*#__PURE__*/
function (_Adjust) {
_inheritsLoose(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(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;
}(Adjust);
Adjust.Dodge = Dodge;
module.exports = Dodge;
/***/ }),
/* 221 */
/***/ (function(module, exports, __webpack_require__) {
// 完整版下使用支持按照某个字段进行分组的 dodge
var mix = __webpack_require__(10);
var Adjust = __webpack_require__(31);
var Dodge = __webpack_require__(220);
var Stack = __webpack_require__(225);
var AdjustMixin = __webpack_require__(99);
var DodgeMixin = __webpack_require__(223);
var StackMixin = __webpack_require__(224);
mix(Adjust.prototype, AdjustMixin);
mix(Dodge.prototype, AdjustMixin, DodgeMixin);
mix(Stack.prototype, StackMixin);
Adjust.Jitter = __webpack_require__(222);
Adjust.Symmetric = __webpack_require__(226);
Adjust.Dodge = Dodge;
Adjust.Stack = Stack;
module.exports = Adjust;
/***/ }),
/* 222 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var each = __webpack_require__(2);
var mix = __webpack_require__(10);
var ArrayUtil = {
merge: __webpack_require__(50)
};
var Adjust = __webpack_require__(31);
var AdjustMixin = __webpack_require__(99);
var Jitter =
/*#__PURE__*/
function (_Adjust) {
_inheritsLoose(Jitter, _Adjust);
function Jitter() {
return _Adjust.apply(this, arguments) || this;
}
var _proto = Jitter.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
this.xField = null; // 调整对应的 x 方向对应的字段名称
this.yField = null; // 调整对应的 y 方向对应的字段名称
this.adjustNames = ['x', 'y']; // 指x,y
this.groupFields = null; // 参与分组的数据维度
};
_proto.processAdjust = function processAdjust(dataArray) {
var self = this;
var mergeData = ArrayUtil.merge(dataArray);
self.adjDataArray = dataArray;
self.mergeData = mergeData;
self.adjustData(dataArray, mergeData);
self.adjFrames = null;
self.mergeData = null;
};
_proto.getAdjustOffset = function getAdjustOffset(pre, next) {
var r = Math.random(); // 随机位置,均匀分布
var avg = next - pre; // * length
var append = avg * 0.05;
return pre + append + avg * 0.9 * r;
}; // adjust group data
_proto._adjustGroup = function _adjustGroup(group, dim, key, values) {
var self = this;
var range = self.getAdjustRange(dim, key, values);
each(group, function (record) {
record[dim] = self.getAdjustOffset(range.pre, range.next); // 获取调整的位置
});
};
_proto.adjustDim = function adjustDim(dim, values, data) {
var self = this;
var groupData = self.groupData(data, dim);
each(groupData, function (group, key) {
key = parseFloat(key);
self._adjustGroup(group, dim, key, values);
});
};
return Jitter;
}(Adjust);
mix(Jitter.prototype, AdjustMixin);
Adjust.Jitter = Jitter;
module.exports = Jitter;
/***/ }),
/* 223 */
/***/ (function(module, exports, __webpack_require__) {
var ArrayUtil = {
merge: __webpack_require__(50),
values: __webpack_require__(73)
};
var group = __webpack_require__(159);
var each = __webpack_require__(2);
module.exports = {
/**
* @protected
* @override
*/
processAdjust: function processAdjust(dataArray) {
var self = this;
var mergeData = ArrayUtil.merge(dataArray);
var dodgeDim = self.dodgeBy;
var adjDataArray = dataArray;
if (dodgeDim) {
// 如果指定了分组dim的字段
adjDataArray = group(mergeData, dodgeDim);
}
self.cacheMap = {};
self.adjDataArray = adjDataArray;
self.mergeData = mergeData;
self.adjustData(adjDataArray, mergeData);
self.adjDataArray = null;
self.mergeData = null;
},
getDistribution: function getDistribution(dim) {
var self = this;
var dataArray = self.adjDataArray;
var cacheMap = self.cacheMap;
var map = cacheMap[dim];
if (!map) {
map = {};
each(dataArray, function (data, index) {
var values = ArrayUtil.values(data, dim);
if (!values.length) {
values.push(0);
}
each(values, function (val) {
if (!map[val]) {
map[val] = [];
}
map[val].push(index);
});
});
cacheMap[dim] = map;
}
return map;
},
adjustDim: function adjustDim(dim, values, data, frameCount, frameIndex) {
var self = this;
var map = self.getDistribution(dim);
var groupData = self.groupData(data, dim); // 根据值分组
each(groupData, function (group, key) {
key = parseFloat(key);
var range;
if (values.length === 1) {
range = {
pre: values[0] - 1,
next: values[0] + 1
};
} else {
range = self.getAdjustRange(dim, key, values);
}
each(group, function (record) {
var value = record[dim];
var valueArr = map[value];
var valIndex = valueArr.indexOf(frameIndex);
record[dim] = self.getDodgeOffset(range, valIndex, valueArr.length);
});
});
}
};
/***/ }),
/* 224 */
/***/ (function(module, exports) {
module.exports = {
_initDefaultCfg: function _initDefaultCfg() {
this.xField = null; // 调整对应的 x 方向对应的字段名称
this.yField = null; // 调整对应的 y 方向对应的字段名称
this.height = null; // 仅有一个维度调整时,总的高度
this.size = 10; // 单个点的大小
this.reverseOrder = false; // 是否反序进行层叠
this.adjustNames = ['y']; // Only support stack y
},
processOneDimStack: function processOneDimStack(dataArray) {
var self = this;
var xField = self.xField;
var yField = self.yField || 'y';
var height = self.height;
var stackY = {}; // 如果层叠的顺序翻转
if (self.reverseOrder) {
dataArray = dataArray.slice(0).reverse();
}
for (var i = 0, len = dataArray.length; i < len; i++) {
var data = dataArray[i]; // cates
for (var j = 0, dataLen = data.length; j < dataLen; j++) {
var item = data[j];
var size = item.size || self.size;
var stackHeight = size * 2 / height;
var x = item[xField];
if (!stackY[x]) {
stackY[x] = stackHeight / 2;
}
item[yField] = stackY[x];
stackY[x] += stackHeight;
}
}
},
processAdjust: function processAdjust(dataArray) {
if (this.yField) {
this.processStack(dataArray);
} else {
this.processOneDimStack(dataArray);
}
}
};
/***/ }),
/* 225 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var isArray = __webpack_require__(4);
var isNil = __webpack_require__(6);
var Adjust = __webpack_require__(31);
var Stack =
/*#__PURE__*/
function (_Adjust) {
_inheritsLoose(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(y) ? y[1] : y;
if (!isNil(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;
}(Adjust);
Adjust.Stack = Stack;
module.exports = Stack;
/***/ }),
/* 226 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var each = __webpack_require__(2);
var maxBy = __webpack_require__(162);
var isArray = __webpack_require__(4);
var ArrayUtil = {
merge: __webpack_require__(50)
};
var Adjust = __webpack_require__(31);
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(mergeData, function (obj) {
var value = obj[dim];
if (isArray(value)) {
return Math.max.apply(null, value);
}
return value;
});
var maxValue = maxRecord[dim];
var max = isArray(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(mergeData, function (obj) {
var xValue = obj[xField];
var yValue = obj[yField];
var max = isArray(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(first[yField])) {
cache = self._getXValuesMax();
}
each(dataArray, function (data) {
each(data, function (obj) {
var value = obj[yField];
var offset;
if (isArray(value)) {
var xValue = obj[xField];
var valueMax = cache[xValue];
offset = (max - valueMax) / 2;
var tmp = [];
/* eslint-disable no-loop-func */
each(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;
}(Adjust);
Adjust.Symmetric = Symmetric;
module.exports = Symmetric;
/***/ }),
/* 227 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var isString = __webpack_require__(15);
var ColorUtil = __webpack_require__(100);
var Base = __webpack_require__(32);
var Color =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(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 = this.gradient;
if (!gradient) {
var values = this.values;
gradient = ColorUtil.gradient(values);
this.gradient = gradient;
}
return gradient(percent);
};
return Color;
}(Base);
module.exports = Color;
/***/ }),
/* 228 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(32);
var Opacity =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Opacity, _Base);
function Opacity(cfg) {
var _this;
_this = _Base.call(this, cfg) || this;
_this.names = ['opacity'];
_this.type = 'opacity';
_this.gradient = null;
return _this;
}
return Opacity;
}(Base);
module.exports = Opacity;
/***/ }),
/* 229 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var isNil = __webpack_require__(6);
var isArray = __webpack_require__(4);
var each = __webpack_require__(2);
var Base = __webpack_require__(32);
var Position =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(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(x) || isNil(y)) {
return [];
}
if (isArray(y) && isArray(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(y)) {
x = scaleX.scale(x);
rstY = [];
each(y, function (yVal) {
yVal = scaleY.scale(yVal);
obj = coord.convertPoint({
x: x,
y: yVal
});
if (rstX && rstX !== obj.x) {
if (!isArray(rstX)) {
rstX = [rstX];
}
rstX.push(obj.x);
} else {
rstX = obj.x;
}
rstY.push(obj.y);
});
} else if (isArray(x)) {
y = scaleY.scale(y);
rstX = [];
each(x, function (xVal) {
xVal = scaleX.scale(xVal);
obj = coord.convertPoint({
x: xVal,
y: y
});
if (rstY && rstY !== obj.y) {
if (!isArray(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;
}(Base);
module.exports = Position;
/***/ }),
/* 230 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(32);
var Shape =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(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;
}(Base);
module.exports = Shape;
/***/ }),
/* 231 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(32);
var Size =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(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;
}(Base);
module.exports = Size;
/***/ }),
/* 232 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Base = __webpack_require__(33);
var vec2 = Util.MatrixUtil.vec2;
var Circle =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Circle, _Base);
function Circle() {
return _Base.apply(this, arguments) || this;
}
var _proto = Circle.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 坐标轴的类型
* @type {String}
*/
type: 'circle',
/**
* 指定刻度之间的间距
* @type {Number}
*/
tickInterval: null,
/**
* 开始弧度
* @type {Number}
*/
startAngle: -Math.PI / 2,
/**
* 结束弧度
* @type {Number}
*/
endAngle: Math.PI * 3 / 2,
line: {
// @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线
lineWidth: 1,
stroke: '#C0D0E0'
},
tickLine: {
// @type {Attrs} 标注坐标线的图形属性
lineWidth: 1,
stroke: '#C0D0E0',
length: 5
},
/**
* 默认文本距离轴线的距离
* @type {Number}
*/
_labelOffset: 5
});
};
_proto.parseTick = function parseTick(tick, index, length) {
return {
text: tick,
value: index / length
};
};
_proto._getCirclePoint = function _getCirclePoint(angle, radius) {
var self = this;
var center = self.get('center');
radius = radius || self.get('radius');
return {
x: center.x + Math.cos(angle) * radius,
y: center.y + Math.sin(angle) * radius
};
};
_proto.getTickPoint = function getTickPoint(value) {
var self = this;
var startAngle = self.get('startAngle');
var endAngle = self.get('endAngle');
var angle = startAngle + (endAngle - startAngle) * value;
return self._getCirclePoint(angle);
};
_proto.getSideVector = function getSideVector(offset, point) {
var self = this;
var center = self.get('center');
var vector = [point.x - center.x, point.y - center.y];
if (!Util.isNil(offset)) {
var vecLen = vec2.length(vector);
vec2.scale(vector, vector, offset / vecLen);
}
return vector;
};
_proto.getSidePoint = function getSidePoint(point, offset) {
var self = this;
var vector = self.getSideVector(offset, point);
return {
x: point.x + vector[0],
y: point.y + vector[1]
};
};
_proto.getTickEnd = function getTickEnd(start, length) {
var self = this;
var tickLine = self.get('tickLine');
length = length ? length : tickLine.length;
return self.getSidePoint(start, length);
};
_proto.getTextAnchor = function getTextAnchor(vector) {
var align;
if (Util.snapEqual(vector[0], 0)) {
align = 'center';
} else if (vector[0] > 0) {
align = 'left';
} else if (vector[0] < 0) {
align = 'right';
}
return align;
};
_proto.getLinePath = function getLinePath() {
var self = this;
var center = self.get('center');
var x = center.x;
var y = center.y;
var rx = self.get('radius');
var ry = rx;
var startAngle = self.get('startAngle');
var endAngle = self.get('endAngle');
var inner = self.get('inner');
var path = [];
if (Math.abs(endAngle - startAngle) === Math.PI * 2) {
path = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
} else {
var startPoint = self._getCirclePoint(startAngle);
var endPoint = self._getCirclePoint(endAngle);
var large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
var sweep = startAngle > endAngle ? 0 : 1;
if (!inner) {
path = [['M', x, y], ['L', startPoint.x, startPoint.y], ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y], ['L', x, y]];
} else {
var innerStartVector = self.getSideVector(inner * rx, startPoint);
var innerEndVector = self.getSideVector(inner * rx, endPoint);
var innerStartPoint = {
x: innerStartVector[0] + x,
y: innerStartVector[1] + y
};
var innerEndPoint = {
x: innerEndVector[0] + x,
y: innerEndVector[1] + y
};
path = [['M', innerStartPoint.x, innerStartPoint.y], ['L', startPoint.x, startPoint.y], ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y], ['L', innerEndPoint.x, innerEndPoint.y], ['A', rx * inner, ry * inner, 0, large, Math.abs(sweep - 1), innerStartPoint.x, innerStartPoint.y]];
}
}
return path;
};
_proto.addLabel = function addLabel(tick, point, index) {
var self = this;
var offset = self.get('label').offset || self.get('_labelOffset') || 0.001;
point = self.getSidePoint(point, offset);
_Base.prototype.addLabel.call(this, tick, point, index);
};
_proto.autoRotateLabels = function autoRotateLabels() {
var self = this;
var ticks = self.get('ticks');
var labelRenderer = self.get('labelRenderer');
if (labelRenderer && ticks.length > 12) {
// 小于12个文本时文本不旋转
var radius = self.get('radius');
var startAngle = self.get('startAngle');
var endAngle = self.get('endAngle');
var totalAngle = endAngle - startAngle;
var avgAngle = totalAngle / (ticks.length - 1);
var avgWidth = Math.sin(avgAngle / 2) * radius * 2;
var maxLength = self.getMaxLabelWidth(labelRenderer);
Util.each(labelRenderer.get('group').get('children'), function (label, index) {
var tick = ticks[index];
var angle = tick.value * totalAngle + startAngle;
var mode = angle % (Math.PI * 2);
if (maxLength < avgWidth) {
// 文本的最大宽度大于
if (mode <= 0) {
angle = angle + Math.PI;
}
if (mode > Math.PI) {
angle = angle - Math.PI;
}
angle = angle - Math.PI / 2;
label.attr('textAlign', 'center');
} else {
if (mode > Math.PI / 2) {
angle = angle - Math.PI;
} else if (mode < Math.PI / 2 * -1) {
angle = angle + Math.PI;
}
}
label.rotateAtStart(angle);
});
}
};
return Circle;
}(Base);
module.exports = Circle;
/***/ }),
/* 233 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Base = __webpack_require__(33);
var MatrixUtil = Util.MatrixUtil,
PathUtil = Util.PathUtil;
var vec2 = MatrixUtil.vec2;
var Helix =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Helix, _Base);
function Helix() {
return _Base.apply(this, arguments) || this;
}
var _proto = Helix.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
inner: 0,
type: 'helix',
line: {
// @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线
lineWidth: 1,
stroke: '#C0D0E0'
},
tickLine: {
// @type {Attrs} 标注坐标线的图形属性
lineWidth: 1,
stroke: '#C0D0E0',
length: 5
},
startAngle: 1.25 * Math.PI,
endAngle: 7.25 * Math.PI,
// 螺旋系数
a: 0,
// 画布中心坐标
center: null,
// 坐标轴绘制起点
axisStart: null,
// 坐标轴的n个坐标点
crp: []
});
};
_proto.getLinePath = function getLinePath() {
var self = this;
var crp = self.get('crp');
var axisStart = self.get('axisStart');
var path = PathUtil.catmullRomToBezier(crp);
path.unshift(['M', axisStart.x, axisStart.y]);
return path;
};
_proto.getTickPoint = function getTickPoint(value) {
var self = this;
var startAngle = self.get('startAngle');
var endAngle = self.get('endAngle');
var angle = startAngle + (endAngle - startAngle) * value;
return self._getHelixPoint(angle);
};
_proto._getHelixPoint = function _getHelixPoint(angle) {
var self = this;
var center = self.get('center');
var a = self.get('a'); // 螺线系数
var radius = a * angle + self.get('inner'); // 螺线方程
return {
x: center.x + Math.cos(angle) * radius,
y: center.y + Math.sin(angle) * radius
};
};
_proto.getSideVector = function getSideVector(offset, point) {
var self = this;
var center = self.get('center');
var vector = [point.x - center.x, point.y - center.y];
if (offset) {
var vecLen = vec2.length(vector);
vec2.scale(vector, vector, offset / vecLen);
}
return vector;
};
_proto.getSidePoint = function getSidePoint(point, offset) {
var self = this;
var vector = self.getSideVector(offset, point);
return {
x: point.x + vector[0],
y: point.y + vector[1]
};
};
_proto.getTickEnd = function getTickEnd(start, length) {
var self = this;
var tickLine = self.get('tickLine');
length = length ? length : tickLine.length;
return self.getSidePoint(start, length);
};
return Helix;
}(Base);
module.exports = Helix;
/***/ }),
/* 234 */
/***/ (function(module, exports, __webpack_require__) {
var Axis = __webpack_require__(33);
Axis.Base = Axis;
Axis.Circle = __webpack_require__(232);
Axis.Grid = __webpack_require__(101);
Axis.Helix = __webpack_require__(233);
Axis.Line = __webpack_require__(235);
Axis.Polyline = __webpack_require__(236);
module.exports = Axis;
/***/ }),
/* 235 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(33);
var Util = __webpack_require__(3);
var MatrixUtil = Util.MatrixUtil;
var vec2 = MatrixUtil.vec2;
var Line =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Line, _Base);
function Line() {
return _Base.apply(this, arguments) || this;
}
var _proto = Line.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
x: null,
// @type {Number} 距离初始位置的x轴偏移量,仅对于左侧、右侧的纵向坐标有效
y: null,
// @type {Number} 距离初始位置的y轴偏移量,仅对顶部、底部的横向坐标轴有效
line: {
// @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线
lineWidth: 1,
stroke: '#C0D0E0'
},
tickLine: {
// @type {Attrs} 标注坐标线的图形属性
lineWidth: 1,
stroke: '#C0D0E0',
length: 5
},
isVertical: false,
start: null,
// @type {Object} 起点
end: null // @type {Object} 终点
});
};
_proto._getAvgLabelLength = function _getAvgLabelLength(labelRenderer) {
var labels = labelRenderer.get('group').get('children');
return labels[1].attr('x') - labels[0].attr('x');
};
_proto._getAvgLabelHeightSpace = function _getAvgLabelHeightSpace(labelRenderer) {
var labels = labelRenderer.get('group').get('children');
return labels[1].attr('y') - labels[0].attr('y');
};
/**
* 获取距离坐标轴的向量
* @override
* @param {Number} offset 偏移值
* @return {Array} 返回二维向量
*/
_proto.getSideVector = function getSideVector(offset) {
var self = this;
var isVertical = self.get('isVertical');
var factor = self.get('factor'); // if (Util.isArray(offset)) {
// return offset.map(value => value * factor);
// }
if (!Util.isNumber(offset)) {
return [0, 0];
}
var start = self.get('start');
var end = self.get('end');
var axisVector = self.getAxisVector();
var normal = vec2.normalize([], axisVector);
var direction = false;
if (isVertical && start.y < end.y || !isVertical && start.x > end.x) {
direction = true;
}
var verticalVector = vec2.vertical([], normal, direction);
return vec2.scale([], verticalVector, offset * factor);
};
_proto.getAxisVector = function getAxisVector() {
var start = this.get('start');
var end = this.get('end');
return [end.x - start.x, end.y - start.y];
};
_proto.getLinePath = function getLinePath() {
var self = this;
var start = self.get('start');
var end = self.get('end');
var path = [];
path.push(['M', start.x, start.y]);
path.push(['L', end.x, end.y]);
return path;
};
_proto.getTickEnd = function getTickEnd(start, value) {
var self = this;
var offsetVector = self.getSideVector(value);
return {
x: start.x + offsetVector[0],
y: start.y + offsetVector[1]
};
};
_proto.getTickPoint = function getTickPoint(tickValue) {
var self = this;
var start = self.get('start');
var end = self.get('end');
var rangeX = end.x - start.x;
var rangeY = end.y - start.y;
return {
x: start.x + rangeX * tickValue,
y: start.y + rangeY * tickValue
};
};
_proto.renderTitle = function renderTitle() {
var self = this;
var title = self.get('title');
var offsetPoint = self.getTickPoint(0.5);
var titleOffset = title.offset;
if (Util.isNil(titleOffset)) {
// 没有指定 offset 则自动计算
titleOffset = 20;
var labelsGroup = self.get('labelsGroup');
if (labelsGroup) {
var labelLength = self.getMaxLabelWidth(labelsGroup);
var labelOffset = self.get('label').offset || self.get('_labelOffset');
titleOffset += labelLength + labelOffset;
}
}
var textStyle = title.textStyle;
var cfg = Util.mix({}, textStyle);
if (title.text) {
var vector = self.getAxisVector(); // 坐标轴方向的向量
if (title.autoRotate && Util.isNil(textStyle.rotate)) {
// 自动旋转并且用户没有指定标题的旋转角度
var angle = 0;
if (!Util.snapEqual(vector[1], 0)) {
// 所有水平坐标轴,文本不转置
var v1 = [1, 0];
var v2 = [vector[0], vector[1]];
angle = vec2.angleTo(v2, v1, true);
}
cfg.rotate = angle * (180 / Math.PI);
} else if (!Util.isNil(textStyle.rotate)) {
// 用户设置了旋转角度就以用户设置的为准
cfg.rotate = textStyle.rotate / 180 * Math.PI; // 将角度转换为弧度
}
var sideVector = self.getSideVector(titleOffset);
var point;
var position = title.position;
if (position === 'start') {
point = {
x: this.get('start').x + sideVector[0],
y: this.get('start').y + sideVector[1]
};
} else if (position === 'end') {
point = {
x: this.get('end').x + sideVector[0],
y: this.get('end').y + sideVector[1]
};
} else {
point = {
x: offsetPoint.x + sideVector[0],
y: offsetPoint.y + sideVector[1]
};
}
cfg.x = point.x;
cfg.y = point.y;
cfg.text = title.text;
var group = self.get('group');
var titleShape = group.addShape('Text', {
zIndex: 2,
attrs: cfg
});
titleShape.name = 'axis-title';
self.get('appendInfo') && titleShape.setSilent('appendInfo', self.get('appendInfo'));
}
};
_proto.autoRotateLabels = function autoRotateLabels() {
var self = this;
var labelRenderer = self.get('labelRenderer');
var title = self.get('title');
if (labelRenderer) {
var labelGroup = labelRenderer.get('group');
var labels = labelGroup.get('children');
var offset = self.get('label').offset;
var append = 12;
var titleOffset = title ? title.offset : 48;
if (titleOffset < 0) {
// 如果是负的的话就不旋转
return;
}
var vector = self.getAxisVector(); // 坐标轴的向量,仅处理水平或者垂直的场景
var angle;
var maxWidth;
if (Util.snapEqual(vector[0], 0) && title && title.text) {
// 坐标轴垂直,由于不知道边距,只能防止跟title重合,如果title不存在,则不自动旋转
maxWidth = self.getMaxLabelWidth(labelRenderer);
if (maxWidth > titleOffset - offset - append) {
angle = Math.acos((titleOffset - offset - append) / maxWidth) * -1;
}
} else if (Util.snapEqual(vector[1], 0) && labels.length > 1) {
// 坐标轴水平,不考虑边距,根据最长的和平均值进行翻转
var avgWidth = Math.abs(self._getAvgLabelLength(labelRenderer));
maxWidth = self.getMaxLabelWidth(labelRenderer);
if (maxWidth > avgWidth) {
angle = Math.asin((titleOffset - offset - append) * 1.25 / maxWidth);
}
}
if (angle) {
var factor = self.get('factor');
Util.each(labels, function (label) {
label.rotateAtStart(angle);
if (Util.snapEqual(vector[1], 0)) {
if (factor > 0) {
label.attr('textAlign', 'left');
} else {
label.attr('textAlign', 'right');
}
}
});
}
}
};
_proto.autoHideLabels = function autoHideLabels() {
var self = this;
var labelRenderer = self.get('labelRenderer');
var labelSpace;
var tickStep;
var append = 8;
if (labelRenderer) {
var labelGroup = labelRenderer.get('group');
var labels = labelGroup.get('children');
var vector = self.getAxisVector(); // 坐标轴的向量,仅处理水平或者垂直的场景
if (labels.length < 2) {
return;
}
if (Util.snapEqual(vector[0], 0)) {
// 坐标轴垂直
var maxHeight = self.getMaxLabelHeight(labelRenderer) + append;
var avgHeight = Math.abs(self._getAvgLabelHeightSpace(labelRenderer));
if (maxHeight > avgHeight) {
labelSpace = maxHeight;
tickStep = avgHeight;
}
} else if (Util.snapEqual(vector[1], 0) && labels.length > 1) {
// 坐标轴水平
var maxWidth = self.getMaxLabelWidth(labelRenderer) + append;
var avgWidth = Math.abs(self._getAvgLabelLength(labelRenderer));
if (maxWidth > avgWidth) {
labelSpace = maxWidth;
tickStep = avgWidth;
}
}
if (labelSpace && tickStep) {
var ratio = Math.ceil(labelSpace / tickStep);
Util.each(labels, function (label, i) {
if (i % ratio !== 0) {
label.attr('text', '');
}
});
}
}
};
return Line;
}(Base);
module.exports = Line;
/***/ }),
/* 236 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Base = __webpack_require__(33);
var MatrixUtil = Util.MatrixUtil,
PathUtil = Util.PathUtil;
var vec2 = MatrixUtil.vec2;
var Polyline =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Polyline, _Base);
function Polyline() {
return _Base.apply(this, arguments) || this;
}
var _proto = Polyline.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
type: 'polyline'
});
};
_proto.getLinePath = function getLinePath() {
var self = this;
var tickPoints = self.get('tickPoints');
var start = self.get('start');
var end = self.get('end');
var points = [];
points.push(start.x);
points.push(start.y);
Util.each(tickPoints, function (tick) {
points.push(tick.x);
points.push(tick.y);
});
points.push(end.x);
points.push(end.y);
var path = PathUtil.catmullRomToBezier(points);
path.unshift(['M', start.x, start.y]);
return path;
};
_proto.getTickPoint = function getTickPoint(value, index) {
var tickPoints = this.get('tickPoints');
return tickPoints[index];
};
_proto.getTickEnd = function getTickEnd(start, value, index) {
var self = this;
var lineAttrs = self.get('tickLine');
var tickLength = value ? value : lineAttrs.length;
var offsetVector = self.getSideVector(tickLength, start, index);
return {
x: start.x + offsetVector[0],
y: start.y + offsetVector[1]
};
};
_proto.getSideVector = function getSideVector(offset, point, index) {
var self = this;
var preTickPoint;
if (index === 0) {
preTickPoint = self.get('start');
if (preTickPoint.x === point.x && preTickPoint.y === point.y) {
return [0, 0];
}
} else {
var tickPoints = self.get('tickPoints');
preTickPoint = tickPoints[index - 1];
}
var vector = [point.x - preTickPoint.x, point.y - preTickPoint.y];
var normal = vec2.normalize([], vector);
var verticalVector = vec2.vertical([], normal, false);
return vec2.scale([], verticalVector, offset);
};
return Polyline;
}(Base);
module.exports = Polyline;
/***/ }),
/* 237 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var PI = Math.PI;
var atan = Math.atan;
function calculateAngle(point, center) {
var x = point.x - center.x;
var y = point.y - center.y;
var deg;
if (y === 0) {
if (x < 0) {
deg = PI / 2;
} else {
deg = 270 * PI / 180;
}
} else if (x >= 0 && y > 0) {
deg = PI * 2 - atan(x / y);
} else if (x <= 0 && y < 0) {
deg = PI - atan(x / y);
} else if (x > 0 && y < 0) {
deg = PI + atan(-x / y);
} else if (x < 0 && y > 0) {
deg = atan(x / -y);
}
return deg;
}
var Arc =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Arc, _Guide);
function Arc() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Arc.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 辅助元素类型
* @type {String}
*/
name: 'arc',
/**
* 辅助弧线的起始点
* @type {Object | Function | Array}
*/
start: null,
/**
* 辅助弧线的终止点
* @type {Object | Function | Array}
*/
end: null,
/**
* 辅助文本的样式配置
* @type {Object}
*/
style: {
stroke: '#999',
lineWidth: 1
}
});
};
_proto.render = function render(coord, group) {
var self = this;
var start = self.parsePoint(coord, self.get('start'));
var end = self.parsePoint(coord, self.get('end'));
var coordCenter = coord.getCenter();
var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
var path; // 处理整圆的情况
var startAngle = calculateAngle(start, coordCenter);
var endAngle = calculateAngle(end, coordCenter);
if (endAngle < startAngle) {
endAngle += PI * 2;
}
if (Util.isNumberEqual(start.x, end.x) && Util.isNumberEqual(start.y, end.y) && (self.get('start')[0] !== self.get('end')[0] || self.get('start')[1] !== self.get('end')[1])) {
path = [['M', start.x, start.y], ['A', radius, radius, 0, 1, 1, 2 * coordCenter.x - start.x, 2 * coordCenter.y - start.y], ['A', radius, radius, 0, 1, 1, start.x, start.y]];
} else {
var dAngle = (endAngle - startAngle) % (PI * 2);
var largeArc = dAngle > PI ? 1 : 0;
path = [['M', start.x, start.y], ['A', radius, radius, 0, largeArc, 1, end.x, end.y]];
}
var arcShape = group.addShape('path', {
zIndex: self.get('zIndex'),
attrs: Util.mix({
path: path
}, self.get('style'))
});
arcShape.name = 'guide-arc';
self.get('appendInfo') && arcShape.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', arcShape);
};
return Arc;
}(Guide);
module.exports = Arc;
/***/ }),
/* 238 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var DataMarker =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(DataMarker, _Guide);
function DataMarker() {
return _Guide.apply(this, arguments) || this;
}
var _proto = DataMarker.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'dataMarker',
zIndex: 1,
top: true,
position: null,
style: {
point: {
r: 3,
fill: '#FFFFFF',
stroke: '#1890FF',
lineWidth: 2
},
line: {
stroke: '#A3B1BF',
lineWidth: 1
},
text: {
fill: '#000000',
opacity: 0.65,
fontSize: 12,
textAlign: 'start'
}
},
// end of style
display: {
point: true,
line: true,
text: true
},
lineLength: 20,
direction: 'upward',
autoAdjust: true
});
};
_proto.render = function render(coord, group) {
var self = this;
var point = self.parsePoint(coord, self.get('position')); // container
var markerGroup = group.addGroup();
markerGroup.name = 'guide-data-marker'; // markerGroup.translate(point.x, point.y);
var positions = self._getElementPosition(point);
var display = self.get('display');
var lineShape;
var textShape; // add line
if (display.line) {
var lineData = positions.line;
lineShape = self._drawLine(lineData, markerGroup);
} // add text
if (display.text && self.get('content')) {
var textPosition = positions.text;
textShape = self._drawText(textPosition, markerGroup);
} // add circle
if (display.point) {
var pointPoisition = positions.point;
self._drawPoint(pointPoisition, markerGroup);
}
if (self.get('autoAdjust')) {
var bbox = markerGroup.getBBox();
var minX = bbox.minX,
minY = bbox.minY,
maxX = bbox.maxX,
maxY = bbox.maxY;
var start = coord.start,
end = coord.end;
if (textShape) {
if (minX <= start.x) {
// 左侧超出
textShape.attr('textAlign', 'start');
}
if (maxX >= end.x) {
// 右侧超出
textShape.attr('textAlign', 'end');
}
var direction = self.get('direction');
if (direction === 'upward' && minY <= end.y || direction !== 'upward' && maxY >= start.y) {
// 上方或者下方超出
var textBaseline;
var dir;
if (direction === 'upward' && minY <= end.y) {
textBaseline = 'top';
dir = 1;
} else {
textBaseline = 'bottom';
dir = -1;
}
textShape.attr('textBaseline', textBaseline);
var lineLength = 0;
if (self.get('display').line) {
lineLength = self.get('lineLength');
var linePath = [['M', point.x, point.y], ['L', point.x, point.y + lineLength * dir]];
lineShape.attr('path', linePath);
}
var newY = point.y + (lineLength + 2) * dir;
textShape.attr('y', newY);
}
}
}
self.get('appendInfo') && markerGroup.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', markerGroup);
};
_proto._getElementPosition = function _getElementPosition(position) {
var self = this;
var x = position.x,
y = position.y;
var lineLength = self.get('display').line ? self.get('lineLength') : 0;
var direction = self.get('direction');
var textStyle = self.get('style').text;
textStyle.textBaseline = direction === 'upward' ? 'bottom' : 'top';
var dir = direction === 'upward' ? -1 : 1;
var pointPoisition = {
x: x,
y: y
};
var lineStart = {
x: x,
y: y
};
var lineEnd = {
x: x,
y: lineLength * dir + y
};
var textPosition = {
x: x,
y: (lineLength + 2) * dir + y
};
return {
point: pointPoisition,
line: [lineStart, lineEnd],
text: textPosition
};
};
_proto._drawLine = function _drawLine(lineData, g) {
var self = this;
var lineStyle = self.get('style').line;
var linePath = [['M', lineData[0].x, lineData[0].y], ['L', lineData[1].x, lineData[1].y]];
var lineShape = g.addShape('path', {
attrs: Util.mix({
path: linePath
}, lineStyle)
});
return lineShape;
};
_proto._drawText = function _drawText(position, g) {
var self = this;
var textStyle = this.get('style').text;
var textShape = g.addShape('text', {
attrs: Util.mix({
text: self.get('content')
}, textStyle, position)
});
return textShape;
};
_proto._drawPoint = function _drawPoint(position, g) {
var self = this;
var pointStyle = self.get('style').point;
var pointShape = g.addShape('circle', {
attrs: Util.mix({}, pointStyle, position)
});
return pointShape;
};
return DataMarker;
}(Guide);
module.exports = DataMarker;
/***/ }),
/* 239 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Helper = __webpack_require__(102);
var Guide = __webpack_require__(19);
var DataRegion =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(DataRegion, _Guide);
function DataRegion() {
return _Guide.apply(this, arguments) || this;
}
var _proto = DataRegion.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'dataRegion',
start: null,
// 只支持数值
end: null,
// 只支持数值
content: '',
// 文本内容
style: {
region: {
lineWidth: 0,
fill: '#000000',
opacity: 0.04
},
text: {
textAlign: 'center',
textBaseline: 'bottom',
fontSize: 12,
fill: 'rgba(0, 0, 0, .65)'
}
}
});
};
_proto.render = function render(coord, group, data) {
var self = this; // draw region
var lineLength = self.get('lineLength') || 0; // TODO: 如何命名
var regionData = self._getRegionData(coord, data);
if (!regionData.length) return;
var regionBBox = self._getBBox(regionData);
var path = [];
path.push(['M', regionData[0].x, regionBBox.yMin - lineLength]);
for (var i = 0, len = regionData.length; i < len; i++) {
var p = ['L', regionData[i].x, regionData[i].y];
path.push(p);
}
path.push(['L', regionData[regionData.length - 1].x, regionBBox.yMin - lineLength]); // draw
var style = self.get('style');
var regionStyle = style.region; // 兼容之前的写法
var textStyle = style.text;
var regionGroup = group.addGroup();
regionGroup.name = 'guide-data-region';
regionGroup.addShape('path', {
attrs: Util.mix({
path: path
}, regionStyle)
});
var content = self.get('content');
if (content) {
regionGroup.addShape('Text', {
attrs: Util.mix({
x: (regionBBox.xMin + regionBBox.xMax) / 2,
y: regionBBox.yMin - lineLength,
text: content
}, textStyle)
});
}
self.get('appendInfo') && regionGroup.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', regionGroup);
};
_proto._getRegionData = function _getRegionData(coord, data) {
var self = this;
var start = self.get('start');
var end = self.get('end');
var xField = Helper.getFirstScale(self.get('xScales')).field;
var yField = Helper.getFirstScale(self.get('yScales')).field;
var startXValue = Util.isArray(start) ? start[0] : start[xField];
var endXValue = Util.isArray(end) ? end[0] : end[xField];
var startIndex;
var arr = [];
for (var i = 0, len = data.length; i < len; i++) {
var item = data[i];
if (item[xField] === startXValue) {
startIndex = i;
}
if (i >= startIndex) {
arr.push(self.parsePoint(coord, [item[xField], item[yField]]));
}
if (item[xField] === endXValue) {
break;
}
}
return arr;
};
_proto._getBBox = function _getBBox(data) {
var xs = [];
var ys = [];
for (var i = 0; i < data.length; i++) {
xs.push(data[i].x);
ys.push(data[i].y);
}
var xRange = Util.arrayUtil.getRange(xs);
var yRange = Util.arrayUtil.getRange(ys);
return {
xMin: xRange.min,
xMax: xRange.max,
yMin: yRange.min,
yMax: yRange.max
};
};
return DataRegion;
}(Guide);
module.exports = DataRegion;
/***/ }),
/* 240 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var DomUtil = Util.DomUtil;
var Guide = __webpack_require__(19);
var Html =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Html, _Guide);
function Html() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Html.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'html',
zIndex: 7,
position: null,
/**
* Horizontal alignment, can be 'left'、'middle'、'right'
* @type {String}
*/
alignX: 'middle',
/**
* vertical alignment, can be 'top'、'middle'、'bottom'
* @type {String}
*/
alignY: 'middle',
/**
* Horizontal offset
* @type {Number}
*/
offsetX: null,
/**
* Vertical offset
* @type {Number}
*/
offsetY: null,
/**
* html content
*@type {String | Function}
*/
html: null
});
};
/**
* render Html Guide
* @override
* @param {Coordinate} coord the instance of Coordinate class
* @param {Container} container the container which contain the guide component
*/
_proto.render = function render(coord, container) {
var self = this;
var position = self.parsePoint(coord, self.get('position'));
var parentNode = container.get('canvas').get('el').parentNode;
var wrapperNode = DomUtil.createDom('');
parentNode.appendChild(wrapperNode);
var html = self.get('htmlContent') || self.get('html');
if (Util.isFunction(html)) {
var xScales = self.get('xScales');
var yScales = self.get('yScales');
html = html(xScales, yScales);
}
var htmlNode = DomUtil.createDom(html);
wrapperNode.appendChild(htmlNode);
DomUtil.modifyCSS(wrapperNode, {
position: 'absolute' // to fix dom in the document stream to get the true width
});
self._setDomPosition(wrapperNode, htmlNode, position);
self.set('el', wrapperNode);
};
_proto._setDomPosition = function _setDomPosition(parentDom, childDom, point) {
var self = this;
var alignX = self.get('alignX');
var alignY = self.get('alignY');
var domWidth = DomUtil.getOuterWidth(childDom);
var domHeight = DomUtil.getOuterHeight(childDom);
var position = {
x: point.x,
y: point.y
};
if (alignX === 'middle' && alignY === 'top') {
position.x -= Math.round(domWidth / 2);
} else if (alignX === 'middle' && alignY === 'bottom') {
position.x -= Math.round(domWidth / 2);
position.y -= Math.round(domHeight);
} else if (alignX === 'left' && alignY === 'bottom') {
position.y -= Math.round(domHeight);
} else if (alignX === 'left' && alignY === 'middle') {
position.y -= Math.round(domHeight / 2);
} else if (alignX === 'left' && alignY === 'top') {
position.x = point.x;
position.y = point.y;
} else if (alignX === 'right' && alignY === 'bottom') {
position.x -= Math.round(domWidth);
position.y -= Math.round(domHeight);
} else if (alignX === 'right' && alignY === 'middle') {
position.x -= Math.round(domWidth);
position.y -= Math.round(domHeight / 2);
} else if (alignX === 'right' && alignY === 'top') {
position.x -= Math.round(domWidth);
} else {
// 默认位于中心点
position.x -= Math.round(domWidth / 2);
position.y -= Math.round(domHeight / 2);
}
var offsetX = self.get('offsetX');
if (offsetX) {
position.x += offsetX;
}
var offsetY = self.get('offsetY');
if (offsetY) {
position.y += offsetY;
}
DomUtil.modifyCSS(parentDom, {
top: Math.round(position.y) + 'px',
left: Math.round(position.x) + 'px',
visibility: 'visible',
zIndex: self.get('zIndex')
});
};
/**
* clear html guide
* @override
*/
_proto.clear = function clear() {
var self = this;
var el = self.get('el');
el && el.parentNode && el.parentNode.removeChild(el);
};
return Html;
}(Guide);
module.exports = Html;
/***/ }),
/* 241 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var Image =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Image, _Guide);
function Image() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Image.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
type: 'image',
/**
* the start of image
* @type {Object | Function | Array}
*/
start: null,
/**
* the end of image
* @type {Object | Function | Array}
*/
end: null,
/**
* image url
* @type {String}
*/
src: null,
/**
* Horizontal offset
* @type {Number}
*/
offsetX: null,
/**
* Vertical offset
* @type {Number}
*/
offsetY: null
});
};
_proto.render = function render(coord, group) {
var self = this;
var start = self.parsePoint(coord, self.get('start'));
var cfg = {
x: start.x,
y: start.y
};
cfg.img = self.get('src');
if (!self.get('end')) {
// 如果咩有指定结束点,则 start 为图片的左上角坐标
cfg.width = self.get('width') || 32;
cfg.height = self.get('height') || 32;
} else {
var end = self.parsePoint(coord, self.get('end')); // cfg.width = Math.abs(end.x - start.x);
// cfg.height = Math.abs(end.y - start.y);
cfg.width = end.x - start.x;
cfg.height = end.y - start.y;
}
if (self.get('offsetX')) {
cfg.x += self.get('offsetX');
}
if (self.get('offsetY')) {
cfg.y += self.get('offsetY');
}
var imgGuide = group.addShape('Image', {
zIndex: 1,
attrs: cfg
});
imgGuide.name = 'guide-image';
self.get('appendInfo') && imgGuide.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', imgGuide);
};
return Image;
}(Guide);
module.exports = Image;
/***/ }),
/* 242 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
Guide: __webpack_require__(19),
Arc: __webpack_require__(237),
DataMarker: __webpack_require__(238),
DataRegion: __webpack_require__(239),
Html: __webpack_require__(240),
Image: __webpack_require__(241),
Line: __webpack_require__(243),
Region: __webpack_require__(244),
Text: __webpack_require__(245)
};
/***/ }),
/* 243 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var vec2 = Util.MatrixUtil.vec2;
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var Line =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Line, _Guide);
function Line() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Line.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 辅助元素类型
* @type {String}
*/
name: 'line',
/**
* 辅助线的起点位置
* @type {Object | Function | Array}
*/
start: null,
/**
* 辅助线的终点位置
* @type {Object | Function | Array}
*/
end: null,
/**
* 辅助线的图形样式
* @type {Object}
*/
lineStyle: {
stroke: '#000',
lineWidth: 1
},
/**
* 辅助文本配置
* @type {Object}
*/
text: {
position: 'end',
// 文本的显示位置: start / center / end / 百分比
autoRotate: true,
// 文本是否沿着辅助线的方向自动旋转
style: {
fill: '#999',
fontSize: 12,
fontWeight: 500,
fontFamily: FONT_FAMILY
},
// 辅助文本的样式
content: null // 辅助文本的文字
}
});
};
_proto.render = function render(coord, group) {
var self = this;
var start = self.parsePoint(coord, self.get('start'));
var end = self.parsePoint(coord, self.get('end'));
var guideLineGroup = group.addGroup({
viewId: group.get('viewId')
});
self._drawLines(start, end, guideLineGroup);
var text = self.get('text');
if (text && text.content) {
self._drawText(start, end, guideLineGroup);
}
self.set('el', guideLineGroup);
};
_proto._drawLines = function _drawLines(start, end, group) {
var path = [['M', start.x, start.y], ['L', end.x, end.y]];
var guideLine = group.addShape('Path', {
attrs: Util.mix({
path: path
}, this.get('lineStyle'))
});
guideLine.name = 'guide-line';
this.get('appendInfo') && guideLine.setSilent('appendInfo', this.get('appendInfo'));
};
_proto._drawText = function _drawText(start, end, group) {
var textCfg = this.get('text');
var position = textCfg.position;
var textStyle = textCfg.style || {};
var percent;
if (position === 'start') {
percent = 0;
} else if (position === 'center') {
percent = 0.5;
} else if (Util.isString(position) && position.indexOf('%') !== -1) {
percent = parseInt(position, 10) / 100;
} else if (Util.isNumber(position)) {
percent = position;
} else {
percent = 1;
}
if (percent > 1 || percent < 0) {
percent = 1;
}
var cfg = {
x: start.x + (end.x - start.x) * percent,
y: start.y + (end.y - start.y) * percent
};
if (textCfg.offsetX) {
// 设置了偏移量
cfg.x += textCfg.offsetX;
}
if (textCfg.offsetY) {
// 设置了偏移量
cfg.y += textCfg.offsetY;
}
cfg.text = textCfg.content;
cfg = Util.mix({}, cfg, textStyle);
if (textCfg.autoRotate && Util.isNil(textStyle.rotate)) {
// 自动旋转且用户没有设置旋转角度
var angle = vec2.angleTo([end.x - start.x, end.y - start.y], [1, 0], 1);
cfg.rotate = angle;
} else if (!Util.isNil(textStyle.rotate)) {
// 用户设置了旋转角度
cfg.rotate = textStyle.rotate * Math.PI / 180;
}
var shape = group.addShape('Text', {
attrs: cfg
});
shape.name = 'guide-line-text';
this.get('appendInfo') && shape.setSilent('appendInfo', this.get('appendInfo'));
};
return Line;
}(Guide);
module.exports = Line;
/***/ }),
/* 244 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var Region =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Region, _Guide);
function Region() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Region.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'region',
zIndex: 1,
start: null,
end: null,
style: {
lineWidth: 0,
fill: '#CCD7EB',
opacity: 0.4
}
});
};
_proto.render = function render(coord, group) {
var self = this;
var rectStyle = self.get('style');
var path = self._getPath(coord);
var regionGroup = group.addShape('path', {
zIndex: self.get('zIndex'),
attrs: Util.mix({
path: path
}, rectStyle)
});
regionGroup.name = 'guide-region';
self.get('appendInfo') && regionGroup.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', regionGroup);
};
_proto._getPath = function _getPath(coord) {
var self = this;
var start = self.parsePoint(coord, self.get('start'));
var end = self.parsePoint(coord, self.get('end'));
var path = [['M', start.x, start.y], ['L', end.x, start.y], ['L', end.x, end.y], ['L', start.x, end.y], ['z']];
return path;
};
return Region;
}(Guide);
module.exports = Region;
/***/ }),
/* 245 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var Guide = __webpack_require__(19);
var Text =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(Text, _Guide);
function Text() {
return _Guide.apply(this, arguments) || this;
}
var _proto = Text.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 辅助元素类型
* @type {String}
*/
name: 'text',
/**
* 辅助文本的位置
* @type {Object | Function | Array}
*/
position: null,
/**
* 辅助文本的显示文字
* @type {String}
*/
content: null,
/**
* 辅助文本的样式配置
* @type {Object}
*/
style: {
fill: '#999',
fontSize: 12,
fontWeight: 500,
textAlign: 'center'
},
/**
* x 方向的偏移量
* @type {Number}
*/
offsetX: null,
/**
* y 方向的偏移量
* @type {Number}
*/
offsetY: null,
top: true
});
};
_proto.render = function render(coord, group) {
var self = this;
var point = self.parsePoint(coord, self.get('position'));
var textStyle = Util.mix({}, self.get('style'));
var offsetX = self.get('offsetX');
var offsetY = self.get('offsetY');
if (offsetX) {
point.x += offsetX;
}
if (offsetY) {
point.y += offsetY;
}
if (textStyle.rotate) {
textStyle.rotate = textStyle.rotate * Math.PI / 180; // 将角度转换为弧度
}
var guideText = group.addShape('Text', {
zIndex: self.get('zIndex'),
attrs: Util.mix({
text: self.get('content')
}, textStyle, point)
});
guideText.name = 'guide-text';
self.get('appendInfo') && guideText.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', guideText);
};
return Text;
}(Guide);
module.exports = Text;
/***/ }),
/* 246 */
/***/ (function(module, exports, __webpack_require__) {
var Label = __webpack_require__(103);
module.exports = Label;
/***/ }),
/* 247 */
/***/ (function(module, exports) {
module.exports = function bboxAdjust(labels, shapes) {
var labelBBox, shapeBBox;
var toBeRemoved = [];
for (var i = 0; i < labels.length; i++) {
labelBBox = labels[i].getBBox();
shapeBBox = shapes[i].getBBox();
if (labelBBox.width > shapeBBox.width || labelBBox.height > shapeBBox.height) {
toBeRemoved.push(labels[i]);
} else if (labelBBox.width * labelBBox.height > shapeBBox.width * shapeBBox.height) {
toBeRemoved.push(labels[i]);
}
}
for (var _i = 0; _i < toBeRemoved.length; _i++) {
toBeRemoved[_i].remove();
}
};
/***/ }),
/* 248 */
/***/ (function(module, exports, __webpack_require__) {
var Greedy = __webpack_require__(104);
/*
* 根据如下规则尝试放置label
* 5
* ------------------
* | 1 | 0 |
* 8 —————————4———————— 7
* | 2 | 3 |
* ——————————————————
* 6
*/
function adjustLabelPosition(label, x, y, index) {
var bbox = label.getBBox();
var width = bbox.width;
var height = bbox.height;
var attrs = {
x: x,
y: y,
textAlign: 'center'
};
switch (index) {
case 0:
attrs.y -= height / 2;
attrs.textAlign = 'left';
break;
case 1:
attrs.y -= height / 2;
attrs.textAlign = 'right';
break;
case 2:
attrs.y += height / 2;
attrs.textAlign = 'right';
break;
case 3:
attrs.y += height / 2;
attrs.textAlign = 'left';
break;
case 5:
attrs.y -= height / 2;
break;
case 6:
attrs.y += height / 2;
break;
case 7:
attrs.x += width / 2;
attrs.textAlign = 'left';
break;
case 8:
attrs.x -= width / 2;
attrs.textAlign = 'right';
break;
default:
break;
}
label.attr(attrs);
return label.getBBox();
}
module.exports = function (labels) {
var greedy = new Greedy();
var toBeRemoved = [];
var bbox, label, x, y, canFill;
for (var i = 0; i < labels.length; i++) {
label = labels[i];
x = label.attr('x');
y = label.attr('y');
canFill = false;
for (var _i = 0; _i < 8; _i++) {
bbox = adjustLabelPosition(label, x, y, _i);
if (greedy.hasGap(bbox)) {
greedy.fillGap(bbox);
canFill = true;
break;
}
}
if (!canFill) {
toBeRemoved.push(label);
}
}
for (var _i2 = 0; _i2 < toBeRemoved.length; _i2++) {
toBeRemoved[_i2].remove();
}
return canFill;
};
/***/ }),
/* 249 */
/***/ (function(module, exports, __webpack_require__) {
var Greedy = __webpack_require__(104);
var MAX_TIMES = 20;
function spiralFill(label, greedy) {
var dt = -1;
var x = label.attr('x'),
y = label.attr('y');
var bbox = label.getBBox();
var maxDelta = Math.sqrt(bbox.width * bbox.width + bbox.height * bbox.height);
var dxdy,
t = -dt,
dx = 0,
dy = 0;
var f = function f(t) {
return [(t *= 0.1) * Math.cos(t), t * Math.sin(t)];
};
if (greedy.hasGap(bbox)) {
greedy.fillGap(bbox);
return true;
}
var canFill = false,
times = 0;
while (Math.min(Math.abs(dx), Math.abs(dy)) < maxDelta && times < MAX_TIMES) {
dxdy = f(t += dt);
dx = ~~dxdy[0];
dy = ~~dxdy[1];
label.attr({
x: x + dx,
y: y + dy
});
times++;
if (greedy.hasGap(label.getBBox())) {
greedy.fillGap(bbox);
canFill = true;
break;
}
}
return canFill;
}
module.exports = function (labels) {
var label;
var greedy = new Greedy();
var toBeRemoved = [];
for (var i = 0; i < labels.length; i++) {
label = labels[i];
if (!spiralFill(label, greedy)) {
toBeRemoved.push(label);
}
}
for (var _i = 0; _i < toBeRemoved.length; _i++) {
toBeRemoved[_i].remove();
}
};
/***/ }),
/* 250 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var CatHtml = __webpack_require__(106);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var DomUtil = Util.DomUtil;
var LIST_CLASS = 'g2-legend-list';
var CONTAINER_CLASS = 'g2-legend';
var SLIP_CLASS = 'g2-slip';
var CARET_UP_CLASS = 'g2-caret-up';
var CARET_DOWN_CLASS = 'g2-caret-down';
var ENABLED_CARET_COLOR = 'rgba(0,0,0,0.65)';
var DISABLED_CARET_COLOR = 'rgba(0,0,0,0.25)';
function findNodeByClass(node, className) {
return node.getElementsByClassName(className)[0];
}
var CatPageHtml =
/*#__PURE__*/
function (_CatHtml) {
_inheritsLoose(CatPageHtml, _CatHtml);
function CatPageHtml() {
return _CatHtml.apply(this, arguments) || this;
}
var _proto = CatPageHtml.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _CatHtml.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* type标识
* @type {String}
*/
type: 'category-page-legend',
/**
* html 容器
* @type {DOM}
*/
container: null,
/**
* 向上 / 下翻页图标的样式
* @type {ATTRS}
*/
caretStyle: {
fill: 'rgba(0,0,0,0.65)'
},
/**
* 页码文字的样式
* @type {ATTRS}
*/
pageNumStyle: {
display: 'inline-block',
fontSize: '12px',
fontFamily: FONT_FAMILY,
cursor: 'default'
},
/**
* 翻页块 DOM 的样式
* @type {ATTRS}
*/
slipDomStyle: {
width: 'auto',
height: 'auto',
position: 'absolute'
},
/**
* 翻页块 DOM
* @type {String}
*/
slipTpl: '' + '
' + '
1
' + '
/2
' + '
' + '
',
/**
* 翻页块的宽度,用于设置翻页块相对于 legend 的位置
* @type {Number}
*/
slipWidth: 65,
/**
* legend 内容超出容器的处理方式
* @type {String}
*/
legendOverflow: 'unset'
});
};
_proto.render = function render() {
_CatHtml.prototype._renderHTML.call(this);
this._renderFlipPage();
};
_proto._renderFlipPage = function _renderFlipPage() {
var legendWrapper = document.getElementsByClassName(CONTAINER_CLASS)[0]; // ul
var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS);
var position = this.get('position');
var layout = this.get('layout');
var itemDisplay = position === 'right' || position === 'left' || layout === 'vertical' ? 'block' : 'inline-block'; // 翻页
if (legendWrapper.scrollHeight > legendWrapper.offsetHeight) {
// append a slip div
var slipTpl = this.get('slipTpl');
var slipDom = DomUtil.createDom(slipTpl);
var caretUpDom = findNodeByClass(slipDom, CARET_UP_CLASS);
var caretDownDom = findNodeByClass(slipDom, CARET_DOWN_CLASS);
DomUtil.modifyCSS(caretUpDom, this.get('caretStyle'));
DomUtil.modifyCSS(caretUpDom, {
fill: 'rgba(0,0,0,0.25)'
});
DomUtil.modifyCSS(caretDownDom, this.get('caretStyle'));
var curPageNumDom = findNodeByClass(slipDom, 'cur-pagenum');
var totalPageNumDom = findNodeByClass(slipDom, 'next-pagenum');
var pageNumStyle = this.get('pageNumStyle');
DomUtil.modifyCSS(curPageNumDom, Util.mix({}, pageNumStyle, {
paddingLeft: '10px'
}));
DomUtil.modifyCSS(totalPageNumDom, Util.mix({}, pageNumStyle, {
opacity: 0.3,
paddingRight: '10px'
})); // layout at the center-bottom of the legendWrapper
DomUtil.modifyCSS(slipDom, Util.mix({}, this.get('slipDomStyle'), {
top: legendWrapper.offsetHeight + 'px'
}));
legendWrapper.style.overflow = this.get('legendOverflow');
legendWrapper.appendChild(slipDom);
var li = itemListDom.childNodes;
var curHeight = 0; // find the total page number
var pages = 1;
var blockLi = [];
for (var i = 0; i < li.length; i++) {
li[i].style.display = itemDisplay;
curHeight = li[i].offsetTop + li[i].offsetHeight;
if (curHeight >= legendWrapper.offsetHeight) {
pages++;
blockLi.forEach(function (bl) {
bl.style.display = 'none';
});
blockLi = [];
}
blockLi.push(li[i]);
}
totalPageNumDom.innerText = '/' + pages; // initialize the page
li.forEach(function (l) {
l.style.display = itemDisplay;
curHeight = l.offsetTop + l.offsetHeight;
if (curHeight > legendWrapper.offsetHeight) {
l.style.display = 'none';
}
}); // 上翻事件
caretUpDom.addEventListener('click', function () {
// it is the 1st page
if (li[0].style.display === itemDisplay) return; // otherwise
var firstDisplayItemIdx = -1;
li.forEach(function (l, i) {
if (l.style.display === itemDisplay) {
firstDisplayItemIdx = firstDisplayItemIdx === -1 ? i : firstDisplayItemIdx;
l.style.display = 'none';
}
});
for (var _i = firstDisplayItemIdx - 1; _i >= 0; _i--) {
li[_i].style.display = itemDisplay;
curHeight = li[firstDisplayItemIdx - 1].offsetTop + li[firstDisplayItemIdx - 1].offsetHeight;
li[_i].style.display = 'none';
if (curHeight < legendWrapper.offsetHeight) {
li[_i].style.display = itemDisplay;
} else break;
} // change the page number
var currentPage = Number.parseInt(curPageNumDom.innerText, 10) - 1;
if (currentPage === 1) {
caretUpDom.style.fill = DISABLED_CARET_COLOR;
} else {
caretUpDom.style.fill = ENABLED_CARET_COLOR;
}
caretDownDom.style.fill = ENABLED_CARET_COLOR;
curPageNumDom.innerText = currentPage;
}); // 下翻事件
caretDownDom.addEventListener('click', function () {
// it is the last page
if (li[li.length - 1].style.display === itemDisplay) return; // otherwise
var lastDisplayItemIdx = -1;
li.forEach(function (l, i) {
if (l.style.display === itemDisplay) {
lastDisplayItemIdx = i;
l.style.display = 'none';
}
});
for (var _i2 = lastDisplayItemIdx + 1; _i2 < li.length; _i2++) {
li[_i2].style.display = itemDisplay;
curHeight = li[_i2].offsetTop + li[_i2].offsetHeight;
li[_i2].style.display = 'none';
if (curHeight < legendWrapper.offsetHeight) li[_i2].style.display = itemDisplay;else break;
} // change the page number
var currentPage = Number.parseInt(curPageNumDom.innerText, 10) + 1;
if (currentPage === itemDisplay) {
caretDownDom.style.fill = DISABLED_CARET_COLOR;
} else {
caretDownDom.style.fill = ENABLED_CARET_COLOR;
}
caretUpDom.style.fill = ENABLED_CARET_COLOR;
curPageNumDom.innerText = currentPage;
});
this.set('slipDom', slipDom);
}
};
_proto.destroy = function destroy() {
_CatHtml.prototype.destroy.call(this);
var slipDom = this.get('slipDom');
if (slipDom && slipDom.parentNode) {
slipDom.parentNode.removeChild(slipDom);
}
};
return CatPageHtml;
}(CatHtml);
module.exports = CatPageHtml;
/***/ }),
/* 251 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of the gradient color legend
* @author sima.zhang
*/
var _require = __webpack_require__(61),
ColorUtil = _require.ColorUtil; // TODO:ColorUtil 包需要从 attr 包中抽离
var Util = __webpack_require__(3);
var Continuous = __webpack_require__(63);
var Color =
/*#__PURE__*/
function (_Continuous) {
_inheritsLoose(Color, _Continuous);
function Color() {
return _Continuous.apply(this, arguments) || this;
}
var _proto = Color.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Continuous.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 类型
* @type {String}
*/
type: 'color-legend',
/**
* 布局方式
* horizontal 水平
* vertical 垂直
* @type {String}
*/
layout: 'vertical',
/**
* 两头滑块的样式
* @type {object}
*/
triggerAttr: {
fill: '#fff',
shadowOffsetX: -2,
shadowOffsetY: 2,
shadowBlur: 10,
shadowColor: '#ccc',
radius: 3
},
/**
* 同一分段是否使用相同颜色而不使用渐变色,在 slidable = false 时生效
* @type {boolean}
*/
isSegment: false
});
};
_proto._setPercentage = function _setPercentage() {
var items = this.get('items');
if (items[0].percentage) return;
var min = items[0].value;
var max = items[items.length - 1].value;
Util.each(items, function (it) {
it.percentage = (it.value - min) / (max - min);
});
return;
}; // render the slider while slidable === true
_proto._renderSliderShape = function _renderSliderShape() {
this._setPercentage();
var slider = this.get('slider');
var backgroundElement = slider.get('backgroundElement');
var width = this.get('width');
var height = this.get('height');
var layout = this.get('layout');
var items = this.get('items');
var fill = '';
var rgbColor; // gradient color distributed according to the percentage
if (layout === 'vertical') {
fill += 'l (90) ';
Util.each(items, function (v) {
rgbColor = ColorUtil.toRGB(v.color);
fill += 1 - v.percentage + ':' + rgbColor + ' ';
});
} else {
fill += 'l (0) ';
Util.each(items, function (v) {
rgbColor = ColorUtil.toRGB(v.color);
fill += v.percentage + ':' + rgbColor + ' ';
});
}
return this._addMiddleBar(backgroundElement, 'Rect', {
x: 0,
y: 0,
width: width,
height: height,
fill: fill,
strokeOpacity: 0
});
}; // render the silder while slidable === false
_proto._renderUnslidable = function _renderUnslidable() {
this._setPercentage();
var titleShape = this.get('titleShape');
var titleGap = this.get('titleGap');
titleGap = titleShape ? titleShape.getBBox().height + titleGap : titleGap;
var width = this.get('width');
var height = this.get('height');
var layout = this.get('layout');
var items = this.get('items');
var fill = '';
var rgbColor;
var path = [];
var group = this.get('group');
var bgGroup = group.addGroup();
var isize = items.length; // gradient color distributed according to the percentage
if (layout === 'vertical') {
fill += 'l (90) ';
for (var i = 0; i < isize; i += 1) {
if (i !== 0 && i !== isize - 1) {
path.push(['M', 0, height - items[i].percentage * height]);
path.push(['L', width, height - items[i].percentage * height]);
}
rgbColor = ColorUtil.toRGB(items[i].color);
fill += 1 - items[i].percentage + ':' + rgbColor + ' ';
if (this.get('isSegment') && i > 0) {
// one color instead of gradient color for a block while isSegment === true
var preRgbColor = ColorUtil.toRGB(items[i - 1].color);
fill += 1 - items[i].percentage + ':' + preRgbColor + ' ';
}
bgGroup.addShape('text', {
attrs: Util.mix({}, {
x: width + this.get('textOffset') / 2,
y: height - items[i].percentage * height,
text: this._formatItemValue(items[i].value) + '' // 以字符串格式展示
}, this.get('textStyle'), {
textAlign: 'start'
})
});
}
} else {
// horizontal
fill += 'l (0) ';
for (var _i = 0; _i < isize; _i += 1) {
if (_i !== 0 && _i !== isize - 1) {
path.push(['M', items[_i].percentage * width, 0]);
path.push(['L', items[_i].percentage * width, height]);
}
rgbColor = ColorUtil.toRGB(items[_i].color);
if (this.get('isSegment') && _i > 0) {
var _preRgbColor = ColorUtil.toRGB(items[_i - 1].color);
fill += items[_i].percentage + ':' + _preRgbColor + ' ';
}
fill += items[_i].percentage + ':' + rgbColor + ' ';
bgGroup.addShape('text', {
attrs: Util.mix({}, {
x: items[_i].percentage * width,
y: height + 5 + this.get('textOffset'),
text: this._formatItemValue(items[_i].value) + '' // 以字符串格式展示
}, this.get('textStyle'))
});
}
}
bgGroup.addShape('rect', {
attrs: {
x: 0,
y: 0,
width: width,
height: height,
fill: fill,
strokeOpacity: 0
}
}); // the white line segment to seperate color blocks
bgGroup.addShape('path', {
attrs: Util.mix({
path: path
}, this.get('lineStyle'))
});
bgGroup.move(0, titleGap);
};
return Color;
}(Continuous);
module.exports = Color;
/***/ }),
/* 252 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The entry of legend
* @author sima.zhang
*/
module.exports = {
Category: __webpack_require__(107),
// 分类图例
CatHtml: __webpack_require__(106),
// 分类图例
CatPageHtml: __webpack_require__(250),
// 分类图例
// Tail: require('./tail'), // 尾部跟随图例
Color: __webpack_require__(251),
// 颜色图例
Size: __webpack_require__(254),
// 大小图例(适用于除映射点大小以外的其他大小)
CircleSize: __webpack_require__(253) // 点大小图例
};
/***/ }),
/* 253 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of the size legend
* @author sima.zhang
* @author ye liu
*/
var Util = __webpack_require__(3); // const Global = require('../../global');
var Continuous = __webpack_require__(63);
var SLIDER_HEIGHT = 2;
var CIRCLE_GAP = 16;
var MAX_SIZE = 16;
var MIN_SIZE = 5;
var CircleSize =
/*#__PURE__*/
function (_Continuous) {
_inheritsLoose(CircleSize, _Continuous);
function CircleSize() {
return _Continuous.apply(this, arguments) || this;
}
var _proto = CircleSize.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Continuous.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 类型
* @type {String}
*/
type: 'size-circle-legend',
width: 100,
height: 200,
/**
* 不能滑动时圈的样式
* @type {ATTRS}
*/
_unslidableCircleStyle: {
stroke: 'rgb(99, 161, 248)',
fill: 'rgb(99, 161, 248)',
fillOpacity: 0.3,
lineWidth: 1.5
},
/**
* 滑块的样式
* @type {ATTRS}
*/
triggerAttr: {
fill: 'white',
shadowOffsetX: -2,
shadowOffsetY: 2,
shadowBlur: 10,
shadowColor: '#ccc'
},
/**
* 中间 bar 的前景颜色
* @type {ATTRS}
*/
frontMiddleBarStyle: {
fill: 'rgb(64, 141, 251)'
}
});
}; // render the slider shape
_proto._renderSliderShape = function _renderSliderShape() {
var minRadius = MIN_SIZE;
var slider = this.get('slider');
var backgroundElement = slider.get('backgroundElement');
var layout = this.get('layout');
var width = layout === 'vertical' ? SLIDER_HEIGHT : this.get('width');
var height = layout === 'vertical' ? this.get('height') : SLIDER_HEIGHT;
var x = minRadius;
var y = this.get('height') / 2;
var frontMiddleBarStyle = this.get('frontMiddleBarStyle'); // background of middle bar
var points = layout === 'vertical' ? [[0, 0], [width, 0], [width, height], [0, height]] : [[0, y + height], [0, y - height], [x + width - 4, y - height], [x + width - 4, y + height]];
return this._addMiddleBar(backgroundElement, 'Polygon', Util.mix({
points: points
}, frontMiddleBarStyle));
}; // triggers while layout === horizontal
_proto._addHorizontalTrigger = function _addHorizontalTrigger(type, blockAttr, textAttr, radius) {
var slider = this.get('slider');
var trigger = slider.get(type + 'HandleElement');
var y = -this.get('height') / 2;
var button = trigger.addShape('circle', {
attrs: Util.mix({
x: 0,
y: y,
r: radius
}, blockAttr)
});
var text = trigger.addShape('text', {
attrs: Util.mix(textAttr, {
x: 0,
y: y + radius + 10,
textAlign: 'center',
textBaseline: 'middle'
})
});
var layout = this.get('layout');
var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize';
button.attr('cursor', trigerCursor);
text.attr('cursor', trigerCursor);
this.set(type + 'ButtonElement', button);
this.set(type + 'TextElement', text);
}; // triggers while layout === vertical
_proto._addVerticalTrigger = function _addVerticalTrigger(type, blockAttr, textAttr, radius) {
var slider = this.get('slider');
var trigger = slider.get(type + 'HandleElement');
var button = trigger.addShape('circle', {
attrs: Util.mix({
x: 0,
y: 0,
r: radius
}, blockAttr)
});
var text = trigger.addShape('text', {
attrs: Util.mix(textAttr, {
x: radius + 10,
y: 0,
textAlign: 'start',
textBaseline: 'middle'
})
});
var layout = this.get('layout');
var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize';
button.attr('cursor', trigerCursor);
text.attr('cursor', trigerCursor);
this.set(type + 'ButtonElement', button);
this.set(type + 'TextElement', text);
}; // render the triggers
_proto._renderTrigger = function _renderTrigger() {
var min = this.get('firstItem');
var max = this.get('lastItem');
var layout = this.get('layout');
var textStyle = this.get('textStyle');
var triggerAttr = this.get('triggerAttr');
var minBlockAttr = Util.mix({}, triggerAttr);
var maxBlockAttr = Util.mix({}, triggerAttr);
var minRadius = MIN_SIZE;
var maxRadius = MAX_SIZE;
var minTextAttr = Util.mix({
text: this._formatItemValue(min.value) + ''
}, textStyle);
var maxTextAttr = Util.mix({
text: this._formatItemValue(max.value) + ''
}, textStyle);
if (layout === 'vertical') {
this._addVerticalTrigger('min', minBlockAttr, minTextAttr, minRadius);
this._addVerticalTrigger('max', maxBlockAttr, maxTextAttr, maxRadius);
} else {
this._addHorizontalTrigger('min', minBlockAttr, minTextAttr, minRadius);
this._addHorizontalTrigger('max', maxBlockAttr, maxTextAttr, maxRadius);
}
}; // user interactions
_proto._bindEvents = function _bindEvents() {
var _this = this;
if (this.get('slidable')) {
var slider = this.get('slider');
slider.on('sliderchange', function (ev) {
var range = ev.range;
var firstItemValue = _this.get('firstItem').value;
var lastItemValue = _this.get('lastItem').value;
var minValue = firstItemValue + range[0] / 100 * (lastItemValue - firstItemValue);
var maxValue = firstItemValue + range[1] / 100 * (lastItemValue - firstItemValue);
var minRadius = MIN_SIZE + range[0] / 100 * (MAX_SIZE - MIN_SIZE);
var maxRadius = MIN_SIZE + range[1] / 100 * (MAX_SIZE - MIN_SIZE);
_this._updateElement(minValue, maxValue, minRadius, maxRadius);
var itemFiltered = new Event('itemfilter', ev, true, true);
itemFiltered.range = [minValue, maxValue];
_this.emit('itemfilter', itemFiltered);
});
}
}; // update the triggers
_proto._updateElement = function _updateElement(min, max, minR, maxR) {
// update the text of the triggers
_Continuous.prototype._updateElement.call(this, min, max);
var minTextElement = this.get('minTextElement');
var maxTextElement = this.get('maxTextElement');
var minCircleElement = this.get('minButtonElement');
var maxCircleElement = this.get('maxButtonElement'); // update the radius of the triggers
minCircleElement.attr('r', minR);
maxCircleElement.attr('r', maxR); // update the text position of the triggers
var layout = this.get('layout');
if (layout === 'vertical') {
minTextElement.attr('x', minR + 10);
maxTextElement.attr('x', maxR + 10);
} else {
var y = -this.get('height') / 2;
minTextElement.attr('y', y + minR + 10);
maxTextElement.attr('y', y + maxR + 10);
}
}; // add a circle for slidable === false
_proto._addCircle = function _addCircle(x, y, r, text, maxWidth) {
var group = this.get('group');
var circleGroup = group.addGroup();
var circleStyle = this.get('_unslidableCircleStyle');
var textStyle = this.get('textStyle');
var titleShape = this.get('titleShape');
var titleGap = this.get('titleGap');
if (titleShape) {
titleGap += titleShape.getBBox().height;
}
circleGroup.addShape('circle', {
attrs: Util.mix({
x: x,
y: y + titleGap,
r: r === 0 ? 1 : r
}, circleStyle)
});
if (this.get('layout') === 'vertical') {
circleGroup.addShape('text', {
attrs: Util.mix({
x: maxWidth + 20 + this.get('textOffset'),
y: y + titleGap,
text: text === 0 ? '0' : text
}, textStyle)
});
} else {
circleGroup.addShape('text', {
attrs: Util.mix({
x: x,
y: y + titleGap + maxWidth + 13 + this.get('textOffset'),
text: text === 0 ? '0' : text
}, textStyle)
});
}
}; // the circles while slidable === false
_proto._renderUnslidable = function _renderUnslidable() {
var firstItemValue = this.get('firstItem').value;
var lastItemValue = this.get('lastItem').value;
if (firstItemValue > lastItemValue) {
var tmp = lastItemValue;
lastItemValue = firstItemValue;
firstItemValue = tmp;
}
var minText = this._formatItemValue(firstItemValue);
var maxText = this._formatItemValue(lastItemValue);
var minRadius = firstItemValue < MIN_SIZE ? MIN_SIZE : firstItemValue;
var maxRadius = lastItemValue > MAX_SIZE ? MAX_SIZE : lastItemValue;
if (minRadius > maxRadius) {
minRadius = MIN_SIZE;
maxRadius = MAX_SIZE;
}
if (this.get('layout') === 'vertical') {
this._addCircle(maxRadius, maxRadius, minRadius, minText, 2 * maxRadius); // min
this._addCircle(maxRadius, maxRadius * 2 + CIRCLE_GAP + minRadius, maxRadius, maxText, 2 * maxRadius); // max
} else {
this._addCircle(maxRadius, maxRadius, minRadius, minText, 2 * maxRadius); // min
this._addCircle(maxRadius * 2 + CIRCLE_GAP + minRadius, maxRadius, maxRadius, maxText, 2 * maxRadius); // max
}
};
_proto.activate = function activate(value) {
if (!this.get('slidable')) {
return;
}
_Continuous.prototype.activate.call(this, value);
};
return CircleSize;
}(Continuous);
module.exports = CircleSize;
/***/ }),
/* 254 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of the gradient color legend
* @author sima.zhang
*/
var Util = __webpack_require__(3);
var Continuous = __webpack_require__(63);
var Size =
/*#__PURE__*/
function (_Continuous) {
_inheritsLoose(Size, _Continuous);
function Size() {
return _Continuous.apply(this, arguments) || this;
}
var _proto = Size.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Continuous.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 类型
* @type {String}
*/
type: 'size-legend',
width: 100,
height: 200,
/**
* 不能滑动时圈的样式
* @type {ATTRS}
*/
_unslidableElementStyle: {
fill: '#4E7CCC',
fillOpacity: 1
},
/**
* 中间 bar 的前景颜色
* @type {ATTRS}
*/
frontMiddleBarStyle: {
fill: 'rgb(64, 141, 251)'
}
});
}; // render the slider shape
_proto._renderSliderShape = function _renderSliderShape() {
var slider = this.get('slider');
var backgroundElement = slider.get('backgroundElement');
var layout = this.get('layout');
var width = this.get('width');
var height = this.get('height'); // const x = minRadius;
var y = this.get('height') / 2;
var frontMiddleBarStyle = this.get('frontMiddleBarStyle'); // background of middle bar
var points = layout === 'vertical' ? [[0, 0], [width, 0], [width, height], [width - 4, height]] : [[0, y + height / 2], [0, y + height / 2 - 4], [width, y - height / 2], [width, y + height / 2]];
return this._addMiddleBar(backgroundElement, 'Polygon', Util.mix({
points: points
}, frontMiddleBarStyle));
}; // render the middle bar while slidable === false,
// there are no triggers for this situation
_proto._renderUnslidable = function _renderUnslidable() {
var layout = this.get('layout');
var width = this.get('width');
var height = this.get('height');
var frontMiddleBarStyle = this.get('frontMiddleBarStyle');
var points = layout === 'vertical' ? [[0, 0], [width, 0], [width, height], [width - 4, height]] : [[0, height], [0, height - 4], [width, 0], [width, height]];
var group = this.get('group');
var bgGroup = group.addGroup();
bgGroup.addShape('Polygon', {
attrs: Util.mix({
points: points
}, frontMiddleBarStyle)
});
var minText = this._formatItemValue(this.get('firstItem').value);
var maxText = this._formatItemValue(this.get('lastItem').value);
if (this.get('layout') === 'vertical') {
this._addText(width + 10, height - 3, minText); // min
this._addText(width + 10, 3, maxText); // max
} else {
this._addText(0, height, minText); // min
this._addText(width, height, maxText); // max
}
}; // add min and max text while slidable === false
_proto._addText = function _addText(x, y, text) {
var group = this.get('group');
var textGroup = group.addGroup();
var textStyle = this.get('textStyle');
var titleShape = this.get('titleShape');
var titleGap = this.get('titleGap');
if (titleShape) {
titleGap += titleShape.getBBox().height;
}
if (this.get('layout') === 'vertical') {
textGroup.addShape('text', {
attrs: Util.mix({
x: x + this.get('textOffset'),
y: y,
text: text === 0 ? '0' : text
}, textStyle)
});
} else {
y += titleGap + this.get('textOffset') - 20;
if (!titleShape) y += 10;
textGroup.addShape('text', {
attrs: Util.mix({
x: x,
y: y,
text: text === 0 ? '0' : text
}, textStyle)
});
}
};
return Size;
}(Continuous);
module.exports = Size;
/***/ }),
/* 255 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of slider
* @author sima.zhang
*/
var Util = __webpack_require__(3);
var DomUtil = Util.DomUtil;
var Group = Util.Group;
var Slider =
/*#__PURE__*/
function (_Group) {
_inheritsLoose(Slider, _Group);
function Slider() {
return _Group.apply(this, arguments) || this;
}
var _proto = Slider.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
/**
* 范围
* @type {Array}
*/
range: null,
/**
* 中滑块属性
* 透明的,用于用户交互
* @type {ATTRS}
*/
middleAttr: {
fill: '#fff',
fillOpacity: 0
},
/**
* 背景
* @type {G-Element}
*/
backgroundElement: null,
/**
* 下滑块
* @type {G-Element}
*/
minHandleElement: null,
/**
* 上滑块
* @type {G-Element}
*/
maxHandleElement: null,
/**
* 中块,
* 透明的,用于用户交互
* @type {G-Element}
*/
middleHandleElement: null,
/**
* 当前的激活的元素
* @type {G-Element}
*/
currentTarget: null,
/**
* 布局方式: horizontal,vertical
* @type {String}
*/
layout: 'vertical',
/**
* 宽
* @type {Number}
*/
width: null,
/**
* 高
* @type {Number}
*/
height: null,
/**
* 当前的PageX
* @type {Number}
*/
pageX: null,
/**
* 当前的PageY
* @type {Number}
*/
pageY: null
};
}; // arrange the zindex and cursors of each element
_proto._beforeRenderUI = function _beforeRenderUI() {
var layout = this.get('layout');
var backgroundElement = this.get('backgroundElement');
var minHandleElement = this.get('minHandleElement');
var maxHandleElement = this.get('maxHandleElement');
var middleHandleElement = this.addShape('rect', {
attrs: this.get('middleAttr')
});
var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize';
this.add([backgroundElement, minHandleElement, maxHandleElement]);
this.set('middleHandleElement', middleHandleElement);
backgroundElement.set('zIndex', 0);
middleHandleElement.set('zIndex', 1);
minHandleElement.set('zIndex', 2);
maxHandleElement.set('zIndex', 2);
middleHandleElement.attr('cursor', 'move');
minHandleElement.attr('cursor', trigerCursor);
maxHandleElement.attr('cursor', trigerCursor);
this.sort();
}; // rendering
_proto._renderUI = function _renderUI() {
if (this.get('layout') === 'horizontal') {
this._renderHorizontal();
} else {
this._renderVertical();
}
};
_proto._transform = function _transform(layout) {
var range = this.get('range');
var minRatio = range[0] / 100;
var maxRatio = range[1] / 100;
var width = this.get('width');
var height = this.get('height');
var minHandleElement = this.get('minHandleElement');
var maxHandleElement = this.get('maxHandleElement');
var middleHandleElement = this.get('middleHandleElement');
minHandleElement.resetMatrix();
maxHandleElement.resetMatrix();
if (layout === 'horizontal') {
middleHandleElement.attr({
x: width * minRatio,
y: 0,
width: (maxRatio - minRatio) * width,
height: height
});
minHandleElement.translate(minRatio * width, height);
maxHandleElement.translate(maxRatio * width, height);
} else {
middleHandleElement.attr({
x: 0,
y: height * (1 - maxRatio),
width: width,
height: (maxRatio - minRatio) * height
});
minHandleElement.translate(1, (1 - minRatio) * height);
maxHandleElement.translate(1, (1 - maxRatio) * height);
}
};
_proto._renderHorizontal = function _renderHorizontal() {
this._transform('horizontal');
};
_proto._renderVertical = function _renderVertical() {
this._transform('vertical');
};
_proto._bindUI = function _bindUI() {
this.on('mousedown', Util.wrapBehavior(this, '_onMouseDown'));
}; // if the target matches name
_proto._isElement = function _isElement(target, name) {
var element = this.get(name);
if (target === element) {
return true;
}
if (element.isGroup) {
var elementChildren = element.get('children');
return elementChildren.indexOf(target) > -1;
}
return false;
}; // get the result range after adding diff to range
// insure that the result out of the interval [0, 100]
_proto._getRange = function _getRange(diff, range) {
var rst = diff + range;
rst = rst > 100 ? 100 : rst;
rst = rst < 0 ? 0 : rst;
return rst;
};
_proto._updateStatus = function _updateStatus(dim, ev) {
var totalLength = dim === 'x' ? this.get('width') : this.get('height');
dim = Util.upperFirst(dim);
var range = this.get('range');
var page = this.get('page' + dim);
var currentTarget = this.get('currentTarget');
var rangeStash = this.get('rangeStash');
var layout = this.get('layout');
var sign = layout === 'vertical' ? -1 : 1;
var currentPage = ev['page' + dim]; // the distance of the mouse dragging
var diffPage = currentPage - page;
var diffRange = diffPage / totalLength * 100 * sign;
var diffStashRange; // the min and max trigger overlap, range[0] and range[1] change together
if (range[1] <= range[0]) {
if (this._isElement(currentTarget, 'minHandleElement') || this._isElement(currentTarget, 'maxHandleElement')) {
range[0] = this._getRange(diffRange, range[0]);
range[1] = this._getRange(diffRange, range[0]);
}
} else {
// user drags the min trigger
if (this._isElement(currentTarget, 'minHandleElement')) {
range[0] = this._getRange(diffRange, range[0]);
} // user drags the max trigger
if (this._isElement(currentTarget, 'maxHandleElement')) {
range[1] = this._getRange(diffRange, range[1]);
}
} // the user drags the middle bar
if (this._isElement(currentTarget, 'middleHandleElement')) {
// the diffrence between min and max trigger while mouse down
diffStashRange = rangeStash[1] - rangeStash[0];
range[0] = this._getRange(diffRange, range[0]); // keep the diffStashRange
range[1] = range[0] + diffStashRange;
if (range[1] > 100) {
range[1] = 100;
range[0] = range[1] - diffStashRange;
}
}
this.emit('sliderchange', {
range: range
});
this.set('page' + dim, currentPage);
this._renderUI();
this.get('canvas').draw(); // need delete
return;
}; // the listener of mouse down
_proto._onMouseDown = function _onMouseDown(ev) {
var currentTarget = ev.currentTarget;
var originEvent = ev.event;
var range = this.get('range');
originEvent.stopPropagation();
originEvent.preventDefault();
this.set('pageX', originEvent.pageX);
this.set('pageY', originEvent.pageY);
this.set('currentTarget', currentTarget); // stash the range
this.set('rangeStash', [range[0], range[1]]);
this._bindCanvasEvents();
};
_proto._bindCanvasEvents = function _bindCanvasEvents() {
var containerDOM = this.get('canvas').get('containerDOM'); // this.on('mousemove', Util.wrapBehavior(this, '_onCanvasMouseMove'));
this.onMouseMoveListener = DomUtil.addEventListener(containerDOM, 'mousemove', Util.wrapBehavior(this, '_onCanvasMouseMove'));
this.onMouseUpListener = DomUtil.addEventListener(containerDOM, 'mouseup', Util.wrapBehavior(this, '_onCanvasMouseUp'));
this.onMouseLeaveListener = DomUtil.addEventListener(containerDOM, 'mouseleave', Util.wrapBehavior(this, '_onCanvasMouseUp'));
}; // listener of mouse click and move = drag
_proto._onCanvasMouseMove = function _onCanvasMouseMove(ev) {
if (!this._mouseOutArea(ev)) {
var layout = this.get('layout');
if (layout === 'horizontal') {
this._updateStatus('x', ev);
} else {
this._updateStatus('y', ev);
}
}
}; // listener of mouse up
_proto._onCanvasMouseUp = function _onCanvasMouseUp() {
this._removeDocumentEvents();
}; // remove listeners
_proto._removeDocumentEvents = function _removeDocumentEvents() {
this.onMouseMoveListener.remove();
this.onMouseUpListener.remove();
}; // if the mouse is out of the area
_proto._mouseOutArea = function _mouseOutArea(ev) {
var el = this.get('canvas').get('el');
var el_bbox = el.getBoundingClientRect();
var parent = this.get('parent');
var bbox = parent.getBBox();
var left = parent.attr('matrix')[6];
var top = parent.attr('matrix')[7];
var right = left + bbox.width;
var bottom = top + bbox.height;
var mouseX = ev.clientX - el_bbox.x;
var mouseY = ev.clientY - el_bbox.y;
if (mouseX < left || mouseX > right || mouseY < top || mouseY > bottom) {
return true;
}
return false;
};
return Slider;
}(Group);
module.exports = Slider;
/***/ }),
/* 256 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var Tooltip = __webpack_require__(64);
var Util = __webpack_require__(3);
var DomUtil = Util.DomUtil;
var TooltipTheme = __webpack_require__(259);
var Crosshair = __webpack_require__(109);
var PositionMixin = __webpack_require__(111);
var MarkerGroupMixin = __webpack_require__(110);
var CONTAINER_CLASS = 'g2-tooltip';
var TITLE_CLASS = 'g2-tooltip-title';
var LIST_CLASS = 'g2-tooltip-list';
var MARKER_CLASS = 'g2-tooltip-marker';
var VALUE_CLASS = 'g2-tooltip-value';
var LIST_ITEM_CLASS = 'g2-tooltip-list-item';
function find(dom, cls) {
return dom.getElementsByClassName(cls)[0];
}
function mergeStyles(styles, cfg) {
Object.keys(styles).forEach(function (k) {
if (cfg[k]) {
styles[k] = Util.mix(styles[k], cfg[k]);
}
});
return styles;
}
var HtmlTooltip =
/*#__PURE__*/
function (_Tooltip) {
_inheritsLoose(HtmlTooltip, _Tooltip);
var _proto = HtmlTooltip.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Tooltip.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* tooltip 容器模板
* @type {String}
*/
containerTpl: ' ',
/**
* tooltip 列表项模板
* @type {String}
*/
itemTpl: '' + '' + '{name}{value}',
/**
* tooltip html内容
* @type {String}
*/
htmlContent: null,
/**
* tooltip 内容跟随鼠标移动
* @type {Boolean}
*/
follow: true,
/**
* 是否允许鼠标停留在 tooltip 上,默认不允许
* @type {Boolean}
*/
enterable: false
});
};
function HtmlTooltip(cfg) {
var _this;
_this = _Tooltip.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), PositionMixin);
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), MarkerGroupMixin);
var style = TooltipTheme;
_this.style = mergeStyles(style, cfg);
_this._init_();
if (_this.get('items')) {
_this.render();
} // crosshair
var crosshair = _this.get('crosshairs');
if (crosshair) {
var plot = crosshair.type === 'rect' ? _this.get('backPlot') : _this.get('frontPlot');
var crosshairGroup = new Crosshair(Util.mix({
plot: plot,
plotRange: _this.get('plotRange'),
canvas: _this.get('canvas')
}, _this.get('crosshairs')));
crosshairGroup.hide();
_this.set('crosshairGroup', crosshairGroup);
}
return _this;
}
_proto._init_ = function _init_() {
var self = this;
var containerTpl = self.get('containerTpl');
var outterNode = self.get('canvas').get('el').parentNode;
var container;
if (!this.get('htmlContent')) {
if (/^\#/.test(containerTpl)) {
// 如果传入 dom 节点的 id
var id = containerTpl.replace('#', '');
container = document.getElementById(id);
} else {
container = DomUtil.createDom(containerTpl);
DomUtil.modifyCSS(container, self.style[CONTAINER_CLASS]);
outterNode.appendChild(container);
outterNode.style.position = 'relative';
}
self.set('container', container);
}
};
_proto.render = function render() {
var self = this;
self.clear();
if (self.get('htmlContent')) {
var outterNode = self.get('canvas').get('el').parentNode;
var container = self._getHtmlContent();
outterNode.appendChild(container);
self.set('container', container);
} else {
self._renderTpl();
}
};
_proto._renderTpl = function _renderTpl() {
var self = this;
var showTitle = self.get('showTitle');
var titleContent = self.get('titleContent');
var container = self.get('container');
var titleDom = find(container, TITLE_CLASS);
var listDom = find(container, LIST_CLASS);
var items = self.get('items');
if (titleDom && showTitle) {
DomUtil.modifyCSS(titleDom, self.style[TITLE_CLASS]);
titleDom.innerHTML = titleContent;
}
if (listDom) {
DomUtil.modifyCSS(listDom, self.style[LIST_CLASS]);
Util.each(items, function (item, index) {
listDom.appendChild(self._addItem(item, index));
});
}
};
_proto.clear = function clear() {
var container = this.get('container');
if (this.get('htmlContent')) {
container && container.remove();
} else {
var titleDom = find(container, TITLE_CLASS);
var listDom = find(container, LIST_CLASS);
if (titleDom) {
titleDom.innerHTML = '';
}
if (listDom) {
listDom.innerHTML = '';
}
}
};
_proto.show = function show() {
var container = this.get('container');
container.style.visibility = 'visible';
container.style.display = 'block';
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.show();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.show();
_Tooltip.prototype.show.call(this);
this.get('canvas').draw();
};
_proto.hide = function hide() {
var container = this.get('container');
container.style.visibility = 'hidden';
container.style.display = 'none';
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.hide();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.hide();
_Tooltip.prototype.hide.call(this);
this.get('canvas').draw();
};
_proto.destroy = function destroy() {
var self = this;
var container = self.get('container');
var containerTpl = self.get('containerTpl');
if (container && !/^\#/.test(containerTpl)) {
container.parentNode.removeChild(container);
}
var crosshairGroup = this.get('crosshairGroup');
crosshairGroup && crosshairGroup.destroy();
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.remove();
_Tooltip.prototype.destroy.call(this);
};
_proto._addItem = function _addItem(item, index) {
var itemTpl = this.get('itemTpl'); // TODO: 有可能是个回调函数
var itemDiv = Util.substitute(itemTpl, Util.mix({
index: index
}, item));
var itemDOM = DomUtil.createDom(itemDiv);
DomUtil.modifyCSS(itemDOM, this.style[LIST_ITEM_CLASS]);
var markerDom = find(itemDOM, MARKER_CLASS);
if (markerDom) {
DomUtil.modifyCSS(markerDom, this.style[MARKER_CLASS]);
}
var valueDom = find(itemDOM, VALUE_CLASS);
if (valueDom) {
DomUtil.modifyCSS(valueDom, this.style[VALUE_CLASS]);
}
return itemDOM;
};
_proto._getHtmlContent = function _getHtmlContent() {
var htmlContent = this.get('htmlContent');
var title = this.get('titleContent');
var items = this.get('items');
var htmlString = htmlContent(title, items);
var ele = DomUtil.createDom(htmlString);
return ele;
};
_proto.setPosition = function setPosition(x, y, target) {
var container = this.get('container');
var outterNode = this.get('canvas').get('el');
var viewWidth = DomUtil.getWidth(outterNode);
var viewHeight = DomUtil.getHeight(outterNode);
var containerWidth = container.clientWidth;
var containerHeight = container.clientHeight;
var endx = x;
var endy = y;
var position;
var prePosition = this.get('prePosition') || {
x: 0,
y: 0
};
if (this.get('enterable')) {
y = y - container.clientHeight / 2;
position = [x, y];
if (prePosition && x - prePosition.x > 0) {
// 留 1px 防止鼠标点击事件无法在画布上触发
x -= container.clientWidth + 1;
} else {
x += 1;
}
} else if (this.get('position')) {
var _containerWidth = container.clientWidth;
var _containerHeight = container.clientHeight;
position = this._calcTooltipPosition(x, y, this.get('position'), _containerWidth, _containerHeight, target);
x = position[0];
y = position[1];
} else {
position = this._constraintPositionInBoundary(x, y, containerWidth, containerHeight, viewWidth, viewHeight);
x = position[0];
y = position[1];
}
if (this.get('inPlot')) {
// tooltip 必须限制在绘图区域内
var plotRange = this.get('plotRange');
position = this._constraintPositionInPlot(x, y, containerWidth, containerHeight, plotRange, this.get('enterable'));
x = position[0];
y = position[1];
}
var markerItems = this.get('markerItems');
if (!Util.isEmpty(markerItems)) {
endx = markerItems[0].x;
endy = markerItems[0].y;
}
this.set('prePosition', position); // 记录上次的位置
var follow = this.get('follow');
if (follow) {
container.style.left = x + 'px';
container.style.top = y + 'px';
}
var crosshairGroup = this.get('crosshairGroup');
if (crosshairGroup) {
var items = this.get('items');
crosshairGroup.setPosition(endx, endy, items);
}
_Tooltip.prototype.setPosition.call(this, x, y);
};
return HtmlTooltip;
}(Tooltip);
module.exports = HtmlTooltip;
/***/ }),
/* 257 */
/***/ (function(module, exports, __webpack_require__) {
var Tooltip = __webpack_require__(64);
Tooltip.Html = __webpack_require__(256);
Tooltip.Canvas = __webpack_require__(108);
Tooltip.Mini = __webpack_require__(258);
module.exports = Tooltip;
/***/ }),
/* 258 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(3);
var CanvasTooltip = __webpack_require__(108);
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY;
var DomUtil = Util.DomUtil;
var MatrixUtil = Util.MatrixUtil;
var MiniTooltip =
/*#__PURE__*/
function (_CanvasTooltip) {
_inheritsLoose(MiniTooltip, _CanvasTooltip);
function MiniTooltip() {
return _CanvasTooltip.apply(this, arguments) || this;
}
var _proto = MiniTooltip.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _CanvasTooltip.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* 默认背景板样式
* @type {Object}
*/
boardStyle: {
x: 0,
y: 0,
width: 0,
height: 0,
// fill: 'rgba(50, 50, 50, 1)',
radius: 3
},
/**
* 默认value样式
* @type {Object}
* */
valueStyle: {
x: 0,
y: 0,
text: '',
fontFamily: FONT_FAMILY,
fontSize: 12,
stroke: '#fff',
lineWidth: 2,
fill: 'black',
textBaseline: 'top',
textAlign: 'start'
},
/**
* 默认padding值
* @type {Object}
*/
padding: {
top: 5,
right: 5,
bottom: 0,
left: 5
},
triangleWidth: 10,
triangleHeight: 4
});
};
_proto._init_ = function _init_() {
var self = this;
var padding = self.get('padding');
var parent = self.get('frontPlot'); // container
var container = parent.addGroup();
self.set('container', container); // board
var board = container.addShape('rect', {
attrs: Util.mix({}, self.get('boardStyle'))
});
self.set('board', board); // triangleShpe
var triangleShape = container.addShape('path', {
attrs: {
fill: self.get('boardStyle').fill
}
});
self.set('triangleShape', triangleShape); // itemGroup
var itemGroup = container.addGroup();
itemGroup.move(padding.left, padding.top); // value
var valueShape = itemGroup.addShape('text', {
attrs: Util.mix({}, self.get('valueStyle'))
});
self.set('valueShape', valueShape);
};
_proto.render = function render() {
var self = this;
self.clear();
var board = self.get('board');
var valueShape = self.get('valueShape');
var padding = self.get('padding');
var item = self.get('items')[0];
if (valueShape) {
valueShape.attr('text', item.value);
} // update board based on bbox
var bbox = valueShape ? valueShape.getBBox() : {
width: 80,
height: 30
};
var width = padding.left + bbox.width + padding.right;
var height = padding.top + bbox.height + padding.bottom;
board.attr('width', width);
board.attr('height', height); // update triangle shape
self._centerTriangleShape();
};
_proto.clear = function clear() {
var valueShape = this.get('valueShape');
valueShape.attr('text', '');
};
_proto.setPosition = function setPosition(x, y, target) {
var self = this;
var container = self.get('container');
var plotRange = self.get('plotRange');
var bbox = container.getBBox();
var width = bbox.width;
var height = bbox.height;
x -= width / 2;
if (target && (target.name === 'point' || target.name === 'interval')) {
var targetY = target.getBBox().y;
y = targetY;
}
y -= height;
if (this.get('inPlot')) {
// constrain in plot
if (x < plotRange.tl.x) {
x = plotRange.tl.x;
self._leftTriangleShape();
} else if (x + width / 2 > plotRange.tr.x) {
x = plotRange.tr.x - width;
self._rightTriangleShape();
} else {
self._centerTriangleShape();
}
if (y < plotRange.tl.y) {
y = plotRange.tl.y;
} else if (y + height > plotRange.bl.y) {
y = plotRange.bl.y - height;
}
} else {
// constrain in dom
var outterNode = this.get('canvas').get('el');
var viewWidth = DomUtil.getWidth(outterNode);
var viewHeight = DomUtil.getHeight(outterNode);
if (x < 0) {
x = 0;
self._leftTriangleShape();
} else if (x + width / 2 > viewWidth) {
x = viewWidth - width;
self._rightTriangleShape();
} else {
self._centerTriangleShape();
}
if (y < 0) {
y = 0;
} else if (y + height > viewHeight) {
y = viewHeight - height;
}
}
var ulMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];
var mat = MatrixUtil.transform(ulMatrix, [['t', x, y]]);
container.stopAnimate();
container.animate({
matrix: mat
}, this.get('animationDuration'));
};
_proto._centerTriangleShape = function _centerTriangleShape() {
var triangle = this.get('triangleShape');
var width = this.get('triangleWidth');
var height = this.get('triangleHeight');
var boardBBox = this.get('board').getBBox();
var boardWidth = boardBBox.width;
var boardHeight = boardBBox.height;
var pathArray = [['M', 0, 0], ['L', width, 0], ['L', width / 2, height], ['L', 0, 0], ['Z']];
triangle.attr('path', pathArray);
triangle.move(boardWidth / 2 - width / 2, boardHeight - 1);
};
_proto._leftTriangleShape = function _leftTriangleShape() {
var triangle = this.get('triangleShape');
var width = this.get('triangleWidth');
var height = this.get('triangleHeight');
var boardBBox = this.get('board').getBBox();
var boardHeight = boardBBox.height;
var pathArray = [['M', 0, 0], ['L', width, 0], ['L', 0, height + 3], ['L', 0, 0], ['Z']];
triangle.attr('path', pathArray);
triangle.move(0, boardHeight - 3);
};
_proto._rightTriangleShape = function _rightTriangleShape() {
var triangle = this.get('triangleShape');
var width = this.get('triangleWidth');
var height = this.get('triangleHeight');
var boardBBox = this.get('board').getBBox();
var boardWidth = boardBBox.width;
var boardHeight = boardBBox.height;
var pathArray = [['M', 0, 0], ['L', width, 0], ['L', width, height + 4], ['L', 0, 0], ['Z']];
triangle.attr('path', pathArray);
triangle.move(boardWidth - width - 1, boardHeight - 4);
};
return MiniTooltip;
}(CanvasTooltip);
module.exports = MiniTooltip;
/***/ }),
/* 259 */
/***/ (function(module, exports, __webpack_require__) {
var _TooltipTheme;
var _require = __webpack_require__(18),
FONT_FAMILY = _require.FONT_FAMILY; // tooltip 相关 dom 的 css 类名
var TOOLTIP_CONTAINER_CLASS = 'g2-tooltip';
var TOOLTIP_TITLE_CLASS = 'g2-tooltip-title';
var TOOLTIP_LIST_CLASS = 'g2-tooltip-list';
var TOOLTIP_LIST_ITEM_CLASS = 'g2-tooltip-list-item';
var TOOLTIP_MARKER_CLASS = 'g2-tooltip-marker';
var TOOLTIP_VALUE_CLASS = 'g2-tooltip-value';
var TooltipTheme = (_TooltipTheme = {
crosshairs: false,
offset: 15
}, _TooltipTheme["" + TOOLTIP_CONTAINER_CLASS] = {
position: 'absolute',
visibility: 'hidden',
// @2018-07-25 by blue.lb 这里去掉浮动,火狐上存在样式错位
// whiteSpace: 'nowrap',
zIndex: 8,
transition: 'visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)',
backgroundColor: 'rgba(255, 255, 255, 0.9)',
boxShadow: '0px 0px 10px #aeaeae',
borderRadius: '3px',
color: 'rgb(87, 87, 87)',
fontSize: '12px',
fontFamily: FONT_FAMILY,
lineHeight: '20px',
padding: '10px 10px 6px 10px'
}, _TooltipTheme["" + TOOLTIP_TITLE_CLASS] = {
marginBottom: '4px'
}, _TooltipTheme["" + TOOLTIP_LIST_CLASS] = {
margin: 0,
listStyleType: 'none',
padding: 0
}, _TooltipTheme["" + TOOLTIP_LIST_ITEM_CLASS] = {
marginBottom: '4px'
}, _TooltipTheme["" + TOOLTIP_MARKER_CLASS] = {
width: '5px',
height: '5px',
borderRadius: '50%',
display: 'inline-block',
marginRight: '8px'
}, _TooltipTheme["" + TOOLTIP_VALUE_CLASS] = {
display: 'inline-block',
float: 'right',
marginLeft: '30px'
}, _TooltipTheme);
module.exports = TooltipTheme;
/***/ }),
/* 260 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/**
* @fileOverview the class of Cartesian Coordinate
* @author sima.zhang
*/
var mix = __webpack_require__(10);
var Base = __webpack_require__(42);
var Cartesian =
/*#__PURE__*/
function (_Base) {
_inherits(Cartesian, _Base);
_createClass(Cartesian, [{
key: "getDefaultCfg",
/**
* @override
*/
value: function getDefaultCfg() {
var cfg = _get(_getPrototypeOf(Cartesian.prototype), "getDefaultCfg", this).call(this);
return mix({}, cfg, {
start: {
x: 0,
y: 0
},
end: {
x: 0,
y: 0
},
type: 'cartesian',
isRect: true
});
}
}]);
function Cartesian(cfg) {
var _this;
_classCallCheck(this, Cartesian);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Cartesian).call(this, cfg));
_this._init();
return _this;
}
_createClass(Cartesian, [{
key: "_init",
value: function _init() {
var start = this.start,
end = this.end;
var x = {
start: start.x,
end: end.x
};
var y = {
start: start.y,
end: end.y
};
this.x = x;
this.y = y;
}
}, {
key: "convertPoint",
value: function convertPoint(point) {
var x;
var y;
if (this.isTransposed) {
x = point.y;
y = point.x;
} else {
x = point.x;
y = point.y;
}
return {
x: this.convertDim(x, 'x'),
y: this.convertDim(y, 'y')
};
}
}, {
key: "invertPoint",
value: function invertPoint(point) {
var x = this.invertDim(point.x, 'x');
var y = this.invertDim(point.y, 'y');
if (this.isTransposed) {
return {
x: y,
y: x
};
}
return {
x: x,
y: y
};
}
}]);
return Cartesian;
}(Base);
module.exports = Cartesian;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jYXJ0ZXNpYW4uanMiXSwibmFtZXMiOlsibWl4IiwicmVxdWlyZSIsIkJhc2UiLCJDYXJ0ZXNpYW4iLCJjZmciLCJzdGFydCIsIngiLCJ5IiwiZW5kIiwidHlwZSIsImlzUmVjdCIsIl9pbml0IiwicG9pbnQiLCJpc1RyYW5zcG9zZWQiLCJjb252ZXJ0RGltIiwiaW52ZXJ0RGltIiwibW9kdWxlIiwiZXhwb3J0cyJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7Ozs7QUFJQSxJQUFNQSxHQUFHLEdBQUdDLE9BQU8sQ0FBQyxvQkFBRCxDQUFuQjs7QUFDQSxJQUFNQyxJQUFJLEdBQUdELE9BQU8sQ0FBQyxRQUFELENBQXBCOztJQUVNRSxTOzs7Ozs7OztBQUVKOzs7b0NBR2dCO0FBQ2QsVUFBTUMsR0FBRywrRUFBVDs7QUFDQSxhQUFPSixHQUFHLENBQUMsRUFBRCxFQUFLSSxHQUFMLEVBQVU7QUFDbEJDLFFBQUFBLEtBQUssRUFBRTtBQUNMQyxVQUFBQSxDQUFDLEVBQUUsQ0FERTtBQUVMQyxVQUFBQSxDQUFDLEVBQUU7QUFGRSxTQURXO0FBS2xCQyxRQUFBQSxHQUFHLEVBQUU7QUFDSEYsVUFBQUEsQ0FBQyxFQUFFLENBREE7QUFFSEMsVUFBQUEsQ0FBQyxFQUFFO0FBRkEsU0FMYTtBQVNsQkUsUUFBQUEsSUFBSSxFQUFFLFdBVFk7QUFVbEJDLFFBQUFBLE1BQU0sRUFBRTtBQVZVLE9BQVYsQ0FBVjtBQVlEOzs7QUFFRCxxQkFBWU4sR0FBWixFQUFpQjtBQUFBOztBQUFBOztBQUNmLG1GQUFNQSxHQUFOOztBQUNBLFVBQUtPLEtBQUw7O0FBRmU7QUFHaEI7Ozs7NEJBRU87QUFBQSxVQUNFTixLQURGLEdBQ2lCLElBRGpCLENBQ0VBLEtBREY7QUFBQSxVQUNTRyxHQURULEdBQ2lCLElBRGpCLENBQ1NBLEdBRFQ7QUFFTixVQUFNRixDQUFDLEdBQUc7QUFDUkQsUUFBQUEsS0FBSyxFQUFFQSxLQUFLLENBQUNDLENBREw7QUFFUkUsUUFBQUEsR0FBRyxFQUFFQSxHQUFHLENBQUNGO0FBRkQsT0FBVjtBQUlBLFVBQU1DLENBQUMsR0FBRztBQUNSRixRQUFBQSxLQUFLLEVBQUVBLEtBQUssQ0FBQ0UsQ0FETDtBQUVSQyxRQUFBQSxHQUFHLEVBQUVBLEdBQUcsQ0FBQ0Q7QUFGRCxPQUFWO0FBSUEsV0FBS0QsQ0FBTCxHQUFTQSxDQUFUO0FBQ0EsV0FBS0MsQ0FBTCxHQUFTQSxDQUFUO0FBQ0Q7OztpQ0FFWUssSyxFQUFPO0FBQ2xCLFVBQUlOLENBQUo7QUFDQSxVQUFJQyxDQUFKOztBQUNBLFVBQUksS0FBS00sWUFBVCxFQUF1QjtBQUNyQlAsUUFBQUEsQ0FBQyxHQUFHTSxLQUFLLENBQUNMLENBQVY7QUFDQUEsUUFBQUEsQ0FBQyxHQUFHSyxLQUFLLENBQUNOLENBQVY7QUFDRCxPQUhELE1BR087QUFDTEEsUUFBQUEsQ0FBQyxHQUFHTSxLQUFLLENBQUNOLENBQVY7QUFDQUMsUUFBQUEsQ0FBQyxHQUFHSyxLQUFLLENBQUNMLENBQVY7QUFDRDs7QUFFRCxhQUFPO0FBQ0xELFFBQUFBLENBQUMsRUFBRSxLQUFLUSxVQUFMLENBQWdCUixDQUFoQixFQUFtQixHQUFuQixDQURFO0FBRUxDLFFBQUFBLENBQUMsRUFBRSxLQUFLTyxVQUFMLENBQWdCUCxDQUFoQixFQUFtQixHQUFuQjtBQUZFLE9BQVA7QUFJRDs7O2dDQUVXSyxLLEVBQU87QUFDakIsVUFBTU4sQ0FBQyxHQUFHLEtBQUtTLFNBQUwsQ0FBZUgsS0FBSyxDQUFDTixDQUFyQixFQUF3QixHQUF4QixDQUFWO0FBQ0EsVUFBTUMsQ0FBQyxHQUFHLEtBQUtRLFNBQUwsQ0FBZUgsS0FBSyxDQUFDTCxDQUFyQixFQUF3QixHQUF4QixDQUFWOztBQUVBLFVBQUksS0FBS00sWUFBVCxFQUF1QjtBQUNyQixlQUFPO0FBQ0xQLFVBQUFBLENBQUMsRUFBRUMsQ0FERTtBQUVMQSxVQUFBQSxDQUFDLEVBQUVEO0FBRkUsU0FBUDtBQUlEOztBQUVELGFBQU87QUFDTEEsUUFBQUEsQ0FBQyxFQUFEQSxDQURLO0FBRUxDLFFBQUFBLENBQUMsRUFBREE7QUFGSyxPQUFQO0FBSUQ7Ozs7RUF4RXFCTCxJOztBQTJFeEJjLE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQmQsU0FBakIiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEBmaWxlT3ZlcnZpZXcgdGhlIGNsYXNzIG9mIENhcnRlc2lhbiBDb29yZGluYXRlXG4gKiBAYXV0aG9yIHNpbWEuemhhbmdcbiAqL1xuY29uc3QgbWl4ID0gcmVxdWlyZSgnQGFudHYvdXRpbC9saWIvbWl4Jyk7XG5jb25zdCBCYXNlID0gcmVxdWlyZSgnLi9iYXNlJyk7XG5cbmNsYXNzIENhcnRlc2lhbiBleHRlbmRzIEJhc2Uge1xuXG4gIC8qKlxuICAgKiBAb3ZlcnJpZGVcbiAgICovXG4gIGdldERlZmF1bHRDZmcoKSB7XG4gICAgY29uc3QgY2ZnID0gc3VwZXIuZ2V0RGVmYXVsdENmZygpO1xuICAgIHJldHVybiBtaXgoe30sIGNmZywge1xuICAgICAgc3RhcnQ6IHtcbiAgICAgICAgeDogMCxcbiAgICAgICAgeTogMFxuICAgICAgfSxcbiAgICAgIGVuZDoge1xuICAgICAgICB4OiAwLFxuICAgICAgICB5OiAwXG4gICAgICB9LFxuICAgICAgdHlwZTogJ2NhcnRlc2lhbicsXG4gICAgICBpc1JlY3Q6IHRydWVcbiAgICB9KTtcbiAgfVxuXG4gIGNvbnN0cnVjdG9yKGNmZykge1xuICAgIHN1cGVyKGNmZyk7XG4gICAgdGhpcy5faW5pdCgpO1xuICB9XG5cbiAgX2luaXQoKSB7XG4gICAgY29uc3QgeyBzdGFydCwgZW5kIH0gPSB0aGlzO1xuICAgIGNvbnN0IHggPSB7XG4gICAgICBzdGFydDogc3RhcnQueCxcbiAgICAgIGVuZDogZW5kLnhcbiAgICB9O1xuICAgIGNvbnN0IHkgPSB7XG4gICAgICBzdGFydDogc3RhcnQueSxcbiAgICAgIGVuZDogZW5kLnlcbiAgICB9O1xuICAgIHRoaXMueCA9IHg7XG4gICAgdGhpcy55ID0geTtcbiAgfVxuXG4gIGNvbnZlcnRQb2ludChwb2ludCkge1xuICAgIGxldCB4O1xuICAgIGxldCB5O1xuICAgIGlmICh0aGlzLmlzVHJhbnNwb3NlZCkge1xuICAgICAgeCA9IHBvaW50Lnk7XG4gICAgICB5ID0gcG9pbnQueDtcbiAgICB9IGVsc2Uge1xuICAgICAgeCA9IHBvaW50Lng7XG4gICAgICB5ID0gcG9pbnQueTtcbiAgICB9XG5cbiAgICByZXR1cm4ge1xuICAgICAgeDogdGhpcy5jb252ZXJ0RGltKHgsICd4JyksXG4gICAgICB5OiB0aGlzLmNvbnZlcnREaW0oeSwgJ3knKVxuICAgIH07XG4gIH1cblxuICBpbnZlcnRQb2ludChwb2ludCkge1xuICAgIGNvbnN0IHggPSB0aGlzLmludmVydERpbShwb2ludC54LCAneCcpO1xuICAgIGNvbnN0IHkgPSB0aGlzLmludmVydERpbShwb2ludC55LCAneScpO1xuXG4gICAgaWYgKHRoaXMuaXNUcmFuc3Bvc2VkKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICB4OiB5LFxuICAgICAgICB5OiB4XG4gICAgICB9O1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICB4LFxuICAgICAgeVxuICAgIH07XG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSBDYXJ0ZXNpYW47XG4iXX0=
/***/ }),
/* 261 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/**
* @fileOverview the class of Helix Coordinate
* @author sima.zhang
*/
var MatrixUtil = __webpack_require__(52);
var isNumberEqual = __webpack_require__(51);
var mix = __webpack_require__(10);
var Base = __webpack_require__(42);
var vec2 = MatrixUtil.vec2;
var Helix =
/*#__PURE__*/
function (_Base) {
_inherits(Helix, _Base);
_createClass(Helix, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
var cfg = _get(_getPrototypeOf(Helix.prototype), "getDefaultCfg", this).call(this);
return mix({}, cfg, {
startAngle: 1.25 * Math.PI,
endAngle: 7.25 * Math.PI,
innerRadius: 0,
type: 'helix',
isHelix: true
});
}
}]);
function Helix(cfg) {
var _this;
_classCallCheck(this, Helix);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Helix).call(this, cfg));
_this._init();
return _this;
}
_createClass(Helix, [{
key: "_init",
value: function _init() {
var width = this.width;
var height = this.height;
var radius = this.radius;
var innerRadius = this.innerRadius;
var startAngle = this.startAngle;
var endAngle = this.endAngle;
var index = (endAngle - startAngle) / (2 * Math.PI) + 1; // 螺线圈数
var maxRadius = Math.min(width, height) / 2;
if (radius && radius >= 0 && radius <= 1) {
maxRadius = maxRadius * radius;
}
var d = Math.floor(maxRadius * (1 - innerRadius) / index);
var a = d / (Math.PI * 2); // 螺线系数
var x = {
start: startAngle,
end: endAngle
};
var y = {
start: innerRadius * maxRadius,
end: innerRadius * maxRadius + d * 0.99
};
this.a = a;
this.d = d;
this.x = x;
this.y = y;
}
}, {
key: "getCenter",
value: function getCenter() {
return this.center;
}
/**
* 将百分比数据变成屏幕坐标
* @param {Object} point 归一化的点坐标
* @return {Object} 返回对应的屏幕坐标
*/
}, {
key: "convertPoint",
value: function convertPoint(point) {
var a = this.a;
var center = this.center;
var x;
var y;
if (this.isTransposed) {
x = point.y;
y = point.x;
} else {
x = point.x;
y = point.y;
}
var thi = this.convertDim(x, 'x');
var r = a * thi;
var newY = this.convertDim(y, 'y');
return {
x: center.x + Math.cos(thi) * (r + newY),
y: center.y + Math.sin(thi) * (r + newY)
};
}
/**
* 将屏幕坐标点还原成百分比数据
* @param {Object} point 屏幕坐标
* @return {Object} 返回对应的归一化后的数据
*/
}, {
key: "invertPoint",
value: function invertPoint(point) {
var center = this.center;
var a = this.a;
var d = this.d + this.y.start;
var v = vec2.subtract([], [point.x, point.y], [center.x, center.y]);
var thi = vec2.angleTo(v, [1, 0], true);
var rMin = thi * a; // 坐标与原点的连线在第一圈上的交点,最小r值
if (vec2.length(v) < rMin) {
// 坐标与原点的连线不可能小于最小r值,但不排除因小数计算产生的略小于rMin的情况
rMin = vec2.length(v);
}
var index = Math.floor((vec2.length(v) - rMin) / d); // 当前点位于第index圈
thi = 2 * index * Math.PI + thi;
var r = a * thi;
var newY = vec2.length(v) - r;
newY = isNumberEqual(newY, 0) ? 0 : newY;
var x = this.invertDim(thi, 'x');
var y = this.invertDim(newY, 'y');
x = isNumberEqual(x, 0) ? 0 : x;
y = isNumberEqual(y, 0) ? 0 : y;
var rst = {};
rst.x = this.isTransposed ? y : x;
rst.y = this.isTransposed ? x : y;
return rst;
}
}]);
return Helix;
}(Base);
module.exports = Helix;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9oZWxpeC5qcyJdLCJuYW1lcyI6WyJNYXRyaXhVdGlsIiwicmVxdWlyZSIsImlzTnVtYmVyRXF1YWwiLCJtaXgiLCJCYXNlIiwidmVjMiIsIkhlbGl4IiwiY2ZnIiwic3RhcnRBbmdsZSIsIk1hdGgiLCJQSSIsImVuZEFuZ2xlIiwiaW5uZXJSYWRpdXMiLCJ0eXBlIiwiaXNIZWxpeCIsIl9pbml0Iiwid2lkdGgiLCJoZWlnaHQiLCJyYWRpdXMiLCJpbmRleCIsIm1heFJhZGl1cyIsIm1pbiIsImQiLCJmbG9vciIsImEiLCJ4Iiwic3RhcnQiLCJlbmQiLCJ5IiwiY2VudGVyIiwicG9pbnQiLCJpc1RyYW5zcG9zZWQiLCJ0aGkiLCJjb252ZXJ0RGltIiwiciIsIm5ld1kiLCJjb3MiLCJzaW4iLCJ2Iiwic3VidHJhY3QiLCJhbmdsZVRvIiwick1pbiIsImxlbmd0aCIsImludmVydERpbSIsInJzdCIsIm1vZHVsZSIsImV4cG9ydHMiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBOzs7O0FBSUEsSUFBTUEsVUFBVSxHQUFHQyxPQUFPLENBQUMsd0JBQUQsQ0FBMUI7O0FBQ0EsSUFBTUMsYUFBYSxHQUFHRCxPQUFPLENBQUMscUNBQUQsQ0FBN0I7O0FBQ0EsSUFBTUUsR0FBRyxHQUFHRixPQUFPLENBQUMsb0JBQUQsQ0FBbkI7O0FBQ0EsSUFBTUcsSUFBSSxHQUFHSCxPQUFPLENBQUMsUUFBRCxDQUFwQjs7QUFFQSxJQUFNSSxJQUFJLEdBQUdMLFVBQVUsQ0FBQ0ssSUFBeEI7O0lBRU1DLEs7Ozs7Ozs7b0NBRVk7QUFDZCxVQUFNQyxHQUFHLDJFQUFUOztBQUNBLGFBQU9KLEdBQUcsQ0FBQyxFQUFELEVBQUtJLEdBQUwsRUFBVTtBQUNsQkMsUUFBQUEsVUFBVSxFQUFFLE9BQU9DLElBQUksQ0FBQ0MsRUFETjtBQUVsQkMsUUFBQUEsUUFBUSxFQUFFLE9BQU9GLElBQUksQ0FBQ0MsRUFGSjtBQUdsQkUsUUFBQUEsV0FBVyxFQUFFLENBSEs7QUFJbEJDLFFBQUFBLElBQUksRUFBRSxPQUpZO0FBS2xCQyxRQUFBQSxPQUFPLEVBQUU7QUFMUyxPQUFWLENBQVY7QUFPRDs7O0FBRUQsaUJBQVlQLEdBQVosRUFBaUI7QUFBQTs7QUFBQTs7QUFDZiwrRUFBTUEsR0FBTjs7QUFDQSxVQUFLUSxLQUFMOztBQUZlO0FBR2hCOzs7OzRCQUVPO0FBQ04sVUFBTUMsS0FBSyxHQUFHLEtBQUtBLEtBQW5CO0FBQ0EsVUFBTUMsTUFBTSxHQUFHLEtBQUtBLE1BQXBCO0FBQ0EsVUFBTUMsTUFBTSxHQUFHLEtBQUtBLE1BQXBCO0FBQ0EsVUFBTU4sV0FBVyxHQUFHLEtBQUtBLFdBQXpCO0FBQ0EsVUFBTUosVUFBVSxHQUFHLEtBQUtBLFVBQXhCO0FBQ0EsVUFBTUcsUUFBUSxHQUFHLEtBQUtBLFFBQXRCO0FBRUEsVUFBTVEsS0FBSyxHQUFHLENBQUNSLFFBQVEsR0FBR0gsVUFBWixLQUEyQixJQUFJQyxJQUFJLENBQUNDLEVBQXBDLElBQTBDLENBQXhELENBUk0sQ0FRcUQ7O0FBQzNELFVBQUlVLFNBQVMsR0FBR1gsSUFBSSxDQUFDWSxHQUFMLENBQVNMLEtBQVQsRUFBZ0JDLE1BQWhCLElBQTBCLENBQTFDOztBQUNBLFVBQUlDLE1BQU0sSUFBSUEsTUFBTSxJQUFJLENBQXBCLElBQXlCQSxNQUFNLElBQUksQ0FBdkMsRUFBMEM7QUFDeENFLFFBQUFBLFNBQVMsR0FBR0EsU0FBUyxHQUFHRixNQUF4QjtBQUNEOztBQUVELFVBQU1JLENBQUMsR0FBR2IsSUFBSSxDQUFDYyxLQUFMLENBQVdILFNBQVMsSUFBSSxJQUFJUixXQUFSLENBQVQsR0FBZ0NPLEtBQTNDLENBQVY7QUFDQSxVQUFNSyxDQUFDLEdBQUdGLENBQUMsSUFBSWIsSUFBSSxDQUFDQyxFQUFMLEdBQVUsQ0FBZCxDQUFYLENBZk0sQ0Flc0I7O0FBRTVCLFVBQU1lLENBQUMsR0FBRztBQUNSQyxRQUFBQSxLQUFLLEVBQUVsQixVQURDO0FBRVJtQixRQUFBQSxHQUFHLEVBQUVoQjtBQUZHLE9BQVY7QUFJQSxVQUFNaUIsQ0FBQyxHQUFHO0FBQ1JGLFFBQUFBLEtBQUssRUFBRWQsV0FBVyxHQUFHUSxTQURiO0FBRVJPLFFBQUFBLEdBQUcsRUFBRWYsV0FBVyxHQUFHUSxTQUFkLEdBQTBCRSxDQUFDLEdBQUc7QUFGM0IsT0FBVjtBQUtBLFdBQUtFLENBQUwsR0FBU0EsQ0FBVDtBQUNBLFdBQUtGLENBQUwsR0FBU0EsQ0FBVDtBQUNBLFdBQUtHLENBQUwsR0FBU0EsQ0FBVDtBQUNBLFdBQUtHLENBQUwsR0FBU0EsQ0FBVDtBQUNEOzs7Z0NBRVc7QUFDVixhQUFPLEtBQUtDLE1BQVo7QUFDRDtBQUVEOzs7Ozs7OztpQ0FLYUMsSyxFQUFPO0FBQ2xCLFVBQU1OLENBQUMsR0FBRyxLQUFLQSxDQUFmO0FBQ0EsVUFBTUssTUFBTSxHQUFHLEtBQUtBLE1BQXBCO0FBQ0EsVUFBSUosQ0FBSjtBQUNBLFVBQUlHLENBQUo7O0FBRUEsVUFBSSxLQUFLRyxZQUFULEVBQXVCO0FBQ3JCTixRQUFBQSxDQUFDLEdBQUdLLEtBQUssQ0FBQ0YsQ0FBVjtBQUNBQSxRQUFBQSxDQUFDLEdBQUdFLEtBQUssQ0FBQ0wsQ0FBVjtBQUNELE9BSEQsTUFHTztBQUNMQSxRQUFBQSxDQUFDLEdBQUdLLEtBQUssQ0FBQ0wsQ0FBVjtBQUNBRyxRQUFBQSxDQUFDLEdBQUdFLEtBQUssQ0FBQ0YsQ0FBVjtBQUNEOztBQUVELFVBQU1JLEdBQUcsR0FBRyxLQUFLQyxVQUFMLENBQWdCUixDQUFoQixFQUFtQixHQUFuQixDQUFaO0FBQ0EsVUFBTVMsQ0FBQyxHQUFHVixDQUFDLEdBQUdRLEdBQWQ7QUFDQSxVQUFNRyxJQUFJLEdBQUcsS0FBS0YsVUFBTCxDQUFnQkwsQ0FBaEIsRUFBbUIsR0FBbkIsQ0FBYjtBQUVBLGFBQU87QUFDTEgsUUFBQUEsQ0FBQyxFQUFFSSxNQUFNLENBQUNKLENBQVAsR0FBV2hCLElBQUksQ0FBQzJCLEdBQUwsQ0FBU0osR0FBVCxLQUFpQkUsQ0FBQyxHQUFHQyxJQUFyQixDQURUO0FBRUxQLFFBQUFBLENBQUMsRUFBRUMsTUFBTSxDQUFDRCxDQUFQLEdBQVduQixJQUFJLENBQUM0QixHQUFMLENBQVNMLEdBQVQsS0FBaUJFLENBQUMsR0FBR0MsSUFBckI7QUFGVCxPQUFQO0FBSUQ7QUFFRDs7Ozs7Ozs7Z0NBS1lMLEssRUFBTztBQUNqQixVQUFNRCxNQUFNLEdBQUcsS0FBS0EsTUFBcEI7QUFDQSxVQUFNTCxDQUFDLEdBQUcsS0FBS0EsQ0FBZjtBQUNBLFVBQU1GLENBQUMsR0FBRyxLQUFLQSxDQUFMLEdBQVMsS0FBS00sQ0FBTCxDQUFPRixLQUExQjtBQUNBLFVBQU1ZLENBQUMsR0FBR2pDLElBQUksQ0FBQ2tDLFFBQUwsQ0FBYyxFQUFkLEVBQWtCLENBQUVULEtBQUssQ0FBQ0wsQ0FBUixFQUFXSyxLQUFLLENBQUNGLENBQWpCLENBQWxCLEVBQXdDLENBQUVDLE1BQU0sQ0FBQ0osQ0FBVCxFQUFZSSxNQUFNLENBQUNELENBQW5CLENBQXhDLENBQVY7QUFDQSxVQUFJSSxHQUFHLEdBQUczQixJQUFJLENBQUNtQyxPQUFMLENBQWFGLENBQWIsRUFBZ0IsQ0FBRSxDQUFGLEVBQUssQ0FBTCxDQUFoQixFQUEwQixJQUExQixDQUFWO0FBQ0EsVUFBSUcsSUFBSSxHQUFHVCxHQUFHLEdBQUdSLENBQWpCLENBTmlCLENBTUc7O0FBRXBCLFVBQUluQixJQUFJLENBQUNxQyxNQUFMLENBQVlKLENBQVosSUFBaUJHLElBQXJCLEVBQTJCO0FBQUc7QUFDNUJBLFFBQUFBLElBQUksR0FBR3BDLElBQUksQ0FBQ3FDLE1BQUwsQ0FBWUosQ0FBWixDQUFQO0FBQ0Q7O0FBRUQsVUFBTW5CLEtBQUssR0FBR1YsSUFBSSxDQUFDYyxLQUFMLENBQVcsQ0FBQ2xCLElBQUksQ0FBQ3FDLE1BQUwsQ0FBWUosQ0FBWixJQUFpQkcsSUFBbEIsSUFBMEJuQixDQUFyQyxDQUFkLENBWmlCLENBWXNDOztBQUN2RFUsTUFBQUEsR0FBRyxHQUFHLElBQUliLEtBQUosR0FBWVYsSUFBSSxDQUFDQyxFQUFqQixHQUFzQnNCLEdBQTVCO0FBQ0EsVUFBTUUsQ0FBQyxHQUFHVixDQUFDLEdBQUdRLEdBQWQ7QUFDQSxVQUFJRyxJQUFJLEdBQUc5QixJQUFJLENBQUNxQyxNQUFMLENBQVlKLENBQVosSUFBaUJKLENBQTVCO0FBQ0FDLE1BQUFBLElBQUksR0FBR2pDLGFBQWEsQ0FBQ2lDLElBQUQsRUFBTyxDQUFQLENBQWIsR0FBeUIsQ0FBekIsR0FBNkJBLElBQXBDO0FBRUEsVUFBSVYsQ0FBQyxHQUFHLEtBQUtrQixTQUFMLENBQWVYLEdBQWYsRUFBb0IsR0FBcEIsQ0FBUjtBQUNBLFVBQUlKLENBQUMsR0FBRyxLQUFLZSxTQUFMLENBQWVSLElBQWYsRUFBcUIsR0FBckIsQ0FBUjtBQUNBVixNQUFBQSxDQUFDLEdBQUd2QixhQUFhLENBQUN1QixDQUFELEVBQUksQ0FBSixDQUFiLEdBQXNCLENBQXRCLEdBQTBCQSxDQUE5QjtBQUNBRyxNQUFBQSxDQUFDLEdBQUcxQixhQUFhLENBQUMwQixDQUFELEVBQUksQ0FBSixDQUFiLEdBQXNCLENBQXRCLEdBQTBCQSxDQUE5QjtBQUVBLFVBQU1nQixHQUFHLEdBQUcsRUFBWjtBQUNBQSxNQUFBQSxHQUFHLENBQUNuQixDQUFKLEdBQVEsS0FBS00sWUFBTCxHQUFvQkgsQ0FBcEIsR0FBd0JILENBQWhDO0FBQ0FtQixNQUFBQSxHQUFHLENBQUNoQixDQUFKLEdBQVEsS0FBS0csWUFBTCxHQUFvQk4sQ0FBcEIsR0FBd0JHLENBQWhDO0FBQ0EsYUFBT2dCLEdBQVA7QUFDRDs7OztFQW5IaUJ4QyxJOztBQXNIcEJ5QyxNQUFNLENBQUNDLE9BQVAsR0FBaUJ4QyxLQUFqQiIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGZpbGVPdmVydmlldyB0aGUgY2xhc3Mgb2YgSGVsaXggQ29vcmRpbmF0ZVxuICogQGF1dGhvciBzaW1hLnpoYW5nXG4gKi9cbmNvbnN0IE1hdHJpeFV0aWwgPSByZXF1aXJlKCdAYW50di91dGlsL2xpYi9tYXRyaXgvJyk7XG5jb25zdCBpc051bWJlckVxdWFsID0gcmVxdWlyZSgnQGFudHYvdXRpbC9saWIvbWF0aC9pcy1udW1iZXItZXF1YWwnKTtcbmNvbnN0IG1peCA9IHJlcXVpcmUoJ0BhbnR2L3V0aWwvbGliL21peCcpO1xuY29uc3QgQmFzZSA9IHJlcXVpcmUoJy4vYmFzZScpO1xuXG5jb25zdCB2ZWMyID0gTWF0cml4VXRpbC52ZWMyO1xuXG5jbGFzcyBIZWxpeCBleHRlbmRzIEJhc2Uge1xuXG4gIGdldERlZmF1bHRDZmcoKSB7XG4gICAgY29uc3QgY2ZnID0gc3VwZXIuZ2V0RGVmYXVsdENmZygpO1xuICAgIHJldHVybiBtaXgoe30sIGNmZywge1xuICAgICAgc3RhcnRBbmdsZTogMS4yNSAqIE1hdGguUEksXG4gICAgICBlbmRBbmdsZTogNy4yNSAqIE1hdGguUEksXG4gICAgICBpbm5lclJhZGl1czogMCxcbiAgICAgIHR5cGU6ICdoZWxpeCcsXG4gICAgICBpc0hlbGl4OiB0cnVlXG4gICAgfSk7XG4gIH1cblxuICBjb25zdHJ1Y3RvcihjZmcpIHtcbiAgICBzdXBlcihjZmcpO1xuICAgIHRoaXMuX2luaXQoKTtcbiAgfVxuXG4gIF9pbml0KCkge1xuICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDtcbiAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodDtcbiAgICBjb25zdCByYWRpdXMgPSB0aGlzLnJhZGl1cztcbiAgICBjb25zdCBpbm5lclJhZGl1cyA9IHRoaXMuaW5uZXJSYWRpdXM7XG4gICAgY29uc3Qgc3RhcnRBbmdsZSA9IHRoaXMuc3RhcnRBbmdsZTtcbiAgICBjb25zdCBlbmRBbmdsZSA9IHRoaXMuZW5kQW5nbGU7XG5cbiAgICBjb25zdCBpbmRleCA9IChlbmRBbmdsZSAtIHN0YXJ0QW5nbGUpIC8gKDIgKiBNYXRoLlBJKSArIDE7IC8vIOieuue6v+WciOaVsFxuICAgIGxldCBtYXhSYWRpdXMgPSBNYXRoLm1pbih3aWR0aCwgaGVpZ2h0KSAvIDI7XG4gICAgaWYgKHJhZGl1cyAmJiByYWRpdXMgPj0gMCAmJiByYWRpdXMgPD0gMSkge1xuICAgICAgbWF4UmFkaXVzID0gbWF4UmFkaXVzICogcmFkaXVzO1xuICAgIH1cblxuICAgIGNvbnN0IGQgPSBNYXRoLmZsb29yKG1heFJhZGl1cyAqICgxIC0gaW5uZXJSYWRpdXMpIC8gaW5kZXgpO1xuICAgIGNvbnN0IGEgPSBkIC8gKE1hdGguUEkgKiAyKTsvLyDonrrnur/ns7vmlbBcblxuICAgIGNvbnN0IHggPSB7XG4gICAgICBzdGFydDogc3RhcnRBbmdsZSxcbiAgICAgIGVuZDogZW5kQW5nbGVcbiAgICB9O1xuICAgIGNvbnN0IHkgPSB7XG4gICAgICBzdGFydDogaW5uZXJSYWRpdXMgKiBtYXhSYWRpdXMsXG4gICAgICBlbmQ6IGlubmVyUmFkaXVzICogbWF4UmFkaXVzICsgZCAqIDAuOTlcbiAgICB9O1xuXG4gICAgdGhpcy5hID0gYTtcbiAgICB0aGlzLmQgPSBkO1xuICAgIHRoaXMueCA9IHg7XG4gICAgdGhpcy55ID0geTtcbiAgfVxuXG4gIGdldENlbnRlcigpIHtcbiAgICByZXR1cm4gdGhpcy5jZW50ZXI7XG4gIH1cblxuICAvKipcbiAgICog5bCG55m+5YiG5q+U5pWw5o2u5Y+Y5oiQ5bGP5bmV5Z2Q5qCHXG4gICAqIEBwYXJhbSAge09iamVjdH0gcG9pbnQg5b2S5LiA5YyW55qE54K55Z2Q5qCHXG4gICAqIEByZXR1cm4ge09iamVjdH0gICAgICAg6L+U5Zue5a+55bqU55qE5bGP5bmV5Z2Q5qCHXG4gICAqL1xuICBjb252ZXJ0UG9pbnQocG9pbnQpIHtcbiAgICBjb25zdCBhID0gdGhpcy5hO1xuICAgIGNvbnN0IGNlbnRlciA9IHRoaXMuY2VudGVyO1xuICAgIGxldCB4O1xuICAgIGxldCB5O1xuXG4gICAgaWYgKHRoaXMuaXNUcmFuc3Bvc2VkKSB7XG4gICAgICB4ID0gcG9pbnQueTtcbiAgICAgIHkgPSBwb2ludC54O1xuICAgIH0gZWxzZSB7XG4gICAgICB4ID0gcG9pbnQueDtcbiAgICAgIHkgPSBwb2ludC55O1xuICAgIH1cblxuICAgIGNvbnN0IHRoaSA9IHRoaXMuY29udmVydERpbSh4LCAneCcpO1xuICAgIGNvbnN0IHIgPSBhICogdGhpO1xuICAgIGNvbnN0IG5ld1kgPSB0aGlzLmNvbnZlcnREaW0oeSwgJ3knKTtcblxuICAgIHJldHVybiB7XG4gICAgICB4OiBjZW50ZXIueCArIE1hdGguY29zKHRoaSkgKiAociArIG5ld1kpLFxuICAgICAgeTogY2VudGVyLnkgKyBNYXRoLnNpbih0aGkpICogKHIgKyBuZXdZKVxuICAgIH07XG4gIH1cblxuICAvKipcbiAgICog5bCG5bGP5bmV5Z2Q5qCH54K56L+Y5Y6f5oiQ55m+5YiG5q+U5pWw5o2uXG4gICAqIEBwYXJhbSAge09iamVjdH0gcG9pbnQg5bGP5bmV5Z2Q5qCHXG4gICAqIEByZXR1cm4ge09iamVjdH0gICAgICAg6L+U5Zue5a+55bqU55qE5b2S5LiA5YyW5ZCO55qE5pWw5o2uXG4gICAqL1xuICBpbnZlcnRQb2ludChwb2ludCkge1xuICAgIGNvbnN0IGNlbnRlciA9IHRoaXMuY2VudGVyO1xuICAgIGNvbnN0IGEgPSB0aGlzLmE7XG4gICAgY29uc3QgZCA9IHRoaXMuZCArIHRoaXMueS5zdGFydDtcbiAgICBjb25zdCB2ID0gdmVjMi5zdWJ0cmFjdChbXSwgWyBwb2ludC54LCBwb2ludC55IF0sIFsgY2VudGVyLngsIGNlbnRlci55IF0pO1xuICAgIGxldCB0aGkgPSB2ZWMyLmFuZ2xlVG8odiwgWyAxLCAwIF0sIHRydWUpO1xuICAgIGxldCByTWluID0gdGhpICogYTsgLy8g5Z2Q5qCH5LiO5Y6f54K555qE6L+e57q/5Zyo56ys5LiA5ZyI5LiK55qE5Lqk54K577yM5pyA5bCPcuWAvFxuXG4gICAgaWYgKHZlYzIubGVuZ3RoKHYpIDwgck1pbikgeyAgLy8g5Z2Q5qCH5LiO5Y6f54K555qE6L+e57q/5LiN5Y+v6IO95bCP5LqO5pyA5bCPcuWAvO+8jOS9huS4jeaOkumZpOWboOWwj+aVsOiuoeeul+S6p+eUn+eahOeVpeWwj+S6jnJNaW7nmoTmg4XlhrVcbiAgICAgIHJNaW4gPSB2ZWMyLmxlbmd0aCh2KTtcbiAgICB9XG5cbiAgICBjb25zdCBpbmRleCA9IE1hdGguZmxvb3IoKHZlYzIubGVuZ3RoKHYpIC0gck1pbikgLyBkKTsgLy8g5b2T5YmN54K55L2N5LqO56ysaW5kZXjlnIhcbiAgICB0aGkgPSAyICogaW5kZXggKiBNYXRoLlBJICsgdGhpO1xuICAgIGNvbnN0IHIgPSBhICogdGhpO1xuICAgIGxldCBuZXdZID0gdmVjMi5sZW5ndGgodikgLSByO1xuICAgIG5ld1kgPSBpc051bWJlckVxdWFsKG5ld1ksIDApID8gMCA6IG5ld1k7XG5cbiAgICBsZXQgeCA9IHRoaXMuaW52ZXJ0RGltKHRoaSwgJ3gnKTtcbiAgICBsZXQgeSA9IHRoaXMuaW52ZXJ0RGltKG5ld1ksICd5Jyk7XG4gICAgeCA9IGlzTnVtYmVyRXF1YWwoeCwgMCkgPyAwIDogeDtcbiAgICB5ID0gaXNOdW1iZXJFcXVhbCh5LCAwKSA/IDAgOiB5O1xuXG4gICAgY29uc3QgcnN0ID0ge307XG4gICAgcnN0LnggPSB0aGlzLmlzVHJhbnNwb3NlZCA/IHkgOiB4O1xuICAgIHJzdC55ID0gdGhpcy5pc1RyYW5zcG9zZWQgPyB4IDogeTtcbiAgICByZXR1cm4gcnN0O1xuICB9XG59XG5cbm1vZHVsZS5leHBvcnRzID0gSGVsaXg7XG4iXX0=
/***/ }),
/* 262 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @fileOverview the entry of coordinate
* @author sima.zhang1990@gmail.com
*/
var Coord = __webpack_require__(42);
Coord.Cartesian = __webpack_require__(260);
Coord.Rect = Coord.Cartesian;
Coord.Polar = __webpack_require__(263);
Coord.Helix = __webpack_require__(261);
module.exports = Coord;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJDb29yZCIsInJlcXVpcmUiLCJDYXJ0ZXNpYW4iLCJSZWN0IiwiUG9sYXIiLCJIZWxpeCIsIm1vZHVsZSIsImV4cG9ydHMiXSwibWFwcGluZ3MiOiI7O0FBQUE7Ozs7QUFJQSxJQUFNQSxLQUFLLEdBQUdDLE9BQU8sQ0FBQyxRQUFELENBQXJCOztBQUNBRCxLQUFLLENBQUNFLFNBQU4sR0FBa0JELE9BQU8sQ0FBQyxhQUFELENBQXpCO0FBQ0FELEtBQUssQ0FBQ0csSUFBTixHQUFhSCxLQUFLLENBQUNFLFNBQW5CO0FBQ0FGLEtBQUssQ0FBQ0ksS0FBTixHQUFjSCxPQUFPLENBQUMsU0FBRCxDQUFyQjtBQUNBRCxLQUFLLENBQUNLLEtBQU4sR0FBY0osT0FBTyxDQUFDLFNBQUQsQ0FBckI7QUFFQUssTUFBTSxDQUFDQyxPQUFQLEdBQWlCUCxLQUFqQiIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGZpbGVPdmVydmlldyB0aGUgZW50cnkgb2YgY29vcmRpbmF0ZVxuICogQGF1dGhvciBzaW1hLnpoYW5nMTk5MEBnbWFpbC5jb21cbiAqL1xuY29uc3QgQ29vcmQgPSByZXF1aXJlKCcuL2Jhc2UnKTtcbkNvb3JkLkNhcnRlc2lhbiA9IHJlcXVpcmUoJy4vY2FydGVzaWFuJyk7XG5Db29yZC5SZWN0ID0gQ29vcmQuQ2FydGVzaWFuO1xuQ29vcmQuUG9sYXIgPSByZXF1aXJlKCcuL3BvbGFyJyk7XG5Db29yZC5IZWxpeCA9IHJlcXVpcmUoJy4vaGVsaXgnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBDb29yZDtcbiJdfQ==
/***/ }),
/* 263 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/**
* @fileOverview the class of Polar Coordinate
* @author sima.zhang
*/
var MatrixUtil = __webpack_require__(52);
var isNumberEqual = __webpack_require__(51);
var mix = __webpack_require__(10);
var Base = __webpack_require__(42);
var mat3 = MatrixUtil.mat3;
var vec2 = MatrixUtil.vec2;
var vec3 = MatrixUtil.vec3;
var Polar =
/*#__PURE__*/
function (_Base) {
_inherits(Polar, _Base);
_createClass(Polar, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
var cfg = _get(_getPrototypeOf(Polar.prototype), "getDefaultCfg", this).call(this);
return mix({}, cfg, {
startAngle: -Math.PI / 2,
endAngle: Math.PI * 3 / 2,
innerRadius: 0,
type: 'polar',
isPolar: true
});
}
}]);
function Polar(cfg) {
var _this;
_classCallCheck(this, Polar);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Polar).call(this, cfg));
_this._init();
return _this;
}
_createClass(Polar, [{
key: "_init",
value: function _init() {
var radius = this.radius;
var innerRadius = this.innerRadius;
var center = this.center;
var startAngle = this.startAngle;
var endAngle = this.endAngle;
while (endAngle < startAngle) {
endAngle += Math.PI * 2;
}
this.endAngle = endAngle;
var oneBox = this.getOneBox();
var oneWidth = oneBox.maxX - oneBox.minX;
var oneHeight = oneBox.maxY - oneBox.minY;
var left = Math.abs(oneBox.minX) / oneWidth;
var top = Math.abs(oneBox.minY) / oneHeight;
var width = this.width;
var height = this.height;
var maxRadius;
var circleCentre;
if (height / oneHeight > width / oneWidth) {
// width为主
maxRadius = width / oneWidth;
circleCentre = {
x: center.x - (0.5 - left) * width,
y: center.y - (0.5 - top) * maxRadius * oneHeight
};
} else {
// height为主
maxRadius = height / oneHeight;
circleCentre = {
x: center.x - (0.5 - left) * maxRadius * oneWidth,
y: center.y - (0.5 - top) * height
};
}
if (!radius) {
radius = maxRadius;
} else if (radius > 0 && radius <= 1) {
radius = maxRadius * radius;
} else if (radius <= 0 || radius > maxRadius) {
radius = maxRadius;
}
var x = {
start: startAngle,
end: endAngle
};
var y = {
start: innerRadius * radius,
end: radius
};
this.x = x;
this.y = y;
this.radius = radius;
this.circleCentre = circleCentre;
this.center = circleCentre;
}
}, {
key: "getCenter",
value: function getCenter() {
return this.circleCentre;
}
}, {
key: "getOneBox",
value: function getOneBox() {
var startAngle = this.startAngle;
var endAngle = this.endAngle;
if (Math.abs(endAngle - startAngle) >= Math.PI * 2) {
return {
minX: -1,
maxX: 1,
minY: -1,
maxY: 1
};
}
var xs = [0, Math.cos(startAngle), Math.cos(endAngle)];
var ys = [0, Math.sin(startAngle), Math.sin(endAngle)];
for (var i = Math.min(startAngle, endAngle); i < Math.max(startAngle, endAngle); i += Math.PI / 18) {
xs.push(Math.cos(i));
ys.push(Math.sin(i));
}
return {
minX: Math.min.apply(Math, xs),
maxX: Math.max.apply(Math, xs),
minY: Math.min.apply(Math, ys),
maxY: Math.max.apply(Math, ys)
};
}
}, {
key: "getRadius",
value: function getRadius() {
return this.radius;
}
}, {
key: "convertPoint",
value: function convertPoint(point) {
var center = this.getCenter();
var x = this.isTransposed ? point.y : point.x;
var y = this.isTransposed ? point.x : point.y;
x = this.convertDim(x, 'x');
y = this.convertDim(y, 'y');
return {
x: center.x + Math.cos(x) * y,
y: center.y + Math.sin(x) * y
};
}
}, {
key: "invertPoint",
value: function invertPoint(point) {
var center = this.getCenter();
var vPoint = [point.x - center.x, point.y - center.y];
var x = this.x;
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
mat3.rotate(m, m, x.start);
var vStart = [1, 0, 0];
vec3.transformMat3(vStart, vStart, m);
vStart = [vStart[0], vStart[1]];
var angle = vec2.angleTo(vStart, vPoint, x.end < x.start);
if (isNumberEqual(angle, Math.PI * 2)) {
angle = 0;
}
var radius = vec2.length(vPoint);
var xPercent = angle / (x.end - x.start);
xPercent = x.end - x.start > 0 ? xPercent : -xPercent;
var yPercent = this.invertDim(radius, 'y');
var rst = {};
rst.x = this.isTransposed ? yPercent : xPercent;
rst.y = this.isTransposed ? xPercent : yPercent;
return rst;
}
}]);
return Polar;
}(Base);
module.exports = Polar;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wb2xhci5qcyJdLCJuYW1lcyI6WyJNYXRyaXhVdGlsIiwicmVxdWlyZSIsImlzTnVtYmVyRXF1YWwiLCJtaXgiLCJCYXNlIiwibWF0MyIsInZlYzIiLCJ2ZWMzIiwiUG9sYXIiLCJjZmciLCJzdGFydEFuZ2xlIiwiTWF0aCIsIlBJIiwiZW5kQW5nbGUiLCJpbm5lclJhZGl1cyIsInR5cGUiLCJpc1BvbGFyIiwiX2luaXQiLCJyYWRpdXMiLCJjZW50ZXIiLCJvbmVCb3giLCJnZXRPbmVCb3giLCJvbmVXaWR0aCIsIm1heFgiLCJtaW5YIiwib25lSGVpZ2h0IiwibWF4WSIsIm1pblkiLCJsZWZ0IiwiYWJzIiwidG9wIiwid2lkdGgiLCJoZWlnaHQiLCJtYXhSYWRpdXMiLCJjaXJjbGVDZW50cmUiLCJ4IiwieSIsInN0YXJ0IiwiZW5kIiwieHMiLCJjb3MiLCJ5cyIsInNpbiIsImkiLCJtaW4iLCJtYXgiLCJwdXNoIiwiYXBwbHkiLCJwb2ludCIsImdldENlbnRlciIsImlzVHJhbnNwb3NlZCIsImNvbnZlcnREaW0iLCJ2UG9pbnQiLCJtIiwicm90YXRlIiwidlN0YXJ0IiwidHJhbnNmb3JtTWF0MyIsImFuZ2xlIiwiYW5nbGVUbyIsImxlbmd0aCIsInhQZXJjZW50IiwieVBlcmNlbnQiLCJpbnZlcnREaW0iLCJyc3QiLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTs7OztBQUlBLElBQU1BLFVBQVUsR0FBR0MsT0FBTyxDQUFDLHdCQUFELENBQTFCOztBQUNBLElBQU1DLGFBQWEsR0FBR0QsT0FBTyxDQUFDLHFDQUFELENBQTdCOztBQUNBLElBQU1FLEdBQUcsR0FBR0YsT0FBTyxDQUFDLG9CQUFELENBQW5COztBQUNBLElBQU1HLElBQUksR0FBR0gsT0FBTyxDQUFDLFFBQUQsQ0FBcEI7O0FBRUEsSUFBTUksSUFBSSxHQUFHTCxVQUFVLENBQUNLLElBQXhCO0FBQ0EsSUFBTUMsSUFBSSxHQUFHTixVQUFVLENBQUNNLElBQXhCO0FBQ0EsSUFBTUMsSUFBSSxHQUFHUCxVQUFVLENBQUNPLElBQXhCOztJQUVNQyxLOzs7Ozs7O29DQUVZO0FBQ2QsVUFBTUMsR0FBRywyRUFBVDs7QUFDQSxhQUFPTixHQUFHLENBQUMsRUFBRCxFQUFLTSxHQUFMLEVBQVU7QUFDbEJDLFFBQUFBLFVBQVUsRUFBRSxDQUFDQyxJQUFJLENBQUNDLEVBQU4sR0FBVyxDQURMO0FBRWxCQyxRQUFBQSxRQUFRLEVBQUVGLElBQUksQ0FBQ0MsRUFBTCxHQUFVLENBQVYsR0FBYyxDQUZOO0FBR2xCRSxRQUFBQSxXQUFXLEVBQUUsQ0FISztBQUlsQkMsUUFBQUEsSUFBSSxFQUFFLE9BSlk7QUFLbEJDLFFBQUFBLE9BQU8sRUFBRTtBQUxTLE9BQVYsQ0FBVjtBQU9EOzs7QUFFRCxpQkFBWVAsR0FBWixFQUFpQjtBQUFBOztBQUFBOztBQUNmLCtFQUFNQSxHQUFOOztBQUNBLFVBQUtRLEtBQUw7O0FBRmU7QUFHaEI7Ozs7NEJBRU87QUFDTixVQUFJQyxNQUFNLEdBQUcsS0FBS0EsTUFBbEI7QUFDQSxVQUFNSixXQUFXLEdBQUcsS0FBS0EsV0FBekI7QUFDQSxVQUFNSyxNQUFNLEdBQUcsS0FBS0EsTUFBcEI7QUFDQSxVQUFNVCxVQUFVLEdBQUcsS0FBS0EsVUFBeEI7QUFFQSxVQUFJRyxRQUFRLEdBQUcsS0FBS0EsUUFBcEI7O0FBQ0EsYUFBT0EsUUFBUSxHQUFHSCxVQUFsQixFQUE4QjtBQUM1QkcsUUFBQUEsUUFBUSxJQUFLRixJQUFJLENBQUNDLEVBQUwsR0FBVSxDQUF2QjtBQUNEOztBQUNELFdBQUtDLFFBQUwsR0FBZ0JBLFFBQWhCO0FBQ0EsVUFBTU8sTUFBTSxHQUFHLEtBQUtDLFNBQUwsRUFBZjtBQUVBLFVBQU1DLFFBQVEsR0FBR0YsTUFBTSxDQUFDRyxJQUFQLEdBQWNILE1BQU0sQ0FBQ0ksSUFBdEM7QUFDQSxVQUFNQyxTQUFTLEdBQUdMLE1BQU0sQ0FBQ00sSUFBUCxHQUFjTixNQUFNLENBQUNPLElBQXZDO0FBQ0EsVUFBTUMsSUFBSSxHQUFHakIsSUFBSSxDQUFDa0IsR0FBTCxDQUFTVCxNQUFNLENBQUNJLElBQWhCLElBQXdCRixRQUFyQztBQUNBLFVBQU1RLEdBQUcsR0FBR25CLElBQUksQ0FBQ2tCLEdBQUwsQ0FBU1QsTUFBTSxDQUFDTyxJQUFoQixJQUF3QkYsU0FBcEM7QUFDQSxVQUFNTSxLQUFLLEdBQUcsS0FBS0EsS0FBbkI7QUFDQSxVQUFNQyxNQUFNLEdBQUcsS0FBS0EsTUFBcEI7QUFDQSxVQUFJQyxTQUFKO0FBQ0EsVUFBSUMsWUFBSjs7QUFDQSxVQUFLRixNQUFNLEdBQUdQLFNBQVYsR0FBd0JNLEtBQUssR0FBR1QsUUFBcEMsRUFBK0M7QUFBRTtBQUMvQ1csUUFBQUEsU0FBUyxHQUFHRixLQUFLLEdBQUdULFFBQXBCO0FBQ0FZLFFBQUFBLFlBQVksR0FBRztBQUNiQyxVQUFBQSxDQUFDLEVBQUVoQixNQUFNLENBQUNnQixDQUFQLEdBQVcsQ0FBQyxNQUFNUCxJQUFQLElBQWVHLEtBRGhCO0FBRWJLLFVBQUFBLENBQUMsRUFBRWpCLE1BQU0sQ0FBQ2lCLENBQVAsR0FBVyxDQUFDLE1BQU1OLEdBQVAsSUFBY0csU0FBZCxHQUEwQlI7QUFGM0IsU0FBZjtBQUlELE9BTkQsTUFNTztBQUFFO0FBQ1BRLFFBQUFBLFNBQVMsR0FBR0QsTUFBTSxHQUFHUCxTQUFyQjtBQUNBUyxRQUFBQSxZQUFZLEdBQUc7QUFDYkMsVUFBQUEsQ0FBQyxFQUFFaEIsTUFBTSxDQUFDZ0IsQ0FBUCxHQUFXLENBQUMsTUFBTVAsSUFBUCxJQUFlSyxTQUFmLEdBQTJCWCxRQUQ1QjtBQUViYyxVQUFBQSxDQUFDLEVBQUVqQixNQUFNLENBQUNpQixDQUFQLEdBQVcsQ0FBQyxNQUFNTixHQUFQLElBQWNFO0FBRmYsU0FBZjtBQUlEOztBQUVELFVBQUksQ0FBQ2QsTUFBTCxFQUFhO0FBQ1hBLFFBQUFBLE1BQU0sR0FBR2UsU0FBVDtBQUNELE9BRkQsTUFFTyxJQUFJZixNQUFNLEdBQUcsQ0FBVCxJQUFjQSxNQUFNLElBQUksQ0FBNUIsRUFBK0I7QUFDcENBLFFBQUFBLE1BQU0sR0FBR2UsU0FBUyxHQUFHZixNQUFyQjtBQUNELE9BRk0sTUFFQSxJQUFJQSxNQUFNLElBQUksQ0FBVixJQUFlQSxNQUFNLEdBQUdlLFNBQTVCLEVBQXVDO0FBQzVDZixRQUFBQSxNQUFNLEdBQUdlLFNBQVQ7QUFDRDs7QUFFRCxVQUFNRSxDQUFDLEdBQUc7QUFDUkUsUUFBQUEsS0FBSyxFQUFFM0IsVUFEQztBQUVSNEIsUUFBQUEsR0FBRyxFQUFFekI7QUFGRyxPQUFWO0FBS0EsVUFBTXVCLENBQUMsR0FBRztBQUNSQyxRQUFBQSxLQUFLLEVBQUV2QixXQUFXLEdBQUdJLE1BRGI7QUFFUm9CLFFBQUFBLEdBQUcsRUFBRXBCO0FBRkcsT0FBVjtBQUtBLFdBQUtpQixDQUFMLEdBQVNBLENBQVQ7QUFDQSxXQUFLQyxDQUFMLEdBQVNBLENBQVQ7QUFDQSxXQUFLbEIsTUFBTCxHQUFjQSxNQUFkO0FBQ0EsV0FBS2dCLFlBQUwsR0FBb0JBLFlBQXBCO0FBQ0EsV0FBS2YsTUFBTCxHQUFjZSxZQUFkO0FBQ0Q7OztnQ0FFVztBQUNWLGFBQU8sS0FBS0EsWUFBWjtBQUNEOzs7Z0NBRVc7QUFDVixVQUFNeEIsVUFBVSxHQUFHLEtBQUtBLFVBQXhCO0FBQ0EsVUFBTUcsUUFBUSxHQUFHLEtBQUtBLFFBQXRCOztBQUNBLFVBQUlGLElBQUksQ0FBQ2tCLEdBQUwsQ0FBU2hCLFFBQVEsR0FBR0gsVUFBcEIsS0FBbUNDLElBQUksQ0FBQ0MsRUFBTCxHQUFVLENBQWpELEVBQW9EO0FBQ2xELGVBQU87QUFDTFksVUFBQUEsSUFBSSxFQUFFLENBQUMsQ0FERjtBQUVMRCxVQUFBQSxJQUFJLEVBQUUsQ0FGRDtBQUdMSSxVQUFBQSxJQUFJLEVBQUUsQ0FBQyxDQUhGO0FBSUxELFVBQUFBLElBQUksRUFBRTtBQUpELFNBQVA7QUFNRDs7QUFDRCxVQUFNYSxFQUFFLEdBQUcsQ0FBRSxDQUFGLEVBQUs1QixJQUFJLENBQUM2QixHQUFMLENBQVM5QixVQUFULENBQUwsRUFBMkJDLElBQUksQ0FBQzZCLEdBQUwsQ0FBUzNCLFFBQVQsQ0FBM0IsQ0FBWDtBQUNBLFVBQU00QixFQUFFLEdBQUcsQ0FBRSxDQUFGLEVBQUs5QixJQUFJLENBQUMrQixHQUFMLENBQVNoQyxVQUFULENBQUwsRUFBMkJDLElBQUksQ0FBQytCLEdBQUwsQ0FBUzdCLFFBQVQsQ0FBM0IsQ0FBWDs7QUFFQSxXQUFLLElBQUk4QixDQUFDLEdBQUdoQyxJQUFJLENBQUNpQyxHQUFMLENBQVNsQyxVQUFULEVBQXFCRyxRQUFyQixDQUFiLEVBQTZDOEIsQ0FBQyxHQUFHaEMsSUFBSSxDQUFDa0MsR0FBTCxDQUFTbkMsVUFBVCxFQUFxQkcsUUFBckIsQ0FBakQsRUFBaUY4QixDQUFDLElBQUloQyxJQUFJLENBQUNDLEVBQUwsR0FBVSxFQUFoRyxFQUFvRztBQUNsRzJCLFFBQUFBLEVBQUUsQ0FBQ08sSUFBSCxDQUFRbkMsSUFBSSxDQUFDNkIsR0FBTCxDQUFTRyxDQUFULENBQVI7QUFDQUYsUUFBQUEsRUFBRSxDQUFDSyxJQUFILENBQVFuQyxJQUFJLENBQUMrQixHQUFMLENBQVNDLENBQVQsQ0FBUjtBQUNEOztBQUVELGFBQU87QUFDTG5CLFFBQUFBLElBQUksRUFBRWIsSUFBSSxDQUFDaUMsR0FBTCxDQUFTRyxLQUFULENBQWVwQyxJQUFmLEVBQXFCNEIsRUFBckIsQ0FERDtBQUVMaEIsUUFBQUEsSUFBSSxFQUFFWixJQUFJLENBQUNrQyxHQUFMLENBQVNFLEtBQVQsQ0FBZXBDLElBQWYsRUFBcUI0QixFQUFyQixDQUZEO0FBR0xaLFFBQUFBLElBQUksRUFBRWhCLElBQUksQ0FBQ2lDLEdBQUwsQ0FBU0csS0FBVCxDQUFlcEMsSUFBZixFQUFxQjhCLEVBQXJCLENBSEQ7QUFJTGYsUUFBQUEsSUFBSSxFQUFFZixJQUFJLENBQUNrQyxHQUFMLENBQVNFLEtBQVQsQ0FBZXBDLElBQWYsRUFBcUI4QixFQUFyQjtBQUpELE9BQVA7QUFNRDs7O2dDQUVXO0FBQ1YsYUFBTyxLQUFLdkIsTUFBWjtBQUNEOzs7aUNBRVk4QixLLEVBQU87QUFDbEIsVUFBTTdCLE1BQU0sR0FBRyxLQUFLOEIsU0FBTCxFQUFmO0FBQ0EsVUFBSWQsQ0FBQyxHQUFHLEtBQUtlLFlBQUwsR0FBb0JGLEtBQUssQ0FBQ1osQ0FBMUIsR0FBOEJZLEtBQUssQ0FBQ2IsQ0FBNUM7QUFDQSxVQUFJQyxDQUFDLEdBQUcsS0FBS2MsWUFBTCxHQUFvQkYsS0FBSyxDQUFDYixDQUExQixHQUE4QmEsS0FBSyxDQUFDWixDQUE1QztBQUVBRCxNQUFBQSxDQUFDLEdBQUcsS0FBS2dCLFVBQUwsQ0FBZ0JoQixDQUFoQixFQUFtQixHQUFuQixDQUFKO0FBQ0FDLE1BQUFBLENBQUMsR0FBRyxLQUFLZSxVQUFMLENBQWdCZixDQUFoQixFQUFtQixHQUFuQixDQUFKO0FBRUEsYUFBTztBQUNMRCxRQUFBQSxDQUFDLEVBQUVoQixNQUFNLENBQUNnQixDQUFQLEdBQVd4QixJQUFJLENBQUM2QixHQUFMLENBQVNMLENBQVQsSUFBY0MsQ0FEdkI7QUFFTEEsUUFBQUEsQ0FBQyxFQUFFakIsTUFBTSxDQUFDaUIsQ0FBUCxHQUFXekIsSUFBSSxDQUFDK0IsR0FBTCxDQUFTUCxDQUFULElBQWNDO0FBRnZCLE9BQVA7QUFJRDs7O2dDQUVXWSxLLEVBQU87QUFDakIsVUFBTTdCLE1BQU0sR0FBRyxLQUFLOEIsU0FBTCxFQUFmO0FBQ0EsVUFBTUcsTUFBTSxHQUFHLENBQUVKLEtBQUssQ0FBQ2IsQ0FBTixHQUFVaEIsTUFBTSxDQUFDZ0IsQ0FBbkIsRUFBc0JhLEtBQUssQ0FBQ1osQ0FBTixHQUFVakIsTUFBTSxDQUFDaUIsQ0FBdkMsQ0FBZjtBQUNBLFVBQU1ELENBQUMsR0FBRyxLQUFLQSxDQUFmO0FBQ0EsVUFBTWtCLENBQUMsR0FBRyxDQUFFLENBQUYsRUFBSyxDQUFMLEVBQVEsQ0FBUixFQUFXLENBQVgsRUFBYyxDQUFkLEVBQWlCLENBQWpCLEVBQW9CLENBQXBCLEVBQXVCLENBQXZCLEVBQTBCLENBQTFCLENBQVY7QUFDQWhELE1BQUFBLElBQUksQ0FBQ2lELE1BQUwsQ0FBWUQsQ0FBWixFQUFlQSxDQUFmLEVBQWtCbEIsQ0FBQyxDQUFDRSxLQUFwQjtBQUVBLFVBQUlrQixNQUFNLEdBQUcsQ0FBRSxDQUFGLEVBQUssQ0FBTCxFQUFRLENBQVIsQ0FBYjtBQUNBaEQsTUFBQUEsSUFBSSxDQUFDaUQsYUFBTCxDQUFtQkQsTUFBbkIsRUFBMkJBLE1BQTNCLEVBQW1DRixDQUFuQztBQUNBRSxNQUFBQSxNQUFNLEdBQUcsQ0FBRUEsTUFBTSxDQUFDLENBQUQsQ0FBUixFQUFhQSxNQUFNLENBQUMsQ0FBRCxDQUFuQixDQUFUO0FBQ0EsVUFBSUUsS0FBSyxHQUFHbkQsSUFBSSxDQUFDb0QsT0FBTCxDQUFhSCxNQUFiLEVBQXFCSCxNQUFyQixFQUE2QmpCLENBQUMsQ0FBQ0csR0FBRixHQUFRSCxDQUFDLENBQUNFLEtBQXZDLENBQVo7O0FBQ0EsVUFBSW5DLGFBQWEsQ0FBQ3VELEtBQUQsRUFBUTlDLElBQUksQ0FBQ0MsRUFBTCxHQUFVLENBQWxCLENBQWpCLEVBQXVDO0FBQ3JDNkMsUUFBQUEsS0FBSyxHQUFHLENBQVI7QUFDRDs7QUFDRCxVQUFNdkMsTUFBTSxHQUFHWixJQUFJLENBQUNxRCxNQUFMLENBQVlQLE1BQVosQ0FBZjtBQUVBLFVBQUlRLFFBQVEsR0FBR0gsS0FBSyxJQUFJdEIsQ0FBQyxDQUFDRyxHQUFGLEdBQVFILENBQUMsQ0FBQ0UsS0FBZCxDQUFwQjtBQUNBdUIsTUFBQUEsUUFBUSxHQUFHekIsQ0FBQyxDQUFDRyxHQUFGLEdBQVFILENBQUMsQ0FBQ0UsS0FBVixHQUFrQixDQUFsQixHQUFzQnVCLFFBQXRCLEdBQWlDLENBQUNBLFFBQTdDO0FBRUEsVUFBTUMsUUFBUSxHQUFHLEtBQUtDLFNBQUwsQ0FBZTVDLE1BQWYsRUFBdUIsR0FBdkIsQ0FBakI7QUFDQSxVQUFNNkMsR0FBRyxHQUFHLEVBQVo7QUFDQUEsTUFBQUEsR0FBRyxDQUFDNUIsQ0FBSixHQUFRLEtBQUtlLFlBQUwsR0FBb0JXLFFBQXBCLEdBQStCRCxRQUF2QztBQUNBRyxNQUFBQSxHQUFHLENBQUMzQixDQUFKLEdBQVEsS0FBS2MsWUFBTCxHQUFvQlUsUUFBcEIsR0FBK0JDLFFBQXZDO0FBQ0EsYUFBT0UsR0FBUDtBQUNEOzs7O0VBdkppQjNELEk7O0FBMEpwQjRELE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQnpELEtBQWpCIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAZmlsZU92ZXJ2aWV3IHRoZSBjbGFzcyBvZiBQb2xhciBDb29yZGluYXRlXG4gKiBAYXV0aG9yIHNpbWEuemhhbmdcbiAqL1xuY29uc3QgTWF0cml4VXRpbCA9IHJlcXVpcmUoJ0BhbnR2L3V0aWwvbGliL21hdHJpeC8nKTtcbmNvbnN0IGlzTnVtYmVyRXF1YWwgPSByZXF1aXJlKCdAYW50di91dGlsL2xpYi9tYXRoL2lzLW51bWJlci1lcXVhbCcpO1xuY29uc3QgbWl4ID0gcmVxdWlyZSgnQGFudHYvdXRpbC9saWIvbWl4Jyk7XG5jb25zdCBCYXNlID0gcmVxdWlyZSgnLi9iYXNlJyk7XG5cbmNvbnN0IG1hdDMgPSBNYXRyaXhVdGlsLm1hdDM7XG5jb25zdCB2ZWMyID0gTWF0cml4VXRpbC52ZWMyO1xuY29uc3QgdmVjMyA9IE1hdHJpeFV0aWwudmVjMztcblxuY2xhc3MgUG9sYXIgZXh0ZW5kcyBCYXNlIHtcblxuICBnZXREZWZhdWx0Q2ZnKCkge1xuICAgIGNvbnN0IGNmZyA9IHN1cGVyLmdldERlZmF1bHRDZmcoKTtcbiAgICByZXR1cm4gbWl4KHt9LCBjZmcsIHtcbiAgICAgIHN0YXJ0QW5nbGU6IC1NYXRoLlBJIC8gMixcbiAgICAgIGVuZEFuZ2xlOiBNYXRoLlBJICogMyAvIDIsXG4gICAgICBpbm5lclJhZGl1czogMCxcbiAgICAgIHR5cGU6ICdwb2xhcicsXG4gICAgICBpc1BvbGFyOiB0cnVlXG4gICAgfSk7XG4gIH1cblxuICBjb25zdHJ1Y3RvcihjZmcpIHtcbiAgICBzdXBlcihjZmcpO1xuICAgIHRoaXMuX2luaXQoKTtcbiAgfVxuXG4gIF9pbml0KCkge1xuICAgIGxldCByYWRpdXMgPSB0aGlzLnJhZGl1cztcbiAgICBjb25zdCBpbm5lclJhZGl1cyA9IHRoaXMuaW5uZXJSYWRpdXM7XG4gICAgY29uc3QgY2VudGVyID0gdGhpcy5jZW50ZXI7XG4gICAgY29uc3Qgc3RhcnRBbmdsZSA9IHRoaXMuc3RhcnRBbmdsZTtcblxuICAgIGxldCBlbmRBbmdsZSA9IHRoaXMuZW5kQW5nbGU7XG4gICAgd2hpbGUgKGVuZEFuZ2xlIDwgc3RhcnRBbmdsZSkge1xuICAgICAgZW5kQW5nbGUgKz0gKE1hdGguUEkgKiAyKTtcbiAgICB9XG4gICAgdGhpcy5lbmRBbmdsZSA9IGVuZEFuZ2xlO1xuICAgIGNvbnN0IG9uZUJveCA9IHRoaXMuZ2V0T25lQm94KCk7XG5cbiAgICBjb25zdCBvbmVXaWR0aCA9IG9uZUJveC5tYXhYIC0gb25lQm94Lm1pblg7XG4gICAgY29uc3Qgb25lSGVpZ2h0ID0gb25lQm94Lm1heFkgLSBvbmVCb3gubWluWTtcbiAgICBjb25zdCBsZWZ0ID0gTWF0aC5hYnMob25lQm94Lm1pblgpIC8gb25lV2lkdGg7XG4gICAgY29uc3QgdG9wID0gTWF0aC5hYnMob25lQm94Lm1pblkpIC8gb25lSGVpZ2h0O1xuICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDtcbiAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodDtcbiAgICBsZXQgbWF4UmFkaXVzO1xuICAgIGxldCBjaXJjbGVDZW50cmU7XG4gICAgaWYgKChoZWlnaHQgLyBvbmVIZWlnaHQpID4gKHdpZHRoIC8gb25lV2lkdGgpKSB7IC8vIHdpZHRo5Li65Li7XG4gICAgICBtYXhSYWRpdXMgPSB3aWR0aCAvIG9uZVdpZHRoO1xuICAgICAgY2lyY2xlQ2VudHJlID0ge1xuICAgICAgICB4OiBjZW50ZXIueCAtICgwLjUgLSBsZWZ0KSAqIHdpZHRoLFxuICAgICAgICB5OiBjZW50ZXIueSAtICgwLjUgLSB0b3ApICogbWF4UmFkaXVzICogb25lSGVpZ2h0XG4gICAgICB9O1xuICAgIH0gZWxzZSB7IC8vIGhlaWdodOS4uuS4u1xuICAgICAgbWF4UmFkaXVzID0gaGVpZ2h0IC8gb25lSGVpZ2h0O1xuICAgICAgY2lyY2xlQ2VudHJlID0ge1xuICAgICAgICB4OiBjZW50ZXIueCAtICgwLjUgLSBsZWZ0KSAqIG1heFJhZGl1cyAqIG9uZVdpZHRoLFxuICAgICAgICB5OiBjZW50ZXIueSAtICgwLjUgLSB0b3ApICogaGVpZ2h0XG4gICAgICB9O1xuICAgIH1cblxuICAgIGlmICghcmFkaXVzKSB7XG4gICAgICByYWRpdXMgPSBtYXhSYWRpdXM7XG4gICAgfSBlbHNlIGlmIChyYWRpdXMgPiAwICYmIHJhZGl1cyA8PSAxKSB7XG4gICAgICByYWRpdXMgPSBtYXhSYWRpdXMgKiByYWRpdXM7XG4gICAgfSBlbHNlIGlmIChyYWRpdXMgPD0gMCB8fCByYWRpdXMgPiBtYXhSYWRpdXMpIHtcbiAgICAgIHJhZGl1cyA9IG1heFJhZGl1cztcbiAgICB9XG5cbiAgICBjb25zdCB4ID0ge1xuICAgICAgc3RhcnQ6IHN0YXJ0QW5nbGUsXG4gICAgICBlbmQ6IGVuZEFuZ2xlXG4gICAgfTtcblxuICAgIGNvbnN0IHkgPSB7XG4gICAgICBzdGFydDogaW5uZXJSYWRpdXMgKiByYWRpdXMsXG4gICAgICBlbmQ6IHJhZGl1c1xuICAgIH07XG5cbiAgICB0aGlzLnggPSB4O1xuICAgIHRoaXMueSA9IHk7XG4gICAgdGhpcy5yYWRpdXMgPSByYWRpdXM7XG4gICAgdGhpcy5jaXJjbGVDZW50cmUgPSBjaXJjbGVDZW50cmU7XG4gICAgdGhpcy5jZW50ZXIgPSBjaXJjbGVDZW50cmU7XG4gIH1cblxuICBnZXRDZW50ZXIoKSB7XG4gICAgcmV0dXJuIHRoaXMuY2lyY2xlQ2VudHJlO1xuICB9XG5cbiAgZ2V0T25lQm94KCkge1xuICAgIGNvbnN0IHN0YXJ0QW5nbGUgPSB0aGlzLnN0YXJ0QW5nbGU7XG4gICAgY29uc3QgZW5kQW5nbGUgPSB0aGlzLmVuZEFuZ2xlO1xuICAgIGlmIChNYXRoLmFicyhlbmRBbmdsZSAtIHN0YXJ0QW5nbGUpID49IE1hdGguUEkgKiAyKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICBtaW5YOiAtMSxcbiAgICAgICAgbWF4WDogMSxcbiAgICAgICAgbWluWTogLTEsXG4gICAgICAgIG1heFk6IDFcbiAgICAgIH07XG4gICAgfVxuICAgIGNvbnN0IHhzID0gWyAwLCBNYXRoLmNvcyhzdGFydEFuZ2xlKSwgTWF0aC5jb3MoZW5kQW5nbGUpIF07XG4gICAgY29uc3QgeXMgPSBbIDAsIE1hdGguc2luKHN0YXJ0QW5nbGUpLCBNYXRoLnNpbihlbmRBbmdsZSkgXTtcblxuICAgIGZvciAobGV0IGkgPSBNYXRoLm1pbihzdGFydEFuZ2xlLCBlbmRBbmdsZSk7IGkgPCBNYXRoLm1heChzdGFydEFuZ2xlLCBlbmRBbmdsZSk7IGkgKz0gTWF0aC5QSSAvIDE4KSB7XG4gICAgICB4cy5wdXNoKE1hdGguY29zKGkpKTtcbiAgICAgIHlzLnB1c2goTWF0aC5zaW4oaSkpO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBtaW5YOiBNYXRoLm1pbi5hcHBseShNYXRoLCB4cyksXG4gICAgICBtYXhYOiBNYXRoLm1heC5hcHBseShNYXRoLCB4cyksXG4gICAgICBtaW5ZOiBNYXRoLm1pbi5hcHBseShNYXRoLCB5cyksXG4gICAgICBtYXhZOiBNYXRoLm1heC5hcHBseShNYXRoLCB5cylcbiAgICB9O1xuICB9XG5cbiAgZ2V0UmFkaXVzKCkge1xuICAgIHJldHVybiB0aGlzLnJhZGl1cztcbiAgfVxuXG4gIGNvbnZlcnRQb2ludChwb2ludCkge1xuICAgIGNvbnN0IGNlbnRlciA9IHRoaXMuZ2V0Q2VudGVyKCk7XG4gICAgbGV0IHggPSB0aGlzLmlzVHJhbnNwb3NlZCA/IHBvaW50LnkgOiBwb2ludC54O1xuICAgIGxldCB5ID0gdGhpcy5pc1RyYW5zcG9zZWQgPyBwb2ludC54IDogcG9pbnQueTtcblxuICAgIHggPSB0aGlzLmNvbnZlcnREaW0oeCwgJ3gnKTtcbiAgICB5ID0gdGhpcy5jb252ZXJ0RGltKHksICd5Jyk7XG5cbiAgICByZXR1cm4ge1xuICAgICAgeDogY2VudGVyLnggKyBNYXRoLmNvcyh4KSAqIHksXG4gICAgICB5OiBjZW50ZXIueSArIE1hdGguc2luKHgpICogeVxuICAgIH07XG4gIH1cblxuICBpbnZlcnRQb2ludChwb2ludCkge1xuICAgIGNvbnN0IGNlbnRlciA9IHRoaXMuZ2V0Q2VudGVyKCk7XG4gICAgY29uc3QgdlBvaW50ID0gWyBwb2ludC54IC0gY2VudGVyLngsIHBvaW50LnkgLSBjZW50ZXIueSBdO1xuICAgIGNvbnN0IHggPSB0aGlzLng7XG4gICAgY29uc3QgbSA9IFsgMSwgMCwgMCwgMCwgMSwgMCwgMCwgMCwgMSBdO1xuICAgIG1hdDMucm90YXRlKG0sIG0sIHguc3RhcnQpO1xuXG4gICAgbGV0IHZTdGFydCA9IFsgMSwgMCwgMCBdO1xuICAgIHZlYzMudHJhbnNmb3JtTWF0Myh2U3RhcnQsIHZTdGFydCwgbSk7XG4gICAgdlN0YXJ0ID0gWyB2U3RhcnRbMF0sIHZTdGFydFsxXSBdO1xuICAgIGxldCBhbmdsZSA9IHZlYzIuYW5nbGVUbyh2U3RhcnQsIHZQb2ludCwgeC5lbmQgPCB4LnN0YXJ0KTtcbiAgICBpZiAoaXNOdW1iZXJFcXVhbChhbmdsZSwgTWF0aC5QSSAqIDIpKSB7XG4gICAgICBhbmdsZSA9IDA7XG4gICAgfVxuICAgIGNvbnN0IHJhZGl1cyA9IHZlYzIubGVuZ3RoKHZQb2ludCk7XG5cbiAgICBsZXQgeFBlcmNlbnQgPSBhbmdsZSAvICh4LmVuZCAtIHguc3RhcnQpO1xuICAgIHhQZXJjZW50ID0geC5lbmQgLSB4LnN0YXJ0ID4gMCA/IHhQZXJjZW50IDogLXhQZXJjZW50O1xuXG4gICAgY29uc3QgeVBlcmNlbnQgPSB0aGlzLmludmVydERpbShyYWRpdXMsICd5Jyk7XG4gICAgY29uc3QgcnN0ID0ge307XG4gICAgcnN0LnggPSB0aGlzLmlzVHJhbnNwb3NlZCA/IHlQZXJjZW50IDogeFBlcmNlbnQ7XG4gICAgcnN0LnkgPSB0aGlzLmlzVHJhbnNwb3NlZCA/IHhQZXJjZW50IDogeVBlcmNlbnQ7XG4gICAgcmV0dXJuIHJzdDtcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IFBvbGFyO1xuIl19
/***/ }),
/* 264 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview Default animation funciton
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var G = __webpack_require__(23);
var PathUtil = Util.PathUtil;
function getClip(coord) {
var start = coord.start;
var end = coord.end;
var width = coord.getWidth();
var height = coord.getHeight();
var margin = 200;
var startAngle;
var endAngle;
var center;
var radius;
var clip;
if (coord.isPolar) {
radius = coord.getRadius();
center = coord.getCenter();
startAngle = coord.startAngle;
endAngle = coord.endAngle;
clip = new G.Fan({
attrs: {
x: center.x,
y: center.y,
rs: 0,
re: radius + margin,
startAngle: startAngle,
endAngle: startAngle
}
});
clip.endState = {
endAngle: endAngle
};
} else {
clip = new G.Rect({
attrs: {
x: start.x - margin,
y: end.y - margin,
width: coord.isTransposed ? width + margin * 2 : 0,
height: coord.isTransposed ? 0 : height + margin * 2
}
});
if (coord.isTransposed) {
clip.endState = {
height: height + margin * 2
};
} else {
clip.endState = {
width: width + margin * 2
};
}
}
clip.isClip = true;
return clip;
} // 获取图形的包围盒
function getPointsBox(points) {
if (Util.isEmpty(points)) {
return null;
}
var minX = points[0].x;
var maxX = points[0].x;
var minY = points[0].y;
var maxY = points[0].y;
Util.each(points, function (point) {
minX = minX > point.x ? point.x : minX;
maxX = maxX < point.x ? point.x : maxX;
minY = minY > point.y ? point.y : minY;
maxY = maxY < point.y ? point.y : maxY;
});
return {
minX: minX,
maxX: maxX,
minY: minY,
maxY: maxY,
centerX: (minX + maxX) / 2,
centerY: (minY + maxY) / 2
};
}
function getAngle(shape, coord) {
var points = shape.points || shape.get('origin').points;
var box = getPointsBox(points);
var endAngle;
var startAngle;
var coordStartAngle = coord.startAngle;
var coordEndAngle = coord.endAngle;
var diffAngle = coordEndAngle - coordStartAngle;
if (coord.isTransposed) {
endAngle = box.maxY * diffAngle;
startAngle = box.minY * diffAngle;
} else {
endAngle = box.maxX * diffAngle;
startAngle = box.minX * diffAngle;
}
endAngle += coordStartAngle;
startAngle += coordStartAngle;
return {
startAngle: startAngle,
endAngle: endAngle
};
}
function getAnimateParam(animateCfg, index, id) {
var result = {};
if (animateCfg.delay) {
result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
}
result.easing = Util.isFunction(animateCfg.easing) ? animateCfg.easing(index, id) : animateCfg.easing;
result.duration = Util.isFunction(animateCfg.duration) ? animateCfg.duration(index, id) : animateCfg.duration;
result.callback = animateCfg.callback;
return result;
}
function scaleInY(shape, animateCfg) {
var id = shape._id;
var index = shape.get('index');
var box = shape.getBBox();
var points = shape.get('origin').points;
var x = (box.minX + box.maxX) / 2;
var y;
if (points[0].y - points[1].y <= 0) {
// 当顶点在零点之下
y = box.maxY;
} else {
y = box.minY;
}
var v = [x, y, 1];
shape.apply(v);
shape.attr('transform', [['t', -x, -y], ['s', 1, 0.01], ['t', x, y]]);
var endState = {
transform: [['t', -x, -y], ['s', 1, 100], ['t', x, y]]
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay);
}
function scaleInX(shape, animateCfg) {
var id = shape._id;
var index = shape.get('index');
var box = shape.getBBox();
var points = shape.get('origin').points;
var x;
var y = (box.minY + box.maxY) / 2;
if (points[0].y - points[1].y > 0) {
// 当顶点在零点之下
x = box.maxX;
} else {
x = box.minX;
}
var v = [x, y, 1];
shape.apply(v);
shape.attr({
transform: [['t', -x, -y], ['s', 0.01, 1], ['t', x, y]]
});
var endState = {
transform: [['t', -x, -y], ['s', 100, 1], ['t', x, y]]
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay);
}
function lineWidthOut(shape, animateCfg) {
var endState = {
lineWidth: 0,
opacity: 0
};
var id = shape._id;
var index = shape.get('index');
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, function () {
shape.remove();
}, animateParam.delay);
}
function zoomIn(shape, animateCfg, coord) {
var id = shape._id;
var index = shape.get('index');
var x;
var y;
if (coord.isPolar && shape.name !== 'point') {
x = coord.getCenter().x;
y = coord.getCenter().y;
} else {
var box = shape.getBBox();
x = (box.minX + box.maxX) / 2;
y = (box.minY + box.maxY) / 2;
}
var v = [x, y, 1];
shape.apply(v);
shape.attr({
transform: [['t', -x, -y], ['s', 0.01, 0.01], ['t', x, y]]
});
var endState = {
transform: [['t', -x, -y], ['s', 100, 100], ['t', x, y]]
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay);
}
function zoomOut(shape, animateCfg, coord) {
var id = shape._id;
var index = shape.get('index');
var x;
var y;
if (coord.isPolar && shape.name !== 'point') {
x = coord.getCenter().x;
y = coord.getCenter().y;
} else {
var box = shape.getBBox();
x = (box.minX + box.maxX) / 2;
y = (box.minY + box.maxY) / 2;
}
var v = [x, y, 1];
shape.apply(v);
var endState = {
transform: [['t', -x, -y], ['s', 0.01, 0.01], ['t', x, y]]
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, function () {
shape.remove();
}, animateParam.delay);
}
function pathIn(shape, animateCfg) {
if (shape.get('type') !== 'path') return;
var id = shape._id;
var index = shape.get('index');
var path = PathUtil.pathToAbsolute(shape.attr('path'));
shape.attr('path', [path[0]]);
var endState = {
path: path
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay);
}
function pathOut(shape, animateCfg) {
if (shape.get('type') !== 'path') return;
var id = shape._id;
var index = shape.get('index');
var path = PathUtil.pathToAbsolute(shape.attr('path'));
var endState = {
path: [path[0]]
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, function () {
shape.remove();
}, animateParam.delay);
}
function clipIn(shape, animateCfg, coord, startAngle, endAngle) {
var clip = getClip(coord);
var canvas = shape.get('canvas');
var id = shape._id;
var index = shape.get('index');
var endState;
if (startAngle) {
clip.attr('startAngle', startAngle);
clip.attr('endAngle', startAngle);
endState = {
endAngle: endAngle
};
} else {
endState = clip.endState;
}
clip.set('canvas', canvas);
shape.attr('clip', clip);
shape.setSilent('animating', true);
var animateParam = getAnimateParam(animateCfg, index, id, endState);
clip.animate(endState, animateParam.duration, animateParam.easing, function () {
if (shape && !shape.get('destroyed')) {
shape.attr('clip', null);
shape.setSilent('cacheShape', null);
shape.setSilent('animating', false);
clip.remove();
}
}, animateParam.delay);
}
function fadeIn(shape, animateCfg) {
var id = shape._id;
var index = shape.get('index');
var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
shape.attr('fillOpacity', 0);
shape.attr('strokeOpacity', 0);
var endState = {
fillOpacity: fillOpacity,
strokeOpacity: strokeOpacity
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay);
}
function fadeOut(shape, animateCfg) {
var id = shape._id;
var index = shape.get('index');
var endState = {
fillOpacity: 0,
strokeOpacity: 0
};
var animateParam = getAnimateParam(animateCfg, index, id, endState);
shape.animate(endState, animateParam.duration, animateParam.easing, function () {
shape.remove();
}, animateParam.delay);
}
function fanIn(shape, animateCfg, coord) {
var angle = getAngle(shape, coord);
var endAngle = angle.endAngle;
var startAngle = angle.startAngle;
clipIn(shape, animateCfg, coord, startAngle, endAngle);
} // 默认动画库
module.exports = {
enter: {
clipIn: clipIn,
zoomIn: zoomIn,
pathIn: pathIn,
scaleInY: scaleInY,
scaleInX: scaleInX,
fanIn: fanIn,
fadeIn: fadeIn
},
leave: {
lineWidthOut: lineWidthOut,
zoomOut: zoomOut,
pathOut: pathOut,
fadeOut: fadeOut
},
appear: {
clipIn: clipIn,
zoomIn: zoomIn,
pathIn: pathIn,
scaleInY: scaleInY,
scaleInX: scaleInX,
fanIn: fanIn,
fadeIn: fadeIn
},
update: {
fadeIn: fadeIn,
fanIn: fanIn
}
};
/***/ }),
/* 265 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The entry of chart's animation
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var Animate = __webpack_require__(112);
var MatrixUtil = Util.MatrixUtil;
var mat3 = MatrixUtil.mat3; // 获取图组内所有的shapes
function getShapes(container, viewId) {
var shapes = [];
if (container.get('animate') === false) {
return [];
}
var children = container.get('children');
Util.each(children, function (child) {
if (child.isGroup) {
shapes = shapes.concat(getShapes(child, viewId));
} else if (child.isShape && child._id) {
var id = child._id;
id = id.split('-')[0];
if (id === viewId) {
shapes.push(child);
}
}
});
return shapes;
}
function cache(shapes) {
var rst = {};
Util.each(shapes, function (shape) {
if (!shape._id || shape.isClip) return;
var id = shape._id;
rst[id] = {
_id: id,
type: shape.get('type'),
attrs: Util.cloneDeep(shape.attr()),
// 原始属性
name: shape.name,
index: shape.get('index'),
animateCfg: shape.get('animateCfg'),
coord: shape.get('coord')
};
});
return rst;
}
function getAnimate(geomType, coord, animationType, animationName) {
var result;
if (animationName) {
result = Animate.Action[animationType][animationName];
} else {
result = Animate.getAnimation(geomType, coord, animationType);
}
return result;
}
function getAnimateCfg(geomType, animationType, animateCfg) {
var defaultCfg = Animate.getAnimateCfg(geomType, animationType);
if (animateCfg && animateCfg[animationType]) {
return Util.deepMix({}, defaultCfg, animateCfg[animationType]);
}
return defaultCfg;
}
function addAnimate(cache, shapes, canvas, isUpdate) {
var animate;
var animateCfg;
var canvasDrawn = false;
if (isUpdate) {
// Step: leave -> update -> enter
var updateShapes = []; // 存储的是 shapes
var newShapes = []; // 存储的是 shapes
Util.each(shapes, function (shape) {
var result = cache[shape._id];
if (!result) {
newShapes.push(shape);
} else {
shape.setSilent('cacheShape', result);
updateShapes.push(shape);
delete cache[shape._id];
}
});
Util.each(cache, function (deletedShape) {
var name = deletedShape.name,
coord = deletedShape.coord,
_id = deletedShape._id,
attrs = deletedShape.attrs,
index = deletedShape.index,
type = deletedShape.type;
animateCfg = getAnimateCfg(name, 'leave', deletedShape.animateCfg);
animate = getAnimate(name, coord, 'leave', animateCfg.animation);
if (Util.isFunction(animate)) {
var tempShape = canvas.addShape(type, {
attrs: attrs,
index: index
});
tempShape._id = _id;
tempShape.name = name;
if (coord && name !== 'label') {
var tempShapeMatrix = tempShape.getMatrix();
var finalMatrix = mat3.multiply([], tempShapeMatrix, coord.matrix);
tempShape.setMatrix(finalMatrix);
}
canvasDrawn = true;
animate(tempShape, animateCfg, coord);
}
});
Util.each(updateShapes, function (updateShape) {
var name = updateShape.name;
var coord = updateShape.get('coord');
var cacheAttrs = updateShape.get('cacheShape').attrs; // 判断如果属性相同的话就不进行变换
if (!Util.isEqual(cacheAttrs, updateShape.attr())) {
animateCfg = getAnimateCfg(name, 'update', updateShape.get('animateCfg'));
animate = getAnimate(name, coord, 'update', animateCfg.animation);
if (Util.isFunction(animate)) {
animate(updateShape, animateCfg, coord);
} else {
var endState = Util.cloneDeep(updateShape.attr());
updateShape.attr(cacheAttrs);
updateShape.animate(endState, animateCfg.duration, animateCfg.easing, function () {
updateShape.setSilent('cacheShape', null);
});
}
canvasDrawn = true;
}
});
Util.each(newShapes, function (newShape) {
var name = newShape.name;
var coord = newShape.get('coord');
animateCfg = getAnimateCfg(name, 'enter', newShape.get('animateCfg'));
animate = getAnimate(name, coord, 'enter', animateCfg.animation);
if (Util.isFunction(animate)) {
animate(newShape, animateCfg, coord);
canvasDrawn = true;
}
});
} else {
Util.each(shapes, function (shape) {
var name = shape.name;
var coord = shape.get('coord');
animateCfg = getAnimateCfg(name, 'appear', shape.get('animateCfg'));
animate = getAnimate(name, coord, 'appear', animateCfg.animation);
if (Util.isFunction(animate)) {
animate(shape, animateCfg, coord);
canvasDrawn = true;
}
});
}
return canvasDrawn;
}
module.exports = {
execAnimation: function execAnimation(view, isUpdate) {
var viewContainer = view.get('middlePlot');
var axisContainer = view.get('backPlot');
var viewId = view.get('_id');
var canvas = view.get('canvas');
var caches = canvas.get(viewId + 'caches') || [];
if (caches.length === 0) {
isUpdate = false;
}
var shapes = getShapes(viewContainer, viewId);
var axisShapes = getShapes(axisContainer, viewId);
var cacheShapes = shapes.concat(axisShapes);
canvas.setSilent(viewId + 'caches', cache(cacheShapes));
var drawn;
if (isUpdate) {
drawn = addAnimate(caches, cacheShapes, canvas, isUpdate);
} else {
drawn = addAnimate(caches, shapes, canvas, isUpdate);
}
if (!drawn) {
canvas.draw();
}
}
};
/***/ }),
/* 266 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The controller of axis
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var _require = __webpack_require__(29),
Axis = _require.Axis;
var vec2 = Util.MatrixUtil.vec2;
function formatTicks(ticks) {
var tmp = [];
if (ticks.length > 0) {
tmp = ticks.slice(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;
}
function fillAxisTicks(ticks, isLinear, gridCentering) {
var result = [];
if (ticks.length < 1) return result;
if (ticks.length >= 2 && isLinear && gridCentering) {
result.push({
text: '',
tickValue: '',
value: 0
});
}
if (ticks[0].value !== 0) {
result.push({
text: '',
tickValue: '',
value: 0
});
}
result = result.concat(ticks);
if (result[result.length - 1].value !== 1) {
result.push({
text: '',
tickValue: '',
value: 1
});
}
return result;
}
function getDefaultValueFromPosition(position, val) {
if (val === void 0) {
val = 0;
}
if (position === 'middle') {
val = 0.5;
}
if (position.indexOf('%') !== -1) {
val = parseInt(position, 10) / 100;
}
return val;
}
var AxisController =
/*#__PURE__*/
function () {
function AxisController(cfg) {
this.visible = true;
this.canvas = null;
this.container = null;
this.coord = null;
this.options = null;
this.axes = [];
Util.mix(this, cfg);
}
var _proto = AxisController.prototype;
_proto._isHide = function _isHide(field) {
// 对应的坐标轴是否隐藏
var options = this.options;
if (options && options[field] === false) {
return true;
}
return false;
};
_proto._getMiddleValue = function _getMiddleValue(curValue, ticks, index, isLinear) {
if (curValue === 0 && !isLinear) {
return 0;
}
if (curValue === 1) {
return 1;
}
var nextValue = ticks[index + 1].value;
if (!isLinear && nextValue === 1) {
return 1;
}
return (curValue + nextValue) / 2;
};
_proto._getLineRange = function _getLineRange(coord, scale, dimType, index) {
var start;
var end;
var isVertical;
var field = scale.field;
var options = this.options;
var position = '';
if (options[field] && options[field].position) {
position = options[field].position;
} // TODO middle & percentage for position
if (dimType === 'x') {
// x轴的坐标轴,底部的横坐标
var y = position === 'top' ? 1 : 0;
y = getDefaultValueFromPosition(position, y);
start = {
x: 0,
y: y
};
end = {
x: 1,
y: y
};
isVertical = false;
} else {
// y轴坐标轴
if (index) {
// 多轴的情况
var x = position === 'left' ? 0 : 1;
x = getDefaultValueFromPosition(position, x);
start = {
x: x,
y: 0
};
end = {
x: x,
y: 1
};
} else {
// 单个y轴,或者第一个y轴
var _x = position === 'right' ? 1 : 0;
_x = getDefaultValueFromPosition(position, _x);
start = {
x: _x,
y: 0
};
end = {
x: _x,
y: 1
};
}
isVertical = true;
}
start = coord.convert(start);
end = coord.convert(end);
return {
start: start,
end: end,
isVertical: isVertical
};
};
_proto._getLineCfg = function _getLineCfg(coord, scale, dimType, index) {
var factor;
var range = this._getLineRange(coord, scale, dimType, index);
var isVertical = range.isVertical; // 标识该坐标轴是否是纵坐标
var start = range.start;
var end = range.end;
var center = coord.center;
if (coord.isTransposed) {
isVertical = !isVertical;
}
if (isVertical && start.x > center.x || !isVertical && start.y > center.y) {
factor = 1;
} else {
factor = -1;
}
return {
isVertical: isVertical,
factor: factor,
start: start,
end: end
};
}; // 获取圆弧坐标轴配置项信息
_proto._getCircleCfg = function _getCircleCfg(coord) {
var circleCfg = {};
var rangeX = coord.x;
var rangeY = coord.y;
var isReflectY = rangeY.start > rangeY.end;
var start;
if (coord.isTransposed) {
start = {
x: isReflectY ? 0 : 1,
y: 0
};
} else {
start = {
x: 0,
y: isReflectY ? 0 : 1
};
}
start = coord.convert(start);
var center = coord.circleCentre;
var startVector = [start.x - center.x, start.y - center.y];
var normalVector = [1, 0];
var startAngle;
if (start.y > center.y) {
startAngle = vec2.angle(startVector, normalVector);
} else {
startAngle = vec2.angle(startVector, normalVector) * -1;
}
var endAngle = startAngle + (rangeX.end - rangeX.start);
circleCfg.startAngle = startAngle;
circleCfg.endAngle = endAngle;
circleCfg.center = center;
circleCfg.radius = Math.sqrt(Math.pow(start.x - center.x, 2) + Math.pow(start.y - center.y, 2));
circleCfg.inner = coord.innerRadius || 0;
return circleCfg;
};
_proto._getRadiusCfg = function _getRadiusCfg(coord) {
var startAngle = coord.x.start;
var factor = startAngle < 0 ? -1 : 1;
var start;
var end;
if (coord.isTransposed) {
start = {
x: 0,
y: 0
};
end = {
x: 1,
y: 0
};
} else {
start = {
x: 0,
y: 0
};
end = {
x: 0,
y: 1
};
}
return {
factor: factor,
start: coord.convert(start),
end: coord.convert(end)
};
}; // 确定坐标轴的位置
_proto._getAxisPosition = function _getAxisPosition(coord, dimType, index, field) {
var position = ''; // 用户自己定义了 position
var options = this.options; // const VALID_POSITIONS = [
// 'top',
// 'left',
// 'right',
// 'bottom'
// ];
if (options[field] && options[field].position) {
position = options[field].position; // if (VALID_POSITIONS.indexOf(position) > -1) {
// return position;
// }
} else {
var coordType = coord.type;
if (coord.isRect) {
if (dimType === 'x') {
position = 'bottom';
} else if (dimType === 'y') {
if (index) {
position = 'right';
} else {
position = 'left';
}
}
} else if (coordType === 'helix') {
position = 'helix';
} else if (dimType === 'x') {
position = coord.isTransposed ? 'radius' : 'circle';
} else {
position = coord.isTransposed ? 'circle' : 'radius';
}
}
return position;
}; // 获取坐标轴构成的配置信息
_proto._getAxisDefaultCfg = function _getAxisDefaultCfg(coord, scale, type, position) {
var self = this;
var viewTheme = self.viewTheme;
var cfg = {};
var options = self.options;
var field = scale.field;
cfg = Util.deepMix({}, viewTheme.axis[position], cfg, options[field]);
cfg.viewTheme = viewTheme;
if (cfg.title) {
var title = Util.isPlainObject(cfg.title) ? cfg.title : {};
title.text = title.text || scale.alias || field;
Util.deepMix(cfg, {
title: title
});
}
cfg.ticks = scale.getTicks();
if (coord.isPolar && !scale.isCategory) {
if (type === 'x' && Math.abs(coord.endAngle - coord.startAngle) === Math.PI * 2) {
cfg.ticks.pop();
}
}
cfg.coord = coord;
if (cfg.label && Util.isNil(cfg.label.autoRotate)) {
cfg.label.autoRotate = true; // 允许自动旋转,避免重叠
}
if (options.hasOwnProperty('xField') && options.xField.hasOwnProperty('grid')) {
if (cfg.position === 'left') {
Util.deepMix(cfg, options.xField);
}
}
return cfg;
}; // 确定坐标轴的配置信息
_proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, index, viewId) {
if (index === void 0) {
index = '';
}
var self = this;
var position = self._getAxisPosition(coord, dimType, index, scale.field);
var cfg = self._getAxisDefaultCfg(coord, scale, dimType, position);
if (!Util.isEmpty(cfg.grid) && verticalScale) {
// 生成 gridPoints
var gridPoints = [];
var tickValues = [];
var verticalTicks = formatTicks(verticalScale.getTicks()); // 没有垂直的坐标点时不会只栅格
if (verticalTicks.length) {
var ticks = fillAxisTicks(cfg.ticks, scale.isLinear, cfg.grid.align === 'center');
Util.each(ticks, function (tick, idx) {
tickValues.push(tick.tickValue);
var subPoints = [];
var value = tick.value;
if (cfg.grid.align === 'center') {
value = self._getMiddleValue(value, ticks, idx, scale.isLinear);
}
if (!Util.isNil(value)) {
var rangeX = coord.x;
var rangeY = coord.y;
Util.each(verticalTicks, function (verticalTick) {
var x = dimType === 'x' ? value : verticalTick.value;
var y = dimType === 'x' ? verticalTick.value : value;
var point = coord.convert({
x: x,
y: y
});
if (coord.isPolar) {
var center = coord.circleCentre;
if (rangeY.start > rangeY.end) {
y = 1 - y;
}
point.flag = rangeX.start > rangeX.end ? 0 : 1;
point.radius = Math.sqrt(Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2));
}
subPoints.push(point);
});
gridPoints.push({
_id: viewId + '-' + dimType + index + '-grid-' + tick.tickValue,
points: subPoints
});
}
});
}
cfg.grid.items = gridPoints;
cfg.grid.tickValues = tickValues;
}
cfg.type = scale.type;
return cfg;
};
_proto._getHelixCfg = function _getHelixCfg(coord) {
var helixCfg = {};
var a = coord.a;
var startAngle = coord.startAngle;
var endAngle = coord.endAngle;
var index = 100;
var crp = [];
for (var i = 0; i <= index; i++) {
var point = coord.convert({
x: i / 100,
y: 0
});
crp.push(point.x);
crp.push(point.y);
}
var axisStart = coord.convert({
x: 0,
y: 0
});
helixCfg.a = a;
helixCfg.startAngle = startAngle;
helixCfg.endAngle = endAngle;
helixCfg.crp = crp;
helixCfg.axisStart = axisStart;
helixCfg.center = coord.center;
helixCfg.inner = coord.y.start; // 内半径
return helixCfg;
};
_proto._drawAxis = function _drawAxis(coord, scale, verticalScale, dimType, viewId, xAxis, index) {
var container = this.container;
var canvas = this.canvas;
var C; // 坐标轴类
var appendCfg; // 每个坐标轴 start end 等绘制边界的信息
if (coord.type === 'cartesian') {
C = Axis.Line;
appendCfg = this._getLineCfg(coord, scale, dimType, index);
} else if (coord.type === 'helix' && dimType === 'x') {
C = Axis.Helix;
appendCfg = this._getHelixCfg(coord);
} else if (dimType === 'x') {
C = Axis.Circle;
appendCfg = this._getCircleCfg(coord);
} else {
C = Axis.Line;
appendCfg = this._getRadiusCfg(coord);
}
var cfg = this._getAxisCfg(coord, scale, verticalScale, dimType, index, viewId);
cfg = Util.mix({}, cfg, appendCfg);
if (dimType === 'y' && xAxis && xAxis.get('type') === 'circle') {
cfg.circle = xAxis;
}
cfg._id = viewId + '-' + dimType;
if (!Util.isNil(index)) {
cfg._id = viewId + '-' + dimType + index;
}
Util.mix(cfg, {
canvas: canvas,
group: container
});
var axis = new C(cfg);
axis.render();
this.axes.push(axis);
return axis;
};
_proto.createAxis = function createAxis(xScale, yScales, viewId) {
var self = this;
var coord = this.coord;
var coordType = coord.type; // theta坐标系默认不绘制坐标轴
if (coordType !== 'theta' && !(coordType === 'polar' && coord.isTransposed)) {
var xAxis;
if (xScale && !self._isHide(xScale.field)) {
xAxis = self._drawAxis(coord, xScale, yScales[0], 'x', viewId); // 绘制 x 轴
}
if (!Util.isEmpty(yScales) && coordType !== 'helix') {
Util.each(yScales, function (yScale, index) {
if (!self._isHide(yScale.field)) {
self._drawAxis(coord, yScale, xScale, 'y', viewId, xAxis, index);
}
});
}
}
};
_proto.changeVisible = function changeVisible(visible) {
var axes = this.axes;
Util.each(axes, function (axis) {
axis.set('visible', visible);
});
};
_proto.clear = function clear() {
var self = this;
var axes = self.axes;
Util.each(axes, function (axis) {
axis.clear();
});
self.axes = [];
};
return AxisController;
}();
module.exports = AxisController;
/***/ }),
/* 267 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The controller of coordinate
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var Coord = __webpack_require__(262);
var CoordController =
/*#__PURE__*/
function () {
function CoordController(option) {
this.type = 'rect';
this.actions = [];
this.cfg = {};
Util.mix(this, option);
this.option = option || {};
}
var _proto = CoordController.prototype;
_proto.reset = function reset(coordOption) {
this.actions = coordOption.actions || [];
this.type = coordOption.type;
this.cfg = coordOption.cfg;
this.option.actions = this.actions;
this.option.type = this.type;
this.option.cfg = this.cfg;
return this;
};
_proto._execActions = function _execActions(coord) {
var actions = this.actions;
Util.each(actions, function (action) {
var m = action[0];
coord[m](action[1], action[2]);
});
};
_proto.hasAction = function hasAction(actionName) {
var actions = this.actions;
var rst = false;
Util.each(actions, function (action) {
if (actionName === action[0]) {
rst = true;
return false;
}
});
return rst;
};
/**
* 创建坐标系对象
* @param {Object} start 坐标系起始点
* @param {Object} end 坐标系结束点
* @return {Function} 坐标系的构造函数
*/
_proto.createCoord = function createCoord(start, end) {
var self = this;
var type = self.type;
var cfg = self.cfg;
var C; // 构造函数
var coord;
var coordCfg = Util.mix({
start: start,
end: end
}, cfg);
if (type === 'theta') {
// definition of theta coord
C = Coord.Polar;
if (!self.hasAction('transpose')) {
self.transpose(); // 极坐标,同时transpose
}
coord = new C(coordCfg);
coord.type = type;
} else {
C = Coord[Util.upperFirst(type || '')] || Coord.Rect;
coord = new C(coordCfg);
}
self._execActions(coord);
return coord;
};
_proto.rotate = function rotate(angle) {
angle = angle * Math.PI / 180;
this.actions.push(['rotate', angle]);
return this;
};
_proto.reflect = function reflect(dim) {
this.actions.push(['reflect', dim]);
return this;
};
_proto.scale = function scale(sx, sy) {
this.actions.push(['scale', sx, sy]);
return this;
};
_proto.transpose = function transpose() {
this.actions.push(['transpose']);
return this;
};
return CoordController;
}();
module.exports = CoordController;
/***/ }),
/* 268 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The controller of chart's events
* @author sima.zhang
*/
var Util = __webpack_require__(0);
function isSameShape(shape1, shape2) {
if (Util.isNil(shape1) || Util.isNil(shape2)) {
return false;
}
var shape1Origin = shape1.get('origin');
var shape2Origin = shape2.get('origin'); // hotfix: if both shapes have no data,just compare shapes.
if (Util.isNil(shape1Origin) && Util.isNil(shape2Origin)) {
return Util.isEqual(shape1, shape2);
}
return Util.isEqual(shape1Origin, shape2Origin);
}
function registerData(eventObj) {
if (eventObj.shape && eventObj.shape.get('origin')) {
eventObj.data = eventObj.shape.get('origin');
}
}
var EventController =
/*#__PURE__*/
function () {
function EventController(cfg) {
this.view = null;
this.canvas = null;
Util.assign(this, cfg);
this._init();
}
var _proto = EventController.prototype;
_proto._init = function _init() {
this.pixelRatio = this.canvas.get('pixelRatio');
};
_proto._getShapeEventObj = function _getShapeEventObj(ev) {
return {
x: ev.x / this.pixelRatio,
y: ev.y / this.pixelRatio,
target: ev.target,
// canvas 元素
toElement: ev.event.toElement || ev.event.relatedTarget
};
};
_proto._getShape = function _getShape(x, y) {
var view = this.view;
var container = view.get('canvas');
return container.getShape(x, y);
};
_proto._getPointInfo = function _getPointInfo(ev) {
var view = this.view;
var point = {
x: ev.x / this.pixelRatio,
y: ev.y / this.pixelRatio
};
var views = view.getViewsByPoint(point);
point.views = views;
return point;
};
_proto._getEventObj = function _getEventObj(ev, point, views) {
return {
x: point.x,
y: point.y,
target: ev.target,
// canvas 元素
toElement: ev.event.toElement || ev.event.relatedTarget,
// 目标元素
views: views
};
};
_proto.bindEvents = function bindEvents() {
var canvas = this.canvas;
canvas.on('mousedown', Util.wrapBehavior(this, 'onDown'));
canvas.on('mousemove', Util.wrapBehavior(this, 'onMove'));
canvas.on('mouseleave', Util.wrapBehavior(this, 'onOut'));
canvas.on('mouseup', Util.wrapBehavior(this, 'onUp'));
canvas.on('click', Util.wrapBehavior(this, 'onClick'));
canvas.on('dblclick', Util.wrapBehavior(this, 'onClick'));
canvas.on('touchstart', Util.wrapBehavior(this, 'onTouchstart'));
canvas.on('touchmove', Util.wrapBehavior(this, 'onTouchmove'));
canvas.on('touchend', Util.wrapBehavior(this, 'onTouchend'));
};
_proto._triggerShapeEvent = function _triggerShapeEvent(shape, eventName, eventObj) {
if (shape && shape.name && !shape.get('destroyed')) {
var view = this.view;
if (view.isShapeInView(shape)) {
var name = shape.name + ':' + eventName;
eventObj.view = view;
eventObj.appendInfo = shape.get('appendInfo'); // appendInfo is defined by user
view.emit(name, eventObj);
var parent = view.get('parent');
if (parent) {
// chart 上也需要抛出该事件,本期先不抛出
parent.emit(name, eventObj);
}
}
}
};
_proto.onDown = function onDown(ev) {
var view = this.view;
var eventObj = this._getShapeEventObj(ev);
eventObj.shape = this.currentShape;
registerData(eventObj);
view.emit('mousedown', eventObj);
this._triggerShapeEvent(this.currentShape, 'mousedown', eventObj);
};
_proto.onMove = function onMove(ev) {
var self = this;
var view = self.view;
var currentShape = self.currentShape; // 如果图形被销毁,则设置当前 shape 为空
if (currentShape && currentShape.get('destroyed')) {
currentShape = null;
self.currentShape = null;
}
var shape = self._getShape(ev.x, ev.y) || ev.currentTarget;
var eventObj = self._getShapeEventObj(ev);
eventObj.shape = shape;
registerData(eventObj);
view.emit('mousemove', eventObj);
self._triggerShapeEvent(shape, 'mousemove', eventObj);
if (currentShape && !isSameShape(currentShape, shape)) {
var leaveObj = self._getShapeEventObj(ev);
leaveObj.shape = currentShape;
leaveObj.toShape = shape;
registerData(leaveObj);
self._triggerShapeEvent(currentShape, 'mouseleave', leaveObj);
}
if (shape && !isSameShape(currentShape, shape)) {
var enterObj = self._getShapeEventObj(ev);
enterObj.shape = shape;
enterObj.fromShape = currentShape;
registerData(enterObj);
self._triggerShapeEvent(shape, 'mouseenter', enterObj);
}
self.currentShape = shape;
var point = self._getPointInfo(ev);
var preViews = self.curViews || [];
if (preViews.length === 0 && point.views.length) {
view.emit('plotenter', self._getEventObj(ev, point, point.views));
} // point.views 是指当前 view 或者子 view,不会取跟当前 view 同一层级的兄弟元素(view)
if (preViews.length && point.views.length === 0) {
view.emit('plotleave', self._getEventObj(ev, point, preViews));
}
if (point.views.length) {
eventObj = self._getEventObj(ev, point, point.views);
eventObj.shape = shape;
registerData(eventObj);
view.emit('plotmove', eventObj);
}
self.curViews = point.views;
};
_proto.onOut = function onOut(ev) {
var self = this;
var view = self.view;
var point = self._getPointInfo(ev);
var preViews = self.curViews || [];
var evtObj = self._getEventObj(ev, point, preViews); // 只有没有padding 时,当前依然在 view 的 plotRange 情况下才会出现这个情况,保证 plotleave 触发
if (self.curViews && self.curViews.length !== 0 && (!evtObj.toElement || evtObj.toElement.tagName !== 'CANVAS')) {
view.emit('plotleave', evtObj);
self.curViews = []; // 清空
}
};
_proto.onUp = function onUp(ev) {
var view = this.view;
var eventObj = this._getShapeEventObj(ev);
eventObj.shape = this.currentShape;
view.emit('mouseup', eventObj);
this._triggerShapeEvent(this.currentShape, 'mouseup', eventObj);
};
_proto.onClick = function onClick(ev) {
var self = this;
var view = self.view;
var shape = self._getShape(ev.x, ev.y) || ev.currentTarget;
var shapeEventObj = self._getShapeEventObj(ev);
shapeEventObj.shape = shape;
registerData(shapeEventObj);
view.emit('click', shapeEventObj);
self._triggerShapeEvent(shape, ev.type, shapeEventObj);
self.currentShape = shape;
var point = self._getPointInfo(ev);
var views = point.views;
if (!Util.isEmpty(views)) {
var eventObj = self._getEventObj(ev, point, views);
if (self.currentShape) {
var _shape = self.currentShape;
eventObj.shape = _shape;
registerData(eventObj); // eventObj.data = shape.get('origin');
}
view.emit('plotclick', eventObj);
if (ev.type === 'dblclick') {
view.emit('plotdblclick', eventObj);
view.emit('dblclick', shapeEventObj);
}
}
};
_proto.onTouchstart = function onTouchstart(ev) {
var view = this.view;
var shape = this._getShape(ev.x, ev.y) || ev.currentTarget;
var eventObj = this._getShapeEventObj(ev);
eventObj.shape = shape;
registerData(eventObj);
view.emit('touchstart', eventObj);
this._triggerShapeEvent(shape, 'touchstart', eventObj);
this.currentShape = shape;
};
_proto.onTouchmove = function onTouchmove(ev) {
var view = this.view;
var shape = this._getShape(ev.x, ev.y) || ev.currentTarget;
var eventObj = this._getShapeEventObj(ev);
eventObj.shape = shape;
registerData(eventObj);
view.emit('touchmove', eventObj);
this._triggerShapeEvent(shape, 'touchmove', eventObj);
this.currentShape = shape;
};
_proto.onTouchend = function onTouchend(ev) {
var view = this.view;
var eventObj = this._getShapeEventObj(ev);
eventObj.shape = this.currentShape;
registerData(eventObj);
view.emit('touchend', eventObj);
this._triggerShapeEvent(this.currentShape, 'touchend', eventObj);
};
_proto.clearEvents = function clearEvents() {
var canvas = this.canvas;
canvas.off('mousemove', Util.getWrapBehavior(this, 'onMove'));
canvas.off('mouseleave', Util.getWrapBehavior(this, 'onOut'));
canvas.off('mousedown', Util.getWrapBehavior(this, 'onDown'));
canvas.off('mouseup', Util.getWrapBehavior(this, 'onUp'));
canvas.off('click', Util.getWrapBehavior(this, 'onClick'));
canvas.off('dblclick', Util.getWrapBehavior(this, 'onClick'));
canvas.off('touchstart', Util.getWrapBehavior(this, 'onTouchstart'));
canvas.off('touchmove', Util.getWrapBehavior(this, 'onTouchmove'));
canvas.off('touchend', Util.getWrapBehavior(this, 'onTouchend'));
};
return EventController;
}();
module.exports = EventController;
/***/ }),
/* 269 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(0);
var Guide = __webpack_require__(274);
var GuideController =
/*#__PURE__*/
function () {
function GuideController(cfg) {
this.guides = [];
this.options = [];
this.xScales = null;
this.yScales = null;
this.view = null;
this.viewTheme = null;
this.frontGroup = null;
this.backGroup = null;
Util.mix(this, cfg);
}
var _proto = GuideController.prototype;
_proto._creatGuides = function _creatGuides() {
var self = this;
var options = this.options;
var xScales = this.xScales;
var yScales = this.yScales;
var view = this.view;
var viewTheme = this.viewTheme; // @2019-01-18 by blue.lb 这里如果给 backContainer 添加 group 的话,会直接导致 BBoxOfBackPlot 函数中计算 element.getBBox() 出错
if (this.backContainer && view) {
this.backGroup = this.backContainer.addGroup({
viewId: view.get('_id')
});
}
if (this.frontContainer && view) {
this.frontGroup = this.frontContainer.addGroup({
viewId: view.get('_id')
});
}
options.forEach(function (option) {
var type = option.type;
var config = Util.deepMix({
xScales: xScales,
yScales: yScales,
viewTheme: viewTheme
}, viewTheme ? viewTheme.guide[type] : {}, option);
type = Util.upperFirst(type);
var guide = new Guide[type](config);
self.guides.push(guide);
});
return self.guides;
};
_proto.line = function line(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'line'
}, cfg));
return this;
};
_proto.arc = function arc(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'arc'
}, cfg));
return this;
};
_proto.text = function text(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'text'
}, cfg));
return this;
};
_proto.image = function image(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'image'
}, cfg));
return this;
};
_proto.region = function region(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'region'
}, cfg));
return this;
};
_proto.regionFilter = function regionFilter(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'regionFilter'
}, cfg));
return this;
};
_proto.dataMarker = function dataMarker(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'dataMarker'
}, cfg));
return this;
};
_proto.dataRegion = function dataRegion(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'dataRegion'
}, cfg));
return this;
};
_proto.html = function html(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.options.push(Util.mix({
type: 'html'
}, cfg));
return this;
};
_proto.render = function render(coord) {
var self = this;
var view = self.view;
var viewData = view && view.get('data');
var guides = self._creatGuides();
Util.each(guides, function (guide) {
var container;
if (guide.get('top')) {
// 默认 guide 绘制到 backPlot,用户也可以声明 top: true,显示在最上层
// @2019-01-18 by blue.lb 直接用传入的就行
container = self.frontGroup || self.frontContainer; // container = self.frontContainer;
} else {
// @2019-01-18 by blue.lb 直接用传入的就行
container = self.backGroup || self.backContainer; // container = self.backContainer;
}
guide.render(coord, container, viewData, view);
});
};
_proto.clear = function clear() {
this.options = [];
this.reset();
};
_proto.changeVisible = function changeVisible(visible) {
var guides = this.guides;
Util.each(guides, function (guide) {
guide.changeVisible(visible);
});
};
_proto.reset = function reset() {
var guides = this.guides;
Util.each(guides, function (guide) {
guide.clear();
});
this.guides = []; // @2019-01-18 by blue.lb 删除这部分
this.backGroup && this.backGroup.remove();
this.frontGroup && this.frontGroup.remove();
};
return GuideController;
}();
module.exports = GuideController;
/***/ }),
/* 270 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(0);
var _require = __webpack_require__(29),
Legend = _require.Legend;
var Tail = __webpack_require__(276);
var Shape = __webpack_require__(9);
var bboxOfBackPlot = __webpack_require__(116);
var plotRange2BBox = __webpack_require__(118);
var FIELD_ORIGIN = '_origin';
var MARKER_SIZE = 4.5;
var requireAnimationFrameFn = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
var STROKE_MARKERS = ['cross', 'tick', 'plus', 'hyphen', 'line', 'hollowCircle', 'hollowSquare', 'hollowDiamond', 'hollowTriangle', 'hollowTriangleDown', 'hollowHexagon', 'hollowBowtie'];
function _snapEqual(v1, v2, scale) {
var isEqual;
if (Util.isNil(scale)) {
return false;
}
v1 = scale.translate(v1);
v2 = scale.translate(v2);
if (scale.isCategory) {
isEqual = v1 === v2;
} else {
isEqual = Math.abs(v1 - v2) <= 1;
}
return isEqual;
}
function findGeom(geoms, value) {
var rst;
Util.each(geoms, function (geom) {
if (geom.get('visible')) {
var yScale = geom.getYScale();
if (yScale.field === value) {
rst = geom;
return;
}
}
});
return rst;
}
var LegendController =
/*#__PURE__*/
function () {
function LegendController(cfg) {
var self = this;
self.options = {};
Util.mix(self, cfg);
self.clear();
var chart = self.chart;
self.container = chart.get('frontPlot');
self.plotRange = chart.get('plotRange');
}
var _proto = LegendController.prototype;
_proto.clear = function clear() {
var legends = this.legends;
this.backRange = null;
Util.each(legends, function (legendItems) {
Util.each(legendItems, function (legend) {
legend.destroy();
});
});
this.legends = {};
}; // 获取坐标轴等背景元素占的范围,防止遮挡坐标轴
_proto.getBackRange = function getBackRange() {
var backRange = this.backRange;
if (!backRange) {
var backPlot = this.chart.get('backPlot');
backRange = bboxOfBackPlot(backPlot, plotRange2BBox(this.chart.get('plotRange')));
var plotRange = this.plotRange;
if (backRange.maxX - backRange.minX < plotRange.br.x - plotRange.tl.x && backRange.maxY - backRange.minY < plotRange.br.y - plotRange.tl.y) {
// 如果背景小于则直接使用 plotRange
backRange = {
minX: plotRange.tl.x,
minY: plotRange.tl.y,
maxX: plotRange.br.x,
maxY: plotRange.br.y
};
}
this.backRange = backRange;
}
return backRange;
};
_proto._isFieldInView = function _isFieldInView(field, value, view) {
var flag = false;
var scales = view.get('scales');
var fieldScale = scales[field];
if (fieldScale && fieldScale.values) {
flag = Util.inArray(fieldScale.values, value);
}
return flag;
};
_proto._bindClickEvent = function _bindClickEvent(legend, scale, filterVals) {
var self = this;
var chart = self.chart;
var views = chart.get('views');
var field = scale.field;
var options = self.options;
legend.on('itemclick', function (ev) {
if (options.onClick && options.defaultClickHandlerEnabled !== true) {
options.onClick(ev);
} else {
// if 'defaultClickHandlerEnabled' is true the default click behavior would be worked.
var item = ev.item;
var checked = ev.checked;
var isSingleSelected = legend.get('selectedMode') === 'single'; // 图例的选中模式
var clickedValue = item.dataValue; // import: 需要取该图例项原始的数值
if (checked) {
Util.Array.remove(filterVals, clickedValue);
if (self._isFieldInView(field, clickedValue, chart)) {
chart.filter(field, function (field) {
return isSingleSelected ? field === clickedValue : !Util.inArray(filterVals, field);
});
}
Util.each(views, function (view) {
if (self._isFieldInView(field, clickedValue, view)) {
view.filter(field, function (field) {
return isSingleSelected ? field === clickedValue : !Util.inArray(filterVals, field);
});
}
});
} else if (!isSingleSelected) {
filterVals.push(clickedValue);
if (self._isFieldInView(field, clickedValue, chart)) {
chart.filter(field, function (field) {
return !Util.inArray(filterVals, field);
});
}
Util.each(views, function (view) {
if (self._isFieldInView(field, clickedValue, view)) {
view.filter(field, function (field) {
return !Util.inArray(filterVals, field);
});
}
});
}
if (options.onClick) {
options.onClick(ev);
}
chart.set('keepLegend', true); // 图例不重新渲染
chart.set('keepPadding', true); // 边框不重新计算
chart.repaint();
chart.set('keepPadding', false);
chart.set('keepLegend', false);
}
});
};
_proto._bindClickEventForMix = function _bindClickEventForMix(legend) {
var self = this;
var chart = self.chart;
var geoms = chart.getAllGeoms();
legend.on('itemclick', function (ev) {
var itemField = ev.item.field;
var checked = ev.checked;
if (checked) {
Util.each(geoms, function (geom) {
var field = geom.getYScale().field;
if (field === itemField) {
geom.show();
}
});
} else {
Util.each(geoms, function (geom) {
var field = geom.getYScale().field;
if (field === itemField) {
geom.hide();
}
});
}
});
};
_proto._filterLabels = function _filterLabels(shape, geom, visible) {
if (shape.get('gLabel')) {
shape.get('gLabel').set('visible', visible);
} else {
var labelCfg = geom.get('labelCfg');
if (labelCfg && labelCfg.fields && labelCfg.fields.length > 0) {
var xScale = geom.getXScale();
var yScale = geom.getYScale();
var xField = xScale.field;
var yField = yScale.field;
var shapeData = shape.get('origin')._origin;
var labelContainer = geom.get('labelContainer');
var labels = labelContainer.get('labelsGroup').get('children');
Util.each(labels, function (label) {
var labelData = label.get('origin') || [];
if (labelData[xField] === shapeData[xField] && labelData[yField] === shapeData[yField]) {
label.set('visible', visible);
shape.set('gLabel', label);
}
});
}
}
};
_proto._bindFilterEvent = function _bindFilterEvent(legend, scale) {
var self = this;
var chart = this.chart;
var field = scale.field;
legend.on('itemfilter', function (ev) {
var range = ev.range;
chart.filterShape(function (obj, shape, geom) {
// @2018-12-21 by blue.lb 由于数值0直接被类型转换为false,这里需要做更精确一点的判断
if (!Util.isNil(obj[field])) {
var filtered = obj[field] >= range[0] && obj[field] <= range[1]; // shape 带 label,则还需要隐藏 label
self._filterLabels(shape, geom, filtered);
return filtered;
}
return true;
});
var geoms = chart.getAllGeoms() || [];
var _loop = function _loop(i) {
var geom = geoms[i];
if (geom.get('type') === 'heatmap') {
requireAnimationFrameFn(function () {
geom.drawWithRange(range);
});
}
};
for (var i = 0; i < geoms.length; i++) {
_loop(i);
}
});
};
_proto._getShapeData = function _getShapeData(shape) {
var originData = shape.get('origin');
if (Util.isArray(originData)) {
originData = originData[0];
}
return originData[FIELD_ORIGIN];
};
_proto._bindHoverEvent = function _bindHoverEvent(legend, field) {
var self = this;
var chart = self.chart;
var geoms = chart.getAllGeoms();
var options = self.options;
var canvas = chart.get('canvas');
legend.on('itemhover', function (ev) {
var value = ev.item.value;
var pre = self.pre;
if (!pre) {
Util.each(geoms, function (geom) {
var shapeContainer = geom.get('shapeContainer');
var shapes = geom.getShapes();
var activeShapes = [];
if (field) {
var scale = geom.get('scales')[field];
Util.each(shapes, function (shape) {
var origin = self._getShapeData(shape);
if (origin && _snapEqual(origin[field], value, scale)) {
activeShapes.push(shape);
}
});
} else if (geom.getYScale().field === value) {
activeShapes = shapes;
}
if (!Util.isEmpty(activeShapes)) {
ev.shapes = activeShapes;
ev.geom = geom;
if (options.onHover) {
options.onHover(ev);
shapeContainer.sort();
canvas.draw();
} else {
geom.setShapesActived(activeShapes);
}
}
});
self.pre = value;
} else if (pre === value) {
return;
}
});
legend.on('itemunhover', function (ev) {
self.pre = null;
if (options.onUnhover) {
options.onUnhover(ev);
}
Util.each(geoms, function (geom) {
if (geom.get('activeShapes')) {
geom.clearActivedShapes();
canvas.draw();
}
});
});
};
_proto._isFiltered = function _isFiltered(scale, filterVals, scaleValue) {
if (!scale.isCategory) {
return true;
}
var rst = true;
scaleValue = scale.invert(scaleValue);
Util.each(filterVals, function (val) {
if (scale.getText(val) === scale.getText(scaleValue)) {
rst = false;
return false;
}
});
return rst;
};
_proto._alignLegend = function _alignLegend(legend, pre, region, position) {
var self = this;
var viewTheme = self.viewTheme;
var container = self.container;
var canvas = container.get('canvas');
var width = canvas.get('width');
var height = canvas.get('height');
var totalRegion = self.totalRegion;
var plotRange = self.plotRange;
var backRange = self.getBackRange(); // 背景占得范围
var offsetX = legend.get('offset')[0] || 0;
var offsetY = legend.get('offset')[1] || 0; // const offset = Util.isNil(legend.get('offset')) ? MARGIN : legend.get('offset');
var legendHeight = legend.getHeight();
var legendWidth = legend.getWidth();
var borderMargin = viewTheme.legend.margin;
var innerMargin = viewTheme.legend.legendMargin;
var legendNum = self.legends[position].length;
var posArray = position.split('-');
var x = 0;
var y = 0;
var tempoRegion = legendNum > 1 ? totalRegion : region;
if (posArray[0] === 'left' || posArray[0] === 'right') {
height = plotRange.br.y;
x = self._getXAlign(posArray[0], width, region, backRange, legendWidth, borderMargin);
if (pre) {
// @2018-10-19 by blue.lb 由于legend中并不存在y属性,这里需要先获取group再获取y值
// @2019-03-21 by blue.lb 由于内部实现问题,usehtml部分的实例可以直接获取x、y的
y = (pre.get('y') || pre.get('group').get('y')) + pre.getHeight() + innerMargin;
} else {
y = self._getYAlignVertical(posArray[1], height, tempoRegion, backRange, 0, borderMargin, canvas.get('height'));
}
} else if (posArray[0] === 'top' || posArray[0] === 'bottom') {
y = self._getYAlignHorizontal(posArray[0], height, region, backRange, legendHeight, borderMargin);
if (pre) {
var preWidth = pre.getWidth(); // @2018-10-19 by blue.lb 由于legend中并不存在x属性,这里需要先获取group再获取x值
// @2019-03-21 by blue.lb 由于内部实现问题,usehtml部分的实例可以直接获取x、y的
x = (pre.get('x') || pre.get('group').get('x')) + preWidth + innerMargin;
} else {
x = self._getXAlign(posArray[1], width, tempoRegion, backRange, 0, borderMargin);
if (posArray[1] === 'right') x = plotRange.br.x - tempoRegion.totalWidth;
}
}
legend.move(x + offsetX, y + offsetY);
};
_proto._getXAlign = function _getXAlign(pos, width, region, backRange, legendWidth, borderMargin) {
var x = pos === 'left' ? backRange.minX - legendWidth - borderMargin[3] : backRange.maxX + borderMargin[1];
if (pos === 'center') {
x = (width - region.totalWidth) / 2;
}
return x;
};
_proto._getYAlignHorizontal = function _getYAlignHorizontal(pos, height, region, backRange, legendHeight, borderMargin) {
var y = pos === 'top' ? backRange.minY - legendHeight - borderMargin[0] : backRange.maxY + borderMargin[2];
return y;
};
_proto._getYAlignVertical = function _getYAlignVertical(pos, height, region, backRange, legendHeight, borderMargin, canvasHeight) {
var y = pos === 'top' ? backRange.minY - legendHeight - borderMargin[0] : height - region.totalHeight;
if (pos === 'center') {
y = (canvasHeight - region.totalHeight) / 2;
}
return y;
};
_proto._getSubRegion = function _getSubRegion(legends) {
var maxWidth = 0;
var maxHeight = 0;
var totalWidth = 0;
var totalHeight = 0;
Util.each(legends, function (legend) {
var width = legend.getWidth();
var height = legend.getHeight();
if (maxWidth < width) {
maxWidth = width;
}
totalWidth += width;
if (maxHeight < height) {
maxHeight = height;
}
totalHeight += height;
});
return {
maxWidth: maxWidth,
totalWidth: totalWidth,
maxHeight: maxHeight,
totalHeight: totalHeight
};
};
_proto._getRegion = function _getRegion() {
var self = this;
var viewTheme = self.viewTheme;
var legends = self.legends;
var innerMargin = viewTheme.legend.legendMargin;
var subs = [];
var totalWidth = 0;
var totalHeight = 0;
Util.each(legends, function (legendItems) {
var subRegion = self._getSubRegion(legendItems);
subs.push(subRegion);
totalWidth += subRegion.totalWidth + innerMargin;
totalHeight += subRegion.totalHeight + innerMargin;
});
return {
totalWidth: totalWidth,
totalHeight: totalHeight,
subs: subs
};
};
_proto._addCategoryLegend = function _addCategoryLegend(scale, attr, geom, filterVals, position) {
var self = this;
var field = scale.field;
var legendOptions = self.options;
var fieldOption = legendOptions[field];
if (fieldOption) {
legendOptions = fieldOption;
}
var legends = self.legends;
legends[position] = legends[position] || [];
var container = self.container;
var items = [];
var ticks = scale.getTicks();
var isByAttr = true;
var shapeType = geom.get('shapeType') || 'point';
var shape = geom.getDefaultValue('shape') || 'circle';
if (legendOptions[field] && legendOptions[field].marker) {
// 用户为 field 对应的图例定义了 marker
shape = legendOptions[field].marker;
shapeType = 'point';
isByAttr = false;
} else if (legendOptions.marker) {
shape = legendOptions.marker;
shapeType = 'point';
isByAttr = false;
}
var chart = self.chart;
var viewTheme = self.viewTheme;
var canvas = chart.get('canvas');
var plotRange = self.plotRange;
var posArray = position.split('-');
var maxLength = posArray[0] === 'right' || posArray[0] === 'left' ? plotRange.bl.y - plotRange.tr.y : canvas.get('width');
Util.each(ticks, function (tick) {
var text = tick.text;
var name = text;
var scaleValue = tick.value;
var value = scale.invert(scaleValue);
var cfg = {
isInCircle: geom.isInCircle()
};
var checked = filterVals ? self._isFiltered(scale, filterVals, scaleValue) : true;
var colorAttr = geom.getAttr('color');
var shapeAttr = geom.getAttr('shape');
if (colorAttr) {
// 存在颜色映射
if (colorAttr.callback && colorAttr.callback.length > 1) {
// 多参数映射,阻止程序报错
var restArgs = Array(colorAttr.callback.length - 1).fill('');
cfg.color = colorAttr.mapping.apply(colorAttr, [value].concat(restArgs)).join('') || viewTheme.defaultColor;
} else {
cfg.color = colorAttr.mapping(value).join('') || viewTheme.defaultColor;
}
}
if (isByAttr && shapeAttr) {
// 存在形状映射
if (shapeAttr.callback && shapeAttr.callback.length > 1) {
// 多参数映射,阻止程序报错
var _restArgs = Array(shapeAttr.callback.length - 1).fill('');
shape = shapeAttr.mapping.apply(shapeAttr, [value].concat(_restArgs)).join('');
} else {
shape = shapeAttr.mapping(value).join('');
}
}
var shapeObject = Shape.getShapeFactory(shapeType);
var marker = shapeObject.getMarkerCfg(shape, cfg);
if (Util.isFunction(shape)) {
marker.symbol = shape;
}
items.push({
value: name,
// 图例项显示文本的内容
dataValue: value,
// 图例项对应原始数据中的数值
checked: checked,
marker: marker
});
});
var legendCfg = Util.deepMix({}, viewTheme.legend[posArray[0]], legendOptions[field] || legendOptions, {
viewId: chart.get('_id'),
maxLength: maxLength,
items: items,
container: container,
position: [0, 0]
});
if (legendCfg.title) {
Util.deepMix(legendCfg, {
title: {
text: scale.alias || scale.field
}
});
}
var legend;
if (self._isTailLegend(legendOptions, geom)) {
legendCfg.chart = self.chart;
legendCfg.geom = geom;
legend = new Tail(legendCfg);
} else {
if (legendOptions.useHtml) {
var canvasEle = container.get('canvas').get('el');
container = legendOptions.container;
if (Util.isString(container) && /^\#/.test(container)) {
// 如果传入 dom 节点的 id
var id = container.replace('#', '');
container = document.getElementById(id);
}
if (!container) {
container = canvasEle.parentNode;
}
legendCfg.container = container;
if (legendCfg.legendStyle === undefined) legendCfg.legendStyle = {};
legendCfg.legendStyle.CONTAINER_CLASS = {
position: 'absolute',
overflow: 'auto',
'z-index': canvasEle.style.zIndex === '' ? 1 : parseInt(canvasEle.style.zIndex, 10) + 1
};
if (legendOptions.flipPage) {
legendCfg.legendStyle.CONTAINER_CLASS.height = posArray[0] === 'right' || posArray[0] === 'left' ? maxLength + 'px' : 'auto';
legendCfg.legendStyle.CONTAINER_CLASS.width = !(posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto';
legend = new Legend.CatPageHtml(legendCfg);
} else {
legend = new Legend.CatHtml(legendCfg);
}
} else {
legend = new Legend.Category(legendCfg);
}
}
self._bindClickEvent(legend, scale, filterVals);
legends[position].push(legend);
return legend;
};
_proto._bindChartMove = function _bindChartMove(scale) {
var chart = this.chart;
var legends = this.legends;
chart.on('plotmove', function (ev) {
var selected = false;
if (ev.target) {
var origin = ev.target.get('origin');
if (origin) {
var data = origin[FIELD_ORIGIN] || origin[0][FIELD_ORIGIN];
var field = scale.field;
if (data) {
var value = data[field];
Util.each(legends, function (legendItems) {
Util.each(legendItems, function (legend) {
selected = true;
!legend.destroyed && legend.activate(value);
});
});
}
}
}
if (!selected) {
Util.each(legends, function (legendItems) {
Util.each(legendItems, function (legend) {
!legend.destroyed && legend.deactivate();
});
});
}
});
};
_proto._addContinuousLegend = function _addContinuousLegend(scale, attr, position) {
var self = this;
var legends = self.legends;
legends[position] = legends[position] || [];
var container = self.container;
var field = scale.field;
var ticks = scale.getTicks();
var items = [];
var legend;
var minValue;
var maxValue;
var viewTheme = self.viewTheme;
Util.each(ticks, function (tick) {
var scaleValue = tick.value;
var invertValue = scale.invert(scaleValue);
var attrValue = attr.mapping(invertValue).join('');
items.push({
value: tick.tickValue,
// tick.text
attrValue: attrValue,
color: attrValue,
scaleValue: scaleValue
});
if (scaleValue === 0) {
minValue = true;
}
if (scaleValue === 1) {
maxValue = true;
}
});
if (!minValue) {
items.push({
value: scale.min,
attrValue: attr.mapping(0).join(''),
color: attr.mapping(0).join(''),
scaleValue: 0
});
}
if (!maxValue) {
items.push({
value: scale.max,
attrValue: attr.mapping(1).join(''),
color: attr.mapping(1).join(''),
scaleValue: 1
});
}
var options = self.options;
var posArray = position.split('-');
var defaultCfg = viewTheme.legend[posArray[0]];
if (options && options.slidable === false || options[field] && options[field].slidable === false) {
defaultCfg = Util.mix({}, defaultCfg, viewTheme.legend.gradient);
}
var legendCfg = Util.deepMix({}, defaultCfg, options[field] || options, {
items: items,
attr: attr,
formatter: scale.formatter,
container: container,
position: [0, 0]
});
if (legendCfg.title) {
Util.deepMix(legendCfg, {
title: {
text: scale.alias || scale.field
}
});
}
if (attr.type === 'color') {
legend = new Legend.Color(legendCfg);
} else if (attr.type === 'size') {
if (options && options.sizeType === 'circle') legend = new Legend.CircleSize(legendCfg);else legend = new Legend.Size(legendCfg);
} else {
return;
}
self._bindFilterEvent(legend, scale);
legends[position].push(legend);
return legend;
};
_proto._isTailLegend = function _isTailLegend(opt, geom) {
if (opt.hasOwnProperty('attachLast') && opt.attachLast) {
var geomType = geom.get('type');
if (geomType === 'line' || geomType === 'lineStack' || geomType === 'area' || geomType === 'areaStack') return true;
}
return false;
};
_proto._adjustPosition = function _adjustPosition(position, isTailLegend) {
var pos;
if (isTailLegend) {
pos = 'right-top';
} else if (Util.isArray(position)) {
pos = String(position[0]) + '-' + String(position[1]);
} else {
var posArr = position.split('-');
if (posArr.length === 1) {
// 只用了left/right/bottom/top一个位置定位
if (posArr[0] === 'left') pos = 'left-bottom';
if (posArr[0] === 'right') pos = 'right-bottom';
if (posArr[0] === 'top') pos = 'top-center';
if (posArr[0] === 'bottom') pos = 'bottom-center';
} else {
pos = position;
}
}
return pos;
};
_proto.addLegend = function addLegend(scale, attr, geom, filterVals) {
var self = this;
var legendOptions = self.options;
var field = scale.field;
var fieldOption = legendOptions[field];
var viewTheme = self.viewTheme;
if (fieldOption === false) {
// 如果不显示此图例
return null;
}
if (fieldOption && fieldOption.custom) {
self.addCustomLegend(field);
} else {
var position = legendOptions.position || viewTheme.defaultLegendPosition;
position = self._adjustPosition(position, self._isTailLegend(legendOptions, geom));
if (fieldOption && fieldOption.position) {
// 如果对某个图例单独设置 position,则对 position 重新赋值
position = self._adjustPosition(fieldOption.position, self._isTailLegend(fieldOption, geom));
}
var legend;
if (scale.isLinear) {
legend = self._addContinuousLegend(scale, attr, position);
} else {
legend = self._addCategoryLegend(scale, attr, geom, filterVals, position);
}
if (legend) {
self._bindHoverEvent(legend, field);
legendOptions.reactive && self._bindChartMove(scale);
}
}
};
/**
* 自定义图例
* @param {string} field 自定义图例的数据字段名,可以为空
* @return {object} legend 自定义图例实例
*/
_proto.addCustomLegend = function addCustomLegend(field) {
var self = this;
var chart = self.chart;
var viewTheme = self.viewTheme;
var container = self.container;
var legendOptions = self.options;
if (field) {
legendOptions = legendOptions[field];
}
var position = legendOptions.position || viewTheme.defaultLegendPosition;
position = self._adjustPosition(position);
var legends = self.legends;
legends[position] = legends[position] || [];
var items = legendOptions.items;
if (!items) {
return;
}
var geoms = chart.getAllGeoms();
Util.each(items, function (item) {
var geom = findGeom(geoms, item.value);
if (!Util.isPlainObject(item.marker)) {
// 直接传入字符串或者回调函数时转换为对象,如 item.marker = 'circle'
item.marker = {
symbol: item.marker || 'circle',
radius: MARKER_SIZE
};
if (Util.indexOf(STROKE_MARKERS, item.marker.symbol) !== -1) {
item.marker.stroke = item.fill;
} else {
item.marker.fill = item.fill;
}
} else {
// 用户传入对象 item.marker = { symbol: 'circle', fill: 'red', radius: 3 }
item.marker.radius = item.marker.radius || MARKER_SIZE;
}
var symbol = item.marker.symbol;
if (Util.isString(symbol) && symbol.indexOf('hollow') !== -1) {
item.marker.symbol = Util.lowerFirst(symbol.substr(6));
}
item.checked = Util.isNil(item.checked) ? true : item.checked;
item.geom = geom;
});
var canvas = chart.get('canvas');
var plotRange = self.plotRange;
var posArray = position.split('-');
var maxLength = posArray[0] === 'right' || posArray[0] === 'left' ? plotRange.bl.y - plotRange.tr.y : canvas.get('width');
var legendCfg = Util.deepMix({}, viewTheme.legend[posArray[0]], legendOptions, {
maxLength: maxLength,
items: items,
container: container,
position: [0, 0]
});
var legend;
if (legendOptions.useHtml) {
var htmlContainer = legendOptions.container;
if (/^\#/.test(container)) {
// 如果传入 dom 节点的 id
var id = htmlContainer.replace('#', '');
htmlContainer = document.getElementById(id);
} else if (!htmlContainer) {
htmlContainer = container.get('canvas').get('el').parentNode;
}
legendCfg.container = htmlContainer;
if (legendCfg.legendStyle === undefined) legendCfg.legendStyle = {};
if (!legendCfg.legendStyle.CONTAINER_CLASS) {
legendCfg.legendStyle.CONTAINER_CLASS = {
height: posArray[0] === 'right' || posArray[0] === 'left' ? maxLength + 'px' : 'auto',
width: !(posArray[0] === 'right' || posArray[0] === 'left') ? maxLength + 'px' : 'auto',
position: 'absolute',
overflow: 'auto'
};
}
if (legendOptions.flipPage) legend = new Legend.CatPageHtml(legendCfg);else legend = new Legend.CatHtml(legendCfg);
} else legend = new Legend.Category(legendCfg);
legends[position].push(legend);
legend.on('itemclick', function (ev) {
if (legendOptions.onClick) {
// 用户自定义了图例点击事件
legendOptions.onClick(ev);
}
});
self._bindHoverEvent(legend);
return legend;
};
_proto.addMixedLegend = function addMixedLegend(scales, geoms) {
var self = this;
var items = [];
Util.each(scales, function (scale) {
var value = scale.alias || scale.field;
Util.each(geoms, function (geom) {
if (geom.getYScale() === scale && scale.values && scale.values.length > 0) {
var shapeType = geom.get('shapeType') || 'point';
var shape = geom.getDefaultValue('shape') || 'circle';
var shapeObject = Shape.getShapeFactory(shapeType);
var cfg = {
color: geom.getDefaultValue('color')
};
var marker = shapeObject.getMarkerCfg(shape, cfg);
var item = {
value: value,
marker: marker,
field: scale.field
};
items.push(item);
}
}); // end of geom loop
}); // end of scale loop
var options = {
custom: true,
items: items
};
self.options = Util.deepMix({}, options, self.options);
var legend = self.addCustomLegend();
self._bindClickEventForMix(legend);
};
_proto.alignLegends = function alignLegends() {
var self = this;
var legends = self.legends;
var totalRegion = self._getRegion(legends);
self.totalRegion = totalRegion;
var i = 0;
Util.each(legends, function (legendItems, position) {
var region =
/* self._getRegion(legendItems)*/
totalRegion.subs[i];
Util.each(legendItems, function (legend, index) {
var pre = legendItems[index - 1];
if (!(legend.get('useHtml') && !legend.get('autoPosition'))) {
self._alignLegend(legend, pre, region, position);
}
});
i++;
});
return this;
};
return LegendController;
}();
module.exports = LegendController;
/***/ }),
/* 271 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 度量的控制器
* @author dxq613@gmail.com
*/
var Scale = __webpack_require__(147);
var Util = __webpack_require__(0);
var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
var TYPES = {
LINEAR: 'linear',
CAT: 'cat',
TIME: 'time'
};
var ScaleController =
/*#__PURE__*/
function () {
function ScaleController(cfg) {
// defs 列定义
this.defs = {};
this.viewTheme = {
scales: {}
}; // filtered fields
this.filters = {};
Util.assign(this, cfg);
}
var _proto = ScaleController.prototype;
_proto._getDef = function _getDef(field) {
var defs = this.defs;
var viewTheme = this.viewTheme;
var def = null;
if (viewTheme.scales[field] || defs[field]) {
def = Util.mix({}, viewTheme.scales[field]); // 处理覆盖属性的问题
Util.each(defs[field], function (v, k) {
if (Util.isNil(v)) {
delete def[k];
} else {
def[k] = v;
}
});
if (this.filters[field]) {
delete def.min;
delete def.max;
}
}
return def;
};
_proto._getDefaultType = function _getDefaultType(field, data) {
var type = TYPES.LINEAR;
var value = Util.Array.firstValue(data, field);
if (Util.isArray(value)) {
value = value[0];
}
if (dateRegex.test(value)) {
type = TYPES.TIME;
} else if (Util.isString(value)) {
type = TYPES.CAT;
}
return type;
};
_proto._getScaleCfg = function _getScaleCfg(type, field, data) {
var cfg = {
field: field
};
var values = Util.Array.values(data, field);
cfg.values = values;
if (!Scale.isCategory(type) && type !== 'time') {
var range = Util.Array.getRange(values);
cfg.min = range.min;
cfg.max = range.max;
cfg.nice = true;
}
if (type === 'time') {
cfg.nice = false;
}
return cfg;
};
_proto.createScale = function createScale(field, data) {
var self = this;
var def = self._getDef(field);
var scale;
var validData = data || [];
var firstValue = Util.Array.firstValue(validData, field);
if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
scale = Scale.identity({
value: field,
field: field.toString(),
values: [field]
});
} else {
// 如果已经定义过这个度量
var type;
if (def) {
type = def.type;
}
type = type || self._getDefaultType(field, validData);
var cfg = self._getScaleCfg(type, field, validData);
if (def) {
Util.mix(cfg, def);
}
scale = Scale[type](cfg);
}
return scale;
};
return ScaleController;
}();
module.exports = ScaleController;
/***/ }),
/* 272 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The controller of tooltip
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var _require = __webpack_require__(29),
Tooltip = _require.Tooltip;
var MatrixUtil = Util.MatrixUtil;
var Vector2 = MatrixUtil.vec2;
var TYPE_SHOW_MARKERS = ['line', 'area', 'path', 'areaStack']; // 默认展示 tooltip marker 的几何图形
var TYPE_SHOW_CROSSHAIRS = ['line', 'area']; // 默认展示十字瞄准线的几何图形
// TODO FIXME this is HARD CODING
var IGNORE_TOOLTIP_ITEM_PROPERTIES = ['marker', 'showMarker'];
function _indexOfArray(items, item) {
var rst = -1;
Util.each(items, function (sub, index) {
var isEqual = true;
for (var key in item) {
if (item.hasOwnProperty(key) && IGNORE_TOOLTIP_ITEM_PROPERTIES.indexOf(key) === -1) {
if (!Util.isObject(item[key]) && item[key] !== sub[key]) {
isEqual = false;
break;
}
}
}
if (isEqual) {
rst = index;
return false;
}
});
return rst;
} // 判断是否有样式
function _hasClass(dom, className) {
if (!dom) {
return false;
}
var cls = '';
if (!dom.className) return false;
if (!Util.isNil(dom.className.baseVal)) {
cls = dom.className.baseVal;
} else {
cls = dom.className;
}
return cls.indexOf(className) !== -1;
}
function _isParent(dom, cls) {
var parent = dom.parentNode;
var rst = false;
while (parent && parent !== document.body) {
if (_hasClass(parent, cls)) {
rst = true;
break;
}
parent = parent.parentNode;
}
return rst;
} // 去除重复的值, 去除不同图形相同数据,只展示一份即可
function _uniqItems(items) {
var tmp = [];
Util.each(items, function (item) {
var index = _indexOfArray(tmp, item);
if (index === -1) {
tmp.push(item);
} else {
tmp[index] = item;
}
});
return tmp;
}
var TooltipController =
/*#__PURE__*/
function () {
function TooltipController(cfg) {
Util.assign(this, cfg);
this.timeStamp = 0;
}
var _proto = TooltipController.prototype;
_proto._normalizeEvent = function _normalizeEvent(event) {
var chart = this.chart;
var canvas = this._getCanvas();
var point = canvas.getPointByClient(event.clientX, event.clientY);
var pixelRatio = canvas.get('pixelRatio');
point.x = point.x / pixelRatio;
point.y = point.y / pixelRatio;
var views = chart.getViewsByPoint(point);
point.views = views;
return point;
};
_proto._getCanvas = function _getCanvas() {
return this.chart.get('canvas');
};
_proto._getTriggerEvent = function _getTriggerEvent() {
var options = this.options;
var triggerOn = options.triggerOn;
var eventName;
if (!triggerOn || triggerOn === 'mousemove') {
eventName = 'plotmove';
} else if (triggerOn === 'click') {
eventName = 'plotclick';
} else if (triggerOn === 'none') {
eventName = null;
}
return eventName;
};
_proto._getDefaultTooltipCfg = function _getDefaultTooltipCfg() {
var self = this;
var chart = self.chart;
var viewTheme = self.viewTheme;
var options = self.options;
var defaultCfg = Util.mix({}, viewTheme.tooltip);
var geoms = chart.getAllGeoms().filter(function (geom) {
return geom.get('visible');
});
var shapes = [];
Util.each(geoms, function (geom) {
var type = geom.get('type');
var adjusts = geom.get('adjusts');
var isSymmetric = false;
if (adjusts) {
Util.each(adjusts, function (adjust) {
if (adjust.type === 'symmetric' || adjust.type === 'Symmetric') {
isSymmetric = true;
return false;
}
});
}
if (Util.indexOf(shapes, type) === -1 && !isSymmetric) {
shapes.push(type);
}
});
var isTransposed = geoms.length && geoms[0].get('coord') ? geoms[0].get('coord').isTransposed : false;
var crosshairsCfg;
if (geoms.length && geoms[0].get('coord') && geoms[0].get('coord').type === 'cartesian') {
if (shapes[0] === 'interval' && options.shared !== false) {
// 直角坐标系下 interval 的 crosshair 为矩形背景框
var crosshairs = Util.mix({}, viewTheme.tooltipCrosshairsRect);
crosshairs.isTransposed = isTransposed;
crosshairsCfg = {
zIndex: 0,
// 矩形背景框不可覆盖 geom
crosshairs: crosshairs
};
} else if (Util.indexOf(TYPE_SHOW_CROSSHAIRS, shapes[0]) > -1) {
var _crosshairs = Util.mix({}, viewTheme.tooltipCrosshairsLine);
_crosshairs.isTransposed = isTransposed;
crosshairsCfg = {
crosshairs: _crosshairs
};
}
}
return Util.mix(defaultCfg, crosshairsCfg, {});
};
_proto._bindEvent = function _bindEvent() {
var chart = this.chart;
var triggerEvent = this._getTriggerEvent();
if (triggerEvent) {
chart.on(triggerEvent, Util.wrapBehavior(this, 'onMouseMove'));
chart.on('plotleave', Util.wrapBehavior(this, 'onMouseOut'));
}
};
_proto._offEvent = function _offEvent() {
var chart = this.chart;
var triggerEvent = this._getTriggerEvent();
if (triggerEvent) {
chart.off(triggerEvent, Util.getWrapBehavior(this, 'onMouseMove'));
chart.off('plotleave', Util.getWrapBehavior(this, 'onMouseOut'));
}
};
_proto._setTooltip = function _setTooltip(point, items, markersItems, target) {
var self = this;
var tooltip = self.tooltip;
var prePoint = self.prePoint;
if (!prePoint || prePoint.x !== point.x || prePoint.y !== point.y) {
items = _uniqItems(items);
self.prePoint = point;
var chart = self.chart;
var viewTheme = self.viewTheme;
var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x;
var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y;
if (!tooltip.get('visible')) {
chart.emit('tooltip:show', {
x: x,
y: y,
tooltip: tooltip
});
}
var first = items[0];
var title = first.title || first.name;
if (tooltip.isContentChange(title, items)) {
chart.emit('tooltip:change', {
tooltip: tooltip,
x: x,
y: y,
items: items
}); // bugfix: when set the title in the tooltip:change event does not take effect.
title = items[0].title || items[0].name;
tooltip.setContent(title, items);
if (!Util.isEmpty(markersItems)) {
if (self.options.hideMarkers === true) {
// 不展示 tooltip marker
tooltip.set('markerItems', markersItems); // 用于 tooltip 辅助线的定位
} else {
tooltip.setMarkers(markersItems, viewTheme.tooltipMarker);
}
} else {
tooltip.clearMarkers(); // clearMarkers 只会将 markerItems 从 markerGroup 中移除
// 所以我们还要将 markerItems 从 tooltip 中移除
// 这么做是为了防止上一次设置 marker 时的 markerItems 影响此次 tooltip 辅助线的定位
tooltip.set('markerItems', []);
}
}
var canvas = this._getCanvas();
if (target === canvas && tooltip.get('type') === 'mini') {
// filter mini tooltip
tooltip.hide();
} else {
tooltip.setPosition(x, y, target);
tooltip.show();
}
}
};
_proto.hideTooltip = function hideTooltip() {
var tooltip = this.tooltip;
var chart = this.chart;
var canvas = this._getCanvas();
this.prePoint = null;
tooltip.hide();
chart.emit('tooltip:hide', {
tooltip: tooltip
});
canvas.draw();
};
_proto.onMouseMove = function onMouseMove(ev) {
if (Util.isEmpty(ev.views)) {
return;
}
var lastTimeStamp = this.timeStamp;
var timeStamp = +new Date();
var point = {
x: ev.x,
y: ev.y
};
if (timeStamp - lastTimeStamp > 16 && !this.chart.get('stopTooltip')) {
this.showTooltip(point, ev.views, ev.shape);
this.timeStamp = timeStamp;
}
};
_proto.onMouseOut = function onMouseOut(ev) {
var tooltip = this.tooltip; // const canvas = this._getCanvas();
if (!tooltip.get('visible') || !tooltip.get('follow')) {
return;
} // 除非离开 plot 时鼠标依然在图形上,这段逻辑没有意义
// if (ev && ev.target !== canvas) {
// return;
// }
if (ev && ev.toElement && (_hasClass(ev.toElement, 'g2-tooltip') || _isParent(ev.toElement, 'g2-tooltip'))) {
return;
}
this.hideTooltip();
};
_proto.renderTooltip = function renderTooltip() {
var self = this;
if (self.tooltip) {
// tooltip 对象已经创建
return;
}
var chart = self.chart;
var viewTheme = self.viewTheme;
var canvas = self._getCanvas();
var defaultCfg = self._getDefaultTooltipCfg();
var options = self.options;
options = Util.deepMix({
plotRange: chart.get('plotRange'),
capture: false,
canvas: canvas,
frontPlot: chart.get('frontPlot'),
viewTheme: viewTheme.tooltip,
backPlot: chart.get('backPlot')
}, defaultCfg, options);
if (options.crosshairs && options.crosshairs.type === 'rect') {
options.zIndex = 0; // toolip 背景框不可遮盖住 geom,防止用户配置了 crosshairs
}
options.visible = false; // @2018-09-13 by blue.lb 如果设置shared为false不需要指定position
// if (options.shared === false && Util.isNil(options.position)) {
// options.position = 'top';
// }
var tooltip;
if (options.type === 'mini') {
options.crosshairs = false; // this.options.shared = false;
options.position = 'top';
tooltip = new Tooltip.Mini(options);
} else if (options.useHtml) {
tooltip = new Tooltip.Html(options);
} else {
tooltip = new Tooltip.Canvas(options);
}
self.tooltip = tooltip;
var triggerEvent = self._getTriggerEvent();
if (!tooltip.get('enterable') && triggerEvent === 'plotmove') {
// 鼠标不允许进入 tooltip 容器
var tooltipContainer = tooltip.get('container');
if (tooltipContainer) {
tooltipContainer.onmousemove = function (e) {
// 避免 tooltip 频繁闪烁
var eventObj = self._normalizeEvent(e);
chart.emit(triggerEvent, eventObj);
};
}
}
self._bindEvent();
};
_proto.showTooltip = function showTooltip(point, views, target) {
var self = this;
if (Util.isEmpty(views) || !point) {
return;
}
if (!this.tooltip) {
this.renderTooltip(); // 如果一开始 tooltip 关闭,用户重新调用的时候需要先生成 tooltip
}
var options = self.options;
var markersItems = [];
var items = [];
Util.each(views, function (view) {
if (!view.get('tooltipEnable')) {
// 如果不显示tooltip,则跳过
return true;
}
var geoms = view.get('geoms');
var coord = view.get('coord');
Util.each(geoms, function (geom) {
var type = geom.get('type');
if (geom.get('visible') && geom.get('tooltipCfg') !== false) {
var dataArray = geom.get('dataArray');
if (geom.isShareTooltip() || options.shared === false && Util.inArray(['area', 'line', 'path', 'polygon'], type)) {
Util.each(dataArray, function (obj) {
var tmpPoint = geom.findPoint(point, obj);
if (tmpPoint) {
var subItems = geom.getTipItems(tmpPoint, options.title);
Util.each(subItems, function (v) {
var point = v.point;
if (point && point.x && point.y) {
// hotfix: make sure there is no null value
var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x;
var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y;
point = coord.applyMatrix(x, y, 1);
v.x = point[0];
v.y = point[1];
v.showMarker = true;
var itemMarker = self._getItemMarker(geom, v.color);
v.marker = itemMarker;
if (Util.indexOf(TYPE_SHOW_MARKERS, type) !== -1) {
markersItems.push(v);
}
}
});
items = items.concat(subItems);
}
});
} else {
var geomContainer = geom.get('shapeContainer');
var canvas = geomContainer.get('canvas');
var pixelRatio = canvas.get('pixelRatio');
var shape = geomContainer.getShape(point.x * pixelRatio, point.y * pixelRatio);
if (shape && shape.get('visible') && shape.get('origin')) {
items = geom.getTipItems(shape.get('origin'), options.title);
}
}
}
});
Util.each(items, function (item) {
var point = item.point;
var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x;
var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y;
point = coord.applyMatrix(x, y, 1);
item.x = point[0];
item.y = point[1];
});
});
if (items.length) {
var first = items[0]; // bugfix: multiple tooltip items with different titles
if (!items.every(function (item) {
return item.title === first.title;
})) {
var nearestItem = first;
var nearestDistance = Infinity;
items.forEach(function (item) {
var distance = Vector2.distance([point.x, point.y], [item.x, item.y]);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestItem = item;
}
});
items = items.filter(function (item) {
return item.title === nearestItem.title;
});
markersItems = markersItems.filter(function (item) {
return item.title === nearestItem.title;
});
}
if (options.shared === false && items.length > 1) {
var snapItem = items[0];
var min = Math.abs(point.y - snapItem.y);
Util.each(items, function (aItem) {
if (Math.abs(point.y - aItem.y) <= min) {
snapItem = aItem;
min = Math.abs(point.y - aItem.y);
}
});
if (snapItem && snapItem.x && snapItem.y) {
markersItems = [snapItem];
}
items = [snapItem];
} // 3.0 采用当前鼠标位置作为 tooltip 的参考点
// if (!Util.isEmpty(markersItems)) {
// point = markersItems[0];
// }
self._setTooltip(point, items, markersItems, target);
} else {
self.hideTooltip();
}
};
_proto.clear = function clear() {
var tooltip = this.tooltip;
tooltip && tooltip.destroy();
this.tooltip = null;
this.prePoint = null;
this._offEvent();
};
_proto._getItemMarker = function _getItemMarker(geom, color) {
var shapeType = geom.get('shapeType') || 'point';
var shape = geom.getDefaultValue('shape') || 'circle';
var shapeObject = Shape.getShapeFactory(shapeType);
var cfg = {
color: color
};
var marker = shapeObject.getMarkerCfg(shape, cfg);
return marker;
};
return TooltipController;
}();
module.exports = TooltipController;
/***/ }),
/* 273 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview view
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(113);
var Geom = __webpack_require__(8);
var Util = __webpack_require__(0);
var Controller = __webpack_require__(115);
var Global = __webpack_require__(5);
var Theme = __webpack_require__(125);
var FIELD_ORIGIN = '_origin';
var Animate = __webpack_require__(265);
function isFullCircle(coord) {
var startAngle = coord.startAngle;
var endAngle = coord.endAngle;
if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
return false;
}
return true;
}
function isBetween(value, start, end) {
var tmp = (value - start) / (end - start);
return tmp >= 0 && tmp <= 1;
}
function isPointInCoord(coord, point) {
var result = false;
if (coord) {
var type = coord.type;
if (type === 'theta') {
var start = coord.start;
var end = coord.end;
result = isBetween(point.x, start.x, end.x) && isBetween(point.y, start.y, end.y);
} else {
var invertPoint = coord.invert(point);
result = invertPoint.x >= 0 && invertPoint.y >= 0 && invertPoint.x <= 1 && invertPoint.y <= 1;
}
}
return result;
}
var ViewGeoms = {};
Util.each(Geom, function (geomConstructor, className) {
var methodName = Util.lowerFirst(className);
ViewGeoms[methodName] = function (cfg) {
var geom = new geomConstructor(cfg);
this.addGeom(geom);
return geom;
};
});
/**
* 图表中的视图
* @class View
*/
var View =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(View, _Base);
var _proto = View.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
return {
viewContainer: null,
coord: null,
start: {
x: 0,
y: 0
},
end: {
x: 1,
y: 1
},
geoms: [],
scales: {},
options: {},
scaleController: null,
padding: 0,
theme: null,
parent: null,
tooltipEnable: true,
// 是否展示 tooltip
animate: Global.animate,
visible: true
};
};
function View(cfg) {
var _this;
_this = _Base.call(this, cfg) || this;
var self = _assertThisInitialized(_assertThisInitialized(_this));
self._setTheme();
Util.each(Geom, function (GeomConstructor, className) {
var methodName = Util.lowerFirst(className);
self[methodName] = function (cfg) {
if (cfg === void 0) {
cfg = {};
}
cfg.viewTheme = self.get('viewTheme');
var geom = new GeomConstructor(cfg);
self.addGeom(geom);
return geom;
};
}); // Util.mix(this, ViewGeoms);
self.init();
return _this;
}
_proto._setTheme = function _setTheme() {
var self = this;
var theme = self.get('theme');
var viewTheme = {};
var newTheme = {};
if (Util.isObject(theme)) {
newTheme = theme;
} else if (Util.indexOf(Object.keys(Theme), theme) !== -1) {
newTheme = Theme[theme];
}
Util.deepMix(viewTheme, Global, newTheme);
self.set('viewTheme', viewTheme);
};
/**
* @protected
* 初始化
*/
_proto.init = function init() {
this._initViewPlot(); // 先创建容器
if (this.get('data')) {
this._initData(this.get('data'));
}
this._initOptions();
this._initControllers();
this._bindEvents();
}; // 初始化配置项
_proto._initOptions = function _initOptions() {
var self = this;
var options = Util.mix({}, self.get('options')); // 防止修改原始值
if (!options.scales) {
options.scales = {};
}
if (!options.coord) {
options.coord = {};
}
if (options.animate === false) {
this.set('animate', false);
}
if (options.tooltip === false || Util.isNull(options.tooltip)) {
// 配置项方式关闭 tooltip
this.set('tooltipEnable', false);
}
if (options.geoms && options.geoms.length) {
Util.each(options.geoms, function (geomOption) {
self._createGeom(geomOption);
});
}
var scaleController = self.get('scaleController');
if (scaleController) {
scaleController.defs = options.scales;
}
var coordController = self.get('coordController');
if (coordController) {
coordController.reset(options.coord);
}
this.set('options', options);
};
_proto._createGeom = function _createGeom(cfg) {
var type = cfg.type;
var geom;
if (this[type]) {
geom = this[type]();
Util.each(cfg, function (v, k) {
if (geom[k]) {
if (Util.isObject(v) && v.field) {
// 配置项传入
if (v === 'label') {
geom[k](v.field, v.callback, v.cfg);
} else {
var _cfg;
Util.each(v, function (value, key) {
if (key !== 'field') {
_cfg = value;
}
});
geom[k](v.field, _cfg);
}
} else {
geom[k](v);
}
}
});
}
}; // 初始化所有的控制器
_proto._initControllers = function _initControllers() {
var self = this;
var options = self.get('options');
var viewTheme = self.get('viewTheme');
var canvas = self.get('canvas');
var scaleController = new Controller.Scale({
viewTheme: viewTheme,
defs: options.scales
});
var coordController = new Controller.Coord(options.coord);
this.set('scaleController', scaleController);
this.set('coordController', coordController);
var axisController = new Controller.Axis({
canvas: canvas,
viewTheme: viewTheme
});
this.set('axisController', axisController);
var guideController = new Controller.Guide({
viewTheme: viewTheme,
options: options.guides || []
});
this.set('guideController', guideController);
};
_proto._initViewPlot = function _initViewPlot() {
if (!this.get('viewContainer')) {
// 用于 geom 的绘制
this.set('viewContainer', this.get('middlePlot'));
}
};
_proto._initGeoms = function _initGeoms() {
var geoms = this.get('geoms');
var filteredData = this.get('filteredData');
var coord = this.get('coord');
var viewId = this.get('_id');
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
geom.set('data', filteredData);
geom.set('coord', coord);
geom.set('_id', viewId + '-geom' + i);
geom.set('keyFields', this.get('keyFields'));
geom.init();
}
};
_proto._clearGeoms = function _clearGeoms() {
var self = this;
var geoms = self.get('geoms');
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
geom.clear();
}
};
_proto._removeGeoms = function _removeGeoms() {
var self = this;
var geoms = self.get('geoms');
while (geoms.length > 0) {
var geom = geoms.shift();
geom.destroy();
}
};
_proto._drawGeoms = function _drawGeoms() {
this.emit('beforedrawgeoms');
var geoms = this.get('geoms');
var coord = this.get('coord');
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
geom.setCoord(coord);
geom.paint();
}
this.emit('afterdrawgeoms');
};
_proto.isShapeInView = function isShapeInView(shape) {
var id = this.get('_id');
var shapeId = shape._id;
if (shapeId) {
return shapeId.split('-')[0] === id;
}
var parent = shape;
while (parent) {
if (parent.get('viewId') === id) {
return true;
}
parent = parent.get('parent');
}
return false;
};
/**
* View 所在的范围
* @protected
* @return {Object} View 所在的范围
*/
_proto.getViewRegion = function getViewRegion() {
var self = this;
var parent = self.get('parent');
var start;
var end;
if (parent) {
var region = parent.getViewRegion();
var viewRegion = self._getViewRegion(region.start, region.end);
start = viewRegion.start;
end = viewRegion.end;
} else {
start = self.get('start');
end = self.get('end');
}
return {
start: start,
end: end
};
}; // 获取 range 所在的范围
_proto._getViewRegion = function _getViewRegion(plotStart, plotEnd) {
var start = this.get('start');
var end = this.get('end');
var startX = start.x;
var startY = 1 - end.y;
var endX = end.x;
var endY = 1 - start.y;
var padding = this.get('padding'); // 转换成 上、右、下、左的模式
var allPadding = Util.toAllPadding(padding);
var top = allPadding[0];
var right = allPadding[1];
var bottom = allPadding[2];
var left = allPadding[3];
var startPoint = {
x: startX * (plotEnd.x - plotStart.x) + plotStart.x + left,
y: startY * (plotEnd.y - plotStart.y) + plotStart.y - bottom
};
var endPoint = {
x: endX * (plotEnd.x - plotStart.x) + plotStart.x - right,
y: endY * (plotEnd.y - plotStart.y) + plotStart.y + top
};
return {
start: startPoint,
end: endPoint
};
};
_proto._createCoord = function _createCoord() {
var coordController = this.get('coordController');
var region = this.getViewRegion();
var coord = coordController.createCoord(region.start, region.end);
this.set('coord', coord);
};
_proto._renderAxes = function _renderAxes() {
var options = this.get('options');
var axesOptions = options.axes;
if (axesOptions === false) {
// 不渲染坐标轴
return;
}
var axisController = this.get('axisController');
axisController.container = this.get('backPlot');
axisController.coord = this.get('coord');
axisController.options = axesOptions || {};
var xScale = this.getXScale();
var yScales = this.getYScales();
var viewId = this.get('_id');
axisController.createAxis(xScale, yScales, viewId);
};
_proto._renderGuides = function _renderGuides() {
var guideController = this.get('guideController');
if (!Util.isEmpty(guideController.options)) {
var coord = this.get('coord');
guideController.view = this;
guideController.backContainer = this.get('backPlot');
guideController.frontContainer = this.get('frontPlot');
guideController.xScales = this._getScales('x');
guideController.yScales = this._getScales('y');
guideController.render(coord);
}
}; // 注册事件
_proto._bindEvents = function _bindEvents() {
var eventController = new Controller.Event({
view: this,
canvas: this.get('canvas')
});
eventController.bindEvents();
this.set('eventController', eventController);
}; // 清理时间
_proto._clearEvents = function _clearEvents() {
var eventController = this.get('eventController');
eventController && eventController.clearEvents();
};
_proto._getScales = function _getScales(dimType) {
var geoms = this.get('geoms');
var result = {};
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
var scale = dimType === 'x' ? geom.getXScale() : geom.getYScale();
if (scale && !result[scale.field]) {
result[scale.field] = scale;
}
}
return result;
};
_proto._adjustScale = function _adjustScale() {
this._setCatScalesRange();
var geoms = this.get('geoms');
var scaleController = this.get('scaleController');
var colDefs = scaleController.defs;
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
if (geom.get('type') === 'interval') {
var yScale = geom.getYScale();
var field = yScale.field,
min = yScale.min,
max = yScale.max,
type = yScale.type;
if (!(colDefs[field] && colDefs[field].min) && type !== 'time') {
if (min > 0) {
yScale.change({
min: 0
});
} else if (max <= 0) {
// 当柱状图全为负值时也需要从 0 开始生长
yScale.change({
max: 0
});
}
}
}
}
};
_proto._setCatScalesRange = function _setCatScalesRange() {
var self = this;
var coord = self.get('coord');
var viewTheme = self.get('viewTheme');
var xScale = self.getXScale();
var yScales = self.getYScales();
var scales = [];
xScale && scales.push(xScale);
scales = scales.concat(yScales);
var inFullCircle = coord.isPolar && isFullCircle(coord);
var scaleController = self.get('scaleController');
var colDefs = scaleController.defs;
Util.each(scales, function (scale) {
if ((scale.isCategory || scale.isIdentity) && scale.values && !(colDefs[scale.field] && colDefs[scale.field].range)) {
var count = scale.values.length;
var range;
if (count === 1) {
range = [0.5, 1]; // 只有一个分类时,防止计算出现 [0.5,0.5]的状态
} else {
var widthRatio = 1;
var offset = 0;
if (inFullCircle) {
if (!coord.isTransposed) {
range = [0, 1 - 1 / count];
} else {
widthRatio = viewTheme.widthRatio.multiplePie;
offset = 1 / count * widthRatio;
range = [offset / 2, 1 - offset / 2];
}
} else {
offset = 1 / count * 1 / 2; // 两边留下分类空间的一半
range = [offset, 1 - offset]; // 坐标轴最前面和最后面留下空白防止绘制柱状图时
}
}
scale.range = range;
}
});
};
_proto.getXScale = function getXScale() {
var geoms = this.get('geoms'); // 如果进行过滤,那么 geom 默认隐藏时会出现不一致
// 默认隐藏时坐标轴不绘制,但是调用了 geom.show() 后,则图形显示了,坐标轴依然不见
/* .filter(function(geom) {
return geom.get('visible');
}); */
var xScale = null;
if (!Util.isEmpty(geoms)) {
xScale = geoms[0].getXScale();
}
return xScale;
};
_proto.getYScales = function getYScales() {
var geoms = this.get('geoms');
/* .filter(function(geom) {
return geom.get('visible');
}); */
var rst = [];
for (var i = 0; i < geoms.length; i++) {
var geom = geoms[i];
var yScale = geom.getYScale();
if (yScale && Util.indexOf(rst, yScale) === -1) {
rst.push(yScale);
}
}
return rst;
};
/**
* 获取数据对应在画布空间的坐标
* @param {Object} item 原始数据
* @return {Object} 返回对应的画布上的坐标点
*/
_proto.getXY = function getXY(item) {
var self = this;
var coord = self.get('coord');
var xScales = self._getScales('x');
var yScales = self._getScales('y');
var x;
var y;
for (var field in item) {
if (xScales[field]) {
x = xScales[field].scale(item[field]);
}
if (yScales[field]) {
y = yScales[field].scale(item[field]);
}
}
if (!Util.isNil(x) && !Util.isNil(y)) {
return coord.convert({
x: x,
y: y
});
}
return null;
};
/**
* 获取逼近的点的数据集合
* @param {Object} point 画布上的像素点
* @return {Array} 数据
*/
_proto.getSnapRecords = function getSnapRecords(point) {
var self = this;
var geoms = self.get('geoms');
var rst = [];
Util.each(geoms, function (geom) {
var dataArray = geom.get('dataArray');
var record;
Util.each(dataArray, function (data) {
record = geom.findPoint(point, data);
record && rst.push(record);
});
});
return rst;
};
/**
* @protected
* 添加几何标记
* @param {Geom} geom 几何标记
*/
_proto.addGeom = function addGeom(geom) {
var self = this;
var geoms = self.get('geoms');
geoms.push(geom);
geom.set('view', self);
var container = self.get('viewContainer');
geom.set('container', container);
geom.set('animate', self.get('animate'));
geom.bindEvents();
};
/**
* @protected
* 移除几何标记
* @param {Geom} geom 几何标记
*/
_proto.removeGeom = function removeGeom(geom) {
var geoms = this.get('geoms');
Util.Array.remove(geoms, geom);
geom.destroy();
};
_proto.createScale = function createScale(field, data) {
var scales = this.get('scales');
var parent = this.get('parent');
var scale = scales[field]; // const filters = this._getFilters();
if (!data) {
var filteredData = this.get('filteredData');
var legendFields = this._getFieldsForLegend(); // 过滤导致数据为空时,需要使用全局数据
// 参与过滤的字段的度量也根据全局数据来生成
if (filteredData.length && legendFields.indexOf(field) === -1) {
data = filteredData;
} else {
data = this.get('data');
}
}
var scaleController = this.get('scaleController');
if (!scale) {
scale = scaleController.createScale(field, data);
if (scale.sync && parent) {
var parentScale = parent.createScale(field, data);
scale = this._getSyncScale(parentScale, scale);
}
scales[field] = scale;
} else if (scale.sync) {
// 防止 view 内部创建的scale,Chart 上的scale 范围更大
var newScale = scaleController.createScale(field, data);
this._syncScale(scale, newScale);
}
return scale;
};
_proto._getFieldsForLegend = function _getFieldsForLegend() {
var fields = [];
var geoms = this.get('geoms');
Util.each(geoms, function (geom) {
var geomFields = geom.getFieldsForLegend();
fields = fields.concat(geomFields);
});
return Util.uniq(fields);
}; // 如果需要同步度量,则使得 values,min,max的范围最大
_proto._getSyncScale = function _getSyncScale(parentScale, scale) {
if (parentScale.type !== scale.type) {
return scale;
}
this._syncScale(parentScale, scale);
return parentScale;
};
_proto._syncScale = function _syncScale(distScale, sourceScale) {
var mergeValues = Util.union(distScale.values, sourceScale.values);
if (sourceScale.isLinear) {
var max = Math.max(distScale.max, sourceScale.max);
var min = Math.min(distScale.min, sourceScale.min);
if (distScale.max !== max || distScale.min !== min) {
distScale.change({
min: min,
max: max,
values: mergeValues
});
}
}
if (mergeValues.length !== distScale.values.length) {
distScale.change({
values: mergeValues
});
}
};
/**
* @protected
* 获取过滤后的值(需要显示的值)
* @param {String} field 度量
* @return {Array.} 滤后的值
*/
_proto.getFilteredValues = function getFilteredValues(field) {
var scale = this.get('scales')[field];
var values = scale.values;
var filters = this._getFilters();
var rst;
if (filters && filters[field]) {
rst = values.filter(filters[field]);
} else {
rst = values.slice(0);
}
return rst;
};
/**
* @protected
* 获取被过滤的值(不需显示的值)
* @param {String} field 度量
* @return {Array.} 滤出的值
*/
_proto.getFilteredOutValues = function getFilteredOutValues(field) {
var scale = this.get('scales')[field];
var values = scale.values;
var filters = this._getFilters();
var rst;
if (filters && filters[field]) {
rst = values.filter(function (v) {
return !filters[field](v);
});
} else {
rst = [];
}
return rst;
};
_proto.filter = function filter(field, condition) {
var options = this.get('options');
if (!options.filters) {
options.filters = {};
}
options.filters[field] = condition;
this.get('scaleController').filters = options.filters;
}; // 获取 filters
_proto._getFilters = function _getFilters() {
var options = this.get('options');
return options.filters;
}; // 执行 filter 数据
_proto.execFilter = function execFilter(data) {
var self = this;
var filters = self._getFilters();
if (filters) {
data = data.filter(function (obj) {
var rst = true;
Util.each(filters, function (fn, k) {
if (fn) {
rst = fn(obj[k], obj);
if (!rst) {
return false;
}
}
});
return rst;
});
}
return data;
};
_proto.axis = function axis(field, cfg) {
var options = this.get('options');
if (field === false) {
options.axes = false;
} else {
if (!options.axes) {
options.axes = {};
}
var axisOptions = options.axes;
axisOptions[field] = cfg;
}
return this;
};
_proto.guide = function guide() {
return this.get('guideController');
};
_proto._getKeyFields = function _getKeyFields(scaleDefs) {
var keyFields = [];
Util.each(scaleDefs, function (def, field) {
if (def.key) {
keyFields.push(field);
}
});
this.set('keyFields', keyFields);
};
_proto.scale = function scale(field, cfg) {
var options = this.get('options');
var scaleDefs = options.scales;
if (Util.isObject(field)) {
Util.mix(scaleDefs, field);
} else {
scaleDefs[field] = cfg;
}
this._getKeyFields(scaleDefs);
return this;
};
_proto.tooltip = function tooltip(visible) {
this.set('tooltipEnable', visible);
return this;
};
_proto.animate = function animate(enable) {
var options = this.get('options');
options.animate = enable;
this.set('animate', enable);
return this;
};
_proto.changeOptions = function changeOptions(options) {
this.set('options', options);
this._initOptions(options);
return this;
};
/**
* @internal 查找包含指定点的视图
* @param {Object} point 点的位置
* @return {Array} 多个视图
*/
_proto.getViewsByPoint = function getViewsByPoint(point) {
var rst = [];
var views = this.get('views');
if (isPointInCoord(this.get('coord'), point)) {
rst.push(this);
}
Util.each(views, function (view) {
if (view.get('visible') && isPointInCoord(view.get('coord'), point)) {
rst.push(view);
}
});
return rst;
};
/**
* 遍历所有的 shape ,用户更改 shape 后进行刷新
* @param {Function} fn 回调函数包含参数:record,shape,geom,view
* @return {View} 当前视图
*/
_proto.eachShape = function eachShape(fn) {
var self = this;
var views = self.get('views');
var canvas = self.get('canvas');
Util.each(views, function (view) {
view.eachShape(fn);
});
var geoms = this.get('geoms');
Util.each(geoms, function (geom) {
var shapes = geom.getShapes();
Util.each(shapes, function (shape) {
var origin = shape.get('origin');
if (Util.isArray(origin)) {
var arr = origin.map(function (subOrigin) {
return subOrigin[FIELD_ORIGIN];
});
fn(arr, shape, geom, self);
} else {
var obj = origin[FIELD_ORIGIN];
fn(obj, shape, geom, self);
}
});
});
canvas.draw();
return this;
};
/**
* 遍历所有的 shape ,回调函数中 true / false 控制图形是否显示
* @param {Function} fn 回调函数包含参数:record,shape,geom,view
* @return {View} 当前视图
*/
_proto.filterShape = function filterShape(fn) {
var callback = function callback(record, shape, geom, view) {
if (!fn(record, shape, geom, view)) {
shape.hide();
} else {
shape.show();
}
};
this.eachShape(callback);
return this;
};
_proto.clearInner = function clearInner() {
this.set('scales', {});
this.emit('beforeclearinner');
var options = this.get('options');
options.geoms = null;
this._clearGeoms(); // reset guide
this.get('guideController') && this.get('guideController').reset(); // clear axis
this.get('axisController') && this.get('axisController').clear();
this.emit('afterclearinner');
};
/**
* 清除视图内容,包括 geoms
* @return {View} 当前视图
*/
_proto.clear = function clear() {
var options = this.get('options');
options.filters = null;
this._removeGeoms(); // const container = this.get('viewContainer');
// container.clear();
this.clearInner();
this.get('guideController') && this.get('guideController').clear();
this.set('isUpdate', false);
this.set('keyFields', []);
return this;
};
/**
* 设置坐标系信息
* @param {String} type 类型
* @param {Object} cfg 配置项
* @return {Object} coordController 坐标系的管理器
*/
_proto.coord = function coord(type, cfg) {
var coordController = this.get('coordController');
coordController.reset({
type: type,
cfg: cfg
});
return coordController;
};
/**
* 当父元素边框发生改变时坐标系需要重新调整
* @protected
*/
_proto.resetCoord = function resetCoord() {
this._createCoord();
};
_proto.source = function source(data, scales) {
this._initData(data);
if (scales) {
this.scale(scales);
}
this.emit('setdata');
return this;
};
_proto.changeData = function changeData(data) {
this.emit('beforechangedata');
this._initData(data);
this.emit('afterchangedata');
this.repaint();
return this;
};
_proto._initData = function _initData(data) {
var dataView = this.get('dataView');
if (dataView) {
dataView.off('change', Util.getWrapBehavior(this, '_onViewChange'));
this.set('dataView', null);
}
if (data && data.isDataView) {
data.on('change', Util.wrapBehavior(this, '_onViewChange'));
this.set('dataView', data);
data = data.rows;
}
this.set('data', data);
};
_proto._onViewChange = function _onViewChange() {
this.emit('beforechangedata');
var dataView = this.get('dataView');
var rows = dataView.rows;
this.set('data', rows);
this.emit('afterchangedata');
this.repaint();
}; // 初始化各个 view 和绘制辅助元素
_proto.beforeRender = function beforeRender() {
var views = this.get('views'); // 如果存在 views 则初始化子 view 的方法
Util.each(views, function (view) {
view.beforeRender();
});
this.initView();
}; // 绘制坐标轴、图例、辅助元素等图表组件
_proto.drawComponents = function drawComponents() {
var views = this.get('views'); // 如果存在 views 则初始化子 view 的方法
Util.each(views, function (view) {
view.drawComponents();
});
this._renderAxes();
this._renderGuides();
}; // 绘制图形
_proto.drawCanvas = function drawCanvas(stopDraw) {
if (!stopDraw) {
var views = this.get('views');
var backPlot = this.get('backPlot');
backPlot.sort();
var canvas = this.get('canvas');
var animate = this.get('animate');
if (animate) {
var isUpdate = this.get('isUpdate');
Util.each(views, function (view) {
Animate.execAnimation(view, isUpdate);
});
Animate.execAnimation(this, isUpdate);
} else {
canvas.draw();
}
}
};
_proto.render = function render(stopDraw) {
this.clearInner();
this.emit('beforerender');
this.beforeRender();
this.emit('beforepaint');
this.drawComponents();
this.paint();
this.emit('afterpaint');
this.drawCanvas(stopDraw);
this.emit('afterrender');
this.set('rendered', true);
return this;
};
_proto.initView = function initView() {
var data = this.get('data') || [];
var filteredData = this.execFilter(data);
this.set('filteredData', filteredData); // if (!Util.isEmpty(data)) {
this._createCoord(); // draw geometry 前绘制区域可能会发生改变
this.emit('beforeinitgeoms');
this._initGeoms();
this._adjustScale(); // }
};
_proto.paint = function paint() {
var views = this.get('views'); // 绘制
Util.each(views, function (view) {
view.paint();
});
var data = this.get('data');
if (!Util.isEmpty(data)) {
this._drawGeoms();
} // 如果 view 隐藏了,隐藏所有的图形和坐标轴
if (!this.get('visible')) {
this.changeVisible(false, true); // 隐藏所有的图形,但是不绘制
}
};
_proto.changeVisible = function changeVisible(visible, stopDraw) {
var geoms = this.get('geoms');
Util.each(geoms, function (geom) {
// if (geom.get('visible')) { // geom 隐藏时不受
geom.changeVisible(visible, true); // }
});
this.get('axisController') && this.get('axisController').changeVisible(visible);
this.get('guideController') && this.get('guideController').changeVisible(visible);
if (!stopDraw) {
var canvas = this.get('canvas');
canvas.draw();
}
};
_proto.repaint = function repaint() {
this.set('isUpdate', true);
this.clearInner();
this.render();
};
_proto.destroy = function destroy() {
this._clearEvents();
var dataView = this.get('dataView');
dataView && dataView.off('change', Util.getWrapBehavior(this, '_onViewChange'));
this.clear();
_Base.prototype.destroy.call(this);
};
return View;
}(Base);
module.exports = View;
/***/ }),
/* 274 */
/***/ (function(module, exports, __webpack_require__) {
var _require = __webpack_require__(29),
Guide = _require.Guide;
var RegionFilter = __webpack_require__(275);
Guide.RegionFilter = RegionFilter;
module.exports = Guide;
/***/ }),
/* 275 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(0);
var Guide = __webpack_require__(19);
var _require = __webpack_require__(35),
Path = _require.Path;
var RegionFilter =
/*#__PURE__*/
function (_Guide) {
_inheritsLoose(RegionFilter, _Guide);
function RegionFilter() {
return _Guide.apply(this, arguments) || this;
}
var _proto = RegionFilter.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Guide.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
name: 'regionFilter',
zIndex: 1,
top: true,
start: null,
end: null,
color: null,
apply: null,
style: {
opacity: 1
}
});
};
_proto.render = function render(coord, group, viewData, view) {
var self = this;
var layer = group.addGroup();
layer.name = 'guide-region-filter';
view.once('afterpaint', function () {
// 2018-08-08 by blue.lb padding为auto时,会导致重新绘制一次,这时候layer已经被销毁了
if (layer.get('destroyed')) return;
self._drawShapes(view, layer);
var clip = self._drawClip(coord);
layer.attr({
clip: clip
});
self.set('clip', clip);
self.get('appendInfo') && layer.setSilent('appendInfo', self.get('appendInfo'));
self.set('el', layer);
});
};
_proto._drawShapes = function _drawShapes(view, layer) {
var self = this;
var output = [];
var geoms = view.getAllGeoms();
geoms.map(function (geom) {
var shapes = geom.getShapes();
var geomType = geom.get('type');
var filter = self._geomFilter(geomType);
if (filter) {
shapes.map(function (shape) {
var shapeType = shape.type; // const shapeAttr = Util.mix({}, shape.attr());
var shapeAttr = Util.cloneDeep(shape.attr());
self._adjustDisplay(shapeAttr);
var s = layer.addShape(shapeType, {
attrs: shapeAttr
});
output.push(s);
return shape;
});
}
return geom;
});
return output;
};
_proto._drawClip = function _drawClip(coord) {
var self = this;
var start = self.parsePoint(coord, self.get('start'));
var end = self.parsePoint(coord, self.get('end'));
var path = [['M', start.x, start.y], ['L', end.x, start.y], ['L', end.x, end.y], ['L', start.x, end.y], ['z']];
var clip = new Path({
attrs: {
path: path,
opacity: 1
}
});
return clip;
};
_proto._adjustDisplay = function _adjustDisplay(attr) {
var self = this;
var color = self.get('color');
if (attr.fill) {
attr.fill = attr.fillStyle = color;
}
attr.stroke = attr.strokeStyle = color;
};
_proto._geomFilter = function _geomFilter(geomType) {
var self = this;
var apply = self.get('apply');
if (apply) {
return Util.contains(apply, geomType);
}
return true;
};
_proto.clear = function clear() {
_Guide.prototype.clear.call(this);
var clip = this.get('clip');
clip && clip.remove();
};
return RegionFilter;
}(Guide);
module.exports = RegionFilter;
/***/ }),
/* 276 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of tail legend
* @author Ye Liu
*/
var Util = __webpack_require__(0); // const Category = require('./category');
var Components = __webpack_require__(29);
var Global = __webpack_require__(5);
var Legend = Components.Legend;
var Category = Legend.Category;
var Tail =
/*#__PURE__*/
function (_Category) {
_inheritsLoose(Tail, _Category);
function Tail() {
return _Category.apply(this, arguments) || this;
}
var _proto = Tail.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Category.prototype.getDefaultCfg.call(this);
return Util.mix({}, cfg, {
/**
* type标识
* @type {String}
*/
type: 'tail-legend',
/**
* 布局方式
* horizontal 水平
* vertical 垂直
* @type {String}
*/
layout: 'vertical',
autoLayout: true
});
};
_proto._addItem = function _addItem(item) {
var itemsGroup = this.get('itemsGroup');
var x = this._getNextX();
var y = 0;
var unCheckColor = this.get('unCheckColor');
var itemGroup = itemsGroup.addGroup({
x: 0,
y: 0,
value: item.value,
scaleValue: item.scaleValue,
checked: item.checked
});
itemGroup.translate(x, y);
itemGroup.set('viewId', itemsGroup.get('viewId'));
var textStyle = this.get('textStyle');
var wordSpace = this.get('_wordSpaceing');
var startX = 0;
if (item.marker) {
// 如果有marker添加marker
var markerAttrs = Util.mix({}, item.marker, {
x: item.marker.radius,
y: 0
});
if (!item.checked) {
if (markerAttrs.fill) {
markerAttrs.fill = unCheckColor;
}
if (markerAttrs.stroke) {
markerAttrs.stroke = unCheckColor;
}
}
var markerShape = itemGroup.addShape('marker', {
type: 'marker',
attrs: markerAttrs
});
markerShape.attr('cursor', 'pointer');
markerShape.name = 'legend-marker';
startX += markerShape.getBBox().width + wordSpace;
}
var textAttrs = Util.mix({}, textStyle, {
x: startX,
y: 0,
text: this._formatItemValue(item.value)
});
if (!item.checked) {
Util.mix(textAttrs, {
fill: unCheckColor
});
}
var textShape = itemGroup.addShape('text', {
attrs: textAttrs
});
textShape.attr('cursor', 'pointer');
textShape.name = 'legend-text';
this.get('appendInfo') && textShape.setSilent('appendInfo', this.get('appendInfo')); // 添加一个包围矩形,用于事件支持
var bbox = itemGroup.getBBox();
var itemWidth = this.get('itemWidth');
var wrapperShape = itemGroup.addShape('rect', {
attrs: {
x: x,
y: y - bbox.height / 2,
fill: '#fff',
fillOpacity: 0,
width: itemWidth || bbox.width,
height: bbox.height
}
});
wrapperShape.attr('cursor', 'pointer');
wrapperShape.setSilent('origin', item); // 保存图例项相关的数据,便于事件操作
wrapperShape.name = 'legend-item';
this.get('appendInfo') && wrapperShape.setSilent('appendInfo', this.get('appendInfo'));
itemGroup.name = 'legendGroup';
return itemGroup;
};
_proto._adjust = function _adjust() {
var self = this;
var geom = self.get('geom');
if (geom) {
var groupMatrix = self.get('group').attr('matrix');
groupMatrix[7] = 0;
var dataArray = self.get('geom').get('dataArray');
var groups = this.get('itemsGroup').get('children');
var index = 0;
Util.each(groups, function (groupItem) {
var dArray = dataArray[index];
var lastY = dArray[dArray.length - 1].y;
if (Util.isArray(lastY)) {
lastY = lastY[1];
}
var groupHeight = groupItem.getBBox().height;
var x = groupItem.get('x');
var y = lastY - groupHeight / 2;
groupItem.translate(x, y);
index++;
});
if (self.get('autoLayout')) {
self._antiCollision(groups);
}
}
};
_proto.render = function render() {
var _this = this;
_Category.prototype.render.call(this);
var chart = this.get('chart');
chart.once('afterpaint', function () {
_this._adjust();
});
};
_proto._getPreviousY = function _getPreviousY(item) {
var y = item.attr('matrix')[7];
var height = item.getBBox().height;
return y + height;
};
_proto._adjustDenote = function _adjustDenote(group, start, end) {
var margin = Global.legend.legendMargin;
var x0 = -2;
var x2 = -margin * 2;
group.addShape('path', {
attrs: {
path: 'M' + x0 + ',' + start + 'L' + x2 + ',' + (end + 3),
lineWidth: 1,
lineDash: [2, 2],
stroke: '#999999'
}
});
};
_proto._antiCollision = function _antiCollision(items) {
var self = this;
items.sort(function (a, b) {
var ay = a.attr('matrix')[7];
var by = b.attr('matrix')[7];
return ay - by;
});
var overlapping = true;
var plotRange = self.get('chart').get('plotRange');
var startY = plotRange.tl.y;
var totalHeight = Math.abs(startY - plotRange.bl.y);
var elementHeight = items[0].getBBox().height;
var minY = Number.MIN_VALUE;
var maxY = 0;
var boxes = items.map(function (item) {
var y = item.attr('matrix')[7];
if (y > maxY) {
maxY = y;
}
if (y < minY) {
minY = y;
}
return {
size: item.getBBox().height,
targets: [y - startY]
};
});
minY -= startY;
var i = 0;
while (overlapping) {
for (var _i = 0; _i < boxes.length; _i++) {
var box = boxes[_i];
var target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2;
box.pos = Math.min(Math.max(minY, target - box.size / 2), totalHeight - box.size);
}
overlapping = false;
i = boxes.length;
while (i--) {
if (i > 0) {
var previous = boxes[i - 1];
var current = boxes[i];
if (previous.pos + previous.size > current.pos) {
// overlapping
previous.size += current.size;
previous.targets = previous.targets.concat(current.targets);
boxes.splice(i, 1);
overlapping = true;
}
}
} // end of while i
} // end of while
// adjust y
i = 0;
var group = this.get('itemsGroup').addGroup();
boxes.forEach(function (b) {
var posInCompositeBox = startY + elementHeight;
b.targets.forEach(function () {
var origin_y = items[i].attr('matrix')[7];
var y = b.pos + posInCompositeBox - elementHeight / 2;
var dist = Math.abs(origin_y - y);
if (dist > elementHeight / 2) {
self._adjustDenote(group, y, origin_y - self.get('group').attr('matrix')[7] / 2);
}
items[i].translate(0, -origin_y);
items[i].translate(0, y);
posInCompositeBox += elementHeight;
i++;
});
});
}; // end of antiCollision
return Tail;
}(Category);
module.exports = Tail;
/***/ }),
/* 277 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The class of canvas plot
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var _require = __webpack_require__(23),
Group = _require.Group;
var AUTO_STR = 'auto';
var PlotBack =
/*#__PURE__*/
function (_Group) {
_inheritsLoose(PlotBack, _Group);
function PlotBack() {
return _Group.apply(this, arguments) || this;
}
var _proto = PlotBack.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
/**
* 类型
* @type {String}
*/
type: 'plotBack',
/**
* 画布边距
* @type {Number | Array | Object | "auto"}
*/
padding: null,
/**
* 大背景
* @type {Object}
*/
background: null,
/**
* 绘图区域范围
* @type {Object}
*/
plotRange: null,
/**
* 绘图区域背景
* @type {Object}
*/
plotBackground: null
};
};
_proto._beforeRenderUI = function _beforeRenderUI() {
this._calculateRange();
};
_proto._renderUI = function _renderUI() {
this._renderBackground();
this._renderPlotBackground();
};
_proto._renderBackground = function _renderBackground() {
var self = this;
var background = self.get('background');
if (background) {
var canvas = this.get('canvas');
var width = self.get('width') || canvas.get('width');
var height = self.get('height') || canvas.get('height');
var cfg = {
x: 0,
y: 0,
width: width,
height: height
};
var rect = self.get('backgroundShape');
if (!rect) {
rect = this.addShape('rect', {
attrs: Util.mix(cfg, background)
});
this.set('backgroundShape', rect);
} else {
rect.attr(cfg);
}
} else {
return;
}
};
_proto._renderPlotBackground = function _renderPlotBackground() {
var self = this;
var plotBackground = self.get('plotBackground');
if (plotBackground) {
var plotRange = self.get('plotRange');
var width = plotRange.br.x - plotRange.bl.x;
var height = plotRange.br.y - plotRange.tr.y;
var tl = plotRange.tl;
var cfg = {
x: tl.x,
y: tl.y,
width: width,
height: height
};
var plotBackShape = self.get('plotBackShape');
if (!plotBackShape) {
if (plotBackground.image) {
cfg.img = plotBackground.image;
plotBackShape = self.addShape('image', {
attrs: cfg
});
} else {
// 矩形
Util.mix(cfg, plotBackground);
plotBackShape = self.addShape('rect', {
attrs: cfg
});
}
self.set('plotBackShape', plotBackShape);
} else {
plotBackShape.attr(cfg);
}
} else {
return;
}
};
_proto._convert = function _convert(val, isHorizontal) {
if (Util.isString(val)) {
if (val === AUTO_STR) {
val = 0;
} else if (val.indexOf('%') !== -1) {
var canvas = this.get('canvas');
var width = this.get('width') || canvas.get('width');
var height = this.get('height') || canvas.get('height');
val = parseInt(val, 10) / 100;
val = isHorizontal ? val * width : val * height;
}
}
return val;
};
_proto._calculateRange = function _calculateRange() {
var self = this;
var plotRange = self.get('plotRange');
if (Util.isNil(plotRange)) {
plotRange = {};
}
var padding = self.get('padding');
var canvas = this.get('canvas');
var width = self.get('width') || canvas.get('width');
var height = self.get('height') || canvas.get('height');
var allPadding = Util.toAllPadding(padding);
var top = self._convert(allPadding[0], false);
var right = self._convert(allPadding[1], true);
var bottom = self._convert(allPadding[2], false);
var left = self._convert(allPadding[3], true);
var minX = Math.min(left, width - right);
var maxX = Math.max(left, width - right);
var minY = Math.min(height - bottom, top);
var maxY = Math.max(height - bottom, top);
plotRange.tl = {
x: minX,
y: minY
}; // top-left
plotRange.tr = {
x: maxX,
y: minY
}; // top-right
plotRange.bl = {
x: minX,
y: maxY
}; // bottom-left
plotRange.br = {
x: maxX,
y: maxY
}; // bottom-right
plotRange.cc = {
x: (maxX + minX) / 2,
y: (maxY + minY) / 2
};
this.set('plotRange', plotRange);
};
_proto.repaint = function repaint() {
this._calculateRange();
this._renderBackground();
this._renderPlotBackground();
return this;
};
return PlotBack;
}(Group);
module.exports = PlotBack;
/***/ }),
/* 278 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview circle facets
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(43);
function getPoint(center, r, angle) {
return {
x: center.x + r * Math.cos(angle),
y: center.y + r * Math.sin(angle)
};
}
var Circle =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Circle, _Base);
function Circle() {
return _Base.apply(this, arguments) || this;
}
var _proto = Circle.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
cfg.type = 'circle';
return cfg;
};
_proto.getRegion = function getRegion(count, index) {
var r = 1 / 2; // 画布半径
var avgAngle = Math.PI * 2 / count;
var angle = -1 * Math.PI / 2 + avgAngle * index; // 当前分面所在的弧度
var facetR = r / (1 + 1 / Math.sin(avgAngle / 2));
var center = {
x: 0.5,
y: 0.5
}; // 画布圆心
var middle = getPoint(center, r - facetR, angle); // 分面的中心点
var startAngle = Math.PI * 5 / 4; // 右上角
var endAngle = Math.PI * 1 / 4; // 左下角
return {
start: getPoint(middle, facetR, startAngle),
end: getPoint(middle, facetR, endAngle)
};
};
_proto.generateFacets = function generateFacets(data) {
var self = this;
var fields = self.fields;
var field = fields[0];
if (!field) {
throw 'Please specify for the field for facet!';
}
var values = self.getFieldValues(field, data);
var count = values.length;
var rst = [];
values.forEach(function (value, index) {
var conditions = [{
field: field,
value: value,
values: values
}];
var filter = self.getFilter(conditions);
var subData = data.filter(filter);
var facet = {
type: self.type,
colValue: value,
colField: field,
colIndex: index,
cols: count,
rows: 1,
rowIndex: 0,
data: subData,
region: self.getRegion(count, index)
};
rst.push(facet);
});
return rst;
};
return Circle;
}(Base);
module.exports = Circle;
/***/ }),
/* 279 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview Facet 的入口
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var Chart = __webpack_require__(114);
var Facets = {};
Facets.Rect = __webpack_require__(120);
Facets.List = __webpack_require__(119);
Facets.Circle = __webpack_require__(278);
Facets.Tree = __webpack_require__(282);
Facets.Mirror = __webpack_require__(281);
Facets.Matrix = __webpack_require__(280);
Chart.prototype.facet = function (type, cfg) {
var cls = Facets[Util.upperFirst(type)];
if (!cls) {
throw new Error('Not support such type of facets as: ' + type);
}
var preFacets = this.get('facets');
if (preFacets) {
preFacets.destroy();
}
cfg.chart = this;
var facets = new cls(cfg);
this.set('facets', facets);
};
module.exports = Facets;
/***/ }),
/* 280 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview Use matrices to compare different fields
* @author dxq613@gmail.com
*/
var Rect = __webpack_require__(120);
var Matrix =
/*#__PURE__*/
function (_Rect) {
_inheritsLoose(Matrix, _Rect);
function Matrix() {
return _Rect.apply(this, arguments) || this;
}
var _proto = Matrix.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Rect.prototype.getDefaultCfg.call(this);
cfg.type = 'matrix';
cfg.showTitle = false;
return cfg;
};
_proto.generateFacets = function generateFacets(data) {
var self = this;
var fields = self.fields;
var rows = fields.length;
var cols = rows; // 矩阵中行列相等,等于指定的字段个数
var rst = [];
for (var i = 0; i < cols; i++) {
var colField = fields[i];
for (var j = 0; j < rows; j++) {
var rowField = fields[j];
var facet = {
type: self.type,
colValue: colField,
rowValue: rowField,
colField: colField,
rowField: rowField,
colIndex: i,
rowIndex: j,
cols: cols,
rows: rows,
data: data,
region: self.getRegion(rows, cols, i, j)
};
rst.push(facet);
}
}
return rst;
}; // 设置 x 坐标轴的文本、title 是否显示
_proto.setXAxis = function setXAxis(xField, axes, facet) {
if (facet.rowIndex !== facet.rows - 1) {
axes[xField].title = null;
axes[xField].label = null;
}
}; // 设置 y 坐标轴的文本、title 是否显示
_proto.setYAxis = function setYAxis(yField, axes, facet) {
if (facet.colIndex !== 0) {
axes[yField].title = null;
axes[yField].label = null;
}
};
return Matrix;
}(Rect);
module.exports = Matrix;
/***/ }),
/* 281 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview mirror facets
* @author dxq613@gmail.com
*/
var List = __webpack_require__(119);
var Mirror =
/*#__PURE__*/
function (_List) {
_inheritsLoose(Mirror, _List);
function Mirror() {
return _List.apply(this, arguments) || this;
}
var _proto = Mirror.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _List.prototype.getDefaultCfg.call(this);
cfg.type = 'mirror';
this.transpose = false;
return cfg;
};
_proto.init = function init() {
var self = this;
if (self.transpose) {
self.cols = 2;
self.rows = 1;
} else {
self.cols = 1;
self.rows = 2;
}
_List.prototype.init.call(this);
};
_proto.beforeProcessView = function beforeProcessView(view, facet) {
if (this.transpose) {
if (facet.colIndex % 2 === 0) {
view.coord().transpose().scale(-1, 1);
} else {
view.coord().transpose();
}
} else {
if (facet.rowIndex % 2 !== 0) {
view.coord().scale(1, -1);
}
}
};
_proto.renderTitle = function renderTitle(view, facet) {
if (this.transpose) {
this.drawColTitle(view, facet);
} else {
this.drawRowTitle(view, facet);
}
};
_proto.setXAxis = function setXAxis(xField, axes, facet) {
// 当是最后一行或者下面没有 view 时文本不显示
if (facet.colIndex === 1 || facet.rowIndex === 1) {
axes[xField].label = null;
axes[xField].title = null;
}
};
_proto.setYAxis = function setYAxis()
/* yField, axes, facet */
{};
return Mirror;
}(List);
module.exports = Mirror;
/***/ }),
/* 282 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview tree facets
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(43);
var Util = __webpack_require__(0);
var assign = Util.assign;
var Tree =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Tree, _Base);
function Tree() {
return _Base.apply(this, arguments) || this;
}
var _proto = Tree.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Base.prototype.getDefaultCfg.call(this);
cfg.type = 'tree';
cfg.line = {
lineWidth: 1,
stroke: '#ddd'
};
cfg.lineSmooth = false;
return cfg;
};
_proto.generateFacets = function generateFacets(data) {
var self = this;
var fields = self.fields;
if (!fields.length) {
throw 'Please specify for the fields for facet!';
}
var rst = [];
var root = self.getRootFacet(data); // if (self.showRoot) {
rst.push(root); // }
root.children = self.getChildFacets(data, 1, rst);
self.setRegion(rst);
return rst;
};
_proto.getRootFacet = function getRootFacet(data) {
var self = this;
var facet = {
type: self.type,
rows: self.getRows(),
rowIndex: 0,
colIndex: 0,
colValue: self.rootTitle,
data: data
};
return facet;
};
_proto.getRows = function getRows() {
return this.fields.length + 1;
}; // get child
_proto.getChildFacets = function getChildFacets(data, level, arr) {
var self = this;
var fields = self.fields;
var length = fields.length;
if (length < level) {
return;
}
var rst = [];
var field = fields[level - 1];
var values = self.getFieldValues(field, data);
values.forEach(function (value, index) {
var conditions = [{
field: field,
value: value,
values: values
}];
var filter = self.getFilter(conditions);
var subData = data.filter(filter);
if (subData.length) {
var facet = {
type: self.type,
colValue: value,
colField: field,
colIndex: index,
rows: self.getRows(),
rowIndex: level,
data: subData,
children: self.getChildFacets(subData, level + 1, arr)
};
rst.push(facet);
arr.push(facet);
}
});
return rst;
}; // 设置 region
_proto.setRegion = function setRegion(facets) {
var self = this;
self.forceColIndex(facets);
facets.forEach(function (facet) {
facet.region = self.getRegion(facet.rows, facet.cols, facet.colIndex, facet.rowIndex);
});
}; // set column index of facets
_proto.forceColIndex = function forceColIndex(facets) {
var self = this;
var leafs = [];
var index = 0;
facets.forEach(function (facet) {
if (self.isLeaf(facet)) {
leafs.push(facet);
facet.colIndex = index;
index++;
}
});
leafs.forEach(function (facet) {
facet.cols = leafs.length;
});
var maxLevel = self.fields.length;
for (var i = maxLevel - 1; i >= 0; i--) {
var levelFacets = self.getFacetsByLevel(facets, i); // var yIndex = maxLevel - i;
for (var j = 0; j < levelFacets.length; j++) {
var facet = levelFacets[j];
if (!self.isLeaf(facet)) {
facet.originColIndex = facet.colIndex;
facet.colIndex = self.getRegionIndex(facet.children);
facet.cols = leafs.length;
}
}
}
}; // get facet use level
_proto.getFacetsByLevel = function getFacetsByLevel(facets, level) {
var rst = [];
facets.forEach(function (facet) {
if (facet.rowIndex === level) {
rst.push(facet);
}
});
return rst;
}; // set facets region
_proto.getRegion = function getRegion(rows, cols, xIndex, yIndex) {
var xWidth = 1 / cols; // x轴方向的每个分面的偏移
var yWidth = 1 / rows; // y轴方向的每个分面的偏移
var start = {
x: xWidth * xIndex,
y: yWidth * yIndex
};
var end = {
x: start.x + xWidth,
y: start.y + yWidth * 2 / 3 // 预留1/3的空隙,方便添加连接线
};
return {
start: start,
end: end
};
}; // if the facet has children , make it's column index in the middle of it's children
_proto.getRegionIndex = function getRegionIndex(children) {
var first = children[0];
var last = children[children.length - 1];
return (last.colIndex - first.colIndex) / 2 + first.colIndex;
}; // is a leaf without children
_proto.isLeaf = function isLeaf(facet) {
return !facet.children || !facet.children.length;
};
_proto.setXAxis = function setXAxis(xField, axes, facet) {
// 当是最后一行或者下面没有 view 时文本不显示
if (facet.rowIndex !== facet.rows - 1) {
axes[xField].label = null;
axes[xField].title = null;
}
}; // 设置 y 坐标轴的文本、title 是否显示
_proto.setYAxis = function setYAxis(yField, axes, facet) {
if (facet.originColIndex !== 0 && facet.colIndex !== 0) {
axes[yField].title = null;
axes[yField].label = null;
}
}; // 绘制完成后
_proto.onPaint = function onPaint() {
_Base.prototype.onPaint.call(this);
this.group.clear();
if (this.facets && this.line) {
this.drawLines(this.facets, this.group);
}
};
_proto.drawLines = function drawLines(facets, group) {
var self = this;
var lineGroup = group.addGroup();
facets.forEach(function (facet) {
if (!self.isLeaf(facet)) {
var children = facet.children;
self._addFacetLines(facet, children, lineGroup);
}
});
}; // add lines with it's children
_proto._addFacetLines = function _addFacetLines(facet, children, group) {
var self = this;
var view = facet.view;
var region = view.getViewRegion();
var start = {
x: region.start.x + (region.end.x - region.start.x) / 2,
y: region.start.y
};
children.forEach(function (subFacet) {
var subRegion = subFacet.view.getViewRegion();
var end = {
x: subRegion.start.x + (subRegion.end.x - subRegion.start.x) / 2,
y: subRegion.end.y
};
var middle1 = {
x: start.x,
y: start.y + (end.y - start.y) / 2
};
var middle2 = {
x: end.x,
y: middle1.y
};
self._drawLine([start, middle1, middle2, end], group);
});
};
_proto._getPath = function _getPath(points) {
var self = this;
var path = [];
var smooth = self.lineSmooth;
if (smooth) {
path.push(['M', points[0].x, points[0].y]);
path.push(['C', points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y]);
} else {
points.forEach(function (point, index) {
if (index === 0) {
path.push(['M', point.x, point.y]);
} else {
path.push(['L', point.x, point.y]);
}
});
}
return path;
}; // draw line width points
_proto._drawLine = function _drawLine(points, group) {
var self = this;
var path = self._getPath(points);
var line = self.line;
group.addShape('path', {
attrs: assign({
path: path
}, line)
});
};
return Tree;
}(Base);
module.exports = Tree;
/***/ }),
/* 283 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview 面积图
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var SplitMixin = __webpack_require__(122);
var Util = __webpack_require__(0);
__webpack_require__(298);
var Area =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Area, _GeomBase);
var _proto = Area.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'area';
cfg.shapeType = 'area';
cfg.generatePoints = true;
cfg.sortable = true;
return cfg;
};
function Area(cfg) {
var _this;
_this = _GeomBase.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), SplitMixin);
return _this;
}
_proto.draw = function draw(data, container, shapeFactory, index) {
var self = this;
var cfg = this.getDrawCfg(data[0]);
self._applyViewThemeShapeStyle(cfg, cfg.shape, shapeFactory);
var splitArray = this.splitData(data);
cfg.origin = data; // path,line,area 等图的origin 是整个序列
Util.each(splitArray, function (subData, splitedIndex) {
cfg.splitedIndex = splitedIndex; // 传入分割片段索引 用于生成id
var points = subData.map(function (obj) {
return obj.points;
});
cfg.points = points;
var geomShape = shapeFactory.drawShape(cfg.shape, cfg, container);
self.appendShapeInfo(geomShape, index + splitedIndex);
});
};
return Area;
}(GeomBase);
var AreaStack =
/*#__PURE__*/
function (_Area) {
_inheritsLoose(AreaStack, _Area);
function AreaStack() {
return _Area.apply(this, arguments) || this;
}
var _proto2 = AreaStack.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Area.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'stack'
}];
return cfg;
};
return AreaStack;
}(Area);
Area.Stack = AreaStack;
GeomBase.Area = Area;
GeomBase.AreaStack = AreaStack;
module.exports = Area;
/***/ }),
/* 284 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 边,用于关系图的边
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
__webpack_require__(299);
var Edge =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Edge, _GeomBase);
function Edge() {
return _GeomBase.apply(this, arguments) || this;
}
var _proto = Edge.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'edge';
cfg.shapeType = 'edge';
cfg.generatePoints = true;
return cfg;
};
return Edge;
}(GeomBase);
GeomBase.Edge = Edge;
module.exports = Edge;
/***/ }),
/* 285 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview heatmap
* @author leungwensen@gmail.com
*/
var _require = __webpack_require__(61),
ColorUtil = _require.ColorUtil; // TODO: ColorUtil 独立成包,从 attr 包中抽离
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
var ORIGIN_FIELD = '_origin';
var SHADOW_CANVAS = 'shadowCanvas';
var VALUE_RANGE = 'valueRange';
var IMAGE_SHAPE = 'imageShape';
var MAPPED_DATA = 'mappedData';
var GRAY_SCALE_BLURRED_CANVAS = 'grayScaleBlurredCanvas';
var HEATMAP_SIZE = 'heatmapSize';
var Heatmap =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Heatmap, _GeomBase);
function Heatmap() {
return _GeomBase.apply(this, arguments) || this;
}
var _proto = Heatmap.prototype;
/**
* get default configuration
* @protected
* @return {Object} configuration
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'heatmap';
cfg.paletteCache = {}; // cfg.shapeType = 'heatmap';
return cfg;
};
_proto._prepareRange = function _prepareRange() {
var self = this;
var data = self.get(MAPPED_DATA);
var colorAttr = self.getAttr('color');
var colorField = colorAttr.field;
var min = Infinity;
var max = -Infinity;
data.forEach(function (row) {
var value = row[ORIGIN_FIELD][colorField];
if (value > max) {
max = value;
}
if (value < min) {
min = value;
}
});
if (min === max) {
min = max - 1;
}
var range = [min, max];
self.set(VALUE_RANGE, range);
};
_proto._prepareSize = function _prepareSize() {
var self = this;
var radius = self.getDefaultValue('size');
if (!Util.isNumber(radius)) {
radius = self._getDefaultSize();
}
var styleOptions = self.get('styleOptions');
var blur = styleOptions && Util.isObject(styleOptions.style) ? styleOptions.style.blur : null;
if (!Util.isFinite(blur) || blur === null) {
blur = radius / 2;
}
self.set(HEATMAP_SIZE, {
blur: blur,
radius: radius
});
};
_proto._getDefaultSize = function _getDefaultSize() {
var self = this;
var position = self.getAttr('position');
var coord = self.get('coord');
var radius = Math.min(coord.width / (position.scales[0].ticks.length * 4), coord.height / (position.scales[1].ticks.length * 4));
return radius;
};
_proto._colorize = function _colorize(img) {
var self = this;
var colorAttr = self.getAttr('color');
var pixels = img.data;
var paletteCache = self.get('paletteCache');
for (var i = 3; i < pixels.length; i += 4) {
var alpha = pixels[i]; // get gradient color from opacity value
if (alpha) {
var palette = void 0;
if (paletteCache[alpha]) {
palette = paletteCache[alpha];
} else {
palette = ColorUtil.rgb2arr(colorAttr.gradient(alpha / 256));
paletteCache[alpha] = palette;
} // const palette = colorUtil.rgb2arr(colorAttr.gradient(alpha / 256));
pixels[i - 3] = palette[0];
pixels[i - 2] = palette[1];
pixels[i - 1] = palette[2];
pixels[i] = alpha;
}
}
};
_proto._prepareGreyScaleBlurredCircle = function _prepareGreyScaleBlurredCircle(r, blur) {
var self = this;
var circleCanvas = self.get(GRAY_SCALE_BLURRED_CANVAS);
if (!circleCanvas) {
circleCanvas = document.createElement('canvas');
self.set(GRAY_SCALE_BLURRED_CANVAS, circleCanvas);
}
var r2 = r + blur;
var ctx = circleCanvas.getContext('2d');
circleCanvas.width = circleCanvas.height = r2 * 2;
ctx.clearRect(0, 0, circleCanvas.width, circleCanvas.height); // ctx.shadowOffsetX = ctx.shadowOffsetY = r2 * 2;
ctx.shadowOffsetX = ctx.shadowOffsetY = r2 * 2;
ctx.shadowBlur = blur;
ctx.shadowColor = 'black';
ctx.beginPath();
ctx.arc(-r2, -r2, r, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
};
_proto._drawGrayScaleBlurredCircle = function _drawGrayScaleBlurredCircle(x, y, r, alpha, ctx) {
var self = this;
var circleCanvas = self.get(GRAY_SCALE_BLURRED_CANVAS);
ctx.globalAlpha = alpha;
ctx.drawImage(circleCanvas, x - r, y - r);
};
_proto._getShadowCanvasCtx = function _getShadowCanvasCtx() {
var self = this;
var canvas = self.get(SHADOW_CANVAS);
if (!canvas) {
canvas = document.createElement('canvas');
self.set(SHADOW_CANVAS, canvas);
}
var coord = self.get('coord');
if (coord) {
canvas.width = coord.width;
canvas.height = coord.height;
}
return canvas.getContext('2d');
};
_proto._clearShadowCanvasCtx = function _clearShadowCanvasCtx() {
var ctx = this._getShadowCanvasCtx();
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
};
_proto._getImageShape = function _getImageShape() {
var self = this;
var imageShape = self.get(IMAGE_SHAPE);
if (imageShape) {
return imageShape;
}
var container = self.get('container');
imageShape = container.addShape('Image', {});
self.set(IMAGE_SHAPE, imageShape);
return imageShape;
};
_proto.clear = function clear() {
// @2019-02-28 by blue.lb 由于设置了SHADOW_CANVAS作为像素缓存canvas,每次销毁chart时,也需要清除该缓冲区
this._clearShadowCanvasCtx();
_GeomBase.prototype.clear.call(this);
};
_proto.drawWithRange = function drawWithRange(range) {
var self = this; // canvas size
var _self$get = self.get('coord'),
start = _self$get.start,
end = _self$get.end,
width = _self$get.width,
height = _self$get.height; // value, range, etc
var valueField = self.getAttr('color').field;
var size = self.get(HEATMAP_SIZE); // prepare shadow canvas context
self._clearShadowCanvasCtx();
var ctx = self._getShadowCanvasCtx(); // filter data
var data = self.get(MAPPED_DATA);
if (range) {
data = data.filter(function (row) {
return row[ORIGIN_FIELD][valueField] <= range[1] && row[ORIGIN_FIELD][valueField] >= range[0];
});
} // step1. draw points with shadow
var scale = self._getScale(valueField);
for (var i = 0; i < data.length; i++) {
var obj = data[i];
var cfg = self.getDrawCfg(obj);
var alpha = scale.scale(obj[ORIGIN_FIELD][valueField]);
self._drawGrayScaleBlurredCircle(cfg.x - start.x, cfg.y - end.y, size.radius + size.blur, alpha, ctx);
} // step2. convert pixels
var colored = ctx.getImageData(0, 0, width, height);
self._clearShadowCanvasCtx();
self._colorize(colored);
ctx.putImageData(colored, 0, 0);
var imageShape = self._getImageShape();
imageShape.attr('x', start.x);
imageShape.attr('y', end.y);
imageShape.attr('width', width);
imageShape.attr('height', height);
imageShape.attr('img', ctx.canvas);
};
_proto.draw = function draw(data
/* , container, shapeFactory, index */
) {
var self = this;
self.set(MAPPED_DATA, data);
self._prepareRange();
self._prepareSize();
var size = self.get(HEATMAP_SIZE);
self._prepareGreyScaleBlurredCircle(size.radius, size.blur);
var range = self.get(VALUE_RANGE);
self.drawWithRange(range); // super.draw(data, container, shapeFactory, index);
};
return Heatmap;
}(GeomBase);
GeomBase.Heatmap = Heatmap;
module.exports = Heatmap;
/***/ }),
/* 286 */
/***/ (function(module, exports, __webpack_require__) {
var Geom = __webpack_require__(8);
Geom.Point = __webpack_require__(295);
Geom.PointJitter = Geom.Point.Jitter;
Geom.PointStack = Geom.Point.Stack;
Geom.Path = __webpack_require__(123);
Geom.Line = __webpack_require__(291);
Geom.LineStack = Geom.Line.Stack;
Geom.Interval = __webpack_require__(287);
Geom.IntervalStack = Geom.Interval.Stack;
Geom.IntervalDodge = Geom.Interval.Dodge;
Geom.IntervalSymmetric = Geom.Interval.Symmetric;
Geom.Area = __webpack_require__(283);
Geom.AreaStack = Geom.Area.Stack;
Geom.Polygon = __webpack_require__(296);
Geom.Schema = __webpack_require__(297);
Geom.SchemaDodge = Geom.Schema.Dodge;
Geom.Edge = __webpack_require__(284);
Geom.Heatmap = __webpack_require__(285);
Geom.Venn = __webpack_require__(309);
Geom.Violin = __webpack_require__(310);
module.exports = Geom;
/***/ }),
/* 287 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview interval geometry
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
var SizeMixin = __webpack_require__(67);
__webpack_require__(300);
var Interval =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Interval, _GeomBase);
var _proto = Interval.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'interval';
cfg.shapeType = 'interval';
cfg.generatePoints = true;
return cfg;
};
function Interval(cfg) {
var _this;
_this = _GeomBase.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
return _this;
}
_proto.createShapePointsCfg = function createShapePointsCfg(obj) {
var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj);
cfg.size = this.getNormalizedSize(obj);
return cfg;
};
_proto.clearInner = function clearInner() {
_GeomBase.prototype.clearInner.call(this);
this.set('defaultSize', null);
};
return Interval;
}(GeomBase);
var IntervalStack =
/*#__PURE__*/
function (_Interval) {
_inheritsLoose(IntervalStack, _Interval);
function IntervalStack() {
return _Interval.apply(this, arguments) || this;
}
var _proto2 = IntervalStack.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Interval.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'stack'
}];
return cfg;
};
return IntervalStack;
}(Interval);
var IntervalDodge =
/*#__PURE__*/
function (_Interval2) {
_inheritsLoose(IntervalDodge, _Interval2);
function IntervalDodge() {
return _Interval2.apply(this, arguments) || this;
}
var _proto3 = IntervalDodge.prototype;
_proto3.getDefaultCfg = function getDefaultCfg() {
var cfg = _Interval2.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'dodge'
}];
return cfg;
};
return IntervalDodge;
}(Interval);
var IntervalSymmetric =
/*#__PURE__*/
function (_Interval3) {
_inheritsLoose(IntervalSymmetric, _Interval3);
function IntervalSymmetric() {
return _Interval3.apply(this, arguments) || this;
}
var _proto4 = IntervalSymmetric.prototype;
_proto4.getDefaultCfg = function getDefaultCfg() {
var cfg = _Interval3.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'symmetric'
}];
return cfg;
};
return IntervalSymmetric;
}(Interval);
Interval.Stack = IntervalStack;
Interval.Dodge = IntervalDodge;
Interval.Symmetric = IntervalSymmetric;
GeomBase.Interval = Interval;
GeomBase.IntervalStack = IntervalStack;
GeomBase.IntervalDodge = IntervalDodge;
GeomBase.IntervalSymmetric = IntervalSymmetric;
module.exports = Interval;
/***/ }),
/* 288 */
/***/ (function(module, exports, __webpack_require__) {
var GeomLabels = __webpack_require__(66);
var PolarLabels = __webpack_require__(121);
var PieLabels = __webpack_require__(290);
var IntervalLabels = __webpack_require__(289);
var Labels = {
getLabelsClass: function getLabelsClass(coordType, type) {
var rst = GeomLabels;
if (coordType === 'polar') {
rst = PolarLabels;
} else if (coordType === 'theta') {
// pie chart
rst = PieLabels;
} else if (type === 'interval' || type === 'polygon') {
// bar
rst = IntervalLabels;
}
return rst;
}
};
module.exports = Labels;
/***/ }),
/* 289 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(0);
var GeomLabels = __webpack_require__(66);
var IntervalLabels =
/*#__PURE__*/
function (_GeomLabels) {
_inheritsLoose(IntervalLabels, _GeomLabels);
function IntervalLabels() {
return _GeomLabels.apply(this, arguments) || this;
}
var _proto = IntervalLabels.prototype;
_proto.setLabelPosition = function setLabelPosition(point, originPoint, index, position) {
if (Util.isFunction(position)) {
position = position(point.text, originPoint._origin, index);
}
var coord = this.get('coord');
var transposed = coord.isTransposed;
var point0 = coord.convertPoint(originPoint.points[0]);
var point1 = coord.convertPoint(originPoint.points[2]);
var width = (point0.x - point1.x) / 2 * (transposed ? -1 : 1);
var height = (point0.y - point1.y) / 2 * (transposed ? -1 : 1);
switch (position) {
case 'right':
if (transposed) {
point.x -= width;
point.y += height;
point.textAlign = point.textAlign || 'center';
} else {
point.x -= width;
point.y += height;
point.textAlign = point.textAlign || 'left';
}
break;
case 'left':
if (transposed) {
point.x -= width;
point.y -= height;
point.textAlign = point.textAlign || 'center';
} else {
point.x += width;
point.y += height;
point.textAlign = point.textAlign || 'right';
}
break;
case 'bottom':
if (transposed) {
point.x -= width * 2;
point.textAlign = point.textAlign || 'left';
} else {
point.y += height * 2;
point.textAlign = point.textAlign || 'center';
}
break;
case 'middle':
if (transposed) {
point.x -= width;
} else {
point.y += height;
}
point.textAlign = point.textAlign || 'center';
break;
case 'top':
if (transposed) {
point.textAlign = point.textAlign || 'left';
} else {
point.textAlign = point.textAlign || 'center';
}
break;
default:
break;
}
};
return IntervalLabels;
}(GeomLabels);
module.exports = IntervalLabels;
/***/ }),
/* 290 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Util = __webpack_require__(0);
var PolarLabels = __webpack_require__(121);
var PathUtil = __webpack_require__(25);
var Global = __webpack_require__(5);
var MARGIN = 5;
function getEndPoint(center, angle, r) {
return {
x: center.x + r * Math.cos(angle),
y: center.y + r * Math.sin(angle)
};
}
function antiCollision(labels, lineHeight, plotRange, center, isRight) {
// adjust y position of labels to avoid overlapping
var overlapping = true;
var start = plotRange.start;
var end = plotRange.end;
var startY = Math.min(start.y, end.y);
var totalHeight = Math.abs(start.y - end.y);
var i;
var maxY = 0;
var minY = Number.MIN_VALUE;
var boxes = labels.map(function (label) {
if (label.y > maxY) {
maxY = label.y;
}
if (label.y < minY) {
minY = label.y;
}
return {
size: lineHeight,
targets: [label.y - startY]
};
});
minY -= startY;
if (maxY - startY > totalHeight) {
totalHeight = maxY - startY;
}
while (overlapping) {
/* eslint no-loop-func: 0 */
boxes.forEach(function (box) {
var target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2;
box.pos = Math.min(Math.max(minY, target - box.size / 2), totalHeight - box.size); // box.pos = Math.max(0, target - box.size / 2);
}); // detect overlapping and join boxes
overlapping = false;
i = boxes.length;
while (i--) {
if (i > 0) {
var previousBox = boxes[i - 1];
var box = boxes[i];
if (previousBox.pos + previousBox.size > box.pos) {
// overlapping
previousBox.size += box.size;
previousBox.targets = previousBox.targets.concat(box.targets); // overflow, shift up
if (previousBox.pos + previousBox.size > totalHeight) {
previousBox.pos = totalHeight - previousBox.size;
}
boxes.splice(i, 1); // removing box
overlapping = true;
}
}
}
}
i = 0; // step 4: normalize y and adjust x
boxes.forEach(function (b) {
var posInCompositeBox = startY + lineHeight / 2; // middle of the label
b.targets.forEach(function () {
labels[i].y = b.pos + posInCompositeBox;
posInCompositeBox += lineHeight;
i++;
});
}); // (x - cx)^2 + (y - cy)^2 = totalR^2
labels.forEach(function (label) {
var rPow2 = label.r * label.r;
var dyPow2 = Math.pow(Math.abs(label.y - center.y), 2);
if (rPow2 < dyPow2) {
label.x = center.x;
} else {
var dx = Math.sqrt(rPow2 - dyPow2);
if (!isRight) {
// left
label.x = center.x - dx;
} else {
// right
label.x = center.x + dx;
}
}
});
}
var PieLabels =
/*#__PURE__*/
function (_PolarLabels) {
_inheritsLoose(PieLabels, _PolarLabels);
function PieLabels() {
return _PolarLabels.apply(this, arguments) || this;
}
var _proto = PieLabels.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
return {
label: Global.thetaLabels
};
};
_proto.getDefaultOffset = function getDefaultOffset(point) {
return point.offset || 0;
};
/**
* @protected
* to avoid overlapping
* @param {Array} items labels to be placed
* @return {Array} items
*/
_proto.adjustItems = function adjustItems(items) {
var self = this;
var offset = items[0] ? items[0].offset : 0;
if (offset > 0) {
items = self._distribute(items, offset);
}
return _PolarLabels.prototype.adjustItems.call(this, items);
};
/**
* @private
* distribute labels
* @param {Array} labels labels
* @param {Number} offset offset
* @return {Array} labels
*/
_proto._distribute = function _distribute(labels, offset) {
var self = this;
var coord = self.get('coord');
var radius = coord.getRadius();
var lineHeight = self.get('label').labelHeight;
var center = coord.getCenter();
var totalR = radius + offset;
var totalHeight = totalR * 2 + lineHeight * 2;
var plotRange = {
start: coord.start,
end: coord.end
};
var geom = self.get('geom');
if (geom) {
var view = geom.get('view');
plotRange = view.getViewRegion();
} // step 1: separate labels
var halves = [[], // left
[] // right
];
labels.forEach(function (label) {
if (!label) {
return;
}
if (label.textAlign === 'right') {
// left
halves[0].push(label);
} else {
// right or center will be put on the right side
halves[1].push(label);
}
});
halves.forEach(function (half, index) {
// step 2: reduce labels
var maxLabelsCountForOneSide = parseInt(totalHeight / lineHeight, 10);
if (half.length > maxLabelsCountForOneSide) {
half.sort(function (a, b) {
// sort by percentage DESC
return b['..percent'] - a['..percent'];
});
half.splice(maxLabelsCountForOneSide, half.length - maxLabelsCountForOneSide);
} // step 3: distribute position (x and y)
half.sort(function (a, b) {
// sort by y ASC
return a.y - b.y;
});
antiCollision(half, lineHeight, plotRange, center, index);
});
return halves[0].concat(halves[1]);
}; // 连接线
_proto.lineToLabel = function lineToLabel(label) {
var self = this;
var coord = self.get('coord');
var r = coord.getRadius();
var distance = label.offset;
var angle = label.orignAngle || label.angle;
var center = coord.getCenter();
var start = getEndPoint(center, angle, r + MARGIN / 2);
var inner = getEndPoint(center, angle, r + distance / 2);
if (!label.labelLine) {
label.labelLine = self.get('label').labelLine || {};
}
label.labelLine.path = ['M' + start.x, start.y + ' Q' + inner.x, inner.y + ' ' + label.x, label.y].join(',');
};
/**
* @protected
* get rotation for label
* @param {Number} angle angle
* @param {Number} offset offset
* @return {Number} rotate
*/
_proto.getLabelRotate = function getLabelRotate(angle, offset) {
var rotate;
if (offset < 0) {
rotate = angle * 180 / Math.PI;
if (rotate > 90) {
rotate = rotate - 180;
}
if (rotate < -90) {
rotate = rotate + 180;
}
}
return rotate / 180 * Math.PI;
};
/**
* @protected
* get text align for label
* @param {Object} point point
* @return {String} align
*/
_proto.getLabelAlign = function getLabelAlign(point) {
var self = this;
var coord = self.get('coord');
var center = coord.getCenter();
var align;
if (point.angle <= Math.PI / 2 && point.x >= center.x) {
align = 'left';
} else {
align = 'right';
}
var offset = self.getDefaultOffset(point);
if (offset <= 0) {
if (align === 'right') {
align = 'left';
} else {
align = 'right';
}
}
return align;
};
_proto.getArcPoint = function getArcPoint(point) {
return point;
};
_proto.getPointAngle = function getPointAngle(point) {
var self = this;
var coord = self.get('coord');
var startPoint = {
x: Util.isArray(point.x) ? point.x[0] : point.x,
y: point.y[0]
};
self.transLabelPoint(startPoint); // 转换到画布坐标,如果坐标系发生改变
var endPoint = {
x: Util.isArray(point.x) ? point.x[1] : point.x,
y: point.y[1]
};
self.transLabelPoint(endPoint); // 转换到画布坐标,如果坐标系发生改变
var angle;
var startAngle = PathUtil.getPointAngle(coord, startPoint);
if (point.points && point.points[0].y === point.points[1].y) {
angle = startAngle;
} else {
var endAngle = PathUtil.getPointAngle(coord, endPoint);
if (startAngle >= endAngle) {
// 100% pie slice
endAngle = endAngle + Math.PI * 2;
}
angle = startAngle + (endAngle - startAngle) / 2;
}
return angle;
};
_proto.getCirclePoint = function getCirclePoint(angle, offset) {
var self = this;
var coord = self.get('coord');
var center = coord.getCenter();
var r = coord.getRadius() + offset;
var point = getEndPoint(center, angle, r);
point.angle = angle;
point.r = r;
return point;
};
return PieLabels;
}(PolarLabels);
module.exports = PieLabels;
/***/ }),
/* 291 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 线图
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Path = __webpack_require__(123);
__webpack_require__(301);
var Line =
/*#__PURE__*/
function (_Path) {
_inheritsLoose(Line, _Path);
function Line() {
return _Path.apply(this, arguments) || this;
}
var _proto = Line.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _Path.prototype.getDefaultCfg.call(this);
cfg.type = 'line';
cfg.sortable = true;
return cfg;
};
return Line;
}(Path);
var LineStack =
/*#__PURE__*/
function (_Line) {
_inheritsLoose(LineStack, _Line);
function LineStack() {
return _Line.apply(this, arguments) || this;
}
var _proto2 = LineStack.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Line.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'stack'
}];
return cfg;
};
return LineStack;
}(Line);
Line.Stack = LineStack;
GeomBase.Line = Line;
GeomBase.LineStack = LineStack;
module.exports = Line;
/***/ }),
/* 292 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview the interaction when geom was actived
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var FIELD_ORIGIN = '_origin';
function isSameShape(shape1, shape2) {
if (Util.isNil(shape1) || Util.isNil(shape2)) {
return false;
}
var shape1Origin = shape1.get('origin');
var shape2Origin = shape2.get('origin');
return Util.isEqual(shape1Origin, shape2Origin);
}
function isChange(preShapes, shapes) {
if (!preShapes) {
return true;
}
if (preShapes.length !== shapes.length) {
return true;
}
var rst = false;
Util.each(shapes, function (shape, index) {
if (!isSameShape(shape, preShapes[index])) {
rst = true;
return false;
}
});
return rst;
}
function getOriginAttrs(activeCfg, shape) {
var originAttrs = {};
Util.each(activeCfg, function (v, k) {
var originValue = shape.attr(k);
if (Util.isArray(originValue)) {
originValue = Util.cloneDeep(originValue); // 缓存原来的属性,由于 .attr('matrix') 是数组,所以此处需要深度复制
}
originAttrs[k] = originValue;
});
return originAttrs;
}
var ActiveMixin = {
_isAllowActive: function _isAllowActive() {
var allowActive = this.get('allowActive');
if (Util.isNil(allowActive)) {
// 用户未设置,使用默认的策略
var view = this.get('view');
var isShareTooltip = this.isShareTooltip();
var options = view.get('options'); // 默认情况下,tooltip 关闭或者 tooltip 模式为 shared === false 的时候允许 active
if (options.tooltip === false || !isShareTooltip) {
return true;
}
} else {
return allowActive;
}
return false;
},
_onMouseenter: function _onMouseenter(ev) {
var self = this;
var shape = ev.shape;
var shapeContainer = self.get('shapeContainer');
if (shape && shapeContainer.contain(shape) && self._isAllowActive()) {
// shape.get('animating')
self.setShapesActived(shape);
}
},
_onMouseleave: function _onMouseleave() {
var self = this;
var view = self.get('view');
var canvas = view.get('canvas');
if (self.get('activeShapes')) {
self.clearActivedShapes();
canvas.draw();
}
},
_bindActiveAction: function _bindActiveAction() {
var self = this;
var view = self.get('view');
var type = self.get('type');
view.on(type + ':mouseenter', Util.wrapBehavior(self, '_onMouseenter'));
view.on(type + ':mouseleave', Util.wrapBehavior(self, '_onMouseleave'));
},
_offActiveAction: function _offActiveAction() {
var self = this;
var view = self.get('view');
var type = self.get('type');
view.off(type + ':mouseenter', Util.getWrapBehavior(self, '_onMouseenter'));
view.off(type + ':mouseleave', Util.getWrapBehavior(self, '_onMouseleave'));
},
_setActiveShape: function _setActiveShape(shape) {
var self = this;
var activedOptions = self.get('activedOptions') || {};
var shapeData = shape.get('origin');
var shapeName = shapeData.shape || self.getDefaultValue('shape');
if (Util.isArray(shapeName)) {
shapeName = shapeName[0];
}
var shapeFactory = self.get('shapeFactory');
var shapeCfg = Util.mix({}, shape.attr(), {
origin: shapeData
});
var activeCfg = shapeFactory.getActiveCfg(shapeName, shapeCfg);
if (activedOptions.style) {
Util.mix(activeCfg, activedOptions.style);
}
var originAttrs = getOriginAttrs(activeCfg, shape);
shape.setSilent('_originAttrs', originAttrs);
if (activedOptions.animate) {
shape.animate(activeCfg, 300);
} else {
shape.attr(activeCfg);
}
shape.set('zIndex', 1); // 提前
},
setShapesActived: function setShapesActived(shapes) {
var self = this;
if (!Util.isArray(shapes)) {
shapes = [shapes];
}
var preShapes = self.get('activeShapes'); // 获取上次被激活的 shapes
if (!isChange(preShapes, shapes)) {
return;
}
var view = self.get('view');
var canvas = view.get('canvas');
var shapeContainer = self.get('shapeContainer');
var activedOptions = self.get('activedOptions');
if (activedOptions && activedOptions.highlight) {
// 上次的动画未完成,所以要停止掉动画
Util.each(shapes, function (shape) {
if (shape.get('animating')) {
shape.stopAnimate();
}
});
self.highlightShapes(shapes);
} else {
if (preShapes) {
self.clearActivedShapes(); // 先清除激活元素
}
Util.each(shapes, function (shape) {
if (shape.get('animating')) {
shape.stopAnimate();
}
if (shape.get('visible') && !shape.get('selected')) {
self._setActiveShape(shape);
}
});
}
self.set('activeShapes', shapes);
shapeContainer.sort();
canvas.draw();
},
clearActivedShapes: function clearActivedShapes() {
var self = this;
var shapeContainer = self.get('shapeContainer');
var activedOptions = self.get('activedOptions');
var activeAnimate = activedOptions && activedOptions.animate;
if (shapeContainer && !shapeContainer.get('destroyed')) {
var activeShapes = self.get('activeShapes');
Util.each(activeShapes, function (activeShape) {
if (!activeShape.get('selected')) {
var originAttrs = activeShape.get('_originAttrs');
if (activeAnimate) {
activeShape.stopAnimate();
activeShape.animate(originAttrs, 300);
} else {
activeShape.attr(originAttrs);
}
activeShape.setZIndex(0);
activeShape.set('_originAttrs', null);
}
});
var preHighlightShapes = self.get('preHighlightShapes');
if (preHighlightShapes) {
var shapes = shapeContainer.get('children');
Util.each(shapes, function (shape) {
if (!shape.get('selected')) {
var originAttrs = shape.get('_originAttrs');
if (originAttrs) {
if (activeAnimate) {
shape.stopAnimate();
shape.animate(originAttrs, 300);
} else {
shape.attr(originAttrs);
}
shape.setZIndex(0);
shape.set('_originAttrs', null);
}
}
});
} // 恢复原来排序
var children = shapeContainer.get('children');
children.sort(function (obj1, obj2) {
return obj1._INDEX - obj2._INDEX;
});
self.set('activeShapes', null);
self.set('preHighlightShapes', null);
}
},
getGroupShapesByPoint: function getGroupShapesByPoint(point) {
var self = this;
var shapeContainer = self.get('shapeContainer');
var activeShapes = [];
if (shapeContainer) {
var xField = self.getXScale().field;
var shapes = self.getShapes();
var originObj = self._getOriginByPoint(point);
Util.each(shapes, function (shape) {
var origin = shape.get('origin');
if (shape.get('visible') && origin) {
// 有可能不是图形,而是label文本,所以判断一下
var shapeXValue = origin[FIELD_ORIGIN][xField];
if (shapeXValue === originObj[xField]) {
activeShapes.push(shape);
}
}
});
}
return activeShapes;
},
getSingleShapeByPoint: function getSingleShapeByPoint(point) {
var self = this;
var shapeContainer = self.get('shapeContainer');
var canvas = shapeContainer.get('canvas');
var pixelRatio = canvas.get('pixelRatio');
var result;
if (shapeContainer) {
result = shapeContainer.getShape(point.x * pixelRatio, point.y * pixelRatio);
}
if (result && result.get('origin')) {
return result;
}
},
highlightShapes: function highlightShapes(_highlightShapes, highlightCfg) {
var self = this;
if (!Util.isArray(_highlightShapes)) {
_highlightShapes = [_highlightShapes];
}
var preHighlightShapes = self.get('activeShapes'); // 获取上次被激活的 shapes
if (!isChange(preHighlightShapes, _highlightShapes)) {
return;
}
if (preHighlightShapes) {
self.clearActivedShapes();
}
var shapes = self.getShapes();
var activedOptions = self.get('activedOptions');
var activeAnimate = activedOptions && activedOptions.animate;
var activeStyle = activedOptions && activedOptions.style;
Util.each(shapes, function (shape) {
var changeAttrs = {};
shape.stopAnimate();
if (Util.indexOf(_highlightShapes, shape) !== -1) {
Util.mix(changeAttrs, activeStyle, highlightCfg);
shape.setZIndex(1); // 提前
} else {
Util.mix(changeAttrs, {
fillOpacity: 0.3,
// @2018-07-11 by blue.lb 由于线图只有stoke,fillOpacity不生效,最好还是直接改成整个图形透明度opacity
opacity: 0.3
});
shape.setZIndex(0);
}
var originAttrs = getOriginAttrs(changeAttrs, shape);
shape.setSilent('_originAttrs', originAttrs);
if (activeAnimate) {
shape.animate(changeAttrs, 300);
} else {
shape.attr(changeAttrs);
}
});
self.set('preHighlightShapes', _highlightShapes);
self.set('activeShapes', _highlightShapes);
}
};
module.exports = ActiveMixin;
/***/ }),
/* 293 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview the interaction when geom was selected
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var FIELD_ORIGIN = '_origin';
function isSameShape(shape1, shape2) {
if (Util.isNil(shape1) || Util.isNil(shape2)) {
return false;
}
var shape1Origin = shape1.get('origin');
var shape2Origin = shape2.get('origin');
return Util.isEqual(shape1Origin, shape2Origin);
}
function getOriginAttrs(selectedCfg, shape) {
var originAttrs = {};
Util.each(selectedCfg, function (v, k) {
if (k === 'transform') {
k = 'matrix';
}
var originValue = shape.attr(k);
if (Util.isArray(originValue)) {
originValue = Util.cloneDeep(originValue); // 缓存原来的属性,由于 .attr('matrix') 是数组,所以此处需要深度复制
}
originAttrs[k] = originValue;
});
return originAttrs;
}
var SelectMixin = {
_isAllowSelect: function _isAllowSelect() {
var isAllowSelect = this.get('allowSelect');
if (Util.isNil(isAllowSelect)) {
var type = this.get('type');
var coord = this.get('coord');
var coordType = coord && coord.type;
if (type === 'interval' && coordType === 'theta') {
// 饼图默认可以进行选中
return true;
}
} else {
// 用户设置了 select 配置
return isAllowSelect;
}
return false;
},
_onClick: function _onClick(ev) {
var self = this;
if (self._isAllowSelect()) {
// 允许选中下才执行
self.clearActivedShapes(); // 清除hover效果
var shape = ev.shape;
var shapeContainer = self.get('shapeContainer');
if (shape && !shape.get('animating') && shapeContainer.contain(shape)) {
self.setShapeSelected(shape);
}
}
},
_bindSelectedAction: function _bindSelectedAction() {
var self = this;
var view = self.get('view');
var type = self.get('type');
view.on(type + ':click', Util.wrapBehavior(self, '_onClick'));
},
_offSelectedAction: function _offSelectedAction() {
var self = this;
var view = self.get('view');
var type = self.get('type');
view.off(type + ':click', Util.getWrapBehavior(self, '_onClick'));
},
_setShapeStatus: function _setShapeStatus(shape, status) {
var self = this;
var view = self.get('view');
var selectedOptions = self.get('selectedOptions') || {};
var animate = selectedOptions.animate !== false; // 默认允许动画
var canvas = view.get('canvas');
shape.set('selected', status);
var shapeData = shape.get('origin');
if (status) {
// 选中状态
var shapeName = shapeData.shape || self.getDefaultValue('shape');
if (Util.isArray(shapeName)) {
shapeName = shapeName[0];
}
var shapeFactory = self.get('shapeFactory');
var cfg = Util.mix({
geom: self,
point: shapeData
}, selectedOptions);
var selectedStyle = shapeFactory.getSelectedCfg(shapeName, cfg);
Util.mix(selectedStyle, cfg.style); // 用户设置的优先级更高
if (!shape.get('_originAttrs')) {
// 缓存原有属性
if (shape.get('animating')) {
// 停止动画
shape.stopAnimate();
}
shape.set('_originAttrs', getOriginAttrs(selectedStyle, shape));
}
if (animate) {
shape.animate(selectedStyle, 300);
} else {
shape.attr(selectedStyle);
canvas.draw();
}
} else {
var originAttrs = shape.get('_originAttrs');
shape.set('_originAttrs', null);
if (animate) {
shape.animate(originAttrs, 300);
} else {
shape.attr(originAttrs);
canvas.draw();
}
}
},
setShapeSelected: function setShapeSelected(shape) {
var self = this;
var selectedShapes = self._getSelectedShapes();
var selectedOptions = self.get('selectedOptions') || {};
var cancelable = selectedOptions.cancelable !== false; // 选中状态是否允许取消,默认允许
if (selectedOptions.mode === 'multiple') {
// 支持多选
if (Util.indexOf(selectedShapes, shape) === -1) {
selectedShapes.push(shape);
self._setShapeStatus(shape, true);
} else if (cancelable) {
// 图形已经被选中并且选中状态允许取消选中
Util.Array.remove(selectedShapes, shape);
self._setShapeStatus(shape, false);
}
} else {
var selectedShape = selectedShapes[0];
if (cancelable) {
// 如果允许取消,则选中null
shape = isSameShape(selectedShape, shape) ? null : shape;
}
if (!isSameShape(selectedShape, shape)) {
if (selectedShape) {
self._setShapeStatus(selectedShape, false);
}
if (shape) {
self._setShapeStatus(shape, true);
}
}
}
},
clearSelected: function clearSelected() {
var self = this;
var shapeContainer = self.get('shapeContainer');
if (shapeContainer && !shapeContainer.get('destroyed')) {
var selectedShapes = self._getSelectedShapes();
Util.each(selectedShapes, function (shape) {
self._setShapeStatus(shape, false);
shape.set('_originAttrs', null);
});
}
},
/**
* 设置记录对应的图形选中
* @param {Object} record 选中的记录
* @chainable
* @return {Geom} 返回当前的 Geometry
*/
setSelected: function setSelected(record) {
var self = this;
var shapes = self.getShapes();
Util.each(shapes, function (shape) {
var origin = shape.get('origin');
if (origin && origin[FIELD_ORIGIN] === record) {
self.setShapeSelected(shape);
}
});
return this;
},
_getSelectedShapes: function _getSelectedShapes() {
var self = this;
var shapes = self.getShapes();
var selectedShapes = [];
Util.each(shapes, function (shape) {
if (shape.get('selected')) {
selectedShapes.push(shape);
}
});
self.set('selectedShapes', selectedShapes);
return selectedShapes;
}
};
module.exports = SelectMixin;
/***/ }),
/* 294 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview The tooltip handler
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var _require = __webpack_require__(5),
defaultColor = _require.defaultColor;
var FIELD_ORIGIN = '_origin';
function getScaleName(scale) {
return scale.alias || scale.field;
}
var TooltipMixin = {
_getIntervalSize: function _getIntervalSize(obj) {
var size = null;
var type = this.get('type');
var coord = this.get('coord');
if (coord.isRect && (type === 'interval' || type === 'schema')) {
size = this.getSize(obj[FIELD_ORIGIN]); // 如果字段发生了映射,宽度计算就会报错
var dim = coord.isTransposed ? 'y' : 'x';
if (Util.isArray(obj[dim])) {
var width = Math.abs(obj[dim][1] - obj[dim][0]);
size = size < width ? null : size; // 直方图计算错误
}
}
return size;
},
_snapEqual: function _snapEqual(v1, v2, scale) {
var equals;
v1 = scale.translate(v1);
v2 = scale.translate(v2);
if (scale.isCategory) {
equals = v1 === v2;
} else {
equals = Util.snapEqual(v1, v2);
}
return equals;
},
_getScaleValueByPoint: function _getScaleValueByPoint(point) {
var result = 0;
var coord = this.get('coord');
var xScale = this.getXScale();
var invertPoint = coord.invert(point);
var xValue = invertPoint.x;
if (this.isInCircle() && xValue > (1 + xScale.rangeMax()) / 2) {
xValue = xScale.rangeMin(); // 极坐标下,scale 的 range 被做过特殊处理 see view.js#L88
}
result = xScale.invert(xValue);
if (xScale.isCategory) {
result = xScale.translate(result); // 防止分类类型
}
return result;
},
_getOriginByPoint: function _getOriginByPoint(point) {
var xScale = this.getXScale();
var yScale = this.getYScale();
var xField = xScale.field;
var yField = yScale.field;
var coord = this.get('coord');
var invertPoint = coord.invert(point);
var xValue = xScale.invert(invertPoint.x);
var yValue = yScale.invert(invertPoint.y);
var result = {};
result[xField] = xValue;
result[yField] = yValue;
return result;
},
_getScale: function _getScale(field) {
var self = this;
var scales = self.get('scales');
var rst = null;
Util.each(scales, function (scale) {
if (scale.field === field) {
rst = scale;
return false;
}
});
return rst;
},
// 获取值对应的度量
_getTipValueScale: function _getTipValueScale() {
var attrs = this.getAttrsForLegend();
var scale;
Util.each(attrs, function (attr) {
var tmpScale = attr.getScale(attr.type);
if (tmpScale.isLinear) {
// 如果指定字段是非position的,同时是连续的
scale = tmpScale;
return false;
}
});
var xScale = this.getXScale();
var yScale = this.getYScale();
if (!scale && yScale && yScale.field === '..y') {
return xScale;
}
return scale || yScale || xScale;
},
_getTipTitleScale: function _getTipTitleScale(titleField) {
var self = this;
if (titleField) {
return self._getScale(titleField);
}
var position = self.getAttr('position');
var fields = position.getFields();
var tmpField;
Util.each(fields, function (field) {
if (field.indexOf('..') === -1) {
tmpField = field;
return false;
}
});
return self._getScale(tmpField);
},
_filterValue: function _filterValue(arr, point) {
var coord = this.get('coord');
var yScale = this.getYScale();
var yField = yScale.field;
var invertPoint = coord.invert(point);
var yValue = invertPoint.y;
yValue = yScale.invert(yValue);
var rst = arr[arr.length - 1];
Util.each(arr, function (obj) {
var origin = obj[FIELD_ORIGIN];
if (origin[yField][0] <= yValue && origin[yField][1] >= yValue) {
rst = obj;
return false;
}
});
return rst;
},
getXDistance: function getXDistance() {
var self = this;
var distance = self.get('xDistance');
if (!distance) {
var xScale = self.getXScale();
if (xScale.isCategory) {
distance = 1;
} else {
var values = xScale.values; // values 是无序的
var min = xScale.translate(values[0]);
var max = min;
Util.each(values, function (value) {
// 时间类型需要 translate
value = xScale.translate(value);
if (value < min) {
min = value;
}
if (value > max) {
max = value;
}
});
var length = values.length; // 应该是除以 length - 1
distance = (max - min) / (length - 1);
}
self.set('xDistance', distance);
}
return distance;
},
findPoint: function findPoint(point, dataArray) {
var self = this;
var type = self.get('type');
var xScale = self.getXScale();
var yScale = self.getYScale();
var xField = xScale.field;
var yField = yScale.field;
var rst = null;
if (Util.indexOf(['heatmap', 'point'], type) > -1) {
var coord = self.get('coord');
var invertPoint = coord.invert(point);
var xValue = xScale.invert(invertPoint.x);
var yValue = yScale.invert(invertPoint.y);
var min = Infinity;
Util.each(dataArray, function (obj) {
var distance = Math.pow(obj[FIELD_ORIGIN][xField] - xValue, 2) + Math.pow(obj[FIELD_ORIGIN][yField] - yValue, 2);
if (distance < min) {
min = distance;
rst = obj;
}
});
return rst;
}
var first = dataArray[0];
var last = dataArray[dataArray.length - 1];
if (!first) {
return rst;
}
var value = self._getScaleValueByPoint(point); // 根据该点获得对应度量后数据的值
var firstXValue = first[FIELD_ORIGIN][xField];
var firstYValue = first[FIELD_ORIGIN][yField];
var lastXValue = last[FIELD_ORIGIN][xField];
var isYRange = yScale.isLinear && Util.isArray(firstYValue); // 考虑 x 维度相同,y 是数组区间的情况
// 如果x的值是数组
if (Util.isArray(firstXValue)) {
Util.each(dataArray, function (record) {
var origin = record[FIELD_ORIGIN];
if (xScale.translate(origin[xField][0]) <= value && xScale.translate(origin[xField][1]) >= value) {
if (isYRange) {
if (!Util.isArray(rst)) {
rst = [];
}
rst.push(record);
} else {
rst = record;
return false;
}
}
});
if (Util.isArray(rst)) {
rst = this._filterValue(rst, point);
}
} else {
var next;
if (!xScale.isLinear && xScale.type !== 'timeCat') {
Util.each(dataArray, function (record, index) {
var origin = record[FIELD_ORIGIN];
if (self._snapEqual(origin[xField], value, xScale)) {
if (isYRange) {
if (!Util.isArray(rst)) {
rst = [];
}
rst.push(record);
} else {
rst = record;
return false;
}
} else if (xScale.translate(origin[xField]) <= value) {
last = record;
next = dataArray[index + 1];
}
});
if (Util.isArray(rst)) {
rst = this._filterValue(rst, point);
}
} else {
if ((value > xScale.translate(lastXValue) || value < xScale.translate(firstXValue)) && (value > xScale.max || value < xScale.min)) {
return null;
}
var firstIdx = 0;
var lastIdx = dataArray.length - 1;
var middleIdx;
while (firstIdx <= lastIdx) {
middleIdx = Math.floor((firstIdx + lastIdx) / 2);
var item = dataArray[middleIdx][FIELD_ORIGIN][xField];
if (self._snapEqual(item, value, xScale)) {
return dataArray[middleIdx];
}
if (xScale.translate(item) <= xScale.translate(value)) {
firstIdx = middleIdx + 1;
last = dataArray[middleIdx];
next = dataArray[middleIdx + 1];
} else {
if (lastIdx === 0) {
last = dataArray[0];
}
lastIdx = middleIdx - 1;
}
}
}
if (last && next) {
// 计算最逼近的
if (Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - value) > Math.abs(xScale.translate(next[FIELD_ORIGIN][xField]) - value)) {
last = next;
}
}
}
var distance = self.getXDistance(); // 每个分类间的平均间距
if (!rst && Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - value) <= distance / 2) {
rst = last;
}
return rst;
},
/**
* @protected
* 获取tooltip的标题
* @param {Object} origin 点的原始信息
* @param {String} titleField 标题的字段
* @return {String} 提示信息的标题
*/
getTipTitle: function getTipTitle(origin, titleField) {
var tipTitle = '';
var titleScale = this._getTipTitleScale(titleField);
if (titleScale) {
var value = origin[titleScale.field];
tipTitle = titleScale.getText(value);
} else if (this.get('type') === 'heatmap') {
// 热力图在不存在 title 的时候特殊处理
var xScale = this.getXScale();
var yScale = this.getYScale();
var xValue = xScale.getText(origin[xScale.field]);
var yValue = yScale.getText(origin[yScale.field]);
tipTitle = '( ' + xValue + ', ' + yValue + ' )';
}
return tipTitle;
},
getTipValue: function getTipValue(origin, valueScale) {
var value;
var field = valueScale.field;
var key = origin.key;
value = origin[field];
if (Util.isArray(value)) {
var tmp = [];
Util.each(value, function (sub) {
tmp.push(valueScale.getText(sub));
});
value = tmp.join('-');
} else {
value = valueScale.getText(value, key);
}
return value;
},
/**
* @protected
* 获取tooltip的名称
* @param {Object} origin 点的原始信息
* @return {String} 提示信息的名称
*/
getTipName: function getTipName(origin) {
var name;
var nameScale;
var groupScales = this._getGroupScales();
if (groupScales.length) {
// 如果存在分组类型,取第一个分组类型
Util.each(groupScales, function (scale) {
nameScale = scale;
return false;
});
}
if (nameScale) {
var field = nameScale.field;
name = nameScale.getText(origin[field]);
} else {
var valueScale = this._getTipValueScale();
name = getScaleName(valueScale);
}
return name;
},
/**
* 获取点对应tooltip的信息
* @protected
* @param {Object} point 原始的数据记录
* @param {String} titleField tooltipTitle 配置信息
* @return {Array} 一条或者多条记录
*/
getTipItems: function getTipItems(point, titleField) {
var self = this;
var origin = point[FIELD_ORIGIN];
var tipTitle = self.getTipTitle(origin, titleField);
var tooltipCfg = self.get('tooltipCfg');
var items = [];
var name;
var value;
function addItem(itemName, itemValue, cfg) {
if (!Util.isNil(itemValue) && itemValue !== '') {
// 值为null的时候,忽视
var item = {
title: tipTitle,
point: point,
name: itemName || tipTitle,
value: itemValue,
color: point.color || defaultColor,
marker: true
};
item.size = self._getIntervalSize(point);
items.push(Util.mix({}, item, cfg));
}
}
if (tooltipCfg) {
var fields = tooltipCfg.fields;
var cfg = tooltipCfg.cfg;
var callbackParams = [];
Util.each(fields, function (field) {
callbackParams.push(origin[field]);
});
if (cfg) {
// 存在回调函数
if (Util.isFunction(cfg)) {
cfg = cfg.apply(null, callbackParams);
}
var itemCfg = Util.mix({}, {
point: point,
title: tipTitle,
color: point.color || defaultColor,
marker: true // 默认展示 marker
}, cfg);
itemCfg.size = self._getIntervalSize(point);
items.push(itemCfg);
} else {
Util.each(fields, function (field) {
if (!Util.isNil(origin[field])) {
// 字段数据为null ,undefined时不显示
var scale = self._getScale(field);
name = getScaleName(scale);
value = scale.getText(origin[field]);
addItem(name, value);
}
});
}
} else {
var valueScale = self._getTipValueScale();
if (!Util.isNil(origin[valueScale.field])) {
// 字段数据为null ,undefined时不显示
value = self.getTipValue(origin, valueScale);
name = self.getTipName(origin);
addItem(name, value);
}
}
return items;
},
isShareTooltip: function isShareTooltip() {
var shareTooltip = this.get('shareTooltip');
var type = this.get('type');
var view = this.get('view');
var options;
if (view.get('parent')) {
options = view.get('parent').get('options');
} else {
options = view.get('options');
}
if (type === 'interval') {
var coord = this.get('coord');
var coordType = coord.type;
if (coordType === 'theta' || coordType === 'polar' && coord.isTransposed) {
shareTooltip = false;
}
} else if (!this.getYScale() || Util.inArray(['contour', 'point', 'polygon', 'edge'], type)) {
shareTooltip = false;
}
if (options.tooltip && Util.isBoolean(options.tooltip.shared)) {
// 以用户设置的为准
shareTooltip = options.tooltip.shared;
}
return shareTooltip;
}
};
module.exports = TooltipMixin;
/***/ }),
/* 295 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 点图
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
__webpack_require__(302);
var Point =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Point, _GeomBase);
function Point() {
return _GeomBase.apply(this, arguments) || this;
}
var _proto = Point.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'point';
cfg.shapeType = 'point';
cfg.generatePoints = true;
return cfg;
};
_proto.drawPoint = function drawPoint(obj, container, shapeFactory, index) {
var self = this;
var shape = obj.shape;
var cfg = self.getDrawCfg(obj);
self._applyViewThemeShapeStyle(cfg, shape, shapeFactory);
var geomShape;
if (Util.isArray(obj.y)) {
var hasAdjust = self.hasStack();
Util.each(obj.y, function (y, idx) {
cfg.y = y;
cfg.yIndex = idx;
if (!hasAdjust || idx !== 0) {
geomShape = shapeFactory.drawShape(shape, cfg, container);
self.appendShapeInfo(geomShape, index + idx);
}
});
} else if (!Util.isNil(obj.y)) {
geomShape = shapeFactory.drawShape(shape, cfg, container);
self.appendShapeInfo(geomShape, index);
}
};
return Point;
}(GeomBase);
var PointJitter =
/*#__PURE__*/
function (_Point) {
_inheritsLoose(PointJitter, _Point);
function PointJitter() {
return _Point.apply(this, arguments) || this;
}
var _proto2 = PointJitter.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Point.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'jitter'
}];
return cfg;
};
return PointJitter;
}(Point);
var PointStack =
/*#__PURE__*/
function (_Point2) {
_inheritsLoose(PointStack, _Point2);
function PointStack() {
return _Point2.apply(this, arguments) || this;
}
var _proto3 = PointStack.prototype;
_proto3.getDefaultCfg = function getDefaultCfg() {
var cfg = _Point2.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'stack'
}];
return cfg;
};
return PointStack;
}(Point);
Point.Jitter = PointJitter;
Point.Stack = PointStack;
GeomBase.Point = Point;
GeomBase.PointJitter = PointJitter;
GeomBase.PointStack = PointStack;
module.exports = Point;
/***/ }),
/* 296 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 多边形
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
__webpack_require__(303);
var Polygon =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Polygon, _GeomBase);
function Polygon() {
return _GeomBase.apply(this, arguments) || this;
}
var _proto = Polygon.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'polygon';
cfg.shapeType = 'polygon';
cfg.generatePoints = true;
return cfg;
};
_proto.createShapePointsCfg = function createShapePointsCfg(obj) {
var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj);
var self = this;
var x = cfg.x;
var y = cfg.y;
var temp;
if (!(Util.isArray(x) && Util.isArray(y))) {
// x 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,y都是分类
x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
} else if (Util.isArray(x)) {
// 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 (Util.isArray(y)) {
// 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;
}(GeomBase);
GeomBase.Polygon = Polygon;
module.exports = Polygon;
/***/ }),
/* 297 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview 自定义图形
* @author dxq613@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
var SizeMixin = __webpack_require__(67);
__webpack_require__(304);
var Schema =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Schema, _GeomBase);
var _proto = Schema.prototype;
/**
* 获取默认的配置属性
* @protected
* @return {Object} 默认属性
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'schema';
cfg.shapeType = 'schema';
cfg.generatePoints = true;
return cfg;
};
function Schema(cfg) {
var _this;
_this = _GeomBase.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
return _this;
}
_proto.createShapePointsCfg = function createShapePointsCfg(obj) {
var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj);
cfg.size = this.getNormalizedSize(obj);
return cfg;
};
return Schema;
}(GeomBase);
var SchemaDodge =
/*#__PURE__*/
function (_Schema) {
_inheritsLoose(SchemaDodge, _Schema);
function SchemaDodge() {
return _Schema.apply(this, arguments) || this;
}
var _proto2 = SchemaDodge.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Schema.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'dodge'
}];
return cfg;
};
return SchemaDodge;
}(Schema);
Schema.Dodge = SchemaDodge;
GeomBase.Schema = Schema;
GeomBase.SchemaDodge = SchemaDodge;
module.exports = Schema;
/***/ }),
/* 298 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview area shape
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var PathUtil = __webpack_require__(25);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
function getLineAttrs(cfg) {
var defaultAttrs = Global.shape.hollowArea;
var lineAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addStrokeAttrs(lineAttrs, cfg);
if (Util.isNumber(cfg.size)) {
lineAttrs.lineWidth = cfg.size;
}
return lineAttrs;
}
function getFillAttrs(cfg) {
var defaultAttrs = Global.shape.area;
var areaAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addFillAttrs(areaAttrs, cfg);
if (cfg.color) {
areaAttrs.stroke = areaAttrs.stroke || cfg.color;
}
if (Util.isNumber(cfg.size)) {
areaAttrs.lineWidth = cfg.size;
}
return areaAttrs;
}
function getPath(cfg, smooth, shape) {
var path = [];
var pointsArr = [];
var topLinePoints = []; // area 区域上部分
var bottomLinePoints = []; // area 区域下部分
var isInCircle = cfg.isInCircle;
Util.each(cfg.points, function (point) {
topLinePoints.push(point[1]);
bottomLinePoints.push(point[0]);
}); // if (!isInCircle) {
bottomLinePoints = bottomLinePoints.reverse(); // }
pointsArr.push(topLinePoints, bottomLinePoints);
Util.each(pointsArr, function (points, index) {
var subPath = [];
points = shape.parsePoints(points);
var p1 = points[0];
if (isInCircle) {
points.push({
x: p1.x,
y: p1.y
});
}
if (smooth) {
subPath = PathUtil.getSplinePath(points, false, cfg.constraint);
} else {
subPath = PathUtil.getLinePath(points, false);
}
if (index > 0) {
subPath[0][0] = 'L';
}
path = path.concat(subPath);
});
path.push(['Z']);
return path;
} // get marker cfg
function _getMarkerCfg(cfg) {
return {
symbol: function symbol(x, y) {
return [['M', x - 5.5, y - 4], ['L', x + 5.5, y - 4], ['L', x + 5.5, y + 4], ['L', x - 5.5, y + 4], ['Z']];
},
radius: 5,
fill: cfg.color,
fillOpacity: 0.6
};
} // 鼠标悬浮触发active状态
function _getActiveCfg(type, cfg) {
if (type === 'line' || type === 'smoothLine') {
// 线加粗
var lineWidth = cfg.lineWidth || 0;
return {
lineWidth: lineWidth + 1
};
}
var opacity = cfg.fillOpacity || cfg.opacity || 1;
return {
fillOpacity: opacity - 0.15,
strokeOpacity: opacity - 0.15
};
} // 当只有一个数据时绘制点
function drawPointShape(shapeObj, cfg, container) {
var coord = shapeObj._coord;
var point = coord.convertPoint(cfg.points[0][1]);
return container.addShape('circle', {
attrs: Util.mix({
x: point.x,
y: point.y,
r: 2,
fill: cfg.color
}, cfg.style)
});
}
var Area = Shape.registerFactory('area', {
defaultShapeType: 'area',
/**
* @override
* @protected
* 计算点 如果存在多个点,分割成单个的点, 不考虑多个x对应一个y的情况
* 单点则补上y0点
*/
getDefaultPoints: function getDefaultPoints(pointInfo) {
var points = [];
var x = pointInfo.x;
var y = pointInfo.y;
var y0 = pointInfo.y0;
y = Util.isArray(y) ? y : [y0, y];
Util.each(y, function (yItem) {
points.push({
x: x,
y: yItem
});
});
return points;
},
// 获取激活的图形属性
getActiveCfg: function getActiveCfg(type, cfg) {
return _getActiveCfg(type, cfg);
},
drawShape: function drawShape(type, cfg, container) {
var shape = this.getShape(type);
var gShape;
if (cfg.points.length === 1 && Global.showSinglePoint) {
gShape = drawPointShape(this, cfg, container);
} else {
gShape = shape.draw(cfg, container);
}
if (gShape) {
gShape.set('origin', cfg.origin);
gShape._id = cfg.splitedIndex ? cfg._id + cfg.splitedIndex : cfg._id;
gShape.name = this.name;
}
return gShape;
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
if (cfg && cfg.style) {
return cfg.style;
}
return this.getActiveCfg(type, cfg);
}
}); // 默认:填充区域图
Shape.registerShape('area', 'area', {
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var path = getPath(cfg, false, this); // path = this.parsePath(path, false);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg);
}
}); // 填充平滑区域图
Shape.registerShape('area', 'smooth', {
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var coord = this._coord; // 曲线的限制
cfg.constraint = [[coord.start.x, coord.end.y], [coord.end.x, coord.start.y]];
var path = getPath(cfg, true, this); // path = this.parsePath(path, false);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg);
}
}); // 封闭的折线
Shape.registerShape('area', 'line', {
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg);
var path = getPath(cfg, false, this); // path = this.parsePath(path, false);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg);
}
}); // 封闭的平滑线
Shape.registerShape('area', 'smoothLine', {
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg);
var path = getPath(cfg, true, this);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg);
}
});
Area.spline = Area.smooth;
module.exports = Area;
/***/ }),
/* 299 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 边的 shape
* @author dxq613@gmail.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
var PathUtil = __webpack_require__(25);
var CORNER_PERCENT = 1 / 3;
function getAttrs(cfg) {
var defaultCfg = Global.shape.edge;
var lineAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(lineAttrs, cfg);
return lineAttrs;
}
var Edge = Shape.registerFactory('edge', {
defaultShapeType: 'line',
getDefaultPoints: function getDefaultPoints(pointInfo) {
return ShapeUtil.splitPoints(pointInfo);
},
getActiveCfg: function getActiveCfg(type, cfg) {
var lineWidth = cfg.lineWidth || 0;
return {
lineWidth: lineWidth + 1
};
}
});
function getCPath(from, to) {
var points = [];
points.push({
x: from.x,
y: from.y * (1 - 1 / 2) + to.y * 1 / 2
});
points.push({
y: from.y * (1 - 1 / 2) + to.y * 1 / 2,
x: to.x
});
points.push(to);
var sub = ['C'];
Util.each(points, function (point) {
sub.push(point.x, point.y);
});
return sub;
}
function getQPath(to, center) {
var points = [];
points.push({
x: center.x,
y: center.y
});
points.push(to);
var sub = ['Q'];
Util.each(points, function (point) {
sub.push(point.x, point.y);
});
return sub;
}
function createSmoothPath(from, to) {
var sub = getCPath(from, to);
var path = [['M', from.x, from.y]];
path.push(sub);
return path;
}
function createArcPath(from, to, center) {
var sub = getQPath(to, center);
var path = [['M', from.x, from.y]];
path.push(sub);
return path;
}
function createArcWeightPath(points, center) {
var arc1 = getQPath(points[1], center);
var arc2 = getQPath(points[3], center);
var path = [['M', points[0].x, points[0].y]];
path.push(arc2);
path.push(['L', points[3].x, points[3].y]);
path.push(['L', points[2].x, points[2].y]);
path.push(arc1);
path.push(['L', points[1].x, points[1].y]);
path.push(['L', points[0].x, points[0].y]);
path.push(['Z']);
return path;
}
function createRectPath(from, to) {
var points = [];
points.push({
y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,
x: from.x
});
points.push({
y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,
x: to.x
});
points.push(to);
var path = [['M', from.x, from.y]];
Util.each(points, function (point) {
path.push(['L', point.x, point.y]);
});
return path;
}
Shape.registerShape('edge', 'line', {
draw: function draw(cfg, container) {
var points = this.parsePoints(cfg.points);
var attrCfg = getAttrs(cfg);
var path = PathUtil.getLinePath(points);
var line = container.addShape('path', {
attrs: Util.mix(attrCfg, {
path: path
})
});
return line;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4.5
}, getAttrs(cfg));
}
});
Shape.registerShape('edge', 'vhv', {
draw: function draw(cfg, container) {
var points = cfg.points;
var attrCfg = getAttrs(cfg);
var path = createRectPath(points[0], points[1]);
path = this.parsePath(path);
var line = container.addShape('path', {
attrs: Util.mix(attrCfg, {
path: path
})
});
return line;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4.5
}, getAttrs(cfg));
}
});
Shape.registerShape('edge', 'smooth', {
draw: function draw(cfg, container) {
var points = cfg.points;
var attrCfg = getAttrs(cfg);
var path = createSmoothPath(points[0], points[1]);
path = this.parsePath(path);
var line = container.addShape('path', {
attrs: Util.mix(attrCfg, {
path: path
})
});
return line;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4.5
}, getAttrs(cfg));
}
}); // 弧线包括笛卡尔坐标系下的半圆弧线、极坐标系下以圆心为控制点的二阶曲线、笛卡尔坐标系下带权重的三阶曲线、极坐标系下带权重的以圆心为控制点的二阶曲线
Shape.registerShape('edge', 'arc', {
draw: function draw(cfg, container) {
var points = cfg.points;
var type = points.length > 2 ? 'weight' : 'normal';
var attrCfg = getAttrs(cfg);
var line;
var path;
if (cfg.isInCircle) {
var center = {
x: 0,
y: 1
};
if (type === 'normal') {
path = createArcPath(points[0], points[1], center);
} else {
attrCfg.fill = attrCfg.stroke;
path = createArcWeightPath(points, center);
}
path = this.parsePath(path);
line = container.addShape('path', {
attrs: Util.mix(attrCfg, {
path: path
})
});
} else {
if (type === 'normal') {
points = this.parsePoints(points);
line = container.addShape('arc', {
attrs: Util.mix(attrCfg, {
x: (points[1].x + points[0].x) / 2,
y: points[0].y,
r: Math.abs(points[1].x - points[0].x) / 2,
startAngle: Math.PI,
endAngle: Math.PI * 2
})
});
} else {
path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y]];
var c1 = getCPath(points[1], points[3]);
var c2 = getCPath(points[2], points[0]);
path.push(c1);
path.push(['L', points[3].x, points[3].y]);
path.push(['L', points[2].x, points[2].y]);
path.push(c2);
path.push(['Z']);
path = this.parsePath(path);
attrCfg.fill = attrCfg.stroke;
line = container.addShape('path', {
attrs: Util.mix(attrCfg, {
path: path
})
});
}
}
return line;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4.5
}, getAttrs(cfg));
}
});
module.exports = Edge;
/***/ }),
/* 300 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview interval shapes
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
* @author huangtonger@aliyun.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var PathUtil = __webpack_require__(25);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
var G = __webpack_require__(23);
var GPathUtil = Util.PathUtil; // 获取柱状图的几个点
function getRectPoints(cfg, isPyramid) {
var x = cfg.x;
var y = cfg.y;
var y0 = cfg.y0; // 0 点的位置
var width = cfg.size; // 有3种情况,
// 1. y,x都不是数组
// 2. y是数组,x不是
// 3. x是数组,y不是
var ymin = y0;
var ymax = y;
if (Util.isArray(y)) {
ymax = y[1];
ymin = y[0];
}
var xmin;
var xmax;
if (Util.isArray(x)) {
xmin = x[0];
xmax = x[1];
} else {
xmin = x - width / 2;
xmax = x + width / 2;
}
var points = [];
points.push({
x: xmin,
y: ymin
}, {
x: xmin,
y: ymax
});
if (isPyramid) {
points.push({
x: xmax,
y: (ymax + ymin) / 2
});
} else {
points.push({
x: xmax,
y: ymax
}, {
x: xmax,
y: ymin
});
}
return points;
}
function getRectPath(points) {
var path = [];
for (var i = 0; i < points.length; i++) {
var point = points[i];
if (point) {
var action = i === 0 ? 'M' : 'L';
path.push([action, point.x, point.y]);
}
}
var first = points[0];
path.push(['L', first.x, first.y]);
path.push(['z']);
return path;
}
function getLinePoints(cfg) {
var x = cfg.x;
var y = cfg.y;
var y0 = cfg.y0; // 0 点的位置
var points = [];
if (Util.isArray(y)) {
Util.each(y, function (yItem, idx) {
points.push({
x: Util.isArray(x) ? x[idx] : x,
y: yItem
});
});
} else {
points.push({
x: x,
y: y
}, {
x: x,
y: y0
});
}
return points;
}
function getTickPoints(cfg) {
var x = cfg.x;
var y = Util.isArray(cfg.y) ? cfg.y[1] : cfg.y;
var y0 = Util.isArray(cfg.y) ? cfg.y[0] : cfg.y0;
var barWidth = cfg.size;
var points = [];
points.push({
x: x - barWidth / 2,
y: y
}, {
x: x + barWidth / 2,
y: y
}, {
x: x,
y: y
}, {
x: x,
y: y0
}, {
x: x - barWidth / 2,
y: y0
}, {
x: x + barWidth / 2,
y: y0
});
return points;
}
function getTickPath(points) {
var path = [];
path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['M', points[4].x, points[4].y], ['L', points[5].x, points[5].y]);
return path;
}
function getFillAttrs(cfg) {
var defaultAttrs = Global.shape.interval;
var attrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addFillAttrs(attrs, cfg);
if (cfg.color) {
attrs.stroke = attrs.stroke || cfg.color;
}
return attrs;
}
function getLineAttrs(cfg) {
var defaultAttrs = Global.shape.hollowInterval;
var attrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addStrokeAttrs(attrs, cfg);
return attrs;
}
function getFunnelPath(cfg, isFunnel) {
var path = [];
var points = cfg.points;
var nextPoints = cfg.nextPoints;
if (!Util.isNil(nextPoints)) {
path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', nextPoints[1].x, nextPoints[1].y], ['L', nextPoints[0].x, nextPoints[0].y], ['Z']);
} else if (isFunnel) {
path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['Z']);
} else {
path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', points[2].x, points[2].y], ['L', points[2].x, points[2].y], ['Z']);
}
return path;
}
function getThetaCfg(point, coord) {
var r = coord.getRadius();
var inner = coord.innerRadius;
var startAngle;
var endAngle;
var ir = r * inner;
var startPoint;
var endPoint;
if (!Util.isArray(point.x) && Util.isArray(point.y)) {
point.x = [point.x, point.x]; // 如果x是一个值,y是数组,将x转成数组
}
if (Util.isArray(point.x)) {
startPoint = {
x: point.x[0],
y: point.y[0]
};
endPoint = {
x: point.x[1],
y: point.y[1]
};
startAngle = PathUtil.getPointAngle(coord, startPoint);
endAngle = PathUtil.getPointAngle(coord, endPoint);
if (endAngle <= startAngle) {
// 考虑占比百分百的情形
endAngle = endAngle + Math.PI * 2;
}
} else {
endPoint = point;
startAngle = coord.startAngle;
endAngle = PathUtil.getPointAngle(coord, endPoint);
}
return {
r: r,
ir: ir,
startAngle: startAngle,
endAngle: endAngle
};
} // 获取选中时的样式,当前仅支持饼图
function _getSelectedCfg(type, cfg) {
var geom = cfg.geom;
var coord = geom.get('coord');
var point = cfg.point;
var r = 7.5;
var selectedCfg;
if (coord && coord.type === 'theta') {
var thetaCfg = getThetaCfg(point, coord);
var middleAngle = (thetaCfg.endAngle - thetaCfg.startAngle) / 2 + thetaCfg.startAngle;
var x = r * Math.cos(middleAngle);
var y = r * Math.sin(middleAngle);
selectedCfg = {
transform: [['t', x, y]]
};
}
return Util.mix({}, selectedCfg);
}
var Interval = Shape.registerFactory('interval', {
defaultShapeType: 'rect',
getActiveCfg: function getActiveCfg(type, cfg) {
if (!type || Util.inArray(['rect', 'funnel', 'pyramid'], type)) {
// 透明度降低 0.15
var fillOpacity = cfg.fillOpacity || cfg.opacity || 1;
return {
fillOpacity: fillOpacity - 0.15
};
}
var lineWidth = cfg.lineWidth || 0;
return {
lineWidth: lineWidth + 1
};
},
getDefaultPoints: function getDefaultPoints(pointInfo) {
return getRectPoints(pointInfo);
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
return _getSelectedCfg(type, cfg);
}
}); // 默认柱状图
Shape.registerShape('interval', 'rect', {
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var path = getRectPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var rectCfg = getFillAttrs(cfg);
var isInCircle = cfg.isInCircle;
return Util.mix({
symbol: isInCircle ? 'circle' : 'square',
radius: isInCircle ? 4.5 : 4
}, rectCfg);
}
}); // 空心柱状图
Shape.registerShape('interval', 'hollowRect', {
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg);
var path = getRectPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var rectCfg = getLineAttrs(cfg);
var isInCircle = cfg.isInCircle;
return Util.mix({
symbol: isInCircle ? 'circle' : 'square',
radius: isInCircle ? 4.5 : 4
}, rectCfg);
}
}); // 线形柱状图
Shape.registerShape('interval', 'line', {
getPoints: function getPoints(pointInfo) {
return getLinePoints(pointInfo);
},
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg);
attrs.lineWidth = cfg.size || 1; // size 就是线的宽度
var path = getRectPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var lineCfg = getLineAttrs(cfg);
return Util.mix({
symbol: 'line',
radius: 5
}, lineCfg);
}
}); // 钉子形的柱状图
Shape.registerShape('interval', 'tick', {
getPoints: function getPoints(pointInfo) {
return getTickPoints(pointInfo);
},
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg); // @2018-12-25 by blue.lb 经过测试发现size代表的是宽度,而style中的lineWidth才是设置线宽,放在interval暂时先特殊处理
if (!attrs.lineWidth) {
attrs.lineWidth = 2;
}
var path = getTickPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var lineCfg = getLineAttrs(cfg);
return Util.mix({
symbol: 'tick',
radius: 5
}, lineCfg);
}
}); // 漏斗图
Shape.registerShape('interval', 'funnel', {
getPoints: function getPoints(pointInfo) {
pointInfo.size = pointInfo.size * 2; // 漏斗图的 size 是柱状图的两倍
return getRectPoints(pointInfo);
},
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var path = getFunnelPath(cfg, true);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var funnelCfg = getFillAttrs(cfg);
return Util.mix({
symbol: 'square',
radius: 4
}, funnelCfg);
}
}); // 金字塔图
Shape.registerShape('interval', 'pyramid', {
getPoints: function getPoints(pointInfo) {
pointInfo.size = pointInfo.size * 2; // 漏斗图的 size 是柱状图的两倍
return getRectPoints(pointInfo, true);
},
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var path = getFunnelPath(cfg, false);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var funnelCfg = getFillAttrs(cfg);
return Util.mix({
symbol: 'square',
radius: 4
}, funnelCfg);
}
}); // 水波图
/**
* 用贝塞尔曲线模拟正弦波
* Using Bezier curves to fit sine wave.
* There is 4 control points for each curve of wave,
* which is at 1/4 wave length of the sine wave.
*
* The control points for a wave from (a) to (d) are a-b-c-d:
* c *----* d
* b *
* |
* ... a * ..................
*
* whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)
*
* @param {number} x x position of the left-most point (a)
* @param {number} stage 0-3, stating which part of the wave it is
* @param {number} waveLength wave length of the sine wave
* @param {number} amplitude wave amplitude
* @return {Array} 正弦片段曲线
*/
function getWaterWavePositions(x, stage, waveLength, amplitude) {
if (stage === 0) {
return [[x + 1 / 2 * waveLength / Math.PI / 2, amplitude / 2], [x + 1 / 2 * waveLength / Math.PI, amplitude], [x + waveLength / 4, amplitude]];
} else if (stage === 1) {
return [[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2), amplitude], [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1), amplitude / 2], [x + waveLength / 4, 0]];
} else if (stage === 2) {
return [[x + 1 / 2 * waveLength / Math.PI / 2, -amplitude / 2], [x + 1 / 2 * waveLength / Math.PI, -amplitude], [x + waveLength / 4, -amplitude]];
}
return [[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2), -amplitude], [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1), -amplitude / 2], [x + waveLength / 4, 0]];
}
/**
* 获取水波路径
* @param {number} radius 半径
* @param {number} waterLevel 水位
* @param {number} waveLength 波长
* @param {number} phase 相位
* @param {number} amplitude 震幅
* @param {number} cx 圆心x
* @param {number} cy 圆心y
* @return {Array} path 路径
* @reference http://gitlab.alipay-inc.com/datavis/g6/blob/1.2.0/src/graph/utils/path.js#L135
*/
function getWaterWavePath(radius, waterLevel, waveLength, phase, amplitude, cx, cy) {
var curves = Math.ceil(2 * radius / waveLength * 4) * 2;
var path = []; // map phase to [-Math.PI * 2, 0]
while (phase < -Math.PI * 2) {
phase += Math.PI * 2;
}
while (phase > 0) {
phase -= Math.PI * 2;
}
phase = phase / Math.PI / 2 * waveLength;
var left = cx - radius + phase - radius * 2;
/**
* top-left corner as start point
*
* draws this point
* |
* \|/
* ~~~~~~~~
* | |
* +------+
*/
path.push(['M', left, waterLevel]);
/**
* top wave
*
* ~~~~~~~~ <- draws this sine wave
* | |
* +------+
*/
var waveRight = 0;
for (var c = 0; c < curves; ++c) {
var stage = c % 4;
var pos = getWaterWavePositions(c * waveLength / 4, stage, waveLength, amplitude);
path.push(['C', pos[0][0] + left, -pos[0][1] + waterLevel, pos[1][0] + left, -pos[1][1] + waterLevel, pos[2][0] + left, -pos[2][1] + waterLevel]);
if (c === curves - 1) {
waveRight = pos[2][0];
}
}
/**
* top-right corner
*
* ~~~~~~~~
* 3. draws this line -> | | <- 1. draws this line
* +------+
* ^
* |
* 2. draws this line
*/
path.push(['L', waveRight + left, cy + radius]);
path.push(['L', left, cy + radius]);
path.push(['L', left, waterLevel]);
return path;
}
/**
* 添加水波
* @param {number} x 中心x
* @param {number} y 中心y
* @param {number} level 水位等级 0~1
* @param {number} waveCount 水波数
* @param {number} colors 色值
* @param {number} group 图组
* @param {number} clip 用于剪切的图形
* @param {number} radius 绘制图形的高度
*/
function addWaterWave(x, y, level, waveCount, colors, group, clip, radius) {
var bbox = clip.getBBox();
var width = bbox.maxX - bbox.minX;
var height = bbox.maxY - bbox.minY;
var duration = 5000;
var delayDiff = 300;
for (var i = 0; i < waveCount; i++) {
var wave = group.addShape('path', {
attrs: {
path: getWaterWavePath(radius, bbox.minY + height * level, width / 4, 0, width / 64, x, y),
fill: colors[i],
clip: clip
}
}); // FIXME wave animation error in svg
if (Global.renderer === 'canvas') {
wave.animate({
transform: [['t', width / 2, 0]],
repeat: true
}, duration - i * delayDiff);
}
}
}
Shape.registerShape('interval', 'liquid-fill-gauge', {
draw: function draw(cfg, container) {
var self = this;
var cy = 0.5;
var sumX = 0;
var minX = Infinity;
Util.each(cfg.points, function (p) {
if (p.x < minX) {
minX = p.x;
}
sumX += p.x;
});
var cx = sumX / cfg.points.length;
var cp = self.parsePoint({
x: cx,
y: cy
});
var minP = self.parsePoint({
x: minX,
y: 0.5
});
var xWidth = cp.x - minP.x;
var radius = Math.min(xWidth, minP.y);
var attrs = getFillAttrs(cfg);
var clipCircle = new G.Circle({
attrs: {
x: cp.x,
y: cp.y,
r: radius
}
});
addWaterWave(cp.x, cp.y, cfg.y / (2 * cp.y), 1, [attrs.fill], container, clipCircle, radius * 4);
return container.addShape('circle', {
attrs: Util.mix(getLineAttrs(cfg), {
x: cp.x,
y: cp.y,
r: radius + radius / 8
})
});
}
});
var pathMetaCache = {};
Shape.registerShape('interval', 'liquid-fill-path', {
draw: function draw(cfg, container) {
var self = this;
var attrs = Util.mix({}, getFillAttrs(cfg));
var path = cfg.shape[1];
var cy = 0.5;
var sumX = 0;
var minX = Infinity;
Util.each(cfg.points, function (p) {
if (p.x < minX) {
minX = p.x;
}
sumX += p.x;
});
var cx = sumX / cfg.points.length;
var cp = self.parsePoint({
x: cx,
y: cy
});
var minP = self.parsePoint({
x: minX,
y: 0.5
});
var xWidth = cp.x - minP.x;
var radius = Math.min(xWidth, minP.y);
var pathMeta;
if (pathMetaCache[path]) {
pathMeta = pathMetaCache[path];
} else {
var segments = GPathUtil.parsePathString(path);
pathMetaCache[path] = pathMeta = {
segments: segments
};
}
var transform = [];
if (attrs.rotate) {
transform.push(['r', attrs.rotate / 180 * Math.PI]);
delete attrs.rotate;
}
var shape = container.addShape('path', {
attrs: Util.mix(attrs, {
fillOpacity: 0,
path: pathMeta.segments
})
});
var bbox = Util.cloneDeep(shape.getBBox());
var rangeX = bbox.maxX - bbox.minX;
var rangeY = bbox.maxY - bbox.minY;
var range = Math.max(rangeX, rangeY);
var scale = radius * 2 / range;
shape.transform(transform.concat([['s', scale, scale]]));
var dw = scale * rangeX / 2; // (bbox.maxX - bbox.minX) / 2;
var dh = scale * rangeY / 2; // (bbox.maxY - bbox.minY) / 2;
shape.transform([['t', cp.x - dw, cp.y - dh]]);
addWaterWave(cp.x, cp.y, cfg.y / (2 * cp.y), 1, [attrs.fill], container, shape, minP.y * 4);
var keyShape = container.addShape('path', {
attrs: Util.mix(getLineAttrs(cfg), {
path: pathMeta.segments
})
});
keyShape.transform(transform.concat([['s', scale, scale], ['t', cp.x - dw, cp.y - dh]]));
return keyShape;
}
});
Shape.registerShape('interval', 'top-line', {
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var style = cfg.style || {};
var linePath = [['M', cfg.points[1].x, cfg.points[1].y], ['L', cfg.points[2].x, cfg.points[2].y]];
var lineAttrs = {
stroke: style.stroke || 'white',
lineWidth: style.lineWidth || 1,
path: this.parsePath(linePath)
};
var path = getRectPath(cfg.points);
path = this.parsePath(path);
delete attrs.stroke; // 不在柱子上绘制线
var rectShape = container.addShape('path', {
attrs: Util.mix(attrs, {
zIndex: 0,
path: path
})
});
container.addShape('path', {
zIndex: 1,
attrs: lineAttrs
});
return rectShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
var rectCfg = getFillAttrs(cfg);
var isInCircle = cfg.isInCircle;
return Util.mix({
symbol: isInCircle ? 'circle' : 'square',
radius: isInCircle ? 4.5 : 4
}, rectCfg);
}
});
module.exports = Interval;
/***/ }),
/* 301 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview line shapes
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
* @author huangtonger@aliyun.com
*/
var Util = __webpack_require__(0);
var PathUtil = __webpack_require__(25);
var ShapeUtil = __webpack_require__(22);
var Shape = __webpack_require__(9);
var Global = __webpack_require__(5);
var DOT_ARR = [1, 1];
var DASH_ARR = [5.5, 1];
function getAttrs(cfg) {
var defaultCfg = Global.shape.line;
var lineAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(lineAttrs, cfg);
if (cfg.size) {
lineAttrs.lineWidth = cfg.size;
}
return lineAttrs;
}
function getMarkerAttrs(cfg) {
var defaultCfg = Global.shape.line;
var lineAttrs = Util.mix({
lineWidth: 2,
radius: 6
}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(lineAttrs, cfg);
return lineAttrs;
} // 获取带有上下区间的 path
function getRangePath(points, smooth, isInCircle, cfg) {
var topPoints = [];
var isStack = cfg.isStack;
var bottomPoints = [];
for (var i = 0; i < points.length; i++) {
var point = points[i];
var tmp = ShapeUtil.splitPoints(point);
bottomPoints.push(tmp[0]);
topPoints.push(tmp[1]);
}
var topPath = getSinglePath(topPoints, smooth, isInCircle, cfg);
var bottomPath = getSinglePath(bottomPoints, smooth, isInCircle, cfg);
if (isStack) {
return topPath;
}
return topPath.concat(bottomPath);
} // 单条 path
function getSinglePath(points, smooth, isInCircle, cfg) {
var path;
if (!smooth) {
path = PathUtil.getLinePath(points, false);
if (isInCircle) {
path.push(['Z']);
}
} else {
// 直角坐标系下绘制曲线时限制最大值、最小值
var constraint = cfg.constraint;
if (isInCircle && points.length) {
points.push({
x: points[0].x,
y: points[0].y
});
}
path = PathUtil.getSplinePath(points, false, constraint);
}
return path;
} // get line path
function getPath(cfg, smooth) {
var path;
var points = cfg.points;
var isInCircle = cfg.isInCircle;
var first = points[0];
if (Util.isArray(first.y)) {
path = getRangePath(points, smooth, isInCircle, cfg);
} else {
path = getSinglePath(points, smooth, isInCircle, cfg);
}
return path;
}
function _interpPoints(points, fn) {
var tmpPoints = [];
Util.each(points, function (point, index) {
var nextPoint = points[index + 1];
tmpPoints.push(point);
if (nextPoint) {
tmpPoints = tmpPoints.concat(fn(point, nextPoint));
}
});
return tmpPoints;
} // 插值的图形path,不考虑null
function _getInterPath(points) {
var path = [];
Util.each(points, function (point, index) {
var subPath = index === 0 ? ['M', point.x, point.y] : ['L', point.x, point.y];
path.push(subPath);
});
return path;
} // 插值的图形
function _getInterPointShapeCfg(cfg, fn) {
var points = _interpPoints(cfg.points, fn);
return _getInterPath(points);
}
function _markerFn(x, y, r) {
return [['M', x - r, y], ['L', x + r, y]];
}
function _smoothMarkerFn(x, y, r) {
return [['M', x - r, y], ['A', r / 2, r / 2, 0, 1, 1, x, y], ['A', r / 2, r / 2, 0, 1, 0, x + r, y]];
} // get marker cfg
function _getMarkerCfg(cfg, smooth) {
return Util.mix({
symbol: smooth ? _smoothMarkerFn : _markerFn
}, getMarkerAttrs(cfg));
}
function _getInterMarkerCfg(cfg, fn) {
return Util.mix({
symbol: fn
}, getMarkerAttrs(cfg));
} // 当只有一个数据时绘制点
function drawPointShape(shapeObj, cfg, container) {
var point = cfg.points[0];
return container.addShape('circle', {
attrs: Util.mix({
x: point.x,
y: point.y,
r: 2,
fill: cfg.color
}, cfg.style)
});
} // regist line geom
var Line = Shape.registerFactory('line', {
// 默认的shape
defaultShapeType: 'line',
/* getMarkerCfg(type, cfg) {
const lineObj = Line[type] || Line.line;
return lineObj.getMarkerCfg(cfg);
}, */
getActiveCfg: function getActiveCfg(type, cfg) {
var lineWidth = cfg.lineWidth || 0;
return {
lineWidth: lineWidth + 1
};
},
// 计算点 如果存在多个点,分割成单个的点, 不考虑多个x对应一个y的情况
getDefaultPoints: function getDefaultPoints(pointInfo) {
return ShapeUtil.splitPoints(pointInfo);
},
drawShape: function drawShape(type, cfg, container) {
var shape = this.getShape(type);
var gShape;
if (cfg.points.length === 1 && Global.showSinglePoint) {
gShape = drawPointShape(this, cfg, container);
} else {
gShape = shape.draw(cfg, container);
}
if (gShape) {
gShape.set('origin', cfg.origin);
gShape._id = cfg.splitedIndex ? cfg._id + cfg.splitedIndex : cfg._id;
gShape.name = this.name;
}
return gShape;
}
}); // draw line shape
Shape.registerShape('line', 'line', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getPath(cfg, false);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg);
}
}); // 点线 ···
Shape.registerShape('line', 'dot', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getPath(cfg, false);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path,
lineDash: DOT_ARR
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var tmp = _getMarkerCfg(cfg, false);
tmp.lineDash = DOT_ARR;
return tmp;
}
}); // 断线 - - -
Shape.registerShape('line', 'dash', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getPath(cfg, false);
return container.addShape('path', {
attrs: Util.mix({
path: path,
lineDash: DASH_ARR
}, attrs)
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var tmp = _getMarkerCfg(cfg, false);
tmp.lineDash = tmp.lineDash || DASH_ARR;
return tmp;
}
}); // draw smooth line shape
Shape.registerShape('line', 'smooth', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var coord = this._coord; // 曲线的限制
cfg.constraint = [[coord.start.x, coord.end.y], [coord.end.x, coord.start.y]];
var path = getPath(cfg, true);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getMarkerCfg(cfg, true);
}
});
Shape.registerShape('line', 'hv', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) {
var tmp = [];
tmp.push({
x: nextPoint.x,
y: point.y
});
return tmp;
});
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getInterMarkerCfg(cfg, function (x, y, r) {
return [['M', x - r - 1, y - 2.5], ['L', x, y - 2.5], ['L', x, y + 2.5], ['L', x + r + 1, y + 2.5]];
});
}
});
Shape.registerShape('line', 'vh', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) {
var tmp = [];
tmp.push({
x: point.x,
y: nextPoint.y
});
return tmp;
});
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getInterMarkerCfg(cfg, function (x, y, r) {
return [['M', x - r - 1, y + 2.5], ['L', x, y + 2.5], ['L', x, y - 2.5], ['L', x + r + 1, y - 2.5]];
});
}
});
Shape.registerShape('line', 'hvh', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) {
var tmp = [];
var middlex = (nextPoint.x - point.x) / 2 + point.x;
tmp.push({
x: middlex,
y: point.y
});
tmp.push({
x: middlex,
y: nextPoint.y
});
return tmp;
});
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getInterMarkerCfg(cfg, function (x, y, r) {
return [['M', x - (r + 1), y + 2.5], ['L', x - r / 2, y + 2.5], ['L', x - r / 2, y - 2.5], ['L', x + r / 2, y - 2.5], ['L', x + r / 2, y + 2.5], ['L', x + r + 1, y + 2.5]];
});
}
});
Shape.registerShape('line', 'vhv', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) {
var tmp = [];
var middley = (nextPoint.y - point.y) / 2 + point.y;
tmp.push({
x: point.x,
y: middley
});
tmp.push({
x: nextPoint.x,
y: middley
});
return tmp;
});
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return _getInterMarkerCfg(cfg, function (x, y) {
// 宽 13px,高 8px
return [['M', x - 5, y + 2.5], ['L', x - 5, y], ['L', x, y], ['L', x, y - 3], ['L', x, y + 3], ['L', x + 6.5, y + 3]];
});
}
});
Line.spline = Line.smooth;
module.exports = Line;
/***/ }),
/* 302 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview point shapes
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
* @author huangtonger@aliyun.com
*/
var Util = __webpack_require__(0);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
var Shape = __webpack_require__(9); // const svgpath = require('svgpath');
var _require = __webpack_require__(23),
Marker = _require.Marker;
var PathUtil = Util.PathUtil;
var SHAPES = ['circle', 'square', 'bowtie', 'diamond', 'hexagon', 'triangle', 'triangle-down'];
var HOLLOW_SHAPES = ['cross', 'tick', 'plus', 'hyphen', 'line', 'pointerLine', 'pointerArrow'];
var SQRT_3 = Math.sqrt(3); // 增加marker
Util.mix(Marker.Symbols, {
hexagon: function hexagon(x, y, r) {
var diffX = r / 2 * SQRT_3;
return [['M', x, y - r], ['L', x + diffX, y - r / 2], ['L', x + diffX, y + r / 2], ['L', x, y + r], ['L', x - diffX, y + r / 2], ['L', x - diffX, y - r / 2], ['Z']];
},
bowtie: function bowtie(x, y, r) {
var diffY = r - 1.5;
return [['M', x - r, y - diffY], ['L', x + r, y + diffY], ['L', x + r, y - diffY], ['L', x - r, y + diffY], ['Z']];
},
cross: function cross(x, y, r) {
return [['M', x - r, y - r], ['L', x + r, y + r], ['M', x + r, y - r], ['L', x - r, y + r]];
},
tick: function tick(x, y, r) {
return [['M', x - r / 2, y - r], ['L', x + r / 2, y - r], ['M', x, y - r], ['L', x, y + r], ['M', x - r / 2, y + r], ['L', x + r / 2, y + r]];
},
plus: function plus(x, y, r) {
return [['M', x - r, y], ['L', x + r, y], ['M', x, y - r], ['L', x, y + r]];
},
hyphen: function hyphen(x, y, r) {
return [['M', x - r, y], ['L', x + r, y]];
},
line: function line(x, y, r) {
return [['M', x, y - r], ['L', x, y + r]];
}
});
function getFillAttrs(cfg) {
var defaultAttrs = Global.shape.point;
var pointAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addFillAttrs(pointAttrs, cfg);
if (Util.isNumber(cfg.size)) {
pointAttrs.radius = cfg.size;
}
return pointAttrs;
}
function getLineAttrs(cfg) {
var defaultAttrs = Global.shape.hollowPoint;
var pointAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addStrokeAttrs(pointAttrs, cfg);
if (Util.isNumber(cfg.size)) {
pointAttrs.radius = cfg.size;
}
return pointAttrs;
}
var Point = Shape.registerFactory('point', {
defaultShapeType: 'hollowCircle',
getActiveCfg: function getActiveCfg(type, cfg) {
// 点放大 + 颜色加亮
var radius = cfg.radius;
var color;
if (type && (type.indexOf('hollow') === 0 || Util.indexOf(HOLLOW_SHAPES, type) !== -1) || !type) {
color = cfg.stroke || cfg.strokeStyle;
} else {
color = cfg.fill || cfg.fillStyle;
}
return {
radius: radius + 1,
shadowBlur: radius,
shadowColor: color,
stroke: color,
strokeOpacity: 1,
lineWidth: 1
};
},
getDefaultPoints: function getDefaultPoints(pointInfo) {
return ShapeUtil.splitPoints(pointInfo);
}
});
function getRectPath(cfg) {
var x = cfg.points[0].x;
var y = cfg.points[0].y;
var w = cfg.size[0];
var h = cfg.size[1];
var path = [['M', x - 0.5 * w, y - 0.5 * h], ['L', x + 0.5 * w, y - 0.5 * h], ['L', x + 0.5 * w, y + 0.5 * h], ['L', x - 0.5 * w, y + 0.5 * h], ['z']];
return path;
} // 用于桑基图的节点
Shape.registerShape('point', 'rect', {
draw: function draw(cfg, container) {
var rectAttrs = getFillAttrs(cfg);
var path = getRectPath(cfg);
path = this.parsePath(path);
var gShape = container.addShape('path', {
attrs: Util.mix(rectAttrs, {
path: path
})
});
return gShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
var attrs = getFillAttrs(cfg);
attrs.symbol = 'rect';
attrs.radius = 4.5;
return attrs;
}
}); // 添加shapes
Util.each(SHAPES, function (shape) {
Shape.registerShape('point', shape, {
draw: function draw(cfg, container) {
// cfg.points = this.parsePoints(cfg.points);
var attrs = getFillAttrs(cfg);
return container.addShape('Marker', {
attrs: Util.mix(attrs, {
symbol: shape,
x: cfg.x,
y: cfg.y
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var attrs = getFillAttrs(cfg);
attrs.symbol = shape;
attrs.radius = 4.5;
return attrs;
}
}); // 添加该 shape 对应的 hollowShape
Shape.registerShape('point', 'hollow' + Util.upperFirst(shape), {
draw: function draw(cfg, container) {
// cfg.points = this.parsePoints(cfg.points);
var attrs = getLineAttrs(cfg);
return container.addShape('Marker', {
attrs: Util.mix(attrs, {
symbol: shape,
x: cfg.x,
y: cfg.y
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var attrs = getLineAttrs(cfg);
attrs.symbol = shape;
attrs.radius = 4.5;
return attrs;
}
});
}); // 添加 hollowShapes
Util.each(HOLLOW_SHAPES, function (shape) {
Shape.registerShape('point', shape, {
draw: function draw(cfg, container) {
var attrs = getLineAttrs(cfg);
return container.addShape('Marker', {
attrs: Util.mix(attrs, {
symbol: shape,
x: cfg.x,
y: cfg.y
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
var attrs = getLineAttrs(cfg);
attrs.symbol = shape;
attrs.radius = 4.5;
return attrs;
}
});
}); // image
Shape.registerShape('point', 'image', {
draw: function draw(cfg, container) {
cfg.points = this.parsePoints(cfg.points);
return container.addShape('image', {
attrs: {
x: cfg.points[0].x - cfg.size / 2,
y: cfg.points[0].y - cfg.size,
width: cfg.size,
height: cfg.size,
img: cfg.shape[1]
}
});
}
}); // path
var pathMetaCache = {};
Shape.registerShape('point', 'path', {
draw: function draw(cfg, container) {
var attrs = Util.mix({}, getLineAttrs(cfg), getFillAttrs(cfg));
var path = cfg.shape[1];
var size = cfg.size || 10;
var pathMeta;
if (pathMetaCache[path]) {
pathMeta = pathMetaCache[path];
} else {
var segments = PathUtil.parsePathString(path);
var nums = Util.flatten(segments).filter(function (num) {
return Util.isNumber(num);
});
pathMetaCache[path] = pathMeta = {
range: Math.max.apply(null, nums) - Math.min.apply(null, nums),
segments: segments
};
}
var scale = size / pathMeta.range;
var transform = [];
if (attrs.rotate) {
transform.push(['r', attrs.rotate / 180 * Math.PI]);
delete attrs.rotate;
}
var shape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: pathMeta.segments
})
});
transform.push(['s', scale, scale], ['t', cfg.x, cfg.y]);
shape.transform(transform);
return shape;
}
});
module.exports = Point;
/***/ }),
/* 303 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview line shapes
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
* @author huangtonger@aliyun.com
# @author liuye10@yahoo.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
function getAttrs(cfg) {
var defaultCfg = Global.shape.polygon;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addFillAttrs(pathAttrs, cfg);
return pathAttrs;
}
function getHollowAttrs(cfg) {
var defaultCfg = Global.shape.hollowPolygon;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(pathAttrs, cfg);
return pathAttrs;
}
function getPath(points) {
var flag = points[0];
var i = 1;
var path = [['M', flag.x, flag.y]];
while (i < points.length) {
var c = points[i];
if (c.x !== points[i - 1].x || c.y !== points[i - 1].y) {
path.push(['L', c.x, c.y]);
if (c.x === flag.x && c.y === flag.y && i < points.length - 1) {
flag = points[i + 1];
path.push(['Z']);
path.push(['M', flag.x, flag.y]);
i++;
}
}
i++;
}
if (!Util.isEqual(path[path.length - 1], flag)) {
path.push(['L', flag.x, flag.y]);
}
path.push(['Z']);
return path;
} // regist line geom
var Polygon = Shape.registerFactory('polygon', {
defaultShapeType: 'polygon',
getDefaultPoints: function getDefaultPoints(pointInfo) {
var points = [];
Util.each(pointInfo.x, function (subX, index) {
var subY = pointInfo.y[index];
points.push({
x: subX,
y: subY
});
});
return points;
},
getActiveCfg: function getActiveCfg(type, cfg) {
var lineWidth = cfg.lineWidth || 1;
if (type === 'hollow') {
return {
lineWidth: lineWidth + 1
};
}
var opacity = cfg.fillOpacity || cfg.opacity || 1;
return {
// lineWidth,
fillOpacity: opacity - 0.08
};
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
if (cfg && cfg.style) {
return cfg.style;
}
return this.getActiveCfg(type, cfg);
}
});
Shape.registerShape('polygon', 'polygon', {
draw: function draw(cfg, container) {
if (!Util.isEmpty(cfg.points)) {
var attrs = getAttrs(cfg);
var path = getPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
}
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'square',
radius: 4
}, getAttrs(cfg));
}
});
Shape.registerShape('polygon', 'hollow', {
draw: function draw(cfg, container) {
if (!Util.isEmpty(cfg.points)) {
var attrs = getHollowAttrs(cfg);
var path = getPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
}
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'square',
radius: 4
}, getAttrs(cfg));
}
});
module.exports = Polygon;
/***/ }),
/* 304 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 自定义的 shape
* @author dxq613@gmail.com
* @author sima.zhang1990@gmail.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
function _parseValue(value) {
if (!Util.isArray(value)) {
value = [value];
}
var min = value[0]; // 最小值
var max = value[value.length - 1]; // 最大值
var min1 = value.length > 1 ? value[1] : min;
var max1 = value.length > 3 ? value[3] : max;
var median = value.length > 2 ? value[2] : min1;
return {
min: min,
// 最小值
max: max,
// 最大值
min1: min1,
max1: max1,
median: median
};
}
function addPoints(from, to) {
Util.each(from, function (subArr) {
to.push({
x: subArr[0],
y: subArr[1]
});
});
}
function getAttrs(cfg) {
var defaultAttrs = Global.shape.schema;
var lineAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addStrokeAttrs(lineAttrs, cfg);
return lineAttrs;
}
function getFillAttrs(cfg) {
var defaultAttrs = Global.shape.schema;
var lineAttrs = Util.mix({}, defaultAttrs, cfg.style);
ShapeUtil.addFillAttrs(lineAttrs, cfg);
if (cfg.color) {
lineAttrs.stroke = cfg.color || lineAttrs.stroke;
}
return lineAttrs;
}
function getBoxPoints(x, y, width) {
var points = [];
var pointsArray;
var obj;
if (Util.isArray(y)) {
// 2维
obj = _parseValue(y);
pointsArray = [[x - width / 2, obj.max], [x + width / 2, obj.max], [x, obj.max], [x, obj.max1], [x - width / 2, obj.min1], [x - width / 2, obj.max1], [x + width / 2, obj.max1], [x + width / 2, obj.min1], [x, obj.min1], [x, obj.min], [x - width / 2, obj.min], [x + width / 2, obj.min], [x - width / 2, obj.median], [x + width / 2, obj.median]];
} else {
// 只有一个维度
y = y || 0.5;
obj = _parseValue(x);
pointsArray = [[obj.min, y - width / 2], [obj.min, y + width / 2], [obj.min, y], [obj.min1, y], [obj.min1, y - width / 2], [obj.min1, y + width / 2], [obj.max1, y + width / 2], [obj.max1, y - width / 2], [obj.max1, y], [obj.max, y], [obj.max, y - width / 2], [obj.max, y + width / 2], [obj.median, y - width / 2], [obj.median, y + width / 2]];
}
addPoints(pointsArray, points);
return points;
}
function _sortValue(value) {
if (!Util.isArray(value)) {
value = [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;
} // 获取K线图的points
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;
}
function getBoxPath(points) {
var path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['M', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['L', points[6].x, points[6].y], ['L', points[7].x, points[7].y], ['L', points[4].x, points[4].y], // 封闭 z
['Z'], ['M', points[8].x, points[8].y], ['L', points[9].x, points[9].y], ['M', points[10].x, points[10].y], ['L', points[11].x, points[11].y], ['M', points[12].x, points[12].y], ['L', points[13].x, points[13].y]];
return path;
}
function getCandlePath(points) {
var path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['L', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['Z'], ['M', points[6].x, points[6].y], ['L', points[7].x, points[7].y]];
return path;
}
var Schema = Shape.registerFactory('schema', {
defaultShapeType: '',
getActiveCfg: function getActiveCfg(type, cfg) {
if (type === 'box') {
var lineWidth = cfg.lineWidth || 1;
return {
lineWidth: lineWidth + 1
};
}
var opacity = cfg.fillOpacity || cfg.opacity || 1;
return {
fillOpacity: opacity - 0.15,
strokeOpacity: opacity - 0.15
};
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
if (cfg && cfg.style) {
return cfg.style;
}
return this.getActiveCfg(type, cfg);
}
}); // 箱线图
Shape.registerShape('schema', 'box', {
getPoints: function getPoints(pointInfo) {
return getBoxPoints(pointInfo.x, pointInfo.y, pointInfo.size);
},
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getBoxPath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return {
symbol: function symbol(x, y, r) {
var yValues = [y - 6, y - 3, y, y + 3, y + 6];
var points = getBoxPoints(x, yValues, r);
return [['M', points[0].x + 1, points[0].y], ['L', points[1].x - 1, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['M', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['L', points[6].x, points[6].y], ['L', points[7].x, points[7].y], ['L', points[4].x, points[4].y], ['Z'], ['M', points[8].x, points[8].y], ['L', points[9].x, points[9].y], ['M', points[10].x + 1, points[10].y], ['L', points[11].x - 1, points[11].y], ['M', points[12].x, points[12].y], ['L', points[13].x, points[13].y]];
},
radius: 6,
lineWidth: 1,
stroke: cfg.color
};
}
}); // K线
Shape.registerShape('schema', 'candle', {
getPoints: function getPoints(pointInfo) {
return getCandlePoints(pointInfo.x, pointInfo.y, pointInfo.size);
},
draw: function draw(cfg, container) {
var attrs = getFillAttrs(cfg);
var path = getCandlePath(cfg.points);
path = this.parsePath(path);
return container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
},
getMarkerCfg: function getMarkerCfg(cfg) {
return {
symbol: function symbol(x, y, r) {
y = [y + 7.5, y + 3, y - 3, y - 7.5];
var points = getCandlePoints(x, y, r);
return [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['L', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['Z'], ['M', points[6].x, points[6].y], ['L', points[7].x, points[7].y]];
},
lineWidth: 1,
stroke: cfg.color,
fill: cfg.color,
radius: 6
};
}
});
module.exports = Schema;
/***/ }),
/* 305 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview venn shapes
* @author leungwensen@gmail.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
var PathUtil = Util.PathUtil;
function getAttrs(cfg) {
var defaultCfg = Global.shape.venn;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addFillAttrs(pathAttrs, cfg);
return pathAttrs;
}
function getHollowAttrs(cfg) {
var defaultCfg = Global.shape.hollowVenn;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(pathAttrs, cfg);
return pathAttrs;
} // register venn geom
var Venn = Shape.registerFactory('venn', {
defaultShapeType: 'venn',
getActiveCfg: function getActiveCfg(type, cfg) {
var lineWidth = cfg.lineWidth || 1;
if (type === 'hollow') {
return {
lineWidth: lineWidth + 1
};
}
var opacity = cfg.fillOpacity || cfg.opacity || 1;
return {
// lineWidth,
fillOpacity: opacity - 0.08
};
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
if (cfg && cfg.style) {
return cfg.style;
}
return this.getActiveCfg(type, cfg);
}
});
Shape.registerShape('venn', 'venn', {
draw: function draw(cfg, container) {
var origin = cfg.origin._origin;
var path = origin.path;
var attrs = getAttrs(cfg);
var segments = PathUtil.parsePathString(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: segments
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getAttrs(cfg));
}
});
Shape.registerShape('venn', 'hollow', {
draw: function draw(cfg, container) {
var origin = cfg.origin._origin;
var path = origin.path;
var attrs = getHollowAttrs(cfg);
var segments = PathUtil.parsePathString(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: segments
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getAttrs(cfg));
}
});
module.exports = Venn;
/***/ }),
/* 306 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview venn shapes
* @author leungwensen@gmail.com
*/
var Util = __webpack_require__(0);
var Shape = __webpack_require__(9);
var ShapeUtil = __webpack_require__(22);
var Global = __webpack_require__(5);
var PathUtil = __webpack_require__(25);
function getAttrs(cfg) {
var defaultCfg = Global.shape.venn;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addFillAttrs(pathAttrs, cfg);
if (cfg.color) {
pathAttrs.stroke = pathAttrs.stroke || cfg.color;
}
return pathAttrs;
}
function getHollowAttrs(cfg) {
var defaultCfg = Global.shape.hollowVenn;
var pathAttrs = Util.mix({}, defaultCfg, cfg.style);
ShapeUtil.addStrokeAttrs(pathAttrs, cfg);
return pathAttrs;
}
function getViolinPath(points) {
var path = [];
for (var i = 0; i < points.length; i++) {
var point = points[i];
if (point) {
var action = i === 0 ? 'M' : 'L';
path.push([action, point.x, point.y]);
}
}
var first = points[0];
if (first) {
path.push(['L', first.x, first.y]);
path.push(['z']);
}
return path;
}
function getSmoothViolinPath(points) {
var half = points.length / 2;
var leftPoints = [];
var rightPoints = [];
for (var i = 0; i < points.length; i++) {
if (i < half) {
leftPoints.push(points[i]);
} else {
rightPoints.push(points[i]);
}
}
var leftPath = PathUtil.getSplinePath(leftPoints, false);
var rightPath = PathUtil.getSplinePath(rightPoints, false);
if (rightPoints.length) {
leftPath.push(['L', rightPoints[0].x, rightPoints[0].y]);
}
rightPath.shift();
var path = leftPath.concat(rightPath);
if (leftPoints.length) {
path.push(['L', leftPoints[0].x, leftPoints[0].y]);
}
path.push(['z']);
return path;
}
function normalizeSize(arr) {
var max = Math.max.apply(null, arr);
return arr.map(function (num) {
return num / max;
});
} // register violin geom shape
var Violin = Shape.registerFactory('violin', {
defaultShapeType: 'violin',
getDefaultPoints: function getDefaultPoints(pointInfo) {
var radius = pointInfo.size / 2;
var points = [];
var sizeArr = normalizeSize(pointInfo._size);
Util.each(pointInfo.y, function (y, index) {
var offset = sizeArr[index] * radius;
var isMin = index === 0;
var isMax = index === pointInfo.y.length - 1;
points.push({
isMin: isMin,
isMax: isMax,
x: pointInfo.x - offset,
y: y
});
points.unshift({
isMin: isMin,
isMax: isMax,
x: pointInfo.x + offset,
y: y
});
});
return points;
},
getActiveCfg: function getActiveCfg(type, cfg) {
var lineWidth = cfg.lineWidth || 1;
if (type === 'hollow') {
return {
lineWidth: lineWidth + 1
};
}
var opacity = cfg.fillOpacity || cfg.opacity || 1;
return {
// lineWidth,
fillOpacity: opacity - 0.08
};
},
getSelectedCfg: function getSelectedCfg(type, cfg) {
if (cfg && cfg.style) {
return cfg.style;
}
return this.getActiveCfg(type, cfg);
}
}); // normal violin, filled path
Shape.registerShape('violin', 'violin', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getViolinPath(cfg.points);
path = this.parsePath(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getAttrs(cfg));
}
}); // smooth spline violin, filled path
Shape.registerShape('violin', 'smooth', {
draw: function draw(cfg, container) {
var attrs = getAttrs(cfg);
var path = getSmoothViolinPath(cfg.points);
path = this.parsePath(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getAttrs(cfg));
}
}); // hollow violin, stroked path
Shape.registerShape('violin', 'hollow', {
draw: function draw(cfg, container) {
var attrs = getHollowAttrs(cfg);
var path = getViolinPath(cfg.points);
path = this.parsePath(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getHollowAttrs(cfg));
}
}); // hollow smooth spline violin, stroked path
Shape.registerShape('violin', 'smoothHollow', {
draw: function draw(cfg, container) {
var attrs = getHollowAttrs(cfg);
var path = getSmoothViolinPath(cfg.points);
path = this.parsePath(path);
var pathShape = container.addShape('path', {
attrs: Util.mix(attrs, {
path: path
})
});
return pathShape;
},
getMarkerCfg: function getMarkerCfg(cfg) {
return Util.mix({
symbol: 'circle',
radius: 4
}, getHollowAttrs(cfg));
}
});
module.exports = Violin;
/***/ }),
/* 307 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(0);
module.exports = function (field) {
if (Util.isArray(field)) {
return field;
}
if (Util.isString(field)) {
return field.split('*');
}
return [field];
};
/***/ }),
/* 308 */
/***/ (function(module, exports, __webpack_require__) {
var MatrixUtil = __webpack_require__(0).MatrixUtil;
var Vector2 = MatrixUtil.vec2;
function smoothBezier(points, smooth, isLoop, constraint) {
var cps = [];
var prevPoint;
var nextPoint;
var hasConstraint = !!constraint;
var min, max;
if (hasConstraint) {
min = [Infinity, Infinity];
max = [-Infinity, -Infinity];
for (var i = 0, l = points.length; i < l; i++) {
var point = points[i];
min = Vector2.min([], min, point);
max = Vector2.max([], max, point);
}
min = Vector2.min([], min, constraint[0]);
max = Vector2.max([], max, constraint[1]);
}
for (var _i = 0, len = points.length; _i < len; _i++) {
var _point = points[_i];
if (isLoop) {
prevPoint = points[_i ? _i - 1 : len - 1];
nextPoint = points[(_i + 1) % len];
} else {
if (_i === 0 || _i === len - 1) {
cps.push(_point);
continue;
} else {
prevPoint = points[_i - 1];
nextPoint = points[_i + 1];
}
}
var v = [];
v = Vector2.sub(v, nextPoint, prevPoint);
v = 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) {
cp0 = Vector2.max([], cp0, min);
cp0 = Vector2.min([], cp0, max);
cp1 = Vector2.max([], cp1, min);
cp1 = Vector2.min([], cp1, max);
}
cps.push(cp0);
cps.push(cp1);
}
if (isLoop) {
cps.push(cps.shift());
}
return cps;
}
function catmullRom2bezier(crp, z, constraint) {
var isLoop = !!z;
var pointList = [];
for (var i = 0, l = crp.length; i < l; i += 2) {
pointList.push([crp[i], crp[i + 1]]);
}
var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
var len = pointList.length;
var d1 = [];
var cp1;
var cp2;
var p;
for (var _i2 = 0; _i2 < len - 1; _i2++) {
cp1 = controlPointList[_i2 * 2];
cp2 = controlPointList[_i2 * 2 + 1];
p = pointList[_i2 + 1];
d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]);
}
if (isLoop) {
cp1 = controlPointList[len];
cp2 = controlPointList[len + 1];
p = pointList[0];
d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]);
}
return d1;
}
module.exports = {
catmullRom2bezier: catmullRom2bezier
};
/***/ }),
/* 309 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview Venn Diagram
* @author leungwensen@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
var _require = __webpack_require__(526),
venn = _require.venn,
scaleSolution = _require.scaleSolution,
circlePath = _require.circlePath,
intersectionAreaPath = _require.intersectionAreaPath,
computeTextCentres = _require.computeTextCentres;
__webpack_require__(305);
var Venn =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Venn, _GeomBase);
function Venn() {
return _GeomBase.apply(this, arguments) || this;
}
var _proto = Venn.prototype;
/**
* get default configuration
* @protected
* @return {Object} configuration
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'venn';
cfg.shapeType = 'venn';
cfg.generatePoints = false; // super.draw(data, container, shapeFactory, index);
return cfg;
};
_proto._getAttrValues = function _getAttrValues(attr, record) {
if (attr.type === 'position') {
return [record.x, record.y];
}
return _GeomBase.prototype._getAttrValues.call(this, attr, record);
};
_proto.sets = function sets(field) {
this.set('setsField', field);
return this;
};
_proto._initAttrs = function _initAttrs() {
var self = this;
_GeomBase.prototype._initAttrs.call(this);
var attrOptions = self.get('attrOptions');
var setsField = self.get('setsField') || 'sets';
var data = self.get('data');
var sizeField = attrOptions.size ? attrOptions.size.field : 'size'; // prepare data
data.forEach(function (row) {
row.sets = row[setsField];
row._sets = row[setsField].join('&');
row.size = row[sizeField];
});
var solution = venn(data); // scaling
var coord = self.get('coord');
var xRange = [Math.min(coord.x.end, coord.x.start), Math.max(coord.x.end, coord.x.start)];
var yRange = [Math.min(coord.y.end, coord.y.start), Math.max(coord.y.end, coord.y.start)];
var width = xRange[1] - xRange[0];
var height = yRange[1] - yRange[0];
var styleOptions = self.get('styleOptions');
var padding = styleOptions && Util.isObject(styleOptions.style) ? styleOptions.style.padding : 0;
if (!Util.isFinite(padding)) {
padding = 0;
}
var circles = scaleSolution(solution, width, height, padding);
var textCenters = computeTextCentres(circles, data);
data.forEach(function (row) {
var sets = row.sets;
var id = sets.join(',');
row.id = id;
if (sets.length === 1) {
var circle = circles[id];
row.path = circlePath(circle.x, circle.y, circle.radius);
Util.assign(row, circle);
} else {
var setCircles = sets.map(function (set) {
return circles[set];
});
var path = intersectionAreaPath(setCircles);
if (!/[zZ]$/.test(path)) {
path += 'Z';
}
row.path = path;
var center = textCenters[id] || {
x: 0,
y: 0
};
Util.assign(row, center);
}
}); // x, y scales
// self.position('x*y');
// self.scale('x', { type: 'identity' });
// self.scale('y', { type: 'identity' });
}; // createShapePointsCfg(obj) {
// const xScale = this.getXScale();
// const yScale = this.getYScale();
// return {
// x: obj[xScale.field],
// y: obj[yScale.field],
// y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
// };
// }
// paint() {
// super.paint();
// const self = this;
// const dataArray = self.get('dataArray');
// const shapeContainer = self.get('shapeContainer');
// // add labels
// dataArray.forEach(row => {
// const cfg = self.getDrawCfg(row[0]);
// const origin = cfg.origin._origin;
// shapeContainer.addShape('text', {
// attrs: Util.mix({}, {
// x: origin.x,
// y: origin.y,
// text: origin.label || '',
// fontSize: 18,
// fill: cfg.shape === 'hollow' ? cfg.color : '#666',
// textAlign: 'center',
// textBaseline: 'middle'
// }, cfg.style ? cfg.style.textStyle : {})
// });
// });
// }
return Venn;
}(GeomBase);
GeomBase.Venn = Venn;
module.exports = Venn;
/***/ }),
/* 310 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
/**
* @fileOverview Venn Diagram
* @author leungwensen@gmail.com
*/
var GeomBase = __webpack_require__(8);
var Util = __webpack_require__(0);
var SizeMixin = __webpack_require__(67);
__webpack_require__(306);
var Violin =
/*#__PURE__*/
function (_GeomBase) {
_inheritsLoose(Violin, _GeomBase);
var _proto = Violin.prototype;
/**
* get default configuration
* @protected
* @return {Object} configuration
*/
_proto.getDefaultCfg = function getDefaultCfg() {
var cfg = _GeomBase.prototype.getDefaultCfg.call(this);
cfg.type = 'violin';
cfg.shapeType = 'violin';
cfg.generatePoints = true; // super.draw(data, container, shapeFactory, index);
return cfg;
};
function Violin(cfg) {
var _this;
_this = _GeomBase.call(this, cfg) || this;
Util.assign(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
return _this;
}
_proto.createShapePointsCfg = function createShapePointsCfg(obj) {
var self = this;
var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj);
cfg.size = self.getNormalizedSize(obj);
var sizeField = self.get('_sizeField');
cfg._size = obj._origin[sizeField];
return cfg;
};
_proto.clearInner = function clearInner() {
_GeomBase.prototype.clearInner.call(this);
this.set('defaultSize', null);
};
_proto._initAttrs = function _initAttrs() {
var self = this;
var attrOptions = self.get('attrOptions');
var sizeField = attrOptions.size ? attrOptions.size.field : self.get('_sizeField') ? self.get('_sizeField') : 'size';
self.set('_sizeField', sizeField);
delete attrOptions.size;
_GeomBase.prototype._initAttrs.call(this);
};
return Violin;
}(GeomBase);
var ViolinDodge =
/*#__PURE__*/
function (_Violin) {
_inheritsLoose(ViolinDodge, _Violin);
function ViolinDodge() {
return _Violin.apply(this, arguments) || this;
}
var _proto2 = ViolinDodge.prototype;
_proto2.getDefaultCfg = function getDefaultCfg() {
var cfg = _Violin.prototype.getDefaultCfg.call(this);
cfg.hasDefaultAdjust = true;
cfg.adjusts = [{
type: 'dodge'
}];
return cfg;
};
return ViolinDodge;
}(Violin);
Violin.Dodge = ViolinDodge;
GeomBase.Violin = Violin;
GeomBase.ViolinDodge = ViolinDodge;
module.exports = Violin;
/***/ }),
/* 311 */
/***/ (function(module, exports, __webpack_require__) {
var _html, _tooltip;
/**
* @fileOverview G2 3.0 dark theme
* @author sima.zhang
*/
var Util = __webpack_require__(0);
var BasicTheme = __webpack_require__(124); // tooltip 相关 dom 的 css 类名
var TOOLTIP_CONTAINER_CLASS = 'g2-tooltip';
var LEGEND_CONTAINER_CLASS = 'g2-legend';
var DarkTheme = Util.deepMix({}, BasicTheme, {
background: {
fill: '#1F1F1F',
radius: 2
},
// 容器区域
plotBackground: {
fill: '#1F1F1F'
},
// 绘图区域
axis: {
top: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
line: {
stroke: '#737373'
},
tickLine: {
stroke: '#737373'
}
},
bottom: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
line: {
stroke: '#737373'
},
tickLine: {
stroke: '#737373'
}
},
left: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
grid: {
lineStyle: {
stroke: '#404040'
}
}
},
right: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
grid: {
lineStyle: {
stroke: '#404040'
}
}
},
circle: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
line: {
stroke: '#737373'
},
tickLine: {
stroke: '#737373'
},
grid: {
lineStyle: {
stroke: '#404040'
}
}
},
radius: {
label: {
textStyle: {
fill: '#A6A6A6'
}
},
line: {
stroke: '#737373'
},
tickLine: {
stroke: '#737373'
},
grid: {
lineStyle: {
stroke: '#404040'
}
}
},
helix: {
line: {
stroke: '#737373'
},
tickLine: {
stroke: '#737373'
}
}
},
label: {
textStyle: {
fill: '#A6A6A6'
}
},
legend: {
right: {
textStyle: {
fill: '#737373'
},
unCheckColor: '#bfbfbf'
},
left: {
textStyle: {
fill: '#737373'
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
top: {
textStyle: {
fill: '#737373'
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
bottom: {
textStyle: {
fill: '#737373'
},
// 图例项文本的样式
unCheckColor: '#bfbfbf'
},
html: (_html = {}, _html["" + LEGEND_CONTAINER_CLASS] = {
color: '#D9D9D9'
}, _html),
gradient: {
textStyle: {
fill: '#D9D9D9'
},
lineStyle: {
stroke: '#404040'
}
}
},
tooltip: (_tooltip = {}, _tooltip["" + TOOLTIP_CONTAINER_CLASS] = {
color: '#D9D9D9',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
boxShadow: '0px 0px 2px #000'
}, _tooltip),
tooltipCrosshairsRect: {
type: 'rect',
rectStyle: {
fill: '#fff',
opacity: 0.1
}
},
// tooltip 辅助背景框样式
tooltipCrosshairsLine: {
lineStyle: {
stroke: 'rgba(255, 255, 255, 0.45)'
}
},
guide: {
line: {
text: {
style: {
fill: '#A6A6A6'
}
}
},
text: {
style: {
fill: '#A6A6A6'
}
},
region: {
// TODO
style: {
lineWidth: 0,
// 辅助框的边框宽度
fill: '#000',
// 辅助框填充的颜色
fillOpacity: 0.04 // 辅助框的背景透明度
// 辅助框的图形样式属性
}
}
}
});
module.exports = DarkTheme;
/***/ }),
/* 312 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Event = __webpack_require__(128);
var Group = __webpack_require__(127);
var Timeline = __webpack_require__(316);
var renderers = __webpack_require__(321);
var Canvas = function Canvas(cfg) {
Canvas.superclass.constructor.call(this, cfg);
};
Canvas.CFG = {
eventEnable: true,
/**
* 像素宽度
* @type {Number}
*/
width: null,
/**
* 像素高度
* @type {Number}
*/
height: null,
/**
* 画布宽度
* @type {Number}
*/
widthCanvas: null,
/**
* 画布高度
* @type {Number}
*/
heightCanvas: null,
/**
* CSS宽
* @type {String}
*/
widthStyle: null,
/**
* CSS高
* @type {String}
*/
heightStyle: null,
/**
* 容器DOM
* @type {Object}
*/
containerDOM: null,
/**
* 当前Canvas的DOM
* @type {Object}
*/
canvasDOM: null,
/**
* 屏幕像素比
* @type {Number}
*/
pixelRatio: null,
/**
* 渲染器,默认是canvas
* @type {String}
*/
renderer: 'canvas'
};
Util.extend(Canvas, Group);
Util.augment(Canvas, {
init: function init() {
Canvas.superclass.init.call(this);
this._setGlobalParam();
this._setContainer();
this._initPainter();
this._scale();
if (this.get('eventEnable')) {
this._registEvents();
}
},
getEmitter: function getEmitter(element, event) {
if (element) {
if (Util.isEmpty(element._getEvents())) {
var parent = element.get('parent');
if (parent && !event.propagationStopped) {
return this.getEmitter(parent, event);
}
} else {
return element;
}
}
},
_getEventObj: function _getEventObj(type, e, point, target) {
var event = new Event(type, e, true, true);
event.x = point.x;
event.y = point.y;
event.clientX = e.clientX;
event.clientY = e.clientY;
event.currentTarget = target;
event.target = target;
return event;
},
_triggerEvent: function _triggerEvent(type, e) {
var point = this.getPointByClient(e.clientX, e.clientY);
var shape = this.getShape(point.x, point.y, e);
var el = this.get('el');
var emitObj;
if (type === 'mousemove') {
var preShape = this.get('preShape');
if (preShape && preShape !== shape) {
var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
emitObj = this.getEmitter(preShape, e);
emitObj && emitObj.emit('mouseleave', mouseleave);
el.style.cursor = 'default';
}
if (shape) {
var mousemove = this._getEventObj('mousemove', e, point, shape);
emitObj = this.getEmitter(shape, e);
emitObj && emitObj.emit('mousemove', mousemove);
if (preShape !== shape) {
var mouseenter = this._getEventObj('mouseenter', e, point, shape);
emitObj && emitObj.emit('mouseenter', mouseenter, e);
}
} else {
var canvasmousemove = this._getEventObj('mousemove', e, point, this);
this.emit('mousemove', canvasmousemove);
}
this.set('preShape', shape);
} else {
var event = this._getEventObj(type, e, point, shape || this);
emitObj = this.getEmitter(shape, e);
if (emitObj && emitObj !== this) {
emitObj.emit(type, event);
}
this.emit(type, event);
}
if (shape && !shape.get('destroyed')) {
el.style.cursor = shape.attr('cursor') || 'default';
}
},
_registEvents: function _registEvents() {
var self = this;
var el = self.get('el');
var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseleave', 'mouseup', 'click', 'dblclick'];
Util.each(events, function (event) {
el.addEventListener(event, function (e) {
self._triggerEvent(event, e);
}, false);
}); // special cases
el.addEventListener('touchstart', function (e) {
if (!Util.isEmpty(e.touches)) {
self._triggerEvent('touchstart', e.touches[0]);
}
}, false);
el.addEventListener('touchmove', function (e) {
if (!Util.isEmpty(e.touches)) {
self._triggerEvent('touchmove', e.touches[0]);
}
}, false);
el.addEventListener('touchend', function (e) {
if (!Util.isEmpty(e.changedTouches)) {
self._triggerEvent('touchend', e.changedTouches[0]);
}
}, false);
},
_scale: function _scale() {
var pixelRatio = this.get('pixelRatio');
this.scale(pixelRatio, pixelRatio);
},
_setGlobalParam: function _setGlobalParam() {
var pixelRatio = this.get('pixelRatio');
if (!pixelRatio) {
this.set('pixelRatio', Util.getRatio());
}
var renderer = renderers[this.get('renderer') || 'canvas'];
this._cfg.renderer = renderer;
this._cfg.canvas = this;
var timeline = new Timeline(this);
this._cfg.timeline = timeline;
},
_setContainer: function _setContainer() {
var containerId = this.get('containerId');
var containerDOM = this.get('containerDOM');
if (!containerDOM) {
containerDOM = document.getElementById(containerId);
this.set('containerDOM', containerDOM);
}
Util.modifyCSS(containerDOM, {
position: 'relative'
});
},
_initPainter: function _initPainter() {
var containerDOM = this.get('containerDOM');
var painter = new this._cfg.renderer.painter(containerDOM);
this._cfg.painter = painter;
this._cfg.canvasDOM = this._cfg.el = painter.canvas;
this.changeSize(this.get('width'), this.get('height'));
},
_resize: function _resize() {
var canvasDOM = this.get('canvasDOM');
var widthCanvas = this.get('widthCanvas');
var heightCanvas = this.get('heightCanvas');
var widthStyle = this.get('widthStyle');
var heightStyle = this.get('heightStyle');
canvasDOM.style.width = widthStyle;
canvasDOM.style.height = heightStyle;
canvasDOM.setAttribute('width', widthCanvas);
canvasDOM.setAttribute('height', heightCanvas);
},
getWidth: function getWidth() {
var pixelRatio = this.get('pixelRatio');
var width = this.get('width');
return width * pixelRatio;
},
getHeight: function getHeight() {
var pixelRatio = this.get('pixelRatio');
var height = this.get('height');
return height * pixelRatio;
},
changeSize: function changeSize(width, height) {
var pixelRatio = this.get('pixelRatio');
var widthCanvas = width * pixelRatio;
var heightCanvas = height * pixelRatio;
this.set('widthCanvas', widthCanvas);
this.set('heightCanvas', heightCanvas);
this.set('widthStyle', width + 'px');
this.set('heightStyle', height + 'px');
this.set('width', width);
this.set('height', height);
this._resize();
},
/**
* 将窗口坐标转变成 canvas 坐标
* @param {Number} clientX 窗口x坐标
* @param {Number} clientY 窗口y坐标
* @return {Object} canvas坐标
*/
getPointByClient: function getPointByClient(clientX, clientY) {
var el = this.get('el');
var pixelRatio = this.get('pixelRatio') || 1;
var bbox = el.getBoundingClientRect();
return {
x: (clientX - bbox.left) * pixelRatio,
y: (clientY - bbox.top) * pixelRatio
};
},
getClientByPoint: function getClientByPoint(x, y) {
var el = this.get('el');
var bbox = el.getBoundingClientRect();
var pixelRatio = this.get('pixelRatio') || 1;
return {
clientX: x / pixelRatio + bbox.left,
clientY: y / pixelRatio + bbox.top
};
},
draw: function draw() {
this._cfg.painter.draw(this);
},
getShape: function getShape(x, y, e) {
if (arguments.length === 3 && this._cfg.renderer.getShape) {
return this._cfg.renderer.getShape.call(this, x, y, e);
}
return Canvas.superclass.getShape.call(this, x, y);
},
_drawSync: function _drawSync() {
this._cfg.painter.drawSync(this);
},
destroy: function destroy() {
var cfg = this._cfg;
var containerDOM = cfg.containerDOM;
var canvasDOM = cfg.canvasDOM;
if (canvasDOM && containerDOM) {
containerDOM.removeChild(canvasDOM);
}
cfg.timeline.stop();
Canvas.superclass.destroy.call(this);
}
});
module.exports = Canvas;
/***/ }),
/* 313 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var ReservedProps = {
delay: 'delay',
rotate: 'rotate'
};
var colorRalaredProps = {
fill: 'fill',
stroke: 'stroke',
fillStyle: 'fillStyle',
strokeStyle: 'strokeStyle'
};
function getFromAttrs(toAttrs, shape) {
var rst = {};
var attrs = shape._attrs;
for (var k in toAttrs.attrs) {
rst[k] = attrs[k];
}
return rst;
}
function getFormatProps(props, shape) {
var rst = {
matrix: null,
attrs: {}
};
var attrs = shape._attrs;
for (var k in props) {
if (k === 'transform') {
rst.matrix = Util.transform(shape.getMatrix(), props[k]);
} else if (k === 'rotate') {
rst.matrix = Util.transform(shape.getMatrix(), [['r', props[k]]]);
} else if (k === 'matrix') {
rst.matrix = props[k];
} else if (colorRalaredProps[k] && /^[r,R,L,l]{1}[\s]*\(/.test(props[k])) {
// 渐变色不支持动画
continue;
} else if (!ReservedProps[k] && attrs[k] !== props[k]) {
rst.attrs[k] = props[k];
}
}
return rst;
}
function checkExistedAttrs(animators, animator) {
var delay = animator.delay;
var hasOwnProperty = Object.prototype.hasOwnProperty;
Util.each(animator.toAttrs, function (v, k) {
Util.each(animators, function (animator) {
if (delay < animator.startTime + animator.duration) {
if (hasOwnProperty.call(animator.toAttrs, k)) {
delete animator.toAttrs[k];
delete animator.fromAttrs[k];
}
}
});
});
if (animator.toMatrix) {
Util.each(animators, function (animator) {
if (delay < animator.startTime + animator.duration && animator.toMatrix) {
delete animator.toMatrix;
}
});
}
return animators;
}
module.exports = {
/**
* 执行动画
* @param {Object} toProps 动画最终状态
* @param {Number} duration 动画执行时间
* @param {String} easing 动画缓动效果
* @param {Function} callback 动画执行后的回调
* @param {Number} delay 动画延迟时间
*/
animate: function animate(toProps, duration, easing, callback, delay) {
if (delay === void 0) {
delay = 0;
}
var self = this;
self.set('animating', true);
var timeline = self.get('timeline');
if (!timeline) {
timeline = self.get('canvas').get('timeline');
self.setSilent('timeline', timeline);
}
var animators = self.get('animators') || []; // 初始化tick
if (!timeline._timer) {
timeline.initTimer();
}
if (Util.isNumber(callback)) {
delay = callback;
callback = null;
}
if (Util.isFunction(easing)) {
callback = easing;
easing = 'easeLinear';
} else {
easing = easing ? easing : 'easeLinear';
}
var formatProps = getFormatProps(toProps, self); // 记录动画属性
var animator = {
fromAttrs: getFromAttrs(formatProps, self),
toAttrs: formatProps.attrs,
fromMatrix: Util.clone(self.getMatrix()),
toMatrix: formatProps.matrix,
duration: duration,
easing: easing,
callback: callback,
delay: delay,
startTime: timeline.getTime(),
id: Util.uniqueId()
}; // 如果动画队列中已经有这个图形了
if (animators.length > 0) {
// 先检查是否需要合并属性。若有相同的动画,将该属性从前一个动画中删除,直接用后一个动画中
animators = checkExistedAttrs(animators, animator);
} else {
// 否则将图形添加到队列
timeline.addAnimator(self);
}
animators.push(animator);
self.setSilent('animators', animators);
self.setSilent('pause', {
isPaused: false
});
},
stopAnimate: function stopAnimate() {
var _this = this;
var animators = this.get('animators'); // 将动画执行到最后一帧,执行回调
Util.each(animators, function (animator) {
_this.attr(animator.toAttrs);
if (animator.toMatrix) {
_this.attr('matrix', animator.toMatrix);
}
if (animator.callback) {
animator.callback();
}
});
this.setSilent('animating', false);
this.setSilent('animators', []);
},
pauseAnimate: function pauseAnimate() {
var self = this;
var timeline = self.get('timeline'); // 记录下是在什么时候暂停的
self.setSilent('pause', {
isPaused: true,
pauseTime: timeline.getTime()
});
return self;
},
resumeAnimate: function resumeAnimate() {
var self = this;
var timeline = self.get('timeline');
var current = timeline.getTime();
var animators = self.get('animators');
var pauseTime = self.get('pause').pauseTime; // 之后更新属性需要计算动画已经执行的时长,如果暂停了,就把初始时间调后
Util.each(animators, function (animator) {
animator.startTime = animator.startTime + (current - pauseTime);
animator._paused = false;
animator._pauseTime = null;
});
self.setSilent('pause', {
isPaused: false
});
self.setSilent('animators', animators);
return self;
}
};
/***/ }),
/* 314 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
module.exports = {
canFill: false,
canStroke: false,
initAttrs: function initAttrs(attrs) {
this._attrs = {
opacity: 1,
fillOpacity: 1,
strokeOpacity: 1,
matrix: [1, 0, 0, 0, 1, 0, 0, 0, 1]
};
this.attr(Util.assign(this.getDefaultAttrs(), attrs));
return this;
},
getDefaultAttrs: function getDefaultAttrs() {
return {};
},
/**
* 设置或者设置属性,有以下 4 种情形:
* - name 不存在, 则返回属性集合
* - name 为字符串,value 为空,获取属性值
* - name 为字符串,value 不为空,设置属性值,返回 this
* - name 为键值对,value 为空,设置属性值
*
* @param {String | Object} name 属性名
* @param {*} value 属性值
* @return {*} 属性值
*/
attr: function attr(name, value) {
var self = this;
if (arguments.length === 0) {
return self._attrs;
}
if (Util.isObject(name)) {
// self._attrs = Util.deepMix(self._attrs, name);
for (var k in name) {
this._setAttr(k, name[k]);
}
self.clearBBox();
this._cfg.hasUpdate = true;
return self;
}
if (arguments.length === 2) {
this._setAttr(name, value);
self.clearBBox();
this._cfg.hasUpdate = true;
return self;
}
return self._attrs[name];
},
_setAttr: function _setAttr(name, value) {
var self = this;
var attrs = this._attrs;
attrs[name] = value;
if (name === 'fill' || name === 'stroke') {
attrs[name + 'Style'] = value;
return;
}
if (name === 'opacity') {
attrs.globalAlpha = value;
return;
}
if (name === 'clip' && value) {
self._setClip(value);
return;
}
if (name === 'path' && self._afterSetAttrPath) {
self._afterSetAttrPath(value);
return;
}
if (name === 'transform') {
self.transform(value);
return;
}
if (name === 'rotate') {
self.rotateAtStart(value);
}
},
clearBBox: function clearBBox() {
this.setSilent('box', null);
},
hasFill: function hasFill() {
return this.canFill && this._attrs.fillStyle;
},
hasStroke: function hasStroke() {
return this.canStroke && this._attrs.strokeStyle;
},
_setClip: function _setClip(item) {
item._cfg.renderer = this._cfg.renderer;
item._cfg.canvas = this._cfg.canvas;
item._cfg.parent = this._cfg.parent;
item.hasFill = function () {
return true;
};
}
};
/***/ }),
/* 315 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var Inside = __webpack_require__(70);
var mathUtl = {
arc: __webpack_require__(44),
ellipse: __webpack_require__(136),
line: __webpack_require__(45)
};
var canvas = Util.createDom('');
var context = canvas.getContext('2d');
function isPointInPathByContext(x, y, ctx) {
ctx.createPath(context);
return context.isPointInPath(x, y);
}
var arc = function arc(x, y) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.r,
startAngle = attrs.startAngle,
endAngle = attrs.endAngle,
clockwise = attrs.clockwise;
var lineWidth = this.getHitLineWidth();
if (this.hasStroke()) {
return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
}
return false;
};
var circle = function circle(x, y) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.r;
var lineWidth = this.getHitLineWidth();
var fill = this.hasFill();
var stroke = this.hasStroke();
if (fill && stroke) {
return Inside.circle(cx, cy, r, x, y) || Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
}
if (fill) {
return Inside.circle(cx, cy, r, x, y);
}
if (stroke) {
return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
}
return false;
};
var ellipse = function ellipse(x, y) {
var attrs = this._attrs;
var fill = this.hasFill();
var stroke = this.hasStroke();
var cx = attrs.x;
var cy = attrs.y;
var rx = attrs.rx;
var ry = attrs.ry;
var lineWidth = this.getHitLineWidth();
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
var p = [x, y, 1];
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
Util.mat3.scale(m, m, [scaleX, scaleY]);
Util.mat3.translate(m, m, [cx, cy]);
var inm = Util.mat3.invert([], m);
Util.vec3.transformMat3(p, p, inm);
if (fill && stroke) {
return Inside.circle(0, 0, r, p[0], p[1]) || Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
}
if (fill) {
return Inside.circle(0, 0, r, p[0], p[1]);
}
if (stroke) {
return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
}
return false;
};
var fan = function fan(x, y) {
var self = this;
var fill = self.hasFill();
var stroke = self.hasStroke();
var attrs = self._attrs;
var cx = attrs.x;
var cy = attrs.y;
var rs = attrs.rs;
var re = attrs.re;
var startAngle = attrs.startAngle;
var endAngle = attrs.endAngle;
var clockwise = attrs.clockwise;
var v1 = [1, 0];
var subv = [x - cx, y - cy];
var angle = Util.vec2.angleTo(v1, subv);
function _isPointInFill() {
var angle1 = mathUtl.arc.nearAngle(angle, startAngle, endAngle, clockwise);
if (Util.isNumberEqual(angle, angle1)) {
var ls = Util.vec2.squaredLength(subv);
if (rs * rs <= ls && ls <= re * re) {
return true;
}
}
return false;
}
function _isPointInStroke() {
var lineWidth = self.getHitLineWidth();
var ssp = {
x: Math.cos(startAngle) * rs + cx,
y: Math.sin(startAngle) * rs + cy
};
var sep = {
x: Math.cos(startAngle) * re + cx,
y: Math.sin(startAngle) * re + cy
};
var esp = {
x: Math.cos(endAngle) * rs + cx,
y: Math.sin(endAngle) * rs + cy
};
var eep = {
x: Math.cos(endAngle) * re + cx,
y: Math.sin(endAngle) * re + cy
};
if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) {
return true;
}
if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) {
return true;
}
if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) {
return true;
}
if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) {
return true;
}
return false;
}
if (fill && stroke) {
return _isPointInFill() || _isPointInStroke();
}
if (fill) {
return _isPointInFill();
}
if (stroke) {
return _isPointInStroke();
}
return false;
};
var image = function image(x, y) {
var attrs = this._attrs;
if (this.get('toDraw') || !attrs.img) {
return false;
}
if (!this._cfg.attrs || this._cfg.attrs.img !== attrs.img) {
this._setAttrImg();
}
var rx = attrs.x;
var ry = attrs.y;
var width = attrs.width;
var height = attrs.height;
return Inside.rect(rx, ry, width, height, x, y);
};
var line = function line(x, y) {
var attrs = this._attrs;
var x1 = attrs.x1,
y1 = attrs.y1,
x2 = attrs.x2,
y2 = attrs.y2;
var lineWidth = this.getHitLineWidth();
if (this.hasStroke()) {
return Inside.line(x1, y1, x2, y2, lineWidth, x, y);
}
return false;
};
var path = function path(x, y) {
var self = this;
var segments = self.get('segments');
var fill = self.hasFill();
var stroke = self.hasStroke();
function _isPointInStroke() {
if (!Util.isEmpty(segments)) {
var lineWidth = self.getHitLineWidth();
for (var i = 0, l = segments.length; i < l; i++) {
if (segments[i].isInside(x, y, lineWidth)) {
return true;
}
}
return false;
}
}
if (fill && stroke) {
return isPointInPathByContext(x, y, self) || _isPointInStroke();
}
if (fill) {
return isPointInPathByContext(x, y, self);
}
if (stroke) {
return _isPointInStroke();
}
return false;
};
var polygon = function polygon(x, y) {
var self = this;
var fill = self.hasFill();
var stroke = self.hasStroke();
function _isPointInStroke() {
var attrs = self._attrs;
var points = attrs.points;
if (points.length < 2) {
return false;
}
var lineWidth = self.getHitLineWidth();
var outPoints = points.slice(0);
if (points.length >= 3) {
outPoints.push(points[0]);
}
return Inside.polyline(outPoints, lineWidth, x, y);
}
if (fill && stroke) {
return isPointInPathByContext(x, y, self) || _isPointInStroke();
}
if (fill) {
return isPointInPathByContext(x, y, self);
}
if (stroke) {
return _isPointInStroke();
}
return false;
};
var marker = function marker(x, y) {
var attrs = this._attrs;
var cx = attrs.x;
var cy = attrs.y;
var r = attrs.radius || attrs.r;
var lineWidth = this.getHitLineWidth();
return Inside.circle(cx, cy, r + lineWidth / 2, x, y);
};
var polyline = function polyline(x, y) {
var self = this;
var attrs = self._attrs;
if (self.hasStroke()) {
var points = attrs.points;
if (points.length < 2) {
return false;
}
var lineWidth = attrs.lineWidth;
return Inside.polyline(points, lineWidth, x, y);
}
return false;
};
var rect = function rect(x, y) {
var self = this;
var fill = self.hasFill();
var stroke = self.hasStroke();
function _isPointInStroke() {
var attrs = self._attrs;
var rx = attrs.x;
var ry = attrs.y;
var width = attrs.width;
var height = attrs.height;
var radius = attrs.radius;
var lineWidth = self.getHitLineWidth();
if (radius === 0) {
var halfWidth = lineWidth / 2;
return Inside.line(rx - halfWidth, ry, rx + width + halfWidth, ry, lineWidth, x, y) || Inside.line(rx + width, ry - halfWidth, rx + width, ry + height + halfWidth, lineWidth, x, y) || Inside.line(rx + width + halfWidth, ry + height, rx - halfWidth, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height + halfWidth, rx, ry - halfWidth, lineWidth, x, y);
}
return Inside.line(rx + radius, ry, rx + width - radius, ry, lineWidth, x, y) || Inside.line(rx + width, ry + radius, rx + width, ry + height - radius, lineWidth, x, y) || Inside.line(rx + width - radius, ry + height, rx + radius, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height - radius, rx, ry + radius, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + radius, radius, 1.5 * Math.PI, 2 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + height - radius, radius, 0, 0.5 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + height - radius, radius, 0.5 * Math.PI, Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + radius, radius, Math.PI, 1.5 * Math.PI, false, lineWidth, x, y);
}
if (fill && stroke) {
return isPointInPathByContext(x, y, self) || _isPointInStroke();
}
if (fill) {
return isPointInPathByContext(x, y, self);
}
if (stroke) {
return _isPointInStroke();
}
return false;
};
var text = function text(x, y) {
var self = this;
var box = self.getBBox();
if (self.hasFill() || self.hasStroke()) {
return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);
}
};
var dom = function dom(x, y) {
if (!this._cfg.el) {
return false;
}
var box = this._cfg.el.getBBox();
return Inside.box(box.x, box.x + box.width, box.y, box.y + box.height, x, y);
};
var shapes = {
arc: arc,
circle: circle,
dom: dom,
ellipse: ellipse,
fan: fan,
image: image,
line: line,
path: path,
marker: marker,
polygon: polygon,
polyline: polyline,
rect: rect,
text: text
};
module.exports = {
isPointInPath: function isPointInPath(x, y) {
var shape = shapes[this.type];
if (shape) {
return shape.call(this, x, y);
}
return false;
}
};
/***/ }),
/* 316 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var PathUtil = __webpack_require__(71);
var d3Timer = __webpack_require__(96);
var d3Ease = __webpack_require__(193);
var _require = __webpack_require__(438),
interpolate = _require.interpolate,
interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算
var Timeline = function Timeline(canvas) {
// 待执行动画的队列
this._animators = []; // 当前时间
this._current = 0; // 计时器实例
this._timer = null; // 画布
this.canvas = canvas;
};
function _update(self, animator, ratio) {
var cProps = {}; // 此刻属性
var toAttrs = animator.toAttrs;
var fromAttrs = animator.fromAttrs;
var toMatrix = animator.toMatrix;
if (self.get('destroyed')) {
return;
}
var interf; // 差值函数
for (var k in toAttrs) {
if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {
if (k === 'path') {
var toPath = toAttrs[k];
var fromPath = fromAttrs[k];
if (toPath.length > fromPath.length) {
toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
fromPath = PathUtil.fillPathByDiff(fromPath, toPath);
fromPath = PathUtil.formatPath(fromPath, toPath);
animator.fromAttrs.path = fromPath;
animator.toAttrs.path = toPath;
} else if (!animator.pathFormatted) {
toPath = PathUtil.parsePathString(toAttrs[k]);
fromPath = PathUtil.parsePathString(fromAttrs[k]);
fromPath = PathUtil.formatPath(fromPath, toPath);
animator.fromAttrs.path = fromPath;
animator.toAttrs.path = toPath;
animator.pathFormatted = true;
}
cProps[k] = [];
for (var i = 0; i < toPath.length; i++) {
var toPathPoint = toPath[i];
var fromPathPoint = fromPath[i];
var cPathPoint = [];
for (var j = 0; j < toPathPoint.length; j++) {
if (Util.isNumber(toPathPoint[j]) && fromPathPoint && Util.isNumber(fromPathPoint[j])) {
interf = interpolate(fromPathPoint[j], toPathPoint[j]);
cPathPoint.push(interf(ratio));
} else {
cPathPoint.push(toPathPoint[j]);
}
}
cProps[k].push(cPathPoint);
}
} else {
interf = interpolate(fromAttrs[k], toAttrs[k]);
cProps[k] = interf(ratio);
}
}
}
if (toMatrix) {
var mf = interpolateArray(animator.fromMatrix, toMatrix);
var cM = mf(ratio);
self.setMatrix(cM);
}
self.attr(cProps);
}
function update(shape, animator, elapsed) {
var startTime = animator.startTime; // 如果还没有开始执行或暂停,先不更新
if (elapsed < startTime + animator.delay || animator.isPaused) {
return false;
}
var ratio;
var duration = animator.duration;
var easing = animator.easing; // 已执行时间
elapsed = elapsed - startTime - animator.delay;
if (animator.toAttrs.repeat) {
ratio = elapsed % duration / duration;
ratio = d3Ease[easing](ratio);
} else {
ratio = elapsed / duration;
if (ratio < 1) {
ratio = d3Ease[easing](ratio);
} else {
shape.attr(animator.toAttrs);
if (animator.toMatrix) {
shape.setMatrix(animator.toMatrix);
}
return true;
}
}
_update(shape, animator, ratio);
return false;
}
Util.augment(Timeline, {
initTimer: function initTimer() {
var _this = this;
var self = this;
var isFinished = false;
var shape, animators, animator;
self._timer = d3Timer.timer(function (elapsed) {
self._current = elapsed;
if (_this._animators.length > 0) {
for (var i = _this._animators.length - 1; i >= 0; i--) {
shape = _this._animators[i];
if (shape.get('destroyed')) {
// 如果已经被销毁,直接移出队列
self.removeAnimator(i);
continue;
}
if (!shape.get('pause').isPaused) {
animators = shape.get('animators');
for (var j = animators.length - 1; j >= 0; j--) {
animator = animators[j];
isFinished = update(shape, animator, elapsed);
if (isFinished) {
animators.splice(j, 1);
isFinished = false;
if (animator.callback) {
animator.callback();
}
}
}
}
if (animators.length === 0) {
self.removeAnimator(i);
}
}
_this.canvas.draw();
}
});
},
addAnimator: function addAnimator(shape) {
this._animators.push(shape);
},
removeAnimator: function removeAnimator(index) {
this._animators.splice(index, 1);
},
isAnimating: function isAnimating() {
return !!this._animators.length;
},
stop: function stop() {
if (this._timer) {
this._timer.stop();
}
},
stopAllAnimations: function stopAllAnimations() {
this._animators.forEach(function (animator) {
animator.stopAnimate();
});
this._animators = [];
this.canvas.draw();
},
getTime: function getTime() {
return this._current;
}
});
module.exports = Timeline;
/***/ }),
/* 317 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1); // 是否未改变
function isUnchanged(m) {
return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
} // 是否仅仅是scale
function isScale(m) {
return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
}
function multiple(m1, m2) {
if (!isUnchanged(m2)) {
if (isScale(m2)) {
m1[0] *= m2[0];
m1[4] *= m2[4];
} else {
Util.mat3.multiply(m1, m1, m2);
}
}
}
module.exports = {
initTransform: function initTransform() {},
resetMatrix: function resetMatrix() {
this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
},
translate: function translate(tx, ty) {
var matrix = this._attrs.matrix;
Util.mat3.translate(matrix, matrix, [tx, ty]);
this.clearTotalMatrix();
this.attr('matrix', matrix);
return this;
},
rotate: function rotate(radian) {
var matrix = this._attrs.matrix;
Util.mat3.rotate(matrix, matrix, radian);
this.clearTotalMatrix();
this.attr('matrix', matrix);
return this;
},
scale: function scale(s1, s2) {
var matrix = this._attrs.matrix;
Util.mat3.scale(matrix, matrix, [s1, s2]);
this.clearTotalMatrix();
this.attr('matrix', matrix);
return this;
},
rotateAtStart: function rotateAtStart(rotate) {
var x = this._attrs.x || this._cfg.attrs.x;
var y = this._attrs.y || this._cfg.attrs.y;
if (Math.abs(rotate) > Math.PI * 2) {
rotate = rotate / 180 * Math.PI;
}
return this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
},
move: function move(x, y) {
var cx = this.get('x') || 0; // 当前的x
var cy = this.get('y') || 0; // 当前的y
this.translate(x - cx, y - cy);
this.set('x', x);
this.set('y', y);
return this;
},
transform: function transform(ts) {
var self = this;
var matrix = this._attrs.matrix;
Util.each(ts, function (t) {
switch (t[0]) {
case 't':
self.translate(t[1], t[2]);
break;
case 's':
self.scale(t[1], t[2]);
break;
case 'r':
self.rotate(t[1]);
break;
case 'm':
self.attr('matrix', Util.mat3.multiply([], matrix, t[1]));
self.clearTotalMatrix();
break;
default:
break;
}
});
return self;
},
setTransform: function setTransform(ts) {
this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
return this.transform(ts);
},
getMatrix: function getMatrix() {
return this.attr('matrix');
},
setMatrix: function setMatrix(m) {
this.attr('matrix', m);
this.clearTotalMatrix();
return this;
},
apply: function apply(v, root) {
var m;
if (root) {
m = this._getMatrixByRoot(root);
} else {
m = this.attr('matrix');
}
Util.vec3.transformMat3(v, v, m);
return this;
},
// 获取到达指定根节点的矩阵
_getMatrixByRoot: function _getMatrixByRoot(root) {
var self = this;
root = root || self;
var parent = self;
var parents = [];
while (parent !== root) {
parents.unshift(parent);
parent = parent.get('parent');
}
parents.unshift(parent);
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
Util.each(parents, function (child) {
Util.mat3.multiply(m, child.attr('matrix'), m);
});
return m;
},
/**
* 应用到当前元素上的总的矩阵
* @return {Matrix} 矩阵
*/
getTotalMatrix: function getTotalMatrix() {
var m = this._cfg.totalMatrix;
if (!m) {
m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
var parent = this._cfg.parent;
if (parent) {
var pm = parent.getTotalMatrix();
multiple(m, pm);
}
multiple(m, this.attr('matrix'));
this._cfg.totalMatrix = m;
}
return m;
},
// 清除当前的矩阵
clearTotalMatrix: function clearTotalMatrix() {// this._cfg.totalMatrix = null;
},
invert: function invert(v) {
var m = this.getTotalMatrix(); // 单精屏幕下大多数矩阵没变化
if (isScale(m)) {
v[0] /= m[0];
v[1] /= m[4];
} else {
var inm = Util.mat3.invert([], m);
if (inm) {
Util.vec3.transformMat3(v, v, inm);
}
}
return this;
},
resetTransform: function resetTransform(context) {
var mo = this.attr('matrix'); // 不改变时
if (!isUnchanged(mo)) {
context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
}
}
};
/***/ }),
/* 318 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
painter: __webpack_require__(319)
};
/***/ }),
/* 319 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var renderUtil = __webpack_require__(320);
var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'lineDashOffset'];
var Painter =
/*#__PURE__*/
function () {
function Painter(dom) {
if (!dom) {
return null;
}
var canvasId = Util.uniqueId('canvas_');
var canvasDom = Util.createDom('');
dom.appendChild(canvasDom);
this.type = 'canvas';
this.canvas = canvasDom;
this.context = canvasDom.getContext('2d');
this.toDraw = false;
return this;
}
var _proto = Painter.prototype;
_proto.beforeDraw = function beforeDraw() {
var el = this.canvas;
this.context && this.context.clearRect(0, 0, el.width, el.height);
};
_proto.draw = function draw(model) {
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
self.beforeDraw();
try {
self._drawGroup(model);
} catch (ev) {
// 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
};
_proto.drawSync = function drawSync(model) {
this.beforeDraw();
this._drawGroup(model);
};
_proto._drawGroup = function _drawGroup(group) {
if (group._cfg.removed || group._cfg.destroyed || !group._cfg.visible) {
return;
}
var self = this;
var children = group._cfg.children;
var child = null;
this.setContext(group);
for (var i = 0; i < children.length; i++) {
child = children[i];
if (children[i].isGroup) {
self._drawGroup(child);
} else {
self._drawShape(child);
}
}
this.restoreContext(group);
};
_proto._drawShape = function _drawShape(shape) {
if (shape._cfg.removed || shape._cfg.destroyed || !shape._cfg.visible) {
return;
}
this.setContext(shape);
shape.drawInner(this.context);
this.restoreContext(shape);
shape._cfg.attrs = shape._attrs;
shape._cfg.hasUpdate = false;
};
_proto.setContext = function setContext(shape) {
var context = this.context;
var clip = shape._attrs.clip;
context.save();
if (clip) {
// context.save();
clip.resetTransform(context);
clip.createPath(context);
context.clip(); // context.restore();
}
this.resetContext(shape);
shape.resetTransform(context);
};
_proto.restoreContext = function restoreContext() {
this.context.restore();
};
_proto.resetContext = function resetContext(shape) {
var context = this.context;
var elAttrs = shape._attrs; // var canvas = this.get('canvas');
if (!shape.isGroup) {
for (var k in elAttrs) {
if (SHAPE_ATTRS.indexOf(k) > -1) {
// 非canvas属性不附加
var v = elAttrs[k];
if (k === 'fillStyle') {
v = renderUtil.parseStyle(v, shape, context);
}
if (k === 'strokeStyle') {
v = renderUtil.parseStyle(v, shape, context);
}
if (k === 'lineDash' && context.setLineDash) {
if (Util.isArray(v)) {
context.setLineDash(v);
} else if (Util.isString(v)) {
context.setLineDash(v.split(' '));
}
} else {
context[k] = v;
}
}
}
}
};
return Painter;
}();
module.exports = Painter;
/***/ }),
/* 320 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
var regexDot = /[^\s\,]+/ig;
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
var numColorCache = {};
function addStop(steps, gradient) {
var arr = steps.match(regexColorStop);
Util.each(arr, function (item) {
item = item.split(':');
gradient.addColorStop(item[0], item[1]);
});
}
function parseLineGradient(color, self, context) {
var arr = regexLG.exec(color);
var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
var steps = arr[2];
var box = self.getBBox();
var start;
var end;
if (angle >= 0 && angle < 0.5 * Math.PI) {
start = {
x: box.minX,
y: box.minY
};
end = {
x: box.maxX,
y: box.maxY
};
} else if (0.5 * Math.PI <= angle && angle < Math.PI) {
start = {
x: box.maxX,
y: box.minY
};
end = {
x: box.minX,
y: box.maxY
};
} else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
start = {
x: box.maxX,
y: box.maxY
};
end = {
x: box.minX,
y: box.minY
};
} else {
start = {
x: box.minX,
y: box.maxY
};
end = {
x: box.maxX,
y: box.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;
}
function parseRadialGradient(color, self, context) {
var arr = regexRG.exec(color);
var fx = parseFloat(arr[1]);
var fy = parseFloat(arr[2]);
var fr = parseFloat(arr[3]);
var steps = arr[4]; // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
if (fr === 0) {
var colors = steps.match(regexColorStop);
return colors[colors.length - 1].split(':')[1];
}
var box = self.getBBox();
var width = box.maxX - box.minX;
var height = box.maxY - box.minY;
var r = Math.sqrt(width * width + height * height) / 2;
var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r);
addStop(steps, gradient);
return gradient;
}
function parsePattern(color, self, context) {
if (self.get('patternSource') && self.get('patternSource') === color) {
return self.get('pattern');
}
var pattern;
var img;
var arr = regexPR.exec(color);
var repeat = arr[1];
var source = arr[2]; // Function to be called when pattern loads
function onload() {
// Create pattern
pattern = context.createPattern(img, repeat);
self.setSilent('pattern', pattern); // be a cache
self.setSilent('patternSource', color);
}
switch (repeat) {
case 'a':
repeat = 'repeat';
break;
case 'x':
repeat = 'repeat-x';
break;
case 'y':
repeat = 'repeat-y';
break;
case 'n':
repeat = 'no-repeat';
break;
default:
repeat = 'no-repeat';
}
img = new Image(); // If source URL is not a data URL
if (!source.match(/^data:/i)) {
// Set crossOrigin for this image
img.crossOrigin = 'Anonymous';
}
img.src = source;
if (img.complete) {
onload();
} else {
img.onload = onload; // Fix onload() bug in IE9
img.src = img.src;
}
return pattern;
}
module.exports = {
parsePath: function parsePath(path) {
path = path || [];
if (Util.isArray(path)) {
return path;
}
if (Util.isString(path)) {
path = path.match(regexTags);
Util.each(path, function (item, index) {
item = item.match(regexDot);
if (item[0].length > 1) {
var tag = item[0].charAt(0);
item.splice(1, 0, item[0].substr(1));
item[0] = tag;
}
Util.each(item, function (sub, i) {
if (!isNaN(sub)) {
item[i] = +sub;
}
});
path[index] = item;
});
return path;
}
},
parseStyle: function parseStyle(color, self, context) {
if (Util.isString(color)) {
if (color[1] === '(' || color[2] === '(') {
if (color[0] === 'l') {
// regexLG.test(color)
return parseLineGradient(color, self, context);
} else if (color[0] === 'r') {
// regexRG.test(color)
return parseRadialGradient(color, self, context);
} else if (color[0] === 'p') {
// regexPR.test(color)
return parsePattern(color, self, context);
}
}
return color;
}
},
numberToColor: function numberToColor(num) {
// 增加缓存
var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};
/***/ }),
/* 321 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
canvas: __webpack_require__(318),
svg: __webpack_require__(329)
};
/***/ }),
/* 322 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/9.
*/
var Util = __webpack_require__(1);
var Gradient = __webpack_require__(325);
var Shadow = __webpack_require__(327);
var Arrow = __webpack_require__(323);
var Clip = __webpack_require__(324);
var Pattern = __webpack_require__(326);
var Defs =
/*#__PURE__*/
function () {
function Defs(canvas) {
var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
var id = Util.uniqueId('defs_');
el.id = id;
canvas.appendChild(el);
this.children = [];
this.defaultArrow = {};
this.el = el;
this.canvas = canvas;
}
var _proto = Defs.prototype;
_proto.find = function find(type, attr) {
var children = this.children;
var result = null;
for (var i = 0; i < children.length; i++) {
if (children[i].match(type, attr)) {
result = children[i].id;
break;
}
}
return result;
};
_proto.findById = function findById(id) {
var children = this.children;
var flag = null;
for (var i = 0; i < children.length; i++) {
if (children[i].id === id) {
flag = children[i];
break;
}
}
return flag;
};
_proto.add = function add(item) {
this.children.push(item);
item.canvas = this.canvas;
item.parent = this;
};
_proto.getDefaultArrow = function getDefaultArrow(attrs, name) {
var stroke = attrs.stroke || attrs.strokeStyle;
if (this.defaultArrow[stroke]) {
return this.defaultArrow[stroke].id;
}
var arrow = new Arrow(attrs, name);
this.defaultArrow[stroke] = arrow;
this.el.appendChild(arrow.el);
return arrow.id;
};
_proto.addGradient = function addGradient(cfg) {
var gradient = new Gradient(cfg);
this.el.appendChild(gradient.el);
this.add(gradient);
return gradient.id;
};
_proto.addArrow = function addArrow(attrs, name) {
var arrow = new Arrow(attrs, name);
this.el.appendChild(arrow.el);
return arrow.id;
};
_proto.addShadow = function addShadow(cfg) {
var shadow = new Shadow(cfg);
this.el.appendChild(shadow.el);
this.add(shadow);
return shadow.id;
};
_proto.addPattern = function addPattern(cfg) {
var pattern = new Pattern(cfg);
this.el.appendChild(pattern.el);
this.add(pattern);
return pattern.id;
};
_proto.addClip = function addClip(cfg) {
var clip = new Clip(cfg);
this.el.appendChild(clip.el);
this.add(clip);
return clip.id;
};
return Defs;
}();
module.exports = Defs;
/***/ }),
/* 323 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/11.
*/
var Util = __webpack_require__(1);
var Arrow =
/*#__PURE__*/
function () {
function Arrow(attrs, type) {
var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
var id = Util.uniqueId('marker_');
el.setAttribute('id', id);
var shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
shape.setAttribute('stroke', 'none');
shape.setAttribute('fill', attrs.stroke || '#000');
el.appendChild(shape);
el.setAttribute('overflow', 'visible');
el.setAttribute('orient', 'auto-start-reverse');
this.el = el;
this.child = shape;
this.id = id;
this.cfg = attrs[type === 'marker-start' ? 'startArrow' : 'endArrow'];
this.stroke = attrs.stroke || '#000';
if (this.cfg === true) {
this._setDefaultPath(type, shape);
} else {
this._setMarker(attrs.lineWidth, shape);
}
return this;
}
var _proto = Arrow.prototype;
_proto.match = function match() {
return false;
};
_proto._setDefaultPath = function _setDefaultPath(type, el) {
var parent = this.el;
el.setAttribute('d', 'M0,0 L6,3 L0,6 L3,3Z');
parent.setAttribute('refX', 3);
parent.setAttribute('refY', 3);
};
_proto._setMarker = function _setMarker(r, el) {
var parent = this.el;
var path = this.cfg.path;
var d = this.cfg.d;
if (Util.isArray(path)) {
path = path.map(function (segment) {
return segment.join(' ');
}).join('');
}
el.setAttribute('d', path);
parent.appendChild(el);
if (d) {
parent.setAttribute('refX', d / r);
}
};
_proto.update = function update(fill) {
var child = this.child;
if (child.attr) {
child.attr('fill', fill);
} else {
child.setAttribute('fill', fill);
}
};
return Arrow;
}();
module.exports = Arrow;
/***/ }),
/* 324 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/14.
*/
var Util = __webpack_require__(1);
var Clip =
/*#__PURE__*/
function () {
function Clip(cfg) {
this.type = 'clip';
var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
this.el = el;
this.id = Util.uniqueId('clip_');
el.id = this.id;
var shapeEl = cfg._cfg.el; // just in case the clip shape is also a shape needs to be drawn
el.appendChild(shapeEl.cloneNode(true));
this.cfg = cfg;
return this;
}
var _proto = Clip.prototype;
_proto.match = function match() {
return false;
};
_proto.remove = function remove() {
var el = this.el;
el.parentNode.removeChild(el);
};
return Clip;
}();
module.exports = Clip;
/***/ }),
/* 325 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/9.
*/
var Util = __webpack_require__(1);
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
function addStop(steps) {
var arr = steps.match(regexColorStop);
if (!arr) {
return '';
}
var stops = '';
arr.sort(function (a, b) {
a = a.split(':');
b = b.split(':');
return Number(a[0]) - Number(b[0]);
});
Util.each(arr, function (item) {
item = item.split(':');
stops += "";
});
return stops;
}
function parseLineGradient(color, el) {
var arr = regexLG.exec(color);
var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
var steps = arr[2];
var start;
var end;
if (angle >= 0 && angle < 0.5 * Math.PI) {
start = {
x: 0,
y: 0
};
end = {
x: 1,
y: 1
};
} else if (0.5 * Math.PI <= angle && angle < Math.PI) {
start = {
x: 1,
y: 0
};
end = {
x: 0,
y: 1
};
} else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
start = {
x: 1,
y: 1
};
end = {
x: 0,
y: 0
};
} else {
start = {
x: 0,
y: 1
};
end = {
x: 1,
y: 0
};
}
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;
el.setAttribute('x1', start.x);
el.setAttribute('y1', start.y);
el.setAttribute('x2', x);
el.setAttribute('y2', y);
el.innerHTML = addStop(steps);
}
function parseRadialGradient(color, self) {
var arr = regexRG.exec(color);
var cx = parseFloat(arr[1]);
var cy = parseFloat(arr[2]);
var r = parseFloat(arr[3]);
var steps = arr[4];
self.setAttribute('cx', cx);
self.setAttribute('cy', cy);
self.setAttribute('r', r);
self.innerHTML = addStop(steps);
}
var Gradient =
/*#__PURE__*/
function () {
function Gradient(cfg) {
var el = null;
var id = Util.uniqueId('gradient_');
if (cfg.toLowerCase()[0] === 'l') {
el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
parseLineGradient(cfg, el);
} else {
el = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient');
parseRadialGradient(cfg, el);
}
el.setAttribute('id', id);
this.el = el;
this.id = id;
this.cfg = cfg;
return this;
}
var _proto = Gradient.prototype;
_proto.match = function match(type, attr) {
return this.cfg === attr;
};
return Gradient;
}();
module.exports = Gradient;
/***/ }),
/* 326 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/9.
*/
var Util = __webpack_require__(1);
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
var Pattern =
/*#__PURE__*/
function () {
function Pattern(cfg) {
var el = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');
el.setAttribute('patternUnits', 'userSpaceOnUse');
var child = document.createElementNS('http://www.w3.org/2000/svg', 'image');
el.appendChild(child);
var id = Util.uniqueId('pattern_');
el.id = id;
this.el = el;
this.id = id;
this.cfg = cfg;
var arr = regexPR.exec(cfg);
var source = arr[2];
child.setAttribute('href', source);
var img = new Image();
if (!source.match(/^data:/i)) {
img.crossOrigin = 'Anonymous';
}
img.src = source;
function onload() {
console.log(img.width, img.height);
el.setAttribute('width', img.width);
el.setAttribute('height', img.height);
}
if (img.complete) {
onload();
} else {
img.onload = onload; // Fix onload() bug in IE9
img.src = img.src;
}
return this;
}
var _proto = Pattern.prototype;
_proto.match = function match(type, attr) {
return this.cfg === attr;
};
return Pattern;
}();
module.exports = Pattern;
/***/ }),
/* 327 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Created by Elaine on 2018/5/10.
*/
var Util = __webpack_require__(1);
var ATTR_MAP = {
shadowColor: 'color',
shadowOpacity: 'opacity',
shadowBlur: 'blur',
shadowOffsetX: 'dx',
shadowOffsetY: 'dy'
};
var SHADOW_DIMENSION = {
x: '-40%',
y: '-40%',
width: '200%',
height: '200%'
};
var Shadow =
/*#__PURE__*/
function () {
function Shadow(cfg) {
this.type = 'filter';
var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter'); // expand the filter region to fill in shadows
Util.each(SHADOW_DIMENSION, function (v, k) {
el.setAttribute(k, v);
});
this.el = el;
this.id = Util.uniqueId('filter_');
this.el.id = this.id;
this.cfg = cfg;
this._parseShadow(cfg, el);
return this;
}
var _proto = Shadow.prototype;
_proto.match = function match(type, cfg) {
if (this.type !== type) {
return false;
}
var flag = true;
var config = this.cfg;
Util.each(Object.keys(config), function (attr) {
if (config[attr] !== cfg[attr]) {
flag = false;
return false;
}
});
return flag;
};
_proto.update = function update(name, value) {
var config = this.cfg;
config[ATTR_MAP[name]] = value;
this._parseShadow(config, this.el);
return this;
};
_proto._parseShadow = function _parseShadow(config, el) {
var child = "";
el.innerHTML = child;
};
return Shadow;
}();
module.exports = Shadow;
/***/ }),
/* 328 */
/***/ (function(module, exports) {
var TAG_MAP = {
svg: 'svg',
circle: 'circle',
rect: 'rect',
text: 'text',
path: 'path',
foreignObject: 'foreignObject',
polygon: 'polygon',
ellipse: 'ellipse',
image: 'image'
};
module.exports = function getShape(x, y, e) {
var target = e.target || e.srcElement;
if (!TAG_MAP[target.tagName]) {
var parent = target.parentNode;
while (parent && !TAG_MAP[parent.tagName]) {
parent = parent.parentNode;
}
target = parent;
}
if (this._cfg.el === target) {
return this;
}
return this.find(function (item) {
return item._cfg && item._cfg.el === target;
});
};
/***/ }),
/* 329 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
painter: __webpack_require__(330),
getShape: __webpack_require__(328)
};
/***/ }),
/* 330 */
/***/ (function(module, exports, __webpack_require__) {
var Util = __webpack_require__(1);
var _require = __webpack_require__(36),
parseRadius = _require.parseRadius;
var Marker = __webpack_require__(68);
var Defs = __webpack_require__(322);
var SHAPE_TO_TAGS = {
rect: 'path',
circle: 'circle',
line: 'line',
path: 'path',
marker: 'path',
text: 'text',
polygon: 'polygon',
image: 'image',
ellipse: 'ellipse',
dom: 'foreignObject',
fan: 'path',
group: 'g'
};
var LETTER_SPACING = 0.3;
var SVG_ATTR_MAP = {
opacity: 'opacity',
fillStyle: 'fill',
strokeOpacity: 'stroke-opacity',
fillOpacity: 'fill-opacity',
strokeStyle: 'stroke',
x: 'x',
y: 'y',
r: 'r',
width: 'width',
height: 'height',
x1: 'x1',
x2: 'x2',
y1: 'y1',
y2: 'y2',
lineCap: 'stroke-linecap',
lineJoin: 'stroke-linejoin',
lineWidth: 'stroke-width',
lineDash: 'stroke-dasharray',
lineDashOffset: 'stroke-dashoffset',
miterLimit: 'stroke-miterlimit',
font: 'font',
fontSize: 'font-size',
fontStyle: 'font-style',
fontVariant: 'font-variant',
fontWeight: 'font-weight',
fontFamily: 'font-family',
startArrow: 'marker-start',
endArrow: 'marker-end',
path: 'd',
class: 'class',
id: 'id',
style: 'style',
preserveAspectRatio: 'preserveAspectRatio'
};
var BASELINE_MAP = {
top: 'before-edge',
middle: 'central',
bottom: 'after-edge',
alphabetic: 'baseline',
hanging: 'hanging'
};
var ANCHOR_MAP = {
left: 'left',
start: 'left',
center: 'middle',
right: 'end',
end: 'end'
};
var Painter =
/*#__PURE__*/
function () {
function Painter(dom) {
if (!dom) {
return null;
}
var svgId = Util.uniqueId('canvas_');
var canvasDom = Util.createDom("");
dom.appendChild(canvasDom);
this.type = 'svg';
this.canvas = canvasDom;
this.context = new Defs(canvasDom);
this.toDraw = false;
return this;
}
var _proto = Painter.prototype;
_proto.draw = function draw(model) {
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
try {
model.resetMatrix();
self._drawGroup(model, false);
} catch (ev) {
// 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
};
_proto.drawSync = function drawSync(model) {
this._drawChildren(model, false);
};
_proto._drawGroup = function _drawGroup(model, redraw) {
var cfg = model._cfg;
if (cfg.removed || cfg.destroyed) {
return;
}
/**
* FIXME redraw: 为了使元素置顶的临时解决方案
* 如果直接将dom元素重排可以解决部分问题。但是如果重排后的group中有新增的shape,置顶效果就没有了
* 所以只能删除原有节点,新增节点以及所有子节点。这时候哪怕shape有el,也需要判断一下是否需要重绘
*/
if (!cfg.el && cfg.attrs) {
redraw = true;
}
if (cfg.tobeRemoved) {
Util.each(cfg.tobeRemoved, function (item) {
if (item.parentNode) {
item.parentNode.removeChild(item);
}
});
cfg.tobeRemoved = [];
}
this._drawShape(model, redraw);
if (cfg.children && cfg.children.length > 0) {
this._drawChildren(model, redraw);
}
};
_proto._drawChildren = function _drawChildren(parent, redraw) {
var self = this;
var children = parent._cfg.children;
var shape; // 防止在画children的时候,父group已经被destroy
if (!children) {
return;
}
if (parent._cfg.el && !redraw) {
// FIXME 这边是为了解决一个group中有元素已经生成el,还有一些没生成el时,没生成el的置底效果不work
var childLen = parent._cfg.el.childNodes.length + 1;
if (childLen !== 0 && childLen !== children.length) {
redraw = true;
}
}
for (var i = 0; i < children.length; i++) {
shape = children[i];
if (shape.isGroup) {
self._drawGroup(shape, redraw);
} else {
self._drawShape(shape, redraw);
}
}
};
_proto._drawShape = function _drawShape(model, redraw) {
var self = this;
var attrs = model._attrs;
var cfg = model._cfg;
var el = cfg.el; // 删除
if (cfg.removed || cfg.destroyed) {
if (el) {
el.parentNode.removeChild(cfg.el);
}
return;
} // 重绘节点
if (redraw && el) {
el.parentNode && el.parentNode.removeChild(el);
el = null;
} // 新增节点
if (!el && cfg.parent) {
self._createDom(model);
self._updateShape(model);
}
el = cfg.el;
if (cfg.visible === false) {
el.setAttribute('visibility', 'hidden');
return;
}
if (cfg.visible && el.hasAttribute('visibility')) {
el.removeAttribute('visibility');
} // 更新
if (cfg.hasUpdate) {
self._updateShape(model);
}
if (attrs.clip && attrs.clip._cfg.hasUpdate) {
self._updateShape(attrs.clip);
}
};
_proto._updateShape = function _updateShape(model) {
var self = this;
var attrs = model._attrs;
var formerAttrs = model._cfg.attrs;
if (!formerAttrs) {
return;
}
if (!model._cfg.el) {
self._createDom(model);
}
if ('clip' in attrs) {
this._setClip(model, attrs.clip);
}
if ('shadowOffsetX' in attrs || 'shadowOffsetY' in attrs || 'shadowBlur' in attrs || 'shadowColor' in attrs) {
this._setShadow(model);
}
if (model.type === 'text') {
self._updateText(model);
return;
}
if (model.type === 'fan') {
self._updateFan(model);
}
if (model.type === 'marker') {
model._cfg.el.setAttribute('d', self._assembleMarker(attrs));
}
if (model.type === 'rect') {
model._cfg.el.setAttribute('d', self._assembleRect(attrs));
}
for (var key in attrs) {
if (attrs[key] !== formerAttrs[key]) {
self._setAttribute(model, key, attrs[key]);
}
}
model._cfg.attrs = Util.deepMix({}, model._attrs);
model._cfg.hasUpdate = false;
};
_proto._setAttribute = function _setAttribute(model, name, value) {
var type = model.type;
var attrs = model._attrs;
var el = model._cfg.el;
var defs = this.context; // 计算marker路径
if ((type === 'marker' || type === 'rect') && ~['x', 'y', 'radius', 'r'].indexOf(name)) {
return;
} // 圆和椭圆不是x, y, 是cx, cy。 marker的x,y 用于计算marker的路径,不需要写到dom
if (~['circle', 'ellipse'].indexOf(type) && ~['x', 'y'].indexOf(name)) {
el.setAttribute('c' + name, parseInt(value, 10));
return;
} // 多边形
if (type === 'polygon' && name === 'points') {
if (!value || value.length === 0) {
value = '';
}
if (Util.isArray(value)) {
value = value.map(function (point) {
return point[0] + ',' + point[1];
});
value = value.join(' ');
}
el.setAttribute('points', value);
return;
} // 设置path
if (name === 'path' && Util.isArray(value)) {
el.setAttribute('d', this._formatPath(value));
return;
} // 设置图片
if (name === 'img') {
this._setImage(model, value);
return;
}
if (name === 'transform') {
if (!value) {
el.removeAttribute('transform');
return;
}
this._setTransform(model);
return;
}
if (name === 'rotate') {
if (!value) {
el.removeAttribute('transform');
return;
}
this._setTransform(model);
return;
}
if (name === 'matrix') {
this._setTransform(model);
return;
}
if (name === 'fillStyle' || name === 'strokeStyle') {
this._setColor(model, name, value);
return;
}
if (name === 'clip') {
return;
}
if (~name.indexOf('Arrow')) {
name = SVG_ATTR_MAP[name];
if (!value) {
model._cfg[name] = null;
el.removeAttribute(name);
} else {
var id = null;
if (typeof value === 'boolean') {
id = defs.getDefaultArrow(attrs, name);
} else {
id = defs.addArrow(attrs, name);
}
el.setAttribute(name, "url(#" + id + ")");
model._cfg[name] = id;
}
return;
} // foreignObject
if (name === 'html') {
if (typeof value === 'string') {
el.innerHTML = value;
} else {
el.innerHTML = '';
el.appendChild(value);
}
}
if (SVG_ATTR_MAP[name]) {
el.setAttribute(SVG_ATTR_MAP[name], value);
}
};
_proto._createDom = function _createDom(model) {
var type = SHAPE_TO_TAGS[model.type];
var attrs = model._attrs;
if (!type) {
throw new Error('the type' + model.type + 'is not supported by svg');
}
var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
model._cfg.el = shape;
if (model._cfg.parent) {
model._cfg.parent.get('el').appendChild(shape);
}
model._cfg.attrs = {};
if (model.type === 'text') {
shape.setAttribute('paint-order', 'stroke');
shape.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
} else {
if (!attrs.stroke && !attrs.strokeStyle) {
shape.setAttribute('stroke', 'none');
}
if (!attrs.fill && !attrs.fillStyle) {
shape.setAttribute('fill', 'none');
}
}
return shape;
};
_proto._assembleMarker = function _assembleMarker(attrs) {
var r = attrs.r;
if (typeof attrs.r === 'undefined') {
r = attrs.radius;
}
if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
return '';
}
var d = '';
if (typeof attrs.symbol === 'function') {
d = attrs.symbol(attrs.x, attrs.y, r);
} else {
d = Marker.Symbols[attrs.symbol || 'circle'](attrs.x, attrs.y, r);
}
if (Util.isArray(d)) {
d = d.map(function (path) {
return path.join(' ');
}).join('');
}
return d;
};
_proto._assembleRect = function _assembleRect(attrs) {
var x = attrs.x;
var y = attrs.y;
var w = attrs.width;
var h = attrs.height;
var radius = attrs.radius;
if (!radius) {
return "M " + x + "," + y + " l " + w + ",0 l 0," + h + " l" + -w + " 0 z";
}
var r = parseRadius(radius);
if (Util.isArray(radius)) {
if (radius.length === 1) {
r.r1 = r.r2 = r.r3 = r.r4 = radius[0];
} else if (radius.length === 2) {
r.r1 = r.r3 = radius[0];
r.r2 = r.r4 = radius[1];
} else if (radius.length === 3) {
r.r1 = radius[0];
r.r2 = r.r4 = radius[1];
r.r3 = radius[2];
} else {
r.r1 = radius[0];
r.r2 = radius[1];
r.r3 = radius[2];
r.r4 = radius[3];
}
} else {
r.r1 = r.r2 = r.r3 = r.r4 = radius;
}
var d = [["M " + (x + r.r1) + "," + y], ["l " + (w - r.r1 - r.r2) + ",0"], ["a " + r.r2 + "," + r.r2 + ",0,0,1," + r.r2 + "," + r.r2], ["l 0," + (h - r.r2 - r.r3)], ["a " + r.r3 + "," + r.r3 + ",0,0,1," + -r.r3 + "," + r.r3], ["l " + (r.r3 + r.r4 - w) + ",0"], ["a " + r.r4 + "," + r.r4 + ",0,0,1," + -r.r4 + "," + -r.r4], ["l 0," + (r.r4 + r.r1 - h)], ["a " + r.r1 + "," + r.r1 + ",0,0,1," + r.r1 + "," + -r.r1], ['z']];
return d.join(' ');
};
_proto._formatPath = function _formatPath(value) {
value = value.map(function (path) {
return path.join(' ');
}).join('');
if (~value.indexOf('NaN')) {
return '';
}
return value;
};
_proto._setTransform = function _setTransform(model) {
var matrix = model._attrs.matrix;
var el = model._cfg.el;
var transform = [];
for (var i = 0; i < 9; i += 3) {
transform.push(matrix[i] + ',' + matrix[i + 1]);
}
transform = transform.join(',');
if (transform.indexOf('NaN') === -1) {
el.setAttribute('transform', "matrix(" + transform + ")");
} else {
console.warn('invalid matrix:', matrix);
}
};
_proto._setImage = function _setImage(model, img) {
var attrs = model._attrs;
var el = model._cfg.el;
if (Util.isString(img)) {
el.setAttribute('href', img);
} else if (img instanceof Image) {
if (!attrs.width) {
el.setAttribute('width', img.width);
model._attrs.width = img.width;
}
if (!attrs.height) {
el.setAttribute('height', img.height);
model._attrs.height = img.height;
}
el.setAttribute('href', img.src);
} else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
el.setAttribute('href', img.toDataURL());
} else if (img instanceof ImageData) {
var canvas = document.createElement('canvas');
canvas.setAttribute('width', img.width);
canvas.setAttribute('height', img.height);
canvas.getContext('2d').putImageData(img, 0, 0);
if (!attrs.width) {
el.setAttribute('width', img.width);
model._attrs.width = img.width;
}
if (!attrs.height) {
el.setAttribute('height', img.height);
model._attrs.height = img.height;
}
el.setAttribute('href', canvas.toDataURL());
}
};
_proto._updateFan = function _updateFan(model) {
function getPoint(angle, radius, center) {
return {
x: radius * Math.cos(angle) + center.x,
y: radius * Math.sin(angle) + center.y
};
}
var attrs = model._attrs;
var cfg = model._cfg;
var center = {
x: attrs.x,
y: attrs.y
};
var d = [];
var startAngle = attrs.startAngle;
var endAngle = attrs.endAngle;
if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
endAngle -= 0.00001;
}
var outerStart = getPoint(startAngle, attrs.re, center);
var outerEnd = getPoint(endAngle, attrs.re, center);
var fa = endAngle > startAngle ? 1 : 0;
var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
var rs = attrs.rs;
var re = attrs.re;
var innerStart = getPoint(startAngle, attrs.rs, center);
var innerEnd = getPoint(endAngle, attrs.rs, center);
if (attrs.rs > 0) {
d.push("M " + outerEnd.x + "," + outerEnd.y);
d.push("L " + innerEnd.x + "," + innerEnd.y);
d.push("A " + rs + "," + rs + ",0," + fs + "," + (fa === 1 ? 0 : 1) + "," + innerStart.x + "," + innerStart.y);
d.push("L " + outerStart.x + " " + outerStart.y);
} else {
d.push("M " + center.x + "," + center.y);
d.push("L " + outerStart.x + "," + outerStart.y);
}
d.push("A " + re + "," + re + ",0," + fs + "," + fa + "," + outerEnd.x + "," + outerEnd.y);
if (attrs.rs > 0) {
d.push("L " + innerEnd.x + "," + innerEnd.y);
} else {
d.push('Z');
}
cfg.el.setAttribute('d', d.join(' '));
};
_proto._updateText = function _updateText(model) {
var self = this;
var attrs = model._attrs;
var formerAttrs = model._cfg.attrs;
var el = model._cfg.el;
this._setFont(model);
for (var attr in attrs) {
if (attrs[attr] !== formerAttrs[attr]) {
if (attr === 'text') {
self._setText(model, "" + attrs[attr]);
continue;
}
if (attr === 'fillStyle' || attr === 'strokeStyle') {
this._setColor(model, attr, attrs[attr]);
continue;
}
if (attr === 'matrix') {
this._setTransform(model);
continue;
}
if (SVG_ATTR_MAP[attr]) {
el.setAttribute(SVG_ATTR_MAP[attr], attrs[attr]);
}
}
}
model._cfg.attrs = Object.assign({}, model._attrs);
model._cfg.hasUpdate = false;
};
_proto._setFont = function _setFont(model) {
var el = model.get('el');
var attrs = model._attrs;
var fontSize = attrs.fontSize;
el.setAttribute('alignment-baseline', BASELINE_MAP[attrs.textBaseline] || 'baseline');
el.setAttribute('text-anchor', ANCHOR_MAP[attrs.textAlign] || 'left');
if (fontSize && +fontSize < 12) {
// 小于 12 像素的文本进行 scale 处理
attrs.matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];
model.transform([['t', -attrs.x, -attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', attrs.x, attrs.y]]);
}
};
_proto._setText = function _setText(model, text) {
var el = model._cfg.el;
var baseline = model._attrs.textBaseline || 'bottom';
if (!text) {
el.innerHTML = '';
} else if (~text.indexOf('\n')) {
var x = model._attrs.x;
var textArr = text.split('\n');
var textLen = textArr.length - 1;
var arr = '';
Util.each(textArr, function (segment, i) {
if (i === 0) {
if (baseline === 'alphabetic') {
arr += "" + segment + "";
} else if (baseline === 'top') {
arr += "" + segment + "";
} else if (baseline === 'middle') {
arr += "" + segment + "";
} else if (baseline === 'bottom') {
arr += "" + segment + "";
} else if (baseline === 'hanging') {
arr += "" + segment + "";
}
} else {
arr += "" + segment + "";
}
});
el.innerHTML = arr;
} else {
el.innerHTML = text;
}
};
_proto._setClip = function _setClip(model, value) {
var el = model._cfg.el;
if (!value) {
el.removeAttribute('clip-path');
return;
}
if (!el.hasAttribute('clip-path')) {
this._createDom(value);
this._updateShape(value);
var id = this.context.addClip(value);
el.setAttribute('clip-path', "url(#" + id + ")");
} else if (value._cfg.hasUpdate) {
this._updateShape(value);
}
};
_proto._setColor = function _setColor(model, name, value) {
var el = model._cfg.el;
var defs = this.context;
if (!value) {
el.setAttribute(SVG_ATTR_MAP[name], 'none');
return;
}
value = value.trim();
if (/^[r,R,L,l]{1}[\s]*\(/.test(value)) {
var id = defs.find('gradient', value);
if (!id) {
id = defs.addGradient(value);
}
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + id + ")");
} else if (/^[p,P]{1}[\s]*\(/.test(value)) {
var _id = defs.find('pattern', value);
if (!_id) {
_id = defs.addPattern(value);
}
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + _id + ")");
} else {
el.setAttribute(SVG_ATTR_MAP[name], value);
}
};
_proto._setShadow = function _setShadow(model) {
var el = model._cfg.el;
var attrs = model._attrs;
var cfg = {
dx: attrs.shadowOffsetX,
dy: attrs.shadowOffsetY,
blur: attrs.shadowBlur,
color: attrs.shadowColor
};
if (!cfg.dx && !cfg.dy && !cfg.blur && !cfg.color) {
el.removeAttribute('filter');
} else {
var id = this.context.find('filter', cfg);
if (!id) {
id = this.context.addShadow(cfg, this);
}
el.setAttribute('filter', "url(#" + id + ")");
}
};
return Painter;
}();
module.exports = Painter;
/***/ }),
/* 331 */
/***/ (function(module, exports, __webpack_require__) {
var Shape = __webpack_require__(7);
Shape.Arc = __webpack_require__(129);
Shape.Circle = __webpack_require__(130);
Shape.Dom = __webpack_require__(131);
Shape.Ellipse = __webpack_require__(132);
Shape.Fan = __webpack_require__(133);
Shape.Image = __webpack_require__(134);
Shape.Line = __webpack_require__(135);
Shape.Marker = __webpack_require__(68);
Shape.Path = __webpack_require__(138);
Shape.Polygon = __webpack_require__(139);
Shape.Polyline = __webpack_require__(140);
Shape.Rect = __webpack_require__(141);
Shape.Text = __webpack_require__(142);
module.exports = Shape;
/***/ }),
/* 332 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sub = exports.mul = undefined;
exports.create = create;
exports.fromMat4 = fromMat4;
exports.clone = clone;
exports.copy = copy;
exports.fromValues = fromValues;
exports.set = set;
exports.identity = identity;
exports.transpose = transpose;
exports.invert = invert;
exports.adjoint = adjoint;
exports.determinant = determinant;
exports.multiply = multiply;
exports.translate = translate;
exports.rotate = rotate;
exports.scale = scale;
exports.fromTranslation = fromTranslation;
exports.fromRotation = fromRotation;
exports.fromScaling = fromScaling;
exports.fromMat2d = fromMat2d;
exports.fromQuat = fromQuat;
exports.normalFromMat4 = normalFromMat4;
exports.projection = projection;
exports.str = str;
exports.frob = frob;
exports.add = add;
exports.subtract = subtract;
exports.multiplyScalar = multiplyScalar;
exports.multiplyScalarAndAdd = multiplyScalarAndAdd;
exports.exactEquals = exactEquals;
exports.equals = equals;
var _common = __webpack_require__(72);
var glMatrix = _interopRequireWildcard(_common);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/**
* 3x3 Matrix
* @module mat3
*/
/**
* Creates a new identity mat3
*
* @returns {mat3} a new 3x3 matrix
*/
function create() {
var out = new glMatrix.ARRAY_TYPE(9);
if (glMatrix.ARRAY_TYPE != Float32Array) {
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[5] = 0;
out[6] = 0;
out[7] = 0;
}
out[0] = 1;
out[4] = 1;
out[8] = 1;
return out;
}
/**
* Copies the upper-left 3x3 values into the given mat3.
*
* @param {mat3} out the receiving 3x3 matrix
* @param {mat4} a the source 4x4 matrix
* @returns {mat3} out
*/
function fromMat4(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[4];
out[4] = a[5];
out[5] = a[6];
out[6] = a[8];
out[7] = a[9];
out[8] = a[10];
return out;
}
/**
* Creates a new mat3 initialized with values from an existing matrix
*
* @param {mat3} a matrix to clone
* @returns {mat3} a new 3x3 matrix
*/
function clone(a) {
var out = new glMatrix.ARRAY_TYPE(9);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Copy the values from one mat3 to another
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Create a new mat3 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} A new mat3
*/
function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
var out = new glMatrix.ARRAY_TYPE(9);
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m10;
out[4] = m11;
out[5] = m12;
out[6] = m20;
out[7] = m21;
out[8] = m22;
return out;
}
/**
* Set the components of a mat3 to the given values
*
* @param {mat3} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} out
*/
function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m10;
out[4] = m11;
out[5] = m12;
out[6] = m20;
out[7] = m21;
out[8] = m22;
return out;
}
/**
* Set a mat3 to the identity matrix
*
* @param {mat3} out the receiving matrix
* @returns {mat3} out
*/
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 1;
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Transpose the values of a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function transpose(out, a) {
// If we are transposing ourselves we can skip a few steps but have to cache some values
if (out === a) {
var a01 = a[1],
a02 = a[2],
a12 = a[5];
out[1] = a[3];
out[2] = a[6];
out[3] = a01;
out[5] = a[7];
out[6] = a02;
out[7] = a12;
} else {
out[0] = a[0];
out[1] = a[3];
out[2] = a[6];
out[3] = a[1];
out[4] = a[4];
out[5] = a[7];
out[6] = a[2];
out[7] = a[5];
out[8] = a[8];
}
return out;
}
/**
* Inverts a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function invert(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
var b01 = a22 * a11 - a12 * a21;
var b11 = -a22 * a10 + a12 * a20;
var b21 = a21 * a10 - a11 * a20;
// Calculate the determinant
var det = a00 * b01 + a01 * b11 + a02 * b21;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = b01 * det;
out[1] = (-a22 * a01 + a02 * a21) * det;
out[2] = (a12 * a01 - a02 * a11) * det;
out[3] = b11 * det;
out[4] = (a22 * a00 - a02 * a20) * det;
out[5] = (-a12 * a00 + a02 * a10) * det;
out[6] = b21 * det;
out[7] = (-a21 * a00 + a01 * a20) * det;
out[8] = (a11 * a00 - a01 * a10) * det;
return out;
}
/**
* Calculates the adjugate of a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function adjoint(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
out[0] = a11 * a22 - a12 * a21;
out[1] = a02 * a21 - a01 * a22;
out[2] = a01 * a12 - a02 * a11;
out[3] = a12 * a20 - a10 * a22;
out[4] = a00 * a22 - a02 * a20;
out[5] = a02 * a10 - a00 * a12;
out[6] = a10 * a21 - a11 * a20;
out[7] = a01 * a20 - a00 * a21;
out[8] = a00 * a11 - a01 * a10;
return out;
}
/**
* Calculates the determinant of a mat3
*
* @param {mat3} a the source matrix
* @returns {Number} determinant of a
*/
function determinant(a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
}
/**
* Multiplies two mat3's
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function multiply(out, a, b) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
var b00 = b[0],
b01 = b[1],
b02 = b[2];
var b10 = b[3],
b11 = b[4],
b12 = b[5];
var b20 = b[6],
b21 = b[7],
b22 = b[8];
out[0] = b00 * a00 + b01 * a10 + b02 * a20;
out[1] = b00 * a01 + b01 * a11 + b02 * a21;
out[2] = b00 * a02 + b01 * a12 + b02 * a22;
out[3] = b10 * a00 + b11 * a10 + b12 * a20;
out[4] = b10 * a01 + b11 * a11 + b12 * a21;
out[5] = b10 * a02 + b11 * a12 + b12 * a22;
out[6] = b20 * a00 + b21 * a10 + b22 * a20;
out[7] = b20 * a01 + b21 * a11 + b22 * a21;
out[8] = b20 * a02 + b21 * a12 + b22 * a22;
return out;
}
/**
* Translate a mat3 by the given vector
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to translate
* @param {vec2} v vector to translate by
* @returns {mat3} out
*/
function translate(out, a, v) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a10 = a[3],
a11 = a[4],
a12 = a[5],
a20 = a[6],
a21 = a[7],
a22 = a[8],
x = v[0],
y = v[1];
out[0] = a00;
out[1] = a01;
out[2] = a02;
out[3] = a10;
out[4] = a11;
out[5] = a12;
out[6] = x * a00 + y * a10 + a20;
out[7] = x * a01 + y * a11 + a21;
out[8] = x * a02 + y * a12 + a22;
return out;
}
/**
* Rotates a mat3 by the given angle
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
function rotate(out, a, rad) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a10 = a[3],
a11 = a[4],
a12 = a[5],
a20 = a[6],
a21 = a[7],
a22 = a[8],
s = Math.sin(rad),
c = Math.cos(rad);
out[0] = c * a00 + s * a10;
out[1] = c * a01 + s * a11;
out[2] = c * a02 + s * a12;
out[3] = c * a10 - s * a00;
out[4] = c * a11 - s * a01;
out[5] = c * a12 - s * a02;
out[6] = a20;
out[7] = a21;
out[8] = a22;
return out;
};
/**
* Scales the mat3 by the dimensions in the given vec2
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to rotate
* @param {vec2} v the vec2 to scale the matrix by
* @returns {mat3} out
**/
function scale(out, a, v) {
var x = v[0],
y = v[1];
out[0] = x * a[0];
out[1] = x * a[1];
out[2] = x * a[2];
out[3] = y * a[3];
out[4] = y * a[4];
out[5] = y * a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.translate(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {vec2} v Translation vector
* @returns {mat3} out
*/
function fromTranslation(out, v) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 1;
out[5] = 0;
out[6] = v[0];
out[7] = v[1];
out[8] = 1;
return out;
}
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.rotate(dest, dest, rad);
*
* @param {mat3} out mat3 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
function fromRotation(out, rad) {
var s = Math.sin(rad),
c = Math.cos(rad);
out[0] = c;
out[1] = s;
out[2] = 0;
out[3] = -s;
out[4] = c;
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.scale(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {vec2} v Scaling vector
* @returns {mat3} out
*/
function fromScaling(out, v) {
out[0] = v[0];
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = v[1];
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Copies the values from a mat2d into a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat2d} a the matrix to copy
* @returns {mat3} out
**/
function fromMat2d(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = 0;
out[3] = a[2];
out[4] = a[3];
out[5] = 0;
out[6] = a[4];
out[7] = a[5];
out[8] = 1;
return out;
}
/**
* Calculates a 3x3 matrix from the given quaternion
*
* @param {mat3} out mat3 receiving operation result
* @param {quat} q Quaternion to create matrix from
*
* @returns {mat3} out
*/
function fromQuat(out, q) {
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var yx = y * x2;
var yy = y * y2;
var zx = z * x2;
var zy = z * y2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
out[0] = 1 - yy - zz;
out[3] = yx - wz;
out[6] = zx + wy;
out[1] = yx + wz;
out[4] = 1 - xx - zz;
out[7] = zy - wx;
out[2] = zx - wy;
out[5] = zy + wx;
out[8] = 1 - xx - yy;
return out;
}
/**
* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
*
* @param {mat3} out mat3 receiving operation result
* @param {mat4} a Mat4 to derive the normal matrix from
*
* @returns {mat3} out
*/
function normalFromMat4(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
var b00 = a00 * a11 - a01 * a10;
var b01 = a00 * a12 - a02 * a10;
var b02 = a00 * a13 - a03 * a10;
var b03 = a01 * a12 - a02 * a11;
var b04 = a01 * a13 - a03 * a11;
var b05 = a02 * a13 - a03 * a12;
var b06 = a20 * a31 - a21 * a30;
var b07 = a20 * a32 - a22 * a30;
var b08 = a20 * a33 - a23 * a30;
var b09 = a21 * a32 - a22 * a31;
var b10 = a21 * a33 - a23 * a31;
var b11 = a22 * a33 - a23 * a32;
// Calculate the determinant
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
return out;
}
/**
* Generates a 2D projection matrix with the given bounds
*
* @param {mat3} out mat3 frustum matrix will be written into
* @param {number} width Width of your gl context
* @param {number} height Height of gl context
* @returns {mat3} out
*/
function projection(out, width, height) {
out[0] = 2 / width;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = -2 / height;
out[5] = 0;
out[6] = -1;
out[7] = 1;
out[8] = 1;
return out;
}
/**
* Returns a string representation of a mat3
*
* @param {mat3} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
function str(a) {
return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
}
/**
* Returns Frobenius norm of a mat3
*
* @param {mat3} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
function frob(a) {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
}
/**
* Adds two mat3's
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
out[4] = a[4] + b[4];
out[5] = a[5] + b[5];
out[6] = a[6] + b[6];
out[7] = a[7] + b[7];
out[8] = a[8] + b[8];
return out;
}
/**
* Subtracts matrix b from matrix a
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
out[4] = a[4] - b[4];
out[5] = a[5] - b[5];
out[6] = a[6] - b[6];
out[7] = a[7] - b[7];
out[8] = a[8] - b[8];
return out;
}
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat3} out
*/
function multiplyScalar(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
out[4] = a[4] * b;
out[5] = a[5] * b;
out[6] = a[6] * b;
out[7] = a[7] * b;
out[8] = a[8] * b;
return out;
}
/**
* Adds two mat3's after multiplying each element of the second operand by a scalar value.
*
* @param {mat3} out the receiving vector
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat3} out
*/
function multiplyScalarAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
out[4] = a[4] + b[4] * scale;
out[5] = a[5] + b[5] * scale;
out[6] = a[6] + b[6] * scale;
out[7] = a[7] + b[7] * scale;
out[8] = a[8] + b[8] * scale;
return out;
}
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {mat3} a The first matrix.
* @param {mat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
}
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {mat3} a The first matrix.
* @param {mat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5],
a6 = a[6],
a7 = a[7],
a8 = a[8];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3],
b4 = b[4],
b5 = b[5],
b6 = b[6],
b7 = b[7],
b8 = b[8];
return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
}
/**
* Alias for {@link mat3.multiply}
* @function
*/
var mul = exports.mul = multiply;
/**
* Alias for {@link mat3.subtract}
* @function
*/
var sub = exports.sub = subtract;
/***/ }),
/* 333 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.forEach = exports.sqrLen = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = exports.len = undefined;
exports.create = create;
exports.clone = clone;
exports.fromValues = fromValues;
exports.copy = copy;
exports.set = set;
exports.add = add;
exports.subtract = subtract;
exports.multiply = multiply;
exports.divide = divide;
exports.ceil = ceil;
exports.floor = floor;
exports.min = min;
exports.max = max;
exports.round = round;
exports.scale = scale;
exports.scaleAndAdd = scaleAndAdd;
exports.distance = distance;
exports.squaredDistance = squaredDistance;
exports.length = length;
exports.squaredLength = squaredLength;
exports.negate = negate;
exports.inverse = inverse;
exports.normalize = normalize;
exports.dot = dot;
exports.cross = cross;
exports.lerp = lerp;
exports.random = random;
exports.transformMat2 = transformMat2;
exports.transformMat2d = transformMat2d;
exports.transformMat3 = transformMat3;
exports.transformMat4 = transformMat4;
exports.rotate = rotate;
exports.angle = angle;
exports.str = str;
exports.exactEquals = exactEquals;
exports.equals = equals;
var _common = __webpack_require__(72);
var glMatrix = _interopRequireWildcard(_common);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/**
* 2 Dimensional Vector
* @module vec2
*/
/**
* Creates a new, empty vec2
*
* @returns {vec2} a new 2D vector
*/
function create() {
var out = new glMatrix.ARRAY_TYPE(2);
if (glMatrix.ARRAY_TYPE != Float32Array) {
out[0] = 0;
out[1] = 0;
}
return out;
}
/**
* Creates a new vec2 initialized with values from an existing vector
*
* @param {vec2} a vector to clone
* @returns {vec2} a new 2D vector
*/
function clone(a) {
var out = new glMatrix.ARRAY_TYPE(2);
out[0] = a[0];
out[1] = a[1];
return out;
}
/**
* Creates a new vec2 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @returns {vec2} a new 2D vector
*/
function fromValues(x, y) {
var out = new glMatrix.ARRAY_TYPE(2);
out[0] = x;
out[1] = y;
return out;
}
/**
* Copy the values from one vec2 to another
*
* @param {vec2} out the receiving vector
* @param {vec2} a the source vector
* @returns {vec2} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
return out;
}
/**
* Set the components of a vec2 to the given values
*
* @param {vec2} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @returns {vec2} out
*/
function set(out, x, y) {
out[0] = x;
out[1] = y;
return out;
}
/**
* Adds two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
return out;
}
/**
* Subtracts vector b from vector a
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
return out;
}
/**
* Multiplies two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function multiply(out, a, b) {
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
return out;
}
/**
* Divides two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function divide(out, a, b) {
out[0] = a[0] / b[0];
out[1] = a[1] / b[1];
return out;
}
/**
* Math.ceil the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to ceil
* @returns {vec2} out
*/
function ceil(out, a) {
out[0] = Math.ceil(a[0]);
out[1] = Math.ceil(a[1]);
return out;
}
/**
* Math.floor the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to floor
* @returns {vec2} out
*/
function floor(out, a) {
out[0] = Math.floor(a[0]);
out[1] = Math.floor(a[1]);
return out;
}
/**
* Returns the minimum of two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function min(out, a, b) {
out[0] = Math.min(a[0], b[0]);
out[1] = Math.min(a[1], b[1]);
return out;
}
/**
* Returns the maximum of two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function max(out, a, b) {
out[0] = Math.max(a[0], b[0]);
out[1] = Math.max(a[1], b[1]);
return out;
}
/**
* Math.round the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to round
* @returns {vec2} out
*/
function round(out, a) {
out[0] = Math.round(a[0]);
out[1] = Math.round(a[1]);
return out;
}
/**
* Scales a vec2 by a scalar number
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec2} out
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
return out;
}
/**
* Adds two vec2's after scaling the second operand by a scalar value
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec2} out
*/
function scaleAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
return out;
}
/**
* Calculates the euclidian distance between two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} distance between a and b
*/
function distance(a, b) {
var x = b[0] - a[0],
y = b[1] - a[1];
return Math.sqrt(x * x + y * y);
}
/**
* Calculates the squared euclidian distance between two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} squared distance between a and b
*/
function squaredDistance(a, b) {
var x = b[0] - a[0],
y = b[1] - a[1];
return x * x + y * y;
}
/**
* Calculates the length of a vec2
*
* @param {vec2} a vector to calculate length of
* @returns {Number} length of a
*/
function length(a) {
var x = a[0],
y = a[1];
return Math.sqrt(x * x + y * y);
}
/**
* Calculates the squared length of a vec2
*
* @param {vec2} a vector to calculate squared length of
* @returns {Number} squared length of a
*/
function squaredLength(a) {
var x = a[0],
y = a[1];
return x * x + y * y;
}
/**
* Negates the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to negate
* @returns {vec2} out
*/
function negate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
return out;
}
/**
* Returns the inverse of the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to invert
* @returns {vec2} out
*/
function inverse(out, a) {
out[0] = 1.0 / a[0];
out[1] = 1.0 / a[1];
return out;
}
/**
* Normalize a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to normalize
* @returns {vec2} out
*/
function normalize(out, a) {
var x = a[0],
y = a[1];
var len = x * x + y * y;
if (len > 0) {
//TODO: evaluate use of glm_invsqrt here?
len = 1 / Math.sqrt(len);
out[0] = a[0] * len;
out[1] = a[1] * len;
}
return out;
}
/**
* Calculates the dot product of two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} dot product of a and b
*/
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
/**
* Computes the cross product of two vec2's
* Note that the cross product must by definition produce a 3D vector
*
* @param {vec3} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec3} out
*/
function cross(out, a, b) {
var z = a[0] * b[1] - a[1] * b[0];
out[0] = out[1] = 0;
out[2] = z;
return out;
}
/**
* Performs a linear interpolation between two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec2} out
*/
function lerp(out, a, b, t) {
var ax = a[0],
ay = a[1];
out[0] = ax + t * (b[0] - ax);
out[1] = ay + t * (b[1] - ay);
return out;
}
/**
* Generates a random vector with the given scale
*
* @param {vec2} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec2} out
*/
function random(out, scale) {
scale = scale || 1.0;
var r = glMatrix.RANDOM() * 2.0 * Math.PI;
out[0] = Math.cos(r) * scale;
out[1] = Math.sin(r) * scale;
return out;
}
/**
* Transforms the vec2 with a mat2
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat2} m matrix to transform with
* @returns {vec2} out
*/
function transformMat2(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[2] * y;
out[1] = m[1] * x + m[3] * y;
return out;
}
/**
* Transforms the vec2 with a mat2d
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat2d} m matrix to transform with
* @returns {vec2} out
*/
function transformMat2d(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[2] * y + m[4];
out[1] = m[1] * x + m[3] * y + m[5];
return out;
}
/**
* Transforms the vec2 with a mat3
* 3rd vector component is implicitly '1'
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat3} m matrix to transform with
* @returns {vec2} out
*/
function transformMat3(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[3] * y + m[6];
out[1] = m[1] * x + m[4] * y + m[7];
return out;
}
/**
* Transforms the vec2 with a mat4
* 3rd vector component is implicitly '0'
* 4th vector component is implicitly '1'
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec2} out
*/
function transformMat4(out, a, m) {
var x = a[0];
var y = a[1];
out[0] = m[0] * x + m[4] * y + m[12];
out[1] = m[1] * x + m[5] * y + m[13];
return out;
}
/**
* Rotate a 2D vector
* @param {vec2} out The receiving vec2
* @param {vec2} a The vec2 point to rotate
* @param {vec2} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec2} out
*/
function rotate(out, a, b, c) {
//Translate point to the origin
var p0 = a[0] - b[0],
p1 = a[1] - b[1],
sinC = Math.sin(c),
cosC = Math.cos(c);
//perform rotation and translate to correct position
out[0] = p0 * cosC - p1 * sinC + b[0];
out[1] = p0 * sinC + p1 * cosC + b[1];
return out;
}
/**
* Get the angle between two 2D vectors
* @param {vec2} a The first operand
* @param {vec2} b The second operand
* @returns {Number} The angle in radians
*/
function angle(a, b) {
var x1 = a[0],
y1 = a[1],
x2 = b[0],
y2 = b[1];
var len1 = x1 * x1 + y1 * y1;
if (len1 > 0) {
//TODO: evaluate use of glm_invsqrt here?
len1 = 1 / Math.sqrt(len1);
}
var len2 = x2 * x2 + y2 * y2;
if (len2 > 0) {
//TODO: evaluate use of glm_invsqrt here?
len2 = 1 / Math.sqrt(len2);
}
var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
if (cosine > 1.0) {
return 0;
} else if (cosine < -1.0) {
return Math.PI;
} else {
return Math.acos(cosine);
}
}
/**
* Returns a string representation of a vector
*
* @param {vec2} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'vec2(' + a[0] + ', ' + a[1] + ')';
}
/**
* Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
*
* @param {vec2} a The first vector.
* @param {vec2} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1];
}
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec2} a The first vector.
* @param {vec2} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1];
var b0 = b[0],
b1 = b[1];
return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));
}
/**
* Alias for {@link vec2.length}
* @function
*/
var len = exports.len = length;
/**
* Alias for {@link vec2.subtract}
* @function
*/
var sub = exports.sub = subtract;
/**
* Alias for {@link vec2.multiply}
* @function
*/
var mul = exports.mul = multiply;
/**
* Alias for {@link vec2.divide}
* @function
*/
var div = exports.div = divide;
/**
* Alias for {@link vec2.distance}
* @function
*/
var dist = exports.dist = distance;
/**
* Alias for {@link vec2.squaredDistance}
* @function
*/
var sqrDist = exports.sqrDist = squaredDistance;
/**
* Alias for {@link vec2.squaredLength}
* @function
*/
var sqrLen = exports.sqrLen = squaredLength;
/**
* Perform some operation over an array of vec2s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/
var forEach = exports.forEach = function () {
var vec = create();
return function (a, stride, offset, count, fn, arg) {
var i = void 0,
l = void 0;
if (!stride) {
stride = 2;
}
if (!offset) {
offset = 0;
}
if (count) {
l = Math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];vec[1] = a[i + 1];
fn(vec, vec, arg);
a[i] = vec[0];a[i + 1] = vec[1];
}
return a;
};
}();
/***/ }),
/* 334 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.forEach = exports.sqrLen = exports.len = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = undefined;
exports.create = create;
exports.clone = clone;
exports.length = length;
exports.fromValues = fromValues;
exports.copy = copy;
exports.set = set;
exports.add = add;
exports.subtract = subtract;
exports.multiply = multiply;
exports.divide = divide;
exports.ceil = ceil;
exports.floor = floor;
exports.min = min;
exports.max = max;
exports.round = round;
exports.scale = scale;
exports.scaleAndAdd = scaleAndAdd;
exports.distance = distance;
exports.squaredDistance = squaredDistance;
exports.squaredLength = squaredLength;
exports.negate = negate;
exports.inverse = inverse;
exports.normalize = normalize;
exports.dot = dot;
exports.cross = cross;
exports.lerp = lerp;
exports.hermite = hermite;
exports.bezier = bezier;
exports.random = random;
exports.transformMat4 = transformMat4;
exports.transformMat3 = transformMat3;
exports.transformQuat = transformQuat;
exports.rotateX = rotateX;
exports.rotateY = rotateY;
exports.rotateZ = rotateZ;
exports.angle = angle;
exports.str = str;
exports.exactEquals = exactEquals;
exports.equals = equals;
var _common = __webpack_require__(72);
var glMatrix = _interopRequireWildcard(_common);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/**
* 3 Dimensional Vector
* @module vec3
*/
/**
* Creates a new, empty vec3
*
* @returns {vec3} a new 3D vector
*/
function create() {
var out = new glMatrix.ARRAY_TYPE(3);
if (glMatrix.ARRAY_TYPE != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
}
return out;
}
/**
* Creates a new vec3 initialized with values from an existing vector
*
* @param {vec3} a vector to clone
* @returns {vec3} a new 3D vector
*/
function clone(a) {
var out = new glMatrix.ARRAY_TYPE(3);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
return out;
}
/**
* Calculates the length of a vec3
*
* @param {vec3} a vector to calculate length of
* @returns {Number} length of a
*/
function length(a) {
var x = a[0];
var y = a[1];
var z = a[2];
return Math.sqrt(x * x + y * y + z * z);
}
/**
* Creates a new vec3 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @returns {vec3} a new 3D vector
*/
function fromValues(x, y, z) {
var out = new glMatrix.ARRAY_TYPE(3);
out[0] = x;
out[1] = y;
out[2] = z;
return out;
}
/**
* Copy the values from one vec3 to another
*
* @param {vec3} out the receiving vector
* @param {vec3} a the source vector
* @returns {vec3} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
return out;
}
/**
* Set the components of a vec3 to the given values
*
* @param {vec3} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @returns {vec3} out
*/
function set(out, x, y, z) {
out[0] = x;
out[1] = y;
out[2] = z;
return out;
}
/**
* Adds two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
return out;
}
/**
* Subtracts vector b from vector a
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
return out;
}
/**
* Multiplies two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function multiply(out, a, b) {
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
out[2] = a[2] * b[2];
return out;
}
/**
* Divides two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function divide(out, a, b) {
out[0] = a[0] / b[0];
out[1] = a[1] / b[1];
out[2] = a[2] / b[2];
return out;
}
/**
* Math.ceil the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to ceil
* @returns {vec3} out
*/
function ceil(out, a) {
out[0] = Math.ceil(a[0]);
out[1] = Math.ceil(a[1]);
out[2] = Math.ceil(a[2]);
return out;
}
/**
* Math.floor the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to floor
* @returns {vec3} out
*/
function floor(out, a) {
out[0] = Math.floor(a[0]);
out[1] = Math.floor(a[1]);
out[2] = Math.floor(a[2]);
return out;
}
/**
* Returns the minimum of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function min(out, a, b) {
out[0] = Math.min(a[0], b[0]);
out[1] = Math.min(a[1], b[1]);
out[2] = Math.min(a[2], b[2]);
return out;
}
/**
* Returns the maximum of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function max(out, a, b) {
out[0] = Math.max(a[0], b[0]);
out[1] = Math.max(a[1], b[1]);
out[2] = Math.max(a[2], b[2]);
return out;
}
/**
* Math.round the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to round
* @returns {vec3} out
*/
function round(out, a) {
out[0] = Math.round(a[0]);
out[1] = Math.round(a[1]);
out[2] = Math.round(a[2]);
return out;
}
/**
* Scales a vec3 by a scalar number
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec3} out
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
return out;
}
/**
* Adds two vec3's after scaling the second operand by a scalar value
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec3} out
*/
function scaleAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
return out;
}
/**
* Calculates the euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} distance between a and b
*/
function distance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
return Math.sqrt(x * x + y * y + z * z);
}
/**
* Calculates the squared euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} squared distance between a and b
*/
function squaredDistance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
return x * x + y * y + z * z;
}
/**
* Calculates the squared length of a vec3
*
* @param {vec3} a vector to calculate squared length of
* @returns {Number} squared length of a
*/
function squaredLength(a) {
var x = a[0];
var y = a[1];
var z = a[2];
return x * x + y * y + z * z;
}
/**
* Negates the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to negate
* @returns {vec3} out
*/
function negate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
out[2] = -a[2];
return out;
}
/**
* Returns the inverse of the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to invert
* @returns {vec3} out
*/
function inverse(out, a) {
out[0] = 1.0 / a[0];
out[1] = 1.0 / a[1];
out[2] = 1.0 / a[2];
return out;
}
/**
* Normalize a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to normalize
* @returns {vec3} out
*/
function normalize(out, a) {
var x = a[0];
var y = a[1];
var z = a[2];
var len = x * x + y * y + z * z;
if (len > 0) {
//TODO: evaluate use of glm_invsqrt here?
len = 1 / Math.sqrt(len);
out[0] = a[0] * len;
out[1] = a[1] * len;
out[2] = a[2] * len;
}
return out;
}
/**
* Calculates the dot product of two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} dot product of a and b
*/
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
/**
* Computes the cross product of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function cross(out, a, b) {
var ax = a[0],
ay = a[1],
az = a[2];
var bx = b[0],
by = b[1],
bz = b[2];
out[0] = ay * bz - az * by;
out[1] = az * bx - ax * bz;
out[2] = ax * by - ay * bx;
return out;
}
/**
* Performs a linear interpolation between two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function lerp(out, a, b, t) {
var ax = a[0];
var ay = a[1];
var az = a[2];
out[0] = ax + t * (b[0] - ax);
out[1] = ay + t * (b[1] - ay);
out[2] = az + t * (b[2] - az);
return out;
}
/**
* Performs a hermite interpolation with two control points
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {vec3} c the third operand
* @param {vec3} d the fourth operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function hermite(out, a, b, c, d, t) {
var factorTimes2 = t * t;
var factor1 = factorTimes2 * (2 * t - 3) + 1;
var factor2 = factorTimes2 * (t - 2) + t;
var factor3 = factorTimes2 * (t - 1);
var factor4 = factorTimes2 * (3 - 2 * t);
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
return out;
}
/**
* Performs a bezier interpolation with two control points
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {vec3} c the third operand
* @param {vec3} d the fourth operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function bezier(out, a, b, c, d, t) {
var inverseFactor = 1 - t;
var inverseFactorTimesTwo = inverseFactor * inverseFactor;
var factorTimes2 = t * t;
var factor1 = inverseFactorTimesTwo * inverseFactor;
var factor2 = 3 * t * inverseFactorTimesTwo;
var factor3 = 3 * factorTimes2 * inverseFactor;
var factor4 = factorTimes2 * t;
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
return out;
}
/**
* Generates a random vector with the given scale
*
* @param {vec3} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec3} out
*/
function random(out, scale) {
scale = scale || 1.0;
var r = glMatrix.RANDOM() * 2.0 * Math.PI;
var z = glMatrix.RANDOM() * 2.0 - 1.0;
var zScale = Math.sqrt(1.0 - z * z) * scale;
out[0] = Math.cos(r) * zScale;
out[1] = Math.sin(r) * zScale;
out[2] = z * scale;
return out;
}
/**
* Transforms the vec3 with a mat4.
* 4th vector component is implicitly '1'
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec3} out
*/
function transformMat4(out, a, m) {
var x = a[0],
y = a[1],
z = a[2];
var w = m[3] * x + m[7] * y + m[11] * z + m[15];
w = w || 1.0;
out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
return out;
}
/**
* Transforms the vec3 with a mat3.
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat3} m the 3x3 matrix to transform with
* @returns {vec3} out
*/
function transformMat3(out, a, m) {
var x = a[0],
y = a[1],
z = a[2];
out[0] = x * m[0] + y * m[3] + z * m[6];
out[1] = x * m[1] + y * m[4] + z * m[7];
out[2] = x * m[2] + y * m[5] + z * m[8];
return out;
}
/**
* Transforms the vec3 with a quat
* Can also be used for dual quaternions. (Multiply it with the real part)
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {quat} q quaternion to transform with
* @returns {vec3} out
*/
function transformQuat(out, a, q) {
// benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
var qx = q[0],
qy = q[1],
qz = q[2],
qw = q[3];
var x = a[0],
y = a[1],
z = a[2];
// var qvec = [qx, qy, qz];
// var uv = vec3.cross([], qvec, a);
var uvx = qy * z - qz * y,
uvy = qz * x - qx * z,
uvz = qx * y - qy * x;
// var uuv = vec3.cross([], qvec, uv);
var uuvx = qy * uvz - qz * uvy,
uuvy = qz * uvx - qx * uvz,
uuvz = qx * uvy - qy * uvx;
// vec3.scale(uv, uv, 2 * w);
var w2 = qw * 2;
uvx *= w2;
uvy *= w2;
uvz *= w2;
// vec3.scale(uuv, uuv, 2);
uuvx *= 2;
uuvy *= 2;
uuvz *= 2;
// return vec3.add(out, a, vec3.add(out, uv, uuv));
out[0] = x + uvx + uuvx;
out[1] = y + uvy + uuvy;
out[2] = z + uvz + uuvz;
return out;
}
/**
* Rotate a 3D vector around the x-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateX(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[0];
r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Rotate a 3D vector around the y-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateY(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
r[1] = p[1];
r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Rotate a 3D vector around the z-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateZ(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
r[2] = p[2];
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Get the angle between two 3D vectors
* @param {vec3} a The first operand
* @param {vec3} b The second operand
* @returns {Number} The angle in radians
*/
function angle(a, b) {
var tempA = fromValues(a[0], a[1], a[2]);
var tempB = fromValues(b[0], b[1], b[2]);
normalize(tempA, tempA);
normalize(tempB, tempB);
var cosine = dot(tempA, tempB);
if (cosine > 1.0) {
return 0;
} else if (cosine < -1.0) {
return Math.PI;
} else {
return Math.acos(cosine);
}
}
/**
* Returns a string representation of a vector
*
* @param {vec3} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
}
/**
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
}
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2];
var b0 = b[0],
b1 = b[1],
b2 = b[2];
return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));
}
/**
* Alias for {@link vec3.subtract}
* @function
*/
var sub = exports.sub = subtract;
/**
* Alias for {@link vec3.multiply}
* @function
*/
var mul = exports.mul = multiply;
/**
* Alias for {@link vec3.divide}
* @function
*/
var div = exports.div = divide;
/**
* Alias for {@link vec3.distance}
* @function
*/
var dist = exports.dist = distance;
/**
* Alias for {@link vec3.squaredDistance}
* @function
*/
var sqrDist = exports.sqrDist = squaredDistance;
/**
* Alias for {@link vec3.length}
* @function
*/
var len = exports.len = length;
/**
* Alias for {@link vec3.squaredLength}
* @function
*/
var sqrLen = exports.sqrLen = squaredLength;
/**
* Perform some operation over an array of vec3s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/
var forEach = exports.forEach = function () {
var vec = create();
return function (a, stride, offset, count, fn, arg) {
var i = void 0,
l = void 0;
if (!stride) {
stride = 3;
}
if (!offset) {
offset = 0;
}
if (count) {
l = Math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
fn(vec, vec, arg);
a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
}
return a;
};
}();
/***/ }),
/* 335 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 自动计算数字坐标轴
* @author dxq613@gmail.com
*/
var isNil = __webpack_require__(6);
var isNumber = __webpack_require__(11);
var AutoUtil = __webpack_require__(145);
var MIN_COUNT = 5;
var MAX_COUNT = 7;
var SNAP_COUNT_ARRAY = [0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
module.exports = function (info) {
var min = info.min;
var max = info.max;
var interval = info.interval;
var minTickInterval = info.minTickInterval;
var ticks = [];
var minCount = info.minCount || MIN_COUNT;
var maxCount = info.maxCount || MAX_COUNT;
var isFixedCount = minCount === maxCount; // 是否限定死了个数
var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
var avgCount = (minCount + maxCount) / 2;
var count = avgCount; // 用户传入的逼近数组
var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
if (min === minLimit && max === maxLimit && isFixedCount) {
interval = (max - min) / (count - 1);
}
if (isNil(min)) {
min = 0;
}
if (isNil(max)) {
max = 0;
}
if (max === min) {
if (min === 0) {
max = 1;
} else {
if (min > 0) {
min = 0;
} else {
max = 0;
}
}
if (max - min < 5 && !interval && max - min >= 1) {
interval = 1;
}
}
if (isNil(interval)) {
// 计算间距
var temp = (max - min) / (avgCount - 1);
interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
if (maxCount !== minCount) {
count = parseInt((max - min) / interval, 10);
if (count > maxCount) {
count = maxCount;
}
if (count < minCount) {
count = minCount;
} // 不确定tick的个数时,使得tick偏小
interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
}
} // interval should not be less than minTickInterval
if (isNumber(minTickInterval) && interval < minTickInterval) {
interval = minTickInterval;
}
if (info.interval || maxCount !== minCount) {
// 校正 max 和 min
max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
count = Math.round((max - min) / interval);
min = AutoUtil.fixedBase(min, interval);
max = AutoUtil.fixedBase(max, interval);
} else {
avgCount = parseInt(avgCount, 10); // 取整
var avg = (max + min) / 2;
var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
var sideCount = Math.floor((avgCount - 2) / 2);
var maxTick = avgTick + sideCount * interval;
var minTick;
if (avgCount % 2 === 0) {
minTick = avgTick - sideCount * interval;
} else {
minTick = avgTick - (sideCount + 1) * interval;
}
while (maxTick < max) {
// 保证计算出来的刻度最大值 maxTick 不小于数据最大值 max
maxTick = AutoUtil.fixedBase(maxTick + interval, interval);
}
while (minTick > min) {
// 保证计算出来的刻度最小值 minTick 不小于数据最大值 min
minTick = AutoUtil.fixedBase(minTick - interval, interval); // 防止超常浮点数计算问题
}
max = maxTick;
min = minTick;
}
max = Math.min(max, maxLimit);
min = Math.max(min, minLimit);
ticks.push(min);
for (var i = 1; i < count; i++) {
var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
if (tickValue < max) {
ticks.push(tickValue);
}
}
if (ticks[ticks.length - 1] < max) {
ticks.push(max);
}
return {
min: min,
max: max,
interval: interval,
count: count,
ticks: ticks
};
};
/***/ }),
/* 336 */
/***/ (function(module, exports, __webpack_require__) {
/**
* @fileOverview 计算时间坐标轴
* @author dxq613@gmail.com
*/
var AutoUtil = __webpack_require__(145);
var isNil = __webpack_require__(6);
var MAX_COUNT = 6;
var SNAP_ARRAY = [1, 2, 4, 6, 8, 12];
var MINUTE_MS = 60 * 1000;
var HOUR_MS = 3600 * 1000;
var DAY_MS = 24 * 3600 * 1000;
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_MS);
}
function diffHour(min, max) {
return Math.ceil((max - min) / HOUR_MS);
}
function diffMinus(min, max) {
return Math.ceil((max - min) / (60 * 1000));
}
module.exports = function (info) {
var minInterval = info.minInterval;
var ticks = [];
var min = info.min;
var max = info.max;
var interval = info.interval;
var count; // 如果最大值和最小值相等,则设置最大值大于最小值一天
if (max === min) {
max = min + DAY_MS;
} // 计算间距
if (isNil(interval)) {
var innerTime = max - min;
var dms = DAY_MS; // 天代表的秒
var yms = 365 * dms; // 年代表的秒
interval = parseInt(innerTime / (info.maxCount || MAX_COUNT), 10);
if (minInterval && minInterval > interval) {
interval = minInterval;
}
var yfactor = interval / yms;
var minYear = getYear(min); // 大于半年
if (yfactor > 0.51) {
var year = Math.ceil(yfactor); // interval = year * yms;
var maxYear = getYear(max);
for (var i = minYear; i <= maxYear + year; i = i + year) {
ticks.push(createYear(i));
}
interval = null;
} else if (yfactor > 0.0834) {
// 大于一个月
var month = Math.ceil(yfactor / 0.0834);
var mmMoth = getMonth(min);
var dMonths = diffMonth(min, max);
for (var _i = 0; _i <= dMonths + month; _i = _i + month) {
ticks.push(creatMonth(minYear, _i + mmMoth));
}
interval = null;
} else if (interval > dms * 0.5) {
// 大于一天
var date = new Date(min);
var _year = date.getFullYear();
var _month = date.getMonth(min);
var mday = date.getDate();
var day = Math.ceil(interval / dms);
var ddays = diffDay(min, max);
interval = day * dms;
for (var _i2 = 0; _i2 < ddays + day; _i2 = _i2 + day) {
ticks.push(new Date(_year, _month, mday + _i2).getTime());
}
} else if (interval > HOUR_MS) {
// 大于一个小时
var _date = new Date(min);
var _year2 = _date.getFullYear();
var _month2 = _date.getMonth(min);
var _day = _date.getDate();
var hour = _date.getHours();
var hours = AutoUtil.snapTo(SNAP_ARRAY, Math.ceil(interval / HOUR_MS));
var dHours = diffHour(min, max);
interval = hours * HOUR_MS;
for (var _i3 = 0; _i3 <= dHours + hours; _i3 = _i3 + hours) {
ticks.push(new Date(_year2, _month2, _day, hour + _i3).getTime());
}
} else if (interval > MINUTE_MS) {
// 最小单位是分钟
var dMinus = diffMinus(min, max);
var minutes = Math.ceil(interval / MINUTE_MS);
interval = minutes * MINUTE_MS;
for (var _i4 = 0; _i4 <= dMinus + minutes; _i4 = _i4 + minutes) {
ticks.push(min + _i4 * MINUTE_MS);
}
} else {
if (interval < 1000) {
interval = 1000;
}
min = Math.floor(min / 1000) * 1000;
var dSeconds = Math.ceil((max - min) / 1000);
var seconds = Math.ceil(interval / 1000);
interval = seconds * 1000;
for (var _i5 = 0; _i5 < dSeconds + seconds; _i5 = _i5 + seconds) {
ticks.push(min + _i5 * 1000);
}
}
}
if (!ticks.length) {
min = Math.floor(min / 1000) * 1000;
max = Math.ceil(max / 1000) * 1000;
count = (max - min) / interval;
for (var _i6 = 0; _i6 <= count; _i6++) {
ticks.push(AutoUtil.fixedBase(interval * _i6 + min, interval));
}
}
return {
max: max,
min: min,
interval: interval,
ticks: ticks,
count: ticks.length
};
};
/***/ }),
/* 337 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Base = __webpack_require__(26);
var isNumber = __webpack_require__(11);
var Identity =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(Identity, _Base);
function Identity() {
return _Base.apply(this, arguments) || this;
}
var _proto = Identity.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Base.prototype._initDefaultCfg.call(this);
this.isIdentity = true;
this.type = 'identity';
/**
* 常量值
* @type {*}
*/
this.value = null;
}
/**
* @override
*/
;
_proto.getText = function getText() {
return this.value.toString();
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
if (this.value !== value && isNumber(value)) {
return value;
}
return this.range[0];
}
/**
* @override
*/
;
_proto.invert = function invert() {
return this.value;
};
return Identity;
}(Base);
Base.Identity = Identity;
module.exports = Identity;
/***/ }),
/* 338 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 使用度量,进行log转换
* @author dxq613@gmail.com
*/
var each = __webpack_require__(2);
var Base = __webpack_require__(26);
var Linear = __webpack_require__(48); // 计算log
function log(a, b) {
if (a === 1) {
return 1;
}
return Math.log(b) / Math.log(a);
}
/**
* 度量的log计算
* @class Scale.Log
*/
var Log =
/*#__PURE__*/
function (_Linear) {
_inheritsLoose(Log, _Linear);
function Log() {
return _Linear.apply(this, arguments) || this;
}
var _proto = Log.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Linear.prototype._initDefaultCfg.call(this);
this.type = 'log';
/**
* @override
* log 的坐标点的个数控制在10个以下
* @type {Number}
*/
this.tickCount = 10;
/**
* 进行log计算的基数
* @type {Number}
*/
this.base = 2; // 最小的tick,仅内部使用
this._minTick = null;
}
/**
* @override
*/
;
_proto.calculateTicks = function calculateTicks() {
var self = this;
var base = self.base;
var minTick;
if (self.min < 0) {
throw new Error('The minimum value must be greater than zero!');
}
var maxTick = log(base, self.max);
if (self.min > 0) {
minTick = Math.floor(log(base, self.min));
} else {
var values = self.values;
var positiveMin = self.max; // 查找大于0的第一个值, 如果都小于0,默认为1
each(values, function (value) {
if (value > 0 && value < positiveMin) {
positiveMin = value;
}
});
if (positiveMin === self.max) {
positiveMin = self.max / base;
}
if (positiveMin > 1) {
positiveMin = 1;
}
minTick = Math.floor(log(base, positiveMin));
self._minTick = minTick;
self.positiveMin = positiveMin;
}
var count = maxTick - minTick;
var tickCount = self.tickCount;
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 (self.min === 0) {
ticks.unshift(0);
}
return ticks;
} // 获取度量计算时,value占的定义域百分比
;
_proto._getScalePercent = function _getScalePercent(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;
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
var percent = this._getScalePercent(value);
var rangeMin = this.rangeMin();
var rangeMax = this.rangeMax();
return rangeMin + percent * (rangeMax - rangeMin);
}
/**
* @override
*/
;
_proto.invert = function invert(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);
};
return Log;
}(Linear);
Base.Log = Log;
module.exports = Log;
/***/ }),
/* 339 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 使用pow进行度量计算
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(26);
var Linear = __webpack_require__(48); // 求以a为次幂,结果为b的基数,如 x^^a = b;求x
function calBase(a, b) {
var e = Math.E;
var value = Math.pow(e, Math.log(b) / a); // 使用换底公式求底
return value;
}
/**
* 度量的Pow计算
* @class Scale.Log
*/
var Pow =
/*#__PURE__*/
function (_Linear) {
_inheritsLoose(Pow, _Linear);
function Pow() {
return _Linear.apply(this, arguments) || this;
}
var _proto = Pow.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Linear.prototype._initDefaultCfg.call(this);
this.type = 'pow';
/**
* @override
* pow 的坐标点的个数控制在10个以下
* @type {Number}
*/
this.tickCount = 10;
/**
* 进行pow计算的基数
* @type {Number}
*/
this.exponent = 2;
}
/**
* @override
*/
;
_proto.calculateTicks = function calculateTicks() {
var self = this;
var exponent = self.exponent;
var min;
var max = Math.ceil(calBase(exponent, self.max));
if (self.min >= 0) {
min = Math.floor(calBase(exponent, self.min));
} else {
min = 0;
}
if (min > max) {
var tmp = max;
max = min;
min = tmp;
}
var count = max - min;
var tickCount = self.tickCount;
var avg = Math.ceil(count / tickCount);
var ticks = [];
for (var i = min; i < max + avg; i = i + avg) {
ticks.push(Math.pow(i, exponent));
}
return ticks;
} // 获取度量计算时,value占的定义域百分比
;
_proto._getScalePercent = function _getScalePercent(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;
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
var percent = this._getScalePercent(value);
var rangeMin = this.rangeMin();
var rangeMax = this.rangeMax();
return rangeMin + percent * (rangeMax - rangeMin);
}
/**
* @override
*/
;
_proto.invert = function invert(value) {
var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
var exponent = this.exponent;
var max = calBase(exponent, this.max);
var min = calBase(exponent, this.min);
var tmp = percent * (max - min) + min;
return Math.pow(tmp, exponent);
};
return Pow;
}(Linear);
Base.Pow = Pow;
module.exports = Pow;
/***/ }),
/* 340 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview 时间数据作为分类类型
* @author dxq613@gmail.com
*/
var Base = __webpack_require__(26);
var Category = __webpack_require__(146);
var fecha = __webpack_require__(216);
var catAuto = __webpack_require__(144);
var TimeUtil = __webpack_require__(148);
var each = __webpack_require__(2);
var isNumber = __webpack_require__(11);
var isObject = __webpack_require__(38);
var isString = __webpack_require__(15);
/**
* 度量的构造函数
* @class Scale.TimeCategory
*/
var TimeCategory =
/*#__PURE__*/
function (_Category) {
_inheritsLoose(TimeCategory, _Category);
function TimeCategory() {
return _Category.apply(this, arguments) || this;
}
var _proto = TimeCategory.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Category.prototype._initDefaultCfg.call(this);
this.type = 'timeCat';
/**
* 是否需要排序,默认进行排序
* @type {Boolean}
*/
this.sortable = true;
this.tickCount = 5;
/**
* 时间格式化
* @type {String}
*/
this.mask = 'YYYY-MM-DD';
};
_proto.init = function init() {
var self = this;
var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳
each(values, function (v, i) {
values[i] = self._toTimeStamp(v);
});
if (this.sortable) {
// 允许排序
values.sort(function (v1, v2) {
return v1 - v2;
});
}
if (!self.ticks) {
self.ticks = this.calculateTicks();
}
}
/**
* 计算 ticks
* @return {array} 返回 ticks 数组
*/
;
_proto.calculateTicks = function calculateTicks() {
var self = this;
var count = self.tickCount;
var ticks;
if (count) {
var temp = catAuto({
maxCount: count,
data: self.values,
isRounding: self.isRounding
});
ticks = temp.ticks;
} else {
ticks = self.values;
}
return ticks;
}
/**
* @override
*/
;
_proto.translate = function translate(value) {
value = this._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;
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
var rangeMin = this.rangeMin();
var rangeMax = this.rangeMax();
var index = this.translate(value);
var percent;
if (this.values.length === 1 || isNaN(index)) {
// is index is NAN should not be set as 0
percent = index;
} else if (index > -1) {
percent = index / (this.values.length - 1);
} else {
percent = 0;
}
return rangeMin + percent * (rangeMax - rangeMin);
}
/**
* @override
*/
;
_proto.getText = function getText(value) {
var result = '';
var index = this.translate(value);
if (index > -1) {
result = this.values[index];
} else {
result = value;
}
var formatter = this.formatter;
result = parseInt(result, 10);
result = formatter ? formatter(result) : fecha.format(result, this.mask);
return result;
}
/**
* @override
*/
;
_proto.getTicks = function getTicks() {
var self = this;
var ticks = this.ticks;
var rst = [];
each(ticks, function (tick) {
var obj;
if (isObject(tick)) {
obj = tick;
} else {
obj = {
text: isString(tick) ? tick : self.getText(tick),
value: self.scale(tick),
tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
};
}
rst.push(obj);
});
return rst;
} // 将时间转换为时间戳
;
_proto._toTimeStamp = function _toTimeStamp(value) {
return TimeUtil.toTimeStamp(value);
};
return TimeCategory;
}(Category);
Base.TimeCat = TimeCategory;
module.exports = TimeCategory;
/***/ }),
/* 341 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
/**
* @fileOverview The measurement of linear data scale function
* @author dxq613@gmail.com
*/
var fecha = __webpack_require__(216);
var each = __webpack_require__(2);
var isNil = __webpack_require__(6);
var isString = __webpack_require__(15);
var Base = __webpack_require__(26);
var Linear = __webpack_require__(48);
var timeAuto = __webpack_require__(336);
var TimeUtil = __webpack_require__(148);
/**
* 时间度量的构造函数
* @class Scale.Time
*/
var Time =
/*#__PURE__*/
function (_Linear) {
_inheritsLoose(Time, _Linear);
function Time() {
return _Linear.apply(this, arguments) || this;
}
var _proto = Time.prototype;
_proto._initDefaultCfg = function _initDefaultCfg() {
_Linear.prototype._initDefaultCfg.call(this);
this.type = 'time';
this.mask = 'YYYY-MM-DD';
}
/**
* @override
*/
;
_proto.init = function init() {
var self = this;
var values = self.values;
if (values && values.length) {
// 重新计算最大最小值
var timeStamps = [];
var min = Infinity; // 最小值
var secondMin = min; // 次小值
var max = 0; // 使用一个循环,计算min,max,secondMin
each(values, function (v) {
var timeStamp = self._toTimeStamp(v);
if (isNaN(timeStamp)) {
throw new TypeError("Invalid Time: " + v);
}
if (min > timeStamp) {
secondMin = min;
min = timeStamp;
} else if (secondMin > timeStamp) {
secondMin = timeStamp;
}
if (max < timeStamp) {
max = timeStamp;
}
timeStamps.push(timeStamp);
}); // 存在多个值时,设置最小间距
if (values.length > 1) {
self.minTickInterval = secondMin - min;
}
if (isNil(self.min) || self._toTimeStamp(self.min) > min) {
self.min = min;
}
if (isNil(self.max) || self._toTimeStamp(self.max) < max) {
self.max = max;
}
}
_Linear.prototype.init.call(this);
};
_proto.calculateTicks = function calculateTicks() {
var self = this;
var min = self.min;
var max = self.max;
var count = self.tickCount;
var interval = self.tickInterval;
var tmp = timeAuto({
min: min,
max: max,
minCount: count,
maxCount: count,
interval: interval,
minInterval: self.minTickInterval
});
return tmp.ticks;
}
/**
* @override
*/
;
_proto.getText = function getText(value) {
var formatter = this.formatter;
value = this.translate(value);
value = formatter ? formatter(value) : fecha.format(value, this.mask);
return value;
}
/**
* @override
*/
;
_proto.scale = function scale(value) {
if (isString(value)) {
value = this.translate(value);
}
return _Linear.prototype.scale.call(this, value);
}
/**
* @override
*/
;
_proto.translate = function translate(value) {
return this._toTimeStamp(value);
} // 将时间转换为时间戳
;
_proto._toTimeStamp = function _toTimeStamp(value) {
return TimeUtil.toTimeStamp(value);
};
return Time;
}(Linear);
Base.Time = Time;
module.exports = Time;
/***/ }),
/* 342 */
/***/ (function(module, exports, __webpack_require__) {
var filter = __webpack_require__(76);
var contains = __webpack_require__(49);
/**
* Flattens `array` a single level deep.
*
* @param {Array} arr The array to inspect.
* @param {Array} values The values to exclude.
* @return {Array} Returns the new array of filtered values.
* @example
* difference([2, 1], [2, 3]); // => [1]
*/
var difference = function difference(arr) {
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return filter(arr, function (value) {
return !contains(values, value);
});
};
module.exports = difference;
/***/ }),
/* 343 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(14);
var isPlainObject = __webpack_require__(39);
var isMatch = __webpack_require__(171);
function find(arr, predicate) {
var _predicate = void 0;
if (isFunction(predicate)) {
_predicate = predicate;
}
if (isPlainObject(predicate)) {
_predicate = function _predicate(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;
}
module.exports = find;
/***/ }),
/* 344 */
/***/ (function(module, exports, __webpack_require__) {
var isNil = __webpack_require__(6);
var isArray = __webpack_require__(4);
var firstValue = function firstValue(data, name) {
var rst = null;
for (var i = 0; i < data.length; i++) {
var obj = data[i];
var value = obj[name];
if (!isNil(value)) {
if (isArray(value)) {
rst = value[0];
} else {
rst = value;
}
break;
}
}
return rst;
};
module.exports = firstValue;
/***/ }),
/* 345 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
/**
* Flattens `array` a single level deep.
*
* @param {Array} arr The array to flatten.
* @param {Array} result The array to return.
* @return {Array} Returns the new flattened array.
* @example
*
* flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
*/
var flattenDeep = function flattenDeep(arr) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (!isArray(arr)) {
result.push(arr);
} else {
for (var i = 0; i < arr.length; i += 1) {
flattenDeep(arr[i], result);
}
}
return result;
};
module.exports = flattenDeep;
/***/ }),
/* 346 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var each = __webpack_require__(2);
/**
* Flattens `array` a single level deep.
*
* @param {Array} arr The array to flatten.
* @return {Array} Returns the new flattened array.
* @example
*
* flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
*/
var flatten = function flatten(arr) {
if (!isArray(arr)) {
return arr;
}
var result = [];
each(arr, function (item) {
if (isArray(item)) {
each(item, function (subItem) {
result.push(subItem);
});
} else {
result.push(item);
}
});
return result;
};
module.exports = flatten;
/***/ }),
/* 347 */
/***/ (function(module, exports, __webpack_require__) {
var filter = __webpack_require__(76);
var isArray = __webpack_require__(4);
var getRange = function getRange(values) {
// 存在 NaN 时,min,max 判定会出问题
values = filter(values, function (v) {
return !isNaN(v);
});
if (!values.length) {
// 如果没有数值则直接返回0
return {
min: 0,
max: 0
};
}
if (isArray(values[0])) {
var tmp = [];
for (var i = 0; i < values.length; i++) {
tmp = tmp.concat(values[i]);
}
values = tmp;
}
var max = Math.max.apply(null, values);
var min = Math.min.apply(null, values);
return {
min: min,
max: max
};
};
module.exports = getRange;
/***/ }),
/* 348 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
contains: __webpack_require__(49),
difference: __webpack_require__(342),
find: __webpack_require__(343),
firstValue: __webpack_require__(344),
flatten: __webpack_require__(346),
flattenDeep: __webpack_require__(345),
getRange: __webpack_require__(347),
merge: __webpack_require__(50),
pull: __webpack_require__(150),
pullAt: __webpack_require__(149),
reduce: __webpack_require__(349),
remove: __webpack_require__(350),
sortBy: __webpack_require__(351),
union: __webpack_require__(352),
uniq: __webpack_require__(151),
valuesOfKey: __webpack_require__(73)
};
/***/ }),
/* 349 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var isPlainObject = __webpack_require__(39);
var each = __webpack_require__(2);
var reduce = function reduce(arr, fn, init) {
if (!isArray(arr) && !isPlainObject(arr)) {
return arr;
}
var result = init;
each(arr, function (data, i) {
result = fn(result, data, i);
});
return result;
};
module.exports = reduce;
/***/ }),
/* 350 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(20);
var pullAt = __webpack_require__(149);
var remove = function remove(arr, predicate) {
/**
* const arr = [1, 2, 3, 4]
* const evens = remove(arr, n => n % 2 == 0)
* console.log(arr) // => [1, 3]
* console.log(evens) // => [2, 4]
*/
var result = [];
if (!isArrayLike(arr)) {
return result;
}
var i = -1;
var indexes = [];
var length = arr.length;
while (++i < length) {
var value = arr[i];
if (predicate(value, i, arr)) {
result.push(value);
indexes.push(i);
}
}
pullAt(arr, indexes);
return result;
};
module.exports = remove;
/***/ }),
/* 351 */
/***/ (function(module, exports, __webpack_require__) {
var isString = __webpack_require__(15);
var isFunction = __webpack_require__(14);
var isArray = __webpack_require__(4);
function sortBy(arr, key) {
var comparer = void 0;
if (isFunction(key)) {
comparer = function comparer(a, b) {
return key(a) - key(b);
};
} else {
var keys = [];
if (isString(key)) {
keys.push(key);
} else if (isArray(key)) {
keys = key;
}
comparer = function comparer(a, b) {
for (var i = 0; i < keys.length; i += 1) {
var prop = keys[i];
if (a[prop] > b[prop]) {
return 1;
}
if (a[prop] < b[prop]) {
return -1;
}
}
return 0;
};
}
arr.sort(comparer);
return arr;
}
module.exports = sortBy;
/***/ }),
/* 352 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var toArray = __webpack_require__(53);
var uniq = __webpack_require__(151);
var union = function union() {
var result = [];
var sources = toArray(arguments);
each(sources, function (arr) {
result = result.concat(arr);
});
return uniq(result);
};
module.exports = union;
/***/ }),
/* 353 */
/***/ (function(module, exports) {
function debounce(func, wait, immediate) {
var timeout = void 0;
return function () {
var context = this,
args = arguments;
var later = function later() {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(context, args);
}
};
}
module.exports = debounce;
/***/ }),
/* 354 */
/***/ (function(module, exports) {
/**
* 添加事件监听器
* @param {Object} target DOM对象
* @param {String} eventType 事件名
* @param {Funtion} callback 回调函数
* @return {Object} 返回对象
*/
module.exports = function addEventListener(target, eventType, callback) {
if (target) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function remove() {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, callback);
return {
remove: function remove() {
target.detachEvent('on' + eventType, callback);
}
};
}
}
};
/***/ }),
/* 355 */
/***/ (function(module, exports) {
module.exports = function getBoundingClientRect(node, defaultValue) {
if (node && node.getBoundingClientRect) {
var rect = node.getBoundingClientRect();
var top = document.documentElement.clientTop;
var left = document.documentElement.clientLeft;
return {
top: rect.top - top,
bottom: rect.bottom - top,
left: rect.left - left,
right: rect.right - left
};
}
return defaultValue || null;
};
/***/ }),
/* 356 */
/***/ (function(module, exports) {
/**
* 获取高度
* @param {HTMLElement} el dom节点
* @param {Number} defaultValue 默认值
* @return {Number} 高度
*/
module.exports = function getHeight(el, defaultValue) {
var height = this.getStyle(el, 'height', defaultValue);
if (height === 'auto') {
height = el.offsetHeight;
}
return parseFloat(height);
};
/***/ }),
/* 357 */
/***/ (function(module, exports) {
/**
* 获取外层高度
* @param {HTMLElement} el dom节点
* @param {Number} defaultValue 默认值
* @return {Number} 高度
*/
module.exports = function getOuterHeight(el, defaultValue) {
var height = this.getHeight(el, defaultValue);
var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
return height + bTop + bBottom + pTop + pBottom;
};
/***/ }),
/* 358 */
/***/ (function(module, exports) {
/**
* 获取外层宽度
* @param {HTMLElement} el dom节点
* @param {Number} defaultValue 默认值
* @return {Number} 宽度
*/
module.exports = function getOuterWidth(el, defaultValue) {
var width = this.getWidth(el, defaultValue);
var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
return width + bLeft + bRight + pLeft + pRight;
};
/***/ }),
/* 359 */
/***/ (function(module, exports) {
module.exports = function getRatio() {
return window.devicePixelRatio ? window.devicePixelRatio : 2;
};
/***/ }),
/* 360 */
/***/ (function(module, exports, __webpack_require__) {
var isNil = __webpack_require__(6);
/**
* 获取样式
* @param {Object} dom DOM节点
* @param {String} name 样式名
* @param {Any} defaultValue 默认值
* @return {String} 属性值
*/
module.exports = function getStyle(dom, name, defaultValue) {
try {
if (window.getComputedStyle) {
return window.getComputedStyle(dom, null)[name];
}
return dom.currentStyle[name];
} catch (e) {
if (!isNil(defaultValue)) {
return defaultValue;
}
return null;
}
};
/***/ }),
/* 361 */
/***/ (function(module, exports) {
/**
* 获取宽度
* @param {HTMLElement} el dom节点
* @param {Number} defaultValue 默认值
* @return {Number} 宽度
*/
module.exports = function getWidth(el, defaultValue) {
var width = this.getStyle(el, 'width', defaultValue);
if (width === 'auto') {
width = el.offsetWidth;
}
return parseFloat(width);
};
/***/ }),
/* 362 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
addEventListener: __webpack_require__(354),
createDom: __webpack_require__(153),
getBoundingClientRect: __webpack_require__(355),
getHeight: __webpack_require__(356),
getOuterHeight: __webpack_require__(357),
getOuterWidth: __webpack_require__(358),
getRatio: __webpack_require__(359),
getStyle: __webpack_require__(360),
getWidth: __webpack_require__(361),
modifyCSS: __webpack_require__(154),
requestAnimationFrame: __webpack_require__(155)
};
/***/ }),
/* 363 */
/***/ (function(module, exports) {
/**
* 获取封装的事件
* @protected
* @param {Object} obj 对象
* @param {String} action 事件名称
* @return {Function} 返回事件处理函数
*/
function getWrapBehavior(obj, action) {
return obj['_wrap_' + action];
}
module.exports = getWrapBehavior;
/***/ }),
/* 364 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
getWrapBehavior: __webpack_require__(363),
wrapBehavior: __webpack_require__(365)
};
/***/ }),
/* 365 */
/***/ (function(module, exports) {
/**
* 封装事件,便于使用上下文this,和便于解除事件时使用
* @protected
* @param {Object} obj 对象
* @param {String} action 事件名称
* @return {Function} 返回事件处理函数
*/
function wrapBehavior(obj, action) {
if (obj['_wrap_' + action]) {
return obj['_wrap_' + action];
}
var method = function method(e) {
obj[action](e);
};
obj['_wrap_' + action] = method;
return method;
}
module.exports = wrapBehavior;
/***/ }),
/* 366 */
/***/ (function(module, exports, __webpack_require__) {
var number2color = __webpack_require__(367);
module.exports = {
number2color: number2color,
numberToColor: number2color,
parsePath: __webpack_require__(368),
parseRadius: __webpack_require__(369)
};
/***/ }),
/* 367 */
/***/ (function(module, exports) {
var numColorCache = {};
module.exports = function numberToColor(num) {
// 增加缓存
var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
};
/***/ }),
/* 368 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var isString = __webpack_require__(15);
var each = __webpack_require__(2);
var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
var regexDot = /[^\s\,]+/ig;
module.exports = function parsePath(path) {
path = path || [];
if (isArray(path)) {
return path;
}
if (isString(path)) {
path = path.match(regexTags);
each(path, function (item, index) {
item = item.match(regexDot);
if (item[0].length > 1) {
var tag = item[0].charAt(0);
item.splice(1, 0, item[0].substr(1));
item[0] = tag;
}
each(item, function (sub, i) {
if (!isNaN(sub)) {
item[i] = +sub;
}
});
path[index] = item;
});
return path;
}
};
/***/ }),
/* 369 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
module.exports = function parseRadius(radius) {
var r1 = 0,
r2 = 0,
r3 = 0,
r4 = 0;
if (isArray(radius)) {
if (radius.length === 1) {
r1 = r2 = r3 = r4 = radius[0];
} else if (radius.length === 2) {
r1 = r3 = radius[0];
r2 = r4 = radius[1];
} else if (radius.length === 3) {
r1 = radius[0];
r2 = r4 = radius[1];
r3 = radius[2];
} else {
r1 = radius[0];
r2 = radius[1];
r3 = radius[2];
r4 = radius[3];
}
} else {
r1 = r2 = r3 = r4 = radius;
}
return {
r1: r1,
r2: r2,
r3: r3,
r4: r4
};
};
/***/ }),
/* 370 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(20);
var indexOf = function indexOf(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;
};
module.exports = indexOf;
/***/ }),
/* 371 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(14);
var isEqual = __webpack_require__(77);
/**
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {Function} [fn] The function to customize comparisons.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* function isGreeting(value) {
* return /^h(?:i|ello)$/.test(value);
* }
*
* function customizer(objValue, othValue) {
* if (isGreeting(objValue) && isGreeting(othValue)) {
* return true;
* }
* }
*
* var array = ['hello', 'goodbye'];
* var other = ['hi', 'goodbye'];
*
* isEqualWith(array, other, customizer); // => true
*/
var isEqualWith = function isEqualWith(value, other, fn) {
if (!isFunction(fn)) {
return isEqual(value, other);
}
return !!fn(value, other);
};
module.exports = isEqualWith;
/***/ }),
/* 372 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isArrayLike = __webpack_require__(20);
var map = function map(arr, func) {
if (!isArrayLike(arr)) {
return arr;
}
var result = [];
each(arr, function (value, index) {
result.push(func(value, index));
});
return result;
};
module.exports = map;
/***/ }),
/* 373 */
/***/ (function(module, exports) {
var fixedBase = function fixedBase(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));
};
module.exports = fixedBase;
/***/ }),
/* 374 */
/***/ (function(module, exports, __webpack_require__) {
var isNumberEqual = __webpack_require__(51);
module.exports = {
clamp: __webpack_require__(78),
fixedBase: __webpack_require__(373),
isDecimal: __webpack_require__(375),
isEven: __webpack_require__(376),
isInteger: __webpack_require__(377),
isNegative: __webpack_require__(378),
isNumberEqual: isNumberEqual,
isOdd: __webpack_require__(379),
isPositive: __webpack_require__(380),
maxBy: __webpack_require__(162),
minBy: __webpack_require__(381),
mod: __webpack_require__(163),
snapEqual: isNumberEqual,
toDegree: __webpack_require__(164),
toInt: __webpack_require__(165),
toInteger: __webpack_require__(165),
toRadian: __webpack_require__(166)
};
/***/ }),
/* 375 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isDecimal = function isDecimal(num) {
return isNumber(num) && num % 1 !== 0;
};
module.exports = isDecimal;
/***/ }),
/* 376 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isEven = function isEven(num) {
return isNumber(num) && num % 2 === 0;
};
module.exports = isEven;
/***/ }),
/* 377 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isInteger = Number.isInteger ? Number.isInteger : function (num) {
return isNumber(num) && num % 1 === 0;
};
module.exports = isInteger;
/***/ }),
/* 378 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isNagative = function isNagative(num) {
return isNumber(num) && num < 0;
};
module.exports = isNagative;
/***/ }),
/* 379 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isOdd = function isOdd(num) {
return isNumber(num) && num % 2 !== 0;
};
module.exports = isOdd;
/***/ }),
/* 380 */
/***/ (function(module, exports, __webpack_require__) {
var isNumber = __webpack_require__(11);
var isPositive = function isPositive(num) {
return isNumber(num) && num > 0;
};
module.exports = isPositive;
/***/ }),
/* 381 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var isFunction = __webpack_require__(14);
var each = __webpack_require__(2);
/**
* @param {Array} arr The array to iterate over.
* @param {Function} [fn] The iteratee invoked per element.
* @return {*} Returns the minimum value.
* @example
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* minBy(objects, 'n');
* // => { 'n': 1 }
*/
var minBy = function minBy(arr, fn) {
if (!isArray(arr)) {
return undefined;
}
var min = arr[0];
var minData = void 0;
if (isFunction(fn)) {
minData = fn(arr[0]);
} else {
minData = arr[0][fn];
}
var data = void 0;
each(arr, function (val) {
if (isFunction(fn)) {
data = fn(val);
} else {
data = val[fn];
}
if (data < minData) {
min = val;
minData = data;
}
});
return min;
};
module.exports = minBy;
/***/ }),
/* 382 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(2);
/***/ }),
/* 383 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(170);
/***/ }),
/* 384 */
/***/ (function(module, exports, __webpack_require__) {
var contains = __webpack_require__(49);
var values = __webpack_require__(173);
module.exports = function (obj, value) {
return contains(values(obj), value);
};
/***/ }),
/* 385 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
forIn: __webpack_require__(382),
has: __webpack_require__(170),
hasKey: __webpack_require__(383),
hasValue: __webpack_require__(384),
keys: __webpack_require__(172),
isMatch: __webpack_require__(171),
values: __webpack_require__(173)
};
/***/ }),
/* 386 */
/***/ (function(module, exports, __webpack_require__) {
var isEqual = __webpack_require__(390);
function getMinDiff(del, add, modify) {
var type = null;
var min = modify;
if (add < min) {
min = add;
type = 'add';
}
if (del < min) {
min = del;
type = 'del';
}
return {
type: type,
min: min
};
}
/*
* https://en.wikipedia.org/wiki/Levenshtein_distance
* 计算两条path的编辑距离
*/
var levenshteinDistance = function levenshteinDistance(source, target) {
var sourceLen = source.length;
var targetLen = target.length;
var sourceSegment = void 0,
targetSegment = void 0;
var temp = 0;
if (sourceLen === 0 || targetLen === 0) {
return null;
}
var dist = [];
for (var i = 0; i <= sourceLen; i++) {
dist[i] = [];
dist[i][0] = { min: i };
}
for (var j = 0; j <= targetLen; j++) {
dist[0][j] = { min: j };
}
for (var _i = 1; _i <= sourceLen; _i++) {
sourceSegment = source[_i - 1];
for (var _j = 1; _j <= targetLen; _j++) {
targetSegment = target[_j - 1];
if (isEqual(sourceSegment, targetSegment)) {
temp = 0;
} else {
temp = 1;
}
var del = dist[_i - 1][_j].min + 1;
var add = dist[_i][_j - 1].min + 1;
var modify = dist[_i - 1][_j - 1].min + temp;
dist[_i][_j] = getMinDiff(del, add, modify);
}
}
return dist;
};
module.exports = function fillPathByDiff(source, target) {
var diffMatrix = levenshteinDistance(source, target);
var sourceLen = source.length;
var targetLen = target.length;
var changes = [];
var index = 1;
var minPos = 1;
// 如果source和target不是完全不相等
if (diffMatrix[sourceLen][targetLen] !== sourceLen) {
// 获取从source到target所需改动
for (var i = 1; i <= sourceLen; i++) {
var min = diffMatrix[i][i].min;
minPos = i;
for (var j = index; j <= targetLen; j++) {
if (diffMatrix[i][j].min < min) {
min = diffMatrix[i][j].min;
minPos = j;
}
}
index = minPos;
if (diffMatrix[i][index].type) {
changes.push({ index: i - 1, type: diffMatrix[i][index].type });
}
}
// 对source进行增删path
for (var _i2 = changes.length - 1; _i2 >= 0; _i2--) {
index = changes[_i2].index;
if (changes[_i2].type === 'add') {
source.splice(index, 0, [].concat(source[index]));
} else {
source.splice(index, 1);
}
}
}
// source尾部补齐
sourceLen = source.length;
if (sourceLen < targetLen) {
for (var _i3 = 0; _i3 < targetLen - sourceLen; _i3++) {
if (source[sourceLen - 1][0] === 'z' || source[sourceLen - 1][0] === 'Z') {
source.splice(sourceLen - 2, 0, source[sourceLen - 2]);
} else {
source.push(source[sourceLen - 1]);
}
}
}
return source;
};
/***/ }),
/* 387 */
/***/ (function(module, exports) {
function decasteljau(points, t) {
var left = [];
var right = [];
function recurse(points, t) {
if (points.length === 1) {
left.push(points[0]);
right.push(points[0]);
} else {
var middlePoints = [];
for (var i = 0; i < points.length - 1; i++) {
if (i === 0) {
left.push(points[0]);
}
if (i === points.length - 2) {
right.push(points[i + 1]);
}
middlePoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
}
recurse(middlePoints, t);
}
}
if (points.length) {
recurse(points, t);
}
return { left: left, right: right.reverse() };
}
function splitCurve(start, end, count) {
var points = [[start[1], start[2]]];
count = count || 2;
var segments = [];
if (end[0] === 'A') {
points.push(end[6]);
points.push(end[7]);
} else if (end[0] === 'C') {
points.push([end[1], end[2]]);
points.push([end[3], end[4]]);
points.push([end[5], end[6]]);
} else if (end[0] === 'S' || end[0] === 'Q') {
points.push([end[1], end[2]]);
points.push([end[3], end[4]]);
} else {
points.push([end[1], end[2]]);
}
var leftSegments = points;
var t = 1 / count;
for (var i = 0; i < count - 1; i++) {
var rt = t / (1 - t * i);
var split = decasteljau(leftSegments, rt);
segments.push(split.left);
leftSegments = split.right;
}
segments.push(leftSegments);
var result = segments.map(function (segment) {
var cmd = [];
if (segment.length === 4) {
cmd.push('C');
cmd = cmd.concat(segment[2]);
}
if (segment.length >= 3) {
if (segment.length === 3) {
cmd.push('Q');
}
cmd = cmd.concat(segment[1]);
}
if (segment.length === 2) {
cmd.push('L');
}
cmd = cmd.concat(segment[segment.length - 1]);
return cmd;
});
return result;
}
function splitSegment(start, end, count) {
if (count === 1) {
return [[].concat(start)];
}
var segments = [];
if (end[0] === 'L' || end[0] === 'C' || end[0] === 'Q') {
segments = segments.concat(splitCurve(start, end, count));
} else {
var temp = [].concat(start);
if (temp[0] === 'M') {
temp[0] = 'L';
}
for (var i = 0; i <= count - 1; i++) {
segments.push(temp);
}
}
return segments;
}
module.exports = function fillPath(source, target) {
if (source.length === 1) {
return source;
}
var sourceLen = source.length - 1;
var targetLen = target.length - 1;
var ratio = sourceLen / targetLen;
var segmentsToFill = [];
if (source.length === 1 && source[0][0] === 'M') {
for (var i = 0; i < targetLen - sourceLen; i++) {
source.push(source[0]);
}
return source;
}
for (var _i = 0; _i < targetLen; _i++) {
var index = Math.floor(ratio * _i);
segmentsToFill[index] = (segmentsToFill[index] || 0) + 1;
}
var filled = segmentsToFill.reduce(function (filled, count, i) {
if (i === sourceLen) {
return filled.concat(source[sourceLen]);
}
return filled.concat(splitSegment(source[i], source[i + 1], count));
}, []);
filled.unshift(source[0]);
if (target[targetLen] === 'Z' || target[targetLen] === 'z') {
filled.push('Z');
}
return filled;
};
/***/ }),
/* 388 */
/***/ (function(module, exports) {
/*
* 抽取pathSegment中的关键点
* M,L,A,Q,H,V一个端点
* Q, S抽取一个端点,一个控制点
* C抽取一个端点,两个控制点
*/
function _getSegmentPoints(segment) {
var points = [];
switch (segment[0]) {
case 'M':
points.push([segment[1], segment[2]]);
break;
case 'L':
points.push([segment[1], segment[2]]);
break;
case 'A':
points.push([segment[6], segment[7]]);
break;
case 'Q':
points.push([segment[3], segment[4]]);
points.push([segment[1], segment[2]]);
break;
case 'T':
points.push([segment[1], segment[2]]);
break;
case 'C':
points.push([segment[5], segment[6]]);
points.push([segment[1], segment[2]]);
points.push([segment[3], segment[4]]);
break;
case 'S':
points.push([segment[3], segment[4]]);
points.push([segment[1], segment[2]]);
break;
case 'H':
points.push([segment[1], segment[1]]);
break;
case 'V':
points.push([segment[1], segment[1]]);
break;
default:
}
return points;
}
// 将两个点均分成count个点
function _splitPoints(points, former, count) {
var result = [].concat(points);
var index = void 0;
var t = 1 / (count + 1);
var formerEnd = _getSegmentPoints(former)[0];
for (var i = 1; i <= count; i++) {
t *= i;
index = Math.floor(points.length * t);
if (index === 0) {
result.unshift([formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
} else {
result.splice(index, 0, [formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
}
}
return result;
}
module.exports = function formatPath(fromPath, toPath) {
if (fromPath.length <= 1) {
return fromPath;
}
var points = void 0;
for (var i = 0; i < toPath.length; i++) {
if (fromPath[i][0] !== toPath[i][0]) {
// 获取fromPath的pathSegment的端点,根据toPath的指令对其改造
points = _getSegmentPoints(fromPath[i]);
switch (toPath[i][0]) {
case 'M':
fromPath[i] = ['M'].concat(points[0]);
break;
case 'L':
fromPath[i] = ['L'].concat(points[0]);
break;
case 'A':
fromPath[i] = [].concat(toPath[i]);
fromPath[i][6] = points[0][0];
fromPath[i][7] = points[0][1];
break;
case 'Q':
if (points.length < 2) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 1);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['Q'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
case 'T':
fromPath[i] = ['T'].concat(points[0]);
break;
case 'C':
if (points.length < 3) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 2);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['C'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
case 'S':
if (points.length < 2) {
if (i > 0) {
points = _splitPoints(points, fromPath[i - 1], 1);
} else {
fromPath[i] = toPath[i];
break;
}
}
fromPath[i] = ['S'].concat(points.reduce(function (arr, i) {
return arr.concat(i);
}, []));
break;
default:
fromPath[i] = toPath[i];
}
}
}
return fromPath;
};
/***/ }),
/* 389 */
/***/ (function(module, exports, __webpack_require__) {
var pathIntersection = __webpack_require__(391);
var path2absolute = __webpack_require__(177);
var path2curve = __webpack_require__(178);
var catmullRom2Bezier = __webpack_require__(174);
module.exports = {
catmullRom2Bezier: catmullRom2Bezier,
catmullRomToBezier: catmullRom2Bezier,
fillPath: __webpack_require__(387),
fillPathByDiff: __webpack_require__(386),
formatPath: __webpack_require__(388),
intersection: pathIntersection,
pathIntersection: pathIntersection,
parsePathArray: __webpack_require__(175),
parsePathString: __webpack_require__(176),
pathToAbsolute: path2absolute,
path2absolute: path2absolute,
pathTocurve: path2curve,
path2curve: path2curve,
rectPath: __webpack_require__(179)
};
/***/ }),
/* 390 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
module.exports = function isEqual(obj1, obj2) {
if (obj1.length !== obj2.length) {
return false;
}
var result = true;
each(obj1, function (item, i) {
if (item !== obj2[i]) {
result = false;
return false;
}
});
return result;
};
/***/ }),
/* 391 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(4);
var rectPath = __webpack_require__(179);
var pathTocurve = __webpack_require__(178);
var base3 = function base3(t, p1, p2, p3, p4) {
var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
return t * t2 - 3 * p1 + 3 * p2;
};
var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
if (z === null) {
z = 1;
}
z = z > 1 ? 1 : z < 0 ? 0 : z;
var z2 = z / 2;
var n = 12;
var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
var sum = 0;
for (var i = 0; i < n; i++) {
var ct = z2 * Tvalues[i] + z2;
var xbase = base3(ct, x1, x2, x3, x4);
var ybase = base3(ct, y1, y2, y3, y4);
var comb = xbase * xbase + ybase * ybase;
sum += Cvalues[i] * Math.sqrt(comb);
}
return z2 * sum;
};
var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
var tvalues = [];
var bounds = [[], []];
var a = void 0;
var b = void 0;
var c = void 0;
var t = void 0;
for (var i = 0; i < 2; ++i) {
if (i === 0) {
b = 6 * x0 - 12 * x1 + 6 * x2;
a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
c = 3 * x1 - 3 * x0;
} else {
b = 6 * y0 - 12 * y1 + 6 * y2;
a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
c = 3 * y1 - 3 * y0;
}
if (Math.abs(a) < 1e-12) {
if (Math.abs(b) < 1e-12) {
continue;
}
t = -c / b;
if (t > 0 && t < 1) {
tvalues.push(t);
}
continue;
}
var b2ac = b * b - 4 * c * a;
var sqrtb2ac = Math.sqrt(b2ac);
if (b2ac < 0) {
continue;
}
var t1 = (-b + sqrtb2ac) / (2 * a);
if (t1 > 0 && t1 < 1) {
tvalues.push(t1);
}
var t2 = (-b - sqrtb2ac) / (2 * a);
if (t2 > 0 && t2 < 1) {
tvalues.push(t2);
}
}
var j = tvalues.length;
var jlen = j;
var mt = void 0;
while (j--) {
t = tvalues[j];
mt = 1 - t;
bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
}
bounds[0][jlen] = x0;
bounds[1][jlen] = y0;
bounds[0][jlen + 1] = x3;
bounds[1][jlen + 1] = y3;
bounds[0].length = bounds[1].length = jlen + 2;
return {
min: {
x: Math.min.apply(0, bounds[0]),
y: Math.min.apply(0, bounds[1])
},
max: {
x: Math.max.apply(0, bounds[0]),
y: Math.max.apply(0, bounds[1])
}
};
};
var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
return;
}
var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
if (!denominator) {
return;
}
var px = nx / denominator;
var py = ny / denominator;
var px2 = +px.toFixed(2);
var py2 = +py.toFixed(2);
if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
return;
}
return {
x: px,
y: py
};
};
var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
};
var box = function box(x, y, width, height) {
if (x === null) {
x = y = width = height = 0;
}
if (y === null) {
y = x.y;
width = x.width;
height = x.height;
x = x.x;
}
return {
x: x,
y: y,
width: width,
w: width,
height: height,
h: height,
x2: x + width,
y2: y + height,
cx: x + width / 2,
cy: y + height / 2,
r1: Math.min(width, height) / 2,
r2: Math.max(width, height) / 2,
r0: Math.sqrt(width * width + height * height) / 2,
path: rectPath(x, y, width, height),
vb: [x, y, width, height].join(' ')
};
};
var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
bbox1 = box(bbox1);
bbox2 = box(bbox2);
return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
};
var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
if (!isArray(p1x)) {
p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
}
var bbox = curveDim.apply(null, p1x);
return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
};
var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
var t1 = 1 - t;
var t13 = Math.pow(t1, 3);
var t12 = Math.pow(t1, 2);
var t2 = t * t;
var t3 = t2 * t;
var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
var ax = t1 * p1x + t * c1x;
var ay = t1 * p1y + t * c1y;
var cx = t1 * c2x + t * p2x;
var cy = t1 * c2y + t * p2y;
var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
// (mx > nx || my < ny) && (alpha += 180);
return {
x: x,
y: y,
m: {
x: mx,
y: my
},
n: {
x: nx,
y: ny
},
start: {
x: ax,
y: ay
},
end: {
x: cx,
y: cy
},
alpha: alpha
};
};
var interHelper = function interHelper(bez1, bez2, justCount) {
var bbox1 = bezierBBox(bez1);
var bbox2 = bezierBBox(bez2);
if (!isBBoxIntersect(bbox1, bbox2)) {
return justCount ? 0 : [];
}
var l1 = bezlen.apply(0, bez1);
var l2 = bezlen.apply(0, bez2);
var n1 = ~~(l1 / 8);
var n2 = ~~(l2 / 8);
var dots1 = [];
var dots2 = [];
var xy = {};
var res = justCount ? 0 : [];
for (var i = 0; i < n1 + 1; i++) {
var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
dots1.push({
x: d.x,
y: d.y,
t: i / n1
});
}
for (var _i = 0; _i < n2 + 1; _i++) {
var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
dots2.push({
x: _d.x,
y: _d.y,
t: _i / n2
});
}
for (var _i2 = 0; _i2 < n1; _i2++) {
for (var j = 0; j < n2; j++) {
var di = dots1[_i2];
var di1 = dots1[_i2 + 1];
var dj = dots2[j];
var dj1 = dots2[j + 1];
var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
if (is) {
if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
continue;
}
xy[is.x.toFixed(4)] = is.y.toFixed(4);
var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
if (justCount) {
res++;
} else {
res.push({
x: is.x,
y: is.y,
t1: t1,
t2: t2
});
}
}
}
}
}
return res;
};
var interPathHelper = function interPathHelper(path1, path2, justCount) {
path1 = pathTocurve(path1);
path2 = pathTocurve(path2);
var x1 = void 0;
var y1 = void 0;
var x2 = void 0;
var y2 = void 0;
var x1m = void 0;
var y1m = void 0;
var x2m = void 0;
var y2m = void 0;
var bez1 = void 0;
var bez2 = void 0;
var res = justCount ? 0 : [];
for (var i = 0, ii = path1.length; i < ii; i++) {
var pi = path1[i];
if (pi[0] === 'M') {
x1 = x1m = pi[1];
y1 = y1m = pi[2];
} else {
if (pi[0] === 'C') {
bez1 = [x1, y1].concat(pi.slice(1));
x1 = bez1[6];
y1 = bez1[7];
} else {
bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
x1 = x1m;
y1 = y1m;
}
for (var j = 0, jj = path2.length; j < jj; j++) {
var pj = path2[j];
if (pj[0] === 'M') {
x2 = x2m = pj[1];
y2 = y2m = pj[2];
} else {
if (pj[0] === 'C') {
bez2 = [x2, y2].concat(pj.slice(1));
x2 = bez2[6];
y2 = bez2[7];
} else {
bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
x2 = x2m;
y2 = y2m;
}
var intr = interHelper(bez1, bez2, justCount);
if (justCount) {
res += intr;
} else {
for (var k = 0, kk = intr.length; k < kk; k++) {
intr[k].segment1 = i;
intr[k].segment2 = j;
intr[k].bez1 = bez1;
intr[k].bez2 = bez2;
}
res = res.concat(intr);
}
}
}
}
}
return res;
};
module.exports = function pathIntersection(path1, path2) {
return interPathHelper(path1, path2);
};
/***/ }),
/* 392 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(2);
var isPlaineObject = __webpack_require__(39);
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Creates an object composed of the picked `object` properties.
*
* @param {Object} object The source object.
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
* pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
*/
var pick = function pick(object, keys) {
if (object === null || !isPlaineObject(object)) {
return {};
}
var result = {};
each(keys, function (key) {
if (hasOwnProperty.call(object, key)) {
result[key] = object[key];
}
});
return result;
};
module.exports = pick;
/***/ }),
/* 393 */
/***/ (function(module, exports, __webpack_require__) {
var strUtil = {
lc: __webpack_require__(394),
lowerCase: __webpack_require__(180),
lowerFirst: __webpack_require__(181),
substitute: __webpack_require__(395),
uc: __webpack_require__(396),
upperCase: __webpack_require__(182),
upperFirst: __webpack_require__(183)
};
module.exports = strUtil;
/***/ }),
/* 394 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(180);
/***/ }),
/* 395 */
/***/ (function(module, exports) {
var substitute = 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];
});
};
module.exports = substitute;
/***/ }),
/* 396 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(182);
/***/ }),
/* 397 */
/***/ (function(module, exports) {
function throttle(func, wait, options) {
var timeout = void 0,
context = void 0,
args = void 0,
result = void 0;
var previous = 0;
if (!options) options = {};
var later = function later() {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
result = func.apply(context, args);
if (!timeout) context = args = null;
};
var throttled = function throttled() {
var now = Date.now();
if (!previous && options.leading === false) previous = now;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = now;
result = func.apply(context, args);
if (!timeout) context = args = null;
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
throttled.cancel = function () {
clearTimeout(timeout);
previous = 0;
timeout = context = args = null;
};
return throttled;
}
module.exports = throttle;
/***/ }),
/* 398 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(16);
var checkType = {
getType: __webpack_require__(184),
isArray: __webpack_require__(4),
isArrayLike: __webpack_require__(20),
isBoolean: __webpack_require__(185),
isFunction: __webpack_require__(14),
isNil: __webpack_require__(6),
isNull: __webpack_require__(401),
isNumber: __webpack_require__(11),
isObject: __webpack_require__(38),
isObjectLike: __webpack_require__(80),
isPlainObject: __webpack_require__(39),
isPrototype: __webpack_require__(187),
isType: isType,
isUndefined: __webpack_require__(403),
isString: __webpack_require__(15),
isRegExp: __webpack_require__(402),
isDate: __webpack_require__(186),
isArguments: __webpack_require__(399),
isError: __webpack_require__(400)
};
module.exports = checkType;
/***/ }),
/* 399 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 是否是参数类型
*
* @param {Object} value 测试的值
* @return {Boolean}
*/
var isType = __webpack_require__(16);
var isArguments = function isArguments(value) {
return isType(value, 'Arguments');
};
module.exports = isArguments;
/***/ }),
/* 400 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 是否是参数类型
*
* @param {Object} value 测试的值
* @return {Boolean}
*/
var isType = __webpack_require__(16);
var isError = function isError(value) {
return isType(value, 'Error');
};
module.exports = isError;
/***/ }),
/* 401 */
/***/ (function(module, exports) {
var isNull = function isNull(value) {
return value === null;
};
module.exports = isNull;
/***/ }),
/* 402 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(16);
var isRegExp = function isRegExp(str) {
return isType(str, 'RegExp');
};
module.exports = isRegExp;
/***/ }),
/* 403 */
/***/ (function(module, exports) {
var isUndefined = function isUndefined(value) {
return value === undefined;
};
module.exports = isUndefined;
/***/ }),
/* 404 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _Base2.default.generateBaseTypedComponent('Axis'); /**
* Axis Component
*/
/***/ }),
/* 405 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(41);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _warning = __webpack_require__(219);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Empty Component
* 用 g2 创建 chart 一开始没有数据,有数据时对当前 chart 更新数据时,会有问题。
* 因此用了 Empty 作为无数据 chart,PureChart 作为有数据的 chart。
*/
(0, _warning2.default)(_react2.default.PureComponent, '`React.PureComponent` needs React >=15.3.0');
// react 15.3.0 以下不支持 PureComponent 就做一个兼容
var Empty = function (_ref) {
_inherits(Empty, _ref);
function Empty() {
_classCallCheck(this, Empty);
return _possibleConstructorReturn(this, (Empty.__proto__ || Object.getPrototypeOf(Empty)).apply(this, arguments));
}
_createClass(Empty, [{
key: 'render',
value: function render() {
var _props = this.props,
width = _props.width,
height = _props.height,
placeholder = _props.placeholder;
return _react2.default.createElement(
'div',
{ style: { width: width, height: height } },
placeholder
);
}
}]);
return Empty;
}(_react2.default.PureComponent || _react2.default.Component);
Empty.propTypes = {
width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
height: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
placeholder: _propTypes2.default.node
};
Empty.defaultProps = {
width: '100%',
placeholder: _react2.default.createElement(
'div',
{ style: { position: 'relative', top: '48%', textAlign: 'center' } },
'\u6682\u65E0\u6570\u636E'
)
};
exports.default = Empty;
/***/ }),
/* 406 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(41);
var _react2 = _interopRequireDefault(_react);
var _purechart = __webpack_require__(407);
var _purechart2 = _interopRequireDefault(_purechart);
var _empty = __webpack_require__(405);
var _empty2 = _interopRequireDefault(_empty);
var _ErrorBoundary = __webpack_require__(409);
var _ErrorBoundary2 = _interopRequireDefault(_ErrorBoundary);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Chart Component
*/
function hasSource(source) {
var flag = true;
if (source == null || source.length === 0) {
flag = false;
}
return !!flag;
}
var Chart = function (_ref) {
_inherits(Chart, _ref);
function Chart() {
var _ref2;
var _temp, _this, _ret;
_classCallCheck(this, Chart);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = Chart.__proto__ || Object.getPrototypeOf(Chart)).call.apply(_ref2, [this].concat(args))), _this), _this._refCallback = function (c) {
if (c) {
_this.chart = c.getG2Instance();
}
}, _this.hasViewSource = function () {
var hasViewSource = false;
_react2.default.Children.map(_this.props.children, function (child) {
if (!hasViewSource && child && typeof child.type === 'function' && child.type.name === 'View' && child.props.data && hasSource(child.props.data)) {
hasViewSource = true;
}
});
return hasViewSource;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Chart, [{
key: 'getG2Instance',
value: function getG2Instance() {
return this.chart;
}
}, {
key: 'render',
value: function render() {
var _props = this.props,
data = _props.data,
width = _props.width,
height = _props.height,
placeholder = _props.placeholder,
className = _props.className,
style = _props.style;
return _react2.default.createElement(
'div',
{ className: className, style: style },
hasSource(data) || this.hasViewSource() || !placeholder ? _react2.default.createElement(_purechart2.default, _extends({ ref: this._refCallback }, this.props)) : _react2.default.createElement(_empty2.default, {
width: width,
height: height,
placeholder: placeholder === true ? undefined : placeholder
})
);
}
}]);
return Chart;
}(_react2.default.PureComponent || _react2.default.Component);
var BChart = function (_React$Component) {
_inherits(BChart, _React$Component);
function BChart() {
_classCallCheck(this, BChart);
return _possibleConstructorReturn(this, (BChart.__proto__ || Object.getPrototypeOf(BChart)).apply(this, arguments));
}
_createClass(BChart, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
_ErrorBoundary2.default,
null,
_react2.default.createElement(Chart, this.props)
);
}
}]);
return BChart;
}(_react2.default.Component);
exports.default = BChart;
/***/ }),
/* 407 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(41);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _processor = __webpack_require__(421);
var _processor2 = _interopRequireDefault(_processor);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint react/no-unused-prop-types: "off" */
var PureChart = function (_Component) {
_inherits(PureChart, _Component);
function PureChart(props) {
_classCallCheck(this, PureChart);
var _this = _possibleConstructorReturn(this, (PureChart.__proto__ || Object.getPrototypeOf(PureChart)).call(this, props));
_initialiseProps.call(_this);
_this.name = 'Chart';
_this.gId = 0;
_this.id = _this.createId();
_this.g2Processor = new _processor2.default();
return _this;
}
_createClass(PureChart, [{
key: 'getChildContext',
value: function getChildContext() {
return {
addElement: this.addElement,
updateElement: this.updateElement,
deleteElement: this.deleteElement,
createId: this.createId,
getParentInfo: this.getParentInfo,
getViewId: this.getViewId
};
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
this.addElement(this.name, this.id, _extends({}, this.props, {
container: this.containerWrap
}));
this.chart = this.g2Processor.createG2Instance();
this.notifyG2Instance();
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate() {
this.updateElement(this.name, this.id, _extends({}, this.props, {
container: this.containerWrap
}));
var newChart = this.g2Processor.batchedUpdate();
if (this.chart !== newChart) {
this.chart = newChart;
this.notifyG2Instance();
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.g2Processor.destory();
this.chart = null;
this.containerWrap = null;
}
}, {
key: 'getG2Instance',
value: function getG2Instance() {
return this.chart;
}
}, {
key: 'notifyG2Instance',
value: function notifyG2Instance() {
if (this.props.onGetG2Instance) {
this.props.onGetG2Instance(this.chart);
}
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
{ ref: this.refHandle },
this.props.children
);
}
}]);
return PureChart;
}(_react.Component);
PureChart.propTypes = {
data: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.object), _propTypes2.default.object]),
scale: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array]),
animate: _propTypes2.default.bool,
width: _propTypes2.default.number,
height: _propTypes2.default.number.isRequired,
onGetG2Instance: _propTypes2.default.func
};
PureChart.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.getViewId = function () {};
this.getParentInfo = function () {
return {
id: _this2.id,
name: _this2.name
};
};
this.createId = function () {
_this2.gId += 1;
return _this2.gId;
};
this.addElement = function (name, id, props, parentInfo, viewId) {
return _this2.g2Processor.addElement(name, id, props, parentInfo, viewId);
};
this.updateElement = function (name, id, props, parentInfo, viewId) {
_this2.g2Processor.updateElement(name, id, props, parentInfo, viewId);
};
this.deleteElement = function (name, id, parentInfo) {
_this2.g2Processor.deleteElement(name, id, parentInfo);
};
this.refHandle = function (cw) {
// chart container wrap for reset operation
if (!_this2.containerWrap) {
_this2.containerWrap = cw;
}
};
};
exports.default = PureChart;
/***/ }),
/* 408 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _Base2.default.generateBaseTypedComponent('Coord'); /**
* Coord Component
*/
/***/ }),
/* 409 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(41);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ErrorBoundary = function (_React$Component) {
_inherits(ErrorBoundary, _React$Component);
function ErrorBoundary(props) {
_classCallCheck(this, ErrorBoundary);
var _this = _possibleConstructorReturn(this, (ErrorBoundary.__proto__ || Object.getPrototypeOf(ErrorBoundary)).call(this, props));
_this.state = { hasError: false };
return _this;
}
_createClass(ErrorBoundary, [{
key: 'componentDidCatch',
value: function componentDidCatch() {
this.setState({ hasError: true });
}
}, {
key: 'unstable_handleError',
value: function unstable_handleError() {
this.setState({ hasError: true });
}
}, {
key: 'render',
value: function render() {
if (this.state.hasError) {
return _react2.default.createElement(
'h1',
null,
'bizcharts error.'
);
}
return this.props.children;
}
}]);
return ErrorBoundary;
}(_react2.default.Component);
exports.default = ErrorBoundary;
/***/ }),
/* 410 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
__webpack_require__(279);
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _Base2.default.generateBaseTypedComponent('Facet');
/***/ }),
/* 411 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
__webpack_require__(286);
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Geom Component
*/
exports.default = _Base2.default.generateBaseTypedComponent('Geom');
/***/ }),
/* 412 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Guide = _Base2.default.generateBaseTypedComponent('Guide'); /*
Components:
Guide
Guide.Line
Guide.Image
Guide.Text
Guide.Region
Guide.Arc
Guide.Html
Guide.RegionFilter
Guide.DataMarker
Guide.DataRegion
*/
Guide.Line = _Base2.default.generateBaseTypedComponent('GuideLine');
Guide.Image = _Base2.default.generateBaseTypedComponent('GuideImage');
Guide.Text = _Base2.default.generateBaseTypedComponent('GuideText');
Guide.Region = _Base2.default.generateBaseTypedComponent('GuideRegion');
Guide.Html = _Base2.default.generateBaseTypedComponent('GuideHtml');
Guide.Arc = _Base2.default.generateBaseTypedComponent('GuideArc');
Guide.RegionFilter = _Base2.default.generateBaseTypedComponent('GuideRegionFilter');
Guide.DataMarker = _Base2.default.generateBaseTypedComponent('GuideDataMarker');
Guide.DataRegion = _Base2.default.generateBaseTypedComponent('GuideDataRegion');
exports.default = Guide;
/***/ }),
/* 413 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _invariant = __webpack_require__(521);
var _invariant2 = _interopRequireDefault(_invariant);
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Label Component
*/
var Label = function (_BaseComponent) {
_inherits(Label, _BaseComponent);
function Label(props) {
_classCallCheck(this, Label);
return _possibleConstructorReturn(this, (Label.__proto__ || Object.getPrototypeOf(Label)).call(this, props, 'Label'));
}
_createClass(Label, [{
key: 'componentWillMount',
value: function componentWillMount() {
var parentInfo = this.context.getParentInfo();
(0, _invariant2.default)(parentInfo.name === 'Geom', '`` must be wrapped in ``');
this.id = this.context.createId();
this.context.addElement(this.name, this.id, this.props, this.context.getParentInfo(), this.context.getViewId());
}
}]);
return Label;
}(_Base2.default);
Label.contextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
Label.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
exports.default = Label;
/***/ }),
/* 414 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Legend Component
*/
var Legend = function (_BaseComponent) {
_inherits(Legend, _BaseComponent);
function Legend(props) {
_classCallCheck(this, Legend);
return _possibleConstructorReturn(this, (Legend.__proto__ || Object.getPrototypeOf(Legend)).call(this, props, 'Legend'));
}
return Legend;
}(_Base2.default);
Legend.contextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
Legend.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
Legend.defaultProps = {
visible: true
};
exports.default = Legend;
/***/ }),
/* 415 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _Base2.default.generateBaseTypedComponent('Tooltip'); /**
* Tooltip Component
*/
/***/ }),
/* 416 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _Base = __webpack_require__(24);
var _Base2 = _interopRequireDefault(_Base);
var _propTypes = __webpack_require__(28);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* View Component
*/
var View = function (_BaseComponent) {
_inherits(View, _BaseComponent);
function View(props) {
_classCallCheck(this, View);
var _this = _possibleConstructorReturn(this, (View.__proto__ || Object.getPrototypeOf(View)).call(this, props, 'View'));
_this.getViewId = function () {
return _this.id;
};
return _this;
}
_createClass(View, [{
key: 'getChildContext',
value: function getChildContext() {
return {
addElement: this.context.addElement,
updateElement: this.context.updateElement,
deleteElement: this.context.deleteElement,
createId: this.context.createId,
getParentInfo: this.getParentInfo,
getViewId: this.getViewId
};
}
}]);
return View;
}(_Base2.default);
View.contextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
View.childContextTypes = {
addElement: _propTypes2.default.func,
updateElement: _propTypes2.default.func,
deleteElement: _propTypes2.default.func,
createId: _propTypes2.default.func,
getParentInfo: _propTypes2.default.func,
getViewId: _propTypes2.default.func
};
exports.default = View;
/***/ }),
/* 417 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Facet = exports.Label = exports.Guide = exports.View = exports.Geom = exports.Tooltip = exports.Legend = exports.Axis = exports.Coord = exports.Chart = undefined;
var _Chart2 = __webpack_require__(406);
var _Chart3 = _interopRequireDefault(_Chart2);
var _Coord2 = __webpack_require__(408);
var _Coord3 = _interopRequireDefault(_Coord2);
var _Axis2 = __webpack_require__(404);
var _Axis3 = _interopRequireDefault(_Axis2);
var _Legend2 = __webpack_require__(414);
var _Legend3 = _interopRequireDefault(_Legend2);
var _Tooltip2 = __webpack_require__(415);
var _Tooltip3 = _interopRequireDefault(_Tooltip2);
var _Geom2 = __webpack_require__(411);
var _Geom3 = _interopRequireDefault(_Geom2);
var _View2 = __webpack_require__(416);
var _View3 = _interopRequireDefault(_View2);
var _Guide2 = __webpack_require__(412);
var _Guide3 = _interopRequireDefault(_Guide2);
var _Label2 = __webpack_require__(413);
var _Label3 = _interopRequireDefault(_Label2);
var _Facet2 = __webpack_require__(410);
var _Facet3 = _interopRequireDefault(_Facet2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.Chart = _Chart3.default;
exports.Coord = _Coord3.default;
exports.Axis = _Axis3.default;
exports.Legend = _Legend3.default;
exports.Tooltip = _Tooltip3.default;
exports.Geom = _Geom3.default;
exports.View = _View3.default;
exports.Guide = _Guide3.default;
exports.Label = _Label3.default;
exports.Facet = _Facet3.default;
/***/ }),
/* 418 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var addFuncMap = {
Chart: 'addChart',
Coord: 'addCoord',
Geom: 'addGeom',
Axis: 'addAxis',
Tooltip: 'addTooltip',
Legend: 'addLegend',
Label: 'addLabel',
View: 'addView',
Guide: 'addGuide',
GuideLine: 'addGuideLine',
GuideImage: 'addGuideImage',
GuideText: 'addGuideText',
GuideRegion: 'addGuideRegion',
GuideHtml: 'addGuideHtml',
GuideArc: 'addGuideArc',
GuideRegionFilter: 'addGuideRegionFilter',
GuideDataMarker: 'addGuideDataMarker',
GuideDataRegion: 'addGuideDataRegion',
Facet: 'addFacet'
};
var iAdd = {
addElement: function addElement(name, config, elemInfo) {
this[addFuncMap[name]](config, elemInfo, elemInfo.id, elemInfo.viewId, elemInfo.parentInfo);
},
getConfigContainer: function getConfigContainer(viewContainer, vId) {
if (vId) {
if (!viewContainer.views) {
viewContainer.views = {};
}
viewContainer = viewContainer.views[vId];
if (!viewContainer) {
viewContainer = {};
viewContainer.views[vId] = viewContainer;
}
}
return viewContainer;
},
addUniqueElement: function addUniqueElement(config, name, elemInfo, id, vId) {
var configContainer = this.getConfigContainer(config, vId);
if (configContainer[name]) {
// error
}
configContainer[name] = elemInfo;
return id;
},
addChart: function addChart(config, elemInfo, id) {
return this.addUniqueElement(config, 'chart', elemInfo, id, null);
},
addView: function addView(configContainer, elemInfo, id) {
if (!configContainer.views) {
configContainer.views = {};
}
configContainer.views[id] = elemInfo;
return id;
},
addAxis: function addAxis(config, elemInfo, id, vId) {
var configContainer = this.getConfigContainer(config, vId);
if (!configContainer.axises) {
configContainer.axises = {};
}
configContainer.axises[id] = elemInfo;
return id;
},
addCoord: function addCoord(config, elemInfo, id, vId) {
return this.addUniqueElement(config, 'coord', elemInfo, id, vId);
},
addGeom: function addGeom(config, elemInfo, id, vId, isLabel) {
var configContainer = this.getConfigContainer(config, vId);
if (!configContainer.geoms) {
configContainer.geoms = {};
}
if (configContainer.geoms[id]) {
if (isLabel) {
configContainer.geoms[id].label = elemInfo.label;
} else {
if (!configContainer.geoms[id].label) {
console.log('geom label error');
}
elemInfo.label = configContainer.geoms[id].label;
configContainer.geoms[id] = elemInfo;
}
} else {
configContainer.geoms[id] = elemInfo;
}
return id;
},
addLabel: function addLabel(config, elemInfo, id, vId, parentInfo) {
var configContainer = this.getConfigContainer(config, vId);
if (!configContainer.geoms) {
configContainer.geoms = {};
}
this.addGeom(config, { label: elemInfo }, parentInfo.id, vId, true);
return id;
},
addTooltip: function addTooltip(config, elemInfo, id, vId) {
return this.addUniqueElement(config, 'tooltip', elemInfo, id, vId);
},
addFacet: function addFacet(config, elemInfo, id, vId) {
return this.addUniqueElement(config, 'facet', elemInfo, id, vId);
},
addLegend: function addLegend(config, elemInfo, id, vId) {
var configContainer = this.getConfigContainer(config, vId);
if (!configContainer.legends) {
configContainer.legends = {};
}
configContainer.legends[id] = elemInfo;
return id;
},
addGuide: function addGuide(config, elemInfo, id, vId) {
return this.addUniqueElement(config, 'guide', elemInfo, id, vId);
},
addTypedGuide: function addTypedGuide(config, name, elemInfo, id, vId, parentInfo) {
var configContainer = this.getConfigContainer(config, vId);
var guide = configContainer.guide;
if (!guide) {
this.addUniqueElement('guide', {}, parentInfo.id, vId);
guide = configContainer.guide;
}
if (!guide.elements) {
guide.elements = {};
}
elemInfo.type = name;
guide.elements[id] = elemInfo;
return id;
},
addGuideLine: function addGuideLine(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'line', props, id, vId, parentInfo);
},
addGuideImage: function addGuideImage(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'image', props, id, vId, parentInfo);
},
addGuideText: function addGuideText(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'text', props, id, vId, parentInfo);
},
addGuideRegion: function addGuideRegion(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'region', props, id, vId, parentInfo);
},
addGuideHtml: function addGuideHtml(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'html', props, id, vId, parentInfo);
},
addGuideArc: function addGuideArc(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'arc', props, id, vId, parentInfo);
},
addGuideRegionFilter: function addGuideRegionFilter(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'regionFilter', props, id, vId, parentInfo);
},
addGuideDataMarker: function addGuideDataMarker(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'dataMarker', props, id, vId, parentInfo);
},
addGuideDataRegion: function addGuideDataRegion(config, props, id, vId, parentInfo) {
this.addTypedGuide(config, 'dataRegion', props, id, vId, parentInfo);
}
};
exports.default = iAdd;
/***/ }),
/* 419 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var deleteFuncMap = {
Chart: 'deleteChart',
Coord: 'deleteCoord',
Geom: 'deleteGeom',
Axis: 'deleteAxis',
Tooltip: 'deleteTooltip',
Legend: 'deleteLegend',
Label: 'deleteLabel',
View: 'deleteView',
Guide: 'deleteGuide',
GuideLine: 'deleteTypedGuide',
GuideImage: 'deleteTypedGuide',
GuideText: 'deleteTypedGuide',
GuideRegion: 'deleteTypedGuide',
GuideHtml: 'deleteTypedGuide',
GuideArc: 'deleteTypedGuide',
Facet: 'deleteFacet'
};
var reExecuteDeleteElements = {
Geom: true,
Label: true,
Facet: true
};
var iDelete = {
deleteAxis: function deleteAxis(chart, config, id) {
var axisConfig = config.axises[id].props;
chart.axis(axisConfig.name, false);
},
deleteTooltip: function deleteTooltip(chart) {
chart.tooltip(false);
},
deleteCoord: function deleteCoord(chart) {
chart.coord('rect', {});
},
deleteLegend: function deleteLegend(chart, config, id) {
var legendConfig = config.legends[id].props;
chart.legend.apply(chart, _toConsumableArray(legendConfig.name ? [legendConfig.name, false] : [false]));
},
deleteGuide: function deleteGuide(chart) {
chart.guide().clear();
},
deleteView: function deleteView(chart, config, id) {
if (!config.views[id].g2Instance) return;
chart.removeView(config.views[id].g2Instance);
delete config.views[id].g2Instance;
},
deleteViewElement: function deleteViewElement(chart, config, deleteInfos, elementInfos) {
var _this = this;
// 次模块只处理元素的删除,将删除同步到 g2。
// 因此此处只需要将view destory 掉,如果需要则重建。
Object.keys(deleteInfos).forEach(function (id) {
var elementInfo = elementInfos[id];
var viewId = elementInfo.viewId;
if (viewId) {
if (reExecuteDeleteElements[elementInfo.name]) {
config.views[viewId].needReExecute = true;
} else if (config.views[viewId].g2Instance && _this[deleteFuncMap[elementInfo.name]]) {
_this[deleteFuncMap[elementInfo.name]](config.views[viewId].g2Instance, config.views[viewId], elementInfo.id);
}
}
});
},
needReExecute: function needReExecute(deleteInfos, elementInfos) {
for (var id in deleteInfos) {
if (reExecuteDeleteElements[elementInfos[id].name] && !elementInfos[id].viewId) {
return true;
}
}
return false;
// return Object.keys(deleteInfos).find((id) => {
// return reExecuteDeleteElements[elementInfos[id].name] && !elementInfos[id].viewId;
// });
},
synchronizeG2Delete: function synchronizeG2Delete(chart, config, deleteInfos, elementInfos) {
var _this2 = this;
Object.keys(deleteInfos).forEach(function (id) {
var funName = deleteFuncMap[elementInfos[id].name];
if (_this2[funName] && !elementInfos[id].viewId) {
_this2[funName](chart, config, id);
}
});
this.deleteViewElement(chart, config, deleteInfos, elementInfos);
}
};
exports.default = iDelete;
/***/ }),
/* 420 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _warning = __webpack_require__(219);
var _warning2 = _interopRequireDefault(_warning);
var _shared = __webpack_require__(82);
var _common = __webpack_require__(189);
var _common2 = _interopRequireDefault(_common);
var _g2Creator = __webpack_require__(191);
var _g2Creator2 = _interopRequireDefault(_g2Creator);
var _configMerge = __webpack_require__(81);
var _configMerge2 = _interopRequireDefault(_configMerge);
var _event = __webpack_require__(190);
var _event2 = _interopRequireDefault(_event);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// import interfaceEs6 from 'interface-es6';
var COORD_FUNC_PROPS = _common2.default.COORD_FUNC_PROPS;
var GEOM_FUNC_PROPS = _common2.default.GEOM_FUNC_PROPS;
var iUpdate = {
needRebuildChart: function needRebuildChart(config) {
if (config.chart.props == null || config.chart.updateProps == null) return false;
var chartProps = config.chart.props;
var nextChartProps = config.chart.updateProps;
if (!_shared.Util.shallowEqual(chartProps.padding, nextChartProps.padding) || !_shared.Util.shallowEqual(chartProps.background, nextChartProps.background) || !_shared.Util.shallowEqual(chartProps.plotBackground, nextChartProps.plotBackground) || !_shared.Util.shallowEqual(chartProps.pixelRatio, nextChartProps.pixelRatio)) return true;
return false;
},
needReExecute: function needReExecute(config) {
var geoms = config.geoms;
if (geoms == null) return false;
for (var id in geoms) {
if (geoms[id].props && geoms[id].updateProps && (geoms[id].props.type !== geoms[id].updateProps.type || geoms[id].props.color && !geoms[id].updateProps.color || geoms[id].props.size && !geoms[id].updateProps.size || geoms[id].props.shape && !geoms[id].updateProps.shape)) return true;
}
return false;
// return Object.keys(geoms).find((id) => {
// if (!geoms[id].props || !geoms[id].updateProps) return false;
// return geoms[id].props.type !== geoms[id].updateProps.type;
// });
},
needRepaint: function needRepaint(config) {
var chartConfig = config.chart;
var data = chartConfig.props.data;
var nextData = chartConfig.updateProps.data;
return data === nextData;
},
synchronizeG2Update: function synchronizeG2Update(chart, config) {
this.updateChart(chart, config.chart);
this.updateAxises(chart, config.axises);
this.updateTooltip(chart, config);
this.updateCoord(chart, config);
this.updateLegends(chart, config.legends);
this.updateGeoms(chart, config.geoms);
this.updateGuide(chart, config.guide);
this.updateFacet(chart, config);
this.updateViews(chart, config);
},
updateChart: function updateChart(chart, chartConfig) {
if (!chartConfig) return;
var props = chartConfig.props;
var nextProps = chartConfig.updateProps;
var width = props.width,
height = props.height,
animate = props.animate,
data = props.data,
scale = props.scale;
var nextWidth = nextProps.width,
nextHeight = nextProps.height,
nextAnimate = nextProps.animate,
nextData = nextProps.data,
nextScale = nextProps.scale;
if (data !== nextData) {
chart.changeData(nextData);
}
if (!_shared.Util.shallowEqual(scale, nextScale)) {
if (_shared.Util.isArray(nextScale)) {
chart.scale(nextScale[0], nextScale[1]);
} else {
chart.scale(nextScale);
}
}
if (animate !== nextAnimate) {
chart.animate(nextAnimate);
}
if (width !== nextWidth && height !== nextHeight) {
chart.changeSize(nextWidth, nextHeight);
} else if (width !== nextWidth) {
chart.changeWidth(nextWidth);
} else if (height !== nextHeight) {
chart.changeHeight(nextHeight);
}
_event2.default.updateEvents(chart, _event2.default.chartEvents, chartConfig.props, nextProps);
_event2.default.updateBaseEvents(chart, chartConfig.updateProps, nextProps);
},
updateAxis: function updateAxis(chart, axisConfig) {
var _axisConfig$props = axisConfig.props,
name = _axisConfig$props.name,
visible = _axisConfig$props.visible,
others = _objectWithoutProperties(_axisConfig$props, ['name', 'visible']);
var _axisConfig$updatePro = axisConfig.updateProps,
nextName = _axisConfig$updatePro.name,
nextVisible = _axisConfig$updatePro.visible,
nextOthers = _objectWithoutProperties(_axisConfig$updatePro, ['name', 'visible']);
(0, _warning2.default)(name === nextName, '`name` propertry should not be changed in ``');
if (visible !== nextVisible) {
chart.axis(name, !!nextVisible);
}
// todo others have g2Instance
if (!_shared.Util.shallowEqual(others, nextOthers)) {
chart.axis(name, nextOthers);
}
},
updateAxises: function updateAxises(chart, axises) {
if (!axises) return;
for (var id in axises) {
if (axises[id] && axises[id].props && axises[id].updateProps) {
this.updateAxis(chart, axises[id]);
}
}
},
updateTooltip: function updateTooltip(chart, config) {
if (!config.tooltip) return;
var props = config.tooltip.props;
var nextProps = config.tooltip.updateProps;
if (props == null && nextProps == null) {
return;
}
if (!_shared.Util.shallowEqual(props, nextProps)) {
chart.tooltip(_extends({}, nextProps));
}
},
updateCoord: function updateCoord(chart, config) {
var coordConfig = config.coord;
if (!coordConfig) return;
var props = coordConfig.props;
var nextProps = coordConfig.updateProps;
if (props == null || nextProps == null) {
return;
}
// type can not be in coord's second param.
var nextAttrs = _shared.Util.without(nextProps, COORD_FUNC_PROPS.concat(['type']));
if (!_shared.Util.shallowEqual(props, nextProps)) {
var g2Instance = chart.coord(nextProps.type, nextAttrs);
coordConfig.g2Instance = g2Instance;
_shared.Prop.init(COORD_FUNC_PROPS, nextProps, function (value, key) {
if (key === 'reflect') {
_shared.Util.each(value, function (v) {
return g2Instance[key](v);
});
} else {
g2Instance[key].apply(g2Instance, _toConsumableArray(value));
}
});
}
},
updateLegend: function updateLegend(chart, legendConfig) {
var props = legendConfig.props;
var nextProps = legendConfig.updateProps;
if (!nextProps) return;
if (_shared.Util.shallowEqual(props, nextProps)) {
return;
}
var name = nextProps.name,
visible = nextProps.visible,
cfg = _objectWithoutProperties(nextProps, ['name', 'visible']);
var arg = !visible ? visible : cfg;
chart.legend.apply(chart, _toConsumableArray(name ? [name, arg] : [arg]));
},
updateLegends: function updateLegends(chart, legends) {
if (legends == null) {
return;
}
for (var id in legends) {
if (legends[id]) {
this.updateLegend(chart, legends[id]);
}
}
},
updateLabel: function updateLabel(geom, props, nextProps) {
if (props == null || nextProps == null) {
return;
}
var content = props.content,
others = _objectWithoutProperties(props, ['content']);
var nextContent = nextProps.content,
nextOthers = _objectWithoutProperties(nextProps, ['content']);
if (!_shared.Util.shallowEqual(others, nextOthers) || !_shared.Util.shallowEqual(content, nextContent)) {
if (_shared.Util.isArray(nextContent)) {
geom.label(nextContent[0], nextContent[1], nextOthers);
} else {
geom.label(nextContent, nextOthers);
}
}
},
updateGeom: function updateGeom(chart, geomConfig) {
var props = geomConfig.props;
var nextProps = geomConfig.updateProps;
if (!props || !nextProps) return;
if (props.type !== nextProps.type) {
// needReExecute chart
return;
}
var geom = geomConfig.g2Instance;
if (_shared.Util.shallowEqual(props, nextProps)) {
if (geomConfig.label) {
this.updateLabel(geom, geomConfig.label.props, geomConfig.label.updateProps);
}
return;
}
var adjust = props.adjust,
attrs = _objectWithoutProperties(props, ['adjust']);
var nextAdjust = nextProps.adjust,
nextAttrs = _objectWithoutProperties(nextProps, ['adjust']);
if (adjust || nextAdjust) {
geom.adjust(nextAdjust);
}
_shared.Prop.update(GEOM_FUNC_PROPS, attrs, nextAttrs, function (value, key) {
geom[key].apply(geom, _toConsumableArray(value));
});
if (geomConfig.label) {
this.updateLabel(geom, geomConfig.label.props, geomConfig.label.updateProps);
}
},
updateGeoms: function updateGeoms(chart, geoms) {
if (geoms == null) {
return false;
}
for (var id in geoms) {
if (geoms[id]) {
this.updateGeom(chart, geoms[id]);
}
}
return false;
},
isTypedGuideChanged: function isTypedGuideChanged(config) {
if (!_shared.Util.shallowEqual(config.props, config.updateProps)) {
return true;
}
return false;
},
updateGuide: function updateGuide(chart, guide) {
if (!guide || !guide.elements) {
return;
}
var guides = guide.elements;
var needRebuildGuide = false;
for (var id in guides) {
if (guides[id]) {
if (guides[id].updateProps || this.isTypedGuideChanged(guides[id])) {
needRebuildGuide = true;
break;
}
}
}
if (needRebuildGuide) {
_configMerge2.default.mergeGuide(guide, true);
chart.guide().clear();
_g2Creator2.default.guide(chart, guide);
}
},
updateView: function updateView(chart, viewInfo) {
if (!viewInfo || !viewInfo.props || !viewInfo.updateProps || viewInfo.parentInfo.name === 'Facet') {
return;
}
var view = viewInfo.g2Instance;
var props = viewInfo.props;
var nextProps = viewInfo.updateProps;
/*
Others object must exclude geoms property.
Because geoms property will cover the g2 view' inner geoms property.
*/
var scale = props.scale,
data = props.data,
animate = props.animate,
axis = props.axis,
filter = props.filter;
var nextScale = nextProps.scale,
nextAnimate = nextProps.animate,
nextData = nextProps.data,
nextAxis = nextProps.axis,
nextFilter = nextProps.filter;
if (animate !== nextAnimate) {
view.animate(nextAnimate);
}
if (data !== nextData) {
view.changeData(nextData);
}
if (!_shared.Util.shallowEqual(scale, nextScale)) {
view.scale(nextScale);
}
if (!_shared.Util.shallowEqual(filter, nextFilter)) {
nextFilter.forEach(function (filterArg) {
view.filter(filterArg[0], filterArg[1]);
});
}
if (axis !== nextAxis) {
view.axis(nextAxis);
}
this.updateCoord(view, viewInfo);
this.updateAxises(view, viewInfo.axises);
this.updateGeoms(view, viewInfo.geoms);
this.updateGuide(view, viewInfo.guide);
},
updateViews: function updateViews(chart, config) {
var views = config.views;
if (!views) return;
for (var id in views) {
var curView = views[id];
if (curView && (curView.needReExecute || this.needReExecute(curView))) {
_g2Creator2.default.synchronizeG2View(curView.g2Instance, curView);
views[id].needReExecute = false;
} else {
this.updateView(chart, curView);
}
}
},
updateFacet: function updateFacet(chart, config) {
var facetConfig = config.facet;
if (!facetConfig) return;
var props = facetConfig.props;
var nextProps = facetConfig.updateProps;
if (props == null || nextProps == null) return;
var type = props.type,
others = _objectWithoutProperties(props, ['type']);
var nextType = nextProps.type,
nextOthers = _objectWithoutProperties(nextProps, ['type']);
if (type !== nextType || !_shared.Util.shallowEqual(others, nextOthers)) {
facetConfig.props = nextProps;
_g2Creator2.default.facet(chart, config);
}
}
};
exports.default = iUpdate;
/***/ }),
/* 421 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _configAdd = __webpack_require__(418);
var _configAdd2 = _interopRequireDefault(_configAdd);
var _configMerge = __webpack_require__(81);
var _configMerge2 = _interopRequireDefault(_configMerge);
var _g2Update = __webpack_require__(420);
var _g2Update2 = _interopRequireDefault(_g2Update);
var _g2Delete = __webpack_require__(419);
var _g2Delete2 = _interopRequireDefault(_g2Delete);
var _g2Creator = __webpack_require__(191);
var _g2Creator2 = _interopRequireDefault(_g2Creator);
var _shared = __webpack_require__(82);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Processor = function () {
function Processor() {
_classCallCheck(this, Processor);
this.config = {};
this.elementInfos = {};
this.added = false;
this.initedG2 = false;
this.updated = false;
this.deleted = false;
this.deleteInfos = {};
}
_createClass(Processor, [{
key: 'calUpdateFlag',
value: function calUpdateFlag(name, id) {
/* eslint-disable no-unused-vars */
var _elementInfos$id$prop = this.elementInfos[id].props,
children = _elementInfos$id$prop.children,
props = _objectWithoutProperties(_elementInfos$id$prop, ['children']);
var _elementInfos$id$upda = this.elementInfos[id].updateProps,
nextChildren = _elementInfos$id$upda.children,
nextProps = _objectWithoutProperties(_elementInfos$id$upda, ['children']);
/* eslint-enable */
if (name === 'Chart' || name === 'View') {
var data = props.data,
otherProps = _objectWithoutProperties(props, ['data']);
var nextData = nextProps.data,
nextOtherProps = _objectWithoutProperties(nextProps, ['data']);
if (data !== nextData || !_shared.Util.isEqual(otherProps, nextOtherProps)) {
this.updated = true;
}
} else if (!_shared.Util.isEqual(props, nextProps)) {
this.updated = true;
}
}
}, {
key: 'addElement',
value: function addElement(name, id, props, parentInfo, viewId) {
if (!this.chart && this.initedG2) return;
this.added = true;
this.elementInfos[id] = {
id: id,
viewId: viewId,
parentInfo: parentInfo,
name: name,
props: _extends({}, props)
};
if (parentInfo && !this.elementInfos[parentInfo.id]) {
this.elementInfos[parentInfo.id] = {
id: parentInfo.id,
name: parentInfo.name
};
}
_configAdd2.default.addElement(name, this.config, this.elementInfos[id]);
}
}, {
key: 'updateElement',
value: function updateElement(name, id, props) {
this.elementInfos[id].updateProps = _extends({}, props);
this.calUpdateFlag(name, id);
}
}, {
key: 'deleteElement',
value: function deleteElement(name, id) {
if (!this.chart) return;
this.deleteInfos[id] = id;
this.deleted = true;
}
}, {
key: 'createG2Instance',
value: function createG2Instance() {
var config = this.config;
var chart = _g2Creator2.default.createChart(config, this.elementInfos);
_g2Creator2.default.executeChartConfig(chart, config, this.elementInfos);
_g2Creator2.default.synchronizeG2Add(chart, config, this.elementInfos);
chart.render();
this.chart = chart;
this.initedG2 = true;
this.resetStates();
return chart;
}
}, {
key: 'destory',
value: function destory() {
this.chart.destroy();
this.chart = null;
}
}, {
key: 'resetStates',
value: function resetStates() {
var elems = this.elementInfos;
for (var id in elems) {
if (elems[id].updateProps) delete elems[id].updateProps;
if (this.deleteInfos[id]) {
delete elems[id];
}
}
this.added = false;
this.updated = false;
this.deleteInfos = {};
}
}, {
key: 'reExecuteChart',
value: function reExecuteChart() {
this.chart.clear();
_configMerge2.default.merge(this.config, this.deleteInfos, this.elementInfos, true);
_g2Creator2.default.executeChartConfig(this.chart, this.config, this.elementInfos);
_g2Creator2.default.synchronizeG2Add(this.chart, this.config, this.elementInfos);
this.chart.repaint();
this.resetStates();
return this.chart;
}
}, {
key: 'batchedUpdate',
value: function batchedUpdate() {
if (this.chart == null) return null;
if (this.config.chart.props.forceUpdate || _g2Update2.default.needRebuildChart(this.config)) {
_configMerge2.default.merge(this.config, this.deleteInfos, this.elementInfos, true);
this.chart.destroy();
this.chart = 'destroy';
return this.createG2Instance();
}
if (_g2Delete2.default.needReExecute(this.deleteInfos, this.elementInfos) || _g2Update2.default.needReExecute(this.config)) {
this.reExecuteChart();
return this.chart;
}
if (this.deleted) {
_g2Delete2.default.synchronizeG2Delete(this.chart, this.config, this.deleteInfos, this.elementInfos);
_configMerge2.default.mergeDelete(this.config, this.deleteInfos, this.elementInfos);
}
if (this.added) {
_g2Creator2.default.synchronizeG2Add(this.chart, this.config);
}
if (this.updated) {
_g2Update2.default.synchronizeG2Update(this.chart, this.config);
}
// if (g2Update.needRepaint(this.config) && (this.added || this.deleted || this.updated)) {
if (this.added || this.deleted || this.updated) {
this.chart.repaint();
}
_configMerge2.default.mergeUpdate(this.config, false);
this.resetStates();
return this.chart;
}
}]);
return Processor;
}();
exports.default = Processor;
/***/ }),
/* 422 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _util = __webpack_require__(54);
var _util2 = _interopRequireDefault(_util);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
init: function init() {
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var props = arguments[1];
var callback = arguments[2];
_util2.default.each(keys, function (key) {
var value = props[key];
if (value !== undefined) {
if (!_util2.default.isArray(value)) {
value = [value];
}
callback(value, key);
}
});
},
update: function update(keys, props, nextProps, callback) {
var value = void 0;
var nextValue = void 0;
_util2.default.each(keys, function (key) {
value = props[key];
nextValue = nextProps[key];
if (!_util2.default.shallowEqual(nextValue, value)) {
if (!_util2.default.isArray(nextValue)) {
nextValue = [nextValue];
}
callback(nextValue, key);
}
});
}
}; /**
* prop function
*/
/***/ }),
/* 423 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* themes
*/
exports.default = {};
/***/ }),
/* 424 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = cubehelix;
/* unused harmony export Cubehelix */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(83);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(192);
var A = -0.14861,
B = +1.78277,
C = -0.29227,
D = -0.90649,
E = +1.97294,
ED = E * D,
EB = E * B,
BC_DA = B * C - D * A;
function cubehelixConvert(o) {
if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["a" /* Rgb */])) o = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* rgbConvert */])(o);
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
bl = b - l,
k = (E * (g - l) - C * bl) / D,
s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* rad2deg */] - 120 : NaN;
return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
}
function cubehelix(h, s, l, opacity) {
return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
}
function Cubehelix(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* Color */], {
brighter: function(k) {
k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* brighter */], k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
darker: function(k) {
k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["e" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["e" /* darker */], k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
rgb: function() {
var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* deg2rad */],
l = +this.l,
a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
cosh = Math.cos(h),
sinh = Math.sin(h);
return new __WEBPACK_IMPORTED_MODULE_1__color__["a" /* Rgb */](
255 * (l + a * (A * cosh + B * sinh)),
255 * (l + a * (C * cosh + D * sinh)),
255 * (l + a * (E * cosh)),
this.opacity
);
}
}));
/***/ }),
/* 425 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export gray */
/* harmony export (immutable) */ __webpack_exports__["b"] = lab;
/* unused harmony export Lab */
/* unused harmony export lch */
/* harmony export (immutable) */ __webpack_exports__["a"] = hcl;
/* unused harmony export Hcl */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(83);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(192);
// https://beta.observablehq.com/@mbostock/lab-and-rgb
var K = 18,
Xn = 0.96422,
Yn = 1,
Zn = 0.82521,
t0 = 4 / 29,
t1 = 6 / 29,
t2 = 3 * t1 * t1,
t3 = t1 * t1 * t1;
function labConvert(o) {
if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
if (o instanceof Hcl) {
if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* deg2rad */];
return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
}
if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["a" /* Rgb */])) o = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* rgbConvert */])(o);
var r = rgb2lrgb(o.r),
g = rgb2lrgb(o.g),
b = rgb2lrgb(o.b),
y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
if (r === g && g === b) x = z = y; else {
x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
}
return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
}
function gray(l, opacity) {
return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
}
function lab(l, a, b, opacity) {
return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
}
function Lab(l, a, b, opacity) {
this.l = +l;
this.a = +a;
this.b = +b;
this.opacity = +opacity;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* Color */], {
brighter: function(k) {
return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
darker: function(k) {
return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
rgb: function() {
var y = (this.l + 16) / 116,
x = isNaN(this.a) ? y : y + this.a / 500,
z = isNaN(this.b) ? y : y - this.b / 200;
x = Xn * lab2xyz(x);
y = Yn * lab2xyz(y);
z = Zn * lab2xyz(z);
return new __WEBPACK_IMPORTED_MODULE_1__color__["a" /* Rgb */](
lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
this.opacity
);
}
}));
function xyz2lab(t) {
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
}
function lab2xyz(t) {
return t > t1 ? t * t * t : t2 * (t - t0);
}
function lrgb2rgb(x) {
return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
}
function rgb2lrgb(x) {
return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
}
function hclConvert(o) {
if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
if (!(o instanceof Lab)) o = labConvert(o);
if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity);
var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* rad2deg */];
return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
}
function lch(l, c, h, opacity) {
return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
}
function hcl(h, c, l, opacity) {
return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
}
function Hcl(h, c, l, opacity) {
this.h = +h;
this.c = +c;
this.l = +l;
this.opacity = +opacity;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* Color */], {
brighter: function(k) {
return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
},
darker: function(k) {
return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
},
rgb: function() {
return labConvert(this).rgb();
}
}));
/***/ }),
/* 426 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var noop = {value: function() {}};
function dispatch() {
for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
if (!(t = arguments[i] + "") || (t in _)) throw new Error("illegal type: " + t);
_[t] = [];
}
return new Dispatch(_);
}
function Dispatch(_) {
this._ = _;
}
function parseTypenames(typenames, types) {
return typenames.trim().split(/^|\s+/).map(function(t) {
var name = "", i = t.indexOf(".");
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
return {type: t, name: name};
});
}
Dispatch.prototype = dispatch.prototype = {
constructor: Dispatch,
on: function(typename, callback) {
var _ = this._,
T = parseTypenames(typename + "", _),
t,
i = -1,
n = T.length;
// If no callback was specified, return the callback of the given type and name.
if (arguments.length < 2) {
while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
return;
}
// If a type was specified, set the callback for the given type and name.
// Otherwise, if a null callback was specified, remove callbacks of the given name.
if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
while (++i < n) {
if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
}
return this;
},
copy: function() {
var copy = {}, _ = this._;
for (var t in _) copy[t] = _[t].slice();
return new Dispatch(copy);
},
call: function(type, that) {
if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
},
apply: function(type, that, args) {
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
}
};
function get(type, name) {
for (var i = 0, n = type.length, c; i < n; ++i) {
if ((c = type[i]).name === name) {
return c.value;
}
}
}
function set(type, name, callback) {
for (var i = 0, n = type.length; i < n; ++i) {
if (type[i].name === name) {
type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
break;
}
}
if (callback != null) type.push({name: name, value: callback});
return type;
}
/* harmony default export */ __webpack_exports__["a"] = (dispatch);
/***/ }),
/* 427 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dispatch__ = __webpack_require__(426);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__dispatch__["a"]; });
/***/ }),
/* 428 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return backIn; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return backOut; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return backInOut; });
var overshoot = 1.70158;
var backIn = (function custom(s) {
s = +s;
function backIn(t) {
return t * t * ((s + 1) * t - s);
}
backIn.overshoot = custom;
return backIn;
})(overshoot);
var backOut = (function custom(s) {
s = +s;
function backOut(t) {
return --t * t * ((s + 1) * t + s) + 1;
}
backOut.overshoot = custom;
return backOut;
})(overshoot);
var backInOut = (function custom(s) {
s = +s;
function backInOut(t) {
return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
}
backInOut.overshoot = custom;
return backInOut;
})(overshoot);
/***/ }),
/* 429 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = bounceIn;
/* harmony export (immutable) */ __webpack_exports__["a"] = bounceOut;
/* harmony export (immutable) */ __webpack_exports__["c"] = bounceInOut;
var b1 = 4 / 11,
b2 = 6 / 11,
b3 = 8 / 11,
b4 = 3 / 4,
b5 = 9 / 11,
b6 = 10 / 11,
b7 = 15 / 16,
b8 = 21 / 22,
b9 = 63 / 64,
b0 = 1 / b1 / b1;
function bounceIn(t) {
return 1 - bounceOut(1 - t);
}
function bounceOut(t) {
return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
}
function bounceInOut(t) {
return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
}
/***/ }),
/* 430 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = circleIn;
/* harmony export (immutable) */ __webpack_exports__["c"] = circleOut;
/* harmony export (immutable) */ __webpack_exports__["a"] = circleInOut;
function circleIn(t) {
return 1 - Math.sqrt(1 - t * t);
}
function circleOut(t) {
return Math.sqrt(1 - --t * t);
}
function circleInOut(t) {
return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
}
/***/ }),
/* 431 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = cubicIn;
/* harmony export (immutable) */ __webpack_exports__["c"] = cubicOut;
/* harmony export (immutable) */ __webpack_exports__["a"] = cubicInOut;
function cubicIn(t) {
return t * t * t;
}
function cubicOut(t) {
return --t * t * t + 1;
}
function cubicInOut(t) {
return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
}
/***/ }),
/* 432 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return elasticIn; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return elasticOut; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return elasticInOut; });
var tau = 2 * Math.PI,
amplitude = 1,
period = 0.3;
var elasticIn = (function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticIn(t) {
return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
}
elasticIn.amplitude = function(a) { return custom(a, p * tau); };
elasticIn.period = function(p) { return custom(a, p); };
return elasticIn;
})(amplitude, period);
var elasticOut = (function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticOut(t) {
return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
}
elasticOut.amplitude = function(a) { return custom(a, p * tau); };
elasticOut.period = function(p) { return custom(a, p); };
return elasticOut;
})(amplitude, period);
var elasticInOut = (function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticInOut(t) {
return ((t = t * 2 - 1) < 0
? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p)
: 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
}
elasticInOut.amplitude = function(a) { return custom(a, p * tau); };
elasticInOut.period = function(p) { return custom(a, p); };
return elasticInOut;
})(amplitude, period);
/***/ }),
/* 433 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = expIn;
/* harmony export (immutable) */ __webpack_exports__["c"] = expOut;
/* harmony export (immutable) */ __webpack_exports__["a"] = expInOut;
function expIn(t) {
return Math.pow(2, 10 * t - 10);
}
function expOut(t) {
return 1 - Math.pow(2, -10 * t);
}
function expInOut(t) {
return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
}
/***/ }),
/* 434 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = linear;
function linear(t) {
return +t;
}
/***/ }),
/* 435 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return polyIn; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return polyOut; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return polyInOut; });
var exponent = 3;
var polyIn = (function custom(e) {
e = +e;
function polyIn(t) {
return Math.pow(t, e);
}
polyIn.exponent = custom;
return polyIn;
})(exponent);
var polyOut = (function custom(e) {
e = +e;
function polyOut(t) {
return 1 - Math.pow(1 - t, e);
}
polyOut.exponent = custom;
return polyOut;
})(exponent);
var polyInOut = (function custom(e) {
e = +e;
function polyInOut(t) {
return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
}
polyInOut.exponent = custom;
return polyInOut;
})(exponent);
/***/ }),
/* 436 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = quadIn;
/* harmony export (immutable) */ __webpack_exports__["c"] = quadOut;
/* harmony export (immutable) */ __webpack_exports__["a"] = quadInOut;
function quadIn(t) {
return t * t;
}
function quadOut(t) {
return t * (2 - t);
}
function quadInOut(t) {
return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
}
/***/ }),
/* 437 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = sinIn;
/* harmony export (immutable) */ __webpack_exports__["c"] = sinOut;
/* harmony export (immutable) */ __webpack_exports__["a"] = sinInOut;
var pi = Math.PI,
halfPi = pi / 2;
function sinIn(t) {
return 1 - Math.cos(t * halfPi);
}
function sinOut(t) {
return Math.sin(t * halfPi);
}
function sinInOut(t) {
return (1 - Math.cos(pi * t)) / 2;
}
/***/ }),
/* 438 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(86);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolate", function() { return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(194);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateArray", function() { return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(85);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasis", function() { return __WEBPACK_IMPORTED_MODULE_2__src_basis__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(195);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(197);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateDate", function() { return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(55);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateNumber", function() { return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(198);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateObject", function() { return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(444);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRound", function() { return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(200);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateString", function() { return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(446);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(448);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateZoom", function() { return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(199);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgb", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(441);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHsl", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHslLong", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(442);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateLab", function() { return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(440);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHcl", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHclLong", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(439);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(443);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "quantize", function() { return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"]; });
/***/ }),
/* 439 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return cubehelixLong; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(40);
function cubehelix(hue) {
return (function cubehelixGamma(y) {
y = +y;
function cubehelix(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* cubehelix */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* cubehelix */])(end)).h),
s = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = cubehelixGamma;
return cubehelix;
})(1);
}
/* harmony default export */ __webpack_exports__["a"] = (cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 440 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hclLong; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(40);
function hcl(hue) {
return function(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* hcl */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* hcl */])(end)).h),
c = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
/* harmony default export */ __webpack_exports__["a"] = (hcl(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 441 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hslLong; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(40);
function hsl(hue) {
return function(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h),
s = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
/* harmony default export */ __webpack_exports__["a"] = (hsl(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 442 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(40);
function lab(start, end) {
var l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* lab */])(start)).l, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* lab */])(end)).l),
a = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
b = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.l = l(t);
start.a = a(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
/***/ }),
/* 443 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(interpolator, n) {
var samples = new Array(n);
for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
return samples;
});
/***/ }),
/* 444 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return a = +a, b -= a, function(t) {
return Math.round(a + b * t);
};
});
/***/ }),
/* 445 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return identity; });
var degrees = 180 / Math.PI;
var identity = {
translateX: 0,
translateY: 0,
rotate: 0,
skewX: 0,
scaleX: 1,
scaleY: 1
};
/* harmony default export */ __webpack_exports__["b"] = (function(a, b, c, d, e, f) {
var scaleX, scaleY, skewX;
if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
return {
translateX: e,
translateY: f,
rotate: Math.atan2(b, a) * degrees,
skewX: Math.atan(skewX) * degrees,
scaleX: scaleX,
scaleY: scaleY
};
});
/***/ }),
/* 446 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return interpolateTransformCss; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return interpolateTransformSvg; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(447);
function interpolateTransform(parse, pxComma, pxParen, degParen) {
function pop(s) {
return s.length ? s.pop() + " " : "";
}
function translate(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push("translate(", null, pxComma, null, pxParen);
q.push({i: i - 4, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb)}, {i: i - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb)});
} else if (xb || yb) {
s.push("translate(" + xb + pxComma + yb + pxParen);
}
}
function rotate(a, b, s, q) {
if (a !== b) {
if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path
q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b)});
} else if (b) {
s.push(pop(s) + "rotate(" + b + degParen);
}
}
function skewX(a, b, s, q) {
if (a !== b) {
q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b)});
} else if (b) {
s.push(pop(s) + "skewX(" + b + degParen);
}
}
function scale(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push(pop(s) + "scale(", null, ",", null, ")");
q.push({i: i - 4, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb)}, {i: i - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb)});
} else if (xb !== 1 || yb !== 1) {
s.push(pop(s) + "scale(" + xb + "," + yb + ")");
}
}
return function(a, b) {
var s = [], // string constants and placeholders
q = []; // number interpolators
a = parse(a), b = parse(b);
translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
rotate(a.rotate, b.rotate, s, q);
skewX(a.skewX, b.skewX, s, q);
scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
a = b = null; // gc
return function(t) {
var i = -1, n = q.length, o;
while (++i < n) s[(o = q[i]).i] = o.x(t);
return s.join("");
};
};
}
var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
/***/ }),
/* 447 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = parseCss;
/* harmony export (immutable) */ __webpack_exports__["b"] = parseSvg;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(445);
var cssNode,
cssRoot,
cssView,
svgNode;
function parseCss(value) {
if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
cssNode.style.transform = value;
value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
cssRoot.removeChild(cssNode);
value = value.slice(7, -1).split(",");
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
}
function parseSvg(value) {
if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
svgNode.setAttribute("transform", value);
if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
value = value.matrix;
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
}
/***/ }),
/* 448 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var rho = Math.SQRT2,
rho2 = 2,
rho4 = 4,
epsilon2 = 1e-12;
function cosh(x) {
return ((x = Math.exp(x)) + 1 / x) / 2;
}
function sinh(x) {
return ((x = Math.exp(x)) - 1 / x) / 2;
}
function tanh(x) {
return ((x = Math.exp(2 * x)) - 1) / (x + 1);
}
// p0 = [ux0, uy0, w0]
// p1 = [ux1, uy1, w1]
/* harmony default export */ __webpack_exports__["a"] = (function(p0, p1) {
var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],
ux1 = p1[0], uy1 = p1[1], w1 = p1[2],
dx = ux1 - ux0,
dy = uy1 - uy0,
d2 = dx * dx + dy * dy,
i,
S;
// Special case for u0 ≅ u1.
if (d2 < epsilon2) {
S = Math.log(w1 / w0) / rho;
i = function(t) {
return [
ux0 + t * dx,
uy0 + t * dy,
w0 * Math.exp(rho * t * S)
];
}
}
// General case.
else {
var d1 = Math.sqrt(d2),
b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
S = (r1 - r0) / rho;
i = function(t) {
var s = t * S,
coshr0 = cosh(r0),
u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
return [
ux0 + u * dx,
uy0 + u * dy,
w0 * coshr0 / cosh(rho * s + r0)
];
}
}
i.duration = S * 1000;
return i;
});
/***/ }),
/* 449 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export cubehelixLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(30);
function cubehelix(hue) {
return (function cubehelixGamma(y) {
y = +y;
function cubehelix(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* cubehelix */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* cubehelix */])(end)).h),
s = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = cubehelixGamma;
return cubehelix;
})(1);
}
/* unused harmony default export */ var _unused_webpack_default_export = (cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 450 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony default export */ var _unused_webpack_default_export = (function(range) {
var n = range.length;
return function(t) {
return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
};
});
/***/ }),
/* 451 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export hclLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(30);
function hcl(hue) {
return function(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* hcl */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* hcl */])(end)).h),
c = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
/* unused harmony default export */ var _unused_webpack_default_export = (hcl(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 452 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export hslLong */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(30);
function hsl(hue) {
return function(start, end) {
var h = hue((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h),
s = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
/* unused harmony default export */ var _unused_webpack_default_export = (hsl(__WEBPACK_IMPORTED_MODULE_1__color__["b" /* hue */]));
var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
/***/ }),
/* 453 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__color__ = __webpack_require__(30);
/* unused harmony default export */ var _unused_webpack_default_export = (function(a, b) {
var i = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__color__["b" /* hue */])(+a, +b);
return function(t) {
var x = i(t);
return x - 360 * Math.floor(x / 360);
};
});
/***/ }),
/* 454 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export default */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(30);
function lab(start, end) {
var l = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* lab */])(start)).l, (end = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* lab */])(end)).l),
a = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
b = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
opacity = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
return function(t) {
start.l = l(t);
start.a = a(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
/***/ }),
/* 455 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export default */
function piecewise(interpolate, values) {
var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n);
while (i < n) I[i] = interpolate(v, v = values[++i]);
return function(t) {
var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n)));
return I[i](t - i);
};
}
/***/ }),
/* 456 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony default export */ var _unused_webpack_default_export = (function(interpolator, n) {
var samples = new Array(n);
for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
return samples;
});
/***/ }),
/* 457 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony default export */ var _unused_webpack_default_export = (function(a, b) {
return a = +a, b -= a, function(t) {
return Math.round(a + b * t);
};
});
/***/ }),
/* 458 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return identity; });
var degrees = 180 / Math.PI;
var identity = {
translateX: 0,
translateY: 0,
rotate: 0,
skewX: 0,
scaleX: 1,
scaleY: 1
};
/* harmony default export */ __webpack_exports__["b"] = (function(a, b, c, d, e, f) {
var scaleX, scaleY, skewX;
if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
return {
translateX: e,
translateY: f,
rotate: Math.atan2(b, a) * degrees,
skewX: Math.atan(skewX) * degrees,
scaleX: scaleX,
scaleY: scaleY
};
});
/***/ }),
/* 459 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return interpolateTransformCss; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return interpolateTransformSvg; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(56);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(460);
function interpolateTransform(parse, pxComma, pxParen, degParen) {
function pop(s) {
return s.length ? s.pop() + " " : "";
}
function translate(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push("translate(", null, pxComma, null, pxParen);
q.push({i: i - 4, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb)}, {i: i - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb)});
} else if (xb || yb) {
s.push("translate(" + xb + pxComma + yb + pxParen);
}
}
function rotate(a, b, s, q) {
if (a !== b) {
if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path
q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b)});
} else if (b) {
s.push(pop(s) + "rotate(" + b + degParen);
}
}
function skewX(a, b, s, q) {
if (a !== b) {
q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b)});
} else if (b) {
s.push(pop(s) + "skewX(" + b + degParen);
}
}
function scale(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push(pop(s) + "scale(", null, ",", null, ")");
q.push({i: i - 4, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb)}, {i: i - 2, x: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb)});
} else if (xb !== 1 || yb !== 1) {
s.push(pop(s) + "scale(" + xb + "," + yb + ")");
}
}
return function(a, b) {
var s = [], // string constants and placeholders
q = []; // number interpolators
a = parse(a), b = parse(b);
translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
rotate(a.rotate, b.rotate, s, q);
skewX(a.skewX, b.skewX, s, q);
scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
a = b = null; // gc
return function(t) {
var i = -1, n = q.length, o;
while (++i < n) s[(o = q[i]).i] = o.x(t);
return s.join("");
};
};
}
var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
/***/ }),
/* 460 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = parseCss;
/* harmony export (immutable) */ __webpack_exports__["b"] = parseSvg;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(458);
var cssNode,
cssRoot,
cssView,
svgNode;
function parseCss(value) {
if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
cssNode.style.transform = value;
value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
cssRoot.removeChild(cssNode);
value = value.slice(7, -1).split(",");
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
}
function parseSvg(value) {
if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
svgNode.setAttribute("transform", value);
if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* identity */];
value = value.matrix;
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
}
/***/ }),
/* 461 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var rho = Math.SQRT2,
rho2 = 2,
rho4 = 4,
epsilon2 = 1e-12;
function cosh(x) {
return ((x = Math.exp(x)) + 1 / x) / 2;
}
function sinh(x) {
return ((x = Math.exp(x)) - 1 / x) / 2;
}
function tanh(x) {
return ((x = Math.exp(2 * x)) - 1) / (x + 1);
}
// p0 = [ux0, uy0, w0]
// p1 = [ux1, uy1, w1]
/* unused harmony default export */ var _unused_webpack_default_export = (function(p0, p1) {
var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],
ux1 = p1[0], uy1 = p1[1], w1 = p1[2],
dx = ux1 - ux0,
dy = uy1 - uy0,
d2 = dx * dx + dy * dy,
i,
S;
// Special case for u0 ≅ u1.
if (d2 < epsilon2) {
S = Math.log(w1 / w0) / rho;
i = function(t) {
return [
ux0 + t * dx,
uy0 + t * dy,
w0 * Math.exp(rho * t * S)
];
}
}
// General case.
else {
var d1 = Math.sqrt(d2),
b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
S = (r1 - r0) / rho;
i = function(t) {
var s = t * S,
coshr0 = cosh(r0),
u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
return [
ux0 + u * dx,
uy0 + u * dy,
w0 * coshr0 / cosh(rho * s + r0)
];
}
}
i.duration = S * 1000;
return i;
});
/***/ }),
/* 462 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return function() {
return x;
};
});
/***/ }),
/* 463 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__creator__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select__ = __webpack_require__(209);
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__select__["a" /* default */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__creator__["a" /* default */])(name).call(document.documentElement));
});
/***/ }),
/* 464 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = local;
var nextId = 0;
function local() {
return new Local;
}
function Local() {
this._ = "@" + (++nextId).toString(36);
}
Local.prototype = local.prototype = {
constructor: Local,
get: function(node) {
var id = this._;
while (!(id in node)) if (!(node = node.parentNode)) return;
return node[id];
},
set: function(node, value) {
return node[this._] = value;
},
remove: function(node) {
return this._ in node && delete node[this._];
},
toString: function() {
return this._;
}
};
/***/ }),
/* 465 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sourceEvent__ = __webpack_require__(94);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__point__ = __webpack_require__(58);
/* harmony default export */ __webpack_exports__["a"] = (function(node) {
var event = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__sourceEvent__["a" /* default */])();
if (event.changedTouches) event = event.changedTouches[0];
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__point__["a" /* default */])(node, event);
});
/***/ }),
/* 466 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__selection_index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function(selector) {
return typeof selector === "string"
? new __WEBPACK_IMPORTED_MODULE_0__selection_index__["b" /* Selection */]([document.querySelectorAll(selector)], [document.documentElement])
: new __WEBPACK_IMPORTED_MODULE_0__selection_index__["b" /* Selection */]([selector == null ? [] : selector], __WEBPACK_IMPORTED_MODULE_0__selection_index__["c" /* root */]);
});
/***/ }),
/* 467 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__creator__ = __webpack_require__(57);
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
var create = typeof name === "function" ? name : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__creator__["a" /* default */])(name);
return this.select(function() {
return this.appendChild(create.apply(this, arguments));
});
});
/***/ }),
/* 468 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__namespace__ = __webpack_require__(90);
function attrRemove(name) {
return function() {
this.removeAttribute(name);
};
}
function attrRemoveNS(fullname) {
return function() {
this.removeAttributeNS(fullname.space, fullname.local);
};
}
function attrConstant(name, value) {
return function() {
this.setAttribute(name, value);
};
}
function attrConstantNS(fullname, value) {
return function() {
this.setAttributeNS(fullname.space, fullname.local, value);
};
}
function attrFunction(name, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.removeAttribute(name);
else this.setAttribute(name, v);
};
}
function attrFunctionNS(fullname, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
else this.setAttributeNS(fullname.space, fullname.local, v);
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
var fullname = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__namespace__["a" /* default */])(name);
if (arguments.length < 2) {
var node = this.node();
return fullname.local
? node.getAttributeNS(fullname.space, fullname.local)
: node.getAttribute(fullname);
}
return this.each((value == null
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
});
/***/ }),
/* 469 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
var callback = arguments[0];
arguments[0] = this;
callback.apply(null, arguments);
return this;
});
/***/ }),
/* 470 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function classArray(string) {
return string.trim().split(/^|\s+/);
}
function classList(node) {
return node.classList || new ClassList(node);
}
function ClassList(node) {
this._node = node;
this._names = classArray(node.getAttribute("class") || "");
}
ClassList.prototype = {
add: function(name) {
var i = this._names.indexOf(name);
if (i < 0) {
this._names.push(name);
this._node.setAttribute("class", this._names.join(" "));
}
},
remove: function(name) {
var i = this._names.indexOf(name);
if (i >= 0) {
this._names.splice(i, 1);
this._node.setAttribute("class", this._names.join(" "));
}
},
contains: function(name) {
return this._names.indexOf(name) >= 0;
}
};
function classedAdd(node, names) {
var list = classList(node), i = -1, n = names.length;
while (++i < n) list.add(names[i]);
}
function classedRemove(node, names) {
var list = classList(node), i = -1, n = names.length;
while (++i < n) list.remove(names[i]);
}
function classedTrue(names) {
return function() {
classedAdd(this, names);
};
}
function classedFalse(names) {
return function() {
classedRemove(this, names);
};
}
function classedFunction(names, value) {
return function() {
(value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
var names = classArray(name + "");
if (arguments.length < 2) {
var list = classList(this.node()), i = -1, n = names.length;
while (++i < n) if (!list.contains(names[i])) return false;
return true;
}
return this.each((typeof value === "function"
? classedFunction : value
? classedTrue
: classedFalse)(names, value));
});
/***/ }),
/* 471 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function selection_cloneShallow() {
return this.parentNode.insertBefore(this.cloneNode(false), this.nextSibling);
}
function selection_cloneDeep() {
return this.parentNode.insertBefore(this.cloneNode(true), this.nextSibling);
}
/* harmony default export */ __webpack_exports__["a"] = (function(deep) {
return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
});
/***/ }),
/* 472 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__enter__ = __webpack_require__(210);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constant__ = __webpack_require__(462);
var keyPrefix = "$"; // Protect against keys like “__proto__”.
function bindIndex(parent, group, enter, update, exit, data) {
var i = 0,
node,
groupLength = group.length,
dataLength = data.length;
// Put any non-null nodes that fit into update.
// Put any null nodes into enter.
// Put any remaining data into enter.
for (; i < dataLength; ++i) {
if (node = group[i]) {
node.__data__ = data[i];
update[i] = node;
} else {
enter[i] = new __WEBPACK_IMPORTED_MODULE_1__enter__["b" /* EnterNode */](parent, data[i]);
}
}
// Put any non-null nodes that don’t fit into exit.
for (; i < groupLength; ++i) {
if (node = group[i]) {
exit[i] = node;
}
}
}
function bindKey(parent, group, enter, update, exit, data, key) {
var i,
node,
nodeByKeyValue = {},
groupLength = group.length,
dataLength = data.length,
keyValues = new Array(groupLength),
keyValue;
// Compute the key for each node.
// If multiple nodes have the same key, the duplicates are added to exit.
for (i = 0; i < groupLength; ++i) {
if (node = group[i]) {
keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
if (keyValue in nodeByKeyValue) {
exit[i] = node;
} else {
nodeByKeyValue[keyValue] = node;
}
}
}
// Compute the key for each datum.
// If there a node associated with this key, join and add it to update.
// If there is not (or the key is a duplicate), add it to enter.
for (i = 0; i < dataLength; ++i) {
keyValue = keyPrefix + key.call(parent, data[i], i, data);
if (node = nodeByKeyValue[keyValue]) {
update[i] = node;
node.__data__ = data[i];
nodeByKeyValue[keyValue] = null;
} else {
enter[i] = new __WEBPACK_IMPORTED_MODULE_1__enter__["b" /* EnterNode */](parent, data[i]);
}
}
// Add any remaining nodes that were not bound to data to exit.
for (i = 0; i < groupLength; ++i) {
if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
exit[i] = node;
}
}
}
/* harmony default export */ __webpack_exports__["a"] = (function(value, key) {
if (!value) {
data = new Array(this.size()), j = -1;
this.each(function(d) { data[++j] = d; });
return data;
}
var bind = key ? bindKey : bindIndex,
parents = this._parents,
groups = this._groups;
if (typeof value !== "function") value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__constant__["a" /* default */])(value);
for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
var parent = parents[j],
group = groups[j],
groupLength = group.length,
data = value.call(parent, parent && parent.__data__, j, parents),
dataLength = data.length,
enterGroup = enter[j] = new Array(dataLength),
updateGroup = update[j] = new Array(dataLength),
exitGroup = exit[j] = new Array(groupLength);
bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
// Now connect the enter nodes to their following update node, such that
// appendChild can insert the materialized enter node before this node,
// rather than at the end of the parent node.
for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
if (previous = enterGroup[i0]) {
if (i0 >= i1) i1 = i0 + 1;
while (!(next = updateGroup[i1]) && ++i1 < dataLength);
previous._next = next || null;
}
}
}
update = new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](update, parents);
update._enter = enter;
update._exit = exit;
return update;
});
/***/ }),
/* 473 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
return arguments.length
? this.property("__data__", value)
: this.node().__data__;
});
/***/ }),
/* 474 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__window__ = __webpack_require__(95);
function dispatchEvent(node, type, params) {
var window = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__window__["a" /* default */])(node),
event = window.CustomEvent;
if (typeof event === "function") {
event = new event(type, params);
} else {
event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
}
function dispatchConstant(type, params) {
return function() {
return dispatchEvent(this, type, params);
};
}
function dispatchFunction(type, params) {
return function() {
return dispatchEvent(this, type, params.apply(this, arguments));
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(type, params) {
return this.each((typeof params === "function"
? dispatchFunction
: dispatchConstant)(type, params));
});
/***/ }),
/* 475 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(callback) {
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
if (node = group[i]) callback.call(node, node.__data__, i, group);
}
}
return this;
});
/***/ }),
/* 476 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
return !this.node();
});
/***/ }),
/* 477 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sparse__ = __webpack_require__(211);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return new __WEBPACK_IMPORTED_MODULE_1__index__["b" /* Selection */](this._exit || this._groups.map(__WEBPACK_IMPORTED_MODULE_0__sparse__["a" /* default */]), this._parents);
});
/***/ }),
/* 478 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__matcher__ = __webpack_require__(208);
/* harmony default export */ __webpack_exports__["a"] = (function(match) {
if (typeof match !== "function") match = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__matcher__["a" /* default */])(match);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
subgroup.push(node);
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](subgroups, this._parents);
});
/***/ }),
/* 479 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function htmlRemove() {
this.innerHTML = "";
}
function htmlConstant(value) {
return function() {
this.innerHTML = value;
};
}
function htmlFunction(value) {
return function() {
var v = value.apply(this, arguments);
this.innerHTML = v == null ? "" : v;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
return arguments.length
? this.each(value == null
? htmlRemove : (typeof value === "function"
? htmlFunction
: htmlConstant)(value))
: this.node().innerHTML;
});
/***/ }),
/* 480 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__creator__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__selector__ = __webpack_require__(93);
function constantNull() {
return null;
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, before) {
var create = typeof name === "function" ? name : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__creator__["a" /* default */])(name),
select = before == null ? constantNull : typeof before === "function" ? before : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__selector__["a" /* default */])(before);
return this.select(function() {
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
});
});
/***/ }),
/* 481 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(onenter, onupdate, onexit) {
var enter = this.enter(), update = this, exit = this.exit();
enter = typeof onenter === "function" ? onenter(enter) : enter.append(onenter + "");
if (onupdate != null) update = onupdate(update);
if (onexit == null) exit.remove(); else onexit(exit);
return enter && update ? enter.merge(update).order() : update;
});
/***/ }),
/* 482 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function lower() {
if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
/* harmony default export */ __webpack_exports__["a"] = (function() {
return this.each(lower);
});
/***/ }),
/* 483 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function(selection) {
for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
if (node = group0[i] || group1[i]) {
merge[i] = node;
}
}
}
for (; j < m0; ++j) {
merges[j] = groups0[j];
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](merges, this._parents);
});
/***/ }),
/* 484 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
var node = group[i];
if (node) return node;
}
}
return null;
});
/***/ }),
/* 485 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
var nodes = new Array(this.size()), i = -1;
this.each(function() { nodes[++i] = this; });
return nodes;
});
/***/ }),
/* 486 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
if (node = group[i]) {
if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
return this;
});
/***/ }),
/* 487 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function propertyRemove(name) {
return function() {
delete this[name];
};
}
function propertyConstant(name, value) {
return function() {
this[name] = value;
};
}
function propertyFunction(name, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) delete this[name];
else this[name] = v;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
return arguments.length > 1
? this.each((value == null
? propertyRemove : typeof value === "function"
? propertyFunction
: propertyConstant)(name, value))
: this.node()[name];
});
/***/ }),
/* 488 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function raise() {
if (this.nextSibling) this.parentNode.appendChild(this);
}
/* harmony default export */ __webpack_exports__["a"] = (function() {
return this.each(raise);
});
/***/ }),
/* 489 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function remove() {
var parent = this.parentNode;
if (parent) parent.removeChild(this);
}
/* harmony default export */ __webpack_exports__["a"] = (function() {
return this.each(remove);
});
/***/ }),
/* 490 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__selector__ = __webpack_require__(93);
/* harmony default export */ __webpack_exports__["a"] = (function(select) {
if (typeof select !== "function") select = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__selector__["a" /* default */])(select);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
if ("__data__" in node) subnode.__data__ = node.__data__;
subgroup[i] = subnode;
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](subgroups, this._parents);
});
/***/ }),
/* 491 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__selectorAll__ = __webpack_require__(213);
/* harmony default export */ __webpack_exports__["a"] = (function(select) {
if (typeof select !== "function") select = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__selectorAll__["a" /* default */])(select);
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if (node = group[i]) {
subgroups.push(select.call(node, node.__data__, i, group));
parents.push(node);
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](subgroups, parents);
});
/***/ }),
/* 492 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {
var size = 0;
this.each(function() { ++size; });
return size;
});
/***/ }),
/* 493 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
/* harmony default export */ __webpack_exports__["a"] = (function(compare) {
if (!compare) compare = ascending;
function compareNode(a, b) {
return a && b ? compare(a.__data__, b.__data__) : !a - !b;
}
for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
if (node = group[i]) {
sortgroup[i] = node;
}
}
sortgroup.sort(compareNode);
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Selection */](sortgroups, this._parents).order();
});
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
/***/ }),
/* 494 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function textRemove() {
this.textContent = "";
}
function textConstant(value) {
return function() {
this.textContent = value;
};
}
function textFunction(value) {
return function() {
var v = value.apply(this, arguments);
this.textContent = v == null ? "" : v;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
return arguments.length
? this.each(value == null
? textRemove : (typeof value === "function"
? textFunction
: textConstant)(value))
: this.node().textContent;
});
/***/ }),
/* 495 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sourceEvent__ = __webpack_require__(94);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__point__ = __webpack_require__(58);
/* harmony default export */ __webpack_exports__["a"] = (function(node, touches, identifier) {
if (arguments.length < 3) identifier = touches, touches = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__sourceEvent__["a" /* default */])().changedTouches;
for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
if ((touch = touches[i]).identifier === identifier) {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__point__["a" /* default */])(node, touch);
}
}
return null;
});
/***/ }),
/* 496 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sourceEvent__ = __webpack_require__(94);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__point__ = __webpack_require__(58);
/* harmony default export */ __webpack_exports__["a"] = (function(node, touches) {
if (touches == null) touches = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__sourceEvent__["a" /* default */])().touches;
for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
points[i] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__point__["a" /* default */])(node, touches[i]);
}
return points;
});
/***/ }),
/* 497 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(97);
/* harmony default export */ __webpack_exports__["a"] = (function(callback, delay, time) {
var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["d" /* Timer */], total = delay;
if (delay == null) return t.restart(callback, delay, time), t;
delay = +delay, time = time == null ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__timer__["a" /* now */])() : +time;
t.restart(function tick(elapsed) {
elapsed += total;
t.restart(tick, total += delay, time);
callback(elapsed);
}, delay, time);
return t;
});
/***/ }),
/* 498 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(97);
/* harmony default export */ __webpack_exports__["a"] = (function(callback, delay, time) {
var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["d" /* Timer */];
delay = delay == null ? 0 : +delay;
t.restart(function(elapsed) {
t.stop();
callback(elapsed + delay);
}, delay, time);
return t;
});
/***/ }),
/* 499 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__transition_index__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__transition_schedule__ = __webpack_require__(13);
var root = [null];
/* harmony default export */ __webpack_exports__["a"] = (function(node, name) {
var schedules = node.__transition,
schedule,
i;
if (schedules) {
name = name == null ? null : name + "";
for (i in schedules) {
if ((schedule = schedules[i]).state > __WEBPACK_IMPORTED_MODULE_1__transition_schedule__["d" /* SCHEDULED */] && schedule.name === name) {
return new __WEBPACK_IMPORTED_MODULE_0__transition_index__["b" /* Transition */]([[node]], root, name, +i);
}
}
}
return null;
});
/***/ }),
/* 500 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__selection_index__ = __webpack_require__(501);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__transition_index__ = __webpack_require__(27);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "transition", function() { return __WEBPACK_IMPORTED_MODULE_1__transition_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__active__ = __webpack_require__(499);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "active", function() { return __WEBPACK_IMPORTED_MODULE_2__active__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__interrupt__ = __webpack_require__(214);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interrupt", function() { return __WEBPACK_IMPORTED_MODULE_3__interrupt__["a"]; });
/***/ }),
/* 501 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__interrupt__ = __webpack_require__(502);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__transition__ = __webpack_require__(503);
__WEBPACK_IMPORTED_MODULE_0_d3_selection__["selection"].prototype.interrupt = __WEBPACK_IMPORTED_MODULE_1__interrupt__["a" /* default */];
__WEBPACK_IMPORTED_MODULE_0_d3_selection__["selection"].prototype.transition = __WEBPACK_IMPORTED_MODULE_2__transition__["a" /* default */];
/***/ }),
/* 502 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__interrupt__ = __webpack_require__(214);
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
return this.each(function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__interrupt__["a" /* default */])(this, name);
});
});
/***/ }),
/* 503 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__transition_index__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__transition_schedule__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_d3_ease__ = __webpack_require__(193);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_d3_timer__ = __webpack_require__(96);
var defaultTiming = {
time: null, // Set on use.
delay: 0,
duration: 250,
ease: __WEBPACK_IMPORTED_MODULE_2_d3_ease__["easeCubicInOut"]
};
function inherit(node, id) {
var timing;
while (!(timing = node.__transition) || !(timing = timing[id])) {
if (!(node = node.parentNode)) {
return defaultTiming.time = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_d3_timer__["now"])(), defaultTiming;
}
}
return timing;
}
/* harmony default export */ __webpack_exports__["a"] = (function(name) {
var id,
timing;
if (name instanceof __WEBPACK_IMPORTED_MODULE_0__transition_index__["b" /* Transition */]) {
id = name._id, name = name._name;
} else {
id = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__transition_index__["c" /* newId */])(), (timing = defaultTiming).time = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_d3_timer__["now"])(), name = name == null ? null : name + "";
}
for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if (node = group[i]) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__transition_schedule__["h" /* default */])(node, name, id, i, group, timing || inherit(node, id));
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0__transition_index__["b" /* Transition */](groups, this._parents, name, id);
});
/***/ }),
/* 504 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_interpolate__ = __webpack_require__(88);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__tween__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__interpolate__ = __webpack_require__(215);
function attrRemove(name) {
return function() {
this.removeAttribute(name);
};
}
function attrRemoveNS(fullname) {
return function() {
this.removeAttributeNS(fullname.space, fullname.local);
};
}
function attrConstant(name, interpolate, value1) {
var string00,
string1 = value1 + "",
interpolate0;
return function() {
var string0 = this.getAttribute(name);
return string0 === string1 ? null
: string0 === string00 ? interpolate0
: interpolate0 = interpolate(string00 = string0, value1);
};
}
function attrConstantNS(fullname, interpolate, value1) {
var string00,
string1 = value1 + "",
interpolate0;
return function() {
var string0 = this.getAttributeNS(fullname.space, fullname.local);
return string0 === string1 ? null
: string0 === string00 ? interpolate0
: interpolate0 = interpolate(string00 = string0, value1);
};
}
function attrFunction(name, interpolate, value) {
var string00,
string10,
interpolate0;
return function() {
var string0, value1 = value(this), string1;
if (value1 == null) return void this.removeAttribute(name);
string0 = this.getAttribute(name);
string1 = value1 + "";
return string0 === string1 ? null
: string0 === string00 && string1 === string10 ? interpolate0
: (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
};
}
function attrFunctionNS(fullname, interpolate, value) {
var string00,
string10,
interpolate0;
return function() {
var string0, value1 = value(this), string1;
if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
string0 = this.getAttributeNS(fullname.space, fullname.local);
string1 = value1 + "";
return string0 === string1 ? null
: string0 === string00 && string1 === string10 ? interpolate0
: (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
var fullname = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["namespace"])(name), i = fullname === "transform" ? __WEBPACK_IMPORTED_MODULE_0_d3_interpolate__["e" /* interpolateTransformSvg */] : __WEBPACK_IMPORTED_MODULE_3__interpolate__["a" /* default */];
return this.attrTween(name, typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__tween__["b" /* tweenValue */])(this, "attr." + name, value))
: value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
: (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value));
});
/***/ }),
/* 505 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
function attrInterpolate(name, i) {
return function(t) {
this.setAttribute(name, i(t));
};
}
function attrInterpolateNS(fullname, i) {
return function(t) {
this.setAttributeNS(fullname.space, fullname.local, i(t));
};
}
function attrTweenNS(fullname, value) {
var t0, i0;
function tween() {
var i = value.apply(this, arguments);
if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i);
return t0;
}
tween._value = value;
return tween;
}
function attrTween(name, value) {
var t0, i0;
function tween() {
var i = value.apply(this, arguments);
if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i);
return t0;
}
tween._value = value;
return tween;
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value) {
var key = "attr." + name;
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
if (value == null) return this.tween(key, null);
if (typeof value !== "function") throw new Error;
var fullname = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_selection__["namespace"])(name);
return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
});
/***/ }),
/* 506 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
function delayFunction(id, value) {
return function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["g" /* init */])(this, id).delay = +value.apply(this, arguments);
};
}
function delayConstant(id, value) {
return value = +value, function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["g" /* init */])(this, id).delay = value;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
var id = this._id;
return arguments.length
? this.each((typeof value === "function"
? delayFunction
: delayConstant)(id, value))
: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(this.node(), id).delay;
});
/***/ }),
/* 507 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
function durationFunction(id, value) {
return function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id).duration = +value.apply(this, arguments);
};
}
function durationConstant(id, value) {
return value = +value, function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id).duration = value;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
var id = this._id;
return arguments.length
? this.each((typeof value === "function"
? durationFunction
: durationConstant)(id, value))
: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(this.node(), id).duration;
});
/***/ }),
/* 508 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
function easeConstant(id, value) {
if (typeof value !== "function") throw new Error;
return function() {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id).ease = value;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
var id = this._id;
return arguments.length
? this.each(easeConstant(id, value))
: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(this.node(), id).ease;
});
/***/ }),
/* 509 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var on0, on1, that = this, id = that._id, size = that.size();
return new Promise(function(resolve, reject) {
var cancel = {value: reject},
end = {value: function() { if (--size === 0) resolve(); }};
that.each(function() {
var schedule = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */])(this, id),
on = schedule.on;
// If this node shared a dispatch with the previous node,
// just assign the updated shared dispatch and we’re done!
// Otherwise, copy-on-write.
if (on !== on0) {
on1 = (on0 = on).copy();
on1._.cancel.push(cancel);
on1._.interrupt.push(cancel);
on1._.end.push(end);
}
schedule.on = on1;
});
});
});
/***/ }),
/* 510 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(27);
/* harmony default export */ __webpack_exports__["a"] = (function(match) {
if (typeof match !== "function") match = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_selection__["matcher"])(match);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
subgroup.push(node);
}
}
}
return new __WEBPACK_IMPORTED_MODULE_1__index__["b" /* Transition */](subgroups, this._parents, this._name, this._id);
});
/***/ }),
/* 511 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(27);
/* harmony default export */ __webpack_exports__["a"] = (function(transition) {
if (transition._id !== this._id) throw new Error;
for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
if (node = group0[i] || group1[i]) {
merge[i] = node;
}
}
}
for (; j < m0; ++j) {
merges[j] = groups0[j];
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Transition */](merges, this._parents, this._name, this._id);
});
/***/ }),
/* 512 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__schedule__ = __webpack_require__(13);
function start(name) {
return (name + "").trim().split(/^|\s+/).every(function(t) {
var i = t.indexOf(".");
if (i >= 0) t = t.slice(0, i);
return !t || t === "start";
});
}
function onFunction(id, name, listener) {
var on0, on1, sit = start(name) ? __WEBPACK_IMPORTED_MODULE_0__schedule__["g" /* init */] : __WEBPACK_IMPORTED_MODULE_0__schedule__["e" /* set */];
return function() {
var schedule = sit(this, id),
on = schedule.on;
// If this node shared a dispatch with the previous node,
// just assign the updated shared dispatch and we’re done!
// Otherwise, copy-on-write.
if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
schedule.on = on1;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, listener) {
var id = this._id;
return arguments.length < 2
? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__schedule__["f" /* get */])(this.node(), id).on.on(name)
: this.each(onFunction(id, name, listener));
});
/***/ }),
/* 513 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function removeFunction(id) {
return function() {
var parent = this.parentNode;
for (var i in this.__transition) if (+i !== id) return;
if (parent) parent.removeChild(this);
};
}
/* harmony default export */ __webpack_exports__["a"] = (function() {
return this.on("end.remove", removeFunction(this._id));
});
/***/ }),
/* 514 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__schedule__ = __webpack_require__(13);
/* harmony default export */ __webpack_exports__["a"] = (function(select) {
var name = this._name,
id = this._id;
if (typeof select !== "function") select = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_selection__["selector"])(select);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
if ("__data__" in node) subnode.__data__ = node.__data__;
subgroup[i] = subnode;
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__schedule__["h" /* default */])(subgroup[i], name, id, i, subgroup, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__schedule__["f" /* get */])(node, id));
}
}
}
return new __WEBPACK_IMPORTED_MODULE_1__index__["b" /* Transition */](subgroups, this._parents, name, id);
});
/***/ }),
/* 515 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__schedule__ = __webpack_require__(13);
/* harmony default export */ __webpack_exports__["a"] = (function(select) {
var name = this._name,
id = this._id;
if (typeof select !== "function") select = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_d3_selection__["selectorAll"])(select);
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if (node = group[i]) {
for (var children = select.call(node, node.__data__, i, group), child, inherit = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__schedule__["f" /* get */])(node, id), k = 0, l = children.length; k < l; ++k) {
if (child = children[k]) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__schedule__["h" /* default */])(child, name, id, k, children, inherit);
}
}
subgroups.push(children);
parents.push(node);
}
}
}
return new __WEBPACK_IMPORTED_MODULE_1__index__["b" /* Transition */](subgroups, parents, name, id);
});
/***/ }),
/* 516 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_selection__ = __webpack_require__(21);
var Selection = __WEBPACK_IMPORTED_MODULE_0_d3_selection__["selection"].prototype.constructor;
/* harmony default export */ __webpack_exports__["a"] = (function() {
return new Selection(this._groups, this._parents);
});
/***/ }),
/* 517 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_interpolate__ = __webpack_require__(88);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_d3_selection__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__schedule__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__tween__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__interpolate__ = __webpack_require__(215);
function styleNull(name, interpolate) {
var string00,
string10,
interpolate0;
return function() {
var string0 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["style"])(this, name),
string1 = (this.style.removeProperty(name), __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["style"])(this, name));
return string0 === string1 ? null
: string0 === string00 && string1 === string10 ? interpolate0
: interpolate0 = interpolate(string00 = string0, string10 = string1);
};
}
function styleRemove(name) {
return function() {
this.style.removeProperty(name);
};
}
function styleConstant(name, interpolate, value1) {
var string00,
string1 = value1 + "",
interpolate0;
return function() {
var string0 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["style"])(this, name);
return string0 === string1 ? null
: string0 === string00 ? interpolate0
: interpolate0 = interpolate(string00 = string0, value1);
};
}
function styleFunction(name, interpolate, value) {
var string00,
string10,
interpolate0;
return function() {
var string0 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["style"])(this, name),
value1 = value(this),
string1 = value1 + "";
if (value1 == null) string1 = value1 = (this.style.removeProperty(name), __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_d3_selection__["style"])(this, name));
return string0 === string1 ? null
: string0 === string00 && string1 === string10 ? interpolate0
: (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
};
}
function styleMaybeRemove(id, name) {
var on0, on1, listener0, key = "style." + name, event = "end." + key, remove;
return function() {
var schedule = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__schedule__["e" /* set */])(this, id),
on = schedule.on,
listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined;
// If this node shared a dispatch with the previous node,
// just assign the updated shared dispatch and we’re done!
// Otherwise, copy-on-write.
if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
schedule.on = on1;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value, priority) {
var i = (name += "") === "transform" ? __WEBPACK_IMPORTED_MODULE_0_d3_interpolate__["a" /* interpolateTransformCss */] : __WEBPACK_IMPORTED_MODULE_4__interpolate__["a" /* default */];
return value == null ? this
.styleTween(name, styleNull(name, i))
.on("end.style." + name, styleRemove(name))
: typeof value === "function" ? this
.styleTween(name, styleFunction(name, i, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__tween__["b" /* tweenValue */])(this, "style." + name, value)))
.each(styleMaybeRemove(this._id, name))
: this
.styleTween(name, styleConstant(name, i, value), priority)
.on("end.style." + name, null);
});
/***/ }),
/* 518 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function styleInterpolate(name, i, priority) {
return function(t) {
this.style.setProperty(name, i(t), priority);
};
}
function styleTween(name, value, priority) {
var t, i0;
function tween() {
var i = value.apply(this, arguments);
if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority);
return t;
}
tween._value = value;
return tween;
}
/* harmony default export */ __webpack_exports__["a"] = (function(name, value, priority) {
var key = "style." + (name += "");
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
if (value == null) return this.tween(key, null);
if (typeof value !== "function") throw new Error;
return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
});
/***/ }),
/* 519 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__tween__ = __webpack_require__(59);
function textConstant(value) {
return function() {
this.textContent = value;
};
}
function textFunction(value) {
return function() {
var value1 = value(this);
this.textContent = value1 == null ? "" : value1;
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(value) {
return this.tween("text", typeof value === "function"
? textFunction(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__tween__["b" /* tweenValue */])(this, "text", value))
: textConstant(value == null ? "" : value + ""));
});
/***/ }),
/* 520 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__schedule__ = __webpack_require__(13);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var name = this._name,
id0 = this._id,
id1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__index__["c" /* newId */])();
for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if (node = group[i]) {
var inherit = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__schedule__["f" /* get */])(node, id0);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__schedule__["h" /* default */])(node, name, id1, i, group, {
time: inherit.time + inherit.delay + inherit.duration,
delay: 0,
duration: inherit.duration,
ease: inherit.ease
});
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0__index__["b" /* Transition */](groups, this._parents, name, id1);
});
/***/ }),
/* 521 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var invariant = function(condition, format, a, b, c, d, e, f) {
if (true) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var error;
if (format === undefined) {
error = new Error(
'Minified exception occurred; use the non-minified dev environment ' +
'for the full error message and additional helpful warnings.'
);
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(
format.replace(/%s/g, function() { return args[argIndex++]; })
);
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
};
module.exports = invariant;
/***/ }),
/* 522 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/***/ }),
/* 523 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var printWarning = function() {};
if (true) {
var ReactPropTypesSecret = __webpack_require__(217);
var loggedTypeFailures = {};
var has = Function.call.bind(Object.prototype.hasOwnProperty);
printWarning = function(text) {
var message = 'Warning: ' + text;
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
}
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param {object} typeSpecs Map of name to a ReactPropType
* @param {object} values Runtime values that need to be type-checked
* @param {string} location e.g. "prop", "context", "child context"
* @param {string} componentName Name of the component for error messages.
* @param {?Function} getStack Returns the component stack.
* @private
*/
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
if (true) {
for (var typeSpecName in typeSpecs) {
if (has(typeSpecs, typeSpecName)) {
var error;
// Prop type validation may throw. In case they do, we don't want to
// fail the render phase where it didn't fail before. So we log it.
// After these have been cleaned up, we'll let them throw.
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
if (typeof typeSpecs[typeSpecName] !== 'function') {
var err = Error(
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
);
err.name = 'Invariant Violation';
throw err;
}
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
} catch (ex) {
error = ex;
}
if (error && !(error instanceof Error)) {
printWarning(
(componentName || 'React class') + ': type specification of ' +
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
'You may have forgotten to pass an argument to the type checker ' +
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
'shape all require an argument).'
);
}
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = true;
var stack = getStack ? getStack() : '';
printWarning(
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
);
}
}
}
}
}
/**
* Resets warning cache when testing.
*
* @private
*/
checkPropTypes.resetWarningCache = function() {
if (true) {
loggedTypeFailures = {};
}
}
module.exports = checkPropTypes;
/***/ }),
/* 524 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactIs = __webpack_require__(218);
var assign = __webpack_require__(522);
var ReactPropTypesSecret = __webpack_require__(217);
var checkPropTypes = __webpack_require__(523);
var has = Function.call.bind(Object.prototype.hasOwnProperty);
var printWarning = function() {};
if (true) {
printWarning = function(text) {
var message = 'Warning: ' + text;
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
}
function emptyFunctionThatReturnsNull() {
return null;
}
module.exports = function(isValidElement, throwOnDirectAccess) {
/* global Symbol */
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
/**
* Returns the iterator method function contained on the iterable object.
*
* Be sure to invoke the function with the iterable as context:
*
* var iteratorFn = getIteratorFn(myIterable);
* if (iteratorFn) {
* var iterator = iteratorFn.call(myIterable);
* ...
* }
*
* @param {?object} maybeIterable
* @return {?function}
*/
function getIteratorFn(maybeIterable) {
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
/**
* Collection of methods that allow declaration and validation of props that are
* supplied to React components. Example usage:
*
* var Props = require('ReactPropTypes');
* var MyArticle = React.createClass({
* propTypes: {
* // An optional string prop named "description".
* description: Props.string,
*
* // A required enum prop named "category".
* category: Props.oneOf(['News','Photos']).isRequired,
*
* // A prop named "dialog" that requires an instance of Dialog.
* dialog: Props.instanceOf(Dialog).isRequired
* },
* render: function() { ... }
* });
*
* A more formal specification of how these methods are used:
*
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
* decl := ReactPropTypes.{type}(.isRequired)?
*
* Each and every declaration produces a function with the same signature. This
* allows the creation of custom validation functions. For example:
*
* var MyLink = React.createClass({
* propTypes: {
* // An optional string or URI prop named "href".
* href: function(props, propName, componentName) {
* var propValue = props[propName];
* if (propValue != null && typeof propValue !== 'string' &&
* !(propValue instanceof URI)) {
* return new Error(
* 'Expected a string or an URI for ' + propName + ' in ' +
* componentName
* );
* }
* }
* },
* render: function() {...}
* });
*
* @internal
*/
var ANONYMOUS = '<>';
// Important!
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
var ReactPropTypes = {
array: createPrimitiveTypeChecker('array'),
bool: createPrimitiveTypeChecker('boolean'),
func: createPrimitiveTypeChecker('function'),
number: createPrimitiveTypeChecker('number'),
object: createPrimitiveTypeChecker('object'),
string: createPrimitiveTypeChecker('string'),
symbol: createPrimitiveTypeChecker('symbol'),
any: createAnyTypeChecker(),
arrayOf: createArrayOfTypeChecker,
element: createElementTypeChecker(),
elementType: createElementTypeTypeChecker(),
instanceOf: createInstanceTypeChecker,
node: createNodeChecker(),
objectOf: createObjectOfTypeChecker,
oneOf: createEnumTypeChecker,
oneOfType: createUnionTypeChecker,
shape: createShapeTypeChecker,
exact: createStrictShapeTypeChecker,
};
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
/*eslint-disable no-self-compare*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
}
/*eslint-enable no-self-compare*/
/**
* We use an Error-like object for backward compatibility as people may call
* PropTypes directly and inspect their output. However, we don't use real
* Errors anymore. We don't inspect their stack anyway, and creating them
* is prohibitively expensive if they are created too often, such as what
* happens in oneOfType() for any type before the one that matched.
*/
function PropTypeError(message) {
this.message = message;
this.stack = '';
}
// Make `instanceof Error` still work for returned errors.
PropTypeError.prototype = Error.prototype;
function createChainableTypeChecker(validate) {
if (true) {
var manualPropTypeCallCache = {};
var manualPropTypeWarningCount = 0;
}
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (secret !== ReactPropTypesSecret) {
if (throwOnDirectAccess) {
// New behavior only for users of `prop-types` package
var err = new Error(
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
'Use `PropTypes.checkPropTypes()` to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
err.name = 'Invariant Violation';
throw err;
} else if ("development" !== 'production' && typeof console !== 'undefined') {
// Old behavior for people using React.PropTypes
var cacheKey = componentName + ':' + propName;
if (
!manualPropTypeCallCache[cacheKey] &&
// Avoid spamming the console because they are often not actionable except for lib authors
manualPropTypeWarningCount < 3
) {
printWarning(
'You are manually calling a React.PropTypes validation ' +
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
'and will throw in the standalone `prop-types` package. ' +
'You may be seeing this warning due to a third-party PropTypes ' +
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
);
manualPropTypeCallCache[cacheKey] = true;
manualPropTypeWarningCount++;
}
}
}
if (props[propName] == null) {
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
}
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
}
return null;
} else {
return validate(props, propName, componentName, location, propFullName);
}
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function createPrimitiveTypeChecker(expectedType) {
function validate(props, propName, componentName, location, propFullName, secret) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== expectedType) {
// `propValue` being instance of, say, date/regexp, pass the 'object'
// check, but we can offer a more precise error message here rather than
// 'of type `object`'.
var preciseType = getPreciseType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createAnyTypeChecker() {
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
}
function createArrayOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
}
var propValue = props[propName];
if (!Array.isArray(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
}
for (var i = 0; i < propValue.length; i++) {
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
if (error instanceof Error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createElementTypeChecker() {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!isValidElement(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createElementTypeTypeChecker() {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!ReactIs.isValidElementType(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createInstanceTypeChecker(expectedClass) {
function validate(props, propName, componentName, location, propFullName) {
if (!(props[propName] instanceof expectedClass)) {
var expectedClassName = expectedClass.name || ANONYMOUS;
var actualClassName = getClassName(props[propName]);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createEnumTypeChecker(expectedValues) {
if (!Array.isArray(expectedValues)) {
if (true) {
if (arguments.length > 1) {
printWarning(
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
);
} else {
printWarning('Invalid argument supplied to oneOf, expected an array.');
}
}
return emptyFunctionThatReturnsNull;
}
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
for (var i = 0; i < expectedValues.length; i++) {
if (is(propValue, expectedValues[i])) {
return null;
}
}
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
var type = getPreciseType(value);
if (type === 'symbol') {
return String(value);
}
return value;
});
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
}
return createChainableTypeChecker(validate);
}
function createObjectOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
}
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
}
for (var key in propValue) {
if (has(propValue, key)) {
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
if (error instanceof Error) {
return error;
}
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createUnionTypeChecker(arrayOfTypeCheckers) {
if (!Array.isArray(arrayOfTypeCheckers)) {
true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
return emptyFunctionThatReturnsNull;
}
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (typeof checker !== 'function') {
printWarning(
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
);
return emptyFunctionThatReturnsNull;
}
}
function validate(props, propName, componentName, location, propFullName) {
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
return null;
}
}
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
}
return createChainableTypeChecker(validate);
}
function createNodeChecker() {
function validate(props, propName, componentName, location, propFullName) {
if (!isNode(props[propName])) {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createShapeTypeChecker(shapeTypes) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
}
for (var key in shapeTypes) {
var checker = shapeTypes[key];
if (!checker) {
continue;
}
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
if (error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createStrictShapeTypeChecker(shapeTypes) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
}
// We need to check all keys in case some are required but missing from
// props.
var allKeys = assign({}, props[propName], shapeTypes);
for (var key in allKeys) {
var checker = shapeTypes[key];
if (!checker) {
return new PropTypeError(
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
);
}
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
if (error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function isNode(propValue) {
switch (typeof propValue) {
case 'number':
case 'string':
case 'undefined':
return true;
case 'boolean':
return !propValue;
case 'object':
if (Array.isArray(propValue)) {
return propValue.every(isNode);
}
if (propValue === null || isValidElement(propValue)) {
return true;
}
var iteratorFn = getIteratorFn(propValue);
if (iteratorFn) {
var iterator = iteratorFn.call(propValue);
var step;
if (iteratorFn !== propValue.entries) {
while (!(step = iterator.next()).done) {
if (!isNode(step.value)) {
return false;
}
}
} else {
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
if (!isNode(entry[1])) {
return false;
}
}
}
}
} else {
return false;
}
return true;
default:
return false;
}
}
function isSymbol(propType, propValue) {
// Native Symbol.
if (propType === 'symbol') {
return true;
}
// falsy value can't be a Symbol
if (!propValue) {
return false;
}
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
if (propValue['@@toStringTag'] === 'Symbol') {
return true;
}
// Fallback for non-spec compliant Symbols which are polyfilled.
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
return true;
}
return false;
}
// Equivalent of `typeof` but with special handling for array and regexp.
function getPropType(propValue) {
var propType = typeof propValue;
if (Array.isArray(propValue)) {
return 'array';
}
if (propValue instanceof RegExp) {
// Old webkits (at least until Android 4.0) return 'function' rather than
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
// passes PropTypes.object.
return 'object';
}
if (isSymbol(propType, propValue)) {
return 'symbol';
}
return propType;
}
// This handles more types than `getPropType`. Only used for error messages.
// See `createPrimitiveTypeChecker`.
function getPreciseType(propValue) {
if (typeof propValue === 'undefined' || propValue === null) {
return '' + propValue;
}
var propType = getPropType(propValue);
if (propType === 'object') {
if (propValue instanceof Date) {
return 'date';
} else if (propValue instanceof RegExp) {
return 'regexp';
}
}
return propType;
}
// Returns a string that is postfixed to a warning about an invalid type.
// For example, "undefined" or "of type array"
function getPostfixForTypeWarning(value) {
var type = getPreciseType(value);
switch (type) {
case 'array':
case 'object':
return 'an ' + type;
case 'boolean':
case 'date':
case 'regexp':
return 'a ' + type;
default:
return type;
}
}
// Returns class name of the object, if any.
function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
return ANONYMOUS;
}
return propValue.constructor.name;
}
ReactPropTypes.checkPropTypes = checkPropTypes;
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/***/ }),
/* 525 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/** @license React v16.8.4
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (true) {
(function() {
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
function isValidElementType(type) {
return typeof type === 'string' || typeof type === 'function' ||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
}
/**
* Forked from fbjs/warning:
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
*
* Only change is we use console.warn instead of console.error,
* and do nothing when 'console' is not supported.
* This really simplifies the code.
* ---
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var lowPriorityWarning = function () {};
{
var printWarning = function (format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.warn(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
lowPriorityWarning = function (condition, format) {
if (format === undefined) {
throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (!condition) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
printWarning.apply(undefined, [format].concat(args));
}
};
}
var lowPriorityWarning$1 = lowPriorityWarning;
function typeOf(object) {
if (typeof object === 'object' && object !== null) {
var $$typeof = object.$$typeof;
switch ($$typeof) {
case REACT_ELEMENT_TYPE:
var type = object.type;
switch (type) {
case REACT_ASYNC_MODE_TYPE:
case REACT_CONCURRENT_MODE_TYPE:
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_SUSPENSE_TYPE:
return type;
default:
var $$typeofType = type && type.$$typeof;
switch ($$typeofType) {
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_PROVIDER_TYPE:
return $$typeofType;
default:
return $$typeof;
}
}
case REACT_LAZY_TYPE:
case REACT_MEMO_TYPE:
case REACT_PORTAL_TYPE:
return $$typeof;
}
}
return undefined;
}
// AsyncMode is deprecated along with isAsyncMode
var AsyncMode = REACT_ASYNC_MODE_TYPE;
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
var Lazy = REACT_LAZY_TYPE;
var Memo = REACT_MEMO_TYPE;
var Portal = REACT_PORTAL_TYPE;
var Profiler = REACT_PROFILER_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false;
// AsyncMode should be deprecated
function isAsyncMode(object) {
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true;
lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
}
}
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
}
function isConcurrentMode(object) {
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
}
function isContextConsumer(object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
function isContextProvider(object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
function isElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
}
function isForwardRef(object) {
return typeOf(object) === REACT_FORWARD_REF_TYPE;
}
function isFragment(object) {
return typeOf(object) === REACT_FRAGMENT_TYPE;
}
function isLazy(object) {
return typeOf(object) === REACT_LAZY_TYPE;
}
function isMemo(object) {
return typeOf(object) === REACT_MEMO_TYPE;
}
function isPortal(object) {
return typeOf(object) === REACT_PORTAL_TYPE;
}
function isProfiler(object) {
return typeOf(object) === REACT_PROFILER_TYPE;
}
function isStrictMode(object) {
return typeOf(object) === REACT_STRICT_MODE_TYPE;
}
function isSuspense(object) {
return typeOf(object) === REACT_SUSPENSE_TYPE;
}
exports.typeOf = typeOf;
exports.AsyncMode = AsyncMode;
exports.ConcurrentMode = ConcurrentMode;
exports.ContextConsumer = ContextConsumer;
exports.ContextProvider = ContextProvider;
exports.Element = Element;
exports.ForwardRef = ForwardRef;
exports.Fragment = Fragment;
exports.Lazy = Lazy;
exports.Memo = Memo;
exports.Portal = Portal;
exports.Profiler = Profiler;
exports.StrictMode = StrictMode;
exports.Suspense = Suspense;
exports.isValidElementType = isValidElementType;
exports.isAsyncMode = isAsyncMode;
exports.isConcurrentMode = isConcurrentMode;
exports.isContextConsumer = isContextConsumer;
exports.isContextProvider = isContextProvider;
exports.isElement = isElement;
exports.isForwardRef = isForwardRef;
exports.isFragment = isFragment;
exports.isLazy = isLazy;
exports.isMemo = isMemo;
exports.isPortal = isPortal;
exports.isProfiler = isProfiler;
exports.isStrictMode = isStrictMode;
exports.isSuspense = isSuspense;
})();
}
/***/ }),
/* 526 */
/***/ (function(module, exports, __webpack_require__) {
(function (global, factory) {
true ? factory(exports, __webpack_require__(21), __webpack_require__(500)) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-transition'], factory) :
(factory((global.venn = {}),global.d3,global.d3));
}(this, (function (exports,d3Selection,d3Transition) { 'use strict';
var SMALL = 1e-10;
/** Returns the intersection area of a bunch of circles (where each circle
is an object having an x,y and radius property) */
function intersectionArea(circles, stats) {
// get all the intersection points of the circles
var intersectionPoints = getIntersectionPoints(circles);
// filter out points that aren't included in all the circles
var innerPoints = intersectionPoints.filter(function (p) {
return containedInCircles(p, circles);
});
var arcArea = 0, polygonArea = 0, arcs = [], i;
// if we have intersection points that are within all the circles,
// then figure out the area contained by them
if (innerPoints.length > 1) {
// sort the points by angle from the center of the polygon, which lets
// us just iterate over points to get the edges
var center = getCenter(innerPoints);
for (i = 0; i < innerPoints.length; ++i ) {
var p = innerPoints[i];
p.angle = Math.atan2(p.x - center.x, p.y - center.y);
}
innerPoints.sort(function(a,b) { return b.angle - a.angle;});
// iterate over all points, get arc between the points
// and update the areas
var p2 = innerPoints[innerPoints.length - 1];
for (i = 0; i < innerPoints.length; ++i) {
var p1 = innerPoints[i];
// polygon area updates easily ...
polygonArea += (p2.x + p1.x) * (p1.y - p2.y);
// updating the arc area is a little more involved
var midPoint = {x : (p1.x + p2.x) / 2,
y : (p1.y + p2.y) / 2},
arc = null;
for (var j = 0; j < p1.parentIndex.length; ++j) {
if (p2.parentIndex.indexOf(p1.parentIndex[j]) > -1) {
// figure out the angle halfway between the two points
// on the current circle
var circle = circles[p1.parentIndex[j]],
a1 = Math.atan2(p1.x - circle.x, p1.y - circle.y),
a2 = Math.atan2(p2.x - circle.x, p2.y - circle.y);
var angleDiff = (a2 - a1);
if (angleDiff < 0) {
angleDiff += 2*Math.PI;
}
// and use that angle to figure out the width of the
// arc
var a = a2 - angleDiff/2,
width = distance(midPoint, {
x : circle.x + circle.radius * Math.sin(a),
y : circle.y + circle.radius * Math.cos(a)
});
// clamp the width to the largest is can actually be
// (sometimes slightly overflows because of FP errors)
if (width > circle.radius * 2) {
width = circle.radius * 2;
}
// pick the circle whose arc has the smallest width
if ((arc === null) || (arc.width > width)) {
arc = { circle : circle,
width : width,
p1 : p1,
p2 : p2};
}
}
}
if (arc !== null) {
arcs.push(arc);
arcArea += circleArea(arc.circle.radius, arc.width);
p2 = p1;
}
}
} else {
// no intersection points, is either disjoint - or is completely
// overlapped. figure out which by examining the smallest circle
var smallest = circles[0];
for (i = 1; i < circles.length; ++i) {
if (circles[i].radius < smallest.radius) {
smallest = circles[i];
}
}
// make sure the smallest circle is completely contained in all
// the other circles
var disjoint = false;
for (i = 0; i < circles.length; ++i) {
if (distance(circles[i], smallest) > Math.abs(smallest.radius - circles[i].radius)) {
disjoint = true;
break;
}
}
if (disjoint) {
arcArea = polygonArea = 0;
} else {
arcArea = smallest.radius * smallest.radius * Math.PI;
arcs.push({circle : smallest,
p1: { x: smallest.x, y : smallest.y + smallest.radius},
p2: { x: smallest.x - SMALL, y : smallest.y + smallest.radius},
width : smallest.radius * 2 });
}
}
polygonArea /= 2;
if (stats) {
stats.area = arcArea + polygonArea;
stats.arcArea = arcArea;
stats.polygonArea = polygonArea;
stats.arcs = arcs;
stats.innerPoints = innerPoints;
stats.intersectionPoints = intersectionPoints;
}
return arcArea + polygonArea;
}
/** returns whether a point is contained by all of a list of circles */
function containedInCircles(point, circles) {
for (var i = 0; i < circles.length; ++i) {
if (distance(point, circles[i]) > circles[i].radius + SMALL) {
return false;
}
}
return true;
}
/** Gets all intersection points between a bunch of circles */
function getIntersectionPoints(circles) {
var ret = [];
for (var i = 0; i < circles.length; ++i) {
for (var j = i + 1; j < circles.length; ++j) {
var intersect = circleCircleIntersection(circles[i],
circles[j]);
for (var k = 0; k < intersect.length; ++k) {
var p = intersect[k];
p.parentIndex = [i,j];
ret.push(p);
}
}
}
return ret;
}
/** Circular segment area calculation. See http://mathworld.wolfram.com/CircularSegment.html */
function circleArea(r, width) {
return r * r * Math.acos(1 - width/r) - (r - width) * Math.sqrt(width * (2 * r - width));
}
/** euclidean distance between two points */
function distance(p1, p2) {
return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) +
(p1.y - p2.y) * (p1.y - p2.y));
}
/** Returns the overlap area of two circles of radius r1 and r2 - that
have their centers separated by distance d. Simpler faster
circle intersection for only two circles */
function circleOverlap(r1, r2, d) {
// no overlap
if (d >= r1 + r2) {
return 0;
}
// completely overlapped
if (d <= Math.abs(r1 - r2)) {
return Math.PI * Math.min(r1, r2) * Math.min(r1, r2);
}
var w1 = r1 - (d * d - r2 * r2 + r1 * r1) / (2 * d),
w2 = r2 - (d * d - r1 * r1 + r2 * r2) / (2 * d);
return circleArea(r1, w1) + circleArea(r2, w2);
}
/** Given two circles (containing a x/y/radius attributes),
returns the intersecting points if possible.
note: doesn't handle cases where there are infinitely many
intersection points (circles are equivalent):, or only one intersection point*/
function circleCircleIntersection(p1, p2) {
var d = distance(p1, p2),
r1 = p1.radius,
r2 = p2.radius;
// if to far away, or self contained - can't be done
if ((d >= (r1 + r2)) || (d <= Math.abs(r1 - r2))) {
return [];
}
var a = (r1 * r1 - r2 * r2 + d * d) / (2 * d),
h = Math.sqrt(r1 * r1 - a * a),
x0 = p1.x + a * (p2.x - p1.x) / d,
y0 = p1.y + a * (p2.y - p1.y) / d,
rx = -(p2.y - p1.y) * (h / d),
ry = -(p2.x - p1.x) * (h / d);
return [{x: x0 + rx, y : y0 - ry },
{x: x0 - rx, y : y0 + ry }];
}
/** Returns the center of a bunch of points */
function getCenter(points) {
var center = {x: 0, y: 0};
for (var i =0; i < points.length; ++i ) {
center.x += points[i].x;
center.y += points[i].y;
}
center.x /= points.length;
center.y /= points.length;
return center;
}
/** finds the zeros of a function, given two starting points (which must
* have opposite signs */
function bisect(f, a, b, parameters) {
parameters = parameters || {};
var maxIterations = parameters.maxIterations || 100,
tolerance = parameters.tolerance || 1e-10,
fA = f(a),
fB = f(b),
delta = b - a;
if (fA * fB > 0) {
throw "Initial bisect points must have opposite signs";
}
if (fA === 0) return a;
if (fB === 0) return b;
for (var i = 0; i < maxIterations; ++i) {
delta /= 2;
var mid = a + delta,
fMid = f(mid);
if (fMid * fA >= 0) {
a = mid;
}
if ((Math.abs(delta) < tolerance) || (fMid === 0)) {
return mid;
}
}
return a + delta;
}
// need some basic operations on vectors, rather than adding a dependency,
// just define here
function zeros(x) { var r = new Array(x); for (var i = 0; i < x; ++i) { r[i] = 0; } return r; }
function zerosM(x,y) { return zeros(x).map(function() { return zeros(y); }); }
function dot(a, b) {
var ret = 0;
for (var i = 0; i < a.length; ++i) {
ret += a[i] * b[i];
}
return ret;
}
function norm2(a) {
return Math.sqrt(dot(a, a));
}
function scale(ret, value, c) {
for (var i = 0; i < value.length; ++i) {
ret[i] = value[i] * c;
}
}
function weightedSum(ret, w1, v1, w2, v2) {
for (var j = 0; j < ret.length; ++j) {
ret[j] = w1 * v1[j] + w2 * v2[j];
}
}
/** minimizes a function using the downhill simplex method */
function nelderMead(f, x0, parameters) {
parameters = parameters || {};
var maxIterations = parameters.maxIterations || x0.length * 200,
nonZeroDelta = parameters.nonZeroDelta || 1.05,
zeroDelta = parameters.zeroDelta || 0.001,
minErrorDelta = parameters.minErrorDelta || 1e-6,
minTolerance = parameters.minErrorDelta || 1e-5,
rho = (parameters.rho !== undefined) ? parameters.rho : 1,
chi = (parameters.chi !== undefined) ? parameters.chi : 2,
psi = (parameters.psi !== undefined) ? parameters.psi : -0.5,
sigma = (parameters.sigma !== undefined) ? parameters.sigma : 0.5,
maxDiff;
// initialize simplex.
var N = x0.length,
simplex = new Array(N + 1);
simplex[0] = x0;
simplex[0].fx = f(x0);
simplex[0].id = 0;
for (var i = 0; i < N; ++i) {
var point = x0.slice();
point[i] = point[i] ? point[i] * nonZeroDelta : zeroDelta;
simplex[i+1] = point;
simplex[i+1].fx = f(point);
simplex[i+1].id = i+1;
}
function updateSimplex(value) {
for (var i = 0; i < value.length; i++) {
simplex[N][i] = value[i];
}
simplex[N].fx = value.fx;
}
var sortOrder = function(a, b) { return a.fx - b.fx; };
var centroid = x0.slice(),
reflected = x0.slice(),
contracted = x0.slice(),
expanded = x0.slice();
for (var iteration = 0; iteration < maxIterations; ++iteration) {
simplex.sort(sortOrder);
if (parameters.history) {
// copy the simplex (since later iterations will mutate) and
// sort it to have a consistent order between iterations
var sortedSimplex = simplex.map(function (x) {
var state = x.slice();
state.fx = x.fx;
state.id = x.id;
return state;
});
sortedSimplex.sort(function(a,b) { return a.id - b.id; });
parameters.history.push({x: simplex[0].slice(),
fx: simplex[0].fx,
simplex: sortedSimplex});
}
maxDiff = 0;
for (i = 0; i < N; ++i) {
maxDiff = Math.max(maxDiff, Math.abs(simplex[0][i] - simplex[1][i]));
}
if ((Math.abs(simplex[0].fx - simplex[N].fx) < minErrorDelta) &&
(maxDiff < minTolerance)) {
break;
}
// compute the centroid of all but the worst point in the simplex
for (i = 0; i < N; ++i) {
centroid[i] = 0;
for (var j = 0; j < N; ++j) {
centroid[i] += simplex[j][i];
}
centroid[i] /= N;
}
// reflect the worst point past the centroid and compute loss at reflected
// point
var worst = simplex[N];
weightedSum(reflected, 1+rho, centroid, -rho, worst);
reflected.fx = f(reflected);
// if the reflected point is the best seen, then possibly expand
if (reflected.fx < simplex[0].fx) {
weightedSum(expanded, 1+chi, centroid, -chi, worst);
expanded.fx = f(expanded);
if (expanded.fx < reflected.fx) {
updateSimplex(expanded);
} else {
updateSimplex(reflected);
}
}
// if the reflected point is worse than the second worst, we need to
// contract
else if (reflected.fx >= simplex[N-1].fx) {
var shouldReduce = false;
if (reflected.fx > worst.fx) {
// do an inside contraction
weightedSum(contracted, 1+psi, centroid, -psi, worst);
contracted.fx = f(contracted);
if (contracted.fx < worst.fx) {
updateSimplex(contracted);
} else {
shouldReduce = true;
}
} else {
// do an outside contraction
weightedSum(contracted, 1-psi * rho, centroid, psi*rho, worst);
contracted.fx = f(contracted);
if (contracted.fx < reflected.fx) {
updateSimplex(contracted);
} else {
shouldReduce = true;
}
}
if (shouldReduce) {
// if we don't contract here, we're done
if (sigma >= 1) break;
// do a reduction
for (i = 1; i < simplex.length; ++i) {
weightedSum(simplex[i], 1 - sigma, simplex[0], sigma, simplex[i]);
simplex[i].fx = f(simplex[i]);
}
}
} else {
updateSimplex(reflected);
}
}
simplex.sort(sortOrder);
return {fx : simplex[0].fx,
x : simplex[0]};
}
/// searches along line 'pk' for a point that satifies the wolfe conditions
/// See 'Numerical Optimization' by Nocedal and Wright p59-60
/// f : objective function
/// pk : search direction
/// current: object containing current gradient/loss
/// next: output: contains next gradient/loss
/// returns a: step size taken
function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
var phi0 = current.fx, phiPrime0 = dot(current.fxprime, pk),
phi = phi0, phi_old = phi0,
phiPrime = phiPrime0,
a0 = 0;
a = a || 1;
c1 = c1 || 1e-6;
c2 = c2 || 0.1;
function zoom(a_lo, a_high, phi_lo) {
for (var iteration = 0; iteration < 16; ++iteration) {
a = (a_lo + a_high)/2;
weightedSum(next.x, 1.0, current.x, a, pk);
phi = next.fx = f(next.x, next.fxprime);
phiPrime = dot(next.fxprime, pk);
if ((phi > (phi0 + c1 * a * phiPrime0)) ||
(phi >= phi_lo)) {
a_high = a;
} else {
if (Math.abs(phiPrime) <= -c2 * phiPrime0) {
return a;
}
if (phiPrime * (a_high - a_lo) >=0) {
a_high = a_lo;
}
a_lo = a;
phi_lo = phi;
}
}
return 0;
}
for (var iteration = 0; iteration < 10; ++iteration) {
weightedSum(next.x, 1.0, current.x, a, pk);
phi = next.fx = f(next.x, next.fxprime);
phiPrime = dot(next.fxprime, pk);
if ((phi > (phi0 + c1 * a * phiPrime0)) ||
(iteration && (phi >= phi_old))) {
return zoom(a0, a, phi_old);
}
if (Math.abs(phiPrime) <= -c2 * phiPrime0) {
return a;
}
if (phiPrime >= 0 ) {
return zoom(a, a0, phi);
}
phi_old = phi;
a0 = a;
a *= 2;
}
return a;
}
function conjugateGradient(f, initial, params) {
// allocate all memory up front here, keep out of the loop for perfomance
// reasons
var current = {x: initial.slice(), fx: 0, fxprime: initial.slice()},
next = {x: initial.slice(), fx: 0, fxprime: initial.slice()},
yk = initial.slice(),
pk, temp,
a = 1,
maxIterations;
params = params || {};
maxIterations = params.maxIterations || initial.length * 20;
current.fx = f(current.x, current.fxprime);
pk = current.fxprime.slice();
scale(pk, current.fxprime,-1);
for (var i = 0; i < maxIterations; ++i) {
a = wolfeLineSearch(f, pk, current, next, a);
// todo: history in wrong spot?
if (params.history) {
params.history.push({x: current.x.slice(),
fx: current.fx,
fxprime: current.fxprime.slice(),
alpha: a});
}
if (!a) {
// faiiled to find point that satifies wolfe conditions.
// reset direction for next iteration
scale(pk, current.fxprime, -1);
} else {
// update direction using Polak–Ribiere CG method
weightedSum(yk, 1, next.fxprime, -1, current.fxprime);
var delta_k = dot(current.fxprime, current.fxprime),
beta_k = Math.max(0, dot(yk, next.fxprime) / delta_k);
weightedSum(pk, beta_k, pk, -1, next.fxprime);
temp = current;
current = next;
next = temp;
}
if (norm2(current.fxprime) <= 1e-5) {
break;
}
}
if (params.history) {
params.history.push({x: current.x.slice(),
fx: current.fx,
fxprime: current.fxprime.slice(),
alpha: a});
}
return current;
}
/** given a list of set objects, and their corresponding overlaps.
updates the (x, y, radius) attribute on each set such that their positions
roughly correspond to the desired overlaps */
function venn(areas, parameters) {
parameters = parameters || {};
parameters.maxIterations = parameters.maxIterations || 500;
var initialLayout = parameters.initialLayout || bestInitialLayout;
var loss = parameters.lossFunction || lossFunction;
// add in missing pairwise areas as having 0 size
areas = addMissingAreas(areas);
// initial layout is done greedily
var circles = initialLayout(areas, parameters);
// transform x/y coordinates to a vector to optimize
var initial = [], setids = [], setid;
for (setid in circles) {
if (circles.hasOwnProperty(setid)) {
initial.push(circles[setid].x);
initial.push(circles[setid].y);
setids.push(setid);
}
}
// optimize initial layout from our loss function
var solution = nelderMead(
function(values) {
var current = {};
for (var i = 0; i < setids.length; ++i) {
var setid = setids[i];
current[setid] = {x: values[2 * i],
y: values[2 * i + 1],
radius : circles[setid].radius,
// size : circles[setid].size
};
}
return loss(current, areas);
},
initial,
parameters);
// transform solution vector back to x/y points
var positions = solution.x;
for (var i = 0; i < setids.length; ++i) {
setid = setids[i];
circles[setid].x = positions[2 * i];
circles[setid].y = positions[2 * i + 1];
}
return circles;
}
var SMALL$1 = 1e-10;
/** Returns the distance necessary for two circles of radius r1 + r2 to
have the overlap area 'overlap' */
function distanceFromIntersectArea(r1, r2, overlap) {
// handle complete overlapped circles
if (Math.min(r1, r2) * Math.min(r1,r2) * Math.PI <= overlap + SMALL$1) {
return Math.abs(r1 - r2);
}
return bisect(function(distance$$1) {
return circleOverlap(r1, r2, distance$$1) - overlap;
}, 0, r1 + r2);
}
/** Missing pair-wise intersection area data can cause problems:
treating as an unknown means that sets will be laid out overlapping,
which isn't what people expect. To reflect that we want disjoint sets
here, set the overlap to 0 for all missing pairwise set intersections */
function addMissingAreas(areas) {
areas = areas.slice();
// two circle intersections that aren't defined
var ids = [], pairs = {}, i, j, a, b;
for (i = 0; i < areas.length; ++i) {
var area = areas[i];
if (area.sets.length == 1) {
ids.push(area.sets[0]);
} else if (area.sets.length == 2) {
a = area.sets[0];
b = area.sets[1];
pairs[[a, b]] = true;
pairs[[b, a]] = true;
}
}
ids.sort(function(a, b) { return a > b; });
for (i = 0; i < ids.length; ++i) {
a = ids[i];
for (j = i + 1; j < ids.length; ++j) {
b = ids[j];
if (!([a, b] in pairs)) {
areas.push({'sets': [a, b],
'size': 0});
}
}
}
return areas;
}
/// Returns two matrices, one of the euclidean distances between the sets
/// and the other indicating if there are subset or disjoint set relationships
function getDistanceMatrices(areas, sets, setids) {
// initialize an empty distance matrix between all the points
var distances = zerosM(sets.length, sets.length),
constraints = zerosM(sets.length, sets.length);
// compute required distances between all the sets such that
// the areas match
areas.filter(function(x) { return x.sets.length == 2; })
.map(function(current) {
var left = setids[current.sets[0]],
right = setids[current.sets[1]],
r1 = Math.sqrt(sets[left].size / Math.PI),
r2 = Math.sqrt(sets[right].size / Math.PI),
distance$$1 = distanceFromIntersectArea(r1, r2, current.size);
distances[left][right] = distances[right][left] = distance$$1;
// also update constraints to indicate if its a subset or disjoint
// relationship
var c = 0;
if (current.size + 1e-10 >= Math.min(sets[left].size,
sets[right].size)) {
c = 1;
} else if (current.size <= 1e-10) {
c = -1;
}
constraints[left][right] = constraints[right][left] = c;
});
return {distances: distances, constraints: constraints};
}
/// computes the gradient and loss simulatenously for our constrained MDS optimizer
function constrainedMDSGradient(x, fxprime, distances, constraints) {
var loss = 0, i;
for (i = 0; i < fxprime.length; ++i) {
fxprime[i] = 0;
}
for (i = 0; i < distances.length; ++i) {
var xi = x[2 * i], yi = x[2 * i + 1];
for (var j = i + 1; j < distances.length; ++j) {
var xj = x[2 * j], yj = x[2 * j + 1],
dij = distances[i][j],
constraint = constraints[i][j];
var squaredDistance = (xj - xi) * (xj - xi) + (yj - yi) * (yj - yi),
distance$$1 = Math.sqrt(squaredDistance),
delta = squaredDistance - dij * dij;
if (((constraint > 0) && (distance$$1 <= dij)) ||
((constraint < 0) && (distance$$1 >= dij))) {
continue;
}
loss += 2 * delta * delta;
fxprime[2*i] += 4 * delta * (xi - xj);
fxprime[2*i + 1] += 4 * delta * (yi - yj);
fxprime[2*j] += 4 * delta * (xj - xi);
fxprime[2*j + 1] += 4 * delta * (yj - yi);
}
}
return loss;
}
/// takes the best working variant of either constrained MDS or greedy
function bestInitialLayout(areas, params) {
var initial = greedyLayout(areas, params);
var loss = params.lossFunction || lossFunction;
// greedylayout is sufficient for all 2/3 circle cases. try out
// constrained MDS for higher order problems, take its output
// if it outperforms. (greedy is aesthetically better on 2/3 circles
// since it axis aligns)
if (areas.length >= 8) {
var constrained = constrainedMDSLayout(areas, params),
constrainedLoss = loss(constrained, areas),
greedyLoss = loss(initial, areas);
if (constrainedLoss + 1e-8 < greedyLoss) {
initial = constrained;
}
}
return initial;
}
/// use the constrained MDS variant to generate an initial layout
function constrainedMDSLayout(areas, params) {
params = params || {};
var restarts = params.restarts || 10;
// bidirectionally map sets to a rowid (so we can create a matrix)
var sets = [], setids = {}, i;
for (i = 0; i < areas.length; ++i ) {
var area = areas[i];
if (area.sets.length == 1) {
setids[area.sets[0]] = sets.length;
sets.push(area);
}
}
var matrices = getDistanceMatrices(areas, sets, setids),
distances = matrices.distances,
constraints = matrices.constraints;
// keep distances bounded, things get messed up otherwise.
// TODO: proper preconditioner?
var norm = norm2(distances.map(norm2))/(distances.length);
distances = distances.map(function (row) {
return row.map(function (value) { return value / norm; });});
var obj = function(x, fxprime) {
return constrainedMDSGradient(x, fxprime, distances, constraints);
};
var best, current;
for (i = 0; i < restarts; ++i) {
var initial = zeros(distances.length*2).map(Math.random);
current = conjugateGradient(obj, initial, params);
if (!best || (current.fx < best.fx)) {
best = current;
}
}
var positions = best.x;
// translate rows back to (x,y,radius) coordinates
var circles = {};
for (i = 0; i < sets.length; ++i) {
var set = sets[i];
circles[set.sets[0]] = {
x: positions[2*i] * norm,
y: positions[2*i + 1] * norm,
radius: Math.sqrt(set.size / Math.PI)
};
}
if (params.history) {
for (i = 0; i < params.history.length; ++i) {
scale(params.history[i].x, norm);
}
}
return circles;
}
/** Lays out a Venn diagram greedily, going from most overlapped sets to
least overlapped, attempting to position each new set such that the
overlapping areas to already positioned sets are basically right */
function greedyLayout(areas, params) {
var loss = params && params.lossFunction ? params.lossFunction : lossFunction;
// define a circle for each set
var circles = {}, setOverlaps = {}, set;
for (var i = 0; i < areas.length; ++i) {
var area = areas[i];
if (area.sets.length == 1) {
set = area.sets[0];
circles[set] = {x: 1e10, y: 1e10,
rowid: circles.length,
size: area.size,
radius: Math.sqrt(area.size / Math.PI)};
setOverlaps[set] = [];
}
}
areas = areas.filter(function(a) { return a.sets.length == 2; });
// map each set to a list of all the other sets that overlap it
for (i = 0; i < areas.length; ++i) {
var current = areas[i];
var weight = current.hasOwnProperty('weight') ? current.weight : 1.0;
var left = current.sets[0], right = current.sets[1];
// completely overlapped circles shouldn't be positioned early here
if (current.size + SMALL$1 >= Math.min(circles[left].size,
circles[right].size)) {
weight = 0;
}
setOverlaps[left].push ({set:right, size:current.size, weight:weight});
setOverlaps[right].push({set:left, size:current.size, weight:weight});
}
// get list of most overlapped sets
var mostOverlapped = [];
for (set in setOverlaps) {
if (setOverlaps.hasOwnProperty(set)) {
var size = 0;
for (i = 0; i < setOverlaps[set].length; ++i) {
size += setOverlaps[set][i].size * setOverlaps[set][i].weight;
}
mostOverlapped.push({set: set, size:size});
}
}
// sort by size desc
function sortOrder(a,b) {
return b.size - a.size;
}
mostOverlapped.sort(sortOrder);
// keep track of what sets have been laid out
var positioned = {};
function isPositioned(element) {
return element.set in positioned;
}
// adds a point to the output
function positionSet(point, index) {
circles[index].x = point.x;
circles[index].y = point.y;
positioned[index] = true;
}
// add most overlapped set at (0,0)
positionSet({x: 0, y: 0}, mostOverlapped[0].set);
// get distances between all points. TODO, necessary?
// answer: probably not
// var distances = venn.getDistanceMatrices(circles, areas).distances;
for (i = 1; i < mostOverlapped.length; ++i) {
var setIndex = mostOverlapped[i].set,
overlap = setOverlaps[setIndex].filter(isPositioned);
set = circles[setIndex];
overlap.sort(sortOrder);
if (overlap.length === 0) {
// this shouldn't happen anymore with addMissingAreas
throw "ERROR: missing pairwise overlap information";
}
var points = [];
for (var j = 0; j < overlap.length; ++j) {
// get appropriate distance from most overlapped already added set
var p1 = circles[overlap[j].set],
d1 = distanceFromIntersectArea(set.radius, p1.radius,
overlap[j].size);
// sample positions at 90 degrees for maximum aesthetics
points.push({x : p1.x + d1, y : p1.y});
points.push({x : p1.x - d1, y : p1.y});
points.push({y : p1.y + d1, x : p1.x});
points.push({y : p1.y - d1, x : p1.x});
// if we have at least 2 overlaps, then figure out where the
// set should be positioned analytically and try those too
for (var k = j + 1; k < overlap.length; ++k) {
var p2 = circles[overlap[k].set],
d2 = distanceFromIntersectArea(set.radius, p2.radius,
overlap[k].size);
var extraPoints = circleCircleIntersection(
{ x: p1.x, y: p1.y, radius: d1},
{ x: p2.x, y: p2.y, radius: d2});
for (var l = 0; l < extraPoints.length; ++l) {
points.push(extraPoints[l]);
}
}
}
// we have some candidate positions for the set, examine loss
// at each position to figure out where to put it at
var bestLoss = 1e50, bestPoint = points[0];
for (j = 0; j < points.length; ++j) {
circles[setIndex].x = points[j].x;
circles[setIndex].y = points[j].y;
var localLoss = loss(circles, areas);
if (localLoss < bestLoss) {
bestLoss = localLoss;
bestPoint = points[j];
}
}
positionSet(bestPoint, setIndex);
}
return circles;
}
/** Given a bunch of sets, and the desired overlaps between these sets - computes
the distance from the actual overlaps to the desired overlaps. Note that
this method ignores overlaps of more than 2 circles */
function lossFunction(sets, overlaps) {
var output = 0;
function getCircles(indices) {
return indices.map(function(i) { return sets[i]; });
}
for (var i = 0; i < overlaps.length; ++i) {
var area = overlaps[i], overlap;
if (area.sets.length == 1) {
continue;
} else if (area.sets.length == 2) {
var left = sets[area.sets[0]],
right = sets[area.sets[1]];
overlap = circleOverlap(left.radius, right.radius,
distance(left, right));
} else {
overlap = intersectionArea(getCircles(area.sets));
}
var weight = area.hasOwnProperty('weight') ? area.weight : 1.0;
output += weight * (overlap - area.size) * (overlap - area.size);
}
return output;
}
// orientates a bunch of circles to point in orientation
function orientateCircles(circles, orientation, orientationOrder) {
if (orientationOrder === null) {
circles.sort(function (a, b) { return b.radius - a.radius; });
} else {
circles.sort(orientationOrder);
}
var i;
// shift circles so largest circle is at (0, 0)
if (circles.length > 0) {
var largestX = circles[0].x,
largestY = circles[0].y;
for (i = 0; i < circles.length; ++i) {
circles[i].x -= largestX;
circles[i].y -= largestY;
}
}
if (circles.length == 2) {
// if the second circle is a subset of the first, arrange so that
// it is off to one side. hack for https://github.com/benfred/venn.js/issues/120
var dist = distance(circles[0], circles[1]);
if (dist < Math.abs(circles[1].radius - circles[0].radius)) {
circles[1].x = circles[0].x + circles[0].radius - circles[1].radius - 1e-10;
circles[1].y = circles[0].y;
}
}
// rotate circles so that second largest is at an angle of 'orientation'
// from largest
if (circles.length > 1) {
var rotation = Math.atan2(circles[1].x, circles[1].y) - orientation,
c = Math.cos(rotation),
s = Math.sin(rotation), x, y;
for (i = 0; i < circles.length; ++i) {
x = circles[i].x;
y = circles[i].y;
circles[i].x = c * x - s * y;
circles[i].y = s * x + c * y;
}
}
// mirror solution if third solution is above plane specified by
// first two circles
if (circles.length > 2) {
var angle = Math.atan2(circles[2].x, circles[2].y) - orientation;
while (angle < 0) { angle += 2* Math.PI; }
while (angle > 2*Math.PI) { angle -= 2* Math.PI; }
if (angle > Math.PI) {
var slope = circles[1].y / (1e-10 + circles[1].x);
for (i = 0; i < circles.length; ++i) {
var d = (circles[i].x + slope * circles[i].y) / (1 + slope*slope);
circles[i].x = 2 * d - circles[i].x;
circles[i].y = 2 * d * slope - circles[i].y;
}
}
}
}
function disjointCluster(circles) {
// union-find clustering to get disjoint sets
circles.map(function(circle) { circle.parent = circle; });
// path compression step in union find
function find(circle) {
if (circle.parent !== circle) {
circle.parent = find(circle.parent);
}
return circle.parent;
}
function union(x, y) {
var xRoot = find(x), yRoot = find(y);
xRoot.parent = yRoot;
}
// get the union of all overlapping sets
for (var i = 0; i < circles.length; ++i) {
for (var j = i + 1; j < circles.length; ++j) {
var maxDistance = circles[i].radius + circles[j].radius;
if (distance(circles[i], circles[j]) + 1e-10 < maxDistance) {
union(circles[j], circles[i]);
}
}
}
// find all the disjoint clusters and group them together
var disjointClusters = {}, setid;
for (i = 0; i < circles.length; ++i) {
setid = find(circles[i]).parent.setid;
if (!(setid in disjointClusters)) {
disjointClusters[setid] = [];
}
disjointClusters[setid].push(circles[i]);
}
// cleanup bookkeeping
circles.map(function(circle) { delete circle.parent; });
// return in more usable form
var ret = [];
for (setid in disjointClusters) {
if (disjointClusters.hasOwnProperty(setid)) {
ret.push(disjointClusters[setid]);
}
}
return ret;
}
function getBoundingBox(circles) {
var minMax = function(d) {
var hi = Math.max.apply(null, circles.map(
function(c) { return c[d] + c.radius; } )),
lo = Math.min.apply(null, circles.map(
function(c) { return c[d] - c.radius;} ));
return {max:hi, min:lo};
};
return {xRange: minMax('x'), yRange: minMax('y')};
}
function normalizeSolution(solution, orientation, orientationOrder) {
if (orientation === null){
orientation = Math.PI/2;
}
// work with a list instead of a dictionary, and take a copy so we
// don't mutate input
var circles = [], i, setid;
for (setid in solution) {
if (solution.hasOwnProperty(setid)) {
var previous = solution[setid];
circles.push({x: previous.x,
y: previous.y,
radius: previous.radius,
setid: setid});
}
}
// get all the disjoint clusters
var clusters = disjointCluster(circles);
// orientate all disjoint sets, get sizes
for (i = 0; i < clusters.length; ++i) {
orientateCircles(clusters[i], orientation, orientationOrder);
var bounds = getBoundingBox(clusters[i]);
clusters[i].size = (bounds.xRange.max - bounds.xRange.min) * (bounds.yRange.max - bounds.yRange.min);
clusters[i].bounds = bounds;
}
clusters.sort(function(a, b) { return b.size - a.size; });
// orientate the largest at 0,0, and get the bounds
circles = clusters[0];
var returnBounds = circles.bounds;
var spacing = (returnBounds.xRange.max - returnBounds.xRange.min)/50;
function addCluster(cluster, right, bottom) {
if (!cluster) return;
var bounds = cluster.bounds, xOffset, yOffset, centreing;
if (right) {
xOffset = returnBounds.xRange.max - bounds.xRange.min + spacing;
} else {
xOffset = returnBounds.xRange.max - bounds.xRange.max;
centreing = (bounds.xRange.max - bounds.xRange.min) / 2 -
(returnBounds.xRange.max - returnBounds.xRange.min) / 2;
if (centreing < 0) xOffset += centreing;
}
if (bottom) {
yOffset = returnBounds.yRange.max - bounds.yRange.min + spacing;
} else {
yOffset = returnBounds.yRange.max - bounds.yRange.max;
centreing = (bounds.yRange.max - bounds.yRange.min) / 2 -
(returnBounds.yRange.max - returnBounds.yRange.min) / 2;
if (centreing < 0) yOffset += centreing;
}
for (var j = 0; j < cluster.length; ++j) {
cluster[j].x += xOffset;
cluster[j].y += yOffset;
circles.push(cluster[j]);
}
}
var index = 1;
while (index < clusters.length) {
addCluster(clusters[index], true, false);
addCluster(clusters[index+1], false, true);
addCluster(clusters[index+2], true, true);
index += 3;
// have one cluster (in top left). lay out next three relative
// to it in a grid
returnBounds = getBoundingBox(circles);
}
// convert back to solution form
var ret = {};
for (i = 0; i < circles.length; ++i) {
ret[circles[i].setid] = circles[i];
}
return ret;
}
/** Scales a solution from venn.venn or venn.greedyLayout such that it fits in
a rectangle of width/height - with padding around the borders. also
centers the diagram in the available space at the same time */
function scaleSolution(solution, width, height, padding) {
var circles = [], setids = [];
for (var setid in solution) {
if (solution.hasOwnProperty(setid)) {
setids.push(setid);
circles.push(solution[setid]);
}
}
width -= 2*padding;
height -= 2*padding;
var bounds = getBoundingBox(circles),
xRange = bounds.xRange,
yRange = bounds.yRange;
if ((xRange.max == xRange.min) ||
(yRange.max == yRange.min)) {
console.log("not scaling solution: zero size detected");
return solution;
}
var xScaling = width / (xRange.max - xRange.min),
yScaling = height / (yRange.max - yRange.min),
scaling = Math.min(yScaling, xScaling),
// while we're at it, center the diagram too
xOffset = (width - (xRange.max - xRange.min) * scaling) / 2,
yOffset = (height - (yRange.max - yRange.min) * scaling) / 2;
var scaled = {};
for (var i = 0; i < circles.length; ++i) {
var circle = circles[i];
scaled[setids[i]] = {
radius: scaling * circle.radius,
x: padding + xOffset + (circle.x - xRange.min) * scaling,
y: padding + yOffset + (circle.y - yRange.min) * scaling,
};
}
return scaled;
}
/*global console:true*/
function VennDiagram() {
var width = 600,
height = 350,
padding = 15,
duration = 1000,
orientation = Math.PI / 2,
normalize = true,
wrap = true,
styled = true,
fontSize = null,
orientationOrder = null,
// mimic the behaviour of d3.scale.category10 from the previous
// version of d3
colourMap = {},
// so this is the same as d3.schemeCategory10, which is only defined in d3 4.0
// since we can support older versions of d3 as long as we don't force this,
// I'm hackily redefining below. TODO: remove this and change to d3.schemeCategory10
colourScheme = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"],
colourIndex = 0,
colours = function(key) {
if (key in colourMap) {
return colourMap[key];
}
var ret = colourMap[key] = colourScheme[colourIndex];
colourIndex += 1;
if (colourIndex >= colourScheme.length) {
colourIndex = 0;
}
return ret;
},
layoutFunction = venn,
loss = lossFunction;
function chart(selection) {
var data = selection.datum();
// handle 0-sized sets by removing from input
var toremove = {};
data.forEach(function(datum) {
if ((datum.size == 0) && datum.sets.length == 1) {
toremove[datum.sets[0]] = 1;
}
});
data = data.filter(function(datum) {
return !datum.sets.some(function(set) { return set in toremove; });
});
var circles = {};
var textCentres = {};
if (data.length > 0) {
var solution = layoutFunction(data, {lossFunction: loss});
if (normalize) {
solution = normalizeSolution(solution,
orientation,
orientationOrder);
}
circles = scaleSolution(solution, width, height, padding);
textCentres = computeTextCentres(circles, data);
}
// Figure out the current label for each set. These can change
// and D3 won't necessarily update (fixes https://github.com/benfred/venn.js/issues/103)
var labels = {};
data.forEach(function(datum) {
if (datum.label) {
labels[datum.sets] = datum.label;
}
});
function label(d) {
if (d.sets in labels) {
return labels[d.sets];
}
if (d.sets.length == 1) {
return '' + d.sets[0];
}
}
// create svg if not already existing
selection.selectAll("svg").data([circles]).enter().append("svg");
var svg = selection.select("svg")
.attr("width", width)
.attr("height", height);
// to properly transition intersection areas, we need the
// previous circles locations. load from elements
var previous = {}, hasPrevious = false;
svg.selectAll(".venn-area path").each(function (d) {
var path = d3Selection.select(this).attr("d");
if ((d.sets.length == 1) && path) {
hasPrevious = true;
previous[d.sets[0]] = circleFromPath(path);
}
});
// interpolate intersection area paths between previous and
// current paths
var pathTween = function(d) {
return function(t) {
var c = d.sets.map(function(set) {
var start = previous[set], end = circles[set];
if (!start) {
start = {x : width/2, y : height/2, radius : 1};
}
if (!end) {
end = {x : width/2, y : height/2, radius : 1};
}
return {'x' : start.x * (1 - t) + end.x * t,
'y' : start.y * (1 - t) + end.y * t,
'radius' : start.radius * (1 - t) + end.radius * t};
});
return intersectionAreaPath(c);
};
};
// update data, joining on the set ids
var nodes = svg.selectAll(".venn-area")
.data(data, function(d) { return d.sets; });
// create new nodes
var enter = nodes.enter()
.append('g')
.attr("class", function(d) {
return "venn-area venn-" +
(d.sets.length == 1 ? "circle" : "intersection");
})
.attr("data-venn-sets", function(d) {
return d.sets.join("_");
});
var enterPath = enter.append("path"),
enterText = enter.append("text")
.attr("class", "label")
.text(function (d) { return label(d); } )
.attr("text-anchor", "middle")
.attr("dy", ".35em")
.attr("x", width/2)
.attr("y", height/2);
// apply minimal style if wanted
if (styled) {
enterPath.style("fill-opacity", "0")
.filter(function (d) { return d.sets.length == 1; } )
.style("fill", function(d) { return colours(d.sets); })
.style("fill-opacity", ".25");
enterText
.style("fill", function(d) { return d.sets.length == 1 ? colours(d.sets) : "#444"; });
}
// update existing, using pathTween if necessary
var update = selection;
if (hasPrevious) {
update = selection.transition("venn").duration(duration);
update.selectAll("path")
.attrTween("d", pathTween);
} else {
update.selectAll("path")
.attr("d", function(d) {
return intersectionAreaPath(d.sets.map(function (set) { return circles[set]; }));
});
}
var updateText = update.selectAll("text")
.filter(function (d) { return d.sets in textCentres; })
.text(function (d) { return label(d); } )
.attr("x", function(d) { return Math.floor(textCentres[d.sets].x);})
.attr("y", function(d) { return Math.floor(textCentres[d.sets].y);});
if (wrap) {
if (hasPrevious) {
// d3 4.0 uses 'on' for events on transitions,
// but d3 3.0 used 'each' instead. switch appropiately
if ('on' in updateText) {
updateText.on("end", wrapText(circles, label));
} else {
updateText.each("end", wrapText(circles, label));
}
} else {
updateText.each(wrapText(circles, label));
}
}
// remove old
var exit = nodes.exit().transition('venn').duration(duration).remove();
exit.selectAll("path")
.attrTween("d", pathTween);
var exitText = exit.selectAll("text")
.attr("x", width/2)
.attr("y", height/2);
// if we've been passed a fontSize explicitly, use it to
// transition
if (fontSize !== null) {
enterText.style("font-size", "0px");
updateText.style("font-size", fontSize);
exitText.style("font-size", "0px");
}
return {'circles': circles,
'textCentres': textCentres,
'nodes': nodes,
'enter': enter,
'update': update,
'exit': exit};
}
chart.wrap = function(_) {
if (!arguments.length) return wrap;
wrap = _;
return chart;
};
chart.width = function(_) {
if (!arguments.length) return width;
width = _;
return chart;
};
chart.height = function(_) {
if (!arguments.length) return height;
height = _;
return chart;
};
chart.padding = function(_) {
if (!arguments.length) return padding;
padding = _;
return chart;
};
chart.colours = function(_) {
if (!arguments.length) return colours;
colours = _;
return chart;
};
chart.fontSize = function(_) {
if (!arguments.length) return fontSize;
fontSize = _;
return chart;
};
chart.duration = function(_) {
if (!arguments.length) return duration;
duration = _;
return chart;
};
chart.layoutFunction = function(_) {
if (!arguments.length) return layoutFunction;
layoutFunction = _;
return chart;
};
chart.normalize = function(_) {
if (!arguments.length) return normalize;
normalize = _;
return chart;
};
chart.styled = function(_) {
if (!arguments.length) return styled;
styled = _;
return chart;
};
chart.orientation = function(_) {
if (!arguments.length) return orientation;
orientation = _;
return chart;
};
chart.orientationOrder = function(_) {
if (!arguments.length) return orientationOrder;
orientationOrder = _;
return chart;
};
chart.lossFunction = function(_) {
if (!arguments.length) return loss;
loss = _;
return chart;
};
return chart;
}
// sometimes text doesn't fit inside the circle, if thats the case lets wrap
// the text here such that it fits
// todo: looks like this might be merged into d3 (
// https://github.com/mbostock/d3/issues/1642),
// also worth checking out is
// http://engineering.findthebest.com/wrapping-axis-labels-in-d3-js/
// this seems to be one of those things that should be easy but isn't
function wrapText(circles, labeller) {
return function() {
var text = d3Selection.select(this),
data = text.datum(),
width = circles[data.sets[0]].radius || 50,
label = labeller(data) || '';
var words = label.split(/\s+/).reverse(),
maxLines = 3,
minChars = (label.length + words.length) / maxLines,
word = words.pop(),
line = [word],
joined,
lineNumber = 0,
lineHeight = 1.1, // ems
tspan = text.text(null).append("tspan").text(word);
while (true) {
word = words.pop();
if (!word) break;
line.push(word);
joined = line.join(" ");
tspan.text(joined);
if (joined.length > minChars && tspan.node().getComputedTextLength() > width) {
line.pop();
tspan.text(line.join(" "));
line = [word];
tspan = text.append("tspan").text(word);
lineNumber++;
}
}
var initial = 0.35 - lineNumber * lineHeight / 2,
x = text.attr("x"),
y = text.attr("y");
text.selectAll("tspan")
.attr("x", x)
.attr("y", y)
.attr("dy", function(d, i) {
return (initial + i * lineHeight) + "em";
});
};
}
function circleMargin(current, interior, exterior) {
var margin = interior[0].radius - distance(interior[0], current), i, m;
for (i = 1; i < interior.length; ++i) {
m = interior[i].radius - distance(interior[i], current);
if (m <= margin) {
margin = m;
}
}
for (i = 0; i < exterior.length; ++i) {
m = distance(exterior[i], current) - exterior[i].radius;
if (m <= margin) {
margin = m;
}
}
return margin;
}
// compute the center of some circles by maximizing the margin of
// the center point relative to the circles (interior) after subtracting
// nearby circles (exterior)
function computeTextCentre(interior, exterior) {
// get an initial estimate by sampling around the interior circles
// and taking the point with the biggest margin
var points = [], i;
for (i = 0; i < interior.length; ++i) {
var c = interior[i];
points.push({x: c.x, y: c.y});
points.push({x: c.x + c.radius/2, y: c.y});
points.push({x: c.x - c.radius/2, y: c.y});
points.push({x: c.x, y: c.y + c.radius/2});
points.push({x: c.x, y: c.y - c.radius/2});
}
var initial = points[0], margin = circleMargin(points[0], interior, exterior);
for (i = 1; i < points.length; ++i) {
var m = circleMargin(points[i], interior, exterior);
if (m >= margin) {
initial = points[i];
margin = m;
}
}
// maximize the margin numerically
var solution = nelderMead(
function(p) { return -1 * circleMargin({x: p[0], y: p[1]}, interior, exterior); },
[initial.x, initial.y],
{maxIterations:500, minErrorDelta:1e-10}).x;
var ret = {x: solution[0], y: solution[1]};
// check solution, fallback as needed (happens if fully overlapped
// etc)
var valid = true;
for (i = 0; i < interior.length; ++i) {
if (distance(ret, interior[i]) > interior[i].radius) {
valid = false;
break;
}
}
for (i = 0; i < exterior.length; ++i) {
if (distance(ret, exterior[i]) < exterior[i].radius) {
valid = false;
break;
}
}
if (!valid) {
if (interior.length == 1) {
ret = {x: interior[0].x, y: interior[0].y};
} else {
var areaStats = {};
intersectionArea(interior, areaStats);
if (areaStats.arcs.length === 0) {
ret = {'x': 0, 'y': -1000, disjoint:true};
} else if (areaStats.arcs.length == 1) {
ret = {'x': areaStats.arcs[0].circle.x,
'y': areaStats.arcs[0].circle.y};
} else if (exterior.length) {
// try again without other circles
ret = computeTextCentre(interior, []);
} else {
// take average of all the points in the intersection
// polygon. this should basically never happen
// and has some issues:
// https://github.com/benfred/venn.js/issues/48#issuecomment-146069777
ret = getCenter(areaStats.arcs.map(function (a) { return a.p1; }));
}
}
}
return ret;
}
// given a dictionary of {setid : circle}, returns
// a dictionary of setid to list of circles that completely overlap it
function getOverlappingCircles(circles) {
var ret = {}, circleids = [];
for (var circleid in circles) {
circleids.push(circleid);
ret[circleid] = [];
}
for (var i = 0; i < circleids.length; i++) {
var a = circles[circleids[i]];
for (var j = i + 1; j < circleids.length; ++j) {
var b = circles[circleids[j]],
d = distance(a, b);
if (d + b.radius <= a.radius + 1e-10) {
ret[circleids[j]].push(circleids[i]);
} else if (d + a.radius <= b.radius + 1e-10) {
ret[circleids[i]].push(circleids[j]);
}
}
}
return ret;
}
function computeTextCentres(circles, areas) {
var ret = {}, overlapped = getOverlappingCircles(circles);
for (var i = 0; i < areas.length; ++i) {
var area = areas[i].sets, areaids = {}, exclude = {};
for (var j = 0; j < area.length; ++j) {
areaids[area[j]] = true;
var overlaps = overlapped[area[j]];
// keep track of any circles that overlap this area,
// and don't consider for purposes of computing the text
// centre
for (var k = 0; k < overlaps.length; ++k) {
exclude[overlaps[k]] = true;
}
}
var interior = [], exterior = [];
for (var setid in circles) {
if (setid in areaids) {
interior.push(circles[setid]);
} else if (!(setid in exclude)) {
exterior.push(circles[setid]);
}
}
var centre = computeTextCentre(interior, exterior);
ret[area] = centre;
if (centre.disjoint && (areas[i].size > 0)) {
console.log("WARNING: area " + area + " not represented on screen");
}
}
return ret;
}
// sorts all areas in the venn diagram, so that
// a particular area is on top (relativeTo) - and
// all other areas are so that the smallest areas are on top
function sortAreas(div, relativeTo) {
// figure out sets that are completly overlapped by relativeTo
var overlaps = getOverlappingCircles(div.selectAll("svg").datum());
var exclude = {};
for (var i = 0; i < relativeTo.sets.length; ++i) {
var check = relativeTo.sets[i];
for (var setid in overlaps) {
var overlap = overlaps[setid];
for (var j = 0; j < overlap.length; ++j) {
if (overlap[j] == check) {
exclude[setid] = true;
break;
}
}
}
}
// checks that all sets are in exclude;
function shouldExclude(sets) {
for (var i = 0; i < sets.length; ++i) {
if (!(sets[i] in exclude)) {
return false;
}
}
return true;
}
// need to sort div's so that Z order is correct
div.selectAll("g").sort(function (a, b) {
// highest order set intersections first
if (a.sets.length != b.sets.length) {
return a.sets.length - b.sets.length;
}
if (a == relativeTo) {
return shouldExclude(b.sets) ? -1 : 1;
}
if (b == relativeTo) {
return shouldExclude(a.sets) ? 1 : -1;
}
// finally by size
return b.size - a.size;
});
}
function circlePath(x, y, r) {
var ret = [];
ret.push("\nM", x, y);
ret.push("\nm", -r, 0);
ret.push("\na", r, r, 0, 1, 0, r *2, 0);
ret.push("\na", r, r, 0, 1, 0,-r *2, 0);
return ret.join(" ");
}
// inverse of the circlePath function, returns a circle object from an svg path
function circleFromPath(path) {
var tokens = path.split(' ');
return {'x' : parseFloat(tokens[1]),
'y' : parseFloat(tokens[2]),
'radius' : -parseFloat(tokens[4])
};
}
/** returns a svg path of the intersection area of a bunch of circles */
function intersectionAreaPath(circles) {
var stats = {};
intersectionArea(circles, stats);
var arcs = stats.arcs;
if (arcs.length === 0) {
return "M 0 0";
} else if (arcs.length == 1) {
var circle = arcs[0].circle;
return circlePath(circle.x, circle.y, circle.radius);
} else {
// draw path around arcs
var ret = ["\nM", arcs[0].p2.x, arcs[0].p2.y];
for (var i = 0; i < arcs.length; ++i) {
var arc = arcs[i], r = arc.circle.radius, wide = arc.width > r;
ret.push("\nA", r, r, 0, wide ? 1 : 0, 1,
arc.p1.x, arc.p1.y);
}
return ret.join(" ");
}
}
exports.intersectionArea = intersectionArea;
exports.circleCircleIntersection = circleCircleIntersection;
exports.circleOverlap = circleOverlap;
exports.circleArea = circleArea;
exports.distance = distance;
exports.venn = venn;
exports.greedyLayout = greedyLayout;
exports.scaleSolution = scaleSolution;
exports.normalizeSolution = normalizeSolution;
exports.bestInitialLayout = bestInitialLayout;
exports.lossFunction = lossFunction;
exports.disjointCluster = disjointCluster;
exports.distanceFromIntersectArea = distanceFromIntersectArea;
exports.VennDiagram = VennDiagram;
exports.wrapText = wrapText;
exports.computeTextCentres = computeTextCentres;
exports.computeTextCentre = computeTextCentre;
exports.sortAreas = sortAreas;
exports.circlePath = circlePath;
exports.circleFromPath = circleFromPath;
exports.intersectionAreaPath = intersectionAreaPath;
Object.defineProperty(exports, '__esModule', { value: true });
})));
/***/ }),
/* 527 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(60);
module.exports = __webpack_require__(60);
/***/ })
/******/ ]);
});
/***/ }),
/* 63 */
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(79)(function () {
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
});
/***/ }),
/* 64 */
/***/ (function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function (it, key) {
return hasOwnProperty.call(it, key);
};
/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = __webpack_require__(242);
var defined = __webpack_require__(151);
module.exports = function (it) {
return IObject(defined(it));
};
/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _iterator = __webpack_require__(481);
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = __webpack_require__(491);
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
/***/ }),
/* 67 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_rc_util_es_Dom_contains__ = __webpack_require__(120);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_rc_util_es_Dom_addEventListener__ = __webpack_require__(39);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_rc_util_es_ContainerRender__ = __webpack_require__(121);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_rc_util_es_Portal__ = __webpack_require__(168);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_11_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils__ = __webpack_require__(266);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Popup__ = __webpack_require__(516);
function noop() {}
function returnEmptyString() {
return '';
}
function returnDocument() {
return window.document;
}
var ALL_HANDLERS = ['onClick', 'onMouseDown', 'onTouchStart', 'onMouseEnter', 'onMouseLeave', 'onFocus', 'onBlur', 'onContextMenu'];
var IS_REACT_16 = !!__WEBPACK_IMPORTED_MODULE_6_react_dom__["createPortal"];
var contextTypes = {
rcTrigger: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.shape({
onPopupMouseDown: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func
})
};
var Trigger = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default()(Trigger, _React$Component);
function Trigger(props) {
__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Trigger);
var _this = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.call(this, props));
_initialiseProps.call(_this);
var popupVisible = void 0;
if ('popupVisible' in props) {
popupVisible = !!props.popupVisible;
} else {
popupVisible = !!props.defaultPopupVisible;
}
_this.prevPopupVisible = popupVisible;
_this.state = {
popupVisible: popupVisible
};
return _this;
}
Trigger.prototype.getChildContext = function getChildContext() {
return {
rcTrigger: {
onPopupMouseDown: this.onPopupMouseDown
}
};
};
Trigger.prototype.componentWillMount = function componentWillMount() {
var _this2 = this;
ALL_HANDLERS.forEach(function (h) {
_this2['fire' + h] = function (e) {
_this2.fireEvents(h, e);
};
});
};
Trigger.prototype.componentDidMount = function componentDidMount() {
this.componentDidUpdate({}, {
popupVisible: this.state.popupVisible
});
};
Trigger.prototype.componentWillReceiveProps = function componentWillReceiveProps(_ref) {
var popupVisible = _ref.popupVisible;
if (popupVisible !== undefined) {
this.setState({
popupVisible: popupVisible
});
}
};
Trigger.prototype.componentDidUpdate = function componentDidUpdate(_, prevState) {
var props = this.props;
var state = this.state;
var triggerAfterPopupVisibleChange = function triggerAfterPopupVisibleChange() {
if (prevState.popupVisible !== state.popupVisible) {
props.afterPopupVisibleChange(state.popupVisible);
}
};
if (!IS_REACT_16) {
this.renderComponent(null, triggerAfterPopupVisibleChange);
}
this.prevPopupVisible = prevState.popupVisible;
// We must listen to `mousedown` or `touchstart`, edge case:
// https://github.com/ant-design/ant-design/issues/5804
// https://github.com/react-component/calendar/issues/250
// https://github.com/react-component/trigger/issues/50
if (state.popupVisible) {
var currentDocument = void 0;
if (!this.clickOutsideHandler && (this.isClickToHide() || this.isContextMenuToShow())) {
currentDocument = props.getDocument();
this.clickOutsideHandler = Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Dom_addEventListener__["a" /* default */])(currentDocument, 'mousedown', this.onDocumentClick);
}
// always hide on mobile
if (!this.touchOutsideHandler) {
currentDocument = currentDocument || props.getDocument();
this.touchOutsideHandler = Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Dom_addEventListener__["a" /* default */])(currentDocument, 'touchstart', this.onDocumentClick);
}
// close popup when trigger type contains 'onContextMenu' and document is scrolling.
if (!this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) {
currentDocument = currentDocument || props.getDocument();
this.contextMenuOutsideHandler1 = Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Dom_addEventListener__["a" /* default */])(currentDocument, 'scroll', this.onContextMenuClose);
}
// close popup when trigger type contains 'onContextMenu' and window is blur.
if (!this.contextMenuOutsideHandler2 && this.isContextMenuToShow()) {
this.contextMenuOutsideHandler2 = Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Dom_addEventListener__["a" /* default */])(window, 'blur', this.onContextMenuClose);
}
return;
}
this.clearOutsideHandler();
};
Trigger.prototype.componentWillUnmount = function componentWillUnmount() {
this.clearDelayTimer();
this.clearOutsideHandler();
clearTimeout(this.mouseDownTimeout);
};
Trigger.prototype.getPopupDomNode = function getPopupDomNode() {
// for test
if (this._component && this._component.getPopupDomNode) {
return this._component.getPopupDomNode();
}
return null;
};
Trigger.prototype.getPopupAlign = function getPopupAlign() {
var props = this.props;
var popupPlacement = props.popupPlacement,
popupAlign = props.popupAlign,
builtinPlacements = props.builtinPlacements;
if (popupPlacement && builtinPlacements) {
return Object(__WEBPACK_IMPORTED_MODULE_12__utils__["a" /* getAlignFromPlacement */])(builtinPlacements, popupPlacement, popupAlign);
}
return popupAlign;
};
/**
* @param popupVisible Show or not the popup element
* @param event SyntheticEvent, used for `pointAlign`
*/
Trigger.prototype.setPopupVisible = function setPopupVisible(popupVisible, event) {
var alignPoint = this.props.alignPoint;
this.clearDelayTimer();
if (this.state.popupVisible !== popupVisible) {
if (!('popupVisible' in this.props)) {
this.setState({ popupVisible: popupVisible });
}
this.props.onPopupVisibleChange(popupVisible);
}
// Always record the point position since mouseEnterDelay will delay the show
if (alignPoint && event) {
this.setPoint(event);
}
};
Trigger.prototype.delaySetPopupVisible = function delaySetPopupVisible(visible, delayS, event) {
var _this3 = this;
var delay = delayS * 1000;
this.clearDelayTimer();
if (delay) {
var point = event ? { pageX: event.pageX, pageY: event.pageY } : null;
this.delayTimer = setTimeout(function () {
_this3.setPopupVisible(visible, point);
_this3.clearDelayTimer();
}, delay);
} else {
this.setPopupVisible(visible, event);
}
};
Trigger.prototype.clearDelayTimer = function clearDelayTimer() {
if (this.delayTimer) {
clearTimeout(this.delayTimer);
this.delayTimer = null;
}
};
Trigger.prototype.clearOutsideHandler = function clearOutsideHandler() {
if (this.clickOutsideHandler) {
this.clickOutsideHandler.remove();
this.clickOutsideHandler = null;
}
if (this.contextMenuOutsideHandler1) {
this.contextMenuOutsideHandler1.remove();
this.contextMenuOutsideHandler1 = null;
}
if (this.contextMenuOutsideHandler2) {
this.contextMenuOutsideHandler2.remove();
this.contextMenuOutsideHandler2 = null;
}
if (this.touchOutsideHandler) {
this.touchOutsideHandler.remove();
this.touchOutsideHandler = null;
}
};
Trigger.prototype.createTwoChains = function createTwoChains(event) {
var childPros = this.props.children.props;
var props = this.props;
if (childPros[event] && props[event]) {
return this['fire' + event];
}
return childPros[event] || props[event];
};
Trigger.prototype.isClickToShow = function isClickToShow() {
var _props = this.props,
action = _props.action,
showAction = _props.showAction;
return action.indexOf('click') !== -1 || showAction.indexOf('click') !== -1;
};
Trigger.prototype.isContextMenuToShow = function isContextMenuToShow() {
var _props2 = this.props,
action = _props2.action,
showAction = _props2.showAction;
return action.indexOf('contextMenu') !== -1 || showAction.indexOf('contextMenu') !== -1;
};
Trigger.prototype.isClickToHide = function isClickToHide() {
var _props3 = this.props,
action = _props3.action,
hideAction = _props3.hideAction;
return action.indexOf('click') !== -1 || hideAction.indexOf('click') !== -1;
};
Trigger.prototype.isMouseEnterToShow = function isMouseEnterToShow() {
var _props4 = this.props,
action = _props4.action,
showAction = _props4.showAction;
return action.indexOf('hover') !== -1 || showAction.indexOf('mouseEnter') !== -1;
};
Trigger.prototype.isMouseLeaveToHide = function isMouseLeaveToHide() {
var _props5 = this.props,
action = _props5.action,
hideAction = _props5.hideAction;
return action.indexOf('hover') !== -1 || hideAction.indexOf('mouseLeave') !== -1;
};
Trigger.prototype.isFocusToShow = function isFocusToShow() {
var _props6 = this.props,
action = _props6.action,
showAction = _props6.showAction;
return action.indexOf('focus') !== -1 || showAction.indexOf('focus') !== -1;
};
Trigger.prototype.isBlurToHide = function isBlurToHide() {
var _props7 = this.props,
action = _props7.action,
hideAction = _props7.hideAction;
return action.indexOf('focus') !== -1 || hideAction.indexOf('blur') !== -1;
};
Trigger.prototype.forcePopupAlign = function forcePopupAlign() {
if (this.state.popupVisible && this._component && this._component.alignInstance) {
this._component.alignInstance.forceAlign();
}
};
Trigger.prototype.fireEvents = function fireEvents(type, e) {
var childCallback = this.props.children.props[type];
if (childCallback) {
childCallback(e);
}
var callback = this.props[type];
if (callback) {
callback(e);
}
};
Trigger.prototype.close = function close() {
this.setPopupVisible(false);
};
Trigger.prototype.render = function render() {
var _this4 = this;
var popupVisible = this.state.popupVisible;
var _props8 = this.props,
children = _props8.children,
forceRender = _props8.forceRender,
alignPoint = _props8.alignPoint,
className = _props8.className;
var child = __WEBPACK_IMPORTED_MODULE_4_react___default.a.Children.only(children);
var newChildProps = { key: 'trigger' };
if (this.isContextMenuToShow()) {
newChildProps.onContextMenu = this.onContextMenu;
} else {
newChildProps.onContextMenu = this.createTwoChains('onContextMenu');
}
if (this.isClickToHide() || this.isClickToShow()) {
newChildProps.onClick = this.onClick;
newChildProps.onMouseDown = this.onMouseDown;
newChildProps.onTouchStart = this.onTouchStart;
} else {
newChildProps.onClick = this.createTwoChains('onClick');
newChildProps.onMouseDown = this.createTwoChains('onMouseDown');
newChildProps.onTouchStart = this.createTwoChains('onTouchStart');
}
if (this.isMouseEnterToShow()) {
newChildProps.onMouseEnter = this.onMouseEnter;
if (alignPoint) {
newChildProps.onMouseMove = this.onMouseMove;
}
} else {
newChildProps.onMouseEnter = this.createTwoChains('onMouseEnter');
}
if (this.isMouseLeaveToHide()) {
newChildProps.onMouseLeave = this.onMouseLeave;
} else {
newChildProps.onMouseLeave = this.createTwoChains('onMouseLeave');
}
if (this.isFocusToShow() || this.isBlurToHide()) {
newChildProps.onFocus = this.onFocus;
newChildProps.onBlur = this.onBlur;
} else {
newChildProps.onFocus = this.createTwoChains('onFocus');
newChildProps.onBlur = this.createTwoChains('onBlur');
}
var childrenClassName = __WEBPACK_IMPORTED_MODULE_11_classnames___default()(child && child.props && child.props.className, className);
if (childrenClassName) {
newChildProps.className = childrenClassName;
}
var trigger = __WEBPACK_IMPORTED_MODULE_4_react___default.a.cloneElement(child, newChildProps);
if (!IS_REACT_16) {
return __WEBPACK_IMPORTED_MODULE_4_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_9_rc_util_es_ContainerRender__["a" /* default */],
{
parent: this,
visible: popupVisible,
autoMount: false,
forceRender: forceRender,
getComponent: this.getComponent,
getContainer: this.getContainer
},
function (_ref2) {
var renderComponent = _ref2.renderComponent;
_this4.renderComponent = renderComponent;
return trigger;
}
);
}
var portal = void 0;
// prevent unmounting after it's rendered
if (popupVisible || this._component || forceRender) {
portal = __WEBPACK_IMPORTED_MODULE_4_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_10_rc_util_es_Portal__["a" /* default */],
{
key: 'portal',
getContainer: this.getContainer,
didUpdate: this.handlePortalUpdate
},
this.getComponent()
);
}
return [trigger, portal];
};
return Trigger;
}(__WEBPACK_IMPORTED_MODULE_4_react___default.a.Component);
Trigger.propTypes = {
children: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
action: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.arrayOf(__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string)]),
showAction: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
hideAction: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
getPopupClassNameFromAlign: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
onPopupVisibleChange: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
afterPopupVisibleChange: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
popup: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.node, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func]).isRequired,
popupStyle: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,
prefixCls: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
popupClassName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
className: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
popupPlacement: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
builtinPlacements: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,
popupTransitionName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object]),
popupAnimation: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
mouseEnterDelay: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.number,
mouseLeaveDelay: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.number,
zIndex: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.number,
focusDelay: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.number,
blurDelay: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.number,
getPopupContainer: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
getDocument: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
forceRender: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
destroyPopupOnHide: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
mask: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
maskClosable: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
onPopupAlign: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
popupAlign: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,
popupVisible: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
defaultPopupVisible: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
maskTransitionName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object]),
maskAnimation: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
stretch: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
alignPoint: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool // Maybe we can support user pass position in the future
};
Trigger.contextTypes = contextTypes;
Trigger.childContextTypes = contextTypes;
Trigger.defaultProps = {
prefixCls: 'rc-trigger-popup',
getPopupClassNameFromAlign: returnEmptyString,
getDocument: returnDocument,
onPopupVisibleChange: noop,
afterPopupVisibleChange: noop,
onPopupAlign: noop,
popupClassName: '',
mouseEnterDelay: 0,
mouseLeaveDelay: 0.1,
focusDelay: 0,
blurDelay: 0.15,
popupStyle: {},
destroyPopupOnHide: false,
popupAlign: {},
defaultPopupVisible: false,
mask: false,
maskClosable: true,
action: [],
showAction: [],
hideAction: []
};
var _initialiseProps = function _initialiseProps() {
var _this5 = this;
this.onMouseEnter = function (e) {
var mouseEnterDelay = _this5.props.mouseEnterDelay;
_this5.fireEvents('onMouseEnter', e);
_this5.delaySetPopupVisible(true, mouseEnterDelay, mouseEnterDelay ? null : e);
};
this.onMouseMove = function (e) {
_this5.fireEvents('onMouseMove', e);
_this5.setPoint(e);
};
this.onMouseLeave = function (e) {
_this5.fireEvents('onMouseLeave', e);
_this5.delaySetPopupVisible(false, _this5.props.mouseLeaveDelay);
};
this.onPopupMouseEnter = function () {
_this5.clearDelayTimer();
};
this.onPopupMouseLeave = function (e) {
// https://github.com/react-component/trigger/pull/13
// react bug?
if (e.relatedTarget && !e.relatedTarget.setTimeout && _this5._component && _this5._component.getPopupDomNode && Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_Dom_contains__["a" /* default */])(_this5._component.getPopupDomNode(), e.relatedTarget)) {
return;
}
_this5.delaySetPopupVisible(false, _this5.props.mouseLeaveDelay);
};
this.onFocus = function (e) {
_this5.fireEvents('onFocus', e);
// incase focusin and focusout
_this5.clearDelayTimer();
if (_this5.isFocusToShow()) {
_this5.focusTime = Date.now();
_this5.delaySetPopupVisible(true, _this5.props.focusDelay);
}
};
this.onMouseDown = function (e) {
_this5.fireEvents('onMouseDown', e);
_this5.preClickTime = Date.now();
};
this.onTouchStart = function (e) {
_this5.fireEvents('onTouchStart', e);
_this5.preTouchTime = Date.now();
};
this.onBlur = function (e) {
_this5.fireEvents('onBlur', e);
_this5.clearDelayTimer();
if (_this5.isBlurToHide()) {
_this5.delaySetPopupVisible(false, _this5.props.blurDelay);
}
};
this.onContextMenu = function (e) {
e.preventDefault();
_this5.fireEvents('onContextMenu', e);
_this5.setPopupVisible(true, e);
};
this.onContextMenuClose = function () {
if (_this5.isContextMenuToShow()) {
_this5.close();
}
};
this.onClick = function (event) {
_this5.fireEvents('onClick', event);
// focus will trigger click
if (_this5.focusTime) {
var preTime = void 0;
if (_this5.preClickTime && _this5.preTouchTime) {
preTime = Math.min(_this5.preClickTime, _this5.preTouchTime);
} else if (_this5.preClickTime) {
preTime = _this5.preClickTime;
} else if (_this5.preTouchTime) {
preTime = _this5.preTouchTime;
}
if (Math.abs(preTime - _this5.focusTime) < 20) {
return;
}
_this5.focusTime = 0;
}
_this5.preClickTime = 0;
_this5.preTouchTime = 0;
if (event && event.preventDefault) {
event.preventDefault();
}
var nextVisible = !_this5.state.popupVisible;
if (_this5.isClickToHide() && !nextVisible || nextVisible && _this5.isClickToShow()) {
_this5.setPopupVisible(!_this5.state.popupVisible, event);
}
};
this.onPopupMouseDown = function () {
var _context$rcTrigger = _this5.context.rcTrigger,
rcTrigger = _context$rcTrigger === undefined ? {} : _context$rcTrigger;
_this5.hasPopupMouseDown = true;
clearTimeout(_this5.mouseDownTimeout);
_this5.mouseDownTimeout = setTimeout(function () {
_this5.hasPopupMouseDown = false;
}, 0);
if (rcTrigger.onPopupMouseDown) {
rcTrigger.onPopupMouseDown.apply(rcTrigger, arguments);
}
};
this.onDocumentClick = function (event) {
if (_this5.props.mask && !_this5.props.maskClosable) {
return;
}
var target = event.target;
var root = Object(__WEBPACK_IMPORTED_MODULE_6_react_dom__["findDOMNode"])(_this5);
if (!Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_Dom_contains__["a" /* default */])(root, target) && !_this5.hasPopupMouseDown) {
_this5.close();
}
};
this.getRootDomNode = function () {
return Object(__WEBPACK_IMPORTED_MODULE_6_react_dom__["findDOMNode"])(_this5);
};
this.getPopupClassNameFromAlign = function (align) {
var className = [];
var _props9 = _this5.props,
popupPlacement = _props9.popupPlacement,
builtinPlacements = _props9.builtinPlacements,
prefixCls = _props9.prefixCls,
alignPoint = _props9.alignPoint,
getPopupClassNameFromAlign = _props9.getPopupClassNameFromAlign;
if (popupPlacement && builtinPlacements) {
className.push(Object(__WEBPACK_IMPORTED_MODULE_12__utils__["b" /* getAlignPopupClassName */])(builtinPlacements, prefixCls, align, alignPoint));
}
if (getPopupClassNameFromAlign) {
className.push(getPopupClassNameFromAlign(align));
}
return className.join(' ');
};
this.getComponent = function () {
var _props10 = _this5.props,
prefixCls = _props10.prefixCls,
destroyPopupOnHide = _props10.destroyPopupOnHide,
popupClassName = _props10.popupClassName,
action = _props10.action,
onPopupAlign = _props10.onPopupAlign,
popupAnimation = _props10.popupAnimation,
popupTransitionName = _props10.popupTransitionName,
popupStyle = _props10.popupStyle,
mask = _props10.mask,
maskAnimation = _props10.maskAnimation,
maskTransitionName = _props10.maskTransitionName,
zIndex = _props10.zIndex,
popup = _props10.popup,
stretch = _props10.stretch,
alignPoint = _props10.alignPoint;
var _state = _this5.state,
popupVisible = _state.popupVisible,
point = _state.point;
var align = _this5.getPopupAlign();
var mouseProps = {};
if (_this5.isMouseEnterToShow()) {
mouseProps.onMouseEnter = _this5.onPopupMouseEnter;
}
if (_this5.isMouseLeaveToHide()) {
mouseProps.onMouseLeave = _this5.onPopupMouseLeave;
}
mouseProps.onMouseDown = _this5.onPopupMouseDown;
mouseProps.onTouchStart = _this5.onPopupMouseDown;
return __WEBPACK_IMPORTED_MODULE_4_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_13__Popup__["a" /* default */],
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({
prefixCls: prefixCls,
destroyPopupOnHide: destroyPopupOnHide,
visible: popupVisible,
point: alignPoint && point,
className: popupClassName,
action: action,
align: align,
onAlign: onPopupAlign,
animation: popupAnimation,
getClassNameFromAlign: _this5.getPopupClassNameFromAlign
}, mouseProps, {
stretch: stretch,
getRootDomNode: _this5.getRootDomNode,
style: popupStyle,
mask: mask,
zIndex: zIndex,
transitionName: popupTransitionName,
maskAnimation: maskAnimation,
maskTransitionName: maskTransitionName,
ref: _this5.savePopup
}),
typeof popup === 'function' ? popup() : popup
);
};
this.getContainer = function () {
var props = _this5.props;
var popupContainer = document.createElement('div');
// Make sure default popup container will never cause scrollbar appearing
// https://github.com/react-component/trigger/issues/41
popupContainer.style.position = 'absolute';
popupContainer.style.top = '0';
popupContainer.style.left = '0';
popupContainer.style.width = '100%';
var mountNode = props.getPopupContainer ? props.getPopupContainer(Object(__WEBPACK_IMPORTED_MODULE_6_react_dom__["findDOMNode"])(_this5)) : props.getDocument().body;
mountNode.appendChild(popupContainer);
return popupContainer;
};
this.setPoint = function (point) {
var alignPoint = _this5.props.alignPoint;
if (!alignPoint || !point) return;
_this5.setState({
point: {
pageX: point.pageX,
pageY: point.pageY
}
});
};
this.handlePortalUpdate = function () {
if (_this5.prevPopupVisible !== _this5.state.popupVisible) {
_this5.props.afterPopupVisibleChange(_this5.state.popupVisible);
}
};
this.savePopup = function (node) {
_this5._component = node;
};
};
/* harmony default export */ __webpack_exports__["a"] = (Trigger);
/***/ }),
/* 68 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__propertyUtils__ = __webpack_require__(520);
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 RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
var getComputedStyleX = void 0;
// https://stackoverflow.com/a/3485654/3040605
function forceRelayout(elem) {
var originalStyle = elem.style.display;
elem.style.display = 'none';
elem.offsetHeight; // eslint-disable-line
elem.style.display = originalStyle;
}
function css(el, name, v) {
var value = v;
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
for (var i in name) {
if (name.hasOwnProperty(i)) {
css(el, i, name[i]);
}
}
return undefined;
}
if (typeof value !== 'undefined') {
if (typeof value === 'number') {
value = value + 'px';
}
el.style[name] = value;
return undefined;
}
return getComputedStyleX(el, name);
}
function getClientPosition(elem) {
var box = void 0;
var x = void 0;
var y = void 0;
var doc = elem.ownerDocument;
var body = doc.body;
var docElem = doc && doc.documentElement;
// 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
box = elem.getBoundingClientRect();
// 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
// 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
// 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
x = box.left;
y = box.top;
// In IE, most of the time, 2 extra pixels are added to the top and left
// due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
// IE6 standards mode, this border can be overridden by setting the
// document element's border to zero -- thus, we cannot rely on the
// offset always being 2 pixels.
// In quirks mode, the offset can be determined by querying the body's
// clientLeft/clientTop, but in standards mode, it is found by querying
// the document element's clientLeft/clientTop. Since we already called
// getClientBoundingRect we have already forced a reflow, so it is not
// too expensive just to query them all.
// ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
// 窗口边框标准是设 documentElement ,quirks 时设置 body
// 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
// 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
// 标准 ie 下 docElem.clientTop 就是 border-top
// ie7 html 即窗口边框改变不了。永远为 2
// 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
x -= docElem.clientLeft || body.clientLeft || 0;
y -= docElem.clientTop || body.clientTop || 0;
return {
left: x,
top: y
};
}
function getScroll(w, top) {
var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
var method = 'scroll' + (top ? 'Top' : 'Left');
if (typeof ret !== 'number') {
var d = w.document;
// ie6,7,8 standard mode
ret = d.documentElement[method];
if (typeof ret !== 'number') {
// quirks mode
ret = d.body[method];
}
}
return ret;
}
function getScrollLeft(w) {
return getScroll(w);
}
function getScrollTop(w) {
return getScroll(w, true);
}
function getOffset(el) {
var pos = getClientPosition(el);
var doc = el.ownerDocument;
var w = doc.defaultView || doc.parentWindow;
pos.left += getScrollLeft(w);
pos.top += getScrollTop(w);
return pos;
}
/**
* A crude way of determining if an object is a window
* @member util
*/
function isWindow(obj) {
// must use == for ie8
/* eslint eqeqeq:0 */
return obj !== null && obj !== undefined && obj == obj.window;
}
function getDocument(node) {
if (isWindow(node)) {
return node.document;
}
if (node.nodeType === 9) {
return node;
}
return node.ownerDocument;
}
function _getComputedStyle(elem, name, cs) {
var computedStyle = cs;
var val = '';
var d = getDocument(elem);
computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null);
// https://github.com/kissyteam/kissy/issues/61
if (computedStyle) {
val = computedStyle.getPropertyValue(name) || computedStyle[name];
}
return val;
}
var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
var RE_POS = /^(top|right|bottom|left)$/;
var CURRENT_STYLE = 'currentStyle';
var RUNTIME_STYLE = 'runtimeStyle';
var LEFT = 'left';
var PX = 'px';
function _getComputedStyleIE(elem, name) {
// currentStyle maybe null
// http://msdn.microsoft.com/en-us/library/ms535231.aspx
var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
// 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
// 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
// 在 ie 下不对,需要直接用 offset 方式
// borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
// exclude left right for relativity
if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
// Remember the original values
var style = elem.style;
var left = style[LEFT];
var rsLeft = elem[RUNTIME_STYLE][LEFT];
// prevent flashing of content
elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
// Put in the new values to get a computed value out
style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
ret = style.pixelLeft + PX;
// Revert the changed values
style[LEFT] = left;
elem[RUNTIME_STYLE][LEFT] = rsLeft;
}
return ret === '' ? 'auto' : ret;
}
if (typeof window !== 'undefined') {
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
}
function getOffsetDirection(dir, option) {
if (dir === 'left') {
return option.useCssRight ? 'right' : dir;
}
return option.useCssBottom ? 'bottom' : dir;
}
function oppositeOffsetDirection(dir) {
if (dir === 'left') {
return 'right';
} else if (dir === 'right') {
return 'left';
} else if (dir === 'top') {
return 'bottom';
} else if (dir === 'bottom') {
return 'top';
}
}
// 设置 elem 相对 elem.ownerDocument 的坐标
function setLeftTop(elem, offset, option) {
// set position first, in-case top/left are set even on static elem
if (css(elem, 'position') === 'static') {
elem.style.position = 'relative';
}
var presetH = -999;
var presetV = -999;
var horizontalProperty = getOffsetDirection('left', option);
var verticalProperty = getOffsetDirection('top', option);
var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty);
var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty);
if (horizontalProperty !== 'left') {
presetH = 999;
}
if (verticalProperty !== 'top') {
presetV = 999;
}
var originalTransition = '';
var originalOffset = getOffset(elem);
if ('left' in offset || 'top' in offset) {
originalTransition = Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["c" /* getTransitionProperty */])(elem) || '';
Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["e" /* setTransitionProperty */])(elem, 'none');
}
if ('left' in offset) {
elem.style[oppositeHorizontalProperty] = '';
elem.style[horizontalProperty] = presetH + 'px';
}
if ('top' in offset) {
elem.style[oppositeVerticalProperty] = '';
elem.style[verticalProperty] = presetV + 'px';
}
// force relayout
forceRelayout(elem);
var old = getOffset(elem);
var originalStyle = {};
for (var key in offset) {
if (offset.hasOwnProperty(key)) {
var dir = getOffsetDirection(key, option);
var preset = key === 'left' ? presetH : presetV;
var off = originalOffset[key] - old[key];
if (dir === key) {
originalStyle[dir] = preset + off;
} else {
originalStyle[dir] = preset - off;
}
}
}
css(elem, originalStyle);
// force relayout
forceRelayout(elem);
if ('left' in offset || 'top' in offset) {
Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["e" /* setTransitionProperty */])(elem, originalTransition);
}
var ret = {};
for (var _key in offset) {
if (offset.hasOwnProperty(_key)) {
var _dir = getOffsetDirection(_key, option);
var _off = offset[_key] - originalOffset[_key];
if (_key === _dir) {
ret[_dir] = originalStyle[_dir] + _off;
} else {
ret[_dir] = originalStyle[_dir] - _off;
}
}
}
css(elem, ret);
}
function setTransform(elem, offset) {
var originalOffset = getOffset(elem);
var originalXY = Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["b" /* getTransformXY */])(elem);
var resultXY = { x: originalXY.x, y: originalXY.y };
if ('left' in offset) {
resultXY.x = originalXY.x + offset.left - originalOffset.left;
}
if ('top' in offset) {
resultXY.y = originalXY.y + offset.top - originalOffset.top;
}
Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["d" /* setTransformXY */])(elem, resultXY);
}
function setOffset(elem, offset, option) {
if (option.ignoreShake) {
var oriOffset = getOffset(elem);
var oLeft = oriOffset.left.toFixed(0);
var oTop = oriOffset.top.toFixed(0);
var tLeft = offset.left.toFixed(0);
var tTop = offset.top.toFixed(0);
if (oLeft === tLeft && oTop === tTop) {
return;
}
}
if (option.useCssRight || option.useCssBottom) {
setLeftTop(elem, offset, option);
} else if (option.useCssTransform && Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["a" /* getTransformName */])() in document.body.style) {
setTransform(elem, offset, option);
} else {
setLeftTop(elem, offset, option);
}
}
function each(arr, fn) {
for (var i = 0; i < arr.length; i++) {
fn(arr[i]);
}
}
function isBorderBoxFn(elem) {
return getComputedStyleX(elem, 'boxSizing') === 'border-box';
}
var BOX_MODELS = ['margin', 'border', 'padding'];
var CONTENT_INDEX = -1;
var PADDING_INDEX = 2;
var BORDER_INDEX = 1;
var MARGIN_INDEX = 0;
function swap(elem, options, callback) {
var old = {};
var style = elem.style;
var name = void 0;
// Remember the old values, and insert the new ones
for (name in options) {
if (options.hasOwnProperty(name)) {
old[name] = style[name];
style[name] = options[name];
}
}
callback.call(elem);
// Revert the old values
for (name in options) {
if (options.hasOwnProperty(name)) {
style[name] = old[name];
}
}
}
function getPBMWidth(elem, props, which) {
var value = 0;
var prop = void 0;
var j = void 0;
var i = void 0;
for (j = 0; j < props.length; j++) {
prop = props[j];
if (prop) {
for (i = 0; i < which.length; i++) {
var cssProp = void 0;
if (prop === 'border') {
cssProp = '' + prop + which[i] + 'Width';
} else {
cssProp = prop + which[i];
}
value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
}
}
}
return value;
}
var domUtils = {};
each(['Width', 'Height'], function (name) {
domUtils['doc' + name] = function (refWin) {
var d = refWin.document;
return Math.max(
// firefox chrome documentElement.scrollHeight< body.scrollHeight
// ie standard mode : documentElement.scrollHeight> body.scrollHeight
d.documentElement['scroll' + name],
// quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
d.body['scroll' + name], domUtils['viewport' + name](d));
};
domUtils['viewport' + name] = function (win) {
// pc browser includes scrollbar in window.innerWidth
var prop = 'client' + name;
var doc = win.document;
var body = doc.body;
var documentElement = doc.documentElement;
var documentElementProp = documentElement[prop];
// 标准模式取 documentElement
// backcompat 取 body
return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
};
});
/*
得到元素的大小信息
@param elem
@param name
@param {String} [extra] 'padding' : (css width) + padding
'border' : (css width) + padding + border
'margin' : (css width) + padding + border + margin
*/
function getWH(elem, name, ex) {
var extra = ex;
if (isWindow(elem)) {
return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
} else if (elem.nodeType === 9) {
return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
}
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
var borderBoxValue = name === 'width' ? elem.getBoundingClientRect().width : elem.getBoundingClientRect().height;
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem, computedStyle);
var cssBoxValue = 0;
if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) {
borderBoxValue = undefined;
// Fall back to computed then un computed css if necessary
cssBoxValue = getComputedStyleX(elem, name);
if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) {
cssBoxValue = elem.style[name] || 0;
}
// Normalize '', auto, and prepare for extra
cssBoxValue = parseFloat(cssBoxValue) || 0;
}
if (extra === undefined) {
extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
}
var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
var val = borderBoxValue || cssBoxValue;
if (extra === CONTENT_INDEX) {
if (borderBoxValueOrIsBorderBox) {
return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
}
return cssBoxValue;
} else if (borderBoxValueOrIsBorderBox) {
if (extra === BORDER_INDEX) {
return val;
}
return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle));
}
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
}
var cssShow = {
position: 'absolute',
visibility: 'hidden',
display: 'block'
};
// fix #119 : https://github.com/kissyteam/kissy/issues/119
function getWHIgnoreDisplay() {
for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) {
args[_key2] = arguments[_key2];
}
var val = void 0;
var elem = args[0];
// in case elem is window
// elem.offsetWidth === undefined
if (elem.offsetWidth !== 0) {
val = getWH.apply(undefined, args);
} else {
swap(elem, cssShow, function () {
val = getWH.apply(undefined, args);
});
}
return val;
}
each(['width', 'height'], function (name) {
var first = name.charAt(0).toUpperCase() + name.slice(1);
domUtils['outer' + first] = function (el, includeMargin) {
return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
};
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
domUtils[name] = function (elem, v) {
var val = v;
if (val !== undefined) {
if (elem) {
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem);
if (isBorderBox) {
val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
}
return css(elem, name, val);
}
return undefined;
}
return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
};
});
function mix(to, from) {
for (var i in from) {
if (from.hasOwnProperty(i)) {
to[i] = from[i];
}
}
return to;
}
var utils = {
getWindow: function getWindow(node) {
if (node && node.document && node.setTimeout) {
return node;
}
var doc = node.ownerDocument || node;
return doc.defaultView || doc.parentWindow;
},
getDocument: getDocument,
offset: function offset(el, value, option) {
if (typeof value !== 'undefined') {
setOffset(el, value, option || {});
} else {
return getOffset(el);
}
},
isWindow: isWindow,
each: each,
css: css,
clone: function clone(obj) {
var i = void 0;
var ret = {};
for (i in obj) {
if (obj.hasOwnProperty(i)) {
ret[i] = obj[i];
}
}
var overflow = obj.overflow;
if (overflow) {
for (i in obj) {
if (obj.hasOwnProperty(i)) {
ret.overflow[i] = obj.overflow[i];
}
}
}
return ret;
},
mix: mix,
getWindowScrollLeft: function getWindowScrollLeft(w) {
return getScrollLeft(w);
},
getWindowScrollTop: function getWindowScrollTop(w) {
return getScrollTop(w);
},
merge: function merge() {
var ret = {};
for (var _len2 = arguments.length, args = Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
args[_key3] = arguments[_key3];
}
for (var i = 0; i < args.length; i++) {
utils.mix(ret, args[i]);
}
return ret;
},
viewportWidth: 0,
viewportHeight: 0
};
mix(utils, domUtils);
/* harmony default export */ __webpack_exports__["a"] = (utils);
/***/ }),
/* 69 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__button__ = __webpack_require__(549);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__button_group__ = __webpack_require__(550);
__WEBPACK_IMPORTED_MODULE_0__button__["a" /* default */].Group = __WEBPACK_IMPORTED_MODULE_1__button_group__["a" /* default */];
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__button__["a" /* default */]);
/***/ }),
/* 70 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export toArray */
/* harmony export (immutable) */ __webpack_exports__["a"] = getActiveIndex;
/* unused harmony export getActiveKey */
/* harmony export (immutable) */ __webpack_exports__["j"] = setTransform;
/* harmony export (immutable) */ __webpack_exports__["h"] = isTransform3dSupported;
/* unused harmony export setTransition */
/* harmony export (immutable) */ __webpack_exports__["g"] = getTransformPropValue;
/* harmony export (immutable) */ __webpack_exports__["i"] = isVertical;
/* harmony export (immutable) */ __webpack_exports__["f"] = getTransformByIndex;
/* harmony export (immutable) */ __webpack_exports__["d"] = getMarginStyle;
/* unused harmony export getStyle */
/* unused harmony export setPxStyle */
/* harmony export (immutable) */ __webpack_exports__["b"] = getDataAttr;
/* harmony export (immutable) */ __webpack_exports__["c"] = getLeft;
/* harmony export (immutable) */ __webpack_exports__["e"] = getTop;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react__);
function toArray(children) {
// allow [c,[a,b]]
var c = [];
__WEBPACK_IMPORTED_MODULE_1_react___default.a.Children.forEach(children, function (child) {
if (child) {
c.push(child);
}
});
return c;
}
function getActiveIndex(children, activeKey) {
var c = toArray(children);
for (var i = 0; i < c.length; i++) {
if (c[i].key === activeKey) {
return i;
}
}
return -1;
}
function getActiveKey(children, index) {
var c = toArray(children);
return c[index].key;
}
function setTransform(style, v) {
style.transform = v;
style.webkitTransform = v;
style.mozTransform = v;
}
function isTransform3dSupported(style) {
return ('transform' in style || 'webkitTransform' in style || 'MozTransform' in style) && window.atob;
}
function setTransition(style, v) {
style.transition = v;
style.webkitTransition = v;
style.MozTransition = v;
}
function getTransformPropValue(v) {
return {
transform: v,
WebkitTransform: v,
MozTransform: v
};
}
function isVertical(tabBarPosition) {
return tabBarPosition === 'left' || tabBarPosition === 'right';
}
function getTransformByIndex(index, tabBarPosition) {
var translate = isVertical(tabBarPosition) ? 'translateY' : 'translateX';
return translate + '(' + -index * 100 + '%) translateZ(0)';
}
function getMarginStyle(index, tabBarPosition) {
var marginDirection = isVertical(tabBarPosition) ? 'marginTop' : 'marginLeft';
return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default()({}, marginDirection, -index * 100 + '%');
}
function getStyle(el, property) {
return +window.getComputedStyle(el).getPropertyValue(property).replace('px', '');
}
function setPxStyle(el, value, vertical) {
value = vertical ? '0px, ' + value + 'px, 0px' : value + 'px, 0px, 0px';
setTransform(el.style, 'translate3d(' + value + ')');
}
function getDataAttr(props) {
return Object.keys(props).reduce(function (prev, key) {
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') {
prev[key] = props[key];
}
return prev;
}, {});
}
function toNum(style, property) {
return +style.getPropertyValue(property).replace('px', '');
}
function getTypeValue(start, current, end, tabNode, wrapperNode) {
var total = getStyle(wrapperNode, 'padding-' + start);
if (!tabNode || !tabNode.parentNode) {
return total;
}
var childNodes = tabNode.parentNode.childNodes;
Array.prototype.some.call(childNodes, function (node) {
var style = window.getComputedStyle(node);
if (node !== tabNode) {
total += toNum(style, 'margin-' + start);
total += node[current];
total += toNum(style, 'margin-' + end);
if (style.boxSizing === 'content-box') {
total += toNum(style, 'border-' + start + '-width') + toNum(style, 'border-' + end + '-width');
}
return false;
}
// We need count current node margin
// ref: https://github.com/react-component/tabs/pull/139#issuecomment-431005262
total += toNum(style, 'margin-' + start);
return true;
});
return total;
}
function getLeft(tabNode, wrapperNode) {
return getTypeValue('left', 'offsetWidth', 'right', tabNode, wrapperNode);
}
function getTop(tabNode, wrapperNode) {
return getTypeValue('top', 'offsetHeight', 'bottom', tabNode, wrapperNode);
}
/***/ }),
/* 71 */
/***/ (function(module, exports, __webpack_require__) {
var baseIsNative = __webpack_require__(654),
getValue = __webpack_require__(657);
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
module.exports = getNative;
/***/ }),
/* 72 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ContentBlock
* @format
*
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CharacterMetadata = __webpack_require__(36);
var Immutable = __webpack_require__(14);
var findRangesImmutable = __webpack_require__(105);
var List = Immutable.List,
Map = Immutable.Map,
OrderedSet = Immutable.OrderedSet,
Record = Immutable.Record,
Repeat = Immutable.Repeat;
var EMPTY_SET = OrderedSet();
var defaultRecord = {
key: '',
type: 'unstyled',
text: '',
characterList: List(),
depth: 0,
data: Map()
};
var ContentBlockRecord = Record(defaultRecord);
var decorateCharacterList = function decorateCharacterList(config) {
if (!config) {
return config;
}
var characterList = config.characterList,
text = config.text;
if (text && !characterList) {
config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
}
return config;
};
var ContentBlock = function (_ContentBlockRecord) {
_inherits(ContentBlock, _ContentBlockRecord);
function ContentBlock(config) {
_classCallCheck(this, ContentBlock);
return _possibleConstructorReturn(this, _ContentBlockRecord.call(this, decorateCharacterList(config)));
}
ContentBlock.prototype.getKey = function getKey() {
return this.get('key');
};
ContentBlock.prototype.getType = function getType() {
return this.get('type');
};
ContentBlock.prototype.getText = function getText() {
return this.get('text');
};
ContentBlock.prototype.getCharacterList = function getCharacterList() {
return this.get('characterList');
};
ContentBlock.prototype.getLength = function getLength() {
return this.getText().length;
};
ContentBlock.prototype.getDepth = function getDepth() {
return this.get('depth');
};
ContentBlock.prototype.getData = function getData() {
return this.get('data');
};
ContentBlock.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getStyle() : EMPTY_SET;
};
ContentBlock.prototype.getEntityAt = function getEntityAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getEntity() : null;
};
/**
* Execute a callback for every contiguous range of styles within the block.
*/
ContentBlock.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
};
/**
* Execute a callback for every contiguous range of entities within the block.
*/
ContentBlock.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
};
return ContentBlock;
}(ContentBlockRecord);
function haveEqualStyle(charA, charB) {
return charA.getStyle() === charB.getStyle();
}
function haveEqualEntity(charA, charB) {
return charA.getEntity() === charB.getEntity();
}
module.exports = ContentBlock;
/***/ }),
/* 73 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @typechecks
*/
/**
* Unicode-enabled replacesments for basic String functions.
*
* All the functions in this module assume that the input string is a valid
* UTF-16 encoding of a Unicode sequence. If it's not the case, the behavior
* will be undefined.
*
* WARNING: Since this module is typechecks-enforced, you may find new bugs
* when replacing normal String functions with ones provided here.
*/
var invariant = __webpack_require__(13);
// These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
// surrogate code unit.
var SURROGATE_HIGH_START = 0xD800;
var SURROGATE_HIGH_END = 0xDBFF;
var SURROGATE_LOW_START = 0xDC00;
var SURROGATE_LOW_END = 0xDFFF;
var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
/**
* @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
* @return {boolean} Whether code-unit is in a surrogate (hi/low) range
*/
function isCodeUnitInSurrogateRange(codeUnit) {
return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
}
/**
* Returns whether the two characters starting at `index` form a surrogate pair.
* For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
* (s, 1) returns false.
*
* @param {string} str
* @param {number} index
* @return {boolean}
*/
function isSurrogatePair(str, index) {
!(0 <= index && index < str.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant(false) : void 0;
if (index + 1 === str.length) {
return false;
}
var first = str.charCodeAt(index);
var second = str.charCodeAt(index + 1);
return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END;
}
/**
* @param {string} str Non-empty string
* @return {boolean} True if the input includes any surrogate code units
*/
function hasSurrogateUnit(str) {
return SURROGATE_UNITS_REGEX.test(str);
}
/**
* Return the length of the original Unicode character at given position in the
* String by looking into the UTF-16 code unit; that is equal to 1 for any
* non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
* returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
* representing non-BMP characters ([U+10000..U+10FFFF]).
*
* Examples:
* - '\u0020' => 1
* - '\u3020' => 1
* - '\uD835' => 2
* - '\uD835\uDDEF' => 2
* - '\uDDEF' => 2
*
* @param {string} str Non-empty string
* @param {number} pos Position in the string to look for one code unit
* @return {number} Number 1 or 2
*/
function getUTF16Length(str, pos) {
return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
}
/**
* Fully Unicode-enabled replacement for String#length
*
* @param {string} str Valid Unicode string
* @return {number} The number of Unicode characters in the string
*/
function strlen(str) {
// Call the native functions if there's no surrogate char
if (!hasSurrogateUnit(str)) {
return str.length;
}
var len = 0;
for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
len++;
}
return len;
}
/**
* Fully Unicode-enabled replacement for String#substr()
*
* @param {string} str Valid Unicode string
* @param {number} start Location in Unicode sequence to begin extracting
* @param {?number} length The number of Unicode characters to extract
* (default: to the end of the string)
* @return {string} Extracted sub-string
*/
function substr(str, start, length) {
start = start || 0;
length = length === undefined ? Infinity : length || 0;
// Call the native functions if there's no surrogate char
if (!hasSurrogateUnit(str)) {
return str.substr(start, length);
}
// Obvious cases
var size = str.length;
if (size <= 0 || start > size || length <= 0) {
return '';
}
// Find the actual starting position
var posA = 0;
if (start > 0) {
for (; start > 0 && posA < size; start--) {
posA += getUTF16Length(str, posA);
}
if (posA >= size) {
return '';
}
} else if (start < 0) {
for (posA = size; start < 0 && 0 < posA; start++) {
posA -= getUTF16Length(str, posA - 1);
}
if (posA < 0) {
posA = 0;
}
}
// Find the actual ending position
var posB = size;
if (length < size) {
for (posB = posA; length > 0 && posB < size; length--) {
posB += getUTF16Length(str, posB);
}
}
return str.substring(posA, posB);
}
/**
* Fully Unicode-enabled replacement for String#substring()
*
* @param {string} str Valid Unicode string
* @param {number} start Location in Unicode sequence to begin extracting
* @param {?number} end Location in Unicode sequence to end extracting
* (default: end of the string)
* @return {string} Extracted sub-string
*/
function substring(str, start, end) {
start = start || 0;
end = end === undefined ? Infinity : end || 0;
if (start < 0) {
start = 0;
}
if (end < 0) {
end = 0;
}
var length = Math.abs(end - start);
start = start < end ? start : end;
return substr(str, start, length);
}
/**
* Get a list of Unicode code-points from a String
*
* @param {string} str Valid Unicode string
* @return {array} A list of code-points in [0..0x10FFFF]
*/
function getCodePoints(str) {
var codePoints = [];
for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
codePoints.push(str.codePointAt(pos));
}
return codePoints;
}
var UnicodeUtils = {
getCodePoints: getCodePoints,
getUTF16Length: getUTF16Length,
hasSurrogateUnit: hasSurrogateUnit,
isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
isSurrogatePair: isSurrogatePair,
strlen: strlen,
substring: substring,
substr: substr
};
module.exports = UnicodeUtils;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 74 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(422));
__export(__webpack_require__(1060));
__export(__webpack_require__(1061));
__export(__webpack_require__(1063));
__export(__webpack_require__(423));
__export(__webpack_require__(1067));
__export(__webpack_require__(1068));
__export(__webpack_require__(424));
__export(__webpack_require__(1073));
__export(__webpack_require__(1074));
//# sourceMappingURL=utils.js.map
/***/ }),
/* 75 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var invariant = function(condition, format, a, b, c, d, e, f) {
if (process.env.NODE_ENV !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var error;
if (format === undefined) {
error = new Error(
'Minified exception occurred; use the non-minified dev environment ' +
'for the full error message and additional helpful warnings.'
);
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(
format.replace(/%s/g, function() { return args[argIndex++]; })
);
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
};
module.exports = invariant;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(55);
var createDesc = __webpack_require__(92);
module.exports = __webpack_require__(63) ? function (object, key, value) {
return dP.f(object, key, createDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
/***/ }),
/* 77 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(78);
module.exports = function (it) {
if (!isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
/***/ }),
/* 78 */
/***/ (function(module, exports) {
module.exports = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/* 79 */
/***/ (function(module, exports) {
module.exports = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
/***/ }),
/* 80 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_rc_pagination_es_locale_en_US__ = __webpack_require__(245);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__date_picker_locale_en_US__ = __webpack_require__(159);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__time_picker_locale_en_US__ = __webpack_require__(160);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__calendar_locale_en_US__ = __webpack_require__(247);
/* harmony default export */ __webpack_exports__["a"] = ({
locale: 'en',
Pagination: __WEBPACK_IMPORTED_MODULE_0_rc_pagination_es_locale_en_US__["a" /* default */],
DatePicker: __WEBPACK_IMPORTED_MODULE_1__date_picker_locale_en_US__["a" /* default */],
TimePicker: __WEBPACK_IMPORTED_MODULE_2__time_picker_locale_en_US__["a" /* default */],
Calendar: __WEBPACK_IMPORTED_MODULE_3__calendar_locale_en_US__["a" /* default */],
global: {
placeholder: 'Please select'
},
Table: {
filterTitle: 'Filter menu',
filterConfirm: 'OK',
filterReset: 'Reset',
selectAll: 'Select current page',
selectInvert: 'Invert current page',
sortTitle: 'Sort'
},
Modal: {
okText: 'OK',
cancelText: 'Cancel',
justOkText: 'OK'
},
Popconfirm: {
okText: 'OK',
cancelText: 'Cancel'
},
Transfer: {
titles: ['', ''],
searchPlaceholder: 'Search here',
itemUnit: 'item',
itemsUnit: 'items'
},
Upload: {
uploading: 'Uploading...',
removeFile: 'Remove file',
uploadError: 'Upload error',
previewFile: 'Preview file'
},
Empty: {
description: 'No Data'
},
Icon: {
icon: 'icon'
},
Text: {
edit: 'edit',
copy: 'copy',
copied: 'copy success',
expand: 'expand'
}
});
/***/ }),
/* 81 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Menu__ = __webpack_require__(510);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__SubMenu__ = __webpack_require__(265);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__MenuItem__ = __webpack_require__(530);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__MenuItemGroup__ = __webpack_require__(533);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Divider__ = __webpack_require__(534);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_1__SubMenu__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_2__MenuItem__["a"]; });
/* unused harmony reexport MenuItem */
/* unused harmony reexport MenuItemGroup */
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_3__MenuItemGroup__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_4__Divider__["a"]; });
/* harmony default export */ __webpack_exports__["e"] = (__WEBPACK_IMPORTED_MODULE_0__Menu__["a" /* default */]);
/***/ }),
/* 82 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["h"] = noop;
/* harmony export (immutable) */ __webpack_exports__["a"] = getKeyFromChildrenIndex;
/* harmony export (immutable) */ __webpack_exports__["b"] = getMenuIdFromSubMenuEventKey;
/* harmony export (immutable) */ __webpack_exports__["e"] = loopMenuItem;
/* harmony export (immutable) */ __webpack_exports__["f"] = loopMenuItemRecursively;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return menuAllProps; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getWidth; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return setStyle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isMobileDevice; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
var isMobile = __webpack_require__(514);
function noop() {}
function getKeyFromChildrenIndex(child, menuEventKey, index) {
var prefix = menuEventKey || '';
return child.key || prefix + 'item_' + index;
}
function getMenuIdFromSubMenuEventKey(eventKey) {
return eventKey + '-menu-';
}
function loopMenuItem(children, cb) {
var index = -1;
__WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.forEach(children, function (c) {
index++;
if (c && c.type && c.type.isMenuItemGroup) {
__WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.forEach(c.props.children, function (c2) {
index++;
cb(c2, index);
});
} else {
cb(c, index);
}
});
}
function loopMenuItemRecursively(children, keys, ret) {
/* istanbul ignore if */
if (!children || ret.find) {
return;
}
__WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.forEach(children, function (c) {
if (c) {
var construct = c.type;
if (!construct || !(construct.isSubMenu || construct.isMenuItem || construct.isMenuItemGroup)) {
return;
}
if (keys.indexOf(c.key) !== -1) {
ret.find = true;
} else if (c.props.children) {
loopMenuItemRecursively(c.props.children, keys, ret);
}
}
});
}
var menuAllProps = ['defaultSelectedKeys', 'selectedKeys', 'defaultOpenKeys', 'openKeys', 'mode', 'getPopupContainer', 'onSelect', 'onDeselect', 'onDestroy', 'openTransitionName', 'openAnimation', 'subMenuOpenDelay', 'subMenuCloseDelay', 'forceSubMenuRender', 'triggerSubMenuAction', 'level', 'selectable', 'multiple', 'onOpenChange', 'visible', 'focusable', 'defaultActiveFirst', 'prefixCls', 'inlineIndent', 'parentMenu', 'title', 'rootPrefixCls', 'eventKey', 'active', 'onItemHover', 'onTitleMouseEnter', 'onTitleMouseLeave', 'onTitleClick', 'popupAlign', 'popupOffset', 'isOpen', 'renderMenuItem', 'manualRef', 'subMenuKey', 'disabled', 'index', 'isSelected', 'store', 'activeKey', 'builtinPlacements', 'overflowedIndicator',
// the following keys found need to be removed from test regression
'attribute', 'value', 'popupClassName', 'inlineCollapsed', 'menu', 'theme', 'itemIcon', 'expandIcon'];
// ref: https://github.com/ant-design/ant-design/issues/14007
// ref: https://bugs.chromium.org/p/chromium/issues/detail?id=360889
// getBoundingClientRect return the full precision value, which is
// not the same behavior as on chrome. Set the precision to 6 to
// unify their behavior
var getWidth = function getWidth(elem) {
var width = elem && typeof elem.getBoundingClientRect === 'function' && elem.getBoundingClientRect().width;
if (width) {
width = +width.toFixed(6);
}
return width || 0;
};
var setStyle = function setStyle(elem, styleProperty, value) {
if (elem && typeof elem.style === 'object') {
elem.style[styleProperty] = value;
}
};
var isMobileDevice = function isMobileDevice() {
return isMobile.any;
};
/***/ }),
/* 83 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = function() {};
if (process.env.NODE_ENV !== 'production') {
warning = function(condition, format, args) {
var len = arguments.length;
args = new Array(len > 2 ? len - 2 : 0);
for (var key = 2; key < len; key++) {
args[key - 2] = arguments[key];
}
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
'message argument'
);
}
if (format.length < 10 || (/^[s\W]*$/).test(format)) {
throw new Error(
'The warning format should be able to uniquely identify this ' +
'warning. Please, use a more descriptive format than: ' + format
);
}
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' +
format.replace(/%s/g, function() {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch(x) {}
}
};
}
module.exports = warning;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 84 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(28),
now = __webpack_require__(585),
toNumber = __webpack_require__(288);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
timeWaiting = wait - timeSinceLastCall;
return maxing
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
: timeWaiting;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
module.exports = debounce;
/***/ }),
/* 85 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Checkbox__ = __webpack_require__(299);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Group__ = __webpack_require__(615);
__WEBPACK_IMPORTED_MODULE_0__Checkbox__["a" /* default */].Group = __WEBPACK_IMPORTED_MODULE_1__Group__["a" /* default */];
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Checkbox__["a" /* default */]);
/***/ }),
/* 86 */
/***/ (function(module, exports) {
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
}
module.exports = eq;
/***/ }),
/* 87 */
/***/ (function(module, exports) {
/**
* This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
return value;
}
module.exports = identity;
/***/ }),
/* 88 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule SelectionState
* @format
*
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Immutable = __webpack_require__(14);
var Record = Immutable.Record;
var defaultRecord = {
anchorKey: '',
anchorOffset: 0,
focusKey: '',
focusOffset: 0,
isBackward: false,
hasFocus: false
};
var SelectionStateRecord = Record(defaultRecord);
var SelectionState = function (_SelectionStateRecord) {
_inherits(SelectionState, _SelectionStateRecord);
function SelectionState() {
_classCallCheck(this, SelectionState);
return _possibleConstructorReturn(this, _SelectionStateRecord.apply(this, arguments));
}
SelectionState.prototype.serialize = function serialize() {
return 'Anchor: ' + this.getAnchorKey() + ':' + this.getAnchorOffset() + ', ' + 'Focus: ' + this.getFocusKey() + ':' + this.getFocusOffset() + ', ' + 'Is Backward: ' + String(this.getIsBackward()) + ', ' + 'Has Focus: ' + String(this.getHasFocus());
};
SelectionState.prototype.getAnchorKey = function getAnchorKey() {
return this.get('anchorKey');
};
SelectionState.prototype.getAnchorOffset = function getAnchorOffset() {
return this.get('anchorOffset');
};
SelectionState.prototype.getFocusKey = function getFocusKey() {
return this.get('focusKey');
};
SelectionState.prototype.getFocusOffset = function getFocusOffset() {
return this.get('focusOffset');
};
SelectionState.prototype.getIsBackward = function getIsBackward() {
return this.get('isBackward');
};
SelectionState.prototype.getHasFocus = function getHasFocus() {
return this.get('hasFocus');
};
/**
* Return whether the specified range overlaps with an edge of the
* SelectionState.
*/
SelectionState.prototype.hasEdgeWithin = function hasEdgeWithin(blockKey, start, end) {
var anchorKey = this.getAnchorKey();
var focusKey = this.getFocusKey();
if (anchorKey === focusKey && anchorKey === blockKey) {
var selectionStart = this.getStartOffset();
var selectionEnd = this.getEndOffset();
return start <= selectionEnd && selectionStart <= end;
}
if (blockKey !== anchorKey && blockKey !== focusKey) {
return false;
}
var offsetToCheck = blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
return start <= offsetToCheck && end >= offsetToCheck;
};
SelectionState.prototype.isCollapsed = function isCollapsed() {
return this.getAnchorKey() === this.getFocusKey() && this.getAnchorOffset() === this.getFocusOffset();
};
SelectionState.prototype.getStartKey = function getStartKey() {
return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
};
SelectionState.prototype.getStartOffset = function getStartOffset() {
return this.getIsBackward() ? this.getFocusOffset() : this.getAnchorOffset();
};
SelectionState.prototype.getEndKey = function getEndKey() {
return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
};
SelectionState.prototype.getEndOffset = function getEndOffset() {
return this.getIsBackward() ? this.getAnchorOffset() : this.getFocusOffset();
};
SelectionState.createEmpty = function createEmpty(key) {
return new SelectionState({
anchorKey: key,
anchorOffset: 0,
focusKey: key,
focusOffset: 0,
isBackward: false,
hasFocus: false
});
};
return SelectionState;
}(SelectionStateRecord);
module.exports = SelectionState;
/***/ }),
/* 89 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/**
* This function is used to mark string literals representing CSS class names
* so that they can be transformed statically. This allows for modularization
* and minification of CSS class names.
*
* In static_upstream, this function is actually implemented, but it should
* eventually be replaced with something more descriptive, and the transform
* that is used in the main stack should be ported for use elsewhere.
*
* @param string|object className to modularize, or an object of key/values.
* In the object case, the values are conditions that
* determine if the className keys should be included.
* @param [string ...] Variable list of classNames in the string case.
* @return string Renderable space-separated CSS className.
*/
function cx(classNames) {
if (typeof classNames == 'object') {
return Object.keys(classNames).filter(function (className) {
return classNames[className];
}).map(replace).join(' ');
}
return Array.prototype.map.call(arguments, replace).join(' ');
}
function replace(str) {
return str.replace(/\//g, '-');
}
module.exports = cx;
/***/ }),
/* 90 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Immutable = factory());
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step !== 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
if (o !== o || o === Infinity) {
return 0;
}
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.of = function() {var keyValues = SLICE$0.call(arguments, 0);
return emptyMap().withMutations(function(map ) {
for (var i = 0; i < keyValues.length; i += 2) {
if (i + 1 >= keyValues.length) {
throw new Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
};
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
if (end === Infinity) {
end = originalSize;
} else {
end = end | 0;
}
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
if (this._map && !this._map.has(k)) {
var defaultVal = this._defaultValues[k];
if (v === defaultVal) {
return this;
}
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findEntry: function(predicate, context, notSetValue) {
var found = notSetValue;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
findLastEntry: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
},
findLastKey: function(predicate, context) {
return this.toKeyedSeq().reverse().findKey(predicate, context);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
lastKeyOf: function(searchValue) {
return this.toKeyedSeq().reverse().keyOf(searchValue);
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.lastKeyOf(searchValue);
return key === undefined ? -1 : key;
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var entry = this.findLastEntry(predicate, context);
return entry ? entry[0] : -1;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
keySeq: function() {
return Range(0, this.size);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
SetIterable.prototype.contains = SetIterable.prototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : String(value);
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ }),
/* 91 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return createBrowserHistory; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createHashHistory; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return createMemoryHistory; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return createLocation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return locationsAreEqual; });
/* unused harmony export parsePath */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return createPath; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_esm_extends__ = __webpack_require__(1160);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_resolve_pathname__ = __webpack_require__(1161);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_value_equal__ = __webpack_require__(1162);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_tiny_warning__ = __webpack_require__(1163);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_tiny_invariant__ = __webpack_require__(1164);
function addLeadingSlash(path) {
return path.charAt(0) === '/' ? path : '/' + path;
}
function stripLeadingSlash(path) {
return path.charAt(0) === '/' ? path.substr(1) : path;
}
function hasBasename(path, prefix) {
return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
}
function stripBasename(path, prefix) {
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
}
function stripTrailingSlash(path) {
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
}
function parsePath(path) {
var pathname = path || '/';
var search = '';
var hash = '';
var hashIndex = pathname.indexOf('#');
if (hashIndex !== -1) {
hash = pathname.substr(hashIndex);
pathname = pathname.substr(0, hashIndex);
}
var searchIndex = pathname.indexOf('?');
if (searchIndex !== -1) {
search = pathname.substr(searchIndex);
pathname = pathname.substr(0, searchIndex);
}
return {
pathname: pathname,
search: search === '?' ? '' : search,
hash: hash === '#' ? '' : hash
};
}
function createPath(location) {
var pathname = location.pathname,
search = location.search,
hash = location.hash;
var path = pathname || '/';
if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
return path;
}
function createLocation(path, state, key, currentLocation) {
var location;
if (typeof path === 'string') {
// Two-arg form: push(path, state)
location = parsePath(path);
location.state = state;
} else {
// One-arg form: push(location)
location = Object(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_esm_extends__["a" /* default */])({}, path);
if (location.pathname === undefined) location.pathname = '';
if (location.search) {
if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
} else {
location.search = '';
}
if (location.hash) {
if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
} else {
location.hash = '';
}
if (state !== undefined && location.state === undefined) location.state = state;
}
try {
location.pathname = decodeURI(location.pathname);
} catch (e) {
if (e instanceof URIError) {
throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
} else {
throw e;
}
}
if (key) location.key = key;
if (currentLocation) {
// Resolve incomplete/relative pathname relative to current location.
if (!location.pathname) {
location.pathname = currentLocation.pathname;
} else if (location.pathname.charAt(0) !== '/') {
location.pathname = Object(__WEBPACK_IMPORTED_MODULE_1_resolve_pathname__["a" /* default */])(location.pathname, currentLocation.pathname);
}
} else {
// When there is no prior location and pathname is empty, set it to /
if (!location.pathname) {
location.pathname = '/';
}
}
return location;
}
function locationsAreEqual(a, b) {
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && Object(__WEBPACK_IMPORTED_MODULE_2_value_equal__["a" /* default */])(a.state, b.state);
}
function createTransitionManager() {
var prompt = null;
function setPrompt(nextPrompt) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(prompt == null, 'A history supports only one prompt at a time') : void 0;
prompt = nextPrompt;
return function () {
if (prompt === nextPrompt) prompt = null;
};
}
function confirmTransitionTo(location, action, getUserConfirmation, callback) {
// TODO: If another transition starts while we're still confirming
// the previous one, we may end up in a weird state. Figure out the
// best way to handle this.
if (prompt != null) {
var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
if (typeof result === 'string') {
if (typeof getUserConfirmation === 'function') {
getUserConfirmation(result, callback);
} else {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(false, 'A history needs a getUserConfirmation function in order to use a prompt message') : void 0;
callback(true);
}
} else {
// Return false from a transition hook to cancel the transition.
callback(result !== false);
}
} else {
callback(true);
}
}
var listeners = [];
function appendListener(fn) {
var isActive = true;
function listener() {
if (isActive) fn.apply(void 0, arguments);
}
listeners.push(listener);
return function () {
isActive = false;
listeners = listeners.filter(function (item) {
return item !== listener;
});
};
}
function notifyListeners() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
listeners.forEach(function (listener) {
return listener.apply(void 0, args);
});
}
return {
setPrompt: setPrompt,
confirmTransitionTo: confirmTransitionTo,
appendListener: appendListener,
notifyListeners: notifyListeners
};
}
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
function getConfirmation(message, callback) {
callback(window.confirm(message)); // eslint-disable-line no-alert
}
/**
* Returns true if the HTML5 history API is supported. Taken from Modernizr.
*
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
* changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
*/
function supportsHistory() {
var ua = window.navigator.userAgent;
if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
return window.history && 'pushState' in window.history;
}
/**
* Returns true if browser fires popstate on hash change.
* IE10 and IE11 do not.
*/
function supportsPopStateOnHashChange() {
return window.navigator.userAgent.indexOf('Trident') === -1;
}
/**
* Returns false if using go(n) with hash history causes a full page reload.
*/
function supportsGoWithoutReloadUsingHash() {
return window.navigator.userAgent.indexOf('Firefox') === -1;
}
/**
* Returns true if a given popstate event is an extraneous WebKit event.
* Accounts for the fact that Chrome on iOS fires real popstate events
* containing undefined state when pressing the back button.
*/
function isExtraneousPopstateEvent(event) {
event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
}
var PopStateEvent = 'popstate';
var HashChangeEvent = 'hashchange';
function getHistoryState() {
try {
return window.history.state || {};
} catch (e) {
// IE 11 sometimes throws when accessing window.history.state
// See https://github.com/ReactTraining/history/pull/289
return {};
}
}
/**
* Creates a history object that uses the HTML5 history API including
* pushState, replaceState, and the popstate event.
*/
function createBrowserHistory(props) {
if (props === void 0) {
props = {};
}
!canUseDOM ? process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_4_tiny_invariant__["a" /* default */])(false, 'Browser history needs a DOM') : Object(__WEBPACK_IMPORTED_MODULE_4_tiny_invariant__["a" /* default */])(false) : void 0;
var globalHistory = window.history;
var canUseHistory = supportsHistory();
var needsHashChangeListener = !supportsPopStateOnHashChange();
var _props = props,
_props$forceRefresh = _props.forceRefresh,
forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
_props$getUserConfirm = _props.getUserConfirmation,
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
_props$keyLength = _props.keyLength,
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
function getDOMLocation(historyState) {
var _ref = historyState || {},
key = _ref.key,
state = _ref.state;
var _window$location = window.location,
pathname = _window$location.pathname,
search = _window$location.search,
hash = _window$location.hash;
var path = pathname + search + hash;
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0;
if (basename) path = stripBasename(path, basename);
return createLocation(path, state, key);
}
function createKey() {
return Math.random().toString(36).substr(2, keyLength);
}
var transitionManager = createTransitionManager();
function setState(nextState) {
Object(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_esm_extends__["a" /* default */])(history, nextState);
history.length = globalHistory.length;
transitionManager.notifyListeners(history.location, history.action);
}
function handlePopState(event) {
// Ignore extraneous popstate events in WebKit.
if (isExtraneousPopstateEvent(event)) return;
handlePop(getDOMLocation(event.state));
}
function handleHashChange() {
handlePop(getDOMLocation(getHistoryState()));
}
var forceNextPop = false;
function handlePop(location) {
if (forceNextPop) {
forceNextPop = false;
setState();
} else {
var action = 'POP';
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (ok) {
setState({
action: action,
location: location
});
} else {
revertPop(location);
}
});
}
}
function revertPop(fromLocation) {
var toLocation = history.location; // TODO: We could probably make this more reliable by
// keeping a list of keys we've seen in sessionStorage.
// Instead, we just default to 0 for keys we don't know.
var toIndex = allKeys.indexOf(toLocation.key);
if (toIndex === -1) toIndex = 0;
var fromIndex = allKeys.indexOf(fromLocation.key);
if (fromIndex === -1) fromIndex = 0;
var delta = toIndex - fromIndex;
if (delta) {
forceNextPop = true;
go(delta);
}
}
var initialLocation = getDOMLocation(getHistoryState());
var allKeys = [initialLocation.key]; // Public interface
function createHref(location) {
return basename + createPath(location);
}
function push(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
var action = 'PUSH';
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
var href = createHref(location);
var key = location.key,
state = location.state;
if (canUseHistory) {
globalHistory.pushState({
key: key,
state: state
}, null, href);
if (forceRefresh) {
window.location.href = href;
} else {
var prevIndex = allKeys.indexOf(history.location.key);
var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
nextKeys.push(location.key);
allKeys = nextKeys;
setState({
action: action,
location: location
});
}
} else {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') : void 0;
window.location.href = href;
}
});
}
function replace(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
var action = 'REPLACE';
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
var href = createHref(location);
var key = location.key,
state = location.state;
if (canUseHistory) {
globalHistory.replaceState({
key: key,
state: state
}, null, href);
if (forceRefresh) {
window.location.replace(href);
} else {
var prevIndex = allKeys.indexOf(history.location.key);
if (prevIndex !== -1) allKeys[prevIndex] = location.key;
setState({
action: action,
location: location
});
}
} else {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') : void 0;
window.location.replace(href);
}
});
}
function go(n) {
globalHistory.go(n);
}
function goBack() {
go(-1);
}
function goForward() {
go(1);
}
var listenerCount = 0;
function checkDOMListeners(delta) {
listenerCount += delta;
if (listenerCount === 1 && delta === 1) {
window.addEventListener(PopStateEvent, handlePopState);
if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
} else if (listenerCount === 0) {
window.removeEventListener(PopStateEvent, handlePopState);
if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
}
}
var isBlocked = false;
function block(prompt) {
if (prompt === void 0) {
prompt = false;
}
var unblock = transitionManager.setPrompt(prompt);
if (!isBlocked) {
checkDOMListeners(1);
isBlocked = true;
}
return function () {
if (isBlocked) {
isBlocked = false;
checkDOMListeners(-1);
}
return unblock();
};
}
function listen(listener) {
var unlisten = transitionManager.appendListener(listener);
checkDOMListeners(1);
return function () {
checkDOMListeners(-1);
unlisten();
};
}
var history = {
length: globalHistory.length,
action: 'POP',
location: initialLocation,
createHref: createHref,
push: push,
replace: replace,
go: go,
goBack: goBack,
goForward: goForward,
block: block,
listen: listen
};
return history;
}
var HashChangeEvent$1 = 'hashchange';
var HashPathCoders = {
hashbang: {
encodePath: function encodePath(path) {
return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);
},
decodePath: function decodePath(path) {
return path.charAt(0) === '!' ? path.substr(1) : path;
}
},
noslash: {
encodePath: stripLeadingSlash,
decodePath: addLeadingSlash
},
slash: {
encodePath: addLeadingSlash,
decodePath: addLeadingSlash
}
};
function getHashPath() {
// We can't use window.location.hash here because it's not
// consistent across browsers - Firefox will pre-decode it!
var href = window.location.href;
var hashIndex = href.indexOf('#');
return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
}
function pushHashPath(path) {
window.location.hash = path;
}
function replaceHashPath(path) {
var hashIndex = window.location.href.indexOf('#');
window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
}
function createHashHistory(props) {
if (props === void 0) {
props = {};
}
!canUseDOM ? process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_4_tiny_invariant__["a" /* default */])(false, 'Hash history needs a DOM') : Object(__WEBPACK_IMPORTED_MODULE_4_tiny_invariant__["a" /* default */])(false) : void 0;
var globalHistory = window.history;
var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
var _props = props,
_props$getUserConfirm = _props.getUserConfirmation,
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
_props$hashType = _props.hashType,
hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
var _HashPathCoders$hashT = HashPathCoders[hashType],
encodePath = _HashPathCoders$hashT.encodePath,
decodePath = _HashPathCoders$hashT.decodePath;
function getDOMLocation() {
var path = decodePath(getHashPath());
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0;
if (basename) path = stripBasename(path, basename);
return createLocation(path);
}
var transitionManager = createTransitionManager();
function setState(nextState) {
Object(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_esm_extends__["a" /* default */])(history, nextState);
history.length = globalHistory.length;
transitionManager.notifyListeners(history.location, history.action);
}
var forceNextPop = false;
var ignorePath = null;
function handleHashChange() {
var path = getHashPath();
var encodedPath = encodePath(path);
if (path !== encodedPath) {
// Ensure we always have a properly-encoded hash.
replaceHashPath(encodedPath);
} else {
var location = getDOMLocation();
var prevLocation = history.location;
if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.
ignorePath = null;
handlePop(location);
}
}
function handlePop(location) {
if (forceNextPop) {
forceNextPop = false;
setState();
} else {
var action = 'POP';
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (ok) {
setState({
action: action,
location: location
});
} else {
revertPop(location);
}
});
}
}
function revertPop(fromLocation) {
var toLocation = history.location; // TODO: We could probably make this more reliable by
// keeping a list of paths we've seen in sessionStorage.
// Instead, we just default to 0 for paths we don't know.
var toIndex = allPaths.lastIndexOf(createPath(toLocation));
if (toIndex === -1) toIndex = 0;
var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
if (fromIndex === -1) fromIndex = 0;
var delta = toIndex - fromIndex;
if (delta) {
forceNextPop = true;
go(delta);
}
} // Ensure the hash is encoded properly before doing anything else.
var path = getHashPath();
var encodedPath = encodePath(path);
if (path !== encodedPath) replaceHashPath(encodedPath);
var initialLocation = getDOMLocation();
var allPaths = [createPath(initialLocation)]; // Public interface
function createHref(location) {
return '#' + encodePath(basename + createPath(location));
}
function push(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(state === undefined, 'Hash history cannot push state; it is ignored') : void 0;
var action = 'PUSH';
var location = createLocation(path, undefined, undefined, history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
var path = createPath(location);
var encodedPath = encodePath(basename + path);
var hashChanged = getHashPath() !== encodedPath;
if (hashChanged) {
// We cannot tell if a hashchange was caused by a PUSH, so we'd
// rather setState here and ignore the hashchange. The caveat here
// is that other hash histories in the page will consider it a POP.
ignorePath = path;
pushHashPath(encodedPath);
var prevIndex = allPaths.lastIndexOf(createPath(history.location));
var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
nextPaths.push(path);
allPaths = nextPaths;
setState({
action: action,
location: location
});
} else {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack') : void 0;
setState();
}
});
}
function replace(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(state === undefined, 'Hash history cannot replace state; it is ignored') : void 0;
var action = 'REPLACE';
var location = createLocation(path, undefined, undefined, history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
var path = createPath(location);
var encodedPath = encodePath(basename + path);
var hashChanged = getHashPath() !== encodedPath;
if (hashChanged) {
// We cannot tell if a hashchange was caused by a REPLACE, so we'd
// rather setState here and ignore the hashchange. The caveat here
// is that other hash histories in the page will consider it a POP.
ignorePath = path;
replaceHashPath(encodedPath);
}
var prevIndex = allPaths.indexOf(createPath(history.location));
if (prevIndex !== -1) allPaths[prevIndex] = path;
setState({
action: action,
location: location
});
});
}
function go(n) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : void 0;
globalHistory.go(n);
}
function goBack() {
go(-1);
}
function goForward() {
go(1);
}
var listenerCount = 0;
function checkDOMListeners(delta) {
listenerCount += delta;
if (listenerCount === 1 && delta === 1) {
window.addEventListener(HashChangeEvent$1, handleHashChange);
} else if (listenerCount === 0) {
window.removeEventListener(HashChangeEvent$1, handleHashChange);
}
}
var isBlocked = false;
function block(prompt) {
if (prompt === void 0) {
prompt = false;
}
var unblock = transitionManager.setPrompt(prompt);
if (!isBlocked) {
checkDOMListeners(1);
isBlocked = true;
}
return function () {
if (isBlocked) {
isBlocked = false;
checkDOMListeners(-1);
}
return unblock();
};
}
function listen(listener) {
var unlisten = transitionManager.appendListener(listener);
checkDOMListeners(1);
return function () {
checkDOMListeners(-1);
unlisten();
};
}
var history = {
length: globalHistory.length,
action: 'POP',
location: initialLocation,
createHref: createHref,
push: push,
replace: replace,
go: go,
goBack: goBack,
goForward: goForward,
block: block,
listen: listen
};
return history;
}
function clamp(n, lowerBound, upperBound) {
return Math.min(Math.max(n, lowerBound), upperBound);
}
/**
* Creates a history object that stores locations in memory.
*/
function createMemoryHistory(props) {
if (props === void 0) {
props = {};
}
var _props = props,
getUserConfirmation = _props.getUserConfirmation,
_props$initialEntries = _props.initialEntries,
initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
_props$initialIndex = _props.initialIndex,
initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
_props$keyLength = _props.keyLength,
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
var transitionManager = createTransitionManager();
function setState(nextState) {
Object(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_esm_extends__["a" /* default */])(history, nextState);
history.length = history.entries.length;
transitionManager.notifyListeners(history.location, history.action);
}
function createKey() {
return Math.random().toString(36).substr(2, keyLength);
}
var index = clamp(initialIndex, 0, initialEntries.length - 1);
var entries = initialEntries.map(function (entry) {
return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
}); // Public interface
var createHref = createPath;
function push(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
var action = 'PUSH';
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
var prevIndex = history.index;
var nextIndex = prevIndex + 1;
var nextEntries = history.entries.slice(0);
if (nextEntries.length > nextIndex) {
nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
} else {
nextEntries.push(location);
}
setState({
action: action,
location: location,
index: nextIndex,
entries: nextEntries
});
});
}
function replace(path, state) {
process.env.NODE_ENV !== "production" ? Object(__WEBPACK_IMPORTED_MODULE_3_tiny_warning__["a" /* default */])(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
var action = 'REPLACE';
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return;
history.entries[history.index] = location;
setState({
action: action,
location: location
});
});
}
function go(n) {
var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
var action = 'POP';
var location = history.entries[nextIndex];
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (ok) {
setState({
action: action,
location: location,
index: nextIndex
});
} else {
// Mimic the behavior of DOM histories by
// causing a render after a cancelled POP.
setState();
}
});
}
function goBack() {
go(-1);
}
function goForward() {
go(1);
}
function canGo(n) {
var nextIndex = history.index + n;
return nextIndex >= 0 && nextIndex < history.entries.length;
}
function block(prompt) {
if (prompt === void 0) {
prompt = false;
}
return transitionManager.setPrompt(prompt);
}
function listen(listener) {
return transitionManager.appendListener(listener);
}
var history = {
length: entries.length,
action: 'POP',
location: entries[index],
index: index,
entries: entries,
createHref: createHref,
push: push,
replace: replace,
go: go,
goBack: goBack,
goForward: goForward,
canGo: canGo,
block: block,
listen: listen
};
return history;
}
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9)))
/***/ }),
/* 92 */
/***/ (function(module, exports) {
module.exports = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
/***/ }),
/* 93 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _react = __webpack_require__(0);
var _react2 = _interopRequireDefault(_react);
var _implementation = __webpack_require__(460);
var _implementation2 = _interopRequireDefault(_implementation);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _react2.default.createContext || _implementation2.default;
module.exports = exports['default'];
/***/ }),
/* 94 */
/***/ (function(module, exports) {
module.exports = {};
/***/ }),
/* 95 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(531);
/***/ }),
/* 96 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Select; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_select__ = __webpack_require__(250);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__config_provider__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_omit_js__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_warning__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__icon__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_type__ = __webpack_require__(40);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}
return t;
};
var SelectSizes = Object(__WEBPACK_IMPORTED_MODULE_8__util_type__["a" /* tuple */])('default', 'large', 'small');
var SelectPropTypes = {
prefixCls: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
className: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
size: __WEBPACK_IMPORTED_MODULE_1_prop_types__["oneOf"](SelectSizes),
notFoundContent: __WEBPACK_IMPORTED_MODULE_1_prop_types__["any"],
showSearch: __WEBPACK_IMPORTED_MODULE_1_prop_types__["bool"],
optionLabelProp: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
transitionName: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
choiceTransitionName: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
id: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"]
}; // => It is needless to export the declaration of below two inner components.
// export { Option, OptGroup };
var Select =
/*#__PURE__*/
function (_React$Component) {
_inherits(Select, _React$Component);
function Select(props) {
var _this;
_classCallCheck(this, Select);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Select).call(this, props));
_this.saveSelect = function (node) {
_this.rcSelect = node;
};
_this.renderSelect = function (_ref) {
var _classNames;
var getContextPopupContainer = _ref.getPopupContainer,
getPrefixCls = _ref.getPrefixCls,
renderEmpty = _ref.renderEmpty;
var _a = _this.props,
customizePrefixCls = _a.prefixCls,
_a$className = _a.className,
className = _a$className === void 0 ? '' : _a$className,
size = _a.size,
mode = _a.mode,
getPopupContainer = _a.getPopupContainer,
removeIcon = _a.removeIcon,
clearIcon = _a.clearIcon,
menuItemSelectedIcon = _a.menuItemSelectedIcon,
showArrow = _a.showArrow,
restProps = __rest(_a, ["prefixCls", "className", "size", "mode", "getPopupContainer", "removeIcon", "clearIcon", "menuItemSelectedIcon", "showArrow"]);
var rest = Object(__WEBPACK_IMPORTED_MODULE_5_omit_js__["a" /* default */])(restProps, ['inputIcon']);
var prefixCls = getPrefixCls('select', customizePrefixCls);
var cls = __WEBPACK_IMPORTED_MODULE_3_classnames___default()((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-lg"), size === 'large'), _defineProperty(_classNames, "".concat(prefixCls, "-sm"), size === 'small'), _defineProperty(_classNames, "".concat(prefixCls, "-show-arrow"), showArrow), _classNames), className);
var optionLabelProp = _this.props.optionLabelProp;
if (_this.isCombobox()) {
// children 带 dom 结构时,无法填入输入框
optionLabelProp = optionLabelProp || 'value';
}
var modeConfig = {
multiple: mode === 'multiple',
tags: mode === 'tags',
combobox: _this.isCombobox()
};
var finalRemoveIcon = removeIcon && (__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](removeIcon) ? __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](removeIcon, {
className: __WEBPACK_IMPORTED_MODULE_3_classnames___default()(removeIcon.props.className, "".concat(prefixCls, "-remove-icon"))
}) : removeIcon) || __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__icon__["a" /* default */], {
type: "close",
className: "".concat(prefixCls, "-remove-icon")
});
var finalClearIcon = clearIcon && (__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](clearIcon) ? __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](clearIcon, {
className: __WEBPACK_IMPORTED_MODULE_3_classnames___default()(clearIcon.props.className, "".concat(prefixCls, "-clear-icon"))
}) : clearIcon) || __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__icon__["a" /* default */], {
type: "close-circle",
theme: "filled",
className: "".concat(prefixCls, "-clear-icon")
});
var finalMenuItemSelectedIcon = menuItemSelectedIcon && (__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](menuItemSelectedIcon) ? __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](menuItemSelectedIcon, {
className: __WEBPACK_IMPORTED_MODULE_3_classnames___default()(menuItemSelectedIcon.props.className, "".concat(prefixCls, "-selected-icon"))
}) : menuItemSelectedIcon) || __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__icon__["a" /* default */], {
type: "check",
className: "".concat(prefixCls, "-selected-icon")
});
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_2_rc_select__["c" /* default */], _extends({
inputIcon: _this.renderSuffixIcon(prefixCls),
removeIcon: finalRemoveIcon,
clearIcon: finalClearIcon,
menuItemSelectedIcon: finalMenuItemSelectedIcon,
showArrow: showArrow
}, rest, modeConfig, {
prefixCls: prefixCls,
className: cls,
optionLabelProp: optionLabelProp || 'children',
notFoundContent: _this.getNotFoundContent(renderEmpty),
getPopupContainer: getPopupContainer || getContextPopupContainer,
ref: _this.saveSelect
}));
};
Object(__WEBPACK_IMPORTED_MODULE_6__util_warning__["a" /* default */])(props.mode !== 'combobox', 'Select', 'The combobox mode is deprecated, ' + 'it will be removed in next major version, ' + 'please use AutoComplete instead');
return _this;
}
_createClass(Select, [{
key: "focus",
value: function focus() {
this.rcSelect.focus();
}
}, {
key: "blur",
value: function blur() {
this.rcSelect.blur();
}
}, {
key: "getNotFoundContent",
value: function getNotFoundContent(renderEmpty) {
var notFoundContent = this.props.notFoundContent;
if (notFoundContent !== undefined) {
return notFoundContent;
}
if (this.isCombobox()) {
return null;
}
return renderEmpty('Select'); // if (this.isCombobox()) {
// // AutoComplete don't have notFoundContent defaultly
// return notFoundContent === undefined ? null : notFoundContent;
// }
// return renderEmpty('Select');
// // return notFoundContent === undefined ? locale.notFoundContent : notFoundContent;
}
}, {
key: "isCombobox",
value: function isCombobox() {
var mode = this.props.mode;
return mode === 'combobox' || mode === Select.SECRET_COMBOBOX_MODE_DO_NOT_USE;
}
}, {
key: "renderSuffixIcon",
value: function renderSuffixIcon(prefixCls) {
var _this$props = this.props,
loading = _this$props.loading,
suffixIcon = _this$props.suffixIcon;
if (suffixIcon) {
return __WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](suffixIcon) ? __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](suffixIcon, {
className: __WEBPACK_IMPORTED_MODULE_3_classnames___default()(suffixIcon.props.className, "".concat(prefixCls, "-arrow-icon"))
}) : suffixIcon;
}
if (loading) {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__icon__["a" /* default */], {
type: "loading"
});
}
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__icon__["a" /* default */], {
type: "down",
className: "".concat(prefixCls, "-arrow-icon")
});
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_4__config_provider__["a" /* ConfigConsumer */], null, this.renderSelect);
}
}]);
return Select;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Select.Option = __WEBPACK_IMPORTED_MODULE_2_rc_select__["b" /* Option */];
Select.OptGroup = __WEBPACK_IMPORTED_MODULE_2_rc_select__["a" /* OptGroup */];
Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = 'SECRET_COMBOBOX_MODE_DO_NOT_USE';
Select.defaultProps = {
showSearch: false,
transitionName: 'slide-up',
choiceTransitionName: 'zoom'
};
Select.propTypes = SelectPropTypes;
/***/ }),
/* 97 */
/***/ (function(module, exports, __webpack_require__) {
var root = __webpack_require__(29);
/** Built-in value references. */
var Symbol = root.Symbol;
module.exports = Symbol;
/***/ }),
/* 98 */
/***/ (function(module, exports) {
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length &&
(type == 'number' ||
(type != 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length);
}
module.exports = isIndex;
/***/ }),
/* 99 */
/***/ (function(module, exports, __webpack_require__) {
var isSymbol = __webpack_require__(126);
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
module.exports = toKey;
/***/ }),
/* 100 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _from = __webpack_require__(320);
var _from2 = _interopRequireDefault(_from);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
} else {
return (0, _from2.default)(arr);
}
};
/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(58),
isLength = __webpack_require__(187);
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
module.exports = isArrayLike;
/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {
var identity = __webpack_require__(87),
overRest = __webpack_require__(824),
setToString = __webpack_require__(357);
/**
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
*/
function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + '');
}
module.exports = baseRest;
/***/ }),
/* 103 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = measureScrollbar;
/* harmony export (immutable) */ __webpack_exports__["a"] = debounce;
/* harmony export (immutable) */ __webpack_exports__["e"] = warningOnce;
/* harmony export (immutable) */ __webpack_exports__["d"] = remove;
/* harmony export (immutable) */ __webpack_exports__["b"] = getDataAndAriaProps;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_warning__ = __webpack_require__(83);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_warning__);
var scrollbarVerticalSize = void 0;
var scrollbarHorizontalSize = void 0;
// Measure scrollbar width for padding body during modal show/hide
var scrollbarMeasure = {
position: 'absolute',
top: '-9999px',
width: '50px',
height: '50px'
};
function measureScrollbar() {
var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
if (typeof document === 'undefined' || typeof window === 'undefined') {
return 0;
}
var isVertical = direction === 'vertical';
if (isVertical && scrollbarVerticalSize) {
return scrollbarVerticalSize;
} else if (!isVertical && scrollbarHorizontalSize) {
return scrollbarHorizontalSize;
}
var scrollDiv = document.createElement('div');
Object.keys(scrollbarMeasure).forEach(function (scrollProp) {
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
});
// Append related overflow style
if (isVertical) {
scrollDiv.style.overflowY = 'scroll';
} else {
scrollDiv.style.overflowX = 'scroll';
}
document.body.appendChild(scrollDiv);
var size = 0;
if (isVertical) {
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
scrollbarVerticalSize = size;
} else if (!isVertical) {
size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
scrollbarHorizontalSize = size;
}
document.body.removeChild(scrollDiv);
return size;
}
function debounce(func, wait, immediate) {
var timeout = void 0;
function debounceFunc() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var context = this;
// https://fb.me/react-event-pooling
if (args[0] && args[0].persist) {
args[0].persist();
}
var later = function later() {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(context, args);
}
}
debounceFunc.cancel = function cancel() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
};
return debounceFunc;
}
var warned = {};
function warningOnce(condition, format, args) {
if (!warned[format]) {
__WEBPACK_IMPORTED_MODULE_0_warning___default()(condition, format, args);
warned[format] = !condition;
}
}
function remove(array, item) {
var index = array.indexOf(item);
var front = array.slice(0, index);
var last = array.slice(index + 1, array.length);
return front.concat(last);
}
/**
* Returns only data- and aria- key/value pairs
* @param {object} props
*/
function getDataAndAriaProps(props) {
return Object.keys(props).reduce(function (memo, key) {
if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
memo[key] = props[key];
}
return memo;
}, {});
}
/***/ }),
/* 104 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule BlockMapBuilder
* @format
*
*/
var Immutable = __webpack_require__(14);
var OrderedMap = Immutable.OrderedMap;
var BlockMapBuilder = {
createFromArray: function createFromArray(blocks) {
return OrderedMap(blocks.map(function (block) {
return [block.getKey(), block];
}));
}
};
module.exports = BlockMapBuilder;
/***/ }),
/* 105 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule findRangesImmutable
* @format
*
*/
/**
* Search through an array to find contiguous stretches of elements that
* match a specified filter function.
*
* When ranges are found, execute a specified `found` function to supply
* the values to the caller.
*/
function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
if (!haystack.size) {
return;
}
var cursor = 0;
haystack.reduce(function (value, nextValue, nextIndex) {
if (!areEqualFn(value, nextValue)) {
if (filterFn(value)) {
foundFn(cursor, nextIndex);
}
cursor = nextIndex;
}
return nextValue;
});
filterFn(haystack.last()) && foundFn(cursor, haystack.count());
}
module.exports = findRangesImmutable;
/***/ }),
/* 106 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule isEventHandled
* @format
*
*/
/**
* Utility method for determining whether or not the value returned
* from a handler indicates that it was handled.
*/
function isEventHandled(value) {
return value === 'handled' || value === true;
}
module.exports = isEventHandled;
/***/ }),
/* 107 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftOffsetKey
* @format
*
*/
var KEY_DELIMITER = '-';
var DraftOffsetKey = {
encode: function encode(blockKey, decoratorKey, leafKey) {
return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
},
decode: function decode(offsetKey) {
var _offsetKey$split = offsetKey.split(KEY_DELIMITER),
blockKey = _offsetKey$split[0],
decoratorKey = _offsetKey$split[1],
leafKey = _offsetKey$split[2];
return {
blockKey: blockKey,
decoratorKey: parseInt(decoratorKey, 10),
leafKey: parseInt(leafKey, 10)
};
}
};
module.exports = DraftOffsetKey;
/***/ }),
/* 108 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule removeTextWithStrategy
* @format
*
*/
var DraftModifier = __webpack_require__(32);
/**
* For a collapsed selection state, remove text based on the specified strategy.
* If the selection state is not collapsed, remove the entire selected range.
*/
function removeTextWithStrategy(editorState, strategy, direction) {
var selection = editorState.getSelection();
var content = editorState.getCurrentContent();
var target = selection;
if (selection.isCollapsed()) {
if (direction === 'forward') {
if (editorState.isSelectionAtEndOfContent()) {
return content;
}
} else if (editorState.isSelectionAtStartOfContent()) {
return content;
}
target = strategy(editorState);
if (target === selection) {
return content;
}
}
return DraftModifier.removeRange(content, target, direction);
}
module.exports = removeTextWithStrategy;
/***/ }),
/* 109 */
/***/ (function(module, exports) {
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/**
* Replaces all `placeholder` elements in `array` with an internal placeholder
* and returns an array of their indexes.
*
* @private
* @param {Array} array The array to modify.
* @param {*} placeholder The placeholder to replace.
* @returns {Array} Returns the new array of placeholder indexes.
*/
function replaceHolders(array, placeholder) {
var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value === placeholder || value === PLACEHOLDER) {
array[index] = PLACEHOLDER;
result[resIndex++] = index;
}
}
return result;
}
module.exports = replaceHolders;
/***/ }),
/* 110 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BrowserRouter__ = __webpack_require__(1159);
/* unused harmony reexport BrowserRouter */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__HashRouter__ = __webpack_require__(1165);
/* unused harmony reexport HashRouter */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Link__ = __webpack_require__(444);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_2__Link__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__MemoryRouter__ = __webpack_require__(1166);
/* unused harmony reexport MemoryRouter */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NavLink__ = __webpack_require__(1168);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_4__NavLink__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Prompt__ = __webpack_require__(1170);
/* unused harmony reexport Prompt */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Redirect__ = __webpack_require__(1172);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_6__Redirect__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Route__ = __webpack_require__(445);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_7__Route__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Router__ = __webpack_require__(234);
/* unused harmony reexport Router */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__StaticRouter__ = __webpack_require__(1174);
/* unused harmony reexport StaticRouter */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Switch__ = __webpack_require__(1176);
/* unused harmony reexport Switch */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__generatePath__ = __webpack_require__(1178);
/* unused harmony reexport generatePath */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__matchPath__ = __webpack_require__(1179);
/* unused harmony reexport matchPath */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__withRouter__ = __webpack_require__(1180);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_13__withRouter__["a"]; });
/***/ }),
/* 111 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(241);
var enumBugKeys = __webpack_require__(155);
module.exports = Object.keys || function keys(O) {
return $keys(O, enumBugKeys);
};
/***/ }),
/* 112 */
/***/ (function(module, exports) {
module.exports = true;
/***/ }),
/* 113 */
/***/ (function(module, exports) {
var id = 0;
var px = Math.random();
module.exports = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
/***/ }),
/* 114 */
/***/ (function(module, exports) {
exports.f = {}.propertyIsEnumerable;
/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(151);
module.exports = function (it) {
return Object(defined(it));
};
/***/ }),
/* 116 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
if (process.env.NODE_ENV === 'production') {
module.exports = __webpack_require__(461);
} else {
module.exports = __webpack_require__(462);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 117 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
module.exports = emptyFunction;
/***/ }),
/* 118 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Module dependencies.
*/
try {
var index = __webpack_require__(253);
} catch (err) {
var index = __webpack_require__(253);
}
/**
* Whitespace regexp.
*/
var re = /\s+/;
/**
* toString reference.
*/
var toString = Object.prototype.toString;
/**
* Wrap `el` in a `ClassList`.
*
* @param {Element} el
* @return {ClassList}
* @api public
*/
module.exports = function(el){
return new ClassList(el);
};
/**
* Initialize a new ClassList for `el`.
*
* @param {Element} el
* @api private
*/
function ClassList(el) {
if (!el || !el.nodeType) {
throw new Error('A DOM element reference is required');
}
this.el = el;
this.list = el.classList;
}
/**
* Add class `name` if not already present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.add = function(name){
// classList
if (this.list) {
this.list.add(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (!~i) arr.push(name);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove class `name` when present, or
* pass a regular expression to remove
* any which match.
*
* @param {String|RegExp} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.remove = function(name){
if ('[object RegExp]' == toString.call(name)) {
return this.removeMatching(name);
}
// classList
if (this.list) {
this.list.remove(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (~i) arr.splice(i, 1);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove all classes matching `re`.
*
* @param {RegExp} re
* @return {ClassList}
* @api private
*/
ClassList.prototype.removeMatching = function(re){
var arr = this.array();
for (var i = 0; i < arr.length; i++) {
if (re.test(arr[i])) {
this.remove(arr[i]);
}
}
return this;
};
/**
* Toggle class `name`, can force state via `force`.
*
* For browsers that support classList, but do not support `force` yet,
* the mistake will be detected and corrected.
*
* @param {String} name
* @param {Boolean} force
* @return {ClassList}
* @api public
*/
ClassList.prototype.toggle = function(name, force){
// classList
if (this.list) {
if ("undefined" !== typeof force) {
if (force !== this.list.toggle(name, force)) {
this.list.toggle(name); // toggle again to correct
}
} else {
this.list.toggle(name);
}
return this;
}
// fallback
if ("undefined" !== typeof force) {
if (!force) {
this.remove(name);
} else {
this.add(name);
}
} else {
if (this.has(name)) {
this.remove(name);
} else {
this.add(name);
}
}
return this;
};
/**
* Return an array of classes.
*
* @return {Array}
* @api public
*/
ClassList.prototype.array = function(){
var className = this.el.getAttribute('class') || '';
var str = className.replace(/^\s+|\s+$/g, '');
var arr = str.split(re);
if ('' === arr[0]) arr.shift();
return arr;
};
/**
* Check if class `name` is present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.has =
ClassList.prototype.contains = function(name){
return this.list
? this.list.contains(name)
: !! ~index(this.array(), name);
};
/***/ }),
/* 119 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* WEBPACK VAR INJECTION */(function(global) {/**
* A collection of shims that provide minimal functionality of the ES6 collections.
*
* These implementations are not meant to be used outside of the ResizeObserver
* modules as they cover only a limited range of use cases.
*/
/* eslint-disable require-jsdoc, valid-jsdoc */
var MapShim = (function () {
if (typeof Map !== 'undefined') {
return Map;
}
/**
* Returns index in provided array that matches the specified key.
*
* @param {Array} arr
* @param {*} key
* @returns {number}
*/
function getIndex(arr, key) {
var result = -1;
arr.some(function (entry, index) {
if (entry[0] === key) {
result = index;
return true;
}
return false;
});
return result;
}
return /** @class */ (function () {
function class_1() {
this.__entries__ = [];
}
Object.defineProperty(class_1.prototype, "size", {
/**
* @returns {boolean}
*/
get: function () {
return this.__entries__.length;
},
enumerable: true,
configurable: true
});
/**
* @param {*} key
* @returns {*}
*/
class_1.prototype.get = function (key) {
var index = getIndex(this.__entries__, key);
var entry = this.__entries__[index];
return entry && entry[1];
};
/**
* @param {*} key
* @param {*} value
* @returns {void}
*/
class_1.prototype.set = function (key, value) {
var index = getIndex(this.__entries__, key);
if (~index) {
this.__entries__[index][1] = value;
}
else {
this.__entries__.push([key, value]);
}
};
/**
* @param {*} key
* @returns {void}
*/
class_1.prototype.delete = function (key) {
var entries = this.__entries__;
var index = getIndex(entries, key);
if (~index) {
entries.splice(index, 1);
}
};
/**
* @param {*} key
* @returns {void}
*/
class_1.prototype.has = function (key) {
return !!~getIndex(this.__entries__, key);
};
/**
* @returns {void}
*/
class_1.prototype.clear = function () {
this.__entries__.splice(0);
};
/**
* @param {Function} callback
* @param {*} [ctx=null]
* @returns {void}
*/
class_1.prototype.forEach = function (callback, ctx) {
if (ctx === void 0) { ctx = null; }
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
var entry = _a[_i];
callback.call(ctx, entry[1], entry[0]);
}
};
return class_1;
}());
})();
/**
* Detects whether window and document objects are available in current environment.
*/
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
// Returns global object of a current environment.
var global$1 = (function () {
if (typeof global !== 'undefined' && global.Math === Math) {
return global;
}
if (typeof self !== 'undefined' && self.Math === Math) {
return self;
}
if (typeof window !== 'undefined' && window.Math === Math) {
return window;
}
// eslint-disable-next-line no-new-func
return Function('return this')();
})();
/**
* A shim for the requestAnimationFrame which falls back to the setTimeout if
* first one is not supported.
*
* @returns {number} Requests' identifier.
*/
var requestAnimationFrame$1 = (function () {
if (typeof requestAnimationFrame === 'function') {
// It's required to use a bounded function because IE sometimes throws
// an "Invalid calling object" error if rAF is invoked without the global
// object on the left hand side.
return requestAnimationFrame.bind(global$1);
}
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
})();
// Defines minimum timeout before adding a trailing call.
var trailingTimeout = 2;
/**
* Creates a wrapper function which ensures that provided callback will be
* invoked only once during the specified delay period.
*
* @param {Function} callback - Function to be invoked after the delay period.
* @param {number} delay - Delay after which to invoke callback.
* @returns {Function}
*/
function throttle (callback, delay) {
var leadingCall = false, trailingCall = false, lastCallTime = 0;
/**
* Invokes the original callback function and schedules new invocation if
* the "proxy" was called during current request.
*
* @returns {void}
*/
function resolvePending() {
if (leadingCall) {
leadingCall = false;
callback();
}
if (trailingCall) {
proxy();
}
}
/**
* Callback invoked after the specified delay. It will further postpone
* invocation of the original function delegating it to the
* requestAnimationFrame.
*
* @returns {void}
*/
function timeoutCallback() {
requestAnimationFrame$1(resolvePending);
}
/**
* Schedules invocation of the original function.
*
* @returns {void}
*/
function proxy() {
var timeStamp = Date.now();
if (leadingCall) {
// Reject immediately following calls.
if (timeStamp - lastCallTime < trailingTimeout) {
return;
}
// Schedule new call to be in invoked when the pending one is resolved.
// This is important for "transitions" which never actually start
// immediately so there is a chance that we might miss one if change
// happens amids the pending invocation.
trailingCall = true;
}
else {
leadingCall = true;
trailingCall = false;
setTimeout(timeoutCallback, delay);
}
lastCallTime = timeStamp;
}
return proxy;
}
// Minimum delay before invoking the update of observers.
var REFRESH_DELAY = 20;
// A list of substrings of CSS properties used to find transition events that
// might affect dimensions of observed elements.
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
// Check if MutationObserver is available.
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
/**
* Singleton controller class which handles updates of ResizeObserver instances.
*/
var ResizeObserverController = /** @class */ (function () {
/**
* Creates a new instance of ResizeObserverController.
*
* @private
*/
function ResizeObserverController() {
/**
* Indicates whether DOM listeners have been added.
*
* @private {boolean}
*/
this.connected_ = false;
/**
* Tells that controller has subscribed for Mutation Events.
*
* @private {boolean}
*/
this.mutationEventsAdded_ = false;
/**
* Keeps reference to the instance of MutationObserver.
*
* @private {MutationObserver}
*/
this.mutationsObserver_ = null;
/**
* A list of connected observers.
*
* @private {Array}
*/
this.observers_ = [];
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
}
/**
* Adds observer to observers list.
*
* @param {ResizeObserverSPI} observer - Observer to be added.
* @returns {void}
*/
ResizeObserverController.prototype.addObserver = function (observer) {
if (!~this.observers_.indexOf(observer)) {
this.observers_.push(observer);
}
// Add listeners if they haven't been added yet.
if (!this.connected_) {
this.connect_();
}
};
/**
* Removes observer from observers list.
*
* @param {ResizeObserverSPI} observer - Observer to be removed.
* @returns {void}
*/
ResizeObserverController.prototype.removeObserver = function (observer) {
var observers = this.observers_;
var index = observers.indexOf(observer);
// Remove observer if it's present in registry.
if (~index) {
observers.splice(index, 1);
}
// Remove listeners if controller has no connected observers.
if (!observers.length && this.connected_) {
this.disconnect_();
}
};
/**
* Invokes the update of observers. It will continue running updates insofar
* it detects changes.
*
* @returns {void}
*/
ResizeObserverController.prototype.refresh = function () {
var changesDetected = this.updateObservers_();
// Continue running updates if changes have been detected as there might
// be future ones caused by CSS transitions.
if (changesDetected) {
this.refresh();
}
};
/**
* Updates every observer from observers list and notifies them of queued
* entries.
*
* @private
* @returns {boolean} Returns "true" if any observer has detected changes in
* dimensions of it's elements.
*/
ResizeObserverController.prototype.updateObservers_ = function () {
// Collect observers that have active observations.
var activeObservers = this.observers_.filter(function (observer) {
return observer.gatherActive(), observer.hasActive();
});
// Deliver notifications in a separate cycle in order to avoid any
// collisions between observers, e.g. when multiple instances of
// ResizeObserver are tracking the same element and the callback of one
// of them changes content dimensions of the observed target. Sometimes
// this may result in notifications being blocked for the rest of observers.
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
return activeObservers.length > 0;
};
/**
* Initializes DOM listeners.
*
* @private
* @returns {void}
*/
ResizeObserverController.prototype.connect_ = function () {
// Do nothing if running in a non-browser environment or if listeners
// have been already added.
if (!isBrowser || this.connected_) {
return;
}
// Subscription to the "Transitionend" event is used as a workaround for
// delayed transitions. This way it's possible to capture at least the
// final state of an element.
document.addEventListener('transitionend', this.onTransitionEnd_);
window.addEventListener('resize', this.refresh);
if (mutationObserverSupported) {
this.mutationsObserver_ = new MutationObserver(this.refresh);
this.mutationsObserver_.observe(document, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
}
else {
document.addEventListener('DOMSubtreeModified', this.refresh);
this.mutationEventsAdded_ = true;
}
this.connected_ = true;
};
/**
* Removes DOM listeners.
*
* @private
* @returns {void}
*/
ResizeObserverController.prototype.disconnect_ = function () {
// Do nothing if running in a non-browser environment or if listeners
// have been already removed.
if (!isBrowser || !this.connected_) {
return;
}
document.removeEventListener('transitionend', this.onTransitionEnd_);
window.removeEventListener('resize', this.refresh);
if (this.mutationsObserver_) {
this.mutationsObserver_.disconnect();
}
if (this.mutationEventsAdded_) {
document.removeEventListener('DOMSubtreeModified', this.refresh);
}
this.mutationsObserver_ = null;
this.mutationEventsAdded_ = false;
this.connected_ = false;
};
/**
* "Transitionend" event handler.
*
* @private
* @param {TransitionEvent} event
* @returns {void}
*/
ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
// Detect whether transition may affect dimensions of an element.
var isReflowProperty = transitionKeys.some(function (key) {
return !!~propertyName.indexOf(key);
});
if (isReflowProperty) {
this.refresh();
}
};
/**
* Returns instance of the ResizeObserverController.
*
* @returns {ResizeObserverController}
*/
ResizeObserverController.getInstance = function () {
if (!this.instance_) {
this.instance_ = new ResizeObserverController();
}
return this.instance_;
};
/**
* Holds reference to the controller's instance.
*
* @private {ResizeObserverController}
*/
ResizeObserverController.instance_ = null;
return ResizeObserverController;
}());
/**
* Defines non-writable/enumerable properties of the provided target object.
*
* @param {Object} target - Object for which to define properties.
* @param {Object} props - Properties to be defined.
* @returns {Object} Target object.
*/
var defineConfigurable = (function (target, props) {
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
var key = _a[_i];
Object.defineProperty(target, key, {
value: props[key],
enumerable: false,
writable: false,
configurable: true
});
}
return target;
});
/**
* Returns the global object associated with provided element.
*
* @param {Object} target
* @returns {Object}
*/
var getWindowOf = (function (target) {
// Assume that the element is an instance of Node, which means that it
// has the "ownerDocument" property from which we can retrieve a
// corresponding global object.
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
// Return the local global object if it's not possible extract one from
// provided element.
return ownerGlobal || global$1;
});
// Placeholder of an empty content rectangle.
var emptyRect = createRectInit(0, 0, 0, 0);
/**
* Converts provided string to a number.
*
* @param {number|string} value
* @returns {number}
*/
function toFloat(value) {
return parseFloat(value) || 0;
}
/**
* Extracts borders size from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @param {...string} positions - Borders positions (top, right, ...)
* @returns {number}
*/
function getBordersSize(styles) {
var positions = [];
for (var _i = 1; _i < arguments.length; _i++) {
positions[_i - 1] = arguments[_i];
}
return positions.reduce(function (size, position) {
var value = styles['border-' + position + '-width'];
return size + toFloat(value);
}, 0);
}
/**
* Extracts paddings sizes from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @returns {Object} Paddings box.
*/
function getPaddings(styles) {
var positions = ['top', 'right', 'bottom', 'left'];
var paddings = {};
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
var position = positions_1[_i];
var value = styles['padding-' + position];
paddings[position] = toFloat(value);
}
return paddings;
}
/**
* Calculates content rectangle of provided SVG element.
*
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
* to be calculated.
* @returns {DOMRectInit}
*/
function getSVGContentRect(target) {
var bbox = target.getBBox();
return createRectInit(0, 0, bbox.width, bbox.height);
}
/**
* Calculates content rectangle of provided HTMLElement.
*
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
* @returns {DOMRectInit}
*/
function getHTMLElementContentRect(target) {
// Client width & height properties can't be
// used exclusively as they provide rounded values.
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
// By this condition we can catch all non-replaced inline, hidden and
// detached elements. Though elements with width & height properties less
// than 0.5 will be discarded as well.
//
// Without it we would need to implement separate methods for each of
// those cases and it's not possible to perform a precise and performance
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
// gives wrong results for elements with width & height less than 0.5.
if (!clientWidth && !clientHeight) {
return emptyRect;
}
var styles = getWindowOf(target).getComputedStyle(target);
var paddings = getPaddings(styles);
var horizPad = paddings.left + paddings.right;
var vertPad = paddings.top + paddings.bottom;
// Computed styles of width & height are being used because they are the
// only dimensions available to JS that contain non-rounded values. It could
// be possible to utilize the getBoundingClientRect if only it's data wasn't
// affected by CSS transformations let alone paddings, borders and scroll bars.
var width = toFloat(styles.width), height = toFloat(styles.height);
// Width & height include paddings and borders when the 'border-box' box
// model is applied (except for IE).
if (styles.boxSizing === 'border-box') {
// Following conditions are required to handle Internet Explorer which
// doesn't include paddings and borders to computed CSS dimensions.
//
// We can say that if CSS dimensions + paddings are equal to the "client"
// properties then it's either IE, and thus we don't need to subtract
// anything, or an element merely doesn't have paddings/borders styles.
if (Math.round(width + horizPad) !== clientWidth) {
width -= getBordersSize(styles, 'left', 'right') + horizPad;
}
if (Math.round(height + vertPad) !== clientHeight) {
height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
}
}
// Following steps can't be applied to the document's root element as its
// client[Width/Height] properties represent viewport area of the window.
// Besides, it's as well not necessary as the itself neither has
// rendered scroll bars nor it can be clipped.
if (!isDocumentElement(target)) {
// In some browsers (only in Firefox, actually) CSS width & height
// include scroll bars size which can be removed at this step as scroll
// bars are the only difference between rounded dimensions + paddings
// and "client" properties, though that is not always true in Chrome.
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
// Chrome has a rather weird rounding of "client" properties.
// E.g. for an element with content width of 314.2px it sometimes gives
// the client width of 315px and for the width of 314.7px it may give
// 314px. And it doesn't happen all the time. So just ignore this delta
// as a non-relevant.
if (Math.abs(vertScrollbar) !== 1) {
width -= vertScrollbar;
}
if (Math.abs(horizScrollbar) !== 1) {
height -= horizScrollbar;
}
}
return createRectInit(paddings.left, paddings.top, width, height);
}
/**
* Checks whether provided element is an instance of the SVGGraphicsElement.
*
* @param {Element} target - Element to be checked.
* @returns {boolean}
*/
var isSVGGraphicsElement = (function () {
// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
// interface.
if (typeof SVGGraphicsElement !== 'undefined') {
return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
}
// If it's so, then check that element is at least an instance of the
// SVGElement and that it has the "getBBox" method.
// eslint-disable-next-line no-extra-parens
return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
typeof target.getBBox === 'function'); };
})();
/**
* Checks whether provided element is a document element ().
*
* @param {Element} target - Element to be checked.
* @returns {boolean}
*/
function isDocumentElement(target) {
return target === getWindowOf(target).document.documentElement;
}
/**
* Calculates an appropriate content rectangle for provided html or svg element.
*
* @param {Element} target - Element content rectangle of which needs to be calculated.
* @returns {DOMRectInit}
*/
function getContentRect(target) {
if (!isBrowser) {
return emptyRect;
}
if (isSVGGraphicsElement(target)) {
return getSVGContentRect(target);
}
return getHTMLElementContentRect(target);
}
/**
* Creates rectangle with an interface of the DOMRectReadOnly.
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
*
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
* @returns {DOMRectReadOnly}
*/
function createReadOnlyRect(_a) {
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
var rect = Object.create(Constr.prototype);
// Rectangle's properties are not writable and non-enumerable.
defineConfigurable(rect, {
x: x, y: y, width: width, height: height,
top: y,
right: x + width,
bottom: height + y,
left: x
});
return rect;
}
/**
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
*
* @param {number} x - X coordinate.
* @param {number} y - Y coordinate.
* @param {number} width - Rectangle's width.
* @param {number} height - Rectangle's height.
* @returns {DOMRectInit}
*/
function createRectInit(x, y, width, height) {
return { x: x, y: y, width: width, height: height };
}
/**
* Class that is responsible for computations of the content rectangle of
* provided DOM element and for keeping track of it's changes.
*/
var ResizeObservation = /** @class */ (function () {
/**
* Creates an instance of ResizeObservation.
*
* @param {Element} target - Element to be observed.
*/
function ResizeObservation(target) {
/**
* Broadcasted width of content rectangle.
*
* @type {number}
*/
this.broadcastWidth = 0;
/**
* Broadcasted height of content rectangle.
*
* @type {number}
*/
this.broadcastHeight = 0;
/**
* Reference to the last observed content rectangle.
*
* @private {DOMRectInit}
*/
this.contentRect_ = createRectInit(0, 0, 0, 0);
this.target = target;
}
/**
* Updates content rectangle and tells whether it's width or height properties
* have changed since the last broadcast.
*
* @returns {boolean}
*/
ResizeObservation.prototype.isActive = function () {
var rect = getContentRect(this.target);
this.contentRect_ = rect;
return (rect.width !== this.broadcastWidth ||
rect.height !== this.broadcastHeight);
};
/**
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
* from the corresponding properties of the last observed content rectangle.
*
* @returns {DOMRectInit} Last observed content rectangle.
*/
ResizeObservation.prototype.broadcastRect = function () {
var rect = this.contentRect_;
this.broadcastWidth = rect.width;
this.broadcastHeight = rect.height;
return rect;
};
return ResizeObservation;
}());
var ResizeObserverEntry = /** @class */ (function () {
/**
* Creates an instance of ResizeObserverEntry.
*
* @param {Element} target - Element that is being observed.
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
*/
function ResizeObserverEntry(target, rectInit) {
var contentRect = createReadOnlyRect(rectInit);
// According to the specification following properties are not writable
// and are also not enumerable in the native implementation.
//
// Property accessors are not being used as they'd require to define a
// private WeakMap storage which may cause memory leaks in browsers that
// don't support this type of collections.
defineConfigurable(this, { target: target, contentRect: contentRect });
}
return ResizeObserverEntry;
}());
var ResizeObserverSPI = /** @class */ (function () {
/**
* Creates a new instance of ResizeObserver.
*
* @param {ResizeObserverCallback} callback - Callback function that is invoked
* when one of the observed elements changes it's content dimensions.
* @param {ResizeObserverController} controller - Controller instance which
* is responsible for the updates of observer.
* @param {ResizeObserver} callbackCtx - Reference to the public
* ResizeObserver instance which will be passed to callback function.
*/
function ResizeObserverSPI(callback, controller, callbackCtx) {
/**
* Collection of resize observations that have detected changes in dimensions
* of elements.
*
* @private {Array}
*/
this.activeObservations_ = [];
/**
* Registry of the ResizeObservation instances.
*
* @private {Map}
*/
this.observations_ = new MapShim();
if (typeof callback !== 'function') {
throw new TypeError('The callback provided as parameter 1 is not a function.');
}
this.callback_ = callback;
this.controller_ = controller;
this.callbackCtx_ = callbackCtx;
}
/**
* Starts observing provided element.
*
* @param {Element} target - Element to be observed.
* @returns {void}
*/
ResizeObserverSPI.prototype.observe = function (target) {
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
// Do nothing if current environment doesn't have the Element interface.
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
// Do nothing if element is already being observed.
if (observations.has(target)) {
return;
}
observations.set(target, new ResizeObservation(target));
this.controller_.addObserver(this);
// Force the update of observations.
this.controller_.refresh();
};
/**
* Stops observing provided element.
*
* @param {Element} target - Element to stop observing.
* @returns {void}
*/
ResizeObserverSPI.prototype.unobserve = function (target) {
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
// Do nothing if current environment doesn't have the Element interface.
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
// Do nothing if element is not being observed.
if (!observations.has(target)) {
return;
}
observations.delete(target);
if (!observations.size) {
this.controller_.removeObserver(this);
}
};
/**
* Stops observing all elements.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.disconnect = function () {
this.clearActive();
this.observations_.clear();
this.controller_.removeObserver(this);
};
/**
* Collects observation instances the associated element of which has changed
* it's content rectangle.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.gatherActive = function () {
var _this = this;
this.clearActive();
this.observations_.forEach(function (observation) {
if (observation.isActive()) {
_this.activeObservations_.push(observation);
}
});
};
/**
* Invokes initial callback function with a list of ResizeObserverEntry
* instances collected from active resize observations.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.broadcastActive = function () {
// Do nothing if observer doesn't have active observations.
if (!this.hasActive()) {
return;
}
var ctx = this.callbackCtx_;
// Create ResizeObserverEntry instance for every active observation.
var entries = this.activeObservations_.map(function (observation) {
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
});
this.callback_.call(ctx, entries, ctx);
this.clearActive();
};
/**
* Clears the collection of active observations.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.clearActive = function () {
this.activeObservations_.splice(0);
};
/**
* Tells whether observer has active observations.
*
* @returns {boolean}
*/
ResizeObserverSPI.prototype.hasActive = function () {
return this.activeObservations_.length > 0;
};
return ResizeObserverSPI;
}());
// Registry of internal observers. If WeakMap is not available use current shim
// for the Map collection as it has all required methods and because WeakMap
// can't be fully polyfilled anyway.
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
/**
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
* exposing only those methods and properties that are defined in the spec.
*/
var ResizeObserver = /** @class */ (function () {
/**
* Creates a new instance of ResizeObserver.
*
* @param {ResizeObserverCallback} callback - Callback that is invoked when
* dimensions of the observed elements change.
*/
function ResizeObserver(callback) {
if (!(this instanceof ResizeObserver)) {
throw new TypeError('Cannot call a class as a function.');
}
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
var controller = ResizeObserverController.getInstance();
var observer = new ResizeObserverSPI(callback, controller, this);
observers.set(this, observer);
}
return ResizeObserver;
}());
// Expose public methods of ResizeObserver.
[
'observe',
'unobserve',
'disconnect'
].forEach(function (method) {
ResizeObserver.prototype[method] = function () {
var _a;
return (_a = observers.get(this))[method].apply(_a, arguments);
};
});
var index = (function () {
// Export existing implementation if available.
if (typeof global$1.ResizeObserver !== 'undefined') {
return global$1.ResizeObserver;
}
return ResizeObserver;
})();
/* harmony default export */ __webpack_exports__["default"] = (index);
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(25)))
/***/ }),
/* 120 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = contains;
function contains(root, n) {
var node = n;
while (node) {
if (node === root) {
return true;
}
node = node.parentNode;
}
return false;
}
/***/ }),
/* 121 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_prop_types__);
var ContainerRender = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default()(ContainerRender, _React$Component);
function ContainerRender() {
var _ref;
var _temp, _this, _ret;
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, ContainerRender);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(this, (_ref = ContainerRender.__proto__ || Object.getPrototypeOf(ContainerRender)).call.apply(_ref, [this].concat(args))), _this), _this.removeContainer = function () {
if (_this.container) {
__WEBPACK_IMPORTED_MODULE_5_react_dom___default.a.unmountComponentAtNode(_this.container);
_this.container.parentNode.removeChild(_this.container);
_this.container = null;
}
}, _this.renderComponent = function (props, ready) {
var _this$props = _this.props,
visible = _this$props.visible,
getComponent = _this$props.getComponent,
forceRender = _this$props.forceRender,
getContainer = _this$props.getContainer,
parent = _this$props.parent;
if (visible || parent._component || forceRender) {
if (!_this.container) {
_this.container = getContainer();
}
__WEBPACK_IMPORTED_MODULE_5_react_dom___default.a.unstable_renderSubtreeIntoContainer(parent, getComponent(props), _this.container, function callback() {
if (ready) {
ready.call(this);
}
});
}
}, _temp), __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(_this, _ret);
}
__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(ContainerRender, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (this.props.autoMount) {
this.renderComponent();
}
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate() {
if (this.props.autoMount) {
this.renderComponent();
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
if (this.props.autoDestroy) {
this.removeContainer();
}
}
}, {
key: 'render',
value: function render() {
return this.props.children({
renderComponent: this.renderComponent,
removeContainer: this.removeContainer
});
}
}]);
return ContainerRender;
}(__WEBPACK_IMPORTED_MODULE_4_react___default.a.Component);
ContainerRender.propTypes = {
autoMount: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,
autoDestroy: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,
visible: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,
forceRender: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,
parent: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.any,
getComponent: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func.isRequired,
getContainer: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func.isRequired,
children: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func.isRequired
};
ContainerRender.defaultProps = {
autoMount: true,
autoDestroy: true,
forceRender: false
};
/* harmony default export */ __webpack_exports__["a"] = (ContainerRender);
/***/ }),
/* 122 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Input__ = __webpack_require__(170);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Group__ = __webpack_require__(547);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Search__ = __webpack_require__(548);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__TextArea__ = __webpack_require__(275);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Password__ = __webpack_require__(552);
__WEBPACK_IMPORTED_MODULE_0__Input__["a" /* default */].Group = __WEBPACK_IMPORTED_MODULE_1__Group__["a" /* default */];
__WEBPACK_IMPORTED_MODULE_0__Input__["a" /* default */].Search = __WEBPACK_IMPORTED_MODULE_2__Search__["a" /* default */];
__WEBPACK_IMPORTED_MODULE_0__Input__["a" /* default */].TextArea = __WEBPACK_IMPORTED_MODULE_3__TextArea__["a" /* default */];
__WEBPACK_IMPORTED_MODULE_0__Input__["a" /* default */].Password = __WEBPACK_IMPORTED_MODULE_4__Password__["a" /* default */];
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Input__["a" /* default */]);
/***/ }),
/* 123 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Wave; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_css_animation_es_Event__ = __webpack_require__(260);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_raf__ = __webpack_require__(274);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__config_provider__ = __webpack_require__(6);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var styleForPesudo; // Where el is the DOM element you'd like to test for visibility
function isHidden(element) {
if (process.env.NODE_ENV === 'test') {
return false;
}
return !element || element.offsetParent === null;
}
var Wave =
/*#__PURE__*/
function (_React$Component) {
_inherits(Wave, _React$Component);
function Wave() {
var _this;
_classCallCheck(this, Wave);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Wave).apply(this, arguments));
_this.animationStart = false;
_this.destroy = false;
_this.onClick = function (node, waveColor) {
if (!node || isHidden(node) || node.className.indexOf('-leave') >= 0) {
return;
}
var insertExtraNode = _this.props.insertExtraNode;
_this.extraNode = document.createElement('div');
var extraNode = _this.extraNode;
extraNode.className = 'ant-click-animating-node';
var attributeName = _this.getAttributeName();
node.setAttribute(attributeName, 'true'); // Not white or transparnt or grey
styleForPesudo = styleForPesudo || document.createElement('style');
if (waveColor && waveColor !== '#ffffff' && waveColor !== 'rgb(255, 255, 255)' && _this.isNotGrey(waveColor) && !/rgba\(\d*, \d*, \d*, 0\)/.test(waveColor) && // any transparent rgba color
waveColor !== 'transparent') {
// Add nonce if CSP exist
if (_this.csp && _this.csp.nonce) {
styleForPesudo.nonce = _this.csp.nonce;
}
extraNode.style.borderColor = waveColor;
styleForPesudo.innerHTML = "[ant-click-animating-without-extra-node=\"true\"]:after { border-color: ".concat(waveColor, "; }");
if (!document.body.contains(styleForPesudo)) {
document.body.appendChild(styleForPesudo);
}
}
if (insertExtraNode) {
node.appendChild(extraNode);
}
__WEBPACK_IMPORTED_MODULE_2_css_animation_es_Event__["a" /* default */].addStartEventListener(node, _this.onTransitionStart);
__WEBPACK_IMPORTED_MODULE_2_css_animation_es_Event__["a" /* default */].addEndEventListener(node, _this.onTransitionEnd);
};
_this.bindAnimationEvent = function (node) {
if (!node || !node.getAttribute || node.getAttribute('disabled') || node.className.indexOf('disabled') >= 0) {
return;
}
var onClick = function onClick(e) {
// Fix radio button click twice
if (e.target.tagName === 'INPUT' || isHidden(e.target)) {
return;
}
_this.resetEffect(node); // Get wave color from target
var waveColor = getComputedStyle(node).getPropertyValue('border-top-color') || // Firefox Compatible
getComputedStyle(node).getPropertyValue('border-color') || getComputedStyle(node).getPropertyValue('background-color');
_this.clickWaveTimeoutId = window.setTimeout(function () {
return _this.onClick(node, waveColor);
}, 0);
__WEBPACK_IMPORTED_MODULE_3__util_raf__["a" /* default */].cancel(_this.animationStartId);
_this.animationStart = true; // Render to trigger transition event cost 3 frames. Let's delay 10 frames to reset this.
_this.animationStartId = Object(__WEBPACK_IMPORTED_MODULE_3__util_raf__["a" /* default */])(function () {
_this.animationStart = false;
}, 10);
};
node.addEventListener('click', onClick, true);
return {
cancel: function cancel() {
node.removeEventListener('click', onClick, true);
}
};
};
_this.onTransitionStart = function (e) {
if (_this.destroy) return;
var node = Object(__WEBPACK_IMPORTED_MODULE_1_react_dom__["findDOMNode"])(_assertThisInitialized(_this));
if (!e || e.target !== node) {
return;
}
if (!_this.animationStart) {
_this.resetEffect(node);
}
};
_this.onTransitionEnd = function (e) {
if (!e || e.animationName !== 'fadeEffect') {
return;
}
_this.resetEffect(e.target);
};
_this.renderWave = function (_ref) {
var csp = _ref.csp;
var children = _this.props.children;
_this.csp = csp;
return children;
};
return _this;
}
_createClass(Wave, [{
key: "isNotGrey",
value: function isNotGrey(color) {
var match = (color || '').match(/rgba?\((\d*), (\d*), (\d*)(, [\.\d]*)?\)/);
if (match && match[1] && match[2] && match[3]) {
return !(match[1] === match[2] && match[2] === match[3]);
}
return true;
}
}, {
key: "getAttributeName",
value: function getAttributeName() {
var insertExtraNode = this.props.insertExtraNode;
return insertExtraNode ? 'ant-click-animating' : 'ant-click-animating-without-extra-node';
}
}, {
key: "resetEffect",
value: function resetEffect(node) {
if (!node || node === this.extraNode || !(node instanceof Element)) {
return;
}
var insertExtraNode = this.props.insertExtraNode;
var attributeName = this.getAttributeName();
node.setAttribute(attributeName, 'false'); // edge has bug on `removeAttribute` #14466
this.removeExtraStyleNode();
if (insertExtraNode && this.extraNode && node.contains(this.extraNode)) {
node.removeChild(this.extraNode);
}
__WEBPACK_IMPORTED_MODULE_2_css_animation_es_Event__["a" /* default */].removeStartEventListener(node, this.onTransitionStart);
__WEBPACK_IMPORTED_MODULE_2_css_animation_es_Event__["a" /* default */].removeEndEventListener(node, this.onTransitionEnd);
}
}, {
key: "removeExtraStyleNode",
value: function removeExtraStyleNode() {
if (styleForPesudo) {
styleForPesudo.innerHTML = '';
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
var node = Object(__WEBPACK_IMPORTED_MODULE_1_react_dom__["findDOMNode"])(this);
if (node.nodeType !== 1) {
return;
}
this.instance = this.bindAnimationEvent(node);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.instance) {
this.instance.cancel();
}
if (this.clickWaveTimeoutId) {
clearTimeout(this.clickWaveTimeoutId);
}
this.destroy = true;
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_4__config_provider__["a" /* ConfigConsumer */], null, this.renderWave);
}
}]);
return Wave;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9)))
/***/ }),
/* 124 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return propType; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return defaultProp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return commonMixinWrapper; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__locale_en_US__ = __webpack_require__(246);
function noop() {}
var propType = {
className: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.string,
locale: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.object,
style: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.object,
visible: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.bool,
onSelect: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.func,
prefixCls: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.string,
onChange: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.func,
onOk: __WEBPACK_IMPORTED_MODULE_3_prop_types___default.a.func
};
var defaultProp = {
locale: __WEBPACK_IMPORTED_MODULE_4__locale_en_US__["a" /* default */],
style: {},
visible: true,
prefixCls: 'rc-calendar',
className: '',
onSelect: noop,
onChange: noop,
onClear: noop,
renderFooter: function renderFooter() {
return null;
},
renderSidebar: function renderSidebar() {
return null;
}
};
var commonMixinWrapper = function commonMixinWrapper(ComposeComponent) {
var _class, _temp2;
return _temp2 = _class = function (_ComposeComponent) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(_class, _ComposeComponent);
function _class() {
var _temp, _this, _ret;
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, _class);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _ComposeComponent.call.apply(_ComposeComponent, [this].concat(args))), _this), _this.getFormat = function () {
var format = _this.props.format;
var _this$props = _this.props,
locale = _this$props.locale,
timePicker = _this$props.timePicker;
if (!format) {
if (timePicker) {
format = locale.dateTimeFormat;
} else {
format = locale.dateFormat;
}
}
return format;
}, _this.focus = function () {
if (_this.focusElement) {
_this.focusElement.focus();
} else if (_this.rootInstance) {
_this.rootInstance.focus();
}
}, _this.saveFocusElement = function (focusElement) {
_this.focusElement = focusElement;
}, _this.saveRoot = function (root) {
_this.rootInstance = root;
}, _temp), __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(_this, _ret);
}
_class.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return this.props.visible || nextProps.visible;
};
return _class;
}(ComposeComponent), _class.displayName = 'CommonMixinWrapper', _class.defaultProps = ComposeComponent.defaultProps, _class.getDerivedStateFromProps = ComposeComponent.getDerivedStateFromProps, _temp2;
};
/***/ }),
/* 125 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__radio__ = __webpack_require__(173);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__group__ = __webpack_require__(571);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__radioButton__ = __webpack_require__(572);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_2__radioButton__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_1__group__["a"]; });
__WEBPACK_IMPORTED_MODULE_0__radio__["a" /* default */].Button = __WEBPACK_IMPORTED_MODULE_2__radioButton__["a" /* default */];
__WEBPACK_IMPORTED_MODULE_0__radio__["a" /* default */].Group = __WEBPACK_IMPORTED_MODULE_1__group__["a" /* default */];
/* harmony default export */ __webpack_exports__["c"] = (__WEBPACK_IMPORTED_MODULE_0__radio__["a" /* default */]);
/***/ }),
/* 126 */
/***/ (function(module, exports, __webpack_require__) {
var baseGetTag = __webpack_require__(57),
isObjectLike = __webpack_require__(46);
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
}
module.exports = isSymbol;
/***/ }),
/* 127 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__row__ = __webpack_require__(291);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__col__ = __webpack_require__(295);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_0__row__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_1__col__["a"]; });
/***/ }),
/* 128 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.canUseDOM = exports.slidesOnLeft = exports.slidesOnRight = exports.siblingDirection = exports.getTotalSlides = exports.getPostClones = exports.getPreClones = exports.getTrackLeft = exports.getTrackAnimateCSS = exports.getTrackCSS = exports.checkSpecKeys = exports.getSlideCount = exports.checkNavigable = exports.getNavigableIndexes = exports.swipeEnd = exports.swipeMove = exports.swipeStart = exports.keyHandler = exports.changeSlide = exports.slideHandler = exports.initializedState = exports.extractObject = exports.canGoNext = exports.getSwipeDirection = exports.getHeight = exports.getWidth = exports.lazySlidesOnRight = exports.lazySlidesOnLeft = exports.lazyEndIndex = exports.lazyStartIndex = exports.getRequiredLazySlides = exports.getOnDemandLazySlides = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = __webpack_require__(0);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(8);
var _reactDom2 = _interopRequireDefault(_reactDom);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getOnDemandLazySlides = exports.getOnDemandLazySlides = function getOnDemandLazySlides(spec) {
var onDemandSlides = [];
var startIndex = lazyStartIndex(spec);
var endIndex = lazyEndIndex(spec);
for (var slideIndex = startIndex; slideIndex < endIndex; slideIndex++) {
if (spec.lazyLoadedList.indexOf(slideIndex) < 0) {
onDemandSlides.push(slideIndex);
}
}
return onDemandSlides;
};
// return list of slides that need to be present
var getRequiredLazySlides = exports.getRequiredLazySlides = function getRequiredLazySlides(spec) {
var requiredSlides = [];
var startIndex = lazyStartIndex(spec);
var endIndex = lazyEndIndex(spec);
for (var slideIndex = startIndex; slideIndex < endIndex; slideIndex++) {
requiredSlides.push(slideIndex);
}
return requiredSlides;
};
// startIndex that needs to be present
var lazyStartIndex = exports.lazyStartIndex = function lazyStartIndex(spec) {
return spec.currentSlide - lazySlidesOnLeft(spec);
};
var lazyEndIndex = exports.lazyEndIndex = function lazyEndIndex(spec) {
return spec.currentSlide + lazySlidesOnRight(spec);
};
var lazySlidesOnLeft = exports.lazySlidesOnLeft = function lazySlidesOnLeft(spec) {
return spec.centerMode ? Math.floor(spec.slidesToShow / 2) + (parseInt(spec.centerPadding) > 0 ? 1 : 0) : 0;
};
var lazySlidesOnRight = exports.lazySlidesOnRight = function lazySlidesOnRight(spec) {
return spec.centerMode ? Math.floor((spec.slidesToShow - 1) / 2) + 1 + (parseInt(spec.centerPadding) > 0 ? 1 : 0) : spec.slidesToShow;
};
// get width of an element
var getWidth = exports.getWidth = function getWidth(elem) {
return elem && elem.offsetWidth || 0;
};
var getHeight = exports.getHeight = function getHeight(elem) {
return elem && elem.offsetHeight || 0;
};
var getSwipeDirection = exports.getSwipeDirection = function getSwipeDirection(touchObject) {
var verticalSwiping = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var xDist, yDist, r, swipeAngle;
xDist = touchObject.startX - touchObject.curX;
yDist = touchObject.startY - touchObject.curY;
r = Math.atan2(yDist, xDist);
swipeAngle = Math.round(r * 180 / Math.PI);
if (swipeAngle < 0) {
swipeAngle = 360 - Math.abs(swipeAngle);
}
if (swipeAngle <= 45 && swipeAngle >= 0 || swipeAngle <= 360 && swipeAngle >= 315) {
return "left";
}
if (swipeAngle >= 135 && swipeAngle <= 225) {
return "right";
}
if (verticalSwiping === true) {
if (swipeAngle >= 35 && swipeAngle <= 135) {
return "up";
} else {
return "down";
}
}
return "vertical";
};
// whether or not we can go next
var canGoNext = exports.canGoNext = function canGoNext(spec) {
var canGo = true;
if (!spec.infinite) {
if (spec.centerMode && spec.currentSlide >= spec.slideCount - 1) {
canGo = false;
} else if (spec.slideCount <= spec.slidesToShow || spec.currentSlide >= spec.slideCount - spec.slidesToShow) {
canGo = false;
}
}
return canGo;
};
// given an object and a list of keys, return new object with given keys
var extractObject = exports.extractObject = function extractObject(spec, keys) {
var newObject = {};
keys.forEach(function (key) {
return newObject[key] = spec[key];
});
return newObject;
};
// get initialized state
var initializedState = exports.initializedState = function initializedState(spec) {
// spec also contains listRef, trackRef
var slideCount = _react2.default.Children.count(spec.children);
var listWidth = Math.ceil(getWidth(_reactDom2.default.findDOMNode(spec.listRef)));
var trackWidth = Math.ceil(getWidth(_reactDom2.default.findDOMNode(spec.trackRef)));
var slideWidth = void 0;
if (!spec.vertical) {
var centerPaddingAdj = spec.centerMode && parseInt(spec.centerPadding) * 2;
if (typeof spec.centerPadding === "string" && spec.centerPadding.slice(-1) === "%") {
centerPaddingAdj *= listWidth / 100;
}
slideWidth = Math.ceil((listWidth - centerPaddingAdj) / spec.slidesToShow);
} else {
slideWidth = listWidth;
}
var slideHeight = _reactDom2.default.findDOMNode(spec.listRef) && getHeight(_reactDom2.default.findDOMNode(spec.listRef).querySelector('[data-index="0"]'));
var listHeight = slideHeight * spec.slidesToShow;
var currentSlide = spec.currentSlide === undefined ? spec.initialSlide : spec.currentSlide;
if (spec.rtl && spec.currentSlide === undefined) {
currentSlide = slideCount - 1 - spec.initialSlide;
}
var lazyLoadedList = spec.lazyLoadedList || [];
var slidesToLoad = getOnDemandLazySlides({ currentSlide: currentSlide, lazyLoadedList: lazyLoadedList }, spec);
lazyLoadedList.concat(slidesToLoad);
var state = {
slideCount: slideCount,
slideWidth: slideWidth,
listWidth: listWidth,
trackWidth: trackWidth,
currentSlide: currentSlide,
slideHeight: slideHeight,
listHeight: listHeight,
lazyLoadedList: lazyLoadedList
};
if (spec.autoplaying === null && spec.autoplay) {
state["autoplaying"] = "playing";
}
return state;
};
var slideHandler = exports.slideHandler = function slideHandler(spec) {
var waitForAnimate = spec.waitForAnimate,
animating = spec.animating,
fade = spec.fade,
infinite = spec.infinite,
index = spec.index,
slideCount = spec.slideCount,
lazyLoadedList = spec.lazyLoadedList,
lazyLoad = spec.lazyLoad,
currentSlide = spec.currentSlide,
centerMode = spec.centerMode,
slidesToScroll = spec.slidesToScroll,
slidesToShow = spec.slidesToShow,
useCSS = spec.useCSS;
if (waitForAnimate && animating) return {};
var animationSlide = index,
finalSlide = void 0,
animationLeft = void 0,
finalLeft = void 0;
var state = {},
nextState = {};
if (fade) {
if (!infinite && (index < 0 || index >= slideCount)) return {};
if (index < 0) {
animationSlide = index + slideCount;
} else if (index >= slideCount) {
animationSlide = index - slideCount;
}
if (lazyLoad && lazyLoadedList.indexOf(animationSlide) < 0) {
lazyLoadedList.push(animationSlide);
}
state = {
animating: true,
currentSlide: animationSlide,
lazyLoadedList: lazyLoadedList
};
nextState = { animating: false };
} else {
finalSlide = animationSlide;
if (animationSlide < 0) {
finalSlide = animationSlide + slideCount;
if (!infinite) finalSlide = 0;else if (slideCount % slidesToScroll !== 0) finalSlide = slideCount - slideCount % slidesToScroll;
} else if (!canGoNext(spec) && animationSlide > currentSlide) {
animationSlide = finalSlide = currentSlide;
} else if (centerMode && animationSlide >= slideCount) {
animationSlide = infinite ? slideCount : slideCount - 1;
finalSlide = infinite ? 0 : slideCount - 1;
} else if (animationSlide >= slideCount) {
finalSlide = animationSlide - slideCount;
if (!infinite) finalSlide = slideCount - slidesToShow;else if (slideCount % slidesToScroll !== 0) finalSlide = 0;
}
animationLeft = getTrackLeft(_extends({}, spec, { slideIndex: animationSlide }));
finalLeft = getTrackLeft(_extends({}, spec, { slideIndex: finalSlide }));
if (!infinite) {
if (animationLeft === finalLeft) animationSlide = finalSlide;
animationLeft = finalLeft;
}
lazyLoad && lazyLoadedList.concat(getOnDemandLazySlides(_extends({}, spec, { currentSlide: animationSlide })));
if (!useCSS) {
state = {
currentSlide: finalSlide,
trackStyle: getTrackCSS(_extends({}, spec, { left: finalLeft })),
lazyLoadedList: lazyLoadedList
};
} else {
state = {
animating: true,
currentSlide: finalSlide,
trackStyle: getTrackAnimateCSS(_extends({}, spec, { left: animationLeft })),
lazyLoadedList: lazyLoadedList
};
nextState = {
animating: false,
currentSlide: finalSlide,
trackStyle: getTrackCSS(_extends({}, spec, { left: finalLeft })),
swipeLeft: null
};
}
}
return { state: state, nextState: nextState };
};
var changeSlide = exports.changeSlide = function changeSlide(spec, options) {
var indexOffset, previousInt, slideOffset, unevenOffset, targetSlide;
var slidesToScroll = spec.slidesToScroll,
slidesToShow = spec.slidesToShow,
slideCount = spec.slideCount,
currentSlide = spec.currentSlide,
lazyLoad = spec.lazyLoad,
infinite = spec.infinite;
unevenOffset = slideCount % slidesToScroll !== 0;
indexOffset = unevenOffset ? 0 : (slideCount - currentSlide) % slidesToScroll;
if (options.message === "previous") {
slideOffset = indexOffset === 0 ? slidesToScroll : slidesToShow - indexOffset;
targetSlide = currentSlide - slideOffset;
if (lazyLoad && !infinite) {
previousInt = currentSlide - slideOffset;
targetSlide = previousInt === -1 ? slideCount - 1 : previousInt;
}
} else if (options.message === "next") {
slideOffset = indexOffset === 0 ? slidesToScroll : indexOffset;
targetSlide = currentSlide + slideOffset;
if (lazyLoad && !infinite) {
targetSlide = (currentSlide + slidesToScroll) % slideCount + indexOffset;
}
} else if (options.message === "dots") {
// Click on dots
targetSlide = options.index * options.slidesToScroll;
if (targetSlide === options.currentSlide) {
return null;
}
} else if (options.message === "children") {
// Click on the slides
targetSlide = options.index;
if (targetSlide === options.currentSlide) {
return null;
}
if (infinite) {
var direction = siblingDirection(_extends({}, spec, { targetSlide: targetSlide }));
if (targetSlide > options.currentSlide && direction === "left") {
targetSlide = targetSlide - slideCount;
} else if (targetSlide < options.currentSlide && direction === "right") {
targetSlide = targetSlide + slideCount;
}
}
} else if (options.message === "index") {
targetSlide = Number(options.index);
if (targetSlide === options.currentSlide) {
return null;
}
}
return targetSlide;
};
var keyHandler = exports.keyHandler = function keyHandler(e, accessibility, rtl) {
if (e.target.tagName.match("TEXTAREA|INPUT|SELECT") || !accessibility) return "";
if (e.keyCode === 37) return rtl ? "next" : "previous";
if (e.keyCode === 39) return rtl ? "previous" : "next";
return "";
};
var swipeStart = exports.swipeStart = function swipeStart(e, swipe, draggable) {
e.target.tagName === "IMG" && e.preventDefault();
if (!swipe || !draggable && e.type.indexOf("mouse") !== -1) return "";
return {
dragging: true,
touchObject: {
startX: e.touches ? e.touches[0].pageX : e.clientX,
startY: e.touches ? e.touches[0].pageY : e.clientY,
curX: e.touches ? e.touches[0].pageX : e.clientX,
curY: e.touches ? e.touches[0].pageY : e.clientY
}
};
};
var swipeMove = exports.swipeMove = function swipeMove(e, spec) {
// spec also contains, trackRef and slideIndex
var scrolling = spec.scrolling,
animating = spec.animating,
vertical = spec.vertical,
swipeToSlide = spec.swipeToSlide,
verticalSwiping = spec.verticalSwiping,
rtl = spec.rtl,
currentSlide = spec.currentSlide,
edgeFriction = spec.edgeFriction,
edgeDragged = spec.edgeDragged,
onEdge = spec.onEdge,
swiped = spec.swiped,
swiping = spec.swiping,
slideCount = spec.slideCount,
slidesToScroll = spec.slidesToScroll,
infinite = spec.infinite,
touchObject = spec.touchObject,
swipeEvent = spec.swipeEvent,
listHeight = spec.listHeight,
listWidth = spec.listWidth;
if (scrolling) return;
if (animating) return e.preventDefault();
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault();
var swipeLeft = void 0,
state = {};
var curLeft = getTrackLeft(spec);
touchObject.curX = e.touches ? e.touches[0].pageX : e.clientX;
touchObject.curY = e.touches ? e.touches[0].pageY : e.clientY;
touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(touchObject.curX - touchObject.startX, 2)));
var verticalSwipeLength = Math.round(Math.sqrt(Math.pow(touchObject.curY - touchObject.startY, 2)));
if (!verticalSwiping && !swiping && verticalSwipeLength > 10) {
return { scrolling: true };
}
if (verticalSwiping) touchObject.swipeLength = verticalSwipeLength;
var positionOffset = (!rtl ? 1 : -1) * (touchObject.curX > touchObject.startX ? 1 : -1);
if (verticalSwiping) positionOffset = touchObject.curY > touchObject.startY ? 1 : -1;
var dotCount = Math.ceil(slideCount / slidesToScroll);
var swipeDirection = getSwipeDirection(spec.touchObject, verticalSwiping);
var touchSwipeLength = touchObject.swipeLength;
if (!infinite) {
if (currentSlide === 0 && swipeDirection === "right" || currentSlide + 1 >= dotCount && swipeDirection === "left" || !canGoNext(spec) && swipeDirection === "left") {
touchSwipeLength = touchObject.swipeLength * edgeFriction;
if (edgeDragged === false && onEdge) {
onEdge(swipeDirection);
state["edgeDragged"] = true;
}
}
}
if (!swiped && swipeEvent) {
swipeEvent(swipeDirection);
state["swiped"] = true;
}
if (!vertical) {
if (!rtl) {
swipeLeft = curLeft + touchSwipeLength * positionOffset;
} else {
swipeLeft = curLeft - touchSwipeLength * positionOffset;
}
} else {
swipeLeft = curLeft + touchSwipeLength * (listHeight / listWidth) * positionOffset;
}
if (verticalSwiping) {
swipeLeft = curLeft + touchSwipeLength * positionOffset;
}
state = _extends({}, state, {
touchObject: touchObject,
swipeLeft: swipeLeft,
trackStyle: getTrackCSS(_extends({}, spec, { left: swipeLeft }))
});
if (Math.abs(touchObject.curX - touchObject.startX) < Math.abs(touchObject.curY - touchObject.startY) * 0.8) {
return state;
}
if (touchObject.swipeLength > 10) {
state["swiping"] = true;
e.preventDefault();
}
return state;
};
var swipeEnd = exports.swipeEnd = function swipeEnd(e, spec) {
var dragging = spec.dragging,
swipe = spec.swipe,
touchObject = spec.touchObject,
listWidth = spec.listWidth,
touchThreshold = spec.touchThreshold,
verticalSwiping = spec.verticalSwiping,
listHeight = spec.listHeight,
currentSlide = spec.currentSlide,
swipeToSlide = spec.swipeToSlide,
scrolling = spec.scrolling,
onSwipe = spec.onSwipe;
if (!dragging) {
if (swipe) e.preventDefault();
return {};
}
var minSwipe = verticalSwiping ? listHeight / touchThreshold : listWidth / touchThreshold;
var swipeDirection = getSwipeDirection(touchObject, verticalSwiping);
// reset the state of touch related state variables.
var state = {
dragging: false,
edgeDragged: false,
scrolling: false,
swiping: false,
swiped: false,
swipeLeft: null,
touchObject: {}
};
if (scrolling) {
return state;
}
if (!touchObject.swipeLength) {
return state;
}
if (touchObject.swipeLength > minSwipe) {
e.preventDefault();
if (onSwipe) {
onSwipe(swipeDirection);
}
var slideCount = void 0,
newSlide = void 0;
switch (swipeDirection) {
case "left":
case "up":
newSlide = currentSlide + getSlideCount(spec);
slideCount = swipeToSlide ? checkNavigable(spec, newSlide) : newSlide;
state["currentDirection"] = 0;
break;
case "right":
case "down":
newSlide = currentSlide - getSlideCount(spec);
slideCount = swipeToSlide ? checkNavigable(spec, newSlide) : newSlide;
state["currentDirection"] = 1;
break;
default:
slideCount = currentSlide;
}
state["triggerSlideHandler"] = slideCount;
} else {
// Adjust the track back to it's original position.
var currentLeft = getTrackLeft(spec);
state["trackStyle"] = getTrackAnimateCSS(_extends({}, spec, { left: currentLeft }));
}
return state;
};
var getNavigableIndexes = exports.getNavigableIndexes = function getNavigableIndexes(spec) {
var max = spec.infinite ? spec.slideCount * 2 : spec.slideCount;
var breakpoint = spec.infinite ? spec.slidesToShow * -1 : 0;
var counter = spec.infinite ? spec.slidesToShow * -1 : 0;
var indexes = [];
while (breakpoint < max) {
indexes.push(breakpoint);
breakpoint = counter + spec.slidesToScroll;
counter += Math.min(spec.slidesToScroll, spec.slidesToShow);
}
return indexes;
};
var checkNavigable = exports.checkNavigable = function checkNavigable(spec, index) {
var navigables = getNavigableIndexes(spec);
var prevNavigable = 0;
if (index > navigables[navigables.length - 1]) {
index = navigables[navigables.length - 1];
} else {
for (var n in navigables) {
if (index < navigables[n]) {
index = prevNavigable;
break;
}
prevNavigable = navigables[n];
}
}
return index;
};
var getSlideCount = exports.getSlideCount = function getSlideCount(spec) {
var centerOffset = spec.centerMode ? spec.slideWidth * Math.floor(spec.slidesToShow / 2) : 0;
if (spec.swipeToSlide) {
var swipedSlide = void 0;
var slickList = _reactDom2.default.findDOMNode(spec.listRef);
var slides = slickList.querySelectorAll(".slick-slide");
Array.from(slides).every(function (slide) {
if (!spec.vertical) {
if (slide.offsetLeft - centerOffset + getWidth(slide) / 2 > spec.swipeLeft * -1) {
swipedSlide = slide;
return false;
}
} else {
if (slide.offsetTop + getHeight(slide) / 2 > spec.swipeLeft * -1) {
swipedSlide = slide;
return false;
}
}
return true;
});
if (!swipedSlide) {
return 0;
}
var currentIndex = spec.rtl === true ? spec.slideCount - spec.currentSlide : spec.currentSlide;
var slidesTraversed = Math.abs(swipedSlide.dataset.index - currentIndex) || 1;
return slidesTraversed;
} else {
return spec.slidesToScroll;
}
};
var checkSpecKeys = exports.checkSpecKeys = function checkSpecKeys(spec, keysArray) {
return keysArray.reduce(function (value, key) {
return value && spec.hasOwnProperty(key);
}, true) ? null : console.error("Keys Missing:", spec);
};
var getTrackCSS = exports.getTrackCSS = function getTrackCSS(spec) {
checkSpecKeys(spec, ["left", "variableWidth", "slideCount", "slidesToShow", "slideWidth"]);
var trackWidth = void 0,
trackHeight = void 0;
var trackChildren = spec.slideCount + 2 * spec.slidesToShow;
if (!spec.vertical) {
trackWidth = getTotalSlides(spec) * spec.slideWidth;
} else {
trackHeight = trackChildren * spec.slideHeight;
}
var style = {
opacity: 1,
transition: "",
WebkitTransition: ""
};
if (spec.useTransform) {
var WebkitTransform = !spec.vertical ? "translate3d(" + spec.left + "px, 0px, 0px)" : "translate3d(0px, " + spec.left + "px, 0px)";
var transform = !spec.vertical ? "translate3d(" + spec.left + "px, 0px, 0px)" : "translate3d(0px, " + spec.left + "px, 0px)";
var msTransform = !spec.vertical ? "translateX(" + spec.left + "px)" : "translateY(" + spec.left + "px)";
style = _extends({}, style, {
WebkitTransform: WebkitTransform,
transform: transform,
msTransform: msTransform
});
} else {
if (spec.vertical) {
style["top"] = spec.left;
} else {
style["left"] = spec.left;
}
}
if (spec.fade) style = { opacity: 1 };
if (trackWidth) style.width = trackWidth;
if (trackHeight) style.height = trackHeight;
// Fallback for IE8
if (window && !window.addEventListener && window.attachEvent) {
if (!spec.vertical) {
style.marginLeft = spec.left + "px";
} else {
style.marginTop = spec.left + "px";
}
}
return style;
};
var getTrackAnimateCSS = exports.getTrackAnimateCSS = function getTrackAnimateCSS(spec) {
checkSpecKeys(spec, ["left", "variableWidth", "slideCount", "slidesToShow", "slideWidth", "speed", "cssEase"]);
var style = getTrackCSS(spec);
// useCSS is true by default so it can be undefined
if (spec.useTransform) {
style.WebkitTransition = "-webkit-transform " + spec.speed + "ms " + spec.cssEase;
style.transition = "transform " + spec.speed + "ms " + spec.cssEase;
} else {
if (spec.vertical) {
style.transition = "top " + spec.speed + "ms " + spec.cssEase;
} else {
style.transition = "left " + spec.speed + "ms " + spec.cssEase;
}
}
return style;
};
var getTrackLeft = exports.getTrackLeft = function getTrackLeft(spec) {
if (spec.unslick) {
return 0;
}
checkSpecKeys(spec, ["slideIndex", "trackRef", "infinite", "centerMode", "slideCount", "slidesToShow", "slidesToScroll", "slideWidth", "listWidth", "variableWidth", "slideHeight"]);
var slideIndex = spec.slideIndex,
trackRef = spec.trackRef,
infinite = spec.infinite,
centerMode = spec.centerMode,
slideCount = spec.slideCount,
slidesToShow = spec.slidesToShow,
slidesToScroll = spec.slidesToScroll,
slideWidth = spec.slideWidth,
listWidth = spec.listWidth,
variableWidth = spec.variableWidth,
slideHeight = spec.slideHeight,
fade = spec.fade,
vertical = spec.vertical;
var slideOffset = 0;
var targetLeft;
var targetSlide;
var verticalOffset = 0;
if (fade || spec.slideCount === 1) {
return 0;
}
var slidesToOffset = 0;
if (infinite) {
slidesToOffset = -getPreClones(spec); // bring active slide to the beginning of visual area
// if next scroll doesn't have enough children, just reach till the end of original slides instead of shifting slidesToScroll children
if (slideCount % slidesToScroll !== 0 && slideIndex + slidesToScroll > slideCount) {
slidesToOffset = -(slideIndex > slideCount ? slidesToShow - (slideIndex - slideCount) : slideCount % slidesToScroll);
}
// shift current slide to center of the frame
if (centerMode) {
slidesToOffset += parseInt(slidesToShow / 2);
}
} else {
if (slideCount % slidesToScroll !== 0 && slideIndex + slidesToScroll > slideCount) {
slidesToOffset = slidesToShow - slideCount % slidesToScroll;
}
if (centerMode) {
slidesToOffset = parseInt(slidesToShow / 2);
}
}
slideOffset = slidesToOffset * slideWidth;
verticalOffset = slidesToOffset * slideHeight;
if (!vertical) {
targetLeft = slideIndex * slideWidth * -1 + slideOffset;
} else {
targetLeft = slideIndex * slideHeight * -1 + verticalOffset;
}
if (variableWidth === true) {
var targetSlideIndex;
var trackElem = _reactDom2.default.findDOMNode(trackRef);
targetSlideIndex = slideIndex + getPreClones(spec);
targetSlide = trackElem && trackElem.childNodes[targetSlideIndex];
targetLeft = targetSlide ? targetSlide.offsetLeft * -1 : 0;
if (centerMode === true) {
targetSlideIndex = infinite ? slideIndex + getPreClones(spec) : slideIndex;
targetSlide = trackElem && trackElem.children[targetSlideIndex];
targetLeft = 0;
for (var slide = 0; slide < targetSlideIndex; slide++) {
targetLeft -= trackElem && trackElem.children[slide] && trackElem.children[slide].offsetWidth;
}
targetLeft -= parseInt(spec.centerPadding);
targetLeft += targetSlide && (listWidth - targetSlide.offsetWidth) / 2;
}
}
return targetLeft;
};
var getPreClones = exports.getPreClones = function getPreClones(spec) {
if (spec.unslick || !spec.infinite) {
return 0;
}
if (spec.variableWidth) {
return spec.slideCount;
}
return spec.slidesToShow + (spec.centerMode ? 1 : 0);
};
var getPostClones = exports.getPostClones = function getPostClones(spec) {
if (spec.unslick || !spec.infinite) {
return 0;
}
return spec.slideCount;
};
var getTotalSlides = exports.getTotalSlides = function getTotalSlides(spec) {
return spec.slideCount === 1 ? 1 : getPreClones(spec) + spec.slideCount + getPostClones(spec);
};
var siblingDirection = exports.siblingDirection = function siblingDirection(spec) {
if (spec.targetSlide > spec.currentSlide) {
if (spec.targetSlide > spec.currentSlide + slidesOnRight(spec)) {
return "left";
}
return "right";
} else {
if (spec.targetSlide < spec.currentSlide - slidesOnLeft(spec)) {
return "right";
}
return "left";
}
};
var slidesOnRight = exports.slidesOnRight = function slidesOnRight(_ref) {
var slidesToShow = _ref.slidesToShow,
centerMode = _ref.centerMode,
rtl = _ref.rtl,
centerPadding = _ref.centerPadding;
// returns no of slides on the right of active slide
if (centerMode) {
var right = (slidesToShow - 1) / 2 + 1;
if (parseInt(centerPadding) > 0) right += 1;
if (rtl && slidesToShow % 2 === 0) right += 1;
return right;
}
if (rtl) {
return 0;
}
return slidesToShow - 1;
};
var slidesOnLeft = exports.slidesOnLeft = function slidesOnLeft(_ref2) {
var slidesToShow = _ref2.slidesToShow,
centerMode = _ref2.centerMode,
rtl = _ref2.rtl,
centerPadding = _ref2.centerPadding;
// returns no of slides on the left of active slide
if (centerMode) {
var left = (slidesToShow - 1) / 2 + 1;
if (parseInt(centerPadding) > 0) left += 1;
if (!rtl && slidesToShow % 2 === 0) left += 1;
return left;
}
if (rtl) {
return slidesToShow - 1;
}
return 0;
};
var canUseDOM = exports.canUseDOM = function canUseDOM() {
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
};
/***/ }),
/* 129 */
/***/ (function(module, exports, __webpack_require__) {
var getNative = __webpack_require__(71);
/* Built-in method references that are verified to be native. */
var nativeCreate = getNative(Object, 'create');
module.exports = nativeCreate;
/***/ }),
/* 130 */
/***/ (function(module, exports, __webpack_require__) {
var listCacheClear = __webpack_require__(662),
listCacheDelete = __webpack_require__(663),
listCacheGet = __webpack_require__(664),
listCacheHas = __webpack_require__(665),
listCacheSet = __webpack_require__(666);
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/* 131 */
/***/ (function(module, exports, __webpack_require__) {
var eq = __webpack_require__(86);
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
module.exports = assocIndexOf;
/***/ }),
/* 132 */
/***/ (function(module, exports, __webpack_require__) {
var isKeyable = __webpack_require__(668);
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
module.exports = getMapData;
/***/ }),
/* 133 */
/***/ (function(module, exports, __webpack_require__) {
var toFinite = __webpack_require__(755);
/**
* Converts `value` to an integer.
*
* **Note:** This method is loosely based on
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {number} Returns the converted integer.
* @example
*
* _.toInteger(3.2);
* // => 3
*
* _.toInteger(Number.MIN_VALUE);
* // => 0
*
* _.toInteger(Infinity);
* // => 1.7976931348623157e+308
*
* _.toInteger('3.2');
* // => 3
*/
function toInteger(value) {
var result = toFinite(value),
remainder = result % 1;
return result === result ? (remainder ? result - remainder : result) : 0;
}
module.exports = toInteger;
/***/ }),
/* 134 */
/***/ (function(module, exports) {
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
module.exports = copyArray;
/***/ }),
/* 135 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(28);
/** Built-in value references. */
var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
module.exports = baseCreate;
/***/ }),
/* 136 */
/***/ (function(module, exports) {
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
module.exports = apply;
/***/ }),
/* 137 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["p"] = warnOnlyTreeNode;
/* harmony export (immutable) */ __webpack_exports__["b"] = arrDel;
/* harmony export (immutable) */ __webpack_exports__["a"] = arrAdd;
/* harmony export (immutable) */ __webpack_exports__["o"] = posToArr;
/* harmony export (immutable) */ __webpack_exports__["l"] = getPosition;
/* unused harmony export isTreeNode */
/* harmony export (immutable) */ __webpack_exports__["k"] = getNodeChildren;
/* unused harmony export isCheckDisabled */
/* unused harmony export traverseTreeNodes */
/* harmony export (immutable) */ __webpack_exports__["m"] = mapChildren;
/* harmony export (immutable) */ __webpack_exports__["j"] = getDragNodesKeys;
/* harmony export (immutable) */ __webpack_exports__["c"] = calcDropPosition;
/* harmony export (immutable) */ __webpack_exports__["d"] = calcSelectedKeys;
/* harmony export (immutable) */ __webpack_exports__["g"] = convertDataToTree;
/* harmony export (immutable) */ __webpack_exports__["h"] = convertTreeToEntities;
/* harmony export (immutable) */ __webpack_exports__["n"] = parseCheckedKeys;
/* harmony export (immutable) */ __webpack_exports__["e"] = conductCheck;
/* harmony export (immutable) */ __webpack_exports__["f"] = conductExpandParent;
/* harmony export (immutable) */ __webpack_exports__["i"] = getDataAndAria;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_warning__ = __webpack_require__(83);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_warning__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__TreeNode__ = __webpack_require__(365);
var DRAG_SIDE_RANGE = 0.25;
var DRAG_MIN_GAP = 2;
var onlyTreeNodeWarned = false;
function warnOnlyTreeNode() {
if (onlyTreeNodeWarned) return;
onlyTreeNodeWarned = true;
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, 'Tree only accept TreeNode as children.');
}
function arrDel(list, value) {
var clone = list.slice();
var index = clone.indexOf(value);
if (index >= 0) {
clone.splice(index, 1);
}
return clone;
}
function arrAdd(list, value) {
var clone = list.slice();
if (clone.indexOf(value) === -1) {
clone.push(value);
}
return clone;
}
function posToArr(pos) {
return pos.split('-');
}
function getPosition(level, index) {
return level + '-' + index;
}
function isTreeNode(node) {
return node && node.type && node.type.isTreeNode;
}
function getNodeChildren(children) {
return Object(__WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__["a" /* default */])(children).filter(isTreeNode);
}
function isCheckDisabled(node) {
var _ref = node.props || {},
disabled = _ref.disabled,
disableCheckbox = _ref.disableCheckbox;
return !!(disabled || disableCheckbox);
}
function traverseTreeNodes(treeNodes, callback) {
function processNode(node, index, parent) {
var children = node ? node.props.children : treeNodes;
var pos = node ? getPosition(parent.pos, index) : 0;
// Filter children
var childList = getNodeChildren(children);
// Process node if is not root
if (node) {
var data = {
node: node,
index: index,
pos: pos,
key: node.key || pos,
parentPos: parent.node ? parent.pos : null
};
callback(data);
}
// Process children node
__WEBPACK_IMPORTED_MODULE_1_react__["Children"].forEach(childList, function (subNode, subIndex) {
processNode(subNode, subIndex, { node: node, pos: pos });
});
}
processNode(null);
}
/**
* Use `rc-util` `toArray` to get the children list which keeps the key.
* And return single node if children is only one(This can avoid `key` missing check).
*/
function mapChildren(children, func) {
var list = Object(__WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__["a" /* default */])(children).map(func);
if (list.length === 1) {
return list[0];
}
return list;
}
function getDragNodesKeys(treeNodes, node) {
var _node$props = node.props,
eventKey = _node$props.eventKey,
pos = _node$props.pos;
var dragNodesKeys = [];
traverseTreeNodes(treeNodes, function (_ref2) {
var key = _ref2.key;
dragNodesKeys.push(key);
});
dragNodesKeys.push(eventKey || pos);
return dragNodesKeys;
}
// Only used when drag, not affect SSR.
function calcDropPosition(event, treeNode) {
var clientY = event.clientY;
var _treeNode$selectHandl = treeNode.selectHandle.getBoundingClientRect(),
top = _treeNode$selectHandl.top,
bottom = _treeNode$selectHandl.bottom,
height = _treeNode$selectHandl.height;
var des = Math.max(height * DRAG_SIDE_RANGE, DRAG_MIN_GAP);
if (clientY <= top + des) {
return -1;
} else if (clientY >= bottom - des) {
return 1;
}
return 0;
}
/**
* Return selectedKeys according with multiple prop
* @param selectedKeys
* @param props
* @returns [string]
*/
function calcSelectedKeys(selectedKeys, props) {
if (!selectedKeys) return undefined;
var multiple = props.multiple;
if (multiple) {
return selectedKeys.slice();
}
if (selectedKeys.length) {
return [selectedKeys[0]];
}
return selectedKeys;
}
/**
* Since React internal will convert key to string,
* we need do this to avoid `checkStrictly` use number match
*/
function keyListToString(keyList) {
if (!keyList) return keyList;
return keyList.map(function (key) {
return String(key);
});
}
var internalProcessProps = function internalProcessProps(props) {
return props;
};
function convertDataToTree(treeData, processer) {
if (!treeData) return [];
var _ref3 = processer || {},
_ref3$processProps = _ref3.processProps,
processProps = _ref3$processProps === undefined ? internalProcessProps : _ref3$processProps;
var list = Array.isArray(treeData) ? treeData : [treeData];
return list.map(function (_ref4) {
var children = _ref4.children,
props = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties___default()(_ref4, ['children']);
var childrenNodes = convertDataToTree(children, processer);
return __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_4__TreeNode__["a" /* default */],
processProps(props),
childrenNodes
);
});
}
// TODO: ========================= NEW LOGIC =========================
/**
* Calculate treeNodes entities. `processTreeEntity` is used for `rc-tree-select`
* @param treeNodes
* @param processTreeEntity User can customize the entity
*/
function convertTreeToEntities(treeNodes) {
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
initWrapper = _ref5.initWrapper,
processEntity = _ref5.processEntity,
onProcessFinished = _ref5.onProcessFinished;
var posEntities = {};
var keyEntities = {};
var wrapper = {
posEntities: posEntities,
keyEntities: keyEntities
};
if (initWrapper) {
wrapper = initWrapper(wrapper) || wrapper;
}
traverseTreeNodes(treeNodes, function (item) {
var node = item.node,
index = item.index,
pos = item.pos,
key = item.key,
parentPos = item.parentPos;
var entity = { node: node, index: index, key: key, pos: pos };
posEntities[pos] = entity;
keyEntities[key] = entity;
// Fill children
entity.parent = posEntities[parentPos];
if (entity.parent) {
entity.parent.children = entity.parent.children || [];
entity.parent.children.push(entity);
}
if (processEntity) {
processEntity(entity, wrapper);
}
});
if (onProcessFinished) {
onProcessFinished(wrapper);
}
return wrapper;
}
/**
* Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
*/
function parseCheckedKeys(keys) {
if (!keys) {
return null;
}
// Convert keys to object format
var keyProps = void 0;
if (Array.isArray(keys)) {
// [Legacy] Follow the api doc
keyProps = {
checkedKeys: keys,
halfCheckedKeys: undefined
};
} else if (typeof keys === 'object') {
keyProps = {
checkedKeys: keys.checked || undefined,
halfCheckedKeys: keys.halfChecked || undefined
};
} else {
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, '`checkedKeys` is not an array or an object');
return null;
}
keyProps.checkedKeys = keyListToString(keyProps.checkedKeys);
keyProps.halfCheckedKeys = keyListToString(keyProps.halfCheckedKeys);
return keyProps;
}
/**
* Conduct check state by the keyList. It will conduct up & from the provided key.
* If the conduct path reach the disabled or already checked / unchecked node will stop conduct.
* @param keyList list of keys
* @param isCheck is check the node or not
* @param keyEntities parsed by `convertTreeToEntities` function in Tree
* @param checkStatus Can pass current checked status for process (usually for uncheck operation)
* @returns {{checkedKeys: [], halfCheckedKeys: []}}
*/
function conductCheck(keyList, isCheck, keyEntities) {
var checkStatus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var checkedKeys = {};
var halfCheckedKeys = {}; // Record the key has some child checked (include child half checked)
(checkStatus.checkedKeys || []).forEach(function (key) {
checkedKeys[key] = true;
});
(checkStatus.halfCheckedKeys || []).forEach(function (key) {
halfCheckedKeys[key] = true;
});
// Conduct up
function conductUp(key) {
if (checkedKeys[key] === isCheck) return;
var entity = keyEntities[key];
if (!entity) return;
var children = entity.children,
parent = entity.parent,
node = entity.node;
if (isCheckDisabled(node)) return;
// Check child node checked status
var everyChildChecked = true;
var someChildChecked = false; // Child checked or half checked
(children || []).filter(function (child) {
return !isCheckDisabled(child.node);
}).forEach(function (_ref6) {
var childKey = _ref6.key;
var childChecked = checkedKeys[childKey];
var childHalfChecked = halfCheckedKeys[childKey];
if (childChecked || childHalfChecked) someChildChecked = true;
if (!childChecked) everyChildChecked = false;
});
// Update checked status
if (isCheck) {
checkedKeys[key] = everyChildChecked;
} else {
checkedKeys[key] = false;
}
halfCheckedKeys[key] = someChildChecked;
if (parent) {
conductUp(parent.key);
}
}
// Conduct down
function conductDown(key) {
if (checkedKeys[key] === isCheck) return;
var entity = keyEntities[key];
if (!entity) return;
var children = entity.children,
node = entity.node;
if (isCheckDisabled(node)) return;
checkedKeys[key] = isCheck;
(children || []).forEach(function (child) {
conductDown(child.key);
});
}
function conduct(key) {
var entity = keyEntities[key];
if (!entity) {
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, '\'' + key + '\' does not exist in the tree.');
return;
}
var children = entity.children,
parent = entity.parent,
node = entity.node;
checkedKeys[key] = isCheck;
if (isCheckDisabled(node)) return;
// Conduct down
(children || []).filter(function (child) {
return !isCheckDisabled(child.node);
}).forEach(function (child) {
conductDown(child.key);
});
// Conduct up
if (parent) {
conductUp(parent.key);
}
}
(keyList || []).forEach(function (key) {
conduct(key);
});
var checkedKeyList = [];
var halfCheckedKeyList = [];
// Fill checked list
Object.keys(checkedKeys).forEach(function (key) {
if (checkedKeys[key]) {
checkedKeyList.push(key);
}
});
// Fill half checked list
Object.keys(halfCheckedKeys).forEach(function (key) {
if (!checkedKeys[key] && halfCheckedKeys[key]) {
halfCheckedKeyList.push(key);
}
});
return {
checkedKeys: checkedKeyList,
halfCheckedKeys: halfCheckedKeyList
};
}
/**
* If user use `autoExpandParent` we should get the list of parent node
* @param keyList
* @param keyEntities
*/
function conductExpandParent(keyList, keyEntities) {
var expandedKeys = {};
function conductUp(key) {
if (expandedKeys[key]) return;
var entity = keyEntities[key];
if (!entity) return;
expandedKeys[key] = true;
var parent = entity.parent,
node = entity.node;
if (isCheckDisabled(node)) return;
if (parent) {
conductUp(parent.key);
}
}
(keyList || []).forEach(function (key) {
conductUp(key);
});
return Object.keys(expandedKeys);
}
/**
* Returns only the data- and aria- key/value pairs
* @param {object} props
*/
function getDataAndAria(props) {
return Object.keys(props).reduce(function (prev, key) {
if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
prev[key] = props[key];
}
return prev;
}, {});
}
/***/ }),
/* 138 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Animate__ = __webpack_require__(864);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__AnimateChild__ = __webpack_require__(366);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CSSMotion__ = __webpack_require__(867);
/* unused harmony reexport AnimateChild */
/* unused harmony reexport CSSMotion */
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Animate__["a" /* default */]);
/***/ }),
/* 139 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getContentStateFragment
* @format
*
*/
var randomizeBlockMapKeys = __webpack_require__(375);
var removeEntitiesAtEdges = __webpack_require__(376);
var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
var startKey = selectionState.getStartKey();
var startOffset = selectionState.getStartOffset();
var endKey = selectionState.getEndKey();
var endOffset = selectionState.getEndOffset();
// Edge entities should be stripped to ensure that we don't preserve
// invalid partial entities when the fragment is reused. We do, however,
// preserve entities that are entirely within the selection range.
var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
var blockMap = contentWithoutEdgeEntities.getBlockMap();
var blockKeys = blockMap.keySeq();
var startIndex = blockKeys.indexOf(startKey);
var endIndex = blockKeys.indexOf(endKey) + 1;
return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
var text = block.getText();
var chars = block.getCharacterList();
if (startKey === endKey) {
return block.merge({
text: text.slice(startOffset, endOffset),
characterList: chars.slice(startOffset, endOffset)
});
}
if (blockKey === startKey) {
return block.merge({
text: text.slice(startOffset),
characterList: chars.slice(startOffset)
});
}
if (blockKey === endKey) {
return block.merge({
text: text.slice(0, endOffset),
characterList: chars.slice(0, endOffset)
});
}
return block;
}));
};
module.exports = getContentStateFragment;
/***/ }),
/* 140 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
var _assign = __webpack_require__(27);
var _extends = _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; };
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftEntity
* @format
*
*/
var DraftEntityInstance = __webpack_require__(380);
var Immutable = __webpack_require__(14);
var invariant = __webpack_require__(13);
var Map = Immutable.Map;
var instances = Map();
var instanceKey = 0;
/**
* Temporary utility for generating the warnings
*/
function logWarning(oldMethodCall, newMethodCall) {
console.warn('WARNING: ' + oldMethodCall + ' will be deprecated soon!\nPlease use "' + newMethodCall + '" instead.');
}
/**
* A "document entity" is an object containing metadata associated with a
* piece of text in a ContentBlock.
*
* For example, a `link` entity might include a `uri` property. When a
* ContentBlock is rendered in the browser, text that refers to that link
* entity may be rendered as an anchor, with the `uri` as the href value.
*
* In a ContentBlock, every position in the text may correspond to zero
* or one entities. This correspondence is tracked using a key string,
* generated via DraftEntity.create() and used to obtain entity metadata
* via DraftEntity.get().
*/
var DraftEntity = {
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.getLastCreatedEntityKey' instead.
* ---
* Get the random key string from whatever entity was last created.
* We need this to support the new API, as part of transitioning to put Entity
* storage in contentState.
*/
getLastCreatedEntityKey: function getLastCreatedEntityKey() {
logWarning('DraftEntity.getLastCreatedEntityKey', 'contentState.getLastCreatedEntityKey');
return DraftEntity.__getLastCreatedEntityKey();
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.createEntity' instead.
* ---
* Create a DraftEntityInstance and store it for later retrieval.
*
* A random key string will be generated and returned. This key may
* be used to track the entity's usage in a ContentBlock, and for
* retrieving data about the entity at render time.
*/
create: function create(type, mutability, data) {
logWarning('DraftEntity.create', 'contentState.createEntity');
return DraftEntity.__create(type, mutability, data);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.addEntity' instead.
* ---
* Add an existing DraftEntityInstance to the DraftEntity map. This is
* useful when restoring instances from the server.
*/
add: function add(instance) {
logWarning('DraftEntity.add', 'contentState.addEntity');
return DraftEntity.__add(instance);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.getEntity' instead.
* ---
* Retrieve the entity corresponding to the supplied key string.
*/
get: function get(key) {
logWarning('DraftEntity.get', 'contentState.getEntity');
return DraftEntity.__get(key);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.mergeEntityData' instead.
* ---
* Entity instances are immutable. If you need to update the data for an
* instance, this method will merge your data updates and return a new
* instance.
*/
mergeData: function mergeData(key, toMerge) {
logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
return DraftEntity.__mergeData(key, toMerge);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.replaceEntityData' instead.
* ---
* Completely replace the data for a given instance.
*/
replaceData: function replaceData(key, newData) {
logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
return DraftEntity.__replaceData(key, newData);
},
// ***********************************WARNING******************************
// --- the above public API will be deprecated in the next version of Draft!
// The methods below this line are private - don't call them directly.
/**
* Get the random key string from whatever entity was last created.
* We need this to support the new API, as part of transitioning to put Entity
* storage in contentState.
*/
__getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
return '' + instanceKey;
},
/**
* Create a DraftEntityInstance and store it for later retrieval.
*
* A random key string will be generated and returned. This key may
* be used to track the entity's usage in a ContentBlock, and for
* retrieving data about the entity at render time.
*/
__create: function __create(type, mutability, data) {
return DraftEntity.__add(new DraftEntityInstance({ type: type, mutability: mutability, data: data || {} }));
},
/**
* Add an existing DraftEntityInstance to the DraftEntity map. This is
* useful when restoring instances from the server.
*/
__add: function __add(instance) {
var key = '' + ++instanceKey;
instances = instances.set(key, instance);
return key;
},
/**
* Retrieve the entity corresponding to the supplied key string.
*/
__get: function __get(key) {
var instance = instances.get(key);
!!!instance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unknown DraftEntity key: %s.', key) : invariant(false) : void 0;
return instance;
},
/**
* Entity instances are immutable. If you need to update the data for an
* instance, this method will merge your data updates and return a new
* instance.
*/
__mergeData: function __mergeData(key, toMerge) {
var instance = DraftEntity.__get(key);
var newData = _extends({}, instance.getData(), toMerge);
var newInstance = instance.set('data', newData);
instances = instances.set(key, newInstance);
return newInstance;
},
/**
* Completely replace the data for a given instance.
*/
__replaceData: function __replaceData(key, newData) {
var instance = DraftEntity.__get(key);
var newInstance = instance.set('data', newData);
instances = instances.set(key, newInstance);
return newInstance;
}
};
module.exports = DraftEntity;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 141 */
/***/ (function(module, exports) {
/**
* Converts `set` to an array of its values.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the values.
*/
function setToArray(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = value;
});
return result;
}
module.exports = setToArray;
/***/ }),
/* 142 */
/***/ (function(module, exports, __webpack_require__) {
var arrayLikeKeys = __webpack_require__(356),
baseKeys = __webpack_require__(1004),
isArrayLike = __webpack_require__(101);
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
module.exports = keys;
/***/ }),
/* 143 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var debounce = __webpack_require__(84);
var factory_1 = __webpack_require__(420);
var applicators_1 = __webpack_require__(425);
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(debounce, new applicators_1.PreValueApplicator(), { setter: true }));
/**
* Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.
* The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them.
* Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function.
* Subsequent calls to the debounced function return the result of the last func invocation.
*
* Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
*
* If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
*
* @param {number} [wait=0] The number in milliseconds to delay.
* @param {DebounceOptions} [options] The options object.
* @example
*
* class MyClass {
* value = 100;
*
* @Debounce(10)
* add(a) {
* this.value += a;
* }
* }
*
* const myClass = new MyClass();
*
* myClass.add(10);
* myClass.add(50);
* myClass.add(20);
*
* myClass.value; // => 100;
*
* setTimeout(() => {
* myClass.value; // => 120;
* }, 11);
*/
function Debounce(wait, options) {
return decorator(wait, options);
}
exports.Debounce = Debounce;
exports.debounce = Debounce;
exports.default = decorator;
//# sourceMappingURL=debounce.js.map
/***/ }),
/* 144 */
/***/ (function(module, exports, __webpack_require__) {
var baseCreate = __webpack_require__(135),
isObject = __webpack_require__(28);
/**
* Creates a function that produces an instance of `Ctor` regardless of
* whether it was invoked as part of a `new` expression or by `call` or `apply`.
*
* @private
* @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function.
*/
function createCtor(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
case 0: return new Ctor;
case 1: return new Ctor(args[0]);
case 2: return new Ctor(args[0], args[1]);
case 3: return new Ctor(args[0], args[1], args[2]);
case 4: return new Ctor(args[0], args[1], args[2], args[3]);
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
}
var thisBinding = baseCreate(Ctor.prototype),
result = Ctor.apply(thisBinding, args);
// Mimic the constructor's `return` behavior.
// See https://es5.github.io/#x13.2.2 for more details.
return isObject(result) ? result : thisBinding;
};
}
module.exports = createCtor;
/***/ }),
/* 145 */
/***/ (function(module, exports) {
/**
* Gets the argument placeholder value for `func`.
*
* @private
* @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value.
*/
function getHolder(func) {
var object = func;
return object.placeholder;
}
module.exports = getHolder;
/***/ }),
/* 146 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bind = __webpack_require__(1101);
var factory_1 = __webpack_require__(420);
var applicators_1 = __webpack_require__(425);
/**
* Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
*
* The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.
*
* Note: Unlike native Function#bind, this method doesn't set the "length" property of bound functions.
* @param {...*} [partials] The argument to be partially applied.
* @example
*
* class MyClass {
* @Bind()
* bound() {
* return this;
* }
*
* unbound() {
* return this;
* }
* }
*
* const myClass = new MyClass();
*
* myClass.bound.call(null); // => myClass {}
* myClass.unbound.call(null); // => null
*/
exports.Bind = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(bind, new applicators_1.BindApplicator(), {
optionalParams: true
}));
exports.bind = exports.Bind;
exports.default = exports.Bind;
//# sourceMappingURL=bind.js.map
/***/ }),
/* 147 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
module.exports = {"login":"antd-pro-login-login","getCaptcha":"antd-pro-login-getCaptcha","icon":"antd-pro-login-icon","other":"antd-pro-login-other","register":"antd-pro-login-register","prefixIcon":"antd-pro-login-prefixIcon","submit":"antd-pro-login-submit"};
/***/ }),
/* 148 */
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(456);
module.exports = function (fn, that, length) {
aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1: return function (a) {
return fn.call(that, a);
};
case 2: return function (a, b) {
return fn.call(that, a, b);
};
case 3: return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function (/* ...args */) {
return fn.apply(that, arguments);
};
};
/***/ }),
/* 149 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(78);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function (it, S) {
if (!isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ }),
/* 150 */
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = function (it) {
return toString.call(it).slice(8, -1);
};
/***/ }),
/* 151 */
/***/ (function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
/***/ }),
/* 152 */
/***/ (function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
module.exports = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ }),
/* 153 */
/***/ (function(module, exports, __webpack_require__) {
var shared = __webpack_require__(154)('keys');
var uid = __webpack_require__(113);
module.exports = function (key) {
return shared[key] || (shared[key] = uid(key));
};
/***/ }),
/* 154 */
/***/ (function(module, exports, __webpack_require__) {
var core = __webpack_require__(33);
var global = __webpack_require__(54);
var SHARED = '__core-js_shared__';
var store = global[SHARED] || (global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: core.version,
mode: __webpack_require__(112) ? 'pure' : 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
/***/ }),
/* 155 */
/***/ (function(module, exports) {
// IE 8- don't enum bug keys
module.exports = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
/***/ }),
/* 156 */
/***/ (function(module, exports) {
exports.f = Object.getOwnPropertySymbols;
/***/ }),
/* 157 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/* 158 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
var emptyFunction = __webpack_require__(117);
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = emptyFunction;
if (process.env.NODE_ENV !== 'production') {
var printWarning = function printWarning(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
warning = function warning(condition, format) {
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (format.indexOf('Failed Composite propType: ') === 0) {
return; // Ignore CompositeComponent proptype check.
}
if (!condition) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
printWarning.apply(undefined, [format].concat(args));
}
};
}
module.exports = warning;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 159 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_rc_calendar_es_locale_en_US__ = __webpack_require__(246);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__time_picker_locale_en_US__ = __webpack_require__(160);
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); }
// Merge into a locale object
var locale = {
lang: _extends({
placeholder: 'Select date',
rangePlaceholder: ['Start date', 'End date']
}, __WEBPACK_IMPORTED_MODULE_0_rc_calendar_es_locale_en_US__["a" /* default */]),
timePickerLocale: _extends({}, __WEBPACK_IMPORTED_MODULE_1__time_picker_locale_en_US__["a" /* default */])
}; // All settings at:
// https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json
/* harmony default export */ __webpack_exports__["a"] = (locale);
/***/ }),
/* 160 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var locale = {
placeholder: 'Select time'
};
/* harmony default export */ __webpack_exports__["a"] = (locale);
/***/ }),
/* 161 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(77);
var dPs = __webpack_require__(485);
var enumBugKeys = __webpack_require__(155);
var IE_PROTO = __webpack_require__(153)('IE_PROTO');
var Empty = function () { /* empty */ };
var PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(240)('iframe');
var i = enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
__webpack_require__(486).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE] = anObject(O);
result = new Empty();
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ }),
/* 162 */
/***/ (function(module, exports, __webpack_require__) {
var def = __webpack_require__(55).f;
var has = __webpack_require__(64);
var TAG = __webpack_require__(44)('toStringTag');
module.exports = function (it, tag, stat) {
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
};
/***/ }),
/* 163 */
/***/ (function(module, exports, __webpack_require__) {
exports.f = __webpack_require__(44);
/***/ }),
/* 164 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(54);
var core = __webpack_require__(33);
var LIBRARY = __webpack_require__(112);
var wksExt = __webpack_require__(163);
var defineProperty = __webpack_require__(55).f;
module.exports = function (name) {
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
};
/***/ }),
/* 165 */
/***/ (function(module, exports, __webpack_require__) {
var pIE = __webpack_require__(114);
var createDesc = __webpack_require__(92);
var toIObject = __webpack_require__(65);
var toPrimitive = __webpack_require__(149);
var has = __webpack_require__(64);
var IE8_DOM_DEFINE = __webpack_require__(239);
var gOPD = Object.getOwnPropertyDescriptor;
exports.f = __webpack_require__(63) ? gOPD : function getOwnPropertyDescriptor(O, P) {
O = toIObject(O);
P = toPrimitive(P, true);
if (IE8_DOM_DEFINE) try {
return gOPD(O, P);
} catch (e) { /* empty */ }
if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
};
/***/ }),
/* 166 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isCssAnimationSupported; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__ = __webpack_require__(66);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Event__ = __webpack_require__(260);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_component_classes__ = __webpack_require__(118);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_component_classes___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_component_classes__);
var isCssAnimationSupported = __WEBPACK_IMPORTED_MODULE_1__Event__["a" /* default */].endEvents.length !== 0;
var capitalPrefixes = ['Webkit', 'Moz', 'O',
// ms is special .... !
'ms'];
var prefixes = ['-webkit-', '-moz-', '-o-', 'ms-', ''];
function getStyleProperty(node, name) {
// old ff need null, https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
var style = window.getComputedStyle(node, null);
var ret = '';
for (var i = 0; i < prefixes.length; i++) {
ret = style.getPropertyValue(prefixes[i] + name);
if (ret) {
break;
}
}
return ret;
}
function fixBrowserByTimeout(node) {
if (isCssAnimationSupported) {
var transitionDelay = parseFloat(getStyleProperty(node, 'transition-delay')) || 0;
var transitionDuration = parseFloat(getStyleProperty(node, 'transition-duration')) || 0;
var animationDelay = parseFloat(getStyleProperty(node, 'animation-delay')) || 0;
var animationDuration = parseFloat(getStyleProperty(node, 'animation-duration')) || 0;
var time = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);
// sometimes, browser bug
node.rcEndAnimTimeout = setTimeout(function () {
node.rcEndAnimTimeout = null;
if (node.rcEndListener) {
node.rcEndListener();
}
}, time * 1000 + 200);
}
}
function clearBrowserBugTimeout(node) {
if (node.rcEndAnimTimeout) {
clearTimeout(node.rcEndAnimTimeout);
node.rcEndAnimTimeout = null;
}
}
var cssAnimation = function cssAnimation(node, transitionName, endCallback) {
var nameIsObj = (typeof transitionName === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(transitionName)) === 'object';
var className = nameIsObj ? transitionName.name : transitionName;
var activeClassName = nameIsObj ? transitionName.active : transitionName + '-active';
var end = endCallback;
var start = void 0;
var active = void 0;
var nodeClasses = __WEBPACK_IMPORTED_MODULE_2_component_classes___default()(node);
if (endCallback && Object.prototype.toString.call(endCallback) === '[object Object]') {
end = endCallback.end;
start = endCallback.start;
active = endCallback.active;
}
if (node.rcEndListener) {
node.rcEndListener();
}
node.rcEndListener = function (e) {
if (e && e.target !== node) {
return;
}
if (node.rcAnimTimeout) {
clearTimeout(node.rcAnimTimeout);
node.rcAnimTimeout = null;
}
clearBrowserBugTimeout(node);
nodeClasses.remove(className);
nodeClasses.remove(activeClassName);
__WEBPACK_IMPORTED_MODULE_1__Event__["a" /* default */].removeEndEventListener(node, node.rcEndListener);
node.rcEndListener = null;
// Usually this optional end is used for informing an owner of
// a leave animation and telling it to remove the child.
if (end) {
end();
}
};
__WEBPACK_IMPORTED_MODULE_1__Event__["a" /* default */].addEndEventListener(node, node.rcEndListener);
if (start) {
start();
}
nodeClasses.add(className);
node.rcAnimTimeout = setTimeout(function () {
node.rcAnimTimeout = null;
nodeClasses.add(activeClassName);
if (active) {
setTimeout(active, 0);
}
fixBrowserByTimeout(node);
// 30ms for firefox
}, 30);
return {
stop: function stop() {
if (node.rcEndListener) {
node.rcEndListener();
}
}
};
};
cssAnimation.style = function (node, style, callback) {
if (node.rcEndListener) {
node.rcEndListener();
}
node.rcEndListener = function (e) {
if (e && e.target !== node) {
return;
}
if (node.rcAnimTimeout) {
clearTimeout(node.rcAnimTimeout);
node.rcAnimTimeout = null;
}
clearBrowserBugTimeout(node);
__WEBPACK_IMPORTED_MODULE_1__Event__["a" /* default */].removeEndEventListener(node, node.rcEndListener);
node.rcEndListener = null;
// Usually this optional callback is used for informing an owner of
// a leave animation and telling it to remove the child.
if (callback) {
callback();
}
};
__WEBPACK_IMPORTED_MODULE_1__Event__["a" /* default */].addEndEventListener(node, node.rcEndListener);
node.rcAnimTimeout = setTimeout(function () {
for (var s in style) {
if (style.hasOwnProperty(s)) {
node.style[s] = style[s];
}
}
node.rcAnimTimeout = null;
fixBrowserByTimeout(node);
}, 0);
};
cssAnimation.setTransition = function (node, p, value) {
var property = p;
var v = value;
if (value === undefined) {
v = property;
property = '';
}
property = property || '';
capitalPrefixes.forEach(function (prefix) {
node.style[prefix + 'Transition' + property] = v;
});
};
cssAnimation.isCssAnimationSupported = isCssAnimationSupported;
/* harmony default export */ __webpack_exports__["a"] = (cssAnimation);
/***/ }),
/* 167 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = createChainedFunction;
/**
* Safe chained function
*
* Will only create a new function if needed,
* otherwise will pass back existing functions or null.
*
* @returns {function|null}
*/
function createChainedFunction() {
var args = [].slice.call(arguments, 0);
if (args.length === 1) {
return args[0];
}
return function chainedFunction() {
for (var i = 0; i < args.length; i++) {
if (args[i] && args[i].apply) {
args[i].apply(this, arguments);
}
}
};
}
/***/ }),
/* 168 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_prop_types__);
var Portal = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default()(Portal, _React$Component);
function Portal() {
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Portal);
return __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(this, (Portal.__proto__ || Object.getPrototypeOf(Portal)).apply(this, arguments));
}
__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Portal, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.createContainer();
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
var didUpdate = this.props.didUpdate;
if (didUpdate) {
didUpdate(prevProps);
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.removeContainer();
}
}, {
key: 'createContainer',
value: function createContainer() {
this._container = this.props.getContainer();
this.forceUpdate();
}
}, {
key: 'removeContainer',
value: function removeContainer() {
if (this._container) {
this._container.parentNode.removeChild(this._container);
}
}
}, {
key: 'render',
value: function render() {
if (this._container) {
return __WEBPACK_IMPORTED_MODULE_5_react_dom___default.a.createPortal(this.props.children, this._container);
}
return null;
}
}]);
return Portal;
}(__WEBPACK_IMPORTED_MODULE_4_react___default.a.Component);
Portal.propTypes = {
getContainer: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func.isRequired,
children: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.node.isRequired,
didUpdate: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func
};
/* harmony default export */ __webpack_exports__["a"] = (Portal);
/***/ }),
/* 169 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (immutable) */ __webpack_exports__["u"] = toTitle;
/* harmony export (immutable) */ __webpack_exports__["k"] = getValuePropValue;
/* harmony export (immutable) */ __webpack_exports__["i"] = getPropValue;
/* unused harmony export isMultiple */
/* harmony export (immutable) */ __webpack_exports__["m"] = isCombobox;
/* harmony export (immutable) */ __webpack_exports__["n"] = isMultipleOrTags;
/* harmony export (immutable) */ __webpack_exports__["o"] = isMultipleOrTagsOrCombobox;
/* harmony export (immutable) */ __webpack_exports__["p"] = isSingleMode;
/* harmony export (immutable) */ __webpack_exports__["t"] = toArray;
/* harmony export (immutable) */ __webpack_exports__["h"] = getMapKey;
/* harmony export (immutable) */ __webpack_exports__["q"] = preventDefaultEvent;
/* harmony export (immutable) */ __webpack_exports__["e"] = findIndexInValueBySingleValue;
/* harmony export (immutable) */ __webpack_exports__["g"] = getLabelFromPropsValue;
/* harmony export (immutable) */ __webpack_exports__["j"] = getSelectKeys;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return UNSELECTABLE_STYLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return UNSELECTABLE_ATTRIBUTE; });
/* harmony export (immutable) */ __webpack_exports__["d"] = findFirstMenuItem;
/* harmony export (immutable) */ __webpack_exports__["l"] = includesSeparators;
/* harmony export (immutable) */ __webpack_exports__["s"] = splitBySeparators;
/* harmony export (immutable) */ __webpack_exports__["c"] = defaultFilterFn;
/* harmony export (immutable) */ __webpack_exports__["v"] = validateOptionValue;
/* harmony export (immutable) */ __webpack_exports__["r"] = saveRef;
/* harmony export (immutable) */ __webpack_exports__["f"] = generateUUID;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
function toTitle(title) {
if (typeof title === 'string') {
return title;
}
return '';
}
function getValuePropValue(child) {
if (!child) {
return null;
}
var props = child.props;
if ('value' in props) {
return props.value;
}
if (child.key) {
return child.key;
}
if (child.type && child.type.isSelectOptGroup && props.label) {
return props.label;
}
throw new Error("Need at least a key or a value or a label (only for OptGroup) for ".concat(child));
}
function getPropValue(child, prop) {
if (prop === 'value') {
return getValuePropValue(child);
}
return child.props[prop];
}
function isMultiple(props) {
return props.multiple;
}
function isCombobox(props) {
return props.combobox;
}
function isMultipleOrTags(props) {
return props.multiple || props.tags;
}
function isMultipleOrTagsOrCombobox(props) {
return isMultipleOrTags(props) || isCombobox(props);
}
function isSingleMode(props) {
return !isMultipleOrTagsOrCombobox(props);
}
function toArray(value) {
var ret = value;
if (value === undefined) {
ret = [];
} else if (!Array.isArray(value)) {
ret = [value];
}
return ret;
}
function getMapKey(value) {
return "".concat(typeof value, "-").concat(value);
}
function preventDefaultEvent(e) {
e.preventDefault();
}
function findIndexInValueBySingleValue(value, singleValue) {
var index = -1;
if (value) {
for (var i = 0; i < value.length; i++) {
if (value[i] === singleValue) {
index = i;
break;
}
}
}
return index;
}
function getLabelFromPropsValue(value, key) {
var label;
value = toArray(value);
if (value) {
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < value.length; i++) {
if (value[i].key === key) {
label = value[i].label;
break;
}
}
}
return label;
}
function getSelectKeys(menuItems, value) {
if (value === null || value === undefined) {
return [];
}
var selectedKeys = [];
__WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.forEach(menuItems, function (item) {
var type = item.type;
if (type.isMenuItemGroup) {
selectedKeys = selectedKeys.concat(getSelectKeys(item.props.children, value));
} else {
var itemValue = getValuePropValue(item);
var itemKey = item.key;
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey) {
selectedKeys.push(itemKey);
}
}
});
return selectedKeys;
}
var UNSELECTABLE_STYLE = {
userSelect: 'none',
WebkitUserSelect: 'none'
};
var UNSELECTABLE_ATTRIBUTE = {
unselectable: 'on'
};
function findFirstMenuItem(children) {
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.type.isMenuItemGroup) {
var found = findFirstMenuItem(child.props.children);
if (found) {
return found;
}
} else if (!child.props.disabled) {
return child;
}
}
return null;
}
function includesSeparators(str, separators) {
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < separators.length; ++i) {
if (str.lastIndexOf(separators[i]) > 0) {
return true;
}
}
return false;
}
function splitBySeparators(str, separators) {
var reg = new RegExp("[".concat(separators.join(), "]"));
return str.split(reg).filter(function (token) {
return token;
});
}
function defaultFilterFn(input, child) {
if (child.props.disabled) {
return false;
}
var value = toArray(getPropValue(child, this.props.optionFilterProp)).join('');
return value.toLowerCase().indexOf(input.toLowerCase()) > -1;
}
function validateOptionValue(value, props) {
if (isSingleMode(props) || isMultiple(props)) {
return;
}
if (typeof value !== 'string') {
throw new Error("Invalid `value` of type `".concat(typeof value, "` supplied to Option, ") + "expected `string` when `tags/combobox` is `true`.");
}
}
function saveRef(instance, name) {
return function (node) {
instance[name] = node;
};
}
function generateUUID() {
if (process.env.NODE_ENV === 'test') {
return 'test-uuid';
}
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
// tslint:disable-next-line:no-bitwise
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16); // tslint:disable-next-line:no-bitwise
return (c === 'x' ? r : r & 0x7 | 0x8).toString(16);
});
return uuid;
}
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9)))
/***/ }),
/* 170 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_omit_js__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__config_provider__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__icon__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_type__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_warning__ = __webpack_require__(19);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function fixControlledValue(value) {
if (typeof value === 'undefined' || value === null) {
return '';
}
return value;
}
function hasPrefixSuffix(props) {
return !!('prefix' in props || props.suffix || props.allowClear);
}
var InputSizes = Object(__WEBPACK_IMPORTED_MODULE_7__util_type__["a" /* tuple */])('small', 'default', 'large');
var Input =
/*#__PURE__*/
function (_React$Component) {
_inherits(Input, _React$Component);
function Input(props) {
var _this;
_classCallCheck(this, Input);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Input).call(this, props));
_this.handleKeyDown = function (e) {
var _this$props = _this.props,
onPressEnter = _this$props.onPressEnter,
onKeyDown = _this$props.onKeyDown;
if (e.keyCode === 13 && onPressEnter) {
onPressEnter(e);
}
if (onKeyDown) {
onKeyDown(e);
}
};
_this.saveInput = function (node) {
_this.input = node;
};
_this.handleReset = function (e) {
_this.setValue('', e, function () {
_this.focus();
});
};
_this.handleChange = function (e) {
_this.setValue(e.target.value, e);
};
_this.renderComponent = function (_ref) {
var getPrefixCls = _ref.getPrefixCls;
var customizePrefixCls = _this.props.prefixCls;
var prefixCls = getPrefixCls('input', customizePrefixCls);
return _this.renderLabeledInput(prefixCls, _this.renderInput(prefixCls));
};
var value = typeof props.value === 'undefined' ? props.defaultValue : props.value;
_this.state = {
value: value
};
return _this;
}
_createClass(Input, [{
key: "getSnapshotBeforeUpdate",
value: function getSnapshotBeforeUpdate(prevProps) {
if (hasPrefixSuffix(prevProps) !== hasPrefixSuffix(this.props)) {
Object(__WEBPACK_IMPORTED_MODULE_8__util_warning__["a" /* default */])(this.input !== document.activeElement, 'Input', "When Input is focused, dynamic add or remove prefix / suffix will make it lose focus caused by dom structure change. Read more: https://ant.design/components/input/#FAQ");
}
return null;
} // Since polyfill `getSnapshotBeforeUpdate` need work with `componentDidUpdate`.
// We keep an empty function here.
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {}
}, {
key: "focus",
value: function focus() {
this.input.focus();
}
}, {
key: "blur",
value: function blur() {
this.input.blur();
}
}, {
key: "select",
value: function select() {
this.input.select();
}
}, {
key: "getInputClassName",
value: function getInputClassName(prefixCls) {
var _classNames;
var _this$props2 = this.props,
size = _this$props2.size,
disabled = _this$props2.disabled;
return __WEBPACK_IMPORTED_MODULE_2_classnames___default()(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-sm"), size === 'small'), _defineProperty(_classNames, "".concat(prefixCls, "-lg"), size === 'large'), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames));
}
}, {
key: "setValue",
value: function setValue(value, e, callback) {
if (!('value' in this.props)) {
this.setState({
value: value
}, callback);
}
var onChange = this.props.onChange;
if (onChange) {
var event = e;
if (e.type === 'click') {
// click clear icon
event = Object.create(e);
event.target = this.input;
event.currentTarget = this.input;
var originalInputValue = this.input.value; // change input value cause e.target.value should be '' when clear input
this.input.value = '';
onChange(event); // reset input value
this.input.value = originalInputValue;
return;
}
onChange(event);
}
}
}, {
key: "renderClearIcon",
value: function renderClearIcon(prefixCls) {
var allowClear = this.props.allowClear;
var value = this.state.value;
if (!allowClear || value === undefined || value === null || value === '') {
return null;
}
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_6__icon__["a" /* default */], {
type: "close-circle",
theme: "filled",
onClick: this.handleReset,
className: "".concat(prefixCls, "-clear-icon"),
role: "button"
});
}
}, {
key: "renderSuffix",
value: function renderSuffix(prefixCls) {
var _this$props3 = this.props,
suffix = _this$props3.suffix,
allowClear = _this$props3.allowClear;
if (suffix || allowClear) {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: "".concat(prefixCls, "-suffix")
}, this.renderClearIcon(prefixCls), suffix);
}
return null;
}
}, {
key: "renderLabeledInput",
value: function renderLabeledInput(prefixCls, children) {
var _classNames3;
var _this$props4 = this.props,
addonBefore = _this$props4.addonBefore,
addonAfter = _this$props4.addonAfter,
style = _this$props4.style,
size = _this$props4.size,
className = _this$props4.className; // Not wrap when there is not addons
if (!addonBefore && !addonAfter) {
return children;
}
var wrapperClassName = "".concat(prefixCls, "-group");
var addonClassName = "".concat(wrapperClassName, "-addon");
var addonBeforeNode = addonBefore ? __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: addonClassName
}, addonBefore) : null;
var addonAfterNode = addonAfter ? __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: addonClassName
}, addonAfter) : null;
var mergedWrapperClassName = __WEBPACK_IMPORTED_MODULE_2_classnames___default()("".concat(prefixCls, "-wrapper"), _defineProperty({}, wrapperClassName, addonBefore || addonAfter));
var mergedGroupClassName = __WEBPACK_IMPORTED_MODULE_2_classnames___default()(className, "".concat(prefixCls, "-group-wrapper"), (_classNames3 = {}, _defineProperty(_classNames3, "".concat(prefixCls, "-group-wrapper-sm"), size === 'small'), _defineProperty(_classNames3, "".concat(prefixCls, "-group-wrapper-lg"), size === 'large'), _classNames3)); // Need another wrapper for changing display:table to display:inline-block
// and put style prop in wrapper
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: mergedGroupClassName,
style: style
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: mergedWrapperClassName
}, addonBeforeNode, __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](children, {
style: null
}), addonAfterNode));
}
}, {
key: "renderLabeledIcon",
value: function renderLabeledIcon(prefixCls, children) {
var _classNames4;
var props = this.props;
var suffix = this.renderSuffix(prefixCls);
if (!hasPrefixSuffix(props)) {
return children;
}
var prefix = props.prefix ? __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: "".concat(prefixCls, "-prefix")
}, props.prefix) : null;
var affixWrapperCls = __WEBPACK_IMPORTED_MODULE_2_classnames___default()(props.className, "".concat(prefixCls, "-affix-wrapper"), (_classNames4 = {}, _defineProperty(_classNames4, "".concat(prefixCls, "-affix-wrapper-sm"), props.size === 'small'), _defineProperty(_classNames4, "".concat(prefixCls, "-affix-wrapper-lg"), props.size === 'large'), _classNames4));
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: affixWrapperCls,
style: props.style
}, prefix, __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](children, {
style: null,
className: this.getInputClassName(prefixCls)
}), suffix);
}
}, {
key: "renderInput",
value: function renderInput(prefixCls) {
var _this$props5 = this.props,
className = _this$props5.className,
addonBefore = _this$props5.addonBefore,
addonAfter = _this$props5.addonAfter;
var value = this.state.value; // Fix https://fb.me/react-unknown-prop
var otherProps = Object(__WEBPACK_IMPORTED_MODULE_3_omit_js__["a" /* default */])(this.props, ['prefixCls', 'onPressEnter', 'addonBefore', 'addonAfter', 'prefix', 'suffix', 'allowClear', // Input elements must be either controlled or uncontrolled,
// specify either the value prop, or the defaultValue prop, but not both.
'defaultValue']);
return this.renderLabeledIcon(prefixCls, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("input", _extends({}, otherProps, {
value: fixControlledValue(value),
onChange: this.handleChange,
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()(this.getInputClassName(prefixCls), _defineProperty({}, className, className && !addonBefore && !addonAfter)),
onKeyDown: this.handleKeyDown,
ref: this.saveInput
})));
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_5__config_provider__["a" /* ConfigConsumer */], null, this.renderComponent);
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(nextProps) {
if ('value' in nextProps) {
return {
value: nextProps.value
};
}
return null;
}
}]);
return Input;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Input.defaultProps = {
type: 'text',
disabled: false
};
Input.propTypes = {
type: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
id: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
size: __WEBPACK_IMPORTED_MODULE_1_prop_types__["oneOf"](InputSizes),
maxLength: __WEBPACK_IMPORTED_MODULE_1_prop_types__["number"],
disabled: __WEBPACK_IMPORTED_MODULE_1_prop_types__["bool"],
value: __WEBPACK_IMPORTED_MODULE_1_prop_types__["any"],
defaultValue: __WEBPACK_IMPORTED_MODULE_1_prop_types__["any"],
className: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
addonBefore: __WEBPACK_IMPORTED_MODULE_1_prop_types__["node"],
addonAfter: __WEBPACK_IMPORTED_MODULE_1_prop_types__["node"],
prefixCls: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
onPressEnter: __WEBPACK_IMPORTED_MODULE_1_prop_types__["func"],
onKeyDown: __WEBPACK_IMPORTED_MODULE_1_prop_types__["func"],
onKeyUp: __WEBPACK_IMPORTED_MODULE_1_prop_types__["func"],
onFocus: __WEBPACK_IMPORTED_MODULE_1_prop_types__["func"],
onBlur: __WEBPACK_IMPORTED_MODULE_1_prop_types__["func"],
prefix: __WEBPACK_IMPORTED_MODULE_1_prop_types__["node"],
suffix: __WEBPACK_IMPORTED_MODULE_1_prop_types__["node"],
allowClear: __WEBPACK_IMPORTED_MODULE_1_prop_types__["bool"]
};
Object(__WEBPACK_IMPORTED_MODULE_4_react_lifecycles_compat__["polyfill"])(Input);
/* harmony default export */ __webpack_exports__["a"] = (Input);
/***/ }),
/* 171 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__DateTHead__ = __webpack_require__(561);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__DateTBody__ = __webpack_require__(562);
var DateTable = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(DateTable, _React$Component);
function DateTable() {
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, DateTable);
return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.apply(this, arguments));
}
DateTable.prototype.render = function render() {
var props = this.props;
var prefixCls = props.prefixCls;
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'table',
{ className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
__WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_4__DateTHead__["a" /* default */], props),
__WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_5__DateTBody__["a" /* default */], props)
);
};
return DateTable;
}(__WEBPACK_IMPORTED_MODULE_3_react___default.a.Component);
/* harmony default export */ __webpack_exports__["a"] = (DateTable);
/***/ }),
/* 172 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["d"] = getNowByCurrentStateValue;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return calendarMixinPropTypes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return calendarMixinDefaultProps; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return calendarMixinWrapper; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_moment__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_moment___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_moment__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_index__ = __webpack_require__(50);
function noop() {}
function getNowByCurrentStateValue(value) {
var ret = void 0;
if (value) {
ret = Object(__WEBPACK_IMPORTED_MODULE_7__util_index__["e" /* getTodayTime */])(value);
} else {
ret = __WEBPACK_IMPORTED_MODULE_6_moment___default()();
}
return ret;
}
var calendarMixinPropTypes = {
value: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.object,
defaultValue: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.object,
onKeyDown: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func
};
var calendarMixinDefaultProps = {
onKeyDown: noop
};
var calendarMixinWrapper = function calendarMixinWrapper(ComposeComponent) {
var _class, _temp2;
return _temp2 = _class = function (_ComposeComponent) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(_class, _ComposeComponent);
function _class() {
var _temp, _this, _ret;
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, _class);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _ComposeComponent.call.apply(_ComposeComponent, [this].concat(args))), _this), _this.onSelect = function (value, cause) {
if (value) {
_this.setValue(value);
}
_this.setSelectedValue(value, cause);
}, _this.renderRoot = function (newProps) {
var _className;
var props = _this.props;
var prefixCls = props.prefixCls;
var className = (_className = {}, _className[prefixCls] = 1, _className[prefixCls + '-hidden'] = !props.visible, _className[props.className] = !!props.className, _className[newProps.className] = !!newProps.className, _className);
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'div',
{
ref: _this.saveRoot,
className: '' + __WEBPACK_IMPORTED_MODULE_5_classnames___default()(className),
style: _this.props.style,
tabIndex: '0',
onKeyDown: _this.onKeyDown
},
newProps.children
);
}, _this.setSelectedValue = function (selectedValue, cause) {
// if (this.isAllowedDate(selectedValue)) {
if (!('selectedValue' in _this.props)) {
_this.setState({
selectedValue: selectedValue
});
}
if (_this.props.onSelect) {
_this.props.onSelect(selectedValue, cause);
}
// }
}, _this.setValue = function (value) {
var originalValue = _this.state.value;
if (!('value' in _this.props)) {
_this.setState({
value: value
});
}
if (originalValue && value && !originalValue.isSame(value) || !originalValue && value || originalValue && !value) {
_this.props.onChange(value);
}
}, _this.isAllowedDate = function (value) {
var disabledDate = _this.props.disabledDate;
var disabledTime = _this.props.disabledTime;
return Object(__WEBPACK_IMPORTED_MODULE_7__util_index__["g" /* isAllowedDate */])(value, disabledDate, disabledTime);
}, _temp), __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(_this, _ret);
}
_class.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
// Use origin function if provided
if (ComposeComponent.getDerivedStateFromProps) {
return ComposeComponent.getDerivedStateFromProps(nextProps, prevState);
}
var value = nextProps.value,
selectedValue = nextProps.selectedValue;
var newState = {};
if ('value' in nextProps) {
newState.value = value || nextProps.defaultValue || getNowByCurrentStateValue(prevState.value);
}
if ('selectedValue' in nextProps) {
newState.selectedValue = selectedValue;
}
return newState;
};
return _class;
}(ComposeComponent), _class.displayName = 'CalendarMixinWrapper', _class.defaultProps = ComposeComponent.defaultProps, _temp2;
};
/***/ }),
/* 173 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Radio; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_checkbox__ = __webpack_require__(282);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_shallowequal__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_shallowequal___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_shallowequal__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__config_provider__ = __webpack_require__(6);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}
return t;
};
var Radio =
/*#__PURE__*/
function (_React$Component) {
_inherits(Radio, _React$Component);
function Radio() {
var _this;
_classCallCheck(this, Radio);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Radio).apply(this, arguments));
_this.saveCheckbox = function (node) {
_this.rcCheckbox = node;
};
_this.onChange = function (e) {
if (_this.props.onChange) {
_this.props.onChange(e);
}
if (_this.context.radioGroup && _this.context.radioGroup.onChange) {
_this.context.radioGroup.onChange(e);
}
};
_this.renderRadio = function (_ref) {
var _classNames;
var getPrefixCls = _ref.getPrefixCls;
var _assertThisInitialize = _assertThisInitialized(_this),
props = _assertThisInitialize.props,
context = _assertThisInitialize.context;
var customizePrefixCls = props.prefixCls,
className = props.className,
children = props.children,
style = props.style,
restProps = __rest(props, ["prefixCls", "className", "children", "style"]);
var radioGroup = context.radioGroup;
var prefixCls = getPrefixCls('radio', customizePrefixCls);
var radioProps = _extends({}, restProps);
if (radioGroup) {
radioProps.name = radioGroup.name;
radioProps.onChange = _this.onChange;
radioProps.checked = props.value === radioGroup.value;
radioProps.disabled = props.disabled || radioGroup.disabled;
}
var wrapperClassString = __WEBPACK_IMPORTED_MODULE_3_classnames___default()(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-wrapper"), true), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-checked"), radioProps.checked), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-disabled"), radioProps.disabled), _classNames));
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("label", {
className: wrapperClassString,
style: style,
onMouseEnter: props.onMouseEnter,
onMouseLeave: props.onMouseLeave
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_2_rc_checkbox__["a" /* default */], _extends({}, radioProps, {
prefixCls: prefixCls,
ref: _this.saveCheckbox
})), children !== undefined ? __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", null, children) : null);
};
return _this;
}
_createClass(Radio, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps, nextState, nextContext) {
return !__WEBPACK_IMPORTED_MODULE_4_shallowequal___default()(this.props, nextProps) || !__WEBPACK_IMPORTED_MODULE_4_shallowequal___default()(this.state, nextState) || !__WEBPACK_IMPORTED_MODULE_4_shallowequal___default()(this.context.radioGroup, nextContext.radioGroup);
}
}, {
key: "focus",
value: function focus() {
this.rcCheckbox.focus();
}
}, {
key: "blur",
value: function blur() {
this.rcCheckbox.blur();
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_5__config_provider__["a" /* ConfigConsumer */], null, this.renderRadio);
}
}]);
return Radio;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Radio.defaultProps = {
type: 'radio'
};
Radio.contextTypes = {
radioGroup: __WEBPACK_IMPORTED_MODULE_1_prop_types__["any"]
};
/***/ }),
/* 174 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactComponentWithPureRenderMixin
*/
var shallowEqual = __webpack_require__(566);
function shallowCompare(instance, nextProps, nextState) {
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
}
/**
* If your React component's render function is "pure", e.g. it will render the
* same result given the same props and state, provide this mixin for a
* considerable performance boost.
*
* Most React components have pure render functions.
*
* Example:
*
* var ReactComponentWithPureRenderMixin =
* require('ReactComponentWithPureRenderMixin');
* React.createClass({
* mixins: [ReactComponentWithPureRenderMixin],
*
* render: function() {
* return foo
;
* }
* });
*
* Note: This only checks shallow equality for props and state. If these contain
* complex data structures this mixin may have false-negatives for deeper
* differences. Only mixin to components which have simple props and state, or
* use `forceUpdate()` when you know deep data structures have changed.
*
* See https://facebook.github.io/react/docs/pure-render-mixin.html
*/
var ReactComponentWithPureRenderMixin = {
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
};
module.exports = ReactComponentWithPureRenderMixin;
/***/ }),
/* 175 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_css_animation__ = __webpack_require__(166);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_raf__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_raf___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_raf__);
function animate(node, show, done) {
var height;
var requestAnimationFrameId;
return Object(__WEBPACK_IMPORTED_MODULE_0_css_animation__["a" /* default */])(node, 'ant-motion-collapse', {
start: function start() {
if (!show) {
node.style.height = "".concat(node.offsetHeight, "px");
node.style.opacity = '1';
} else {
height = node.offsetHeight;
node.style.height = '0px';
node.style.opacity = '0';
}
},
active: function active() {
if (requestAnimationFrameId) {
__WEBPACK_IMPORTED_MODULE_1_raf___default.a.cancel(requestAnimationFrameId);
}
requestAnimationFrameId = __WEBPACK_IMPORTED_MODULE_1_raf___default()(function () {
node.style.height = "".concat(show ? height : 0, "px");
node.style.opacity = show ? '1' : '0';
});
},
end: function end() {
if (requestAnimationFrameId) {
__WEBPACK_IMPORTED_MODULE_1_raf___default.a.cancel(requestAnimationFrameId);
}
node.style.height = '';
node.style.opacity = '';
done();
}
});
}
var animation = {
enter: function enter(node, done) {
return animate(node, true, done);
},
leave: function leave(node, done) {
return animate(node, false, done);
},
appear: function appear(node, done) {
return animate(node, true, done);
}
};
/* harmony default export */ __webpack_exports__["a"] = (animation);
/***/ }),
/* 176 */
/***/ (function(module, exports, __webpack_require__) {
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.arrayTreeFilter = factory());
}(this, (function () { 'use strict';
function arrayTreeFilter(data, filterFn, options) {
options = options || {};
options.childrenKeyName = options.childrenKeyName || "children";
var children = data || [];
var result = [];
var level = 0;
do {
var foundItem = children.filter(function (item) {
return filterFn(item, level);
})[0];
if (!foundItem) {
break;
}
result.push(foundItem);
children = foundItem[options.childrenKeyName] || [];
level += 1;
} while (children.length > 0);
return result;
}
return arrayTreeFilter;
})));
/***/ }),
/* 177 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_rc_util_es_Children_mapSelf__ = __webpack_require__(301);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__month_MonthPanel__ = __webpack_require__(619);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__year_YearPanel__ = __webpack_require__(620);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__decade_DecadePanel__ = __webpack_require__(621);
function goMonth(direction) {
var next = this.props.value.clone();
next.add(direction, 'months');
this.props.onValueChange(next);
}
function goYear(direction) {
var next = this.props.value.clone();
next.add(direction, 'years');
this.props.onValueChange(next);
}
function showIf(condition, el) {
return condition ? el : null;
}
var CalendarHeader = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(CalendarHeader, _React$Component);
function CalendarHeader(props) {
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, CalendarHeader);
var _this = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.call(this, props));
_initialiseProps.call(_this);
_this.nextMonth = goMonth.bind(_this, 1);
_this.previousMonth = goMonth.bind(_this, -1);
_this.nextYear = goYear.bind(_this, 1);
_this.previousYear = goYear.bind(_this, -1);
_this.state = { yearPanelReferer: null };
return _this;
}
CalendarHeader.prototype.render = function render() {
var _this2 = this;
var props = this.props;
var prefixCls = props.prefixCls,
locale = props.locale,
mode = props.mode,
value = props.value,
showTimePicker = props.showTimePicker,
enableNext = props.enableNext,
enablePrev = props.enablePrev,
disabledMonth = props.disabledMonth,
renderFooter = props.renderFooter;
var panel = null;
if (mode === 'month') {
panel = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_6__month_MonthPanel__["a" /* default */], {
locale: locale,
defaultValue: value,
rootPrefixCls: prefixCls,
onSelect: this.onMonthSelect,
onYearPanelShow: function onYearPanelShow() {
return _this2.showYearPanel('month');
},
disabledDate: disabledMonth,
cellRender: props.monthCellRender,
contentRender: props.monthCellContentRender,
renderFooter: renderFooter
});
}
if (mode === 'year') {
panel = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_7__year_YearPanel__["a" /* default */], {
locale: locale,
defaultValue: value,
rootPrefixCls: prefixCls,
onSelect: this.onYearSelect,
onDecadePanelShow: this.showDecadePanel,
renderFooter: renderFooter
});
}
if (mode === 'decade') {
panel = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_8__decade_DecadePanel__["a" /* default */], {
locale: locale,
defaultValue: value,
rootPrefixCls: prefixCls,
onSelect: this.onDecadeSelect,
renderFooter: renderFooter
});
}
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'div',
{ className: prefixCls + '-header' },
__WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'div',
{ style: { position: 'relative' } },
showIf(enablePrev && !showTimePicker, __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement('a', {
className: prefixCls + '-prev-year-btn',
role: 'button',
onClick: this.previousYear,
title: locale.previousYear
})),
showIf(enablePrev && !showTimePicker, __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement('a', {
className: prefixCls + '-prev-month-btn',
role: 'button',
onClick: this.previousMonth,
title: locale.previousMonth
})),
this.monthYearElement(showTimePicker),
showIf(enableNext && !showTimePicker, __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement('a', {
className: prefixCls + '-next-month-btn',
onClick: this.nextMonth,
title: locale.nextMonth
})),
showIf(enableNext && !showTimePicker, __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement('a', {
className: prefixCls + '-next-year-btn',
onClick: this.nextYear,
title: locale.nextYear
}))
),
panel
);
};
return CalendarHeader;
}(__WEBPACK_IMPORTED_MODULE_3_react___default.a.Component);
CalendarHeader.propTypes = {
prefixCls: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.string,
value: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.object,
onValueChange: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func,
showTimePicker: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.bool,
onPanelChange: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func,
locale: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.object,
enablePrev: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.any,
enableNext: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.any,
disabledMonth: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func,
renderFooter: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func,
onMonthSelect: __WEBPACK_IMPORTED_MODULE_4_prop_types___default.a.func
};
CalendarHeader.defaultProps = {
enableNext: 1,
enablePrev: 1,
onPanelChange: function onPanelChange() {},
onValueChange: function onValueChange() {}
};
var _initialiseProps = function _initialiseProps() {
var _this3 = this;
this.onMonthSelect = function (value) {
_this3.props.onPanelChange(value, 'date');
if (_this3.props.onMonthSelect) {
_this3.props.onMonthSelect(value);
} else {
_this3.props.onValueChange(value);
}
};
this.onYearSelect = function (value) {
var referer = _this3.state.yearPanelReferer;
_this3.setState({ yearPanelReferer: null });
_this3.props.onPanelChange(value, referer);
_this3.props.onValueChange(value);
};
this.onDecadeSelect = function (value) {
_this3.props.onPanelChange(value, 'year');
_this3.props.onValueChange(value);
};
this.monthYearElement = function (showTimePicker) {
var props = _this3.props;
var prefixCls = props.prefixCls;
var locale = props.locale;
var value = props.value;
var localeData = value.localeData();
var monthBeforeYear = locale.monthBeforeYear;
var selectClassName = prefixCls + '-' + (monthBeforeYear ? 'my-select' : 'ym-select');
var timeClassName = showTimePicker ? ' ' + prefixCls + '-time-status' : '';
var year = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'a',
{
className: prefixCls + '-year-select' + timeClassName,
role: 'button',
onClick: showTimePicker ? null : function () {
return _this3.showYearPanel('date');
},
title: showTimePicker ? null : locale.yearSelect
},
value.format(locale.yearFormat)
);
var month = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'a',
{
className: prefixCls + '-month-select' + timeClassName,
role: 'button',
onClick: showTimePicker ? null : _this3.showMonthPanel,
title: showTimePicker ? null : locale.monthSelect
},
locale.monthFormat ? value.format(locale.monthFormat) : localeData.monthsShort(value)
);
var day = void 0;
if (showTimePicker) {
day = __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'a',
{
className: prefixCls + '-day-select' + timeClassName,
role: 'button'
},
value.format(locale.dayFormat)
);
}
var my = [];
if (monthBeforeYear) {
my = [month, day, year];
} else {
my = [year, month, day];
}
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
'span',
{ className: selectClassName },
Object(__WEBPACK_IMPORTED_MODULE_5_rc_util_es_Children_mapSelf__["a" /* default */])(my)
);
};
this.showMonthPanel = function () {
// null means that users' interaction doesn't change value
_this3.props.onPanelChange(null, 'month');
};
this.showYearPanel = function (referer) {
_this3.setState({ yearPanelReferer: referer });
_this3.props.onPanelChange(null, 'year');
};
this.showDecadePanel = function () {
_this3.props.onPanelChange(null, 'decade');
};
};
/* harmony default export */ __webpack_exports__["a"] = (CalendarHeader);
/***/ }),
/* 178 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_rc_util_es_createChainedFunction__ = __webpack_require__(167);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_rc_util_es_KeyCode__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__picker_placements__ = __webpack_require__(623);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_rc_trigger__ = __webpack_require__(67);
function noop() {}
function refFn(field, component) {
this[field] = component;
}
var Picker = function (_React$Component) {
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(Picker, _React$Component);
function Picker(props) {
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Picker);
var _this = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.call(this, props));
_initialiseProps.call(_this);
var open = void 0;
if ('open' in props) {
open = props.open;
} else {
open = props.defaultOpen;
}
var value = props.value || props.defaultValue;
_this.saveCalendarRef = refFn.bind(_this, 'calendarInstance');
_this.state = {
open: open,
value: value
};
return _this;
}
Picker.prototype.componentDidUpdate = function componentDidUpdate(_, prevState) {
if (!prevState.open && this.state.open) {
// setTimeout is for making sure saveCalendarRef happen before focusCalendar
this.focusTimeout = setTimeout(this.focusCalendar, 0, this);
}
};
Picker.prototype.componentWillUnmount = function componentWillUnmount() {
clearTimeout(this.focusTimeout);
};
Picker.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) {
var newState = {};
var value = nextProps.value,
open = nextProps.open;
if ('value' in nextProps) {
newState.value = value;
}
if (open !== undefined) {
newState.open = open;
}
return newState;
};
Picker.prototype.render = function render() {
var props = this.props;
var prefixCls = props.prefixCls,
placement = props.placement,
style = props.style,
getCalendarContainer = props.getCalendarContainer,
align = props.align,
animation = props.animation,
disabled = props.disabled,
dropdownClassName = props.dropdownClassName,
transitionName = props.transitionName,
children = props.children;
var state = this.state;
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_10_rc_trigger__["a" /* default */],
{
popup: this.getCalendarElement(),
popupAlign: align,
builtinPlacements: __WEBPACK_IMPORTED_MODULE_9__picker_placements__["a" /* default */],
popupPlacement: placement,
action: disabled && !state.open ? [] : ['click'],
destroyPopupOnHide: true,
getPopupContainer: getCalendarContainer,
popupStyle: style,
popupAnimation: animation,
popupTransitionName: transitionName,
popupVisible: state.open,
onPopupVisibleChange: this.onVisibleChange,
prefixCls: prefixCls,
popupClassName: dropdownClassName
},
__WEBPACK_IMPORTED_MODULE_3_react___default.a.cloneElement(children(state, props), { onKeyDown: this.onKeyDown })
);
};
return Picker;
}(__WEBPACK_IMPORTED_MODULE_3_react___default.a.Component);
Picker.propTypes = {
animation: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string]),
disabled: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
transitionName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
onChange: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
onOpenChange: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
children: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
getCalendarContainer: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,
calendar: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.element,
style: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,
open: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
defaultOpen: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,
prefixCls: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,
placement: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,
value: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.array]),
defaultValue: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.array]),
align: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object
};
Picker.defaultProps = {
prefixCls: 'rc-calendar-picker',
style: {},
align: {},
placement: 'bottomLeft',
defaultOpen: false,
onChange: noop,
onOpenChange: noop
};
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.onCalendarKeyDown = function (event) {
if (event.keyCode === __WEBPACK_IMPORTED_MODULE_8_rc_util_es_KeyCode__["a" /* default */].ESC) {
event.stopPropagation();
_this2.close(_this2.focus);
}
};
this.onCalendarSelect = function (value) {
var cause = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = _this2.props;
if (!('value' in props)) {
_this2.setState({
value: value
});
}
if (cause.source === 'keyboard' || cause.source === 'dateInputSelect' || !props.calendar.props.timePicker && cause.source !== 'dateInput' || cause.source === 'todayButton') {
_this2.close(_this2.focus);
}
props.onChange(value);
};
this.onKeyDown = function (event) {
if (!_this2.state.open && (event.keyCode === __WEBPACK_IMPORTED_MODULE_8_rc_util_es_KeyCode__["a" /* default */].DOWN || event.keyCode === __WEBPACK_IMPORTED_MODULE_8_rc_util_es_KeyCode__["a" /* default */].ENTER)) {
_this2.open();
event.preventDefault();
}
};
this.onCalendarOk = function () {
_this2.close(_this2.focus);
};
this.onCalendarClear = function () {
_this2.close(_this2.focus);
};
this.onVisibleChange = function (open) {
_this2.setOpen(open);
};
this.getCalendarElement = function () {
var props = _this2.props;
var state = _this2.state;
var calendarProps = props.calendar.props;
var value = state.value;
var defaultValue = value;
var extraProps = {
ref: _this2.saveCalendarRef,
defaultValue: defaultValue || calendarProps.defaultValue,
selectedValue: value,
onKeyDown: _this2.onCalendarKeyDown,
onOk: Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_createChainedFunction__["a" /* default */])(calendarProps.onOk, _this2.onCalendarOk),
onSelect: Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_createChainedFunction__["a" /* default */])(calendarProps.onSelect, _this2.onCalendarSelect),
onClear: Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_createChainedFunction__["a" /* default */])(calendarProps.onClear, _this2.onCalendarClear)
};
return __WEBPACK_IMPORTED_MODULE_3_react___default.a.cloneElement(props.calendar, extraProps);
};
this.setOpen = function (open, callback) {
var onOpenChange = _this2.props.onOpenChange;
if (_this2.state.open !== open) {
if (!('open' in _this2.props)) {
_this2.setState({
open: open
}, callback);
}
onOpenChange(open);
}
};
this.open = function (callback) {
_this2.setOpen(true, callback);
};
this.close = function (callback) {
_this2.setOpen(false, callback);
};
this.focus = function () {
if (!_this2.state.open) {
__WEBPACK_IMPORTED_MODULE_4_react_dom___default.a.findDOMNode(_this2).focus();
}
};
this.focusCalendar = function () {
if (_this2.state.open && !!_this2.calendarInstance) {
_this2.calendarInstance.focus();
}
};
};
Object(__WEBPACK_IMPORTED_MODULE_6_react_lifecycles_compat__["polyfill"])(Picker);
/* harmony default export */ __webpack_exports__["a"] = (Picker);
/***/ }),
/* 179 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dropdown__ = __webpack_require__(314);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dropdown_button__ = __webpack_require__(638);
__WEBPACK_IMPORTED_MODULE_0__dropdown__["a" /* default */].Button = __WEBPACK_IMPORTED_MODULE_1__dropdown_button__["a" /* default */];
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__dropdown__["a" /* default */]);
/***/ }),
/* 180 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(41),
isKey = __webpack_require__(181),
stringToPath = __webpack_require__(648),
toString = __webpack_require__(184);
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
module.exports = castPath;
/***/ }),
/* 181 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(41),
isSymbol = __webpack_require__(126);
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/;
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(object != null && value in Object(object));
}
module.exports = isKey;
/***/ }),
/* 182 */
/***/ (function(module, exports, __webpack_require__) {
var mapCacheClear = __webpack_require__(651),
mapCacheDelete = __webpack_require__(667),
mapCacheGet = __webpack_require__(669),
mapCacheHas = __webpack_require__(670),
mapCacheSet = __webpack_require__(671);
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
module.exports = MapCache;
/***/ }),
/* 183 */
/***/ (function(module, exports, __webpack_require__) {
var getNative = __webpack_require__(71),
root = __webpack_require__(29);
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map');
module.exports = Map;
/***/ }),
/* 184 */
/***/ (function(module, exports, __webpack_require__) {
var baseToString = __webpack_require__(318);
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
module.exports = toString;
/***/ }),
/* 185 */
/***/ (function(module, exports) {
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
module.exports = arrayMap;
/***/ }),
/* 186 */
/***/ (function(module, exports, __webpack_require__) {
var baseIsArguments = __webpack_require__(672),
isObjectLike = __webpack_require__(46);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Built-in value references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
module.exports = isArguments;
/***/ }),
/* 187 */
/***/ (function(module, exports) {
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
module.exports = isLength;
/***/ }),
/* 188 */
/***/ (function(module, exports, __webpack_require__) {
var baseGet = __webpack_require__(323);
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
module.exports = get;
/***/ }),
/* 189 */
/***/ (function(module, exports, __webpack_require__) {
var defineProperty = __webpack_require__(326);
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__' && defineProperty) {
defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
module.exports = baseAssignValue;
/***/ }),
/* 190 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = argumentContainer;
/* harmony export (immutable) */ __webpack_exports__["i"] = identity;
/* harmony export (immutable) */ __webpack_exports__["b"] = flattenArray;
/* unused harmony export treeTraverse */
/* harmony export (immutable) */ __webpack_exports__["c"] = flattenFields;
/* harmony export (immutable) */ __webpack_exports__["k"] = normalizeValidateRules;
/* harmony export (immutable) */ __webpack_exports__["f"] = getValidateTriggers;
/* harmony export (immutable) */ __webpack_exports__["g"] = getValueFromEvent;
/* harmony export (immutable) */ __webpack_exports__["d"] = getErrorStrs;
/* harmony export (immutable) */ __webpack_exports__["e"] = getParams;
/* harmony export (immutable) */ __webpack_exports__["j"] = isEmptyObject;
/* harmony export (immutable) */ __webpack_exports__["h"] = hasRules;
/* harmony export (immutable) */ __webpack_exports__["l"] = startsWith;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_hoist_non_react_statics__ = __webpack_require__(707);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_hoist_non_react_statics___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_hoist_non_react_statics__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_warning__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_warning__);
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'WrappedComponent';
}
function argumentContainer(Container, WrappedComponent) {
/* eslint no-param-reassign:0 */
Container.displayName = 'Form(' + getDisplayName(WrappedComponent) + ')';
Container.WrappedComponent = WrappedComponent;
return __WEBPACK_IMPORTED_MODULE_1_hoist_non_react_statics___default()(Container, WrappedComponent);
}
function identity(obj) {
return obj;
}
function flattenArray(arr) {
return Array.prototype.concat.apply([], arr);
}
function treeTraverse() {
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var tree = arguments[1];
var isLeafNode = arguments[2];
var errorMessage = arguments[3];
var callback = arguments[4];
if (isLeafNode(path, tree)) {
callback(path, tree);
} else if (tree === undefined || tree === null) {
// Do nothing
} else if (Array.isArray(tree)) {
tree.forEach(function (subTree, index) {
return treeTraverse(path + '[' + index + ']', subTree, isLeafNode, errorMessage, callback);
});
} else {
// It's object and not a leaf node
if (typeof tree !== 'object') {
__WEBPACK_IMPORTED_MODULE_2_warning___default()(false, errorMessage);
return;
}
Object.keys(tree).forEach(function (subTreeKey) {
var subTree = tree[subTreeKey];
treeTraverse('' + path + (path ? '.' : '') + subTreeKey, subTree, isLeafNode, errorMessage, callback);
});
}
}
function flattenFields(maybeNestedFields, isLeafNode, errorMessage) {
var fields = {};
treeTraverse(undefined, maybeNestedFields, isLeafNode, errorMessage, function (path, node) {
fields[path] = node;
});
return fields;
}
function normalizeValidateRules(validate, rules, validateTrigger) {
var validateRules = validate.map(function (item) {
var newItem = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, item, {
trigger: item.trigger || []
});
if (typeof newItem.trigger === 'string') {
newItem.trigger = [newItem.trigger];
}
return newItem;
});
if (rules) {
validateRules.push({
trigger: validateTrigger ? [].concat(validateTrigger) : [],
rules: rules
});
}
return validateRules;
}
function getValidateTriggers(validateRules) {
return validateRules.filter(function (item) {
return !!item.rules && item.rules.length;
}).map(function (item) {
return item.trigger;
}).reduce(function (pre, curr) {
return pre.concat(curr);
}, []);
}
function getValueFromEvent(e) {
// To support custom element
if (!e || !e.target) {
return e;
}
var target = e.target;
return target.type === 'checkbox' ? target.checked : target.value;
}
function getErrorStrs(errors) {
if (errors) {
return errors.map(function (e) {
if (e && e.message) {
return e.message;
}
return e;
});
}
return errors;
}
function getParams(ns, opt, cb) {
var names = ns;
var options = opt;
var callback = cb;
if (cb === undefined) {
if (typeof names === 'function') {
callback = names;
options = {};
names = undefined;
} else if (Array.isArray(names)) {
if (typeof options === 'function') {
callback = options;
options = {};
} else {
options = options || {};
}
} else {
callback = options;
options = names || {};
names = undefined;
}
}
return {
names: names,
options: options,
callback: callback
};
}
function isEmptyObject(obj) {
return Object.keys(obj).length === 0;
}
function hasRules(validate) {
if (validate) {
return validate.some(function (item) {
return item.rules && item.rules.length;
});
}
return false;
}
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
/***/ }),
/* 191 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_omit_js__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_debounce__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_debounce___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_lodash_debounce__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__config_provider__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_type__ = __webpack_require__(40);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}
return t;
};
var SpinSizes = Object(__WEBPACK_IMPORTED_MODULE_6__util_type__["a" /* tuple */])('small', 'default', 'large'); // Render indicator
var defaultIndicator = null;
function renderIndicator(prefixCls, props) {
var indicator = props.indicator;
var dotClassName = "".concat(prefixCls, "-dot");
if (__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](indicator)) {
return __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](indicator, {
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()(indicator.props.className, dotClassName)
});
}
if (__WEBPACK_IMPORTED_MODULE_0_react__["isValidElement"](defaultIndicator)) {
return __WEBPACK_IMPORTED_MODULE_0_react__["cloneElement"](defaultIndicator, {
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()(defaultIndicator.props.className, dotClassName)
});
}
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()(dotClassName, "".concat(prefixCls, "-dot-spin"))
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("i", null), __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("i", null), __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("i", null), __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("i", null));
}
function shouldDelay(spinning, delay) {
return !!spinning && !!delay && !isNaN(Number(delay));
}
var Spin =
/*#__PURE__*/
function (_React$Component) {
_inherits(Spin, _React$Component);
function Spin(props) {
var _this;
_classCallCheck(this, Spin);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Spin).call(this, props));
_this.debouncifyUpdateSpinning = function (props) {
var _ref = props || _this.props,
delay = _ref.delay;
if (delay) {
_this.updateSpinning = __WEBPACK_IMPORTED_MODULE_4_lodash_debounce___default()(_this.originalUpdateSpinning, delay);
}
};
_this.updateSpinning = function () {
var spinning = _this.props.spinning;
var currentSpinning = _this.state.spinning;
if (currentSpinning !== spinning) {
_this.setState({
spinning: spinning
});
}
};
_this.renderSpin = function (_ref2) {
var _classNames;
var getPrefixCls = _ref2.getPrefixCls;
var _a = _this.props,
customizePrefixCls = _a.prefixCls,
className = _a.className,
size = _a.size,
tip = _a.tip,
wrapperClassName = _a.wrapperClassName,
style = _a.style,
restProps = __rest(_a, ["prefixCls", "className", "size", "tip", "wrapperClassName", "style"]);
var spinning = _this.state.spinning;
var prefixCls = getPrefixCls('spin', customizePrefixCls);
var spinClassName = __WEBPACK_IMPORTED_MODULE_2_classnames___default()(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-sm"), size === 'small'), _defineProperty(_classNames, "".concat(prefixCls, "-lg"), size === 'large'), _defineProperty(_classNames, "".concat(prefixCls, "-spinning"), spinning), _defineProperty(_classNames, "".concat(prefixCls, "-show-text"), !!tip), _classNames), className); // fix https://fb.me/react-unknown-prop
var divProps = Object(__WEBPACK_IMPORTED_MODULE_3_omit_js__["a" /* default */])(restProps, ['spinning', 'delay', 'indicator']);
var spinElement = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("div", _extends({}, divProps, {
style: style,
className: spinClassName
}), renderIndicator(prefixCls, _this.props), tip ? __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("div", {
className: "".concat(prefixCls, "-text")
}, tip) : null);
if (_this.isNestedPattern()) {
var containerClassName = __WEBPACK_IMPORTED_MODULE_2_classnames___default()("".concat(prefixCls, "-container"), _defineProperty({}, "".concat(prefixCls, "-blur"), spinning));
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("div", _extends({}, divProps, {
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()("".concat(prefixCls, "-nested-loading"), wrapperClassName)
}), spinning && __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("div", {
key: "loading"
}, spinElement), __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("div", {
className: containerClassName,
key: "container"
}, _this.props.children));
}
return spinElement;
};
var spinning = props.spinning,
delay = props.delay;
var shouldBeDelayed = shouldDelay(spinning, delay);
_this.state = {
spinning: spinning && !shouldBeDelayed
};
_this.originalUpdateSpinning = _this.updateSpinning;
_this.debouncifyUpdateSpinning(props);
return _this;
}
_createClass(Spin, [{
key: "isNestedPattern",
value: function isNestedPattern() {
return !!(this.props && this.props.children);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var updateSpinning = this.updateSpinning;
if (updateSpinning && updateSpinning.cancel) {
updateSpinning.cancel();
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.updateSpinning();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.debouncifyUpdateSpinning();
this.updateSpinning();
}
}, {
key: "render",
value: function render() {
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_5__config_provider__["a" /* ConfigConsumer */], null, this.renderSpin);
}
}], [{
key: "setDefaultIndicator",
value: function setDefaultIndicator(indicator) {
defaultIndicator = indicator;
}
}]);
return Spin;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Spin.defaultProps = {
spinning: true,
size: 'default',
wrapperClassName: ''
};
Spin.propTypes = {
prefixCls: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
className: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
spinning: __WEBPACK_IMPORTED_MODULE_1_prop_types__["bool"],
size: __WEBPACK_IMPORTED_MODULE_1_prop_types__["oneOf"](SpinSizes),
wrapperClassName: __WEBPACK_IMPORTED_MODULE_1_prop_types__["string"],
indicator: __WEBPACK_IMPORTED_MODULE_1_prop_types__["element"]
};
/* harmony default export */ __webpack_exports__["a"] = (Spin);
/***/ }),
/* 192 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Pagination__ = __webpack_require__(721);
/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Pagination__["a" /* default */]);
/***/ }),
/* 193 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = changeConfirmLocale;
/* harmony export (immutable) */ __webpack_exports__["b"] = getConfirmLocale;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__locale_provider_default__ = __webpack_require__(80);
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); }
var runtimeLocale = _extends({}, __WEBPACK_IMPORTED_MODULE_0__locale_provider_default__["a" /* default */].Modal);
function changeConfirmLocale(newLocale) {
if (newLocale) {
runtimeLocale = _extends({}, runtimeLocale, newLocale);
} else {
runtimeLocale = _extends({}, __WEBPACK_IMPORTED_MODULE_0__locale_provider_default__["a" /* default */].Modal);
}
}
function getConfirmLocale() {
return runtimeLocale;
}
/***/ }),
/* 194 */
/***/ (function(module, exports) {
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f',
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
rsComboSymbolsRange = '\\u20d0-\\u20ff',
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
/**
* Checks if `string` contains Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
function hasUnicode(string) {
return reHasUnicode.test(string);
}
module.exports = hasUnicode;
/***/ }),
/* 195 */
/***/ (function(module, exports, __webpack_require__) {
var asciiSize = __webpack_require__(751),
hasUnicode = __webpack_require__(194),
unicodeSize = __webpack_require__(752);
/**
* Gets the number of symbols in `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the string size.
*/
function stringSize(string) {
return hasUnicode(string)
? unicodeSize(string)
: asciiSize(string);
}
module.exports = stringSize;
/***/ }),
/* 196 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = validProgress;
function validProgress(progress) {
if (!progress || progress < 0) {
return 0;
} else if (progress > 100) {
return 100;
}
return progress;
}
/***/ }),
/* 197 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (immutable) */ __webpack_exports__["g"] = isDev;
/* harmony export (immutable) */ __webpack_exports__["h"] = isEventFromHandle;
/* harmony export (immutable) */ __webpack_exports__["j"] = isValueOutOfRange;
/* harmony export (immutable) */ __webpack_exports__["i"] = isNotTouchEvent;
/* unused harmony export getClosestPoint */
/* unused harmony export getPrecision */
/* harmony export (immutable) */ __webpack_exports__["e"] = getMousePosition;
/* harmony export (immutable) */ __webpack_exports__["f"] = getTouchPosition;
/* harmony export (immutable) */ __webpack_exports__["c"] = getHandleCenterPosition;
/* harmony export (immutable) */ __webpack_exports__["a"] = ensureValueInRange;
/* harmony export (immutable) */ __webpack_exports__["b"] = ensureValuePrecision;
/* harmony export (immutable) */ __webpack_exports__["k"] = pauseEvent;
/* unused harmony export calculateNextValue */
/* harmony export (immutable) */ __webpack_exports__["d"] = getKeyboardValueMutator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray__ = __webpack_require__(100);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_dom__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__ = __webpack_require__(23);
function isDev() {
return process.env.NODE_ENV !== 'production';
}
function isEventFromHandle(e, handles) {
try {
return Object.keys(handles).some(function (key) {
return e.target === Object(__WEBPACK_IMPORTED_MODULE_1_react_dom__["findDOMNode"])(handles[key]);
});
} catch (error) {
return false;
}
}
function isValueOutOfRange(value, _ref) {
var min = _ref.min,
max = _ref.max;
return value < min || value > max;
}
function isNotTouchEvent(e) {
return e.touches.length > 1 || e.type.toLowerCase() === 'touchend' && e.touches.length > 0;
}
function getClosestPoint(val, _ref2) {
var marks = _ref2.marks,
step = _ref2.step,
min = _ref2.min;
var points = Object.keys(marks).map(parseFloat);
if (step !== null) {
var closestStep = Math.round((val - min) / step) * step + min;
points.push(closestStep);
}
var diffs = points.map(function (point) {
return Math.abs(val - point);
});
return points[diffs.indexOf(Math.min.apply(Math, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default()(diffs)))];
}
function getPrecision(step) {
var stepString = step.toString();
var precision = 0;
if (stepString.indexOf('.') >= 0) {
precision = stepString.length - stepString.indexOf('.') - 1;
}
return precision;
}
function getMousePosition(vertical, e) {
return vertical ? e.clientY : e.pageX;
}
function getTouchPosition(vertical, e) {
return vertical ? e.touches[0].clientY : e.touches[0].pageX;
}
function getHandleCenterPosition(vertical, handle) {
var coords = handle.getBoundingClientRect();
return vertical ? coords.top + coords.height * 0.5 : window.pageXOffset + coords.left + coords.width * 0.5;
}
function ensureValueInRange(val, _ref3) {
var max = _ref3.max,
min = _ref3.min;
if (val <= min) {
return min;
}
if (val >= max) {
return max;
}
return val;
}
function ensureValuePrecision(val, props) {
var step = props.step;
var closestPoint = isFinite(getClosestPoint(val, props)) ? getClosestPoint(val, props) : 0; // eslint-disable-line
return step === null ? closestPoint : parseFloat(closestPoint.toFixed(getPrecision(step)));
}
function pauseEvent(e) {
e.stopPropagation();
e.preventDefault();
}
function calculateNextValue(func, value, props) {
var operations = {
increase: function increase(a, b) {
return a + b;
},
decrease: function decrease(a, b) {
return a - b;
}
};
var indexToGet = operations[func](Object.keys(props.marks).indexOf(JSON.stringify(value)), 1);
var keyToGet = Object.keys(props.marks)[indexToGet];
if (props.step) {
return operations[func](value, props.step);
} else if (!!Object.keys(props.marks).length && !!props.marks[keyToGet]) {
return props.marks[keyToGet];
}
return value;
}
function getKeyboardValueMutator(e) {
switch (e.keyCode) {
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].UP:
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].RIGHT:
return function (value, props) {
return calculateNextValue('increase', value, props);
};
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].DOWN:
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].LEFT:
return function (value, props) {
return calculateNextValue('decrease', value, props);
};
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].END:
return function (value, props) {
return props.max;
};
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].HOME:
return function (value, props) {
return props.min;
};
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].PAGE_UP:
return function (value, props) {
return value + props.step * 2;
};
case __WEBPACK_IMPORTED_MODULE_2_rc_util_es_KeyCode__["a" /* default */].PAGE_DOWN:
return function (value, props) {
return value - props.step * 2;
};
default:
return undefined;
}
}
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9)))
/***/ }),
/* 198 */
/***/ (function(module, exports, __webpack_require__) {
var ListCache = __webpack_require__(130),
stackClear = __webpack_require__(804),
stackDelete = __webpack_require__(805),
stackGet = __webpack_require__(806),
stackHas = __webpack_require__(807),
stackSet = __webpack_require__(808);
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
var data = this.__data__ = new ListCache(entries);
this.size = data.size;
}
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
module.exports = Stack;
/***/ }),
/* 199 */
/***/ (function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
/***/ }),
/* 200 */
/***/ (function(module, exports) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
return value === proto;
}
module.exports = isPrototype;
/***/ }),
/* 201 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(29),
stubFalse = __webpack_require__(815);
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
module.exports = isBuffer;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(199)(module)))
/***/ }),
/* 202 */
/***/ (function(module, exports, __webpack_require__) {
var baseIsTypedArray = __webpack_require__(816),
baseUnary = __webpack_require__(353),
nodeUtil = __webpack_require__(817);
/* Node.js helper references. */
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
module.exports = isTypedArray;
/***/ }),
/* 203 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export getStyleProperty */
/* harmony export (immutable) */ __webpack_exports__["c"] = getStyleValue;
/* unused harmony export getVendorPrefixes */
/* unused harmony export getVendorPrefixedEventName */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return animationEndName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return transitionEndName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return supportTransition; });
/* harmony export (immutable) */ __webpack_exports__["e"] = mergeChildren;
/* harmony export (immutable) */ __webpack_exports__["b"] = cloneProps;
/* harmony export (immutable) */ __webpack_exports__["d"] = getTransitionName;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_rc_util_es_Children_toArray__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fbjs_lib_ExecutionEnvironment__ = __webpack_require__(866);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fbjs_lib_ExecutionEnvironment___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_fbjs_lib_ExecutionEnvironment__);
// =================== Style ====================
var stylePrefixes = ['-webkit-', '-moz-', '-o-', 'ms-', ''];
function getStyleProperty(node, name) {
// old ff need null, https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
var style = window.getComputedStyle(node, null);
var ret = '';
for (var i = 0; i < stylePrefixes.length; i++) {
ret = style.getPropertyValue(stylePrefixes[i] + name);
if (ret) {
break;
}
}
return ret;
}
function getStyleValue(node, name) {
return parseFloat(getStyleProperty(node, name));
}
// ================= Transition =================
// Event wrapper. Copy from react source code
function makePrefixMap(styleProp, eventName) {
var prefixes = {};
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
prefixes['Webkit' + styleProp] = 'webkit' + eventName;
prefixes['Moz' + styleProp] = 'moz' + eventName;
prefixes['ms' + styleProp] = 'MS' + eventName;
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
return prefixes;
}
function getVendorPrefixes(domSupport, win) {
var prefixes = {
animationend: makePrefixMap('Animation', 'AnimationEnd'),
transitionend: makePrefixMap('Transition', 'TransitionEnd')
};
if (domSupport) {
if (!('AnimationEvent' in win)) {
delete prefixes.animationend.animation;
}
if (!('TransitionEvent' in win)) {
delete prefixes.transitionend.transition;
}
}
return prefixes;
}
var vendorPrefixes = getVendorPrefixes(__WEBPACK_IMPORTED_MODULE_1_fbjs_lib_ExecutionEnvironment__["canUseDOM"], typeof window !== 'undefined' ? window : {});
var style = {};
if (__WEBPACK_IMPORTED_MODULE_1_fbjs_lib_ExecutionEnvironment__["canUseDOM"]) {
style = document.createElement('div').style;
}
var prefixedEventNames = {};
function getVendorPrefixedEventName(eventName) {
if (prefixedEventNames[eventName]) {
return prefixedEventNames[eventName];
}
var prefixMap = vendorPrefixes[eventName];
if (prefixMap) {
var stylePropList = Object.keys(prefixMap);
var len = stylePropList.length;
for (var i = 0; i < len; i += 1) {
var styleProp = stylePropList[i];
if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {
prefixedEventNames[eventName] = prefixMap[styleProp];
return prefixedEventNames[eventName];
}
}
}
return '';
}
var animationEndName = getVendorPrefixedEventName('animationend');
var transitionEndName = getVendorPrefixedEventName('transitionend');
var supportTransition = !!(animationEndName && transitionEndName);
// ==================== Node ====================
/**
* [Legacy] Find the same children in both prev & next list.
* Insert not find one before the find one, otherwise in the end. For example:
* - prev: [1,2,3]
* - next: [2,4]
* -> [1,2,4,3]
*/
function mergeChildren(prev, next) {
var prevList = Object(__WEBPACK_IMPORTED_MODULE_0_rc_util_es_Children_toArray__["a" /* default */])(prev);
var nextList = Object(__WEBPACK_IMPORTED_MODULE_0_rc_util_es_Children_toArray__["a" /* default */])(next);
// Skip if is single children
if (prevList.length === 1 && nextList.length === 1 && prevList[0].key === nextList[0].key) {
return nextList;
}
var mergeList = [];
var nextChildrenMap = {};
var missMatchChildrenList = [];
// Fill matched prev node into next node map
prevList.forEach(function (prevNode) {
if (prevNode && nextList.some(function (_ref) {
var key = _ref.key;
return key === prevNode.key;
})) {
if (missMatchChildrenList.length) {
nextChildrenMap[prevNode.key] = missMatchChildrenList;
missMatchChildrenList = [];
}
} else {
missMatchChildrenList.push(prevNode);
}
});
// Insert prev node before the matched next node
nextList.forEach(function (nextNode) {
if (nextNode && nextChildrenMap[nextNode.key]) {
mergeList = mergeList.concat(nextChildrenMap[nextNode.key]);
}
mergeList.push(nextNode);
});
mergeList = mergeList.concat(missMatchChildrenList);
return mergeList;
}
function cloneProps(props, propList) {
var newProps = {};
propList.forEach(function (prop) {
if (prop in props) {
newProps[prop] = props[prop];
}
});
return newProps;
}
function getTransitionName(transitionName, transitionType) {
if (!transitionName) return null;
if (typeof transitionName === 'object') {
var type = transitionType.replace(/-\w/g, function (match) {
return match[1].toUpperCase();
});
return transitionName[type];
}
return transitionName + '-' + transitionType;
}
/***/ }),
/* 204 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["p"] = warnOnlyTreeNode;
/* harmony export (immutable) */ __webpack_exports__["b"] = arrDel;
/* harmony export (immutable) */ __webpack_exports__["a"] = arrAdd;
/* harmony export (immutable) */ __webpack_exports__["o"] = posToArr;
/* harmony export (immutable) */ __webpack_exports__["l"] = getPosition;
/* unused harmony export isTreeNode */
/* harmony export (immutable) */ __webpack_exports__["k"] = getNodeChildren;
/* unused harmony export isCheckDisabled */
/* unused harmony export traverseTreeNodes */
/* harmony export (immutable) */ __webpack_exports__["m"] = mapChildren;
/* harmony export (immutable) */ __webpack_exports__["j"] = getDragNodesKeys;
/* harmony export (immutable) */ __webpack_exports__["c"] = calcDropPosition;
/* harmony export (immutable) */ __webpack_exports__["d"] = calcSelectedKeys;
/* harmony export (immutable) */ __webpack_exports__["g"] = convertDataToTree;
/* harmony export (immutable) */ __webpack_exports__["h"] = convertTreeToEntities;
/* harmony export (immutable) */ __webpack_exports__["n"] = parseCheckedKeys;
/* harmony export (immutable) */ __webpack_exports__["e"] = conductCheck;
/* harmony export (immutable) */ __webpack_exports__["f"] = conductExpandParent;
/* harmony export (immutable) */ __webpack_exports__["i"] = getDataAndAria;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_warning__ = __webpack_require__(83);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_warning__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__TreeNode__ = __webpack_require__(369);
var DRAG_SIDE_RANGE = 0.25;
var DRAG_MIN_GAP = 2;
var onlyTreeNodeWarned = false;
function warnOnlyTreeNode() {
if (onlyTreeNodeWarned) return;
onlyTreeNodeWarned = true;
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, 'Tree only accept TreeNode as children.');
}
function arrDel(list, value) {
var clone = list.slice();
var index = clone.indexOf(value);
if (index >= 0) {
clone.splice(index, 1);
}
return clone;
}
function arrAdd(list, value) {
var clone = list.slice();
if (clone.indexOf(value) === -1) {
clone.push(value);
}
return clone;
}
function posToArr(pos) {
return pos.split('-');
}
function getPosition(level, index) {
return level + '-' + index;
}
function isTreeNode(node) {
return node && node.type && node.type.isTreeNode;
}
function getNodeChildren(children) {
return Object(__WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__["a" /* default */])(children).filter(isTreeNode);
}
function isCheckDisabled(node) {
var _ref = node.props || {},
disabled = _ref.disabled,
disableCheckbox = _ref.disableCheckbox;
return !!(disabled || disableCheckbox);
}
function traverseTreeNodes(treeNodes, callback) {
function processNode(node, index, parent) {
var children = node ? node.props.children : treeNodes;
var pos = node ? getPosition(parent.pos, index) : 0;
// Filter children
var childList = getNodeChildren(children);
// Process node if is not root
if (node) {
var data = {
node: node,
index: index,
pos: pos,
key: node.key || pos,
parentPos: parent.node ? parent.pos : null
};
callback(data);
}
// Process children node
__WEBPACK_IMPORTED_MODULE_1_react__["Children"].forEach(childList, function (subNode, subIndex) {
processNode(subNode, subIndex, { node: node, pos: pos });
});
}
processNode(null);
}
/**
* Use `rc-util` `toArray` to get the children list which keeps the key.
* And return single node if children is only one(This can avoid `key` missing check).
*/
function mapChildren(children, func) {
var list = Object(__WEBPACK_IMPORTED_MODULE_2_rc_util_es_Children_toArray__["a" /* default */])(children).map(func);
if (list.length === 1) {
return list[0];
}
return list;
}
function getDragNodesKeys(treeNodes, node) {
var _node$props = node.props,
eventKey = _node$props.eventKey,
pos = _node$props.pos;
var dragNodesKeys = [];
traverseTreeNodes(treeNodes, function (_ref2) {
var key = _ref2.key;
dragNodesKeys.push(key);
});
dragNodesKeys.push(eventKey || pos);
return dragNodesKeys;
}
// Only used when drag, not affect SSR.
function calcDropPosition(event, treeNode) {
var clientY = event.clientY;
var _treeNode$selectHandl = treeNode.selectHandle.getBoundingClientRect(),
top = _treeNode$selectHandl.top,
bottom = _treeNode$selectHandl.bottom,
height = _treeNode$selectHandl.height;
var des = Math.max(height * DRAG_SIDE_RANGE, DRAG_MIN_GAP);
if (clientY <= top + des) {
return -1;
} else if (clientY >= bottom - des) {
return 1;
}
return 0;
}
/**
* Return selectedKeys according with multiple prop
* @param selectedKeys
* @param props
* @returns [string]
*/
function calcSelectedKeys(selectedKeys, props) {
if (!selectedKeys) return undefined;
var multiple = props.multiple;
if (multiple) {
return selectedKeys.slice();
}
if (selectedKeys.length) {
return [selectedKeys[0]];
}
return selectedKeys;
}
/**
* Since React internal will convert key to string,
* we need do this to avoid `checkStrictly` use number match
*/
function keyListToString(keyList) {
if (!keyList) return keyList;
return keyList.map(function (key) {
return String(key);
});
}
var internalProcessProps = function internalProcessProps(props) {
return props;
};
function convertDataToTree(treeData, processer) {
if (!treeData) return [];
var _ref3 = processer || {},
_ref3$processProps = _ref3.processProps,
processProps = _ref3$processProps === undefined ? internalProcessProps : _ref3$processProps;
var list = Array.isArray(treeData) ? treeData : [treeData];
return list.map(function (_ref4) {
var children = _ref4.children,
props = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_objectWithoutProperties___default()(_ref4, ['children']);
var childrenNodes = convertDataToTree(children, processer);
return __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement(
__WEBPACK_IMPORTED_MODULE_4__TreeNode__["a" /* default */],
processProps(props),
childrenNodes
);
});
}
// TODO: ========================= NEW LOGIC =========================
/**
* Calculate treeNodes entities. `processTreeEntity` is used for `rc-tree-select`
* @param treeNodes
* @param processTreeEntity User can customize the entity
*/
function convertTreeToEntities(treeNodes) {
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
initWrapper = _ref5.initWrapper,
processEntity = _ref5.processEntity,
onProcessFinished = _ref5.onProcessFinished;
var posEntities = {};
var keyEntities = {};
var wrapper = {
posEntities: posEntities,
keyEntities: keyEntities
};
if (initWrapper) {
wrapper = initWrapper(wrapper) || wrapper;
}
traverseTreeNodes(treeNodes, function (item) {
var node = item.node,
index = item.index,
pos = item.pos,
key = item.key,
parentPos = item.parentPos;
var entity = { node: node, index: index, key: key, pos: pos };
posEntities[pos] = entity;
keyEntities[key] = entity;
// Fill children
entity.parent = posEntities[parentPos];
if (entity.parent) {
entity.parent.children = entity.parent.children || [];
entity.parent.children.push(entity);
}
if (processEntity) {
processEntity(entity, wrapper);
}
});
if (onProcessFinished) {
onProcessFinished(wrapper);
}
return wrapper;
}
/**
* Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
*/
function parseCheckedKeys(keys) {
if (!keys) {
return null;
}
// Convert keys to object format
var keyProps = void 0;
if (Array.isArray(keys)) {
// [Legacy] Follow the api doc
keyProps = {
checkedKeys: keys,
halfCheckedKeys: undefined
};
} else if (typeof keys === 'object') {
keyProps = {
checkedKeys: keys.checked || undefined,
halfCheckedKeys: keys.halfChecked || undefined
};
} else {
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, '`checkedKeys` is not an array or an object');
return null;
}
keyProps.checkedKeys = keyListToString(keyProps.checkedKeys);
keyProps.halfCheckedKeys = keyListToString(keyProps.halfCheckedKeys);
return keyProps;
}
/**
* Conduct check state by the keyList. It will conduct up & from the provided key.
* If the conduct path reach the disabled or already checked / unchecked node will stop conduct.
* @param keyList list of keys
* @param isCheck is check the node or not
* @param keyEntities parsed by `convertTreeToEntities` function in Tree
* @param checkStatus Can pass current checked status for process (usually for uncheck operation)
* @returns {{checkedKeys: [], halfCheckedKeys: []}}
*/
function conductCheck(keyList, isCheck, keyEntities) {
var checkStatus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var checkedKeys = {};
var halfCheckedKeys = {}; // Record the key has some child checked (include child half checked)
(checkStatus.checkedKeys || []).forEach(function (key) {
checkedKeys[key] = true;
});
(checkStatus.halfCheckedKeys || []).forEach(function (key) {
halfCheckedKeys[key] = true;
});
// Conduct up
function conductUp(key) {
if (checkedKeys[key] === isCheck) return;
var entity = keyEntities[key];
if (!entity) return;
var children = entity.children,
parent = entity.parent,
node = entity.node;
if (isCheckDisabled(node)) return;
// Check child node checked status
var everyChildChecked = true;
var someChildChecked = false; // Child checked or half checked
(children || []).filter(function (child) {
return !isCheckDisabled(child.node);
}).forEach(function (_ref6) {
var childKey = _ref6.key;
var childChecked = checkedKeys[childKey];
var childHalfChecked = halfCheckedKeys[childKey];
if (childChecked || childHalfChecked) someChildChecked = true;
if (!childChecked) everyChildChecked = false;
});
// Update checked status
if (isCheck) {
checkedKeys[key] = everyChildChecked;
} else {
checkedKeys[key] = false;
}
halfCheckedKeys[key] = someChildChecked;
if (parent) {
conductUp(parent.key);
}
}
// Conduct down
function conductDown(key) {
if (checkedKeys[key] === isCheck) return;
var entity = keyEntities[key];
if (!entity) return;
var children = entity.children,
node = entity.node;
if (isCheckDisabled(node)) return;
checkedKeys[key] = isCheck;
(children || []).forEach(function (child) {
conductDown(child.key);
});
}
function conduct(key) {
var entity = keyEntities[key];
if (!entity) {
__WEBPACK_IMPORTED_MODULE_3_warning___default()(false, '\'' + key + '\' does not exist in the tree.');
return;
}
var children = entity.children,
parent = entity.parent,
node = entity.node;
checkedKeys[key] = isCheck;
if (isCheckDisabled(node)) return;
// Conduct down
(children || []).filter(function (child) {
return !isCheckDisabled(child.node);
}).forEach(function (child) {
conductDown(child.key);
});
// Conduct up
if (parent) {
conductUp(parent.key);
}
}
(keyList || []).forEach(function (key) {
conduct(key);
});
var checkedKeyList = [];
var halfCheckedKeyList = [];
// Fill checked list
Object.keys(checkedKeys).forEach(function (key) {
if (checkedKeys[key]) {
checkedKeyList.push(key);
}
});
// Fill half checked list
Object.keys(halfCheckedKeys).forEach(function (key) {
if (!checkedKeys[key] && halfCheckedKeys[key]) {
halfCheckedKeyList.push(key);
}
});
return {
checkedKeys: checkedKeyList,
halfCheckedKeys: halfCheckedKeyList
};
}
/**
* If user use `autoExpandParent` we should get the list of parent node
* @param keyList
* @param keyEntities
*/
function conductExpandParent(keyList, keyEntities) {
var expandedKeys = {};
function conductUp(key) {
if (expandedKeys[key]) return;
var entity = keyEntities[key];
if (!entity) return;
expandedKeys[key] = true;
var parent = entity.parent,
node = entity.node;
if (isCheckDisabled(node)) return;
if (parent) {
conductUp(parent.key);
}
}
(keyList || []).forEach(function (key) {
conductUp(key);
});
return Object.keys(expandedKeys);
}
/**
* Returns only the data- and aria- key/value pairs
* @param {object} props
*/
function getDataAndAria(props) {
return Object.keys(props).reduce(function (prev, key) {
if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
prev[key] = props[key];
}
return prev;
}, {});
}
/***/ }),
/* 205 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rc_tree__ = __webpack_require__(371);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__propTypes__ = __webpack_require__(372);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
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; }
/**
* SelectNode wrapped the tree node.
* Let's use SelectNode instead of TreeNode
* since TreeNode is so confuse here.
*/
var SelectNode = function SelectNode(props) {
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_1_rc_tree__["a" /* TreeNode */], props);
};
SelectNode.propTypes = _objectSpread({}, __WEBPACK_IMPORTED_MODULE_1_rc_tree__["a" /* TreeNode */].propTypes, {
value: __WEBPACK_IMPORTED_MODULE_2__propTypes__["a" /* valueProp */]
}); // Let Tree trade as TreeNode to reuse this for performance saving.
SelectNode.isTreeNode = 1;
/* harmony default export */ __webpack_exports__["a"] = (SelectNode);
/***/ }),
/* 206 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SHOW_ALL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return SHOW_PARENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SHOW_CHILD; });
var SHOW_ALL = 'SHOW_ALL';
var SHOW_PARENT = 'SHOW_PARENT';
var SHOW_CHILD = 'SHOW_CHILD';
/***/ }),
/* 207 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return selectorPropTypes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return selectorContextTypes; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util__ = __webpack_require__(47);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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; }
/**
* Input Box is in different position for different mode.
* This not the same design as `Select` cause it's followed by antd 0.x `Select`.
* We will not follow the new design immediately since antd 3.x is already released.
*
* So this file named as Selector to avoid confuse.
*/
var selectorPropTypes = {
prefixCls: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
className: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
style: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object,
open: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
selectorValueList: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.array,
allowClear: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
showArrow: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
onClick: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
onBlur: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
onFocus: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
removeSelected: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
// Pass by component
ariaId: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
inputIcon: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func]),
clearIcon: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func])
};
var selectorContextTypes = {
onSelectorFocus: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
onSelectorBlur: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
onSelectorKeyDown: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
onSelectorClear: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired
};
/* harmony default export */ __webpack_exports__["a"] = (function (modeName) {
var BaseSelector =
/*#__PURE__*/
function (_React$Component) {
_inherits(BaseSelector, _React$Component);
function BaseSelector() {
var _this;
_classCallCheck(this, BaseSelector);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BaseSelector).call(this));
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
var _this$props = _this.props,
onFocus = _this$props.onFocus,
focused = _this$props.focused;
var onSelectorFocus = _this.context.rcTreeSelect.onSelectorFocus;
if (!focused) {
onSelectorFocus();
}
if (onFocus) {
onFocus.apply(void 0, arguments);
}
});
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
var onBlur = _this.props.onBlur;
var onSelectorBlur = _this.context.rcTreeSelect.onSelectorBlur; // TODO: Not trigger when is inner component get focused
onSelectorBlur();
if (onBlur) {
onBlur.apply(void 0, arguments);
}
});
_defineProperty(_assertThisInitialized(_this), "focus", function () {
_this.domRef.current.focus();
});
_defineProperty(_assertThisInitialized(_this), "blur", function () {
_this.domRef.current.focus();
});
_this.domRef = Object(__WEBPACK_IMPORTED_MODULE_4__util__["g" /* createRef */])();
return _this;
}
_createClass(BaseSelector, [{
key: "renderClear",
value: function renderClear() {
var _this$props2 = this.props,
prefixCls = _this$props2.prefixCls,
allowClear = _this$props2.allowClear,
selectorValueList = _this$props2.selectorValueList,
clearIcon = _this$props2.clearIcon;
var onSelectorClear = this.context.rcTreeSelect.onSelectorClear;
if (!allowClear || !selectorValueList.length || !selectorValueList[0].value) {
return null;
}
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", {
key: "clear",
className: "".concat(prefixCls, "-selection__clear"),
onClick: onSelectorClear
}, typeof clearIcon === 'function' ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(clearIcon, _objectSpread({}, this.props)) : clearIcon);
}
}, {
key: "renderArrow",
value: function renderArrow() {
var _this$props3 = this.props,
prefixCls = _this$props3.prefixCls,
showArrow = _this$props3.showArrow,
inputIcon = _this$props3.inputIcon;
if (!showArrow) {
return null;
}
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", {
key: "arrow",
className: "".concat(prefixCls, "-arrow"),
style: {
outline: 'none'
}
}, typeof inputIcon === 'function' ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(inputIcon, _objectSpread({}, this.props)) : inputIcon);
}
}, {
key: "render",
value: function render() {
var _classNames;
var _this$props4 = this.props,
prefixCls = _this$props4.prefixCls,
className = _this$props4.className,
style = _this$props4.style,
open = _this$props4.open,
focused = _this$props4.focused,
disabled = _this$props4.disabled,
allowClear = _this$props4.allowClear,
onClick = _this$props4.onClick,
ariaId = _this$props4.ariaId,
renderSelection = _this$props4.renderSelection,
renderPlaceholder = _this$props4.renderPlaceholder,
tabIndex = _this$props4.tabIndex;
var onSelectorKeyDown = this.context.rcTreeSelect.onSelectorKeyDown;
var myTabIndex = tabIndex;
if (disabled) {
myTabIndex = null;
}
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", {
style: style,
onClick: onClick,
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()(className, prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-open"), open), _defineProperty(_classNames, "".concat(prefixCls, "-focused"), open || focused), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-enabled"), !disabled), _defineProperty(_classNames, "".concat(prefixCls, "-allow-clear"), allowClear), _classNames)),
ref: this.domRef,
role: "combobox",
"aria-expanded": open,
"aria-owns": open ? ariaId : undefined,
"aria-controls": open ? ariaId : undefined,
"aria-haspopup": "listbox",
"aria-disabled": disabled,
tabIndex: myTabIndex,
onFocus: this.onFocus,
onBlur: this.onBlur,
onKeyDown: onSelectorKeyDown
}, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", {
key: "selection",
className: __WEBPACK_IMPORTED_MODULE_2_classnames___default()("".concat(prefixCls, "-selection"), "".concat(prefixCls, "-selection--").concat(modeName))
}, renderSelection(), this.renderClear(), this.renderArrow(), renderPlaceholder && renderPlaceholder()));
}
}]);
return BaseSelector;
}(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component);
_defineProperty(BaseSelector, "propTypes", _objectSpread({}, selectorPropTypes, {
// Pass by HOC
renderSelection: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
renderPlaceholder: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
tabIndex: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.number
}));
_defineProperty(BaseSelector, "contextTypes", {
rcTreeSelect: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.shape(_objectSpread({}, selectorContextTypes))
});
_defineProperty(BaseSelector, "defaultProps", {
tabIndex: 0
});
Object(__WEBPACK_IMPORTED_MODULE_3_react_lifecycles_compat__["polyfill"])(BaseSelector);
return BaseSelector;
});
/***/ }),
/* 208 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return popupContextTypes; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rc_tree__ = __webpack_require__(371);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util__ = __webpack_require__(47);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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; }
var popupContextTypes = {
onPopupKeyDown: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
onTreeNodeSelect: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired,
onTreeNodeCheck: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func.isRequired
};
var BasePopup =
/*#__PURE__*/
function (_React$Component) {
_inherits(BasePopup, _React$Component);
function BasePopup(props) {
var _this;
_classCallCheck(this, BasePopup);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BasePopup).call(this));
_defineProperty(_assertThisInitialized(_this), "onTreeExpand", function (expandedKeyList) {
var _this$props = _this.props,
treeExpandedKeys = _this$props.treeExpandedKeys,
onTreeExpand = _this$props.onTreeExpand,
onTreeExpanded = _this$props.onTreeExpanded; // Set uncontrolled state
if (!treeExpandedKeys) {
_this.setState({
expandedKeyList: expandedKeyList
}, onTreeExpanded);
}
if (onTreeExpand) {
onTreeExpand(expandedKeyList);
}
});
_defineProperty(_assertThisInitialized(_this), "onLoad", function (loadedKeys) {
_this.setState({
loadedKeys: loadedKeys
});
});
_defineProperty(_assertThisInitialized(_this), "getTree", function () {
return _this.treeRef.current;
});
_defineProperty(_assertThisInitialized(_this), "getLoadData", function () {
var _this$props2 = _this.props,
loadData = _this$props2.loadData,
upperSearchValue = _this$props2.upperSearchValue;
if (upperSearchValue) return null;
return loadData;
});
_defineProperty(_assertThisInitialized(_this), "filterTreeNode", function (treeNode) {
var _this$props3 = _this.props,
upperSearchValue = _this$props3.upperSearchValue,
treeNodeFilterProp = _this$props3.treeNodeFilterProp;
var filterVal = treeNode.props[treeNodeFilterProp];
if (typeof filterVal === 'string') {
return upperSearchValue && filterVal.toUpperCase().indexOf(upperSearchValue) !== -1;
}
return false;
});
_defineProperty(_assertThisInitialized(_this), "renderNotFound", function () {
var _this$props4 = _this.props,
prefixCls = _this$props4.prefixCls,
notFoundContent = _this$props4.notFoundContent;
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", {
className: "".concat(prefixCls, "-not-found")
}, notFoundContent);
});
var treeDefaultExpandAll = props.treeDefaultExpandAll,
treeDefaultExpandedKeys = props.treeDefaultExpandedKeys,
keyEntities = props.keyEntities; // TODO: make `expandedKeyList` control
var _expandedKeyList = treeDefaultExpandedKeys;
if (treeDefaultExpandAll) {
_expandedKeyList = Object.keys(keyEntities);
}
_this.state = {
keyList: [],
expandedKeyList: _expandedKeyList,
// Cache `expandedKeyList` when tree is in filter. This is used in `getDerivedStateFromProps`
cachedExpandedKeyList: [],
// eslint-disable-line react/no-unused-state
loadedKeys: []
};
_this.treeRef = Object(__WEBPACK_IMPORTED_MODULE_4__util__["g" /* createRef */])();
return _this;
}
_createClass(BasePopup, [{
key: "render",
value: function render() {
var _this$state = this.state,
keyList = _this$state.keyList,
expandedKeyList = _this$state.expandedKeyList,
loadedKeys = _this$state.loadedKeys;
var _this$props5 = this.props,
prefixCls = _this$props5.prefixCls,
treeNodes = _this$props5.treeNodes,
filteredTreeNodes = _this$props5.filteredTreeNodes,
treeIcon = _this$props5.treeIcon,
treeLine = _this$props5.treeLine,
treeCheckable = _this$props5.treeCheckable,
treeCheckStrictly = _this$props5.treeCheckStrictly,
multiple = _this$props5.multiple,
ariaId = _this$props5.ariaId,
renderSearch = _this$props5.renderSearch,
switcherIcon = _this$props5.switcherIcon,
searchHalfCheckedKeys = _this$props5.searchHalfCheckedKeys;
var _this$context$rcTreeS = this.context.rcTreeSelect,
onPopupKeyDown = _this$context$rcTreeS.onPopupKeyDown,
onTreeNodeSelect = _this$context$rcTreeS.onTreeNodeSelect,
onTreeNodeCheck = _this$context$rcTreeS.onTreeNodeCheck;
var loadData = this.getLoadData();
var treeProps = {};
if (treeCheckable) {
treeProps.checkedKeys = keyList;
} else {
treeProps.selectedKeys = keyList;
}
var $notFound;
var $treeNodes;
if (filteredTreeNodes) {
if (filteredTreeNodes.length) {
treeProps.checkStrictly = true;
$treeNodes = filteredTreeNodes; // Fill halfCheckedKeys
if (treeCheckable && !treeCheckStrictly) {
treeProps.checkedKeys = {
checked: keyList,
halfChecked: searchHalfCheckedKeys
};
}
} else {
$notFound = this.renderNotFound();
}
} else if (!treeNodes || !treeNodes.length) {
$notFound = this.renderNotFound();
} else {
$treeNodes = treeNodes;
}
var $tree;
if ($notFound) {
$tree = $notFound;
} else {
$tree = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_3_rc_tree__["b" /* default */], _extends({
ref: this.treeRef,
prefixCls: "".concat(prefixCls, "-tree"),
showIcon: treeIcon,
showLine: treeLine,
selectable: !treeCheckable,
checkable: treeCheckable,
checkStrictly: treeCheckStrictly,
multiple: multiple,
loadData: loadData,
loadedKeys: loadedKeys,
expandedKeys: expandedKeyList,
filterTreeNode: this.filterTreeNode,
onSelect: onTreeNodeSelect,
onCheck: onTreeNodeCheck,
onExpand: this.onTreeExpand,
onLoad: this.onLoad,
switcherIcon: switcherIcon
}, treeProps), $treeNodes);
}
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div", {
role: "listbox",
id: ariaId,
onKeyDown: onPopupKeyDown,
tabIndex: -1
}, renderSearch ? renderSearch() : null, $tree);
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(nextProps, prevState) {
var _ref = prevState || {},
_ref$prevProps = _ref.prevProps,
prevProps = _ref$prevProps === void 0 ? {} : _ref$prevProps,
loadedKeys = _ref.loadedKeys,
expandedKeyList = _ref.expandedKeyList,
cachedExpandedKeyList = _ref.cachedExpandedKeyList;
var valueList = nextProps.valueList,
valueEntities = nextProps.valueEntities,
keyEntities = nextProps.keyEntities,
treeExpandedKeys = nextProps.treeExpandedKeys,
filteredTreeNodes = nextProps.filteredTreeNodes,
upperSearchValue = nextProps.upperSearchValue;
var newState = {
prevProps: nextProps
}; // Check value update
if (valueList !== prevProps.valueList) {
newState.keyList = valueList.map(function (_ref2) {
var value = _ref2.value;
return valueEntities[value];
}).filter(function (entity) {
return entity;
}).map(function (_ref3) {
var key = _ref3.key;
return key;
});
} // Show all when tree is in filter mode
if (!treeExpandedKeys && filteredTreeNodes && filteredTreeNodes.length && filteredTreeNodes !== prevProps.filteredTreeNodes) {
newState.expandedKeyList = Object.keys(keyEntities);
} // Cache `expandedKeyList` when filter set
if (upperSearchValue && !prevProps.upperSearchValue) {
newState.cachedExpandedKeyList = expandedKeyList;
} else if (!upperSearchValue && prevProps.upperSearchValue && !treeExpandedKeys) {
newState.expandedKeyList = cachedExpandedKeyList || [];
newState.cachedExpandedKeyList = [];
} // Use expandedKeys if provided
if (prevProps.treeExpandedKeys !== treeExpandedKeys) {
newState.expandedKeyList = treeExpandedKeys;
} // Clean loadedKeys if key not exist in keyEntities anymore
if (nextProps.loadData) {
newState.loadedKeys = loadedKeys.filter(function (key) {
return key in keyEntities;
});
}
return newState;
}
}]);
return BasePopup;
}(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component);
_defineProperty(BasePopup, "propTypes", {
prefixCls: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
upperSearchValue: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
valueList: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.array,
searchHalfCheckedKeys: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.array,
valueEntities: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object,
keyEntities: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object,
treeIcon: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
treeLine: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
treeNodeFilterProp: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
treeCheckable: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node]),
treeCheckStrictly: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
treeDefaultExpandAll: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
treeDefaultExpandedKeys: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.array,
treeExpandedKeys: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.array,
loadData: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
multiple: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool,
onTreeExpand: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
treeNodes: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node,
filteredTreeNodes: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node,
notFoundContent: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node,
ariaId: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string,
switcherIcon: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func]),
// HOC
renderSearch: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func,
onTreeExpanded: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func
});
_defineProperty(BasePopup, "contextTypes", {
rcTreeSelect: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.shape(_objectSpread({}, popupContextTypes))
});
Object(__WEBPACK_IMPORTED_MODULE_2_react_lifecycles_compat__["polyfill"])(BasePopup);
/* harmony default export */ __webpack_exports__["a"] = (BasePopup);
/***/ }),
/* 209 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_classnames__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_classnames__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_react_lifecycles_compat__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rc_util_es_Children_toArray__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_copy_to_clipboard__ = __webpack_require__(889);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_copy_to_clipboard___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_copy_to_clipboard__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_omit_js__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__config_provider__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__locale_provider_LocaleReceiver__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_warning__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_transButton__ = __webpack_require__(891);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_resizeObserver__ = __webpack_require__(276);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__util_raf__ = __webpack_require__(274);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_styleChecker__ = __webpack_require__(289);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__icon__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__tooltip__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Typography__ = __webpack_require__(374);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Editable__ = __webpack_require__(892);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__util__ = __webpack_require__(893);
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}
return t;
};
var isLineClampSupport = Object(__WEBPACK_IMPORTED_MODULE_12__util_styleChecker__["a" /* default */])('webkitLineClamp');
var isTextOverflowSupport = Object(__WEBPACK_IMPORTED_MODULE_12__util_styleChecker__["a" /* default */])('textOverflow');
function wrapperDecorations(_ref, content) {
var mark = _ref.mark,
code = _ref.code,
underline = _ref.underline,
del = _ref["delete"],
strong = _ref.strong;
var currentContent = content;
function wrap(needed, tag) {
if (!needed) return;
currentContent = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](tag, {
children: currentContent
});
}
wrap(strong, 'strong');
wrap(underline, 'u');
wrap(del, 'del');
wrap(code, 'code');
wrap(mark, 'mark');
return currentContent;
}
var ELLIPSIS_STR = '...';
var Base =
/*#__PURE__*/
function (_React$Component) {
_inherits(Base, _React$Component);
function Base() {
var _this;
_classCallCheck(this, Base);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Base).apply(this, arguments));
_this.state = {
edit: false,
copied: false,
ellipsisText: '',
ellipsisContent: null,
isEllipsis: false,
expanded: false,
clientRendered: false
}; // =============== Expend ===============
_this.onExpandClick = function () {
var _this$getEllipsis = _this.getEllipsis(),
onExpand = _this$getEllipsis.onExpand;
_this.setState({
expanded: true
});
if (onExpand) {
onExpand();
}
}; // ================ Edit ================
_this.onEditClick = function () {
_this.triggerEdit(true);
};
_this.onEditChange = function (value) {
var _this$getEditable = _this.getEditable(),
onChange = _this$getEditable.onChange;
if (onChange) {
onChange(value);
}
_this.triggerEdit(false);
};
_this.onEditCancel = function () {
_this.triggerEdit(false);
}; // ================ Copy ================
_this.onCopyClick = function () {
var _this$props = _this.props,
children = _this$props.children,
copyable = _this$props.copyable;
var copyConfig = _extends({}, _typeof(copyable) === 'object' ? copyable : null);
if (copyConfig.text === undefined) {
copyConfig.text = String(children);
}
__WEBPACK_IMPORTED_MODULE_4_copy_to_clipboard___default()(copyConfig.text || '');
_this.setState({
copied: true
}, function () {
if (copyConfig.onCopy) {
copyConfig.onCopy();
}
_this.copyId = window.setTimeout(function () {
_this.setState({
copied: false
});
}, 3000);
});
};
_this.setContentRef = function (node) {
_this.content = node;
};
_this.setEditRef = function (node) {
_this.editIcon = node;
};
_this.triggerEdit = function (edit) {
var _this$getEditable2 = _this.getEditable(),
onStart = _this$getEditable2.onStart;
if (edit && onStart) {
onStart();
}
_this.setState({
edit: edit
}, function () {
if (!edit && _this.editIcon) {
_this.editIcon.focus();
}
});
}; // ============== Ellipsis ==============
_this.resizeOnNextFrame = function () {
__WEBPACK_IMPORTED_MODULE_11__util_raf__["a" /* default */].cancel(_this.rafId);
_this.rafId = Object(__WEBPACK_IMPORTED_MODULE_11__util_raf__["a" /* default */])(function () {
// Do not bind `syncEllipsis`. It need for test usage on prototype
_this.syncEllipsis();
});
};
return _this;
}
_createClass(Base, [{
key: "componentDidMount",
value: function componentDidMount() {
this.setState({
clientRendered: true
});
this.resizeOnNextFrame();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
var ellipsis = this.getEllipsis();
var prevEllipsis = this.getEllipsis(prevProps);
if (this.props.children !== prevProps.children || ellipsis.rows !== prevEllipsis.rows) {
this.resizeOnNextFrame();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
window.clearTimeout(this.copyId);
__WEBPACK_IMPORTED_MODULE_11__util_raf__["a" /* default */].cancel(this.rafId);
}
}, {
key: "getEditable",
value: function getEditable(props) {
var edit = this.state.edit;
var _ref2 = props || this.props,
editable = _ref2.editable;
if (!editable) return {
editing: edit
};
return _extends({
editing: edit
}, _typeof(editable) === 'object' ? editable : null);
}
}, {
key: "getEllipsis",
value: function getEllipsis(props) {
var _ref3 = props || this.props,
ellipsis = _ref3.ellipsis;
if (!ellipsis) return {};
return _extends({
rows: 1,
expandable: false
}, _typeof(ellipsis) === 'object' ? ellipsis : null);
}
}, {
key: "canUseCSSEllipsis",
value: function canUseCSSEllipsis() {
var clientRendered = this.state.clientRendered;
var _this$props2 = this.props,
editable = _this$props2.editable,
copyable = _this$props2.copyable;
var _this$getEllipsis2 = this.getEllipsis(),
rows = _this$getEllipsis2.rows,
expandable = _this$getEllipsis2.expandable; // Can't use css ellipsis since we need to provide the place for button
if (editable || copyable || expandable || !clientRendered) {
return false;
}
if (rows === 1) {
return isTextOverflowSupport;
}
return isLineClampSupport;
}
}, {
key: "syncEllipsis",
value: function syncEllipsis() {
var _this$state = this.state,
ellipsisText = _this$state.ellipsisText,
isEllipsis = _this$state.isEllipsis,
expanded = _this$state.expanded;
var _this$getEllipsis3 = this.getEllipsis(),
rows = _this$getEllipsis3.rows;
var children = this.props.children;
if (!rows || rows < 0 || !this.content || expanded) return; // Do not measure if css already support ellipsis
if (this.canUseCSSEllipsis()) return;
Object(__WEBPACK_IMPORTED_MODULE_8__util_warning__["a" /* default */])(Object(__WEBPACK_IMPORTED_MODULE_3_rc_util_es_Children_toArray__["a" /* default */])(children).every(function (child) {
return typeof child === 'string';
}), 'Typography', '`ellipsis` should use string as children only.');
var _measure = Object(__WEBPACK_IMPORTED_MODULE_17__util__["a" /* measure */])(this.content, rows, children, this.renderOperations(true), ELLIPSIS_STR),
content = _measure.content,
text = _measure.text,
ellipsis = _measure.ellipsis;
if (ellipsisText !== text || isEllipsis !== ellipsis) {
this.setState({
ellipsisText: text,
ellipsisContent: content,
isEllipsis: ellipsis
});
}
}
}, {
key: "renderExpand",
value: function renderExpand(forceRender) {
var _this$getEllipsis4 = this.getEllipsis(),
expandable = _this$getEllipsis4.expandable;
var prefixCls = this.props.prefixCls;
var _this$state2 = this.state,
expanded = _this$state2.expanded,
isEllipsis = _this$state2.isEllipsis;
if (!expandable) return null; // force render expand icon for measure usage or it will cause dead loop
if (!forceRender && (expanded || !isEllipsis)) return null;
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("a", {
key: "expand",
className: "".concat(prefixCls, "-expand"),
onClick: this.onExpandClick,
"aria-label": this.expandStr
}, this.expandStr);
}
}, {
key: "renderEdit",
value: function renderEdit() {
var _this$props3 = this.props,
editable = _this$props3.editable,
prefixCls = _this$props3.prefixCls;
if (!editable) return;
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_14__tooltip__["a" /* default */], {
key: "edit",
title: this.editStr
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_9__util_transButton__["a" /* default */], {
ref: this.setEditRef,
className: "".concat(prefixCls, "-edit"),
onClick: this.onEditClick,
"aria-label": this.editStr
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_13__icon__["a" /* default */], {
role: "button",
type: "edit"
})));
}
}, {
key: "renderCopy",
value: function renderCopy() {
var copied = this.state.copied;
var _this$props4 = this.props,
copyable = _this$props4.copyable,
prefixCls = _this$props4.prefixCls;
if (!copyable) return;
var title = copied ? this.copiedStr : this.copyStr;
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_14__tooltip__["a" /* default */], {
key: "copy",
title: title
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_9__util_transButton__["a" /* default */], {
className: __WEBPACK_IMPORTED_MODULE_1_classnames___default()("".concat(prefixCls, "-copy"), copied && "".concat(prefixCls, "-copy-success")),
onClick: this.onCopyClick,
"aria-label": title
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_13__icon__["a" /* default */], {
role: "button",
type: copied ? 'check' : 'copy'
})));
}
}, {
key: "renderEditInput",
value: function renderEditInput() {
var _this$props5 = this.props,
children = _this$props5.children,
prefixCls = _this$props5.prefixCls;
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_16__Editable__["a" /* default */], {
value: typeof children === 'string' ? children : '',
onSave: this.onEditChange,
onCancel: this.onEditCancel,
prefixCls: prefixCls
});
}
}, {
key: "renderOperations",
value: function renderOperations(forceRenderExpanded) {
return [this.renderExpand(forceRenderExpanded), this.renderEdit(), this.renderCopy()].filter(function (node) {
return node;
});
}
}, {
key: "renderContent",
value: function renderContent() {
var _this2 = this;
var _this$state3 = this.state,
ellipsisContent = _this$state3.ellipsisContent,
isEllipsis = _this$state3.isEllipsis,
expanded = _this$state3.expanded;
var _a = this.props,
component = _a.component,
children = _a.children,
className = _a.className,
prefixCls = _a.prefixCls,
type = _a.type,
disabled = _a.disabled,
style = _a.style,
restProps = __rest(_a, ["component", "children", "className", "prefixCls", "type", "disabled", "style"]);
var _this$getEllipsis5 = this.getEllipsis(),
rows = _this$getEllipsis5.rows;
var textProps = Object(__WEBPACK_IMPORTED_MODULE_5_omit_js__["a" /* default */])(restProps, ['prefixCls', 'editable', 'copyable', 'ellipsis', 'mark', 'underline', 'mark', 'code', 'delete', 'underline', 'strong'].concat(_toConsumableArray(__WEBPACK_IMPORTED_MODULE_6__config_provider__["b" /* configConsumerProps */])));
var cssEllipsis = this.canUseCSSEllipsis();
var cssTextOverflow = rows === 1 && cssEllipsis;
var cssLineClamp = rows && rows > 1 && cssEllipsis;
var textNode = children;
var ariaLabel = null; // Only use js ellipsis when css ellipsis not support
if (rows && isEllipsis && !expanded && !cssEllipsis) {
ariaLabel = String(children); // We move full content to outer element to avoid repeat read the content by accessibility
textNode = __WEBPACK_IMPORTED_MODULE_0_react__["createElement"]("span", {
title: String(children),
"aria-hidden": "true"
}, ellipsisContent, ELLIPSIS_STR);
}
textNode = wrapperDecorations(this.props, textNode);
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_7__locale_provider_LocaleReceiver__["a" /* default */], {
componentName: "Text"
}, function (_ref4) {
var _classNames;
var edit = _ref4.edit,
copyStr = _ref4.copy,
copied = _ref4.copied,
expand = _ref4.expand;
_this2.editStr = edit;
_this2.copyStr = copyStr;
_this2.copiedStr = copied;
_this2.expandStr = expand;
return __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_10__util_resizeObserver__["a" /* default */], {
onResize: _this2.resizeOnNextFrame,
disabled: !rows
}, __WEBPACK_IMPORTED_MODULE_0_react__["createElement"](__WEBPACK_IMPORTED_MODULE_15__Typography__["a" /* default */], _extends({
className: __WEBPACK_IMPORTED_MODULE_1_classnames___default()(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), type), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis"), rows), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis-single-line"), cssTextOverflow), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis-multiple-line"), cssLineClamp), _classNames)),
style: _extends({}, style, {
WebkitLineClamp: cssLineClamp ? rows : null
}),
component: component,
setContentRef: _this2.setContentRef,
"aria-label": ariaLabel
}, textProps), textNode, _this2.renderOperations()));
});
}
}, {
key: "render",
value: function render() {
var _this$getEditable3 = this.getEditable(),
editing = _this$getEditable3.editing;
if (editing) {
return this.renderEditInput();
}
return this.renderContent();
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(nextProps) {
var children = nextProps.children,
editable = nextProps.editable;
Object(__WEBPACK_IMPORTED_MODULE_8__util_warning__["a" /* default */])(!editable || typeof children === 'string', 'Typography', 'When `editable` is enabled, the `children` should use string.');
return {};
}
}]);
return Base;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);
Base.defaultProps = {
children: ''
};
Object(__WEBPACK_IMPORTED_MODULE_2_react_lifecycles_compat__["polyfill"])(Base);
/* harmony default export */ __webpack_exports__["a"] = (Object(__WEBPACK_IMPORTED_MODULE_6__config_provider__["c" /* withConfigConsumer */])({
prefixCls: 'typography'
})(Base));
/***/ }),
/* 210 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ContentState
* @format
*
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var BlockMapBuilder = __webpack_require__(104);
var CharacterMetadata = __webpack_require__(36);
var ContentBlock = __webpack_require__(72);
var ContentBlockNode = __webpack_require__(37);
var DraftEntity = __webpack_require__(140);
var DraftFeatureFlags = __webpack_require__(61);
var Immutable = __webpack_require__(14);
var SelectionState = __webpack_require__(88);
var generateRandomKey = __webpack_require__(51);
var sanitizeDraftText = __webpack_require__(211);
var List = Immutable.List,
Record = Immutable.Record,
Repeat = Immutable.Repeat;
var experimentalTreeDataSupport = DraftFeatureFlags.draft_tree_data_support;
var defaultRecord = {
entityMap: null,
blockMap: null,
selectionBefore: null,
selectionAfter: null
};
var ContentBlockNodeRecord = experimentalTreeDataSupport ? ContentBlockNode : ContentBlock;
var ContentStateRecord = Record(defaultRecord);
var ContentState = function (_ContentStateRecord) {
_inherits(ContentState, _ContentStateRecord);
function ContentState() {
_classCallCheck(this, ContentState);
return _possibleConstructorReturn(this, _ContentStateRecord.apply(this, arguments));
}
ContentState.prototype.getEntityMap = function getEntityMap() {
// TODO: update this when we fully remove DraftEntity
return DraftEntity;
};
ContentState.prototype.getBlockMap = function getBlockMap() {
return this.get('blockMap');
};
ContentState.prototype.getSelectionBefore = function getSelectionBefore() {
return this.get('selectionBefore');
};
ContentState.prototype.getSelectionAfter = function getSelectionAfter() {
return this.get('selectionAfter');
};
ContentState.prototype.getBlockForKey = function getBlockForKey(key) {
var block = this.getBlockMap().get(key);
return block;
};
ContentState.prototype.getKeyBefore = function getKeyBefore(key) {
return this.getBlockMap().reverse().keySeq().skipUntil(function (v) {
return v === key;
}).skip(1).first();
};
ContentState.prototype.getKeyAfter = function getKeyAfter(key) {
return this.getBlockMap().keySeq().skipUntil(function (v) {
return v === key;
}).skip(1).first();
};
ContentState.prototype.getBlockAfter = function getBlockAfter(key) {
return this.getBlockMap().skipUntil(function (_, k) {
return k === key;
}).skip(1).first();
};
ContentState.prototype.getBlockBefore = function getBlockBefore(key) {
return this.getBlockMap().reverse().skipUntil(function (_, k) {
return k === key;
}).skip(1).first();
};
ContentState.prototype.getBlocksAsArray = function getBlocksAsArray() {
return this.getBlockMap().toArray();
};
ContentState.prototype.getFirstBlock = function getFirstBlock() {
return this.getBlockMap().first();
};
ContentState.prototype.getLastBlock = function getLastBlock() {
return this.getBlockMap().last();
};
ContentState.prototype.getPlainText = function getPlainText(delimiter) {
return this.getBlockMap().map(function (block) {
return block ? block.getText() : '';
}).join(delimiter || '\n');
};
ContentState.prototype.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
// TODO: update this when we fully remove DraftEntity
return DraftEntity.__getLastCreatedEntityKey();
};
ContentState.prototype.hasText = function hasText() {
var blockMap = this.getBlockMap();
return blockMap.size > 1 || blockMap.first().getLength() > 0;
};
ContentState.prototype.createEntity = function createEntity(type, mutability, data) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__create(type, mutability, data);
return this;
};
ContentState.prototype.mergeEntityData = function mergeEntityData(key, toMerge) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__mergeData(key, toMerge);
return this;
};
ContentState.prototype.replaceEntityData = function replaceEntityData(key, newData) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__replaceData(key, newData);
return this;
};
ContentState.prototype.addEntity = function addEntity(instance) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__add(instance);
return this;
};
ContentState.prototype.getEntity = function getEntity(key) {
// TODO: update this when we fully remove DraftEntity
return DraftEntity.__get(key);
};
ContentState.createFromBlockArray = function createFromBlockArray(
// TODO: update flow type when we completely deprecate the old entity API
blocks, entityMap) {
// TODO: remove this when we completely deprecate the old entity API
var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
var blockMap = BlockMapBuilder.createFromArray(theBlocks);
var selectionState = blockMap.isEmpty() ? new SelectionState() : SelectionState.createEmpty(blockMap.first().getKey());
return new ContentState({
blockMap: blockMap,
entityMap: entityMap || DraftEntity,
selectionBefore: selectionState,
selectionAfter: selectionState
});
};
ContentState.createFromText = function createFromText(text) {
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : /\r\n?|\n/g;
var strings = text.split(delimiter);
var blocks = strings.map(function (block) {
block = sanitizeDraftText(block);
return new ContentBlockNodeRecord({
key: generateRandomKey(),
text: block,
type: 'unstyled',
characterList: List(Repeat(CharacterMetadata.EMPTY, block.length))
});
});
return ContentState.createFromBlockArray(blocks);
};
return ContentState;
}(ContentStateRecord);
module.exports = ContentState;
/***/ }),
/* 211 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule sanitizeDraftText
* @format
*
*/
var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
function sanitizeDraftText(input) {
return input.replace(REGEX_BLOCK_DELIMITER, '');
}
module.exports = sanitizeDraftText;
/***/ }),
/* 212 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @typechecks
*
*/
/**
* Constants to represent text directionality
*
* Also defines a *global* direciton, to be used in bidi algorithms as a
* default fallback direciton, when no better direction is found or provided.
*
* NOTE: Use `setGlobalDir()`, or update `initGlobalDir()`, to set the initial
* global direction value based on the application.
*
* Part of the implementation of Unicode Bidirectional Algorithm (UBA)
* Unicode Standard Annex #9 (UAX9)
* http://www.unicode.org/reports/tr9/
*/
var invariant = __webpack_require__(13);
var NEUTRAL = 'NEUTRAL'; // No strong direction
var LTR = 'LTR'; // Left-to-Right direction
var RTL = 'RTL'; // Right-to-Left direction
var globalDir = null;
// == Helpers ==
/**
* Check if a directionality value is a Strong one
*/
function isStrong(dir) {
return dir === LTR || dir === RTL;
}
/**
* Get string value to be used for `dir` HTML attribute or `direction` CSS
* property.
*/
function getHTMLDir(dir) {
!isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
return dir === LTR ? 'ltr' : 'rtl';
}
/**
* Get string value to be used for `dir` HTML attribute or `direction` CSS
* property, but returns null if `dir` has same value as `otherDir`.
* `null`.
*/
function getHTMLDirIfDifferent(dir, otherDir) {
!isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
!isStrong(otherDir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
return dir === otherDir ? null : getHTMLDir(dir);
}
// == Global Direction ==
/**
* Set the global direction.
*/
function setGlobalDir(dir) {
globalDir = dir;
}
/**
* Initialize the global direction
*/
function initGlobalDir() {
setGlobalDir(LTR);
}
/**
* Get the global direction
*/
function getGlobalDir() {
if (!globalDir) {
this.initGlobalDir();
}
!globalDir ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Global direction not set.') : invariant(false) : void 0;
return globalDir;
}
var UnicodeBidiDirection = {
// Values
NEUTRAL: NEUTRAL,
LTR: LTR,
RTL: RTL,
// Helpers
isStrong: isStrong,
getHTMLDir: getHTMLDir,
getHTMLDirIfDifferent: getHTMLDirIfDifferent,
// Global Direction
setGlobalDir: setGlobalDir,
initGlobalDir: initGlobalDir,
getGlobalDir: getGlobalDir
};
module.exports = UnicodeBidiDirection;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9)))
/***/ }),
/* 213 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DefaultDraftBlockRenderMap
* @format
*
*/
var _require = __webpack_require__(14),
Map = _require.Map;
var React = __webpack_require__(0);
var cx = __webpack_require__(89);
var UL_WRAP = React.createElement('ul', { className: cx('public/DraftStyleDefault/ul') });
var OL_WRAP = React.createElement('ol', { className: cx('public/DraftStyleDefault/ol') });
var PRE_WRAP = React.createElement('pre', { className: cx('public/DraftStyleDefault/pre') });
var DefaultDraftBlockRenderMap = Map({
'header-one': {
element: 'h1'
},
'header-two': {
element: 'h2'
},
'header-three': {
element: 'h3'
},
'header-four': {
element: 'h4'
},
'header-five': {
element: 'h5'
},
'header-six': {
element: 'h6'
},
'unordered-list-item': {
element: 'li',
wrapper: UL_WRAP
},
'ordered-list-item': {
element: 'li',
wrapper: OL_WRAP
},
blockquote: {
element: 'blockquote'
},
atomic: {
element: 'figure'
},
'code-block': {
element: 'pre',
wrapper: PRE_WRAP
},
unstyled: {
element: 'div',
aliasedElements: ['p']
}
});
module.exports = DefaultDraftBlockRenderMap;
/***/ }),
/* 214 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
module.exports = {
BACKSPACE: 8,
TAB: 9,
RETURN: 13,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
COMMA: 188,
PERIOD: 190,
A: 65,
Z: 90,
ZERO: 48,
NUMPAD_0: 96,
NUMPAD_9: 105
};
/***/ }),
/* 215 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getEntityKeyForSelection
* @format
*
*/
/**
* Return the entity key that should be used when inserting text for the
* specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
* and `SEGMENTED` entities should not be used for insertion behavior.
*/
function getEntityKeyForSelection(contentState, targetSelection) {
var entityKey;
if (targetSelection.isCollapsed()) {
var key = targetSelection.getAnchorKey();
var offset = targetSelection.getAnchorOffset();
if (offset > 0) {
entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
if (entityKey !== contentState.getBlockForKey(key).getEntityAt(offset)) {
return null;
}
return filterKey(contentState.getEntityMap(), entityKey);
}
return null;
}
var startKey = targetSelection.getStartKey();
var startOffset = targetSelection.getStartOffset();
var startBlock = contentState.getBlockForKey(startKey);
entityKey = startOffset === startBlock.getLength() ? null : startBlock.getEntityAt(startOffset);
return filterKey(contentState.getEntityMap(), entityKey);
}
/**
* Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
* return it. If not, return null.
*/
function filterKey(entityMap, entityKey) {
if (entityKey) {
var entity = entityMap.__get(entityKey);
return entity.getMutability() === 'MUTABLE' ? entityKey : null;
}
return null;
}
module.exports = getEntityKeyForSelection;
/***/ }),
/* 216 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var isTextNode = __webpack_require__(929);
/*eslint-disable no-bitwise */
/**
* Checks if a given DOM node contains or is another DOM node.
*/
function containsNode(outerNode, innerNode) {
if (!outerNode || !innerNode) {
return false;
} else if (outerNode === innerNode) {
return true;
} else if (isTextNode(outerNode)) {
return false;
} else if (isTextNode(innerNode)) {
return containsNode(outerNode, innerNode.parentNode);
} else if ('contains' in outerNode) {
return outerNode.contains(innerNode);
} else if (outerNode.compareDocumentPosition) {
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
} else {
return false;
}
}
module.exports = containsNode;
/***/ }),
/* 217 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @typechecks
*/
var getStyleProperty = __webpack_require__(931);
/**
* @param {DOMNode} element [description]
* @param {string} name Overflow style property name.
* @return {boolean} True if the supplied ndoe is scrollable.
*/
function _isNodeScrollable(element, name) {
var overflow = Style.get(element, name);
return overflow === 'auto' || overflow === 'scroll';
}
/**
* Utilities for querying and mutating style properties.
*/
var Style = {
/**
* Gets the style property for the supplied node. This will return either the
* computed style, if available, or the declared style.
*
* @param {DOMNode} node
* @param {string} name Style property name.
* @return {?string} Style property value.
*/
get: getStyleProperty,
/**
* Determines the nearest ancestor of a node that is scrollable.
*
* NOTE: This can be expensive if used repeatedly or on a node nested deeply.
*
* @param {?DOMNode} node Node from which to start searching.
* @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
*/
getScrollParent: function getScrollParent(node) {
if (!node) {
return null;
}
var ownerDocument = node.ownerDocument;
while (node && node !== ownerDocument.body) {
if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) {
return node;
}
node = node.parentNode;
}
return ownerDocument.defaultView || ownerDocument.parentWindow;
}
};
module.exports = Style;
/***/ }),
/* 218 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @typechecks
*/
var getDocumentScrollElement = __webpack_require__(936);
var getUnboundedScrollPosition = __webpack_require__(937);
/**
* Gets the scroll position of the supplied element or window.
*
* The return values are bounded. This means that if the scroll position is
* negative or exceeds the element boundaries (which is possible using inertial
* scrolling), you will get zero or the maximum scroll position, respectively.
*
* If you need the unbound scroll position, use `getUnboundedScrollPosition`.
*
* @param {DOMWindow|DOMElement} scrollable
* @return {object} Map with `x` and `y` keys.
*/
function getScrollPosition(scrollable) {
var documentScrollElement = getDocumentScrollElement(scrollable.ownerDocument || scrollable.document);
if (scrollable.Window && scrollable instanceof scrollable.Window) {
scrollable = documentScrollElement;
}
var scrollPosition = getUnboundedScrollPosition(scrollable);
var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable;
var xMax = scrollable.scrollWidth - viewport.clientWidth;
var yMax = scrollable.scrollHeight - viewport.clientHeight;
scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
return scrollPosition;
}
module.exports = getScrollPosition;
/***/ }),
/* 219 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule findAncestorOffsetKey
* @format
*
*/
var getSelectionOffsetKeyForNode = __webpack_require__(388);
/**
* Get the key from the node's nearest offset-aware ancestor.
*/
function findAncestorOffsetKey(node) {
var searchNode = node;
while (searchNode && searchNode !== document.documentElement) {
var key = getSelectionOffsetKeyForNode(searchNode);
if (key != null) {
return key;
}
searchNode = searchNode.parentNode;
}
return null;
}
module.exports = findAncestorOffsetKey;
/***/ }),
/* 220 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule KeyBindingUtil
* @format
*
*/
var UserAgent = __webpack_require__(48);
var isOSX = UserAgent.isPlatform('Mac OS X');
var KeyBindingUtil = {
/**
* Check whether the ctrlKey modifier is *not* being used in conjunction with
* the altKey modifier. If they are combined, the result is an `altGraph`
* key modifier, which should not be handled by this set of key bindings.
*/
isCtrlKeyCommand: function isCtrlKeyCommand(e) {
return !!e.ctrlKey && !e.altKey;
},
isOptionKeyCommand: function isOptionKeyCommand(e) {
return isOSX && e.altKey;
},
hasCommandModifier: function hasCommandModifier(e) {
return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
}
};
module.exports = KeyBindingUtil;
/***/ }),
/* 221 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule moveSelectionBackward
* @format
*
*/
/**
* Given a collapsed selection, move the focus `maxDistance` backward within
* the selected block. If the selection will go beyond the start of the block,
* move focus to the end of the previous block, but no further.
*
* This function is not Unicode-aware, so surrogate pairs will be treated
* as having length 2.
*/
function moveSelectionBackward(editorState, maxDistance) {
var selection = editorState.getSelection();
var content = editorState.getCurrentContent();
var key = selection.getStartKey();
var offset = selection.getStartOffset();
var focusKey = key;
var focusOffset = 0;
if (maxDistance > offset) {
var keyBefore = content.getKeyBefore(key);
if (keyBefore == null) {
focusKey = key;
} else {
focusKey = keyBefore;
var blockBefore = content.getBlockForKey(keyBefore);
focusOffset = blockBefore.getText().length;
}
} else {
focusOffset = offset - maxDistance;
}
return selection.merge({
focusKey: focusKey,
focusOffset: focusOffset,
isBackward: true
});
}
module.exports = moveSelectionBackward;
/***/ }),
/* 222 */
/***/ (function(module, exports, __webpack_require__) {
var baseGetTag = __webpack_require__(57),
isArray = __webpack_require__(41),
isObjectLike = __webpack_require__(46);
/** `Object#toString` result references. */
var stringTag = '[object String]';
/**
* Checks if `value` is classified as a `String` primitive or object.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
* // => true
*
* _.isString(1);
* // => false
*/
function isString(value) {
return typeof value == 'string' ||
(!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
}
module.exports = isString;
/***/ }),
/* 223 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = getSearchWord;
function getWord(text, position) {
var str = String(text);
/* eslint no-bitwise:0 */
var pos = Number(position) >>> 0;
// Search for the word's beginning and end.
var left = str.slice(0, pos + 1).search(/\S+$/);
var right = str.slice(pos).search(/\s/);
if (right < 0) {
return {
word: str.slice(left),
begin: left,
end: str.length
};
}
// Return the word, using the located bounds to extract it from the string.
return {
word: str.slice(left, right + pos),
begin: left,
end: right + pos
};
}
function getSearchWord(editorState, selection) {
var anchorKey = selection.getAnchorKey();
var anchorOffset = selection.getAnchorOffset() - 1;
var currentContent = editorState.getCurrentContent();
var currentBlock = currentContent.getBlockForKey(anchorKey);
if (currentBlock) {
var blockText = currentBlock.getText();
return getWord(blockText, anchorOffset);
}
return '';
}
/***/ }),
/* 224 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = exportContent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_draft_js__ = __webpack_require__(60);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_draft_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_draft_js__);
function encodeContent(text) {
return text.split('&').join('&').split('<').join('<').split('>').join('>').split('\xA0').join(' ').split('\n').join('
\n');
}
var MentionGenerator = function () {
function MentionGenerator(contentState, options) {
__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, MentionGenerator);
this.contentState = contentState;
this.options = options;
}
MentionGenerator.prototype.generate = function generate() {
var contentRaw = Object(__WEBPACK_IMPORTED_MODULE_1_draft_js__["convertToRaw"])(this.contentState);
return this.processContent(contentRaw);
};
MentionGenerator.prototype.processContent = function processContent(contentRaw) {
var blocks = contentRaw.blocks;
var encode = this.options.encode;
return blocks.map(function (block) {
return encode ? encodeContent(block.text) : block.text;
}).join(encode ? '
\n' : '\n');
};
return MentionGenerator;
}();
function exportContent(contentState) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return new MentionGenerator(contentState, options).generate();
}
/***/ }),
/* 225 */
/***/ (function(module, exports, __webpack_require__) {
var baseIsEqualDeep = __webpack_require__(1025),
isObjectLike = __webpack_require__(46);
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
return value !== value && other !== other;
}
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
}
module.exports = baseIsEqual;
/***/ }),
/* 226 */
/***/ (function(module, exports, __webpack_require__) {
var MapCache = __webpack_require__(182),
setCacheAdd = __webpack_require__(1026),
setCacheHas = __webpack_require__(1027);
/**
*
* Creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
var index = -1,
length = values == null ? 0 : values.length;
this.__data__ = new MapCache;
while (++index < length) {
this.add(values[index]);
}
}
// Add methods to `SetCache`.
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
module.exports = SetCache;
/***/ }),
/* 227 */
/***/ (function(module, exports) {
/**
* Checks if a `cache` value for `key` exists.
*
* @private
* @param {Object} cache The cache to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function cacheHas(cache, key) {
return cache.has(key);
}
module.exports = cacheHas;
/***/ }),
/* 228 */
/***/ (function(module, exports, __webpack_require__) {
var baseIndexOf = __webpack_require__(1044);
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
module.exports = arrayIncludes;
/***/ }),
/* 229 */
/***/ (function(module, exports, __webpack_require__) {
var baseCreate = __webpack_require__(135),
baseLodash = __webpack_require__(230);
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
/**
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
* @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__dir__ = 1;
this.__filtered__ = false;
this.__iteratees__ = [];
this.__takeCount__ = MAX_ARRAY_LENGTH;
this.__views__ = [];
}
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
module.exports = LazyWrapper;
/***/ }),
/* 230 */
/***/ (function(module, exports) {
/**
* The function whose prototype chain sequence wrappers inherit from.
*
* @private
*/
function baseLodash() {
// No operation performed.
}
module.exports = baseLodash;
/***/ }),
/* 231 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
module.exports = {"miniChart":"antd-pro-charts-miniChart","chartContent":"antd-pro-charts-chartContent","chartLoading":"antd-pro-charts-chartLoading"};
/***/ }),
/* 232 */
/***/ (function(module, exports, __webpack_require__) {
(function webpackUniversalModuleDefinition(root, factory) {
if(true)
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["DataSet"] = factory();
else
root["DataSet"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
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, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 195);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_area__ = __webpack_require__(103);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoArea", function() { return __WEBPACK_IMPORTED_MODULE_0__src_area__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_bounds__ = __webpack_require__(197);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBounds", function() { return __WEBPACK_IMPORTED_MODULE_1__src_bounds__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_centroid__ = __webpack_require__(198);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCentroid", function() { return __WEBPACK_IMPORTED_MODULE_2__src_centroid__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_circle__ = __webpack_require__(104);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCircle", function() { return __WEBPACK_IMPORTED_MODULE_3__src_circle__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_clip_extent__ = __webpack_require__(65);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoClipExtent", function() { return __WEBPACK_IMPORTED_MODULE_4__src_clip_extent__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_contains__ = __webpack_require__(217);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoContains", function() { return __WEBPACK_IMPORTED_MODULE_5__src_contains__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_distance__ = __webpack_require__(122);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoDistance", function() { return __WEBPACK_IMPORTED_MODULE_6__src_distance__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_graticule__ = __webpack_require__(218);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGraticule", function() { return __WEBPACK_IMPORTED_MODULE_7__src_graticule__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGraticule10", function() { return __WEBPACK_IMPORTED_MODULE_7__src_graticule__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_interpolate__ = __webpack_require__(219);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterpolate", function() { return __WEBPACK_IMPORTED_MODULE_8__src_interpolate__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_length__ = __webpack_require__(123);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLength", function() { return __WEBPACK_IMPORTED_MODULE_9__src_length__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_path_index__ = __webpack_require__(220);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPath", function() { return __WEBPACK_IMPORTED_MODULE_10__src_path_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_projection_albers__ = __webpack_require__(125);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAlbers", function() { return __WEBPACK_IMPORTED_MODULE_11__src_projection_albers__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_projection_albersUsa__ = __webpack_require__(230);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAlbersUsa", function() { return __WEBPACK_IMPORTED_MODULE_12__src_projection_albersUsa__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_projection_azimuthalEqualArea__ = __webpack_require__(231);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAzimuthalEqualArea", function() { return __WEBPACK_IMPORTED_MODULE_13__src_projection_azimuthalEqualArea__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAzimuthalEqualAreaRaw", function() { return __WEBPACK_IMPORTED_MODULE_13__src_projection_azimuthalEqualArea__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_projection_azimuthalEquidistant__ = __webpack_require__(232);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAzimuthalEquidistant", function() { return __WEBPACK_IMPORTED_MODULE_14__src_projection_azimuthalEquidistant__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAzimuthalEquidistantRaw", function() { return __WEBPACK_IMPORTED_MODULE_14__src_projection_azimuthalEquidistant__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_projection_conicConformal__ = __webpack_require__(233);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicConformal", function() { return __WEBPACK_IMPORTED_MODULE_15__src_projection_conicConformal__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicConformalRaw", function() { return __WEBPACK_IMPORTED_MODULE_15__src_projection_conicConformal__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_projection_conicEqualArea__ = __webpack_require__(68);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicEqualArea", function() { return __WEBPACK_IMPORTED_MODULE_16__src_projection_conicEqualArea__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicEqualAreaRaw", function() { return __WEBPACK_IMPORTED_MODULE_16__src_projection_conicEqualArea__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__src_projection_conicEquidistant__ = __webpack_require__(234);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicEquidistant", function() { return __WEBPACK_IMPORTED_MODULE_17__src_projection_conicEquidistant__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoConicEquidistantRaw", function() { return __WEBPACK_IMPORTED_MODULE_17__src_projection_conicEquidistant__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__src_projection_equirectangular__ = __webpack_require__(127);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEquirectangular", function() { return __WEBPACK_IMPORTED_MODULE_18__src_projection_equirectangular__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEquirectangularRaw", function() { return __WEBPACK_IMPORTED_MODULE_18__src_projection_equirectangular__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__src_projection_gnomonic__ = __webpack_require__(235);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGnomonic", function() { return __WEBPACK_IMPORTED_MODULE_19__src_projection_gnomonic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGnomonicRaw", function() { return __WEBPACK_IMPORTED_MODULE_19__src_projection_gnomonic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__src_projection_identity__ = __webpack_require__(236);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoIdentity", function() { return __WEBPACK_IMPORTED_MODULE_20__src_projection_identity__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__src_projection_index__ = __webpack_require__(17);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoProjection", function() { return __WEBPACK_IMPORTED_MODULE_21__src_projection_index__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoProjectionMutator", function() { return __WEBPACK_IMPORTED_MODULE_21__src_projection_index__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__src_projection_mercator__ = __webpack_require__(71);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMercator", function() { return __WEBPACK_IMPORTED_MODULE_22__src_projection_mercator__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMercatorRaw", function() { return __WEBPACK_IMPORTED_MODULE_22__src_projection_mercator__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__src_projection_orthographic__ = __webpack_require__(237);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoOrthographic", function() { return __WEBPACK_IMPORTED_MODULE_23__src_projection_orthographic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoOrthographicRaw", function() { return __WEBPACK_IMPORTED_MODULE_23__src_projection_orthographic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__src_projection_stereographic__ = __webpack_require__(238);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoStereographic", function() { return __WEBPACK_IMPORTED_MODULE_24__src_projection_stereographic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoStereographicRaw", function() { return __WEBPACK_IMPORTED_MODULE_24__src_projection_stereographic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__src_projection_transverseMercator__ = __webpack_require__(239);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTransverseMercator", function() { return __WEBPACK_IMPORTED_MODULE_25__src_projection_transverseMercator__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTransverseMercatorRaw", function() { return __WEBPACK_IMPORTED_MODULE_25__src_projection_transverseMercator__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__src_rotation__ = __webpack_require__(50);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoRotation", function() { return __WEBPACK_IMPORTED_MODULE_26__src_rotation__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__src_stream__ = __webpack_require__(22);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoStream", function() { return __WEBPACK_IMPORTED_MODULE_27__src_stream__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__src_transform__ = __webpack_require__(51);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTransform", function() { return __WEBPACK_IMPORTED_MODULE_28__src_transform__["a"]; });
// DEPRECATED! Use d3.geoIdentity().clipExtent(…).
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return abs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return atan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return atan2; });
/* unused harmony export ceil */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return cos; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return exp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return floor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return max; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return min; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return pow; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return round; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return sign; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return sin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return tan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return epsilon; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return epsilon2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return pi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return halfPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return quarterPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return sqrt1_2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return sqrt2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return sqrtPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return tau; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return degrees; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return radians; });
/* harmony export (immutable) */ __webpack_exports__["z"] = sinci;
/* harmony export (immutable) */ __webpack_exports__["e"] = asin;
/* harmony export (immutable) */ __webpack_exports__["b"] = acos;
/* harmony export (immutable) */ __webpack_exports__["B"] = sqrt;
/* harmony export (immutable) */ __webpack_exports__["G"] = tanh;
/* harmony export (immutable) */ __webpack_exports__["A"] = sinh;
/* harmony export (immutable) */ __webpack_exports__["i"] = cosh;
/* harmony export (immutable) */ __webpack_exports__["d"] = arsinh;
/* harmony export (immutable) */ __webpack_exports__["c"] = arcosh;
var abs = Math.abs;
var atan = Math.atan;
var atan2 = Math.atan2;
var ceil = Math.ceil;
var cos = Math.cos;
var exp = Math.exp;
var floor = Math.floor;
var log = Math.log;
var max = Math.max;
var min = Math.min;
var pow = Math.pow;
var round = Math.round;
var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
var sin = Math.sin;
var tan = Math.tan;
var epsilon = 1e-6;
var epsilon2 = 1e-12;
var pi = Math.PI;
var halfPi = pi / 2;
var quarterPi = pi / 4;
var sqrt1_2 = Math.SQRT1_2;
var sqrt2 = sqrt(2);
var sqrtPi = sqrt(pi);
var tau = pi * 2;
var degrees = 180 / pi;
var radians = pi / 180;
function sinci(x) {
return x ? x / Math.sin(x) : 1;
}
function asin(x) {
return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
}
function acos(x) {
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
}
function sqrt(x) {
return x > 0 ? Math.sqrt(x) : 0;
}
function tanh(x) {
x = exp(2 * x);
return (x - 1) / (x + 1);
}
function sinh(x) {
return (exp(x) - exp(-x)) / 2;
}
function cosh(x) {
return (exp(x) + exp(-x)) / 2;
}
function arsinh(x) {
return log(x + sqrt(x * x + 1));
}
function arcosh(x) {
return log(x + sqrt(x * x - 1));
}
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var assign = __webpack_require__(3);
var isNil = __webpack_require__(77);
var isObject = __webpack_require__(76);
var uniqueId = __webpack_require__(356);
var EventEmitter = __webpack_require__(139);
var View = __webpack_require__(39);
var CONSTANTS = __webpack_require__(84);
var DataSet =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(DataSet, _EventEmitter);
function DataSet(initialProps) {
var _this;
if (initialProps === void 0) {
initialProps = {
state: {}
};
}
_this = _EventEmitter.call(this) || this;
var me = _assertThisInitialized(_assertThisInitialized(_this));
assign(me, {
_onChangeTimer: null,
DataSet: DataSet,
isDataSet: true,
views: {}
}, initialProps);
return _this;
}
var _proto = DataSet.prototype;
_proto._getUniqueViewName = function _getUniqueViewName() {
var me = this;
var name = uniqueId('view_');
while (me.views[name]) {
name = uniqueId('view_');
}
return name;
};
_proto.createView = function createView(name, options) {
if (options === void 0) {
options = {};
}
var me = this;
if (isNil(name)) {
name = me._getUniqueViewName();
}
if (isObject(name)) {
options = name;
name = me._getUniqueViewName();
}
if (me.views[name]) {
throw new Error("data view exists: " + name);
}
var view = new View(me, options);
me.views[name] = view;
return view;
};
_proto.getView = function getView(name) {
return this.views[name];
};
_proto.setView = function setView(name, view) {
this.views[name] = view;
};
_proto.setState = function setState(name, value) {
var me = this;
me.state[name] = value;
if (me._onChangeTimer) {
clearTimeout(me._onChangeTimer);
me._onChangeTimer = null;
}
me._onChangeTimer = setTimeout(function () {
me.emit('statechange', name, value);
}, 16); // execute after one frame
};
return DataSet;
}(EventEmitter);
assign(DataSet, {
CONSTANTS: CONSTANTS,
DataSet: DataSet,
DataView: View,
// alias
View: View,
connectors: {},
transforms: {},
registerConnector: function registerConnector(name, connector) {
DataSet.connectors[name] = connector;
},
getConnector: function getConnector(name) {
return DataSet.connectors[name] || DataSet.connectors.default;
},
registerTransform: function registerTransform(name, transform) {
DataSet.transforms[name] = transform;
},
getTransform: function getTransform(name) {
return DataSet.transforms[name] || DataSet.transforms.default;
}
}, CONSTANTS);
View.DataSet = DataSet;
assign(DataSet.prototype, {
view: DataSet.prototype.createView // alias
});
DataSet.version = '0.10.2';
module.exports = DataSet;
/***/ }),
/* 3 */
/***/ (function(module, exports) {
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;
};
module.exports = mix;
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return epsilon; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return epsilon2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return pi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return halfPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return quarterPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return tau; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return degrees; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return radians; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return abs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return atan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return atan2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return cos; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return exp; });
/* unused harmony export floor */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return pow; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return sin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return sign; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return sqrt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return tan; });
/* harmony export (immutable) */ __webpack_exports__["b"] = acos;
/* harmony export (immutable) */ __webpack_exports__["c"] = asin;
/* harmony export (immutable) */ __webpack_exports__["m"] = haversin;
var epsilon = 1e-6;
var epsilon2 = 1e-12;
var pi = Math.PI;
var halfPi = pi / 2;
var quarterPi = pi / 4;
var tau = pi * 2;
var degrees = 180 / pi;
var radians = pi / 180;
var abs = Math.abs;
var atan = Math.atan;
var atan2 = Math.atan2;
var cos = Math.cos;
var ceil = Math.ceil;
var exp = Math.exp;
var floor = Math.floor;
var log = Math.log;
var pow = Math.pow;
var sin = Math.sin;
var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
var sqrt = Math.sqrt;
var tan = Math.tan;
function acos(x) {
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
}
function asin(x) {
return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
}
function haversin(x) {
return (x = sin(x / 2)) * x;
}
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return epsilon; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return epsilon2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return pi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return halfPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return quarterPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return tau; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return degrees; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return radians; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return abs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return atan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return atan2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return cos; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return exp; });
/* unused harmony export floor */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return pow; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return sin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return sign; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return sqrt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return tan; });
/* harmony export (immutable) */ __webpack_exports__["b"] = acos;
/* harmony export (immutable) */ __webpack_exports__["c"] = asin;
/* harmony export (immutable) */ __webpack_exports__["m"] = haversin;
var epsilon = 1e-6;
var epsilon2 = 1e-12;
var pi = Math.PI;
var halfPi = pi / 2;
var quarterPi = pi / 4;
var tau = pi * 2;
var degrees = 180 / pi;
var radians = pi / 180;
var abs = Math.abs;
var atan = Math.atan;
var atan2 = Math.atan2;
var cos = Math.cos;
var ceil = Math.ceil;
var exp = Math.exp;
var floor = Math.floor;
var log = Math.log;
var pow = Math.pow;
var sin = Math.sin;
var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
var sqrt = Math.sqrt;
var tan = Math.tan;
function acos(x) {
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
}
function asin(x) {
return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
}
function haversin(x) {
return (x = sin(x / 2)) * x;
}
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(41);
var isArray = Array.isArray ? Array.isArray : function (value) {
return isType(value, 'Array');
};
module.exports = isArray;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(6);
var isString = __webpack_require__(10);
var INVALID_FIELD_ERR_MSG = 'Invalid field: it must be a string!';
var INVALID_FIELDS_ERR_MSG = 'Invalid fields: it must be an array!';
module.exports = {
getField: function getField(options, defaultField) {
var field = options.field,
fields = options.fields;
if (isString(field)) {
return field;
}
if (isArray(field)) {
console.warn(INVALID_FIELD_ERR_MSG);
return field[0];
}
console.warn(INVALID_FIELD_ERR_MSG + " will try to get fields instead.");
if (isString(fields)) {
return fields;
}
if (isArray(fields) && fields.length) {
return fields[0];
}
if (defaultField) {
return defaultField;
}
throw new TypeError(INVALID_FIELD_ERR_MSG);
},
getFields: function getFields(options, defaultFields) {
var field = options.field,
fields = options.fields;
if (isArray(fields)) {
return fields;
}
if (isString(fields)) {
console.warn(INVALID_FIELDS_ERR_MSG);
return [fields];
}
console.warn(INVALID_FIELDS_ERR_MSG + " will try to get field instead.");
if (isString(field)) {
console.warn(INVALID_FIELDS_ERR_MSG);
return [field];
}
if (isArray(field) && field.length) {
console.warn(INVALID_FIELDS_ERR_MSG);
return field;
}
if (defaultFields) {
return defaultFields;
}
throw new TypeError(INVALID_FIELDS_ERR_MSG);
}
};
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
/* global window */
var lodash;
if (true) {
try {
lodash = __webpack_require__(169);
} catch (e) {}
}
if (!lodash) {
lodash = window._;
}
module.exports = lodash;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(76);
var isArray = __webpack_require__(6);
var each = function each(elements, func) {
if (!elements) {
return;
}
var rst = void 0;
if (isArray(elements)) {
for (var i = 0, len = elements.length; i < len; i++) {
rst = func(elements[i], i);
if (rst === false) {
break;
}
}
} else if (isObject(elements)) {
for (var k in elements) {
if (elements.hasOwnProperty(k)) {
rst = func(elements[k], k);
if (rst === false) {
break;
}
}
}
}
};
module.exports = each;
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
var isType = __webpack_require__(41);
var isString = function isString(str) {
return isType(str, 'String');
};
module.exports = isString;
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 是否为函数
* @param {*} fn 对象
* @return {Boolean} 是否函数
*/
var isType = __webpack_require__(41);
var isFunction = function isFunction(value) {
return isType(value, 'Function');
};
module.exports = isFunction;
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _ = __webpack_require__(8),
Graph = __webpack_require__(16).Graph;
module.exports = {
addDummyNode: addDummyNode,
simplify: simplify,
asNonCompoundGraph: asNonCompoundGraph,
successorWeights: successorWeights,
predecessorWeights: predecessorWeights,
intersectRect: intersectRect,
buildLayerMatrix: buildLayerMatrix,
normalizeRanks: normalizeRanks,
removeEmptyRanks: removeEmptyRanks,
addBorderNode: addBorderNode,
maxRank: maxRank,
partition: partition,
time: time,
notime: notime
};
/*
* Adds a dummy node to the graph and return v.
*/
function addDummyNode(g, type, attrs, name) {
var v;
do {
v = _.uniqueId(name);
} while (g.hasNode(v));
attrs.dummy = type;
g.setNode(v, attrs);
return v;
}
/*
* Returns a new graph with only simple edges. Handles aggregation of data
* associated with multi-edges.
*/
function simplify(g) {
var simplified = new Graph().setGraph(g.graph());
_.forEach(g.nodes(), function(v) { simplified.setNode(v, g.node(v)); });
_.forEach(g.edges(), function(e) {
var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 },
label = g.edge(e);
simplified.setEdge(e.v, e.w, {
weight: simpleLabel.weight + label.weight,
minlen: Math.max(simpleLabel.minlen, label.minlen)
});
});
return simplified;
}
function asNonCompoundGraph(g) {
var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph());
_.forEach(g.nodes(), function(v) {
if (!g.children(v).length) {
simplified.setNode(v, g.node(v));
}
});
_.forEach(g.edges(), function(e) {
simplified.setEdge(e, g.edge(e));
});
return simplified;
}
function successorWeights(g) {
var weightMap = _.map(g.nodes(), function(v) {
var sucs = {};
_.forEach(g.outEdges(v), function(e) {
sucs[e.w] = (sucs[e.w] || 0) + g.edge(e).weight;
});
return sucs;
});
return _.zipObject(g.nodes(), weightMap);
}
function predecessorWeights(g) {
var weightMap = _.map(g.nodes(), function(v) {
var preds = {};
_.forEach(g.inEdges(v), function(e) {
preds[e.v] = (preds[e.v] || 0) + g.edge(e).weight;
});
return preds;
});
return _.zipObject(g.nodes(), weightMap);
}
/*
* Finds where a line starting at point ({x, y}) would intersect a rectangle
* ({x, y, width, height}) if it were pointing at the rectangle's center.
*/
function intersectRect(rect, point) {
var x = rect.x;
var y = rect.y;
// Rectangle intersection algorithm from:
// http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
var dx = point.x - x;
var dy = point.y - y;
var w = rect.width / 2;
var h = rect.height / 2;
if (!dx && !dy) {
throw new Error("Not possible to find intersection inside of the rectangle");
}
var sx, sy;
if (Math.abs(dy) * w > Math.abs(dx) * h) {
// Intersection is top or bottom of rect.
if (dy < 0) {
h = -h;
}
sx = h * dx / dy;
sy = h;
} else {
// Intersection is left or right of rect.
if (dx < 0) {
w = -w;
}
sx = w;
sy = w * dy / dx;
}
return { x: x + sx, y: y + sy };
}
/*
* Given a DAG with each node assigned "rank" and "order" properties, this
* function will produce a matrix with the ids of each node.
*/
function buildLayerMatrix(g) {
var layering = _.map(_.range(maxRank(g) + 1), function() { return []; });
_.forEach(g.nodes(), function(v) {
var node = g.node(v),
rank = node.rank;
if (!_.isUndefined(rank)) {
layering[rank][node.order] = v;
}
});
return layering;
}
/*
* Adjusts the ranks for all nodes in the graph such that all nodes v have
* rank(v) >= 0 and at least one node w has rank(w) = 0.
*/
function normalizeRanks(g) {
var min = _.minBy(_.map(g.nodes(), function(v) { return g.node(v).rank; }));
_.forEach(g.nodes(), function(v) {
var node = g.node(v);
if (_.has(node, "rank")) {
node.rank -= min;
}
});
}
function removeEmptyRanks(g) {
// Ranks may not start at 0, so we need to offset them
var offset = _.minBy(_.map(g.nodes(), function(v) { return g.node(v).rank; }));
var layers = [];
_.forEach(g.nodes(), function(v) {
var rank = g.node(v).rank - offset;
if (!layers[rank]) {
layers[rank] = [];
}
layers[rank].push(v);
});
var delta = 0,
nodeRankFactor = g.graph().nodeRankFactor;
_.forEach(layers, function(vs, i) {
if (_.isUndefined(vs) && i % nodeRankFactor !== 0) {
--delta;
} else if (delta) {
_.forEach(vs, function(v) { g.node(v).rank += delta; });
}
});
}
function addBorderNode(g, prefix, rank, order) {
var node = {
width: 0,
height: 0
};
if (arguments.length >= 4) {
node.rank = rank;
node.order = order;
}
return addDummyNode(g, "border", node, prefix);
}
function maxRank(g) {
return _.max(_.map(g.nodes(), function(v) {
var rank = g.node(v).rank;
if (!_.isUndefined(rank)) {
return rank;
}
}));
}
/*
* Partition a collection into two groups: `lhs` and `rhs`. If the supplied
* function returns true for an entry it goes into `lhs`. Otherwise it goes
* into `rhs.
*/
function partition(collection, fn) {
var result = { lhs: [], rhs: [] };
_.forEach(collection, function(value) {
if (fn(value)) {
result.lhs.push(value);
} else {
result.rhs.push(value);
}
});
return result;
}
/*
* Returns a new function that wraps `fn` with a timer. The wrapper logs the
* time it takes to execute the function.
*/
function time(name, fn) {
var start = _.now();
try {
return fn();
} finally {
console.log(name + " time: " + (_.now() - start) + "ms");
}
}
function notime(name, fn) {
return fn();
}
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
/* global window */
var lodash;
if (true) {
try {
lodash = __webpack_require__(169);
} catch (e) {}
}
if (!lodash) {
lodash = window._;
}
module.exports = lodash;
/***/ }),
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_bisect__ = __webpack_require__(109);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bisect", function() { return __WEBPACK_IMPORTED_MODULE_0__src_bisect__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bisectRight", function() { return __WEBPACK_IMPORTED_MODULE_0__src_bisect__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bisectLeft", function() { return __WEBPACK_IMPORTED_MODULE_0__src_bisect__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_ascending__ = __webpack_require__(30);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "ascending", function() { return __WEBPACK_IMPORTED_MODULE_1__src_ascending__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_bisector__ = __webpack_require__(110);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bisector", function() { return __WEBPACK_IMPORTED_MODULE_2__src_bisector__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_cross__ = __webpack_require__(201);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "cross", function() { return __WEBPACK_IMPORTED_MODULE_3__src_cross__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_descending__ = __webpack_require__(202);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "descending", function() { return __WEBPACK_IMPORTED_MODULE_4__src_descending__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_deviation__ = __webpack_require__(112);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "deviation", function() { return __WEBPACK_IMPORTED_MODULE_5__src_deviation__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_extent__ = __webpack_require__(114);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "extent", function() { return __WEBPACK_IMPORTED_MODULE_6__src_extent__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_histogram__ = __webpack_require__(203);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "histogram", function() { return __WEBPACK_IMPORTED_MODULE_7__src_histogram__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_threshold_freedmanDiaconis__ = __webpack_require__(206);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "thresholdFreedmanDiaconis", function() { return __WEBPACK_IMPORTED_MODULE_8__src_threshold_freedmanDiaconis__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_threshold_scott__ = __webpack_require__(207);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "thresholdScott", function() { return __WEBPACK_IMPORTED_MODULE_9__src_threshold_scott__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_threshold_sturges__ = __webpack_require__(118);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "thresholdSturges", function() { return __WEBPACK_IMPORTED_MODULE_10__src_threshold_sturges__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_max__ = __webpack_require__(208);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return __WEBPACK_IMPORTED_MODULE_11__src_max__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_mean__ = __webpack_require__(209);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mean", function() { return __WEBPACK_IMPORTED_MODULE_12__src_mean__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_median__ = __webpack_require__(210);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "median", function() { return __WEBPACK_IMPORTED_MODULE_13__src_median__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_merge__ = __webpack_require__(211);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return __WEBPACK_IMPORTED_MODULE_14__src_merge__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_min__ = __webpack_require__(119);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return __WEBPACK_IMPORTED_MODULE_15__src_min__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_pairs__ = __webpack_require__(111);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pairs", function() { return __WEBPACK_IMPORTED_MODULE_16__src_pairs__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__src_permute__ = __webpack_require__(212);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "permute", function() { return __WEBPACK_IMPORTED_MODULE_17__src_permute__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__src_quantile__ = __webpack_require__(66);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "quantile", function() { return __WEBPACK_IMPORTED_MODULE_18__src_quantile__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__src_range__ = __webpack_require__(116);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return __WEBPACK_IMPORTED_MODULE_19__src_range__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__src_scan__ = __webpack_require__(213);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "scan", function() { return __WEBPACK_IMPORTED_MODULE_20__src_scan__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__src_shuffle__ = __webpack_require__(214);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "shuffle", function() { return __WEBPACK_IMPORTED_MODULE_21__src_shuffle__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__src_sum__ = __webpack_require__(215);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sum", function() { return __WEBPACK_IMPORTED_MODULE_22__src_sum__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__src_ticks__ = __webpack_require__(117);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "ticks", function() { return __WEBPACK_IMPORTED_MODULE_23__src_ticks__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "tickIncrement", function() { return __WEBPACK_IMPORTED_MODULE_23__src_ticks__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "tickStep", function() { return __WEBPACK_IMPORTED_MODULE_23__src_ticks__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__src_transpose__ = __webpack_require__(120);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return __WEBPACK_IMPORTED_MODULE_24__src_transpose__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__src_variance__ = __webpack_require__(113);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "variance", function() { return __WEBPACK_IMPORTED_MODULE_25__src_variance__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__src_zip__ = __webpack_require__(216);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "zip", function() { return __WEBPACK_IMPORTED_MODULE_26__src_zip__["a"]; });
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(6);
var isFunction = __webpack_require__(11);
var isString = __webpack_require__(10);
var groupBy = __webpack_require__(352);
var simpleSortBy = __webpack_require__(353);
module.exports = function (rows, group_by, order_by) {
if (order_by === void 0) {
order_by = [];
}
var newRows = rows;
if (order_by && order_by.length) {
newRows = simpleSortBy(rows, order_by);
}
var groupingFn;
if (isFunction(group_by)) {
groupingFn = group_by;
} else if (isArray(group_by)) {
groupingFn = function groupingFn(row) {
return "_" + group_by.map(function (col) {
return row[col];
}).join('-');
}; // NOTE: Object.keys({'b': 'b', '2': '2', '1': '1', 'a': 'a'}) => [ '1', '2', 'b', 'a' ]
// that is why we have to add a prefix
} else if (isString(group_by)) {
groupingFn = function groupingFn(row) {
return "_" + row[group_by];
};
}
var groups = groupBy(newRows, groupingFn);
return groups;
};
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
/* global window */
var graphlib;
if (true) {
try {
graphlib = __webpack_require__(433);
} catch (e) {}
}
if (!graphlib) {
graphlib = window.graphlib;
}
module.exports = graphlib;
/***/ }),
/* 17 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = projection;
/* harmony export (immutable) */ __webpack_exports__["b"] = projectionMutator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__ = __webpack_require__(226);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__clip_circle__ = __webpack_require__(227);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__clip_extent__ = __webpack_require__(65);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compose__ = __webpack_require__(105);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__identity__ = __webpack_require__(67);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__rotation__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__transform__ = __webpack_require__(51);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fit__ = __webpack_require__(70);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__resample__ = __webpack_require__(228);
var transformRadians = Object(__WEBPACK_IMPORTED_MODULE_7__transform__["b" /* transformer */])({
point: function(x, y) {
this.stream.point(x * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], y * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]);
}
});
function projection(project) {
return projectionMutator(function() { return project; })();
}
function projectionMutator(projectAt) {
var project,
k = 150, // scale
x = 480, y = 250, // translate
dx, dy, lambda = 0, phi = 0, // center
deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, projectRotate, // rotate
theta = null, preclip = __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__["a" /* default */], // clip angle
x0 = null, y0, x1, y1, postclip = __WEBPACK_IMPORTED_MODULE_4__identity__["a" /* default */], // clip extent
delta2 = 0.5, projectResample = Object(__WEBPACK_IMPORTED_MODULE_9__resample__["a" /* default */])(projectTransform, delta2), // precision
cache,
cacheStream;
function projection(point) {
point = projectRotate(point[0] * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], point[1] * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]);
return [point[0] * k + dx, dy - point[1] * k];
}
function invert(point) {
point = projectRotate.invert((point[0] - dx) / k, (dy - point[1]) / k);
return point && [point[0] * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], point[1] * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
}
function projectTransform(x, y) {
return x = project(x, y), [x[0] * k + dx, dy - x[1] * k];
}
projection.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = transformRadians(preclip(rotate, projectResample(postclip(cacheStream = stream))));
};
projection.clipAngle = function(_) {
return arguments.length ? (preclip = +_ ? Object(__WEBPACK_IMPORTED_MODULE_1__clip_circle__["a" /* default */])(theta = _ * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], 6 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]) : (theta = null, __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__["a" /* default */]), reset()) : theta * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */];
};
projection.clipExtent = function(_) {
return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, __WEBPACK_IMPORTED_MODULE_4__identity__["a" /* default */]) : Object(__WEBPACK_IMPORTED_MODULE_2__clip_extent__["a" /* clipExtent */])(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
};
projection.scale = function(_) {
return arguments.length ? (k = +_, recenter()) : k;
};
projection.translate = function(_) {
return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
};
projection.center = function(_) {
return arguments.length ? (lambda = _[0] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], phi = _[1] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], recenter()) : [lambda * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], phi * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
};
projection.rotate = function(_) {
return arguments.length ? (deltaLambda = _[0] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], deltaPhi = _[1] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], deltaGamma = _.length > 2 ? _[2] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */] : 0, recenter()) : [deltaLambda * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], deltaPhi * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], deltaGamma * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
};
projection.precision = function(_) {
return arguments.length ? (projectResample = Object(__WEBPACK_IMPORTED_MODULE_9__resample__["a" /* default */])(projectTransform, delta2 = _ * _), reset()) : Object(__WEBPACK_IMPORTED_MODULE_5__math__["u" /* sqrt */])(delta2);
};
projection.fitExtent = function(extent, object) {
return Object(__WEBPACK_IMPORTED_MODULE_8__fit__["a" /* fitExtent */])(projection, extent, object);
};
projection.fitSize = function(size, object) {
return Object(__WEBPACK_IMPORTED_MODULE_8__fit__["b" /* fitSize */])(projection, size, object);
};
function recenter() {
projectRotate = Object(__WEBPACK_IMPORTED_MODULE_3__compose__["a" /* default */])(rotate = Object(__WEBPACK_IMPORTED_MODULE_6__rotation__["b" /* rotateRadians */])(deltaLambda, deltaPhi, deltaGamma), project);
var center = project(lambda, phi);
dx = x - center[0] * k;
dy = y + center[1] * k;
return reset();
}
function reset() {
cache = cacheStream = null;
return projection;
}
return function() {
project = projectAt.apply(this, arguments);
projection.invert = project.invert && invert;
return recenter();
};
}
/***/ }),
/* 18 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = projection;
/* harmony export (immutable) */ __webpack_exports__["b"] = projectionMutator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__ = __webpack_require__(336);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__clip_circle__ = __webpack_require__(338);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__clip_extent__ = __webpack_require__(145);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compose__ = __webpack_require__(144);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__identity__ = __webpack_require__(150);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__rotation__ = __webpack_require__(78);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__transform__ = __webpack_require__(81);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fit__ = __webpack_require__(154);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__resample__ = __webpack_require__(339);
var transformRadians = Object(__WEBPACK_IMPORTED_MODULE_7__transform__["b" /* transform */])({
point: function(x, y) {
this.stream.point(x * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], y * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]);
}
});
function projection(project) {
return projectionMutator(function() { return project; })();
}
function projectionMutator(projectAt) {
var project,
k = 150, // scale
x = 480, y = 250, // translate
dx, dy, lambda = 0, phi = 0, // center
deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, projectRotate, // rotate
theta = null, preclip = __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__["a" /* default */], // clip angle
x0 = null, y0, x1, y1, postclip = __WEBPACK_IMPORTED_MODULE_4__identity__["a" /* default */], // clip extent
delta2 = 0.5, projectResample = Object(__WEBPACK_IMPORTED_MODULE_9__resample__["a" /* default */])(projectTransform, delta2), // precision
cache,
cacheStream;
function projection(point) {
point = projectRotate(point[0] * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], point[1] * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]);
return [point[0] * k + dx, dy - point[1] * k];
}
function invert(point) {
point = projectRotate.invert((point[0] - dx) / k, (dy - point[1]) / k);
return point && [point[0] * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], point[1] * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
}
function projectTransform(x, y) {
return x = project(x, y), [x[0] * k + dx, dy - x[1] * k];
}
projection.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = transformRadians(preclip(rotate, projectResample(postclip(cacheStream = stream))));
};
projection.clipAngle = function(_) {
return arguments.length ? (preclip = +_ ? Object(__WEBPACK_IMPORTED_MODULE_1__clip_circle__["a" /* default */])(theta = _ * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], 6 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */]) : (theta = null, __WEBPACK_IMPORTED_MODULE_0__clip_antimeridian__["a" /* default */]), reset()) : theta * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */];
};
projection.clipExtent = function(_) {
return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, __WEBPACK_IMPORTED_MODULE_4__identity__["a" /* default */]) : Object(__WEBPACK_IMPORTED_MODULE_2__clip_extent__["a" /* clipExtent */])(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
};
projection.scale = function(_) {
return arguments.length ? (k = +_, recenter()) : k;
};
projection.translate = function(_) {
return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
};
projection.center = function(_) {
return arguments.length ? (lambda = _[0] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], phi = _[1] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], recenter()) : [lambda * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], phi * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
};
projection.rotate = function(_) {
return arguments.length ? (deltaLambda = _[0] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], deltaPhi = _[1] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */], deltaGamma = _.length > 2 ? _[2] % 360 * __WEBPACK_IMPORTED_MODULE_5__math__["r" /* radians */] : 0, recenter()) : [deltaLambda * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], deltaPhi * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */], deltaGamma * __WEBPACK_IMPORTED_MODULE_5__math__["h" /* degrees */]];
};
projection.precision = function(_) {
return arguments.length ? (projectResample = Object(__WEBPACK_IMPORTED_MODULE_9__resample__["a" /* default */])(projectTransform, delta2 = _ * _), reset()) : Object(__WEBPACK_IMPORTED_MODULE_5__math__["u" /* sqrt */])(delta2);
};
projection.fitExtent = Object(__WEBPACK_IMPORTED_MODULE_8__fit__["a" /* fitExtent */])(projection);
projection.fitSize = Object(__WEBPACK_IMPORTED_MODULE_8__fit__["b" /* fitSize */])(projection);
function recenter() {
projectRotate = Object(__WEBPACK_IMPORTED_MODULE_3__compose__["a" /* default */])(rotate = Object(__WEBPACK_IMPORTED_MODULE_6__rotation__["b" /* rotateRadians */])(deltaLambda, deltaPhi, deltaGamma), project);
var center = project(lambda, phi);
dx = x - center[0] * k;
dy = y + center[1] * k;
return reset();
}
function reset() {
cache = cacheStream = null;
return projection;
}
return function() {
project = projectAt.apply(this, arguments);
projection.invert = project.invert && invert;
return recenter();
};
}
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
!function(t,r){ true?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.ss={})}(this,function(t){"use strict";function r(t){if(0===t.length)return 0;for(var r,n=t[0],e=0,a=1;a=Math.abs(t[a])?e+=n-r+t[a]:e+=t[a]-r+n,n=r;return n+e}function g(t){if(0===t.length)throw new Error("mean requires at least one data point");return r(t)/t.length}function n(t,r){var n,e,a=g(t),o=0;if(2===r)for(e=0;er&&(r=t[n]);return r}function i(t,r){var n=t.length*r;if(0===t.length)throw new Error("quantile requires at least one data point.");if(r<0||1f&&p(t,n,e);sf;)l--}t[n]===f?p(t,n,l):p(t,++l,e),l<=r&&(n=l+1),r<=l&&(e=l-1)}}function p(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function s(t,r){var n=t.slice();if(Array.isArray(r)){!function(t,r){for(var n=[0],e=0;et[t.length-1])return 1;var n=function(t,r){var n=0,e=0,a=t.length;for(;e>>1]?a=n:e=-~n;return e}(t,r);if(t[n]!==r)return n/t.length;n++;var e=function(t,r){var n=0,e=0,a=t.length;for(;e=t[n=e+a>>>1]?e=-~n:a=n;return e}(t,r);if(e===n)return n/t.length;var a=e-n+1;return a*(e+n)/2/a/t.length}function m(t){var r=s(t,.75),n=s(t,.25);if("number"==typeof r&&"number"==typeof n)return r-n}function d(t){return+s(t,.5)}function b(t){for(var r=d(t),n=[],e=0;e=e[n][u]);--g)(s=x(h,u,o,i)+e[n-1][h-1])n&&(n=t[e]),t[e]t.length)throw new Error("cannot generate more classes than there are data values");var n=f(t);if(1===y(n))return[n];var e=S(r,n.length),a=S(r,n.length);!function(t,r,n){for(var e,a=r[0].length,o=t[Math.floor(a/2)],i=[],u=[],h=0;h=Math.abs(a)&&(c+=1);else if("greater"===n)for(h=0;h<=e;h++)o[h]>=a&&(c+=1);else for(h=0;h<=e;h++)o[h]<=a&&(c+=1);return c/e},t.bisect=function(t,r,n,e,a){if("function"!=typeof t)throw new TypeError("func must be a function");for(var o=0;o __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */] && --i > 0);
return phi / 2;
}
function mollweideBromleyRaw(cx, cy, cp) {
function forward(lambda, phi) {
return [cx * lambda * Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi = mollweideBromleyTheta(cp, phi)), cy * Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(phi)];
}
forward.invert = function(x, y) {
return y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(y / cy), [x / (cx * Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(y)), Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])((2 * y + Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(2 * y)) / cp)];
};
return forward;
}
var mollweideRaw = mollweideBromleyRaw(__WEBPACK_IMPORTED_MODULE_1__math__["D" /* sqrt2 */] / __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */], __WEBPACK_IMPORTED_MODULE_1__math__["D" /* sqrt2 */], __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */]);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(mollweideRaw)
.scale(169.529);
});
/***/ }),
/* 22 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function streamGeometry(geometry, stream) {
if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
streamGeometryType[geometry.type](geometry, stream);
}
}
var streamObjectType = {
Feature: function(object, stream) {
streamGeometry(object.geometry, stream);
},
FeatureCollection: function(object, stream) {
var features = object.features, i = -1, n = features.length;
while (++i < n) streamGeometry(features[i].geometry, stream);
}
};
var streamGeometryType = {
Sphere: function(object, stream) {
stream.sphere();
},
Point: function(object, stream) {
object = object.coordinates;
stream.point(object[0], object[1], object[2]);
},
MultiPoint: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
},
LineString: function(object, stream) {
streamLine(object.coordinates, stream, 0);
},
MultiLineString: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) streamLine(coordinates[i], stream, 0);
},
Polygon: function(object, stream) {
streamPolygon(object.coordinates, stream);
},
MultiPolygon: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) streamPolygon(coordinates[i], stream);
},
GeometryCollection: function(object, stream) {
var geometries = object.geometries, i = -1, n = geometries.length;
while (++i < n) streamGeometry(geometries[i], stream);
}
};
function streamLine(coordinates, stream, closed) {
var i = -1, n = coordinates.length - closed, coordinate;
stream.lineStart();
while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
stream.lineEnd();
}
function streamPolygon(coordinates, stream) {
var i = -1, n = coordinates.length;
stream.polygonStart();
while (++i < n) streamLine(coordinates[i], stream, 1);
stream.polygonEnd();
}
/* harmony default export */ __webpack_exports__["a"] = (function(object, stream) {
if (object && streamObjectType.hasOwnProperty(object.type)) {
streamObjectType[object.type](object, stream);
} else {
streamGeometry(object, stream);
}
});
/***/ }),
/* 23 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_array__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(1);
function pointEqual(a, b) {
return Object(__WEBPACK_IMPORTED_MODULE_2__math__["a" /* abs */])(a[0] - b[0]) < __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */] && Object(__WEBPACK_IMPORTED_MODULE_2__math__["a" /* abs */])(a[1] - b[1]) < __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */];
}
function interpolateLine(coordinates, m) {
var i = -1,
n = coordinates.length,
p0 = coordinates[0],
p1,
dx,
dy,
resampled = [];
while (++i < n) {
p1 = coordinates[i];
dx = (p1[0] - p0[0]) / m;
dy = (p1[1] - p0[1]) / m;
for (var j = 0; j < m; ++j) resampled.push([p0[0] + j * dx, p0[1] + j * dy]);
p0 = p1;
}
resampled.push(p1);
return resampled;
}
function interpolateSphere(lobes) {
var coordinates = [],
lobe,
lambda0, phi0, phi1,
lambda2, phi2,
i, n = lobes[0].length;
// Northern Hemisphere
for (i = 0; i < n; ++i) {
lobe = lobes[0][i];
lambda0 = lobe[0][0], phi0 = lobe[0][1], phi1 = lobe[1][1];
lambda2 = lobe[2][0], phi2 = lobe[2][1];
coordinates.push(interpolateLine([
[lambda0 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi0 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda0 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi1 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda2 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi1 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda2 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi2 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]]
], 30));
}
// Southern Hemisphere
for (i = lobes[1].length - 1; i >= 0; --i) {
lobe = lobes[1][i];
lambda0 = lobe[0][0], phi0 = lobe[0][1], phi1 = lobe[1][1];
lambda2 = lobe[2][0], phi2 = lobe[2][1];
coordinates.push(interpolateLine([
[lambda2 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi2 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda2 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi1 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda0 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi1 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]],
[lambda0 + __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */], phi0 - __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */]]
], 30));
}
return {
type: "Polygon",
coordinates: [Object(__WEBPACK_IMPORTED_MODULE_0_d3_array__["merge"])(coordinates)]
};
}
/* harmony default export */ __webpack_exports__["a"] = (function(project, lobes) {
var sphere = interpolateSphere(lobes);
lobes = lobes.map(function(lobe) {
return lobe.map(function(l) {
return [
[l[0][0] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */], l[0][1] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */]],
[l[1][0] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */], l[1][1] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */]],
[l[2][0] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */], l[2][1] * __WEBPACK_IMPORTED_MODULE_2__math__["v" /* radians */]]
];
});
});
var bounds = lobes.map(function(lobe) {
return lobe.map(function(l) {
var x0 = project(l[0][0], l[0][1])[0],
x1 = project(l[2][0], l[2][1])[0],
y0 = project(l[1][0], l[0][1])[1],
y1 = project(l[1][0], l[1][1])[1],
t;
if (y0 > y1) t = y0, y0 = y1, y1 = t;
return [[x0, y0], [x1, y1]];
});
});
function forward(lambda, phi) {
var sign = phi < 0 ? -1 : +1, lobe = lobes[+(phi < 0)];
for (var i = 0, n = lobe.length - 1; i < n && lambda > lobe[i][2][0]; ++i);
var p = project(lambda - lobe[i][1][0], phi);
p[0] += project(lobe[i][1][0], sign * phi > sign * lobe[i][0][1] ? lobe[i][0][1] : phi)[0];
return p;
}
// Assumes mutually exclusive bounding boxes for lobes.
if (project.invert) forward.invert = function(x, y) {
var bound = bounds[+(y < 0)], lobe = lobes[+(y < 0)];
for (var i = 0, n = bound.length; i < n; ++i) {
var b = bound[i];
if (b[0][0] <= x && x < b[1][0] && b[0][1] <= y && y < b[1][1]) {
var p = project.invert(x - project(lobe[i][1][0], 0)[0], y);
p[0] += lobe[i][1][0];
return pointEqual(forward(p[0], p[1]), [x, y]) ? p : null;
}
}
};
var p = Object(__WEBPACK_IMPORTED_MODULE_1_d3_geo__["geoProjection"])(forward),
stream_ = p.stream;
p.stream = function(stream) {
var rotate = p.rotate(),
rotateStream = stream_(stream),
sphereStream = (p.rotate([0, 0]), stream_(stream));
p.rotate(rotate);
rotateStream.sphere = function() { Object(__WEBPACK_IMPORTED_MODULE_1_d3_geo__["geoStream"])(sphere, sphereStream); };
return rotateStream;
};
return p;
});
/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(9);
var isFunction = __webpack_require__(11);
var keys = Object.keys ? function (obj) {
return Object.keys(obj);
} : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(key);
}
});
return result;
};
module.exports = keys;
/***/ }),
/* 25 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = noop;
function noop() {}
/***/ }),
/* 26 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function streamGeometry(geometry, stream) {
if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
streamGeometryType[geometry.type](geometry, stream);
}
}
var streamObjectType = {
Feature: function(feature, stream) {
streamGeometry(feature.geometry, stream);
},
FeatureCollection: function(object, stream) {
var features = object.features, i = -1, n = features.length;
while (++i < n) streamGeometry(features[i].geometry, stream);
}
};
var streamGeometryType = {
Sphere: function(object, stream) {
stream.sphere();
},
Point: function(object, stream) {
object = object.coordinates;
stream.point(object[0], object[1], object[2]);
},
MultiPoint: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
},
LineString: function(object, stream) {
streamLine(object.coordinates, stream, 0);
},
MultiLineString: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) streamLine(coordinates[i], stream, 0);
},
Polygon: function(object, stream) {
streamPolygon(object.coordinates, stream);
},
MultiPolygon: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) streamPolygon(coordinates[i], stream);
},
GeometryCollection: function(object, stream) {
var geometries = object.geometries, i = -1, n = geometries.length;
while (++i < n) streamGeometry(geometries[i], stream);
}
};
function streamLine(coordinates, stream, closed) {
var i = -1, n = coordinates.length - closed, coordinate;
stream.lineStart();
while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
stream.lineEnd();
}
function streamPolygon(coordinates, stream) {
var i = -1, n = coordinates.length;
stream.polygonStart();
while (++i < n) streamLine(coordinates[i], stream, 1);
stream.polygonEnd();
}
/* harmony default export */ __webpack_exports__["a"] = (function(object, stream) {
if (object && streamObjectType.hasOwnProperty(object.type)) {
streamObjectType[object.type](object, stream);
} else {
streamGeometry(object, stream);
}
});
/***/ }),
/* 27 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return function constant() {
return x;
};
});
/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {
var assign = __webpack_require__(3);
module.exports = {
assign: assign
};
/***/ }),
/* 29 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// Adds floating point numbers with twice the normal precision.
// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
// 305–363 (1997).
// Code adapted from GeographicLib by Charles F. F. Karney,
// http://geographiclib.sourceforge.net/
/* harmony default export */ __webpack_exports__["a"] = (function() {
return new Adder;
});
function Adder() {
this.reset();
}
Adder.prototype = {
constructor: Adder,
reset: function() {
this.s = // rounded value
this.t = 0; // exact error
},
add: function(y) {
add(temp, y, this.t);
add(this, temp.s, this.s);
if (this.s) this.t += temp.t;
else this.s = temp.t;
},
valueOf: function() {
return this.s;
}
};
var temp = new Adder;
function add(adder, a, b) {
var x = adder.s = a + b,
bv = x - a,
av = x - bv;
adder.t = (a - av) + (b - bv);
}
/***/ }),
/* 30 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
});
/***/ }),
/* 31 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
/* harmony default export */ __webpack_exports__["a"] = (function(projectAt) {
var phi0 = 0,
m = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjectionMutator"])(projectAt),
p = m(phi0);
p.parallel = function(_) {
return arguments.length ? m(phi0 = _ * __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */]) : phi0 * __WEBPACK_IMPORTED_MODULE_1__math__["j" /* degrees */];
};
return p;
});
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(9);
var isPlaineObject = __webpack_require__(54);
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Creates an object composed of the picked `object` properties.
*
* @param {Object} object The source object.
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
* pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
*/
var pick = function pick(object, keys) {
if (object === null || !isPlaineObject(object)) {
return {};
}
var result = {};
each(keys, function (key) {
if (hasOwnProperty.call(object, key)) {
result[key] = object[key];
}
});
return result;
};
module.exports = pick;
/***/ }),
/* 33 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_path__ = __webpack_require__(349);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "path", function() { return __WEBPACK_IMPORTED_MODULE_0__src_path__["a"]; });
/***/ }),
/* 34 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_cluster__ = __webpack_require__(369);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "cluster", function() { return __WEBPACK_IMPORTED_MODULE_0__src_cluster__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_hierarchy_index__ = __webpack_require__(86);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "hierarchy", function() { return __WEBPACK_IMPORTED_MODULE_1__src_hierarchy_index__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_pack_index__ = __webpack_require__(381);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pack", function() { return __WEBPACK_IMPORTED_MODULE_2__src_pack_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_pack_siblings__ = __webpack_require__(160);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "packSiblings", function() { return __WEBPACK_IMPORTED_MODULE_3__src_pack_siblings__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_pack_enclose__ = __webpack_require__(161);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "packEnclose", function() { return __WEBPACK_IMPORTED_MODULE_4__src_pack_enclose__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_partition__ = __webpack_require__(383);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "partition", function() { return __WEBPACK_IMPORTED_MODULE_5__src_partition__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_stratify__ = __webpack_require__(384);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "stratify", function() { return __WEBPACK_IMPORTED_MODULE_6__src_stratify__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_tree__ = __webpack_require__(385);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "tree", function() { return __WEBPACK_IMPORTED_MODULE_7__src_tree__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_treemap_index__ = __webpack_require__(386);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemap", function() { return __WEBPACK_IMPORTED_MODULE_8__src_treemap_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_treemap_binary__ = __webpack_require__(387);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapBinary", function() { return __WEBPACK_IMPORTED_MODULE_9__src_treemap_binary__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_treemap_dice__ = __webpack_require__(45);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapDice", function() { return __WEBPACK_IMPORTED_MODULE_10__src_treemap_dice__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_treemap_slice__ = __webpack_require__(55);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapSlice", function() { return __WEBPACK_IMPORTED_MODULE_11__src_treemap_slice__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_treemap_sliceDice__ = __webpack_require__(388);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapSliceDice", function() { return __WEBPACK_IMPORTED_MODULE_12__src_treemap_sliceDice__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_treemap_squarify__ = __webpack_require__(88);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapSquarify", function() { return __WEBPACK_IMPORTED_MODULE_13__src_treemap_squarify__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_treemap_resquarify__ = __webpack_require__(389);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treemapResquarify", function() { return __WEBPACK_IMPORTED_MODULE_14__src_treemap_resquarify__["a"]; });
/***/ }),
/* 35 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["g"] = spherical;
/* harmony export (immutable) */ __webpack_exports__["a"] = cartesian;
/* harmony export (immutable) */ __webpack_exports__["d"] = cartesianDot;
/* harmony export (immutable) */ __webpack_exports__["c"] = cartesianCross;
/* harmony export (immutable) */ __webpack_exports__["b"] = cartesianAddInPlace;
/* harmony export (immutable) */ __webpack_exports__["f"] = cartesianScale;
/* harmony export (immutable) */ __webpack_exports__["e"] = cartesianNormalizeInPlace;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
function spherical(cartesian) {
return [Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(cartesian[1], cartesian[0]), Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])(cartesian[2])];
}
function cartesian(spherical) {
var lambda = spherical[0], phi = spherical[1], cosPhi = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(phi);
return [cosPhi * Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(lambda), cosPhi * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(lambda), Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(phi)];
}
function cartesianDot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
function cartesianCross(a, b) {
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
}
// TODO return a
function cartesianAddInPlace(a, b) {
a[0] += b[0], a[1] += b[1], a[2] += b[2];
}
function cartesianScale(vector, k) {
return [vector[0] * k, vector[1] * k, vector[2] * k];
}
// TODO return d
function cartesianNormalizeInPlace(d) {
var l = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
d[0] /= l, d[1] /= l, d[2] /= l;
}
/***/ }),
/* 36 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return x === null ? NaN : +x;
});
/***/ }),
/* 37 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = azimuthalRaw;
/* harmony export (immutable) */ __webpack_exports__["a"] = azimuthalInvert;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
function azimuthalRaw(scale) {
return function(x, y) {
var cx = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(x),
cy = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(y),
k = scale(cx * cy);
return [
k * cy * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(x),
k * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y)
];
}
}
function azimuthalInvert(angle) {
return function(x, y) {
var z = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(x * x + y * y),
c = angle(z),
sc = Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(c),
cc = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(c);
return [
Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(x * sc, z * cc),
Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])(z && y * sc / z)
];
}
}
/***/ }),
/* 38 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = sinusoidalRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
function sinusoidalRaw(lambda, phi) {
return [lambda * Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi), phi];
}
sinusoidalRaw.invert = function(x, y) {
return [x / Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(y), y];
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(sinusoidalRaw)
.scale(152.63);
});
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var EventEmitter = __webpack_require__(139);
var assign = __webpack_require__(3);
var clone = __webpack_require__(40);
var cloneDeep = __webpack_require__(40);
var find = __webpack_require__(320);
var forIn = __webpack_require__(9);
var isArray = __webpack_require__(6);
var isPlainObject = __webpack_require__(54);
var isMatch = __webpack_require__(140);
var isObject = __webpack_require__(76);
var isString = __webpack_require__(10);
var keys = __webpack_require__(24);
var pick = __webpack_require__(32);
function cloneOptions(options) {
var result = {};
forIn(options, function (value, key) {
if (isObject(value) && value.isView) {
result[key] = value;
} else if (isArray(value)) {
result[key] = value.concat([]);
} else if (isPlainObject(value)) {
result[key] = clone(value);
} else {
result[key] = value;
}
});
return result;
}
var View =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(View, _EventEmitter);
// constructor
function View(dataSet, options) {
var _this;
_this = _EventEmitter.call(this) || this;
var me = _assertThisInitialized(_assertThisInitialized(_this));
options = options || {};
dataSet = dataSet || {};
if (!dataSet.isDataSet) {
options = dataSet;
dataSet = null;
}
assign(me, {
dataSet: dataSet,
loose: !dataSet,
dataType: 'table',
isView: true,
isDataView: true,
// alias
origin: [],
rows: [],
transforms: [],
watchingStates: null
}, options);
if (!me.loose) {
var watchingStates = me.watchingStates;
dataSet.on('statechange', function (name) {
if (isArray(watchingStates)) {
if (watchingStates.indexOf(name) > -1) {
me._reExecute();
}
} else {
me._reExecute();
}
});
}
return _this;
}
var _proto = View.prototype;
_proto._parseStateExpression = function _parseStateExpression(expr) {
var dataSet = this.dataSet;
var matched = /^\$state\.(\w+)/.exec(expr);
if (matched) {
return dataSet.state[matched[1]];
}
return expr;
};
_proto._preparseOptions = function _preparseOptions(options) {
var me = this;
var optionsCloned = cloneOptions(options);
if (me.loose) {
return optionsCloned;
}
forIn(optionsCloned, function (value, key) {
if (isString(value) && /^\$state\./.test(value)) {
optionsCloned[key] = me._parseStateExpression(value);
}
});
return optionsCloned;
}; // connectors
_proto._prepareSource = function _prepareSource(source, options) {
var me = this;
var DataSet = View.DataSet; // warning me.origin is protected
me._source = {
source: source,
options: options
};
if (!options) {
if (source instanceof View || isString(source)) {
me.origin = DataSet.getConnector('default')(source, me.dataSet);
} else if (isArray(source)) {
// TODO branch: if source is like ['dataview1', 'dataview2']
me.origin = source;
} else if (isObject(source) && source.type) {
options = me._preparseOptions(source); // connector without source
me.origin = DataSet.getConnector(options.type)(options, me);
} else {
throw new TypeError('Invalid source');
}
} else {
options = me._preparseOptions(options);
me.origin = DataSet.getConnector(options.type)(source, options, me);
}
me.rows = cloneDeep(me.origin);
return me;
};
_proto.source = function source(_source, options) {
var me = this;
me._prepareSource(_source, options);
me._reExecuteTransforms();
me.trigger('change');
return me;
}; // transforms
_proto.transform = function transform(options) {
if (options === void 0) {
options = {};
}
var me = this;
me.transforms.push(options);
me._executeTransform(options);
return me;
};
_proto._executeTransform = function _executeTransform(options) {
var me = this;
options = me._preparseOptions(options);
var transform = View.DataSet.getTransform(options.type);
transform(me, options);
};
_proto._reExecuteTransforms = function _reExecuteTransforms() {
var me = this;
me.transforms.forEach(function (options) {
me._executeTransform(options);
});
}; // rows
_proto.addRow = function addRow(row) {
this.rows.push(row);
};
_proto.removeRow = function removeRow(index) {
this.rows.splice(index, 1);
};
_proto.updateRow = function updateRow(index, newRow) {
assign(this.rows[index], newRow);
};
_proto.findRows = function findRows(query) {
return this.rows.filter(function (row) {
return isMatch(row, query);
});
};
_proto.findRow = function findRow(query) {
return find(this.rows, query);
}; // columns
_proto.getColumnNames = function getColumnNames() {
var firstRow = this.rows[0];
if (firstRow) {
return keys(firstRow);
}
return [];
};
_proto.getColumnName = function getColumnName(index) {
return this.getColumnNames()[index];
};
_proto.getColumnIndex = function getColumnIndex(columnName) {
var columnNames = this.getColumnNames();
return columnNames.indexOf(columnName);
};
_proto.getColumn = function getColumn(columnName) {
return this.rows.map(function (row) {
return row[columnName];
});
};
_proto.getColumnData = function getColumnData(columnName) {
return this.getColumn(columnName);
}; // data process
_proto.getSubset = function getSubset(startRowIndex, endRowIndex, columnNames) {
var subset = [];
for (var i = startRowIndex; i <= endRowIndex; i++) {
subset.push(pick(this.rows[i], columnNames));
}
return subset;
};
_proto.toString = function toString(prettyPrint) {
var me = this;
if (prettyPrint) {
return JSON.stringify(me.rows, null, 2);
}
return JSON.stringify(me.rows);
};
_proto._reExecute = function _reExecute() {
var me = this;
var _me$_source = me._source,
source = _me$_source.source,
options = _me$_source.options;
me._prepareSource(source, options);
me._reExecuteTransforms();
me.trigger('change');
};
return View;
}(EventEmitter);
module.exports = View;
/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {
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 isArray = __webpack_require__(6);
var clone = function clone(obj) {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
return obj;
}
var rst = void 0;
if (isArray(obj)) {
rst = [];
for (var i = 0, l = obj.length; i < l; i++) {
if (_typeof(obj[i]) === 'object' && obj[i] != null) {
rst[i] = clone(obj[i]);
} else {
rst[i] = obj[i];
}
}
} else {
rst = {};
for (var k in obj) {
if (_typeof(obj[k]) === 'object' && obj[k] != null) {
rst[k] = clone(obj[k]);
} else {
rst[k] = obj[k];
}
}
}
return rst;
};
module.exports = clone;
/***/ }),
/* 41 */
/***/ (function(module, exports) {
var toString = {}.toString;
var isType = function isType(value, type) {
return toString.call(value) === '[object ' + type + ']';
};
module.exports = isType;
/***/ }),
/* 42 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// Adds floating point numbers with twice the normal precision.
// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
// 305–363 (1997).
// Code adapted from GeographicLib by Charles F. F. Karney,
// http://geographiclib.sourceforge.net/
/* harmony default export */ __webpack_exports__["a"] = (function() {
return new Adder;
});
function Adder() {
this.reset();
}
Adder.prototype = {
constructor: Adder,
reset: function() {
this.s = // rounded value
this.t = 0; // exact error
},
add: function(y) {
add(temp, y, this.t);
add(this, temp.s, this.s);
if (this.s) this.t += temp.t;
else this.s = temp.t;
},
valueOf: function() {
return this.s;
}
};
var temp = new Adder;
function add(adder, a, b) {
var x = adder.s = a + b,
bv = x - a,
av = x - bv;
adder.t = (a - av) + (b - bv);
}
/***/ }),
/* 43 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["g"] = spherical;
/* harmony export (immutable) */ __webpack_exports__["a"] = cartesian;
/* harmony export (immutable) */ __webpack_exports__["d"] = cartesianDot;
/* harmony export (immutable) */ __webpack_exports__["c"] = cartesianCross;
/* harmony export (immutable) */ __webpack_exports__["b"] = cartesianAddInPlace;
/* harmony export (immutable) */ __webpack_exports__["f"] = cartesianScale;
/* harmony export (immutable) */ __webpack_exports__["e"] = cartesianNormalizeInPlace;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
function spherical(cartesian) {
return [Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(cartesian[1], cartesian[0]), Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])(cartesian[2])];
}
function cartesian(spherical) {
var lambda = spherical[0], phi = spherical[1], cosPhi = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(phi);
return [cosPhi * Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(lambda), cosPhi * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(lambda), Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(phi)];
}
function cartesianDot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
function cartesianCross(a, b) {
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
}
// TODO return a
function cartesianAddInPlace(a, b) {
a[0] += b[0], a[1] += b[1], a[2] += b[2];
}
function cartesianScale(vector, k) {
return [vector[0] * k, vector[1] * k, vector[2] * k];
}
// TODO return d
function cartesianNormalizeInPlace(d) {
var l = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
d[0] /= l, d[1] /= l, d[2] /= l;
}
/***/ }),
/* 44 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = azimuthalRaw;
/* harmony export (immutable) */ __webpack_exports__["a"] = azimuthalInvert;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
function azimuthalRaw(scale) {
return function(x, y) {
var cx = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(x),
cy = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(y),
k = scale(cx * cy);
return [
k * cy * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(x),
k * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y)
];
}
}
function azimuthalInvert(angle) {
return function(x, y) {
var z = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(x * x + y * y),
c = angle(z),
sc = Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(c),
cc = Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(c);
return [
Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(x * sc, z * cc),
Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])(z && y * sc / z)
];
}
}
/***/ }),
/* 45 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(parent, x0, y0, x1, y1) {
var nodes = parent.children,
node,
i = -1,
n = nodes.length,
k = parent.value && (x1 - x0) / parent.value;
while (++i < n) {
node = nodes[i], node.y0 = y0, node.y1 = y1;
node.x0 = x0, node.x1 = x0 += node.value * k;
}
});
/***/ }),
/* 46 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return abs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return atan2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return cos; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return max; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return min; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return sin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return sqrt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return epsilon; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return pi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return halfPi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return tau; });
/* harmony export (immutable) */ __webpack_exports__["b"] = acos;
/* harmony export (immutable) */ __webpack_exports__["c"] = asin;
var abs = Math.abs;
var atan2 = Math.atan2;
var cos = Math.cos;
var max = Math.max;
var min = Math.min;
var sin = Math.sin;
var sqrt = Math.sqrt;
var epsilon = 1e-12;
var pi = Math.PI;
var halfPi = pi / 2;
var tau = 2 * pi;
function acos(x) {
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
}
function asin(x) {
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
}
/***/ }),
/* 47 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(series, order) {
if (!((n = series.length) > 1)) return;
for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
s0 = s1, s1 = series[order[i]];
for (j = 0; j < m; ++j) {
s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
}
}
});
/***/ }),
/* 48 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(series) {
var n = series.length, o = new Array(n);
while (--n >= 0) o[n] = n;
return o;
});
/***/ }),
/* 49 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return epsilon; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return epsilon2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return beaches; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return cells; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return circles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return edges; });
/* harmony export (immutable) */ __webpack_exports__["d"] = Diagram;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Beach__ = __webpack_require__(513);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Cell__ = __webpack_require__(191);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Circle__ = __webpack_require__(192);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Edge__ = __webpack_require__(100);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RedBlackTree__ = __webpack_require__(99);
var epsilon = 1e-6;
var epsilon2 = 1e-12;
var beaches;
var cells;
var circles;
var edges;
function triangleArea(a, b, c) {
return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
}
function lexicographic(a, b) {
return b[1] - a[1]
|| b[0] - a[0];
}
function Diagram(sites, extent) {
var site = sites.sort(lexicographic).pop(),
x,
y,
circle;
edges = [];
cells = new Array(sites.length);
beaches = new __WEBPACK_IMPORTED_MODULE_4__RedBlackTree__["b" /* default */];
circles = new __WEBPACK_IMPORTED_MODULE_4__RedBlackTree__["b" /* default */];
while (true) {
circle = __WEBPACK_IMPORTED_MODULE_2__Circle__["c" /* firstCircle */];
if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) {
if (site[0] !== x || site[1] !== y) {
Object(__WEBPACK_IMPORTED_MODULE_0__Beach__["a" /* addBeach */])(site);
x = site[0], y = site[1];
}
site = sites.pop();
} else if (circle) {
Object(__WEBPACK_IMPORTED_MODULE_0__Beach__["b" /* removeBeach */])(circle.arc);
} else {
break;
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__Cell__["d" /* sortCellHalfedges */])();
if (extent) {
var x0 = +extent[0][0],
y0 = +extent[0][1],
x1 = +extent[1][0],
y1 = +extent[1][1];
Object(__WEBPACK_IMPORTED_MODULE_3__Edge__["a" /* clipEdges */])(x0, y0, x1, y1);
Object(__WEBPACK_IMPORTED_MODULE_1__Cell__["b" /* clipCells */])(x0, y0, x1, y1);
}
this.edges = edges;
this.cells = cells;
beaches =
circles =
edges =
cells = null;
}
Diagram.prototype = {
constructor: Diagram,
polygons: function() {
var edges = this.edges;
return this.cells.map(function(cell) {
var polygon = cell.halfedges.map(function(i) { return Object(__WEBPACK_IMPORTED_MODULE_1__Cell__["a" /* cellHalfedgeStart */])(cell, edges[i]); });
polygon.data = cell.site.data;
return polygon;
});
},
triangles: function() {
var triangles = [],
edges = this.edges;
this.cells.forEach(function(cell, i) {
if (!(m = (halfedges = cell.halfedges).length)) return;
var site = cell.site,
halfedges,
j = -1,
m,
s0,
e1 = edges[halfedges[m - 1]],
s1 = e1.left === site ? e1.right : e1.left;
while (++j < m) {
s0 = s1;
e1 = edges[halfedges[j]];
s1 = e1.left === site ? e1.right : e1.left;
if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
triangles.push([site.data, s0.data, s1.data]);
}
}
});
return triangles;
},
links: function() {
return this.edges.filter(function(edge) {
return edge.right;
}).map(function(edge) {
return {
source: edge.left.data,
target: edge.right.data
};
});
},
find: function(x, y, radius) {
var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell;
// Use the previously-found cell, or start with an arbitrary one.
while (!(cell = that.cells[i1])) if (++i1 >= n) return null;
var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy;
// Traverse the half-edges to find a closer cell, if any.
do {
cell = that.cells[i0 = i1], i1 = null;
cell.halfedges.forEach(function(e) {
var edge = that.edges[e], v = edge.left;
if ((v === cell.site || !v) && !(v = edge.right)) return;
var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy;
if (v2 < d2) d2 = v2, i1 = v.index;
});
} while (i1 !== null);
that._found = i0;
return radius == null || d2 <= radius * radius ? cell.site : null;
}
}
/***/ }),
/* 50 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = rotateRadians;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__compose__ = __webpack_require__(105);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(4);
function rotationIdentity(lambda, phi) {
return [lambda > __WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda - __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda < -__WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda + __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda, phi];
}
rotationIdentity.invert = rotationIdentity;
function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
return (deltaLambda %= __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */]) ? (deltaPhi || deltaGamma ? Object(__WEBPACK_IMPORTED_MODULE_0__compose__["a" /* default */])(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma))
: rotationLambda(deltaLambda))
: (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma)
: rotationIdentity);
}
function forwardRotationLambda(deltaLambda) {
return function(lambda, phi) {
return lambda += deltaLambda, [lambda > __WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda - __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda < -__WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda + __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda, phi];
};
}
function rotationLambda(deltaLambda) {
var rotation = forwardRotationLambda(deltaLambda);
rotation.invert = forwardRotationLambda(-deltaLambda);
return rotation;
}
function rotationPhiGamma(deltaPhi, deltaGamma) {
var cosDeltaPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(deltaPhi),
sinDeltaPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(deltaPhi),
cosDeltaGamma = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(deltaGamma),
sinDeltaGamma = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(deltaGamma);
function rotation(lambda, phi) {
var cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(lambda) * cosPhi,
y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(lambda) * cosPhi,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = z * cosDeltaPhi + x * sinDeltaPhi;
return [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
Object(__WEBPACK_IMPORTED_MODULE_1__math__["c" /* asin */])(k * cosDeltaGamma + y * sinDeltaGamma)
];
}
rotation.invert = function(lambda, phi) {
var cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(lambda) * cosPhi,
y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(lambda) * cosPhi,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = z * cosDeltaGamma - y * sinDeltaGamma;
return [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
Object(__WEBPACK_IMPORTED_MODULE_1__math__["c" /* asin */])(k * cosDeltaPhi - x * sinDeltaPhi)
];
};
return rotation;
}
/* harmony default export */ __webpack_exports__["a"] = (function(rotate) {
rotate = rotateRadians(rotate[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], rotate[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], rotate.length > 2 ? rotate[2] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */] : 0);
function forward(coordinates) {
coordinates = rotate(coordinates[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], coordinates[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */]);
return coordinates[0] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates[1] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates;
}
forward.invert = function(coordinates) {
coordinates = rotate.invert(coordinates[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], coordinates[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */]);
return coordinates[0] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates[1] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates;
};
return forward;
});
/***/ }),
/* 51 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = transformer;
/* harmony default export */ __webpack_exports__["a"] = (function(methods) {
return {
stream: transformer(methods)
};
});
function transformer(methods) {
return function(stream) {
var s = new TransformStream;
for (var key in methods) s[key] = methods[key];
s.stream = stream;
return s;
};
}
function TransformStream() {}
TransformStream.prototype = {
constructor: TransformStream,
point: function(x, y) { this.stream.point(x, y); },
sphere: function() { this.stream.sphere(); },
lineStart: function() { this.stream.lineStart(); },
lineEnd: function() { this.stream.lineEnd(); },
polygonStart: function() { this.stream.polygonStart(); },
polygonEnd: function() { this.stream.polygonEnd(); }
};
/***/ }),
/* 52 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(1);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b, c, d, e, f, g, h) {
if (arguments.length < 8) h = 0;
function forward(lambda, phi) {
if (!phi) return [a * lambda / __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */], 0];
var phi2 = phi * phi,
xB = a + phi2 * (b + phi2 * (c + phi2 * d)),
yB = phi * (e - 1 + phi2 * (f - h + phi2 * g)),
m = (xB * xB + yB * yB) / (2 * yB),
alpha = lambda * Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* asin */])(xB / m) / __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */];
return [m * Object(__WEBPACK_IMPORTED_MODULE_0__math__["y" /* sin */])(alpha), phi * (1 + phi2 * h) + m * (1 - Object(__WEBPACK_IMPORTED_MODULE_0__math__["h" /* cos */])(alpha))];
}
forward.invert = function(x, y) {
var lambda = __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */] * x / a,
phi = y,
deltaLambda, deltaPhi, i = 50;
do {
var phi2 = phi * phi,
xB = a + phi2 * (b + phi2 * (c + phi2 * d)),
yB = phi * (e - 1 + phi2 * (f - h + phi2 * g)),
p = xB * xB + yB * yB,
q = 2 * yB,
m = p / q,
m2 = m * m,
dAlphadLambda = Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* asin */])(xB / m) / __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */],
alpha = lambda * dAlphadLambda,
xB2 = xB * xB,
dxBdPhi = (2 * b + phi2 * (4 * c + phi2 * 6 * d)) * phi,
dyBdPhi = e + phi2 * (3 * f + phi2 * 5 * g),
dpdPhi = 2 * (xB * dxBdPhi + yB * (dyBdPhi - 1)),
dqdPhi = 2 * (dyBdPhi - 1),
dmdPhi = (dpdPhi * q - p * dqdPhi) / (q * q),
cosAlpha = Object(__WEBPACK_IMPORTED_MODULE_0__math__["h" /* cos */])(alpha),
sinAlpha = Object(__WEBPACK_IMPORTED_MODULE_0__math__["y" /* sin */])(alpha),
mcosAlpha = m * cosAlpha,
msinAlpha = m * sinAlpha,
dAlphadPhi = ((lambda / __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */]) * (1 / Object(__WEBPACK_IMPORTED_MODULE_0__math__["B" /* sqrt */])(1 - xB2 / m2)) * (dxBdPhi * m - xB * dmdPhi)) / m2,
fx = msinAlpha - x,
fy = phi * (1 + phi2 * h) + m - mcosAlpha - y,
deltaxDeltaPhi = dmdPhi * sinAlpha + mcosAlpha * dAlphadPhi,
deltaxDeltaLambda = mcosAlpha * dAlphadLambda,
deltayDeltaPhi = 1 + dmdPhi - (dmdPhi * cosAlpha - msinAlpha * dAlphadPhi),
deltayDeltaLambda = msinAlpha * dAlphadLambda,
denominator = deltaxDeltaPhi * deltayDeltaLambda - deltayDeltaPhi * deltaxDeltaLambda;
if (!denominator) break;
lambda -= deltaLambda = (fy * deltaxDeltaPhi - fx * deltayDeltaPhi) / denominator;
phi -= deltaPhi = (fx * deltayDeltaLambda - fy * deltaxDeltaLambda) / denominator;
} while ((Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(deltaLambda) > __WEBPACK_IMPORTED_MODULE_0__math__["k" /* epsilon */] || Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(deltaPhi) > __WEBPACK_IMPORTED_MODULE_0__math__["k" /* epsilon */]) && --i > 0);
return [lambda, phi];
};
return forward;
});
/***/ }),
/* 53 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__matrix__ = __webpack_require__(294);
// Creates a polyhedral projection.
// * root: a spanning tree of polygon faces. Nodes are automatically
// augmented with a transform matrix.
// * face: a function that returns the appropriate node for a given {lambda, phi}
// point (radians).
// * r: rotation angle for final polyhedral net. Defaults to -pi / 6 (for
// butterflies).
/* harmony default export */ __webpack_exports__["a"] = (function(root, face, r) {
r = r == null ? -__WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 6 : r; // TODO automate
recurse(root, {transform: [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(r), Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(r), 0,
-Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(r), Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(r), 0
]});
function recurse(node, parent) {
node.edges = faceEdges(node.face);
// Find shared edge.
if (parent.face) {
var shared = node.shared = sharedEdge(node.face, parent.face),
m = Object(__WEBPACK_IMPORTED_MODULE_2__matrix__["a" /* default */])(shared.map(parent.project), shared.map(node.project));
node.transform = parent.transform ? Object(__WEBPACK_IMPORTED_MODULE_2__matrix__["c" /* multiply */])(parent.transform, m) : m;
// Replace shared edge in parent edges array.
var edges = parent.edges;
for (var i = 0, n = edges.length; i < n; ++i) {
if (pointEqual(shared[0], edges[i][1]) && pointEqual(shared[1], edges[i][0])) edges[i] = node;
if (pointEqual(shared[0], edges[i][0]) && pointEqual(shared[1], edges[i][1])) edges[i] = node;
}
edges = node.edges;
for (i = 0, n = edges.length; i < n; ++i) {
if (pointEqual(shared[0], edges[i][0]) && pointEqual(shared[1], edges[i][1])) edges[i] = parent;
if (pointEqual(shared[0], edges[i][1]) && pointEqual(shared[1], edges[i][0])) edges[i] = parent;
}
} else {
node.transform = parent.transform;
}
if (node.children) {
node.children.forEach(function(child) {
recurse(child, node);
});
}
return node;
}
function forward(lambda, phi) {
var node = face(lambda, phi),
point = node.project([lambda * __WEBPACK_IMPORTED_MODULE_1__math__["j" /* degrees */], phi * __WEBPACK_IMPORTED_MODULE_1__math__["j" /* degrees */]]),
t;
if (t = node.transform) {
return [
t[0] * point[0] + t[1] * point[1] + t[2],
-(t[3] * point[0] + t[4] * point[1] + t[5])
];
}
point[1] = -point[1];
return point;
}
// Naive inverse! A faster solution would use bounding boxes, or even a
// polygonal quadtree.
if (hasInverse(root)) forward.invert = function(x, y) {
var coordinates = faceInvert(root, [x, -y]);
return coordinates && (coordinates[0] *= __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */], coordinates[1] *= __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */], coordinates);
};
function faceInvert(node, coordinates) {
var invert = node.project.invert,
t = node.transform,
point = coordinates;
if (t) {
t = Object(__WEBPACK_IMPORTED_MODULE_2__matrix__["b" /* inverse */])(t);
point = [
t[0] * point[0] + t[1] * point[1] + t[2],
(t[3] * point[0] + t[4] * point[1] + t[5])
];
}
if (invert && node === faceDegrees(p = invert(point))) return p;
var p,
children = node.children;
for (var i = 0, n = children && children.length; i < n; ++i) {
if (p = faceInvert(children[i], coordinates)) return p;
}
}
function faceDegrees(coordinates) {
return face(coordinates[0] * __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */], coordinates[1] * __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */]);
}
var proj = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(forward),
stream_ = proj.stream;
proj.stream = function(stream) {
var rotate = proj.rotate(),
rotateStream = stream_(stream),
sphereStream = (proj.rotate([0, 0]), stream_(stream));
proj.rotate(rotate);
rotateStream.sphere = function() {
sphereStream.polygonStart();
sphereStream.lineStart();
outline(sphereStream, root);
sphereStream.lineEnd();
sphereStream.polygonEnd();
};
return rotateStream;
};
return proj;
});
function outline(stream, node, parent) {
var point,
edges = node.edges,
n = edges.length,
edge,
multiPoint = {type: "MultiPoint", coordinates: node.face},
notPoles = node.face.filter(function(d) { return Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(d[1]) !== 90; }),
b = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoBounds"])({type: "MultiPoint", coordinates: notPoles}),
inside = false,
j = -1,
dx = b[1][0] - b[0][0];
// TODO
var c = dx === 180 || dx === 360
? [(b[0][0] + b[1][0]) / 2, (b[0][1] + b[1][1]) / 2]
: Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoCentroid"])(multiPoint);
// First find the shared edge…
if (parent) while (++j < n) {
if (edges[j] === parent) break;
}
++j;
for (var i = 0; i < n; ++i) {
edge = edges[(i + j) % n];
if (Array.isArray(edge)) {
if (!inside) {
stream.point((point = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoInterpolate"])(edge[0], c)(__WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */]))[0], point[1]);
inside = true;
}
stream.point((point = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoInterpolate"])(edge[1], c)(__WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */]))[0], point[1]);
} else {
inside = false;
if (edge !== parent) outline(stream, edge, node);
}
}
}
// Tests equality of two spherical points.
function pointEqual(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1];
}
// Finds a shared edge given two clockwise polygons.
function sharedEdge(a, b) {
var x, y, n = a.length, found = null;
for (var i = 0; i < n; ++i) {
x = a[i];
for (var j = b.length; --j >= 0;) {
y = b[j];
if (x[0] === y[0] && x[1] === y[1]) {
if (found) return [found, x];
found = x;
}
}
}
}
// Converts an array of n face vertices to an array of n + 1 edges.
function faceEdges(face) {
var n = face.length,
edges = [];
for (var a = face[n - 1], i = 0; i < n; ++i) edges.push([a, a = face[i]]);
return edges;
}
function hasInverse(node) {
return node.project.invert || node.children && node.children.some(hasInverse);
}
/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {
var isObjectLike = __webpack_require__(321);
var isType = __webpack_require__(41);
var isPlainObject = function isPlainObject(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(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;
};
module.exports = isPlainObject;
/***/ }),
/* 55 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(parent, x0, y0, x1, y1) {
var nodes = parent.children,
node,
i = -1,
n = nodes.length,
k = parent.value && (y1 - y0) / parent.value;
while (++i < n) {
node = nodes[i], node.x0 = x0, node.x1 = x1;
node.y0 = y0, node.y1 = y0 += node.value * k;
}
});
/***/ }),
/* 56 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 判断是否数字
* @return {Boolean} 是否数字
*/
var isType = __webpack_require__(41);
var isNumber = function isNumber(value) {
return isType(value, 'Number');
};
module.exports = isNumber;
/***/ }),
/* 57 */
/***/ (function(module, exports) {
module.exports = function (extent, bw) {
var bandwidth = bw || 1;
var min = extent[0],
max = extent[1];
var values = [];
var tmp = min;
while (tmp < max) {
values.push(tmp);
tmp += bandwidth;
}
values.push(max);
return values;
};
/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {
var _require = __webpack_require__(19),
standardDeviation = _require.standardDeviation,
interquartileRange = _require.interquartileRange;
module.exports = {
silverman: function silverman(arr) {
var stdev = standardDeviation(arr);
var num = 4 * Math.pow(stdev, 5);
var denom = 3 * arr.length;
return Math.pow(num / denom, 0.2);
},
nrd: function nrd(x) {
var s = standardDeviation(x);
var iqr = interquartileRange(x);
if (typeof iqr === 'number') {
s = Math.min(s, iqr / 1.34);
}
return 1.06 * s * Math.pow(x.length, -0.2);
}
};
/***/ }),
/* 59 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _ = __webpack_require__(8);
module.exports = {
longestPath: longestPath,
slack: slack
};
/*
* Initializes ranks for the input graph using the longest path algorithm. This
* algorithm scales well and is fast in practice, it yields rather poor
* solutions. Nodes are pushed to the lowest layer possible, leaving the bottom
* ranks wide and leaving edges longer than necessary. However, due to its
* speed, this algorithm is good for getting an initial ranking that can be fed
* into other algorithms.
*
* This algorithm does not normalize layers because it will be used by other
* algorithms in most cases. If using this algorithm directly, be sure to
* run normalize at the end.
*
* Pre-conditions:
*
* 1. Input graph is a DAG.
* 2. Input graph node labels can be assigned properties.
*
* Post-conditions:
*
* 1. Each node will be assign an (unnormalized) "rank" property.
*/
function longestPath(g) {
var visited = {};
function dfs(v) {
var label = g.node(v);
if (_.has(visited, v)) {
return label.rank;
}
visited[v] = true;
var rank = _.minBy(_.map(g.outEdges(v), function(e) {
return dfs(e.w) - g.edge(e).minlen;
}));
if (rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
rank === undefined || // return value of _.map([]) for Lodash 4
rank === null) { // return value of _.map([null])
rank = 0;
}
return (label.rank = rank);
}
_.forEach(g.sources(), dfs);
}
/*
* Returns the amount of slack for the given edge. The slack is defined as the
* difference between the length of the edge and its minimum length.
*/
function slack(g, e) {
return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen;
}
/***/ }),
/* 60 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function Linear(context) {
this._context = context;
}
Linear.prototype = {
areaStart: function() {
this._line = 0;
},
areaEnd: function() {
this._line = NaN;
},
lineStart: function() {
this._point = 0;
},
lineEnd: function() {
if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
this._line = 1 - this._line;
},
point: function(x, y) {
x = +x, y = +y;
switch (this._point) {
case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
case 1: this._point = 2; // proceed
default: this._context.lineTo(x, y); break;
}
}
};
/* harmony default export */ __webpack_exports__["a"] = (function(context) {
return new Linear(context);
});
/***/ }),
/* 61 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() {});
/***/ }),
/* 62 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = point;
/* harmony export (immutable) */ __webpack_exports__["a"] = Basis;
function point(that, x, y) {
that._context.bezierCurveTo(
(2 * that._x0 + that._x1) / 3,
(2 * that._y0 + that._y1) / 3,
(that._x0 + 2 * that._x1) / 3,
(that._y0 + 2 * that._y1) / 3,
(that._x0 + 4 * that._x1 + x) / 6,
(that._y0 + 4 * that._y1 + y) / 6
);
}
function Basis(context) {
this._context = context;
}
Basis.prototype = {
areaStart: function() {
this._line = 0;
},
areaEnd: function() {
this._line = NaN;
},
lineStart: function() {
this._x0 = this._x1 =
this._y0 = this._y1 = NaN;
this._point = 0;
},
lineEnd: function() {
switch (this._point) {
case 3: point(this, this._x1, this._y1); // proceed
case 2: this._context.lineTo(this._x1, this._y1); break;
}
if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
this._line = 1 - this._line;
},
point: function(x, y) {
x = +x, y = +y;
switch (this._point) {
case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
case 1: this._point = 2; break;
case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // proceed
default: point(this, x, y); break;
}
this._x0 = this._x1, this._x1 = x;
this._y0 = this._y1, this._y1 = y;
}
};
/* unused harmony default export */ var _unused_webpack_default_export = (function(context) {
return new Basis(context);
});
/***/ }),
/* 63 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = point;
/* harmony export (immutable) */ __webpack_exports__["a"] = Cardinal;
function point(that, x, y) {
that._context.bezierCurveTo(
that._x1 + that._k * (that._x2 - that._x0),
that._y1 + that._k * (that._y2 - that._y0),
that._x2 + that._k * (that._x1 - x),
that._y2 + that._k * (that._y1 - y),
that._x2,
that._y2
);
}
function Cardinal(context, tension) {
this._context = context;
this._k = (1 - tension) / 6;
}
Cardinal.prototype = {
areaStart: function() {
this._line = 0;
},
areaEnd: function() {
this._line = NaN;
},
lineStart: function() {
this._x0 = this._x1 = this._x2 =
this._y0 = this._y1 = this._y2 = NaN;
this._point = 0;
},
lineEnd: function() {
switch (this._point) {
case 2: this._context.lineTo(this._x2, this._y2); break;
case 3: point(this, this._x1, this._y1); break;
}
if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
this._line = 1 - this._line;
},
point: function(x, y) {
x = +x, y = +y;
switch (this._point) {
case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
case 1: this._point = 2; this._x1 = x, this._y1 = y; break;
case 2: this._point = 3; // proceed
default: point(this, x, y); break;
}
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
/* unused harmony default export */ var _unused_webpack_default_export = ((function custom(tension) {
function cardinal(context) {
return new Cardinal(context, tension);
}
cardinal.tension = function(tension) {
return custom(+tension);
};
return cardinal;
})(0));
/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {
var hierarchy = __webpack_require__(193);
var Layout =
/*#__PURE__*/
function () {
function Layout(root, options) {
if (options === void 0) {
options = {};
}
var me = this;
me.options = options;
me.rootNode = hierarchy(root, options);
}
var _proto = Layout.prototype;
_proto.execute = function execute() {
throw new Error('please override this method');
};
return Layout;
}();
module.exports = Layout;
/***/ }),
/* 65 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = clipExtent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__buffer__ = __webpack_require__(106);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__line__ = __webpack_require__(200);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__polygon__ = __webpack_require__(107);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_d3_array__ = __webpack_require__(14);
var clipMax = 1e9, clipMin = -clipMax;
// TODO Use d3-polygon’s polygonContains here for the ring check?
// TODO Eliminate duplicate buffering in clipBuffer and polygon.push?
function clipExtent(x0, y0, x1, y1) {
function visible(x, y) {
return x0 <= x && x <= x1 && y0 <= y && y <= y1;
}
function interpolate(from, to, direction, stream) {
var a = 0, a1 = 0;
if (from == null
|| (a = corner(from, direction)) !== (a1 = corner(to, direction))
|| comparePoint(from, to) < 0 ^ direction > 0) {
do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
while ((a = (a + direction + 4) % 4) !== a1);
} else {
stream.point(to[0], to[1]);
}
}
function corner(p, direction) {
return Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[0] - x0) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 0 : 3
: Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[0] - x1) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 2 : 1
: Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[1] - y0) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 1 : 0
: direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon
}
function compareIntersection(a, b) {
return comparePoint(a.x, b.x);
}
function comparePoint(a, b) {
var ca = corner(a, 1),
cb = corner(b, 1);
return ca !== cb ? ca - cb
: ca === 0 ? b[1] - a[1]
: ca === 1 ? a[0] - b[0]
: ca === 2 ? a[1] - b[1]
: b[0] - a[0];
}
return function(stream) {
var activeStream = stream,
bufferStream = Object(__WEBPACK_IMPORTED_MODULE_1__buffer__["a" /* default */])(),
segments,
polygon,
ring,
x__, y__, v__, // first point
x_, y_, v_, // previous point
first,
clean;
var clipStream = {
point: point,
lineStart: lineStart,
lineEnd: lineEnd,
polygonStart: polygonStart,
polygonEnd: polygonEnd
};
function point(x, y) {
if (visible(x, y)) activeStream.point(x, y);
}
function polygonInside() {
var winding = 0;
for (var i = 0, n = polygon.length; i < n; ++i) {
for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }
else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
}
}
return winding;
}
// Buffer geometry within a polygon and then clip it en masse.
function polygonStart() {
activeStream = bufferStream, segments = [], polygon = [], clean = true;
}
function polygonEnd() {
var startInside = polygonInside(),
cleanInside = clean && startInside,
visible = (segments = Object(__WEBPACK_IMPORTED_MODULE_4_d3_array__["merge"])(segments)).length;
if (cleanInside || visible) {
stream.polygonStart();
if (cleanInside) {
stream.lineStart();
interpolate(null, null, 1, stream);
stream.lineEnd();
}
if (visible) {
Object(__WEBPACK_IMPORTED_MODULE_3__polygon__["a" /* default */])(segments, compareIntersection, startInside, interpolate, stream);
}
stream.polygonEnd();
}
activeStream = stream, segments = polygon = ring = null;
}
function lineStart() {
clipStream.point = linePoint;
if (polygon) polygon.push(ring = []);
first = true;
v_ = false;
x_ = y_ = NaN;
}
// TODO rather than special-case polygons, simply handle them separately.
// Ideally, coincident intersection points should be jittered to avoid
// clipping issues.
function lineEnd() {
if (segments) {
linePoint(x__, y__);
if (v__ && v_) bufferStream.rejoin();
segments.push(bufferStream.result());
}
clipStream.point = point;
if (v_) activeStream.lineEnd();
}
function linePoint(x, y) {
var v = visible(x, y);
if (polygon) ring.push([x, y]);
if (first) {
x__ = x, y__ = y, v__ = v;
first = false;
if (v) {
activeStream.lineStart();
activeStream.point(x, y);
}
} else {
if (v && v_) activeStream.point(x, y);
else {
var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],
b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
if (Object(__WEBPACK_IMPORTED_MODULE_2__line__["a" /* default */])(a, b, x0, y0, x1, y1)) {
if (!v_) {
activeStream.lineStart();
activeStream.point(a[0], a[1]);
}
activeStream.point(b[0], b[1]);
if (!v) activeStream.lineEnd();
clean = false;
} else if (v) {
activeStream.lineStart();
activeStream.point(x, y);
clean = false;
}
}
}
x_ = x, y_ = y, v_ = v;
}
return clipStream;
};
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
var x0 = 0,
y0 = 0,
x1 = 960,
y1 = 500,
cache,
cacheStream,
clip;
return clip = {
stream: function(stream) {
return cache && cacheStream === stream ? cache : cache = clipExtent(x0, y0, x1, y1)(cacheStream = stream);
},
extent: function(_) {
return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]];
}
};
});
/***/ }),
/* 66 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(36);
/* harmony default export */ __webpack_exports__["a"] = (function(values, p, valueof) {
if (valueof == null) valueof = __WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */];
if (!(n = values.length)) return;
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
var n,
i = (n - 1) * p,
i0 = Math.floor(i),
value0 = +valueof(values[i0], i0, values),
value1 = +valueof(values[i0 + 1], i0 + 1, values);
return value0 + (value1 - value0) * (i - i0);
});
/***/ }),
/* 67 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return x;
});
/***/ }),
/* 68 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = conicEqualAreaRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__conic__ = __webpack_require__(69);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__cylindricalEqualArea__ = __webpack_require__(229);
function conicEqualAreaRaw(y0, y1) {
var sy0 = Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y0), n = (sy0 + Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y1)) / 2;
// Are the parallels symmetrical around the Equator?
if (Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(n) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */]) return Object(__WEBPACK_IMPORTED_MODULE_2__cylindricalEqualArea__["a" /* cylindricalEqualAreaRaw */])(y0);
var c = 1 + sy0 * (2 * n - sy0), r0 = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(c) / n;
function project(x, y) {
var r = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(c - 2 * n * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y)) / n;
return [r * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(x *= n), r0 - r * Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(x)];
}
project.invert = function(x, y) {
var r0y = r0 - y;
return [Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(x, Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(r0y)) / n * Object(__WEBPACK_IMPORTED_MODULE_0__math__["s" /* sign */])(r0y), Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
};
return project;
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_1__conic__["a" /* conicProjection */])(conicEqualAreaRaw)
.scale(155.424)
.center([0, 33.6442]);
});
/***/ }),
/* 69 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = conicProjection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(17);
function conicProjection(projectAt) {
var phi0 = 0,
phi1 = __WEBPACK_IMPORTED_MODULE_0__math__["o" /* pi */] / 3,
m = Object(__WEBPACK_IMPORTED_MODULE_1__index__["b" /* projectionMutator */])(projectAt),
p = m(phi0, phi1);
p.parallels = function(_) {
return arguments.length ? m(phi0 = _[0] * __WEBPACK_IMPORTED_MODULE_0__math__["r" /* radians */], phi1 = _[1] * __WEBPACK_IMPORTED_MODULE_0__math__["r" /* radians */]) : [phi0 * __WEBPACK_IMPORTED_MODULE_0__math__["h" /* degrees */], phi1 * __WEBPACK_IMPORTED_MODULE_0__math__["h" /* degrees */]];
};
return p;
}
/***/ }),
/* 70 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = fitExtent;
/* harmony export (immutable) */ __webpack_exports__["b"] = fitSize;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__stream__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__path_bounds__ = __webpack_require__(124);
function fitExtent(projection, extent, object) {
var w = extent[1][0] - extent[0][0],
h = extent[1][1] - extent[0][1],
clip = projection.clipExtent && projection.clipExtent();
projection
.scale(150)
.translate([0, 0]);
if (clip != null) projection.clipExtent(null);
Object(__WEBPACK_IMPORTED_MODULE_0__stream__["a" /* default */])(object, projection.stream(__WEBPACK_IMPORTED_MODULE_1__path_bounds__["a" /* default */]));
var b = __WEBPACK_IMPORTED_MODULE_1__path_bounds__["a" /* default */].result(),
k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
if (clip != null) projection.clipExtent(clip);
return projection
.scale(k * 150)
.translate([x, y]);
}
function fitSize(projection, size, object) {
return fitExtent(projection, [[0, 0], size], object);
}
/***/ }),
/* 71 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = mercatorRaw;
/* harmony export (immutable) */ __webpack_exports__["b"] = mercatorProjection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rotation__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__index__ = __webpack_require__(17);
function mercatorRaw(lambda, phi) {
return [lambda, Object(__WEBPACK_IMPORTED_MODULE_0__math__["n" /* log */])(Object(__WEBPACK_IMPORTED_MODULE_0__math__["v" /* tan */])((__WEBPACK_IMPORTED_MODULE_0__math__["l" /* halfPi */] + phi) / 2))];
}
mercatorRaw.invert = function(x, y) {
return [x, 2 * Object(__WEBPACK_IMPORTED_MODULE_0__math__["d" /* atan */])(Object(__WEBPACK_IMPORTED_MODULE_0__math__["k" /* exp */])(y)) - __WEBPACK_IMPORTED_MODULE_0__math__["l" /* halfPi */]];
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return mercatorProjection(mercatorRaw)
.scale(961 / __WEBPACK_IMPORTED_MODULE_0__math__["w" /* tau */]);
});
function mercatorProjection(project) {
var m = Object(__WEBPACK_IMPORTED_MODULE_2__index__["a" /* default */])(project),
center = m.center,
scale = m.scale,
translate = m.translate,
clipExtent = m.clipExtent,
x0 = null, y0, x1, y1; // clip extent
m.scale = function(_) {
return arguments.length ? (scale(_), reclip()) : scale();
};
m.translate = function(_) {
return arguments.length ? (translate(_), reclip()) : translate();
};
m.center = function(_) {
return arguments.length ? (center(_), reclip()) : center();
};
m.clipExtent = function(_) {
return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];
};
function reclip() {
var k = __WEBPACK_IMPORTED_MODULE_0__math__["o" /* pi */] * scale(),
t = m(Object(__WEBPACK_IMPORTED_MODULE_1__rotation__["a" /* default */])(m.rotate()).invert([0, 0]));
return clipExtent(x0 == null
? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw
? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]]
: [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);
}
return reclip();
}
/***/ }),
/* 72 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = collignonRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
function collignonRaw(lambda, phi) {
var alpha = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(1 - Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(phi));
return [(2 / __WEBPACK_IMPORTED_MODULE_1__math__["E" /* sqrtPi */]) * lambda * alpha, __WEBPACK_IMPORTED_MODULE_1__math__["E" /* sqrtPi */] * (1 - alpha)];
}
collignonRaw.invert = function(x, y) {
var lambda = (lambda = y / __WEBPACK_IMPORTED_MODULE_1__math__["E" /* sqrtPi */] - 1) * lambda;
return [lambda > 0 ? x * Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(__WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / lambda) / 2 : 0, Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(1 - lambda)];
};
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(collignonRaw)
.scale(95.6464)
.center([0, 30]);
});
/***/ }),
/* 73 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return sinuMollweidePhi; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return sinuMollweideY; });
/* harmony export (immutable) */ __webpack_exports__["c"] = sinuMollweideRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mollweide__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__sinusoidal__ = __webpack_require__(38);
var sinuMollweidePhi = 0.7109889596207567;
var sinuMollweideY = 0.0528035274542;
function sinuMollweideRaw(lambda, phi) {
return phi > -sinuMollweidePhi
? (lambda = Object(__WEBPACK_IMPORTED_MODULE_1__mollweide__["d" /* mollweideRaw */])(lambda, phi), lambda[1] += sinuMollweideY, lambda)
: Object(__WEBPACK_IMPORTED_MODULE_2__sinusoidal__["b" /* sinusoidalRaw */])(lambda, phi);
}
sinuMollweideRaw.invert = function(x, y) {
return y > -sinuMollweidePhi
? __WEBPACK_IMPORTED_MODULE_1__mollweide__["d" /* mollweideRaw */].invert(x, y - sinuMollweideY)
: __WEBPACK_IMPORTED_MODULE_2__sinusoidal__["b" /* sinusoidalRaw */].invert(x, y);
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(sinuMollweideRaw)
.rotate([-20, -55])
.scale(164.263)
.center([0, -5.4036]);
});
/***/ }),
/* 74 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// TODO generate on-the-fly to avoid external modification.
var octahedron = [
[0, 90],
[-90, 0], [0, 0], [90, 0], [180, 0],
[0, -90]
];
/* harmony default export */ __webpack_exports__["a"] = ([
[0, 2, 1],
[0, 3, 2],
[5, 1, 2],
[5, 2, 3],
[0, 1, 4],
[0, 4, 3],
[5, 4, 1],
[5, 3, 4]
].map(function(face) {
return face.map(function(i) {
return octahedron[i];
});
}));
/***/ }),
/* 75 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
/* harmony default export */ __webpack_exports__["a"] = (function(project) {
var dx = project(__WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */], 0)[0] - project(-__WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */], 0)[0];
function projectQuincuncial(lambda, phi) {
var t = Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(lambda) < __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */],
p = project(t ? lambda : lambda > 0 ? lambda - __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] : lambda + __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */], phi),
x = (p[0] - p[1]) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */],
y = (p[0] + p[1]) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */];
if (t) return [x, y];
var d = dx * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */],
s = x > 0 ^ y > 0 ? -1 : 1;
return [s * x - Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(y) * d, s * y - Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(x) * d];
}
if (project.invert) projectQuincuncial.invert = function(x0, y0) {
var x = (x0 + y0) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */],
y = (y0 - x0) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */],
t = Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(x) < 0.5 * dx && Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(y) < 0.5 * dx;
if (!t) {
var d = dx * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */],
s = x > 0 ^ y > 0 ? -1 : 1,
x1 = -s * x0 + (y > 0 ? 1 : -1) * d,
y1 = -s * y0 + (x > 0 ? 1 : -1) * d;
x = (-x1 - y1) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */];
y = (x1 - y1) * __WEBPACK_IMPORTED_MODULE_1__math__["C" /* sqrt1_2 */];
}
var p = project.invert(x, y);
if (!t) p[0] += x > 0 ? __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] : -__WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */];
return p;
};
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(projectQuincuncial)
.rotate([-90, -90, 45])
.clipAngle(180 - 1e-3);
});
/***/ }),
/* 76 */
/***/ (function(module, exports) {
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';
};
module.exports = isObject;
/***/ }),
/* 77 */
/***/ (function(module, exports) {
// isFinite,
var isNil = function isNil(value) {
/**
* isNil(null) => true
* isNil() => true
*/
return value === null || value === undefined;
};
module.exports = isNil;
/***/ }),
/* 78 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = rotateRadians;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__compose__ = __webpack_require__(144);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(5);
function rotationIdentity(lambda, phi) {
return [lambda > __WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda - __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda < -__WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda + __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda, phi];
}
rotationIdentity.invert = rotationIdentity;
function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
return (deltaLambda %= __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */]) ? (deltaPhi || deltaGamma ? Object(__WEBPACK_IMPORTED_MODULE_0__compose__["a" /* default */])(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma))
: rotationLambda(deltaLambda))
: (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma)
: rotationIdentity);
}
function forwardRotationLambda(deltaLambda) {
return function(lambda, phi) {
return lambda += deltaLambda, [lambda > __WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda - __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda < -__WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] ? lambda + __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] : lambda, phi];
};
}
function rotationLambda(deltaLambda) {
var rotation = forwardRotationLambda(deltaLambda);
rotation.invert = forwardRotationLambda(-deltaLambda);
return rotation;
}
function rotationPhiGamma(deltaPhi, deltaGamma) {
var cosDeltaPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(deltaPhi),
sinDeltaPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(deltaPhi),
cosDeltaGamma = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(deltaGamma),
sinDeltaGamma = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(deltaGamma);
function rotation(lambda, phi) {
var cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(lambda) * cosPhi,
y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(lambda) * cosPhi,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = z * cosDeltaPhi + x * sinDeltaPhi;
return [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
Object(__WEBPACK_IMPORTED_MODULE_1__math__["c" /* asin */])(k * cosDeltaGamma + y * sinDeltaGamma)
];
}
rotation.invert = function(lambda, phi) {
var cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(lambda) * cosPhi,
y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(lambda) * cosPhi,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = z * cosDeltaGamma - y * sinDeltaGamma;
return [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
Object(__WEBPACK_IMPORTED_MODULE_1__math__["c" /* asin */])(k * cosDeltaPhi - x * sinDeltaPhi)
];
};
return rotation;
}
/* harmony default export */ __webpack_exports__["a"] = (function(rotate) {
rotate = rotateRadians(rotate[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], rotate[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], rotate.length > 2 ? rotate[2] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */] : 0);
function forward(coordinates) {
coordinates = rotate(coordinates[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], coordinates[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */]);
return coordinates[0] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates[1] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates;
}
forward.invert = function(coordinates) {
coordinates = rotate.invert(coordinates[0] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], coordinates[1] * __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */]);
return coordinates[0] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates[1] *= __WEBPACK_IMPORTED_MODULE_1__math__["h" /* degrees */], coordinates;
};
return forward;
});
/***/ }),
/* 79 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = conicEqualAreaRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__conic__ = __webpack_require__(80);
function conicEqualAreaRaw(y0, y1) {
var sy0 = Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y0),
n = (sy0 + Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y1)) / 2,
c = 1 + sy0 * (2 * n - sy0),
r0 = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(c) / n;
function project(x, y) {
var r = Object(__WEBPACK_IMPORTED_MODULE_0__math__["u" /* sqrt */])(c - 2 * n * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(y)) / n;
return [r * Object(__WEBPACK_IMPORTED_MODULE_0__math__["t" /* sin */])(x *= n), r0 - r * Object(__WEBPACK_IMPORTED_MODULE_0__math__["g" /* cos */])(x)];
}
project.invert = function(x, y) {
var r0y = r0 - y;
return [Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* atan2 */])(x, r0y) / n, Object(__WEBPACK_IMPORTED_MODULE_0__math__["c" /* asin */])((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
};
return project;
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_1__conic__["a" /* conicProjection */])(conicEqualAreaRaw)
.scale(155.424)
.center([0, 33.6442]);
});
/***/ }),
/* 80 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = conicProjection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(18);
function conicProjection(projectAt) {
var phi0 = 0,
phi1 = __WEBPACK_IMPORTED_MODULE_0__math__["o" /* pi */] / 3,
m = Object(__WEBPACK_IMPORTED_MODULE_1__index__["b" /* projectionMutator */])(projectAt),
p = m(phi0, phi1);
p.parallels = function(_) {
return arguments.length ? m(phi0 = _[0] * __WEBPACK_IMPORTED_MODULE_0__math__["r" /* radians */], phi1 = _[1] * __WEBPACK_IMPORTED_MODULE_0__math__["r" /* radians */]) : [phi0 * __WEBPACK_IMPORTED_MODULE_0__math__["h" /* degrees */], phi1 * __WEBPACK_IMPORTED_MODULE_0__math__["h" /* degrees */]];
};
return p;
}
/***/ }),
/* 81 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = transform;
/* harmony default export */ __webpack_exports__["a"] = (function(prototype) {
return {
stream: transform(prototype)
};
});
function transform(prototype) {
function T() {}
var p = T.prototype = Object.create(Transform.prototype);
for (var k in prototype) p[k] = prototype[k];
return function(stream) {
var t = new T;
t.stream = stream;
return t;
};
}
function Transform() {}
Transform.prototype = {
point: function(x, y) { this.stream.point(x, y); },
sphere: function() { this.stream.sphere(); },
lineStart: function() { this.stream.lineStart(); },
lineEnd: function() { this.stream.lineEnd(); },
polygonStart: function() { this.stream.polygonStart(); },
polygonEnd: function() { this.stream.polygonEnd(); }
};
/***/ }),
/* 82 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = mercatorRaw;
/* harmony export (immutable) */ __webpack_exports__["b"] = mercatorProjection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(5);
function mercatorRaw(lambda, phi) {
return [lambda, Object(__WEBPACK_IMPORTED_MODULE_1__math__["n" /* log */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["v" /* tan */])((__WEBPACK_IMPORTED_MODULE_1__math__["l" /* halfPi */] + phi) / 2))];
}
mercatorRaw.invert = function(x, y) {
return [x, 2 * Object(__WEBPACK_IMPORTED_MODULE_1__math__["d" /* atan */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["k" /* exp */])(y)) - __WEBPACK_IMPORTED_MODULE_1__math__["l" /* halfPi */]];
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return mercatorProjection(mercatorRaw)
.scale(961 / __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */]);
});
function mercatorProjection(project) {
var m = Object(__WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */])(project),
scale = m.scale,
translate = m.translate,
clipExtent = m.clipExtent,
clipAuto;
m.scale = function(_) {
return arguments.length ? (scale(_), clipAuto && m.clipExtent(null), m) : scale();
};
m.translate = function(_) {
return arguments.length ? (translate(_), clipAuto && m.clipExtent(null), m) : translate();
};
m.clipExtent = function(_) {
if (!arguments.length) return clipAuto ? null : clipExtent();
if (clipAuto = _ == null) {
var k = __WEBPACK_IMPORTED_MODULE_1__math__["o" /* pi */] * scale(),
t = translate();
_ = [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]];
}
clipExtent(_);
return m;
};
return m.clipExtent(null);
}
/***/ }),
/* 83 */
/***/ (function(module, exports, __webpack_require__) {
var each = __webpack_require__(9);
var isFunction = __webpack_require__(11);
var values = Object.values ? function (obj) {
return Object.values(obj);
} : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(value);
}
});
return result;
};
module.exports = values;
/***/ }),
/* 84 */
/***/ (function(module, exports) {
module.exports = {
HIERARCHY: 'hierarchy',
GEO: 'geo',
HEX: 'hex',
GRAPH: 'graph',
TABLE: 'table',
GEO_GRATICULE: 'geo-graticule',
STATISTICS_METHODS: ['max', 'mean', // alias: average
'median', 'min', 'mode', 'product', 'standardDeviation', 'sum', 'sumSimple', 'variance']
};
/***/ }),
/* 85 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var EOL = {},
EOF = {},
QUOTE = 34,
NEWLINE = 10,
RETURN = 13;
function objectConverter(columns) {
return new Function("d", "return {" + columns.map(function(name, i) {
return JSON.stringify(name) + ": d[" + i + "]";
}).join(",") + "}");
}
function customConverter(columns, f) {
var object = objectConverter(columns);
return function(row, i) {
return f(object(row), i, columns);
};
}
// Compute unique columns in order of discovery.
function inferColumns(rows) {
var columnSet = Object.create(null),
columns = [];
rows.forEach(function(row) {
for (var column in row) {
if (!(column in columnSet)) {
columns.push(columnSet[column] = column);
}
}
});
return columns;
}
/* harmony default export */ __webpack_exports__["a"] = (function(delimiter) {
var reFormat = new RegExp("[\"" + delimiter + "\n\r]"),
DELIMITER = delimiter.charCodeAt(0);
function parse(text, f) {
var convert, columns, rows = parseRows(text, function(row, i) {
if (convert) return convert(row, i - 1);
columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
});
rows.columns = columns || [];
return rows;
}
function parseRows(text, f) {
var rows = [], // output rows
N = text.length,
I = 0, // current character index
n = 0, // current line number
t, // current token
eof = N <= 0, // current token followed by EOF?
eol = false; // current token followed by EOL?
// Strip the trailing newline.
if (text.charCodeAt(N - 1) === NEWLINE) --N;
if (text.charCodeAt(N - 1) === RETURN) --N;
function token() {
if (eof) return EOF;
if (eol) return eol = false, EOL;
// Unescape quotes.
var i, j = I, c;
if (text.charCodeAt(j) === QUOTE) {
while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE);
if ((i = I) >= N) eof = true;
else if ((c = text.charCodeAt(I++)) === NEWLINE) eol = true;
else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
return text.slice(j + 1, i - 1).replace(/""/g, "\"");
}
// Find next delimiter or newline.
while (I < N) {
if ((c = text.charCodeAt(i = I++)) === NEWLINE) eol = true;
else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
else if (c !== DELIMITER) continue;
return text.slice(j, i);
}
// Return last token before EOF.
return eof = true, text.slice(j, N);
}
while ((t = token()) !== EOF) {
var row = [];
while (t !== EOL && t !== EOF) row.push(t), t = token();
if (f && (row = f(row, n++)) == null) continue;
rows.push(row);
}
return rows;
}
function format(rows, columns) {
if (columns == null) columns = inferColumns(rows);
return [columns.map(formatValue).join(delimiter)].concat(rows.map(function(row) {
return columns.map(function(column) {
return formatValue(row[column]);
}).join(delimiter);
})).join("\n");
}
function formatRows(rows) {
return rows.map(formatRow).join("\n");
}
function formatRow(row) {
return row.map(formatValue).join(delimiter);
}
function formatValue(text) {
return text == null ? ""
: reFormat.test(text += "") ? "\"" + text.replace(/"/g, "\"\"") + "\""
: text;
}
return {
parse: parse,
parseRows: parseRows,
format: format,
formatRows: formatRows
};
});
/***/ }),
/* 86 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = hierarchy;
/* harmony export (immutable) */ __webpack_exports__["b"] = computeHeight;
/* harmony export (immutable) */ __webpack_exports__["a"] = Node;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__count__ = __webpack_require__(370);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each__ = __webpack_require__(371);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__eachBefore__ = __webpack_require__(372);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__eachAfter__ = __webpack_require__(373);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sum__ = __webpack_require__(374);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__sort__ = __webpack_require__(375);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__path__ = __webpack_require__(376);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ancestors__ = __webpack_require__(377);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__descendants__ = __webpack_require__(378);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__leaves__ = __webpack_require__(379);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__links__ = __webpack_require__(380);
function hierarchy(data, children) {
var root = new Node(data),
valued = +data.value && (root.value = data.value),
node,
nodes = [root],
child,
childs,
i,
n;
if (children == null) children = defaultChildren;
while (node = nodes.pop()) {
if (valued) node.value = +node.data.value;
if ((childs = children(node.data)) && (n = childs.length)) {
node.children = new Array(n);
for (i = n - 1; i >= 0; --i) {
nodes.push(child = node.children[i] = new Node(childs[i]));
child.parent = node;
child.depth = node.depth + 1;
}
}
}
return root.eachBefore(computeHeight);
}
function node_copy() {
return hierarchy(this).eachBefore(copyData);
}
function defaultChildren(d) {
return d.children;
}
function copyData(node) {
node.data = node.data.data;
}
function computeHeight(node) {
var height = 0;
do node.height = height;
while ((node = node.parent) && (node.height < ++height));
}
function Node(data) {
this.data = data;
this.depth =
this.height = 0;
this.parent = null;
}
Node.prototype = hierarchy.prototype = {
constructor: Node,
count: __WEBPACK_IMPORTED_MODULE_0__count__["a" /* default */],
each: __WEBPACK_IMPORTED_MODULE_1__each__["a" /* default */],
eachAfter: __WEBPACK_IMPORTED_MODULE_3__eachAfter__["a" /* default */],
eachBefore: __WEBPACK_IMPORTED_MODULE_2__eachBefore__["a" /* default */],
sum: __WEBPACK_IMPORTED_MODULE_4__sum__["a" /* default */],
sort: __WEBPACK_IMPORTED_MODULE_5__sort__["a" /* default */],
path: __WEBPACK_IMPORTED_MODULE_6__path__["a" /* default */],
ancestors: __WEBPACK_IMPORTED_MODULE_7__ancestors__["a" /* default */],
descendants: __WEBPACK_IMPORTED_MODULE_8__descendants__["a" /* default */],
leaves: __WEBPACK_IMPORTED_MODULE_9__leaves__["a" /* default */],
links: __WEBPACK_IMPORTED_MODULE_10__links__["a" /* default */],
copy: node_copy
};
/***/ }),
/* 87 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = optional;
/* harmony export (immutable) */ __webpack_exports__["b"] = required;
function optional(f) {
return f == null ? null : required(f);
}
function required(f) {
if (typeof f !== "function") throw new Error;
return f;
}
/***/ }),
/* 88 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return phi; });
/* harmony export (immutable) */ __webpack_exports__["c"] = squarifyRatio;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dice__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__slice__ = __webpack_require__(55);
var phi = (1 + Math.sqrt(5)) / 2;
function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
var rows = [],
nodes = parent.children,
row,
nodeValue,
i0 = 0,
i1 = 0,
n = nodes.length,
dx, dy,
value = parent.value,
sumValue,
minValue,
maxValue,
newRatio,
minRatio,
alpha,
beta;
while (i0 < n) {
dx = x1 - x0, dy = y1 - y0;
// Find the next non-empty node.
do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
minValue = maxValue = sumValue;
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
beta = sumValue * sumValue * alpha;
minRatio = Math.max(maxValue / beta, beta / minValue);
// Keep adding nodes while the aspect ratio maintains or improves.
for (; i1 < n; ++i1) {
sumValue += nodeValue = nodes[i1].value;
if (nodeValue < minValue) minValue = nodeValue;
if (nodeValue > maxValue) maxValue = nodeValue;
beta = sumValue * sumValue * alpha;
newRatio = Math.max(maxValue / beta, beta / minValue);
if (newRatio > minRatio) { sumValue -= nodeValue; break; }
minRatio = newRatio;
}
// Position and record the row orientation.
rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
if (row.dice) Object(__WEBPACK_IMPORTED_MODULE_0__dice__["a" /* default */])(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
else Object(__WEBPACK_IMPORTED_MODULE_1__slice__["a" /* default */])(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
value -= sumValue, i0 = i1;
}
return rows;
}
/* harmony default export */ __webpack_exports__["a"] = ((function custom(ratio) {
function squarify(parent, x0, y0, x1, y1) {
squarifyRatio(ratio, parent, x0, y0, x1, y1);
}
squarify.ratio = function(x) {
return custom((x = +x) > 1 ? x : 1);
};
return squarify;
})(phi));
/***/ }),
/* 89 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__identity__ = __webpack_require__(165);
/* harmony default export */ __webpack_exports__["a"] = (function(transform) {
if (transform == null) return __WEBPACK_IMPORTED_MODULE_0__identity__["a" /* default */];
var x0,
y0,
kx = transform.scale[0],
ky = transform.scale[1],
dx = transform.translate[0],
dy = transform.translate[1];
return function(input, i) {
if (!i) x0 = y0 = 0;
var j = 2, n = input.length, output = new Array(n);
output[0] = (x0 += input[0]) * kx + dx;
output[1] = (y0 += input[1]) * ky + dy;
while (j < n) output[j] = input[j], ++j;
return output;
};
});
/***/ }),
/* 90 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export feature */
/* harmony export (immutable) */ __webpack_exports__["b"] = object;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__reverse__ = __webpack_require__(392);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__transform__ = __webpack_require__(89);
/* harmony default export */ __webpack_exports__["a"] = (function(topology, o) {
return o.type === "GeometryCollection"
? {type: "FeatureCollection", features: o.geometries.map(function(o) { return feature(topology, o); })}
: feature(topology, o);
});
function feature(topology, o) {
var id = o.id,
bbox = o.bbox,
properties = o.properties == null ? {} : o.properties,
geometry = object(topology, o);
return id == null && bbox == null ? {type: "Feature", properties: properties, geometry: geometry}
: bbox == null ? {type: "Feature", id: id, properties: properties, geometry: geometry}
: {type: "Feature", id: id, bbox: bbox, properties: properties, geometry: geometry};
}
function object(topology, o) {
var transformPoint = Object(__WEBPACK_IMPORTED_MODULE_1__transform__["a" /* default */])(topology.transform),
arcs = topology.arcs;
function arc(i, points) {
if (points.length) points.pop();
for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) {
points.push(transformPoint(a[k], k));
}
if (i < 0) Object(__WEBPACK_IMPORTED_MODULE_0__reverse__["a" /* default */])(points, n);
}
function point(p) {
return transformPoint(p);
}
function line(arcs) {
var points = [];
for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points);
if (points.length < 2) points.push(points[0]); // This should never happen per the specification.
return points;
}
function ring(arcs) {
var points = line(arcs);
while (points.length < 4) points.push(points[0]); // This may happen if an arc has only two points.
return points;
}
function polygon(arcs) {
return arcs.map(ring);
}
function geometry(o) {
var type = o.type, coordinates;
switch (type) {
case "GeometryCollection": return {type: type, geometries: o.geometries.map(geometry)};
case "Point": coordinates = point(o.coordinates); break;
case "MultiPoint": coordinates = o.coordinates.map(point); break;
case "LineString": coordinates = line(o.arcs); break;
case "MultiLineString": coordinates = o.arcs.map(line); break;
case "Polygon": coordinates = polygon(o.arcs); break;
case "MultiPolygon": coordinates = o.arcs.map(polygon); break;
default: return null;
}
return {type: type, coordinates: coordinates};
}
return geometry(o);
}
/***/ }),
/* 91 */
/***/ (function(module, exports) {
var isArrayLike = function isArrayLike(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);
};
module.exports = isArrayLike;
/***/ }),
/* 92 */
/***/ (function(module, exports) {
/*
* @reference: https://github.com/jasondavies/science.js/blob/master/src/stats/kernel.js
* @reference: https://github.com/Planeshifter/kernel-smooth/blob/master/lib/index.js#L16
*/
function uniform(u) {
return Math.abs(u) <= 1 ? 0.5 : 0;
}
function tricubed(u) {
var abs = 1 - Math.pow(Math.abs(u), 3);
return Math.pow(abs, 3);
}
module.exports = {
boxcar: uniform,
cosine: function cosine(u) {
if (Math.abs(u) <= 1) {
return Math.PI / 4 * Math.cos(Math.PI / 2 * u);
}
return 0;
},
epanechnikov: function epanechnikov(u) {
return Math.abs(u) < 1 ? 0.75 * (1 - u * u) : 0;
},
gaussian: function gaussian(u) {
// return 1 / Math.sqrt(2 * Math.PI) * Math.exp(-0.5 * u * u);
return 0.3989422804 * Math.exp(-0.5 * u * u);
},
quartic: function quartic(u) {
if (Math.abs(u) < 1) {
var tmp = 1 - u * u;
return 15 / 16 * tmp * tmp;
}
return 0;
},
triangular: function triangular(u) {
var abs = Math.abs(u);
return abs < 1 ? 1 - abs : 0;
},
tricube: function tricube(u) {
return Math.abs(u) < 1 ? 70 / 81 * tricubed(u) : 0;
},
triweight: function triweight(u) {
if (Math.abs(u) < 1) {
var tmp = 1 - u * u;
return 35 / 32 * tmp * tmp * tmp;
}
return 0;
},
uniform: uniform
};
/***/ }),
/* 93 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _ = __webpack_require__(13);
module.exports = Graph;
var DEFAULT_EDGE_NAME = "\x00",
GRAPH_NODE = "\x00",
EDGE_KEY_DELIM = "\x01";
// Implementation notes:
//
// * Node id query functions should return string ids for the nodes
// * Edge id query functions should return an "edgeObj", edge object, that is
// composed of enough information to uniquely identify an edge: {v, w, name}.
// * Internally we use an "edgeId", a stringified form of the edgeObj, to
// reference edges. This is because we need a performant way to look these
// edges up and, object properties, which have string keys, are the closest
// we're going to get to a performant hashtable in JavaScript.
function Graph(opts) {
this._isDirected = _.has(opts, "directed") ? opts.directed : true;
this._isMultigraph = _.has(opts, "multigraph") ? opts.multigraph : false;
this._isCompound = _.has(opts, "compound") ? opts.compound : false;
// Label for the graph itself
this._label = undefined;
// Defaults to be set when creating a new node
this._defaultNodeLabelFn = _.constant(undefined);
// Defaults to be set when creating a new edge
this._defaultEdgeLabelFn = _.constant(undefined);
// v -> label
this._nodes = {};
if (this._isCompound) {
// v -> parent
this._parent = {};
// v -> children
this._children = {};
this._children[GRAPH_NODE] = {};
}
// v -> edgeObj
this._in = {};
// u -> v -> Number
this._preds = {};
// v -> edgeObj
this._out = {};
// v -> w -> Number
this._sucs = {};
// e -> edgeObj
this._edgeObjs = {};
// e -> label
this._edgeLabels = {};
}
/* Number of nodes in the graph. Should only be changed by the implementation. */
Graph.prototype._nodeCount = 0;
/* Number of edges in the graph. Should only be changed by the implementation. */
Graph.prototype._edgeCount = 0;
/* === Graph functions ========= */
Graph.prototype.isDirected = function() {
return this._isDirected;
};
Graph.prototype.isMultigraph = function() {
return this._isMultigraph;
};
Graph.prototype.isCompound = function() {
return this._isCompound;
};
Graph.prototype.setGraph = function(label) {
this._label = label;
return this;
};
Graph.prototype.graph = function() {
return this._label;
};
/* === Node functions ========== */
Graph.prototype.setDefaultNodeLabel = function(newDefault) {
if (!_.isFunction(newDefault)) {
newDefault = _.constant(newDefault);
}
this._defaultNodeLabelFn = newDefault;
return this;
};
Graph.prototype.nodeCount = function() {
return this._nodeCount;
};
Graph.prototype.nodes = function() {
return _.keys(this._nodes);
};
Graph.prototype.sources = function() {
var self = this;
return _.filter(this.nodes(), function(v) {
return _.isEmpty(self._in[v]);
});
};
Graph.prototype.sinks = function() {
var self = this;
return _.filter(this.nodes(), function(v) {
return _.isEmpty(self._out[v]);
});
};
Graph.prototype.setNodes = function(vs, value) {
var args = arguments;
var self = this;
_.each(vs, function(v) {
if (args.length > 1) {
self.setNode(v, value);
} else {
self.setNode(v);
}
});
return this;
};
Graph.prototype.setNode = function(v, value) {
if (_.has(this._nodes, v)) {
if (arguments.length > 1) {
this._nodes[v] = value;
}
return this;
}
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
if (this._isCompound) {
this._parent[v] = GRAPH_NODE;
this._children[v] = {};
this._children[GRAPH_NODE][v] = true;
}
this._in[v] = {};
this._preds[v] = {};
this._out[v] = {};
this._sucs[v] = {};
++this._nodeCount;
return this;
};
Graph.prototype.node = function(v) {
return this._nodes[v];
};
Graph.prototype.hasNode = function(v) {
return _.has(this._nodes, v);
};
Graph.prototype.removeNode = function(v) {
var self = this;
if (_.has(this._nodes, v)) {
var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); };
delete this._nodes[v];
if (this._isCompound) {
this._removeFromParentsChildList(v);
delete this._parent[v];
_.each(this.children(v), function(child) {
self.setParent(child);
});
delete this._children[v];
}
_.each(_.keys(this._in[v]), removeEdge);
delete this._in[v];
delete this._preds[v];
_.each(_.keys(this._out[v]), removeEdge);
delete this._out[v];
delete this._sucs[v];
--this._nodeCount;
}
return this;
};
Graph.prototype.setParent = function(v, parent) {
if (!this._isCompound) {
throw new Error("Cannot set parent in a non-compound graph");
}
if (_.isUndefined(parent)) {
parent = GRAPH_NODE;
} else {
// Coerce parent to string
parent += "";
for (var ancestor = parent;
!_.isUndefined(ancestor);
ancestor = this.parent(ancestor)) {
if (ancestor === v) {
throw new Error("Setting " + parent+ " as parent of " + v +
" would create a cycle");
}
}
this.setNode(parent);
}
this.setNode(v);
this._removeFromParentsChildList(v);
this._parent[v] = parent;
this._children[parent][v] = true;
return this;
};
Graph.prototype._removeFromParentsChildList = function(v) {
delete this._children[this._parent[v]][v];
};
Graph.prototype.parent = function(v) {
if (this._isCompound) {
var parent = this._parent[v];
if (parent !== GRAPH_NODE) {
return parent;
}
}
};
Graph.prototype.children = function(v) {
if (_.isUndefined(v)) {
v = GRAPH_NODE;
}
if (this._isCompound) {
var children = this._children[v];
if (children) {
return _.keys(children);
}
} else if (v === GRAPH_NODE) {
return this.nodes();
} else if (this.hasNode(v)) {
return [];
}
};
Graph.prototype.predecessors = function(v) {
var predsV = this._preds[v];
if (predsV) {
return _.keys(predsV);
}
};
Graph.prototype.successors = function(v) {
var sucsV = this._sucs[v];
if (sucsV) {
return _.keys(sucsV);
}
};
Graph.prototype.neighbors = function(v) {
var preds = this.predecessors(v);
if (preds) {
return _.union(preds, this.successors(v));
}
};
Graph.prototype.isLeaf = function (v) {
var neighbors;
if (this.isDirected()) {
neighbors = this.successors(v);
} else {
neighbors = this.neighbors(v);
}
return neighbors.length === 0;
};
Graph.prototype.filterNodes = function(filter) {
var copy = new this.constructor({
directed: this._isDirected,
multigraph: this._isMultigraph,
compound: this._isCompound
});
copy.setGraph(this.graph());
var self = this;
_.each(this._nodes, function(value, v) {
if (filter(v)) {
copy.setNode(v, value);
}
});
_.each(this._edgeObjs, function(e) {
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
copy.setEdge(e, self.edge(e));
}
});
var parents = {};
function findParent(v) {
var parent = self.parent(v);
if (parent === undefined || copy.hasNode(parent)) {
parents[v] = parent;
return parent;
} else if (parent in parents) {
return parents[parent];
} else {
return findParent(parent);
}
}
if (this._isCompound) {
_.each(copy.nodes(), function(v) {
copy.setParent(v, findParent(v));
});
}
return copy;
};
/* === Edge functions ========== */
Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
if (!_.isFunction(newDefault)) {
newDefault = _.constant(newDefault);
}
this._defaultEdgeLabelFn = newDefault;
return this;
};
Graph.prototype.edgeCount = function() {
return this._edgeCount;
};
Graph.prototype.edges = function() {
return _.values(this._edgeObjs);
};
Graph.prototype.setPath = function(vs, value) {
var self = this,
args = arguments;
_.reduce(vs, function(v, w) {
if (args.length > 1) {
self.setEdge(v, w, value);
} else {
self.setEdge(v, w);
}
return w;
});
return this;
};
/*
* setEdge(v, w, [value, [name]])
* setEdge({ v, w, [name] }, [value])
*/
Graph.prototype.setEdge = function() {
var v, w, name, value,
valueSpecified = false,
arg0 = arguments[0];
if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
v = arg0.v;
w = arg0.w;
name = arg0.name;
if (arguments.length === 2) {
value = arguments[1];
valueSpecified = true;
}
} else {
v = arg0;
w = arguments[1];
name = arguments[3];
if (arguments.length > 2) {
value = arguments[2];
valueSpecified = true;
}
}
v = "" + v;
w = "" + w;
if (!_.isUndefined(name)) {
name = "" + name;
}
var e = edgeArgsToId(this._isDirected, v, w, name);
if (_.has(this._edgeLabels, e)) {
if (valueSpecified) {
this._edgeLabels[e] = value;
}
return this;
}
if (!_.isUndefined(name) && !this._isMultigraph) {
throw new Error("Cannot set a named edge when isMultigraph = false");
}
// It didn't exist, so we need to create it.
// First ensure the nodes exist.
this.setNode(v);
this.setNode(w);
this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
// Ensure we add undirected edges in a consistent way.
v = edgeObj.v;
w = edgeObj.w;
Object.freeze(edgeObj);
this._edgeObjs[e] = edgeObj;
incrementOrInitEntry(this._preds[w], v);
incrementOrInitEntry(this._sucs[v], w);
this._in[w][e] = edgeObj;
this._out[v][e] = edgeObj;
this._edgeCount++;
return this;
};
Graph.prototype.edge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name));
return this._edgeLabels[e];
};
Graph.prototype.hasEdge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name));
return _.has(this._edgeLabels, e);
};
Graph.prototype.removeEdge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name)),
edge = this._edgeObjs[e];
if (edge) {
v = edge.v;
w = edge.w;
delete this._edgeLabels[e];
delete this._edgeObjs[e];
decrementOrRemoveEntry(this._preds[w], v);
decrementOrRemoveEntry(this._sucs[v], w);
delete this._in[w][e];
delete this._out[v][e];
this._edgeCount--;
}
return this;
};
Graph.prototype.inEdges = function(v, u) {
var inV = this._in[v];
if (inV) {
var edges = _.values(inV);
if (!u) {
return edges;
}
return _.filter(edges, function(edge) { return edge.v === u; });
}
};
Graph.prototype.outEdges = function(v, w) {
var outV = this._out[v];
if (outV) {
var edges = _.values(outV);
if (!w) {
return edges;
}
return _.filter(edges, function(edge) { return edge.w === w; });
}
};
Graph.prototype.nodeEdges = function(v, w) {
var inEdges = this.inEdges(v, w);
if (inEdges) {
return inEdges.concat(this.outEdges(v, w));
}
};
function incrementOrInitEntry(map, k) {
if (map[k]) {
map[k]++;
} else {
map[k] = 1;
}
}
function decrementOrRemoveEntry(map, k) {
if (!--map[k]) { delete map[k]; }
}
function edgeArgsToId(isDirected, v_, w_, name) {
var v = "" + v_;
var w = "" + w_;
if (!isDirected && v > w) {
var tmp = v;
v = w;
w = tmp;
}
return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +
(_.isUndefined(name) ? DEFAULT_EDGE_NAME : name);
}
function edgeArgsToObj(isDirected, v_, w_, name) {
var v = "" + v_;
var w = "" + w_;
if (!isDirected && v > w) {
var tmp = v;
v = w;
w = tmp;
}
var edgeObj = { v: v, w: w };
if (name) {
edgeObj.name = name;
}
return edgeObj;
}
function edgeObjToId(isDirected, edgeObj) {
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
}
/***/ }),
/* 94 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return prefix; });
var prefix = "$";
function Map() {}
Map.prototype = map.prototype = {
constructor: Map,
has: function(key) {
return (prefix + key) in this;
},
get: function(key) {
return this[prefix + key];
},
set: function(key, value) {
this[prefix + key] = value;
return this;
},
remove: function(key) {
var property = prefix + key;
return property in this && delete this[property];
},
clear: function() {
for (var property in this) if (property[0] === prefix) delete this[property];
},
keys: function() {
var keys = [];
for (var property in this) if (property[0] === prefix) keys.push(property.slice(1));
return keys;
},
values: function() {
var values = [];
for (var property in this) if (property[0] === prefix) values.push(this[property]);
return values;
},
entries: function() {
var entries = [];
for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]});
return entries;
},
size: function() {
var size = 0;
for (var property in this) if (property[0] === prefix) ++size;
return size;
},
empty: function() {
for (var property in this) if (property[0] === prefix) return false;
return true;
},
each: function(f) {
for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
}
};
function map(object, f) {
var map = new Map;
// Copy constructor.
if (object instanceof Map) object.each(function(value, key) { map.set(key, value); });
// Index array by numeric index or specified key function.
else if (Array.isArray(object)) {
var i = -1,
n = object.length,
o;
if (f == null) while (++i < n) map.set(i, object[i]);
else while (++i < n) map.set(f(o = object[i], i, object), o);
}
// Convert object to map.
else if (object) for (var key in object) map.set(key, object[key]);
return map;
}
/* harmony default export */ __webpack_exports__["a"] = (map);
/***/ }),
/* 95 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_path__ = __webpack_require__(33);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constant__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__curve_linear__ = __webpack_require__(60);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__point__ = __webpack_require__(96);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var x = __WEBPACK_IMPORTED_MODULE_3__point__["a" /* x */],
y = __WEBPACK_IMPORTED_MODULE_3__point__["b" /* y */],
defined = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(true),
context = null,
curve = __WEBPACK_IMPORTED_MODULE_2__curve_linear__["a" /* default */],
output = null;
function line(data) {
var i,
n = data.length,
d,
defined0 = false,
buffer;
if (context == null) output = curve(buffer = Object(__WEBPACK_IMPORTED_MODULE_0_d3_path__["path"])());
for (i = 0; i <= n; ++i) {
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
if (defined0 = !defined0) output.lineStart();
else output.lineEnd();
}
if (defined0) output.point(+x(d, i, data), +y(d, i, data));
}
if (buffer) return output = null, buffer + "" || null;
}
line.x = function(_) {
return arguments.length ? (x = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), line) : x;
};
line.y = function(_) {
return arguments.length ? (y = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), line) : y;
};
line.defined = function(_) {
return arguments.length ? (defined = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(!!_), line) : defined;
};
line.curve = function(_) {
return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
};
line.context = function(_) {
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
};
return line;
});
/***/ }),
/* 96 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = x;
/* harmony export (immutable) */ __webpack_exports__["b"] = y;
function x(p) {
return p[0];
}
function y(p) {
return p[1];
}
/***/ }),
/* 97 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = point;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(46);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__cardinal__ = __webpack_require__(63);
function point(that, x, y) {
var x1 = that._x1,
y1 = that._y1,
x2 = that._x2,
y2 = that._y2;
if (that._l01_a > __WEBPACK_IMPORTED_MODULE_0__math__["f" /* epsilon */]) {
var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a,
n = 3 * that._l01_a * (that._l01_a + that._l12_a);
x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
}
if (that._l23_a > __WEBPACK_IMPORTED_MODULE_0__math__["f" /* epsilon */]) {
var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a,
m = 3 * that._l23_a * (that._l23_a + that._l12_a);
x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
}
that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
}
function CatmullRom(context, alpha) {
this._context = context;
this._alpha = alpha;
}
CatmullRom.prototype = {
areaStart: function() {
this._line = 0;
},
areaEnd: function() {
this._line = NaN;
},
lineStart: function() {
this._x0 = this._x1 = this._x2 =
this._y0 = this._y1 = this._y2 = NaN;
this._l01_a = this._l12_a = this._l23_a =
this._l01_2a = this._l12_2a = this._l23_2a =
this._point = 0;
},
lineEnd: function() {
switch (this._point) {
case 2: this._context.lineTo(this._x2, this._y2); break;
case 3: this.point(this._x2, this._y2); break;
}
if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
this._line = 1 - this._line;
},
point: function(x, y) {
x = +x, y = +y;
if (this._point) {
var x23 = this._x2 - x,
y23 = this._y2 - y;
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
}
switch (this._point) {
case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
case 1: this._point = 2; break;
case 2: this._point = 3; // proceed
default: point(this, x, y); break;
}
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
/* unused harmony default export */ var _unused_webpack_default_export = ((function custom(alpha) {
function catmullRom(context) {
return alpha ? new CatmullRom(context, alpha) : new __WEBPACK_IMPORTED_MODULE_1__cardinal__["a" /* Cardinal */](context, 0);
}
catmullRom.alpha = function(alpha) {
return custom(+alpha);
};
return catmullRom;
})(0.5));
/***/ }),
/* 98 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = sum;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__none__ = __webpack_require__(48);
/* harmony default export */ __webpack_exports__["a"] = (function(series) {
var sums = series.map(sum);
return Object(__WEBPACK_IMPORTED_MODULE_0__none__["a" /* default */])(series).sort(function(a, b) { return sums[a] - sums[b]; });
});
function sum(series) {
var s = 0, i = -1, n = series.length, v;
while (++i < n) if (v = +series[i][1]) s += v;
return s;
}
/***/ }),
/* 99 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RedBlackNode;
function RedBlackTree() {
this._ = null; // root node
}
function RedBlackNode(node) {
node.U = // parent node
node.C = // color - true for red, false for black
node.L = // left node
node.R = // right node
node.P = // previous node
node.N = null; // next node
}
RedBlackTree.prototype = {
constructor: RedBlackTree,
insert: function(after, node) {
var parent, grandpa, uncle;
if (after) {
node.P = after;
node.N = after.N;
if (after.N) after.N.P = node;
after.N = node;
if (after.R) {
after = after.R;
while (after.L) after = after.L;
after.L = node;
} else {
after.R = node;
}
parent = after;
} else if (this._) {
after = RedBlackFirst(this._);
node.P = null;
node.N = after;
after.P = after.L = node;
parent = after;
} else {
node.P = node.N = null;
this._ = node;
parent = null;
}
node.L = node.R = null;
node.U = parent;
node.C = true;
after = node;
while (parent && parent.C) {
grandpa = parent.U;
if (parent === grandpa.L) {
uncle = grandpa.R;
if (uncle && uncle.C) {
parent.C = uncle.C = false;
grandpa.C = true;
after = grandpa;
} else {
if (after === parent.R) {
RedBlackRotateLeft(this, parent);
after = parent;
parent = after.U;
}
parent.C = false;
grandpa.C = true;
RedBlackRotateRight(this, grandpa);
}
} else {
uncle = grandpa.L;
if (uncle && uncle.C) {
parent.C = uncle.C = false;
grandpa.C = true;
after = grandpa;
} else {
if (after === parent.L) {
RedBlackRotateRight(this, parent);
after = parent;
parent = after.U;
}
parent.C = false;
grandpa.C = true;
RedBlackRotateLeft(this, grandpa);
}
}
parent = after.U;
}
this._.C = false;
},
remove: function(node) {
if (node.N) node.N.P = node.P;
if (node.P) node.P.N = node.N;
node.N = node.P = null;
var parent = node.U,
sibling,
left = node.L,
right = node.R,
next,
red;
if (!left) next = right;
else if (!right) next = left;
else next = RedBlackFirst(right);
if (parent) {
if (parent.L === node) parent.L = next;
else parent.R = next;
} else {
this._ = next;
}
if (left && right) {
red = next.C;
next.C = node.C;
next.L = left;
left.U = next;
if (next !== right) {
parent = next.U;
next.U = node.U;
node = next.R;
parent.L = node;
next.R = right;
right.U = next;
} else {
next.U = parent;
parent = next;
node = next.R;
}
} else {
red = node.C;
node = next;
}
if (node) node.U = parent;
if (red) return;
if (node && node.C) { node.C = false; return; }
do {
if (node === this._) break;
if (node === parent.L) {
sibling = parent.R;
if (sibling.C) {
sibling.C = false;
parent.C = true;
RedBlackRotateLeft(this, parent);
sibling = parent.R;
}
if ((sibling.L && sibling.L.C)
|| (sibling.R && sibling.R.C)) {
if (!sibling.R || !sibling.R.C) {
sibling.L.C = false;
sibling.C = true;
RedBlackRotateRight(this, sibling);
sibling = parent.R;
}
sibling.C = parent.C;
parent.C = sibling.R.C = false;
RedBlackRotateLeft(this, parent);
node = this._;
break;
}
} else {
sibling = parent.L;
if (sibling.C) {
sibling.C = false;
parent.C = true;
RedBlackRotateRight(this, parent);
sibling = parent.L;
}
if ((sibling.L && sibling.L.C)
|| (sibling.R && sibling.R.C)) {
if (!sibling.L || !sibling.L.C) {
sibling.R.C = false;
sibling.C = true;
RedBlackRotateLeft(this, sibling);
sibling = parent.L;
}
sibling.C = parent.C;
parent.C = sibling.L.C = false;
RedBlackRotateRight(this, parent);
node = this._;
break;
}
}
sibling.C = true;
node = parent;
parent = parent.U;
} while (!node.C);
if (node) node.C = false;
}
};
function RedBlackRotateLeft(tree, node) {
var p = node,
q = node.R,
parent = p.U;
if (parent) {
if (parent.L === p) parent.L = q;
else parent.R = q;
} else {
tree._ = q;
}
q.U = parent;
p.U = q;
p.R = q.L;
if (p.R) p.R.U = p;
q.L = p;
}
function RedBlackRotateRight(tree, node) {
var p = node,
q = node.L,
parent = p.U;
if (parent) {
if (parent.L === p) parent.L = q;
else parent.R = q;
} else {
tree._ = q;
}
q.U = parent;
p.U = q;
p.L = q.R;
if (p.L) p.L.U = p;
q.R = p;
}
function RedBlackFirst(node) {
while (node.L) node = node.L;
return node;
}
/* harmony default export */ __webpack_exports__["b"] = (RedBlackTree);
/***/ }),
/* 100 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["c"] = createEdge;
/* harmony export (immutable) */ __webpack_exports__["b"] = createBorderEdge;
/* harmony export (immutable) */ __webpack_exports__["d"] = setEdgeEnd;
/* harmony export (immutable) */ __webpack_exports__["a"] = clipEdges;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Diagram__ = __webpack_require__(49);
function createEdge(left, right, v0, v1) {
var edge = [null, null],
index = __WEBPACK_IMPORTED_MODULE_0__Diagram__["e" /* edges */].push(edge) - 1;
edge.left = left;
edge.right = right;
if (v0) setEdgeEnd(edge, left, right, v0);
if (v1) setEdgeEnd(edge, right, left, v1);
__WEBPACK_IMPORTED_MODULE_0__Diagram__["b" /* cells */][left.index].halfedges.push(index);
__WEBPACK_IMPORTED_MODULE_0__Diagram__["b" /* cells */][right.index].halfedges.push(index);
return edge;
}
function createBorderEdge(left, v0, v1) {
var edge = [v0, v1];
edge.left = left;
return edge;
}
function setEdgeEnd(edge, left, right, vertex) {
if (!edge[0] && !edge[1]) {
edge[0] = vertex;
edge.left = left;
edge.right = right;
} else if (edge.left === right) {
edge[1] = vertex;
} else {
edge[0] = vertex;
}
}
// Liang–Barsky line clipping.
function clipEdge(edge, x0, y0, x1, y1) {
var a = edge[0],
b = edge[1],
ax = a[0],
ay = a[1],
bx = b[0],
by = b[1],
t0 = 0,
t1 = 1,
dx = bx - ax,
dy = by - ay,
r;
r = x0 - ax;
if (!dx && r > 0) return;
r /= dx;
if (dx < 0) {
if (r < t0) return;
if (r < t1) t1 = r;
} else if (dx > 0) {
if (r > t1) return;
if (r > t0) t0 = r;
}
r = x1 - ax;
if (!dx && r < 0) return;
r /= dx;
if (dx < 0) {
if (r > t1) return;
if (r > t0) t0 = r;
} else if (dx > 0) {
if (r < t0) return;
if (r < t1) t1 = r;
}
r = y0 - ay;
if (!dy && r > 0) return;
r /= dy;
if (dy < 0) {
if (r < t0) return;
if (r < t1) t1 = r;
} else if (dy > 0) {
if (r > t1) return;
if (r > t0) t0 = r;
}
r = y1 - ay;
if (!dy && r < 0) return;
r /= dy;
if (dy < 0) {
if (r > t1) return;
if (r > t0) t0 = r;
} else if (dy > 0) {
if (r < t0) return;
if (r < t1) t1 = r;
}
if (!(t0 > 0) && !(t1 < 1)) return true; // TODO Better check?
if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
return true;
}
function connectEdge(edge, x0, y0, x1, y1) {
var v1 = edge[1];
if (v1) return true;
var v0 = edge[0],
left = edge.left,
right = edge.right,
lx = left[0],
ly = left[1],
rx = right[0],
ry = right[1],
fx = (lx + rx) / 2,
fy = (ly + ry) / 2,
fm,
fb;
if (ry === ly) {
if (fx < x0 || fx >= x1) return;
if (lx > rx) {
if (!v0) v0 = [fx, y0];
else if (v0[1] >= y1) return;
v1 = [fx, y1];
} else {
if (!v0) v0 = [fx, y1];
else if (v0[1] < y0) return;
v1 = [fx, y0];
}
} else {
fm = (lx - rx) / (ry - ly);
fb = fy - fm * fx;
if (fm < -1 || fm > 1) {
if (lx > rx) {
if (!v0) v0 = [(y0 - fb) / fm, y0];
else if (v0[1] >= y1) return;
v1 = [(y1 - fb) / fm, y1];
} else {
if (!v0) v0 = [(y1 - fb) / fm, y1];
else if (v0[1] < y0) return;
v1 = [(y0 - fb) / fm, y0];
}
} else {
if (ly < ry) {
if (!v0) v0 = [x0, fm * x0 + fb];
else if (v0[0] >= x1) return;
v1 = [x1, fm * x1 + fb];
} else {
if (!v0) v0 = [x1, fm * x1 + fb];
else if (v0[0] < x0) return;
v1 = [x0, fm * x0 + fb];
}
}
}
edge[0] = v0;
edge[1] = v1;
return true;
}
function clipEdges(x0, y0, x1, y1) {
var i = __WEBPACK_IMPORTED_MODULE_0__Diagram__["e" /* edges */].length,
edge;
while (i--) {
if (!connectEdge(edge = __WEBPACK_IMPORTED_MODULE_0__Diagram__["e" /* edges */][i], x0, y0, x1, y1)
|| !clipEdge(edge, x0, y0, x1, y1)
|| !(Math.abs(edge[0][0] - edge[1][0]) > __WEBPACK_IMPORTED_MODULE_0__Diagram__["f" /* epsilon */]
|| Math.abs(edge[0][1] - edge[1][1]) > __WEBPACK_IMPORTED_MODULE_0__Diagram__["f" /* epsilon */])) {
delete __WEBPACK_IMPORTED_MODULE_0__Diagram__["e" /* edges */][i];
}
}
}
/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {
var hierarchy = {
compactBox: __webpack_require__(516),
dendrogram: __webpack_require__(518),
indented: __webpack_require__(520),
mindmap: __webpack_require__(522)
};
module.exports = hierarchy;
/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {
var separateTree = __webpack_require__(194);
var VALID_DIRECTIONS = ['LR', // left to right
'RL', // right to left
'TB', // top to bottom
'BT', // bottom to top
'H', // horizontal
'V' // vertical
];
var HORIZONTAL_DIRECTIONS = ['LR', 'RL', 'H'];
var isHorizontal = function isHorizontal(direction) {
return HORIZONTAL_DIRECTIONS.indexOf(direction) > -1;
};
var DEFAULT_DIRECTION = VALID_DIRECTIONS[0];
module.exports = function (root, options, layoutAlgrithm) {
var direction = options.direction || DEFAULT_DIRECTION;
options.isHorizontal = isHorizontal(direction);
if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {
throw new TypeError("Invalid direction: " + direction);
}
if (direction === VALID_DIRECTIONS[0]) {
// LR
layoutAlgrithm(root, options);
} else if (direction === VALID_DIRECTIONS[1]) {
// RL
layoutAlgrithm(root, options);
root.right2left();
} else if (direction === VALID_DIRECTIONS[2]) {
// TB
layoutAlgrithm(root, options);
} else if (direction === VALID_DIRECTIONS[3]) {
// BT
layoutAlgrithm(root, options);
root.bottom2top();
} else if (direction === VALID_DIRECTIONS[4] || direction === VALID_DIRECTIONS[5]) {
// H or V
// separate into left and right trees
var _separateTree = separateTree(root, options),
left = _separateTree.left,
right = _separateTree.right; // do layout for left and right trees
layoutAlgrithm(left, options);
layoutAlgrithm(right, options);
options.isHorizontal ? left.right2left() : left.bottom2top(); // combine left and right trees
right.translate(left.x - right.x, left.y - right.y); // translate root
root.x = left.x;
root.y = right.y;
var bb = root.getBoundingBox();
if (options.isHorizontal) {
if (bb.top < 0) {
root.translate(0, -bb.top);
}
} else {
if (bb.left < 0) {
root.translate(-bb.left, 0);
}
}
}
root.translate(-(root.x + root.width / 2 + root.hgap), -(root.y + root.height / 2 + root.vgap));
return root;
};
/***/ }),
/* 103 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return areaRingSum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return areaStream; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__adder__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__noop__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__stream__ = __webpack_require__(22);
var areaRingSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])();
var areaSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])(),
lambda00,
phi00,
lambda0,
cosPhi0,
sinPhi0;
var areaStream = {
point: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineStart: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonStart: function() {
areaRingSum.reset();
areaStream.lineStart = areaRingStart;
areaStream.lineEnd = areaRingEnd;
},
polygonEnd: function() {
var areaRing = +areaRingSum;
areaSum.add(areaRing < 0 ? __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] + areaRing : areaRing);
this.lineStart = this.lineEnd = this.point = __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */];
},
sphere: function() {
areaSum.add(__WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */]);
}
};
function areaRingStart() {
areaStream.point = areaPointFirst;
}
function areaRingEnd() {
areaPoint(lambda00, phi00);
}
function areaPointFirst(lambda, phi) {
areaStream.point = areaPoint;
lambda00 = lambda, phi00 = phi;
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
lambda0 = lambda, cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi = phi / 2 + __WEBPACK_IMPORTED_MODULE_1__math__["q" /* quarterPi */]), sinPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi);
}
function areaPoint(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
phi = phi / 2 + __WEBPACK_IMPORTED_MODULE_1__math__["q" /* quarterPi */]; // half the angular distance from south pole
// Spherical excess E for a spherical triangle with vertices: south pole,
// previous point, current point. Uses a formula derived from Cagnoli’s
// theorem. See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2).
var dLambda = lambda - lambda0,
sdLambda = dLambda >= 0 ? 1 : -1,
adLambda = sdLambda * dLambda,
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = sinPhi0 * sinPhi,
u = cosPhi0 * cosPhi + k * Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(adLambda),
v = k * sdLambda * Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(adLambda);
areaRingSum.add(Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(v, u));
// Advance the previous points.
lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
}
/* harmony default export */ __webpack_exports__["c"] = (function(object) {
areaSum.reset();
Object(__WEBPACK_IMPORTED_MODULE_3__stream__["a" /* default */])(object, areaStream);
return areaSum * 2;
});
/***/ }),
/* 104 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = circleStream;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cartesian__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constant__ = __webpack_require__(199);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__rotation__ = __webpack_require__(50);
// Generates a circle centered at [0°, 0°], with a given radius and precision.
function circleStream(stream, radius, delta, direction, t0, t1) {
if (!delta) return;
var cosRadius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(radius),
sinRadius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(radius),
step = direction * delta;
if (t0 == null) {
t0 = radius + direction * __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
t1 = radius - step / 2;
} else {
t0 = circleRadius(cosRadius, t0);
t1 = circleRadius(cosRadius, t1);
if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
}
for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
point = Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["g" /* spherical */])([cosRadius, -sinRadius * Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(t), -sinRadius * Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(t)]);
stream.point(point[0], point[1]);
}
}
// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0].
function circleRadius(cosRadius, point) {
point = Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["a" /* cartesian */])(point), point[0] -= cosRadius;
Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["e" /* cartesianNormalizeInPlace */])(point);
var radius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["b" /* acos */])(-point[1]);
return ((-point[2] < 0 ? -radius : radius) + __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */]) % __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
var center = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])([0, 0]),
radius = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(90),
precision = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(6),
ring,
rotate,
stream = {point: point};
function point(x, y) {
ring.push(x = rotate(x, y));
x[0] *= __WEBPACK_IMPORTED_MODULE_2__math__["h" /* degrees */], x[1] *= __WEBPACK_IMPORTED_MODULE_2__math__["h" /* degrees */];
}
function circle() {
var c = center.apply(this, arguments),
r = radius.apply(this, arguments) * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */],
p = precision.apply(this, arguments) * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */];
ring = [];
rotate = Object(__WEBPACK_IMPORTED_MODULE_3__rotation__["b" /* rotateRadians */])(-c[0] * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */], -c[1] * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */], 0).invert;
circleStream(stream, r, p, 1);
c = {type: "Polygon", coordinates: [ring]};
ring = rotate = null;
return c;
}
circle.center = function(_) {
return arguments.length ? (center = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])([+_[0], +_[1]]), circle) : center;
};
circle.radius = function(_) {
return arguments.length ? (radius = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), circle) : radius;
};
circle.precision = function(_) {
return arguments.length ? (precision = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), circle) : precision;
};
return circle;
});
/***/ }),
/* 105 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
function compose(x, y) {
return x = a(x, y), b(x[0], x[1]);
}
if (a.invert && b.invert) compose.invert = function(x, y) {
return x = b.invert(x, y), x && a.invert(x[0], x[1]);
};
return compose;
});
/***/ }),
/* 106 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__noop__ = __webpack_require__(20);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var lines = [],
line;
return {
point: function(x, y) {
line.push([x, y]);
},
lineStart: function() {
lines.push(line = []);
},
lineEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
rejoin: function() {
if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
},
result: function() {
var result = lines;
lines = [];
line = null;
return result;
}
};
});
/***/ }),
/* 107 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__pointEqual__ = __webpack_require__(108);
function Intersection(point, points, other, entry) {
this.x = point;
this.z = points;
this.o = other; // another intersection
this.e = entry; // is an entry?
this.v = false; // visited
this.n = this.p = null; // next & previous
}
// A generalized polygon clipping algorithm: given a polygon that has been cut
// into its visible line segments, and rejoins the segments by interpolating
// along the clip edge.
/* harmony default export */ __webpack_exports__["a"] = (function(segments, compareIntersection, startInside, interpolate, stream) {
var subject = [],
clip = [],
i,
n;
segments.forEach(function(segment) {
if ((n = segment.length - 1) <= 0) return;
var n, p0 = segment[0], p1 = segment[n], x;
// If the first and last points of a segment are coincident, then treat as a
// closed ring. TODO if all rings are closed, then the winding order of the
// exterior ring should be checked.
if (Object(__WEBPACK_IMPORTED_MODULE_0__pointEqual__["a" /* default */])(p0, p1)) {
stream.lineStart();
for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
stream.lineEnd();
return;
}
subject.push(x = new Intersection(p0, segment, null, true));
clip.push(x.o = new Intersection(p0, null, x, false));
subject.push(x = new Intersection(p1, segment, null, false));
clip.push(x.o = new Intersection(p1, null, x, true));
});
if (!subject.length) return;
clip.sort(compareIntersection);
link(subject);
link(clip);
for (i = 0, n = clip.length; i < n; ++i) {
clip[i].e = startInside = !startInside;
}
var start = subject[0],
points,
point;
while (1) {
// Find first unvisited intersection.
var current = start,
isSubject = true;
while (current.v) if ((current = current.n) === start) return;
points = current.z;
stream.lineStart();
do {
current.v = current.o.v = true;
if (current.e) {
if (isSubject) {
for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
} else {
interpolate(current.x, current.n.x, 1, stream);
}
current = current.n;
} else {
if (isSubject) {
points = current.p.z;
for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
} else {
interpolate(current.x, current.p.x, -1, stream);
}
current = current.p;
}
current = current.o;
points = current.z;
isSubject = !isSubject;
} while (!current.v);
stream.lineEnd();
}
});
function link(array) {
if (!(n = array.length)) return;
var n,
i = 0,
a = array[0],
b;
while (++i < n) {
a.n = b = array[i];
b.p = a;
a = b;
}
a.n = b = array[0];
b.p = a;
}
/***/ }),
/* 108 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(4);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(a[0] - b[0]) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] && Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(a[1] - b[1]) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */];
});
/***/ }),
/* 109 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return bisectRight; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return bisectLeft; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ascending__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__bisector__ = __webpack_require__(110);
var ascendingBisect = Object(__WEBPACK_IMPORTED_MODULE_1__bisector__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_0__ascending__["a" /* default */]);
var bisectRight = ascendingBisect.right;
var bisectLeft = ascendingBisect.left;
/* harmony default export */ __webpack_exports__["c"] = (bisectRight);
/***/ }),
/* 110 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ascending__ = __webpack_require__(30);
/* harmony default export */ __webpack_exports__["a"] = (function(compare) {
if (compare.length === 1) compare = ascendingComparator(compare);
return {
left: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) < 0) lo = mid + 1;
else hi = mid;
}
return lo;
},
right: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) > 0) hi = mid;
else lo = mid + 1;
}
return lo;
}
};
});
function ascendingComparator(f) {
return function(d, x) {
return Object(__WEBPACK_IMPORTED_MODULE_0__ascending__["a" /* default */])(f(d), x);
};
}
/***/ }),
/* 111 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = pair;
/* harmony default export */ __webpack_exports__["a"] = (function(array, f) {
if (f == null) f = pair;
var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
while (i < n) pairs[i] = f(p, p = array[++i]);
return pairs;
});
function pair(a, b) {
return [a, b];
}
/***/ }),
/* 112 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__variance__ = __webpack_require__(113);
/* harmony default export */ __webpack_exports__["a"] = (function(array, f) {
var v = Object(__WEBPACK_IMPORTED_MODULE_0__variance__["a" /* default */])(array, f);
return v ? Math.sqrt(v) : v;
});
/***/ }),
/* 113 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(36);
/* harmony default export */ __webpack_exports__["a"] = (function(values, valueof) {
var n = values.length,
m = 0,
i = -1,
mean = 0,
value,
delta,
sum = 0;
if (valueof == null) {
while (++i < n) {
if (!isNaN(value = Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(values[i]))) {
delta = value - mean;
mean += delta / ++m;
sum += delta * (value - mean);
}
}
}
else {
while (++i < n) {
if (!isNaN(value = Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(valueof(values[i], i, values)))) {
delta = value - mean;
mean += delta / ++m;
sum += delta * (value - mean);
}
}
}
if (m > 1) return sum / (m - 1);
});
/***/ }),
/* 114 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(values, valueof) {
var n = values.length,
i = -1,
value,
min,
max;
if (valueof == null) {
while (++i < n) { // Find the first comparable value.
if ((value = values[i]) != null && value >= value) {
min = max = value;
while (++i < n) { // Compare the remaining values.
if ((value = values[i]) != null) {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
}
}
else {
while (++i < n) { // Find the first comparable value.
if ((value = valueof(values[i], i, values)) != null && value >= value) {
min = max = value;
while (++i < n) { // Compare the remaining values.
if ((value = valueof(values[i], i, values)) != null) {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
}
}
return [min, max];
});
/***/ }),
/* 115 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return slice; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return map; });
var array = Array.prototype;
var slice = array.slice;
var map = array.map;
/***/ }),
/* 116 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(start, stop, step) {
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
});
/***/ }),
/* 117 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = tickIncrement;
/* harmony export (immutable) */ __webpack_exports__["c"] = tickStep;
var e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);
/* harmony default export */ __webpack_exports__["a"] = (function(start, stop, count) {
var reverse,
i = -1,
n,
ticks,
step;
stop = +stop, start = +start, count = +count;
if (start === stop && count > 0) return [start];
if (reverse = stop < start) n = start, start = stop, stop = n;
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),
power = Math.floor(Math.log(step) / Math.LN10),
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 tickStep(start, stop, count) {
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;
else if (error >= e5) step1 *= 5;
else if (error >= e2) step1 *= 2;
return stop < start ? -step1 : step1;
}
/***/ }),
/* 118 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(values) {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
});
/***/ }),
/* 119 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(values, valueof) {
var n = values.length,
i = -1,
value,
min;
if (valueof == null) {
while (++i < n) { // Find the first comparable value.
if ((value = values[i]) != null && value >= value) {
min = value;
while (++i < n) { // Compare the remaining values.
if ((value = values[i]) != null && min > value) {
min = value;
}
}
}
}
}
else {
while (++i < n) { // Find the first comparable value.
if ((value = valueof(values[i], i, values)) != null && value >= value) {
min = value;
while (++i < n) { // Compare the remaining values.
if ((value = valueof(values[i], i, values)) != null && min > value) {
min = value;
}
}
}
}
}
return min;
});
/***/ }),
/* 120 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__min__ = __webpack_require__(119);
/* harmony default export */ __webpack_exports__["a"] = (function(matrix) {
if (!(n = matrix.length)) return [];
for (var i = -1, m = Object(__WEBPACK_IMPORTED_MODULE_0__min__["a" /* default */])(matrix, length), transpose = new Array(m); ++i < m;) {
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {
row[j] = matrix[j][i];
}
}
return transpose;
});
function length(d) {
return d.length;
}
/***/ }),
/* 121 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__adder__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__cartesian__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(4);
var sum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])();
/* harmony default export */ __webpack_exports__["a"] = (function(polygon, point) {
var lambda = point[0],
phi = point[1],
normal = [Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(lambda), -Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(lambda), 0],
angle = 0,
winding = 0;
sum.reset();
for (var i = 0, n = polygon.length; i < n; ++i) {
if (!(m = (ring = polygon[i]).length)) continue;
var ring,
m,
point0 = ring[m - 1],
lambda0 = point0[0],
phi0 = point0[1] / 2 + __WEBPACK_IMPORTED_MODULE_2__math__["q" /* quarterPi */],
sinPhi0 = Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(phi0),
cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(phi0);
for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
var point1 = ring[j],
lambda1 = point1[0],
phi1 = point1[1] / 2 + __WEBPACK_IMPORTED_MODULE_2__math__["q" /* quarterPi */],
sinPhi1 = Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(phi1),
cosPhi1 = Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(phi1),
delta = lambda1 - lambda0,
sign = delta >= 0 ? 1 : -1,
absDelta = sign * delta,
antimeridian = absDelta > __WEBPACK_IMPORTED_MODULE_2__math__["o" /* pi */],
k = sinPhi0 * sinPhi1;
sum.add(Object(__WEBPACK_IMPORTED_MODULE_2__math__["e" /* atan2 */])(k * sign * Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(absDelta), cosPhi0 * cosPhi1 + k * Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(absDelta)));
angle += antimeridian ? delta + sign * __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */] : delta;
// Are the longitudes either side of the point’s meridian (lambda),
// and are the latitudes smaller than the parallel (phi)?
if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
var arc = Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["c" /* cartesianCross */])(Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["a" /* cartesian */])(point0), Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["a" /* cartesian */])(point1));
Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["e" /* cartesianNormalizeInPlace */])(arc);
var intersection = Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["c" /* cartesianCross */])(normal, arc);
Object(__WEBPACK_IMPORTED_MODULE_1__cartesian__["e" /* cartesianNormalizeInPlace */])(intersection);
var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * Object(__WEBPACK_IMPORTED_MODULE_2__math__["c" /* asin */])(intersection[2]);
if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
winding += antimeridian ^ delta >= 0 ? 1 : -1;
}
}
}
}
// First, determine whether the South pole is inside or outside:
//
// It is inside if:
// * the polygon winds around it in a clockwise direction.
// * the polygon does not (cumulatively) wind around it, but has a negative
// (counter-clockwise) area.
//
// Second, count the (signed) number of times a segment crosses a lambda
// from the point to the South pole. If it is zero, then the point is the
// same side as the South pole.
return (angle < -__WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] || angle < __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] && sum < -__WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */]) ^ (winding & 1);
});
/***/ }),
/* 122 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__length__ = __webpack_require__(123);
var coordinates = [null, null],
object = {type: "LineString", coordinates: coordinates};
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
coordinates[0] = a;
coordinates[1] = b;
return Object(__WEBPACK_IMPORTED_MODULE_0__length__["a" /* default */])(object);
});
/***/ }),
/* 123 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__adder__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__noop__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__stream__ = __webpack_require__(22);
var lengthSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])(),
lambda0,
sinPhi0,
cosPhi0;
var lengthStream = {
sphere: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
point: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineStart: lengthLineStart,
lineEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonStart: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */]
};
function lengthLineStart() {
lengthStream.point = lengthPointFirst;
lengthStream.lineEnd = lengthLineEnd;
}
function lengthLineEnd() {
lengthStream.point = lengthStream.lineEnd = __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */];
}
function lengthPointFirst(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
lambda0 = lambda, sinPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi), cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi);
lengthStream.point = lengthPoint;
}
function lengthPoint(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
var sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
delta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(lambda - lambda0),
cosDelta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(delta),
sinDelta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(delta),
x = cosPhi * sinDelta,
y = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta,
z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta;
lengthSum.add(Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["u" /* sqrt */])(x * x + y * y), z));
lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi;
}
/* harmony default export */ __webpack_exports__["a"] = (function(object) {
lengthSum.reset();
Object(__WEBPACK_IMPORTED_MODULE_3__stream__["a" /* default */])(object, lengthStream);
return +lengthSum;
});
/***/ }),
/* 124 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__noop__ = __webpack_require__(20);
var x0 = Infinity,
y0 = x0,
x1 = -x0,
y1 = x1;
var boundsStream = {
point: boundsPoint,
lineStart: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
lineEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
polygonStart: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
polygonEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
result: function() {
var bounds = [[x0, y0], [x1, y1]];
x1 = y1 = -(y0 = x0 = Infinity);
return bounds;
}
};
function boundsPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
if (y < y0) y0 = y;
if (y > y1) y1 = y;
}
/* harmony default export */ __webpack_exports__["a"] = (boundsStream);
/***/ }),
/* 125 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__conicEqualArea__ = __webpack_require__(68);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0__conicEqualArea__["b" /* default */])()
.parallels([29.5, 45.5])
.scale(1070)
.translate([480, 250])
.rotate([96, 0])
.center([-0.6, 38.7]);
});
/***/ }),
/* 126 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__buffer__ = __webpack_require__(106);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__polygon__ = __webpack_require__(107);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__polygonContains__ = __webpack_require__(121);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_d3_array__ = __webpack_require__(14);
/* harmony default export */ __webpack_exports__["a"] = (function(pointVisible, clipLine, interpolate, start) {
return function(rotate, sink) {
var line = clipLine(sink),
rotatedStart = rotate.invert(start[0], start[1]),
ringBuffer = Object(__WEBPACK_IMPORTED_MODULE_0__buffer__["a" /* default */])(),
ringSink = clipLine(ringBuffer),
polygonStarted = false,
polygon,
segments,
ring;
var clip = {
point: point,
lineStart: lineStart,
lineEnd: lineEnd,
polygonStart: function() {
clip.point = pointRing;
clip.lineStart = ringStart;
clip.lineEnd = ringEnd;
segments = [];
polygon = [];
},
polygonEnd: function() {
clip.point = point;
clip.lineStart = lineStart;
clip.lineEnd = lineEnd;
segments = Object(__WEBPACK_IMPORTED_MODULE_4_d3_array__["merge"])(segments);
var startInside = Object(__WEBPACK_IMPORTED_MODULE_3__polygonContains__["a" /* default */])(polygon, rotatedStart);
if (segments.length) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
Object(__WEBPACK_IMPORTED_MODULE_1__polygon__["a" /* default */])(segments, compareIntersection, startInside, interpolate, sink);
} else if (startInside) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
sink.lineStart();
interpolate(null, null, 1, sink);
sink.lineEnd();
}
if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
segments = polygon = null;
},
sphere: function() {
sink.polygonStart();
sink.lineStart();
interpolate(null, null, 1, sink);
sink.lineEnd();
sink.polygonEnd();
}
};
function point(lambda, phi) {
var point = rotate(lambda, phi);
if (pointVisible(lambda = point[0], phi = point[1])) sink.point(lambda, phi);
}
function pointLine(lambda, phi) {
var point = rotate(lambda, phi);
line.point(point[0], point[1]);
}
function lineStart() {
clip.point = pointLine;
line.lineStart();
}
function lineEnd() {
clip.point = point;
line.lineEnd();
}
function pointRing(lambda, phi) {
ring.push([lambda, phi]);
var point = rotate(lambda, phi);
ringSink.point(point[0], point[1]);
}
function ringStart() {
ringSink.lineStart();
ring = [];
}
function ringEnd() {
pointRing(ring[0][0], ring[0][1]);
ringSink.lineEnd();
var clean = ringSink.clean(),
ringSegments = ringBuffer.result(),
i, n = ringSegments.length, m,
segment,
point;
ring.pop();
polygon.push(ring);
ring = null;
if (!n) return;
// No intersections.
if (clean & 1) {
segment = ringSegments[0];
if ((m = segment.length - 1) > 0) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
sink.lineStart();
for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);
sink.lineEnd();
}
return;
}
// Rejoin connected segments.
// TODO reuse ringBuffer.rejoin()?
if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
segments.push(ringSegments.filter(validSegment));
}
return clip;
};
});
function validSegment(segment) {
return segment.length > 1;
}
// Intersections are sorted along the clip edge. For both antimeridian cutting
// and circle clipping, the same comparison is used.
function compareIntersection(a, b) {
return ((a = a.x)[0] < 0 ? a[1] - __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] : __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - a[1])
- ((b = b.x)[0] < 0 ? b[1] - __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] : __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - b[1]);
}
/***/ }),
/* 127 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = equirectangularRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(17);
function equirectangularRaw(lambda, phi) {
return [lambda, phi];
}
equirectangularRaw.invert = equirectangularRaw;
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */])(equirectangularRaw)
.scale(152.63);
});
/***/ }),
/* 128 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_airy__ = __webpack_require__(240);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAiry", function() { return __WEBPACK_IMPORTED_MODULE_0__src_airy__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAiryRaw", function() { return __WEBPACK_IMPORTED_MODULE_0__src_airy__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_aitoff__ = __webpack_require__(129);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAitoff", function() { return __WEBPACK_IMPORTED_MODULE_1__src_aitoff__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAitoffRaw", function() { return __WEBPACK_IMPORTED_MODULE_1__src_aitoff__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_armadillo__ = __webpack_require__(241);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoArmadillo", function() { return __WEBPACK_IMPORTED_MODULE_2__src_armadillo__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoArmadilloRaw", function() { return __WEBPACK_IMPORTED_MODULE_2__src_armadillo__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_august__ = __webpack_require__(130);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAugust", function() { return __WEBPACK_IMPORTED_MODULE_3__src_august__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoAugustRaw", function() { return __WEBPACK_IMPORTED_MODULE_3__src_august__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_baker__ = __webpack_require__(242);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBaker", function() { return __WEBPACK_IMPORTED_MODULE_4__src_baker__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBakerRaw", function() { return __WEBPACK_IMPORTED_MODULE_4__src_baker__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_berghaus__ = __webpack_require__(243);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBerghaus", function() { return __WEBPACK_IMPORTED_MODULE_5__src_berghaus__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBerghausRaw", function() { return __WEBPACK_IMPORTED_MODULE_5__src_berghaus__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_boggs__ = __webpack_require__(131);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBoggs", function() { return __WEBPACK_IMPORTED_MODULE_6__src_boggs__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBoggsRaw", function() { return __WEBPACK_IMPORTED_MODULE_6__src_boggs__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_bonne__ = __webpack_require__(244);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBonne", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bonne__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBonneRaw", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bonne__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_bottomley__ = __webpack_require__(245);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBottomley", function() { return __WEBPACK_IMPORTED_MODULE_8__src_bottomley__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBottomleyRaw", function() { return __WEBPACK_IMPORTED_MODULE_8__src_bottomley__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_bromley__ = __webpack_require__(246);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBromley", function() { return __WEBPACK_IMPORTED_MODULE_9__src_bromley__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoBromleyRaw", function() { return __WEBPACK_IMPORTED_MODULE_9__src_bromley__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_chamberlin__ = __webpack_require__(247);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoChamberlin", function() { return __WEBPACK_IMPORTED_MODULE_10__src_chamberlin__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoChamberlinRaw", function() { return __WEBPACK_IMPORTED_MODULE_10__src_chamberlin__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoChamberlinAfrica", function() { return __WEBPACK_IMPORTED_MODULE_10__src_chamberlin__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_collignon__ = __webpack_require__(72);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCollignon", function() { return __WEBPACK_IMPORTED_MODULE_11__src_collignon__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCollignonRaw", function() { return __WEBPACK_IMPORTED_MODULE_11__src_collignon__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_craig__ = __webpack_require__(248);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCraig", function() { return __WEBPACK_IMPORTED_MODULE_12__src_craig__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCraigRaw", function() { return __WEBPACK_IMPORTED_MODULE_12__src_craig__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_craster__ = __webpack_require__(249);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCraster", function() { return __WEBPACK_IMPORTED_MODULE_13__src_craster__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCrasterRaw", function() { return __WEBPACK_IMPORTED_MODULE_13__src_craster__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_cylindricalEqualArea__ = __webpack_require__(132);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCylindricalEqualArea", function() { return __WEBPACK_IMPORTED_MODULE_14__src_cylindricalEqualArea__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCylindricalEqualAreaRaw", function() { return __WEBPACK_IMPORTED_MODULE_14__src_cylindricalEqualArea__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_cylindricalStereographic__ = __webpack_require__(250);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCylindricalStereographic", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cylindricalStereographic__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoCylindricalStereographicRaw", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cylindricalStereographic__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_eckert1_js__ = __webpack_require__(251);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert1", function() { return __WEBPACK_IMPORTED_MODULE_16__src_eckert1_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert1Raw", function() { return __WEBPACK_IMPORTED_MODULE_16__src_eckert1_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__src_eckert2_js__ = __webpack_require__(252);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert2", function() { return __WEBPACK_IMPORTED_MODULE_17__src_eckert2_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert2Raw", function() { return __WEBPACK_IMPORTED_MODULE_17__src_eckert2_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__src_eckert3_js__ = __webpack_require__(253);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert3", function() { return __WEBPACK_IMPORTED_MODULE_18__src_eckert3_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert3Raw", function() { return __WEBPACK_IMPORTED_MODULE_18__src_eckert3_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__src_eckert4_js__ = __webpack_require__(254);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert4", function() { return __WEBPACK_IMPORTED_MODULE_19__src_eckert4_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert4Raw", function() { return __WEBPACK_IMPORTED_MODULE_19__src_eckert4_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__src_eckert5_js__ = __webpack_require__(255);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert5", function() { return __WEBPACK_IMPORTED_MODULE_20__src_eckert5_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert5Raw", function() { return __WEBPACK_IMPORTED_MODULE_20__src_eckert5_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__src_eckert6_js__ = __webpack_require__(256);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert6", function() { return __WEBPACK_IMPORTED_MODULE_21__src_eckert6_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEckert6Raw", function() { return __WEBPACK_IMPORTED_MODULE_21__src_eckert6_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__src_eisenlohr_js__ = __webpack_require__(257);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEisenlohr", function() { return __WEBPACK_IMPORTED_MODULE_22__src_eisenlohr_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoEisenlohrRaw", function() { return __WEBPACK_IMPORTED_MODULE_22__src_eisenlohr_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__src_fahey_js__ = __webpack_require__(258);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoFahey", function() { return __WEBPACK_IMPORTED_MODULE_23__src_fahey_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoFaheyRaw", function() { return __WEBPACK_IMPORTED_MODULE_23__src_fahey_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__src_foucaut_js__ = __webpack_require__(259);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoFoucaut", function() { return __WEBPACK_IMPORTED_MODULE_24__src_foucaut_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoFoucautRaw", function() { return __WEBPACK_IMPORTED_MODULE_24__src_foucaut_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__src_gilbert_js__ = __webpack_require__(260);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGilbert", function() { return __WEBPACK_IMPORTED_MODULE_25__src_gilbert_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__src_gingery_js__ = __webpack_require__(261);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGingery", function() { return __WEBPACK_IMPORTED_MODULE_26__src_gingery_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGingeryRaw", function() { return __WEBPACK_IMPORTED_MODULE_26__src_gingery_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__src_ginzburg4_js__ = __webpack_require__(262);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg4", function() { return __WEBPACK_IMPORTED_MODULE_27__src_ginzburg4_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg4Raw", function() { return __WEBPACK_IMPORTED_MODULE_27__src_ginzburg4_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__src_ginzburg5_js__ = __webpack_require__(263);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg5", function() { return __WEBPACK_IMPORTED_MODULE_28__src_ginzburg5_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg5Raw", function() { return __WEBPACK_IMPORTED_MODULE_28__src_ginzburg5_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__src_ginzburg6_js__ = __webpack_require__(264);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg6", function() { return __WEBPACK_IMPORTED_MODULE_29__src_ginzburg6_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg6Raw", function() { return __WEBPACK_IMPORTED_MODULE_29__src_ginzburg6_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__src_ginzburg8_js__ = __webpack_require__(265);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg8", function() { return __WEBPACK_IMPORTED_MODULE_30__src_ginzburg8_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg8Raw", function() { return __WEBPACK_IMPORTED_MODULE_30__src_ginzburg8_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__src_ginzburg9_js__ = __webpack_require__(266);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg9", function() { return __WEBPACK_IMPORTED_MODULE_31__src_ginzburg9_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGinzburg9Raw", function() { return __WEBPACK_IMPORTED_MODULE_31__src_ginzburg9_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__src_gringorten_js__ = __webpack_require__(133);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGringorten", function() { return __WEBPACK_IMPORTED_MODULE_32__src_gringorten_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGringortenRaw", function() { return __WEBPACK_IMPORTED_MODULE_32__src_gringorten_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__src_guyou_js__ = __webpack_require__(135);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGuyou", function() { return __WEBPACK_IMPORTED_MODULE_33__src_guyou_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGuyouRaw", function() { return __WEBPACK_IMPORTED_MODULE_33__src_guyou_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__src_hammer_js__ = __webpack_require__(268);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHammer", function() { return __WEBPACK_IMPORTED_MODULE_34__src_hammer_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHammerRaw", function() { return __WEBPACK_IMPORTED_MODULE_34__src_hammer_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_35__src_hammerRetroazimuthal_js__ = __webpack_require__(269);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHammerRetroazimuthal", function() { return __WEBPACK_IMPORTED_MODULE_35__src_hammerRetroazimuthal_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHammerRetroazimuthalRaw", function() { return __WEBPACK_IMPORTED_MODULE_35__src_hammerRetroazimuthal_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__src_healpix_js__ = __webpack_require__(270);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHealpix", function() { return __WEBPACK_IMPORTED_MODULE_36__src_healpix_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHealpixRaw", function() { return __WEBPACK_IMPORTED_MODULE_36__src_healpix_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__src_hill_js__ = __webpack_require__(271);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHill", function() { return __WEBPACK_IMPORTED_MODULE_37__src_hill_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHillRaw", function() { return __WEBPACK_IMPORTED_MODULE_37__src_hill_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__src_homolosine_js__ = __webpack_require__(136);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHomolosine", function() { return __WEBPACK_IMPORTED_MODULE_38__src_homolosine_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoHomolosineRaw", function() { return __WEBPACK_IMPORTED_MODULE_38__src_homolosine_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__src_interrupted_index__ = __webpack_require__(23);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterrupt", function() { return __WEBPACK_IMPORTED_MODULE_39__src_interrupted_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__src_interrupted_boggs__ = __webpack_require__(272);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedBoggs", function() { return __WEBPACK_IMPORTED_MODULE_40__src_interrupted_boggs__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__src_interrupted_homolosine__ = __webpack_require__(273);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedHomolosine", function() { return __WEBPACK_IMPORTED_MODULE_41__src_interrupted_homolosine__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__src_interrupted_mollweide__ = __webpack_require__(274);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedMollweide", function() { return __WEBPACK_IMPORTED_MODULE_42__src_interrupted_mollweide__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__src_interrupted_mollweideHemispheres__ = __webpack_require__(275);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedMollweideHemispheres", function() { return __WEBPACK_IMPORTED_MODULE_43__src_interrupted_mollweideHemispheres__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__src_interrupted_sinuMollweide__ = __webpack_require__(276);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedSinuMollweide", function() { return __WEBPACK_IMPORTED_MODULE_44__src_interrupted_sinuMollweide__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__src_interrupted_sinusoidal__ = __webpack_require__(277);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoInterruptedSinusoidal", function() { return __WEBPACK_IMPORTED_MODULE_45__src_interrupted_sinusoidal__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__src_kavrayskiy7_js__ = __webpack_require__(278);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoKavrayskiy7", function() { return __WEBPACK_IMPORTED_MODULE_46__src_kavrayskiy7_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoKavrayskiy7Raw", function() { return __WEBPACK_IMPORTED_MODULE_46__src_kavrayskiy7_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_47__src_lagrange_js__ = __webpack_require__(279);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLagrange", function() { return __WEBPACK_IMPORTED_MODULE_47__src_lagrange_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLagrangeRaw", function() { return __WEBPACK_IMPORTED_MODULE_47__src_lagrange_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__src_larrivee__ = __webpack_require__(280);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLarrivee", function() { return __WEBPACK_IMPORTED_MODULE_48__src_larrivee__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLarriveeRaw", function() { return __WEBPACK_IMPORTED_MODULE_48__src_larrivee__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_49__src_laskowski__ = __webpack_require__(281);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLaskowski", function() { return __WEBPACK_IMPORTED_MODULE_49__src_laskowski__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLaskowskiRaw", function() { return __WEBPACK_IMPORTED_MODULE_49__src_laskowski__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__src_littrow_js__ = __webpack_require__(282);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLittrow", function() { return __WEBPACK_IMPORTED_MODULE_50__src_littrow_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLittrowRaw", function() { return __WEBPACK_IMPORTED_MODULE_50__src_littrow_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__src_loximuthal_js__ = __webpack_require__(283);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLoximuthal", function() { return __WEBPACK_IMPORTED_MODULE_51__src_loximuthal_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoLoximuthalRaw", function() { return __WEBPACK_IMPORTED_MODULE_51__src_loximuthal_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_52__src_miller__ = __webpack_require__(284);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMiller", function() { return __WEBPACK_IMPORTED_MODULE_52__src_miller__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMillerRaw", function() { return __WEBPACK_IMPORTED_MODULE_52__src_miller__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__ = __webpack_require__(285);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographic", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicRaw", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["g"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicAlaska", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicGs48", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicGs50", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["d"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicMiller", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["f"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoModifiedStereographicLee", function() { return __WEBPACK_IMPORTED_MODULE_53__src_modifiedStereographic__["e"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__src_mollweide__ = __webpack_require__(21);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMollweide", function() { return __WEBPACK_IMPORTED_MODULE_54__src_mollweide__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMollweideRaw", function() { return __WEBPACK_IMPORTED_MODULE_54__src_mollweide__["d"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__src_mtFlatPolarParabolic__ = __webpack_require__(286);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarParabolic", function() { return __WEBPACK_IMPORTED_MODULE_55__src_mtFlatPolarParabolic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarParabolicRaw", function() { return __WEBPACK_IMPORTED_MODULE_55__src_mtFlatPolarParabolic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__src_mtFlatPolarQuartic__ = __webpack_require__(287);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarQuartic", function() { return __WEBPACK_IMPORTED_MODULE_56__src_mtFlatPolarQuartic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarQuarticRaw", function() { return __WEBPACK_IMPORTED_MODULE_56__src_mtFlatPolarQuartic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__src_mtFlatPolarSinusoidal__ = __webpack_require__(288);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarSinusoidal", function() { return __WEBPACK_IMPORTED_MODULE_57__src_mtFlatPolarSinusoidal__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoMtFlatPolarSinusoidalRaw", function() { return __WEBPACK_IMPORTED_MODULE_57__src_mtFlatPolarSinusoidal__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__src_naturalEarth__ = __webpack_require__(289);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNaturalEarth", function() { return __WEBPACK_IMPORTED_MODULE_58__src_naturalEarth__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNaturalEarthRaw", function() { return __WEBPACK_IMPORTED_MODULE_58__src_naturalEarth__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__src_naturalEarth2__ = __webpack_require__(290);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNaturalEarth2", function() { return __WEBPACK_IMPORTED_MODULE_59__src_naturalEarth2__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNaturalEarth2Raw", function() { return __WEBPACK_IMPORTED_MODULE_59__src_naturalEarth2__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__src_nellHammer__ = __webpack_require__(291);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNellHammer", function() { return __WEBPACK_IMPORTED_MODULE_60__src_nellHammer__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoNellHammerRaw", function() { return __WEBPACK_IMPORTED_MODULE_60__src_nellHammer__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_61__src_patterson__ = __webpack_require__(292);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPatterson", function() { return __WEBPACK_IMPORTED_MODULE_61__src_patterson__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPattersonRaw", function() { return __WEBPACK_IMPORTED_MODULE_61__src_patterson__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_62__src_polyconic__ = __webpack_require__(293);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyconic", function() { return __WEBPACK_IMPORTED_MODULE_62__src_polyconic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyconicRaw", function() { return __WEBPACK_IMPORTED_MODULE_62__src_polyconic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_63__src_polyhedral_index_js__ = __webpack_require__(53);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyhedral", function() { return __WEBPACK_IMPORTED_MODULE_63__src_polyhedral_index_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_64__src_polyhedral_butterfly_js__ = __webpack_require__(295);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyhedralButterfly", function() { return __WEBPACK_IMPORTED_MODULE_64__src_polyhedral_butterfly_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_65__src_polyhedral_collignon_js__ = __webpack_require__(296);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyhedralCollignon", function() { return __WEBPACK_IMPORTED_MODULE_65__src_polyhedral_collignon_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_66__src_polyhedral_waterman_js__ = __webpack_require__(297);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPolyhedralWaterman", function() { return __WEBPACK_IMPORTED_MODULE_66__src_polyhedral_waterman_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_67__src_project_index__ = __webpack_require__(298);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoProject", function() { return __WEBPACK_IMPORTED_MODULE_67__src_project_index__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_68__src_quincuncial_gringorten_js__ = __webpack_require__(302);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoGringortenQuincuncial", function() { return __WEBPACK_IMPORTED_MODULE_68__src_quincuncial_gringorten_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_69__src_quincuncial_peirce_js__ = __webpack_require__(137);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPeirceQuincuncial", function() { return __WEBPACK_IMPORTED_MODULE_69__src_quincuncial_peirce_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoPierceQuincuncial", function() { return __WEBPACK_IMPORTED_MODULE_69__src_quincuncial_peirce_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_70__src_quantize__ = __webpack_require__(303);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoQuantize", function() { return __WEBPACK_IMPORTED_MODULE_70__src_quantize__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_71__src_quincuncial_index_js__ = __webpack_require__(75);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoQuincuncial", function() { return __WEBPACK_IMPORTED_MODULE_71__src_quincuncial_index_js__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_72__src_rectangularPolyconic__ = __webpack_require__(304);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoRectangularPolyconic", function() { return __WEBPACK_IMPORTED_MODULE_72__src_rectangularPolyconic__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoRectangularPolyconicRaw", function() { return __WEBPACK_IMPORTED_MODULE_72__src_rectangularPolyconic__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__src_robinson__ = __webpack_require__(305);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoRobinson", function() { return __WEBPACK_IMPORTED_MODULE_73__src_robinson__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoRobinsonRaw", function() { return __WEBPACK_IMPORTED_MODULE_73__src_robinson__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_74__src_satellite__ = __webpack_require__(306);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSatellite", function() { return __WEBPACK_IMPORTED_MODULE_74__src_satellite__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSatelliteRaw", function() { return __WEBPACK_IMPORTED_MODULE_74__src_satellite__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_75__src_sinuMollweide__ = __webpack_require__(73);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSinuMollweide", function() { return __WEBPACK_IMPORTED_MODULE_75__src_sinuMollweide__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSinuMollweideRaw", function() { return __WEBPACK_IMPORTED_MODULE_75__src_sinuMollweide__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_76__src_sinusoidal__ = __webpack_require__(38);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSinusoidal", function() { return __WEBPACK_IMPORTED_MODULE_76__src_sinusoidal__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoSinusoidalRaw", function() { return __WEBPACK_IMPORTED_MODULE_76__src_sinusoidal__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_77__src_stitch__ = __webpack_require__(307);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoStitch", function() { return __WEBPACK_IMPORTED_MODULE_77__src_stitch__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_78__src_times__ = __webpack_require__(308);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTimes", function() { return __WEBPACK_IMPORTED_MODULE_78__src_times__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTimesRaw", function() { return __WEBPACK_IMPORTED_MODULE_78__src_times__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_79__src_twoPointAzimuthal__ = __webpack_require__(309);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointAzimuthal", function() { return __WEBPACK_IMPORTED_MODULE_79__src_twoPointAzimuthal__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointAzimuthalRaw", function() { return __WEBPACK_IMPORTED_MODULE_79__src_twoPointAzimuthal__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointAzimuthalUsa", function() { return __WEBPACK_IMPORTED_MODULE_79__src_twoPointAzimuthal__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_80__src_twoPointEquidistant__ = __webpack_require__(310);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointEquidistant", function() { return __WEBPACK_IMPORTED_MODULE_80__src_twoPointEquidistant__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointEquidistantRaw", function() { return __WEBPACK_IMPORTED_MODULE_80__src_twoPointEquidistant__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoTwoPointEquidistantUsa", function() { return __WEBPACK_IMPORTED_MODULE_80__src_twoPointEquidistant__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_81__src_vanDerGrinten__ = __webpack_require__(311);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten", function() { return __WEBPACK_IMPORTED_MODULE_81__src_vanDerGrinten__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrintenRaw", function() { return __WEBPACK_IMPORTED_MODULE_81__src_vanDerGrinten__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_82__src_vanDerGrinten2__ = __webpack_require__(312);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten2", function() { return __WEBPACK_IMPORTED_MODULE_82__src_vanDerGrinten2__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten2Raw", function() { return __WEBPACK_IMPORTED_MODULE_82__src_vanDerGrinten2__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_83__src_vanDerGrinten3__ = __webpack_require__(313);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten3", function() { return __WEBPACK_IMPORTED_MODULE_83__src_vanDerGrinten3__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten3Raw", function() { return __WEBPACK_IMPORTED_MODULE_83__src_vanDerGrinten3__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_84__src_vanDerGrinten4__ = __webpack_require__(314);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten4", function() { return __WEBPACK_IMPORTED_MODULE_84__src_vanDerGrinten4__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoVanDerGrinten4Raw", function() { return __WEBPACK_IMPORTED_MODULE_84__src_vanDerGrinten4__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_85__src_wagner4_js__ = __webpack_require__(315);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner4", function() { return __WEBPACK_IMPORTED_MODULE_85__src_wagner4_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner4Raw", function() { return __WEBPACK_IMPORTED_MODULE_85__src_wagner4_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_86__src_wagner6_js__ = __webpack_require__(316);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner6", function() { return __WEBPACK_IMPORTED_MODULE_86__src_wagner6_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner6Raw", function() { return __WEBPACK_IMPORTED_MODULE_86__src_wagner6_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_87__src_wagner7_js__ = __webpack_require__(317);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner7", function() { return __WEBPACK_IMPORTED_MODULE_87__src_wagner7_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWagner7Raw", function() { return __WEBPACK_IMPORTED_MODULE_87__src_wagner7_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_88__src_wiechel_js__ = __webpack_require__(318);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWiechel", function() { return __WEBPACK_IMPORTED_MODULE_88__src_wiechel_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWiechelRaw", function() { return __WEBPACK_IMPORTED_MODULE_88__src_wiechel_js__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_89__src_winkel3__ = __webpack_require__(319);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWinkel3", function() { return __WEBPACK_IMPORTED_MODULE_89__src_winkel3__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "geoWinkel3Raw", function() { return __WEBPACK_IMPORTED_MODULE_89__src_winkel3__["b"]; });
// DEPRECATED misspelling
/***/ }),
/* 129 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = aitoffRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
function aitoffRaw(x, y) {
var cosy = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(y), sincia = Object(__WEBPACK_IMPORTED_MODULE_1__math__["z" /* sinci */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["b" /* acos */])(cosy * Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(x /= 2)));
return [2 * cosy * Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(x) * sincia, Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(y) * sincia];
}
// Abort if [x, y] is not within an ellipse centered at [0, 0] with
// semi-major axis pi and semi-minor axis pi/2.
aitoffRaw.invert = function(x, y) {
if (x * x + 4 * y * y > __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] * __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] + __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */]) return;
var x1 = x, y1 = y, i = 25;
do {
var sinx = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(x1),
sinx_2 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(x1 / 2),
cosx_2 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(x1 / 2),
siny = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(y1),
cosy = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(y1),
sin_2y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(2 * y1),
sin2y = siny * siny,
cos2y = cosy * cosy,
sin2x_2 = sinx_2 * sinx_2,
c = 1 - cos2y * cosx_2 * cosx_2,
e = c ? Object(__WEBPACK_IMPORTED_MODULE_1__math__["b" /* acos */])(cosy * cosx_2) * Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(f = 1 / c) : f = 0,
f,
fx = 2 * e * cosy * sinx_2 - x,
fy = e * siny - y,
dxdx = f * (cos2y * sin2x_2 + e * cosy * cosx_2 * sin2y),
dxdy = f * (0.5 * sinx * sin_2y - e * 2 * siny * sinx_2),
dydx = f * 0.25 * (sin_2y * sinx_2 - e * siny * cos2y * sinx),
dydy = f * (sin2y * cosx_2 + e * sin2x_2 * cosy),
z = dxdy * dydx - dydy * dxdx;
if (!z) break;
var dx = (fy * dxdy - fx * dydy) / z,
dy = (fx * dydx - fy * dxdx) / z;
x1 -= dx, y1 -= dy;
} while ((Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(dx) > __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */] || Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(dy) > __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */]) && --i > 0);
return [x1, y1];
};
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(aitoffRaw)
.scale(152.63);
});
/***/ }),
/* 130 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = augustRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
function augustRaw(lambda, phi) {
var tanPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["F" /* tan */])(phi / 2),
k = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(1 - tanPhi * tanPhi),
c = 1 + k * Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(lambda /= 2),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(lambda) * k / c,
y = tanPhi / c,
x2 = x * x,
y2 = y * y;
return [
4 / 3 * x * (3 + x2 - 3 * y2),
4 / 3 * y * (3 + 3 * x2 - y2)
];
}
augustRaw.invert = function(x, y) {
x *= 3 / 8, y *= 3 / 8;
if (!x && Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(y) > 1) return null;
var x2 = x * x,
y2 = y * y,
s = 1 + x2 + y2,
sin3Eta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])((s - Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(s * s - 4 * y * y)) / 2),
eta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(sin3Eta) / 3,
xi = sin3Eta ? Object(__WEBPACK_IMPORTED_MODULE_1__math__["c" /* arcosh */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(y / sin3Eta)) / 3 : Object(__WEBPACK_IMPORTED_MODULE_1__math__["d" /* arsinh */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(x)) / 3,
cosEta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(eta),
coshXi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["i" /* cosh */])(xi),
d = coshXi * coshXi - cosEta * cosEta;
return [
Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(x) * 2 * Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* atan2 */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["A" /* sinh */])(xi) * cosEta, 0.25 - d),
Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(y) * 2 * Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* atan2 */])(coshXi * Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(eta), 0.25 + d)
];
};
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(augustRaw)
.scale(66.1603);
});
/***/ }),
/* 131 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = boggsRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mollweide__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(1);
var k = 2.00276,
w = 1.11072;
function boggsRaw(lambda, phi) {
var theta = Object(__WEBPACK_IMPORTED_MODULE_1__mollweide__["c" /* mollweideBromleyTheta */])(__WEBPACK_IMPORTED_MODULE_2__math__["s" /* pi */], phi);
return [k * lambda / (1 / Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(phi) + w / Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(theta)), (phi + __WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(theta)) / k];
}
boggsRaw.invert = function(x, y) {
var ky = k * y, theta = y < 0 ? -__WEBPACK_IMPORTED_MODULE_2__math__["u" /* quarterPi */] : __WEBPACK_IMPORTED_MODULE_2__math__["u" /* quarterPi */], i = 25, delta, phi;
do {
phi = ky - __WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(theta);
theta -= delta = (Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(2 * theta) + 2 * theta - __WEBPACK_IMPORTED_MODULE_2__math__["s" /* pi */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(phi)) / (2 * Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(2 * theta) + 2 + __WEBPACK_IMPORTED_MODULE_2__math__["s" /* pi */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(phi) * __WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(theta));
} while (Object(__WEBPACK_IMPORTED_MODULE_2__math__["a" /* abs */])(delta) > __WEBPACK_IMPORTED_MODULE_2__math__["k" /* epsilon */] && --i > 0);
phi = ky - __WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] * Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(theta);
return [x * (1 / Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(phi) + w / Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(theta)) / k, phi];
};
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(boggsRaw)
.scale(160.857);
});
/***/ }),
/* 132 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = cylindricalEqualAreaRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parallel1__ = __webpack_require__(31);
function cylindricalEqualAreaRaw(phi0) {
var cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_0__math__["h" /* cos */])(phi0);
function forward(lambda, phi) {
return [lambda * cosPhi0, Object(__WEBPACK_IMPORTED_MODULE_0__math__["y" /* sin */])(phi) / cosPhi0];
}
forward.invert = function(x, y) {
return [x / cosPhi0, Object(__WEBPACK_IMPORTED_MODULE_0__math__["e" /* asin */])(y * cosPhi0)];
};
return forward;
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_1__parallel1__["a" /* default */])(cylindricalEqualAreaRaw)
.parallel(38.58) // acos(sqrt(width / height / pi)) * radians
.scale(195.044); // width / (sqrt(width / height / pi) * 2 * pi)
});
/***/ }),
/* 133 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = gringortenRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__square__ = __webpack_require__(134);
function gringortenRaw(lambda, phi) {
var sLambda = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(lambda),
sPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(phi),
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi),
x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(lambda) * cosPhi,
y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(lambda) * cosPhi,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(sPhi * phi);
lambda = Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* atan2 */])(y, z));
phi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(x);
if (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(lambda - __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */]) > __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */]) lambda %= __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */];
var point = gringortenHexadecant(lambda > __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 4 ? __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */] - lambda : lambda, phi);
if (lambda > __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 4) z = point[0], point[0] = -point[1], point[1] = -z;
return (point[0] *= sLambda, point[1] *= -sPhi, point);
}
gringortenRaw.invert = function(x, y) {
if (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(x) > 1) x = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(x) * 2 - x;
if (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(y) > 1) y = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(y) * 2 - y;
var sx = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(x),
sy = Object(__WEBPACK_IMPORTED_MODULE_1__math__["x" /* sign */])(y),
x0 = -sx * x,
y0 = -sy * y,
t = y0 / x0 < 1,
p = gringortenHexadecantInvert(t ? y0 : x0, t ? x0 : y0),
lambda = p[0],
phi = p[1],
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi);
if (t) lambda = -__WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */] - lambda;
return [sx * (Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* atan2 */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(lambda) * cosPhi, -Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(phi)) + __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */]), sy * Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(lambda) * cosPhi)];
};
function gringortenHexadecant(lambda, phi) {
if (phi === __WEBPACK_IMPORTED_MODULE_1__math__["o" /* halfPi */]) return [0, 0];
var sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(phi),
r = sinPhi * sinPhi,
r2 = r * r,
j = 1 + r2,
k = 1 + 3 * r2,
q = 1 - r2,
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(1 / Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(j)),
v = q + r * j * z,
p2 = (1 - sinPhi) / v,
p = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(p2),
a2 = p2 * j,
a = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2),
h = p * q,
x,
i;
if (lambda === 0) return [0, -(h + r * a)];
var cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi),
secPhi = 1 / cosPhi,
drdPhi = 2 * sinPhi * cosPhi,
dvdPhi = (-3 * r + z * k) * drdPhi,
dp2dPhi = (-v * cosPhi - (1 - sinPhi) * dvdPhi) / (v * v),
dpdPhi = (0.5 * dp2dPhi) / p,
dhdPhi = q * dpdPhi - 2 * r * p * drdPhi,
dra2dPhi = r * j * dp2dPhi + p2 * k * drdPhi,
mu = -secPhi * drdPhi,
nu = -secPhi * dra2dPhi,
zeta = -2 * secPhi * dhdPhi,
lambda1 = 4 * lambda / __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */],
delta;
// Slower but accurate bisection method.
if (lambda > 0.222 * __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] || phi < __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 4 && lambda > 0.175 * __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */]) {
x = (h + r * Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2 * (1 + r2) - h * h)) / (1 + r2);
if (lambda > __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 4) return [x, x];
var x1 = x, x0 = 0.5 * x;
x = 0.5 * (x0 + x1), i = 50;
do {
var g = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2 - x * x),
f = (x * (zeta + mu * g) + nu * Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(x / a)) - lambda1;
if (!f) break;
if (f < 0) x0 = x;
else x1 = x;
x = 0.5 * (x0 + x1);
} while (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(x1 - x0) > __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */] && --i > 0);
}
// Newton-Raphson.
else {
x = __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */], i = 25;
do {
var x2 = x * x,
g2 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2 - x2),
zetaMug = zeta + mu * g2,
f2 = x * zetaMug + nu * Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(x / a) - lambda1,
df = zetaMug + (nu - mu * x2) / g2;
x -= delta = g2 ? f2 / df : 0;
} while (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(delta) > __WEBPACK_IMPORTED_MODULE_1__math__["k" /* epsilon */] && --i > 0);
}
return [x, -h - r * Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2 - x * x)];
}
function gringortenHexadecantInvert(x, y) {
var x0 = 0,
x1 = 1,
r = 0.5,
i = 50;
while (true) {
var r2 = r * r,
sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(r),
z = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(1 / Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(1 + r2)),
v = (1 - r2) + r * (1 + r2) * z,
p2 = (1 - sinPhi) / v,
p = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(p2),
a2 = p2 * (1 + r2),
h = p * (1 - r2),
g2 = a2 - x * x,
g = Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(g2),
y0 = y + h + r * g;
if (Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(x1 - x0) < __WEBPACK_IMPORTED_MODULE_1__math__["l" /* epsilon2 */] || --i === 0 || y0 === 0) break;
if (y0 > 0) x0 = r;
else x1 = r;
r = 0.5 * (x0 + x1);
}
if (!i) return null;
var phi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(sinPhi),
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["h" /* cos */])(phi),
secPhi = 1 / cosPhi,
drdPhi = 2 * sinPhi * cosPhi,
dvdPhi = (-3 * r + z * (1 + 3 * r2)) * drdPhi,
dp2dPhi = (-v * cosPhi - (1 - sinPhi) * dvdPhi) / (v * v),
dpdPhi = 0.5 * dp2dPhi / p,
dhdPhi = (1 - r2) * dpdPhi - 2 * r * p * drdPhi,
zeta = -2 * secPhi * dhdPhi,
mu = -secPhi * drdPhi,
nu = -secPhi * (r * (1 + r2) * dp2dPhi + p2 * (1 + 3 * r2) * drdPhi);
return [__WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] / 4 * (x * (zeta + mu * g) + nu * Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(x / Object(__WEBPACK_IMPORTED_MODULE_1__math__["B" /* sqrt */])(a2))), phi];
}
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(Object(__WEBPACK_IMPORTED_MODULE_2__square__["a" /* default */])(gringortenRaw))
.scale(239.75);
});
/***/ }),
/* 134 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(1);
/* harmony default export */ __webpack_exports__["a"] = (function(project) {
var dx = project(__WEBPACK_IMPORTED_MODULE_0__math__["o" /* halfPi */], 0)[0] - project(-__WEBPACK_IMPORTED_MODULE_0__math__["o" /* halfPi */], 0)[0];
function projectSquare(lambda, phi) {
var s = lambda > 0 ? -0.5 : 0.5,
point = project(lambda + s * __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */], phi);
point[0] -= s * dx;
return point;
}
if (project.invert) projectSquare.invert = function(x, y) {
var s = x > 0 ? -0.5 : 0.5,
location = project.invert(x + s * dx, y),
lambda = location[0] - s * __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */];
if (lambda < -__WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */]) lambda += 2 * __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */];
else if (lambda > __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */]) lambda -= 2 * __WEBPACK_IMPORTED_MODULE_0__math__["s" /* pi */];
location[0] = lambda;
return location;
};
return projectSquare;
});
/***/ }),
/* 135 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = guyouRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__elliptic__ = __webpack_require__(267);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__square__ = __webpack_require__(134);
function guyouRaw(lambda, phi) {
var k_ = (__WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] - 1) / (__WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] + 1),
k = Object(__WEBPACK_IMPORTED_MODULE_2__math__["B" /* sqrt */])(1 - k_ * k_),
K = Object(__WEBPACK_IMPORTED_MODULE_1__elliptic__["a" /* ellipticF */])(__WEBPACK_IMPORTED_MODULE_2__math__["o" /* halfPi */], k * k),
f = -1,
psi = Object(__WEBPACK_IMPORTED_MODULE_2__math__["p" /* log */])(Object(__WEBPACK_IMPORTED_MODULE_2__math__["F" /* tan */])(__WEBPACK_IMPORTED_MODULE_2__math__["s" /* pi */] / 4 + Object(__WEBPACK_IMPORTED_MODULE_2__math__["a" /* abs */])(phi) / 2)),
r = Object(__WEBPACK_IMPORTED_MODULE_2__math__["m" /* exp */])(f * psi) / Object(__WEBPACK_IMPORTED_MODULE_2__math__["B" /* sqrt */])(k_),
at = guyouComplexAtan(r * Object(__WEBPACK_IMPORTED_MODULE_2__math__["h" /* cos */])(f * lambda), r * Object(__WEBPACK_IMPORTED_MODULE_2__math__["y" /* sin */])(f * lambda)),
t = Object(__WEBPACK_IMPORTED_MODULE_1__elliptic__["b" /* ellipticFi */])(at[0], at[1], k * k);
return [-t[1], (phi >= 0 ? 1 : -1) * (0.5 * K - t[0])];
}
function guyouComplexAtan(x, y) {
var x2 = x * x,
y_1 = y + 1,
t = 1 - x2 - y * y;
return [
0.5 * ((x >= 0 ? __WEBPACK_IMPORTED_MODULE_2__math__["o" /* halfPi */] : -__WEBPACK_IMPORTED_MODULE_2__math__["o" /* halfPi */]) - Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* atan2 */])(t, 2 * x)),
-0.25 * Object(__WEBPACK_IMPORTED_MODULE_2__math__["p" /* log */])(t * t + 4 * x2) +0.5 * Object(__WEBPACK_IMPORTED_MODULE_2__math__["p" /* log */])(y_1 * y_1 + x2)
];
}
function guyouComplexDivide(a, b) {
var denominator = b[0] * b[0] + b[1] * b[1];
return [
(a[0] * b[0] + a[1] * b[1]) / denominator,
(a[1] * b[0] - a[0] * b[1]) / denominator
];
}
guyouRaw.invert = function(x, y) {
var k_ = (__WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] - 1) / (__WEBPACK_IMPORTED_MODULE_2__math__["D" /* sqrt2 */] + 1),
k = Object(__WEBPACK_IMPORTED_MODULE_2__math__["B" /* sqrt */])(1 - k_ * k_),
K = Object(__WEBPACK_IMPORTED_MODULE_1__elliptic__["a" /* ellipticF */])(__WEBPACK_IMPORTED_MODULE_2__math__["o" /* halfPi */], k * k),
f = -1,
j = Object(__WEBPACK_IMPORTED_MODULE_1__elliptic__["c" /* ellipticJi */])(0.5 * K - y, -x, k * k),
tn = guyouComplexDivide(j[0], j[1]),
lambda = Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* atan2 */])(tn[1], tn[0]) / f;
return [
lambda,
2 * Object(__WEBPACK_IMPORTED_MODULE_2__math__["f" /* atan */])(Object(__WEBPACK_IMPORTED_MODULE_2__math__["m" /* exp */])(0.5 / f * Object(__WEBPACK_IMPORTED_MODULE_2__math__["p" /* log */])(k_ * tn[0] * tn[0] + k_ * tn[1] * tn[1]))) - __WEBPACK_IMPORTED_MODULE_2__math__["o" /* halfPi */]
];
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(Object(__WEBPACK_IMPORTED_MODULE_3__square__["a" /* default */])(guyouRaw))
.scale(151.496);
});
/***/ }),
/* 136 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = homolosineRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mollweide__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__sinusoidal__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sinuMollweide__ = __webpack_require__(73);
function homolosineRaw(lambda, phi) {
return Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(phi) > __WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["b" /* sinuMollweidePhi */]
? (lambda = Object(__WEBPACK_IMPORTED_MODULE_2__mollweide__["d" /* mollweideRaw */])(lambda, phi), lambda[1] -= phi > 0 ? __WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["d" /* sinuMollweideY */] : -__WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["d" /* sinuMollweideY */], lambda)
: Object(__WEBPACK_IMPORTED_MODULE_3__sinusoidal__["b" /* sinusoidalRaw */])(lambda, phi);
}
homolosineRaw.invert = function(x, y) {
return Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(y) > __WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["b" /* sinuMollweidePhi */]
? __WEBPACK_IMPORTED_MODULE_2__mollweide__["d" /* mollweideRaw */].invert(x, y + (y > 0 ? __WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["d" /* sinuMollweideY */] : -__WEBPACK_IMPORTED_MODULE_4__sinuMollweide__["d" /* sinuMollweideY */]))
: __WEBPACK_IMPORTED_MODULE_3__sinusoidal__["b" /* sinusoidalRaw */].invert(x, y);
};
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(homolosineRaw)
.scale(152.63);
});
/***/ }),
/* 137 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__guyou__ = __webpack_require__(135);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index__ = __webpack_require__(75);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_1__index__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_0__guyou__["b" /* guyouRaw */])
.scale(111.48);
});
/***/ }),
/* 138 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_geo__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(1);
// Compute the origin as the midpoint of the two reference points.
// Rotate one of the reference points by the origin.
// Apply the spherical law of sines to compute gamma rotation.
/* harmony default export */ __webpack_exports__["a"] = (function(raw, p0, p1) {
var i = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoInterpolate"])(p0, p1),
o = i(0.5),
a = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoRotation"])([-o[0], -o[1]])(p0),
b = i.distance / 2,
y = -Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* asin */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(a[1] * __WEBPACK_IMPORTED_MODULE_1__math__["v" /* radians */]) / Object(__WEBPACK_IMPORTED_MODULE_1__math__["y" /* sin */])(b)),
R = [-o[0], -o[1], -(a[0] > 0 ? __WEBPACK_IMPORTED_MODULE_1__math__["s" /* pi */] - y : y) * __WEBPACK_IMPORTED_MODULE_1__math__["j" /* degrees */]],
p = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoProjection"])(raw(b)).rotate(R),
r = Object(__WEBPACK_IMPORTED_MODULE_0_d3_geo__["geoRotation"])(R),
center = p.center;
delete p.rotate;
p.center = function(_) {
return arguments.length ? center(r(_)) : r.invert(center());
};
return p
.clipAngle(90);
});
/***/ }),
/* 139 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/*!
* EventEmitter v5.1.0 - git.io/ee
* Unlicense - http://unlicense.org/
* Oliver Caldwell - http://oli.me.uk/
* @preserve
*/
;(function (exports) {
'use strict';
/**
* Class for managing events.
* Can be extended to provide event functionality in other classes.
*
* @class EventEmitter Manages event registering and emitting.
*/
function EventEmitter() {}
// Shortcuts to improve speed and size
var proto = EventEmitter.prototype;
var originalGlobalValue = exports.EventEmitter;
/**
* Finds the index of the listener for the event in its storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
* @return {Number} Index of the specified listener, -1 if not found
* @api private
*/
function indexOfListener(listeners, listener) {
var i = listeners.length;
while (i--) {
if (listeners[i].listener === listener) {
return i;
}
}
return -1;
}
/**
* Alias a method while keeping the context correct, to allow for overwriting of target method.
*
* @param {String} name The name of the target method.
* @return {Function} The aliased method
* @api private
*/
function alias(name) {
return function aliasClosure() {
return this[name].apply(this, arguments);
};
}
/**
* Returns the listener array for the specified event.
* Will initialise the event object and listener arrays if required.
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
* Each property in the object response is an array of listener functions.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Function[]|Object} All listener functions for the event.
*/
proto.getListeners = function getListeners(evt) {
var events = this._getEvents();
var response;
var key;
// Return a concatenated array of all matching events if
// the selector is a regular expression.
if (evt instanceof RegExp) {
response = {};
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
response[key] = events[key];
}
}
}
else {
response = events[evt] || (events[evt] = []);
}
return response;
};
/**
* Takes a list of listener objects and flattens it into a list of listener functions.
*
* @param {Object[]} listeners Raw listener objects.
* @return {Function[]} Just the listener functions.
*/
proto.flattenListeners = function flattenListeners(listeners) {
var flatListeners = [];
var i;
for (i = 0; i < listeners.length; i += 1) {
flatListeners.push(listeners[i].listener);
}
return flatListeners;
};
/**
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Object} All listener functions for an event in an object.
*/
proto.getListenersAsObject = function getListenersAsObject(evt) {
var listeners = this.getListeners(evt);
var response;
if (listeners instanceof Array) {
response = {};
response[evt] = listeners;
}
return response || listeners;
};
function isValidListener (listener) {
if (typeof listener === 'function' || listener instanceof RegExp) {
return true
} else if (listener && typeof listener === 'object') {
return isValidListener(listener.listener)
} else {
return false
}
}
/**
* Adds a listener function to the specified event.
* The listener will not be added if it is a duplicate.
* If the listener returns true then it will be removed after it is called.
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListener = function addListener(evt, listener) {
if (!isValidListener(listener)) {
throw new TypeError('listener must be a function');
}
var listeners = this.getListenersAsObject(evt);
var listenerIsWrapped = typeof listener === 'object';
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
listeners[key].push(listenerIsWrapped ? listener : {
listener: listener,
once: false
});
}
}
return this;
};
/**
* Alias of addListener
*/
proto.on = alias('addListener');
/**
* Semi-alias of addListener. It will add a listener that will be
* automatically removed after its first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addOnceListener = function addOnceListener(evt, listener) {
return this.addListener(evt, {
listener: listener,
once: true
});
};
/**
* Alias of addOnceListener.
*/
proto.once = alias('addOnceListener');
/**
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
* You need to tell it what event names should be matched by a regex.
*
* @param {String} evt Name of the event to create.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvent = function defineEvent(evt) {
this.getListeners(evt);
return this;
};
/**
* Uses defineEvent to define multiple events.
*
* @param {String[]} evts An array of event names to define.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvents = function defineEvents(evts) {
for (var i = 0; i < evts.length; i += 1) {
this.defineEvent(evts[i]);
}
return this;
};
/**
* Removes a listener function from the specified event.
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
*
* @param {String|RegExp} evt Name of the event to remove the listener from.
* @param {Function} listener Method to remove from the event.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListener = function removeListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var index;
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
index = indexOfListener(listeners[key], listener);
if (index !== -1) {
listeners[key].splice(index, 1);
}
}
}
return this;
};
/**
* Alias of removeListener
*/
proto.off = alias('removeListener');
/**
* Adds listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
* You can also pass it a regular expression to add the array of listeners to all events that match it.
* Yeah, this function does quite a bit. That's probably a bad thing.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListeners = function addListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(false, evt, listeners);
};
/**
* Removes listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be removed.
* You can also pass it a regular expression to remove the listeners from all events that match it.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListeners = function removeListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(true, evt, listeners);
};
/**
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
* The first argument will determine if the listeners are removed (true) or added (false).
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be added/removed.
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
*
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
var i;
var value;
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
// If evt is an object then pass each of its properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
// Pass the single listener straight through to the singular method
if (typeof value === 'function') {
single.call(this, i, value);
}
else {
// Otherwise pass back to the multiple function
multiple.call(this, i, value);
}
}
}
}
else {
// So evt must be a string
// And listeners must be an array of listeners
// Loop over it and pass each one to the multiple method
i = listeners.length;
while (i--) {
single.call(this, evt, listeners[i]);
}
}
return this;
};
/**
* Removes all listeners from a specified event.
* If you do not specify an event then all listeners will be removed.
* That means every event will be emptied.
* You can also pass a regex to remove all events that match it.
*
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeEvent = function removeEvent(evt) {
var type = typeof evt;
var events = this._getEvents();
var key;
// Remove different things depending on the state of evt
if (type === 'string') {
// Remove all listeners for the specified event
delete events[evt];
}
else if (evt instanceof RegExp) {
// Remove all events matching the regex.
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
delete events[key];
}
}
}
else {
// Remove all listeners in all events
delete this._events;
}
return this;
};
/**
* Alias of removeEvent.
*
* Added to mirror the node API.
*/
proto.removeAllListeners = alias('removeEvent');
/**
* Emits an event of your choice.
* When emitted, every listener attached to that event will be executed.
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
* So they will not arrive within the array on the other side, they will be separate.
* You can also pass a regular expression to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {Array} [args] Optional array of arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emitEvent = function emitEvent(evt, args) {
var listenersMap = this.getListenersAsObject(evt);
var listeners;
var listener;
var i;
var key;
var response;
for (key in listenersMap) {
if (listenersMap.hasOwnProperty(key)) {
listeners = listenersMap[key].slice(0);
for (i = 0; i < listeners.length; i++) {
// If the listener returns true then it shall be removed from the event
// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[i];
if (listener.once === true) {
this.removeListener(evt, listener.listener);
}
response = listener.listener.apply(this, args || []);
if (response === this._getOnceReturnValue()) {
this.removeListener(evt, listener.listener);
}
}
}
}
return this;
};
/**
* Alias of emitEvent
*/
proto.trigger = alias('emitEvent');
/**
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {...*} Optional additional arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emit = function emit(evt) {
var args = Array.prototype.slice.call(arguments, 1);
return this.emitEvent(evt, args);
};
/**
* Sets the current value to check against when executing listeners. If a
* listeners return value matches the one set here then it will be removed
* after execution. This value defaults to true.
*
* @param {*} value The new value to check for when executing listeners.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.setOnceReturnValue = function setOnceReturnValue(value) {
this._onceReturnValue = value;
return this;
};
/**
* Fetches the current value to check against when executing listeners. If
* the listeners return value matches this one then it should be removed
* automatically. It will return true by default.
*
* @return {*|Boolean} The current value to check for or the default, true.
* @api private
*/
proto._getOnceReturnValue = function _getOnceReturnValue() {
if (this.hasOwnProperty('_onceReturnValue')) {
return this._onceReturnValue;
}
else {
return true;
}
};
/**
* Fetches the events object and creates one if required.
*
* @return {Object} The events storage object.
* @api private
*/
proto._getEvents = function _getEvents() {
return this._events || (this._events = {});
};
/**
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
*
* @return {Function} Non conflicting EventEmitter class.
*/
EventEmitter.noConflict = function noConflict() {
exports.EventEmitter = originalGlobalValue;
return EventEmitter;
};
// Expose the class either via AMD, CommonJS or the global object
if (true) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return EventEmitter;
}).call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
else if (typeof module === 'object' && module.exports){
module.exports = EventEmitter;
}
else {
exports.EventEmitter = EventEmitter;
}
}(this || {}));
/***/ }),
/* 140 */
/***/ (function(module, exports, __webpack_require__) {
var keys = __webpack_require__(24);
var isNil = __webpack_require__(77);
function isMatch(obj, attrs) {
var _keys = keys(attrs);
var length = _keys.length;
if (isNil(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;
}
module.exports = isMatch;
/***/ }),
/* 141 */
/***/ (function(module, exports, __webpack_require__) {
var isFunction = __webpack_require__(11);
var isString = __webpack_require__(10);
var d3Geo = __webpack_require__(0);
var d3GeoProjection = __webpack_require__(128);
var d3CompositeProjection = __webpack_require__(322);
/*
* getGeoProjection
*
* @param {string|function} projection projection name or projection function
* @param {boolean} [exportRaw = false] - whether return the raw projection or not
* */
module.exports = function (projection, exportRaw) {
if (isFunction(projection)) {
return exportRaw ? projection : projection();
}
if (isString(projection)) {
if (d3Geo[projection]) {
return exportRaw ? d3Geo[projection] : d3Geo[projection]();
}
if (d3GeoProjection[projection]) {
return exportRaw ? d3GeoProjection[projection] : d3GeoProjection[projection]();
}
if (d3CompositeProjection[projection]) {
return exportRaw ? d3CompositeProjection[projection] : d3CompositeProjection[projection]();
}
}
return null;
};
/***/ }),
/* 142 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return areaRingSum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return areaStream; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__adder__ = __webpack_require__(42);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__noop__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__stream__ = __webpack_require__(26);
var areaRingSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])();
var areaSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])(),
lambda00,
phi00,
lambda0,
cosPhi0,
sinPhi0;
var areaStream = {
point: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineStart: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonStart: function() {
areaRingSum.reset();
areaStream.lineStart = areaRingStart;
areaStream.lineEnd = areaRingEnd;
},
polygonEnd: function() {
var areaRing = +areaRingSum;
areaSum.add(areaRing < 0 ? __WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */] + areaRing : areaRing);
this.lineStart = this.lineEnd = this.point = __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */];
},
sphere: function() {
areaSum.add(__WEBPACK_IMPORTED_MODULE_1__math__["w" /* tau */]);
}
};
function areaRingStart() {
areaStream.point = areaPointFirst;
}
function areaRingEnd() {
areaPoint(lambda00, phi00);
}
function areaPointFirst(lambda, phi) {
areaStream.point = areaPoint;
lambda00 = lambda, phi00 = phi;
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
lambda0 = lambda, cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi = phi / 2 + __WEBPACK_IMPORTED_MODULE_1__math__["q" /* quarterPi */]), sinPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi);
}
function areaPoint(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
phi = phi / 2 + __WEBPACK_IMPORTED_MODULE_1__math__["q" /* quarterPi */]; // half the angular distance from south pole
// Spherical excess E for a spherical triangle with vertices: south pole,
// previous point, current point. Uses a formula derived from Cagnoli’s
// theorem. See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2).
var dLambda = lambda - lambda0,
sdLambda = dLambda >= 0 ? 1 : -1,
adLambda = sdLambda * dLambda,
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
k = sinPhi0 * sinPhi,
u = cosPhi0 * cosPhi + k * Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(adLambda),
v = k * sdLambda * Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(adLambda);
areaRingSum.add(Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(v, u));
// Advance the previous points.
lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
}
/* harmony default export */ __webpack_exports__["c"] = (function(object) {
areaSum.reset();
Object(__WEBPACK_IMPORTED_MODULE_3__stream__["a" /* default */])(object, areaStream);
return areaSum * 2;
});
/***/ }),
/* 143 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = circleStream;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cartesian__ = __webpack_require__(43);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constant__ = __webpack_require__(326);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__rotation__ = __webpack_require__(78);
// Generates a circle centered at [0°, 0°], with a given radius and precision.
function circleStream(stream, radius, delta, direction, t0, t1) {
if (!delta) return;
var cosRadius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(radius),
sinRadius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(radius),
step = direction * delta;
if (t0 == null) {
t0 = radius + direction * __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
t1 = radius - step / 2;
} else {
t0 = circleRadius(cosRadius, t0);
t1 = circleRadius(cosRadius, t1);
if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
}
for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
point = Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["g" /* spherical */])([cosRadius, -sinRadius * Object(__WEBPACK_IMPORTED_MODULE_2__math__["g" /* cos */])(t), -sinRadius * Object(__WEBPACK_IMPORTED_MODULE_2__math__["t" /* sin */])(t)]);
stream.point(point[0], point[1]);
}
}
// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0].
function circleRadius(cosRadius, point) {
point = Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["a" /* cartesian */])(point), point[0] -= cosRadius;
Object(__WEBPACK_IMPORTED_MODULE_0__cartesian__["e" /* cartesianNormalizeInPlace */])(point);
var radius = Object(__WEBPACK_IMPORTED_MODULE_2__math__["b" /* acos */])(-point[1]);
return ((-point[2] < 0 ? -radius : radius) + __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */]) % __WEBPACK_IMPORTED_MODULE_2__math__["w" /* tau */];
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
var center = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])([0, 0]),
radius = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(90),
precision = Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(6),
ring,
rotate,
stream = {point: point};
function point(x, y) {
ring.push(x = rotate(x, y));
x[0] *= __WEBPACK_IMPORTED_MODULE_2__math__["h" /* degrees */], x[1] *= __WEBPACK_IMPORTED_MODULE_2__math__["h" /* degrees */];
}
function circle() {
var c = center.apply(this, arguments),
r = radius.apply(this, arguments) * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */],
p = precision.apply(this, arguments) * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */];
ring = [];
rotate = Object(__WEBPACK_IMPORTED_MODULE_3__rotation__["b" /* rotateRadians */])(-c[0] * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */], -c[1] * __WEBPACK_IMPORTED_MODULE_2__math__["r" /* radians */], 0).invert;
circleStream(stream, r, p, 1);
c = {type: "Polygon", coordinates: [ring]};
ring = rotate = null;
return c;
}
circle.center = function(_) {
return arguments.length ? (center = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])([+_[0], +_[1]]), circle) : center;
};
circle.radius = function(_) {
return arguments.length ? (radius = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), circle) : radius;
};
circle.precision = function(_) {
return arguments.length ? (precision = typeof _ === "function" ? _ : Object(__WEBPACK_IMPORTED_MODULE_1__constant__["a" /* default */])(+_), circle) : precision;
};
return circle;
});
/***/ }),
/* 144 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
function compose(x, y) {
return x = a(x, y), b(x[0], x[1]);
}
if (a.invert && b.invert) compose.invert = function(x, y) {
return x = b.invert(x, y), x && a.invert(x[0], x[1]);
};
return compose;
});
/***/ }),
/* 145 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = clipExtent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__buffer__ = __webpack_require__(146);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__line__ = __webpack_require__(327);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__polygon__ = __webpack_require__(147);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_d3_array__ = __webpack_require__(14);
var clipMax = 1e9, clipMin = -clipMax;
// TODO Use d3-polygon’s polygonContains here for the ring check?
// TODO Eliminate duplicate buffering in clipBuffer and polygon.push?
function clipExtent(x0, y0, x1, y1) {
function visible(x, y) {
return x0 <= x && x <= x1 && y0 <= y && y <= y1;
}
function interpolate(from, to, direction, stream) {
var a = 0, a1 = 0;
if (from == null
|| (a = corner(from, direction)) !== (a1 = corner(to, direction))
|| comparePoint(from, to) < 0 ^ direction > 0) {
do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
while ((a = (a + direction + 4) % 4) !== a1);
} else {
stream.point(to[0], to[1]);
}
}
function corner(p, direction) {
return Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[0] - x0) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 0 : 3
: Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[0] - x1) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 2 : 1
: Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(p[1] - y0) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] ? direction > 0 ? 1 : 0
: direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon
}
function compareIntersection(a, b) {
return comparePoint(a.x, b.x);
}
function comparePoint(a, b) {
var ca = corner(a, 1),
cb = corner(b, 1);
return ca !== cb ? ca - cb
: ca === 0 ? b[1] - a[1]
: ca === 1 ? a[0] - b[0]
: ca === 2 ? a[1] - b[1]
: b[0] - a[0];
}
return function(stream) {
var activeStream = stream,
bufferStream = Object(__WEBPACK_IMPORTED_MODULE_1__buffer__["a" /* default */])(),
segments,
polygon,
ring,
x__, y__, v__, // first point
x_, y_, v_, // previous point
first,
clean;
var clipStream = {
point: point,
lineStart: lineStart,
lineEnd: lineEnd,
polygonStart: polygonStart,
polygonEnd: polygonEnd
};
function point(x, y) {
if (visible(x, y)) activeStream.point(x, y);
}
function polygonInside() {
var winding = 0;
for (var i = 0, n = polygon.length; i < n; ++i) {
for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }
else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
}
}
return winding;
}
// Buffer geometry within a polygon and then clip it en masse.
function polygonStart() {
activeStream = bufferStream, segments = [], polygon = [], clean = true;
}
function polygonEnd() {
var startInside = polygonInside(),
cleanInside = clean && startInside,
visible = (segments = Object(__WEBPACK_IMPORTED_MODULE_4_d3_array__["merge"])(segments)).length;
if (cleanInside || visible) {
stream.polygonStart();
if (cleanInside) {
stream.lineStart();
interpolate(null, null, 1, stream);
stream.lineEnd();
}
if (visible) {
Object(__WEBPACK_IMPORTED_MODULE_3__polygon__["a" /* default */])(segments, compareIntersection, startInside, interpolate, stream);
}
stream.polygonEnd();
}
activeStream = stream, segments = polygon = ring = null;
}
function lineStart() {
clipStream.point = linePoint;
if (polygon) polygon.push(ring = []);
first = true;
v_ = false;
x_ = y_ = NaN;
}
// TODO rather than special-case polygons, simply handle them separately.
// Ideally, coincident intersection points should be jittered to avoid
// clipping issues.
function lineEnd() {
if (segments) {
linePoint(x__, y__);
if (v__ && v_) bufferStream.rejoin();
segments.push(bufferStream.result());
}
clipStream.point = point;
if (v_) activeStream.lineEnd();
}
function linePoint(x, y) {
var v = visible(x, y);
if (polygon) ring.push([x, y]);
if (first) {
x__ = x, y__ = y, v__ = v;
first = false;
if (v) {
activeStream.lineStart();
activeStream.point(x, y);
}
} else {
if (v && v_) activeStream.point(x, y);
else {
var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],
b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
if (Object(__WEBPACK_IMPORTED_MODULE_2__line__["a" /* default */])(a, b, x0, y0, x1, y1)) {
if (!v_) {
activeStream.lineStart();
activeStream.point(a[0], a[1]);
}
activeStream.point(b[0], b[1]);
if (!v) activeStream.lineEnd();
clean = false;
} else if (v) {
activeStream.lineStart();
activeStream.point(x, y);
clean = false;
}
}
}
x_ = x, y_ = y, v_ = v;
}
return clipStream;
};
}
/* harmony default export */ __webpack_exports__["b"] = (function() {
var x0 = 0,
y0 = 0,
x1 = 960,
y1 = 500,
cache,
cacheStream,
clip;
return clip = {
stream: function(stream) {
return cache && cacheStream === stream ? cache : cache = clipExtent(x0, y0, x1, y1)(cacheStream = stream);
},
extent: function(_) {
return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]];
}
};
});
/***/ }),
/* 146 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__noop__ = __webpack_require__(25);
/* harmony default export */ __webpack_exports__["a"] = (function() {
var lines = [],
line;
return {
point: function(x, y) {
line.push([x, y]);
},
lineStart: function() {
lines.push(line = []);
},
lineEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
rejoin: function() {
if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
},
result: function() {
var result = lines;
lines = [];
line = null;
return result;
}
};
});
/***/ }),
/* 147 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__pointEqual__ = __webpack_require__(148);
function Intersection(point, points, other, entry) {
this.x = point;
this.z = points;
this.o = other; // another intersection
this.e = entry; // is an entry?
this.v = false; // visited
this.n = this.p = null; // next & previous
}
// A generalized polygon clipping algorithm: given a polygon that has been cut
// into its visible line segments, and rejoins the segments by interpolating
// along the clip edge.
/* harmony default export */ __webpack_exports__["a"] = (function(segments, compareIntersection, startInside, interpolate, stream) {
var subject = [],
clip = [],
i,
n;
segments.forEach(function(segment) {
if ((n = segment.length - 1) <= 0) return;
var n, p0 = segment[0], p1 = segment[n], x;
// If the first and last points of a segment are coincident, then treat as a
// closed ring. TODO if all rings are closed, then the winding order of the
// exterior ring should be checked.
if (Object(__WEBPACK_IMPORTED_MODULE_0__pointEqual__["a" /* default */])(p0, p1)) {
stream.lineStart();
for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
stream.lineEnd();
return;
}
subject.push(x = new Intersection(p0, segment, null, true));
clip.push(x.o = new Intersection(p0, null, x, false));
subject.push(x = new Intersection(p1, segment, null, false));
clip.push(x.o = new Intersection(p1, null, x, true));
});
if (!subject.length) return;
clip.sort(compareIntersection);
link(subject);
link(clip);
for (i = 0, n = clip.length; i < n; ++i) {
clip[i].e = startInside = !startInside;
}
var start = subject[0],
points,
point;
while (1) {
// Find first unvisited intersection.
var current = start,
isSubject = true;
while (current.v) if ((current = current.n) === start) return;
points = current.z;
stream.lineStart();
do {
current.v = current.o.v = true;
if (current.e) {
if (isSubject) {
for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
} else {
interpolate(current.x, current.n.x, 1, stream);
}
current = current.n;
} else {
if (isSubject) {
points = current.p.z;
for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
} else {
interpolate(current.x, current.p.x, -1, stream);
}
current = current.p;
}
current = current.o;
points = current.z;
isSubject = !isSubject;
} while (!current.v);
stream.lineEnd();
}
});
function link(array) {
if (!(n = array.length)) return;
var n,
i = 0,
a = array[0],
b;
while (++i < n) {
a.n = b = array[i];
b.p = a;
a = b;
}
a.n = b = array[0];
b.p = a;
}
/***/ }),
/* 148 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(5);
/* harmony default export */ __webpack_exports__["a"] = (function(a, b) {
return Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(a[0] - b[0]) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */] && Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* abs */])(a[1] - b[1]) < __WEBPACK_IMPORTED_MODULE_0__math__["i" /* epsilon */];
});
/***/ }),
/* 149 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__adder__ = __webpack_require__(42);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__noop__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__stream__ = __webpack_require__(26);
var lengthSum = Object(__WEBPACK_IMPORTED_MODULE_0__adder__["a" /* default */])(),
lambda0,
sinPhi0,
cosPhi0;
var lengthStream = {
sphere: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
point: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
lineStart: lengthLineStart,
lineEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonStart: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */],
polygonEnd: __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */]
};
function lengthLineStart() {
lengthStream.point = lengthPointFirst;
lengthStream.lineEnd = lengthLineEnd;
}
function lengthLineEnd() {
lengthStream.point = lengthStream.lineEnd = __WEBPACK_IMPORTED_MODULE_2__noop__["a" /* default */];
}
function lengthPointFirst(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
lambda0 = lambda, sinPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi), cosPhi0 = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi);
lengthStream.point = lengthPoint;
}
function lengthPoint(lambda, phi) {
lambda *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */], phi *= __WEBPACK_IMPORTED_MODULE_1__math__["r" /* radians */];
var sinPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(phi),
cosPhi = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(phi),
delta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["a" /* abs */])(lambda - lambda0),
cosDelta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["g" /* cos */])(delta),
sinDelta = Object(__WEBPACK_IMPORTED_MODULE_1__math__["t" /* sin */])(delta),
x = cosPhi * sinDelta,
y = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta,
z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta;
lengthSum.add(Object(__WEBPACK_IMPORTED_MODULE_1__math__["e" /* atan2 */])(Object(__WEBPACK_IMPORTED_MODULE_1__math__["u" /* sqrt */])(x * x + y * y), z));
lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi;
}
/* harmony default export */ __webpack_exports__["a"] = (function(object) {
lengthSum.reset();
Object(__WEBPACK_IMPORTED_MODULE_3__stream__["a" /* default */])(object, lengthStream);
return +lengthSum;
});
/***/ }),
/* 150 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return x;
});
/***/ }),
/* 151 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__noop__ = __webpack_require__(25);
var x0 = Infinity,
y0 = x0,
x1 = -x0,
y1 = x1;
var boundsStream = {
point: boundsPoint,
lineStart: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
lineEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
polygonStart: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
polygonEnd: __WEBPACK_IMPORTED_MODULE_0__noop__["a" /* default */],
result: function() {
var bounds = [[x0, y0], [x1, y1]];
x1 = y1 = -(y0 = x0 = Infinity);
return bounds;
}
};
function boundsPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
if (y < y0) y0 = y;
if (y > y1) y1 = y;
}
/* harmony default export */ __webpack_exports__["a"] = (boundsStream);
/***/ }),
/* 152 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__conicEqualArea__ = __webpack_require__(79);
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0__conicEqualArea__["b" /* default */])()
.parallels([29.5, 45.5])
.scale(1070)
.translate([480, 250])
.rotate([96, 0])
.center([-0.6, 38.7]);
});
/***/ }),
/* 153 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__buffer__ = __webpack_require__(146);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__polygon__ = __webpack_require__(147);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__polygonContains__ = __webpack_require__(337);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_d3_array__ = __webpack_require__(14);
/* harmony default export */ __webpack_exports__["a"] = (function(pointVisible, clipLine, interpolate, start) {
return function(rotate, sink) {
var line = clipLine(sink),
rotatedStart = rotate.invert(start[0], start[1]),
ringBuffer = Object(__WEBPACK_IMPORTED_MODULE_0__buffer__["a" /* default */])(),
ringSink = clipLine(ringBuffer),
polygonStarted = false,
polygon,
segments,
ring;
var clip = {
point: point,
lineStart: lineStart,
lineEnd: lineEnd,
polygonStart: function() {
clip.point = pointRing;
clip.lineStart = ringStart;
clip.lineEnd = ringEnd;
segments = [];
polygon = [];
},
polygonEnd: function() {
clip.point = point;
clip.lineStart = lineStart;
clip.lineEnd = lineEnd;
segments = Object(__WEBPACK_IMPORTED_MODULE_4_d3_array__["merge"])(segments);
var startInside = Object(__WEBPACK_IMPORTED_MODULE_3__polygonContains__["a" /* default */])(polygon, rotatedStart);
if (segments.length) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
Object(__WEBPACK_IMPORTED_MODULE_1__polygon__["a" /* default */])(segments, compareIntersection, startInside, interpolate, sink);
} else if (startInside) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
sink.lineStart();
interpolate(null, null, 1, sink);
sink.lineEnd();
}
if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
segments = polygon = null;
},
sphere: function() {
sink.polygonStart();
sink.lineStart();
interpolate(null, null, 1, sink);
sink.lineEnd();
sink.polygonEnd();
}
};
function point(lambda, phi) {
var point = rotate(lambda, phi);
if (pointVisible(lambda = point[0], phi = point[1])) sink.point(lambda, phi);
}
function pointLine(lambda, phi) {
var point = rotate(lambda, phi);
line.point(point[0], point[1]);
}
function lineStart() {
clip.point = pointLine;
line.lineStart();
}
function lineEnd() {
clip.point = point;
line.lineEnd();
}
function pointRing(lambda, phi) {
ring.push([lambda, phi]);
var point = rotate(lambda, phi);
ringSink.point(point[0], point[1]);
}
function ringStart() {
ringSink.lineStart();
ring = [];
}
function ringEnd() {
pointRing(ring[0][0], ring[0][1]);
ringSink.lineEnd();
var clean = ringSink.clean(),
ringSegments = ringBuffer.result(),
i, n = ringSegments.length, m,
segment,
point;
ring.pop();
polygon.push(ring);
ring = null;
if (!n) return;
// No intersections.
if (clean & 1) {
segment = ringSegments[0];
if ((m = segment.length - 1) > 0) {
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
sink.lineStart();
for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);
sink.lineEnd();
}
return;
}
// Rejoin connected segments.
// TODO reuse ringBuffer.rejoin()?
if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
segments.push(ringSegments.filter(validSegment));
}
return clip;
};
});
function validSegment(segment) {
return segment.length > 1;
}
// Intersections are sorted along the clip edge. For both antimeridian cutting
// and circle clipping, the same comparison is used.
function compareIntersection(a, b) {
return ((a = a.x)[0] < 0 ? a[1] - __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] : __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - a[1])
- ((b = b.x)[0] < 0 ? b[1] - __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - __WEBPACK_IMPORTED_MODULE_2__math__["i" /* epsilon */] : __WEBPACK_IMPORTED_MODULE_2__math__["l" /* halfPi */] - b[1]);
}
/***/ }),
/* 154 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = fitSize;
/* harmony export (immutable) */ __webpack_exports__["a"] = fitExtent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__stream__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__path_bounds__ = __webpack_require__(151);
function fit(project, extent, object) {
var w = extent[1][0] - extent[0][0],
h = extent[1][1] - extent[0][1],
clip = project.clipExtent && project.clipExtent();
project
.scale(150)
.translate([0, 0]);
if (clip != null) project.clipExtent(null);
Object(__WEBPACK_IMPORTED_MODULE_0__stream__["a" /* default */])(object, project.stream(__WEBPACK_IMPORTED_MODULE_1__path_bounds__["a" /* default */]));
var b = __WEBPACK_IMPORTED_MODULE_1__path_bounds__["a" /* default */].result(),
k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
if (clip != null) project.clipExtent(clip);
return project
.scale(k * 150)
.translate([x, y]);
}
function fitSize(project) {
return function(size, object) {
return fit(project, [[0, 0], size], object);
};
}
function fitExtent(project) {
return function(extent, object) {
return fit(project, extent, object);
};
}
/***/ }),
/* 155 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = equirectangularRaw;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(18);
function equirectangularRaw(lambda, phi) {
return [lambda, phi];
}
equirectangularRaw.invert = equirectangularRaw;
/* harmony default export */ __webpack_exports__["a"] = (function() {
return Object(__WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */])(equirectangularRaw)
.scale(152.63);
});
/***/ }),
/* 156 */
/***/ (function(module, exports, __webpack_require__) {
var isArray = __webpack_require__(6);
/**
* Flattens `array` a single level deep.
*
* @param {Array} arr The array to flatten.
* @param {Array} result The array to return.
* @return {Array} Returns the new flattened array.
* @example
*
* flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
*/
var flattenDeep = function flattenDeep(arr) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (!isArray(arr)) {
result.push(arr);
} else {
for (var i = 0; i < arr.length; i += 1) {
flattenDeep(arr[i], result);
}
}
return result;
};
module.exports = flattenDeep;
/***/ }),
/* 157 */
/***/ (function(module, exports) {
module.exports = function (fraction) {
var step = 1 / fraction;
var pArr = [];
for (var i = 0; i <= 1; i = i + step) {
pArr.push(i);
}
return pArr;
};
/***/ }),
/* 158 */
/***/ (function(module, exports, __webpack_require__) {
var getPointAtLength = __webpack_require__(159);
var cloneDeep = __webpack_require__(40);
var _require = __webpack_require__(0),
geoPath = _require.geoPath;
var _require2 = __webpack_require__(2),
GEO = _require2.GEO,
registerConnector = _require2.registerConnector;
var geoPathGenerator = geoPath();
function GeoJSONConnector(data, options, dataView) {
dataView.dataType = GEO;
var features = cloneDeep(data.features); // pre-process
features.forEach(function (feature) {
feature.name = feature.properties.name;
feature.longitude = [];
feature.latitude = [];
var pathData = feature.pathData = geoPathGenerator(feature);
var points = getPointAtLength(pathData);
points._path.forEach(function (point) {
feature.longitude.push(point[1]);
feature.latitude.push(point[2]);
});
var centroid = geoPathGenerator.centroid(feature);
feature.centroidX = centroid[0];
feature.centroidY = centroid[1];
}); // dataView.origin = features;
return features;
}
registerConnector('geo', GeoJSONConnector);
registerConnector('geojson', GeoJSONConnector);
registerConnector('GeoJSON', GeoJSONConnector);
module.exports = GeoJSONConnector;
/***/ }),
/* 159 */
/***/ (function(module, exports, __webpack_require__) {
var parse = __webpack_require__(362);
var isarray = __webpack_require__(363);
var abs = __webpack_require__(364);
module.exports = Points;
function Points (path) {
if (!(this instanceof Points)) return new Points(path);
this._path = isarray(path) ? path : parse(path);
this._path = abs(this._path);
this._path = zToL(this._path);
}
Points.prototype.at = function (pos, opts) {
return this._walk(pos, opts).pos;
};
Points.prototype.length = function () {
return this._walk(null).length;
};
Points.prototype._walk = function (pos, opts) {
var cur = [ 0, 0 ];
var prev = [ 0, 0, 0 ];
var len = 0;
var fudge = 1.045;
if (typeof pos === 'number') pos *= fudge;
for (var i = 0; i < this._path.length; i++) {
var p = this._path[i];
if (p[0] === 'M') {
cur[0] = p[1];
cur[1] = p[2];
if (pos === 0) {
return { length: len, pos: cur };
}
}
else if (p[0] === 'C') {
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
var n = 100;
for (var j = 0; j <= n; j++) {
var t = j / n;
var x = xof_C(p, t);
var y = yof_C(p, t);
len += dist(cur[0], cur[1], x, y);
cur[0] = x;
cur[1] = y;
if (typeof pos === 'number' && len >= pos) {
var dv = (len - pos) / (len - prev[2]);
var npos = [
cur[0] * (1 - dv) + prev[0] * dv,
cur[1] * (1 - dv) + prev[1] * dv
];
return { length: len, pos: npos };
}
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
}
}
else if (p[0] === 'Q') {
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
var n = 100;
for (var j = 0; j <= n; j++) {
var t = j / n;
var x = xof_Q(p, t);
var y = yof_Q(p, t);
len += dist(cur[0], cur[1], x, y);
cur[0] = x;
cur[1] = y;
if (typeof pos === 'number' && len >= pos) {
var dv = (len - pos) / (len - prev[2]);
var npos = [
cur[0] * (1 - dv) + prev[0] * dv,
cur[1] * (1 - dv) + prev[1] * dv
];
return { length: len, pos: npos };
}
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
}
}
else if (p[0] === 'L') {
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
len += dist(cur[0], cur[1], p[1], p[2]);
cur[0] = p[1];
cur[1] = p[2];
if (typeof pos === 'number' && len >= pos) {
var dv = (len - pos) / (len - prev[2]);
var npos = [
cur[0] * (1 - dv) + prev[0] * dv,
cur[1] * (1 - dv) + prev[1] * dv
];
return { length: len, pos: npos };
}
prev[0] = cur[0];
prev[1] = cur[1];
prev[2] = len;
}
}
return { length: len / fudge, pos: cur };
function xof_C (p, t) {
return Math.pow((1-t), 3) * cur[0]
+ 3 * Math.pow((1-t), 2) * t * p[1]
+ 3 * (1-t) * Math.pow(t, 2) * p[3]
+ Math.pow(t, 3) * p[5]
;
}
function yof_C (p, t) {
return Math.pow((1-t), 3) * cur[1]
+ 3 * Math.pow((1-t), 2) * t * p[2]
+ 3 * (1-t) * Math.pow(t, 2) * p[4]
+ Math.pow(t, 3) * p[6]
;
}
function xof_Q (p, t) {
return Math.pow((1-t), 2) * cur[0]
+ 2 * (1-t) * t * p[1]
+ Math.pow(t, 2) * p[3]
;
}
function yof_Q (p, t) {
return Math.pow((1-t), 2) * cur[1]
+ 2 * (1-t) * t * p[2]
+ Math.pow(t, 2) * p[4]
;
}
};
function dist (ax, ay, bx, by) {
var x = ax - bx;
var y = ay - by;
return Math.sqrt(x*x + y*y);
}
// Convert 'Z' segments to 'L' segments
function zToL(path){
var ret = [];
var startPoint = ['L',0,0];
for(var i=0, len=path.length; i dx * dx + dy * dy;
}
function score(node) {
var a = node._,
b = node.next._,
ab = a.r + b.r,
dx = (a.x * b.r + b.x * a.r) / ab,
dy = (a.y * b.r + b.y * a.r) / ab;
return dx * dx + dy * dy;
}
function Node(circle) {
this._ = circle;
this.next = null;
this.previous = null;
}
function packEnclose(circles) {
if (!(n = circles.length)) return 0;
var a, b, c, n, aa, ca, i, j, k, sj, sk;
// Place the first circle.
a = circles[0], a.x = 0, a.y = 0;
if (!(n > 1)) return a.r;
// Place the second circle.
b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
if (!(n > 2)) return a.r + b.r;
// Place the third circle.
place(b, a, c = circles[2]);
// Initialize the front-chain using the first three circles a, b and c.
a = new Node(a), b = new Node(b), c = new Node(c);
a.next = c.previous = b;
b.next = a.previous = c;
c.next = b.previous = a;
// Attempt to place each remaining circle…
pack: for (i = 3; i < n; ++i) {
place(a._, b._, c = circles[i]), c = new Node(c);
// Find the closest intersecting circle on the front-chain, if any.
// “Closeness” is determined by linear distance along the front-chain.
// “Ahead” or “behind” is likewise determined by linear distance.
j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
do {
if (sj <= sk) {
if (intersects(j._, c._)) {
b = j, a.next = b, b.previous = a, --i;
continue pack;
}
sj += j._.r, j = j.next;
} else {
if (intersects(k._, c._)) {
a = k, a.next = b, b.previous = a, --i;
continue pack;
}
sk += k._.r, k = k.previous;
}
} while (j !== k.next);
// Success! Insert the new circle c between a and b.
c.previous = a, c.next = b, a.next = b.previous = b = c;
// Compute the new closest circle pair to the centroid.
aa = score(a);
while ((c = c.next) !== b) {
if ((ca = score(c)) < aa) {
a = c, aa = ca;
}
}
b = a.next;
}
// Compute the enclosing circle of the front chain.
a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = Object(__WEBPACK_IMPORTED_MODULE_0__enclose__["a" /* default */])(a);
// Translate the circles to put the enclosing circle around the origin.
for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
return c.r;
}
/* harmony default export */ __webpack_exports__["a"] = (function(circles) {
packEnclose(circles);
return circles;
});
/***/ }),
/* 161 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__array__ = __webpack_require__(382);
/* harmony default export */ __webpack_exports__["a"] = (function(circles) {
var i = 0, n = (circles = Object(__WEBPACK_IMPORTED_MODULE_0__array__["a" /* shuffle */])(__WEBPACK_IMPORTED_MODULE_0__array__["b" /* slice */].call(circles))).length, B = [], p, e;
while (i < n) {
p = circles[i];
if (e && enclosesWeak(e, p)) ++i;
else e = encloseBasis(B = extendBasis(B, p)), i = 0;
}
return e;
});
function extendBasis(B, p) {
var i, j;
if (enclosesWeakAll(p, B)) return [p];
// If we get here then B must have at least one element.
for (i = 0; i < B.length; ++i) {
if (enclosesNot(p, B[i])
&& enclosesWeakAll(encloseBasis2(B[i], p), B)) {
return [B[i], p];
}
}
// If we get here then B must have at least two elements.
for (i = 0; i < B.length - 1; ++i) {
for (j = i + 1; j < B.length; ++j) {
if (enclosesNot(encloseBasis2(B[i], B[j]), p)
&& enclosesNot(encloseBasis2(B[i], p), B[j])
&& enclosesNot(encloseBasis2(B[j], p), B[i])
&& enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
return [B[i], B[j], p];
}
}
}
// If we get here then something is very wrong.
throw new Error;
}
function enclosesNot(a, b) {
var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
return dr < 0 || dr * dr < dx * dx + dy * dy;
}
function enclosesWeak(a, b) {
var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
return dr > 0 && dr * dr > dx * dx + dy * dy;
}
function enclosesWeakAll(a, B) {
for (var i = 0; i < B.length; ++i) {
if (!enclosesWeak(a, B[i])) {
return false;
}
}
return true;
}
function encloseBasis(B) {
switch (B.length) {
case 1: return encloseBasis1(B[0]);
case 2: return encloseBasis2(B[0], B[1]);
case 3: return encloseBasis3(B[0], B[1], B[2]);
}
}
function encloseBasis1(a) {
return {
x: a.x,
y: a.y,
r: a.r
};
}
function encloseBasis2(a, b) {
var x1 = a.x, y1 = a.y, r1 = a.r,
x2 = b.x, y2 = b.y, r2 = b.r,
x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
l = Math.sqrt(x21 * x21 + y21 * y21);
return {
x: (x1 + x2 + x21 / l * r21) / 2,
y: (y1 + y2 + y21 / l * r21) / 2,
r: (l + r1 + r2) / 2
};
}
function encloseBasis3(a, b, c) {
var x1 = a.x, y1 = a.y, r1 = a.r,
x2 = b.x, y2 = b.y, r2 = b.r,
x3 = c.x, y3 = c.y, r3 = c.r,
a2 = x1 - x2,
a3 = x1 - x3,
b2 = y1 - y2,
b3 = y1 - y3,
c2 = r2 - r1,
c3 = r3 - r1,
d1 = x1 * x1 + y1 * y1 - r1 * r1,
d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
ab = a3 * b2 - a2 * b3,
xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
xb = (b3 * c2 - b2 * c3) / ab,
ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
yb = (a2 * c3 - a3 * c2) / ab,
A = xb * xb + yb * yb - 1,
B = 2 * (r1 + xa * xb + ya * yb),
C = xa * xa + ya * ya - r1 * r1,
r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
return {
x: x1 + xa + xb * r,
y: y1 + ya + yb * r,
r: r
};
}
/***/ }),
/* 162 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = constantZero;
function constantZero() {
return 0;
}
/* harmony default export */ __webpack_exports__["b"] = (function(x) {
return function() {
return x;
};
});
/***/ }),
/* 163 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(node) {
node.x0 = Math.round(node.x0);
node.y0 = Math.round(node.y0);
node.x1 = Math.round(node.x1);
node.y1 = Math.round(node.y1);
});
/***/ }),
/* 164 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__transform__ = __webpack_require__(89);
/* harmony default export */ __webpack_exports__["a"] = (function(topology) {
var t = Object(__WEBPACK_IMPORTED_MODULE_0__transform__["a" /* default */])(topology.transform), key,
x0 = Infinity, y0 = x0, x1 = -x0, y1 = -x0;
function bboxPoint(p) {
p = t(p);
if (p[0] < x0) x0 = p[0];
if (p[0] > x1) x1 = p[0];
if (p[1] < y0) y0 = p[1];
if (p[1] > y1) y1 = p[1];
}
function bboxGeometry(o) {
switch (o.type) {
case "GeometryCollection": o.geometries.forEach(bboxGeometry); break;
case "Point": bboxPoint(o.coordinates); break;
case "MultiPoint": o.coordinates.forEach(bboxPoint); break;
}
}
topology.arcs.forEach(function(arc) {
var i = -1, n = arc.length, p;
while (++i < n) {
p = t(arc[i], i);
if (p[0] < x0) x0 = p[0];
if (p[0] > x1) x1 = p[0];
if (p[1] < y0) y0 = p[1];
if (p[1] > y1) y1 = p[1];
}
});
for (key in topology.objects) {
bboxGeometry(topology.objects[key]);
}
return [x0, y0, x1, y1];
});
/***/ }),
/* 165 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(x) {
return x;
});
/***/ }),
/* 166 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function(topology, arcs) {
var stitchedArcs = {},
fragmentByStart = {},
fragmentByEnd = {},
fragments = [],
emptyIndex = -1;
// Stitch empty arcs first, since they may be subsumed by other arcs.
arcs.forEach(function(i, j) {
var arc = topology.arcs[i < 0 ? ~i : i], t;
if (arc.length < 3 && !arc[1][0] && !arc[1][1]) {
t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t;
}
});
arcs.forEach(function(i) {
var e = ends(i),
start = e[0],
end = e[1],
f, g;
if (f = fragmentByEnd[start]) {
delete fragmentByEnd[f.end];
f.push(i);
f.end = end;
if (g = fragmentByStart[end]) {
delete fragmentByStart[g.start];
var fg = g === f ? f : f.concat(g);
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else if (f = fragmentByStart[end]) {
delete fragmentByStart[f.start];
f.unshift(i);
f.start = start;
if (g = fragmentByEnd[start]) {
delete fragmentByEnd[g.end];
var gf = g === f ? f : g.concat(f);
fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else {
f = [i];
fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;
}
});
function ends(i) {
var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1;
if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; });
else p1 = arc[arc.length - 1];
return i < 0 ? [p1, p0] : [p0, p1];
}
function flush(fragmentByEnd, fragmentByStart) {
for (var k in fragmentByEnd) {
var f = fragmentByEnd[k];
delete fragmentByStart[f.start];
delete f.start;
delete f.end;
f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; });
fragments.push(f);
}
}
flush(fragmentByEnd, fragmentByStart);
flush(fragmentByStart, fragmentByEnd);
arcs.forEach(function(i) { if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]); });
return fragments;
});
/***/ }),
/* 167 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__identity__ = __webpack_require__(165);
/* harmony default export */ __webpack_exports__["a"] = (function(transform) {
if (transform == null) return __WEBPACK_IMPORTED_MODULE_0__identity__["a" /* default */];
var x0,
y0,
kx = transform.scale[0],
ky = transform.scale[1],
dx = transform.translate[0],
dy = transform.translate[1];
return function(input, i) {
if (!i) x0 = y0 = 0;
var j = 2,
n = input.length,
output = new Array(n),
x1 = Math.round((input[0] - dx) / kx),
y1 = Math.round((input[1] - dy) / ky);
output[0] = x1 - x0, x0 = x1;
output[1] = y1 - y0, y0 = y1;
while (j < n) output[j] = input[j], ++j;
return output;
};
});
/***/ }),
/* 168 */
/***/ (function(module, exports, __webpack_require__) {
var isArrayLike = __webpack_require__(91);
var indexOf = Array.prototype.indexOf;
var contains = function contains(arr, value) {
if (!isArrayLike(arr)) {
return false;
}
return indexOf.call(arr, value) > -1;
};
module.exports = contains;
/***/ }),
/* 169 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
* @license
* Lodash
* Copyright JS Foundation and other contributors
* Released under MIT license
* Based on Underscore.js 1.8.3
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
;(function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.17.4';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Error message constants. */
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as the maximum memoize cache size. */
var MAX_MEMOIZE_SIZE = 500;
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG = 1,
CLONE_FLAT_FLAG = 2,
CLONE_SYMBOLS_FLAG = 4;
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG = 1,
COMPARE_UNORDERED_FLAG = 2;
/** Used to compose bitmasks for function metadata. */
var WRAP_BIND_FLAG = 1,
WRAP_BIND_KEY_FLAG = 2,
WRAP_CURRY_BOUND_FLAG = 4,
WRAP_CURRY_FLAG = 8,
WRAP_CURRY_RIGHT_FLAG = 16,
WRAP_PARTIAL_FLAG = 32,
WRAP_PARTIAL_RIGHT_FLAG = 64,
WRAP_ARY_FLAG = 128,
WRAP_REARG_FLAG = 256,
WRAP_FLIP_FLAG = 512;
/** Used as default options for `_.truncate`. */
var DEFAULT_TRUNC_LENGTH = 30,
DEFAULT_TRUNC_OMISSION = '...';
/** Used to detect hot functions by number of calls within a span of milliseconds. */
var HOT_COUNT = 800,
HOT_SPAN = 16;
/** Used to indicate the type of lazy iteratees. */
var LAZY_FILTER_FLAG = 1,
LAZY_MAP_FLAG = 2,
LAZY_WHILE_FLAG = 3;
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0,
MAX_SAFE_INTEGER = 9007199254740991,
MAX_INTEGER = 1.7976931348623157e+308,
NAN = 0 / 0;
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
/** Used to associate wrap methods with their bit flags. */
var wrapFlags = [
['ary', WRAP_ARY_FLAG],
['bind', WRAP_BIND_FLAG],
['bindKey', WRAP_BIND_KEY_FLAG],
['curry', WRAP_CURRY_FLAG],
['curryRight', WRAP_CURRY_RIGHT_FLAG],
['flip', WRAP_FLIP_FLAG],
['partial', WRAP_PARTIAL_FLAG],
['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
['rearg', WRAP_REARG_FLAG]
];
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
asyncTag = '[object AsyncFunction]',
boolTag = '[object Boolean]',
dateTag = '[object Date]',
domExcTag = '[object DOMException]',
errorTag = '[object Error]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
mapTag = '[object Map]',
numberTag = '[object Number]',
nullTag = '[object Null]',
objectTag = '[object Object]',
promiseTag = '[object Promise]',
proxyTag = '[object Proxy]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
symbolTag = '[object Symbol]',
undefinedTag = '[object Undefined]',
weakMapTag = '[object WeakMap]',
weakSetTag = '[object WeakSet]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
int16Tag = '[object Int16Array]',
int32Tag = '[object Int32Array]',
uint8Tag = '[object Uint8Array]',
uint8ClampedTag = '[object Uint8ClampedArray]',
uint16Tag = '[object Uint16Array]',
uint32Tag = '[object Uint32Array]';
/** Used to match empty string literals in compiled template source. */
var reEmptyStringLeading = /\b__p \+= '';/g,
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
/** Used to match HTML entities and HTML characters. */
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
reUnescapedHtml = /[&<>"']/g,
reHasEscapedHtml = RegExp(reEscapedHtml.source),
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
/** Used to match template delimiters. */
var reEscape = /<%-([\s\S]+?)%>/g,
reEvaluate = /<%([\s\S]+?)%>/g,
reInterpolate = /<%=([\s\S]+?)%>/g;
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
reHasRegExpChar = RegExp(reRegExpChar.source);
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g,
reTrimStart = /^\s+/,
reTrimEnd = /\s+$/;
/** Used to match wrap detail comments. */
var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
reSplitDetails = /,? & /;
/** Used to match words composed of alphanumeric characters. */
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/**
* Used to match
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
*/
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/** Used to match Latin Unicode letters (excluding mathematical operators). */
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** Used to ensure capturing order of template delimiters. */
var reNoMatch = /($^)/;
/** Used to match unescaped characters in compiled string literals. */
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f',
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
rsComboSymbolsRange = '\\u20d0-\\u20ff',
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
rsPunctuationRange = '\\u2000-\\u206f',
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
rsVarRange = '\\ufe0e\\ufe0f',
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]",
rsAstral = '[' + rsAstralRange + ']',
rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsUpper = '[' + rsUpperRange + ']',
rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo, 'g');
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to match complex or compound words. */
var reUnicodeWord = RegExp([
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
rsUpper + '+' + rsOptContrUpper,
rsOrdUpper,
rsOrdLower,
rsDigits,
rsEmoji
].join('|'), 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
/** Used to detect strings that need a more robust regexp to match words. */
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
/** Used to assign default `context` object properties. */
var contextProps = [
'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
'_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
];
/** Used to make template sourceURLs easier to identify. */
var templateCounter = -1;
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
typedArrayTags[setTag] = typedArrayTags[stringTag] =
typedArrayTags[weakMapTag] = false;
/** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] =
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
cloneableTags[boolTag] = cloneableTags[dateTag] =
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
cloneableTags[int32Tag] = cloneableTags[mapTag] =
cloneableTags[numberTag] = cloneableTags[objectTag] =
cloneableTags[regexpTag] = cloneableTags[setTag] =
cloneableTags[stringTag] = cloneableTags[symbolTag] =
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = false;
/** Used to map Latin Unicode letters to basic Latin letters. */
var deburredLetters = {
// Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'N', '\xf1': 'n',
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'Ae', '\xe6': 'ae',
'\xde': 'Th', '\xfe': 'th',
'\xdf': 'ss',
// Latin Extended-A block.
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
'\u0134': 'J', '\u0135': 'j',
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
'\u0163': 't', '\u0165': 't', '\u0167': 't',
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
'\u0174': 'W', '\u0175': 'w',
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
'\u0132': 'IJ', '\u0133': 'ij',
'\u0152': 'Oe', '\u0153': 'oe',
'\u0149': "'n", '\u017f': 's'
};
/** Used to map characters to HTML entities. */
var htmlEscapes = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
/** Used to map HTML entities to characters. */
var htmlUnescapes = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
''': "'"
};
/** Used to escape characters for inclusion in compiled string literals. */
var stringEscapes = {
'\\': '\\',
"'": "'",
'\n': 'n',
'\r': 'r',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
/** Built-in method references without a dependency on `root`. */
var freeParseFloat = parseFloat,
freeParseInt = parseInt;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
try {
return freeProcess && freeProcess.binding && freeProcess.binding('util');
} catch (e) {}
}());
/* Node.js helper references. */
var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
nodeIsDate = nodeUtil && nodeUtil.isDate,
nodeIsMap = nodeUtil && nodeUtil.isMap,
nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
nodeIsSet = nodeUtil && nodeUtil.isSet,
nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/*--------------------------------------------------------------------------*/
/**
* Adds the key-value `pair` to `map`.
*
* @private
* @param {Object} map The map to modify.
* @param {Array} pair The key-value pair to add.
* @returns {Object} Returns `map`.
*/
function addMapEntry(map, pair) {
// Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]);
return map;
}
/**
* Adds `value` to `set`.
*
* @private
* @param {Object} set The set to modify.
* @param {*} value The value to add.
* @returns {Object} Returns `set`.
*/
function addSetEntry(set, value) {
// Don't return `set.add` because it's not chainable in IE 11.
set.add(value);
return set;
}
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
/**
* A specialized version of `_.forEach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
/**
* A specialized version of `_.forEachRight` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEachRight(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
}
/**
* A specialized version of `_.every` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
*/
function arrayEvery(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
}
/**
* A specialized version of `_.filter` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
*/
function arrayFilter(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result[resIndex++] = value;
}
}
return result;
}
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
/**
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
/**
* A specialized version of `_.reduce` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
/**
* A specialized version of `_.reduceRight` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the last element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {
accumulator = iteratee(accumulator, array[length], length, array);
}
return accumulator;
}
/**
* A specialized version of `_.some` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/
function arraySome(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
/**
* Gets the size of an ASCII `string`.
*
* @private
* @param {string} string The string inspect.
* @returns {number} Returns the string size.
*/
var asciiSize = baseProperty('length');
/**
* Converts an ASCII `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function asciiToArray(string) {
return string.split('');
}
/**
* Splits an ASCII `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function asciiWords(string) {
return string.match(reAsciiWord) || [];
}
/**
* The base implementation of methods like `_.findKey` and `_.findLastKey`,
* without support for iteratee shorthands, which iterates over `collection`
* using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the found element or its key, else `undefined`.
*/
function baseFindKey(collection, predicate, eachFunc) {
var result;
eachFunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
}
/**
* The base implementation of `_.findIndex` and `_.findLastIndex` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOf(array, value, fromIndex) {
return value === value
? strictIndexOf(array, value, fromIndex)
: baseFindIndex(array, baseIsNaN, fromIndex);
}
/**
* This function is like `baseIndexOf` except that it accepts a comparator.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @param {Function} comparator The comparator invoked per element.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.isNaN` without support for number objects.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/
function baseIsNaN(value) {
return value !== value;
}
/**
* The base implementation of `_.mean` and `_.meanBy` without support for
* iteratee shorthands.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {number} Returns the mean.
*/
function baseMean(array, iteratee) {
var length = array == null ? 0 : array.length;
return length ? (baseSum(array, iteratee) / length) : NAN;
}
/**
* The base implementation of `_.property` without support for deep paths.
*
* @private
* @param {string} key The key of the property to get.
* @returns {Function} Returns the new accessor function.
*/
function baseProperty(key) {
return function(object) {
return object == null ? undefined : object[key];
};
}
/**
* The base implementation of `_.propertyOf` without support for deep paths.
*
* @private
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
};
}
/**
* The base implementation of `_.reduce` and `_.reduceRight`, without support
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} accumulator The initial value.
* @param {boolean} initAccum Specify using the first or last element of
* `collection` as the initial value.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the accumulated value.
*/
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
eachFunc(collection, function(value, index, collection) {
accumulator = initAccum
? (initAccum = false, value)
: iteratee(accumulator, value, index, collection);
});
return accumulator;
}
/**
* The base implementation of `_.sortBy` which uses `comparer` to define the
* sort order of `array` and replaces criteria objects with their corresponding
* values.
*
* @private
* @param {Array} array The array to sort.
* @param {Function} comparer The function to define sort order.
* @returns {Array} Returns `array`.
*/
function baseSortBy(array, comparer) {
var length = array.length;
array.sort(comparer);
while (length--) {
array[length] = array[length].value;
}
return array;
}
/**
* The base implementation of `_.sum` and `_.sumBy` without support for
* iteratee shorthands.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {number} Returns the sum.
*/
function baseSum(array, iteratee) {
var result,
index = -1,
length = array.length;
while (++index < length) {
var current = iteratee(array[index]);
if (current !== undefined) {
result = result === undefined ? current : (result + current);
}
}
return result;
}
/**
* The base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n The number of times to invoke `iteratee`.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the array of results.
*/
function baseTimes(n, iteratee) {
var index = -1,
result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
/**
* The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
* of key-value pairs for `object` corresponding to the property names of `props`.
*
* @private
* @param {Object} object The object to query.
* @param {Array} props The property names to get values for.
* @returns {Object} Returns the key-value pairs.
*/
function baseToPairs(object, props) {
return arrayMap(props, function(key) {
return [key, object[key]];
});
}
/**
* The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function(value) {
return func(value);
};
}
/**
* The base implementation of `_.values` and `_.valuesIn` which creates an
* array of `object` property values corresponding to the property names
* of `props`.
*
* @private
* @param {Object} object The object to query.
* @param {Array} props The property names to get values for.
* @returns {Object} Returns the array of property values.
*/
function baseValues(object, props) {
return arrayMap(props, function(key) {
return object[key];
});
}
/**
* Checks if a `cache` value for `key` exists.
*
* @private
* @param {Object} cache The cache to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function cacheHas(cache, key) {
return cache.has(key);
}
/**
* Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
* that is not found in the character symbols.
*
* @private
* @param {Array} strSymbols The string symbols to inspect.
* @param {Array} chrSymbols The character symbols to find.
* @returns {number} Returns the index of the first unmatched string symbol.
*/
function charsStartIndex(strSymbols, chrSymbols) {
var index = -1,
length = strSymbols.length;
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
}
/**
* Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
* that is not found in the character symbols.
*
* @private
* @param {Array} strSymbols The string symbols to inspect.
* @param {Array} chrSymbols The character symbols to find.
* @returns {number} Returns the index of the last unmatched string symbol.
*/
function charsEndIndex(strSymbols, chrSymbols) {
var index = strSymbols.length;
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
}
/**
* Gets the number of `placeholder` occurrences in `array`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} placeholder The placeholder to search for.
* @returns {number} Returns the placeholder count.
*/
function countHolders(array, placeholder) {
var length = array.length,
result = 0;
while (length--) {
if (array[length] === placeholder) {
++result;
}
}
return result;
}
/**
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
* letters to basic Latin letters.
*
* @private
* @param {string} letter The matched letter to deburr.
* @returns {string} Returns the deburred letter.
*/
var deburrLetter = basePropertyOf(deburredLetters);
/**
* Used by `_.escape` to convert characters to HTML entities.
*
* @private
* @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character.
*/
var escapeHtmlChar = basePropertyOf(htmlEscapes);
/**
* Used by `_.template` to escape characters for inclusion in compiled string literals.
*
* @private
* @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character.
*/
function escapeStringChar(chr) {
return '\\' + stringEscapes[chr];
}
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `string` contains Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
function hasUnicode(string) {
return reHasUnicode.test(string);
}
/**
* Checks if `string` contains a word composed of Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a word is found, else `false`.
*/
function hasUnicodeWord(string) {
return reHasUnicodeWord.test(string);
}
/**
* Converts `iterator` to an array.
*
* @private
* @param {Object} iterator The iterator to convert.
* @returns {Array} Returns the converted array.
*/
function iteratorToArray(iterator) {
var data,
result = [];
while (!(data = iterator.next()).done) {
result.push(data.value);
}
return result;
}
/**
* Converts `map` to its key-value pairs.
*
* @private
* @param {Object} map The map to convert.
* @returns {Array} Returns the key-value pairs.
*/
function mapToArray(map) {
var index = -1,
result = Array(map.size);
map.forEach(function(value, key) {
result[++index] = [key, value];
});
return result;
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/**
* Replaces all `placeholder` elements in `array` with an internal placeholder
* and returns an array of their indexes.
*
* @private
* @param {Array} array The array to modify.
* @param {*} placeholder The placeholder to replace.
* @returns {Array} Returns the new array of placeholder indexes.
*/
function replaceHolders(array, placeholder) {
var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value === placeholder || value === PLACEHOLDER) {
array[index] = PLACEHOLDER;
result[resIndex++] = index;
}
}
return result;
}
/**
* Converts `set` to an array of its values.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the values.
*/
function setToArray(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = value;
});
return result;
}
/**
* Converts `set` to its value-value pairs.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the value-value pairs.
*/
function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
}
/**
* A specialized version of `_.indexOf` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function strictIndexOf(array, value, fromIndex) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
/**
* A specialized version of `_.lastIndexOf` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function strictLastIndexOf(array, value, fromIndex) {
var index = fromIndex + 1;
while (index--) {
if (array[index] === value) {
return index;
}
}
return index;
}
/**
* Gets the number of symbols in `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the string size.
*/
function stringSize(string) {
return hasUnicode(string)
? unicodeSize(string)
: asciiSize(string);
}
/**
* Converts `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function stringToArray(string) {
return hasUnicode(string)
? unicodeToArray(string)
: asciiToArray(string);
}
/**
* Used by `_.unescape` to convert HTML entities to characters.
*
* @private
* @param {string} chr The matched character to unescape.
* @returns {string} Returns the unescaped character.
*/
var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
/**
* Gets the size of a Unicode `string`.
*
* @private
* @param {string} string The string inspect.
* @returns {number} Returns the string size.
*/
function unicodeSize(string) {
var result = reUnicode.lastIndex = 0;
while (reUnicode.test(string)) {
++result;
}
return result;
}
/**
* Converts a Unicode `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function unicodeToArray(string) {
return string.match(reUnicode) || [];
}
/**
* Splits a Unicode `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function unicodeWords(string) {
return string.match(reUnicodeWord) || [];
}
/*--------------------------------------------------------------------------*/
/**
* Create a new pristine `lodash` function using the `context` object.
*
* @static
* @memberOf _
* @since 1.1.0
* @category Util
* @param {Object} [context=root] The context object.
* @returns {Function} Returns a new `lodash` function.
* @example
*
* _.mixin({ 'foo': _.constant('foo') });
*
* var lodash = _.runInContext();
* lodash.mixin({ 'bar': lodash.constant('bar') });
*
* _.isFunction(_.foo);
* // => true
* _.isFunction(_.bar);
* // => false
*
* lodash.isFunction(lodash.foo);
* // => false
* lodash.isFunction(lodash.bar);
* // => true
*
* // Create a suped-up `defer` in Node.js.
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
*/
var runInContext = (function runInContext(context) {
context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
/** Built-in constructor references. */
var Array = context.Array,
Date = context.Date,
Error = context.Error,
Function = context.Function,
Math = context.Math,
Object = context.Object,
RegExp = context.RegExp,
String = context.String,
TypeError = context.TypeError;
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = context['__core-js_shared__'];
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to generate unique IDs. */
var idCounter = 0;
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Used to infer the `Object` constructor. */
var objectCtorString = funcToString.call(Object);
/** Used to restore the original `_` reference in `_.noConflict`. */
var oldDash = root._;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/** Built-in value references. */
var Buffer = moduleExports ? context.Buffer : undefined,
Symbol = context.Symbol,
Uint8Array = context.Uint8Array,
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
getPrototype = overArg(Object.getPrototypeOf, Object),
objectCreate = Object.create,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
splice = arrayProto.splice,
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
symIterator = Symbol ? Symbol.iterator : undefined,
symToStringTag = Symbol ? Symbol.toStringTag : undefined;
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
/** Mocked built-ins. */
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
ctxNow = Date && Date.now !== root.Date.now && Date.now,
ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil,
nativeFloor = Math.floor,
nativeGetSymbols = Object.getOwnPropertySymbols,
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
nativeIsFinite = context.isFinite,
nativeJoin = arrayProto.join,
nativeKeys = overArg(Object.keys, Object),
nativeMax = Math.max,
nativeMin = Math.min,
nativeNow = Date.now,
nativeParseInt = context.parseInt,
nativeRandom = Math.random,
nativeReverse = arrayProto.reverse;
/* Built-in method references that are verified to be native. */
var DataView = getNative(context, 'DataView'),
Map = getNative(context, 'Map'),
Promise = getNative(context, 'Promise'),
Set = getNative(context, 'Set'),
WeakMap = getNative(context, 'WeakMap'),
nativeCreate = getNative(Object, 'create');
/** Used to store function metadata. */
var metaMap = WeakMap && new WeakMap;
/** Used to lookup unminified function names. */
var realNames = {};
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
promiseCtorString = toSource(Promise),
setCtorString = toSource(Set),
weakMapCtorString = toSource(WeakMap);
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/*------------------------------------------------------------------------*/
/**
* Creates a `lodash` object which wraps `value` to enable implicit method
* chain sequences. Methods that operate on and return arrays, collections,
* and functions can be chained together. Methods that retrieve a single value
* or may return a primitive value will automatically end the chain sequence
* and return the unwrapped value. Otherwise, the value must be unwrapped
* with `_#value`.
*
* Explicit chain sequences, which must be unwrapped with `_#value`, may be
* enabled using `_.chain`.
*
* The execution of chained methods is lazy, that is, it's deferred until
* `_#value` is implicitly or explicitly called.
*
* Lazy evaluation allows several methods to support shortcut fusion.
* Shortcut fusion is an optimization to merge iteratee calls; this avoids
* the creation of intermediate arrays and can greatly reduce the number of
* iteratee executions. Sections of a chain sequence qualify for shortcut
* fusion if the section is applied to an array and iteratees accept only
* one argument. The heuristic for whether a section qualifies for shortcut
* fusion is subject to change.
*
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
* In addition to lodash methods, wrappers have `Array` and `String` methods.
*
* The wrapper `Array` methods are:
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
*
* The wrapper `String` methods are:
* `replace` and `split`
*
* The wrapper methods that support shortcut fusion are:
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
*
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
* `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
* `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
* `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
* `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
* `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
* `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
* `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
* `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
* `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
* `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
* `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
* `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
* `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
* `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
* `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
* `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
* `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
* `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
* `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
* `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
* `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
* `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
* `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
* `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
* `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
* `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
* `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
* `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
* `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
* `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
* `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
* `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
* `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
* `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
* `upperFirst`, `value`, and `words`
*
* @name _
* @constructor
* @category Seq
* @param {*} value The value to wrap in a `lodash` instance.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* function square(n) {
* return n * n;
* }
*
* var wrapped = _([1, 2, 3]);
*
* // Returns an unwrapped value.
* wrapped.reduce(_.add);
* // => 6
*
* // Returns a wrapped value.
* var squares = wrapped.map(square);
*
* _.isArray(squares);
* // => false
*
* _.isArray(squares.value());
* // => true
*/
function lodash(value) {
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
if (value instanceof LodashWrapper) {
return value;
}
if (hasOwnProperty.call(value, '__wrapped__')) {
return wrapperClone(value);
}
}
return new LodashWrapper(value);
}
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
/**
* The function whose prototype chain sequence wrappers inherit from.
*
* @private
*/
function baseLodash() {
// No operation performed.
}
/**
* The base constructor for creating `lodash` wrapper objects.
*
* @private
* @param {*} value The value to wrap.
* @param {boolean} [chainAll] Enable explicit method chain sequences.
*/
function LodashWrapper(value, chainAll) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__chain__ = !!chainAll;
this.__index__ = 0;
this.__values__ = undefined;
}
/**
* By default, the template delimiters used by lodash are like those in
* embedded Ruby (ERB) as well as ES2015 template strings. Change the
* following template settings to use alternative delimiters.
*
* @static
* @memberOf _
* @type {Object}
*/
lodash.templateSettings = {
/**
* Used to detect `data` property values to be HTML-escaped.
*
* @memberOf _.templateSettings
* @type {RegExp}
*/
'escape': reEscape,
/**
* Used to detect code to be evaluated.
*
* @memberOf _.templateSettings
* @type {RegExp}
*/
'evaluate': reEvaluate,
/**
* Used to detect `data` property values to inject.
*
* @memberOf _.templateSettings
* @type {RegExp}
*/
'interpolate': reInterpolate,
/**
* Used to reference the data object in the template text.
*
* @memberOf _.templateSettings
* @type {string}
*/
'variable': '',
/**
* Used to import variables into the compiled template.
*
* @memberOf _.templateSettings
* @type {Object}
*/
'imports': {
/**
* A reference to the `lodash` function.
*
* @memberOf _.templateSettings.imports
* @type {Function}
*/
'_': lodash
}
};
// Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype;
lodash.prototype.constructor = lodash;
LodashWrapper.prototype = baseCreate(baseLodash.prototype);
LodashWrapper.prototype.constructor = LodashWrapper;
/*------------------------------------------------------------------------*/
/**
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
* @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__dir__ = 1;
this.__filtered__ = false;
this.__iteratees__ = [];
this.__takeCount__ = MAX_ARRAY_LENGTH;
this.__views__ = [];
}
/**
* Creates a clone of the lazy wrapper object.
*
* @private
* @name clone
* @memberOf LazyWrapper
* @returns {Object} Returns the cloned `LazyWrapper` object.
*/
function lazyClone() {
var result = new LazyWrapper(this.__wrapped__);
result.__actions__ = copyArray(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = copyArray(this.__iteratees__);
result.__takeCount__ = this.__takeCount__;
result.__views__ = copyArray(this.__views__);
return result;
}
/**
* Reverses the direction of lazy iteration.
*
* @private
* @name reverse
* @memberOf LazyWrapper
* @returns {Object} Returns the new reversed `LazyWrapper` object.
*/
function lazyReverse() {
if (this.__filtered__) {
var result = new LazyWrapper(this);
result.__dir__ = -1;
result.__filtered__ = true;
} else {
result = this.clone();
result.__dir__ *= -1;
}
return result;
}
/**
* Extracts the unwrapped value from its lazy wrapper.
*
* @private
* @name value
* @memberOf LazyWrapper
* @returns {*} Returns the unwrapped value.
*/
function lazyValue() {
var array = this.__wrapped__.value(),
dir = this.__dir__,
isArr = isArray(array),
isRight = dir < 0,
arrLength = isArr ? array.length : 0,
view = getView(0, arrLength, this.__views__),
start = view.start,
end = view.end,
length = end - start,
index = isRight ? end : (start - 1),
iteratees = this.__iteratees__,
iterLength = iteratees.length,
resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__);
if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__);
}
var result = [];
outer:
while (length-- && resIndex < takeCount) {
index += dir;
var iterIndex = -1,
value = array[index];
while (++iterIndex < iterLength) {
var data = iteratees[iterIndex],
iteratee = data.iteratee,
type = data.type,
computed = iteratee(value);
if (type == LAZY_MAP_FLAG) {
value = computed;
} else if (!computed) {
if (type == LAZY_FILTER_FLAG) {
continue outer;
} else {
break outer;
}
}
}
result[resIndex++] = value;
}
return result;
}
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
/*------------------------------------------------------------------------*/
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
this.size = 0;
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/*------------------------------------------------------------------------*/
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
this.size = 0;
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
--this.size;
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/*------------------------------------------------------------------------*/
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.size = 0;
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
};
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
var result = getMapData(this, key)['delete'](key);
this.size -= result ? 1 : 0;
return result;
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
var data = getMapData(this, key),
size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/*------------------------------------------------------------------------*/
/**
*
* Creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
var index = -1,
length = values == null ? 0 : values.length;
this.__data__ = new MapCache;
while (++index < length) {
this.add(values[index]);
}
}
/**
* Adds `value` to the array cache.
*
* @private
* @name add
* @memberOf SetCache
* @alias push
* @param {*} value The value to cache.
* @returns {Object} Returns the cache instance.
*/
function setCacheAdd(value) {
this.__data__.set(value, HASH_UNDEFINED);
return this;
}
/**
* Checks if `value` is in the array cache.
*
* @private
* @name has
* @memberOf SetCache
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function setCacheHas(value) {
return this.__data__.has(value);
}
// Add methods to `SetCache`.
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
/*------------------------------------------------------------------------*/
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
var data = this.__data__ = new ListCache(entries);
this.size = data.size;
}
/**
* Removes all key-value entries from the stack.
*
* @private
* @name clear
* @memberOf Stack
*/
function stackClear() {
this.__data__ = new ListCache;
this.size = 0;
}
/**
* Removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberOf Stack
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
var data = this.__data__,
result = data['delete'](key);
this.size = data.size;
return result;
}
/**
* Gets the stack value for `key`.
*
* @private
* @name get
* @memberOf Stack
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function stackGet(key) {
return this.__data__.get(key);
}
/**
* Checks if a stack value for `key` exists.
*
* @private
* @name has
* @memberOf Stack
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function stackHas(key) {
return this.__data__.has(key);
}
/**
* Sets the stack `key` to `value`.
*
* @private
* @name set
* @memberOf Stack
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the stack cache instance.
*/
function stackSet(key, value) {
var data = this.__data__;
if (data instanceof ListCache) {
var pairs = data.__data__;
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
pairs.push([key, value]);
this.size = ++data.size;
return this;
}
data = this.__data__ = new MapCache(pairs);
}
data.set(key, value);
this.size = data.size;
return this;
}
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
/*------------------------------------------------------------------------*/
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
))) {
result.push(key);
}
}
return result;
}
/**
* A specialized version of `_.sample` for arrays.
*
* @private
* @param {Array} array The array to sample.
* @returns {*} Returns the random element.
*/
function arraySample(array) {
var length = array.length;
return length ? array[baseRandom(0, length - 1)] : undefined;
}
/**
* A specialized version of `_.sampleSize` for arrays.
*
* @private
* @param {Array} array The array to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}
/**
* A specialized version of `_.shuffle` for arrays.
*
* @private
* @param {Array} array The array to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function arrayShuffle(array) {
return shuffleSelf(copyArray(array));
}
/**
* This function is like `assignValue` except that it doesn't assign
* `undefined` values.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/**
* Aggregates elements of `collection` on `accumulator` with keys transformed
* by `iteratee` and values set by `setter`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function baseAggregator(collection, setter, iteratee, accumulator) {
baseEach(collection, function(value, key, collection) {
setter(accumulator, value, iteratee(value), collection);
});
return accumulator;
}
/**
* The base implementation of `_.assign` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssign(object, source) {
return object && copyObject(source, keys(source), object);
}
/**
* The base implementation of `_.assignIn` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssignIn(object, source) {
return object && copyObject(source, keysIn(source), object);
}
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__' && defineProperty) {
defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
/**
* The base implementation of `_.at` without support for individual paths.
*
* @private
* @param {Object} object The object to iterate over.
* @param {string[]} paths The property paths to pick.
* @returns {Array} Returns the picked elements.
*/
function baseAt(object, paths) {
var index = -1,
length = paths.length,
result = Array(length),
skip = object == null;
while (++index < length) {
result[index] = skip ? undefined : get(object, paths[index]);
}
return result;
}
/**
* The base implementation of `_.clamp` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to clamp.
* @param {number} [lower] The lower bound.
* @param {number} upper The upper bound.
* @returns {number} Returns the clamped number.
*/
function baseClamp(number, lower, upper) {
if (number === number) {
if (upper !== undefined) {
number = number <= upper ? number : upper;
}
if (lower !== undefined) {
number = number >= lower ? number : lower;
}
}
return number;
}
/**
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
* traversed objects.
*
* @private
* @param {*} value The value to clone.
* @param {boolean} bitmask The bitmask flags.
* 1 - Deep clone
* 2 - Flatten inherited properties
* 4 - Clone symbols
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
function baseClone(value, bitmask, customizer, key, object, stack) {
var result,
isDeep = bitmask & CLONE_DEEP_FLAG,
isFlat = bitmask & CLONE_FLAT_FLAG,
isFull = bitmask & CLONE_SYMBOLS_FLAG;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
if (result !== undefined) {
return result;
}
if (!isObject(value)) {
return value;
}
var isArr = isArray(value);
if (isArr) {
result = initCloneArray(value);
if (!isDeep) {
return copyArray(value, result);
}
} else {
var tag = getTag(value),
isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
result = (isFlat || isFunc) ? {} : initCloneObject(value);
if (!isDeep) {
return isFlat
? copySymbolsIn(value, baseAssignIn(result, value))
: copySymbols(value, baseAssign(result, value));
}
} else {
if (!cloneableTags[tag]) {
return object ? value : {};
}
result = initCloneByTag(value, tag, baseClone, isDeep);
}
}
// Check for circular references and return its corresponding clone.
stack || (stack = new Stack);
var stacked = stack.get(value);
if (stacked) {
return stacked;
}
stack.set(value, result);
var keysFunc = isFull
? (isFlat ? getAllKeysIn : getAllKeys)
: (isFlat ? keysIn : keys);
var props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;
subValue = value[key];
}
// Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
return result;
}
/**
* The base implementation of `_.conforms` which doesn't clone `source`.
*
* @private
* @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new spec function.
*/
function baseConforms(source) {
var props = keys(source);
return function(object) {
return baseConformsTo(object, source, props);
};
}
/**
* The base implementation of `_.conformsTo` which accepts `props` to check.
*
* @private
* @param {Object} object The object to inspect.
* @param {Object} source The object of property predicates to conform to.
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
*/
function baseConformsTo(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
}
/**
* The base implementation of `_.delay` and `_.defer` which accepts `args`
* to provide to `func`.
*
* @private
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
* @param {Array} args The arguments to provide to `func`.
* @returns {number|Object} Returns the timer id or timeout object.
*/
function baseDelay(func, wait, args) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return setTimeout(function() { func.apply(undefined, args); }, wait);
}
/**
* The base implementation of methods like `_.difference` without support
* for excluding multiple arrays or iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Array} values The values to exclude.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of filtered values.
*/
function baseDifference(array, values, iteratee, comparator) {
var index = -1,
includes = arrayIncludes,
isCommon = true,
length = array.length,
result = [],
valuesLength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arrayMap(values, baseUnary(iteratee));
}
if (comparator) {
includes = arrayIncludesWith;
isCommon = false;
}
else if (values.length >= LARGE_ARRAY_SIZE) {
includes = cacheHas;
isCommon = false;
values = new SetCache(values);
}
outer:
while (++index < length) {
var value = array[index],
computed = iteratee == null ? value : iteratee(value);
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
var valuesIndex = valuesLength;
while (valuesIndex--) {
if (values[valuesIndex] === computed) {
continue outer;
}
}
result.push(value);
}
else if (!includes(values, computed, comparator)) {
result.push(value);
}
}
return result;
}
/**
* The base implementation of `_.forEach` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
*/
var baseEach = createBaseEach(baseForOwn);
/**
* The base implementation of `_.forEachRight` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
*/
var baseEachRight = createBaseEach(baseForOwnRight, true);
/**
* The base implementation of `_.every` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`
*/
function baseEvery(collection, predicate) {
var result = true;
baseEach(collection, function(value, index, collection) {
result = !!predicate(value, index, collection);
return result;
});
return result;
}
/**
* The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The iteratee invoked per iteration.
* @param {Function} comparator The comparator used to compare values.
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current != null && (computed === undefined
? (current === current && !isSymbol(current))
: comparator(current, computed)
)) {
var computed = current,
result = value;
}
}
return result;
}
/**
* The base implementation of `_.fill` without an iteratee call guard.
*
* @private
* @param {Array} array The array to fill.
* @param {*} value The value to fill `array` with.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns `array`.
*/
function baseFill(array, value, start, end) {
var length = array.length;
start = toInteger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : toInteger(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : toLength(end);
while (start < end) {
array[start++] = value;
}
return array;
}
/**
* The base implementation of `_.filter` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
*/
function baseFilter(collection, predicate) {
var result = [];
baseEach(collection, function(value, index, collection) {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
}
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[result.length] = value;
}
}
return result;
}
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`.
*/
var baseFor = createBaseFor();
/**
* This function is like `baseFor` except that it iterates over properties
* in the opposite order.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`.
*/
var baseForRight = createBaseFor(true);
/**
* The base implementation of `_.forOwn` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForOwn(object, iteratee) {
return object && baseFor(object, iteratee, keys);
}
/**
* The base implementation of `_.forOwnRight` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForOwnRight(object, iteratee) {
return object && baseForRight(object, iteratee, keys);
}
/**
* The base implementation of `_.functions` which creates an array of
* `object` function property names filtered from `props`.
*
* @private
* @param {Object} object The object to inspect.
* @param {Array} props The property names to filter.
* @returns {Array} Returns the function names.
*/
function baseFunctions(object, props) {
return arrayFilter(props, function(key) {
return isFunction(object[key]);
});
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = castPath(path, object);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[toKey(path[index++])];
}
return (index && index == length) ? object : undefined;
}
/**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Function} keysFunc The function to get the keys of `object`.
* @param {Function} symbolsFunc The function to get the symbols of `object`.
* @returns {Array} Returns the array of property names and symbols.
*/
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object);
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
}
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/**
* The base implementation of `_.gt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
/**
* The base implementation of `_.has` without support for deep paths.
*
* @private
* @param {Object} [object] The object to query.
* @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`.
*/
function baseHas(object, key) {
return object != null && hasOwnProperty.call(object, key);
}
/**
* The base implementation of `_.hasIn` without support for deep paths.
*
* @private
* @param {Object} [object] The object to query.
* @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`.
*/
function baseHasIn(object, key) {
return object != null && key in Object(object);
}
/**
* The base implementation of `_.inRange` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to check.
* @param {number} start The start of the range.
* @param {number} end The end of the range.
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
*/
function baseInRange(number, start, end) {
return number >= nativeMin(start, end) && number < nativeMax(start, end);
}
/**
* The base implementation of methods like `_.intersection`, without support
* for iteratee shorthands, that accepts an array of arrays to inspect.
*
* @private
* @param {Array} arrays The arrays to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of shared values.
*/
function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length,
othIndex = othLength,
caches = Array(othLength),
maxLength = Infinity,
result = [];
while (othIndex--) {
var array = arrays[othIndex];
if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee));
}
maxLength = nativeMin(array.length, maxLength);
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array)
: undefined;
}
array = arrays[0];
var index = -1,
seen = caches[0];
outer:
while (++index < length && result.length < maxLength) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (!(seen
? cacheHas(seen, computed)
: includes(result, computed, comparator)
)) {
othIndex = othLength;
while (--othIndex) {
var cache = caches[othIndex];
if (!(cache
? cacheHas(cache, computed)
: includes(arrays[othIndex], computed, comparator))
) {
continue outer;
}
}
if (seen) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* The base implementation of `_.invert` and `_.invertBy` which inverts
* `object` with values transformed by `iteratee` and set by `setter`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform values.
* @param {Object} accumulator The initial inverted object.
* @returns {Function} Returns `accumulator`.
*/
function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, function(value, key, object) {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
}
/**
* The base implementation of `_.invoke` without support for individual
* method arguments.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
* @param {Array} args The arguments to invoke the method with.
* @returns {*} Returns the result of the invoked method.
*/
function baseInvoke(object, path, args) {
path = castPath(path, object);
object = parent(object, path);
var func = object == null ? object : object[toKey(last(path))];
return func == null ? undefined : apply(func, object, args);
}
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag;
}
/**
* The base implementation of `_.isArrayBuffer` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
*/
function baseIsArrayBuffer(value) {
return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
}
/**
* The base implementation of `_.isDate` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
*/
function baseIsDate(value) {
return isObjectLike(value) && baseGetTag(value) == dateTag;
}
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
return value !== value && other !== other;
}
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
}
/**
* A specialized version of `baseIsEqual` for arrays and objects which performs
* deep comparisons and tracks traversed objects enabling objects with circular
* references to be compared.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
var objIsArr = isArray(object),
othIsArr = isArray(other),
objTag = objIsArr ? arrayTag : getTag(object),
othTag = othIsArr ? arrayTag : getTag(other);
objTag = objTag == argsTag ? objectTag : objTag;
othTag = othTag == argsTag ? objectTag : othTag;
var objIsObj = objTag == objectTag,
othIsObj = othTag == objectTag,
isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
}
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
if (objIsWrapped || othIsWrapped) {
var objUnwrapped = objIsWrapped ? object.value() : object,
othUnwrapped = othIsWrapped ? other.value() : other;
stack || (stack = new Stack);
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
}
}
if (!isSameTag) {
return false;
}
stack || (stack = new Stack);
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
}
/**
* The base implementation of `_.isMap` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
*/
function baseIsMap(value) {
return isObjectLike(value) && getTag(value) == mapTag;
}
/**
* The base implementation of `_.isMatch` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to inspect.
* @param {Object} source The object of property values to match.
* @param {Array} matchData The property names, values, and compare flags to match.
* @param {Function} [customizer] The function to customize comparisons.
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
*/
function baseIsMatch(object, source, matchData, customizer) {
var index = matchData.length,
length = index,
noCustomizer = !customizer;
if (object == null) {
return !length;
}
object = Object(object);
while (index--) {
var data = matchData[index];
if ((noCustomizer && data[2])
? data[1] !== object[data[0]]
: !(data[0] in object)
) {
return false;
}
}
while (++index < length) {
data = matchData[index];
var key = data[0],
objValue = object[key],
srcValue = data[1];
if (noCustomizer && data[2]) {
if (objValue === undefined && !(key in object)) {
return false;
}
} else {
var stack = new Stack;
if (customizer) {
var result = customizer(objValue, srcValue, key, object, source, stack);
}
if (!(result === undefined
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
: result
)) {
return false;
}
}
}
return true;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.isRegExp` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
*/
function baseIsRegExp(value) {
return isObjectLike(value) && baseGetTag(value) == regexpTag;
}
/**
* The base implementation of `_.isSet` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
*/
function baseIsSet(value) {
return isObjectLike(value) && getTag(value) == setTag;
}
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
/**
* The base implementation of `_.iteratee`.
*
* @private
* @param {*} [value=_.identity] The value to convert to an iteratee.
* @returns {Function} Returns the iteratee.
*/
function baseIteratee(value) {
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
if (typeof value == 'function') {
return value;
}
if (value == null) {
return identity;
}
if (typeof value == 'object') {
return isArray(value)
? baseMatchesProperty(value[0], value[1])
: baseMatches(value);
}
return property(value);
}
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/**
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeysIn(object) {
if (!isObject(object)) {
return nativeKeysIn(object);
}
var isProto = isPrototype(object),
result = [];
for (var key in object) {
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key);
}
}
return result;
}
/**
* The base implementation of `_.lt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
/**
* The base implementation of `_.map` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function baseMap(collection, iteratee) {
var index = -1,
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value, key, collection) {
result[++index] = iteratee(value, key, collection);
});
return result;
}
/**
* The base implementation of `_.matches` which doesn't clone `source`.
*
* @private
* @param {Object} source The object of property values to match.
* @returns {Function} Returns the new spec function.
*/
function baseMatches(source) {
var matchData = getMatchData(source);
if (matchData.length == 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
}
return function(object) {
return object === source || baseIsMatch(object, source, matchData);
};
}
/**
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
*
* @private
* @param {string} path The path of the property to get.
* @param {*} srcValue The value to match.
* @returns {Function} Returns the new spec function.
*/
function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue);
}
return function(object) {
var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue)
? hasIn(object, path)
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
};
}
/**
* The base implementation of `_.merge` without support for multiple sources.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
baseFor(source, function(srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
var newValue = customizer
? customizer(object[key], srcValue, (key + ''), object, source, stack)
: undefined;
if (newValue === undefined) {
newValue = srcValue;
}
assignMergeValue(object, key, newValue);
}
}, keysIn);
}
/**
* A specialized version of `baseMerge` for arrays and objects which performs
* deep merges and tracks traversed objects enabling objects with circular
* references to be merged.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = object[key],
srcValue = source[key],
stacked = stack.get(srcValue);
if (stacked) {
assignMergeValue(object, key, stacked);
return;
}
var newValue = customizer
? customizer(objValue, srcValue, (key + ''), object, source, stack)
: undefined;
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isBuff = !isArr && isBuffer(srcValue),
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else if (isBuff) {
isCommon = false;
newValue = cloneBuffer(srcValue, true);
}
else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
}
else {
newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = initCloneObject(srcValue);
}
}
else {
isCommon = false;
}
}
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
stack['delete'](srcValue);
}
assignMergeValue(object, key, newValue);
}
/**
* The base implementation of `_.nth` which doesn't coerce arguments.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
/**
* The base implementation of `_.orderBy` without param guards.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
* @param {string[]} orders The sort orders of `iteratees`.
* @returns {Array} Returns the new sorted array.
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {
return iteratee(value);
});
return { 'criteria': criteria, 'index': ++index, 'value': value };
});
return baseSortBy(result, function(object, other) {
return compareMultiple(object, other, orders);
});
}
/**
* The base implementation of `_.pick` without support for individual
* property identifiers.
*
* @private
* @param {Object} object The source object.
* @param {string[]} paths The property paths to pick.
* @returns {Object} Returns the new object.
*/
function basePick(object, paths) {
return basePickBy(object, paths, function(value, path) {
return hasIn(object, path);
});
}
/**
* The base implementation of `_.pickBy` without support for iteratee shorthands.
*
* @private
* @param {Object} object The source object.
* @param {string[]} paths The property paths to pick.
* @param {Function} predicate The function invoked per property.
* @returns {Object} Returns the new object.
*/
function basePickBy(object, paths, predicate) {
var index = -1,
length = paths.length,
result = {};
while (++index < length) {
var path = paths[index],
value = baseGet(object, path);
if (predicate(value, path)) {
baseSet(result, castPath(path, object), value);
}
}
return result;
}
/**
* A specialized version of `baseProperty` which supports deep paths.
*
* @private
* @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyDeep(path) {
return function(object) {
return baseGet(object, path);
};
}
/**
* The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAll(array, values, iteratee, comparator) {
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
index = -1,
length = values.length,
seen = array;
if (array === values) {
values = copyArray(values);
}
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
/**
* The base implementation of `_.pullAt` without support for individual
* indexes or capturing the removed elements.
*
* @private
* @param {Array} array The array to modify.
* @param {number[]} indexes The indexes of elements to remove.
* @returns {Array} Returns `array`.
*/
function basePullAt(array, indexes) {
var length = array ? indexes.length : 0,
lastIndex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
} else {
baseUnset(array, index);
}
}
}
return array;
}
/**
* The base implementation of `_.random` without support for returning
* floating-point numbers.
*
* @private
* @param {number} lower The lower bound.
* @param {number} upper The upper bound.
* @returns {number} Returns the random number.
*/
function baseRandom(lower, upper) {
return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
}
/**
* The base implementation of `_.range` and `_.rangeRight` which doesn't
* coerce arguments.
*
* @private
* @param {number} start The start of the range.
* @param {number} end The end of the range.
* @param {number} step The value to increment or decrement by.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the range of numbers.
*/
function baseRange(start, end, step, fromRight) {
var index = -1,
length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
result = Array(length);
while (length--) {
result[fromRight ? length : ++index] = start;
start += step;
}
return result;
}
/**
* The base implementation of `_.repeat` which doesn't coerce arguments.
*
* @private
* @param {string} string The string to repeat.
* @param {number} n The number of times to repeat the string.
* @returns {string} Returns the repeated string.
*/
function baseRepeat(string, n) {
var result = '';
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result;
}
// Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativeFloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
}
/**
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
*/
function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + '');
}
/**
* The base implementation of `_.sample`.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
*/
function baseSample(collection) {
return arraySample(values(collection));
}
/**
* The base implementation of `_.sampleSize` without param guards.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
}
/**
* The base implementation of `_.set`.
*
* @private
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
if (!isObject(object)) {
return object;
}
path = castPath(path, object);
var index = -1,
length = path.length,
lastIndex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = toKey(path[index]),
newValue = value;
if (index != lastIndex) {
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) {
newValue = isObject(objValue)
? objValue
: (isIndex(path[index + 1]) ? [] : {});
}
}
assignValue(nested, key, newValue);
nested = nested[key];
}
return object;
}
/**
* The base implementation of `setData` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to associate metadata with.
* @param {*} data The metadata.
* @returns {Function} Returns `func`.
*/
var baseSetData = !metaMap ? identity : function(func, data) {
metaMap.set(func, data);
return func;
};
/**
* The base implementation of `setToString` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
};
/**
* The base implementation of `_.shuffle`.
*
* @private
* @param {Array|Object} collection The collection to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function baseShuffle(collection) {
return shuffleSelf(values(collection));
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
* @param {Array} array The array to slice.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the slice of `array`.
*/
function baseSlice(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = Array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
/**
* The base implementation of `_.some` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/
function baseSome(collection, predicate) {
var result;
baseEach(collection, function(value, index, collection) {
result = predicate(value, index, collection);
return !result;
});
return !!result;
}
/**
* The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
* performs a binary search of `array` to determine the index at which `value`
* should be inserted into `array` in order to maintain its sort order.
*
* @private
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {boolean} [retHighest] Specify returning the highest qualified index.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
*/
function baseSortedIndex(array, value, retHighest) {
var low = 0,
high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {
var mid = (low + high) >>> 1,
computed = array[mid];
if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
return baseSortedIndexBy(array, value, identity, retHighest);
}
/**
* The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
* which invokes `iteratee` for `value` and each element of `array` to compute
* their sort ranking. The iteratee is invoked with one argument; (value).
*
* @private
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function} iteratee The iteratee invoked per element.
* @param {boolean} [retHighest] Specify returning the highest qualified index.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
*/
function baseSortedIndexBy(array, value, iteratee, retHighest) {
value = iteratee(value);
var low = 0,
high = array == null ? 0 : array.length,
valIsNaN = value !== value,
valIsNull = value === null,
valIsSymbol = isSymbol(value),
valIsUndefined = value === undefined;
while (low < high) {
var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]),
othIsDefined = computed !== undefined,
othIsNull = computed === null,
othIsReflexive = computed === computed,
othIsSymbol = isSymbol(computed);
if (valIsNaN) {
var setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) {
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
} else if (valIsSymbol) {
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
} else if (othIsNull || othIsSymbol) {
setLow = false;
} else {
setLow = retHighest ? (computed <= value) : (computed < value);
}
if (setLow) {
low = mid + 1;
} else {
high = mid;
}
}
return nativeMin(high, MAX_ARRAY_INDEX);
}
/**
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseSortedUniq(array, iteratee) {
var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resIndex++] = value === 0 ? 0 : value;
}
}
return result;
}
/**
* The base implementation of `_.toNumber` which doesn't ensure correct
* conversions of binary, hexadecimal, or octal string values.
*
* @private
* @param {*} value The value to process.
* @returns {number} Returns the number.
*/
function baseToNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
return +value;
}
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee, comparator) {
var index = -1,
includes = arrayIncludes,
length = array.length,
isCommon = true,
result = [],
seen = result;
if (comparator) {
isCommon = false;
includes = arrayIncludesWith;
}
else if (length >= LARGE_ARRAY_SIZE) {
var set = iteratee ? null : createSet(array);
if (set) {
return setToArray(set);
}
isCommon = false;
includes = cacheHas;
seen = new SetCache;
}
else {
seen = iteratee ? [] : result;
}
outer:
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) {
if (seen[seenIndex] === computed) {
continue outer;
}
}
if (iteratee) {
seen.push(computed);
}
result.push(value);
}
else if (!includes(seen, computed, comparator)) {
if (seen !== result) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* The base implementation of `_.unset`.
*
* @private
* @param {Object} object The object to modify.
* @param {Array|string} path The property path to unset.
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = castPath(path, object);
object = parent(object, path);
return object == null || delete object[toKey(last(path))];
}
/**
* The base implementation of `_.update`.
*
* @private
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to update.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseUpdate(object, path, updater, customizer) {
return baseSet(object, path, updater(baseGet(object, path)), customizer);
}
/**
* The base implementation of methods like `_.dropWhile` and `_.takeWhile`
* without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to query.
* @param {Function} predicate The function invoked per iteration.
* @param {boolean} [isDrop] Specify dropping elements instead of taking them.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the slice of `array`.
*/
function baseWhile(array, predicate, isDrop, fromRight) {
var length = array.length,
index = fromRight ? length : -1;
while ((fromRight ? index-- : ++index < length) &&
predicate(array[index], index, array)) {}
return isDrop
? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
: baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
}
/**
* The base implementation of `wrapperValue` which returns the result of
* performing a sequence of actions on the unwrapped `value`, where each
* successive action is supplied the return value of the previous.
*
* @private
* @param {*} value The unwrapped value.
* @param {Array} actions Actions to perform to resolve the unwrapped value.
* @returns {*} Returns the resolved value.
*/
function baseWrapperValue(value, actions) {
var result = value;
if (result instanceof LazyWrapper) {
result = result.value();
}
return arrayReduce(actions, function(result, action) {
return action.func.apply(action.thisArg, arrayPush([result], action.args));
}, result);
}
/**
* The base implementation of methods like `_.xor`, without support for
* iteratee shorthands, that accepts an array of arrays to inspect.
*
* @private
* @param {Array} arrays The arrays to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of values.
*/
function baseXor(arrays, iteratee, comparator) {
var length = arrays.length;
if (length < 2) {
return length ? baseUniq(arrays[0]) : [];
}
var index = -1,
result = Array(length);
while (++index < length) {
var array = arrays[index],
othIndex = -1;
while (++othIndex < length) {
if (othIndex != index) {
result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
}
}
}
return baseUniq(baseFlatten(result, 1), iteratee, comparator);
}
/**
* This base implementation of `_.zipObject` which assigns values using `assignFunc`.
*
* @private
* @param {Array} props The property identifiers.
* @param {Array} values The property values.
* @param {Function} assignFunc The function to assign values.
* @returns {Object} Returns the new object.
*/
function baseZipObject(props, values, assignFunc) {
var index = -1,
length = props.length,
valsLength = values.length,
result = {};
while (++index < length) {
var value = index < valsLength ? values[index] : undefined;
assignFunc(result, props[index], value);
}
return result;
}
/**
* Casts `value` to an empty array if it's not an array like object.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
/**
* Casts `value` to `identity` if it's not a function.
*
* @private
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
/**
* A `baseRest` alias which can be replaced with `identity` by module
* replacement plugins.
*
* @private
* @type {Function}
* @param {Function} func The function to apply a rest parameter to.
* @returns {Function} Returns the new function.
*/
var castRest = baseRest;
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
/**
* A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
*
* @private
* @param {number|Object} id The timer id or timeout object of the timer to clear.
*/
var clearTimeout = ctxClearTimeout || function(id) {
return root.clearTimeout(id);
};
/**
* Creates a clone of `buffer`.
*
* @private
* @param {Buffer} buffer The buffer to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Buffer} Returns the cloned buffer.
*/
function cloneBuffer(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var length = buffer.length,
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}
/**
* Creates a clone of `arrayBuffer`.
*
* @private
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
return result;
}
/**
* Creates a clone of `dataView`.
*
* @private
* @param {Object} dataView The data view to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned data view.
*/
function cloneDataView(dataView, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
}
/**
* Creates a clone of `map`.
*
* @private
* @param {Object} map The map to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned map.
*/
function cloneMap(map, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
return arrayReduce(array, addMapEntry, new map.constructor);
}
/**
* Creates a clone of `regexp`.
*
* @private
* @param {Object} regexp The regexp to clone.
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}
/**
* Creates a clone of `set`.
*
* @private
* @param {Object} set The set to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned set.
*/
function cloneSet(set, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
return arrayReduce(array, addSetEntry, new set.constructor);
}
/**
* Creates a clone of the `symbol` object.
*
* @private
* @param {Object} symbol The symbol object to clone.
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
}
/**
* Creates a clone of `typedArray`.
*
* @private
* @param {Object} typedArray The typed array to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
/**
* Compares values to sort them in ascending order.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {number} Returns the sort order indicator for `value`.
*/
function compareAscending(value, other) {
if (value !== other) {
var valIsDefined = value !== undefined,
valIsNull = value === null,
valIsReflexive = value === value,
valIsSymbol = isSymbol(value);
var othIsDefined = other !== undefined,
othIsNull = other === null,
othIsReflexive = other === other,
othIsSymbol = isSymbol(other);
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
(valIsNull && othIsDefined && othIsReflexive) ||
(!valIsDefined && othIsReflexive) ||
!valIsReflexive) {
return 1;
}
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
(othIsNull && valIsDefined && valIsReflexive) ||
(!othIsDefined && valIsReflexive) ||
!othIsReflexive) {
return -1;
}
}
return 0;
}
/**
* Used by `_.orderBy` to compare multiple properties of a value to another
* and stable sort them.
*
* If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
* specify an order of "desc" for descending or "asc" for ascending sort order
* of corresponding values.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {boolean[]|string[]} orders The order to sort by for each property.
* @returns {number} Returns the sort order indicator for `object`.
*/
function compareMultiple(object, other, orders) {
var index = -1,
objCriteria = object.criteria,
othCriteria = other.criteria,
length = objCriteria.length,
ordersLength = orders.length;
while (++index < length) {
var result = compareAscending(objCriteria[index], othCriteria[index]);
if (result) {
if (index >= ordersLength) {
return result;
}
var order = orders[index];
return result * (order == 'desc' ? -1 : 1);
}
}
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
// that causes it, under certain circumstances, to provide the same value for
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
// for more details.
//
// This also ensures a stable sort in V8 and other engines.
// See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
return object.index - other.index;
}
/**
* Creates an array that is the composition of partially applied arguments,
* placeholders, and provided arguments into a single array of arguments.
*
* @private
* @param {Array} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgs(args, partials, holders, isCurried) {
var argsIndex = -1,
argsLength = args.length,
holdersLength = holders.length,
leftIndex = -1,
leftLength = partials.length,
rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(leftLength + rangeLength),
isUncurried = !isCurried;
while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex];
}
while (++argsIndex < holdersLength) {
if (isUncurried || argsIndex < argsLength) {
result[holders[argsIndex]] = args[argsIndex];
}
}
while (rangeLength--) {
result[leftIndex++] = args[argsIndex++];
}
return result;
}
/**
* This function is like `composeArgs` except that the arguments composition
* is tailored for `_.partialRight`.
*
* @private
* @param {Array} args The provided arguments.
* @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgsRight(args, partials, holders, isCurried) {
var argsIndex = -1,
argsLength = args.length,
holdersIndex = -1,
holdersLength = holders.length,
rightIndex = -1,
rightLength = partials.length,
rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(rangeLength + rightLength),
isUncurried = !isCurried;
while (++argsIndex < rangeLength) {
result[argsIndex] = args[argsIndex];
}
var offset = argsIndex;
while (++rightIndex < rightLength) {
result[offset + rightIndex] = partials[rightIndex];
}
while (++holdersIndex < holdersLength) {
if (isUncurried || argsIndex < argsLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
}
return result;
}
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
/**
* Copies properties of `source` to `object`.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object, customizer) {
var isNew = !object;
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: undefined;
if (newValue === undefined) {
newValue = source[key];
}
if (isNew) {
baseAssignValue(object, key, newValue);
} else {
assignValue(object, key, newValue);
}
}
return object;
}
/**
* Copies own symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbols(source, object) {
return copyObject(source, getSymbols(source), object);
}
/**
* Copies own and inherited symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbolsIn(source, object) {
return copyObject(source, getSymbolsIn(source), object);
}
/**
* Creates a function like `_.groupBy`.
*
* @private
* @param {Function} setter The function to set accumulator values.
* @param {Function} [initializer] The accumulator object initializer.
* @returns {Function} Returns the new aggregator function.
*/
function createAggregator(setter, initializer) {
return function(collection, iteratee) {
var func = isArray(collection) ? arrayAggregator : baseAggregator,
accumulator = initializer ? initializer() : {};
return func(collection, setter, getIteratee(iteratee, 2), accumulator);
};
}
/**
* Creates a function like `_.assign`.
*
* @private
* @param {Function} assigner The function to assign values.
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
return baseRest(function(object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined;
customizer = (assigner.length > 3 && typeof customizer == 'function')
? (length--, customizer)
: undefined;
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;
}
object = Object(object);
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, index, customizer);
}
}
return object;
});
}
/**
* Creates a `baseEach` or `baseEachRight` function.
*
* @private
* @param {Function} eachFunc The function to iterate over a collection.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseEach(eachFunc, fromRight) {
return function(collection, iteratee) {
if (collection == null) {
return collection;
}
if (!isArrayLike(collection)) {
return eachFunc(collection, iteratee);
}
var length = collection.length,
index = fromRight ? length : -1,
iterable = Object(collection);
while ((fromRight ? index-- : ++index < length)) {
if (iteratee(iterable[index], index, iterable) === false) {
break;
}
}
return collection;
};
}
/**
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseFor(fromRight) {
return function(object, iteratee, keysFunc) {
var index = -1,
iterable = Object(object),
props = keysFunc(object),
length = props.length;
while (length--) {
var key = props[fromRight ? length : ++index];
if (iteratee(iterable[key], key, iterable) === false) {
break;
}
}
return object;
};
}
/**
* Creates a function that wraps `func` to invoke it with the optional `this`
* binding of `thisArg`.
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createBind(func, bitmask, thisArg) {
var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, arguments);
}
return wrapper;
}
/**
* Creates a function like `_.lowerFirst`.
*
* @private
* @param {string} methodName The name of the `String` case method to use.
* @returns {Function} Returns the new case function.
*/
function createCaseFirst(methodName) {
return function(string) {
string = toString(string);
var strSymbols = hasUnicode(string)
? stringToArray(string)
: undefined;
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};
}
/**
* Creates a function like `_.camelCase`.
*
* @private
* @param {Function} callback The function to combine each word.
* @returns {Function} Returns the new compounder function.
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}
/**
* Creates a function that produces an instance of `Ctor` regardless of
* whether it was invoked as part of a `new` expression or by `call` or `apply`.
*
* @private
* @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function.
*/
function createCtor(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
case 0: return new Ctor;
case 1: return new Ctor(args[0]);
case 2: return new Ctor(args[0], args[1]);
case 3: return new Ctor(args[0], args[1], args[2]);
case 4: return new Ctor(args[0], args[1], args[2], args[3]);
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
}
var thisBinding = baseCreate(Ctor.prototype),
result = Ctor.apply(thisBinding, args);
// Mimic the constructor's `return` behavior.
// See https://es5.github.io/#x13.2.2 for more details.
return isObject(result) ? result : thisBinding;
};
}
/**
* Creates a function that wraps `func` to enable currying.
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {number} arity The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createCurry(func, bitmask, arity) {
var Ctor = createCtor(func);
function wrapper() {
var length = arguments.length,
args = Array(length),
index = length,
placeholder = getHolder(wrapper);
while (index--) {
args[index] = arguments[index];
}
var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
? []
: replaceHolders(args, placeholder);
length -= holders.length;
if (length < arity) {
return createRecurry(
func, bitmask, createHybrid, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return apply(fn, this, args);
}
return wrapper;
}
/**
* Creates a `_.find` or `_.findLast` function.
*
* @private
* @param {Function} findIndexFunc The function to find the collection index.
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
if (!isArrayLike(collection)) {
var iteratee = getIteratee(predicate, 3);
collection = keys(collection);
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
}
var index = findIndexFunc(collection, predicate, fromIndex);
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
};
}
/**
* Creates a `_.flow` or `_.flowRight` function.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new flow function.
*/
function createFlow(fromRight) {
return flatRest(function(funcs) {
var length = funcs.length,
index = length,
prereq = LodashWrapper.prototype.thru;
if (fromRight) {
funcs.reverse();
}
while (index--) {
var func = funcs[index];
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
var wrapper = new LodashWrapper([], true);
}
}
index = wrapper ? index : length;
while (++index < length) {
func = funcs[index];
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) &&
data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
!data[4].length && data[9] == 1
) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func))
? wrapper[funcName]()
: wrapper.thru(func);
}
}
return function() {
var args = arguments,
value = args[0];
if (wrapper && args.length == 1 && isArray(value)) {
return wrapper.plant(value).value();
}
var index = 0,
result = length ? funcs[index].apply(this, args) : value;
while (++index < length) {
result = funcs[index].call(this, result);
}
return result;
};
});
}
/**
* Creates a function that wraps `func` to invoke it with optional `this`
* binding of `thisArg`, partial application, and currying.
*
* @private
* @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to
* the new function.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [partialsRight] The arguments to append to those provided
* to the new function.
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
var isAry = bitmask & WRAP_ARY_FLAG,
isBind = bitmask & WRAP_BIND_FLAG,
isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
isFlip = bitmask & WRAP_FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtor(func);
function wrapper() {
var length = arguments.length,
args = Array(length),
index = length;
while (index--) {
args[index] = arguments[index];
}
if (isCurried) {
var placeholder = getHolder(wrapper),
holdersCount = countHolders(args, placeholder);
}
if (partials) {
args = composeArgs(args, partials, holders, isCurried);
}
if (partialsRight) {
args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
}
length -= holdersCount;
if (isCurried && length < arity) {
var newHolders = replaceHolders(args, placeholder);
return createRecurry(
func, bitmask, createHybrid, wrapper.placeholder, thisArg,
args, newHolders, argPos, ary, arity - length
);
}
var thisBinding = isBind ? thisArg : this,
fn = isBindKey ? thisBinding[func] : func;
length = args.length;
if (argPos) {
args = reorder(args, argPos);
} else if (isFlip && length > 1) {
args.reverse();
}
if (isAry && ary < length) {
args.length = ary;
}
if (this && this !== root && this instanceof wrapper) {
fn = Ctor || createCtor(fn);
}
return fn.apply(thisBinding, args);
}
return wrapper;
}
/**
* Creates a function like `_.invertBy`.
*
* @private
* @param {Function} setter The function to set accumulator values.
* @param {Function} toIteratee The function to resolve iteratees.
* @returns {Function} Returns the new inverter function.
*/
function createInverter(setter, toIteratee) {
return function(object, iteratee) {
return baseInverter(object, setter, toIteratee(iteratee), {});
};
}
/**
* Creates a function that performs a mathematical operation on two values.
*
* @private
* @param {Function} operator The function to perform the operation.
* @param {number} [defaultValue] The value used for `undefined` arguments.
* @returns {Function} Returns the new mathematical operation function.
*/
function createMathOperation(operator, defaultValue) {
return function(value, other) {
var result;
if (value === undefined && other === undefined) {
return defaultValue;
}
if (value !== undefined) {
result = value;
}
if (other !== undefined) {
if (result === undefined) {
return other;
}
if (typeof value == 'string' || typeof other == 'string') {
value = baseToString(value);
other = baseToString(other);
} else {
value = baseToNumber(value);
other = baseToNumber(other);
}
result = operator(value, other);
}
return result;
};
}
/**
* Creates a function like `_.over`.
*
* @private
* @param {Function} arrayFunc The function to iterate over iteratees.
* @returns {Function} Returns the new over function.
*/
function createOver(arrayFunc) {
return flatRest(function(iteratees) {
iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
return baseRest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
return apply(iteratee, thisArg, args);
});
});
});
}
/**
* Creates the padding for `string` based on `length`. The `chars` string
* is truncated if the number of characters exceeds `length`.
*
* @private
* @param {number} length The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the padding for `string`.
*/
function createPadding(length, chars) {
chars = chars === undefined ? ' ' : baseToString(chars);
var charsLength = chars.length;
if (charsLength < 2) {
return charsLength ? baseRepeat(chars, length) : chars;
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return hasUnicode(chars)
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
/**
* Creates a function that wraps `func` to invoke it with the `this` binding
* of `thisArg` and `partials` prepended to the arguments it receives.
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} partials The arguments to prepend to those provided to
* the new function.
* @returns {Function} Returns the new wrapped function.
*/
function createPartial(func, bitmask, thisArg, partials) {
var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func);
function wrapper() {
var argsIndex = -1,
argsLength = arguments.length,
leftIndex = -1,
leftLength = partials.length,
args = Array(leftLength + argsLength),
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
while (++leftIndex < leftLength) {
args[leftIndex] = partials[leftIndex];
}
while (argsLength--) {
args[leftIndex++] = arguments[++argsIndex];
}
return apply(fn, isBind ? thisArg : this, args);
}
return wrapper;
}
/**
* Creates a `_.range` or `_.rangeRight` function.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new range function.
*/
function createRange(fromRight) {
return function(start, end, step) {
if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
end = step = undefined;
}
// Ensure the sign of `-0` is preserved.
start = toFinite(start);
if (end === undefined) {
end = start;
start = 0;
} else {
end = toFinite(end);
}
step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
return baseRange(start, end, step, fromRight);
};
}
/**
* Creates a function that performs a relational operation on two values.
*
* @private
* @param {Function} operator The function to perform the operation.
* @returns {Function} Returns the new relational operation function.
*/
function createRelationalOperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
}
return operator(value, other);
};
}
/**
* Creates a function that wraps `func` to continue currying.
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to
* the new function.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & WRAP_CURRY_FLAG,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials;
bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) {
setData(result, newData);
}
result.placeholder = placeholder;
return setWrapToString(result, func, bitmask);
}
/**
* Creates a function like `_.round`.
*
* @private
* @param {string} methodName The name of the `Math` method to use when rounding.
* @returns {Function} Returns the new round function.
*/
function createRound(methodName) {
var func = Math[methodName];
return function(number, precision) {
number = toNumber(number);
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
if (precision) {
// Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details.
var pair = (toString(number) + 'e').split('e'),
value = func(pair[0] + 'e' + (+pair[1] + precision));
pair = (toString(value) + 'e').split('e');
return +(pair[0] + 'e' + (+pair[1] - precision));
}
return func(number);
};
}
/**
* Creates a set object of `values`.
*
* @private
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
return new Set(values);
};
/**
* Creates a `_.toPairs` or `_.toPairsIn` function.
*
* @private
* @param {Function} keysFunc The function to get the keys of a given object.
* @returns {Function} Returns the new pairs function.
*/
function createToPairs(keysFunc) {
return function(object) {
var tag = getTag(object);
if (tag == mapTag) {
return mapToArray(object);
}
if (tag == setTag) {
return setToPairs(object);
}
return baseToPairs(object, keysFunc(object));
};
}
/**
* Creates a function that either curries or invokes `func` with optional
* `this` binding and partially applied arguments.
*
* @private
* @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask flags.
* 1 - `_.bind`
* 2 - `_.bindKey`
* 4 - `_.curry` or `_.curryRight` of a bound function
* 8 - `_.curry`
* 16 - `_.curryRight`
* 32 - `_.partial`
* 64 - `_.partialRight`
* 128 - `_.rearg`
* 256 - `_.ary`
* 512 - `_.flip`
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
if (!isBindKey && typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
var length = partials ? partials.length : 0;
if (!length) {
bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
partials = holders = undefined;
}
ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
arity = arity === undefined ? arity : toInteger(arity);
length -= holders ? holders.length : 0;
if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
var partialsRight = partials,
holdersRight = holders;
partials = holders = undefined;
}
var data = isBindKey ? undefined : getData(func);
var newData = [
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
argPos, ary, arity
];
if (data) {
mergeData(newData, data);
}
func = newData[0];
bitmask = newData[1];
thisArg = newData[2];
partials = newData[3];
holders = newData[4];
arity = newData[9] = newData[9] === undefined
? (isBindKey ? 0 : func.length)
: nativeMax(newData[9] - length, 0);
if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
}
if (!bitmask || bitmask == WRAP_BIND_FLAG) {
var result = createBind(func, bitmask, thisArg);
} else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
result = createCurry(func, bitmask, arity);
} else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
result = createPartial(func, bitmask, thisArg, partials);
} else {
result = createHybrid.apply(undefined, newData);
}
var setter = data ? baseSetData : setData;
return setWrapToString(setter(result, newData), func, bitmask);
}
/**
* Used by `_.defaults` to customize its `_.assignIn` use to assign properties
* of source objects to the destination object for all destination properties
* that resolve to `undefined`.
*
* @private
* @param {*} objValue The destination value.
* @param {*} srcValue The source value.
* @param {string} key The key of the property to assign.
* @param {Object} object The parent object of `objValue`.
* @returns {*} Returns the value to assign.
*/
function customDefaultsAssignIn(objValue, srcValue, key, object) {
if (objValue === undefined ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
return srcValue;
}
return objValue;
}
/**
* Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
* objects into destination objects that are passed thru.
*
* @private
* @param {*} objValue The destination value.
* @param {*} srcValue The source value.
* @param {string} key The key of the property to merge.
* @param {Object} object The parent object of `objValue`.
* @param {Object} source The parent object of `srcValue`.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
* @returns {*} Returns the value to assign.
*/
function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) {
// Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, objValue);
baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
stack['delete'](srcValue);
}
return objValue;
}
/**
* Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
* objects.
*
* @private
* @param {*} value The value to inspect.
* @param {string} key The key of the property to inspect.
* @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
*/
function customOmitClone(value) {
return isPlainObject(value) ? undefined : value;
}
/**
* A specialized version of `baseIsEqualDeep` for arrays with support for
* partial deep comparisons.
*
* @private
* @param {Array} array The array to compare.
* @param {Array} other The other array to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
arrLength = array.length,
othLength = other.length;
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(array);
if (stacked && stack.get(other)) {
return stacked == other;
}
var index = -1,
result = true,
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
stack.set(array, other);
stack.set(other, array);
// Ignore non-index properties.
while (++index < arrLength) {
var arrValue = array[index],
othValue = other[index];
if (customizer) {
var compared = isPartial
? customizer(othValue, arrValue, index, other, array, stack)
: customizer(arrValue, othValue, index, array, other, stack);
}
if (compared !== undefined) {
if (compared) {
continue;
}
result = false;
break;
}
// Recursively compare arrays (susceptible to call stack limits).
if (seen) {
if (!arraySome(other, function(othValue, othIndex) {
if (!cacheHas(seen, othIndex) &&
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
return seen.push(othIndex);
}
})) {
result = false;
break;
}
} else if (!(
arrValue === othValue ||
equalFunc(arrValue, othValue, bitmask, customizer, stack)
)) {
result = false;
break;
}
}
stack['delete'](array);
stack['delete'](other);
return result;
}
/**
* A specialized version of `baseIsEqualDeep` for comparing objects of
* the same `toStringTag`.
*
* **Note:** This function only supports comparing values with tags of
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
switch (tag) {
case dataViewTag:
if ((object.byteLength != other.byteLength) ||
(object.byteOffset != other.byteOffset)) {
return false;
}
object = object.buffer;
other = other.buffer;
case arrayBufferTag:
if ((object.byteLength != other.byteLength) ||
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
return false;
}
return true;
case boolTag:
case dateTag:
case numberTag:
// Coerce booleans to `1` or `0` and dates to milliseconds.
// Invalid dates are coerced to `NaN`.
return eq(+object, +other);
case errorTag:
return object.name == other.name && object.message == other.message;
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details.
return object == (other + '');
case mapTag:
var convert = mapToArray;
case setTag:
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
bitmask |= COMPARE_UNORDERED_FLAG;
// Recursively compare objects (susceptible to call stack limits).
stack.set(object, other);
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
stack['delete'](object);
return result;
case symbolTag:
if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other);
}
}
return false;
}
/**
* A specialized version of `baseIsEqualDeep` for objects with support for
* partial deep comparisons.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
objProps = getAllKeys(object),
objLength = objProps.length,
othProps = getAllKeys(other),
othLength = othProps.length;
if (objLength != othLength && !isPartial) {
return false;
}
var index = objLength;
while (index--) {
var key = objProps[index];
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
return false;
}
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked && stack.get(other)) {
return stacked == other;
}
var result = true;
stack.set(object, other);
stack.set(other, object);
var skipCtor = isPartial;
while (++index < objLength) {
key = objProps[index];
var objValue = object[key],
othValue = other[key];
if (customizer) {
var compared = isPartial
? customizer(othValue, objValue, key, other, object, stack)
: customizer(objValue, othValue, key, object, other, stack);
}
// Recursively compare objects (susceptible to call stack limits).
if (!(compared === undefined
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
: compared
)) {
result = false;
break;
}
skipCtor || (skipCtor = key == 'constructor');
}
if (result && !skipCtor) {
var objCtor = object.constructor,
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal.
if (objCtor != othCtor &&
('constructor' in object && 'constructor' in other) &&
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
result = false;
}
}
stack['delete'](object);
stack['delete'](other);
return result;
}
/**
* A specialized version of `baseRest` which flattens the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @returns {Function} Returns the new function.
*/
function flatRest(func) {
return setToString(overRest(func, undefined, flatten), func + '');
}
/**
* Creates an array of own enumerable property names and symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeys(object) {
return baseGetAllKeys(object, keys, getSymbols);
}
/**
* Creates an array of own and inherited enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeysIn(object) {
return baseGetAllKeys(object, keysIn, getSymbolsIn);
}
/**
* Gets metadata for `func`.
*
* @private
* @param {Function} func The function to query.
* @returns {*} Returns the metadata for `func`.
*/
var getData = !metaMap ? noop : function(func) {
return metaMap.get(func);
};
/**
* Gets the name of `func`.
*
* @private
* @param {Function} func The function to query.
* @returns {string} Returns the function name.
*/
function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],
otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
return data.name;
}
}
return result;
}
/**
* Gets the argument placeholder value for `func`.
*
* @private
* @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value.
*/
function getHolder(func) {
var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
return object.placeholder;
}
/**
* Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
* this function returns the custom method, otherwise it returns `baseIteratee`.
* If arguments are provided, the chosen function is invoked with them and
* its result is returned.
*
* @private
* @param {*} [value] The value to convert to an iteratee.
* @param {number} [arity] The arity of the created iteratee.
* @returns {Function} Returns the chosen function or its result.
*/
function getIteratee() {
var result = lodash.iteratee || iteratee;
result = result === iteratee ? baseIteratee : result;
return arguments.length ? result(arguments[0], arguments[1]) : result;
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
/**
* Gets the property names, values, and compare flags of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the match data of `object`.
*/
function getMatchData(object) {
var result = keys(object),
length = result.length;
while (length--) {
var key = result[length],
value = object[key];
result[length] = [key, value, isStrictComparable(value)];
}
return result;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}
/**
* Creates an array of the own enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
if (object == null) {
return [];
}
object = Object(object);
return arrayFilter(nativeGetSymbols(object), function(symbol) {
return propertyIsEnumerable.call(object, symbol);
});
};
/**
* Creates an array of the own and inherited enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));
object = getPrototype(object);
}
return result;
};
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
var getTag = baseGetTag;
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(Map && getTag(new Map) != mapTag) ||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
var result = baseGetTag(value),
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : '';
if (ctorString) {
switch (ctorString) {
case dataViewCtorString: return dataViewTag;
case mapCtorString: return mapTag;
case promiseCtorString: return promiseTag;
case setCtorString: return setTag;
case weakMapCtorString: return weakMapTag;
}
}
return result;
};
}
/**
* Gets the view, applying any `transforms` to the `start` and `end` positions.
*
* @private
* @param {number} start The start of the view.
* @param {number} end The end of the view.
* @param {Array} transforms The transformations to apply to the view.
* @returns {Object} Returns an object containing the `start` and `end`
* positions of the view.
*/
function getView(start, end, transforms) {
var index = -1,
length = transforms.length;
while (++index < length) {
var data = transforms[index],
size = data.size;
switch (data.type) {
case 'drop': start += size; break;
case 'dropRight': end -= size; break;
case 'take': end = nativeMin(end, start + size); break;
case 'takeRight': start = nativeMax(start, end - size); break;
}
}
return { 'start': start, 'end': end };
}
/**
* Extracts wrapper details from the `source` body comment.
*
* @private
* @param {string} source The source to inspect.
* @returns {Array} Returns the wrapper details.
*/
function getWrapDetails(source) {
var match = source.match(reWrapDetails);
return match ? match[1].split(reSplitDetails) : [];
}
/**
* Checks if `path` exists on `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @param {Function} hasFunc The function to check properties.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = castPath(path, object);
var index = -1,
length = path.length,
result = false;
while (++index < length) {
var key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) {
break;
}
object = object[key];
}
if (result || ++index != length) {
return result;
}
length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) &&
(isArray(object) || isArguments(object));
}
/**
* Initializes an array clone.
*
* @private
* @param {Array} array The array to clone.
* @returns {Array} Returns the initialized clone.
*/
function initCloneArray(array) {
var length = array.length,
result = array.constructor(length);
// Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
result.index = array.index;
result.input = array.input;
}
return result;
}
/**
* Initializes an object clone.
*
* @private
* @param {Object} object The object to clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
return (typeof object.constructor == 'function' && !isPrototype(object))
? baseCreate(getPrototype(object))
: {};
}
/**
* Initializes an object clone based on its `toStringTag`.
*
* **Note:** This function only supports cloning values with tags of
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
*
* @private
* @param {Object} object The object to clone.
* @param {string} tag The `toStringTag` of the object to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneByTag(object, tag, cloneFunc, isDeep) {
var Ctor = object.constructor;
switch (tag) {
case arrayBufferTag:
return cloneArrayBuffer(object);
case boolTag:
case dateTag:
return new Ctor(+object);
case dataViewTag:
return cloneDataView(object, isDeep);
case float32Tag: case float64Tag:
case int8Tag: case int16Tag: case int32Tag:
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
return cloneTypedArray(object, isDeep);
case mapTag:
return cloneMap(object, isDeep, cloneFunc);
case numberTag:
case stringTag:
return new Ctor(object);
case regexpTag:
return cloneRegExp(object);
case setTag:
return cloneSet(object, isDeep, cloneFunc);
case symbolTag:
return cloneSymbol(object);
}
}
/**
* Inserts wrapper `details` in a comment at the top of the `source` body.
*
* @private
* @param {string} source The source to modify.
* @returns {Array} details The details to insert.
* @returns {string} Returns the modified source.
*/
function insertWrapDetails(source, details) {
var length = details.length;
if (!length) {
return source;
}
var lastIndex = length - 1;
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
details = details.join(length > 2 ? ', ' : ' ');
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
}
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
return isArray(value) || isArguments(value) ||
!!(spreadableSymbol && value && value[spreadableSymbol]);
}
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length &&
(typeof value == 'number' || reIsUint.test(value)) &&
(value > -1 && value % 1 == 0 && value < length);
}
/**
* Checks if the given arguments are from an iteratee call.
*
* @private
* @param {*} value The potential iteratee value argument.
* @param {*} index The potential iteratee index or key argument.
* @param {*} object The potential iteratee object argument.
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
* else `false`.
*/
function isIterateeCall(value, index, object) {
if (!isObject(object)) {
return false;
}
var type = typeof index;
if (type == 'number'
? (isArrayLike(object) && isIndex(index, object.length))
: (type == 'string' && index in object)
) {
return eq(object[index], value);
}
return false;
}
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(object != null && value in Object(object));
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
/**
* Checks if `func` has a lazy counterpart.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` has a lazy counterpart,
* else `false`.
*/
function isLaziable(func) {
var funcName = getFuncName(func),
other = lodash[funcName];
if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
return false;
}
if (func === other) {
return true;
}
var data = getData(other);
return !!data && func === data[0];
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
/**
* Checks if `func` is capable of being masked.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `func` is maskable, else `false`.
*/
var isMaskable = coreJsData ? isFunction : stubFalse;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
return value === proto;
}
/**
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` if suitable for strict
* equality comparisons, else `false`.
*/
function isStrictComparable(value) {
return value === value && !isObject(value);
}
/**
* A specialized version of `matchesProperty` for source values suitable
* for strict equality comparisons, i.e. `===`.
*
* @private
* @param {string} key The key of the property to get.
* @param {*} srcValue The value to match.
* @returns {Function} Returns the new spec function.
*/
function matchesStrictComparable(key, srcValue) {
return function(object) {
if (object == null) {
return false;
}
return object[key] === srcValue &&
(srcValue !== undefined || (key in Object(object)));
};
}
/**
* A specialized version of `_.memoize` which clears the memoized function's
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
*
* @private
* @param {Function} func The function to have its output memoized.
* @returns {Function} Returns the new memoized function.
*/
function memoizeCapped(func) {
var result = memoize(func, function(key) {
if (cache.size === MAX_MEMOIZE_SIZE) {
cache.clear();
}
return key;
});
var cache = result.cache;
return result;
}
/**
* Merges the function metadata of `source` into `data`.
*
* Merging metadata reduces the number of wrappers used to invoke a function.
* This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
* may be applied regardless of execution order. Methods like `_.ary` and
* `_.rearg` modify function arguments, making the order in which they are
* executed important, preventing the merging of metadata. However, we make
* an exception for a safe combined case where curried functions have `_.ary`
* and or `_.rearg` applied.
*
* @private
* @param {Array} data The destination metadata.
* @param {Array} source The source metadata.
* @returns {Array} Returns `data`.
*/
function mergeData(data, source) {
var bitmask = data[1],
srcBitmask = source[1],
newBitmask = bitmask | srcBitmask,
isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
var isCombo =
((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
// Exit early if metadata can't be merged.
if (!(isCommon || isCombo)) {
return data;
}
// Use source `thisArg` if available.
if (srcBitmask & WRAP_BIND_FLAG) {
data[2] = source[2];
// Set when currying a bound function.
newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
}
// Compose partial arguments.
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & WRAP_ARY_FLAG) {
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
}
// Use source `arity` if one is not provided.
if (data[9] == null) {
data[9] = source[9];
}
// Use source `func` and merge bitmasks.
data[0] = source[0];
data[1] = newBitmask;
return data;
}
/**
* This function is like
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* except that it includes inherited enumerable properties.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function nativeKeysIn(object) {
var result = [];
if (object != null) {
for (var key in Object(object)) {
result.push(key);
}
}
return result;
}
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
/**
* A specialized version of `baseRest` which transforms the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @param {Function} transform The rest array transform.
* @returns {Function} Returns the new function.
*/
function overRest(func, start, transform) {
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
return function() {
var args = arguments,
index = -1,
length = nativeMax(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = transform(array);
return apply(func, this, otherArgs);
};
}
/**
* Gets the parent value at `path` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Array} path The path to get the parent value of.
* @returns {*} Returns the parent value.
*/
function parent(object, path) {
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
}
/**
* Reorder `array` according to the specified indexes where the element at
* the first index is assigned as the first element, the element at
* the second index is assigned as the second element, and so on.
*
* @private
* @param {Array} array The array to reorder.
* @param {Array} indexes The arranged array indexes.
* @returns {Array} Returns `array`.
*/
function reorder(array, indexes) {
var arrLength = array.length,
length = nativeMin(indexes.length, arrLength),
oldArray = copyArray(array);
while (length--) {
var index = indexes[length];
array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
}
return array;
}
/**
* Sets metadata for `func`.
*
* **Note:** If this function becomes hot, i.e. is invoked a lot in a short
* period of time, it will trip its breaker and transition to an identity
* function to avoid garbage collection pauses in V8. See
* [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
* for more details.
*
* @private
* @param {Function} func The function to associate metadata with.
* @param {*} data The metadata.
* @returns {Function} Returns `func`.
*/
var setData = shortOut(baseSetData);
/**
* A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
*
* @private
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
* @returns {number|Object} Returns the timer id or timeout object.
*/
var setTimeout = ctxSetTimeout || function(func, wait) {
return root.setTimeout(func, wait);
};
/**
* Sets the `toString` method of `func` to return `string`.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var setToString = shortOut(baseSetToString);
/**
* Sets the `toString` method of `wrapper` to mimic the source of `reference`
* with wrapper details in a comment at the top of the source body.
*
* @private
* @param {Function} wrapper The function to modify.
* @param {Function} reference The reference function.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @returns {Function} Returns `wrapper`.
*/
function setWrapToString(wrapper, reference, bitmask) {
var source = (reference + '');
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
}
/**
* Creates a function that'll short out and invoke `identity` instead
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
* milliseconds.
*
* @private
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new shortable function.
*/
function shortOut(func) {
var count = 0,
lastCalled = 0;
return function() {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count = 0;
}
return func.apply(undefined, arguments);
};
}
/**
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
*
* @private
* @param {Array} array The array to shuffle.
* @param {number} [size=array.length] The size of `array`.
* @returns {Array} Returns `array`.
*/
function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
size = size === undefined ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[index];
array[index] = value;
}
array.length = size;
return array;
}
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function(string) {
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
/**
* Updates wrapper `details` based on `bitmask` flags.
*
* @private
* @returns {Array} details The details to modify.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @returns {Array} Returns `details`.
*/
function updateWrapDetails(details, bitmask) {
arrayEach(wrapFlags, function(pair) {
var value = '_.' + pair[0];
if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
details.push(value);
}
});
return details.sort();
}
/**
* Creates a clone of `wrapper`.
*
* @private
* @param {Object} wrapper The wrapper to clone.
* @returns {Object} Returns the cloned wrapper.
*/
function wrapperClone(wrapper) {
if (wrapper instanceof LazyWrapper) {
return wrapper.clone();
}
var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
result.__actions__ = copyArray(wrapper.__actions__);
result.__index__ = wrapper.__index__;
result.__values__ = wrapper.__values__;
return result;
}
/*------------------------------------------------------------------------*/
/**
* Creates an array of elements split into groups the length of `size`.
* If `array` can't be split evenly, the final chunk will be the remaining
* elements.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to process.
* @param {number} [size=1] The length of each chunk
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the new array of chunks.
* @example
*
* _.chunk(['a', 'b', 'c', 'd'], 2);
* // => [['a', 'b'], ['c', 'd']]
*
* _.chunk(['a', 'b', 'c', 'd'], 3);
* // => [['a', 'b', 'c'], ['d']]
*/
function chunk(array, size, guard) {
if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
size = 1;
} else {
size = nativeMax(toInteger(size), 0);
}
var length = array == null ? 0 : array.length;
if (!length || size < 1) {
return [];
}
var index = 0,
resIndex = 0,
result = Array(nativeCeil(length / size));
while (index < length) {
result[resIndex++] = baseSlice(array, index, (index += size));
}
return result;
}
/**
* Creates an array with all falsey values removed. The values `false`, `null`,
* `0`, `""`, `undefined`, and `NaN` are falsey.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to compact.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.compact([0, 1, false, 2, '', 3]);
* // => [1, 2, 3]
*/
function compact(array) {
var index = -1,
length = array == null ? 0 : array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value) {
result[resIndex++] = value;
}
}
return result;
}
/**
* Creates a new array concatenating `array` with any additional arrays
* and/or values.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to concatenate.
* @param {...*} [values] The values to concatenate.
* @returns {Array} Returns the new concatenated array.
* @example
*
* var array = [1];
* var other = _.concat(array, 2, [3], [[4]]);
*
* console.log(other);
* // => [1, 2, 3, [4]]
*
* console.log(array);
* // => [1]
*/
function concat() {
var length = arguments.length;
if (!length) {
return [];
}
var args = Array(length - 1),
array = arguments[0],
index = length;
while (index--) {
args[index - 1] = arguments[index];
}
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
}
/**
* Creates an array of `array` values not included in the other given arrays
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. The order and references of result values are
* determined by the first array.
*
* **Note:** Unlike `_.pullAll`, this method returns a new array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
* @returns {Array} Returns the new array of filtered values.
* @see _.without, _.xor
* @example
*
* _.difference([2, 1], [2, 3]);
* // => [1]
*/
var difference = baseRest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: [];
});
/**
* This method is like `_.difference` except that it accepts `iteratee` which
* is invoked for each element of `array` and `values` to generate the criterion
* by which they're compared. The order and references of result values are
* determined by the first array. The iteratee is invoked with one argument:
* (value).
*
* **Note:** Unlike `_.pullAllBy`, this method returns a new array.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
* // => [1.2]
*
* // The `_.property` iteratee shorthand.
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
var differenceBy = baseRest(function(array, values) {
var iteratee = last(values);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
: [];
});
/**
* This method is like `_.difference` except that it accepts `comparator`
* which is invoked to compare elements of `array` to `values`. The order and
* references of result values are determined by the first array. The comparator
* is invoked with two arguments: (arrVal, othVal).
*
* **Note:** Unlike `_.pullAllWith`, this method returns a new array.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
*
* _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
* // => [{ 'x': 2, 'y': 1 }]
*/
var differenceWith = baseRest(function(array, values) {
var comparator = last(values);
if (isArrayLikeObject(comparator)) {
comparator = undefined;
}
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
: [];
});
/**
* Creates a slice of `array` with `n` elements dropped from the beginning.
*
* @static
* @memberOf _
* @since 0.5.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.drop([1, 2, 3]);
* // => [2, 3]
*
* _.drop([1, 2, 3], 2);
* // => [3]
*
* _.drop([1, 2, 3], 5);
* // => []
*
* _.drop([1, 2, 3], 0);
* // => [1, 2, 3]
*/
function drop(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
return baseSlice(array, n < 0 ? 0 : n, length);
}
/**
* Creates a slice of `array` with `n` elements dropped from the end.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropRight([1, 2, 3]);
* // => [1, 2]
*
* _.dropRight([1, 2, 3], 2);
* // => [1]
*
* _.dropRight([1, 2, 3], 5);
* // => []
*
* _.dropRight([1, 2, 3], 0);
* // => [1, 2, 3]
*/
function dropRight(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
n = length - n;
return baseSlice(array, 0, n < 0 ? 0 : n);
}
/**
* Creates a slice of `array` excluding elements dropped from the end.
* Elements are dropped until `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.dropRightWhile(users, function(o) { return !o.active; });
* // => objects for ['barney']
*
* // The `_.matches` iteratee shorthand.
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['barney', 'fred']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.dropRightWhile(users, ['active', false]);
* // => objects for ['barney']
*
* // The `_.property` iteratee shorthand.
* _.dropRightWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
function dropRightWhile(array, predicate) {
return (array && array.length)
? baseWhile(array, getIteratee(predicate, 3), true, true)
: [];
}
/**
* Creates a slice of `array` excluding elements dropped from the beginning.
* Elements are dropped until `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.dropWhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles']
*
* // The `_.matches` iteratee shorthand.
* _.dropWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.dropWhile(users, ['active', false]);
* // => objects for ['pebbles']
*
* // The `_.property` iteratee shorthand.
* _.dropWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
function dropWhile(array, predicate) {
return (array && array.length)
? baseWhile(array, getIteratee(predicate, 3), true)
: [];
}
/**
* Fills elements of `array` with `value` from `start` up to, but not
* including, `end`.
*
* **Note:** This method mutates `array`.
*
* @static
* @memberOf _
* @since 3.2.0
* @category Array
* @param {Array} array The array to fill.
* @param {*} value The value to fill `array` with.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns `array`.
* @example
*
* var array = [1, 2, 3];
*
* _.fill(array, 'a');
* console.log(array);
* // => ['a', 'a', 'a']
*
* _.fill(Array(3), 2);
* // => [2, 2, 2]
*
* _.fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*/
function fill(array, value, start, end) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
start = 0;
end = length;
}
return baseFill(array, value, start, end);
}
/**
* This method is like `_.find` except that it returns the index of the first
* element `predicate` returns truthy for instead of the element itself.
*
* @static
* @memberOf _
* @since 1.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.findIndex(users, function(o) { return o.user == 'barney'; });
* // => 0
*
* // The `_.matches` iteratee shorthand.
* _.findIndex(users, { 'user': 'fred', 'active': false });
* // => 1
*
* // The `_.matchesProperty` iteratee shorthand.
* _.findIndex(users, ['active', false]);
* // => 0
*
* // The `_.property` iteratee shorthand.
* _.findIndex(users, 'active');
* // => 2
*/
function findIndex(array, predicate, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromIndex == null ? 0 : toInteger(fromIndex);
if (index < 0) {
index = nativeMax(length + index, 0);
}
return baseFindIndex(array, getIteratee(predicate, 3), index);
}
/**
* This method is like `_.findIndex` except that it iterates over elements
* of `collection` from right to left.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
* // => 2
*
* // The `_.matches` iteratee shorthand.
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0
*
* // The `_.matchesProperty` iteratee shorthand.
* _.findLastIndex(users, ['active', false]);
* // => 2
*
* // The `_.property` iteratee shorthand.
* _.findLastIndex(users, 'active');
* // => 0
*/
function findLastIndex(array, predicate, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = length - 1;
if (fromIndex !== undefined) {
index = toInteger(fromIndex);
index = fromIndex < 0
? nativeMax(length + index, 0)
: nativeMin(index, length - 1);
}
return baseFindIndex(array, getIteratee(predicate, 3), index, true);
}
/**
* Flattens `array` a single level deep.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flatten([1, [2, [3, [4]], 5]]);
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, 1) : [];
}
/**
* Recursively flattens `array`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flattenDeep([1, [2, [3, [4]], 5]]);
* // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, INFINITY) : [];
}
/**
* Recursively flatten `array` up to `depth` times.
*
* @static
* @memberOf _
* @since 4.4.0
* @category Array
* @param {Array} array The array to flatten.
* @param {number} [depth=1] The maximum recursion depth.
* @returns {Array} Returns the new flattened array.
* @example
*
* var array = [1, [2, [3, [4]], 5]];
*
* _.flattenDepth(array, 1);
* // => [1, 2, [3, [4]], 5]
*
* _.flattenDepth(array, 2);
* // => [1, 2, 3, [4], 5]
*/
function flattenDepth(array, depth) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
depth = depth === undefined ? 1 : toInteger(depth);
return baseFlatten(array, depth);
}
/**
* The inverse of `_.toPairs`; this method returns an object composed
* from key-value `pairs`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} pairs The key-value pairs.
* @returns {Object} Returns the new object.
* @example
*
* _.fromPairs([['a', 1], ['b', 2]]);
* // => { 'a': 1, 'b': 2 }
*/
function fromPairs(pairs) {
var index = -1,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
var pair = pairs[index];
result[pair[0]] = pair[1];
}
return result;
}
/**
* Gets the first element of `array`.
*
* @static
* @memberOf _
* @since 0.1.0
* @alias first
* @category Array
* @param {Array} array The array to query.
* @returns {*} Returns the first element of `array`.
* @example
*
* _.head([1, 2, 3]);
* // => 1
*
* _.head([]);
* // => undefined
*/
function head(array) {
return (array && array.length) ? array[0] : undefined;
}
/**
* Gets the index at which the first occurrence of `value` is found in `array`
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the
* offset from the end of `array`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/
function indexOf(array, value, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromIndex == null ? 0 : toInteger(fromIndex);
if (index < 0) {
index = nativeMax(length + index, 0);
}
return baseIndexOf(array, value, index);
}
/**
* Gets all but the last element of `array`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to query.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.initial([1, 2, 3]);
* // => [1, 2]
*/
function initial(array) {
var length = array == null ? 0 : array.length;
return length ? baseSlice(array, 0, -1) : [];
}
/**
* Creates an array of unique values that are included in all given arrays
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. The order and references of result values are
* determined by the first array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of intersecting values.
* @example
*
* _.intersection([2, 1], [2, 3]);
* // => [2]
*/
var intersection = baseRest(function(arrays) {
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
});
/**
* This method is like `_.intersection` except that it accepts `iteratee`
* which is invoked for each element of each `arrays` to generate the criterion
* by which they're compared. The order and references of result values are
* determined by the first array. The iteratee is invoked with one argument:
* (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of intersecting values.
* @example
*
* _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
* // => [2.1]
*
* // The `_.property` iteratee shorthand.
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
var intersectionBy = baseRest(function(arrays) {
var iteratee = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
} else {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped, getIteratee(iteratee, 2))
: [];
});
/**
* This method is like `_.intersection` except that it accepts `comparator`
* which is invoked to compare elements of `arrays`. The order and references
* of result values are determined by the first array. The comparator is
* invoked with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of intersecting values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.intersectionWith(objects, others, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }]
*/
var intersectionWith = baseRest(function(arrays) {
var comparator = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);
comparator = typeof comparator == 'function' ? comparator : undefined;
if (comparator) {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped, undefined, comparator)
: [];
});
/**
* Converts all elements in `array` into a string separated by `separator`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to convert.
* @param {string} [separator=','] The element separator.
* @returns {string} Returns the joined string.
* @example
*
* _.join(['a', 'b', 'c'], '~');
* // => 'a~b~c'
*/
function join(array, separator) {
return array == null ? '' : nativeJoin.call(array, separator);
}
/**
* Gets the last element of `array`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to query.
* @returns {*} Returns the last element of `array`.
* @example
*
* _.last([1, 2, 3]);
* // => 3
*/
function last(array) {
var length = array == null ? 0 : array.length;
return length ? array[length - 1] : undefined;
}
/**
* This method is like `_.indexOf` except that it iterates over elements of
* `array` from right to left.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3
*
* // Search from the `fromIndex`.
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1
*/
function lastIndexOf(array, value, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = length;
if (fromIndex !== undefined) {
index = toInteger(fromIndex);
index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
}
return value === value
? strictLastIndexOf(array, value, index)
: baseFindIndex(array, baseIsNaN, index, true);
}
/**
* Gets the element at index `n` of `array`. If `n` is negative, the nth
* element from the end is returned.
*
* @static
* @memberOf _
* @since 4.11.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=0] The index of the element to return.
* @returns {*} Returns the nth element of `array`.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
*
* _.nth(array, 1);
* // => 'b'
*
* _.nth(array, -2);
* // => 'c';
*/
function nth(array, n) {
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
}
/**
* Removes all given values from `array` using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
* to remove elements from an array by predicate.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {...*} [values] The values to remove.
* @returns {Array} Returns `array`.
* @example
*
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
*
* _.pull(array, 'a', 'c');
* console.log(array);
* // => ['b', 'b']
*/
var pull = baseRest(pullAll);
/**
* This method is like `_.pull` except that it accepts an array of values to remove.
*
* **Note:** Unlike `_.difference`, this method mutates `array`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @returns {Array} Returns `array`.
* @example
*
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
*
* _.pullAll(array, ['a', 'c']);
* console.log(array);
* // => ['b', 'b']
*/
function pullAll(array, values) {
return (array && array.length && values && values.length)
? basePullAll(array, values)
: array;
}
/**
* This method is like `_.pullAll` except that it accepts `iteratee` which is
* invoked for each element of `array` and `values` to generate the criterion
* by which they're compared. The iteratee is invoked with one argument: (value).
*
* **Note:** Unlike `_.differenceBy`, this method mutates `array`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns `array`.
* @example
*
* var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
*
* _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
* console.log(array);
* // => [{ 'x': 2 }]
*/
function pullAllBy(array, values, iteratee) {
return (array && array.length && values && values.length)
? basePullAll(array, values, getIteratee(iteratee, 2))
: array;
}
/**
* This method is like `_.pullAll` except that it accepts `comparator` which
* is invoked to compare elements of `array` to `values`. The comparator is
* invoked with two arguments: (arrVal, othVal).
*
* **Note:** Unlike `_.differenceWith`, this method mutates `array`.
*
* @static
* @memberOf _
* @since 4.6.0
* @category Array
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`.
* @example
*
* var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
*
* _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
* console.log(array);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
*/
function pullAllWith(array, values, comparator) {
return (array && array.length && values && values.length)
? basePullAll(array, values, undefined, comparator)
: array;
}
/**
* Removes elements from `array` corresponding to `indexes` and returns an
* array of removed elements.
*
* **Note:** Unlike `_.at`, this method mutates `array`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
* var pulled = _.pullAt(array, [1, 3]);
*
* console.log(array);
* // => ['a', 'c']
*
* console.log(pulled);
* // => ['b', 'd']
*/
var pullAt = flatRest(function(array, indexes) {
var length = array == null ? 0 : array.length,
result = baseAt(array, indexes);
basePullAt(array, arrayMap(indexes, function(index) {
return isIndex(index, length) ? +index : index;
}).sort(compareAscending));
return result;
});
/**
* Removes all elements from `array` that `predicate` returns truthy for
* and returns an array of the removed elements. The predicate is invoked
* with three arguments: (value, index, array).
*
* **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
* to pull elements from an array by value.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new array of removed elements.
* @example
*
* var array = [1, 2, 3, 4];
* var evens = _.remove(array, function(n) {
* return n % 2 == 0;
* });
*
* console.log(array);
* // => [1, 3]
*
* console.log(evens);
* // => [2, 4]
*/
function remove(array, predicate) {
var result = [];
if (!(array && array.length)) {
return result;
}
var index = -1,
indexes = [],
length = array.length;
predicate = getIteratee(predicate, 3);
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result.push(value);
indexes.push(index);
}
}
basePullAt(array, indexes);
return result;
}
/**
* Reverses `array` so that the first element becomes the last, the second
* element becomes the second to last, and so on.
*
* **Note:** This method mutates `array` and is based on
* [`Array#reverse`](https://mdn.io/Array/reverse).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to modify.
* @returns {Array} Returns `array`.
* @example
*
* var array = [1, 2, 3];
*
* _.reverse(array);
* // => [3, 2, 1]
*
* console.log(array);
* // => [3, 2, 1]
*/
function reverse(array) {
return array == null ? array : nativeReverse.call(array);
}
/**
* Creates a slice of `array` from `start` up to, but not including, `end`.
*
* **Note:** This method is used instead of
* [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
* returned.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to slice.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the slice of `array`.
*/
function slice(array, start, end) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
start = 0;
end = length;
}
else {
start = start == null ? 0 : toInteger(start);
end = end === undefined ? length : toInteger(end);
}
return baseSlice(array, start, end);
}
/**
* Uses a binary search to determine the lowest index at which `value`
* should be inserted into `array` in order to maintain its sort order.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
*
* _.sortedIndex([30, 50], 40);
* // => 1
*/
function sortedIndex(array, value) {
return baseSortedIndex(array, value);
}
/**
* This method is like `_.sortedIndex` except that it accepts `iteratee`
* which is invoked for `value` and each element of `array` to compute their
* sort ranking. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
*
* var objects = [{ 'x': 4 }, { 'x': 5 }];
*
* _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
* // => 0
*
* // The `_.property` iteratee shorthand.
* _.sortedIndexBy(objects, { 'x': 4 }, 'x');
* // => 0
*/
function sortedIndexBy(array, value, iteratee) {
return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
}
/**
* This method is like `_.indexOf` except that it performs a binary
* search on a sorted `array`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.sortedIndexOf([4, 5, 5, 5, 6], 5);
* // => 1
*/
function sortedIndexOf(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value);
if (index < length && eq(array[index], value)) {
return index;
}
}
return -1;
}
/**
* This method is like `_.sortedIndex` except that it returns the highest
* index at which `value` should be inserted into `array` in order to
* maintain its sort order.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
*
* _.sortedLastIndex([4, 5, 5, 5, 6], 5);
* // => 4
*/
function sortedLastIndex(array, value) {
return baseSortedIndex(array, value, true);
}
/**
* This method is like `_.sortedLastIndex` except that it accepts `iteratee`
* which is invoked for `value` and each element of `array` to compute their
* sort ranking. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
*
* var objects = [{ 'x': 4 }, { 'x': 5 }];
*
* _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
* // => 1
*
* // The `_.property` iteratee shorthand.
* _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
* // => 1
*/
function sortedLastIndexBy(array, value, iteratee) {
return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
}
/**
* This method is like `_.lastIndexOf` except that it performs a binary
* search on a sorted `array`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
* // => 3
*/
function sortedLastIndexOf(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value, true) - 1;
if (eq(array[index], value)) {
return index;
}
}
return -1;
}
/**
* This method is like `_.uniq` except that it's designed and optimized
* for sorted arrays.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* _.sortedUniq([1, 1, 2]);
* // => [1, 2]
*/
function sortedUniq(array) {
return (array && array.length)
? baseSortedUniq(array)
: [];
}
/**
* This method is like `_.uniqBy` except that it's designed and optimized
* for sorted arrays.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
* // => [1.1, 2.3]
*/
function sortedUniqBy(array, iteratee) {
return (array && array.length)
? baseSortedUniq(array, getIteratee(iteratee, 2))
: [];
}
/**
* Gets all but the first element of `array`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to query.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.tail([1, 2, 3]);
* // => [2, 3]
*/
function tail(array) {
var length = array == null ? 0 : array.length;
return length ? baseSlice(array, 1, length) : [];
}
/**
* Creates a slice of `array` with `n` elements taken from the beginning.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to take.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.take([1, 2, 3]);
* // => [1]
*
* _.take([1, 2, 3], 2);
* // => [1, 2]
*
* _.take([1, 2, 3], 5);
* // => [1, 2, 3]
*
* _.take([1, 2, 3], 0);
* // => []
*/
function take(array, n, guard) {
if (!(array && array.length)) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
return baseSlice(array, 0, n < 0 ? 0 : n);
}
/**
* Creates a slice of `array` with `n` elements taken from the end.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to take.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.takeRight([1, 2, 3]);
* // => [3]
*
* _.takeRight([1, 2, 3], 2);
* // => [2, 3]
*
* _.takeRight([1, 2, 3], 5);
* // => [1, 2, 3]
*
* _.takeRight([1, 2, 3], 0);
* // => []
*/
function takeRight(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
n = length - n;
return baseSlice(array, n < 0 ? 0 : n, length);
}
/**
* Creates a slice of `array` with elements taken from the end. Elements are
* taken until `predicate` returns falsey. The predicate is invoked with
* three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.takeRightWhile(users, function(o) { return !o.active; });
* // => objects for ['fred', 'pebbles']
*
* // The `_.matches` iteratee shorthand.
* _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['pebbles']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.takeRightWhile(users, ['active', false]);
* // => objects for ['fred', 'pebbles']
*
* // The `_.property` iteratee shorthand.
* _.takeRightWhile(users, 'active');
* // => []
*/
function takeRightWhile(array, predicate) {
return (array && array.length)
? baseWhile(array, getIteratee(predicate, 3), false, true)
: [];
}
/**
* Creates a slice of `array` with elements taken from the beginning. Elements
* are taken until `predicate` returns falsey. The predicate is invoked with
* three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.takeWhile(users, function(o) { return !o.active; });
* // => objects for ['barney', 'fred']
*
* // The `_.matches` iteratee shorthand.
* _.takeWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['barney']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.takeWhile(users, ['active', false]);
* // => objects for ['barney', 'fred']
*
* // The `_.property` iteratee shorthand.
* _.takeWhile(users, 'active');
* // => []
*/
function takeWhile(array, predicate) {
return (array && array.length)
? baseWhile(array, getIteratee(predicate, 3))
: [];
}
/**
* Creates an array of unique values, in order, from all given arrays using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of combined values.
* @example
*
* _.union([2], [1, 2]);
* // => [2, 1]
*/
var union = baseRest(function(arrays) {
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
});
/**
* This method is like `_.union` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
* which uniqueness is computed. Result values are chosen from the first
* array in which the value occurs. The iteratee is invoked with one argument:
* (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of combined values.
* @example
*
* _.unionBy([2.1], [1.2, 2.3], Math.floor);
* // => [2.1, 1.2]
*
* // The `_.property` iteratee shorthand.
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
var unionBy = baseRest(function(arrays) {
var iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
});
/**
* This method is like `_.union` except that it accepts `comparator` which
* is invoked to compare elements of `arrays`. Result values are chosen from
* the first array in which the value occurs. The comparator is invoked
* with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of combined values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.unionWith(objects, others, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
var unionWith = baseRest(function(arrays) {
var comparator = last(arrays);
comparator = typeof comparator == 'function' ? comparator : undefined;
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
});
/**
* Creates a duplicate-free version of an array, using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons, in which only the first occurrence of each element
* is kept. The order of result values is determined by the order they occur
* in the array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* _.uniq([2, 1, 2]);
* // => [2, 1]
*/
function uniq(array) {
return (array && array.length) ? baseUniq(array) : [];
}
/**
* This method is like `_.uniq` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the criterion by which
* uniqueness is computed. The order of result values is determined by the
* order they occur in the array. The iteratee is invoked with one argument:
* (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
* // => [2.1, 1.2]
*
* // The `_.property` iteratee shorthand.
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
function uniqBy(array, iteratee) {
return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
}
/**
* This method is like `_.uniq` except that it accepts `comparator` which
* is invoked to compare elements of `array`. The order of result values is
* determined by the order they occur in the array.The comparator is invoked
* with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.uniqWith(objects, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
*/
function uniqWith(array, comparator) {
comparator = typeof comparator == 'function' ? comparator : undefined;
return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
}
/**
* This method is like `_.zip` except that it accepts an array of grouped
* elements and creates an array regrouping the elements to their pre-zip
* configuration.
*
* @static
* @memberOf _
* @since 1.2.0
* @category Array
* @param {Array} array The array of grouped elements to process.
* @returns {Array} Returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*
* _.unzip(zipped);
* // => [['a', 'b'], [1, 2], [true, false]]
*/
function unzip(array) {
if (!(array && array.length)) {
return [];
}
var length = 0;
array = arrayFilter(array, function(group) {
if (isArrayLikeObject(group)) {
length = nativeMax(group.length, length);
return true;
}
});
return baseTimes(length, function(index) {
return arrayMap(array, baseProperty(index));
});
}
/**
* This method is like `_.unzip` except that it accepts `iteratee` to specify
* how regrouped values should be combined. The iteratee is invoked with the
* elements of each group: (...group).
*
* @static
* @memberOf _
* @since 3.8.0
* @category Array
* @param {Array} array The array of grouped elements to process.
* @param {Function} [iteratee=_.identity] The function to combine
* regrouped values.
* @returns {Array} Returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip([1, 2], [10, 20], [100, 200]);
* // => [[1, 10, 100], [2, 20, 200]]
*
* _.unzipWith(zipped, _.add);
* // => [3, 30, 300]
*/
function unzipWith(array, iteratee) {
if (!(array && array.length)) {
return [];
}
var result = unzip(array);
if (iteratee == null) {
return result;
}
return arrayMap(result, function(group) {
return apply(iteratee, undefined, group);
});
}
/**
* Creates an array excluding all given values using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* **Note:** Unlike `_.pull`, this method returns a new array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {...*} [values] The values to exclude.
* @returns {Array} Returns the new array of filtered values.
* @see _.difference, _.xor
* @example
*
* _.without([2, 1, 2, 3], 1, 2);
* // => [3]
*/
var without = baseRest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, values)
: [];
});
/**
* Creates an array of unique values that is the
* [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
* of the given arrays. The order of result values is determined by the order
* they occur in the arrays.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of filtered values.
* @see _.difference, _.without
* @example
*
* _.xor([2, 1], [2, 3]);
* // => [1, 3]
*/
var xor = baseRest(function(arrays) {
return baseXor(arrayFilter(arrays, isArrayLikeObject));
});
/**
* This method is like `_.xor` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
* which by which they're compared. The order of result values is determined
* by the order they occur in the arrays. The iteratee is invoked with one
* argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
* // => [1.2, 3.4]
*
* // The `_.property` iteratee shorthand.
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
var xorBy = baseRest(function(arrays) {
var iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
});
/**
* This method is like `_.xor` except that it accepts `comparator` which is
* invoked to compare elements of `arrays`. The order of result values is
* determined by the order they occur in the arrays. The comparator is invoked
* with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.xorWith(objects, others, _.isEqual);
* // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
var xorWith = baseRest(function(arrays) {
var comparator = last(arrays);
comparator = typeof comparator == 'function' ? comparator : undefined;
return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
});
/**
* Creates an array of grouped elements, the first of which contains the
* first elements of the given arrays, the second of which contains the
* second elements of the given arrays, and so on.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {...Array} [arrays] The arrays to process.
* @returns {Array} Returns the new array of grouped elements.
* @example
*
* _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*/
var zip = baseRest(unzip);
/**
* This method is like `_.fromPairs` except that it accepts two arrays,
* one of property identifiers and one of corresponding values.
*
* @static
* @memberOf _
* @since 0.4.0
* @category Array
* @param {Array} [props=[]] The property identifiers.
* @param {Array} [values=[]] The property values.
* @returns {Object} Returns the new object.
* @example
*
* _.zipObject(['a', 'b'], [1, 2]);
* // => { 'a': 1, 'b': 2 }
*/
function zipObject(props, values) {
return baseZipObject(props || [], values || [], assignValue);
}
/**
* This method is like `_.zipObject` except that it supports property paths.
*
* @static
* @memberOf _
* @since 4.1.0
* @category Array
* @param {Array} [props=[]] The property identifiers.
* @param {Array} [values=[]] The property values.
* @returns {Object} Returns the new object.
* @example
*
* _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
* // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
*/
function zipObjectDeep(props, values) {
return baseZipObject(props || [], values || [], baseSet);
}
/**
* This method is like `_.zip` except that it accepts `iteratee` to specify
* how grouped values should be combined. The iteratee is invoked with the
* elements of each group: (...group).
*
* @static
* @memberOf _
* @since 3.8.0
* @category Array
* @param {...Array} [arrays] The arrays to process.
* @param {Function} [iteratee=_.identity] The function to combine
* grouped values.
* @returns {Array} Returns the new array of grouped elements.
* @example
*
* _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
* return a + b + c;
* });
* // => [111, 222]
*/
var zipWith = baseRest(function(arrays) {
var length = arrays.length,
iteratee = length > 1 ? arrays[length - 1] : undefined;
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
return unzipWith(arrays, iteratee);
});
/*------------------------------------------------------------------------*/
/**
* Creates a `lodash` wrapper instance that wraps `value` with explicit method
* chain sequences enabled. The result of such sequences must be unwrapped
* with `_#value`.
*
* @static
* @memberOf _
* @since 1.3.0
* @category Seq
* @param {*} value The value to wrap.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'pebbles', 'age': 1 }
* ];
*
* var youngest = _
* .chain(users)
* .sortBy('age')
* .map(function(o) {
* return o.user + ' is ' + o.age;
* })
* .head()
* .value();
* // => 'pebbles is 1'
*/
function chain(value) {
var result = lodash(value);
result.__chain__ = true;
return result;
}
/**
* This method invokes `interceptor` and returns `value`. The interceptor
* is invoked with one argument; (value). The purpose of this method is to
* "tap into" a method chain sequence in order to modify intermediate results.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Seq
* @param {*} value The value to provide to `interceptor`.
* @param {Function} interceptor The function to invoke.
* @returns {*} Returns `value`.
* @example
*
* _([1, 2, 3])
* .tap(function(array) {
* // Mutate input array.
* array.pop();
* })
* .reverse()
* .value();
* // => [2, 1]
*/
function tap(value, interceptor) {
interceptor(value);
return value;
}
/**
* This method is like `_.tap` except that it returns the result of `interceptor`.
* The purpose of this method is to "pass thru" values replacing intermediate
* results in a method chain sequence.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Seq
* @param {*} value The value to provide to `interceptor`.
* @param {Function} interceptor The function to invoke.
* @returns {*} Returns the result of `interceptor`.
* @example
*
* _(' abc ')
* .chain()
* .trim()
* .thru(function(value) {
* return [value];
* })
* .value();
* // => ['abc']
*/
function thru(value, interceptor) {
return interceptor(value);
}
/**
* This method is the wrapper version of `_.at`.
*
* @name at
* @memberOf _
* @since 1.0.0
* @category Seq
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
*
* _(object).at(['a[0].b.c', 'a[1]']).value();
* // => [3, 4]
*/
var wrapperAt = flatRest(function(paths) {
var length = paths.length,
start = length ? paths[0] : 0,
value = this.__wrapped__,
interceptor = function(object) { return baseAt(object, paths); };
if (length > 1 || this.__actions__.length ||
!(value instanceof LazyWrapper) || !isIndex(start)) {
return this.thru(interceptor);
}
value = value.slice(start, +start + (length ? 1 : 0));
value.__actions__.push({
'func': thru,
'args': [interceptor],
'thisArg': undefined
});
return new LodashWrapper(value, this.__chain__).thru(function(array) {
if (length && !array.length) {
array.push(undefined);
}
return array;
});
});
/**
* Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
*
* @name chain
* @memberOf _
* @since 0.1.0
* @category Seq
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 }
* ];
*
* // A sequence without explicit chaining.
* _(users).head();
* // => { 'user': 'barney', 'age': 36 }
*
* // A sequence with explicit chaining.
* _(users)
* .chain()
* .head()
* .pick('user')
* .value();
* // => { 'user': 'barney' }
*/
function wrapperChain() {
return chain(this);
}
/**
* Executes the chain sequence and returns the wrapped result.
*
* @name commit
* @memberOf _
* @since 3.2.0
* @category Seq
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2];
* var wrapped = _(array).push(3);
*
* console.log(array);
* // => [1, 2]
*
* wrapped = wrapped.commit();
* console.log(array);
* // => [1, 2, 3]
*
* wrapped.last();
* // => 3
*
* console.log(array);
* // => [1, 2, 3]
*/
function wrapperCommit() {
return new LodashWrapper(this.value(), this.__chain__);
}
/**
* Gets the next value on a wrapped object following the
* [iterator protocol](https://mdn.io/iteration_protocols#iterator).
*
* @name next
* @memberOf _
* @since 4.0.0
* @category Seq
* @returns {Object} Returns the next iterator value.
* @example
*
* var wrapped = _([1, 2]);
*
* wrapped.next();
* // => { 'done': false, 'value': 1 }
*
* wrapped.next();
* // => { 'done': false, 'value': 2 }
*
* wrapped.next();
* // => { 'done': true, 'value': undefined }
*/
function wrapperNext() {
if (this.__values__ === undefined) {
this.__values__ = toArray(this.value());
}
var done = this.__index__ >= this.__values__.length,
value = done ? undefined : this.__values__[this.__index__++];
return { 'done': done, 'value': value };
}
/**
* Enables the wrapper to be iterable.
*
* @name Symbol.iterator
* @memberOf _
* @since 4.0.0
* @category Seq
* @returns {Object} Returns the wrapper object.
* @example
*
* var wrapped = _([1, 2]);
*
* wrapped[Symbol.iterator]() === wrapped;
* // => true
*
* Array.from(wrapped);
* // => [1, 2]
*/
function wrapperToIterator() {
return this;
}
/**
* Creates a clone of the chain sequence planting `value` as the wrapped value.
*
* @name plant
* @memberOf _
* @since 3.2.0
* @category Seq
* @param {*} value The value to plant.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* function square(n) {
* return n * n;
* }
*
* var wrapped = _([1, 2]).map(square);
* var other = wrapped.plant([3, 4]);
*
* other.value();
* // => [9, 16]
*
* wrapped.value();
* // => [1, 4]
*/
function wrapperPlant(value) {
var result,
parent = this;
while (parent instanceof baseLodash) {
var clone = wrapperClone(parent);
clone.__index__ = 0;
clone.__values__ = undefined;
if (result) {
previous.__wrapped__ = clone;
} else {
result = clone;
}
var previous = clone;
parent = parent.__wrapped__;
}
previous.__wrapped__ = value;
return result;
}
/**
* This method is the wrapper version of `_.reverse`.
*
* **Note:** This method mutates the wrapped array.
*
* @name reverse
* @memberOf _
* @since 0.1.0
* @category Seq
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2, 3];
*
* _(array).reverse().value()
* // => [3, 2, 1]
*
* console.log(array);
* // => [3, 2, 1]
*/
function wrapperReverse() {
var value = this.__wrapped__;
if (value instanceof LazyWrapper) {
var wrapped = value;
if (this.__actions__.length) {
wrapped = new LazyWrapper(this);
}
wrapped = wrapped.reverse();
wrapped.__actions__.push({
'func': thru,
'args': [reverse],
'thisArg': undefined
});
return new LodashWrapper(wrapped, this.__chain__);
}
return this.thru(reverse);
}
/**
* Executes the chain sequence to resolve the unwrapped value.
*
* @name value
* @memberOf _
* @since 0.1.0
* @alias toJSON, valueOf
* @category Seq
* @returns {*} Returns the resolved unwrapped value.
* @example
*
* _([1, 2, 3]).value();
* // => [1, 2, 3]
*/
function wrapperValue() {
return baseWrapperValue(this.__wrapped__, this.__actions__);
}
/*------------------------------------------------------------------------*/
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. The corresponding value of
* each key is the number of times the key was returned by `iteratee`. The
* iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 0.5.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* _.countBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': 1, '6': 2 }
*
* // The `_.property` iteratee shorthand.
* _.countBy(['one', 'two', 'three'], 'length');
* // => { '3': 2, '5': 1 }
*/
var countBy = createAggregator(function(result, value, key) {
if (hasOwnProperty.call(result, key)) {
++result[key];
} else {
baseAssignValue(result, key, 1);
}
});
/**
* Checks if `predicate` returns truthy for **all** elements of `collection`.
* Iteration is stopped once `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index|key, collection).
*
* **Note:** This method returns `true` for
* [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
* [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
* elements of empty collections.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
* @example
*
* _.every([true, 1, null, 'yes'], Boolean);
* // => false
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
* // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]);
* // => true
*
* // The `_.property` iteratee shorthand.
* _.every(users, 'active');
* // => false
*/
function every(collection, predicate, guard) {
var func = isArray(collection) ? arrayEvery : baseEvery;
if (guard && isIterateeCall(collection, predicate, guard)) {
predicate = undefined;
}
return func(collection, getIteratee(predicate, 3));
}
/**
* Iterates over elements of `collection`, returning an array of all elements
* `predicate` returns truthy for. The predicate is invoked with three
* arguments: (value, index|key, collection).
*
* **Note:** Unlike `_.remove`, this method returns a new array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
* // The `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*/
function filter(collection, predicate) {
var func = isArray(collection) ? arrayFilter : baseFilter;
return func(collection, getIteratee(predicate, 3));
}
/**
* Iterates over elements of `collection`, returning the first element
* `predicate` returns truthy for. The predicate is invoked with three
* arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false },
* { 'user': 'pebbles', 'age': 1, 'active': true }
* ];
*
* _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney'
*
* // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles'
*
* // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]);
* // => object for 'fred'
*
* // The `_.property` iteratee shorthand.
* _.find(users, 'active');
* // => object for 'barney'
*/
var find = createFind(findIndex);
/**
* This method is like `_.find` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Collection
* @param {Array|Object} collection The collection to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=collection.length-1] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
* _.findLast([1, 2, 3, 4], function(n) {
* return n % 2 == 1;
* });
* // => 3
*/
var findLast = createFind(findLastIndex);
/**
* Creates a flattened array of values by running each element in `collection`
* thru `iteratee` and flattening the mapped results. The iteratee is invoked
* with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [n, n];
* }
*
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMap(collection, iteratee) {
return baseFlatten(map(collection, iteratee), 1);
}
/**
* This method is like `_.flatMap` except that it recursively flattens the
* mapped results.
*
* @static
* @memberOf _
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* _.flatMapDeep([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMapDeep(collection, iteratee) {
return baseFlatten(map(collection, iteratee), INFINITY);
}
/**
* This method is like `_.flatMap` except that it recursively flattens the
* mapped results up to `depth` times.
*
* @static
* @memberOf _
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {number} [depth=1] The maximum recursion depth.
* @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* _.flatMapDepth([1, 2], duplicate, 2);
* // => [[1, 1], [2, 2]]
*/
function flatMapDepth(collection, iteratee, depth) {
depth = depth === undefined ? 1 : toInteger(depth);
return baseFlatten(map(collection, iteratee), depth);
}
/**
* Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* **Note:** As with other "Collections" methods, objects with a "length"
* property are iterated like arrays. To avoid this behavior use `_.forIn`
* or `_.forOwn` for object iteration.
*
* @static
* @memberOf _
* @since 0.1.0
* @alias each
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
* @see _.forEachRight
* @example
*
* _.forEach([1, 2], function(value) {
* console.log(value);
* });
* // => Logs `1` then `2`.
*
* _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
* console.log(key);
* });
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/
function forEach(collection, iteratee) {
var func = isArray(collection) ? arrayEach : baseEach;
return func(collection, getIteratee(iteratee, 3));
}
/**
* This method is like `_.forEach` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberOf _
* @since 2.0.0
* @alias eachRight
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
* @see _.forEach
* @example
*
* _.forEachRight([1, 2], function(value) {
* console.log(value);
* });
* // => Logs `2` then `1`.
*/
function forEachRight(collection, iteratee) {
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, getIteratee(iteratee, 3));
}
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. The order of grouped values
* is determined by the order they occur in `collection`. The corresponding
* value of each key is an array of elements responsible for generating the
* key. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] }
*
* // The `_.property` iteratee shorthand.
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
var groupBy = createAggregator(function(result, value, key) {
if (hasOwnProperty.call(result, key)) {
result[key].push(value);
} else {
baseAssignValue(result, key, [value]);
}
});
/**
* Checks if `value` is in `collection`. If `collection` is a string, it's
* checked for a substring of `value`, otherwise
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* is used for equality comparisons. If `fromIndex` is negative, it's used as
* the offset from the end of `collection`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object|string} collection The collection to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
* @returns {boolean} Returns `true` if `value` is found, else `false`.
* @example
*
* _.includes([1, 2, 3], 1);
* // => true
*
* _.includes([1, 2, 3], 1, 2);
* // => false
*
* _.includes({ 'a': 1, 'b': 2 }, 1);
* // => true
*
* _.includes('abcd', 'bc');
* // => true
*/
function includes(collection, value, fromIndex, guard) {
collection = isArrayLike(collection) ? collection : values(collection);
fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
var length = collection.length;
if (fromIndex < 0) {
fromIndex = nativeMax(length + fromIndex, 0);
}
return isString(collection)
? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
: (!!length && baseIndexOf(collection, value, fromIndex) > -1);
}
/**
* Invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. Any additional arguments
* are provided to each invoked method. If `path` is a function, it's invoked
* for, and `this` bound to, each element in `collection`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Array|Function|string} path The path of the method to invoke or
* the function invoked per iteration.
* @param {...*} [args] The arguments to invoke each method with.
* @returns {Array} Returns the array of results.
* @example
*
* _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
* // => [[1, 5, 7], [1, 2, 3]]
*
* _.invokeMap([123, 456], String.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
var invokeMap = baseRest(function(collection, path, args) {
var index = -1,
isFunc = typeof path == 'function',
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
});
return result;
});
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. The corresponding value of
* each key is the last element responsible for generating the key. The
* iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* var array = [
* { 'dir': 'left', 'code': 97 },
* { 'dir': 'right', 'code': 100 }
* ];
*
* _.keyBy(array, function(o) {
* return String.fromCharCode(o.code);
* });
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*
* _.keyBy(array, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyBy = createAggregator(function(result, value, key) {
baseAssignValue(result, key, value);
});
/**
* Creates an array of values by running each element in `collection` thru
* `iteratee`. The iteratee is invoked with three arguments:
* (value, index|key, collection).
*
* Many lodash methods are guarded to work as iteratees for methods like
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
*
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
* @example
*
* function square(n) {
* return n * n;
* }
*
* _.map([4, 8], square);
* // => [16, 64]
*
* _.map({ 'a': 4, 'b': 8 }, square);
* // => [16, 64] (iteration order is not guaranteed)
*
* var users = [
* { 'user': 'barney' },
* { 'user': 'fred' }
* ];
*
* // The `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
function map(collection, iteratee) {
var func = isArray(collection) ? arrayMap : baseMap;
return func(collection, getIteratee(iteratee, 3));
}
/**
* This method is like `_.sortBy` except that it allows specifying the sort
* orders of the iteratees to sort by. If `orders` is unspecified, all values
* are sorted in ascending order. Otherwise, specify an order of "desc" for
* descending or "asc" for ascending sort order of corresponding values.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
* The iteratees to sort by.
* @param {string[]} [orders] The sort orders of `iteratees`.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'fred', 'age': 48 },
* { 'user': 'barney', 'age': 34 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 36 }
* ];
*
* // Sort by `user` in ascending order and by `age` in descending order.
* _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*/
function orderBy(collection, iteratees, orders, guard) {
if (collection == null) {
return [];
}
if (!isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees];
}
orders = guard ? undefined : orders;
if (!isArray(orders)) {
orders = orders == null ? [] : [orders];
}
return baseOrderBy(collection, iteratees, orders);
}
/**
* Creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, the second of which
* contains elements `predicate` returns falsey for. The predicate is
* invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the array of grouped elements.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* ];
*
* _.partition(users, function(o) { return o.active; });
* // => objects for [['fred'], ['barney', 'pebbles']]
*
* // The `_.matches` iteratee shorthand.
* _.partition(users, { 'age': 1, 'active': false });
* // => objects for [['pebbles'], ['barney', 'fred']]
*
* // The `_.matchesProperty` iteratee shorthand.
* _.partition(users, ['active', false]);
* // => objects for [['barney', 'pebbles'], ['fred']]
*
* // The `_.property` iteratee shorthand.
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
var partition = createAggregator(function(result, value, key) {
result[key ? 0 : 1].push(value);
}, function() { return [[], []]; });
/**
* Reduces `collection` to a value which is the accumulated result of running
* each element in `collection` thru `iteratee`, where each successive
* invocation is supplied the return value of the previous. If `accumulator`
* is not given, the first element of `collection` is used as the initial
* value. The iteratee is invoked with four arguments:
* (accumulator, value, index|key, collection).
*
* Many lodash methods are guarded to work as iteratees for methods like
* `_.reduce`, `_.reduceRight`, and `_.transform`.
*
* The guarded methods are:
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
* and `sortBy`
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @returns {*} Returns the accumulated value.
* @see _.reduceRight
* @example
*
* _.reduce([1, 2], function(sum, n) {
* return sum + n;
* }, 0);
* // => 3
*
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
* (result[value] || (result[value] = [])).push(key);
* return result;
* }, {});
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
*/
function reduce(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduce : baseReduce,
initAccum = arguments.length < 3;
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
}
/**
* This method is like `_.reduce` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @returns {*} Returns the accumulated value.
* @see _.reduce
* @example
*
* var array = [[0, 1], [2, 3], [4, 5]];
*
* _.reduceRight(array, function(flattened, other) {
* return flattened.concat(other);
* }, []);
* // => [4, 5, 2, 3, 0, 1]
*/
function reduceRight(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduceRight : baseReduce,
initAccum = arguments.length < 3;
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
}
/**
* The opposite of `_.filter`; this method returns the elements of `collection`
* that `predicate` does **not** return truthy for.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.filter
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true }
* ];
*
* _.reject(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // The `_.matches` iteratee shorthand.
* _.reject(users, { 'age': 40, 'active': true });
* // => objects for ['barney']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.reject(users, ['active', false]);
* // => objects for ['fred']
*
* // The `_.property` iteratee shorthand.
* _.reject(users, 'active');
* // => objects for ['barney']
*/
function reject(collection, predicate) {
var func = isArray(collection) ? arrayFilter : baseFilter;
return func(collection, negate(getIteratee(predicate, 3)));
}
/**
* Gets a random element from `collection`.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Collection
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
* @example
*
* _.sample([1, 2, 3, 4]);
* // => 2
*/
function sample(collection) {
var func = isArray(collection) ? arraySample : baseSample;
return func(collection);
}
/**
* Gets `n` random elements at unique keys from `collection` up to the
* size of `collection`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to sample.
* @param {number} [n=1] The number of elements to sample.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the random elements.
* @example
*
* _.sampleSize([1, 2, 3], 2);
* // => [3, 1]
*
* _.sampleSize([1, 2, 3], 4);
* // => [2, 3, 1]
*/
function sampleSize(collection, n, guard) {
if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
n = 1;
} else {
n = toInteger(n);
}
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
return func(collection, n);
}
/**
* Creates an array of shuffled values, using a version of the
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to shuffle.
* @returns {Array} Returns the new shuffled array.
* @example
*
* _.shuffle([1, 2, 3, 4]);
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
var func = isArray(collection) ? arrayShuffle : baseShuffle;
return func(collection);
}
/**
* Gets the size of `collection` by returning its length for array-like
* values or the number of own enumerable string keyed properties for objects.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object|string} collection The collection to inspect.
* @returns {number} Returns the collection size.
* @example
*
* _.size([1, 2, 3]);
* // => 3
*
* _.size({ 'a': 1, 'b': 2 });
* // => 2
*
* _.size('pebbles');
* // => 7
*/
function size(collection) {
if (collection == null) {
return 0;
}
if (isArrayLike(collection)) {
return isString(collection) ? stringSize(collection) : collection.length;
}
var tag = getTag(collection);
if (tag == mapTag || tag == setTag) {
return collection.size;
}
return baseKeys(collection).length;
}
/**
* Checks if `predicate` returns truthy for **any** element of `collection`.
* Iteration is stopped once `predicate` returns truthy. The predicate is
* invoked with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
* @example
*
* _.some([null, 0, 'yes', false], Boolean);
* // => true
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false }
* ];
*
* // The `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
* // The `_.matchesProperty` iteratee shorthand.
* _.some(users, ['active', false]);
* // => true
*
* // The `_.property` iteratee shorthand.
* _.some(users, 'active');
* // => true
*/
function some(collection, predicate, guard) {
var func = isArray(collection) ? arraySome : baseSome;
if (guard && isIterateeCall(collection, predicate, guard)) {
predicate = undefined;
}
return func(collection, getIteratee(predicate, 3));
}
/**
* Creates an array of elements, sorted in ascending order by the results of
* running each element in a collection thru each iteratee. This method
* performs a stable sort, that is, it preserves the original sort order of
* equal elements. The iteratees are invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Function|Function[])} [iteratees=[_.identity]]
* The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'fred', 'age': 48 },
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 34 }
* ];
*
* _.sortBy(users, [function(o) { return o.user; }]);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*
* _.sortBy(users, ['user', 'age']);
* // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
*/
var sortBy = baseRest(function(collection, iteratees) {
if (collection == null) {
return [];
}
var length = iteratees.length;
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
/*------------------------------------------------------------------------*/
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = ctxNow || function() {
return root.Date.now();
};
/*------------------------------------------------------------------------*/
/**
* The opposite of `_.before`; this method creates a function that invokes
* `func` once it's called `n` or more times.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {number} n The number of calls before `func` is invoked.
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.
* @example
*
* var saves = ['profile', 'settings'];
*
* var done = _.after(saves.length, function() {
* console.log('done saving!');
* });
*
* _.forEach(saves, function(type) {
* asyncSave({ 'type': type, 'complete': done });
* });
* // => Logs 'done saving!' after the two async saves have completed.
*/
function after(n, func) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
n = toInteger(n);
return function() {
if (--n < 1) {
return func.apply(this, arguments);
}
};
}
/**
* Creates a function that invokes `func`, with up to `n` arguments,
* ignoring any additional arguments.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Function
* @param {Function} func The function to cap arguments for.
* @param {number} [n=func.length] The arity cap.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the new capped function.
* @example
*
* _.map(['6', '8', '10'], _.ary(parseInt, 1));
* // => [6, 8, 10]
*/
function ary(func, n, guard) {
n = guard ? undefined : n;
n = (func && n == null) ? func.length : n;
return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
}
/**
* Creates a function that invokes `func`, with the `this` binding and arguments
* of the created function, while it's called less than `n` times. Subsequent
* calls to the created function return the result of the last `func` invocation.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Function
* @param {number} n The number of calls at which `func` is no longer invoked.
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.
* @example
*
* jQuery(element).on('click', _.before(5, addContactToList));
* // => Allows adding up to 4 contacts to the list.
*/
function before(n, func) {
var result;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
n = toInteger(n);
return function() {
if (--n > 0) {
result = func.apply(this, arguments);
}
if (n <= 1) {
func = undefined;
}
return result;
};
}
/**
* Creates a function that invokes `func` with the `this` binding of `thisArg`
* and `partials` prepended to the arguments it receives.
*
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for partially applied arguments.
*
* **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
* property of bound functions.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to bind.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
* function greet(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
* }
*
* var object = { 'user': 'fred' };
*
* var bound = _.bind(greet, object, 'hi');
* bound('!');
* // => 'hi fred!'
*
* // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
*/
var bind = baseRest(function(func, thisArg, partials) {
var bitmask = WRAP_BIND_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bind));
bitmask |= WRAP_PARTIAL_FLAG;
}
return createWrap(func, bitmask, thisArg, partials, holders);
});
/**
* Creates a function that invokes the method at `object[key]` with `partials`
* prepended to the arguments it receives.
*
* This method differs from `_.bind` by allowing bound functions to reference
* methods that may be redefined or don't yet exist. See
* [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
* for more details.
*
* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* @static
* @memberOf _
* @since 0.10.0
* @category Function
* @param {Object} object The object to invoke the method on.
* @param {string} key The key of the method.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
* var object = {
* 'user': 'fred',
* 'greet': function(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
* }
* };
*
* var bound = _.bindKey(object, 'greet', 'hi');
* bound('!');
* // => 'hi fred!'
*
* object.greet = function(greeting, punctuation) {
* return greeting + 'ya ' + this.user + punctuation;
* };
*
* bound('!');
* // => 'hiya fred!'
*
* // Bound with placeholders.
* var bound = _.bindKey(object, 'greet', _, '!');
* bound('hi');
* // => 'hiya fred!'
*/
var bindKey = baseRest(function(object, key, partials) {
var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bindKey));
bitmask |= WRAP_PARTIAL_FLAG;
}
return createWrap(key, bitmask, object, partials, holders);
});
/**
* Creates a function that accepts arguments of `func` and either invokes
* `func` returning its result, if at least `arity` number of arguments have
* been provided, or returns a function that accepts the remaining `func`
* arguments, and so on. The arity of `func` may be specified if `func.length`
* is not sufficient.
*
* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for provided arguments.
*
* **Note:** This method doesn't set the "length" property of curried functions.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Function
* @param {Function} func The function to curry.
* @param {number} [arity=func.length] The arity of `func`.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the new curried function.
* @example
*
* var abc = function(a, b, c) {
* return [a, b, c];
* };
*
* var curried = _.curry(abc);
*
* curried(1)(2)(3);
* // => [1, 2, 3]
*
* curried(1, 2)(3);
* // => [1, 2, 3]
*
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // Curried with placeholders.
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
function curry(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curry.placeholder;
return result;
}
/**
* This method is like `_.curry` except that arguments are applied to `func`
* in the manner of `_.partialRight` instead of `_.partial`.
*
* The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for provided arguments.
*
* **Note:** This method doesn't set the "length" property of curried functions.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Function
* @param {Function} func The function to curry.
* @param {number} [arity=func.length] The arity of `func`.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the new curried function.
* @example
*
* var abc = function(a, b, c) {
* return [a, b, c];
* };
*
* var curried = _.curryRight(abc);
*
* curried(3)(2)(1);
* // => [1, 2, 3]
*
* curried(2, 3)(1);
* // => [1, 2, 3]
*
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // Curried with placeholders.
* curried(3)(1, _)(2);
* // => [1, 2, 3]
*/
function curryRight(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryRight.placeholder;
return result;
}
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* Defers invoking the `func` until the current call stack has cleared. Any
* additional arguments are provided to `func` when it's invoked.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to defer.
* @param {...*} [args] The arguments to invoke `func` with.
* @returns {number} Returns the timer id.
* @example
*
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // => Logs 'deferred' after one millisecond.
*/
var defer = baseRest(function(func, args) {
return baseDelay(func, 1, args);
});
/**
* Invokes `func` after `wait` milliseconds. Any additional arguments are
* provided to `func` when it's invoked.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
* @param {...*} [args] The arguments to invoke `func` with.
* @returns {number} Returns the timer id.
* @example
*
* _.delay(function(text) {
* console.log(text);
* }, 1000, 'later');
* // => Logs 'later' after one second.
*/
var delay = baseRest(function(func, wait, args) {
return baseDelay(func, toNumber(wait) || 0, args);
});
/**
* Creates a function that invokes `func` with arguments reversed.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Function
* @param {Function} func The function to flip arguments for.
* @returns {Function} Returns the new flipped function.
* @example
*
* var flipped = _.flip(function() {
* return _.toArray(arguments);
* });
*
* flipped('a', 'b', 'c', 'd');
* // => ['d', 'c', 'b', 'a']
*/
function flip(func) {
return createWrap(func, WRAP_FLIP_FLAG);
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Expose `MapCache`.
memoize.Cache = MapCache;
/**
* Creates a function that negates the result of the predicate `func`. The
* `func` predicate is invoked with the `this` binding and arguments of the
* created function.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Function
* @param {Function} predicate The predicate to negate.
* @returns {Function} Returns the new negated function.
* @example
*
* function isEven(n) {
* return n % 2 == 0;
* }
*
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
* // => [1, 3, 5]
*/
function negate(predicate) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var args = arguments;
switch (args.length) {
case 0: return !predicate.call(this);
case 1: return !predicate.call(this, args[0]);
case 2: return !predicate.call(this, args[0], args[1]);
case 3: return !predicate.call(this, args[0], args[1], args[2]);
}
return !predicate.apply(this, args);
};
}
/**
* Creates a function that is restricted to invoking `func` once. Repeat calls
* to the function return the value of the first invocation. The `func` is
* invoked with the `this` binding and arguments of the created function.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.
* @example
*
* var initialize = _.once(createApplication);
* initialize();
* initialize();
* // => `createApplication` is invoked once
*/
function once(func) {
return before(2, func);
}
/**
* Creates a function that invokes `func` with its arguments transformed.
*
* @static
* @since 4.0.0
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
* @param {...(Function|Function[])} [transforms=[_.identity]]
* The argument transforms.
* @returns {Function} Returns the new function.
* @example
*
* function doubled(n) {
* return n * 2;
* }
*
* function square(n) {
* return n * n;
* }
*
* var func = _.overArgs(function(x, y) {
* return [x, y];
* }, [square, doubled]);
*
* func(9, 3);
* // => [81, 6]
*
* func(10, 5);
* // => [100, 10]
*/
var overArgs = castRest(function(func, transforms) {
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(getIteratee()))
: arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
var funcsLength = transforms.length;
return baseRest(function(args) {
var index = -1,
length = nativeMin(args.length, funcsLength);
while (++index < length) {
args[index] = transforms[index].call(this, args[index]);
}
return apply(func, this, args);
});
});
/**
* Creates a function that invokes `func` with `partials` prepended to the
* arguments it receives. This method is like `_.bind` except it does **not**
* alter the `this` binding.
*
* The `_.partial.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* **Note:** This method doesn't set the "length" property of partially
* applied functions.
*
* @static
* @memberOf _
* @since 0.2.0
* @category Function
* @param {Function} func The function to partially apply arguments to.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new partially applied function.
* @example
*
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* var sayHelloTo = _.partial(greet, 'hello');
* sayHelloTo('fred');
* // => 'hello fred'
*
* // Partially applied with placeholders.
* var greetFred = _.partial(greet, _, 'fred');
* greetFred('hi');
* // => 'hi fred'
*/
var partial = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partial));
return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
});
/**
* This method is like `_.partial` except that partially applied arguments
* are appended to the arguments it receives.
*
* The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* **Note:** This method doesn't set the "length" property of partially
* applied functions.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Function
* @param {Function} func The function to partially apply arguments to.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new partially applied function.
* @example
*
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* var greetFred = _.partialRight(greet, 'fred');
* greetFred('hi');
* // => 'hi fred'
*
* // Partially applied with placeholders.
* var sayHelloTo = _.partialRight(greet, 'hello', _);
* sayHelloTo('fred');
* // => 'hello fred'
*/
var partialRight = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partialRight));
return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
});
/**
* Creates a function that invokes `func` with arguments arranged according
* to the specified `indexes` where the argument value at the first index is
* provided as the first argument, the argument value at the second index is
* provided as the second argument, and so on.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
* @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*
* var rearged = _.rearg(function(a, b, c) {
* return [a, b, c];
* }, [2, 0, 1]);
*
* rearged('b', 'c', 'a')
* // => ['a', 'b', 'c']
*/
var rearg = flatRest(function(func, indexes) {
return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
});
/**
* Creates a function that invokes `func` with the `this` binding of the
* created function and arguments from `start` and beyond provided as
* an array.
*
* **Note:** This method is based on the
* [rest parameter](https://mdn.io/rest_parameters).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Function
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
* @example
*
* var say = _.rest(function(what, names) {
* return what + ' ' + _.initial(names).join(', ') +
* (_.size(names) > 1 ? ', & ' : '') + _.last(names);
* });
*
* say('hello', 'fred', 'barney', 'pebbles');
* // => 'hello fred, barney, & pebbles'
*/
function rest(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
start = start === undefined ? start : toInteger(start);
return baseRest(func, start);
}
/**
* Creates a function that invokes `func` with the `this` binding of the
* create function and an array of arguments much like
* [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
*
* **Note:** This method is based on the
* [spread operator](https://mdn.io/spread_operator).
*
* @static
* @memberOf _
* @since 3.2.0
* @category Function
* @param {Function} func The function to spread arguments over.
* @param {number} [start=0] The start position of the spread.
* @returns {Function} Returns the new function.
* @example
*
* var say = _.spread(function(who, what) {
* return who + ' says ' + what;
* });
*
* say(['fred', 'hello']);
* // => 'fred says hello'
*
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
* ]);
*
* numbers.then(_.spread(function(x, y) {
* return x + y;
* }));
* // => a Promise of 76
*/
function spread(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
start = start == null ? 0 : nativeMax(toInteger(start), 0);
return baseRest(function(args) {
var array = args[start],
otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);
}
return apply(func, this, otherArgs);
});
}
/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
* immediately invoke them. Provide `options` to indicate whether `func`
* should be invoked on the leading and/or trailing edge of the `wait`
* timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to throttle.
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=true]
* Specify invoking on the leading edge of the timeout.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new throttled function.
* @example
*
* // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled);
*
* // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel);
*/
function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (isObject(options)) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
return debounce(func, wait, {
'leading': leading,
'maxWait': wait,
'trailing': trailing
});
}
/**
* Creates a function that accepts up to one argument, ignoring any
* additional arguments.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Function
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
* @example
*
* _.map(['6', '8', '10'], _.unary(parseInt));
* // => [6, 8, 10]
*/
function unary(func) {
return ary(func, 1);
}
/**
* Creates a function that provides `value` to `wrapper` as its first
* argument. Any additional arguments provided to the function are appended
* to those provided to the `wrapper`. The wrapper is invoked with the `this`
* binding of the created function.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {*} value The value to wrap.
* @param {Function} [wrapper=identity] The wrapper function.
* @returns {Function} Returns the new function.
* @example
*
* var p = _.wrap(_.escape, function(func, text) {
* return '' + func(text) + '
';
* });
*
* p('fred, barney, & pebbles');
* // => 'fred, barney, & pebbles
'
*/
function wrap(value, wrapper) {
return partial(castFunction(wrapper), value);
}
/*------------------------------------------------------------------------*/
/**
* Casts `value` as an array if it's not one.
*
* @static
* @memberOf _
* @since 4.4.0
* @category Lang
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast array.
* @example
*
* _.castArray(1);
* // => [1]
*
* _.castArray({ 'a': 1 });
* // => [{ 'a': 1 }]
*
* _.castArray('abc');
* // => ['abc']
*
* _.castArray(null);
* // => [null]
*
* _.castArray(undefined);
* // => [undefined]
*
* _.castArray();
* // => []
*
* var array = [1, 2, 3];
* console.log(_.castArray(array) === array);
* // => true
*/
function castArray() {
if (!arguments.length) {
return [];
}
var value = arguments[0];
return isArray(value) ? value : [value];
}
/**
* Creates a shallow clone of `value`.
*
* **Note:** This method is loosely based on the
* [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
* and supports cloning arrays, array buffers, booleans, date objects, maps,
* numbers, `Object` objects, regexes, sets, strings, symbols, and typed
* arrays. The own enumerable properties of `arguments` objects are cloned
* as plain objects. An empty object is returned for uncloneable values such
* as error objects, functions, DOM nodes, and WeakMaps.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to clone.
* @returns {*} Returns the cloned value.
* @see _.cloneDeep
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];
*
* var shallow = _.clone(objects);
* console.log(shallow[0] === objects[0]);
* // => true
*/
function clone(value) {
return baseClone(value, CLONE_SYMBOLS_FLAG);
}
/**
* This method is like `_.clone` except that it accepts `customizer` which
* is invoked to produce the cloned value. If `customizer` returns `undefined`,
* cloning is handled by the method instead. The `customizer` is invoked with
* up to four arguments; (value [, index|key, object, stack]).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to clone.
* @param {Function} [customizer] The function to customize cloning.
* @returns {*} Returns the cloned value.
* @see _.cloneDeepWith
* @example
*
* function customizer(value) {
* if (_.isElement(value)) {
* return value.cloneNode(false);
* }
* }
*
* var el = _.cloneWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false
* console.log(el.nodeName);
* // => 'BODY'
* console.log(el.childNodes.length);
* // => 0
*/
function cloneWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
}
/**
* This method is like `_.clone` except that it recursively clones `value`.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Lang
* @param {*} value The value to recursively clone.
* @returns {*} Returns the deep cloned value.
* @see _.clone
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];
*
* var deep = _.cloneDeep(objects);
* console.log(deep[0] === objects[0]);
* // => false
*/
function cloneDeep(value) {
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
}
/**
* This method is like `_.cloneWith` except that it recursively clones `value`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to recursively clone.
* @param {Function} [customizer] The function to customize cloning.
* @returns {*} Returns the deep cloned value.
* @see _.cloneWith
* @example
*
* function customizer(value) {
* if (_.isElement(value)) {
* return value.cloneNode(true);
* }
* }
*
* var el = _.cloneDeepWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false
* console.log(el.nodeName);
* // => 'BODY'
* console.log(el.childNodes.length);
* // => 20
*/
function cloneDeepWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
}
/**
* Checks if `object` conforms to `source` by invoking the predicate
* properties of `source` with the corresponding property values of `object`.
*
* **Note:** This method is equivalent to `_.conforms` when `source` is
* partially applied.
*
* @static
* @memberOf _
* @since 4.14.0
* @category Lang
* @param {Object} object The object to inspect.
* @param {Object} source The object of property predicates to conform to.
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
* @example
*
* var object = { 'a': 1, 'b': 2 };
*
* _.conformsTo(object, { 'b': function(n) { return n > 1; } });
* // => true
*
* _.conformsTo(object, { 'b': function(n) { return n > 2; } });
* // => false
*/
function conformsTo(object, source) {
return source == null || baseConformsTo(object, source, keys(source));
}
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
}
/**
* Checks if `value` is greater than `other`.
*
* @static
* @memberOf _
* @since 3.9.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
* @see _.lt
* @example
*
* _.gt(3, 1);
* // => true
*
* _.gt(3, 3);
* // => false
*
* _.gt(1, 3);
* // => false
*/
var gt = createRelationalOperation(baseGt);
/**
* Checks if `value` is greater than or equal to `other`.
*
* @static
* @memberOf _
* @since 3.9.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than or equal to
* `other`, else `false`.
* @see _.lte
* @example
*
* _.gte(3, 1);
* // => true
*
* _.gte(3, 3);
* // => true
*
* _.gte(1, 3);
* // => false
*/
var gte = createRelationalOperation(function(value, other) {
return value >= other;
});
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/**
* Checks if `value` is classified as an `ArrayBuffer` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
* @example
*
* _.isArrayBuffer(new ArrayBuffer(2));
* // => true
*
* _.isArrayBuffer(new Array(2));
* // => false
*/
var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
/**
* This method is like `_.isArrayLike` except that it also checks if `value`
* is an object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object,
* else `false`.
* @example
*
* _.isArrayLikeObject([1, 2, 3]);
* // => true
*
* _.isArrayLikeObject(document.body.children);
* // => true
*
* _.isArrayLikeObject('abc');
* // => false
*
* _.isArrayLikeObject(_.noop);
* // => false
*/
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
/**
* Checks if `value` is classified as a boolean primitive or object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
* @example
*
* _.isBoolean(false);
* // => true
*
* _.isBoolean(null);
* // => false
*/
function isBoolean(value) {
return value === true || value === false ||
(isObjectLike(value) && baseGetTag(value) == boolTag);
}
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
/**
* Checks if `value` is classified as a `Date` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* _.isDate(new Date);
* // => true
*
* _.isDate('Mon April 23 2012');
* // => false
*/
var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
/**
* Checks if `value` is likely a DOM element.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
* @example
*
* _.isElement(document.body);
* // => true
*
* _.isElement('');
* // => false
*/
function isElement(value) {
return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
}
/**
* Checks if `value` is an empty object, collection, map, or set.
*
* Objects are considered empty if they have no own enumerable string keyed
* properties.
*
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
* jQuery-like collections are considered empty if they have a `length` of `0`.
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
* @example
*
* _.isEmpty(null);
* // => true
*
* _.isEmpty(true);
* // => true
*
* _.isEmpty(1);
* // => true
*
* _.isEmpty([1, 2, 3]);
* // => false
*
* _.isEmpty({ 'a': 1 });
* // => false
*/
function isEmpty(value) {
if (value == null) {
return true;
}
if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
var tag = getTag(value);
if (tag == mapTag || tag == setTag) {
return !value.size;
}
if (isPrototype(value)) {
return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {
return false;
}
}
return true;
}
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
function isEqual(value, other) {
return baseIsEqual(value, other);
}
/**
* This method is like `_.isEqual` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
* are handled by the method instead. The `customizer` is invoked with up to
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {Function} [customizer] The function to customize comparisons.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* function isGreeting(value) {
* return /^h(?:i|ello)$/.test(value);
* }
*
* function customizer(objValue, othValue) {
* if (isGreeting(objValue) && isGreeting(othValue)) {
* return true;
* }
* }
*
* var array = ['hello', 'goodbye'];
* var other = ['hi', 'goodbye'];
*
* _.isEqualWith(array, other, customizer);
* // => true
*/
function isEqualWith(value, other, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
var result = customizer ? customizer(value, other) : undefined;
return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
}
/**
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
* `SyntaxError`, `TypeError`, or `URIError` object.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an error object, else `false`.
* @example
*
* _.isError(new Error);
* // => true
*
* _.isError(Error);
* // => false
*/
function isError(value) {
if (!isObjectLike(value)) {
return false;
}
var tag = baseGetTag(value);
return tag == errorTag || tag == domExcTag ||
(typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
}
/**
* Checks if `value` is a finite primitive number.
*
* **Note:** This method is based on
* [`Number.isFinite`](https://mdn.io/Number/isFinite).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
* @example
*
* _.isFinite(3);
* // => true
*
* _.isFinite(Number.MIN_VALUE);
* // => true
*
* _.isFinite(Infinity);
* // => false
*
* _.isFinite('3');
* // => false
*/
function isFinite(value) {
return typeof value == 'number' && nativeIsFinite(value);
}
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
/**
* Checks if `value` is an integer.
*
* **Note:** This method is based on
* [`Number.isInteger`](https://mdn.io/Number/isInteger).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
* @example
*
* _.isInteger(3);
* // => true
*
* _.isInteger(Number.MIN_VALUE);
* // => false
*
* _.isInteger(Infinity);
* // => false
*
* _.isInteger('3');
* // => false
*/
function isInteger(value) {
return typeof value == 'number' && value == toInteger(value);
}
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/**
* Checks if `value` is classified as a `Map` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
* @example
*
* _.isMap(new Map);
* // => true
*
* _.isMap(new WeakMap);
* // => false
*/
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
/**
* Performs a partial deep comparison between `object` and `source` to
* determine if `object` contains equivalent property values.
*
* **Note:** This method is equivalent to `_.matches` when `source` is
* partially applied.
*
* Partial comparisons will match empty array and empty object `source`
* values against any array or object value, respectively. See `_.isEqual`
* for a list of supported value comparisons.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {Object} object The object to inspect.
* @param {Object} source The object of property values to match.
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
* @example
*
* var object = { 'a': 1, 'b': 2 };
*
* _.isMatch(object, { 'b': 2 });
* // => true
*
* _.isMatch(object, { 'b': 1 });
* // => false
*/
function isMatch(object, source) {
return object === source || baseIsMatch(object, source, getMatchData(source));
}
/**
* This method is like `_.isMatch` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
* are handled by the method instead. The `customizer` is invoked with five
* arguments: (objValue, srcValue, index|key, object, source).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {Object} object The object to inspect.
* @param {Object} source The object of property values to match.
* @param {Function} [customizer] The function to customize comparisons.
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
* @example
*
* function isGreeting(value) {
* return /^h(?:i|ello)$/.test(value);
* }
*
* function customizer(objValue, srcValue) {
* if (isGreeting(objValue) && isGreeting(srcValue)) {
* return true;
* }
* }
*
* var object = { 'greeting': 'hello' };
* var source = { 'greeting': 'hi' };
*
* _.isMatchWith(object, source, customizer);
* // => true
*/
function isMatchWith(object, source, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseIsMatch(object, source, getMatchData(source), customizer);
}
/**
* Checks if `value` is `NaN`.
*
* **Note:** This method is based on
* [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
* global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
* `undefined` and other non-number values.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
* @example
*
* _.isNaN(NaN);
* // => true
*
* _.isNaN(new Number(NaN));
* // => true
*
* isNaN(undefined);
* // => true
*
* _.isNaN(undefined);
* // => false
*/
function isNaN(value) {
// An `NaN` primitive is the only value that is not equal to itself.
// Perform the `toStringTag` check first to avoid errors with some
// ActiveX objects in IE.
return isNumber(value) && value != +value;
}
/**
* Checks if `value` is a pristine native function.
*
* **Note:** This method can't reliably detect native functions in the presence
* of the core-js package because core-js circumvents this kind of detection.
* Despite multiple requests, the core-js maintainer has made it clear: any
* attempt to fix the detection will be obstructed. As a result, we're left
* with little choice but to throw an error. Unfortunately, this also affects
* packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
* which rely on core-js.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
* @example
*
* _.isNative(Array.prototype.push);
* // => true
*
* _.isNative(_);
* // => false
*/
function isNative(value) {
if (isMaskable(value)) {
throw new Error(CORE_ERROR_TEXT);
}
return baseIsNative(value);
}
/**
* Checks if `value` is `null`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `null`, else `false`.
* @example
*
* _.isNull(null);
* // => true
*
* _.isNull(void 0);
* // => false
*/
function isNull(value) {
return value === null;
}
/**
* Checks if `value` is `null` or `undefined`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
* @example
*
* _.isNil(null);
* // => true
*
* _.isNil(void 0);
* // => true
*
* _.isNil(NaN);
* // => false
*/
function isNil(value) {
return value == null;
}
/**
* Checks if `value` is classified as a `Number` primitive or object.
*
* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
* classified as numbers, use the `_.isFinite` method.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a number, else `false`.
* @example
*
* _.isNumber(3);
* // => true
*
* _.isNumber(Number.MIN_VALUE);
* // => true
*
* _.isNumber(Infinity);
* // => true
*
* _.isNumber('3');
* // => false
*/
function isNumber(value) {
return typeof value == 'number' ||
(isObjectLike(value) && baseGetTag(value) == numberTag);
}
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
return false;
}
var proto = getPrototype(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) == objectCtorString;
}
/**
* Checks if `value` is classified as a `RegExp` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
* @example
*
* _.isRegExp(/abc/);
* // => true
*
* _.isRegExp('/abc/');
* // => false
*/
var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
/**
* Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
* double precision number which isn't the result of a rounded unsafe integer.
*
* **Note:** This method is based on
* [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
* @example
*
* _.isSafeInteger(3);
* // => true
*
* _.isSafeInteger(Number.MIN_VALUE);
* // => false
*
* _.isSafeInteger(Infinity);
* // => false
*
* _.isSafeInteger('3');
* // => false
*/
function isSafeInteger(value) {
return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is classified as a `Set` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
* @example
*
* _.isSet(new Set);
* // => true
*
* _.isSet(new WeakSet);
* // => false
*/
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
/**
* Checks if `value` is classified as a `String` primitive or object.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
* // => true
*
* _.isString(1);
* // => false
*/
function isString(value) {
return typeof value == 'string' ||
(!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
}
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
/**
* Checks if `value` is `undefined`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
* @example
*
* _.isUndefined(void 0);
* // => true
*
* _.isUndefined(null);
* // => false
*/
function isUndefined(value) {
return value === undefined;
}
/**
* Checks if `value` is classified as a `WeakMap` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
* @example
*
* _.isWeakMap(new WeakMap);
* // => true
*
* _.isWeakMap(new Map);
* // => false
*/
function isWeakMap(value) {
return isObjectLike(value) && getTag(value) == weakMapTag;
}
/**
* Checks if `value` is classified as a `WeakSet` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
* @example
*
* _.isWeakSet(new WeakSet);
* // => true
*
* _.isWeakSet(new Set);
* // => false
*/
function isWeakSet(value) {
return isObjectLike(value) && baseGetTag(value) == weakSetTag;
}
/**
* Checks if `value` is less than `other`.
*
* @static
* @memberOf _
* @since 3.9.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
* @see _.gt
* @example
*
* _.lt(1, 3);
* // => true
*
* _.lt(3, 3);
* // => false
*
* _.lt(3, 1);
* // => false
*/
var lt = createRelationalOperation(baseLt);
/**
* Checks if `value` is less than or equal to `other`.
*
* @static
* @memberOf _
* @since 3.9.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than or equal to
* `other`, else `false`.
* @see _.gte
* @example
*
* _.lte(1, 3);
* // => true
*
* _.lte(3, 3);
* // => true
*
* _.lte(3, 1);
* // => false
*/
var lte = createRelationalOperation(function(value, other) {
return value <= other;
});
/**
* Converts `value` to an array.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to convert.
* @returns {Array} Returns the converted array.
* @example
*
* _.toArray({ 'a': 1, 'b': 2 });
* // => [1, 2]
*
* _.toArray('abc');
* // => ['a', 'b', 'c']
*
* _.toArray(1);
* // => []
*
* _.toArray(null);
* // => []
*/
function toArray(value) {
if (!value) {
return [];
}
if (isArrayLike(value)) {
return isString(value) ? stringToArray(value) : copyArray(value);
}
if (symIterator && value[symIterator]) {
return iteratorToArray(value[symIterator]());
}
var tag = getTag(value),
func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
return func(value);
}
/**
* Converts `value` to a finite number.
*
* @static
* @memberOf _
* @since 4.12.0
* @category Lang
* @param {*} value The value to convert.
* @returns {number} Returns the converted number.
* @example
*
* _.toFinite(3.2);
* // => 3.2
*
* _.toFinite(Number.MIN_VALUE);
* // => 5e-324
*
* _.toFinite(Infinity);
* // => 1.7976931348623157e+308
*
* _.toFinite('3.2');
* // => 3.2
*/
function toFinite(value) {
if (!value) {
return value === 0 ? value : 0;
}
value = toNumber(value);
if (value === INFINITY || value === -INFINITY) {
var sign = (value < 0 ? -1 : 1);
return sign * MAX_INTEGER;
}
return value === value ? value : 0;
}
/**
* Converts `value` to an integer.
*
* **Note:** This method is loosely based on
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {number} Returns the converted integer.
* @example
*
* _.toInteger(3.2);
* // => 3
*
* _.toInteger(Number.MIN_VALUE);
* // => 0
*
* _.toInteger(Infinity);
* // => 1.7976931348623157e+308
*
* _.toInteger('3.2');
* // => 3
*/
function toInteger(value) {
var result = toFinite(value),
remainder = result % 1;
return result === result ? (remainder ? result - remainder : result) : 0;
}
/**
* Converts `value` to an integer suitable for use as the length of an
* array-like object.
*
* **Note:** This method is based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {number} Returns the converted integer.
* @example
*
* _.toLength(3.2);
* // => 3
*
* _.toLength(Number.MIN_VALUE);
* // => 0
*
* _.toLength(Infinity);
* // => 4294967295
*
* _.toLength('3.2');
* // => 3
*/
function toLength(value) {
return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
}
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
/**
* Converts `value` to a plain object flattening inherited enumerable string
* keyed properties of `value` to own properties of the plain object.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {Object} Returns the converted plain object.
* @example
*
* function Foo() {
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.assign({ 'a': 1 }, new Foo);
* // => { 'a': 1, 'b': 2 }
*
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
* // => { 'a': 1, 'b': 2, 'c': 3 }
*/
function toPlainObject(value) {
return copyObject(value, keysIn(value));
}
/**
* Converts `value` to a safe integer. A safe integer can be compared and
* represented correctly.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {number} Returns the converted integer.
* @example
*
* _.toSafeInteger(3.2);
* // => 3
*
* _.toSafeInteger(Number.MIN_VALUE);
* // => 0
*
* _.toSafeInteger(Infinity);
* // => 9007199254740991
*
* _.toSafeInteger('3.2');
* // => 3
*/
function toSafeInteger(value) {
return value
? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
: (value === 0 ? value : 0);
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/*------------------------------------------------------------------------*/
/**
* Assigns own enumerable string keyed properties of source objects to the
* destination object. Source objects are applied from left to right.
* Subsequent sources overwrite property assignments of previous sources.
*
* **Note:** This method mutates `object` and is loosely based on
* [`Object.assign`](https://mdn.io/Object/assign).
*
* @static
* @memberOf _
* @since 0.10.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.assignIn
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* function Bar() {
* this.c = 3;
* }
*
* Foo.prototype.b = 2;
* Bar.prototype.d = 4;
*
* _.assign({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'c': 3 }
*/
var assign = createAssigner(function(object, source) {
if (isPrototype(source) || isArrayLike(source)) {
copyObject(source, keys(source), object);
return;
}
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
assignValue(object, key, source[key]);
}
}
});
/**
* This method is like `_.assign` except that it iterates over own and
* inherited source properties.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @alias extend
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.assign
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* function Bar() {
* this.c = 3;
* }
*
* Foo.prototype.b = 2;
* Bar.prototype.d = 4;
*
* _.assignIn({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/
var assignIn = createAssigner(function(object, source) {
copyObject(source, keysIn(source), object);
});
/**
* This method is like `_.assignIn` except that it accepts `customizer`
* which is invoked to produce the assigned values. If `customizer` returns
* `undefined`, assignment is handled by the method instead. The `customizer`
* is invoked with five arguments: (objValue, srcValue, key, object, source).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @alias extendWith
* @category Object
* @param {Object} object The destination object.
* @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @see _.assignWith
* @example
*
* function customizer(objValue, srcValue) {
* return _.isUndefined(objValue) ? srcValue : objValue;
* }
*
* var defaults = _.partialRight(_.assignInWith, customizer);
*
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObject(source, keysIn(source), object, customizer);
});
/**
* This method is like `_.assign` except that it accepts `customizer`
* which is invoked to produce the assigned values. If `customizer` returns
* `undefined`, assignment is handled by the method instead. The `customizer`
* is invoked with five arguments: (objValue, srcValue, key, object, source).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @see _.assignInWith
* @example
*
* function customizer(objValue, srcValue) {
* return _.isUndefined(objValue) ? srcValue : objValue;
* }
*
* var defaults = _.partialRight(_.assignWith, customizer);
*
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObject(source, keys(source), object, customizer);
});
/**
* Creates an array of values corresponding to `paths` of `object`.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Array} Returns the picked values.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
*
* _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4]
*/
var at = flatRest(baseAt);
/**
* Creates an object that inherits from the `prototype` object. If a
* `properties` object is given, its own enumerable string keyed properties
* are assigned to the created object.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Object
* @param {Object} prototype The object to inherit from.
* @param {Object} [properties] The properties to assign to the object.
* @returns {Object} Returns the new object.
* @example
*
* function Shape() {
* this.x = 0;
* this.y = 0;
* }
*
* function Circle() {
* Shape.call(this);
* }
*
* Circle.prototype = _.create(Shape.prototype, {
* 'constructor': Circle
* });
*
* var circle = new Circle;
* circle instanceof Circle;
* // => true
*
* circle instanceof Shape;
* // => true
*/
function create(prototype, properties) {
var result = baseCreate(prototype);
return properties == null ? result : baseAssign(result, properties);
}
/**
* Assigns own and inherited enumerable string keyed properties of source
* objects to the destination object for all destination properties that
* resolve to `undefined`. Source objects are applied from left to right.
* Once a property is set, additional values of the same property are ignored.
*
* **Note:** This method mutates `object`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.defaultsDeep
* @example
*
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var defaults = baseRest(function(args) {
args.push(undefined, customDefaultsAssignIn);
return apply(assignInWith, undefined, args);
});
/**
* This method is like `_.defaults` except that it recursively assigns
* default properties.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 3.10.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.defaults
* @example
*
* _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
* // => { 'a': { 'b': 2, 'c': 3 } }
*/
var defaultsDeep = baseRest(function(args) {
args.push(undefined, customDefaultsMerge);
return apply(mergeWith, undefined, args);
});
/**
* This method is like `_.find` except that it returns the key of the first
* element `predicate` returns truthy for instead of the element itself.
*
* @static
* @memberOf _
* @since 1.1.0
* @category Object
* @param {Object} object The object to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {string|undefined} Returns the key of the matched element,
* else `undefined`.
* @example
*
* var users = {
* 'barney': { 'age': 36, 'active': true },
* 'fred': { 'age': 40, 'active': false },
* 'pebbles': { 'age': 1, 'active': true }
* };
*
* _.findKey(users, function(o) { return o.age < 40; });
* // => 'barney' (iteration order is not guaranteed)
*
* // The `_.matches` iteratee shorthand.
* _.findKey(users, { 'age': 1, 'active': true });
* // => 'pebbles'
*
* // The `_.matchesProperty` iteratee shorthand.
* _.findKey(users, ['active', false]);
* // => 'fred'
*
* // The `_.property` iteratee shorthand.
* _.findKey(users, 'active');
* // => 'barney'
*/
function findKey(object, predicate) {
return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
}
/**
* This method is like `_.findKey` except that it iterates over elements of
* a collection in the opposite order.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Object
* @param {Object} object The object to inspect.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {string|undefined} Returns the key of the matched element,
* else `undefined`.
* @example
*
* var users = {
* 'barney': { 'age': 36, 'active': true },
* 'fred': { 'age': 40, 'active': false },
* 'pebbles': { 'age': 1, 'active': true }
* };
*
* _.findLastKey(users, function(o) { return o.age < 40; });
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
*
* // The `_.matches` iteratee shorthand.
* _.findLastKey(users, { 'age': 36, 'active': true });
* // => 'barney'
*
* // The `_.matchesProperty` iteratee shorthand.
* _.findLastKey(users, ['active', false]);
* // => 'fred'
*
* // The `_.property` iteratee shorthand.
* _.findLastKey(users, 'active');
* // => 'pebbles'
*/
function findLastKey(object, predicate) {
return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
}
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
* @since 0.3.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forInRight
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.forIn(new Foo, function(value, key) {
* console.log(key);
* });
* // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
*/
function forIn(object, iteratee) {
return object == null
? object
: baseFor(object, getIteratee(iteratee, 3), keysIn);
}
/**
* This method is like `_.forIn` except that it iterates over properties of
* `object` in the opposite order.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forIn
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.forInRight(new Foo, function(value, key) {
* console.log(key);
* });
* // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
*/
function forInRight(object, iteratee) {
return object == null
? object
: baseForRight(object, getIteratee(iteratee, 3), keysIn);
}
/**
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
*
* @static
* @memberOf _
* @since 0.3.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forOwnRight
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.forOwn(new Foo, function(value, key) {
* console.log(key);
* });
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/
function forOwn(object, iteratee) {
return object && baseForOwn(object, getIteratee(iteratee, 3));
}
/**
* This method is like `_.forOwn` except that it iterates over properties of
* `object` in the opposite order.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forOwn
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.forOwnRight(new Foo, function(value, key) {
* console.log(key);
* });
* // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
*/
function forOwnRight(object, iteratee) {
return object && baseForOwnRight(object, getIteratee(iteratee, 3));
}
/**
* Creates an array of function property names from own enumerable properties
* of `object`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the function names.
* @see _.functionsIn
* @example
*
* function Foo() {
* this.a = _.constant('a');
* this.b = _.constant('b');
* }
*
* Foo.prototype.c = _.constant('c');
*
* _.functions(new Foo);
* // => ['a', 'b']
*/
function functions(object) {
return object == null ? [] : baseFunctions(object, keys(object));
}
/**
* Creates an array of function property names from own and inherited
* enumerable properties of `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the function names.
* @see _.functions
* @example
*
* function Foo() {
* this.a = _.constant('a');
* this.b = _.constant('b');
* }
*
* Foo.prototype.c = _.constant('c');
*
* _.functionsIn(new Foo);
* // => ['a', 'b', 'c']
*/
function functionsIn(object) {
return object == null ? [] : baseFunctions(object, keysIn(object));
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
/**
* Checks if `path` is a direct property of `object`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = { 'a': { 'b': 2 } };
* var other = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.has(object, 'a');
* // => true
*
* _.has(object, 'a.b');
* // => true
*
* _.has(object, ['a', 'b']);
* // => true
*
* _.has(other, 'a');
* // => false
*/
function has(object, path) {
return object != null && hasPath(object, path, baseHas);
}
/**
* Checks if `path` is a direct or inherited property of `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.hasIn(object, 'a');
* // => true
*
* _.hasIn(object, 'a.b');
* // => true
*
* _.hasIn(object, ['a', 'b']);
* // => true
*
* _.hasIn(object, 'b');
* // => false
*/
function hasIn(object, path) {
return object != null && hasPath(object, path, baseHasIn);
}
/**
* Creates an object composed of the inverted keys and values of `object`.
* If `object` contains duplicate values, subsequent values overwrite
* property assignments of previous values.
*
* @static
* @memberOf _
* @since 0.7.0
* @category Object
* @param {Object} object The object to invert.
* @returns {Object} Returns the new inverted object.
* @example
*
* var object = { 'a': 1, 'b': 2, 'c': 1 };
*
* _.invert(object);
* // => { '1': 'c', '2': 'b' }
*/
var invert = createInverter(function(result, value, key) {
result[value] = key;
}, constant(identity));
/**
* This method is like `_.invert` except that the inverted object is generated
* from the results of running each element of `object` thru `iteratee`. The
* corresponding inverted value of each inverted key is an array of keys
* responsible for generating the inverted value. The iteratee is invoked
* with one argument: (value).
*
* @static
* @memberOf _
* @since 4.1.0
* @category Object
* @param {Object} object The object to invert.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Object} Returns the new inverted object.
* @example
*
* var object = { 'a': 1, 'b': 2, 'c': 1 };
*
* _.invertBy(object);
* // => { '1': ['a', 'c'], '2': ['b'] }
*
* _.invertBy(object, function(value) {
* return 'group' + value;
* });
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
*/
var invertBy = createInverter(function(result, value, key) {
if (hasOwnProperty.call(result, value)) {
result[value].push(key);
} else {
result[value] = [key];
}
}, getIteratee);
/**
* Invokes the method at `path` of `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
* @param {...*} [args] The arguments to invoke the method with.
* @returns {*} Returns the result of the invoked method.
* @example
*
* var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
*
* _.invoke(object, 'a[0].b.c.slice', 1, 3);
* // => [2, 3]
*/
var invoke = baseRest(baseInvoke);
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
/**
* Creates an array of the own and inherited enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keysIn(new Foo);
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
*/
function keysIn(object) {
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
}
/**
* The opposite of `_.mapValues`; this method creates an object with the
* same values as `object` and keys generated by running each own enumerable
* string keyed property of `object` thru `iteratee`. The iteratee is invoked
* with three arguments: (value, key, object).
*
* @static
* @memberOf _
* @since 3.8.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns the new mapped object.
* @see _.mapValues
* @example
*
* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
* return key + value;
* });
* // => { 'a1': 1, 'b2': 2 }
*/
function mapKeys(object, iteratee) {
var result = {};
iteratee = getIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
baseAssignValue(result, iteratee(value, key, object), value);
});
return result;
}
/**
* Creates an object with the same keys as `object` and values generated
* by running each own enumerable string keyed property of `object` thru
* `iteratee`. The iteratee is invoked with three arguments:
* (value, key, object).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns the new mapped object.
* @see _.mapKeys
* @example
*
* var users = {
* 'fred': { 'user': 'fred', 'age': 40 },
* 'pebbles': { 'user': 'pebbles', 'age': 1 }
* };
*
* _.mapValues(users, function(o) { return o.age; });
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*
* // The `_.property` iteratee shorthand.
* _.mapValues(users, 'age');
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*/
function mapValues(object, iteratee) {
var result = {};
iteratee = getIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
baseAssignValue(result, key, iteratee(value, key, object));
});
return result;
}
/**
* This method is like `_.assign` except that it recursively merges own and
* inherited enumerable string keyed properties of source objects into the
* destination object. Source properties that resolve to `undefined` are
* skipped if a destination value exists. Array and plain object properties
* are merged recursively. Other objects and value types are overridden by
* assignment. Source objects are applied from left to right. Subsequent
* sources overwrite property assignments of previous sources.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 0.5.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @example
*
* var object = {
* 'a': [{ 'b': 2 }, { 'd': 4 }]
* };
*
* var other = {
* 'a': [{ 'c': 3 }, { 'e': 5 }]
* };
*
* _.merge(object, other);
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
*/
var merge = createAssigner(function(object, source, srcIndex) {
baseMerge(object, source, srcIndex);
});
/**
* This method is like `_.merge` except that it accepts `customizer` which
* is invoked to produce the merged values of the destination and source
* properties. If `customizer` returns `undefined`, merging is handled by the
* method instead. The `customizer` is invoked with six arguments:
* (objValue, srcValue, key, object, source, stack).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} sources The source objects.
* @param {Function} customizer The function to customize assigned values.
* @returns {Object} Returns `object`.
* @example
*
* function customizer(objValue, srcValue) {
* if (_.isArray(objValue)) {
* return objValue.concat(srcValue);
* }
* }
*
* var object = { 'a': [1], 'b': [2] };
* var other = { 'a': [3], 'b': [4] };
*
* _.mergeWith(object, other, customizer);
* // => { 'a': [1, 3], 'b': [2, 4] }
*/
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
baseMerge(object, source, srcIndex, customizer);
});
/**
* The opposite of `_.pick`; this method creates an object composed of the
* own and inherited enumerable property paths of `object` that are not omitted.
*
* **Note:** This method is considerably slower than `_.pick`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [paths] The property paths to omit.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
*
* _.omit(object, ['a', 'c']);
* // => { 'b': '2' }
*/
var omit = flatRest(function(object, paths) {
var result = {};
if (object == null) {
return result;
}
var isDeep = false;
paths = arrayMap(paths, function(path) {
path = castPath(path, object);
isDeep || (isDeep = path.length > 1);
return path;
});
copyObject(object, getAllKeysIn(object), result);
if (isDeep) {
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
}
var length = paths.length;
while (length--) {
baseUnset(result, paths[length]);
}
return result;
});
/**
* The opposite of `_.pickBy`; this method creates an object composed of
* the own and inherited enumerable string keyed properties of `object` that
* `predicate` doesn't return truthy for. The predicate is invoked with two
* arguments: (value, key).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The source object.
* @param {Function} [predicate=_.identity] The function invoked per property.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
*
* _.omitBy(object, _.isNumber);
* // => { 'b': '2' }
*/
function omitBy(object, predicate) {
return pickBy(object, negate(getIteratee(predicate)));
}
/**
* Creates an object composed of the picked `object` properties.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
*
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
var pick = flatRest(function(object, paths) {
return object == null ? {} : basePick(object, paths);
});
/**
* Creates an object composed of the `object` properties `predicate` returns
* truthy for. The predicate is invoked with two arguments: (value, key).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The source object.
* @param {Function} [predicate=_.identity] The function invoked per property.
* @returns {Object} Returns the new object.
* @example
*
* var object = { 'a': 1, 'b': '2', 'c': 3 };
*
* _.pickBy(object, _.isNumber);
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
if (object == null) {
return {};
}
var props = arrayMap(getAllKeysIn(object), function(prop) {
return [prop];
});
predicate = getIteratee(predicate);
return basePickBy(object, props, function(value, path) {
return predicate(value, path[0]);
});
}
/**
* This method is like `_.get` except that if the resolved value is a
* function it's invoked with the `this` binding of its parent object and
* its result is returned.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to resolve.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
*
* _.result(object, 'a[0].b.c1');
* // => 3
*
* _.result(object, 'a[0].b.c2');
* // => 4
*
* _.result(object, 'a[0].b.c3', 'default');
* // => 'default'
*
* _.result(object, 'a[0].b.c3', _.constant('default'));
* // => 'default'
*/
function result(object, path, defaultValue) {
path = castPath(path, object);
var index = -1,
length = path.length;
// Ensure the loop is entered when path is empty.
if (!length) {
length = 1;
object = undefined;
}
while (++index < length) {
var value = object == null ? undefined : object[toKey(path[index])];
if (value === undefined) {
index = length;
value = defaultValue;
}
object = isFunction(value) ? value.call(object) : value;
}
return object;
}
/**
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
* it's created. Arrays are created for missing index properties while objects
* are created for all other missing properties. Use `_.setWith` to customize
* `path` creation.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @returns {Object} Returns `object`.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.set(object, 'a[0].b.c', 4);
* console.log(object.a[0].b.c);
* // => 4
*
* _.set(object, ['x', '0', 'y', 'z'], 5);
* console.log(object.x[0].y.z);
* // => 5
*/
function set(object, path, value) {
return object == null ? object : baseSet(object, path, value);
}
/**
* This method is like `_.set` except that it accepts `customizer` which is
* invoked to produce the objects of `path`. If `customizer` returns `undefined`
* path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @example
*
* var object = {};
*
* _.setWith(object, '[0][1]', 'a', Object);
* // => { '0': { '1': 'a' } }
*/
function setWith(object, path, value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return object == null ? object : baseSet(object, path, value, customizer);
}
/**
* Creates an array of own enumerable string keyed-value pairs for `object`
* which can be consumed by `_.fromPairs`. If `object` is a map or set, its
* entries are returned.
*
* @static
* @memberOf _
* @since 4.0.0
* @alias entries
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the key-value pairs.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.toPairs(new Foo);
* // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
*/
var toPairs = createToPairs(keys);
/**
* Creates an array of own and inherited enumerable string keyed-value pairs
* for `object` which can be consumed by `_.fromPairs`. If `object` is a map
* or set, its entries are returned.
*
* @static
* @memberOf _
* @since 4.0.0
* @alias entriesIn
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the key-value pairs.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.toPairsIn(new Foo);
* // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
*/
var toPairsIn = createToPairs(keysIn);
/**
* An alternative to `_.reduce`; this method transforms `object` to a new
* `accumulator` object which is the result of running each of its own
* enumerable string keyed properties thru `iteratee`, with each invocation
* potentially mutating the `accumulator` object. If `accumulator` is not
* provided, a new object with the same `[[Prototype]]` will be used. The
* iteratee is invoked with four arguments: (accumulator, value, key, object).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
* @since 1.3.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {*} [accumulator] The custom accumulator value.
* @returns {*} Returns the accumulated value.
* @example
*
* _.transform([2, 3, 4], function(result, n) {
* result.push(n *= n);
* return n % 2 == 0;
* }, []);
* // => [4, 9]
*
* _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
* (result[value] || (result[value] = [])).push(key);
* }, {});
* // => { '1': ['a', 'c'], '2': ['b'] }
*/
function transform(object, iteratee, accumulator) {
var isArr = isArray(object),
isArrLike = isArr || isBuffer(object) || isTypedArray(object);
iteratee = getIteratee(iteratee, 4);
if (accumulator == null) {
var Ctor = object && object.constructor;
if (isArrLike) {
accumulator = isArr ? new Ctor : [];
}
else if (isObject(object)) {
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
}
else {
accumulator = {};
}
}
(isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
return iteratee(accumulator, value, index, object);
});
return accumulator;
}
/**
* Removes the property at `path` of `object`.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to unset.
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 7 } }] };
* _.unset(object, 'a[0].b.c');
* // => true
*
* console.log(object);
* // => { 'a': [{ 'b': {} }] };
*
* _.unset(object, ['a', '0', 'b', 'c']);
* // => true
*
* console.log(object);
* // => { 'a': [{ 'b': {} }] };
*/
function unset(object, path) {
return object == null ? true : baseUnset(object, path);
}
/**
* This method is like `_.set` except that accepts `updater` to produce the
* value to set. Use `_.updateWith` to customize `path` creation. The `updater`
* is invoked with one argument: (value).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.6.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {Function} updater The function to produce the updated value.
* @returns {Object} Returns `object`.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.update(object, 'a[0].b.c', function(n) { return n * n; });
* console.log(object.a[0].b.c);
* // => 9
*
* _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
* console.log(object.x[0].y.z);
* // => 0
*/
function update(object, path, updater) {
return object == null ? object : baseUpdate(object, path, castFunction(updater));
}
/**
* This method is like `_.update` except that it accepts `customizer` which is
* invoked to produce the objects of `path`. If `customizer` returns `undefined`
* path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.6.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @example
*
* var object = {};
*
* _.updateWith(object, '[0][1]', _.constant('a'), Object);
* // => { '0': { '1': 'a' } }
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
}
/**
* Creates an array of the own enumerable string keyed property values of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property values.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.values(new Foo);
* // => [1, 2] (iteration order is not guaranteed)
*
* _.values('hi');
* // => ['h', 'i']
*/
function values(object) {
return object == null ? [] : baseValues(object, keys(object));
}
/**
* Creates an array of the own and inherited enumerable string keyed property
* values of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property values.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.valuesIn(new Foo);
* // => [1, 2, 3] (iteration order is not guaranteed)
*/
function valuesIn(object) {
return object == null ? [] : baseValues(object, keysIn(object));
}
/*------------------------------------------------------------------------*/
/**
* Clamps `number` within the inclusive `lower` and `upper` bounds.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Number
* @param {number} number The number to clamp.
* @param {number} [lower] The lower bound.
* @param {number} upper The upper bound.
* @returns {number} Returns the clamped number.
* @example
*
* _.clamp(-10, -5, 5);
* // => -5
*
* _.clamp(10, -5, 5);
* // => 5
*/
function clamp(number, lower, upper) {
if (upper === undefined) {
upper = lower;
lower = undefined;
}
if (upper !== undefined) {
upper = toNumber(upper);
upper = upper === upper ? upper : 0;
}
if (lower !== undefined) {
lower = toNumber(lower);
lower = lower === lower ? lower : 0;
}
return baseClamp(toNumber(number), lower, upper);
}
/**
* Checks if `n` is between `start` and up to, but not including, `end`. If
* `end` is not specified, it's set to `start` with `start` then set to `0`.
* If `start` is greater than `end` the params are swapped to support
* negative ranges.
*
* @static
* @memberOf _
* @since 3.3.0
* @category Number
* @param {number} number The number to check.
* @param {number} [start=0] The start of the range.
* @param {number} end The end of the range.
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
* @see _.range, _.rangeRight
* @example
*
* _.inRange(3, 2, 4);
* // => true
*
* _.inRange(4, 8);
* // => true
*
* _.inRange(4, 2);
* // => false
*
* _.inRange(2, 2);
* // => false
*
* _.inRange(1.2, 2);
* // => true
*
* _.inRange(5.2, 4);
* // => false
*
* _.inRange(-3, -2, -6);
* // => true
*/
function inRange(number, start, end) {
start = toFinite(start);
if (end === undefined) {
end = start;
start = 0;
} else {
end = toFinite(end);
}
number = toNumber(number);
return baseInRange(number, start, end);
}
/**
* Produces a random number between the inclusive `lower` and `upper` bounds.
* If only one argument is provided a number between `0` and the given number
* is returned. If `floating` is `true`, or either `lower` or `upper` are
* floats, a floating-point number is returned instead of an integer.
*
* **Note:** JavaScript follows the IEEE-754 standard for resolving
* floating-point values which can produce unexpected results.
*
* @static
* @memberOf _
* @since 0.7.0
* @category Number
* @param {number} [lower=0] The lower bound.
* @param {number} [upper=1] The upper bound.
* @param {boolean} [floating] Specify returning a floating-point number.
* @returns {number} Returns the random number.
* @example
*
* _.random(0, 5);
* // => an integer between 0 and 5
*
* _.random(5);
* // => also an integer between 0 and 5
*
* _.random(5, true);
* // => a floating-point number between 0 and 5
*
* _.random(1.2, 5.2);
* // => a floating-point number between 1.2 and 5.2
*/
function random(lower, upper, floating) {
if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
upper = floating = undefined;
}
if (floating === undefined) {
if (typeof upper == 'boolean') {
floating = upper;
upper = undefined;
}
else if (typeof lower == 'boolean') {
floating = lower;
lower = undefined;
}
}
if (lower === undefined && upper === undefined) {
lower = 0;
upper = 1;
}
else {
lower = toFinite(lower);
if (upper === undefined) {
upper = lower;
lower = 0;
} else {
upper = toFinite(upper);
}
}
if (lower > upper) {
var temp = lower;
lower = upper;
upper = temp;
}
if (floating || lower % 1 || upper % 1) {
var rand = nativeRandom();
return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
}
return baseRandom(lower, upper);
}
/*------------------------------------------------------------------------*/
/**
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the camel cased string.
* @example
*
* _.camelCase('Foo Bar');
* // => 'fooBar'
*
* _.camelCase('--foo-bar--');
* // => 'fooBar'
*
* _.camelCase('__FOO_BAR__');
* // => 'fooBar'
*/
var camelCase = createCompounder(function(result, word, index) {
word = word.toLowerCase();
return result + (index ? capitalize(word) : word);
});
/**
* Converts the first character of `string` to upper case and the remaining
* to lower case.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to capitalize.
* @returns {string} Returns the capitalized string.
* @example
*
* _.capitalize('FRED');
* // => 'Fred'
*/
function capitalize(string) {
return upperFirst(toString(string).toLowerCase());
}
/**
* Deburrs `string` by converting
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
* letters to basic Latin letters and removing
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to deburr.
* @returns {string} Returns the deburred string.
* @example
*
* _.deburr('déjà vu');
* // => 'deja vu'
*/
function deburr(string) {
string = toString(string);
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
}
/**
* Checks if `string` ends with the given target string.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to inspect.
* @param {string} [target] The string to search for.
* @param {number} [position=string.length] The position to search up to.
* @returns {boolean} Returns `true` if `string` ends with `target`,
* else `false`.
* @example
*
* _.endsWith('abc', 'c');
* // => true
*
* _.endsWith('abc', 'b');
* // => false
*
* _.endsWith('abc', 'b', 2);
* // => true
*/
function endsWith(string, target, position) {
string = toString(string);
target = baseToString(target);
var length = string.length;
position = position === undefined
? length
: baseClamp(toInteger(position), 0, length);
var end = position;
position -= target.length;
return position >= 0 && string.slice(position, end) == target;
}
/**
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
* corresponding HTML entities.
*
* **Note:** No other characters are escaped. To escape additional
* characters use a third-party library like [_he_](https://mths.be/he).
*
* Though the ">" character is escaped for symmetry, characters like
* ">" and "/" don't need escaping in HTML and have no special meaning
* unless they're part of a tag or unquoted attribute value. See
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
* (under "semi-related fun fact") for more details.
*
* When working with HTML you should always
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
* XSS vectors.
*
* @static
* @since 0.1.0
* @memberOf _
* @category String
* @param {string} [string=''] The string to escape.
* @returns {string} Returns the escaped string.
* @example
*
* _.escape('fred, barney, & pebbles');
* // => 'fred, barney, & pebbles'
*/
function escape(string) {
string = toString(string);
return (string && reHasUnescapedHtml.test(string))
? string.replace(reUnescapedHtml, escapeHtmlChar)
: string;
}
/**
* Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
* "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to escape.
* @returns {string} Returns the escaped string.
* @example
*
* _.escapeRegExp('[lodash](https://lodash.com/)');
* // => '\[lodash\]\(https://lodash\.com/\)'
*/
function escapeRegExp(string) {
string = toString(string);
return (string && reHasRegExpChar.test(string))
? string.replace(reRegExpChar, '\\$&')
: string;
}
/**
* Converts `string` to
* [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the kebab cased string.
* @example
*
* _.kebabCase('Foo Bar');
* // => 'foo-bar'
*
* _.kebabCase('fooBar');
* // => 'foo-bar'
*
* _.kebabCase('__FOO_BAR__');
* // => 'foo-bar'
*/
var kebabCase = createCompounder(function(result, word, index) {
return result + (index ? '-' : '') + word.toLowerCase();
});
/**
* Converts `string`, as space separated words, to lower case.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the lower cased string.
* @example
*
* _.lowerCase('--Foo-Bar--');
* // => 'foo bar'
*
* _.lowerCase('fooBar');
* // => 'foo bar'
*
* _.lowerCase('__FOO_BAR__');
* // => 'foo bar'
*/
var lowerCase = createCompounder(function(result, word, index) {
return result + (index ? ' ' : '') + word.toLowerCase();
});
/**
* Converts the first character of `string` to lower case.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.lowerFirst('Fred');
* // => 'fred'
*
* _.lowerFirst('FRED');
* // => 'fRED'
*/
var lowerFirst = createCaseFirst('toLowerCase');
/**
* Pads `string` on the left and right sides if it's shorter than `length`.
* Padding characters are truncated if they can't be evenly divided by `length`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to pad.
* @param {number} [length=0] The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the padded string.
* @example
*
* _.pad('abc', 8);
* // => ' abc '
*
* _.pad('abc', 8, '_-');
* // => '_-abc_-_'
*
* _.pad('abc', 3);
* // => 'abc'
*/
function pad(string, length, chars) {
string = toString(string);
length = toInteger(length);
var strLength = length ? stringSize(string) : 0;
if (!length || strLength >= length) {
return string;
}
var mid = (length - strLength) / 2;
return (
createPadding(nativeFloor(mid), chars) +
string +
createPadding(nativeCeil(mid), chars)
);
}
/**
* Pads `string` on the right side if it's shorter than `length`. Padding
* characters are truncated if they exceed `length`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to pad.
* @param {number} [length=0] The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the padded string.
* @example
*
* _.padEnd('abc', 6);
* // => 'abc '
*
* _.padEnd('abc', 6, '_-');
* // => 'abc_-_'
*
* _.padEnd('abc', 3);
* // => 'abc'
*/
function padEnd(string, length, chars) {
string = toString(string);
length = toInteger(length);
var strLength = length ? stringSize(string) : 0;
return (length && strLength < length)
? (string + createPadding(length - strLength, chars))
: string;
}
/**
* Pads `string` on the left side if it's shorter than `length`. Padding
* characters are truncated if they exceed `length`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to pad.
* @param {number} [length=0] The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the padded string.
* @example
*
* _.padStart('abc', 6);
* // => ' abc'
*
* _.padStart('abc', 6, '_-');
* // => '_-_abc'
*
* _.padStart('abc', 3);
* // => 'abc'
*/
function padStart(string, length, chars) {
string = toString(string);
length = toInteger(length);
var strLength = length ? stringSize(string) : 0;
return (length && strLength < length)
? (createPadding(length - strLength, chars) + string)
: string;
}
/**
* Converts `string` to an integer of the specified radix. If `radix` is
* `undefined` or `0`, a `radix` of `10` is used unless `value` is a
* hexadecimal, in which case a `radix` of `16` is used.
*
* **Note:** This method aligns with the
* [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
*
* @static
* @memberOf _
* @since 1.1.0
* @category String
* @param {string} string The string to convert.
* @param {number} [radix=10] The radix to interpret `value` by.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {number} Returns the converted integer.
* @example
*
* _.parseInt('08');
* // => 8
*
* _.map(['6', '08', '10'], _.parseInt);
* // => [6, 8, 10]
*/
function parseInt(string, radix, guard) {
if (guard || radix == null) {
radix = 0;
} else if (radix) {
radix = +radix;
}
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}
/**
* Repeats the given string `n` times.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to repeat.
* @param {number} [n=1] The number of times to repeat the string.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {string} Returns the repeated string.
* @example
*
* _.repeat('*', 3);
* // => '***'
*
* _.repeat('abc', 2);
* // => 'abcabc'
*
* _.repeat('abc', 0);
* // => ''
*/
function repeat(string, n, guard) {
if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
n = 1;
} else {
n = toInteger(n);
}
return baseRepeat(toString(string), n);
}
/**
* Replaces matches for `pattern` in `string` with `replacement`.
*
* **Note:** This method is based on
* [`String#replace`](https://mdn.io/String/replace).
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to modify.
* @param {RegExp|string} pattern The pattern to replace.
* @param {Function|string} replacement The match replacement.
* @returns {string} Returns the modified string.
* @example
*
* _.replace('Hi Fred', 'Fred', 'Barney');
* // => 'Hi Barney'
*/
function replace() {
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
}
/**
* Converts `string` to
* [snake case](https://en.wikipedia.org/wiki/Snake_case).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the snake cased string.
* @example
*
* _.snakeCase('Foo Bar');
* // => 'foo_bar'
*
* _.snakeCase('fooBar');
* // => 'foo_bar'
*
* _.snakeCase('--FOO-BAR--');
* // => 'foo_bar'
*/
var snakeCase = createCompounder(function(result, word, index) {
return result + (index ? '_' : '') + word.toLowerCase();
});
/**
* Splits `string` by `separator`.
*
* **Note:** This method is based on
* [`String#split`](https://mdn.io/String/split).
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to split.
* @param {RegExp|string} separator The separator pattern to split by.
* @param {number} [limit] The length to truncate results to.
* @returns {Array} Returns the string segments.
* @example
*
* _.split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
function split(string, separator, limit) {
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
separator = limit = undefined;
}
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
if (!limit) {
return [];
}
string = toString(string);
if (string && (
typeof separator == 'string' ||
(separator != null && !isRegExp(separator))
)) {
separator = baseToString(separator);
if (!separator && hasUnicode(string)) {
return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
}
/**
* Converts `string` to
* [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
*
* @static
* @memberOf _
* @since 3.1.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the start cased string.
* @example
*
* _.startCase('--foo-bar--');
* // => 'Foo Bar'
*
* _.startCase('fooBar');
* // => 'Foo Bar'
*
* _.startCase('__FOO_BAR__');
* // => 'FOO BAR'
*/
var startCase = createCompounder(function(result, word, index) {
return result + (index ? ' ' : '') + upperFirst(word);
});
/**
* Checks if `string` starts with the given target string.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to inspect.
* @param {string} [target] The string to search for.
* @param {number} [position=0] The position to search from.
* @returns {boolean} Returns `true` if `string` starts with `target`,
* else `false`.
* @example
*
* _.startsWith('abc', 'a');
* // => true
*
* _.startsWith('abc', 'b');
* // => false
*
* _.startsWith('abc', 'b', 1);
* // => true
*/
function startsWith(string, target, position) {
string = toString(string);
position = position == null
? 0
: baseClamp(toInteger(position), 0, string.length);
target = baseToString(target);
return string.slice(position, position + target.length) == target;
}
/**
* Creates a compiled template function that can interpolate data properties
* in "interpolate" delimiters, HTML-escape interpolated data properties in
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
* properties may be accessed as free variables in the template. If a setting
* object is given, it takes precedence over `_.templateSettings` values.
*
* **Note:** In the development build `_.template` utilizes
* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
* for easier debugging.
*
* For more information on precompiling templates see
* [lodash's custom builds documentation](https://lodash.com/custom-builds).
*
* For more information on Chrome extension sandboxes see
* [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
*
* @static
* @since 0.1.0
* @memberOf _
* @category String
* @param {string} [string=''] The template string.
* @param {Object} [options={}] The options object.
* @param {RegExp} [options.escape=_.templateSettings.escape]
* The HTML "escape" delimiter.
* @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
* The "evaluate" delimiter.
* @param {Object} [options.imports=_.templateSettings.imports]
* An object to import into the template as free variables.
* @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
* The "interpolate" delimiter.
* @param {string} [options.sourceURL='lodash.templateSources[n]']
* The sourceURL of the compiled template.
* @param {string} [options.variable='obj']
* The data object variable name.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the compiled template function.
* @example
*
* // Use the "interpolate" delimiter to create a compiled template.
* var compiled = _.template('hello <%= user %>!');
* compiled({ 'user': 'fred' });
* // => 'hello fred!'
*
* // Use the HTML "escape" delimiter to escape data property values.
* var compiled = _.template('<%- value %>');
* compiled({ 'value': '