text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports["default"] = void 0;
  
  var _react = _interopRequireWildcard(require("react"));
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _enhancer = _interopRequireDefault(require("./enhancer"));
  
  var _types = require("./types");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
  
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  function getPathStyles(offset, percent, strokeColor, strokeWidth) {
    var gapDegree = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
    var gapPosition = arguments.length > 5 ? arguments[5] : undefined;
    var radius = 50 - strokeWidth / 2;
    var beginPositionX = 0;
    var beginPositionY = -radius;
    var endPositionX = 0;
    var endPositionY = -2 * radius;
  
    switch (gapPosition) {
      case 'left':
        beginPositionX = -radius;
        beginPositionY = 0;
        endPositionX = 2 * radius;
        endPositionY = 0;
        break;
  
      case 'right':
        beginPositionX = radius;
        beginPositionY = 0;
        endPositionX = -2 * radius;
        endPositionY = 0;
        break;
  
      case 'bottom':
        beginPositionY = radius;
        endPositionY = 2 * radius;
        break;
  
      default:
    }
  
    var pathString = "M 50,50 m ".concat(beginPositionX, ",").concat(beginPositionY, "\n   a ").concat(radius, ",").concat(radius, " 0 1 1 ").concat(endPositionX, ",").concat(-endPositionY, "\n   a ").concat(radius, ",").concat(radius, " 0 1 1 ").concat(-endPositionX, ",").concat(endPositionY);
    var len = Math.PI * 2 * radius;
    var pathStyle = {
      stroke: strokeColor,
      strokeDasharray: "".concat(percent / 100 * (len - gapDegree), "px ").concat(len, "px"),
      strokeDashoffset: "-".concat(gapDegree / 2 + offset / 100 * (len - gapDegree), "px"),
      transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s' // eslint-disable-line
  
    };
    return {
      pathString: pathString,
      pathStyle: pathStyle
    };
  }
  
  var Circle =
  /*#__PURE__*/
  function (_Component) {
    _inherits(Circle, _Component);
  
    function Circle() {
      var _getPrototypeOf2;
  
      var _this;
  
      _classCallCheck(this, Circle);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Circle)).call.apply(_getPrototypeOf2, [this].concat(args)));
  
      _defineProperty(_assertThisInitialized(_this), "paths", {});
  
      return _this;
    }
  
    _createClass(Circle, [{
      key: "getStokeList",
      value: function getStokeList() {
        var _this2 = this;
  
        var _this$props = this.props,
            prefixCls = _this$props.prefixCls,
            percent = _this$props.percent,
            strokeColor = _this$props.strokeColor,
            strokeWidth = _this$props.strokeWidth,
            strokeLinecap = _this$props.strokeLinecap,
            gapDegree = _this$props.gapDegree,
            gapPosition = _this$props.gapPosition;
        var percentList = Array.isArray(percent) ? percent : [percent];
        var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];
        var stroke = Object.prototype.toString.call(strokeColor) === '[object Object]' ? 'url(#gradient)' : '';
        var stackPtg = 0;
        return percentList.map(function (ptg, index) {
          var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
  
          var _getPathStyles = getPathStyles(stackPtg, ptg, color, strokeWidth, gapDegree, gapPosition),
              pathString = _getPathStyles.pathString,
              pathStyle = _getPathStyles.pathStyle;
  
          stackPtg += ptg;
          return _react["default"].createElement("path", {
            key: index,
            className: "".concat(prefixCls, "-circle-path"),
            d: pathString,
            stroke: stroke,
            strokeLinecap: strokeLinecap,
            strokeWidth: ptg === 0 ? 0 : strokeWidth,
            fillOpacity: "0",
            style: pathStyle,
            ref: function ref(path) {
              _this2.paths[index] = path;
            }
          });
        });
      }
    }, {
      key: "render",
      value: function render() {
        var _this$props2 = this.props,
            prefixCls = _this$props2.prefixCls,
            strokeWidth = _this$props2.strokeWidth,
            trailWidth = _this$props2.trailWidth,
            gapDegree = _this$props2.gapDegree,
            gapPosition = _this$props2.gapPosition,
            trailColor = _this$props2.trailColor,
            strokeLinecap = _this$props2.strokeLinecap,
            style = _this$props2.style,
            className = _this$props2.className,
            strokeColor = _this$props2.strokeColor,
            restProps = _objectWithoutProperties(_this$props2, ["prefixCls", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor"]);
  
        var _getPathStyles2 = getPathStyles(0, 100, trailColor, strokeWidth, gapDegree, gapPosition),
            pathString = _getPathStyles2.pathString,
            pathStyle = _getPathStyles2.pathStyle;
  
        delete restProps.percent;
        var isGradient = Object.prototype.toString.call(strokeColor) === '[object Object]';
        return _react["default"].createElement("svg", _extends({
          className: "".concat(prefixCls, "-circle ").concat(className),
          viewBox: "0 0 100 100",
          style: style
        }, restProps), isGradient && _react["default"].createElement("defs", null, _react["default"].createElement("linearGradient", {
          id: "gradient",
          x1: "100%",
          y1: "0%",
          x2: "0%",
          y2: "0%"
        }, Object.keys(strokeColor).map(function (key, index) {
          return _react["default"].createElement("stop", {
            key: index,
            offset: key,
            stopColor: strokeColor[key]
          });
        }))), _react["default"].createElement("path", {
          className: "".concat(prefixCls, "-circle-trail"),
          d: pathString,
          stroke: trailColor,
          strokeLinecap: strokeLinecap,
          strokeWidth: trailWidth || strokeWidth,
          fillOpacity: "0",
          style: pathStyle
        }), this.getStokeList().reverse());
      }
    }]);
  
    return Circle;
  }(_react.Component);
  
  Circle.propTypes = _objectSpread({}, _types.propTypes, {
    gapPosition: _propTypes["default"].oneOf(['top', 'bottom', 'left', 'right'])
  });
  Circle.defaultProps = _objectSpread({}, _types.defaultProps, {
    gapPosition: 'top'
  });
  
  var _default = (0, _enhancer["default"])(Circle);
  
  exports["default"] = _default;