"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("../../utils/dist/useId.mjs.js"),require("../../utils/dist/platform.mjs.js");var e=require("react");require("../../utils/dist/runAfterTransition.mjs.js");var t=require("../../utils/dist/useLayoutEffect.mjs.js"),r=require("../../utils/dist/useEffectEvent.mjs.js");function n(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}require("react-dom");exports.createSyntheticEvent=n,exports.ignoreFocusEvent=!1,exports.setEventTarget=function(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})},exports.useSyntheticBlurEvent=function(s){let u=e.useRef({isFocused:!1,observer:null});t.useLayoutEffect((()=>{const e=u.current;return()=>{e.observer&&(e.observer.disconnect(),e.observer=null)}}),[]);let i=r.useEffectEvent((e=>{null==s||s(e)}));return e.useCallback((e=>{if(e.target instanceof HTMLButtonElement||e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement){u.current.isFocused=!0;let t=e.target,r=e=>{if(u.current.isFocused=!1,t.disabled){let t=n(e);i(t)}u.current.observer&&(u.current.observer.disconnect(),u.current.observer=null)};t.addEventListener("focusout",r,{once:!0}),u.current.observer=new MutationObserver((()=>{if(u.current.isFocused&&t.disabled){var e;null===(e=u.current.observer)||void 0===e||e.disconnect();let r=t===document.activeElement?null:document.activeElement;t.dispatchEvent(new FocusEvent("blur",{relatedTarget:r})),t.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:r}))}})),u.current.observer.observe(t,{attributes:!0,attributeFilter:["disabled"]})}}),[i])};
//# sourceMappingURL=utils.mjs.js.map
