'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
require('../../../vue-components/index.cjs');
var index = require('../../tooltip/index.cjs');
var props = require('./props.cjs');
var utils = require('./utils.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');
var Circle$1 = require('../../../vue-components/vc-progress/src/Circle.cjs');

var Circle = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ProgressCircle",
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(props.progressCircleProps(), {
    trailColor: null
  }),
  setup(props, {
    slots,
    attrs
  }) {
    const CIRCLE_MIN_STROKE_WIDTH = 3;
    const getMinPercent = (width) => CIRCLE_MIN_STROKE_WIDTH / width * 100;
    const originWidth = vue.computed(() => {
      var _a;
      return (_a = props.width) != null ? _a : 120;
    });
    const mergedSize = vue.computed(() => {
      var _a;
      return (_a = props.size) != null ? _a : [originWidth.value, originWidth.value];
    });
    const sizeRef = vue.computed(() => utils.getSize(mergedSize.value, "circle"));
    const gapDeg = vue.computed(() => {
      if (props.gapDegree || props.gapDegree === 0)
        return props.gapDegree;
      if (props.type === "dashboard")
        return 75;
      return void 0;
    });
    const circleStyle = vue.computed(() => {
      return {
        width: `${sizeRef.value.width}px`,
        height: `${sizeRef.value.height}px`,
        fontSize: `${sizeRef.value.width * 0.15 + 6}px`
      };
    });
    const circleWidth = vue.computed(() => {
      var _a;
      return (_a = props.strokeWidth) != null ? _a : Math.max(getMinPercent(sizeRef.value.width), 6);
    });
    const gapPos = vue.computed(() => props.gapPosition || props.type === "dashboard" && "bottom" || void 0);
    const percent = vue.computed(() => utils.getPercentage(props));
    const isGradient = vue.computed(() => Object.prototype.toString.call(props.strokeColor) === "[object Object]");
    const strokeColor = vue.computed(() => utils.getStrokeColor({
      success: props.success,
      strokeColor: props.strokeColor
    }));
    const wrapperClassName = vue.computed(() => ({
      [`${props.prefixCls}-inner`]: true,
      [`${props.prefixCls}-circle-gradient`]: isGradient.value
    }));
    return () => {
      var _a;
      const circleContent = vue.createVNode(Circle$1.default, {
        "percent": percent.value,
        "strokeWidth": circleWidth.value,
        "trailWidth": circleWidth.value,
        "strokeColor": strokeColor.value,
        "strokeLinecap": props.strokeLinecap,
        "trailColor": props.trailColor,
        "prefixCls": props.prefixCls,
        "gapDegree": gapDeg.value,
        "gapPosition": gapPos.value
      }, null);
      return vue.createVNode("div", {
        ...attrs,
        "class": [wrapperClassName.value, attrs.class],
        "style": [attrs.style, circleStyle.value]
      }, [sizeRef.value.width <= 20 ? vue.createVNode(index.Tooltip, null, {
        default: () => [vue.createVNode("span", null, [circleContent])],
        title: slots.default
      }) : vue.createVNode(vue.Fragment, null, [circleContent, (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
    };
  }
});

exports.default = Circle;
//# sourceMappingURL=Circle.cjs.map
