"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = exports.NumberWithCommas = exports.NWC = exports.GIS_COLORS = exports.Dimension = exports.DATA_COLORS = exports.Compose = void 0;

var _reduceRight = _interopRequireDefault(require("lodash/reduceRight"));

/* eslint-disable @iceworks/best-practices/recommend-polyfill */

/**
 * 内置图表色值
 */
var DATA_COLORS = ['#0070cc', '#2aca96', '#fec400', '#909ca6', '#826af9', '#ff7d51', // 扩充
'#3b81ff', '#00cbfb'];
/**
 * 内置GIS色值
 */

exports.DATA_COLORS = DATA_COLORS;
var GIS_COLORS = ["#34B999", "#0DACB0", "#0D9FB0", "#2386CD", "#0070C0", "#0D5DCB", "#0E4FCE", "#5949C1"];
/**
 * 获取容器真正高度（含margin）
 * @param el 容器
 */

exports.GIS_COLORS = GIS_COLORS;

var Dimension = function Dimension(el) {
  var styles = window.getComputedStyle(el);
  var margin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
  return Math.ceil(el.offsetHeight + margin);
};
/**
 * 数字每三位加逗号
 * @param {*} x 要处理的数字
 */


exports.Dimension = Dimension;

var NumberWithCommas = function NumberWithCommas(x) {
  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};

exports.NumberWithCommas = NumberWithCommas;
var NWC = NumberWithCommas;
/**
 * 一个函数执行完之后把返回的结果再作为参数赋给下一个函数来执行.以此类推;
 * @param fns
 */

exports.NWC = NWC;

var Compose = function Compose(fns) {
  return function (x) {
    return (0, _reduceRight["default"])(fns, function (y, f) {
      return f(y);
    }, x);
  };
};

exports.Compose = Compose;
var _default = {
  DATA_COLORS: DATA_COLORS,
  GIS_COLORS: GIS_COLORS,
  Dimension: Dimension,
  NumberWithCommas: NumberWithCommas,
  NWC: NWC,
  Compose: Compose
};
exports["default"] = _default;