@jacshuo/onyx 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/Chart/BarChart.cjs +1 -1
  2. package/dist/Chart/BarChart.js +1 -1
  3. package/dist/Chart/PieChart.cjs +1 -1
  4. package/dist/Chart/PieChart.js +1 -1
  5. package/dist/Chart/ScatterChart.cjs +1 -1
  6. package/dist/Chart/ScatterChart.js +1 -1
  7. package/dist/Chart/index.cjs +1 -1
  8. package/dist/Chart/index.js +1 -1
  9. package/dist/DataDisplay/VirtualList.cjs +2 -0
  10. package/dist/DataDisplay/VirtualList.css +1 -0
  11. package/dist/DataDisplay/VirtualList.d.cts +5 -0
  12. package/dist/DataDisplay/VirtualList.d.ts +5 -0
  13. package/dist/DataDisplay/VirtualList.js +2 -0
  14. package/dist/DataDisplay/index.cjs +3 -2
  15. package/dist/DataDisplay/index.css +1 -0
  16. package/dist/DataDisplay/index.d.cts +5 -0
  17. package/dist/DataDisplay/index.d.ts +5 -0
  18. package/dist/DataDisplay/index.js +3 -2
  19. package/dist/Extras/FileExplorer.cjs +2 -2
  20. package/dist/Extras/FileExplorer.js +2 -2
  21. package/dist/Extras/LoginPanel.cjs +1 -0
  22. package/dist/Extras/LoginPanel.css +1 -0
  23. package/dist/Extras/LoginPanel.d.cts +3 -0
  24. package/dist/Extras/LoginPanel.d.ts +3 -0
  25. package/dist/Extras/LoginPanel.js +1 -0
  26. package/dist/Extras/RichTextEditor.cjs +45 -0
  27. package/dist/Extras/RichTextEditor.css +1 -0
  28. package/dist/Extras/RichTextEditor.d.cts +10 -0
  29. package/dist/Extras/RichTextEditor.d.ts +10 -0
  30. package/dist/Extras/RichTextEditor.js +45 -0
  31. package/dist/Extras/index.cjs +48 -4
  32. package/dist/Extras/index.css +1 -1
  33. package/dist/Extras/index.d.cts +7 -0
  34. package/dist/Extras/index.d.ts +7 -0
  35. package/dist/Extras/index.js +48 -4
  36. package/dist/Forms/Form.cjs +1 -1
  37. package/dist/Forms/Form.js +1 -1
  38. package/dist/Forms/OTPInput.cjs +1 -0
  39. package/dist/Forms/OTPInput.css +1 -0
  40. package/dist/Forms/OTPInput.d.cts +4 -0
  41. package/dist/Forms/OTPInput.d.ts +4 -0
  42. package/dist/Forms/OTPInput.js +1 -0
  43. package/dist/Forms/Select.cjs +1 -1
  44. package/dist/Forms/Select.js +1 -1
  45. package/dist/Forms/index.cjs +1 -1
  46. package/dist/Forms/index.css +1 -0
  47. package/dist/Forms/index.d.cts +4 -0
  48. package/dist/Forms/index.d.ts +4 -0
  49. package/dist/Forms/index.js +1 -1
  50. package/dist/Layout/SplitPanel.cjs +1 -0
  51. package/dist/Layout/SplitPanel.d.cts +3 -0
  52. package/dist/Layout/SplitPanel.d.ts +3 -0
  53. package/dist/Layout/SplitPanel.js +1 -0
  54. package/dist/Layout/index.cjs +1 -1
  55. package/dist/Layout/index.d.cts +3 -0
  56. package/dist/Layout/index.d.ts +3 -0
  57. package/dist/Layout/index.js +1 -1
  58. package/dist/Navigation/Header.cjs +1 -1
  59. package/dist/Navigation/Header.js +1 -1
  60. package/dist/Navigation/RibbonBar.d.cts +3 -3
  61. package/dist/Navigation/RibbonBar.d.ts +3 -3
  62. package/dist/Navigation/index.cjs +2 -2
  63. package/dist/Navigation/index.d.cts +3 -3
  64. package/dist/Navigation/index.d.ts +3 -3
  65. package/dist/Navigation/index.js +2 -2
  66. package/dist/Primitives/Avatar.cjs +1 -1
  67. package/dist/Primitives/Avatar.js +1 -1
  68. package/dist/Primitives/Badge.cjs +1 -1
  69. package/dist/Primitives/Badge.js +1 -1
  70. package/dist/Primitives/Button.cjs +1 -1
  71. package/dist/Primitives/Button.js +1 -1
  72. package/dist/Primitives/Checkbox.cjs +1 -1
  73. package/dist/Primitives/Checkbox.js +1 -1
  74. package/dist/Primitives/Dropdown.cjs +1 -1
  75. package/dist/Primitives/Dropdown.js +1 -1
  76. package/dist/Primitives/DropdownButton.cjs +1 -1
  77. package/dist/Primitives/DropdownButton.js +1 -1
  78. package/dist/Primitives/Indicator.cjs +1 -1
  79. package/dist/Primitives/Indicator.js +1 -1
  80. package/dist/Primitives/Input.cjs +1 -1
  81. package/dist/Primitives/Input.js +1 -1
  82. package/dist/Primitives/Kbd.cjs +1 -0
  83. package/dist/Primitives/Kbd.css +0 -0
  84. package/dist/Primitives/Kbd.d.cts +6 -0
  85. package/dist/Primitives/Kbd.d.ts +6 -0
  86. package/dist/Primitives/Kbd.js +1 -0
  87. package/dist/Primitives/Label.cjs +1 -1
  88. package/dist/Primitives/Label.js +1 -1
  89. package/dist/Primitives/Radio.cjs +1 -1
  90. package/dist/Primitives/Radio.js +1 -1
  91. package/dist/Primitives/Rating.cjs +2 -0
  92. package/dist/Primitives/Rating.css +0 -0
  93. package/dist/Primitives/Rating.d.cts +4 -0
  94. package/dist/Primitives/Rating.d.ts +4 -0
  95. package/dist/Primitives/Rating.js +2 -0
  96. package/dist/Primitives/Slider.cjs +1 -1
  97. package/dist/Primitives/Slider.js +1 -1
  98. package/dist/Primitives/Switch.cjs +1 -1
  99. package/dist/Primitives/Switch.js +1 -1
  100. package/dist/Primitives/Tag.cjs +1 -1
  101. package/dist/Primitives/Tag.js +1 -1
  102. package/dist/Primitives/index.cjs +2 -1
  103. package/dist/Primitives/index.d.cts +10 -0
  104. package/dist/Primitives/index.d.ts +10 -0
  105. package/dist/Primitives/index.js +2 -1
  106. package/dist/_tsup-dts-rollup.d.cts +825 -0
  107. package/dist/_tsup-dts-rollup.d.ts +825 -0
  108. package/dist/index.cjs +49 -5
  109. package/dist/index.css +1 -1
  110. package/dist/index.d.cts +35 -0
  111. package/dist/index.d.ts +35 -0
  112. package/dist/index.js +49 -5
  113. package/dist/styles/DataDisplay/VirtualList.css +35 -0
  114. package/dist/styles/Extras/LoginPanel.css +16 -0
  115. package/dist/styles/Extras/RichTextEditor.css +908 -0
  116. package/dist/styles/Forms/OTPInput.css +11 -0
  117. package/dist/styles/Layout/SplitPanel.css +15 -0
  118. package/dist/styles/Primitives/Kbd.css +1 -0
  119. package/dist/styles/Primitives/Rating.css +1 -0
  120. package/dist/styles/base.css +278 -0
  121. package/dist/styles.css +278 -0
  122. package/dist/theme.cjs +1 -1
  123. package/dist/theme.d.cts +3 -0
  124. package/dist/theme.d.ts +3 -0
  125. package/dist/theme.js +1 -1
  126. package/package.json +21 -1
