'use strict';

var tslib_es6 = require('../../../../../../tslib@2.3.0/node_modules/tslib/tslib.es6.js');
var Component = require('../../view/Component.js');
var GridModel = require('../../coord/cartesian/GridModel.js');
require('../../util/graphic.js');
var util = require('../../../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.js');
var AxisModel = require('../../coord/cartesian/AxisModel.js');
var axisModelCreator = require('../../coord/axisModelCreator.js');
var Grid = require('../../coord/cartesian/Grid.js');
var CartesianAxisView = require('../axis/CartesianAxisView.js');
var Rect = require('../../../../../../zrender@6.0.0/node_modules/zrender/lib/graphic/shape/Rect.js');

// Grid view
var GridView = /** @class */function (_super) {
  tslib_es6.__extends(GridView, _super);
  function GridView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = 'grid';
    return _this;
  }
  GridView.prototype.render = function (gridModel, ecModel) {
    this.group.removeAll();
    if (gridModel.get('show')) {
      this.group.add(new Rect.default({
        shape: gridModel.coordinateSystem.getRect(),
        style: util.defaults({
          fill: gridModel.get('backgroundColor')
        }, gridModel.getItemStyle()),
        silent: true,
        z2: -1
      }));
    }
  };
  GridView.type = 'grid';
  return GridView;
}(Component.default);
var extraOption = {
  // gridIndex: 0,
  // gridId: '',
  offset: 0
};
function install(registers) {
  registers.registerComponentView(GridView);
  registers.registerComponentModel(GridModel.default);
  registers.registerCoordinateSystem('cartesian2d', Grid.default);
  axisModelCreator.default(registers, 'x', AxisModel.CartesianAxisModel, extraOption);
  axisModelCreator.default(registers, 'y', AxisModel.CartesianAxisModel, extraOption);
  registers.registerComponentView(CartesianAxisView.CartesianXAxisView);
  registers.registerComponentView(CartesianAxisView.CartesianYAxisView);
  registers.registerPreprocessor(function (option) {
    // Only create grid when need
    if (option.xAxis && option.yAxis && !option.grid) {
      option.grid = {};
    }
  });
}

exports.install = install;
