import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useRef } from 'react';
import { u as useId } from './useId-Jj9hXm-g.js';
import '@babel/runtime/helpers/slicedToArray';
import 'react-router-dom';
import '@bigbinary/neeto-hotkeys';
import './overlayManager.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'qs';
import 'ramda';
import './index-DyUNP5G9.js';
import 'i18next';
import Button from './Button.js';
import Modal from './Modal.js';
import Typography from './Typography.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'classnames';
import './Spinner.js';
import './Tooltip.js';
import '@tippyjs/react';
import 'tippy.js';
import './usePrefersReducedMotion-n4ZJtExQ.js';
import '@bigbinary/neeto-icons/Close';
import './Portal-qx5uRFGk.js';
import './index-QWVp_Xt6.js';
import './en-Dmu3B4Vs.js';
import '@babel/runtime/helpers/esm/extends';
import '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
import '@babel/runtime/helpers/esm/inheritsLoose';
import 'react-dom';

var _excluded = ["size", "isOpen", "isSubmitting", "className", "closeOnEsc", "closeButton", "backdropClassName", "closeOnOutsideClick", "onClose", "onSubmit", "title", "message", "submitButtonLabel", "cancelButtonLabel", "initialFocusRef", "initialFocusElement", "hideCancelButton", "style"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var SIZES = {
  medium: "medium"};
var FOCUSABLE_ELEMENTS = {
  submit: "submit"};
var ALERT_STYLES = {
  danger: "danger"};
var Alert = function Alert(_ref) {
  var _ref$size = _ref.size,
    size = _ref$size === void 0 ? SIZES.medium : _ref$size,
    _ref$isOpen = _ref.isOpen,
    isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
    _ref$isSubmitting = _ref.isSubmitting,
    isSubmitting = _ref$isSubmitting === void 0 ? false : _ref$isSubmitting,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    _ref$closeOnEsc = _ref.closeOnEsc,
    closeOnEsc = _ref$closeOnEsc === void 0 ? true : _ref$closeOnEsc,
    _ref$closeButton = _ref.closeButton,
    closeButton = _ref$closeButton === void 0 ? true : _ref$closeButton,
    _ref$backdropClassNam = _ref.backdropClassName,
    backdropClassName = _ref$backdropClassNam === void 0 ? "" : _ref$backdropClassNam,
    _ref$closeOnOutsideCl = _ref.closeOnOutsideClick,
    closeOnOutsideClick = _ref$closeOnOutsideCl === void 0 ? true : _ref$closeOnOutsideCl,
    _ref$onClose = _ref.onClose,
    onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
    _ref$onSubmit = _ref.onSubmit,
    onSubmit = _ref$onSubmit === void 0 ? function () {} : _ref$onSubmit,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? "" : _ref$title,
    _ref$message = _ref.message,
    message = _ref$message === void 0 ? "" : _ref$message,
    _ref$submitButtonLabe = _ref.submitButtonLabel,
    submitButtonLabel = _ref$submitButtonLabe === void 0 ? "Continue" : _ref$submitButtonLabe,
    _ref$cancelButtonLabe = _ref.cancelButtonLabel,
    cancelButtonLabel = _ref$cancelButtonLabe === void 0 ? "Cancel" : _ref$cancelButtonLabe,
    initialFocusRef = _ref.initialFocusRef,
    initialFocusElement = _ref.initialFocusElement,
    _ref$hideCancelButton = _ref.hideCancelButton,
    hideCancelButton = _ref$hideCancelButton === void 0 ? false : _ref$hideCancelButton,
    _ref$style = _ref.style,
    submitButtonStyle = _ref$style === void 0 ? ALERT_STYLES.danger : _ref$style,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  var submitButtonRef = useRef(null);
  var cancelButtonRef = useRef(null);
  var hasCustomFocusableElement = !!initialFocusRef || initialFocusElement;
  var initialFocusElementRef = initialFocusElement === FOCUSABLE_ELEMENTS.submit ? submitButtonRef : cancelButtonRef;

  // Generate unique IDs for title and message
  var baseId = useId();
  var titleId = "alert-title-".concat(baseId);
  var messageId = "alert-message-".concat(baseId);
  var ariaProps = _objectSpread(_objectSpread({}, title && {
    "aria-labelledby": titleId
  }), message && {
    "aria-describedby": messageId
  });
  return /*#__PURE__*/jsxs(Modal, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread(_objectSpread({
    backdropClassName: backdropClassName,
    className: className,
    closeButton: closeButton,
    closeOnEsc: closeOnEsc,
    closeOnOutsideClick: closeOnOutsideClick,
    isOpen: isOpen,
    onClose: onClose,
    size: size
  }, hasCustomFocusableElement && {
    initialFocusRef: initialFocusRef || initialFocusElementRef
  }), ariaProps), otherProps)), {}, {
    "data-testid": "alert-box",
    role: "alertdialog",
    children: [/*#__PURE__*/jsx(Modal.Header, {
      children: /*#__PURE__*/jsx(Typography, {
        "data-testid": "alert-title",
        id: titleId,
        style: "h2",
        children: title
      })
    }), /*#__PURE__*/jsx(Modal.Body, {
      children: /*#__PURE__*/jsx(Typography, {
        "data-testid": "alert-message",
        id: messageId,
        lineHeight: "normal",
        style: "body2",
        children: message
      })
    }), /*#__PURE__*/jsxs(Modal.Footer, {
      className: "neeto-ui-gap-2 neeto-ui-flex neeto-ui-justify-end neeto-ui-items-center",
      children: [!hideCancelButton && /*#__PURE__*/jsx(Button, {
        "data-testid": "alert-cancel-button",
        label: cancelButtonLabel,
        ref: cancelButtonRef,
        style: "tertiary",
        onClick: onClose
      }), /*#__PURE__*/jsx(Button, {
        "data-testid": "alert-submit-button",
        disabled: isSubmitting || !isOpen,
        label: submitButtonLabel,
        loading: isSubmitting,
        ref: submitButtonRef,
        style: submitButtonStyle,
        onClick: onSubmit
      })]
    })]
  }));
};

export { Alert as default };
//# sourceMappingURL=Alert.js.map
