import { __extends } from "../../../node_modules/tslib/tslib.es6.mjs";
import { assert, isArray, each, map, merge } from "../../../../../../zrender@5.4.4/node_modules/zrender/lib/core/util.mjs";
import { replaceVisualOption } from "../../visual/visualSolution.mjs";
import Model from "../../model/Model.mjs";
import ComponentModel from "../../model/Component.mjs";
var DEFAULT_OUT_OF_BRUSH_COLOR = "#ddd";
var BrushModel = (
  /** @class */
  function(_super) {
    __extends(BrushModel2, _super);
    function BrushModel2() {
      var _this = _super !== null && _super.apply(this, arguments) || this;
      _this.type = BrushModel2.type;
      _this.areas = [];
      _this.brushOption = {};
      return _this;
    }
    BrushModel2.prototype.optionUpdated = function(newOption, isInit) {
      var thisOption = this.option;
      !isInit && replaceVisualOption(thisOption, newOption, ["inBrush", "outOfBrush"]);
      var inBrush = thisOption.inBrush = thisOption.inBrush || {};
      thisOption.outOfBrush = thisOption.outOfBrush || {
        color: DEFAULT_OUT_OF_BRUSH_COLOR
      };
      if (!inBrush.hasOwnProperty("liftZ")) {
        inBrush.liftZ = 5;
      }
    };
    BrushModel2.prototype.setAreas = function(areas) {
      if (process.env.NODE_ENV !== "production") {
        assert(isArray(areas));
        each(areas, function(area) {
          assert(area.brushType, "Illegal areas");
        });
      }
      if (!areas) {
        return;
      }
      this.areas = map(areas, function(area) {
        return generateBrushOption(this.option, area);
      }, this);
    };
    BrushModel2.prototype.setBrushOption = function(brushOption) {
      this.brushOption = generateBrushOption(this.option, brushOption);
      this.brushType = this.brushOption.brushType;
    };
    BrushModel2.type = "brush";
    BrushModel2.dependencies = ["geo", "grid", "xAxis", "yAxis", "parallel", "series"];
    BrushModel2.defaultOption = {
      seriesIndex: "all",
      brushType: "rect",
      brushMode: "single",
      transformable: true,
      brushStyle: {
        borderWidth: 1,
        color: "rgba(210,219,238,0.3)",
        borderColor: "#D2DBEE"
      },
      throttleType: "fixRate",
      throttleDelay: 0,
      removeOnClick: true,
      z: 1e4
    };
    return BrushModel2;
  }(ComponentModel)
);
function generateBrushOption(option, brushOption) {
  return merge({
    brushType: option.brushType,
    brushMode: option.brushMode,
    transformable: option.transformable,
    brushStyle: new Model(option.brushStyle).getItemStyle(),
    removeOnClick: option.removeOnClick,
    z: option.z
  }, brushOption, true);
}
const BrushModel$1 = BrushModel;
export {
  BrushModel$1 as default
};
