import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{n}from"./dist-BN3q53Cq.js";var r=e(t(),1),i=Object.defineProperty,a=(e,t)=>i(e,`name`,{value:t,configurable:!0});function o(e,t){return r.useReducer((e,n)=>t[e][n]??e,e)}a(o,`useStateMachine`);var s=a(e=>{let{present:t,children:n}=e,i=c(t),a=typeof n==`function`?n({present:i.isPresent}):r.Children.only(n),o=u(i.ref,f(a));return typeof n==`function`||i.isPresent?r.cloneElement(a,{ref:o}):null},`Presence`);function c(e){let[t,i]=r.useState(),s=r.useRef(null),c=r.useRef(e),l=r.useRef(`none`),u=r.useRef(void 0),[f,p]=o(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return r.useEffect(()=>{f===`mounted`?(l.current=u.current??d(s.current),u.current=void 0):l.current=`none`},[f]),n(()=>{let t=s.current,n=c.current;if(n!==e){let r=l.current,i=d(t);e?(u.current=i,p(`MOUNT`)):i===`none`||t?.display===`none`?p(`UNMOUNT`):p(n&&r!==i?`ANIMATION_OUT`:`UNMOUNT`),c.current=e}},[e,p]),n(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,r=a(r=>{let i=d(s.current).includes(CSS.escape(r.animationName));if(r.target===t&&i&&(p(`ANIMATION_END`),!c.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),i=a(e=>{e.target===t&&(l.current=d(s.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,i),t.addEventListener(`animationcancel`,r),t.addEventListener(`animationend`,r),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,i),t.removeEventListener(`animationcancel`,r),t.removeEventListener(`animationend`,r)}}p(`ANIMATION_END`)},[t,p]),{isPresent:[`mounted`,`unmountSuspended`].includes(f),ref:r.useCallback(e=>{if(e){let t=getComputedStyle(e);s.current=t,u.current=d(t)}else s.current=null;i(e)},[])}}a(c,`usePresence`);function l(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}a(l,`setRef`);function u(...e){let t=r.useRef(e);return t.current=e,r.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=l(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():l(n[e],null)}}},[])}a(u,`useStableComposedRefs`);function d(e){return e?.animationName||`none`}a(d,`getAnimationName`);function f(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}a(f,`getElementRef`);var p=Object.defineProperty,m=(e,t)=>p(e,`name`,{value:t,configurable:!0}),h=r.useId||(()=>void 0),g=0;function _(e){let[t,i]=r.useState(h());return n(()=>{e||i(e=>e??String(g++))},[e]),e||(t?`radix-${t}`:``)}m(_,`useId`);var v=Object.defineProperty,y=(e,t)=>v(e,`name`,{value:t,configurable:!0});function b(e){let t=r.useRef(e);return r.useEffect(()=>{t.current=e}),r.useMemo(()=>((...e)=>t.current?.(...e)),[])}y(b,`useCallbackRef`);export{_ as n,s as r,b as t};