'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var Step = require('./Step.cjs');
var vueTypes = require('../../../utils/vue/vueTypes.cjs');
var propType = require('../../../utils/vue/propType.cjs');
var vnode = require('../../../utils/vue/vnode.cjs');
var _class = require('../../../utils/dom/class.cjs');
var props = require('../../../utils/vue/props.cjs');

var VcSteps = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Steps",
  props: {
    type: vueTypes.default.string.def("default"),
    prefixCls: vueTypes.default.string.def("vc-steps"),
    iconPrefix: vueTypes.default.string.def("vc"),
    direction: vueTypes.default.string.def("horizontal"),
    labelPlacement: vueTypes.default.string.def("horizontal"),
    status: propType.stringType("process"),
    size: vueTypes.default.string.def(""),
    progressDot: vueTypes.default.oneOfType([vueTypes.default.looseBool, vueTypes.default.func]).def(void 0),
    initial: vueTypes.default.number.def(0),
    current: vueTypes.default.number.def(0),
    items: vueTypes.default.array.def(() => []),
    icons: vueTypes.default.shape({
      finish: vueTypes.default.any,
      error: vueTypes.default.any
    }).loose,
    stepIcon: propType.functionType(),
    isInline: vueTypes.default.looseBool,
    itemRender: propType.functionType()
  },
  emits: ["change"],
  setup(props$1, {
    slots,
    emit
  }) {
    const onStepClick = (next) => {
      const {
        current
      } = props$1;
      if (current !== next)
        emit("change", next);
    };
    const renderStep = (item, index, legacyRender) => {
      const {
        prefixCls,
        iconPrefix,
        status,
        current,
        initial,
        icons,
        stepIcon = slots.stepIcon,
        isInline,
        itemRender,
        progressDot = slots.progressDot
      } = props$1;
      const mergedProgressDot = isInline || progressDot;
      const mergedItem = {
        ...item,
        class: ""
      };
      const stepNumber = initial + index;
      const commonProps = {
        active: stepNumber === current,
        stepNumber: stepNumber + 1,
        stepIndex: stepNumber,
        key: stepNumber,
        prefixCls,
        iconPrefix,
        progressDot: mergedProgressDot,
        stepIcon,
        icons,
        onStepClick
      };
      if (status === "error" && index === current - 1)
        mergedItem.class = `${prefixCls}-next-error`;
      if (!mergedItem.status) {
        if (stepNumber === current)
          mergedItem.status = status;
        else if (stepNumber < current)
          mergedItem.status = "finish";
        else
          mergedItem.status = "wait";
      }
      if (isInline) {
        mergedItem.icon = void 0;
        mergedItem.subTitle = void 0;
      }
      if (legacyRender)
        return legacyRender({
          ...mergedItem,
          ...commonProps
        });
      if (itemRender)
        mergedItem.itemRender = (stepItem) => itemRender(mergedItem, stepItem);
      return vue.createVNode(Step.default, {
        ...mergedItem,
        ...commonProps,
        "__legacy": false
      }, null);
    };
    const renderStepWithNode = (node, index) => {
      return renderStep({
        ...node.props
      }, index, (stepProps) => {
        const stepNode = vnode.cloneElement(node, stepProps);
        return stepNode;
      });
    };
    return () => {
      var _a;
      const {
        prefixCls,
        direction,
        type,
        labelPlacement,
        iconPrefix,
        status,
        size,
        current,
        progressDot = slots.progressDot,
        initial,
        icons,
        items,
        isInline,
        itemRender,
        ...restProps
      } = props$1;
      const isNav = type === "navigation";
      const mergedProgressDot = isInline || progressDot;
      const mergedDirection = isInline ? "horizontal" : direction;
      const mergedSize = isInline ? void 0 : size;
      const adjustedLabelPlacement = mergedProgressDot ? "vertical" : labelPlacement;
      const classString = _class.classNames(prefixCls, `${prefixCls}-${direction}`, {
        [`${prefixCls}-${mergedSize}`]: mergedSize,
        [`${prefixCls}-label-${adjustedLabelPlacement}`]: mergedDirection === "horizontal",
        [`${prefixCls}-dot`]: !!mergedProgressDot,
        [`${prefixCls}-navigation`]: isNav,
        [`${prefixCls}-inline`]: isInline
      });
      return vue.createVNode("div", {
        "class": classString,
        ...restProps
      }, [items.filter((item) => item).map((item, index) => renderStep(item, index)), props.filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots)).map(renderStepWithNode)]);
    };
  }
});

exports.default = VcSteps;
//# sourceMappingURL=Steps.cjs.map
