"use strict";const t=require("./utils-Bv1frUk6.cjs.js"),a=require("react"),x=require("./useGlobalListeners-CwGh-cDn.cjs.js");function v(h){let{isDisabled:F,onBlurWithin:c,onFocusWithin:o,onFocusWithinChange:r}=h,n=a.useRef({isFocusWithin:!1}),{addGlobalListener:u,removeAllGlobalListeners:l}=x.$03deb23ff14920c4$export$4eaf04e54aa8eed6(),i=a.useCallback(e=>{e.currentTarget.contains(e.target)&&n.current.isFocusWithin&&!e.currentTarget.contains(e.relatedTarget)&&(n.current.isFocusWithin=!1,l(),c&&c(e),r&&r(!1))},[c,r,n,l]),f=t.$8a9cb279dc87e130$export$715c682d09d639cc(i),g=a.useCallback(e=>{if(!e.currentTarget.contains(e.target))return;const s=t.$431fbd86ca7dc216$export$b204af158042fbac(e.target),W=t.$d4ee10de306f2510$export$cd4e5573fbe2b576(s);if(!n.current.isFocusWithin&&W===t.$d4ee10de306f2510$export$e58f029f0fbfdb29(e.nativeEvent)){o&&o(e),r&&r(!0),n.current.isFocusWithin=!0,f(e);let d=e.currentTarget;u(s,"focus",$=>{if(n.current.isFocusWithin&&!t.$d4ee10de306f2510$export$4282f70798064fe0(d,$.target)){let b=new s.defaultView.FocusEvent("blur",{relatedTarget:$.target});t.$8a9cb279dc87e130$export$c2b7abe5d61ec696(b,d);let p=t.$8a9cb279dc87e130$export$525bc4921d56d4a(b);i(p)}},{capture:!0})}},[o,r,f,u,i]);return F?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:i}}}exports.$9ab94262bd0047c7$export$420e68273165f4ec=v;
//# sourceMappingURL=useFocusWithin-CX8GdFVw.cjs.js.map
