
/*
* 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 * as graphic from '../../util/graphic.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import ChartView from '../../view/Chart.js';
import { each } from 'tvrender/lib/core/util.js';
import LinesPath from './LinesPath.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
function getLineDashByLineStyle(lineStyle) {
  if (lineStyle === 'style_dashed') {
    return [8, 8];
  } else if (lineStyle === 'style_dotted') {
    return [4, 4];
  }
  return 'solid';
}
var MineLinesView = /** @class */function (_super) {
  __extends(MineLinesView, _super);
  function MineLinesView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = MineLinesView.type;
    return _this;
  }
  MineLinesView.prototype.init = function () {};
  MineLinesView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    this._renderLines(data, seriesModel, api);
    var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
    toggleHoverEmphasis(this.group, null, null, false);
    var groupId = seriesModel.get('groupId');
    getECData(this.group).groupId = groupId;
  };
  MineLinesView.prototype._getClipShape = function (seriesModel) {
    if (!seriesModel.get('clip', true)) {
      return;
    }
    var coordSys = seriesModel.coordinateSystem;
    // PENDING make `0.1` configurable, for example, `clipTolerance`?
    return coordSys && coordSys.getArea && coordSys.getArea(.1);
  };
  MineLinesView.prototype._renderLines = function (data, seriesModel, api) {
    if (!this._linesGroup) {
      this._linesGroup = new graphic.Group();
      this.group.add(this._linesGroup);
    } else {
      this._linesGroup.removeAll();
    }
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var linesGroup = this._linesGroup;
    var z2 = seriesModel.get('z2');
    var isMobile = seriesModel.get('isMobile');
    var linesPointById = data.getLayout('linesPointById');
    var rectWidth = api.getWidth();
    var rectHeight = api.getHeight();
    each(linesPointById, function (item, key) {
      var _a = key.split(':'),
        color = _a[0],
        width = _a[1],
        lineStyle = _a[2],
        extend = _a[3];
      var el = new LinesPath({
        shape: {
          points: item,
          extend: extend,
          lineStyle: lineStyle,
          rectWidth: rectWidth,
          rectHeight: rectHeight,
          stroke: color,
          isWebviewRender: isMobile
        },
        style: {
          fill: 'none',
          stroke: color,
          lineWidth: +width,
          lineDash: getLineDashByLineStyle(lineStyle)
        },
        z2: z2
      });
      el.states.emphasis = emphasisState;
      linesGroup.add(el);
    });
  };
  MineLinesView.prototype.remove = function (ecModel, api) {
    this._linesGroup && this._linesGroup.removeAll();
    this._linesGroup = null;
  };
  MineLinesView.prototype.dispose = function (ecModel, api) {
    this.remove(ecModel, api);
    // this._lineGroup.removeAll();
  };

  MineLinesView.type = 'mineLines';
  return MineLinesView;
}(ChartView);
export default MineLinesView;