import { isVNode, defineComponent, computed, createVNode, mergeProps } from 'vue';
import { CheckOutlined, CloseOutlined } from '@ant-design/icons-vue';
import '../vc-steps/index.mjs';
import Progress from '../progress/index.mjs';
import Tooltip from '../tooltip/index.mjs';
import VcStep, { VcStepProps } from '../vc-steps/Step.mjs';
import { useToken } from '../theme/internal.mjs';
import { booleanType, arrayType, stringType, someType, functionType, anyType } from '../_util/type.mjs';
import initDefaultProps from '../_util/props-util/initDefaultProps.mjs';
import '../hooks/index.mjs';
import classNames from '../_util/classNames.mjs';
import omit from '../_util/omit.mjs';
import useStyle from './style/index.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';
import { useBreakpoint } from '../hooks/useBreakpoint.mjs';
import Steps$1 from '../vc-steps/Steps.mjs';

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const stepsProps = () => ({
  "prefixCls": String,
  "iconPrefix": String,
  "current": Number,
  "initial": Number,
  "percent": Number,
  "responsive": booleanType(),
  "items": arrayType(),
  "labelPlacement": stringType(),
  "status": stringType(),
  "size": stringType(),
  "direction": stringType(),
  "progressDot": someType([Boolean, Function]),
  "type": stringType(),
  "onChange": functionType(),
  "onUpdate:current": functionType()
});
const stepProps = () => ({
  description: anyType(),
  icon: anyType(),
  status: stringType(),
  disabled: booleanType(),
  title: anyType(),
  subTitle: anyType(),
  onClick: functionType()
});
const Steps = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ASteps",
  inheritAttrs: false,
  props: initDefaultProps(stepsProps(), {
    current: 0,
    responsive: true,
    labelPlacement: "horizontal"
  }),
  slots: Object,
  // emits: ['update:current', 'change'],
  setup(props, {
    attrs,
    slots,
    emit
  }) {
    const {
      prefixCls,
      direction: rtlDirection,
      configProvider
    } = useConfigInject("steps", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const [, token] = useToken();
    const screens = useBreakpoint();
    const direction = computed(() => props.responsive && screens.value.xs ? "vertical" : props.direction);
    const iconPrefix = computed(() => configProvider.getPrefixCls("", props.iconPrefix));
    const handleChange = (current) => {
      emit("update:current", current);
      emit("change", current);
    };
    const isInline = computed(() => props.type === "inline");
    const mergedPercent = computed(() => isInline.value ? void 0 : props.percent);
    const stepIconRender = ({
      node,
      status
    }) => {
      if (status === "process" && props.percent !== void 0) {
        const progressWidth = props.size === "small" ? token.value.controlHeight : token.value.controlHeightLG;
        const iconWithProgress = createVNode("div", {
          "class": `${prefixCls.value}-progress-icon`
        }, [createVNode(Progress, {
          "type": "circle",
          "percent": mergedPercent.value,
          "size": progressWidth,
          "strokeWidth": 4,
          "format": () => null
        }, null), node]);
        return iconWithProgress;
      }
      return node;
    };
    const icons = computed(() => ({
      finish: createVNode(CheckOutlined, {
        "class": `${prefixCls.value}-finish-icon`
      }, null),
      error: createVNode(CloseOutlined, {
        "class": `${prefixCls.value}-error-icon`
      }, null)
    }));
    return () => {
      const stepsClassName = classNames({
        [`${prefixCls.value}-rtl`]: rtlDirection.value === "rtl",
        [`${prefixCls.value}-with-progress`]: mergedPercent.value !== void 0
      }, attrs.class, hashId.value);
      const itemRender = (item, stepItem) => item.description ? createVNode(Tooltip, {
        "title": item.description
      }, _isSlot(stepItem) ? stepItem : {
        default: () => [stepItem]
      }) : stepItem;
      return wrapSSR(createVNode(Steps$1, mergeProps({
        "icons": icons.value
      }, attrs, omit(props, ["percent", "responsive"]), {
        "items": props.items,
        "direction": direction.value,
        "prefixCls": prefixCls.value,
        "iconPrefix": iconPrefix.value,
        "class": stepsClassName,
        "onChange": handleChange,
        "isInline": isInline.value,
        "itemRender": isInline.value ? itemRender : void 0
      }), {
        stepIcon: stepIconRender,
        ...slots
      }));
    };
  }
});
const Step = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  ...VcStep,
  name: "AStep",
  props: VcStepProps()
});
var index = Object.assign(Steps, {
  Step,
  install: (app) => {
    app.component(Steps.name, Steps);
    app.component(Step.name, Step);
    return app;
  }
});

export { Step, index as default, stepProps, stepsProps };
//# sourceMappingURL=index.mjs.map
