import{r as e}from"./react-OZnHQ5N4.js";import"./use-sync-external-store-D8DD8nbX.js";import{c as t}from"./clsx-BeLtu-UY.js";import{t as r}from"./es-toolkit-wXpXWs0x.js";import"./react-dom-D-NQo2XS.js";var i=e=>"string"==typeof e&&e.indexOf("%")===e.length-1,n=e=>("number"==typeof e||e instanceof Number)&&!(e=>"number"==typeof e&&e!=+e)(e);function h(){}function a(e){return"number"==typeof e&&e>0&&Number.isFinite(e)}var o=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),n=2;n<r;n++)i[n-2]=arguments[n];if("undefined"!=typeof console&&console.warn&&!e)if(void 0===t);else;},c=(e,t,r)=>{var{width:n="100%",height:h="100%",aspect:a,maxHeight:o}=r,c=i(n)?e:Number(n),u=i(h)?t:Number(h);return a&&a>0&&(c?u=c/a:u&&(c=u*a),o&&null!=u&&u>o&&(u=o)),{calculatedWidth:c,calculatedHeight:u}},u={width:0,height:0,overflow:"visible"},s={width:0,overflowX:"visible"},l={height:0,overflowY:"visible"},d={},g=e=>{var{width:t,height:r}=e,n=i(t),h=i(r);return n&&h?u:n?s:h?l:d};function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(null,arguments)}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var w=e.createContext({width:-1,height:-1});function b(t){var{children:r,width:i,height:n}=t,h=e.useMemo(()=>({width:i,height:n}),[i,n]);return function(e){return a(e.width)&&a(e.height)}(h)?e.createElement(w.Provider,{value:h},r):null}var y=e.forwardRef((i,n)=>{var{aspect:a,initialDimension:u={width:-1,height:-1},width:s,height:l,minWidth:d=0,minHeight:f,maxHeight:v,children:p,debounce:w=0,id:y,className:O,onResize:j,style:H={}}=i,x=e.useRef(null),P=e.useRef();P.current=j,e.useImperativeHandle(n,()=>x.current);var[E,R]=e.useState({containerWidth:u.width,containerHeight:u.height}),W=e.useCallback((e,t)=>{R(r=>{var i=Math.round(e),n=Math.round(t);return r.containerWidth===i&&r.containerHeight===n?r:{containerWidth:i,containerHeight:n}})},[]);e.useEffect(()=>{if(null==x.current||"undefined"==typeof ResizeObserver)return h;var e=e=>{var t,{width:r,height:i}=e[0].contentRect;W(r,i),null===(t=P.current)||void 0===t||t.call(P,r,i)};w>0&&(e=r(e,w,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),{width:i,height:n}=x.current.getBoundingClientRect();return W(i,n),t.observe(x.current),()=>{t.disconnect()}},[W,w]);var{containerWidth:N,containerHeight:k}=E;o(!a||a>0,"The aspect(%s) must be greater than zero.",a);var{calculatedWidth:D,calculatedHeight:S}=c(N,k,{width:s,height:l,aspect:a,maxHeight:v});return o(null!=D&&D>0||null!=S&&S>0,"The width(%s) and height(%s) of chart should be greater than 0,\n       please check the style of container, or the props width(%s) and height(%s),\n       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the\n       height and width.",D,S,s,l,d,f,a),e.createElement("div",{id:y?"".concat(y):void 0,className:t("recharts-responsive-container",O),style:m(m({},H),{},{width:s,height:l,minWidth:d,minHeight:f,maxHeight:v}),ref:x},e.createElement("div",{style:g({width:s,height:l})},e.createElement(b,{width:D,height:S},p)))}),O=e.forwardRef((t,r)=>{var i=e.useContext(w);if(a(i.width)&&a(i.height))return t.children;var{width:h,height:o}=function(e){var{width:t,height:r,aspect:i}=e,n=t,h=r;return void 0===n&&void 0===h?(n="100%",h="100%"):void 0===n?n=i&&i>0?void 0:"100%":void 0===h&&(h=i&&i>0?void 0:"100%"),{width:n,height:h}}({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:u,calculatedHeight:s}=c(void 0,void 0,{width:h,height:o,aspect:t.aspect,maxHeight:t.maxHeight});return n(u)&&n(s)?e.createElement(b,{width:u,height:s},t.children):e.createElement(y,f({},t,{width:h,height:o,ref:r}))});export{O as R};
