import { defineComponent, computed, createVNode, Fragment } from 'vue';
import '../../../utils/index.mjs';
import '../../../vue-components/index.mjs';
import { Tooltip } from '../../tooltip/index.mjs';
import { progressCircleProps } from './props.mjs';
import { getSize, getPercentage, getStrokeColor } from './utils.mjs';
import { initDefaultProps } from '../../../utils/vue/initDefaultProps.mjs';
import VCCircle from '../../../vue-components/vc-progress/src/Circle.mjs';

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

export { Circle as default };
//# sourceMappingURL=Circle.mjs.map
