"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.LineDot = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _plot = require("../../plot");

var _utils = require("../utils");

var _line = _interopRequireDefault(require("./common/line"));

var _classnames = _interopRequireDefault(require("classnames"));

var _excluded = ["scale", "x", "y", "className", "classes", "r", "correctness"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var DraggableComponent = function DraggableComponent(_ref) {
  var scale = _ref.scale,
      x = _ref.x,
      y = _ref.y,
      className = _ref.className,
      classes = _ref.classes,
      r = _ref.r,
      correctness = _ref.correctness,
      rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
  return /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("circle", (0, _extends2["default"])({
    cx: scale.x(x),
    cy: scale.y(y),
    r: r * 3,
    className: (0, _classnames["default"])(classes.transparentHandle, className),
    style: {
      pointerEvents: 'none'
    }
  }, rest)), /*#__PURE__*/_react["default"].createElement("circle", (0, _extends2["default"])({
    cx: scale.x(x),
    cy: scale.y(y),
    r: r,
    className: (0, _classnames["default"])(className, classes.handle, correctness && correctness.value)
  }, rest)));
};

DraggableComponent.propTypes = {
  scale: _propTypes["default"].object,
  x: _propTypes["default"].number,
  y: _propTypes["default"].number,
  r: _propTypes["default"].number,
  className: _propTypes["default"].string,
  classes: _propTypes["default"].object,
  correctness: _propTypes["default"].shape({
    value: _propTypes["default"].string,
    label: _propTypes["default"].string
  })
};

var LineDot = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(LineDot, _React$Component);

  var _super = _createSuper(LineDot);

  function LineDot() {
    (0, _classCallCheck2["default"])(this, LineDot);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(LineDot, [{
    key: "render",
    value: function render() {
      var props = this.props;
      var data = props.data,
          graphProps = props.graphProps;

      var _ref2 = graphProps || {},
          _ref2$scale = _ref2.scale,
          scale = _ref2$scale === void 0 ? {} : _ref2$scale,
          _ref2$size = _ref2.size,
          size = _ref2$size === void 0 ? {} : _ref2$size;

      var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'lineDot');
      return /*#__PURE__*/_react["default"].createElement(_line["default"], (0, _extends2["default"])({}, props, {
        xBand: xBand,
        CustomDraggableComponent: DraggableComponent
      }));
    }
  }]);
  return LineDot;
}(_react["default"].Component);

exports.LineDot = LineDot;
(0, _defineProperty2["default"])(LineDot, "propTypes", {
  data: _propTypes["default"].array,
  onChange: _propTypes["default"].func,
  graphProps: _plot.types.GraphPropsType.isRequired
});

var _default = function _default() {
  return {
    type: 'lineDot',
    Component: LineDot,
    name: 'Line Dot'
  };
};

exports["default"] = _default;
//# sourceMappingURL=line-dot.js.map