import { clsx } from 'clsx';
import { useIntl } from 'react-intl';
import { CloseButton } from '../common/closeButton/CloseButton.mjs';
import FlowHeader from '../common/flowHeader/FlowHeader.mjs';
import Logo from '../logo/Logo.mjs';
import Stepper from '../stepper/Stepper.mjs';
import { useScreenSize } from '../common/hooks/useScreenSize.mjs';
import messages from './FlowNavigation.messages.mjs';
import AnimatedLabel from './animatedLabel/AnimatedLabel.mjs';
import BackButton from './backButton/BackButton.mjs';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import { Breakpoint } from '../common/propsValues/breakpoint.mjs';
import { Layout } from '../common/propsValues/layouts.mjs';

const FlowNavigation = ({
  activeStep = 0,
  avatar,
  logo = /*#__PURE__*/jsx(Logo, {}),
  done = false,
  onClose,
  onGoBack,
  steps
}) => {
  const intl = useIntl();
  const closeButton = onClose != null && /*#__PURE__*/jsx(CloseButton, {
    size: "lg",
    onClick: onClose
  });
  const screenSm = useScreenSize(Breakpoint.SMALL);
  const screenLg = useScreenSize(Breakpoint.LARGE);
  const newAvatar = done ? null : avatar;
  const displayGoBack = onGoBack != null && activeStep > 0;
  return /*#__PURE__*/jsx("div", {
    className: clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
      'np-flow-navigation--border-bottom': !done
    }),
    children: /*#__PURE__*/jsx(FlowHeader, {
      className: clsx('np-flow-navigation__content p-x-3', screenSm == null ? 'np-flow-navigation--hidden' : {
        'np-flow-navigation--xs-max': !screenSm,
        // Size switches on parent container which may or may not have the same size as the window.
        'np-flow-navigation--sm': screenSm,
        'np-flow-navigation--lg': screenLg
      }),
      leftContent: /*#__PURE__*/jsxs(Fragment, {
        children: [!screenSm && displayGoBack ? /*#__PURE__*/jsx(BackButton, {
          "aria-label": intl.formatMessage(messages.back),
          onClick: onGoBack
        }) : /*#__PURE__*/jsx("div", {
          className: "np-flow-header__left",
          children: logo
        }), !screenSm && !done && /*#__PURE__*/jsx(AnimatedLabel, {
          className: "m-x-1",
          steps: steps,
          activeLabel: activeStep
        })]
      }),
      rightContent: /*#__PURE__*/jsxs("div", {
        className: "np-flow-header__right d-flex align-items-center justify-content-end order-2--lg",
        children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
          className: "m-x-1"
        }), closeButton]
      }),
      bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
        activeStep: activeStep,
        steps: steps,
        className: clsx('np-flow-navigation__stepper')
      }),
      layout: !screenLg ? Layout.VERTICAL : Layout.HORIZONTAL
    })
  });
};

export { FlowNavigation as default };
//# sourceMappingURL=FlowNavigation.mjs.map
