'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var propType = require('../../../utils/vue/propType.cjs');
var vueTypes = require('../../../utils/vue/vueTypes.cjs');
var util = require('../../../utils/vue/util.cjs');
var _class = require('../../../utils/dom/class.cjs');
var omit = require('../../../utils/lang/omit.cjs');

function isString(str) {
  return typeof str === "string";
}
function noop() {
}
function VcStepProps() {
  return {
    prefixCls: String,
    itemWidth: String,
    active: {
      type: Boolean,
      default: void 0
    },
    disabled: {
      type: Boolean,
      default: void 0
    },
    status: propType.stringType(),
    iconPrefix: String,
    icon: vueTypes.default.any,
    adjustMarginRight: String,
    stepNumber: Number,
    stepIndex: Number,
    description: vueTypes.default.any,
    title: vueTypes.default.any,
    subTitle: vueTypes.default.any,
    progressDot: util.withUndefined(vueTypes.default.oneOfType([vueTypes.default.looseBool, vueTypes.default.func])),
    tailContent: vueTypes.default.any,
    icons: vueTypes.default.shape({
      finish: vueTypes.default.any,
      error: vueTypes.default.any
    }).loose,
    onClick: propType.functionType(),
    onStepClick: propType.functionType(),
    stepIcon: propType.functionType(),
    itemRender: propType.functionType(),
    __legacy: propType.booleanType()
  };
}
var VcStep = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Step",
  inheritAttrs: false,
  props: VcStepProps(),
  setup(props, {
    slots,
    emit,
    attrs
  }) {
    const onItemClick = (e) => {
      emit("click", e);
      emit("stepClick", props.stepIndex);
    };
    const renderIconNode = ({
      icon,
      title,
      description
    }) => {
      const {
        prefixCls,
        stepNumber,
        status,
        iconPrefix,
        icons,
        progressDot = slots.progressDot,
        stepIcon = slots.stepIcon
      } = props;
      let iconNode;
      const iconClassName = _class.classNames(`${prefixCls}-icon`, `${iconPrefix}icon`, {
        [`${iconPrefix}icon-${icon}`]: icon && isString(icon),
        [`${iconPrefix}icon-check`]: !icon && status === "finish" && (icons && !icons.finish || !icons),
        [`${iconPrefix}icon-cross`]: !icon && status === "error" && (icons && !icons.error || !icons)
      });
      const iconDot = vue.createVNode("span", {
        "class": `${prefixCls}-icon-dot`
      }, null);
      if (progressDot) {
        if (typeof progressDot === "function") {
          iconNode = vue.createVNode("span", {
            "class": `${prefixCls}-icon`
          }, [progressDot({
            iconDot,
            index: stepNumber - 1,
            status,
            title,
            description,
            prefixCls
          })]);
        } else {
          iconNode = vue.createVNode("span", {
            "class": `${prefixCls}-icon`
          }, [iconDot]);
        }
      } else if (icon && !isString(icon)) {
        iconNode = vue.createVNode("span", {
          "class": `${prefixCls}-icon`
        }, [icon]);
      } else if (icons && icons.finish && status === "finish") {
        iconNode = vue.createVNode("span", {
          "class": `${prefixCls}-icon`
        }, [icons.finish]);
      } else if (icons && icons.error && status === "error") {
        iconNode = vue.createVNode("span", {
          "class": `${prefixCls}-icon`
        }, [icons.error]);
      } else if (icon || status === "finish" || status === "error") {
        iconNode = vue.createVNode("span", {
          "class": iconClassName
        }, null);
      } else {
        iconNode = vue.createVNode("span", {
          "class": `${prefixCls}-icon`
        }, [stepNumber]);
      }
      if (stepIcon) {
        iconNode = stepIcon({
          index: stepNumber - 1,
          status,
          title,
          description,
          node: iconNode
        });
      }
      return iconNode;
    };
    return () => {
      var _a, _b, _c, _d;
      const {
        prefixCls,
        itemWidth,
        active,
        status = "wait",
        tailContent,
        adjustMarginRight,
        disabled,
        title = (_a = slots.title) == null ? void 0 : _a.call(slots),
        description = (_b = slots.description) == null ? void 0 : _b.call(slots),
        subTitle = (_c = slots.subTitle) == null ? void 0 : _c.call(slots),
        icon = (_d = slots.icon) == null ? void 0 : _d.call(slots),
        onClick,
        onStepClick
      } = props;
      const mergedStatus = status || "wait";
      const classString = _class.classNames(`${prefixCls}-item`, `${prefixCls}-item-${mergedStatus}`, {
        [`${prefixCls}-item-custom`]: icon,
        [`${prefixCls}-item-active`]: active,
        [`${prefixCls}-item-disabled`]: disabled === true
      });
      const stepItemStyle = {};
      if (itemWidth)
        stepItemStyle.width = itemWidth;
      if (adjustMarginRight)
        stepItemStyle.marginRight = adjustMarginRight;
      const accessibilityProps = {
        onClick: onClick || noop
      };
      if (onStepClick && !disabled) {
        accessibilityProps.role = "button";
        accessibilityProps.tabindex = 0;
        accessibilityProps.onClick = onItemClick;
      }
      const stepNode = vue.createVNode("div", {
        ...omit.omit(attrs, ["__legacy"]),
        "class": [classString, attrs.class],
        "style": [attrs.style, stepItemStyle]
      }, [vue.createVNode("div", {
        ...accessibilityProps,
        "class": `${prefixCls}-item-container`
      }, [vue.createVNode("div", {
        "class": `${prefixCls}-item-tail`
      }, [tailContent]), vue.createVNode("div", {
        "class": `${prefixCls}-item-icon`
      }, [renderIconNode({
        icon,
        title,
        description
      })]), vue.createVNode("div", {
        "class": `${prefixCls}-item-content`
      }, [vue.createVNode("div", {
        "class": `${prefixCls}-item-title`
      }, [title, subTitle && vue.createVNode("div", {
        "title": typeof subTitle === "string" ? subTitle : void 0,
        "class": `${prefixCls}-item-subtitle`
      }, [subTitle])]), description && vue.createVNode("div", {
        "class": `${prefixCls}-item-description`
      }, [description])])])]);
      if (props.itemRender)
        return props.itemRender(stepNode);
      return stepNode;
    };
  }
});

exports.VcStepProps = VcStepProps;
exports.default = VcStep;
//# sourceMappingURL=Step.cjs.map
