"use strict";

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

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

var _tooltipText = _interopRequireDefault(require("../../tooltip/tooltip-text"));

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function CircleProgress(props) {
  var _props$size = props.size,
      size = _props$size === void 0 ? 100 : _props$size,
      _props$color = props.color,
      color = _props$color === void 0 ? "#419BFF" : _props$color,
      _props$percent = props.percent,
      percent = _props$percent === void 0 ? 0 : _props$percent,
      _props$width = props.width,
      width = _props$width === void 0 ? 8 : _props$width,
      _props$backgroundColo = props.backgroundColor,
      backgroundColor = _props$backgroundColo === void 0 ? "rgba(40, 121, 255, 0.11)" : _props$backgroundColo,
      _props$linear = props.linear,
      linear = _props$linear === void 0 ? false : _props$linear,
      _props$linearId = props.linearId,
      linearId = _props$linearId === void 0 ? "linearGradient" : _props$linearId,
      _props$linearStartCol = props.linearStartColor,
      linearStartColor = _props$linearStartCol === void 0 ? "#4e90ff" : _props$linearStartCol,
      _props$linearEndColor = props.linearEndColor,
      linearEndColor = _props$linearEndColor === void 0 ? "#2879ff" : _props$linearEndColor,
      _props$showTextConten = props.showTextContent,
      showTextContent = _props$showTextConten === void 0 ? true : _props$showTextConten,
      _props$textcolor = props.textcolor,
      textcolor = _props$textcolor === void 0 ? "#89919F" : _props$textcolor,
      _props$textClass = props.textClass,
      textClass = _props$textClass === void 0 ? "" : _props$textClass;
  var p = percent > 100 ? 100 : percent;
  var c = Math.round((size - width * 2) * Math.PI);
  var remainC = Math.round(c * (100 - p) / 100);
  return /*#__PURE__*/_react["default"].createElement("span", {
    className: "titaui-progress-circle"
  }, /*#__PURE__*/_react["default"].createElement("svg", {
    width: size,
    height: size,
    viewBox: "0 0 ".concat(size, " ").concat(size)
  }, /*#__PURE__*/_react["default"].createElement("circle", {
    cx: size / 2,
    cy: size / 2,
    r: size / 2 - width,
    fill: "none",
    stroke: backgroundColor,
    strokeWidth: width
  }), /*#__PURE__*/_react["default"].createElement("circle", {
    cx: size / 2,
    cy: size / 2,
    r: size / 2 - width,
    fill: "none",
    stroke: linear ? "url(#".concat(linearId, ")") : color,
    strokeWidth: width,
    strokeDasharray: c,
    strokeDashoffset: remainC,
    strokeLinecap: "round",
    transform: "rotate(-90, ".concat(size / 2, " ").concat(size / 2, ")"),
    style: {
      transition: "stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s ease 0s, stroke-width 0.06s ease 0.3s"
    }
  }), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("linearGradient", {
    x1: "96.9769965%",
    y1: "80.9878035%",
    x2: "0%",
    y2: "41.7547666%",
    id: linearId
  }, /*#__PURE__*/_react["default"].createElement("stop", {
    stopColor: linearStartColor,
    offset: "0%"
  }), /*#__PURE__*/_react["default"].createElement("stop", {
    stopColor: linearEndColor,
    offset: "100%"
  })))), // 这里新增的tooltip是因为测试测了很大的数据，我这里卡死到1000显示...后需调整请自增参数
  showTextContent && /*#__PURE__*/_react["default"].createElement(_tooltipText["default"], {
    text: "".concat(percent, "%"),
    maxWidth: 50
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(textClass, " text-content"),
    style: {
      marginLeft: 2,
      color: textcolor
    }
  }, "".concat(percent, "%"))));
}

CircleProgress.defaultProps = {
  textClass: ""
};
var _default = CircleProgress;
exports["default"] = _default;