/* eslint-disable no-use-before-define, react/no-multi-comp */

/* eslint-enable no-use-before-define */

/* harmony default export */

/* harmony export (binding) */

/* harmony import */

/* ie throws if no active element */

/* should never change: */

/*#__PURE__*/

/**
   * A DOM element, a `ref` to an element, or function that returns either. The Modal is appended to it's `container` element.
   *
   * For the sake of assistive technologies, the container should usually be the document body, so that the rest of the
   * page content can be placed behind a virtual backdrop as well as a visual one.
   */

/**
   * A ModalManager instance used to track and manage the state of open
   * Modals. Useful when customizing how modals interact within a container
   */

/**
   * A `react-transition-group@2.0.0` `<Transition/>` component used
   * to control animations for the backdrop components.
   */

/**
   * A `react-transition-group@2.0.0` `<Transition/>` component used
   * to control animations for the dialog component.
   */

/**
   * A callback fired when either the backdrop is clicked, or the escape key is pressed.
   *
   * The `onHide` callback only signals intent from the Modal,
   * you must actually set the `show` prop to `false` for the Modal to close.
   */

/**
   * A callback fired when the Modal is opening.
   */

/**
   * A callback fired when the backdrop, if specified, is clicked.
   */

/**
   * A callback fired when the escape key, if specified in `keyboard`, is pressed.
   *
   * If preventDefault() is called on the keyboard event, closing the modal will be cancelled.
   */

/**
   * A css class or set of classes applied to the modal container when the modal is open,
   * and removed when it is closed.
   */

/**
   * A function that returns a backdrop component. Useful for custom
   * backdrop rendering.
   *
   * ```js
   *  renderBackdrop={props => <MyBackdrop {...props} />}
   * ```
   */

/**
   * A function that returns the dialog component. Useful for custom
   * rendering. **Note:** the component should make sure to apply the provided ref.
   *
   * ```js static
   * renderDialog={props => <MyDialog {...props} />}
   * ```
   */

/**
   * Callback fired after the Modal finishes transitioning in
   */

/**
   * Callback fired after the Modal finishes transitioning out
   */

/**
   * Callback fired as the Modal begins to transition in
   */

/**
   * Callback fired as the Modal begins to transition out
   */

/**
   * Callback fired before the Modal transitions in
   */

/**
   * Callback fired right before the Modal transitions out
   */

/**
   * Close the modal when escape key is pressed
   */

/**
   * Include a backdrop component.
   */

/**
   * Options passed to focus function when `restoreFocus` is set to `true`
   *
   * @link  https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#Parameters
   */

/**
   * Set the visibility of the Modal
   */

/**
   * When `true` The modal will automatically shift focus to itself when it opens, and
   * replace it to the last focused element when it closes. This also
   * works correctly with any Modal children that have the `autoFocus` prop.
   *
   * Generally this should never be set to `false` as it makes the Modal less
   * accessible to assistive technologies, like screen readers.
   */

/**
   * When `true` The modal will prevent focus from leaving the Modal while open.
   *
   * Generally this should never be set to `false` as it makes the Modal less
   * accessible to assistive technologies, like screen readers.
   */

/**
   * When `true` The modal will restore focus to previously focused element once
   * modal is hidden
   */

/**
 * Attach a callback that fires when a component unmounts
 *
 * @param fn Handler to run when the component unmounts
 * @category effects
 */

/**
 * Copyright 2013-2014, Facebook, Inc.
 * All rights reserved.
 * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js
 */

/**
 * Proper state management for containers and the modals in those containers.
 *
 * @internal Used by the Modal to ensure proper styling of containers.
 */

/**
 * Return the actively focused element safely.
 *
 * @param doc the document to checl
 */

/**
 * Returns a ref that is immediately updated with the new value
 *
 * @param value The Ref value
 * @category refs
 */

/***/

//         nextStatus = ENTERING

//         nextStatus = EXITING

//       if (status !== ENTERING && status !== ENTERED) {

//       if (status === ENTERING || status === ENTERED) {

//       }

//     const { status } = this.state

//     if (this.props.in) {

//     }

//     } else {

//   if (prevProps !== this.props) {

//   let nextStatus = null

//   return { nextStatus }

//   }

//  - `exited` switches to true

//  - component unmounts;

//  - show is `true` _and_ `container` has resolved

// --------------------------------

// @ts-ignore

// Call preventDefault to stop modal from closing in react-overlays,

// FIXME: This should work even when animation is disabled.

// Hide cleanup logic when:

// IE11 returns a seemingly empty object in some cases when accessing

// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>

// In the context of a TransitionGroup all enters are really appears

// Name the function so it is clearer in the documentation

// RHL removes it sometimes

// Sets `display` always block when `animation` is false

// Show logic when:

// Support: <=IE11 doesn't support `focus()` on svg elements (RB: #917)

// Support: IE 9 only

// TODO: DOMStringMap and CSSStyleDeclaration aren't strictly compatible

// TODO: remove fallback for next major

// TODO: try and combine these effects: https://github.com/react-bootstrap/react-overlays/pull/794#discussion_r409954120

// This shouldn't be necessary, but there are weird race conditions with

// We prevent the modal from closing during a drag by detecting where the

// allows for nested Transitions

// and so steals focus from it

// apparently only works on the dialog role element

// autofocus after onShow to not trigger a focus event for previous

// because we will override it

// clean up the container

// document.activeElement from an <iframe>

// don't close.

// eslint-disable-next-line @typescript-eslint/no-empty-function

// eslint-disable-next-line @typescript-eslint/no-unused-expressions

// getSnapshotBeforeUpdate(prevProps) {

// if that was the last modal in a container,

// if we are mounting and running this it means appear _must_ be set

// modals before this one is shown.

// nextStatus will always be ENTERING or EXITING.

// no enter animation skip right to ENTERED

// no exit animation skip right to EXITED

// otherwise make sure the next top modal is visible to a SR

// reading a dimension prop will cause the browser to recalculate,

// right now only the first modal of a container will have its classes applied

// setState callbacks and unmounting in testing, so always make sure that

// the click originates from. If it starts in the modal and then ends outside

// the timeout is necessary b/c this will run before the new modal is mounted

// then play our animation.

// to add our scrollbar width

// use computed style, here to get the real padding

// we are only interested in the actual `style` here

// we can cancel any pending setState callbacks after we unmount.

// which will let our animations work

// }
