import{o as e}from"./chunk-CMxvf4Kt.js";import{t}from"./react-DrNXigiH.js";import{B as n,C as r,H as i,Y as a,a as o,c as s,et as c,i as l,n as u,r as d,w as f}from"./generateCategoricalChart-bYKfCxJX.js";import{i as p,r as m}from"./YAxis-BDsOF7PK.js";var h=e(t()),g=e(c()),_=[`x1`,`y1`,`x2`,`y2`,`key`],v=[`offset`];function y(e){"@babel/helpers - typeof";return y=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},y(e)}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function x(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function D(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var O=function(e){var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return h.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function k(e,t){var n;if(h.isValidElement(e))n=h.cloneElement(e,t);else if((0,g.default)(e))n=e(t);else{var r=t.x1,a=t.y1,o=t.x2,s=t.y2,c=t.key,l=i(E(t,_),!1);l.offset;var u=E(l,v);n=h.createElement(`line`,T({},u,{x1:r,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return n}function A(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0?!0:r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(r,a){return k(i,x(x({},e),{},{x1:t,y1:r,x2:t+n,y2:r,key:`line-${a}`,index:a}))});return h.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},o)}function j(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0?!0:r,a=e.verticalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(r,a){return k(i,x(x({},e),{},{x1:r,y1:t,x2:r,y2:t+n,key:`line-${a}`,index:a}))});return h.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},o)}function M(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length)return null;var l=s.map(function(e){return Math.round(e+i-i)}).sort(function(e,t){return e-t});i!==l[0]&&l.unshift(0);var u=l.map(function(e,s){var c=l[s+1]?l[s+1]-e:i+o-e;if(c<=0)return null;var u=s%t.length;return h.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:c,width:a,stroke:`none`,fill:t[u],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return h.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function N(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(function(e){return Math.round(e+a-a)}).sort(function(e,t){return e-t});a!==u[0]&&u.unshift(0);var d=u.map(function(e,t){var n=u[t+1]?u[t+1]-e:a+s-e;if(n<=0)return null;var l=t%r.length;return h.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:n,height:c,stroke:`none`,fill:r[l],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return h.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var P=function(e,t){var n=e.xAxis,i=e.width,a=e.height,o=e.offset;return r(p(x(x(x({},m.defaultProps),n),{},{ticks:f(n,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.left,o.left+o.width,t)},F=function(e,t){var n=e.yAxis,i=e.width,a=e.height,o=e.offset;return r(p(x(x(x({},m.defaultProps),n),{},{ticks:f(n,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.top,o.top+o.height,t)},I={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[]};function L(e){var t=l(),r=d(),i=o(),c=x(x({},e),{},{stroke:e.stroke??I.stroke,fill:e.fill??I.fill,horizontal:e.horizontal??I.horizontal,horizontalFill:e.horizontalFill??I.horizontalFill,vertical:e.vertical??I.vertical,verticalFill:e.verticalFill??I.verticalFill,x:a(e.x)?e.x:i.left,y:a(e.y)?e.y:i.top,width:a(e.width)?e.width:i.width,height:a(e.height)?e.height:i.height}),f=c.x,p=c.y,m=c.width,_=c.height,v=c.syncWithTicks,b=c.horizontalValues,S=c.verticalValues,C=u(),w=s();if(!a(m)||m<=0||!a(_)||_<=0||!a(f)||f!==+f||!a(p)||p!==+p)return null;var E=c.verticalCoordinatesGenerator||P,D=c.horizontalCoordinatesGenerator||F,k=c.horizontalPoints,L=c.verticalPoints;if((!k||!k.length)&&(0,g.default)(D)){var R=b&&b.length,z=D({yAxis:w?x(x({},w),{},{ticks:R?b:w.ticks}):void 0,width:t,height:r,offset:i},R?!0:v);n(Array.isArray(z),`horizontalCoordinatesGenerator should return Array but instead it returned [${y(z)}]`),Array.isArray(z)&&(k=z)}if((!L||!L.length)&&(0,g.default)(E)){var B=S&&S.length,V=E({xAxis:C?x(x({},C),{},{ticks:B?S:C.ticks}):void 0,width:t,height:r,offset:i},B?!0:v);n(Array.isArray(V),`verticalCoordinatesGenerator should return Array but instead it returned [${y(V)}]`),Array.isArray(V)&&(L=V)}return h.createElement(`g`,{className:`recharts-cartesian-grid`},h.createElement(O,{fill:c.fill,fillOpacity:c.fillOpacity,x:c.x,y:c.y,width:c.width,height:c.height,ry:c.ry}),h.createElement(A,T({},c,{offset:i,horizontalPoints:k,xAxis:C,yAxis:w})),h.createElement(j,T({},c,{offset:i,verticalPoints:L,xAxis:C,yAxis:w})),h.createElement(M,T({},c,{horizontalPoints:k})),h.createElement(N,T({},c,{verticalPoints:L})))}L.displayName=`CartesianGrid`;export{L as t};