import{I as e,P as t,t as n}from"./jsx-runtime-BciRPUQx.js";import{N as r,T as i,c as a,d as o,w as s}from"./warning-CmTaXbvT.js";var c=e(t());function l(e){let t=(0,c.useRef)(e);return t.current=e,t}function u(e){let t=l(e);(0,c.useEffect)(()=>()=>t.current(),[])}function d(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}var f=(0,c.createContext)(s?window:void 0);f.Provider;function p(){return(0,c.useContext)(f)}var m=e=>!e||typeof e==`function`?e:t=>{e.current=t};function h(e,t){let n=m(e),r=m(t);return e=>{n&&n(e),r&&r(e)}}function g(e,t){return(0,c.useMemo)(()=>h(e,t),[e,t])}var _=(e,t)=>s?e==null?(t||r()).body:(typeof e==`function`&&(e=e()),e&&`current`in e&&(e=e.current),e&&(`nodeType`in e||e.getBoundingClientRect)?e:null):null;function v(e,t){let n=p(),[r,i]=(0,c.useState)(()=>_(e,n?.document));if(!r){let t=_(e);t&&i(t)}return(0,c.useEffect)(()=>{t&&r&&t(r)},[t,r]),(0,c.useEffect)(()=>{let t=_(e);t!==r&&i(t)},[e,r]),r}function y({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:a}){let s=(0,c.useRef)(null),l=(0,c.useRef)(t),u=o(n);(0,c.useEffect)(()=>{t?l.current=!0:u(s.current)},[t,u]);let d=(0,c.cloneElement)(e,{ref:g(s,i(e))});return t?d:a||!l.current&&r?null:d}var b=[`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`addEndListener`,`children`];function x(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function S(e){let{onEnter:t,onEntering:n,onEntered:r,onExit:a,onExiting:o,onExited:s,addEndListener:l,children:u}=e,d=x(e,b),f=(0,c.useRef)(null),p=g(f,i(u)),m=e=>t=>{e&&f.current&&e(f.current,t)},h=(0,c.useCallback)(m(t),[t]),_=(0,c.useCallback)(m(n),[n]),v=(0,c.useCallback)(m(r),[r]),y=(0,c.useCallback)(m(a),[a]),S=(0,c.useCallback)(m(o),[o]),C=(0,c.useCallback)(m(s),[s]),w=(0,c.useCallback)(m(l),[l]);return Object.assign({},d,{nodeRef:f},t&&{onEnter:h},n&&{onEntering:_},r&&{onEntered:v},a&&{onExit:y},o&&{onExiting:S},s&&{onExited:C},l&&{addEndListener:w},{children:typeof u==`function`?(e,t)=>u(e,Object.assign({},t,{ref:p})):(0,c.cloneElement)(u,{ref:p})})}var C=n(),w=[`component`];function T(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var E=c.forwardRef((e,t)=>{let{component:n}=e,r=S(T(e,w));return(0,C.jsx)(n,Object.assign({ref:t},r))});function D({in:e,onTransition:t}){let n=(0,c.useRef)(null),r=(0,c.useRef)(!0),i=o(t);return a(()=>{if(!n.current)return;let t=!1;return i({in:e,element:n.current,initial:r.current,isStale:()=>t}),()=>{t=!0}},[e,i]),a(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function O({children:e,in:t,onExited:n,onEntered:r,transition:a}){let[o,s]=(0,c.useState)(!t);t&&o&&s(!1);let l=g(D({in:!!t,onTransition:e=>{Promise.resolve(a(e)).then(()=>{e.isStale()||(e.in?r?.(e.element,e.initial):(s(!0),n?.(e.element)))},t=>{throw e.in||s(!0),t})}}),i(e));return o&&!t?null:(0,c.cloneElement)(e,{ref:l})}function k(e,t,n){return e?(0,C.jsx)(E,Object.assign({},n,{component:e})):t?(0,C.jsx)(O,Object.assign({},n,{transition:t})):(0,C.jsx)(y,Object.assign({},n))}function A(e,t){return e.classList?!!t&&e.classList.contains(t):(` `+(e.className.baseVal||e.className)+` `).indexOf(` `+t+` `)!==-1}export{g as a,u as c,v as i,k as n,p as o,y as r,d as s,A as t};