"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _Shape = _interopRequireDefault(require("./Shape"));
var _common = require("../../utils/common");
var _RectanglePainter = require("../../modules/painters/RectanglePainter");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * Rectangle props
 *
 * @category Props
 */

/**
  @category Component
 */
const Rectangle = props => {
  const {
    id,
    children,
    outCircleStyle,
    innerCircleStyle,
    anchorStyle,
    fillStyle,
    onError,
    onFinish
  } = props;
  const painter = new _RectanglePainter.RectanglePainter();
  const toFeatures = async points => {
    const features = [];
    points.forEach(p => features.push((0, _common.createPointFeature)(p, {
      type: 0
    })));
    if (points.length > 1) {
      const bounds = (0, _common.bbox)(points);
      const [[minX, minY], [maxX, maxY]] = bounds;
      const polygonPoints = [[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]];
      features.push((0, _common.createPolygonFeature)(polygonPoints, {
        type: 0
      }));
    }
    return features;
  };
  return /*#__PURE__*/React.createElement(_Shape.default, {
    id: id,
    paintner: painter,
    outCircleStyle: outCircleStyle,
    innerCircleStyle: innerCircleStyle,
    anchorStyle: anchorStyle,
    fillStyle: fillStyle,
    toFeatures: toFeatures,
    onError: onError,
    onFinish: onFinish
  }, children);
};
var _default = exports.default = Rectangle;
//# sourceMappingURL=Rectangle.js.map