import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import Button from "../Button";
import HeaderCloseBtn from "../HeaderCloseBtn";
import Transition from "../Transition";
import Styles from "./FlowController.module.scss";
/**
 * Container for a flow, managing the go back and close controller
 **/
/**
 * A container that manages navigation controls for a multi-step flow.
 * It handles showing back buttons, close buttons, and manages the transition between steps.
 */
export default function FlowController({ children, buttons, step, onClose, onBack, fullPage, firstStep = 0, style, wrapper: Wrapper = "div", }) {
    function _handleBackPress() {
        if (isAtFirstStep)
            onClose && onClose();
        else if (onBack)
            onBack();
    }
    const isAtFirstStep = step === firstStep;
    const shouldDisplayHeaderButton = (isAtFirstStep && onClose) || (!isAtFirstStep && onBack);
    return (_jsxs(Wrapper, { onClick: (e) => e.stopPropagation(), className: Styles.container, style: style, children: [_jsx("header", { children: shouldDisplayHeaderButton && (_jsx(HeaderCloseBtn, { mode: isAtFirstStep ? "close" : "back", hidden: !onBack, onClick: _handleBackPress })) }), _jsx(Transition, { step: step, className: Styles.transition, contentClassName: `${fullPage ? Styles.fullHeight : ""} ${Styles.content}`, children: children }), _jsx("footer", { className: buttons.find((b) => b.state === "hidden") ? Styles.hidden : undefined, children: buttons.map((b) => (_jsx(Button, { onClick: b.onClick, disabled: b.state === "hidden" || b.state === "disabled", children: b.label }))) })] }));
}
export function HeadingImage({ src }) {
    return _jsx("img", { src: src, className: Styles.headingImg });
}
//# sourceMappingURL=FlowController.js.map