"use strict";

exports.__esModule = true;
exports.useWindowFlipPopoverProps = useWindowFlipPopoverProps;
var _FilterRenderingContext = require("../components/FilterRenderingContext");
var _react = require("react");
var _bexCore = require("@wix/bex-core");
function useWindowFlipPopoverProps({
  popoverProps
}) {
  const {
    location
  } = (0, _FilterRenderingContext.useFilterRenderingContext)();
  const inputRef = (0, _react.useRef)();
  const [dropdownWidth, setDropdownWidth] = (0, _react.useState)();
  (0, _bexCore.addResizeObserver)(inputRef.current, () => {
    if (inputRef.current) {
      setDropdownWidth(inputRef.current.width);
    }
  });
  return {
    inputRef,
    windowFlipPopoverProps: {
      appendTo: 'window',
      flip: true,
      fixed: false,
      maxWidth: dropdownWidth,
      ...(location === 'modal' && {
        zIndex: 5001
      }),
      ...popoverProps
    }
  };
}
//# sourceMappingURL=useWindowFlipPopoverProps.js.map