import{I as Q,w as E,J as R,K as V,c as X}from"./generateCategoricalChart-yyhQoVBO.js";import{r as s,f8 as N,K}from"./index-DHiyXWqE.js";function O(e){"@babel/helpers - typeof";return O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(e)}function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?M(Object(r),!0).forEach(function(n){Y(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Y(e,t,r){return t=Z(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Z(e){var t=ee(e,"string");return O(t)=="symbol"?t:String(t)}function ee(e,t){if(O(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(O(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function te(e,t){return oe(e)||ie(e,t)||ne(e,t)||re()}function re(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ne(e,t){if(e){if(typeof e=="string")return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k(e,t)}}function k(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ie(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,l,m,a,f=[],c=!0,y=!1;try{if(m=(r=r.call(e)).next,t!==0)for(;!(c=(n=m.call(r)).done)&&(f.push(n.value),f.length!==t);c=!0);}catch(p){y=!0,l=p}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(y)throw l}}return f}}function oe(e){if(Array.isArray(e))return e}var ue=s.forwardRef(function(e,t){var r=e.aspect,n=e.initialDimension,l=n===void 0?{width:-1,height:-1}:n,m=e.width,a=m===void 0?"100%":m,f=e.height,c=f===void 0?"100%":f,y=e.minWidth,p=y===void 0?0:y,S=e.minHeight,g=e.maxHeight,b=e.children,$=e.debounce,j=$===void 0?0:$,C=e.id,B=e.className,J=e.onResize,T=e.style,L=T===void 0?{}:T,v=s.useRef(null),W=s.useRef();W.current=J,s.useImperativeHandle(t,function(){return Object.defineProperty(v.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),v.current},configurable:!0})});var U=s.useState({containerWidth:l.width,containerHeight:l.height}),_=te(U,2),P=_[0],q=_[1],A=s.useCallback(function(u,h){q(function(i){var o=Math.round(u),d=Math.round(h);return i.containerWidth===o&&i.containerHeight===d?i:{containerWidth:o,containerHeight:d}})},[]);s.useEffect(function(){var u=function(G){var x,z=G[0].contentRect,D=z.width,I=z.height;A(D,I),(x=W.current)===null||x===void 0||x.call(W,D,I)};j>0&&(u=Q(u,j,{trailing:!0,leading:!1}));var h=new ResizeObserver(u),i=v.current.getBoundingClientRect(),o=i.width,d=i.height;return A(o,d),h.observe(v.current),function(){h.disconnect()}},[A,j]);var F=s.useMemo(function(){var u=P.containerWidth,h=P.containerHeight;if(u<0||h<0)return null;E(R(a)||R(c),`The width(%s) and height(%s) are both fixed numbers,
       maybe you don't need to use a ResponsiveContainer.`,a,c),E(!r||r>0,"The aspect(%s) must be greater than zero.",r);var i=R(a)?u:a,o=R(c)?h:c;r&&r>0&&(i?o=i/r:o&&(i=o*r),g&&o>g&&(o=g)),E(i>0||o>0,`The width(%s) and height(%s) of chart should be greater than 0,
       please check the style of container, or the props width(%s) and height(%s),
       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
       height and width.`,i,o,a,c,p,S,r);var d=!Array.isArray(b)&&N.isElement(b)&&V(b.type).endsWith("Chart");return K.Children.map(b,function(w){return N.isElement(w)?s.cloneElement(w,H({width:i,height:o},d?{style:H({height:"100%",width:"100%",maxHeight:o,maxWidth:i},w.props.style)}:{})):w})},[r,b,c,g,S,p,P,a]);return K.createElement("div",{id:C?"".concat(C):void 0,className:X("recharts-responsive-container",B),style:H(H({},L),{},{width:a,height:c,minWidth:p,minHeight:S,maxHeight:g}),ref:v},F)});export{ue as R};
