import{g as B,h as $,i as j,j as L,a as I,_ as A,k as F}from"./@babel-BJZJ6yB5.js";import{a as t}from"./react-CXoDaX02.js";import{s as K,g as T,u as V,f as C,t as X}from"./rc-util-uI9ZRjCe.js";import{i as Y}from"./resize-observer-polyfill-D6qJbdzf.js";var b=t.createContext(null);function q(e){var i=e.children,r=e.onBatchResize,o=t.useRef(0),n=t.useRef([]),a=t.useContext(b),l=t.useCallback(function(d,u,f){o.current+=1;var h=o.current;n.current.push({size:d,element:u,data:f}),Promise.resolve().then(function(){h===o.current&&(r?.(n.current),n.current=[])}),a?.(d,u,f)},[r,a]);return t.createElement(b.Provider,{value:l},i)}var c=new Map;function G(e){e.forEach(function(i){var r,o=i.target;(r=c.get(o))===null||r===void 0||r.forEach(function(n){return n(o)})})}var M=new Y(G);function J(e,i){c.has(e)||(c.set(e,new Set),M.observe(e)),c.get(e).add(i)}function Q(e,i){c.has(e)&&(c.get(e).delete(i),c.get(e).size||(M.unobserve(e),c.delete(e)))}var U=(function(e){B(r,e);var i=$(r);function r(){return j(this,r),i.apply(this,arguments)}return L(r,[{key:"render",value:function(){return this.props.children}}]),r})(t.Component);function Z(e,i){var r=e.children,o=e.disabled,n=t.useRef(null),a=t.useRef(null),l=t.useContext(b),d=typeof r=="function",u=d?r(n):r,f=t.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),h=!d&&t.isValidElement(u)&&K(u),O=h?T(u):null,D=V(O,n),z=function(){var v;return C(n.current)||(n.current&&A(n.current)==="object"?C((v=n.current)===null||v===void 0?void 0:v.nativeElement):null)||C(a.current)};t.useImperativeHandle(i,function(){return z()});var E=t.useRef(e);E.current=e;var _=t.useCallback(function(s){var v=E.current,w=v.onResize,N=v.data,x=s.getBoundingClientRect(),p=x.width,m=x.height,R=s.offsetWidth,g=s.offsetHeight,y=Math.floor(p),k=Math.floor(m);if(f.current.width!==y||f.current.height!==k||f.current.offsetWidth!==R||f.current.offsetHeight!==g){var W={width:y,height:k,offsetWidth:R,offsetHeight:g};f.current=W;var P=R===Math.round(p)?p:R,S=g===Math.round(m)?m:g,H=I(I({},W),{},{offsetWidth:P,offsetHeight:S});l?.(H,s,N),w&&Promise.resolve().then(function(){w(H,s)})}},[]);return t.useEffect(function(){var s=z();return s&&!o&&J(s,_),function(){return Q(s,_)}},[n.current,o]),t.createElement(U,{ref:a},h?t.cloneElement(u,{ref:D}):u)}var ee=t.forwardRef(Z),re="rc-observer-key";function te(e,i){var r=e.children,o=typeof r=="function"?[r]:X(r);return o.map(function(n,a){var l=n?.key||"".concat(re,"-").concat(a);return t.createElement(ee,F({},e,{key:l,ref:a===0?i:void 0}),n)})}var ne=t.forwardRef(te);ne.Collection=q;export{ne as R};
