'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var util = require('../../../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.js');

var each = util.each;
function visualMapPreprocessor(option) {
  var visualMap = option && option.visualMap;
  if (!util.isArray(visualMap)) {
    visualMap = visualMap ? [visualMap] : [];
  }
  each(visualMap, function (opt) {
    if (!opt) {
      return;
    }
    // rename splitList to pieces
    if (has(opt, 'splitList') && !has(opt, 'pieces')) {
      opt.pieces = opt.splitList;
      delete opt.splitList;
    }
    var pieces = opt.pieces;
    if (pieces && util.isArray(pieces)) {
      each(pieces, function (piece) {
        if (util.isObject(piece)) {
          if (has(piece, 'start') && !has(piece, 'min')) {
            piece.min = piece.start;
          }
          if (has(piece, 'end') && !has(piece, 'max')) {
            piece.max = piece.end;
          }
        }
      });
    }
  });
}
function has(obj, name) {
  return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
}

exports.default = visualMapPreprocessor;
