"use strict";var T=Object.create;var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of M(t))!D.call(e,c)&&c!==n&&l(e,c,{get:()=>t[c],enumerable:!(r=v(t,c))||r.enumerable});return e};var y=(e,t,n)=>(n=e!=null?T(w(e)):{},g(t||!e||!e.__esModule?l(n,"default",{value:e,enumerable:!0}):n,e)),S=e=>g(l({},"__esModule",{value:!0}),e);var j={};I(j,{Rect:()=>_,useRect:()=>C});module.exports=S(j);var o=y(require("react")),E=y(require("@reach/observe-rect")),a=require("@reach/utils"),_=({onChange:e,observe:t=!0,children:n})=>{let r=o.useRef(null),c=C(r,{observe:t,onChange:e});return n({ref:r,rect:c})};_.displayName="Rect";function C(e,t,n){var h;let r,c;(0,a.isBoolean)(t)?r=t:(r=(h=t==null?void 0:t.observe)!=null?h:!0,c=t==null?void 0:t.onChange),(0,a.isFunction)(n)&&(c=n);let[s,U]=o.useState(e.current),R=o.useRef(!1),f=o.useRef(!1),[P,d]=o.useState(null),u=o.useRef(c);return(0,a.useIsomorphicLayoutEffect)(()=>{u.current=c,e.current!==s&&U(e.current)}),(0,a.useIsomorphicLayoutEffect)(()=>{s&&!R.current&&(R.current=!0,d(s.getBoundingClientRect()))},[s]),(0,a.useIsomorphicLayoutEffect)(()=>{if(!r)return;let i=s;if(f.current||(f.current=!0,i=e.current),!i)return;let m=(0,E.default)(i,p=>{var b;(b=u.current)==null||b.call(u,p),d(p)});return m.observe(),()=>{m.unobserve()}},[r,s,e]),P}0&&(module.exports={Rect,useRect});
