"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const Steps = require("../steps/Steps.js");
const index_esm = require("../../../@vant/use/dist/index.esm.js");
const index = require("../icon/index.js");
const create = require("../utils/create.js");
const constant = require("../utils/constant.js");
const [name, bem] = create.createNamespace("step");
var stdin_default = Vue.defineComponent({
  name,
  setup(props, {
    slots
  }) {
    const {
      parent,
      index: index$1
    } = index_esm.useParent(Steps.STEPS_KEY);
    if (!parent) {
      return;
    }
    const parentProps = parent.props;
    const getStatus = () => {
      const active = +parentProps.active;
      if (index$1.value < active) {
        return "finish";
      }
      return index$1.value === active ? "process" : "waiting";
    };
    const isActive = () => getStatus() === "process";
    const lineStyle = Vue.computed(() => ({
      background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
    }));
    const titleStyle = Vue.computed(() => {
      if (isActive()) {
        return {
          color: parentProps.activeColor
        };
      }
      if (getStatus() === "waiting") {
        return {
          color: parentProps.inactiveColor
        };
      }
    });
    const onClickStep = () => parent.onClickStep(index$1.value);
    const renderCircle = () => {
      const {
        iconPrefix,
        finishIcon,
        activeIcon,
        activeColor,
        inactiveIcon
      } = parentProps;
      if (isActive()) {
        if (slots["active-icon"]) {
          return slots["active-icon"]();
        }
        return Vue.createVNode(index.Icon, {
          "class": bem("icon", "active"),
          "name": activeIcon,
          "color": activeColor,
          "classPrefix": iconPrefix
        }, null);
      }
      if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
        if (slots["finish-icon"]) {
          return slots["finish-icon"]();
        }
        return Vue.createVNode(index.Icon, {
          "class": bem("icon", "finish"),
          "name": finishIcon,
          "color": activeColor,
          "classPrefix": iconPrefix
        }, null);
      }
      if (slots["inactive-icon"]) {
        return slots["inactive-icon"]();
      }
      if (inactiveIcon) {
        return Vue.createVNode(index.Icon, {
          "class": bem("icon"),
          "name": inactiveIcon,
          "classPrefix": iconPrefix
        }, null);
      }
      return Vue.createVNode("i", {
        "class": bem("circle"),
        "style": lineStyle.value
      }, null);
    };
    return () => {
      var _a;
      const status = getStatus();
      return Vue.createVNode("div", {
        "class": [constant.BORDER, bem([parentProps.direction, {
          [status]: status
        }])]
      }, [Vue.createVNode("div", {
        "class": bem("title", {
          active: isActive()
        }),
        "style": titleStyle.value,
        "onClick": onClickStep
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), Vue.createVNode("div", {
        "class": bem("circle-container"),
        "onClick": onClickStep
      }, [renderCircle()]), Vue.createVNode("div", {
        "class": bem("line"),
        "style": lineStyle.value
      }, null)]);
    };
  }
});
exports.default = stdin_default;
