"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.overlayMiddlewares = overlayMiddlewares;
var _reactDom = require("@floating-ui/react-dom");
/**
 * External dependencies
 */

function overlayMiddlewares() {
  return [{
    name: 'overlay',
    fn({
      rects
    }) {
      return rects.reference;
    }
  }, (0, _reactDom.size)({
    apply({
      rects,
      elements
    }) {
      var _elements$floating;
      const {
        firstElementChild
      } = (_elements$floating = elements.floating) !== null && _elements$floating !== void 0 ? _elements$floating : {};

      // Only HTMLElement instances have the `style` property.
      if (!(firstElementChild instanceof HTMLElement)) {
        return;
      }

      // Reduce the height of the popover to the available space.
      Object.assign(firstElementChild.style, {
        width: `${rects.reference.width}px`,
        height: `${rects.reference.height}px`
      });
    }
  })];
}
//# sourceMappingURL=overlay-middlewares.js.map