import * as i from "react";
function d(c, s, f, a) {
  var e = i.useRef(null);
  e.current = {
    open: s,
    triggerOpen: f,
    customizedTrigger: a
  }, i.useEffect(function() {
    function u(o) {
      var t;
      if (!((t = e.current) !== null && t !== void 0 && t.customizedTrigger)) {
        var r = o.target;
        r.shadowRoot && o.composed && (r = o.composedPath()[0] || r), e.current.open && c().filter(function(n) {
          return n;
        }).every(function(n) {
          return !n.contains(r) && n !== r;
        }) && e.current.triggerOpen(!1);
      }
    }
    return window.addEventListener("mousedown", u), function() {
      return window.removeEventListener("mousedown", u);
    };
  }, []);
}
export {
  d as default
};
