import * as c from "react";
import { ownerDocument as i } from "../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/owner.js";
import { EMPTY_OBJECT as s } from "../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js";
function a(u) {
  const {
    enabled: t = !0,
    mouseDownAction: r,
    open: n
  } = u, e = c.useRef(!1);
  return c.useMemo(() => t ? {
    onMouseDown: (o) => {
      (r === "open" && !n || r === "close" && n) && (e.current = !0, i(o.currentTarget).addEventListener("click", () => {
        e.current = !1;
      }, {
        once: !0
      }));
    },
    onClick: (o) => {
      e.current && (e.current = !1, o.preventBaseUIHandler());
    }
  } : s, [t, r, n]);
}
export {
  a as useMixedToggleClickHandler
};
