import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ContentState } from '../../components/ContentState';
import { Step } from '../../components/NewStepper';
import { Form } from '../Form';
import { Footer } from './Footer';
import { BeforeContentWrapper, FormContent, StyledNewStepper, Wrapper, } from './styles';
import { useLogic } from './useLogic';
/**
 * FormWizard предназначен для построения форм со степпером.
 */
export const FormWizard = (props) => {
    const { Component, footerProps, activeStep, steps } = useLogic(props);
    const { className, isFirstStep, isLastStep, isDisabled, isLoading, isError, form, customFooter, errorMsg, onRetry, onClickStep, onPrevStep, onSubmit, onSubmitError, beforeContent, submitButtonProps, } = props;
    const renderFooter = () => {
        if (customFooter) {
            return customFooter({
                isDisabled,
                isFirstStep,
                isLastStep,
                onPrevStep,
                submitButtonProps,
                ...footerProps,
            });
        }
        return (_jsx(Footer, { isDisabled: isDisabled, isFirstStep: isFirstStep, isLastStep: isLastStep, onPrevStep: onPrevStep, submitButtonProps: submitButtonProps, ...footerProps }));
    };
    return (_jsxs(Wrapper, { className: className, children: [beforeContent && (_jsx(BeforeContentWrapper, { children: beforeContent })), _jsx(StyledNewStepper, { connector: "arrow", onClickPrevStep: onClickStep, activeStep: activeStep, children: steps.map((step) => (_jsx(Step, { ...step }, step.stepId))) }), _jsx(ContentState, { isLoading: isLoading, isError: isError, 
                // biome-ignore lint/suspicious/noTsIgnore: onRetry не требуется, если форма не инициализируется данными, получаемыми с backend
                // @ts-ignore
                errorState: { errorList: [errorMsg || ''], onRetry }, children: _jsxs(Form, { form: form, isDisabled: isDisabled, onSubmit: form.handleSubmit(onSubmit, onSubmitError), children: [_jsx(FormContent, { children: _jsx(Component, {}) }), renderFooter()] }) })] }));
};
