"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.Graphic = 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 _react = _interopRequireDefault(require("react"));

var _styles = require("@material-ui/core/styles");

var _range = _interopRequireDefault(require("lodash/range"));

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

var _styleUtils = require("../style-utils");

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; } }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var Line = (0, _styles.withStyles)(function (theme) {
  return {
    line: {
      strokeWidth: '0.2',
      stroke: (0, _styleUtils.strokeColor)(theme)
    }
  };
})(function (_ref) {
  var angle = _ref.angle,
      classes = _ref.classes,
      major = _ref.major,
      minor = _ref.minor;
  return /*#__PURE__*/_react["default"].createElement("line", {
    transform: "rotate(".concat(angle, ", 50.5,50)"),
    className: classes.line,
    style: {},
    x1: "1",
    x2: major ? 10 : minor ? 6 : 3,
    y1: "50",
    y2: "50"
  });
});
var Spike = (0, _styles.withStyles)(function (theme) {
  return {
    line: {
      strokeWidth: '0.2',
      stroke: (0, _styleUtils.strokeColor)(theme)
    }
  };
})(function (_ref2) {
  var angle = _ref2.angle,
      classes = _ref2.classes;
  return /*#__PURE__*/_react["default"].createElement("line", {
    transform: "rotate(".concat(angle, ", 50.5,50)"),
    className: classes.line,
    style: {},
    x1: "15",
    x2: '46',
    y1: "50",
    y2: "50"
  });
});
var Text = (0, _styles.withStyles)(function (theme) {
  return {
    text: _objectSpread({
      fontSize: '2.5px',
      textAnchor: 'middle',
      fill: (0, _styleUtils.strokeColor)(theme)
    }, (0, _styleUtils.noSelect)())
  };
})(function (_ref3) {
  var angle = _ref3.angle,
      classes = _ref3.classes;
  return /*#__PURE__*/_react["default"].createElement("text", {
    transform: "rotate(".concat(angle - 90, ", 50.5, 50)"),
    className: classes.text,
    x: "50",
    y: "12.5"
  }, angle);
});

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

  var _super = _createSuper(Graphic);

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

  (0, _createClass2["default"])(Graphic, [{
    key: "render",
    value: function render() {
      var classes = this.props.classes;
      return /*#__PURE__*/_react["default"].createElement("svg", {
        viewBox: "0 0 102 61"
      }, /*#__PURE__*/_react["default"].createElement("path", {
        className: classes.path,
        d: "M 1,50 A 1,1 0 0 1 100,50 L 100,60 L 1,60 Z",
        fill: "none"
      }), (0, _range["default"])(0, 181).map(function (r) {
        return /*#__PURE__*/_react["default"].createElement(Line, {
          minor: r % 5 === 0,
          major: r % 10 === 0,
          angle: r,
          key: r
        });
      }), (0, _range["default"])(0, 181, 10).map(function (r) {
        return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
          key: r
        }, /*#__PURE__*/_react["default"].createElement(Spike, {
          angle: r
        }), /*#__PURE__*/_react["default"].createElement(Text, {
          angle: r
        }));
      }), /*#__PURE__*/_react["default"].createElement("circle", {
        r: "4",
        cx: "50.5",
        cy: "50",
        className: classes.circle
      }), /*#__PURE__*/_react["default"].createElement("line", {
        className: classes.line,
        x1: "48.5",
        x2: "52.5",
        y1: "50",
        y2: "50"
      }), /*#__PURE__*/_react["default"].createElement("line", {
        className: classes.line,
        transform: 'rotate(90 50.5 50)',
        x1: "48.5",
        x2: "52.5",
        y1: "50",
        y2: "50"
      }));
    }
  }]);
  return Graphic;
}(_react["default"].PureComponent);

exports.Graphic = Graphic;
(0, _defineProperty2["default"])(Graphic, "propTypes", {
  classes: _propTypes["default"].object.isRequired
});

var _default = (0, _styles.withStyles)(function (theme) {
  return {
    path: {
      strokeWidth: '0.2',
      stroke: (0, _styleUtils.strokeColor)(theme)
    },
    line: {
      strokeWidth: '0.2',
      stroke: (0, _styleUtils.strokeColor)(theme)
    },
    circle: {
      strokeWidth: '0.2',
      stroke: (0, _styleUtils.strokeColor)(theme),
      fill: 'none'
    }
  };
})(Graphic);

exports["default"] = _default;
//# sourceMappingURL=graphic.js.map