const e=require(`./chunk-BcutgqC9.cjs`),t=require(`./dist-B9QvvA-B.cjs`),n=require(`./dist-C1zbYA0G.cjs`),r=require(`./dist-Cq9XeNB7.cjs`);let i=require(`react`);i=e.n(i,1);let a=require(`react/jsx-runtime`),o=require(`react-dom`);o=e.n(o,1);function s(e,t=globalThis?.document){let n=r.t(e);i.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var c=`DismissableLayer`,l=`dismissableLayer.update`,u=`dismissableLayer.pointerDownOutside`,d=`dismissableLayer.focusOutside`,f,p=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),m=i.forwardRef((e,r)=>{let{disableOutsidePointerEvents:o=!1,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:m,onDismiss:h,...g}=e,b=i.useContext(p),[x,S]=i.useState(null),C=x?.ownerDocument??globalThis?.document,[,w]=i.useState({}),T=n.o(r,e=>S(e)),E=Array.from(b.layers),[D]=[...b.layersWithOutsidePointerEventsDisabled].slice(-1),O=E.indexOf(D),k=x?E.indexOf(x):-1,A=b.layersWithOutsidePointerEventsDisabled.size>0,j=k>=O,M=_(e=>{let t=e.target,n=[...b.branches].some(e=>e.contains(t));!j||n||(u?.(e),m?.(e),e.defaultPrevented||h?.())},C),N=v(e=>{let t=e.target;[...b.branches].some(e=>e.contains(t))||(d?.(e),m?.(e),e.defaultPrevented||h?.())},C);return s(e=>{k===b.layers.size-1&&(c?.(e),!e.defaultPrevented&&h&&(e.preventDefault(),h()))},C),i.useEffect(()=>{if(x)return o&&(b.layersWithOutsidePointerEventsDisabled.size===0&&(f=C.body.style.pointerEvents,C.body.style.pointerEvents=`none`),b.layersWithOutsidePointerEventsDisabled.add(x)),b.layers.add(x),y(),()=>{o&&b.layersWithOutsidePointerEventsDisabled.size===1&&(C.body.style.pointerEvents=f)}},[x,C,o,b]),i.useEffect(()=>()=>{x&&(b.layers.delete(x),b.layersWithOutsidePointerEventsDisabled.delete(x),y())},[x,b]),i.useEffect(()=>{let e=()=>w({});return document.addEventListener(l,e),()=>document.removeEventListener(l,e)},[]),(0,a.jsx)(n.t.div,{...g,ref:T,style:{pointerEvents:A?j?`auto`:`none`:void 0,...e.style},onFocusCapture:t.r(e.onFocusCapture,N.onFocusCapture),onBlurCapture:t.r(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:t.r(e.onPointerDownCapture,M.onPointerDownCapture)})});m.displayName=c;var h=`DismissableLayerBranch`,g=i.forwardRef((e,t)=>{let r=i.useContext(p),o=i.useRef(null),s=n.o(t,o);return i.useEffect(()=>{let e=o.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,a.jsx)(n.t.div,{...e,ref:s})});g.displayName=h;function _(e,t=globalThis?.document){let n=r.t(e),a=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!a.current){let r=function(){b(u,n,i,{discrete:!0})},i={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,o.current),o.current=r,t.addEventListener(`click`,o.current,{once:!0})):r()}else t.removeEventListener(`click`,o.current);a.current=!1},r=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(r),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,o.current)}},[t,n]),{onPointerDownCapture:()=>a.current=!0}}function v(e,t=globalThis?.document){let n=r.t(e),a=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!a.current&&b(d,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}function y(){let e=new CustomEvent(l);document.dispatchEvent(e)}function b(e,t,r,{discrete:i}){let a=r.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),i?n.n(a,o):a.dispatchEvent(o)}var x=m,S=g,C=`Portal`,w=i.forwardRef((e,r)=>{let{container:s,...c}=e,[l,u]=i.useState(!1);t.n(()=>u(!0),[]);let d=s||l&&globalThis?.document?.body;return d?o.default.createPortal((0,a.jsx)(n.t.div,{...c,ref:r}),d):null});w.displayName=C,Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return w}});
//# sourceMappingURL=dist-Dth0AO1S.cjs.map