
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import { HashMap, each, merge } from 'tvrender/lib/core/util.js';
import ComponentModel from '../../model/Component.js';
// { [componentType]: MarkerModel }
// const inner = makeInner<Dictionary<MarkLabelModal>, SeriesModel>();
var defaultDataOption = {
  textStyle: {
    // padding: [4, 6, 2, 8],
    fill: '#fff',
    backgroundColor: '#26A69A'
  },
  lineStyle: {
    lineDash: [2, 2],
    stroke: '#26A69A',
    lineWidth: 1
  },
  precision: 3
};
var MarkLabelModal = /** @class */function (_super) {
  __extends(MarkLabelModal, _super);
  function MarkLabelModal() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = MarkLabelModal.type;
    _this.preventAutoZ = true;
    return _this;
  }
  // /**
  //  * @overrite
  //  */
  MarkLabelModal.prototype.init = function (option, parentModel, ecModel) {
    if (process.env.NODE_ENV !== 'production') {
      if (this.type === 'marker') {
        throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
      }
    }
    this.labelMap = new HashMap();
    this.mergeDefaultAndTheme(option, ecModel);
    this._mergeOption(option, ecModel);
  };
  /**
   * @overrite
   */
  MarkLabelModal.prototype.mergeOption = function (newOpt, ecModel) {
    this._mergeOption(newOpt, ecModel);
  };
  MarkLabelModal.prototype._mergeOption = function (newOpt, ecModel) {
    // const componentType = this.mainType;
    if (newOpt.isAvoidOverlap !== void 0) {
      this.option.isAvoidOverlap = newOpt.isAvoidOverlap;
    }
    ecModel.eachSeries(function (seriesModel) {
      var _this = this;
      var seriesName = seriesModel.name;
      var markerOpt = seriesModel.get(this.mainType, true);
      if (!markerOpt || !markerOpt.data) {
        return;
      }
      var dataMap = {};
      each(markerOpt.data, function (item, key) {
        // dataMap[key] = merge(item, defaultDataOption);
        if (!_this.option.data[key]) {
          dataMap[key] = _this.option.data[key] = merge(item, defaultDataOption);
          item.countDown = dataMap[key].countDown;
        } else {
          dataMap[key] = merge(_this.option.data[key], item, true);
          item.countDown = dataMap[key].countDown;
        }
        if (item.$action === 'remove') {
          _this.option.data[key] = void 0;
          delete markerOpt.data[key];
        }
      });
      this.labelMap.set(seriesName, dataMap);
    }, this);
  };
  MarkLabelModal.type = 'markLabel';
  /**
   * If marker model is created by self from series
   */
  // createdBySelf = false;
  MarkLabelModal.dependencies = ['series', 'grid'];
  MarkLabelModal.defaultOption = {
    zlevel: 2,
    z: 5,
    data: {},
    lineStyle: {
      lineDash: [1, 1]
    },
    textStyle: {
      padding: [4, 6, 2, 8]
    },
    isAvoidOverlap: true
  };
  return MarkLabelModal;
}(ComponentModel);
// mixin(MarkLabelModal, DataFormatMixin.prototype);
export default MarkLabelModal;