
/*
* 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 VolPathRectPath from './BoxesPath.js';
import RectPath from '../volPath/RectPath.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
var VolPathRectView = /** @class */function (_super) {
  __extends(VolPathRectView, _super);
  function VolPathRectView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = VolPathRectView.type;
    return _this;
  }
  VolPathRectView.prototype.init = function () {};
  VolPathRectView.prototype.render = function (seriesModel, ecModel) {
    var data = seriesModel.getData();
    this._renderRects(data, seriesModel);
    var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
  };
  VolPathRectView.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);
  };
  VolPathRectView.prototype._renderRects = function (data, seriesModel) {
    if (!this._rectsGroup) {
      this._rectsGroup = new graphic.Group();
      this.group.add(this._rectsGroup);
    } else {
      this._rectsGroup.removeAll();
    }
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var groupId = seriesModel.get('groupId');
    var isMobile = seriesModel.get('isMobile');
    var linesGroup = this._rectsGroup;
    var z2 = seriesModel.get('z2');
    // const linesPointById = data.getLayout('linesPoints');
    var rectPointsByColor = data.getLayout('rectPointsByColor');
    if (!rectPointsByColor) {
      return;
    }
    rectPointsByColor.forEach(function (rectPoints, key) {
      var el = new RectPath({
        shape: {
          typeArray: rectPoints
        },
        style: {
          fill: key,
          stroke: 'none',
          opacity: 0.3
        },
        z2: z2
      });
      linesGroup.add(el);
      el.states.emphasis = emphasisState;
    });
    // each(linesPointById, function (item: any) {
    //     const {  key, points } = item;
    //     const [color, width, lineStyle, fill] = key.split(':');
    //     const el = new VolPathRectPath({ shape: {
    //             points: points,
    //             fill: fill || 'none',
    //             stroke: color,
    //             isWebviewRender: isMobile,
    //         },
    //         style: {
    //             fill: fill || 'none',
    //             stroke: color,
    //             lineWidth: +width,
    //         },
    //         z2
    //     });
    //     el.states.emphasis = emphasisState;
    //     linesGroup.add(el);
    // });
    toggleHoverEmphasis(this.group, null, null, false, false);
    getECData(this.group).groupId = groupId;
  };
  VolPathRectView.prototype.remove = function (ecModel, api) {
    this._rectsGroup && this._rectsGroup.removeAll();
    this._rectsGroup = null;
  };
  VolPathRectView.prototype.dispose = function (ecModel, api) {
    this.remove(ecModel, api);
    // this._lineGroup.removeAll();
  };

  VolPathRectView.type = 'volPathRect';
  return VolPathRectView;
}(ChartView);
export default VolPathRectView;