import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{t as n}from"./react-dom.BzV73oHg.js";import{it as r,pt as i,st as a,tt as o}from"./Tooltip.CcubhKj6.js";var s=e(n(),1),c=e(t(),1),l=(0,c.createContext)(null);function u(e){let t=(0,c.useRef)({});return c.createElement(l.Provider,{value:t},e.children)}var d=(0,c.forwardRef)(function(e,t){let{name:n,isVisible:u=!0,children:d,className:f,style:p,render:m,...h}=e,[g,_]=(0,c.useState)(u?`visible`:`hidden`),v=(0,c.useContext)(l);if(!v)throw Error(`<SharedElement> must be rendered inside a <SharedElementTransition>`);u&&g===`hidden`&&_(`visible`),t=a(t),i(()=>{let e=t.current,r=v.current,i=r[n],a=null;if(e&&u&&i){_(`visible`);let t=e.getAnimations(),o=i.style.map(([t,n])=>{let r=e.style[t];if(t===`translate`){let t=i.rect,n=e.getBoundingClientRect(),r=t.left-n?.left,a=t.top-n?.top;e.style.translate=`${r}px ${a}px`}else e.style[t]=n;return[t,r]});for(let n of e.getAnimations())t.includes(n)||n.cancel();a=requestAnimationFrame(()=>{a=null;for(let[t,n]of o)e.style[t]=n}),delete r[n]}else e&&u&&!i?(queueMicrotask(()=>(0,s.flushSync)(()=>_(`entering`))),a=requestAnimationFrame(()=>{a=null,_(`visible`)})):e&&!u&&queueMicrotask(()=>{r[n]?(delete r[n],(0,s.flushSync)(()=>_(`exiting`)),Promise.all(e.getAnimations().map(e=>e.finished)).then(()=>_(`hidden`)).catch(()=>{})):_(`hidden`)});return()=>{if(a!=null&&cancelAnimationFrame(a),e&&e.isConnected&&!e.hasAttribute(`data-exiting`)){let t=window.getComputedStyle(e);if(t.transitionProperty!==`none`){let i=t.transitionProperty.split(/\s*,\s*/);r[n]={rect:e.getBoundingClientRect(),style:i.map(e=>[e,t[e]])}}}}},[t,v,n,u]);let y=o({children:d,className:f,style:p,render:m,values:{isEntering:g===`entering`,isExiting:g===`exiting`}});return g===`hidden`?null:c.createElement(r.div,{...h,...y,ref:t,"data-entering":g===`entering`||void 0,"data-exiting":g===`exiting`||void 0})});export{d as n,u as t};