"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Step = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const classNames_1 = require("../../utils/classNames");
const cva_1 = require("../../utils/cva");
const StepIcon_1 = require("../StepIcon");
const constants_1 = require("./constants");
const Description_1 = require("./Description");
const Label_1 = require("./Label");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const step = (0, cva_1.cva)(constants_1.stepClassnames.root, {
    variants: {
        isError: {
            true: constants_1.stepClassnames.error,
        },
        isCompleted: {
            true: constants_1.stepClassnames.completed,
        },
        connector: {
            arrow: constants_1.stepClassnames.connectorArrow,
            line: constants_1.stepClassnames.connectorLine,
        },
        activeStep: {
            true: constants_1.stepClassnames.active,
        },
        alternativeLabel: {
            true: constants_1.stepClassnames.alternativeLabel,
        },
        orientation: {
            horizontal: constants_1.stepClassnames.orientationHorizontal,
            vertical: constants_1.stepClassnames.orientationVertical,
        },
        isDisabled: {
            true: constants_1.stepClassnames.disabled,
        },
    },
});
const connector = (0, cva_1.cva)(constants_1.stepClassnames.connector, {
    variants: {
        connector: {
            arrow: constants_1.stepClassnames.connectorArrow,
            line: constants_1.stepClassnames.connectorLine,
        },
        alternativeLabel: {
            true: constants_1.stepClassnames.alternativeLabel,
        },
        orientation: {
            horizontal: constants_1.stepClassnames.orientationHorizontal,
            vertical: constants_1.stepClassnames.orientationVertical,
        },
        hasDescription: {
            true: constants_1.stepClassnames.hasDescription,
        },
    },
});
const Step = (props) => {
    const { isCompletedStep, isRenderButton, handleClick, connectorVariant, alternativeLabel, orientation, children, isError, isWarning, icon, className, label, isRenderVerticalLineConnector, isRenderHorizontalLineConnector, isDisabled, isActiveStep, } = (0, useLogic_1.useLogic)(props);
    const StepContent = isRenderButton ? styles_1.StyledButton : styles_1.StepContentWrapper;
    return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { "data-active-step": isActiveStep, className: (0, classNames_1.classNames)(step({
            isError,
            isCompleted: isCompletedStep,
            connector: connectorVariant,
            activeStep: isActiveStep,
            alternativeLabel,
            orientation,
            isDisabled,
        }), className), children: [(0, jsx_runtime_1.jsxs)(StepContent, { variant: "text", onClick: handleClick, disabled: isDisabled, className: (0, classNames_1.classNames)(constants_1.stepClassnames.content, {
                    [constants_1.stepClassnames.active]: isActiveStep,
                }), children: [(0, jsx_runtime_1.jsxs)(styles_1.LabelWrapper, { className: constants_1.stepClassnames.labelContainer, children: [(0, jsx_runtime_1.jsx)(styles_1.IconWrapper, { className: constants_1.stepClassnames.iconContainer, children: (0, jsx_runtime_1.jsx)(StepIcon_1.StepIcon, { icon: icon, isActive: isActiveStep, isCompleted: isCompletedStep, isError: isError, isWarning: isWarning }) }), (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, isActiveStep: isActiveStep }), connectorVariant === 'arrow' && ((0, jsx_runtime_1.jsx)(styles_1.ArrowConnector, { className: connector({
                                    connector: connectorVariant,
                                    alternativeLabel,
                                    orientation,
                                }) }))] }), children && ((0, jsx_runtime_1.jsx)(Description_1.Description, { className: constants_1.stepClassnames.description, children: children })), isRenderVerticalLineConnector && ((0, jsx_runtime_1.jsx)(styles_1.LineConnector, { className: connector({
                            connector: connectorVariant,
                            orientation,
                        }) }))] }), isRenderHorizontalLineConnector && ((0, jsx_runtime_1.jsx)(styles_1.LineConnector, { className: connector({
                    connector: connectorVariant,
                    alternativeLabel,
                    orientation,
                }) }))] }));
};
exports.Step = Step;
