// packages/block-editor/src/components/block-list/use-block-props/use-is-hovered.js
import {
  useRefEffect,
  privateApis as composePrivateApis
} from "@wordpress/compose";
import { unlock } from "../../../lock-unlock.mjs";
var { subscribeDelegatedListener } = unlock(composePrivateApis);
function useIsHovered({ isEnabled = true } = {}) {
  return useRefEffect(
    (node) => {
      if (!isEnabled) {
        return;
      }
      function listener(event) {
        if (event.defaultPrevented) {
          return;
        }
        event.preventDefault();
        node.classList.toggle(
          "is-hovered",
          event.type === "mouseover"
        );
      }
      const unsubscribeOut = subscribeDelegatedListener(
        node,
        "mouseout",
        listener
      );
      const unsubscribeOver = subscribeDelegatedListener(
        node,
        "mouseover",
        listener
      );
      return () => {
        unsubscribeOut();
        unsubscribeOver();
        node.classList.remove("is-hovered");
      };
    },
    [isEnabled]
  );
}
export {
  useIsHovered
};
//# sourceMappingURL=use-is-hovered.mjs.map
