"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const floatingUi_dom = require("../../../../../../../@floating-ui_dom@1.6.11/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs");
const useDidUpdate = require("../../../../../../../@mantine_hooks@7.15.2_react@18.3.1/node_modules/@mantine/hooks/esm/use-did-update/use-did-update.cjs");
function useFloatingAutoUpdate({
  opened,
  floating,
  position,
  positionDependencies
}) {
  const [delayedUpdate, setDelayedUpdate] = React.useState(0);
  React.useEffect(() => {
    if (floating.refs.reference.current && floating.refs.floating.current && opened) {
      return floatingUi_dom.autoUpdate(
        floating.refs.reference.current,
        floating.refs.floating.current,
        floating.update
      );
    }
    return void 0;
  }, [
    floating.refs.reference.current,
    floating.refs.floating.current,
    opened,
    delayedUpdate,
    position
  ]);
  useDidUpdate.useDidUpdate(() => {
    floating.update();
  }, positionDependencies);
  useDidUpdate.useDidUpdate(() => {
    setDelayedUpdate((c) => c + 1);
  }, [opened]);
}
exports.useFloatingAutoUpdate = useFloatingAutoUpdate;
