import { _ as _define_property } from "@swc/helpers/_/_define_property";
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
import React, { useContext } from "react";
import classNames from "classnames";
import { DataContext } from "../steps/context";
import { ComponentDefaults } from "../../utils/typings";
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
    title: '',
    description: '',
    value: 0,
    icon: null
});
export var Step = function(props) {
    var _ref = _object_spread({}, defaultProps, props), children = _ref.children, title = _ref.title, description = _ref.description, value = _ref.value, icon = _ref.icon, className = _ref.className, restProps = _object_without_properties(_ref, [
        "children",
        "title",
        "description",
        "value",
        "icon",
        "className"
    ]);
    var parent = useContext(DataContext);
    var dot = parent.propSteps.dot;
    var getCurrentStatus = function() {
        var index = value;
        if (index < +parent.propSteps.value) return 'finish';
        return index === +parent.propSteps.value ? 'process' : 'wait';
    };
    var handleClickStep = function() {
        var _parent_propSteps, _parent_propSteps1;
        ((_parent_propSteps = parent.propSteps) === null || _parent_propSteps === void 0 ? void 0 : _parent_propSteps.onStepClick) && ((_parent_propSteps1 = parent.propSteps) === null || _parent_propSteps1 === void 0 ? void 0 : _parent_propSteps1.onStepClick(value));
    };
    var classPrefix = "nut-step";
    var classes = classNames(classPrefix, _define_property({}, "".concat(classPrefix, "-").concat(getCurrentStatus()), true), className);
    var renderIconClass = function() {
        if (icon) {
            return "".concat(classPrefix, "-icon is-icon");
        }
        if (!dot && !icon) {
            return "".concat(classPrefix, "-icon is-text");
        }
        return "".concat(classPrefix, "-icon");
    };
    return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({
        className: classes
    }, restProps), {
        onClick: handleClickStep
    }), /*#__PURE__*/ React.createElement("div", {
        className: "nut-step-head"
    }, /*#__PURE__*/ React.createElement("div", {
        className: "nut-step-line"
    }), /*#__PURE__*/ React.createElement("div", {
        className: renderIconClass()
    }, icon || !dot && /*#__PURE__*/ React.createElement("span", {
        className: "nut-step-inner"
    }, value))), (title || description) && /*#__PURE__*/ React.createElement("div", {
        className: "nut-step-main"
    }, /*#__PURE__*/ React.createElement("span", {
        className: "nut-step-title"
    }, title), description && /*#__PURE__*/ React.createElement("span", {
        className: "nut-step-description"
    }, description)));
};
Step.displayName = 'NutStep';
