'use strict';

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

var tslib_es6 = require('../../../../../../tslib@2.3.0/node_modules/tslib/tslib.es6.js');
var Component = require('../../view/Component.js');
var util = require('../../../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.js');
var MarkerModel = require('./MarkerModel.js');
var model = require('../../util/model.js');
var states = require('../../util/states.js');
var graphic = require('../../util/graphic.js');

var inner = model.makeInner();
var MarkerView = /** @class */function (_super) {
  tslib_es6.__extends(MarkerView, _super);
  function MarkerView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = MarkerView.type;
    return _this;
  }
  MarkerView.prototype.init = function () {
    this.markerGroupMap = util.createHashMap();
  };
  MarkerView.prototype.render = function (markerModel, ecModel, api) {
    var _this = this;
    var markerGroupMap = this.markerGroupMap;
    markerGroupMap.each(function (item) {
      inner(item).keep = false;
    });
    ecModel.eachSeries(function (seriesModel) {
      var markerModel = MarkerModel.default.getMarkerModelFromSeries(seriesModel, _this.type);
      markerModel && _this.renderSeries(seriesModel, markerModel, ecModel, api);
    });
    markerGroupMap.each(function (item) {
      !inner(item).keep && _this.group.remove(item.group);
    });
    updateZ(ecModel, markerGroupMap, this.type);
  };
  MarkerView.prototype.markKeep = function (drawGroup) {
    inner(drawGroup).keep = true;
  };
  MarkerView.prototype.toggleBlurSeries = function (seriesModelList, isBlur) {
    var _this = this;
    util.each(seriesModelList, function (seriesModel) {
      var markerModel = MarkerModel.default.getMarkerModelFromSeries(seriesModel, _this.type);
      if (markerModel) {
        var data = markerModel.getData();
        data.eachItemGraphicEl(function (el) {
          if (el) {
            isBlur ? states.enterBlur(el) : states.leaveBlur(el);
          }
        });
      }
    });
  };
  MarkerView.type = 'marker';
  return MarkerView;
}(Component.default);
function updateZ(ecModel, markerGroupMap, type) {
  ecModel.eachSeries(function (seriesModel) {
    var markerModel = MarkerModel.default.getMarkerModelFromSeries(seriesModel, type);
    var markerDraw = markerGroupMap.get(seriesModel.id);
    if (markerModel && markerDraw && markerDraw.group) {
      var _a = graphic.retrieveZInfo(markerModel),
        z = _a.z,
        zlevel = _a.zlevel;
      graphic.traverseUpdateZ(markerDraw.group, z, zlevel);
    }
  });
}

exports.default = MarkerView;