@@ -1 +1 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function rt(...t){return tailwindMerge.twMerge(clsx.clsx(t))}var Mt=classVarianceAuthority.cva("relative w-full font-sans select-none",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}}),Lt=classVarianceAuthority.cva("flex flex-wrap gap-3 items-center justify-center",{variants:{position:{top:"mb-3",bottom:"mt-3",left:"flex-col mr-4",right:"flex-col ml-4"}},defaultVariants:{position:"bottom"}}),Tt=classVarianceAuthority.cva("absolute z-50 pointer-events-none px-3 py-2 rounded-lg text-xs shadow-lg border transition-opacity duration-150 bg-primary-900 text-primary-50 border-primary-700 dark:bg-primary-950 dark:border-primary-800");function Vt(t){let[o,r]=react.useState(()=>new Set(t)),e=react.useCallback(s=>{r(y=>{let x=new Set(y);return x.has(s)?x.delete(s):x.add(s),x});},[]),a=react.useCallback(s=>o.has(s),[o]),d=react.useCallback(()=>{r(new Set(t));},[t]);return {visible:o,toggle:e,isVisible:a,showAll:d}}function $t(t){let o=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"];return Array.from({length:t},(r,e)=>o[e%o.length])}function Dt(t,o,r=.1){if(t===o)return [t-1,o+1];let a=(o-t)*r;return [Math.floor(t-a),Math.ceil(o+a)]}function Xt(t,o,r){if(r<=1)return [t];let e=(o-t)/(r-1);return Array.from({length:r},(a,d)=>+(t+d*e).toFixed(10))}function tt(t,o){return o?o(t):typeof t=="number"?Math.abs(t)>=1e6?`${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`${(t/1e3).toFixed(1)}K`:Number.isInteger(t)?t.toString():t.toFixed(2):String(t)}function kt(t,o,r,e){let a=(e-90)*Math.PI/180;return {x:t+r*Math.cos(a),y:o+r*Math.sin(a)}}function Ft(t,o,r){return {top:20,right:r?65:20,bottom:t?52:36,left:o?65:52}}function Et(t,o,r){let e=Math.max(t,120);return {width:e,height:o,margins:r,plotLeft:r.left,plotTop:r.top,plotRight:e-r.right,plotBottom:o-r.bottom,plotWidth:Math.max(e-r.left-r.right,10),plotHeight:Math.max(o-r.top-r.bottom,10)}}function de(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function Ut(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function zt(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function It(t,o){let r=t.length;if(r===0)return ()=>(o[0]+o[1])/2;let e=(o[1]-o[0])/r;return a=>{let d=t.indexOf(a);return d<0?(o[0]+o[1])/2:o[0]+d*e+e/2}}function ue(t,o,r){return t.map(e=>`${o(e.x).toFixed(2)},${r(e.y).toFixed(2)}`).join(" ")}function qt(t,o,r){if(t.length===0)return "";let e=t.map(s=>({x:o(s.x),y:r(s.y)}));if(e.length===1)return `M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;let a=.5,d=`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;for(let s=0;s<e.length-1;s++){let y=s===0?{x:2*e[0].x-e[1].x,y:2*e[0].y-e[1].y}:e[s-1],x=e[s],C=e[s+1],R=s+2<e.length?e[s+2]:{x:2*e[e.length-1].x-e[e.length-2].x,y:2*e[e.length-1].y-e[e.length-2].y},P=x.x+(C.x-y.x)*a/3,L=x.y+(C.y-y.y)*a/3,b=C.x-(R.x-x.x)*a/3,p=C.y-(R.y-x.y)*a/3;d+=` C ${P.toFixed(2)} ${L.toFixed(2)}, ${b.toFixed(2)} ${p.toFixed(2)}, ${C.x.toFixed(2)} ${C.y.toFixed(2)}`;}return d}function pe(t,o,r,e,a){if(t.length===0)return "";let d=e?qt(t,o,r):`M ${t.map(x=>`${o(x.x).toFixed(2)},${r(x.y).toFixed(2)}`).join(" L ")}`,s=o(t[t.length-1].x).toFixed(2),y=o(t[0].x).toFixed(2);return `${d} L ${s},${a.toFixed(2)} L ${y},${a.toFixed(2)} Z`}function Gt(t,o=5){return Xt(t[0],t[1],o)}function Qt(t,o,r){if(o.length===0)return -1;let e=1/0,a=0;for(let d=0;d<o.length;d++){let s=Math.abs(r(o[d])-t);s<e&&(e=s,a=d);}return a}function te(t,o){return t.data.find(r=>String(r.x)===o)?.y}function he(t){for(let o of t)for(let r of o.data)if(typeof r.x=="string")return true;return false}function Pt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function oe({series:t,xAxis:o,yAxis:r,y2Axis:e,y2Series:a=[],smooth:d=false,showDots:s=true,area:y=false,strokeWidth:x=2,title:C,height:R=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:V="No data to display"}){let z=react.useRef(null),S=react.useRef(null),[B,K]=react.useState(600),[T,N]=react.useState(null),[w,I]=react.useState(null);react.useEffect(()=>{let l=S.current;if(!l)return;let k=l.getBoundingClientRect().width;k>0&&K(k);let X=new ResizeObserver(Q=>{let j=Q[0]?.contentRect.width;j&&j>0&&K(j);});return X.observe(l),()=>X.disconnect()},[]);let U=react.useMemo(()=>t.map(l=>l.id),[t]),{visible:G,toggle:q,isVisible:D}=Vt(U),gt=react.useMemo(()=>$t(t.length),[t.length]),i=react.useMemo(()=>new Map(t.map((l,k)=>[l.id,l.color??gt[k]])),[t,gt]),A=react.useMemo(()=>Ft(!!o?.label,!!r?.label,!!e),[o?.label,r?.label,e]),c=react.useMemo(()=>Et(B,R,A),[B,R,A]),F=react.useMemo(()=>he(t),[t]),E=react.useMemo(()=>F?de(t,G):[],[t,G,F]),ut=react.useMemo(()=>{if(F){let j=It(E,[c.plotLeft,c.plotRight]);return st=>j(st)}let l=t.flatMap(j=>j.data.map(st=>st.x));if(l.length===0)return ()=>c.plotLeft;let k=Math.min(...l),X=Math.max(...l),Q=zt([k,X],[c.plotLeft,c.plotRight]);return j=>Q(j)},[t,F,E,c]),xt=react.useMemo(()=>Ut(t,G,r),[t,G,r]),mt=react.useMemo(()=>zt(xt,[c.plotBottom,c.plotTop]),[xt,c]),yt=react.useMemo(()=>Gt(xt,r?.tickCount??5),[xt,r?.tickCount]),nt=react.useMemo(()=>{if(!e)return null;let l=t.filter(k=>a.includes(k.id));return Ut(l,G,e)},[e,t,a,G]),et=react.useMemo(()=>nt?zt(nt,[c.plotBottom,c.plotTop]):null,[nt,c]),pt=react.useMemo(()=>nt?Gt(nt,e?.tickCount??5):[],[nt,e?.tickCount]),dt=react.useMemo(()=>{if(F)return E;let l=t.flatMap(Q=>Q.data.map(j=>Number(j.x)));if(l.length===0)return [];let k=Math.min(...l),X=Math.max(...l);return Gt([k,X],o?.tickCount??6)},[F,E,t,o?.tickCount]),n=react.useCallback(l=>{let k=l.currentTarget.closest("svg");if(!k)return;let X=k.getBoundingClientRect(),Q=l.clientX-X.left,j=z.current?.getBoundingClientRect();if(!j)return;let st="",bt=Q;if(F&&E.length>0){let h=It(E,[c.plotLeft,c.plotRight]),_=Qt(Q,E,h);st=E[_]??"",bt=h(st);}else if(!F){let h=dt;st=tt((Q-c.plotLeft)/c.plotWidth*(h[h.length-1]-h[0])+h[0],o?.format),bt=Q;}let m=t.filter(h=>D(h.id)).map(h=>{a.includes(h.id)&&et!=null?et:mt;let vt;if(F)vt=te(h,st);else {let f=Q,at=1/0,wt;for(let ct of h.data){let Y=ut(ct.x),Wt=Math.abs(Y-f);Wt<at&&(at=Wt,wt=ct.y);}vt=wt;}return {name:h.name,value:vt!==void 0?tt(vt,r?.format):"\u2014",color:i.get(h.id)??"var(--color-chart-1)"}});bt>=c.plotLeft&&bt<=c.plotRight&&I(bt);let M=l.clientX-j.left+12,g=l.clientY-j.top-10;N({x:M,y:g,label:st,items:m});},[F,E,c,t,D,a,et,mt,ut,dt,o?.format,r?.format,i]),u=react.useCallback(()=>{N(null),I(null);},[]),$=react.useCallback(l=>{l.preventDefault();let k=l.touches[0];if(!k)return;let X=l.currentTarget.closest("svg");if(!X)return;let Q=X.getBoundingClientRect(),j=z.current?.getBoundingClientRect();if(!j)return;let st=k.clientX-Q.left,bt=st,m="";if(F&&E.length>0){let g=It(E,[c.plotLeft,c.plotRight]),h=Qt(st,E,g);m=E[h]??"",bt=g(m);}bt>=c.plotLeft&&bt<=c.plotRight&&I(bt);let M=t.filter(g=>D(g.id)).map(g=>({name:g.name,value:F&&m?tt(te(g,m)??0,r?.format):"\u2014",color:i.get(g.id)??"var(--color-chart-1)"}));N({x:k.clientX-j.left+12,y:k.clientY-j.top-10,label:m,items:M});},[F,E,c,t,D,r?.format,i]),v=react.useMemo(()=>t.map((l,k)=>({id:l.id,label:l.name,color:l.color??gt[k],visible:D(l.id)})),[t,gt,D]),W=t.some(l=>l.data.length>0),J=jsxRuntime.jsxs("svg",{role:"img","aria-label":C??"Line chart",width:c.width,height:c.height,viewBox:`0 0 ${c.width} ${c.height}`,shapeRendering:"geometricPrecision",children:[r?.gridLines!==false&&yt.map(l=>{let k=mt(l);return jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:k,y2:k,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},l)}),y&&t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)",j=pe(l.data,ut,X,d,c.plotBottom);return jsxRuntime.jsx("path",{d:j,fill:Q,fillOpacity:.15,stroke:"none",className:p?"chart-area-animate":""},`area-${l.id}`)}),t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return d?jsxRuntime.jsx("path",{d:qt(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id):jsxRuntime.jsx("polyline",{points:ue(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id)}),s&&t.map(l=>{if(!D(l.id))return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return l.data.map((j,st)=>jsxRuntime.jsx("circle",{cx:ut(j.x),cy:X(j.y),r:3,fill:Q,stroke:"white",strokeWidth:1.5,className:rt("chart-dot",p?"chart-dot-animate":"")},`${l.id}-${st}`))}),w!=null&&jsxRuntime.jsx("line",{className:"chart-crosshair",x1:w,x2:w,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,strokeDasharray:"4 4",opacity:.5,style:{color:"var(--color-secondary-400)"}}),jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotLeft,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),yt.map(l=>{let k=mt(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:c.plotLeft-4,x2:c.plotLeft,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:c.plotLeft-6,y:k,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,r?.format)})]},l)}),r?.label&&jsxRuntime.jsx("text",{x:-(c.plotTop+c.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),e&&et&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:c.plotRight,x2:c.plotRight,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),pt.map(l=>{let k=et(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:c.plotRight,x2:c.plotRight+4,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:c.plotRight+6,y:k,textAnchor:"start",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,e?.format)})]},l)}),e?.label&&jsxRuntime.jsx("text",{x:c.plotTop+c.plotHeight/2,y:-(c.width-14),textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(90)",children:e.label})]}),jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:c.plotBottom,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),(F?E:dt).map((l,k)=>{let X=ut(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:X,x2:X,y1:c.plotBottom,y2:c.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:X,y:c.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,o?.format)})]},k)}),o?.label&&jsxRuntime.jsx("text",{x:c.plotLeft+c.plotWidth/2,y:c.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label}),jsxRuntime.jsx("rect",{x:c.plotLeft,y:c.plotTop,width:c.plotWidth,height:c.plotHeight,fill:"transparent",onMouseMove:n,onMouseLeave:u,onTouchStart:$,onTouchMove:$,onTouchEnd:u,style:{cursor:"crosshair"}})]}),it=b==="left"||b==="right";return jsxRuntime.jsxs("div",{ref:z,className:rt(Mt(),P),children:[C&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsxRuntime.jsx(Pt,{items:v,position:"top",onToggle:q}),jsxRuntime.jsxs("div",{className:rt("flex items-start",it&&"gap-0"),children:[L&&b==="left"&&jsxRuntime.jsx(Pt,{items:v,position:"left",onToggle:q}),jsxRuntime.jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:W?J:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:R},children:V})}),L&&b==="right"&&jsxRuntime.jsx(Pt,{items:v,position:"right",onToggle:q})]}),L&&b==="bottom"&&jsxRuntime.jsx(Pt,{items:v,position:"bottom",onToggle:q}),T&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[T.label&&jsxRuntime.jsx("div",{className:"mb-1 font-medium text-primary-200",children:T.label}),T.items.map((l,k)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:l.color}}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:[l.name,":"]}),jsxRuntime.jsx("span",{className:"font-medium",children:l.value})]},k))]})]})}function ge(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function xe(t,o,r,e){if(r){let a=0;for(let s of t)if(o.has(s.id))for(let y of s.data)y.y>a&&(a=y.y);a===0&&(a=1);let[,d]=Dt(0,a,.05);return [e?.min??0,e?.max??d]}else {let a=new Map;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=String(x.x);a.set(C,(a.get(C)??0)+x.y);}let d=Math.max(0,...a.values()),[,s]=Dt(0,d===0?1:d,.05);return [e?.min??0,e?.max??s]}}function ye(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function be(t,o=5){return Xt(t[0],t[1],o)}function ve(t,o,r,e,a,d,s,y,x,C,R){let P=t.filter(B=>o.has(B.id)),L=r.length,b=P.length;if(L===0||b===0)return [];let p=d/L,V=p*(1-C),z=b>0?V*(1-R)/b:0,S=[];for(let B=0;B<r.length;B++){let K=r[B],T=a+B*p+(p-V)/2;for(let N=0;N<P.length;N++){let w=P[N],I=w.data.find(q=>String(q.x)===K);if(!I)continue;let U=T+N*(z+V*R/b),G=x(I.y);S.push({seriesId:w.id,category:K,x:U,y:G,width:Math.max(z,1),height:Math.max(s-G,0),stackBase:s,value:I.y,color:e.get(w.id)??"var(--color-chart-1)"});}}return S}function ke(t,o,r,e,a,d,s,y,x,C){let R=t.filter(S=>o.has(S.id)),P=r.length,L=R.length;if(P===0||L===0)return [];let b=s/P,p=b*(1-x),V=L>0?p*(1-C)/L:0,z=[];for(let S=0;S<r.length;S++){let B=r[S],K=d+S*b+(b-p)/2;for(let T=0;T<R.length;T++){let N=R[T],w=N.data.find(G=>String(G.x)===B);if(!w)continue;let I=K+T*(V+p*C/Math.max(L,1)),U=y(w.y);z.push({seriesId:N.id,category:B,x:a,y:I,width:Math.max(U-a,0),height:Math.max(V,1),stackBase:a,value:w.y,color:e.get(N.id)??"var(--color-chart-1)"});}}return z}function Ce(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=r.length;if(R===0)return [];let P=s/R*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,a));for(let p of C)for(let V of r){let z=p.data.find(N=>String(N.x)===V);if(!z)continue;let S=b.get(V)??a,B=Math.max(y(z.y)-a,0),K=r.indexOf(V),T=d+(K+.5)*(s/R);L.push({seriesId:p.id,category:V,x:S,y:T-P/2,width:B,height:Math.max(P,1),stackBase:S,value:z.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(V,S+B);}return L}function Se(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=r.length;if(R===0)return [];let P=d/R*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,s));for(let p of C)for(let V of r){let z=p.data.find(w=>String(w.x)===V);if(!z)continue;let S=b.get(V)??s,B=Math.max(s-y(z.y),0),K=S-B,T=r.indexOf(V),N=a+(T+.5)*(d/R);L.push({seriesId:p.id,category:V,x:N-P/2,y:K,width:Math.max(P,1),height:B,stackBase:S,value:z.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(V,K);}return L}function jt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function ne({series:t,xAxis:o,yAxis:r,orientation:e="vertical",grouped:a=true,barRadius:d=4,barPadding:s=.2,groupPadding:y=.3,title:x,height:C=300,className:R,legend:P=true,legendPosition:L="bottom",animateOnMount:b=true,emptyText:p="No data to display"}){let V=react.useRef(null),z=react.useRef(null),[S,B]=react.useState(600),[K,T]=react.useState(null);react.useEffect(()=>{let n=z.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&B(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&B(W);});return $.observe(n),()=>$.disconnect()},[]);let N=react.useMemo(()=>t.map(n=>n.id),[t]),{visible:w,toggle:I,isVisible:U}=Vt(N),G=react.useMemo(()=>$t(t.length),[t.length]),q=react.useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??G[u]])),[t,G]),D=e==="horizontal",gt=react.useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=react.useMemo(()=>Et(S,C,gt),[S,C,gt]),A=react.useMemo(()=>ge(t,w),[t,w]),c=react.useMemo(()=>xe(t,w,a,D?o:r),[t,w,a,D,o,r]),F=react.useMemo(()=>ye(c,D?[i.plotLeft,i.plotRight]:[i.plotBottom,i.plotTop]),[c,i,D]),E=react.useMemo(()=>be(c,(D?o:r)?.tickCount??5),[c,D,o,r]),ut=react.useMemo(()=>D?a?ke(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y,s):Ce(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y):a?ve(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,i.plotTop,F,y,s):Se(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,F,y),[t,w,A,q,i,F,a,D,y,s]),xt=A.length>0?i.plotWidth/A.length:1,mt=A.length>0?i.plotHeight/A.length:1,yt=react.useCallback((n,u)=>{let $=V.current?.getBoundingClientRect();if(!$)return;let v=t.filter(W=>U(W.id)).map(W=>{let J=W.data.find(it=>String(it.x)===u);return {name:W.name,value:J?tt(J.y,r?.format):"\u2014",color:q.get(W.id)??"var(--color-chart-1)"}});T({x:n.clientX-$.left+12,y:n.clientY-$.top-10,category:u,items:v});},[t,U,q,r?.format]),nt=react.useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??G[u],visible:U(n.id)})),[t,G,U]),et=t.some(n=>n.data.length>0),pt=L==="left"||L==="right",dt=jsxRuntime.jsxs("svg",{role:"img","aria-label":x??"Bar chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[E.map(n=>{let u=F(n);return D?jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n):jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:u,y2:u,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)}),ut.map(n=>{let u=Math.min(d,n.width/2,n.height/2),$=`${n.seriesId}-${n.category}`;return D?jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-h",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$):jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-v",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$)}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),!D&&E.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),D&&E.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),A.map((n,u)=>{if(D){let v=i.plotTop+(u+.5)*mt;return jsxRuntime.jsx("text",{x:i.plotLeft-6,y:v,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}let $=i.plotLeft+(u+.5)*xt;return jsxRuntime.jsx("text",{x:$,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}),r?.label&&!D&&jsxRuntime.jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsxRuntime.jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxRuntime.jsxs("div",{ref:V,className:rt(Mt(),R),children:[x&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:x}),P&&L==="top"&&jsxRuntime.jsx(jt,{items:nt,position:"top",onToggle:I}),jsxRuntime.jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[P&&L==="left"&&jsxRuntime.jsx(jt,{items:nt,position:"left",onToggle:I}),jsxRuntime.jsx("div",{ref:z,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:C},children:p})}),P&&L==="right"&&jsxRuntime.jsx(jt,{items:nt,position:"right",onToggle:I})]}),P&&L==="bottom"&&jsxRuntime.jsx(jt,{items:nt,position:"bottom",onToggle:I}),K&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:K.x,top:K.y},role:"tooltip",children:[jsxRuntime.jsx("div",{className:"mb-1 font-medium text-primary-200",children:K.category}),K.items.map((n,u)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:n.color}}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:[n.name,":"]}),jsxRuntime.jsx("span",{className:"font-medium",children:n.value})]},u))]})]})}function Me(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=C.reduce((p,V)=>p+V.value,0);if(R===0)return [];let P=new Map(t.map((p,V)=>[p.id,p.color??r[V%r.length]])),L=[],b=y;for(let p of C){let V=p.value/R*360,z=x/2,S=b+z,B=b+V-z,K=(S+B)/2,T;if(Math.abs(B-S)>=359.9){let N=kt(d,s,e,S),w=kt(d,s,e,S+180);T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 1 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} A ${e} ${e} 0 1 1 ${N.x.toFixed(3)} ${N.y.toFixed(3)} Z`;}else if(a>0){let N=kt(d,s,e,S),w=kt(d,s,e,B),I=kt(d,s,a,B),U=kt(d,s,a,S),G=B-S>180?1:0;T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${G} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} L ${I.x.toFixed(3)} ${I.y.toFixed(3)} A ${a} ${a} 0 ${G} 0 ${U.x.toFixed(3)} ${U.y.toFixed(3)} Z`;}else {let N=kt(d,s,e,S),w=kt(d,s,e,B),I=B-S>180?1:0;T=`M ${d.toFixed(3)} ${s.toFixed(3)} L ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${I} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} Z`;}L.push({id:p.id,label:p.label,value:p.value,percent:Math.round(p.value/R*1e3)/10,color:P.get(p.id)??"var(--color-chart-1)",startAngle:S,endAngle:B,midAngle:K,path:T,outerR:e,innerR:a,cx:d,cy:s}),b+=V;}return L}function Le(t,o){let r=(t-90)*Math.PI/180;return {dx:Math.cos(r)*o,dy:Math.sin(r)*o}}function Zt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),jsxRuntime.jsx("span",{children:e.label}),jsxRuntime.jsxs("span",{className:"text-secondary-400",children:["(",e.percent,"%)"]})]},e.id))})}function se({data:t,donut:o=false,donutThickness:r=.5,startAngle:e=-90,padAngle:a=0,labelType:d="percent",centerLabel:s,centerSubLabel:y,explodeOnHover:x=true,explodeOffset:C=8,title:R,height:P=300,className:L,legend:b=true,legendPosition:p="bottom",animateOnMount:V=true,emptyText:z="No data to display"}){let S=react.useRef(null),B=react.useRef(null),[K,T]=react.useState(400),[N,w]=react.useState(null),[I,U]=react.useState(null),[G,q]=react.useState({}),D=react.useRef(null);react.useEffect(()=>{let m=B.current;if(!m)return;let M=m.getBoundingClientRect().width;M>0&&T(M);let g=new ResizeObserver(h=>{let _=h[0]?.contentRect.width;_&&_>0&&T(_);});return g.observe(m),()=>g.disconnect()},[]),react.useEffect(()=>{function m(g){let h=D.current;if(!h)return;"touches"in g&&g.cancelable&&g.preventDefault();let _="touches"in g?g.touches[0]?.clientX??h.startX:g.clientX,ht="touches"in g?g.touches[0]?.clientY??h.startY:g.clientY;q(vt=>({...vt,[h.id]:{dx:h.origDx+_-h.startX,dy:h.origDy+ht-h.startY}}));}function M(){D.current=null;}return window.addEventListener("mousemove",m),window.addEventListener("mouseup",M),window.addEventListener("touchmove",m,{passive:false}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",m),window.removeEventListener("touchend",M);}},[]);let gt=react.useMemo(()=>t.map(m=>m.id),[t]),{visible:i,toggle:A,isVisible:c}=Vt(gt),F=react.useMemo(()=>$t(t.length),[t.length]),E=10,ut=6.4,xt=18,mt=14,yt=6,nt=K,et=P,pt=nt/2,dt=et/2,n=d!=="none"?xt+yt+4:yt+4,u=Math.max(Math.min(pt,dt)-n,20),$=o?u*r:0,v=react.useMemo(()=>Me(t,i,F,u,$,pt,dt,e,a),[t,i,F,u,$,pt,dt,e,a]),W=react.useMemo(()=>v.map(m=>m.id).join(","),[v]);react.useEffect(()=>{q({});},[W]);let J=react.useCallback((m,M)=>{if(D.current)return;let g=S.current?.getBoundingClientRect();if(!g)return;w(M);let h=v.find(_=>_.id===M);h&&U({x:m.clientX-g.left+12,y:m.clientY-g.top-10,items:[{label:h.label,value:tt(h.value),percent:`${h.percent}%`,color:h.color}]});},[v]),it=react.useCallback(()=>{w(null),U(null);},[]),l=react.useCallback((m,M,g)=>{let h=G[m]??{dx:0,dy:0};D.current={id:m,startX:M,startY:g,origDx:h.dx,origDy:h.dy};},[G]),k=react.useCallback((m,M)=>{m.preventDefault(),w(M);let g=S.current?.getBoundingClientRect();if(!g)return;let h=m.touches[0];if(!h)return;let _=v.find(ht=>ht.id===M);_&&U({x:h.clientX-g.left+12,y:h.clientY-g.top-10,items:[{label:_.label,value:tt(_.value),percent:`${_.percent}%`,color:_.color}]});},[v]),X=react.useMemo(()=>{let m=t.reduce((M,g)=>M+g.value,0);return t.map((M,g)=>({id:M.id,label:M.label,color:M.color??F[g],visible:c(M.id),percent:m>0?Math.round(M.value/m*1e3)/10:0}))},[t,F,c]),Q=t.length>0&&t.some(m=>m.value>0),j=p==="left"||p==="right",st=react.useMemo(()=>{if(d==="none")return [];let m=E+3,M=yt+E*.5,g=et-yt-E*.5,h=v.filter(f=>f.percent>=3).map(f=>{let at="";switch(d){case "percent":at=`${f.percent}%`;break;case "value":at=tt(f.value);break;case "label":at=f.label;break;case "label+percent":at=`${f.label} ${f.percent}%`;break}let wt=kt(f.cx,f.cy,f.outerR+2,f.midAngle),ct=kt(f.cx,f.cy,f.outerR+xt,f.midAngle),Y=(f.midAngle-90)*Math.PI/180,Wt=Math.cos(Y)>=0,Ht=Math.ceil(at.length*ut);return {id:f.id,color:f.color,text:at,textW:Ht,p1:wt,elbowX:ct.x,y:ct.y,isRight:Wt}}),_=h.filter(f=>f.isRight).sort((f,at)=>f.y-at.y),ht=h.filter(f=>!f.isRight).sort((f,at)=>f.y-at.y);function vt(f){if(f.length!==0)for(let at=0;at<20;at++){let wt=false;for(let Y=1;Y<f.length;Y++){let Wt=f[Y].y-f[Y-1].y;if(Wt<m){let Ht=(m-Wt)/2;f[Y-1].y-=Ht,f[Y].y+=Ht,wt=true;}}f[0].y<M&&(f[0].y=M);for(let Y=1;Y<f.length;Y++)f[Y].y<f[Y-1].y+m&&(f[Y].y=f[Y-1].y+m);let ct=f.length-1;f[ct].y>g&&(f[ct].y=g);for(let Y=ct-1;Y>=0;Y--)f[Y].y>f[Y+1].y-m&&(f[Y].y=f[Y+1].y-m);for(let Y of f)Y.y=Math.max(M,Math.min(g,Y.y));if(!wt)break}}return vt(_),vt(ht),[...ht,..._]},[v,d,et]),bt=jsxRuntime.jsxs("svg",{role:"img","aria-label":R??"Pie chart",width:nt,height:et,viewBox:`0 0 ${nt} ${et}`,shapeRendering:"geometricPrecision",children:[jsxRuntime.jsxs("g",{className:V?"chart-pie-animate":"",children:[v.map((m,M)=>{let g=N===m.id,h=x&&g,_=Le(m.midAngle,h?C:0);return jsxRuntime.jsx("path",{d:m.path,fill:m.color,transform:h?`translate(${_.dx}, ${_.dy})`:void 0,className:rt("chart-slice",V&&`chart-slice-animate-${Math.min(M,7)}`,g&&"chart-slice--exploded"),stroke:m.color,strokeWidth:.6,onMouseMove:ht=>J(ht,m.id),onMouseLeave:it,onTouchStart:ht=>k(ht,m.id),onTouchEnd:it,"aria-label":`${m.label}: ${m.percent}%`},m.id)}),st.map(m=>{let M=G[m.id]??{dx:0,dy:0},g=m.elbowX+M.dx,h=m.y+M.dy,_=g+(m.isRight?mt:-mt),ht=m.isRight?_+3:_-3,vt=mt+3+m.textW+6,f=m.isRight?g:g-vt,at=h-E-2,wt=E*2+4;return jsxRuntime.jsxs("g",{style:{userSelect:"none"},children:[jsxRuntime.jsx("polyline",{points:[`${m.p1.x.toFixed(2)},${m.p1.y.toFixed(2)}`,`${g.toFixed(2)},${h.toFixed(2)}`,`${_.toFixed(2)},${h.toFixed(2)}`].join(" "),fill:"none",stroke:m.color,strokeWidth:1.2,opacity:.85,strokeLinejoin:"round",strokeLinecap:"round",style:{pointerEvents:"none"}}),jsxRuntime.jsx("text",{x:ht.toFixed(2),y:h.toFixed(2),textAnchor:m.isRight?"start":"end",dominantBaseline:"middle",fontSize:E,fill:"currentColor",className:"text-primary-700 dark:text-primary-300",style:{pointerEvents:"none"},children:m.text}),jsxRuntime.jsx("rect",{x:f,y:at,width:vt,height:wt,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseDown:ct=>{ct.stopPropagation(),l(m.id,ct.clientX,ct.clientY);},onTouchStart:ct=>{ct.stopPropagation();let Y=ct.touches[0];Y&&l(m.id,Y.clientX,Y.clientY);}})]},`label-${m.id}`)})]}),o&&jsxRuntime.jsx("g",{style:{pointerEvents:"none"},children:N&&v.find(m=>m.id===N)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("text",{x:pt,y:dt-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:18,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:[v.find(m=>m.id===N)?.percent,"%"]}),jsxRuntime.jsx("text",{x:pt,y:dt+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:v.find(m=>m.id===N)?.label})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s&&jsxRuntime.jsx("text",{x:pt,y:dt-(y?8:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:16,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:s}),y&&jsxRuntime.jsx("text",{x:pt,y:dt+14,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:y})]})})]});return jsxRuntime.jsxs("div",{ref:S,className:rt(Mt(),L),children:[R&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:R}),b&&p==="top"&&jsxRuntime.jsx(Zt,{items:X,position:"top",onToggle:A}),jsxRuntime.jsxs("div",{className:rt("flex items-start justify-center",j&&"gap-0"),children:[b&&p==="left"&&jsxRuntime.jsx(Zt,{items:X,position:"left",onToggle:A}),jsxRuntime.jsx("div",{ref:B,className:"flex-1 min-w-0 overflow-hidden",children:Q?bt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:P},children:z})}),b&&p==="right"&&jsxRuntime.jsx(Zt,{items:X,position:"right",onToggle:A})]}),b&&p==="bottom"&&jsxRuntime.jsx(Zt,{items:X,position:"bottom",onToggle:A}),I&&jsxRuntime.jsx("div",{className:Tt(),style:{left:I.x,top:I.y},role:"tooltip",children:I.items.map((m,M)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:m.color}}),jsxRuntime.jsxs("span",{className:"font-medium",children:[m.label,":"]}),jsxRuntime.jsx("span",{children:m.value}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:["(",m.percent,")"]})]},M))})]})}function Be(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=Number(x.x);C<e&&(e=C),C>a&&(a=C);}if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function Re(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function ce(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function le(t,o=5){return Xt(t[0],t[1],o)}function Ve(t,o,r){let e=1.618033988749895,a=t*137+o,d=a*e%1*2-1,s=a*e*e%1*2-1;return [d*r,s*r]}function $e(t,o,r=12){if(t.length<2)return null;let e=Math.min(...t),a=Math.max(...t),d=Math.min(...o),s=Math.max(...o);return {cx:(e+a)/2,cy:(d+s)/2,rx:(a-e)/2+r,ry:(s-d)/2+r}}function Kt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),e.label]},e.id))})}function me({series:t,xAxis:o,yAxis:r,dotRadius:e=5,dotOpacity:a=.75,clusters:d=false,jitter:s=false,jitterAmount:y=12,linkedLines:x=false,title:C,height:R=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:V="No data to display"}){let z=react.useRef(null),S=react.useRef(null),[B,K]=react.useState(600),[T,N]=react.useState(null);react.useEffect(()=>{let n=S.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&K(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&K(W);});return $.observe(n),()=>$.disconnect()},[]);let w=react.useMemo(()=>t.map(n=>n.id),[t]),{visible:I,toggle:U,isVisible:G}=Vt(w),q=react.useMemo(()=>$t(t.length),[t.length]),D=react.useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??q[u]])),[t,q]),gt=react.useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=react.useMemo(()=>Et(B,R,gt),[B,R,gt]),A=react.useMemo(()=>Be(t,I,o),[t,I,o]),c=react.useMemo(()=>Re(t,I,r),[t,I,r]),F=react.useMemo(()=>ce(A,[i.plotLeft,i.plotRight]),[A,i]),E=react.useMemo(()=>ce(c,[i.plotBottom,i.plotTop]),[c,i]),ut=react.useMemo(()=>le(A,o?.tickCount??6),[A,o?.tickCount]),xt=react.useMemo(()=>le(c,r?.tickCount??5),[c,r?.tickCount]),mt=react.useCallback((n,u,$,v,W)=>{let J=z.current?.getBoundingClientRect();J&&N({x:n.clientX-J.left+12,y:n.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),yt=react.useCallback((n,u,$,v,W)=>{n.preventDefault();let J=z.current?.getBoundingClientRect();if(!J)return;let it=n.touches[0];it&&N({x:it.clientX-J.left+12,y:it.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),nt=react.useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??q[u],visible:G(n.id)})),[t,q,G]),et=t.some(n=>n.data.length>0),pt=b==="left"||b==="right",dt=jsxRuntime.jsxs("svg",{role:"img","aria-label":C??"Scatter chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[xt.map(n=>jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:E(n),y2:E(n),stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)),d&&t.map((n,u)=>{if(!G(n.id)||n.data.length<2)return null;let $=D.get(n.id)??"var(--color-chart-1)",v=n.data.map(it=>F(Number(it.x))),W=n.data.map(it=>E(it.y)),J=$e(v,W,16);return J?jsxRuntime.jsx("ellipse",{cx:J.cx,cy:J.cy,rx:J.rx,ry:J.ry,fill:$,fillOpacity:.06,stroke:$,strokeOpacity:.3,strokeWidth:1.5,strokeDasharray:"5 3",className:p?"chart-cluster-ellipse":"",style:{animationDelay:`${u*.1}s`}},`cluster-${n.id}`):null}),x&&t.map(n=>{if(!G(n.id)||n.data.length<2)return null;let u=D.get(n.id)??"var(--color-chart-1)",v=[...n.data].sort((W,J)=>Number(W.x)-Number(J.x)).map(W=>`${F(Number(W.x)).toFixed(2)},${E(W.y).toFixed(2)}`).join(" ");return jsxRuntime.jsx("polyline",{points:v,fill:"none",stroke:u,strokeWidth:1.5,className:"chart-scatter-link"},`link-${n.id}`)}),t.map((n,u)=>{if(!G(n.id))return null;let $=D.get(n.id)??"var(--color-chart-1)";return jsxRuntime.jsx("g",{className:"chart-scatter-group",children:n.data.map((v,W)=>{let[J,it]=s?Ve(u,W,y):[0,0],l=F(Number(v.x))+J,k=E(v.y)+it;return jsxRuntime.jsx("circle",{cx:l,cy:k,r:e,fill:$,fillOpacity:a,stroke:$,strokeWidth:1,strokeOpacity:.5,className:rt("chart-scatter-dot",p&&"chart-scatter-dot--animate"),style:{color:$},onMouseMove:X=>mt(X,n.name,v.x,v.y,$),onMouseLeave:()=>N(null),onTouchStart:X=>yt(X,n.name,v.x,v.y,$),onTouchEnd:()=>N(null)},W)})},n.id)}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),xt.map(n=>{let u=E(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),ut.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),r?.label&&jsxRuntime.jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsxRuntime.jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxRuntime.jsxs("div",{ref:z,className:rt(Mt(),P),children:[C&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsxRuntime.jsx(Kt,{items:nt,position:"top",onToggle:U}),jsxRuntime.jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[L&&b==="left"&&jsxRuntime.jsx(Kt,{items:nt,position:"left",onToggle:U}),jsxRuntime.jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:R},children:V})}),L&&b==="right"&&jsxRuntime.jsx(Kt,{items:nt,position:"right",onToggle:U})]}),L&&b==="bottom"&&jsxRuntime.jsx(Kt,{items:nt,position:"bottom",onToggle:U}),T&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:T.color}}),jsxRuntime.jsx("span",{className:"font-medium",children:T.seriesName})]}),jsxRuntime.jsxs("div",{className:"text-primary-300",children:["X: ",jsxRuntime.jsx("span",{className:"font-medium text-primary-50",children:T.xVal})," ","Y: ",jsxRuntime.jsx("span",{className:"font-medium text-primary-50",children:T.yVal})]})]})]})}var je={LineChart:oe,BarChart:ne,PieChart:se,ScatterChart:me},lo=je;exports.BarChart=ne;exports.Chart=je;exports.LineChart=oe;exports.PieChart=se;exports.ScatterChart=me;exports.default=lo;
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function rt(...t){return tailwindMerge.twMerge(clsx.clsx(t))}var Mt=classVarianceAuthority.cva("relative w-full font-sans select-none",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}}),Lt=classVarianceAuthority.cva("flex flex-wrap gap-3 items-center justify-center",{variants:{position:{top:"mb-3",bottom:"mt-3",left:"flex-col mr-4",right:"flex-col ml-4"}},defaultVariants:{position:"bottom"}}),Tt=classVarianceAuthority.cva("absolute z-50 pointer-events-none px-3 py-2 rounded-lg text-xs shadow-lg border transition-opacity duration-150 bg-primary-900 text-primary-50 border-primary-700 dark:bg-primary-950 dark:border-primary-800");function Rt(t){let[o,r]=react.useState(()=>new Set(t)),e=react.useCallback(s=>{r(y=>{let x=new Set(y);return x.has(s)?x.delete(s):x.add(s),x});},[]),a=react.useCallback(s=>o.has(s),[o]),d=react.useCallback(()=>{r(new Set(t));},[t]);return {visible:o,toggle:e,isVisible:a,showAll:d}}function $t(t){let o=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"];return Array.from({length:t},(r,e)=>o[e%o.length])}function Dt(t,o,r=.1){if(t===o)return [t-1,o+1];let a=(o-t)*r;return [Math.floor(t-a),Math.ceil(o+a)]}function Xt(t,o,r){if(r<=1)return [t];let e=(o-t)/(r-1);return Array.from({length:r},(a,d)=>+(t+d*e).toFixed(10))}function tt(t,o){return o?o(t):typeof t=="number"?Math.abs(t)>=1e6?`${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`${(t/1e3).toFixed(1)}K`:Number.isInteger(t)?t.toString():t.toFixed(2):String(t)}function kt(t,o,r,e){let a=(e-90)*Math.PI/180;return {x:t+r*Math.cos(a),y:o+r*Math.sin(a)}}function Ft(t,o,r){return {top:20,right:r?65:20,bottom:t?52:36,left:o?65:52}}function Et(t,o,r){let e=Math.max(t,120);return {width:e,height:o,margins:r,plotLeft:r.left,plotTop:r.top,plotRight:e-r.right,plotBottom:o-r.bottom,plotWidth:Math.max(e-r.left-r.right,10),plotHeight:Math.max(o-r.top-r.bottom,10)}}function de(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function Ut(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function It(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function zt(t,o){let r=t.length;if(r===0)return ()=>(o[0]+o[1])/2;let e=(o[1]-o[0])/r;return a=>{let d=t.indexOf(a);return d<0?(o[0]+o[1])/2:o[0]+d*e+e/2}}function ue(t,o,r){return t.map(e=>`${o(e.x).toFixed(2)},${r(e.y).toFixed(2)}`).join(" ")}function qt(t,o,r){if(t.length===0)return "";let e=t.map(s=>({x:o(s.x),y:r(s.y)}));if(e.length===1)return `M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;let a=.5,d=`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;for(let s=0;s<e.length-1;s++){let y=s===0?{x:2*e[0].x-e[1].x,y:2*e[0].y-e[1].y}:e[s-1],x=e[s],C=e[s+1],V=s+2<e.length?e[s+2]:{x:2*e[e.length-1].x-e[e.length-2].x,y:2*e[e.length-1].y-e[e.length-2].y},P=x.x+(C.x-y.x)*a/3,L=x.y+(C.y-y.y)*a/3,b=C.x-(V.x-x.x)*a/3,p=C.y-(V.y-x.y)*a/3;d+=` C ${P.toFixed(2)} ${L.toFixed(2)}, ${b.toFixed(2)} ${p.toFixed(2)}, ${C.x.toFixed(2)} ${C.y.toFixed(2)}`;}return d}function pe(t,o,r,e,a){if(t.length===0)return "";let d=e?qt(t,o,r):`M ${t.map(x=>`${o(x.x).toFixed(2)},${r(x.y).toFixed(2)}`).join(" L ")}`,s=o(t[t.length-1].x).toFixed(2),y=o(t[0].x).toFixed(2);return `${d} L ${s},${a.toFixed(2)} L ${y},${a.toFixed(2)} Z`}function Gt(t,o=5){return Xt(t[0],t[1],o)}function Qt(t,o,r){if(o.length===0)return -1;let e=1/0,a=0;for(let d=0;d<o.length;d++){let s=Math.abs(r(o[d])-t);s<e&&(e=s,a=d);}return a}function te(t,o){return t.data.find(r=>String(r.x)===o)?.y}function he(t){for(let o of t)for(let r of o.data)if(typeof r.x=="string")return true;return false}function Pt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function oe({series:t,xAxis:o,yAxis:r,y2Axis:e,y2Series:a=[],smooth:d=false,showDots:s=true,area:y=false,strokeWidth:x=2,title:C,height:V=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:R="No data to display"}){let I=react.useRef(null),S=react.useRef(null),[B,K]=react.useState(600),[T,N]=react.useState(null),[w,z]=react.useState(null);react.useEffect(()=>{let l=S.current;if(!l)return;let k=l.getBoundingClientRect().width;k>0&&K(k);let X=new ResizeObserver(Q=>{let j=Q[0]?.contentRect.width;j&&j>0&&K(j);});return X.observe(l),()=>X.disconnect()},[]);let U=react.useMemo(()=>t.map(l=>l.id),[t]),{visible:G,toggle:q,isVisible:D}=Rt(U),gt=react.useMemo(()=>$t(t.length),[t.length]),i=react.useMemo(()=>new Map(t.map((l,k)=>[l.id,l.color??gt[k]])),[t,gt]),A=react.useMemo(()=>Ft(!!o?.label,!!r?.label,!!e),[o?.label,r?.label,e]),c=react.useMemo(()=>Et(B,V,A),[B,V,A]),F=react.useMemo(()=>he(t),[t]),E=react.useMemo(()=>F?de(t,G):[],[t,G,F]),ut=react.useMemo(()=>{if(F){let j=zt(E,[c.plotLeft,c.plotRight]);return st=>j(st)}let l=t.flatMap(j=>j.data.map(st=>st.x));if(l.length===0)return ()=>c.plotLeft;let k=Math.min(...l),X=Math.max(...l),Q=It([k,X],[c.plotLeft,c.plotRight]);return j=>Q(j)},[t,F,E,c]),xt=react.useMemo(()=>Ut(t,G,r),[t,G,r]),mt=react.useMemo(()=>It(xt,[c.plotBottom,c.plotTop]),[xt,c]),yt=react.useMemo(()=>Gt(xt,r?.tickCount??5),[xt,r?.tickCount]),nt=react.useMemo(()=>{if(!e)return null;let l=t.filter(k=>a.includes(k.id));return Ut(l,G,e)},[e,t,a,G]),et=react.useMemo(()=>nt?It(nt,[c.plotBottom,c.plotTop]):null,[nt,c]),pt=react.useMemo(()=>nt?Gt(nt,e?.tickCount??5):[],[nt,e?.tickCount]),dt=react.useMemo(()=>{if(F)return E;let l=t.flatMap(Q=>Q.data.map(j=>Number(j.x)));if(l.length===0)return [];let k=Math.min(...l),X=Math.max(...l);return Gt([k,X],o?.tickCount??6)},[F,E,t,o?.tickCount]),n=react.useCallback(l=>{let k=l.currentTarget.closest("svg");if(!k)return;let X=k.getBoundingClientRect(),Q=l.clientX-X.left,j=I.current?.getBoundingClientRect();if(!j)return;let st="",bt=Q;if(F&&E.length>0){let h=zt(E,[c.plotLeft,c.plotRight]),_=Qt(Q,E,h);st=E[_]??"",bt=h(st);}else if(!F){let h=dt;st=tt((Q-c.plotLeft)/c.plotWidth*(h[h.length-1]-h[0])+h[0],o?.format),bt=Q;}let m=t.filter(h=>D(h.id)).map(h=>{a.includes(h.id)&&et!=null?et:mt;let vt;if(F)vt=te(h,st);else {let f=Q,at=1/0,wt;for(let ct of h.data){let Y=ut(ct.x),Wt=Math.abs(Y-f);Wt<at&&(at=Wt,wt=ct.y);}vt=wt;}return {name:h.name,value:vt!==void 0?tt(vt,r?.format):"\u2014",color:i.get(h.id)??"var(--color-chart-1)"}});bt>=c.plotLeft&&bt<=c.plotRight&&z(bt);let M=l.clientX-j.left+12,g=l.clientY-j.top-10;N({x:M,y:g,label:st,items:m});},[F,E,c,t,D,a,et,mt,ut,dt,o?.format,r?.format,i]),u=react.useCallback(()=>{N(null),z(null);},[]),$=react.useCallback(l=>{l.preventDefault();let k=l.touches[0];if(!k)return;let X=l.currentTarget.closest("svg");if(!X)return;let Q=X.getBoundingClientRect(),j=I.current?.getBoundingClientRect();if(!j)return;let st=k.clientX-Q.left,bt=st,m="";if(F&&E.length>0){let g=zt(E,[c.plotLeft,c.plotRight]),h=Qt(st,E,g);m=E[h]??"",bt=g(m);}bt>=c.plotLeft&&bt<=c.plotRight&&z(bt);let M=t.filter(g=>D(g.id)).map(g=>({name:g.name,value:F&&m?tt(te(g,m)??0,r?.format):"\u2014",color:i.get(g.id)??"var(--color-chart-1)"}));N({x:k.clientX-j.left+12,y:k.clientY-j.top-10,label:m,items:M});},[F,E,c,t,D,r?.format,i]),v=react.useMemo(()=>t.map((l,k)=>({id:l.id,label:l.name,color:l.color??gt[k],visible:D(l.id)})),[t,gt,D]),W=t.some(l=>l.data.length>0),J=jsxRuntime.jsxs("svg",{role:"img","aria-label":C??"Line chart",width:c.width,height:c.height,viewBox:`0 0 ${c.width} ${c.height}`,shapeRendering:"geometricPrecision",children:[r?.gridLines!==false&&yt.map(l=>{let k=mt(l);return jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:k,y2:k,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},l)}),y&&t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)",j=pe(l.data,ut,X,d,c.plotBottom);return jsxRuntime.jsx("path",{d:j,fill:Q,fillOpacity:.15,stroke:"none",className:p?"chart-area-animate":""},`area-${l.id}`)}),t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return d?jsxRuntime.jsx("path",{d:qt(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id):jsxRuntime.jsx("polyline",{points:ue(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id)}),s&&t.map(l=>{if(!D(l.id))return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return l.data.map((j,st)=>jsxRuntime.jsx("circle",{cx:ut(j.x),cy:X(j.y),r:3,fill:Q,stroke:"white",strokeWidth:1.5,className:rt("chart-dot",p?"chart-dot-animate":"")},`${l.id}-${st}`))}),w!=null&&jsxRuntime.jsx("line",{className:"chart-crosshair",x1:w,x2:w,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,strokeDasharray:"4 4",opacity:.5,style:{color:"var(--color-secondary-400)"}}),jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotLeft,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),yt.map(l=>{let k=mt(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:c.plotLeft-4,x2:c.plotLeft,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:c.plotLeft-6,y:k,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,r?.format)})]},l)}),r?.label&&jsxRuntime.jsx("text",{x:-(c.plotTop+c.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),e&&et&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:c.plotRight,x2:c.plotRight,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),pt.map(l=>{let k=et(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:c.plotRight,x2:c.plotRight+4,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:c.plotRight+6,y:k,textAnchor:"start",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,e?.format)})]},l)}),e?.label&&jsxRuntime.jsx("text",{x:c.plotTop+c.plotHeight/2,y:-(c.width-14),textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(90)",children:e.label})]}),jsxRuntime.jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:c.plotBottom,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),(F?E:dt).map((l,k)=>{let X=ut(l);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:X,x2:X,y1:c.plotBottom,y2:c.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:X,y:c.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,o?.format)})]},k)}),o?.label&&jsxRuntime.jsx("text",{x:c.plotLeft+c.plotWidth/2,y:c.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label}),jsxRuntime.jsx("rect",{x:c.plotLeft,y:c.plotTop,width:c.plotWidth,height:c.plotHeight,fill:"transparent",onMouseMove:n,onMouseLeave:u,onTouchStart:$,onTouchMove:$,onTouchEnd:u,style:{cursor:"crosshair"}})]}),it=b==="left"||b==="right";return jsxRuntime.jsxs("div",{ref:I,className:rt(Mt(),P),children:[C&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsxRuntime.jsx(Pt,{items:v,position:"top",onToggle:q}),jsxRuntime.jsxs("div",{className:rt("flex items-start",it&&"gap-0"),children:[L&&b==="left"&&jsxRuntime.jsx(Pt,{items:v,position:"left",onToggle:q}),jsxRuntime.jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:W?J:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:V},children:R})}),L&&b==="right"&&jsxRuntime.jsx(Pt,{items:v,position:"right",onToggle:q})]}),L&&b==="bottom"&&jsxRuntime.jsx(Pt,{items:v,position:"bottom",onToggle:q}),T&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[T.label&&jsxRuntime.jsx("div",{className:"mb-1 font-medium text-primary-200",children:T.label}),T.items.map((l,k)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:l.color}}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:[l.name,":"]}),jsxRuntime.jsx("span",{className:"font-medium",children:l.value})]},k))]})]})}function ge(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function xe(t,o,r,e){if(r){let a=0;for(let s of t)if(o.has(s.id))for(let y of s.data)y.y>a&&(a=y.y);a===0&&(a=1);let[,d]=Dt(0,a,.05);return [e?.min??0,e?.max??d]}else {let a=new Map;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=String(x.x);a.set(C,(a.get(C)??0)+x.y);}let d=Math.max(0,...a.values()),[,s]=Dt(0,d===0?1:d,.05);return [e?.min??0,e?.max??s]}}function ye(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function be(t,o=5){return Xt(t[0],t[1],o)}function ve(t,o,r,e,a,d,s,y,x,C,V){let P=t.filter(B=>o.has(B.id)),L=r.length,b=P.length;if(L===0||b===0)return [];let p=d/L,R=p*(1-C),I=b>0?R*(1-V)/b:0,S=[];for(let B=0;B<r.length;B++){let K=r[B],T=a+B*p+(p-R)/2;for(let N=0;N<P.length;N++){let w=P[N],z=w.data.find(q=>String(q.x)===K);if(!z)continue;let U=T+N*(I+R*V/b),G=x(z.y);S.push({seriesId:w.id,category:K,x:U,y:G,width:Math.max(I,1),height:Math.max(s-G,0),stackBase:s,value:z.y,color:e.get(w.id)??"var(--color-chart-1)"});}}return S}function ke(t,o,r,e,a,d,s,y,x,C){let V=t.filter(S=>o.has(S.id)),P=r.length,L=V.length;if(P===0||L===0)return [];let b=s/P,p=b*(1-x),R=L>0?p*(1-C)/L:0,I=[];for(let S=0;S<r.length;S++){let B=r[S],K=d+S*b+(b-p)/2;for(let T=0;T<V.length;T++){let N=V[T],w=N.data.find(G=>String(G.x)===B);if(!w)continue;let z=K+T*(R+p*C/Math.max(L,1)),U=y(w.y);I.push({seriesId:N.id,category:B,x:a,y:z,width:Math.max(U-a,0),height:Math.max(R,1),stackBase:a,value:w.y,color:e.get(N.id)??"var(--color-chart-1)"});}}return I}function Ce(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=r.length;if(V===0)return [];let P=s/V*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,a));for(let p of C)for(let R of r){let I=p.data.find(N=>String(N.x)===R);if(!I)continue;let S=b.get(R)??a,B=Math.max(y(I.y)-a,0),K=r.indexOf(R),T=d+(K+.5)*(s/V);L.push({seriesId:p.id,category:R,x:S,y:T-P/2,width:B,height:Math.max(P,1),stackBase:S,value:I.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(R,S+B);}return L}function Se(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=r.length;if(V===0)return [];let P=d/V*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,s));for(let p of C)for(let R of r){let I=p.data.find(w=>String(w.x)===R);if(!I)continue;let S=b.get(R)??s,B=Math.max(s-y(I.y),0),K=S-B,T=r.indexOf(R),N=a+(T+.5)*(d/V);L.push({seriesId:p.id,category:R,x:N-P/2,y:K,width:Math.max(P,1),height:B,stackBase:S,value:I.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(R,K);}return L}function jt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function ne({series:t,xAxis:o,yAxis:r,orientation:e="vertical",grouped:a=true,barRadius:d=4,barPadding:s=.2,groupPadding:y=.3,title:x,height:C=300,className:V,legend:P=true,legendPosition:L="bottom",animateOnMount:b=true,emptyText:p="No data to display"}){let R=react.useRef(null),I=react.useRef(null),[S,B]=react.useState(600),[K,T]=react.useState(null);react.useEffect(()=>{let n=I.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&B(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&B(W);});return $.observe(n),()=>$.disconnect()},[]);let N=react.useMemo(()=>t.map(n=>n.id),[t]),{visible:w,toggle:z,isVisible:U}=Rt(N),G=react.useMemo(()=>$t(t.length),[t.length]),q=react.useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??G[u]])),[t,G]),D=e==="horizontal",gt=react.useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=react.useMemo(()=>Et(S,C,gt),[S,C,gt]),A=react.useMemo(()=>ge(t,w),[t,w]),c=react.useMemo(()=>xe(t,w,a,D?o:r),[t,w,a,D,o,r]),F=react.useMemo(()=>ye(c,D?[i.plotLeft,i.plotRight]:[i.plotBottom,i.plotTop]),[c,i,D]),E=react.useMemo(()=>be(c,(D?o:r)?.tickCount??5),[c,D,o,r]),ut=react.useMemo(()=>D?a?ke(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y,s):Ce(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y):a?ve(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,i.plotTop,F,y,s):Se(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,F,y),[t,w,A,q,i,F,a,D,y,s]),xt=A.length>0?i.plotWidth/A.length:1,mt=A.length>0?i.plotHeight/A.length:1,yt=react.useCallback((n,u)=>{let $=R.current?.getBoundingClientRect();if(!$)return;let v=t.filter(W=>U(W.id)).map(W=>{let J=W.data.find(it=>String(it.x)===u);return {name:W.name,value:J?tt(J.y,r?.format):"\u2014",color:q.get(W.id)??"var(--color-chart-1)"}});T({x:n.clientX-$.left+12,y:n.clientY-$.top-10,category:u,items:v});},[t,U,q,r?.format]),nt=react.useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??G[u],visible:U(n.id)})),[t,G,U]),et=t.some(n=>n.data.length>0),pt=L==="left"||L==="right",dt=jsxRuntime.jsxs("svg",{role:"img","aria-label":x??"Bar chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[E.map(n=>{let u=F(n);return D?jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n):jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:u,y2:u,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)}),ut.map(n=>{let u=Math.min(d,n.width/2,n.height/2),$=`${n.seriesId}-${n.category}`;return D?jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-h",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$):jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-v",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$)}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),!D&&E.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),D&&E.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),A.map((n,u)=>{if(D){let v=i.plotTop+(u+.5)*mt;return jsxRuntime.jsx("text",{x:i.plotLeft-6,y:v,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}let $=i.plotLeft+(u+.5)*xt;return jsxRuntime.jsx("text",{x:$,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}),r?.label&&!D&&jsxRuntime.jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsxRuntime.jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxRuntime.jsxs("div",{ref:R,className:rt(Mt(),V),children:[x&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:x}),P&&L==="top"&&jsxRuntime.jsx(jt,{items:nt,position:"top",onToggle:z}),jsxRuntime.jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[P&&L==="left"&&jsxRuntime.jsx(jt,{items:nt,position:"left",onToggle:z}),jsxRuntime.jsx("div",{ref:I,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:C},children:p})}),P&&L==="right"&&jsxRuntime.jsx(jt,{items:nt,position:"right",onToggle:z})]}),P&&L==="bottom"&&jsxRuntime.jsx(jt,{items:nt,position:"bottom",onToggle:z}),K&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:K.x,top:K.y},role:"tooltip",children:[jsxRuntime.jsx("div",{className:"mb-1 font-medium text-primary-200",children:K.category}),K.items.map((n,u)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:n.color}}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:[n.name,":"]}),jsxRuntime.jsx("span",{className:"font-medium",children:n.value})]},u))]})]})}function Me(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=C.reduce((p,R)=>p+R.value,0);if(V===0)return [];let P=new Map(t.map((p,R)=>[p.id,p.color??r[R%r.length]])),L=[],b=y;for(let p of C){let R=p.value/V*360,I=x/2,S=b+I,B=b+R-I,K=(S+B)/2,T;if(Math.abs(B-S)>=359.9){let N=kt(d,s,e,S),w=kt(d,s,e,S+180);T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 1 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} A ${e} ${e} 0 1 1 ${N.x.toFixed(3)} ${N.y.toFixed(3)} Z`;}else if(a>0){let N=kt(d,s,e,S),w=kt(d,s,e,B),z=kt(d,s,a,B),U=kt(d,s,a,S),G=B-S>180?1:0;T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${G} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} L ${z.x.toFixed(3)} ${z.y.toFixed(3)} A ${a} ${a} 0 ${G} 0 ${U.x.toFixed(3)} ${U.y.toFixed(3)} Z`;}else {let N=kt(d,s,e,S),w=kt(d,s,e,B),z=B-S>180?1:0;T=`M ${d.toFixed(3)} ${s.toFixed(3)} L ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${z} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} Z`;}L.push({id:p.id,label:p.label,value:p.value,percent:Math.round(p.value/V*1e3)/10,color:P.get(p.id)??"var(--color-chart-1)",startAngle:S,endAngle:B,midAngle:K,path:T,outerR:e,innerR:a,cx:d,cy:s}),b+=R;}return L}function Le(t,o){let r=(t-90)*Math.PI/180;return {dx:Math.cos(r)*o,dy:Math.sin(r)*o}}function Zt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),jsxRuntime.jsx("span",{children:e.label}),jsxRuntime.jsxs("span",{className:"text-secondary-400",children:["(",e.percent,"%)"]})]},e.id))})}function se({data:t,donut:o=false,donutThickness:r=.5,startAngle:e=-90,padAngle:a=0,labelType:d="percent",centerLabel:s,centerSubLabel:y,explodeOnHover:x=true,explodeOffset:C=8,title:V,height:P=300,className:L,legend:b=true,legendPosition:p="bottom",animateOnMount:R=true,emptyText:I="No data to display"}){let S=react.useRef(null),B=react.useRef(null),[K,T]=react.useState(400),[N,w]=react.useState(null),[z,U]=react.useState(null),[G,q]=react.useState({}),D=react.useRef(null);react.useEffect(()=>{let m=B.current;if(!m)return;let M=m.getBoundingClientRect().width;M>0&&T(M);let g=new ResizeObserver(h=>{let _=h[0]?.contentRect.width;_&&_>0&&T(_);});return g.observe(m),()=>g.disconnect()},[]),react.useEffect(()=>{function m(g){let h=D.current;if(!h)return;"touches"in g&&g.cancelable&&g.preventDefault();let _="touches"in g?g.touches[0]?.clientX??h.startX:g.clientX,ht="touches"in g?g.touches[0]?.clientY??h.startY:g.clientY;q(vt=>({...vt,[h.id]:{dx:h.origDx+_-h.startX,dy:h.origDy+ht-h.startY}}));}function M(){D.current=null;}return window.addEventListener("mousemove",m),window.addEventListener("mouseup",M),window.addEventListener("touchmove",m,{passive:false}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",m),window.removeEventListener("touchend",M);}},[]);let gt=react.useMemo(()=>t.map(m=>m.id),[t]),{visible:i,toggle:A,isVisible:c}=Rt(gt),F=react.useMemo(()=>$t(t.length),[t.length]),E=10,ut=6.4,xt=18,mt=14,yt=6,nt=K,et=P,pt=nt/2,dt=et/2,n=d!=="none"?xt+yt+4:yt+4,u=Math.max(Math.min(pt,dt)-n,20),$=o?u*r:0,v=react.useMemo(()=>Me(t,i,F,u,$,pt,dt,e,a),[t,i,F,u,$,pt,dt,e,a]),W=react.useMemo(()=>v.map(m=>m.id).join(","),[v]);react.useEffect(()=>{q({});},[W]);let J=react.useCallback((m,M)=>{if(D.current)return;let g=S.current?.getBoundingClientRect();if(!g)return;w(M);let h=v.find(_=>_.id===M);h&&U({x:m.clientX-g.left+12,y:m.clientY-g.top-10,items:[{label:h.label,value:tt(h.value),percent:`${h.percent}%`,color:h.color}]});},[v]),it=react.useCallback(()=>{w(null),U(null);},[]),l=react.useCallback((m,M,g)=>{let h=G[m]??{dx:0,dy:0};D.current={id:m,startX:M,startY:g,origDx:h.dx,origDy:h.dy};},[G]),k=react.useCallback((m,M)=>{m.preventDefault(),w(M);let g=S.current?.getBoundingClientRect();if(!g)return;let h=m.touches[0];if(!h)return;let _=v.find(ht=>ht.id===M);_&&U({x:h.clientX-g.left+12,y:h.clientY-g.top-10,items:[{label:_.label,value:tt(_.value),percent:`${_.percent}%`,color:_.color}]});},[v]),X=react.useMemo(()=>{let m=t.reduce((M,g)=>M+g.value,0);return t.map((M,g)=>({id:M.id,label:M.label,color:M.color??F[g],visible:c(M.id),percent:m>0?Math.round(M.value/m*1e3)/10:0}))},[t,F,c]),Q=t.length>0&&t.some(m=>m.value>0),j=p==="left"||p==="right",st=react.useMemo(()=>{if(d==="none")return [];let m=E+3,M=yt+E*.5,g=et-yt-E*.5,h=v.filter(f=>f.percent>=3).map(f=>{let at="";switch(d){case "percent":at=`${f.percent}%`;break;case "value":at=tt(f.value);break;case "label":at=f.label;break;case "label+percent":at=`${f.label} ${f.percent}%`;break}let wt=kt(f.cx,f.cy,f.outerR+2,f.midAngle),ct=kt(f.cx,f.cy,f.outerR+xt,f.midAngle),Y=(f.midAngle-90)*Math.PI/180,Wt=Math.cos(Y)>=0,Ht=Math.ceil(at.length*ut);return {id:f.id,color:f.color,text:at,textW:Ht,p1:wt,elbowX:ct.x,y:ct.y,isRight:Wt}}),_=h.filter(f=>f.isRight).sort((f,at)=>f.y-at.y),ht=h.filter(f=>!f.isRight).sort((f,at)=>f.y-at.y);function vt(f){if(f.length!==0)for(let at=0;at<20;at++){let wt=false;for(let Y=1;Y<f.length;Y++){let Wt=f[Y].y-f[Y-1].y;if(Wt<m){let Ht=(m-Wt)/2;f[Y-1].y-=Ht,f[Y].y+=Ht,wt=true;}}f[0].y<M&&(f[0].y=M);for(let Y=1;Y<f.length;Y++)f[Y].y<f[Y-1].y+m&&(f[Y].y=f[Y-1].y+m);let ct=f.length-1;f[ct].y>g&&(f[ct].y=g);for(let Y=ct-1;Y>=0;Y--)f[Y].y>f[Y+1].y-m&&(f[Y].y=f[Y+1].y-m);for(let Y of f)Y.y=Math.max(M,Math.min(g,Y.y));if(!wt)break}}return vt(_),vt(ht),[...ht,..._]},[v,d,et]),bt=jsxRuntime.jsxs("svg",{role:"img","aria-label":V??"Pie chart",width:nt,height:et,viewBox:`0 0 ${nt} ${et}`,shapeRendering:"geometricPrecision",children:[jsxRuntime.jsxs("g",{className:R?"chart-pie-animate":"",children:[v.map((m,M)=>{let g=N===m.id,h=x&&g,_=Le(m.midAngle,h?C:0);return jsxRuntime.jsx("path",{d:m.path,fill:m.color,transform:h?`translate(${_.dx}, ${_.dy})`:void 0,className:rt("chart-slice",R&&`chart-slice-animate-${Math.min(M,7)}`,g&&"chart-slice--exploded"),stroke:m.color,strokeWidth:.6,onMouseMove:ht=>J(ht,m.id),onMouseLeave:it,onTouchStart:ht=>k(ht,m.id),onTouchEnd:it,"aria-label":`${m.label}: ${m.percent}%`},m.id)}),st.map(m=>{let M=G[m.id]??{dx:0,dy:0},g=m.elbowX+M.dx,h=m.y+M.dy,_=g+(m.isRight?mt:-mt),ht=m.isRight?_+3:_-3,vt=mt+3+m.textW+6,f=m.isRight?g:g-vt,at=h-E-2,wt=E*2+4;return jsxRuntime.jsxs("g",{style:{userSelect:"none"},children:[jsxRuntime.jsx("polyline",{points:[`${m.p1.x.toFixed(2)},${m.p1.y.toFixed(2)}`,`${g.toFixed(2)},${h.toFixed(2)}`,`${_.toFixed(2)},${h.toFixed(2)}`].join(" "),fill:"none",stroke:m.color,strokeWidth:1.2,opacity:.85,strokeLinejoin:"round",strokeLinecap:"round",style:{pointerEvents:"none"}}),jsxRuntime.jsx("text",{x:ht.toFixed(2),y:h.toFixed(2),textAnchor:m.isRight?"start":"end",dominantBaseline:"middle",fontSize:E,fill:"currentColor",className:"text-primary-700 dark:text-primary-300",style:{pointerEvents:"none"},children:m.text}),jsxRuntime.jsx("rect",{x:f,y:at,width:vt,height:wt,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseDown:ct=>{ct.stopPropagation(),l(m.id,ct.clientX,ct.clientY);},onTouchStart:ct=>{ct.stopPropagation();let Y=ct.touches[0];Y&&l(m.id,Y.clientX,Y.clientY);}})]},`label-${m.id}`)})]}),o&&jsxRuntime.jsx("g",{style:{pointerEvents:"none"},children:N&&v.find(m=>m.id===N)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("text",{x:pt,y:dt-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:18,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:[v.find(m=>m.id===N)?.percent,"%"]}),jsxRuntime.jsx("text",{x:pt,y:dt+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:v.find(m=>m.id===N)?.label})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s&&jsxRuntime.jsx("text",{x:pt,y:dt-(y?8:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:16,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:s}),y&&jsxRuntime.jsx("text",{x:pt,y:dt+14,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:y})]})})]});return jsxRuntime.jsxs("div",{ref:S,className:rt(Mt(),L),children:[V&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:V}),b&&p==="top"&&jsxRuntime.jsx(Zt,{items:X,position:"top",onToggle:A}),jsxRuntime.jsxs("div",{className:rt("flex items-start justify-center",j&&"gap-0"),children:[b&&p==="left"&&jsxRuntime.jsx(Zt,{items:X,position:"left",onToggle:A}),jsxRuntime.jsx("div",{ref:B,className:"flex-1 min-w-0 overflow-hidden",children:Q?bt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:P},children:I})}),b&&p==="right"&&jsxRuntime.jsx(Zt,{items:X,position:"right",onToggle:A})]}),b&&p==="bottom"&&jsxRuntime.jsx(Zt,{items:X,position:"bottom",onToggle:A}),z&&jsxRuntime.jsx("div",{className:Tt(),style:{left:z.x,top:z.y},role:"tooltip",children:z.items.map((m,M)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:m.color}}),jsxRuntime.jsxs("span",{className:"font-medium",children:[m.label,":"]}),jsxRuntime.jsx("span",{children:m.value}),jsxRuntime.jsxs("span",{className:"text-primary-300",children:["(",m.percent,")"]})]},M))})]})}function Be(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=Number(x.x);C<e&&(e=C),C>a&&(a=C);}if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function Ve(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function ce(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function le(t,o=5){return Xt(t[0],t[1],o)}function Re(t,o,r){let e=1.618033988749895,a=t*137+o,d=a*e%1*2-1,s=a*e*e%1*2-1;return [d*r,s*r]}function $e(t,o,r=12){if(t.length<2)return null;let e=Math.min(...t),a=Math.max(...t),d=Math.min(...o),s=Math.max(...o);return {cx:(e+a)/2,cy:(d+s)/2,rx:(a-e)/2+r,ry:(s-d)/2+r}}function Kt({items:t,position:o,onToggle:r}){return jsxRuntime.jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxRuntime.jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),e.label]},e.id))})}function me({series:t,xAxis:o,yAxis:r,dotRadius:e=5,dotOpacity:a=.75,clusters:d=false,jitter:s=false,jitterAmount:y=12,linkedLines:x=false,title:C,height:V=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:R="No data to display"}){let I=react.useRef(null),S=react.useRef(null),[B,K]=react.useState(600),[T,N]=react.useState(null);react.useEffect(()=>{let n=S.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&K(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&K(W);});return $.observe(n),()=>$.disconnect()},[]);let w=react.useMemo(()=>t.map(n=>n.id),[t]),{visible:z,toggle:U,isVisible:G}=Rt(w),q=react.useMemo(()=>$t(t.length),[t.length]),D=react.useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??q[u]])),[t,q]),gt=react.useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=react.useMemo(()=>Et(B,V,gt),[B,V,gt]),A=react.useMemo(()=>Be(t,z,o),[t,z,o]),c=react.useMemo(()=>Ve(t,z,r),[t,z,r]),F=react.useMemo(()=>ce(A,[i.plotLeft,i.plotRight]),[A,i]),E=react.useMemo(()=>ce(c,[i.plotBottom,i.plotTop]),[c,i]),ut=react.useMemo(()=>le(A,o?.tickCount??6),[A,o?.tickCount]),xt=react.useMemo(()=>le(c,r?.tickCount??5),[c,r?.tickCount]),mt=react.useCallback((n,u,$,v,W)=>{let J=I.current?.getBoundingClientRect();J&&N({x:n.clientX-J.left+12,y:n.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),yt=react.useCallback((n,u,$,v,W)=>{n.preventDefault();let J=I.current?.getBoundingClientRect();if(!J)return;let it=n.touches[0];it&&N({x:it.clientX-J.left+12,y:it.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),nt=react.useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??q[u],visible:G(n.id)})),[t,q,G]),et=t.some(n=>n.data.length>0),pt=b==="left"||b==="right",dt=jsxRuntime.jsxs("svg",{role:"img","aria-label":C??"Scatter chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[xt.map(n=>jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:E(n),y2:E(n),stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)),d&&t.map((n,u)=>{if(!G(n.id)||n.data.length<2)return null;let $=D.get(n.id)??"var(--color-chart-1)",v=n.data.map(it=>F(Number(it.x))),W=n.data.map(it=>E(it.y)),J=$e(v,W,16);return J?jsxRuntime.jsx("ellipse",{cx:J.cx,cy:J.cy,rx:J.rx,ry:J.ry,fill:$,fillOpacity:.06,stroke:$,strokeOpacity:.3,strokeWidth:1.5,strokeDasharray:"5 3",className:p?"chart-cluster-ellipse":"",style:{animationDelay:`${u*.1}s`}},`cluster-${n.id}`):null}),x&&t.map(n=>{if(!G(n.id)||n.data.length<2)return null;let u=D.get(n.id)??"var(--color-chart-1)",v=[...n.data].sort((W,J)=>Number(W.x)-Number(J.x)).map(W=>`${F(Number(W.x)).toFixed(2)},${E(W.y).toFixed(2)}`).join(" ");return jsxRuntime.jsx("polyline",{points:v,fill:"none",stroke:u,strokeWidth:1.5,className:"chart-scatter-link"},`link-${n.id}`)}),t.map((n,u)=>{if(!G(n.id))return null;let $=D.get(n.id)??"var(--color-chart-1)";return jsxRuntime.jsx("g",{className:"chart-scatter-group",children:n.data.map((v,W)=>{let[J,it]=s?Re(u,W,y):[0,0],l=F(Number(v.x))+J,k=E(v.y)+it;return jsxRuntime.jsx("circle",{cx:l,cy:k,r:e,fill:$,fillOpacity:a,stroke:$,strokeWidth:1,strokeOpacity:.5,className:rt("chart-scatter-dot",p&&"chart-scatter-dot--animate"),style:{color:$},onMouseMove:X=>mt(X,n.name,v.x,v.y,$),onMouseLeave:()=>N(null),onTouchStart:X=>yt(X,n.name,v.x,v.y,$),onTouchEnd:()=>N(null)},W)})},n.id)}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),xt.map(n=>{let u=E(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),ut.map(n=>{let u=F(n);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsxRuntime.jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),r?.label&&jsxRuntime.jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsxRuntime.jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxRuntime.jsxs("div",{ref:I,className:rt(Mt(),P),children:[C&&jsxRuntime.jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsxRuntime.jsx(Kt,{items:nt,position:"top",onToggle:U}),jsxRuntime.jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[L&&b==="left"&&jsxRuntime.jsx(Kt,{items:nt,position:"left",onToggle:U}),jsxRuntime.jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsxRuntime.jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:V},children:R})}),L&&b==="right"&&jsxRuntime.jsx(Kt,{items:nt,position:"right",onToggle:U})]}),L&&b==="bottom"&&jsxRuntime.jsx(Kt,{items:nt,position:"bottom",onToggle:U}),T&&jsxRuntime.jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:T.color}}),jsxRuntime.jsx("span",{className:"font-medium",children:T.seriesName})]}),jsxRuntime.jsxs("div",{className:"text-primary-300",children:["X: ",jsxRuntime.jsx("span",{className:"font-medium text-primary-50",children:T.xVal})," ","Y: ",jsxRuntime.jsx("span",{className:"font-medium text-primary-50",children:T.yVal})]})]})]})}var je={LineChart:oe,BarChart:ne,PieChart:se,ScatterChart:me},lo=je;exports.BarChart=ne;exports.Chart=je;exports.LineChart=oe;exports.PieChart=se;exports.ScatterChart=me;exports.default=lo;
@@ -1 +1 @@
1
- import {useRef,useState,useEffect,useMemo,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function rt(...t){return twMerge(clsx(t))}var Mt=cva("relative w-full font-sans select-none",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}}),Lt=cva("flex flex-wrap gap-3 items-center justify-center",{variants:{position:{top:"mb-3",bottom:"mt-3",left:"flex-col mr-4",right:"flex-col ml-4"}},defaultVariants:{position:"bottom"}}),Tt=cva("absolute z-50 pointer-events-none px-3 py-2 rounded-lg text-xs shadow-lg border transition-opacity duration-150 bg-primary-900 text-primary-50 border-primary-700 dark:bg-primary-950 dark:border-primary-800");function Vt(t){let[o,r]=useState(()=>new Set(t)),e=useCallback(s=>{r(y=>{let x=new Set(y);return x.has(s)?x.delete(s):x.add(s),x});},[]),a=useCallback(s=>o.has(s),[o]),d=useCallback(()=>{r(new Set(t));},[t]);return {visible:o,toggle:e,isVisible:a,showAll:d}}function $t(t){let o=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"];return Array.from({length:t},(r,e)=>o[e%o.length])}function Dt(t,o,r=.1){if(t===o)return [t-1,o+1];let a=(o-t)*r;return [Math.floor(t-a),Math.ceil(o+a)]}function Xt(t,o,r){if(r<=1)return [t];let e=(o-t)/(r-1);return Array.from({length:r},(a,d)=>+(t+d*e).toFixed(10))}function tt(t,o){return o?o(t):typeof t=="number"?Math.abs(t)>=1e6?`${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`${(t/1e3).toFixed(1)}K`:Number.isInteger(t)?t.toString():t.toFixed(2):String(t)}function kt(t,o,r,e){let a=(e-90)*Math.PI/180;return {x:t+r*Math.cos(a),y:o+r*Math.sin(a)}}function Ft(t,o,r){return {top:20,right:r?65:20,bottom:t?52:36,left:o?65:52}}function Et(t,o,r){let e=Math.max(t,120);return {width:e,height:o,margins:r,plotLeft:r.left,plotTop:r.top,plotRight:e-r.right,plotBottom:o-r.bottom,plotWidth:Math.max(e-r.left-r.right,10),plotHeight:Math.max(o-r.top-r.bottom,10)}}function de(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function Ut(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function zt(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function It(t,o){let r=t.length;if(r===0)return ()=>(o[0]+o[1])/2;let e=(o[1]-o[0])/r;return a=>{let d=t.indexOf(a);return d<0?(o[0]+o[1])/2:o[0]+d*e+e/2}}function ue(t,o,r){return t.map(e=>`${o(e.x).toFixed(2)},${r(e.y).toFixed(2)}`).join(" ")}function qt(t,o,r){if(t.length===0)return "";let e=t.map(s=>({x:o(s.x),y:r(s.y)}));if(e.length===1)return `M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;let a=.5,d=`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;for(let s=0;s<e.length-1;s++){let y=s===0?{x:2*e[0].x-e[1].x,y:2*e[0].y-e[1].y}:e[s-1],x=e[s],C=e[s+1],R=s+2<e.length?e[s+2]:{x:2*e[e.length-1].x-e[e.length-2].x,y:2*e[e.length-1].y-e[e.length-2].y},P=x.x+(C.x-y.x)*a/3,L=x.y+(C.y-y.y)*a/3,b=C.x-(R.x-x.x)*a/3,p=C.y-(R.y-x.y)*a/3;d+=` C ${P.toFixed(2)} ${L.toFixed(2)}, ${b.toFixed(2)} ${p.toFixed(2)}, ${C.x.toFixed(2)} ${C.y.toFixed(2)}`;}return d}function pe(t,o,r,e,a){if(t.length===0)return "";let d=e?qt(t,o,r):`M ${t.map(x=>`${o(x.x).toFixed(2)},${r(x.y).toFixed(2)}`).join(" L ")}`,s=o(t[t.length-1].x).toFixed(2),y=o(t[0].x).toFixed(2);return `${d} L ${s},${a.toFixed(2)} L ${y},${a.toFixed(2)} Z`}function Gt(t,o=5){return Xt(t[0],t[1],o)}function Qt(t,o,r){if(o.length===0)return -1;let e=1/0,a=0;for(let d=0;d<o.length;d++){let s=Math.abs(r(o[d])-t);s<e&&(e=s,a=d);}return a}function te(t,o){return t.data.find(r=>String(r.x)===o)?.y}function he(t){for(let o of t)for(let r of o.data)if(typeof r.x=="string")return true;return false}function Pt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function oe({series:t,xAxis:o,yAxis:r,y2Axis:e,y2Series:a=[],smooth:d=false,showDots:s=true,area:y=false,strokeWidth:x=2,title:C,height:R=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:V="No data to display"}){let z=useRef(null),S=useRef(null),[B,K]=useState(600),[T,N]=useState(null),[w,I]=useState(null);useEffect(()=>{let l=S.current;if(!l)return;let k=l.getBoundingClientRect().width;k>0&&K(k);let X=new ResizeObserver(Q=>{let j=Q[0]?.contentRect.width;j&&j>0&&K(j);});return X.observe(l),()=>X.disconnect()},[]);let U=useMemo(()=>t.map(l=>l.id),[t]),{visible:G,toggle:q,isVisible:D}=Vt(U),gt=useMemo(()=>$t(t.length),[t.length]),i=useMemo(()=>new Map(t.map((l,k)=>[l.id,l.color??gt[k]])),[t,gt]),A=useMemo(()=>Ft(!!o?.label,!!r?.label,!!e),[o?.label,r?.label,e]),c=useMemo(()=>Et(B,R,A),[B,R,A]),F=useMemo(()=>he(t),[t]),E=useMemo(()=>F?de(t,G):[],[t,G,F]),ut=useMemo(()=>{if(F){let j=It(E,[c.plotLeft,c.plotRight]);return st=>j(st)}let l=t.flatMap(j=>j.data.map(st=>st.x));if(l.length===0)return ()=>c.plotLeft;let k=Math.min(...l),X=Math.max(...l),Q=zt([k,X],[c.plotLeft,c.plotRight]);return j=>Q(j)},[t,F,E,c]),xt=useMemo(()=>Ut(t,G,r),[t,G,r]),mt=useMemo(()=>zt(xt,[c.plotBottom,c.plotTop]),[xt,c]),yt=useMemo(()=>Gt(xt,r?.tickCount??5),[xt,r?.tickCount]),nt=useMemo(()=>{if(!e)return null;let l=t.filter(k=>a.includes(k.id));return Ut(l,G,e)},[e,t,a,G]),et=useMemo(()=>nt?zt(nt,[c.plotBottom,c.plotTop]):null,[nt,c]),pt=useMemo(()=>nt?Gt(nt,e?.tickCount??5):[],[nt,e?.tickCount]),dt=useMemo(()=>{if(F)return E;let l=t.flatMap(Q=>Q.data.map(j=>Number(j.x)));if(l.length===0)return [];let k=Math.min(...l),X=Math.max(...l);return Gt([k,X],o?.tickCount??6)},[F,E,t,o?.tickCount]),n=useCallback(l=>{let k=l.currentTarget.closest("svg");if(!k)return;let X=k.getBoundingClientRect(),Q=l.clientX-X.left,j=z.current?.getBoundingClientRect();if(!j)return;let st="",bt=Q;if(F&&E.length>0){let h=It(E,[c.plotLeft,c.plotRight]),_=Qt(Q,E,h);st=E[_]??"",bt=h(st);}else if(!F){let h=dt;st=tt((Q-c.plotLeft)/c.plotWidth*(h[h.length-1]-h[0])+h[0],o?.format),bt=Q;}let m=t.filter(h=>D(h.id)).map(h=>{a.includes(h.id)&&et!=null?et:mt;let vt;if(F)vt=te(h,st);else {let f=Q,at=1/0,wt;for(let ct of h.data){let Y=ut(ct.x),Wt=Math.abs(Y-f);Wt<at&&(at=Wt,wt=ct.y);}vt=wt;}return {name:h.name,value:vt!==void 0?tt(vt,r?.format):"\u2014",color:i.get(h.id)??"var(--color-chart-1)"}});bt>=c.plotLeft&&bt<=c.plotRight&&I(bt);let M=l.clientX-j.left+12,g=l.clientY-j.top-10;N({x:M,y:g,label:st,items:m});},[F,E,c,t,D,a,et,mt,ut,dt,o?.format,r?.format,i]),u=useCallback(()=>{N(null),I(null);},[]),$=useCallback(l=>{l.preventDefault();let k=l.touches[0];if(!k)return;let X=l.currentTarget.closest("svg");if(!X)return;let Q=X.getBoundingClientRect(),j=z.current?.getBoundingClientRect();if(!j)return;let st=k.clientX-Q.left,bt=st,m="";if(F&&E.length>0){let g=It(E,[c.plotLeft,c.plotRight]),h=Qt(st,E,g);m=E[h]??"",bt=g(m);}bt>=c.plotLeft&&bt<=c.plotRight&&I(bt);let M=t.filter(g=>D(g.id)).map(g=>({name:g.name,value:F&&m?tt(te(g,m)??0,r?.format):"\u2014",color:i.get(g.id)??"var(--color-chart-1)"}));N({x:k.clientX-j.left+12,y:k.clientY-j.top-10,label:m,items:M});},[F,E,c,t,D,r?.format,i]),v=useMemo(()=>t.map((l,k)=>({id:l.id,label:l.name,color:l.color??gt[k],visible:D(l.id)})),[t,gt,D]),W=t.some(l=>l.data.length>0),J=jsxs("svg",{role:"img","aria-label":C??"Line chart",width:c.width,height:c.height,viewBox:`0 0 ${c.width} ${c.height}`,shapeRendering:"geometricPrecision",children:[r?.gridLines!==false&&yt.map(l=>{let k=mt(l);return jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:k,y2:k,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},l)}),y&&t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)",j=pe(l.data,ut,X,d,c.plotBottom);return jsx("path",{d:j,fill:Q,fillOpacity:.15,stroke:"none",className:p?"chart-area-animate":""},`area-${l.id}`)}),t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return d?jsx("path",{d:qt(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id):jsx("polyline",{points:ue(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id)}),s&&t.map(l=>{if(!D(l.id))return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return l.data.map((j,st)=>jsx("circle",{cx:ut(j.x),cy:X(j.y),r:3,fill:Q,stroke:"white",strokeWidth:1.5,className:rt("chart-dot",p?"chart-dot-animate":"")},`${l.id}-${st}`))}),w!=null&&jsx("line",{className:"chart-crosshair",x1:w,x2:w,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,strokeDasharray:"4 4",opacity:.5,style:{color:"var(--color-secondary-400)"}}),jsx("line",{x1:c.plotLeft,x2:c.plotLeft,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),yt.map(l=>{let k=mt(l);return jsxs("g",{children:[jsx("line",{x1:c.plotLeft-4,x2:c.plotLeft,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:c.plotLeft-6,y:k,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,r?.format)})]},l)}),r?.label&&jsx("text",{x:-(c.plotTop+c.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),e&&et&&jsxs(Fragment,{children:[jsx("line",{x1:c.plotRight,x2:c.plotRight,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),pt.map(l=>{let k=et(l);return jsxs("g",{children:[jsx("line",{x1:c.plotRight,x2:c.plotRight+4,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:c.plotRight+6,y:k,textAnchor:"start",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,e?.format)})]},l)}),e?.label&&jsx("text",{x:c.plotTop+c.plotHeight/2,y:-(c.width-14),textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(90)",children:e.label})]}),jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:c.plotBottom,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),(F?E:dt).map((l,k)=>{let X=ut(l);return jsxs("g",{children:[jsx("line",{x1:X,x2:X,y1:c.plotBottom,y2:c.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:X,y:c.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,o?.format)})]},k)}),o?.label&&jsx("text",{x:c.plotLeft+c.plotWidth/2,y:c.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label}),jsx("rect",{x:c.plotLeft,y:c.plotTop,width:c.plotWidth,height:c.plotHeight,fill:"transparent",onMouseMove:n,onMouseLeave:u,onTouchStart:$,onTouchMove:$,onTouchEnd:u,style:{cursor:"crosshair"}})]}),it=b==="left"||b==="right";return jsxs("div",{ref:z,className:rt(Mt(),P),children:[C&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsx(Pt,{items:v,position:"top",onToggle:q}),jsxs("div",{className:rt("flex items-start",it&&"gap-0"),children:[L&&b==="left"&&jsx(Pt,{items:v,position:"left",onToggle:q}),jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:W?J:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:R},children:V})}),L&&b==="right"&&jsx(Pt,{items:v,position:"right",onToggle:q})]}),L&&b==="bottom"&&jsx(Pt,{items:v,position:"bottom",onToggle:q}),T&&jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[T.label&&jsx("div",{className:"mb-1 font-medium text-primary-200",children:T.label}),T.items.map((l,k)=>jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:l.color}}),jsxs("span",{className:"text-primary-300",children:[l.name,":"]}),jsx("span",{className:"font-medium",children:l.value})]},k))]})]})}function ge(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function xe(t,o,r,e){if(r){let a=0;for(let s of t)if(o.has(s.id))for(let y of s.data)y.y>a&&(a=y.y);a===0&&(a=1);let[,d]=Dt(0,a,.05);return [e?.min??0,e?.max??d]}else {let a=new Map;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=String(x.x);a.set(C,(a.get(C)??0)+x.y);}let d=Math.max(0,...a.values()),[,s]=Dt(0,d===0?1:d,.05);return [e?.min??0,e?.max??s]}}function ye(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function be(t,o=5){return Xt(t[0],t[1],o)}function ve(t,o,r,e,a,d,s,y,x,C,R){let P=t.filter(B=>o.has(B.id)),L=r.length,b=P.length;if(L===0||b===0)return [];let p=d/L,V=p*(1-C),z=b>0?V*(1-R)/b:0,S=[];for(let B=0;B<r.length;B++){let K=r[B],T=a+B*p+(p-V)/2;for(let N=0;N<P.length;N++){let w=P[N],I=w.data.find(q=>String(q.x)===K);if(!I)continue;let U=T+N*(z+V*R/b),G=x(I.y);S.push({seriesId:w.id,category:K,x:U,y:G,width:Math.max(z,1),height:Math.max(s-G,0),stackBase:s,value:I.y,color:e.get(w.id)??"var(--color-chart-1)"});}}return S}function ke(t,o,r,e,a,d,s,y,x,C){let R=t.filter(S=>o.has(S.id)),P=r.length,L=R.length;if(P===0||L===0)return [];let b=s/P,p=b*(1-x),V=L>0?p*(1-C)/L:0,z=[];for(let S=0;S<r.length;S++){let B=r[S],K=d+S*b+(b-p)/2;for(let T=0;T<R.length;T++){let N=R[T],w=N.data.find(G=>String(G.x)===B);if(!w)continue;let I=K+T*(V+p*C/Math.max(L,1)),U=y(w.y);z.push({seriesId:N.id,category:B,x:a,y:I,width:Math.max(U-a,0),height:Math.max(V,1),stackBase:a,value:w.y,color:e.get(N.id)??"var(--color-chart-1)"});}}return z}function Ce(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=r.length;if(R===0)return [];let P=s/R*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,a));for(let p of C)for(let V of r){let z=p.data.find(N=>String(N.x)===V);if(!z)continue;let S=b.get(V)??a,B=Math.max(y(z.y)-a,0),K=r.indexOf(V),T=d+(K+.5)*(s/R);L.push({seriesId:p.id,category:V,x:S,y:T-P/2,width:B,height:Math.max(P,1),stackBase:S,value:z.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(V,S+B);}return L}function Se(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=r.length;if(R===0)return [];let P=d/R*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,s));for(let p of C)for(let V of r){let z=p.data.find(w=>String(w.x)===V);if(!z)continue;let S=b.get(V)??s,B=Math.max(s-y(z.y),0),K=S-B,T=r.indexOf(V),N=a+(T+.5)*(d/R);L.push({seriesId:p.id,category:V,x:N-P/2,y:K,width:Math.max(P,1),height:B,stackBase:S,value:z.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(V,K);}return L}function jt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function ne({series:t,xAxis:o,yAxis:r,orientation:e="vertical",grouped:a=true,barRadius:d=4,barPadding:s=.2,groupPadding:y=.3,title:x,height:C=300,className:R,legend:P=true,legendPosition:L="bottom",animateOnMount:b=true,emptyText:p="No data to display"}){let V=useRef(null),z=useRef(null),[S,B]=useState(600),[K,T]=useState(null);useEffect(()=>{let n=z.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&B(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&B(W);});return $.observe(n),()=>$.disconnect()},[]);let N=useMemo(()=>t.map(n=>n.id),[t]),{visible:w,toggle:I,isVisible:U}=Vt(N),G=useMemo(()=>$t(t.length),[t.length]),q=useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??G[u]])),[t,G]),D=e==="horizontal",gt=useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=useMemo(()=>Et(S,C,gt),[S,C,gt]),A=useMemo(()=>ge(t,w),[t,w]),c=useMemo(()=>xe(t,w,a,D?o:r),[t,w,a,D,o,r]),F=useMemo(()=>ye(c,D?[i.plotLeft,i.plotRight]:[i.plotBottom,i.plotTop]),[c,i,D]),E=useMemo(()=>be(c,(D?o:r)?.tickCount??5),[c,D,o,r]),ut=useMemo(()=>D?a?ke(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y,s):Ce(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y):a?ve(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,i.plotTop,F,y,s):Se(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,F,y),[t,w,A,q,i,F,a,D,y,s]),xt=A.length>0?i.plotWidth/A.length:1,mt=A.length>0?i.plotHeight/A.length:1,yt=useCallback((n,u)=>{let $=V.current?.getBoundingClientRect();if(!$)return;let v=t.filter(W=>U(W.id)).map(W=>{let J=W.data.find(it=>String(it.x)===u);return {name:W.name,value:J?tt(J.y,r?.format):"\u2014",color:q.get(W.id)??"var(--color-chart-1)"}});T({x:n.clientX-$.left+12,y:n.clientY-$.top-10,category:u,items:v});},[t,U,q,r?.format]),nt=useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??G[u],visible:U(n.id)})),[t,G,U]),et=t.some(n=>n.data.length>0),pt=L==="left"||L==="right",dt=jsxs("svg",{role:"img","aria-label":x??"Bar chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[E.map(n=>{let u=F(n);return D?jsx("line",{x1:u,x2:u,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n):jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:u,y2:u,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)}),ut.map(n=>{let u=Math.min(d,n.width/2,n.height/2),$=`${n.seriesId}-${n.category}`;return D?jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-h",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$):jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-v",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$)}),jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),!D&&E.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),D&&E.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),A.map((n,u)=>{if(D){let v=i.plotTop+(u+.5)*mt;return jsx("text",{x:i.plotLeft-6,y:v,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}let $=i.plotLeft+(u+.5)*xt;return jsx("text",{x:$,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}),r?.label&&!D&&jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxs("div",{ref:V,className:rt(Mt(),R),children:[x&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:x}),P&&L==="top"&&jsx(jt,{items:nt,position:"top",onToggle:I}),jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[P&&L==="left"&&jsx(jt,{items:nt,position:"left",onToggle:I}),jsx("div",{ref:z,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:C},children:p})}),P&&L==="right"&&jsx(jt,{items:nt,position:"right",onToggle:I})]}),P&&L==="bottom"&&jsx(jt,{items:nt,position:"bottom",onToggle:I}),K&&jsxs("div",{className:Tt(),style:{left:K.x,top:K.y},role:"tooltip",children:[jsx("div",{className:"mb-1 font-medium text-primary-200",children:K.category}),K.items.map((n,u)=>jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:n.color}}),jsxs("span",{className:"text-primary-300",children:[n.name,":"]}),jsx("span",{className:"font-medium",children:n.value})]},u))]})]})}function Me(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),R=C.reduce((p,V)=>p+V.value,0);if(R===0)return [];let P=new Map(t.map((p,V)=>[p.id,p.color??r[V%r.length]])),L=[],b=y;for(let p of C){let V=p.value/R*360,z=x/2,S=b+z,B=b+V-z,K=(S+B)/2,T;if(Math.abs(B-S)>=359.9){let N=kt(d,s,e,S),w=kt(d,s,e,S+180);T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 1 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} A ${e} ${e} 0 1 1 ${N.x.toFixed(3)} ${N.y.toFixed(3)} Z`;}else if(a>0){let N=kt(d,s,e,S),w=kt(d,s,e,B),I=kt(d,s,a,B),U=kt(d,s,a,S),G=B-S>180?1:0;T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${G} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} L ${I.x.toFixed(3)} ${I.y.toFixed(3)} A ${a} ${a} 0 ${G} 0 ${U.x.toFixed(3)} ${U.y.toFixed(3)} Z`;}else {let N=kt(d,s,e,S),w=kt(d,s,e,B),I=B-S>180?1:0;T=`M ${d.toFixed(3)} ${s.toFixed(3)} L ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${I} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} Z`;}L.push({id:p.id,label:p.label,value:p.value,percent:Math.round(p.value/R*1e3)/10,color:P.get(p.id)??"var(--color-chart-1)",startAngle:S,endAngle:B,midAngle:K,path:T,outerR:e,innerR:a,cx:d,cy:s}),b+=V;}return L}function Le(t,o){let r=(t-90)*Math.PI/180;return {dx:Math.cos(r)*o,dy:Math.sin(r)*o}}function Zt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),jsx("span",{children:e.label}),jsxs("span",{className:"text-secondary-400",children:["(",e.percent,"%)"]})]},e.id))})}function se({data:t,donut:o=false,donutThickness:r=.5,startAngle:e=-90,padAngle:a=0,labelType:d="percent",centerLabel:s,centerSubLabel:y,explodeOnHover:x=true,explodeOffset:C=8,title:R,height:P=300,className:L,legend:b=true,legendPosition:p="bottom",animateOnMount:V=true,emptyText:z="No data to display"}){let S=useRef(null),B=useRef(null),[K,T]=useState(400),[N,w]=useState(null),[I,U]=useState(null),[G,q]=useState({}),D=useRef(null);useEffect(()=>{let m=B.current;if(!m)return;let M=m.getBoundingClientRect().width;M>0&&T(M);let g=new ResizeObserver(h=>{let _=h[0]?.contentRect.width;_&&_>0&&T(_);});return g.observe(m),()=>g.disconnect()},[]),useEffect(()=>{function m(g){let h=D.current;if(!h)return;"touches"in g&&g.cancelable&&g.preventDefault();let _="touches"in g?g.touches[0]?.clientX??h.startX:g.clientX,ht="touches"in g?g.touches[0]?.clientY??h.startY:g.clientY;q(vt=>({...vt,[h.id]:{dx:h.origDx+_-h.startX,dy:h.origDy+ht-h.startY}}));}function M(){D.current=null;}return window.addEventListener("mousemove",m),window.addEventListener("mouseup",M),window.addEventListener("touchmove",m,{passive:false}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",m),window.removeEventListener("touchend",M);}},[]);let gt=useMemo(()=>t.map(m=>m.id),[t]),{visible:i,toggle:A,isVisible:c}=Vt(gt),F=useMemo(()=>$t(t.length),[t.length]),E=10,ut=6.4,xt=18,mt=14,yt=6,nt=K,et=P,pt=nt/2,dt=et/2,n=d!=="none"?xt+yt+4:yt+4,u=Math.max(Math.min(pt,dt)-n,20),$=o?u*r:0,v=useMemo(()=>Me(t,i,F,u,$,pt,dt,e,a),[t,i,F,u,$,pt,dt,e,a]),W=useMemo(()=>v.map(m=>m.id).join(","),[v]);useEffect(()=>{q({});},[W]);let J=useCallback((m,M)=>{if(D.current)return;let g=S.current?.getBoundingClientRect();if(!g)return;w(M);let h=v.find(_=>_.id===M);h&&U({x:m.clientX-g.left+12,y:m.clientY-g.top-10,items:[{label:h.label,value:tt(h.value),percent:`${h.percent}%`,color:h.color}]});},[v]),it=useCallback(()=>{w(null),U(null);},[]),l=useCallback((m,M,g)=>{let h=G[m]??{dx:0,dy:0};D.current={id:m,startX:M,startY:g,origDx:h.dx,origDy:h.dy};},[G]),k=useCallback((m,M)=>{m.preventDefault(),w(M);let g=S.current?.getBoundingClientRect();if(!g)return;let h=m.touches[0];if(!h)return;let _=v.find(ht=>ht.id===M);_&&U({x:h.clientX-g.left+12,y:h.clientY-g.top-10,items:[{label:_.label,value:tt(_.value),percent:`${_.percent}%`,color:_.color}]});},[v]),X=useMemo(()=>{let m=t.reduce((M,g)=>M+g.value,0);return t.map((M,g)=>({id:M.id,label:M.label,color:M.color??F[g],visible:c(M.id),percent:m>0?Math.round(M.value/m*1e3)/10:0}))},[t,F,c]),Q=t.length>0&&t.some(m=>m.value>0),j=p==="left"||p==="right",st=useMemo(()=>{if(d==="none")return [];let m=E+3,M=yt+E*.5,g=et-yt-E*.5,h=v.filter(f=>f.percent>=3).map(f=>{let at="";switch(d){case "percent":at=`${f.percent}%`;break;case "value":at=tt(f.value);break;case "label":at=f.label;break;case "label+percent":at=`${f.label} ${f.percent}%`;break}let wt=kt(f.cx,f.cy,f.outerR+2,f.midAngle),ct=kt(f.cx,f.cy,f.outerR+xt,f.midAngle),Y=(f.midAngle-90)*Math.PI/180,Wt=Math.cos(Y)>=0,Ht=Math.ceil(at.length*ut);return {id:f.id,color:f.color,text:at,textW:Ht,p1:wt,elbowX:ct.x,y:ct.y,isRight:Wt}}),_=h.filter(f=>f.isRight).sort((f,at)=>f.y-at.y),ht=h.filter(f=>!f.isRight).sort((f,at)=>f.y-at.y);function vt(f){if(f.length!==0)for(let at=0;at<20;at++){let wt=false;for(let Y=1;Y<f.length;Y++){let Wt=f[Y].y-f[Y-1].y;if(Wt<m){let Ht=(m-Wt)/2;f[Y-1].y-=Ht,f[Y].y+=Ht,wt=true;}}f[0].y<M&&(f[0].y=M);for(let Y=1;Y<f.length;Y++)f[Y].y<f[Y-1].y+m&&(f[Y].y=f[Y-1].y+m);let ct=f.length-1;f[ct].y>g&&(f[ct].y=g);for(let Y=ct-1;Y>=0;Y--)f[Y].y>f[Y+1].y-m&&(f[Y].y=f[Y+1].y-m);for(let Y of f)Y.y=Math.max(M,Math.min(g,Y.y));if(!wt)break}}return vt(_),vt(ht),[...ht,..._]},[v,d,et]),bt=jsxs("svg",{role:"img","aria-label":R??"Pie chart",width:nt,height:et,viewBox:`0 0 ${nt} ${et}`,shapeRendering:"geometricPrecision",children:[jsxs("g",{className:V?"chart-pie-animate":"",children:[v.map((m,M)=>{let g=N===m.id,h=x&&g,_=Le(m.midAngle,h?C:0);return jsx("path",{d:m.path,fill:m.color,transform:h?`translate(${_.dx}, ${_.dy})`:void 0,className:rt("chart-slice",V&&`chart-slice-animate-${Math.min(M,7)}`,g&&"chart-slice--exploded"),stroke:m.color,strokeWidth:.6,onMouseMove:ht=>J(ht,m.id),onMouseLeave:it,onTouchStart:ht=>k(ht,m.id),onTouchEnd:it,"aria-label":`${m.label}: ${m.percent}%`},m.id)}),st.map(m=>{let M=G[m.id]??{dx:0,dy:0},g=m.elbowX+M.dx,h=m.y+M.dy,_=g+(m.isRight?mt:-mt),ht=m.isRight?_+3:_-3,vt=mt+3+m.textW+6,f=m.isRight?g:g-vt,at=h-E-2,wt=E*2+4;return jsxs("g",{style:{userSelect:"none"},children:[jsx("polyline",{points:[`${m.p1.x.toFixed(2)},${m.p1.y.toFixed(2)}`,`${g.toFixed(2)},${h.toFixed(2)}`,`${_.toFixed(2)},${h.toFixed(2)}`].join(" "),fill:"none",stroke:m.color,strokeWidth:1.2,opacity:.85,strokeLinejoin:"round",strokeLinecap:"round",style:{pointerEvents:"none"}}),jsx("text",{x:ht.toFixed(2),y:h.toFixed(2),textAnchor:m.isRight?"start":"end",dominantBaseline:"middle",fontSize:E,fill:"currentColor",className:"text-primary-700 dark:text-primary-300",style:{pointerEvents:"none"},children:m.text}),jsx("rect",{x:f,y:at,width:vt,height:wt,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseDown:ct=>{ct.stopPropagation(),l(m.id,ct.clientX,ct.clientY);},onTouchStart:ct=>{ct.stopPropagation();let Y=ct.touches[0];Y&&l(m.id,Y.clientX,Y.clientY);}})]},`label-${m.id}`)})]}),o&&jsx("g",{style:{pointerEvents:"none"},children:N&&v.find(m=>m.id===N)?jsxs(Fragment,{children:[jsxs("text",{x:pt,y:dt-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:18,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:[v.find(m=>m.id===N)?.percent,"%"]}),jsx("text",{x:pt,y:dt+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:v.find(m=>m.id===N)?.label})]}):jsxs(Fragment,{children:[s&&jsx("text",{x:pt,y:dt-(y?8:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:16,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:s}),y&&jsx("text",{x:pt,y:dt+14,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:y})]})})]});return jsxs("div",{ref:S,className:rt(Mt(),L),children:[R&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:R}),b&&p==="top"&&jsx(Zt,{items:X,position:"top",onToggle:A}),jsxs("div",{className:rt("flex items-start justify-center",j&&"gap-0"),children:[b&&p==="left"&&jsx(Zt,{items:X,position:"left",onToggle:A}),jsx("div",{ref:B,className:"flex-1 min-w-0 overflow-hidden",children:Q?bt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:P},children:z})}),b&&p==="right"&&jsx(Zt,{items:X,position:"right",onToggle:A})]}),b&&p==="bottom"&&jsx(Zt,{items:X,position:"bottom",onToggle:A}),I&&jsx("div",{className:Tt(),style:{left:I.x,top:I.y},role:"tooltip",children:I.items.map((m,M)=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:m.color}}),jsxs("span",{className:"font-medium",children:[m.label,":"]}),jsx("span",{children:m.value}),jsxs("span",{className:"text-primary-300",children:["(",m.percent,")"]})]},M))})]})}function Be(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=Number(x.x);C<e&&(e=C),C>a&&(a=C);}if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function Re(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function ce(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function le(t,o=5){return Xt(t[0],t[1],o)}function Ve(t,o,r){let e=1.618033988749895,a=t*137+o,d=a*e%1*2-1,s=a*e*e%1*2-1;return [d*r,s*r]}function $e(t,o,r=12){if(t.length<2)return null;let e=Math.min(...t),a=Math.max(...t),d=Math.min(...o),s=Math.max(...o);return {cx:(e+a)/2,cy:(d+s)/2,rx:(a-e)/2+r,ry:(s-d)/2+r}}function Kt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),e.label]},e.id))})}function me({series:t,xAxis:o,yAxis:r,dotRadius:e=5,dotOpacity:a=.75,clusters:d=false,jitter:s=false,jitterAmount:y=12,linkedLines:x=false,title:C,height:R=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:V="No data to display"}){let z=useRef(null),S=useRef(null),[B,K]=useState(600),[T,N]=useState(null);useEffect(()=>{let n=S.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&K(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&K(W);});return $.observe(n),()=>$.disconnect()},[]);let w=useMemo(()=>t.map(n=>n.id),[t]),{visible:I,toggle:U,isVisible:G}=Vt(w),q=useMemo(()=>$t(t.length),[t.length]),D=useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??q[u]])),[t,q]),gt=useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=useMemo(()=>Et(B,R,gt),[B,R,gt]),A=useMemo(()=>Be(t,I,o),[t,I,o]),c=useMemo(()=>Re(t,I,r),[t,I,r]),F=useMemo(()=>ce(A,[i.plotLeft,i.plotRight]),[A,i]),E=useMemo(()=>ce(c,[i.plotBottom,i.plotTop]),[c,i]),ut=useMemo(()=>le(A,o?.tickCount??6),[A,o?.tickCount]),xt=useMemo(()=>le(c,r?.tickCount??5),[c,r?.tickCount]),mt=useCallback((n,u,$,v,W)=>{let J=z.current?.getBoundingClientRect();J&&N({x:n.clientX-J.left+12,y:n.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),yt=useCallback((n,u,$,v,W)=>{n.preventDefault();let J=z.current?.getBoundingClientRect();if(!J)return;let it=n.touches[0];it&&N({x:it.clientX-J.left+12,y:it.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),nt=useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??q[u],visible:G(n.id)})),[t,q,G]),et=t.some(n=>n.data.length>0),pt=b==="left"||b==="right",dt=jsxs("svg",{role:"img","aria-label":C??"Scatter chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[xt.map(n=>jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:E(n),y2:E(n),stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)),d&&t.map((n,u)=>{if(!G(n.id)||n.data.length<2)return null;let $=D.get(n.id)??"var(--color-chart-1)",v=n.data.map(it=>F(Number(it.x))),W=n.data.map(it=>E(it.y)),J=$e(v,W,16);return J?jsx("ellipse",{cx:J.cx,cy:J.cy,rx:J.rx,ry:J.ry,fill:$,fillOpacity:.06,stroke:$,strokeOpacity:.3,strokeWidth:1.5,strokeDasharray:"5 3",className:p?"chart-cluster-ellipse":"",style:{animationDelay:`${u*.1}s`}},`cluster-${n.id}`):null}),x&&t.map(n=>{if(!G(n.id)||n.data.length<2)return null;let u=D.get(n.id)??"var(--color-chart-1)",v=[...n.data].sort((W,J)=>Number(W.x)-Number(J.x)).map(W=>`${F(Number(W.x)).toFixed(2)},${E(W.y).toFixed(2)}`).join(" ");return jsx("polyline",{points:v,fill:"none",stroke:u,strokeWidth:1.5,className:"chart-scatter-link"},`link-${n.id}`)}),t.map((n,u)=>{if(!G(n.id))return null;let $=D.get(n.id)??"var(--color-chart-1)";return jsx("g",{className:"chart-scatter-group",children:n.data.map((v,W)=>{let[J,it]=s?Ve(u,W,y):[0,0],l=F(Number(v.x))+J,k=E(v.y)+it;return jsx("circle",{cx:l,cy:k,r:e,fill:$,fillOpacity:a,stroke:$,strokeWidth:1,strokeOpacity:.5,className:rt("chart-scatter-dot",p&&"chart-scatter-dot--animate"),style:{color:$},onMouseMove:X=>mt(X,n.name,v.x,v.y,$),onMouseLeave:()=>N(null),onTouchStart:X=>yt(X,n.name,v.x,v.y,$),onTouchEnd:()=>N(null)},W)})},n.id)}),jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),xt.map(n=>{let u=E(n);return jsxs("g",{children:[jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),ut.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),r?.label&&jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxs("div",{ref:z,className:rt(Mt(),P),children:[C&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsx(Kt,{items:nt,position:"top",onToggle:U}),jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[L&&b==="left"&&jsx(Kt,{items:nt,position:"left",onToggle:U}),jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:R},children:V})}),L&&b==="right"&&jsx(Kt,{items:nt,position:"right",onToggle:U})]}),L&&b==="bottom"&&jsx(Kt,{items:nt,position:"bottom",onToggle:U}),T&&jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[jsx("span",{className:"h-2 w-2 rounded-full",style:{background:T.color}}),jsx("span",{className:"font-medium",children:T.seriesName})]}),jsxs("div",{className:"text-primary-300",children:["X: ",jsx("span",{className:"font-medium text-primary-50",children:T.xVal})," ","Y: ",jsx("span",{className:"font-medium text-primary-50",children:T.yVal})]})]})]})}var je={LineChart:oe,BarChart:ne,PieChart:se,ScatterChart:me},lo=je;export{ne as BarChart,je as Chart,oe as LineChart,se as PieChart,me as ScatterChart,lo as default};
1
+ import {useRef,useState,useEffect,useMemo,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function rt(...t){return twMerge(clsx(t))}var Mt=cva("relative w-full font-sans select-none",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}}),Lt=cva("flex flex-wrap gap-3 items-center justify-center",{variants:{position:{top:"mb-3",bottom:"mt-3",left:"flex-col mr-4",right:"flex-col ml-4"}},defaultVariants:{position:"bottom"}}),Tt=cva("absolute z-50 pointer-events-none px-3 py-2 rounded-lg text-xs shadow-lg border transition-opacity duration-150 bg-primary-900 text-primary-50 border-primary-700 dark:bg-primary-950 dark:border-primary-800");function Rt(t){let[o,r]=useState(()=>new Set(t)),e=useCallback(s=>{r(y=>{let x=new Set(y);return x.has(s)?x.delete(s):x.add(s),x});},[]),a=useCallback(s=>o.has(s),[o]),d=useCallback(()=>{r(new Set(t));},[t]);return {visible:o,toggle:e,isVisible:a,showAll:d}}function $t(t){let o=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"];return Array.from({length:t},(r,e)=>o[e%o.length])}function Dt(t,o,r=.1){if(t===o)return [t-1,o+1];let a=(o-t)*r;return [Math.floor(t-a),Math.ceil(o+a)]}function Xt(t,o,r){if(r<=1)return [t];let e=(o-t)/(r-1);return Array.from({length:r},(a,d)=>+(t+d*e).toFixed(10))}function tt(t,o){return o?o(t):typeof t=="number"?Math.abs(t)>=1e6?`${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`${(t/1e3).toFixed(1)}K`:Number.isInteger(t)?t.toString():t.toFixed(2):String(t)}function kt(t,o,r,e){let a=(e-90)*Math.PI/180;return {x:t+r*Math.cos(a),y:o+r*Math.sin(a)}}function Ft(t,o,r){return {top:20,right:r?65:20,bottom:t?52:36,left:o?65:52}}function Et(t,o,r){let e=Math.max(t,120);return {width:e,height:o,margins:r,plotLeft:r.left,plotTop:r.top,plotRight:e-r.right,plotBottom:o-r.bottom,plotWidth:Math.max(e-r.left-r.right,10),plotHeight:Math.max(o-r.top-r.bottom,10)}}function de(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function Ut(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function It(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function zt(t,o){let r=t.length;if(r===0)return ()=>(o[0]+o[1])/2;let e=(o[1]-o[0])/r;return a=>{let d=t.indexOf(a);return d<0?(o[0]+o[1])/2:o[0]+d*e+e/2}}function ue(t,o,r){return t.map(e=>`${o(e.x).toFixed(2)},${r(e.y).toFixed(2)}`).join(" ")}function qt(t,o,r){if(t.length===0)return "";let e=t.map(s=>({x:o(s.x),y:r(s.y)}));if(e.length===1)return `M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;let a=.5,d=`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;for(let s=0;s<e.length-1;s++){let y=s===0?{x:2*e[0].x-e[1].x,y:2*e[0].y-e[1].y}:e[s-1],x=e[s],C=e[s+1],V=s+2<e.length?e[s+2]:{x:2*e[e.length-1].x-e[e.length-2].x,y:2*e[e.length-1].y-e[e.length-2].y},P=x.x+(C.x-y.x)*a/3,L=x.y+(C.y-y.y)*a/3,b=C.x-(V.x-x.x)*a/3,p=C.y-(V.y-x.y)*a/3;d+=` C ${P.toFixed(2)} ${L.toFixed(2)}, ${b.toFixed(2)} ${p.toFixed(2)}, ${C.x.toFixed(2)} ${C.y.toFixed(2)}`;}return d}function pe(t,o,r,e,a){if(t.length===0)return "";let d=e?qt(t,o,r):`M ${t.map(x=>`${o(x.x).toFixed(2)},${r(x.y).toFixed(2)}`).join(" L ")}`,s=o(t[t.length-1].x).toFixed(2),y=o(t[0].x).toFixed(2);return `${d} L ${s},${a.toFixed(2)} L ${y},${a.toFixed(2)} Z`}function Gt(t,o=5){return Xt(t[0],t[1],o)}function Qt(t,o,r){if(o.length===0)return -1;let e=1/0,a=0;for(let d=0;d<o.length;d++){let s=Math.abs(r(o[d])-t);s<e&&(e=s,a=d);}return a}function te(t,o){return t.data.find(r=>String(r.x)===o)?.y}function he(t){for(let o of t)for(let r of o.data)if(typeof r.x=="string")return true;return false}function Pt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function oe({series:t,xAxis:o,yAxis:r,y2Axis:e,y2Series:a=[],smooth:d=false,showDots:s=true,area:y=false,strokeWidth:x=2,title:C,height:V=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:R="No data to display"}){let I=useRef(null),S=useRef(null),[B,K]=useState(600),[T,N]=useState(null),[w,z]=useState(null);useEffect(()=>{let l=S.current;if(!l)return;let k=l.getBoundingClientRect().width;k>0&&K(k);let X=new ResizeObserver(Q=>{let j=Q[0]?.contentRect.width;j&&j>0&&K(j);});return X.observe(l),()=>X.disconnect()},[]);let U=useMemo(()=>t.map(l=>l.id),[t]),{visible:G,toggle:q,isVisible:D}=Rt(U),gt=useMemo(()=>$t(t.length),[t.length]),i=useMemo(()=>new Map(t.map((l,k)=>[l.id,l.color??gt[k]])),[t,gt]),A=useMemo(()=>Ft(!!o?.label,!!r?.label,!!e),[o?.label,r?.label,e]),c=useMemo(()=>Et(B,V,A),[B,V,A]),F=useMemo(()=>he(t),[t]),E=useMemo(()=>F?de(t,G):[],[t,G,F]),ut=useMemo(()=>{if(F){let j=zt(E,[c.plotLeft,c.plotRight]);return st=>j(st)}let l=t.flatMap(j=>j.data.map(st=>st.x));if(l.length===0)return ()=>c.plotLeft;let k=Math.min(...l),X=Math.max(...l),Q=It([k,X],[c.plotLeft,c.plotRight]);return j=>Q(j)},[t,F,E,c]),xt=useMemo(()=>Ut(t,G,r),[t,G,r]),mt=useMemo(()=>It(xt,[c.plotBottom,c.plotTop]),[xt,c]),yt=useMemo(()=>Gt(xt,r?.tickCount??5),[xt,r?.tickCount]),nt=useMemo(()=>{if(!e)return null;let l=t.filter(k=>a.includes(k.id));return Ut(l,G,e)},[e,t,a,G]),et=useMemo(()=>nt?It(nt,[c.plotBottom,c.plotTop]):null,[nt,c]),pt=useMemo(()=>nt?Gt(nt,e?.tickCount??5):[],[nt,e?.tickCount]),dt=useMemo(()=>{if(F)return E;let l=t.flatMap(Q=>Q.data.map(j=>Number(j.x)));if(l.length===0)return [];let k=Math.min(...l),X=Math.max(...l);return Gt([k,X],o?.tickCount??6)},[F,E,t,o?.tickCount]),n=useCallback(l=>{let k=l.currentTarget.closest("svg");if(!k)return;let X=k.getBoundingClientRect(),Q=l.clientX-X.left,j=I.current?.getBoundingClientRect();if(!j)return;let st="",bt=Q;if(F&&E.length>0){let h=zt(E,[c.plotLeft,c.plotRight]),_=Qt(Q,E,h);st=E[_]??"",bt=h(st);}else if(!F){let h=dt;st=tt((Q-c.plotLeft)/c.plotWidth*(h[h.length-1]-h[0])+h[0],o?.format),bt=Q;}let m=t.filter(h=>D(h.id)).map(h=>{a.includes(h.id)&&et!=null?et:mt;let vt;if(F)vt=te(h,st);else {let f=Q,at=1/0,wt;for(let ct of h.data){let Y=ut(ct.x),Wt=Math.abs(Y-f);Wt<at&&(at=Wt,wt=ct.y);}vt=wt;}return {name:h.name,value:vt!==void 0?tt(vt,r?.format):"\u2014",color:i.get(h.id)??"var(--color-chart-1)"}});bt>=c.plotLeft&&bt<=c.plotRight&&z(bt);let M=l.clientX-j.left+12,g=l.clientY-j.top-10;N({x:M,y:g,label:st,items:m});},[F,E,c,t,D,a,et,mt,ut,dt,o?.format,r?.format,i]),u=useCallback(()=>{N(null),z(null);},[]),$=useCallback(l=>{l.preventDefault();let k=l.touches[0];if(!k)return;let X=l.currentTarget.closest("svg");if(!X)return;let Q=X.getBoundingClientRect(),j=I.current?.getBoundingClientRect();if(!j)return;let st=k.clientX-Q.left,bt=st,m="";if(F&&E.length>0){let g=zt(E,[c.plotLeft,c.plotRight]),h=Qt(st,E,g);m=E[h]??"",bt=g(m);}bt>=c.plotLeft&&bt<=c.plotRight&&z(bt);let M=t.filter(g=>D(g.id)).map(g=>({name:g.name,value:F&&m?tt(te(g,m)??0,r?.format):"\u2014",color:i.get(g.id)??"var(--color-chart-1)"}));N({x:k.clientX-j.left+12,y:k.clientY-j.top-10,label:m,items:M});},[F,E,c,t,D,r?.format,i]),v=useMemo(()=>t.map((l,k)=>({id:l.id,label:l.name,color:l.color??gt[k],visible:D(l.id)})),[t,gt,D]),W=t.some(l=>l.data.length>0),J=jsxs("svg",{role:"img","aria-label":C??"Line chart",width:c.width,height:c.height,viewBox:`0 0 ${c.width} ${c.height}`,shapeRendering:"geometricPrecision",children:[r?.gridLines!==false&&yt.map(l=>{let k=mt(l);return jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:k,y2:k,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},l)}),y&&t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)",j=pe(l.data,ut,X,d,c.plotBottom);return jsx("path",{d:j,fill:Q,fillOpacity:.15,stroke:"none",className:p?"chart-area-animate":""},`area-${l.id}`)}),t.map(l=>{if(!D(l.id)||l.data.length===0)return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return d?jsx("path",{d:qt(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id):jsx("polyline",{points:ue(l.data,ut,X),fill:"none",stroke:Q,strokeWidth:x,strokeLinecap:"round",strokeLinejoin:"round",className:p?"chart-line-animate":""},l.id)}),s&&t.map(l=>{if(!D(l.id))return null;let X=a.includes(l.id)&&et!=null?et:mt,Q=i.get(l.id)??"var(--color-chart-1)";return l.data.map((j,st)=>jsx("circle",{cx:ut(j.x),cy:X(j.y),r:3,fill:Q,stroke:"white",strokeWidth:1.5,className:rt("chart-dot",p?"chart-dot-animate":"")},`${l.id}-${st}`))}),w!=null&&jsx("line",{className:"chart-crosshair",x1:w,x2:w,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,strokeDasharray:"4 4",opacity:.5,style:{color:"var(--color-secondary-400)"}}),jsx("line",{x1:c.plotLeft,x2:c.plotLeft,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),yt.map(l=>{let k=mt(l);return jsxs("g",{children:[jsx("line",{x1:c.plotLeft-4,x2:c.plotLeft,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:c.plotLeft-6,y:k,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,r?.format)})]},l)}),r?.label&&jsx("text",{x:-(c.plotTop+c.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),e&&et&&jsxs(Fragment,{children:[jsx("line",{x1:c.plotRight,x2:c.plotRight,y1:c.plotTop,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),pt.map(l=>{let k=et(l);return jsxs("g",{children:[jsx("line",{x1:c.plotRight,x2:c.plotRight+4,y1:k,y2:k,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:c.plotRight+6,y:k,textAnchor:"start",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,e?.format)})]},l)}),e?.label&&jsx("text",{x:c.plotTop+c.plotHeight/2,y:-(c.width-14),textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(90)",children:e.label})]}),jsx("line",{x1:c.plotLeft,x2:c.plotRight,y1:c.plotBottom,y2:c.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),(F?E:dt).map((l,k)=>{let X=ut(l);return jsxs("g",{children:[jsx("line",{x1:X,x2:X,y1:c.plotBottom,y2:c.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:X,y:c.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(l,o?.format)})]},k)}),o?.label&&jsx("text",{x:c.plotLeft+c.plotWidth/2,y:c.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label}),jsx("rect",{x:c.plotLeft,y:c.plotTop,width:c.plotWidth,height:c.plotHeight,fill:"transparent",onMouseMove:n,onMouseLeave:u,onTouchStart:$,onTouchMove:$,onTouchEnd:u,style:{cursor:"crosshair"}})]}),it=b==="left"||b==="right";return jsxs("div",{ref:I,className:rt(Mt(),P),children:[C&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsx(Pt,{items:v,position:"top",onToggle:q}),jsxs("div",{className:rt("flex items-start",it&&"gap-0"),children:[L&&b==="left"&&jsx(Pt,{items:v,position:"left",onToggle:q}),jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:W?J:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:V},children:R})}),L&&b==="right"&&jsx(Pt,{items:v,position:"right",onToggle:q})]}),L&&b==="bottom"&&jsx(Pt,{items:v,position:"bottom",onToggle:q}),T&&jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[T.label&&jsx("div",{className:"mb-1 font-medium text-primary-200",children:T.label}),T.items.map((l,k)=>jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:l.color}}),jsxs("span",{className:"text-primary-300",children:[l.name,":"]}),jsx("span",{className:"font-medium",children:l.value})]},k))]})]})}function ge(t,o){let r=new Set,e=[];for(let a of t)if(o.has(a.id))for(let d of a.data){let s=String(d.x);r.has(s)||(r.add(s),e.push(s));}return e}function xe(t,o,r,e){if(r){let a=0;for(let s of t)if(o.has(s.id))for(let y of s.data)y.y>a&&(a=y.y);a===0&&(a=1);let[,d]=Dt(0,a,.05);return [e?.min??0,e?.max??d]}else {let a=new Map;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=String(x.x);a.set(C,(a.get(C)??0)+x.y);}let d=Math.max(0,...a.values()),[,s]=Dt(0,d===0?1:d,.05);return [e?.min??0,e?.max??s]}}function ye(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function be(t,o=5){return Xt(t[0],t[1],o)}function ve(t,o,r,e,a,d,s,y,x,C,V){let P=t.filter(B=>o.has(B.id)),L=r.length,b=P.length;if(L===0||b===0)return [];let p=d/L,R=p*(1-C),I=b>0?R*(1-V)/b:0,S=[];for(let B=0;B<r.length;B++){let K=r[B],T=a+B*p+(p-R)/2;for(let N=0;N<P.length;N++){let w=P[N],z=w.data.find(q=>String(q.x)===K);if(!z)continue;let U=T+N*(I+R*V/b),G=x(z.y);S.push({seriesId:w.id,category:K,x:U,y:G,width:Math.max(I,1),height:Math.max(s-G,0),stackBase:s,value:z.y,color:e.get(w.id)??"var(--color-chart-1)"});}}return S}function ke(t,o,r,e,a,d,s,y,x,C){let V=t.filter(S=>o.has(S.id)),P=r.length,L=V.length;if(P===0||L===0)return [];let b=s/P,p=b*(1-x),R=L>0?p*(1-C)/L:0,I=[];for(let S=0;S<r.length;S++){let B=r[S],K=d+S*b+(b-p)/2;for(let T=0;T<V.length;T++){let N=V[T],w=N.data.find(G=>String(G.x)===B);if(!w)continue;let z=K+T*(R+p*C/Math.max(L,1)),U=y(w.y);I.push({seriesId:N.id,category:B,x:a,y:z,width:Math.max(U-a,0),height:Math.max(R,1),stackBase:a,value:w.y,color:e.get(N.id)??"var(--color-chart-1)"});}}return I}function Ce(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=r.length;if(V===0)return [];let P=s/V*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,a));for(let p of C)for(let R of r){let I=p.data.find(N=>String(N.x)===R);if(!I)continue;let S=b.get(R)??a,B=Math.max(y(I.y)-a,0),K=r.indexOf(R),T=d+(K+.5)*(s/V);L.push({seriesId:p.id,category:R,x:S,y:T-P/2,width:B,height:Math.max(P,1),stackBase:S,value:I.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(R,S+B);}return L}function Se(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=r.length;if(V===0)return [];let P=d/V*(1-x),L=[],b=new Map;r.forEach(p=>b.set(p,s));for(let p of C)for(let R of r){let I=p.data.find(w=>String(w.x)===R);if(!I)continue;let S=b.get(R)??s,B=Math.max(s-y(I.y),0),K=S-B,T=r.indexOf(R),N=a+(T+.5)*(d/V);L.push({seriesId:p.id,category:R,x:N-P/2,y:K,width:Math.max(P,1),height:B,stackBase:S,value:I.y,color:e.get(p.id)??"var(--color-chart-1)"}),b.set(R,K);}return L}function jt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-5 rounded-sm shrink-0",style:{background:e.color}}),e.label]},e.id))})}function ne({series:t,xAxis:o,yAxis:r,orientation:e="vertical",grouped:a=true,barRadius:d=4,barPadding:s=.2,groupPadding:y=.3,title:x,height:C=300,className:V,legend:P=true,legendPosition:L="bottom",animateOnMount:b=true,emptyText:p="No data to display"}){let R=useRef(null),I=useRef(null),[S,B]=useState(600),[K,T]=useState(null);useEffect(()=>{let n=I.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&B(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&B(W);});return $.observe(n),()=>$.disconnect()},[]);let N=useMemo(()=>t.map(n=>n.id),[t]),{visible:w,toggle:z,isVisible:U}=Rt(N),G=useMemo(()=>$t(t.length),[t.length]),q=useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??G[u]])),[t,G]),D=e==="horizontal",gt=useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=useMemo(()=>Et(S,C,gt),[S,C,gt]),A=useMemo(()=>ge(t,w),[t,w]),c=useMemo(()=>xe(t,w,a,D?o:r),[t,w,a,D,o,r]),F=useMemo(()=>ye(c,D?[i.plotLeft,i.plotRight]:[i.plotBottom,i.plotTop]),[c,i,D]),E=useMemo(()=>be(c,(D?o:r)?.tickCount??5),[c,D,o,r]),ut=useMemo(()=>D?a?ke(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y,s):Ce(t,w,A,q,i.plotLeft,i.plotTop,i.plotHeight,F,y):a?ve(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,i.plotTop,F,y,s):Se(t,w,A,q,i.plotLeft,i.plotWidth,i.plotBottom,F,y),[t,w,A,q,i,F,a,D,y,s]),xt=A.length>0?i.plotWidth/A.length:1,mt=A.length>0?i.plotHeight/A.length:1,yt=useCallback((n,u)=>{let $=R.current?.getBoundingClientRect();if(!$)return;let v=t.filter(W=>U(W.id)).map(W=>{let J=W.data.find(it=>String(it.x)===u);return {name:W.name,value:J?tt(J.y,r?.format):"\u2014",color:q.get(W.id)??"var(--color-chart-1)"}});T({x:n.clientX-$.left+12,y:n.clientY-$.top-10,category:u,items:v});},[t,U,q,r?.format]),nt=useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??G[u],visible:U(n.id)})),[t,G,U]),et=t.some(n=>n.data.length>0),pt=L==="left"||L==="right",dt=jsxs("svg",{role:"img","aria-label":x??"Bar chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[E.map(n=>{let u=F(n);return D?jsx("line",{x1:u,x2:u,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n):jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:u,y2:u,stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)}),ut.map(n=>{let u=Math.min(d,n.width/2,n.height/2),$=`${n.seriesId}-${n.category}`;return D?jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-h",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$):jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:u,fill:n.color,className:rt("chart-bar-v",b&&"chart-bar-animate"),onMouseMove:v=>yt(v,n.category),onMouseLeave:()=>T(null)},$)}),jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),!D&&E.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),D&&E.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),A.map((n,u)=>{if(D){let v=i.plotTop+(u+.5)*mt;return jsx("text",{x:i.plotLeft-6,y:v,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}let $=i.plotLeft+(u+.5)*xt;return jsx("text",{x:$,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:n},n)}),r?.label&&!D&&jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxs("div",{ref:R,className:rt(Mt(),V),children:[x&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:x}),P&&L==="top"&&jsx(jt,{items:nt,position:"top",onToggle:z}),jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[P&&L==="left"&&jsx(jt,{items:nt,position:"left",onToggle:z}),jsx("div",{ref:I,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:C},children:p})}),P&&L==="right"&&jsx(jt,{items:nt,position:"right",onToggle:z})]}),P&&L==="bottom"&&jsx(jt,{items:nt,position:"bottom",onToggle:z}),K&&jsxs("div",{className:Tt(),style:{left:K.x,top:K.y},role:"tooltip",children:[jsx("div",{className:"mb-1 font-medium text-primary-200",children:K.category}),K.items.map((n,u)=>jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{background:n.color}}),jsxs("span",{className:"text-primary-300",children:[n.name,":"]}),jsx("span",{className:"font-medium",children:n.value})]},u))]})]})}function Me(t,o,r,e,a,d,s,y,x){let C=t.filter(p=>o.has(p.id)),V=C.reduce((p,R)=>p+R.value,0);if(V===0)return [];let P=new Map(t.map((p,R)=>[p.id,p.color??r[R%r.length]])),L=[],b=y;for(let p of C){let R=p.value/V*360,I=x/2,S=b+I,B=b+R-I,K=(S+B)/2,T;if(Math.abs(B-S)>=359.9){let N=kt(d,s,e,S),w=kt(d,s,e,S+180);T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 1 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} A ${e} ${e} 0 1 1 ${N.x.toFixed(3)} ${N.y.toFixed(3)} Z`;}else if(a>0){let N=kt(d,s,e,S),w=kt(d,s,e,B),z=kt(d,s,a,B),U=kt(d,s,a,S),G=B-S>180?1:0;T=`M ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${G} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} L ${z.x.toFixed(3)} ${z.y.toFixed(3)} A ${a} ${a} 0 ${G} 0 ${U.x.toFixed(3)} ${U.y.toFixed(3)} Z`;}else {let N=kt(d,s,e,S),w=kt(d,s,e,B),z=B-S>180?1:0;T=`M ${d.toFixed(3)} ${s.toFixed(3)} L ${N.x.toFixed(3)} ${N.y.toFixed(3)} A ${e} ${e} 0 ${z} 1 ${w.x.toFixed(3)} ${w.y.toFixed(3)} Z`;}L.push({id:p.id,label:p.label,value:p.value,percent:Math.round(p.value/V*1e3)/10,color:P.get(p.id)??"var(--color-chart-1)",startAngle:S,endAngle:B,midAngle:K,path:T,outerR:e,innerR:a,cx:d,cy:s}),b+=R;}return L}function Le(t,o){let r=(t-90)*Math.PI/180;return {dx:Math.cos(r)*o,dy:Math.sin(r)*o}}function Zt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),jsx("span",{children:e.label}),jsxs("span",{className:"text-secondary-400",children:["(",e.percent,"%)"]})]},e.id))})}function se({data:t,donut:o=false,donutThickness:r=.5,startAngle:e=-90,padAngle:a=0,labelType:d="percent",centerLabel:s,centerSubLabel:y,explodeOnHover:x=true,explodeOffset:C=8,title:V,height:P=300,className:L,legend:b=true,legendPosition:p="bottom",animateOnMount:R=true,emptyText:I="No data to display"}){let S=useRef(null),B=useRef(null),[K,T]=useState(400),[N,w]=useState(null),[z,U]=useState(null),[G,q]=useState({}),D=useRef(null);useEffect(()=>{let m=B.current;if(!m)return;let M=m.getBoundingClientRect().width;M>0&&T(M);let g=new ResizeObserver(h=>{let _=h[0]?.contentRect.width;_&&_>0&&T(_);});return g.observe(m),()=>g.disconnect()},[]),useEffect(()=>{function m(g){let h=D.current;if(!h)return;"touches"in g&&g.cancelable&&g.preventDefault();let _="touches"in g?g.touches[0]?.clientX??h.startX:g.clientX,ht="touches"in g?g.touches[0]?.clientY??h.startY:g.clientY;q(vt=>({...vt,[h.id]:{dx:h.origDx+_-h.startX,dy:h.origDy+ht-h.startY}}));}function M(){D.current=null;}return window.addEventListener("mousemove",m),window.addEventListener("mouseup",M),window.addEventListener("touchmove",m,{passive:false}),window.addEventListener("touchend",M),()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",M),window.removeEventListener("touchmove",m),window.removeEventListener("touchend",M);}},[]);let gt=useMemo(()=>t.map(m=>m.id),[t]),{visible:i,toggle:A,isVisible:c}=Rt(gt),F=useMemo(()=>$t(t.length),[t.length]),E=10,ut=6.4,xt=18,mt=14,yt=6,nt=K,et=P,pt=nt/2,dt=et/2,n=d!=="none"?xt+yt+4:yt+4,u=Math.max(Math.min(pt,dt)-n,20),$=o?u*r:0,v=useMemo(()=>Me(t,i,F,u,$,pt,dt,e,a),[t,i,F,u,$,pt,dt,e,a]),W=useMemo(()=>v.map(m=>m.id).join(","),[v]);useEffect(()=>{q({});},[W]);let J=useCallback((m,M)=>{if(D.current)return;let g=S.current?.getBoundingClientRect();if(!g)return;w(M);let h=v.find(_=>_.id===M);h&&U({x:m.clientX-g.left+12,y:m.clientY-g.top-10,items:[{label:h.label,value:tt(h.value),percent:`${h.percent}%`,color:h.color}]});},[v]),it=useCallback(()=>{w(null),U(null);},[]),l=useCallback((m,M,g)=>{let h=G[m]??{dx:0,dy:0};D.current={id:m,startX:M,startY:g,origDx:h.dx,origDy:h.dy};},[G]),k=useCallback((m,M)=>{m.preventDefault(),w(M);let g=S.current?.getBoundingClientRect();if(!g)return;let h=m.touches[0];if(!h)return;let _=v.find(ht=>ht.id===M);_&&U({x:h.clientX-g.left+12,y:h.clientY-g.top-10,items:[{label:_.label,value:tt(_.value),percent:`${_.percent}%`,color:_.color}]});},[v]),X=useMemo(()=>{let m=t.reduce((M,g)=>M+g.value,0);return t.map((M,g)=>({id:M.id,label:M.label,color:M.color??F[g],visible:c(M.id),percent:m>0?Math.round(M.value/m*1e3)/10:0}))},[t,F,c]),Q=t.length>0&&t.some(m=>m.value>0),j=p==="left"||p==="right",st=useMemo(()=>{if(d==="none")return [];let m=E+3,M=yt+E*.5,g=et-yt-E*.5,h=v.filter(f=>f.percent>=3).map(f=>{let at="";switch(d){case "percent":at=`${f.percent}%`;break;case "value":at=tt(f.value);break;case "label":at=f.label;break;case "label+percent":at=`${f.label} ${f.percent}%`;break}let wt=kt(f.cx,f.cy,f.outerR+2,f.midAngle),ct=kt(f.cx,f.cy,f.outerR+xt,f.midAngle),Y=(f.midAngle-90)*Math.PI/180,Wt=Math.cos(Y)>=0,Ht=Math.ceil(at.length*ut);return {id:f.id,color:f.color,text:at,textW:Ht,p1:wt,elbowX:ct.x,y:ct.y,isRight:Wt}}),_=h.filter(f=>f.isRight).sort((f,at)=>f.y-at.y),ht=h.filter(f=>!f.isRight).sort((f,at)=>f.y-at.y);function vt(f){if(f.length!==0)for(let at=0;at<20;at++){let wt=false;for(let Y=1;Y<f.length;Y++){let Wt=f[Y].y-f[Y-1].y;if(Wt<m){let Ht=(m-Wt)/2;f[Y-1].y-=Ht,f[Y].y+=Ht,wt=true;}}f[0].y<M&&(f[0].y=M);for(let Y=1;Y<f.length;Y++)f[Y].y<f[Y-1].y+m&&(f[Y].y=f[Y-1].y+m);let ct=f.length-1;f[ct].y>g&&(f[ct].y=g);for(let Y=ct-1;Y>=0;Y--)f[Y].y>f[Y+1].y-m&&(f[Y].y=f[Y+1].y-m);for(let Y of f)Y.y=Math.max(M,Math.min(g,Y.y));if(!wt)break}}return vt(_),vt(ht),[...ht,..._]},[v,d,et]),bt=jsxs("svg",{role:"img","aria-label":V??"Pie chart",width:nt,height:et,viewBox:`0 0 ${nt} ${et}`,shapeRendering:"geometricPrecision",children:[jsxs("g",{className:R?"chart-pie-animate":"",children:[v.map((m,M)=>{let g=N===m.id,h=x&&g,_=Le(m.midAngle,h?C:0);return jsx("path",{d:m.path,fill:m.color,transform:h?`translate(${_.dx}, ${_.dy})`:void 0,className:rt("chart-slice",R&&`chart-slice-animate-${Math.min(M,7)}`,g&&"chart-slice--exploded"),stroke:m.color,strokeWidth:.6,onMouseMove:ht=>J(ht,m.id),onMouseLeave:it,onTouchStart:ht=>k(ht,m.id),onTouchEnd:it,"aria-label":`${m.label}: ${m.percent}%`},m.id)}),st.map(m=>{let M=G[m.id]??{dx:0,dy:0},g=m.elbowX+M.dx,h=m.y+M.dy,_=g+(m.isRight?mt:-mt),ht=m.isRight?_+3:_-3,vt=mt+3+m.textW+6,f=m.isRight?g:g-vt,at=h-E-2,wt=E*2+4;return jsxs("g",{style:{userSelect:"none"},children:[jsx("polyline",{points:[`${m.p1.x.toFixed(2)},${m.p1.y.toFixed(2)}`,`${g.toFixed(2)},${h.toFixed(2)}`,`${_.toFixed(2)},${h.toFixed(2)}`].join(" "),fill:"none",stroke:m.color,strokeWidth:1.2,opacity:.85,strokeLinejoin:"round",strokeLinecap:"round",style:{pointerEvents:"none"}}),jsx("text",{x:ht.toFixed(2),y:h.toFixed(2),textAnchor:m.isRight?"start":"end",dominantBaseline:"middle",fontSize:E,fill:"currentColor",className:"text-primary-700 dark:text-primary-300",style:{pointerEvents:"none"},children:m.text}),jsx("rect",{x:f,y:at,width:vt,height:wt,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseDown:ct=>{ct.stopPropagation(),l(m.id,ct.clientX,ct.clientY);},onTouchStart:ct=>{ct.stopPropagation();let Y=ct.touches[0];Y&&l(m.id,Y.clientX,Y.clientY);}})]},`label-${m.id}`)})]}),o&&jsx("g",{style:{pointerEvents:"none"},children:N&&v.find(m=>m.id===N)?jsxs(Fragment,{children:[jsxs("text",{x:pt,y:dt-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:18,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:[v.find(m=>m.id===N)?.percent,"%"]}),jsx("text",{x:pt,y:dt+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:v.find(m=>m.id===N)?.label})]}):jsxs(Fragment,{children:[s&&jsx("text",{x:pt,y:dt-(y?8:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:16,fontWeight:600,fill:"currentColor",className:"text-primary-800 dark:text-primary-100",children:s}),y&&jsx("text",{x:pt,y:dt+14,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:y})]})})]});return jsxs("div",{ref:S,className:rt(Mt(),L),children:[V&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:V}),b&&p==="top"&&jsx(Zt,{items:X,position:"top",onToggle:A}),jsxs("div",{className:rt("flex items-start justify-center",j&&"gap-0"),children:[b&&p==="left"&&jsx(Zt,{items:X,position:"left",onToggle:A}),jsx("div",{ref:B,className:"flex-1 min-w-0 overflow-hidden",children:Q?bt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:P},children:I})}),b&&p==="right"&&jsx(Zt,{items:X,position:"right",onToggle:A})]}),b&&p==="bottom"&&jsx(Zt,{items:X,position:"bottom",onToggle:A}),z&&jsx("div",{className:Tt(),style:{left:z.x,top:z.y},role:"tooltip",children:z.items.map((m,M)=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:m.color}}),jsxs("span",{className:"font-medium",children:[m.label,":"]}),jsx("span",{children:m.value}),jsxs("span",{className:"text-primary-300",children:["(",m.percent,")"]})]},M))})]})}function Be(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data){let C=Number(x.x);C<e&&(e=C),C>a&&(a=C);}if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function Ve(t,o,r){let e=1/0,a=-1/0;for(let y of t)if(o.has(y.id))for(let x of y.data)x.y<e&&(e=x.y),x.y>a&&(a=x.y);if(!isFinite(e))return [0,1];let[d,s]=Dt(e,a);return [r?.min??d,r?.max??s]}function ce(t,o){let[r,e]=t,[a,d]=o;return e===r?()=>(a+d)/2:s=>a+(s-r)/(e-r)*(d-a)}function le(t,o=5){return Xt(t[0],t[1],o)}function Re(t,o,r){let e=1.618033988749895,a=t*137+o,d=a*e%1*2-1,s=a*e*e%1*2-1;return [d*r,s*r]}function $e(t,o,r=12){if(t.length<2)return null;let e=Math.min(...t),a=Math.max(...t),d=Math.min(...o),s=Math.max(...o);return {cx:(e+a)/2,cy:(d+s)/2,rx:(a-e)/2+r,ry:(s-d)/2+r}}function Kt({items:t,position:o,onToggle:r}){return jsx("div",{className:Lt({position:o}),children:t.map(e=>jsxs("button",{onClick:()=>r(e.id),className:rt("flex items-center gap-1.5 cursor-pointer rounded px-1.5 py-1 text-xs text-primary-700 transition-opacity hover:bg-primary-100 dark:text-primary-300 dark:hover:bg-primary-800",!e.visible&&"opacity-40"),"aria-pressed":e.visible,children:[jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{background:e.color}}),e.label]},e.id))})}function me({series:t,xAxis:o,yAxis:r,dotRadius:e=5,dotOpacity:a=.75,clusters:d=false,jitter:s=false,jitterAmount:y=12,linkedLines:x=false,title:C,height:V=300,className:P,legend:L=true,legendPosition:b="bottom",animateOnMount:p=true,emptyText:R="No data to display"}){let I=useRef(null),S=useRef(null),[B,K]=useState(600),[T,N]=useState(null);useEffect(()=>{let n=S.current;if(!n)return;let u=n.getBoundingClientRect().width;u>0&&K(u);let $=new ResizeObserver(v=>{let W=v[0]?.contentRect.width;W&&W>0&&K(W);});return $.observe(n),()=>$.disconnect()},[]);let w=useMemo(()=>t.map(n=>n.id),[t]),{visible:z,toggle:U,isVisible:G}=Rt(w),q=useMemo(()=>$t(t.length),[t.length]),D=useMemo(()=>new Map(t.map((n,u)=>[n.id,n.color??q[u]])),[t,q]),gt=useMemo(()=>Ft(!!o?.label,!!r?.label,false),[o?.label,r?.label]),i=useMemo(()=>Et(B,V,gt),[B,V,gt]),A=useMemo(()=>Be(t,z,o),[t,z,o]),c=useMemo(()=>Ve(t,z,r),[t,z,r]),F=useMemo(()=>ce(A,[i.plotLeft,i.plotRight]),[A,i]),E=useMemo(()=>ce(c,[i.plotBottom,i.plotTop]),[c,i]),ut=useMemo(()=>le(A,o?.tickCount??6),[A,o?.tickCount]),xt=useMemo(()=>le(c,r?.tickCount??5),[c,r?.tickCount]),mt=useCallback((n,u,$,v,W)=>{let J=I.current?.getBoundingClientRect();J&&N({x:n.clientX-J.left+12,y:n.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),yt=useCallback((n,u,$,v,W)=>{n.preventDefault();let J=I.current?.getBoundingClientRect();if(!J)return;let it=n.touches[0];it&&N({x:it.clientX-J.left+12,y:it.clientY-J.top-10,seriesName:u,xVal:tt($,o?.format),yVal:tt(v,r?.format),color:W});},[o?.format,r?.format]),nt=useMemo(()=>t.map((n,u)=>({id:n.id,label:n.name,color:n.color??q[u],visible:G(n.id)})),[t,q,G]),et=t.some(n=>n.data.length>0),pt=b==="left"||b==="right",dt=jsxs("svg",{role:"img","aria-label":C??"Scatter chart",width:i.width,height:i.height,viewBox:`0 0 ${i.width} ${i.height}`,shapeRendering:"geometricPrecision",children:[xt.map(n=>jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:E(n),y2:E(n),stroke:"currentColor",strokeWidth:.5,strokeDasharray:"4 4",className:"text-secondary-200 dark:text-secondary-700"},n)),d&&t.map((n,u)=>{if(!G(n.id)||n.data.length<2)return null;let $=D.get(n.id)??"var(--color-chart-1)",v=n.data.map(it=>F(Number(it.x))),W=n.data.map(it=>E(it.y)),J=$e(v,W,16);return J?jsx("ellipse",{cx:J.cx,cy:J.cy,rx:J.rx,ry:J.ry,fill:$,fillOpacity:.06,stroke:$,strokeOpacity:.3,strokeWidth:1.5,strokeDasharray:"5 3",className:p?"chart-cluster-ellipse":"",style:{animationDelay:`${u*.1}s`}},`cluster-${n.id}`):null}),x&&t.map(n=>{if(!G(n.id)||n.data.length<2)return null;let u=D.get(n.id)??"var(--color-chart-1)",v=[...n.data].sort((W,J)=>Number(W.x)-Number(J.x)).map(W=>`${F(Number(W.x)).toFixed(2)},${E(W.y).toFixed(2)}`).join(" ");return jsx("polyline",{points:v,fill:"none",stroke:u,strokeWidth:1.5,className:"chart-scatter-link"},`link-${n.id}`)}),t.map((n,u)=>{if(!G(n.id))return null;let $=D.get(n.id)??"var(--color-chart-1)";return jsx("g",{className:"chart-scatter-group",children:n.data.map((v,W)=>{let[J,it]=s?Re(u,W,y):[0,0],l=F(Number(v.x))+J,k=E(v.y)+it;return jsx("circle",{cx:l,cy:k,r:e,fill:$,fillOpacity:a,stroke:$,strokeWidth:1,strokeOpacity:.5,className:rt("chart-scatter-dot",p&&"chart-scatter-dot--animate"),style:{color:$},onMouseMove:X=>mt(X,n.name,v.x,v.y,$),onMouseLeave:()=>N(null),onTouchStart:X=>yt(X,n.name,v.x,v.y,$),onTouchEnd:()=>N(null)},W)})},n.id)}),jsx("line",{x1:i.plotLeft,x2:i.plotLeft,y1:i.plotTop,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("line",{x1:i.plotLeft,x2:i.plotRight,y1:i.plotBottom,y2:i.plotBottom,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),xt.map(n=>{let u=E(n);return jsxs("g",{children:[jsx("line",{x1:i.plotLeft-4,x2:i.plotLeft,y1:u,y2:u,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:i.plotLeft-6,y:u,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,r?.format)})]},n)}),ut.map(n=>{let u=F(n);return jsxs("g",{children:[jsx("line",{x1:u,x2:u,y1:i.plotBottom,y2:i.plotBottom+4,stroke:"currentColor",strokeWidth:1,className:"text-secondary-300 dark:text-secondary-600"}),jsx("text",{x:u,y:i.plotBottom+14,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"text-secondary-500 dark:text-secondary-400",children:tt(n,o?.format)})]},n)}),r?.label&&jsx("text",{x:-(i.plotTop+i.plotHeight/2),y:14,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",transform:"rotate(-90)",children:r.label}),o?.label&&jsx("text",{x:i.plotLeft+i.plotWidth/2,y:i.height-4,textAnchor:"middle",fontSize:11,fill:"currentColor",className:"text-secondary-600 dark:text-secondary-400",children:o.label})]});return jsxs("div",{ref:I,className:rt(Mt(),P),children:[C&&jsx("h3",{className:"mb-2 text-sm font-semibold text-primary-700 dark:text-primary-200",children:C}),L&&b==="top"&&jsx(Kt,{items:nt,position:"top",onToggle:U}),jsxs("div",{className:rt("flex items-start",pt&&"gap-0"),children:[L&&b==="left"&&jsx(Kt,{items:nt,position:"left",onToggle:U}),jsx("div",{ref:S,className:"flex-1 min-w-0 overflow-hidden",children:et?dt:jsx("div",{className:"flex items-center justify-center text-secondary-400 dark:text-secondary-500",style:{height:V},children:R})}),L&&b==="right"&&jsx(Kt,{items:nt,position:"right",onToggle:U})]}),L&&b==="bottom"&&jsx(Kt,{items:nt,position:"bottom",onToggle:U}),T&&jsxs("div",{className:Tt(),style:{left:T.x,top:T.y},role:"tooltip",children:[jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[jsx("span",{className:"h-2 w-2 rounded-full",style:{background:T.color}}),jsx("span",{className:"font-medium",children:T.seriesName})]}),jsxs("div",{className:"text-primary-300",children:["X: ",jsx("span",{className:"font-medium text-primary-50",children:T.xVal})," ","Y: ",jsx("span",{className:"font-medium text-primary-50",children:T.yVal})]})]})]})}var je={LineChart:oe,BarChart:ne,PieChart:se,ScatterChart:me},lo=je;export{ne as BarChart,je as Chart,oe as LineChart,se as PieChart,me as ScatterChart,lo as default};
@@ -0,0 +1,2 @@
1
+ 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');function Q(...s){return tailwindMerge.twMerge(clsx.clsx(s))}var ee="onyx-vlist:";function te(s,V){let r=0,l=s.length-2;for(;r<=l;){let a=r+l>>1;if(s[a+1]<=V)r=a+1;else if(s[a]>V)l=a-1;else return a}return Math.max(0,r)}function re(s,V){let{items:r,itemHeight:l,estimatedItemHeight:a=48,direction:B="vertical",overscan:x=3,onReachEnd:T,reachEndThreshold:A=120,isLoading:X,onScroll:k,onVisibleRangeChange:q,scrollRestorationId:y}=s,i=B==="vertical",c=typeof l=="number",m=c?l:0,d=react.useRef(null),[f,z]=react.useState(300);react.useEffect(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([g])=>{let v=i?g.contentRect.height:g.contentRect.width;v>0&&z(v);});t.observe(e);let n=e.getBoundingClientRect(),o=i?n.height:n.width;return o>0&&z(o),()=>t.disconnect()},[i]);let[h,K]=react.useState(0);react.useEffect(()=>{if(!y)return;let e=d.current;if(e)try{let t=localStorage.getItem(ee+y);if(t!==null){let n=parseFloat(t);!Number.isNaN(n)&&n>0&&requestAnimationFrame(()=>{i?e.scrollTop=n:e.scrollLeft=n;});}}catch{}},[]);let P=react.useRef(false),F=react.useRef(r.length);r.length!==F.current&&(F.current=r.length,P.current=false);let C=react.useCallback(()=>{let e=d.current;if(!e)return;let t=i?e.scrollTop:e.scrollLeft;if(K(t),k?.(t),y)try{localStorage.setItem(ee+y,String(t));}catch{}T&&!X&&(i?e.scrollHeight-e.clientHeight:e.scrollWidth-e.clientWidth)-t<=A&&(P.current||(P.current=true,T()));},[i,k,y,T,X,A]);react.useEffect(()=>{let e=d.current;if(e)return e.addEventListener("scroll",C,{passive:true}),()=>e.removeEventListener("scroll",C)},[C]),react.useEffect(()=>{if(i)return;let e=d.current;if(!e)return;let t=n=>{Math.abs(n.deltaX)>=Math.abs(n.deltaY)||(n.preventDefault(),e.scrollLeft+=n.deltaY);};return e.addEventListener("wheel",t,{passive:false}),()=>e.removeEventListener("wheel",t)},[i]),react.useEffect(()=>{if(i)return;let e=d.current;if(!e)return;let t=5,n=false,o=false,g=0,v=0,W=S=>{S.target.closest("button,a,input,select,textarea,[role=button],[role=checkbox],[role=radio],[role=option]")||S.button===0&&(n=true,o=false,g=S.clientX,v=e.scrollLeft,e.setPointerCapture(S.pointerId));},L=S=>{if(!n)return;let J=g-S.clientX;if(!o){if(Math.abs(J)<t)return;o=true,e.style.cursor="grabbing",e.style.userSelect="none";}e.scrollLeft=v+J;},U=S=>{if(n){n=false,e.style.cursor="",e.style.userSelect="";try{e.releasePointerCapture(S.pointerId);}catch{}}};return e.addEventListener("pointerdown",W),e.addEventListener("pointermove",L),e.addEventListener("pointerup",U),e.addEventListener("pointercancel",U),()=>{e.removeEventListener("pointerdown",W),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",U),e.removeEventListener("pointercancel",U);}},[i]);let E=react.useRef(new Map),[j,_]=react.useState(0),G=react.useCallback((e,t)=>{if(c||!t)return;let n=i?t.offsetHeight:t.offsetWidth;n>0&&E.current.get(e)!==n&&(E.current.set(e,n),_(o=>o+1));},[c,i]),N=react.useRef(r);N.current!==r&&(N.current=r,c||(E.current=new Map));let p=react.useMemo(()=>{if(c)return [];let e=new Array(r.length+1);e[0]=0;for(let t=0;t<r.length;t++){let n=E.current.get(t),o;n!==void 0?o=n:typeof l=="function"?o=r[t]!==void 0?l(r[t],t):a:o=a,e[t+1]=e[t]+o;}return e},[c,r,l,a,j]),u=react.useCallback(e=>c?e*m:p[e]??0,[c,m,p]),M=react.useCallback(e=>{if(c)return m;let t=E.current.get(e);return t!==void 0?t:typeof l=="function"&&r[e]!==void 0?l(r[e],e):a},[c,m,l,r,a,j]),O,b,R;if(c){O=m*r.length;let e=Math.floor(h/m),t=Math.ceil((h+f)/m);b=Math.max(0,e-x),R=Math.min(r.length-1,t+x-1);}else if(O=p[r.length]??0,p.length>1){let e=te(p,h);b=Math.max(0,e-x);let t=e;for(;t<r.length&&p[t]<h+f;)t++;R=Math.min(r.length-1,t+x-1);}else b=0,R=Math.min(r.length-1,x*2);b=Math.max(0,b),R=Math.max(b,Math.min(r.length-1,R));let D=react.useRef({start:-1,end:-1});return react.useEffect(()=>{let e,t;if(c&&m>0)e=Math.max(0,Math.floor(h/m)),t=Math.min(r.length-1,Math.ceil((h+f)/m)-1);else {for(e=te(p,h),t=e;t<r.length&&p[t]<h+f;)t++;t=Math.max(0,t-1);}(D.current.start!==e||D.current.end!==t)&&(D.current={start:e,end:t},q?.(e,t));}),react.useImperativeHandle(V,()=>({scrollToIndex(e,t="auto"){let n=d.current;if(!n)return;let o=u(e),g=M(e),v=i?n.clientHeight:n.clientWidth,W=i?n.scrollTop:n.scrollLeft,L;if(t==="start")L=o;else if(t==="end")L=o-v+g;else if(t==="center")L=o-(v-g)/2;else if(o<W)L=o;else if(o+g>W+v)L=o-v+g;else return;n.scrollTo({[i?"top":"left"]:Math.max(0,L),behavior:"smooth"});},scrollToOffset(e){let t=d.current;t&&t.scrollTo({[i?"top":"left"]:e,behavior:"smooth"});},getScrollOffset(){let e=d.current;return e?i?e.scrollTop:e.scrollLeft:0}}),[u,M,i]),{scrollerRef:d,startIndex:b,endIndex:R,totalSize:O,getItemOffset:u,getItemSize:M,measureItem:G}}function ae({text:s="Loading\u2026"}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-primary-400",children:[jsxRuntime.jsx("span",{"aria-hidden":true,className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-200 border-t-primary-500"}),jsxRuntime.jsx("span",{children:s})]})}function ce({text:s="No items"}){return jsxRuntime.jsxs("div",{className:"flex h-full min-h-[120px] flex-col items-center justify-center gap-2 text-sm text-primary-400",children:[jsxRuntime.jsx("svg",{"aria-hidden":true,xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 opacity-40",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),jsxRuntime.jsx("span",{children:s})]})}function ue(s,V){let{items:r,renderItem:l,getItemKey:a,itemHeight:B,direction:x="vertical",height:T="100%",width:A="100%",isLoading:X=false,loadingRenderer:k,loadingText:q,emptyRenderer:y,emptyText:i,itemClassName:c,className:m,style:d}=s,f=x==="vertical",z=typeof B!="number",{scrollerRef:h,startIndex:K,endIndex:P,totalSize:F,getItemOffset:C,getItemSize:E,measureItem:j}=re(s,V),_={position:"relative",overflowX:f?"hidden":"auto",overflowY:f?"auto":"hidden",height:T,width:A,cursor:f?void 0:"grab"},G={position:"relative",[f?"height":"width"]:F,[f?"width":"height"]:"100%",overflow:"hidden"},N=[];for(let u=K;u<=P;u++){let M=r[u];if(M===void 0)continue;let O=C(u),b=E(u),R=a?a(M,u):u,D={position:"absolute",[f?"top":"left"]:O,[f?"height":"width"]:z?void 0:b,[f?"width":"height"]:"100%",boxSizing:"border-box"};N.push(jsxRuntime.jsx("div",{role:"row","aria-rowindex":u+1,style:D,className:Q("onyx-vlist-item",c),ref:z?e=>j(u,e):void 0,children:l(M,u)},R));}let p=r.length===0;return jsxRuntime.jsxs("div",{ref:h,role:"grid","aria-rowcount":r.length,"data-virtual-list":true,"data-direction":x,className:Q("onyx-virtual-list",m),style:{..._,...d},children:[p?y?y():jsxRuntime.jsx(ce,{text:i}):jsxRuntime.jsx("div",{style:G,children:N}),X&&(k?k():jsxRuntime.jsx(ae,{text:q}))]})}var fe=react.forwardRef(ue);
2
+ exports.VirtualList=fe;
@@ -0,0 +1 @@
1
+ [data-virtual-list]{-webkit-overflow-scrolling:touch;scroll-behavior:auto;outline:none}.onyx-vlist-item{will-change:transform;contain:layout style}[data-virtual-list][data-direction=horizontal]{cursor:grab}[data-virtual-list]::-webkit-scrollbar{width:6px;height:6px}[data-virtual-list]::-webkit-scrollbar-track{background:transparent}[data-virtual-list]::-webkit-scrollbar-thumb{border-radius:9999px;background-color:color-mix(in srgb,currentColor 25%,transparent)}[data-virtual-list]::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,currentColor 40%,transparent)}
@@ -0,0 +1,5 @@
1
+ export { VirtualList_alias_3 as VirtualList } from '../_tsup-dts-rollup.cjs';
2
+ export { VirtualListHandle_alias_2 as VirtualListHandle } from '../_tsup-dts-rollup.cjs';
3
+ export { VirtualListProps_alias_2 as VirtualListProps } from '../_tsup-dts-rollup.cjs';
4
+ export { VirtualListAlign_alias_2 as VirtualListAlign } from '../_tsup-dts-rollup.cjs';
5
+ export { VirtualListDirection_alias_2 as VirtualListDirection } from '../_tsup-dts-rollup.cjs';
@@ -0,0 +1,5 @@
1
+ export { VirtualList_alias_3 as VirtualList } from '../_tsup-dts-rollup.js';
2
+ export { VirtualListHandle_alias_2 as VirtualListHandle } from '../_tsup-dts-rollup.js';
3
+ export { VirtualListProps_alias_2 as VirtualListProps } from '../_tsup-dts-rollup.js';
4
+ export { VirtualListAlign_alias_2 as VirtualListAlign } from '../_tsup-dts-rollup.js';
5
+ export { VirtualListDirection_alias_2 as VirtualListDirection } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,2 @@
1
+ import {forwardRef,useRef,useState,useEffect,useCallback,useMemo,useImperativeHandle}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs}from'react/jsx-runtime';function Q(...s){return twMerge(clsx(s))}var ee="onyx-vlist:";function te(s,V){let r=0,l=s.length-2;for(;r<=l;){let a=r+l>>1;if(s[a+1]<=V)r=a+1;else if(s[a]>V)l=a-1;else return a}return Math.max(0,r)}function re(s,V){let{items:r,itemHeight:l,estimatedItemHeight:a=48,direction:B="vertical",overscan:x=3,onReachEnd:T,reachEndThreshold:A=120,isLoading:X,onScroll:k,onVisibleRangeChange:q,scrollRestorationId:y}=s,i=B==="vertical",c=typeof l=="number",m=c?l:0,d=useRef(null),[f,z]=useState(300);useEffect(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([g])=>{let v=i?g.contentRect.height:g.contentRect.width;v>0&&z(v);});t.observe(e);let n=e.getBoundingClientRect(),o=i?n.height:n.width;return o>0&&z(o),()=>t.disconnect()},[i]);let[h,K]=useState(0);useEffect(()=>{if(!y)return;let e=d.current;if(e)try{let t=localStorage.getItem(ee+y);if(t!==null){let n=parseFloat(t);!Number.isNaN(n)&&n>0&&requestAnimationFrame(()=>{i?e.scrollTop=n:e.scrollLeft=n;});}}catch{}},[]);let P=useRef(false),F=useRef(r.length);r.length!==F.current&&(F.current=r.length,P.current=false);let C=useCallback(()=>{let e=d.current;if(!e)return;let t=i?e.scrollTop:e.scrollLeft;if(K(t),k?.(t),y)try{localStorage.setItem(ee+y,String(t));}catch{}T&&!X&&(i?e.scrollHeight-e.clientHeight:e.scrollWidth-e.clientWidth)-t<=A&&(P.current||(P.current=true,T()));},[i,k,y,T,X,A]);useEffect(()=>{let e=d.current;if(e)return e.addEventListener("scroll",C,{passive:true}),()=>e.removeEventListener("scroll",C)},[C]),useEffect(()=>{if(i)return;let e=d.current;if(!e)return;let t=n=>{Math.abs(n.deltaX)>=Math.abs(n.deltaY)||(n.preventDefault(),e.scrollLeft+=n.deltaY);};return e.addEventListener("wheel",t,{passive:false}),()=>e.removeEventListener("wheel",t)},[i]),useEffect(()=>{if(i)return;let e=d.current;if(!e)return;let t=5,n=false,o=false,g=0,v=0,W=S=>{S.target.closest("button,a,input,select,textarea,[role=button],[role=checkbox],[role=radio],[role=option]")||S.button===0&&(n=true,o=false,g=S.clientX,v=e.scrollLeft,e.setPointerCapture(S.pointerId));},L=S=>{if(!n)return;let J=g-S.clientX;if(!o){if(Math.abs(J)<t)return;o=true,e.style.cursor="grabbing",e.style.userSelect="none";}e.scrollLeft=v+J;},U=S=>{if(n){n=false,e.style.cursor="",e.style.userSelect="";try{e.releasePointerCapture(S.pointerId);}catch{}}};return e.addEventListener("pointerdown",W),e.addEventListener("pointermove",L),e.addEventListener("pointerup",U),e.addEventListener("pointercancel",U),()=>{e.removeEventListener("pointerdown",W),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",U),e.removeEventListener("pointercancel",U);}},[i]);let E=useRef(new Map),[j,_]=useState(0),G=useCallback((e,t)=>{if(c||!t)return;let n=i?t.offsetHeight:t.offsetWidth;n>0&&E.current.get(e)!==n&&(E.current.set(e,n),_(o=>o+1));},[c,i]),N=useRef(r);N.current!==r&&(N.current=r,c||(E.current=new Map));let p=useMemo(()=>{if(c)return [];let e=new Array(r.length+1);e[0]=0;for(let t=0;t<r.length;t++){let n=E.current.get(t),o;n!==void 0?o=n:typeof l=="function"?o=r[t]!==void 0?l(r[t],t):a:o=a,e[t+1]=e[t]+o;}return e},[c,r,l,a,j]),u=useCallback(e=>c?e*m:p[e]??0,[c,m,p]),M=useCallback(e=>{if(c)return m;let t=E.current.get(e);return t!==void 0?t:typeof l=="function"&&r[e]!==void 0?l(r[e],e):a},[c,m,l,r,a,j]),O,b,R;if(c){O=m*r.length;let e=Math.floor(h/m),t=Math.ceil((h+f)/m);b=Math.max(0,e-x),R=Math.min(r.length-1,t+x-1);}else if(O=p[r.length]??0,p.length>1){let e=te(p,h);b=Math.max(0,e-x);let t=e;for(;t<r.length&&p[t]<h+f;)t++;R=Math.min(r.length-1,t+x-1);}else b=0,R=Math.min(r.length-1,x*2);b=Math.max(0,b),R=Math.max(b,Math.min(r.length-1,R));let D=useRef({start:-1,end:-1});return useEffect(()=>{let e,t;if(c&&m>0)e=Math.max(0,Math.floor(h/m)),t=Math.min(r.length-1,Math.ceil((h+f)/m)-1);else {for(e=te(p,h),t=e;t<r.length&&p[t]<h+f;)t++;t=Math.max(0,t-1);}(D.current.start!==e||D.current.end!==t)&&(D.current={start:e,end:t},q?.(e,t));}),useImperativeHandle(V,()=>({scrollToIndex(e,t="auto"){let n=d.current;if(!n)return;let o=u(e),g=M(e),v=i?n.clientHeight:n.clientWidth,W=i?n.scrollTop:n.scrollLeft,L;if(t==="start")L=o;else if(t==="end")L=o-v+g;else if(t==="center")L=o-(v-g)/2;else if(o<W)L=o;else if(o+g>W+v)L=o-v+g;else return;n.scrollTo({[i?"top":"left"]:Math.max(0,L),behavior:"smooth"});},scrollToOffset(e){let t=d.current;t&&t.scrollTo({[i?"top":"left"]:e,behavior:"smooth"});},getScrollOffset(){let e=d.current;return e?i?e.scrollTop:e.scrollLeft:0}}),[u,M,i]),{scrollerRef:d,startIndex:b,endIndex:R,totalSize:O,getItemOffset:u,getItemSize:M,measureItem:G}}function ae({text:s="Loading\u2026"}){return jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-primary-400",children:[jsx("span",{"aria-hidden":true,className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-200 border-t-primary-500"}),jsx("span",{children:s})]})}function ce({text:s="No items"}){return jsxs("div",{className:"flex h-full min-h-[120px] flex-col items-center justify-center gap-2 text-sm text-primary-400",children:[jsx("svg",{"aria-hidden":true,xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 opacity-40",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),jsx("span",{children:s})]})}function ue(s,V){let{items:r,renderItem:l,getItemKey:a,itemHeight:B,direction:x="vertical",height:T="100%",width:A="100%",isLoading:X=false,loadingRenderer:k,loadingText:q,emptyRenderer:y,emptyText:i,itemClassName:c,className:m,style:d}=s,f=x==="vertical",z=typeof B!="number",{scrollerRef:h,startIndex:K,endIndex:P,totalSize:F,getItemOffset:C,getItemSize:E,measureItem:j}=re(s,V),_={position:"relative",overflowX:f?"hidden":"auto",overflowY:f?"auto":"hidden",height:T,width:A,cursor:f?void 0:"grab"},G={position:"relative",[f?"height":"width"]:F,[f?"width":"height"]:"100%",overflow:"hidden"},N=[];for(let u=K;u<=P;u++){let M=r[u];if(M===void 0)continue;let O=C(u),b=E(u),R=a?a(M,u):u,D={position:"absolute",[f?"top":"left"]:O,[f?"height":"width"]:z?void 0:b,[f?"width":"height"]:"100%",boxSizing:"border-box"};N.push(jsx("div",{role:"row","aria-rowindex":u+1,style:D,className:Q("onyx-vlist-item",c),ref:z?e=>j(u,e):void 0,children:l(M,u)},R));}let p=r.length===0;return jsxs("div",{ref:h,role:"grid","aria-rowcount":r.length,"data-virtual-list":true,"data-direction":x,className:Q("onyx-virtual-list",m),style:{..._,...d},children:[p?y?y():jsx(ce,{text:i}):jsx("div",{style:G,children:N}),X&&(k?k():jsx(ae,{text:q}))]})}var fe=forwardRef(ue);
2
+ export{fe as VirtualList};