import React, { useState } from 'react';
import { useUIFunctions, useConfigState, useGlobalLabels } from '@sentecacommerce-theme/lib';
import { Headers, LoginForm, RegisterForm, ForgotPassword } from './Components';
import { Modal, Button } from '../../';
export var AuthPopup = props => {
  var {
    isCheckout
  } = props;
  var [currentForm, setCurrentForm] = useState('Login');
  var {
    buttons
  } = useGlobalLabels();
  var {
    closeViewById
  } = useUIFunctions();

  var openForm = form => () => {
    setCurrentForm(form);
  };

  var {
    views
  } = useConfigState();

  var handleClose = () => closeViewById(views.auth);

  var Forms = {
    Login: /*#__PURE__*/React.createElement(LoginForm, {
      handleClose: handleClose,
      openForgotPassword: openForm('Forgot Password')
    }),
    Register: /*#__PURE__*/React.createElement(RegisterForm, {
      handleClose: handleClose
    }),
    'Forgot Password': /*#__PURE__*/React.createElement(ForgotPassword, {
      handleClose: handleClose,
      goBack: openForm('Login')
    })
  };
  return /*#__PURE__*/React.createElement(Modal, {
    withBottomOffset: true,
    maxWidth: "45rem",
    open: true,
    handleClose
  }, isCheckout && /*#__PURE__*/React.createElement("div", {
    className: "mt-4 mt-md-0 pb-2"
  }, /*#__PURE__*/React.createElement(Button, {
    bordered: true,
    borderRadius: "small",
    fullWidth: true,
    variant: "light",
    iconPosition: "right",
    link: "/checkout",
    onClick: handleClose
  }, /*#__PURE__*/React.createElement("p", {
    style: {
      lineHeight: '1.5'
    }
  }, buttons.guestCheckout))), currentForm !== 'Forgot Password' && /*#__PURE__*/React.createElement(Headers, {
    active: currentForm,
    setActive: setCurrentForm
  }), Forms[currentForm]);
};
//# sourceMappingURL=index.js.map