import{r as l,R as w}from"./jsx-runtime-yvcgGv6i.js";import{s as v,h as g,c as E,e as C}from"./use-is-mounted-I-UNysEl.js";function h(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function L(){return/Android/gi.test(window.navigator.userAgent)}function x(){return h()||L()}function f(t,a,r){let c=v(a);l.useEffect(()=>{function u(i){c.current(i)}return document.addEventListener(t,u,r),()=>document.removeEventListener(t,u,r)},[t,r])}function P(t,a,r){let c=v(a);l.useEffect(()=>{function u(i){c.current(i)}return window.addEventListener(t,u,r),()=>window.removeEventListener(t,u,r)},[t,r])}function O(t,a,r=!0){let c=l.useRef(!1);l.useEffect(()=>{requestAnimationFrame(()=>{c.current=r})},[r]);function u(n,s){if(!c.current||n.defaultPrevented)return;let e=s(n);if(e===null||!e.getRootNode().contains(e)||!e.isConnected)return;let p=function d(o){return typeof o=="function"?d(o()):Array.isArray(o)||o instanceof Set?o:[o]}(t);for(let d of p){if(d===null)continue;let o=d instanceof HTMLElement?d:d.current;if(o!=null&&o.contains(e)||n.composed&&n.composedPath().includes(o))return}return!g(e,E.Loose)&&e.tabIndex!==-1&&n.preventDefault(),a(n,e)}let i=l.useRef(null);f("pointerdown",n=>{var s,e;c.current&&(i.current=((e=(s=n.composedPath)==null?void 0:s.call(n))==null?void 0:e[0])||n.target)},!0),f("mousedown",n=>{var s,e;c.current&&(i.current=((e=(s=n.composedPath)==null?void 0:s.call(n))==null?void 0:e[0])||n.target)},!0),f("click",n=>{x()||i.current&&(u(n,()=>i.current),i.current=null)},!0),f("touchend",n=>u(n,()=>n.target instanceof HTMLElement?n.target:null),!0),P("blur",n=>u(n,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function R(...t){return l.useMemo(()=>C(...t),[...t])}let m=l.createContext(null);m.displayName="OpenClosedContext";var y=(t=>(t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Closing=4]="Closing",t[t.Opening=8]="Opening",t))(y||{});function T(){return l.useContext(m)}function $({value:t,children:a}){return w.createElement(m.Provider,{value:t},a)}export{P as a,y as d,R as n,$ as s,h as t,T as u,O as y};
