import{r as o}from"./index-26FXPGkN.js";const R={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function d(r){const n=o.useRef(0),e=o.useRef(null),[i,u]=o.useState(R),c=o.useMemo(()=>typeof window<"u"?new ResizeObserver(l=>{const t=l[0];t&&(cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{var f,a;if(e.current){const s=((f=t.borderBoxSize)==null?void 0:f[0])||((a=t.contentBoxSize)==null?void 0:a[0]);if(s){const m=s.inlineSize,h=s.blockSize;u({width:m,height:h,x:t.contentRect.x,y:t.contentRect.y,top:t.contentRect.top,left:t.contentRect.left,bottom:t.contentRect.bottom,right:t.contentRect.right})}else u(t.contentRect)}}))}):null,[]);return o.useEffect(()=>(e.current&&(c==null||c.observe(e.current,r)),()=>{c==null||c.disconnect(),n.current&&cancelAnimationFrame(n.current)}),[e.current]),[e,i]}function z(r){const[n,{width:e,height:i}]=d(r);return{ref:n,width:e,height:i}}export{d as a,z as u};
