@kodiak-finance/orderly-chart 2.8.18 → 2.8.19-rc.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.
package/dist/index.js CHANGED
@@ -1,2 +1,2299 @@
1
- 'use strict';var react=require('react'),recharts=require('recharts'),orderlyI18n=require('@kodiak-finance/orderly-i18n'),orderlyUi=require('@kodiak-finance/orderly-ui'),orderlyUtils=require('@kodiak-finance/orderly-utils'),jsxRuntime=require('react/jsx-runtime');var Kt=Object.create;var mt=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Et=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _t(e))!$t.call(t,r)&&r!==o&&mt(t,r,{get:()=>e[r],enumerable:!(a=zt(e,r))||a.enumerable});return t};var Wt=(t,e,o)=>(o=t!=null?Kt(Gt(t)):{},Et(!t||!t.__esModule?mt(o,"default",{value:t,enumerable:true}):o,t));var Ot=J(it=>{Object.defineProperty(it,"__esModule",{value:true});Object.defineProperty(it,"default",{enumerable:true,get:function(){return Fr}});function Dt(t,e){return {handler:t,config:e}}Dt.withOptions=function(t,e=()=>({})){let o=function(a){return {__options:a,handler:t(a),config:e(a)}};return o.__isOptionsFunction=true,o.__pluginFunction=t,o.__configFunction=e,o};var Fr=Dt;});var St=J(nt=>{Object.defineProperty(nt,"__esModule",{value:true});Object.defineProperty(nt,"default",{enumerable:true,get:function(){return Ar}});var kr=Pr(Ot());function Pr(t){return t&&t.__esModule?t:{default:t}}var Ar=kr.default;});var Vt=J((Hn,It)=>{var st=St();It.exports=(st.__esModule?st:{default:st}).default;});var O=t=>{let e=Math.abs(t),o=e===0?0:e<=10?2:e<=100?1:0,a=orderlyUtils.numberToHumanStyle(e,o);return t<0?`-${a}`:a};var w=t=>{let{label:e,value:o,prefix:a,unit:r="USDC",coloring:i=false,dp:n,rm:s}=t;return jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",className:t.titleClassName,children:[a,jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:r,as:"div",size:"sm",coloring:i,showIdentifier:i,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:s,dp:n,children:o})]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",intensity:54,weight:"semibold",children:e})]})};var ft=()=>{let t=document.documentElement,e=getComputedStyle(t);return {primary:K(e.getPropertyValue("--oui-color-primary")),primaryLight:K(e.getPropertyValue("--oui-color-primary-light")),secondary:K(e.getPropertyValue("--oui-color-secondary")),success:K(e.getPropertyValue("--oui-color-success")),warning:K(e.getPropertyValue("--oui-color-warning")),danger:K(e.getPropertyValue("--oui-color-danger")),info:K(e.getPropertyValue("--oui-color-info")),loss:K(e.getPropertyValue("--oui-color-trading-loss")),profit:K(e.getPropertyValue("--oui-color-trading-profit"))}},K=t=>`rgb(${t.split(" ").join(",")})`;var p=t=>react.useMemo(()=>{let o=ft();return {profit:t?.profit||o.profit,loss:t?.loss||o.loss,primary:o.primary,primaryLight:o.primaryLight}},[t]);var ne=t=>{let{fill:e,x:o,y:a,width:r,height:i}=t,n=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:o,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:e})},se=t=>{let{x:e,y:o,stroke:a,payload:r,index:i,width:n,containerWidth:s}=t,{t:c}=orderlyI18n.useTranslation(),l=i===0?48:s>0?s-10:n+r.offset;return jsxRuntime.jsx("g",{transform:`translate(${l},${o-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:i===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?r.value:c("chart.now")})})},le=t=>{let{width:e,height:o,stroke:a,fill:r}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ce=t=>{let{active:e,payload:o,label:a}=t,r=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=orderlyI18n.useTranslation();return e&&o&&o.length?jsxRuntime.jsx(w,{label:a===r.current?i("chart.now"):a,value:o[0].value,coloring:true}):null},me=t=>{let{invisible:e,data:o,responsiveContainerProps:a}=t,r=p(t.colors),i=react.useRef(0);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:orderlyUi.cn(e&&"chart-invisible"),onResize:n=>{i.current=n;},...a,children:jsxRuntime.jsxs(recharts.BarChart,{data:o,margin:{left:-10,top:10,right:10,bottom:30},children:[!e&&jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(le,{}),content:jsxRuntime.jsx(ce,{})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!e&&jsxRuntime.jsx(recharts.Bar,{dataKey:"pnl",shape:jsxRuntime.jsx(ne,{}),children:o.map((n,s)=>jsxRuntime.jsx(recharts.Cell,{fill:n.pnl>0?r.profit:r.loss},`cell-${s}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:n=>O(n),tickLine:false,axisLine:false,dataKey:"pnl"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:o.length-2,height:1,tick:jsxRuntime.jsx(se,{containerWidth:i.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var z=t=>{let{x:e,y:o,stroke:a,payload:r,index:i}=t,{t:n}=orderlyI18n.useTranslation();return jsxRuntime.jsx("g",{transform:`translate(${e},${o-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?r.value:n("chart.now")})})};var Pe=t=>{let{active:e,payload:o,label:a}=t,r=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=orderlyI18n.useTranslation();return e&&o&&o.length?jsxRuntime.jsx(w,{label:a===r.current?i("chart.now"):a,value:o[0].value,coloring:true}):null},Ae=t=>{let e=[];return t?.reduce((o,a)=>(o+=a.pnl,e.push({...a,pnl:o,_pnl:a.pnl}),o),0),e},Re=t=>{let{responsiveContainerProps:e}=t,o=p(t.colors),{isMobile:a}=orderlyUi.useScreen(),r=react.useMemo(()=>Ae(t.data),[t.data]),i=jsxRuntime.jsxs(recharts.LineChart,{data:r,margin:{top:20,right:10,left:-10,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(z,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:O}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(Pe,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"pnl",stroke:o.primary,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...e,children:i})};var _e=t=>{let{active:e,payload:o,label:a}=t,r=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=orderlyI18n.useTranslation();return e&&o&&o.length?jsxRuntime.jsx(w,{label:a===r.current?i("chart.now"):a,value:o[0].value,coloring:true}):null},Ge=t=>{let e=[];return t?.reduce((o,a)=>(o+=a.pnl,e.push({...a,pnl:o,_pnl:a.pnl}),o),0),e},$e=t=>{let{responsiveContainerProps:e}=t,o=p(t.colors),{isMobile:a}=orderlyUi.useScreen(),r=react.useId(),i=react.useMemo(()=>Ge(t.data),[t.data]),n=jsxRuntime.jsxs(recharts.AreaChart,{data:i,margin:{top:20,right:10,left:-10,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(z,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:O}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(_e,{})}),!t.invisible&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{stopColor:"#608CFF",offset:"0%",stopOpacity:.5}),jsxRuntime.jsx("stop",{stopColor:"#608CFF",offset:"100%",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"pnl",stroke:o.primary,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${r})`})]})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...e,children:n})};var G=({title:t="No Data Available",description:e="No data to display for the selected period",height:o="300px",className:a})=>jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-flex oui-items-center oui-justify-center oui-bg-base-8",a),style:{height:o},children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"center",gap:3,className:"oui-text-center",children:[jsxRuntime.jsx(orderlyUi.BarChartIcon,{}),jsxRuntime.jsx(orderlyUi.Text,{as:"div",size:"sm",weight:"semibold",className:"oui-text-base-contrast-100",children:t}),jsxRuntime.jsx(orderlyUi.Text,{as:"div",size:"xs",className:"oui-text-base-contrast-54",children:e})]})});var lo=t=>{let{fill:e,x:o,y:a,width:r,height:i}=t,n=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:o,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:e})},co=t=>{let{width:e,height:o}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},xt=t=>`${t>0?"+":""}${t.toFixed(2)}`,mo=(t,e)=>t===0?"inherit":t>0?e.profit:e.loss,uo=t=>e=>{let{active:o,payload:a,label:r}=e,i=p();if(o&&a&&a.length>=1){let s=a.find(x=>x.dataKey==="pnl")?.value??0,c=r,l=mo(s,i);return jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[c,":"]}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",style:{color:l},children:[xt(s)," USDC"]})]}),t&&jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",children:[(()=>{let P=a.find(m=>m.dataKey==="cumulativePnL")?.value??0;return xt(P)})()," ","USDC"]})]})]})}return null},po=(t,e,o=false)=>{if(t<=12&&!o)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,o&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(e==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(e==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(e==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},fo=t=>{let e=0;return t.map(o=>(e+=o.pnl,{...o,cumulativePnL:e}))},ho=t=>{let{data:e,aggregationWindow:o="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n,showCumulative:s=true}=t,c=p(t.colors),l=react.useMemo(()=>fo(e),[e]),x=react.useMemo(()=>po(l.length,o,a),[l.length,o,a]),P=react.useMemo(()=>{if(l.length===0)return [0,1];let m=l.map(I=>I.pnl),g=s?l.map(I=>I.cumulativePnL):[],D=s?[...m,...g,0]:[...m,0],R=Math.min(...D),E=Math.max(...D),A=E-R;if(A===0)return [0,1];let F=A*.1,S=R-F,V=E+F,M=Math.pow(10,Math.floor(Math.log10(A))),T=Math.ceil((V-S)/5/M)*M,k=Math.floor(S/T)*T,Y=Math.ceil(V/T)*T;return [k,Y]},[l,s]);return r||l.length===0?jsxRuntime.jsx(G,{title:"No P&L Data",description:"No profit and loss data available for the selected period",height:"100%",className:n}):jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",n),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxRuntime.jsxs(recharts.ComposedChart,{data:l,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"cumulativeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"5%",stopColor:"#608CFF",stopOpacity:.4}),jsxRuntime.jsx("stop",{offset:"95%",stopColor:"#608CFF",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(co,{}),content:uo(s)}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.3)",strokeWidth:2,strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.YAxis,{domain:P,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>yo(m),width:45}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:x,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.Bar,{dataKey:"pnl",shape:jsxRuntime.jsx(lo,{}),minPointSize:1,isAnimationActive:false,children:l.map((m,g)=>jsxRuntime.jsx(recharts.Cell,{fill:m.pnl===0?"rgba(255,255,255,0.2)":m.pnl>0?c.profit:c.loss},`cell-${g}`))}),s&&jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"cumulativePnL",fill:"url(#cumulativeGradient)",stroke:"none",isAnimationActive:false}),s&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"cumulativePnL",stroke:c.primary,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function yo(t){let e=["","K","M","B","T"],o=0,a=Math.abs(t);for(;a>=1e3&&o<e.length-1;)a/=1e3,o++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${e[o]}`}var No=t=>{let{fill:e,x:o,y:a,width:r,height:i}=t,n=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:o,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:e})},Lo=t=>{let{width:e,height:o}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},vt=t=>`${t>0?"+":""}${t}`,Do=t=>e=>{let{active:o,payload:a,label:r}=e;if(o&&a&&a.length>=1){let n=a.find(c=>c.dataKey==="volume")?.value??0;return jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[r,":"]}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",children:[vt(n)," USDC"]})]}),t&&jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",children:[(()=>{let l=a.find(x=>x.dataKey==="cumulativeVolume")?.value??0;return vt(l)})()," ","USDC"]})]})]})}return null},Oo=(t,e,o=false)=>{if(t<=12&&!o)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,o&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(e==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(e==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(e==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},So=t=>{let e=0;return t.map(o=>(e+=o.volume,{...o,cumulativeVolume:e}))},Io=t=>{let{data:e,aggregationWindow:o="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n,showCumulative:s=false}=t,c=p(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),l=react.useMemo(()=>So(e),[e]),x=react.useMemo(()=>Oo(l.length,o,a),[l.length,o,a]),P=react.useMemo(()=>{if(l.length===0)return [0,1];let m=l.map(M=>M.volume),g=s?l.map(M=>M.cumulativeVolume):[],D=Math.max(...s?[...m,...g]:m,0),R=D;if(R===0)return [0,1];let E=R*.1,A=D+E,F=Math.pow(10,Math.floor(Math.log10(R))),S=Math.ceil(A/5/F)*F;return [0,Math.ceil(A/S)*S]},[l,s]);return r||l.length===0?jsxRuntime.jsx(G,{title:"No Volume Data",description:"No trading volume data available for the selected period",height:"100%",className:n}):jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",n),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxRuntime.jsxs(recharts.ComposedChart,{data:l,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"volumeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"5%",stopColor:"#00B49E",stopOpacity:.4}),jsxRuntime.jsx("stop",{offset:"95%",stopColor:"#00B49E",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(Lo,{}),content:Do(s)}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsxRuntime.jsx(recharts.YAxis,{domain:P,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>Vo(m),width:45}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:x,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.Bar,{dataKey:"volume",shape:jsxRuntime.jsx(No,{}),minPointSize:1,isAnimationActive:false,children:l.map((m,g)=>jsxRuntime.jsx(recharts.Cell,{fill:m.volume===0?"rgba(255,255,255,0.2)":c.profit,opacity:.8},`cell-${g}`))}),s&&jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"cumulativeVolume",fill:"url(#volumeGradient)",stroke:"none",isAnimationActive:false}),s&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"cumulativeVolume",stroke:c.profit,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function Vo(t){let e=["","K","M","B","T"],o=0,a=Math.abs(t);for(;a>=1e3&&o<e.length-1;)a/=1e3,o++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${e[o]}`}var Qo=t=>{let{fill:e,x:o,y:a,width:r,height:i}=t,n=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:o,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:e})},Jo=t=>{let{width:e,height:o}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},kt=t=>`${t>0?"+":""}${t.toFixed(2)}`,Zo=t=>e=>{let{active:o,payload:a,label:r}=e;if(o&&a&&a.length>=1){let n=a.find(c=>c.dataKey==="fees")?.value??0;return jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[r,":"]}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",children:[kt(n)," USDC"]})]}),t&&jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxRuntime.jsxs("span",{className:"oui-font-semibold",children:[(()=>{let l=a.find(x=>x.dataKey==="cumulativeFees")?.value??0;return kt(l)})()," ","USDC"]})]})]})}return null},jo=(t,e,o=false)=>{if(t<=12&&!o)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,o&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(e==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(e==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(e==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},ta=t=>{let e=0;return t.map(o=>(e+=o.fees,{...o,cumulativeFees:e}))},ea=t=>{let{data:e,aggregationWindow:o="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n,showCumulative:s=false}=t,c=p(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),l=react.useMemo(()=>ta(e),[e]),x=react.useMemo(()=>jo(l.length,o,a),[l.length,o,a]),P=react.useMemo(()=>{if(l.length===0)return {domain:[0,1],ticks:[0,1]};let m=l.map(B=>B.fees),g=s?l.map(B=>B.cumulativeFees):[],D=s?[...m,...g,0]:[...m,0],R=Math.min(...D),A=Math.max(...D)-R;if(A===0)return {domain:[0,1],ticks:[0,1]};let F=A*.1,S=R-F,V=0,M=Math.pow(10,Math.floor(Math.log10(A))),T=M,k=Math.abs(V-S);for(let B of [1,2,2.5,5]){let lt=M*B,ct=Math.ceil(k/lt);if(ct>=4&&ct<=6){T=lt;break}}let Y=Math.floor(S/T)*T,I=[];for(let B=Y;B<V;B+=T)I.push(Number(B.toFixed(10)));return I.push(0),{domain:[Y,0],ticks:I}},[l,s]);return r||l.length===0?jsxRuntime.jsx(G,{title:"No Fees Data",description:"No fees data available for the selected period",height:"100%",className:n}):jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",n),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxRuntime.jsxs(recharts.ComposedChart,{data:l,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"feesGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"5%",stopColor:"#FF6B6B",stopOpacity:.4}),jsxRuntime.jsx("stop",{offset:"95%",stopColor:"#FF6B6B",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(Jo,{}),content:Zo(s)}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsxRuntime.jsx(recharts.YAxis,{domain:P.domain,ticks:P.ticks,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>oa(m),width:45}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:x,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.Bar,{dataKey:"fees",shape:jsxRuntime.jsx(Qo,{}),minPointSize:1,isAnimationActive:false,children:l.map((m,g)=>jsxRuntime.jsx(recharts.Cell,{fill:m.fees===0?"rgba(255,255,255,0.2)":c.loss,opacity:.8},`cell-${g}`))}),s&&jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"cumulativeFees",fill:"url(#feesGradient)",stroke:"none",isAnimationActive:false}),s&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"cumulativeFees",stroke:c.loss,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function oa(t){let e=["","K","M","B","T"],o=0,a=Math.abs(t);for(;a>=1e3&&o<e.length-1;)a/=1e3,o++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${e[o]}`}var da=t=>{let{width:e,height:o}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},fa=t=>{let{active:e,payload:o,label:a}=t;if(e&&o&&o.length>=1){let r=o[0].payload;return r.close!==null&&r.close!==void 0?jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Open:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:r.open?.toFixed(2)??"--"})]}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"High:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:r.high?.toFixed(2)??"--"})]}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Low:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:r.low?.toFixed(2)??"--"})]}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Close:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:r.close.toFixed(2)})]}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Time:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:a})]})]}):jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54",children:"Price data unavailable"}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"Time:"}),jsxRuntime.jsx("span",{className:"oui-font-semibold",children:a})]})]})}return null},ha=(t,e,o=false)=>{if(t<=12&&!o)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,o&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(e==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(e==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(e==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r};function ya(t){return t.toFixed(2)}var Ca=t=>{let {data:e,aggregationWindow:o="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n}=t;p();let c=react.useMemo(()=>ha(e.length,o,a),[e.length,o,a]),l=react.useMemo(()=>{if(e.length===0)return {domain:[0,1],ticks:[0,1]};let x=e.map(k=>k.close).filter(k=>k!=null);if(x.length===0)return {domain:[0,1],ticks:[0,1]};let P=Math.min(...x),m=Math.max(...x),g=m-P;if(g===0)return {domain:[P-1,m+1],ticks:[P-1,m+1]};let D=g*.1,R=P-D,E=m+D,A=Math.pow(10,Math.floor(Math.log10(g))),F=A,S=E-R;for(let k of [1,2,2.5,5]){let Y=A*k,I=Math.ceil(S/Y);if(I>=4&&I<=6){F=Y;break}}let V=Math.floor(R/F)*F,M=Math.ceil(E/F)*F,T=[];for(let k=V;k<=M;k+=F)T.push(Number(k.toFixed(10)));return {domain:[V,M],ticks:T}},[e]);return r||e.length===0?jsxRuntime.jsx(G,{title:"No Price Data",description:"No price data available for the selected period",height:"100%",className:n}):jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",n),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxRuntime.jsxs(recharts.ComposedChart,{data:e,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(da,{}),content:jsxRuntime.jsx(fa,{})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsxRuntime.jsx(recharts.YAxis,{domain:l.domain,ticks:l.ticks,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:ya,width:50}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:c,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"close",stroke:"#00B49E",strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};var Ta=t=>{let{active:e,payload:o,label:a}=t,r=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=orderlyI18n.useTranslation();return e&&o&&o.length?jsxRuntime.jsx(w,{label:a===r.current?i("chart.now"):a,value:o[0].value}):null},wa=t=>{let{responsiveContainerProps:e}=t,o=p(t.colors),a=react.useId(),{isMobile:r}=orderlyUi.useScreen(),i=r?jsxRuntime.jsxs(recharts.AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(z,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:n=>O(n)}),!t.invisible&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsxRuntime.jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"account_value",stroke:o.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`})]})]}):jsxRuntime.jsxs(recharts.LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(z,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:O}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(Ta,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"account_value",stroke:o.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...e,children:i})};var $a=t=>{let{active:e,payload:o,label:a}=t,r=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=orderlyI18n.useTranslation();return e&&o&&o.length?jsxRuntime.jsx(w,{label:a===r.current?i("chart.now"):a,value:o[0].value}):null},Ea=t=>{let{responsiveContainerProps:e}=t,o=p(t.colors),a=react.useId(),{isMobile:r}=orderlyUi.useScreen(),i=jsxRuntime.jsxs(recharts.AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(z,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:O}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx($a,{})}),!t.invisible&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsxRuntime.jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"account_value",stroke:o.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`})]})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...e,children:i})};var ar=t=>{let{fill:e,x:o,y:a,width:r,height:i,opacity:n}=t,s=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:o,y:i>0?a:a+i,width:r,height:s,stroke:"none",fill:e,opacity:n})},rr=t=>{let{width:e,height:o,payload:a,stroke:r,fill:i}=t;return a?.[0]?.value===0?null:jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ir=t=>{let{active:e,payload:o,label:a,tooltip:r}=t;return o?.[0]?.value===0?null:e&&o&&o.length?jsxRuntime.jsx(w,{label:a,value:o[0].value,titleClassName:"oui-gap-4",rm:r?.rm,dp:r?.dp}):null},nr=t=>{let e=p(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),o=t.data?.reduce((i,n)=>i+n.volume,0)===0,a=t.data?.reduce((i,n)=>i>n.volume?i:n.volume,0),r=a<=10?2:a<=100?1:0;return jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn(t.className),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{children:jsxRuntime.jsxs(recharts.BarChart,{data:t.data,margin:{left:-0,top:6,right:0,bottom:20},children:[jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(rr,{}),content:jsxRuntime.jsx(ir,{tooltip:t.tooltip})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"#000"}),jsxRuntime.jsx(recharts.Bar,{dataKey:"volume",shape:jsxRuntime.jsx(ar,{}),minPointSize:1,children:t.data.map((i,n)=>jsxRuntime.jsx(recharts.Cell,{fill:i.volume>0?e.profit:e.loss,opacity:i.opacity},`cell-${n}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(i,n)=>o?`${n*100}`:sr(i,r),width:45}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"rgb(229, 231, 235)",strokeOpacity:.2})]})})})};function sr(t,e=0){let o=["","K","M","B","T"],a=0;for(;t>=1e3&&a<o.length-1;)t/=1e3,a++;return `${lr(t,e)}${o[a]}`}function lr(t,e){let o=t.toString(),a=o.indexOf(".");if(a===-1||e===0)return o.split(".")[0];let r=a+e+1;return o.slice(0,r)}var xr=t=>{let{width:e,height:o}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:o,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},gr=t=>{let{active:e,payload:o,label:a}=t;return e&&o&&o.length>0?jsxRuntime.jsxs(orderlyUi.Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-font-semibold",children:a}),o.map((r,i)=>jsxRuntime.jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxRuntime.jsxs("span",{style:{color:r.color},className:"oui-font-semibold",children:[r.name,":"]}),jsxRuntime.jsx("span",{children:r.value?.toFixed(2)||0})]},i))]}):null},vr=({volumeData:t,feesData:e,priceData:o,aggregationWindow:a,includeFees:r,className:i})=>{let n=react.useMemo(()=>{let s=new Map;return t.forEach(c=>{s.set(c.date,{...s.get(c.date),date:c.date,volume:c.volume});}),e.forEach(c=>{s.set(c.date,{...s.get(c.date),date:c.date,fees:c.fees});}),o.forEach(c=>{s.set(c.date,{...s.get(c.date),date:c.date,open:c.open,high:c.high,low:c.low,close:c.close});}),Array.from(s.values())},[t,e,o]);return n.length===0?jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",i),children:jsxRuntime.jsx("div",{className:"oui-text-center oui-text-base-contrast-54 oui-py-10",children:"No data available"})}):jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-full oui-h-full",i),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.ComposedChart,{data:n,margin:{left:0,top:10,right:10,bottom:20},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{yAxisId:"left",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,width:45,label:{value:"Volume / Fees",angle:-90,position:"insideLeft"}}),jsxRuntime.jsx(recharts.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,width:50,label:{value:"Price",angle:90,position:"insideRight"}}),jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(xr,{}),content:jsxRuntime.jsx(gr,{})}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsxRuntime.jsx(recharts.Bar,{yAxisId:"left",dataKey:"volume",fill:"rgba(0, 180, 158, 0.6)",name:"Volume"}),jsxRuntime.jsx(recharts.Bar,{yAxisId:"left",dataKey:"fees",fill:"rgba(255, 107, 107, 0.6)",name:"Fees"}),jsxRuntime.jsx(recharts.Line,{yAxisId:"right",type:"natural",dataKey:"close",stroke:"#00B49E",strokeWidth:2,dot:false,isAnimationActive:false,name:"Price",strokeLinecap:"round",strokeLinejoin:"round"})]})})})};var Bt=Wt(Vt()),Rr=()=>(0, Bt.default)(function({addComponents:t,addBase:e}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});Object.defineProperty(exports,"Area",{enumerable:true,get:function(){return recharts.Area}});Object.defineProperty(exports,"AreaChart",{enumerable:true,get:function(){return recharts.AreaChart}});Object.defineProperty(exports,"Bar",{enumerable:true,get:function(){return recharts.Bar}});Object.defineProperty(exports,"BarChart",{enumerable:true,get:function(){return recharts.BarChart}});Object.defineProperty(exports,"Cell",{enumerable:true,get:function(){return recharts.Cell}});Object.defineProperty(exports,"Line",{enumerable:true,get:function(){return recharts.Line}});Object.defineProperty(exports,"LineChart",{enumerable:true,get:function(){return recharts.LineChart}});exports.AssetAreaChart=Ea;exports.AssetLineChart=wa;exports.ChartEmptyState=G;exports.CombinedFeesChart=ea;exports.CombinedPnLChart=ho;exports.CombinedPriceChart=Ca;exports.CombinedVolumeChart=Io;exports.PnLBarChart=me;exports.PnlAreaChart=$e;exports.PnlLineChart=Re;exports.UnifiedSymbolPerformanceChart=vr;exports.VolBarChart=nr;exports.chartPlugin=Rr;//# sourceMappingURL=index.js.map
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var recharts = require('recharts');
5
+ var orderlyI18n = require('@kodiak-finance/orderly-i18n');
6
+ var orderlyUi = require('@kodiak-finance/orderly-ui');
7
+ var orderlyUtils = require('@kodiak-finance/orderly-utils');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __commonJS = (cb, mod) => function __require() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
35
+
36
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/util/createPlugin.js
37
+ var require_createPlugin = __commonJS({
38
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/util/createPlugin.js"(exports) {
39
+ Object.defineProperty(exports, "__esModule", {
40
+ value: true
41
+ });
42
+ Object.defineProperty(exports, "default", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return _default;
46
+ }
47
+ });
48
+ function createPlugin(plugin2, config) {
49
+ return {
50
+ handler: plugin2,
51
+ config
52
+ };
53
+ }
54
+ createPlugin.withOptions = function(pluginFunction, configFunction = () => ({})) {
55
+ const optionsFunction = function(options) {
56
+ return {
57
+ __options: options,
58
+ handler: pluginFunction(options),
59
+ config: configFunction(options)
60
+ };
61
+ };
62
+ optionsFunction.__isOptionsFunction = true;
63
+ optionsFunction.__pluginFunction = pluginFunction;
64
+ optionsFunction.__configFunction = configFunction;
65
+ return optionsFunction;
66
+ };
67
+ var _default = createPlugin;
68
+ }
69
+ });
70
+
71
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/public/create-plugin.js
72
+ var require_create_plugin = __commonJS({
73
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/public/create-plugin.js"(exports) {
74
+ Object.defineProperty(exports, "__esModule", {
75
+ value: true
76
+ });
77
+ Object.defineProperty(exports, "default", {
78
+ enumerable: true,
79
+ get: function() {
80
+ return _default;
81
+ }
82
+ });
83
+ var _createPlugin = /* @__PURE__ */ _interop_require_default(require_createPlugin());
84
+ function _interop_require_default(obj) {
85
+ return obj && obj.__esModule ? obj : {
86
+ default: obj
87
+ };
88
+ }
89
+ var _default = _createPlugin.default;
90
+ }
91
+ });
92
+
93
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/plugin.js
94
+ var require_plugin = __commonJS({
95
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/plugin.js"(exports, module) {
96
+ var createPlugin = require_create_plugin();
97
+ module.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default;
98
+ }
99
+ });
100
+ var tickFormatter = (value) => {
101
+ const absValue = Math.abs(value);
102
+ const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;
103
+ const formatted = orderlyUtils.numberToHumanStyle(absValue, dp);
104
+ return value < 0 ? `-${formatted}` : formatted;
105
+ };
106
+ var OrderlyChartTooltip = (props) => {
107
+ const {
108
+ label,
109
+ value,
110
+ prefix,
111
+ unit = "USDC",
112
+ coloring = false,
113
+ dp,
114
+ rm
115
+ } = props;
116
+ return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Box, { intensity: 600, p: 3, r: "md", children: [
117
+ /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", className: props.titleClassName, children: [
118
+ prefix,
119
+ /* @__PURE__ */ jsxRuntime.jsx(
120
+ orderlyUi.Text.numeral,
121
+ {
122
+ unit,
123
+ as: "div",
124
+ size: "sm",
125
+ coloring,
126
+ showIdentifier: coloring,
127
+ unitClassName: "oui-text-base-contrast-54 oui-ml-1",
128
+ weight: "semibold",
129
+ rm,
130
+ dp,
131
+ children: value
132
+ }
133
+ )
134
+ ] }),
135
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "2xs", intensity: 54, weight: "semibold", children: label })
136
+ ] });
137
+ };
138
+
139
+ // src/utils/theme.ts
140
+ var getThemeColors = () => {
141
+ const root = document.documentElement;
142
+ const computedStyle = getComputedStyle(root);
143
+ const colors = {
144
+ primary: convertToRGB(
145
+ computedStyle.getPropertyValue("--oui-color-primary")
146
+ ),
147
+ primaryLight: convertToRGB(
148
+ computedStyle.getPropertyValue("--oui-color-primary-light")
149
+ ),
150
+ secondary: convertToRGB(
151
+ computedStyle.getPropertyValue("--oui-color-secondary")
152
+ ),
153
+ success: convertToRGB(
154
+ computedStyle.getPropertyValue("--oui-color-success")
155
+ ),
156
+ warning: convertToRGB(
157
+ computedStyle.getPropertyValue("--oui-color-warning")
158
+ ),
159
+ danger: convertToRGB(computedStyle.getPropertyValue("--oui-color-danger")),
160
+ info: convertToRGB(computedStyle.getPropertyValue("--oui-color-info")),
161
+ loss: convertToRGB(
162
+ computedStyle.getPropertyValue("--oui-color-trading-loss")
163
+ ),
164
+ profit: convertToRGB(
165
+ computedStyle.getPropertyValue("--oui-color-trading-profit")
166
+ )
167
+ };
168
+ return colors;
169
+ };
170
+ var convertToRGB = (color) => {
171
+ return `rgb(${color.split(" ").join(",")})`;
172
+ };
173
+
174
+ // src/orderly/useColors.ts
175
+ var useColors = (colors) => {
176
+ const _colors = react.useMemo(() => {
177
+ const themeColors = getThemeColors();
178
+ return {
179
+ profit: colors?.profit || themeColors.profit,
180
+ loss: colors?.loss || themeColors.loss,
181
+ primary: themeColors.primary,
182
+ primaryLight: themeColors.primaryLight
183
+ };
184
+ }, [colors]);
185
+ return _colors;
186
+ };
187
+ var RoundedRectangle = (props) => {
188
+ const { fill, x, y, width, height } = props;
189
+ const absHeight = Math.abs(height);
190
+ return /* @__PURE__ */ jsxRuntime.jsx(
191
+ "rect",
192
+ {
193
+ rx: 2,
194
+ x,
195
+ y: height > 0 ? y : y + height,
196
+ width,
197
+ height: absHeight,
198
+ stroke: "none",
199
+ fill
200
+ }
201
+ );
202
+ };
203
+ var XAxisLabel = (props) => {
204
+ const { x, y, stroke, payload, index, width, containerWidth } = props;
205
+ const { t } = orderlyI18n.useTranslation();
206
+ const _x = index === 0 ? 48 : containerWidth > 0 ? containerWidth - 10 : width + payload.offset;
207
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${_x},${y - 6})`, children: /* @__PURE__ */ jsxRuntime.jsx(
208
+ "text",
209
+ {
210
+ x: 0,
211
+ y: 0,
212
+ dy: 16,
213
+ textAnchor: index === 0 ? "start" : "end",
214
+ fontSize: 10,
215
+ fill: "rgba(255,255,255,0.54)",
216
+ children: index === 0 ? payload.value : t("chart.now")
217
+ }
218
+ ) });
219
+ };
220
+ var CustomizedCross = (props) => {
221
+ const { width, height, stroke, fill } = props;
222
+ return /* @__PURE__ */ jsxRuntime.jsx(
223
+ recharts.Cross,
224
+ {
225
+ x: props.x + props.width / 2,
226
+ top: props.top,
227
+ height,
228
+ width: 1,
229
+ stroke: "rgba(255,255,255,0.16)",
230
+ strokeDasharray: "3 2",
231
+ fill: "none"
232
+ }
233
+ );
234
+ };
235
+ var CustomTooltip = (props) => {
236
+ const { active, payload, label } = props;
237
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
238
+ const { t } = orderlyI18n.useTranslation();
239
+ if (active && payload && payload.length) {
240
+ return /* @__PURE__ */ jsxRuntime.jsx(
241
+ OrderlyChartTooltip,
242
+ {
243
+ label: label === todayStr.current ? t("chart.now") : label,
244
+ value: payload[0].value,
245
+ coloring: true
246
+ }
247
+ );
248
+ }
249
+ return null;
250
+ };
251
+ var PnLBarChart = (props) => {
252
+ const { invisible, data, responsiveContainerProps } = props;
253
+ const colors = useColors(props.colors);
254
+ const widthRef = react.useRef(0);
255
+ return /* @__PURE__ */ jsxRuntime.jsx(
256
+ recharts.ResponsiveContainer,
257
+ {
258
+ className: orderlyUi.cn(invisible && "chart-invisible"),
259
+ onResize: (width) => {
260
+ widthRef.current = width;
261
+ },
262
+ ...responsiveContainerProps,
263
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
264
+ recharts.BarChart,
265
+ {
266
+ data,
267
+ margin: { left: -10, top: 10, right: 10, bottom: 30 },
268
+ children: [
269
+ !invisible && /* @__PURE__ */ jsxRuntime.jsx(
270
+ recharts.Tooltip,
271
+ {
272
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross, {}),
273
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip, {})
274
+ }
275
+ ),
276
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
277
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
278
+ !invisible && /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { dataKey: "pnl", shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle, {}), children: data.map((entry, index) => {
279
+ return /* @__PURE__ */ jsxRuntime.jsx(
280
+ recharts.Cell,
281
+ {
282
+ fill: entry.pnl > 0 ? colors.profit : colors.loss
283
+ },
284
+ `cell-${index}`
285
+ );
286
+ }) }),
287
+ /* @__PURE__ */ jsxRuntime.jsx(
288
+ recharts.YAxis,
289
+ {
290
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
291
+ tickFormatter: (value) => tickFormatter(value),
292
+ tickLine: false,
293
+ axisLine: false,
294
+ dataKey: "pnl"
295
+ }
296
+ ),
297
+ /* @__PURE__ */ jsxRuntime.jsx(
298
+ recharts.XAxis,
299
+ {
300
+ dataKey: "date",
301
+ tickLine: false,
302
+ interval: data.length - 2,
303
+ height: 1,
304
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel, { containerWidth: widthRef.current }),
305
+ stroke: "#FFFFFF",
306
+ strokeOpacity: 0.04
307
+ }
308
+ )
309
+ ]
310
+ }
311
+ )
312
+ }
313
+ );
314
+ };
315
+ var XAxisLabel2 = (props) => {
316
+ const { x, y, stroke, payload, index } = props;
317
+ const { t } = orderlyI18n.useTranslation();
318
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${x},${y - 6})`, children: /* @__PURE__ */ jsxRuntime.jsx(
319
+ "text",
320
+ {
321
+ x: 0,
322
+ y: 0,
323
+ dy: 16,
324
+ textAnchor: "end",
325
+ fontSize: 10,
326
+ fill: "rgba(255,255,255,0.54)",
327
+ children: index === 0 ? payload.value : t("chart.now")
328
+ }
329
+ ) });
330
+ };
331
+ var CustomTooltip2 = (props) => {
332
+ const { active, payload, label } = props;
333
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
334
+ const { t } = orderlyI18n.useTranslation();
335
+ if (active && payload && payload.length) {
336
+ return /* @__PURE__ */ jsxRuntime.jsx(
337
+ OrderlyChartTooltip,
338
+ {
339
+ label: label === todayStr.current ? t("chart.now") : label,
340
+ value: payload[0].value,
341
+ coloring: true
342
+ }
343
+ );
344
+ }
345
+ return null;
346
+ };
347
+ var dataTransfer = (data) => {
348
+ const series = [];
349
+ data?.reduce((acc, item) => {
350
+ acc += item.pnl;
351
+ series.push({ ...item, pnl: acc, _pnl: item.pnl });
352
+ return acc;
353
+ }, 0);
354
+ return series;
355
+ };
356
+ var PnlLineChart = (props) => {
357
+ const { responsiveContainerProps } = props;
358
+ const colors = useColors(props.colors);
359
+ const { isMobile } = orderlyUi.useScreen();
360
+ const data = react.useMemo(() => dataTransfer(props.data), [props.data]);
361
+ const chartComponent = /* @__PURE__ */ jsxRuntime.jsxs(
362
+ recharts.LineChart,
363
+ {
364
+ data,
365
+ margin: { top: 20, right: 10, left: -10, bottom: 0 },
366
+ children: [
367
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
368
+ /* @__PURE__ */ jsxRuntime.jsx(
369
+ recharts.XAxis,
370
+ {
371
+ dataKey: "date",
372
+ interval: props.data.length - 2,
373
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
374
+ stroke: "#FFFFFF",
375
+ strokeOpacity: 0.04
376
+ }
377
+ ),
378
+ /* @__PURE__ */ jsxRuntime.jsx(
379
+ recharts.YAxis,
380
+ {
381
+ dataKey: "pnl",
382
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
383
+ tickLine: false,
384
+ axisLine: false,
385
+ tickFormatter
386
+ }
387
+ ),
388
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
389
+ recharts.Tooltip,
390
+ {
391
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
392
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip2, {})
393
+ }
394
+ ),
395
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
396
+ recharts.Line,
397
+ {
398
+ type: "natural",
399
+ dataKey: "pnl",
400
+ stroke: colors.primary,
401
+ strokeWidth: isMobile ? 1.5 : 2,
402
+ dot: false,
403
+ isAnimationActive: false
404
+ }
405
+ )
406
+ ]
407
+ }
408
+ );
409
+ return /* @__PURE__ */ jsxRuntime.jsx(
410
+ recharts.ResponsiveContainer,
411
+ {
412
+ className: props.invisible ? "chart-invisible" : void 0,
413
+ ...responsiveContainerProps,
414
+ children: chartComponent
415
+ }
416
+ );
417
+ };
418
+ var CustomTooltip3 = (props) => {
419
+ const { active, payload, label } = props;
420
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
421
+ const { t } = orderlyI18n.useTranslation();
422
+ if (active && payload && payload.length) {
423
+ return /* @__PURE__ */ jsxRuntime.jsx(
424
+ OrderlyChartTooltip,
425
+ {
426
+ label: label === todayStr.current ? t("chart.now") : label,
427
+ value: payload[0].value,
428
+ coloring: true
429
+ }
430
+ );
431
+ }
432
+ return null;
433
+ };
434
+ var dataTransfer2 = (data) => {
435
+ const series = [];
436
+ data?.reduce((acc, item) => {
437
+ acc += item.pnl;
438
+ series.push({ ...item, pnl: acc, _pnl: item.pnl });
439
+ return acc;
440
+ }, 0);
441
+ return series;
442
+ };
443
+ var PnlAreaChart = (props) => {
444
+ const { responsiveContainerProps } = props;
445
+ const colors = useColors(props.colors);
446
+ const { isMobile } = orderlyUi.useScreen();
447
+ const colorId = react.useId();
448
+ const data = react.useMemo(() => dataTransfer2(props.data), [props.data]);
449
+ const baseValue = react.useMemo(
450
+ () => data.map((item) => item.pnl).sort((a, b) => a - b)[0] || 0,
451
+ [data]
452
+ );
453
+ const chartComponent = /* @__PURE__ */ jsxRuntime.jsxs(
454
+ recharts.AreaChart,
455
+ {
456
+ data,
457
+ margin: { top: 20, right: 10, left: -10, bottom: 0 },
458
+ children: [
459
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
460
+ /* @__PURE__ */ jsxRuntime.jsx(
461
+ recharts.XAxis,
462
+ {
463
+ dataKey: "date",
464
+ interval: props.data.length - 2,
465
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
466
+ stroke: "#FFFFFF",
467
+ strokeOpacity: 0.04
468
+ }
469
+ ),
470
+ /* @__PURE__ */ jsxRuntime.jsx(
471
+ recharts.YAxis,
472
+ {
473
+ dataKey: "pnl",
474
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
475
+ tickLine: false,
476
+ axisLine: false,
477
+ tickFormatter
478
+ }
479
+ ),
480
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
481
+ recharts.Tooltip,
482
+ {
483
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
484
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip3, {})
485
+ }
486
+ ),
487
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
488
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
489
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: colors.primary, offset: "0%", stopOpacity: 0.5 }),
490
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: colors.primary, offset: "100%", stopOpacity: 0 })
491
+ ] }) }),
492
+ /* @__PURE__ */ jsxRuntime.jsx(
493
+ recharts.Area,
494
+ {
495
+ type: "natural",
496
+ dataKey: "pnl",
497
+ stroke: colors.primary,
498
+ strokeWidth: isMobile ? 1.5 : 2,
499
+ dot: false,
500
+ isAnimationActive: false,
501
+ fill: `url(#${colorId})`,
502
+ baseValue: baseValue || 0
503
+ }
504
+ )
505
+ ] })
506
+ ]
507
+ }
508
+ );
509
+ return /* @__PURE__ */ jsxRuntime.jsx(
510
+ recharts.ResponsiveContainer,
511
+ {
512
+ className: props.invisible ? "chart-invisible" : void 0,
513
+ ...responsiveContainerProps,
514
+ children: chartComponent
515
+ }
516
+ );
517
+ };
518
+ var ChartEmptyState = ({
519
+ title = "No Data Available",
520
+ description = "No data to display for the selected period",
521
+ height = "300px",
522
+ className
523
+ }) => {
524
+ return /* @__PURE__ */ jsxRuntime.jsx(
525
+ orderlyUi.Box,
526
+ {
527
+ className: orderlyUi.cn(
528
+ "oui-w-full oui-flex oui-items-center oui-justify-center oui-bg-base-8",
529
+ className
530
+ ),
531
+ style: { height },
532
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
533
+ orderlyUi.Flex,
534
+ {
535
+ direction: "column",
536
+ itemAlign: "center",
537
+ gap: 3,
538
+ className: "oui-text-center",
539
+ children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.BarChartIcon, {}),
541
+ /* @__PURE__ */ jsxRuntime.jsx(
542
+ orderlyUi.Text,
543
+ {
544
+ as: "div",
545
+ size: "sm",
546
+ weight: "semibold",
547
+ className: "oui-text-base-contrast-100",
548
+ children: title
549
+ }
550
+ ),
551
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { as: "div", size: "xs", className: "oui-text-base-contrast-54", children: description })
552
+ ]
553
+ }
554
+ )
555
+ }
556
+ );
557
+ };
558
+ var RoundedRectangle2 = (props) => {
559
+ const { fill, x, y, width, height } = props;
560
+ const absHeight = Math.abs(height);
561
+ return /* @__PURE__ */ jsxRuntime.jsx(
562
+ "rect",
563
+ {
564
+ rx: 2,
565
+ x,
566
+ y: height > 0 ? y : y + height,
567
+ width,
568
+ height: absHeight,
569
+ stroke: "none",
570
+ fill
571
+ }
572
+ );
573
+ };
574
+ var CustomizedCross2 = (props) => {
575
+ const { width, height } = props;
576
+ return /* @__PURE__ */ jsxRuntime.jsx(
577
+ recharts.Cross,
578
+ {
579
+ x: props.x + props.width / 2,
580
+ top: props.top,
581
+ height,
582
+ width: 1,
583
+ stroke: "rgba(255,255,255,0.16)",
584
+ strokeDasharray: "3 2",
585
+ fill: "none"
586
+ }
587
+ );
588
+ };
589
+ var formatValueWithSign = (value) => {
590
+ const sign = value > 0 ? "+" : "";
591
+ return `${sign}${value.toFixed(2)}`;
592
+ };
593
+ var getValueColor = (value, colors) => {
594
+ if (value === 0) return "inherit";
595
+ return value > 0 ? colors.profit : colors.loss;
596
+ };
597
+ var createCustomTooltip = (showCumulative) => {
598
+ return (props) => {
599
+ const { active, payload, label } = props;
600
+ const colors = useColors();
601
+ if (active && payload && payload.length >= 1) {
602
+ const barData = payload.find((p) => p.dataKey === "pnl");
603
+ const barValue = barData?.value ?? 0;
604
+ const formattedDate = label;
605
+ const barColor = getValueColor(barValue, colors);
606
+ return /* @__PURE__ */ jsxRuntime.jsxs(
607
+ orderlyUi.Box,
608
+ {
609
+ intensity: 600,
610
+ p: 3,
611
+ r: "md",
612
+ className: "oui-flex oui-flex-col oui-gap-2",
613
+ children: [
614
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
615
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-text-base-contrast-54", children: [
616
+ formattedDate,
617
+ ":"
618
+ ] }),
619
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", style: { color: barColor }, children: [
620
+ formatValueWithSign(barValue),
621
+ " USDC"
622
+ ] })
623
+ ] }),
624
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
625
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Cumulative:" }),
626
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", children: [
627
+ (() => {
628
+ const lineData = payload.find(
629
+ (p) => p.dataKey === "cumulativePnL"
630
+ );
631
+ const cumulativeValue = lineData?.value ?? 0;
632
+ return formatValueWithSign(cumulativeValue);
633
+ })(),
634
+ " ",
635
+ "USDC"
636
+ ] })
637
+ ] })
638
+ ]
639
+ }
640
+ );
641
+ }
642
+ return null;
643
+ };
644
+ };
645
+ var calculateOptimalInterval = (dataLength, aggregationWindow, isMobile = false) => {
646
+ if (dataLength <= 12 && !isMobile) return 0;
647
+ let targetLabels;
648
+ if (dataLength > 500) {
649
+ targetLabels = 6;
650
+ } else if (dataLength > 200) {
651
+ targetLabels = 6;
652
+ } else if (dataLength > 100) {
653
+ targetLabels = 7;
654
+ } else if (dataLength > 50) {
655
+ targetLabels = 8;
656
+ } else {
657
+ targetLabels = 12;
658
+ }
659
+ if (isMobile) {
660
+ targetLabels = Math.ceil(targetLabels / 2);
661
+ }
662
+ const baseInterval = Math.ceil(dataLength / targetLabels);
663
+ if (aggregationWindow === "15m") {
664
+ if (baseInterval >= 96) return Math.ceil(baseInterval / 56) * 56;
665
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
666
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 16) * 16;
667
+ return Math.max(8, Math.ceil(baseInterval / 4) * 4);
668
+ }
669
+ if (aggregationWindow === "1h") {
670
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
671
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 12) * 12;
672
+ return Math.max(4, Math.ceil(baseInterval / 4) * 4);
673
+ }
674
+ if (aggregationWindow === "1d") {
675
+ if (baseInterval >= 14) return Math.ceil(baseInterval / 14) * 14;
676
+ if (baseInterval >= 3) return Math.ceil(baseInterval / 7) * 7;
677
+ }
678
+ return baseInterval;
679
+ };
680
+ var transformToCumulative = (data) => {
681
+ let cumulative = 0;
682
+ return data.map((item) => {
683
+ cumulative += item.pnl;
684
+ return {
685
+ ...item,
686
+ cumulativePnL: cumulative
687
+ };
688
+ });
689
+ };
690
+ var CombinedPnLChart = (props) => {
691
+ const {
692
+ data,
693
+ aggregationWindow = "1d",
694
+ isMobile = false,
695
+ invisible,
696
+ responsiveContainerProps,
697
+ className,
698
+ showCumulative = true
699
+ } = props;
700
+ const colors = useColors(props.colors);
701
+ const transformedData = react.useMemo(() => transformToCumulative(data), [data]);
702
+ const xAxisInterval = react.useMemo(() => {
703
+ return calculateOptimalInterval(
704
+ transformedData.length,
705
+ aggregationWindow,
706
+ isMobile
707
+ );
708
+ }, [transformedData.length, aggregationWindow, isMobile]);
709
+ const yAxisDomain = react.useMemo(() => {
710
+ if (transformedData.length === 0) return [0, 1];
711
+ const pnlValues = transformedData.map((item) => item.pnl);
712
+ const cumulativeValues = showCumulative ? transformedData.map((item) => item.cumulativePnL) : [];
713
+ const valuesToConsider = showCumulative ? [...pnlValues, ...cumulativeValues, 0] : [...pnlValues, 0];
714
+ const minValue = Math.min(...valuesToConsider);
715
+ const maxValue = Math.max(...valuesToConsider);
716
+ const range = maxValue - minValue;
717
+ if (range === 0) return [0, 1];
718
+ const padding = range * 0.1;
719
+ const lower = minValue - padding;
720
+ const upper = maxValue + padding;
721
+ const magnitude = Math.pow(10, Math.floor(Math.log10(range)));
722
+ const step = Math.ceil((upper - lower) / 5 / magnitude) * magnitude;
723
+ const roundedLower = Math.floor(lower / step) * step;
724
+ const roundedUpper = Math.ceil(upper / step) * step;
725
+ return [roundedLower, roundedUpper];
726
+ }, [transformedData, showCumulative]);
727
+ if (invisible || transformedData.length === 0) {
728
+ return /* @__PURE__ */ jsxRuntime.jsx(
729
+ ChartEmptyState,
730
+ {
731
+ title: "No P&L Data",
732
+ description: "No profit and loss data available for the selected period",
733
+ height: "100%",
734
+ className
735
+ }
736
+ );
737
+ }
738
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
739
+ recharts.ResponsiveContainer,
740
+ {
741
+ width: "100%",
742
+ height: "100%",
743
+ ...responsiveContainerProps,
744
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
745
+ recharts.ComposedChart,
746
+ {
747
+ data: transformedData,
748
+ margin: { left: 45, top: 10, right: 50, bottom: 20 },
749
+ syncId: "symbol-performance",
750
+ children: [
751
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: "cumulativeGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
752
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "5%", stopColor: "#608CFF", stopOpacity: 0.4 }),
753
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "95%", stopColor: "#608CFF", stopOpacity: 0 })
754
+ ] }) }),
755
+ /* @__PURE__ */ jsxRuntime.jsx(
756
+ recharts.Tooltip,
757
+ {
758
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross2, {}),
759
+ content: createCustomTooltip(showCumulative)
760
+ }
761
+ ),
762
+ /* @__PURE__ */ jsxRuntime.jsx(
763
+ recharts.CartesianGrid,
764
+ {
765
+ vertical: false,
766
+ stroke: "#FFFFFF",
767
+ strokeOpacity: 0.04
768
+ }
769
+ ),
770
+ /* @__PURE__ */ jsxRuntime.jsx(
771
+ recharts.ReferenceLine,
772
+ {
773
+ y: 0,
774
+ stroke: "rgba(255,255,255,0.3)",
775
+ strokeWidth: 2,
776
+ strokeDasharray: "4 4"
777
+ }
778
+ ),
779
+ /* @__PURE__ */ jsxRuntime.jsx(
780
+ recharts.YAxis,
781
+ {
782
+ domain: yAxisDomain,
783
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
784
+ tickLine: false,
785
+ axisLine: false,
786
+ tickFormatter: (value) => tickFormatter2(value),
787
+ width: 45
788
+ }
789
+ ),
790
+ /* @__PURE__ */ jsxRuntime.jsx(
791
+ recharts.XAxis,
792
+ {
793
+ dataKey: "date",
794
+ tickLine: false,
795
+ interval: xAxisInterval,
796
+ minTickGap: 30,
797
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
798
+ stroke: "#FFFFFF",
799
+ strokeOpacity: 0.04
800
+ }
801
+ ),
802
+ /* @__PURE__ */ jsxRuntime.jsx(
803
+ recharts.Bar,
804
+ {
805
+ dataKey: "pnl",
806
+ shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle2, {}),
807
+ minPointSize: 1,
808
+ isAnimationActive: false,
809
+ children: transformedData.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
810
+ recharts.Cell,
811
+ {
812
+ fill: entry.pnl === 0 ? "rgba(255,255,255,0.2)" : entry.pnl > 0 ? colors.profit : colors.loss
813
+ },
814
+ `cell-${index}`
815
+ ))
816
+ }
817
+ ),
818
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
819
+ recharts.Area,
820
+ {
821
+ type: "natural",
822
+ dataKey: "cumulativePnL",
823
+ fill: "url(#cumulativeGradient)",
824
+ stroke: "none",
825
+ isAnimationActive: false
826
+ }
827
+ ),
828
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
829
+ recharts.Line,
830
+ {
831
+ type: "natural",
832
+ dataKey: "cumulativePnL",
833
+ stroke: colors.primary,
834
+ strokeWidth: 2,
835
+ dot: false,
836
+ isAnimationActive: false,
837
+ strokeLinecap: "round",
838
+ strokeLinejoin: "round"
839
+ }
840
+ )
841
+ ]
842
+ }
843
+ )
844
+ }
845
+ ) });
846
+ };
847
+ function tickFormatter2(value) {
848
+ const abbreviations = ["", "K", "M", "B", "T"];
849
+ let index = 0;
850
+ let num = Math.abs(value);
851
+ while (num >= 1e3 && index < abbreviations.length - 1) {
852
+ num /= 1e3;
853
+ index++;
854
+ }
855
+ const sign = value < 0 ? "-" : "";
856
+ const decimalPlaces = num <= 10 ? 1 : 0;
857
+ const rounded = num.toFixed(decimalPlaces);
858
+ return `${sign}${rounded}${abbreviations[index]}`;
859
+ }
860
+ var RoundedRectangle3 = (props) => {
861
+ const { fill, x, y, width, height } = props;
862
+ const absHeight = Math.abs(height);
863
+ return /* @__PURE__ */ jsxRuntime.jsx(
864
+ "rect",
865
+ {
866
+ rx: 2,
867
+ x,
868
+ y: height > 0 ? y : y + height,
869
+ width,
870
+ height: absHeight,
871
+ stroke: "none",
872
+ fill
873
+ }
874
+ );
875
+ };
876
+ var CustomizedCross3 = (props) => {
877
+ const { width, height } = props;
878
+ return /* @__PURE__ */ jsxRuntime.jsx(
879
+ recharts.Cross,
880
+ {
881
+ x: props.x + props.width / 2,
882
+ top: props.top,
883
+ height,
884
+ width: 1,
885
+ stroke: "rgba(255,255,255,0.16)",
886
+ strokeDasharray: "3 2",
887
+ fill: "none"
888
+ }
889
+ );
890
+ };
891
+ var formatValueWithSign2 = (value) => {
892
+ const sign = value > 0 ? "+" : "";
893
+ return `${sign}${value}`;
894
+ };
895
+ var createCustomTooltip2 = (showCumulative) => {
896
+ return (props) => {
897
+ const { active, payload, label } = props;
898
+ if (active && payload && payload.length >= 1) {
899
+ const volumeData = payload.find((p) => p.dataKey === "volume");
900
+ const volumeValue = volumeData?.value ?? 0;
901
+ const formattedDate = label;
902
+ return /* @__PURE__ */ jsxRuntime.jsxs(
903
+ orderlyUi.Box,
904
+ {
905
+ intensity: 600,
906
+ p: 3,
907
+ r: "md",
908
+ className: "oui-flex oui-flex-col oui-gap-2",
909
+ children: [
910
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
911
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-text-base-contrast-54", children: [
912
+ formattedDate,
913
+ ":"
914
+ ] }),
915
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", children: [
916
+ formatValueWithSign2(volumeValue),
917
+ " USDC"
918
+ ] })
919
+ ] }),
920
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
921
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Cumulative:" }),
922
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", children: [
923
+ (() => {
924
+ const cumulativeData = payload.find(
925
+ (p) => p.dataKey === "cumulativeVolume"
926
+ );
927
+ const cumulativeValue = cumulativeData?.value ?? 0;
928
+ return formatValueWithSign2(cumulativeValue);
929
+ })(),
930
+ " ",
931
+ "USDC"
932
+ ] })
933
+ ] })
934
+ ]
935
+ }
936
+ );
937
+ }
938
+ return null;
939
+ };
940
+ };
941
+ var calculateOptimalInterval2 = (dataLength, aggregationWindow, isMobile = false) => {
942
+ if (dataLength <= 12 && !isMobile) return 0;
943
+ let targetLabels;
944
+ if (dataLength > 500) {
945
+ targetLabels = 6;
946
+ } else if (dataLength > 200) {
947
+ targetLabels = 6;
948
+ } else if (dataLength > 100) {
949
+ targetLabels = 7;
950
+ } else if (dataLength > 50) {
951
+ targetLabels = 8;
952
+ } else {
953
+ targetLabels = 12;
954
+ }
955
+ if (isMobile) {
956
+ targetLabels = Math.ceil(targetLabels / 2);
957
+ }
958
+ const baseInterval = Math.ceil(dataLength / targetLabels);
959
+ if (aggregationWindow === "15m") {
960
+ if (baseInterval >= 96) return Math.ceil(baseInterval / 56) * 56;
961
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
962
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 16) * 16;
963
+ return Math.max(8, Math.ceil(baseInterval / 4) * 4);
964
+ }
965
+ if (aggregationWindow === "1h") {
966
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
967
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 12) * 12;
968
+ return Math.max(4, Math.ceil(baseInterval / 4) * 4);
969
+ }
970
+ if (aggregationWindow === "1d") {
971
+ if (baseInterval >= 14) return Math.ceil(baseInterval / 14) * 14;
972
+ if (baseInterval >= 3) return Math.ceil(baseInterval / 7) * 7;
973
+ }
974
+ return baseInterval;
975
+ };
976
+ var transformToCumulative2 = (data) => {
977
+ let cumulative = 0;
978
+ return data.map((item) => {
979
+ cumulative += item.volume;
980
+ return {
981
+ ...item,
982
+ cumulativeVolume: cumulative
983
+ };
984
+ });
985
+ };
986
+ var CombinedVolumeChart = (props) => {
987
+ const {
988
+ data,
989
+ aggregationWindow = "1d",
990
+ isMobile = false,
991
+ invisible,
992
+ responsiveContainerProps,
993
+ className,
994
+ showCumulative = false
995
+ } = props;
996
+ const colors = useColors(
997
+ props.colors ? { profit: props.colors.fill, loss: props.colors.fill } : void 0
998
+ );
999
+ const transformedData = react.useMemo(() => transformToCumulative2(data), [data]);
1000
+ const xAxisInterval = react.useMemo(
1001
+ () => calculateOptimalInterval2(
1002
+ transformedData.length,
1003
+ aggregationWindow,
1004
+ isMobile
1005
+ ),
1006
+ [transformedData.length, aggregationWindow, isMobile]
1007
+ );
1008
+ const yAxisDomain = react.useMemo(() => {
1009
+ if (transformedData.length === 0) return [0, 1];
1010
+ const volumeValues = transformedData.map((item) => item.volume);
1011
+ const cumulativeValues = showCumulative ? transformedData.map((item) => item.cumulativeVolume) : [];
1012
+ const maxValue = Math.max(
1013
+ ...showCumulative ? [...volumeValues, ...cumulativeValues] : volumeValues,
1014
+ 0
1015
+ );
1016
+ const range = maxValue;
1017
+ if (range === 0) return [0, 1];
1018
+ const padding = range * 0.1;
1019
+ const upper = maxValue + padding;
1020
+ const magnitude = Math.pow(10, Math.floor(Math.log10(range)));
1021
+ const step = Math.ceil(upper / 5 / magnitude) * magnitude;
1022
+ const roundedUpper = Math.ceil(upper / step) * step;
1023
+ return [0, roundedUpper];
1024
+ }, [transformedData, showCumulative]);
1025
+ if (invisible || transformedData.length === 0) {
1026
+ return /* @__PURE__ */ jsxRuntime.jsx(
1027
+ ChartEmptyState,
1028
+ {
1029
+ title: "No Volume Data",
1030
+ description: "No trading volume data available for the selected period",
1031
+ height: "100%",
1032
+ className
1033
+ }
1034
+ );
1035
+ }
1036
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
1037
+ recharts.ResponsiveContainer,
1038
+ {
1039
+ width: "100%",
1040
+ height: "100%",
1041
+ ...responsiveContainerProps,
1042
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1043
+ recharts.ComposedChart,
1044
+ {
1045
+ data: transformedData,
1046
+ margin: { left: 45, top: 10, right: 50, bottom: 20 },
1047
+ syncId: "symbol-performance",
1048
+ children: [
1049
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: "volumeGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
1050
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "5%", stopColor: "#00B49E", stopOpacity: 0.4 }),
1051
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "95%", stopColor: "#00B49E", stopOpacity: 0 })
1052
+ ] }) }),
1053
+ /* @__PURE__ */ jsxRuntime.jsx(
1054
+ recharts.Tooltip,
1055
+ {
1056
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross3, {}),
1057
+ content: createCustomTooltip2(showCumulative)
1058
+ }
1059
+ ),
1060
+ /* @__PURE__ */ jsxRuntime.jsx(
1061
+ recharts.CartesianGrid,
1062
+ {
1063
+ vertical: false,
1064
+ stroke: "#FFFFFF",
1065
+ strokeOpacity: 0.04
1066
+ }
1067
+ ),
1068
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
1069
+ /* @__PURE__ */ jsxRuntime.jsx(
1070
+ recharts.YAxis,
1071
+ {
1072
+ domain: yAxisDomain,
1073
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1074
+ tickLine: false,
1075
+ axisLine: false,
1076
+ tickFormatter: (value) => tickFormatter3(value),
1077
+ width: 45
1078
+ }
1079
+ ),
1080
+ /* @__PURE__ */ jsxRuntime.jsx(
1081
+ recharts.XAxis,
1082
+ {
1083
+ dataKey: "date",
1084
+ tickLine: false,
1085
+ interval: xAxisInterval,
1086
+ minTickGap: 30,
1087
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1088
+ stroke: "#FFFFFF",
1089
+ strokeOpacity: 0.04
1090
+ }
1091
+ ),
1092
+ /* @__PURE__ */ jsxRuntime.jsx(
1093
+ recharts.Bar,
1094
+ {
1095
+ dataKey: "volume",
1096
+ shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle3, {}),
1097
+ minPointSize: 1,
1098
+ isAnimationActive: false,
1099
+ children: transformedData.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
1100
+ recharts.Cell,
1101
+ {
1102
+ fill: entry.volume === 0 ? "rgba(255,255,255,0.2)" : colors.profit,
1103
+ opacity: 0.8
1104
+ },
1105
+ `cell-${index}`
1106
+ ))
1107
+ }
1108
+ ),
1109
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
1110
+ recharts.Area,
1111
+ {
1112
+ type: "natural",
1113
+ dataKey: "cumulativeVolume",
1114
+ fill: "url(#volumeGradient)",
1115
+ stroke: "none",
1116
+ isAnimationActive: false
1117
+ }
1118
+ ),
1119
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
1120
+ recharts.Line,
1121
+ {
1122
+ type: "natural",
1123
+ dataKey: "cumulativeVolume",
1124
+ stroke: colors.profit,
1125
+ strokeWidth: 2,
1126
+ dot: false,
1127
+ isAnimationActive: false,
1128
+ strokeLinecap: "round",
1129
+ strokeLinejoin: "round"
1130
+ }
1131
+ )
1132
+ ]
1133
+ }
1134
+ )
1135
+ }
1136
+ ) });
1137
+ };
1138
+ function tickFormatter3(value) {
1139
+ const abbreviations = ["", "K", "M", "B", "T"];
1140
+ let index = 0;
1141
+ let num = Math.abs(value);
1142
+ while (num >= 1e3 && index < abbreviations.length - 1) {
1143
+ num /= 1e3;
1144
+ index++;
1145
+ }
1146
+ const sign = value < 0 ? "-" : "";
1147
+ const decimalPlaces = num <= 10 ? 1 : 0;
1148
+ const rounded = num.toFixed(decimalPlaces);
1149
+ return `${sign}${rounded}${abbreviations[index]}`;
1150
+ }
1151
+ var RoundedRectangle4 = (props) => {
1152
+ const { fill, x, y, width, height } = props;
1153
+ const absHeight = Math.abs(height);
1154
+ return /* @__PURE__ */ jsxRuntime.jsx(
1155
+ "rect",
1156
+ {
1157
+ rx: 2,
1158
+ x,
1159
+ y: height > 0 ? y : y + height,
1160
+ width,
1161
+ height: absHeight,
1162
+ stroke: "none",
1163
+ fill
1164
+ }
1165
+ );
1166
+ };
1167
+ var CustomizedCross4 = (props) => {
1168
+ const { width, height } = props;
1169
+ return /* @__PURE__ */ jsxRuntime.jsx(
1170
+ recharts.Cross,
1171
+ {
1172
+ x: props.x + props.width / 2,
1173
+ top: props.top,
1174
+ height,
1175
+ width: 1,
1176
+ stroke: "rgba(255,255,255,0.16)",
1177
+ strokeDasharray: "3 2",
1178
+ fill: "none"
1179
+ }
1180
+ );
1181
+ };
1182
+ var formatValueWithSign3 = (value) => {
1183
+ const sign = value > 0 ? "+" : "";
1184
+ return `${sign}${value.toFixed(2)}`;
1185
+ };
1186
+ var createCustomTooltip3 = (showCumulative) => {
1187
+ return (props) => {
1188
+ const { active, payload, label } = props;
1189
+ if (active && payload && payload.length >= 1) {
1190
+ const feesData = payload.find((p) => p.dataKey === "fees");
1191
+ const feesValue = feesData?.value ?? 0;
1192
+ const formattedDate = label;
1193
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1194
+ orderlyUi.Box,
1195
+ {
1196
+ intensity: 600,
1197
+ p: 3,
1198
+ r: "md",
1199
+ className: "oui-flex oui-flex-col oui-gap-2",
1200
+ children: [
1201
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1202
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-text-base-contrast-54", children: [
1203
+ formattedDate,
1204
+ ":"
1205
+ ] }),
1206
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", children: [
1207
+ formatValueWithSign3(feesValue),
1208
+ " USDC"
1209
+ ] })
1210
+ ] }),
1211
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1212
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Cumulative:" }),
1213
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "oui-font-semibold", children: [
1214
+ (() => {
1215
+ const cumulativeData = payload.find(
1216
+ (p) => p.dataKey === "cumulativeFees"
1217
+ );
1218
+ const cumulativeValue = cumulativeData?.value ?? 0;
1219
+ return formatValueWithSign3(cumulativeValue);
1220
+ })(),
1221
+ " ",
1222
+ "USDC"
1223
+ ] })
1224
+ ] })
1225
+ ]
1226
+ }
1227
+ );
1228
+ }
1229
+ return null;
1230
+ };
1231
+ };
1232
+ var calculateOptimalInterval3 = (dataLength, aggregationWindow, isMobile = false) => {
1233
+ if (dataLength <= 12 && !isMobile) return 0;
1234
+ let targetLabels;
1235
+ if (dataLength > 500) {
1236
+ targetLabels = 6;
1237
+ } else if (dataLength > 200) {
1238
+ targetLabels = 6;
1239
+ } else if (dataLength > 100) {
1240
+ targetLabels = 7;
1241
+ } else if (dataLength > 50) {
1242
+ targetLabels = 8;
1243
+ } else {
1244
+ targetLabels = 12;
1245
+ }
1246
+ if (isMobile) {
1247
+ targetLabels = Math.ceil(targetLabels / 2);
1248
+ }
1249
+ const baseInterval = Math.ceil(dataLength / targetLabels);
1250
+ if (aggregationWindow === "15m") {
1251
+ if (baseInterval >= 96) return Math.ceil(baseInterval / 56) * 56;
1252
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
1253
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 16) * 16;
1254
+ return Math.max(8, Math.ceil(baseInterval / 4) * 4);
1255
+ }
1256
+ if (aggregationWindow === "1h") {
1257
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
1258
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 12) * 12;
1259
+ return Math.max(4, Math.ceil(baseInterval / 4) * 4);
1260
+ }
1261
+ if (aggregationWindow === "1d") {
1262
+ if (baseInterval >= 14) return Math.ceil(baseInterval / 14) * 14;
1263
+ if (baseInterval >= 3) return Math.ceil(baseInterval / 7) * 7;
1264
+ }
1265
+ return baseInterval;
1266
+ };
1267
+ var transformToCumulative3 = (data) => {
1268
+ let cumulative = 0;
1269
+ return data.map((item) => {
1270
+ cumulative += item.fees;
1271
+ return {
1272
+ ...item,
1273
+ cumulativeFees: cumulative
1274
+ };
1275
+ });
1276
+ };
1277
+ var CombinedFeesChart = (props) => {
1278
+ const {
1279
+ data,
1280
+ aggregationWindow = "1d",
1281
+ isMobile = false,
1282
+ invisible,
1283
+ responsiveContainerProps,
1284
+ className,
1285
+ showCumulative = false
1286
+ } = props;
1287
+ const colors = useColors(
1288
+ props.colors ? { profit: props.colors.fill, loss: props.colors.fill } : void 0
1289
+ );
1290
+ const transformedData = react.useMemo(() => transformToCumulative3(data), [data]);
1291
+ const xAxisInterval = react.useMemo(
1292
+ () => calculateOptimalInterval3(
1293
+ transformedData.length,
1294
+ aggregationWindow,
1295
+ isMobile
1296
+ ),
1297
+ [transformedData.length, aggregationWindow, isMobile]
1298
+ );
1299
+ const yAxisDomainAndTicks = react.useMemo(() => {
1300
+ if (transformedData.length === 0) return { domain: [0, 1], ticks: [0, 1] };
1301
+ const feesValues = transformedData.map((item) => item.fees);
1302
+ const cumulativeValues = showCumulative ? transformedData.map((item) => item.cumulativeFees) : [];
1303
+ const valuesToConsider = showCumulative ? [...feesValues, ...cumulativeValues, 0] : [...feesValues, 0];
1304
+ const minValue = Math.min(...valuesToConsider);
1305
+ const maxValue = Math.max(...valuesToConsider);
1306
+ const range = maxValue - minValue;
1307
+ if (range === 0) return { domain: [0, 1], ticks: [0, 1] };
1308
+ const padding = range * 0.1;
1309
+ const lower = minValue - padding;
1310
+ const upper = 0;
1311
+ const magnitude = Math.pow(10, Math.floor(Math.log10(range)));
1312
+ let step = magnitude;
1313
+ const rangeWidth = Math.abs(upper - lower);
1314
+ for (const divisor of [1, 2, 2.5, 5]) {
1315
+ const candidate = magnitude * divisor;
1316
+ const tickCount = Math.ceil(rangeWidth / candidate);
1317
+ if (tickCount >= 4 && tickCount <= 6) {
1318
+ step = candidate;
1319
+ break;
1320
+ }
1321
+ }
1322
+ const roundedLower = Math.floor(lower / step) * step;
1323
+ const ticks = [];
1324
+ for (let tick = roundedLower; tick < upper; tick += step) {
1325
+ ticks.push(Number(tick.toFixed(10)));
1326
+ }
1327
+ ticks.push(0);
1328
+ return { domain: [roundedLower, 0], ticks };
1329
+ }, [transformedData, showCumulative]);
1330
+ if (invisible || transformedData.length === 0) {
1331
+ return /* @__PURE__ */ jsxRuntime.jsx(
1332
+ ChartEmptyState,
1333
+ {
1334
+ title: "No Fees Data",
1335
+ description: "No fees data available for the selected period",
1336
+ height: "100%",
1337
+ className
1338
+ }
1339
+ );
1340
+ }
1341
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
1342
+ recharts.ResponsiveContainer,
1343
+ {
1344
+ width: "100%",
1345
+ height: "100%",
1346
+ ...responsiveContainerProps,
1347
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1348
+ recharts.ComposedChart,
1349
+ {
1350
+ data: transformedData,
1351
+ margin: { left: 45, top: 10, right: 50, bottom: 20 },
1352
+ syncId: "symbol-performance",
1353
+ children: [
1354
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: "feesGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
1355
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "5%", stopColor: "#FF6B6B", stopOpacity: 0.4 }),
1356
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "95%", stopColor: "#FF6B6B", stopOpacity: 0 })
1357
+ ] }) }),
1358
+ /* @__PURE__ */ jsxRuntime.jsx(
1359
+ recharts.Tooltip,
1360
+ {
1361
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross4, {}),
1362
+ content: createCustomTooltip3(showCumulative)
1363
+ }
1364
+ ),
1365
+ /* @__PURE__ */ jsxRuntime.jsx(
1366
+ recharts.CartesianGrid,
1367
+ {
1368
+ vertical: false,
1369
+ stroke: "#FFFFFF",
1370
+ strokeOpacity: 0.04
1371
+ }
1372
+ ),
1373
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
1374
+ /* @__PURE__ */ jsxRuntime.jsx(
1375
+ recharts.YAxis,
1376
+ {
1377
+ domain: yAxisDomainAndTicks.domain,
1378
+ ticks: yAxisDomainAndTicks.ticks,
1379
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1380
+ tickLine: false,
1381
+ axisLine: false,
1382
+ tickFormatter: (value) => tickFormatter4(value),
1383
+ width: 45
1384
+ }
1385
+ ),
1386
+ /* @__PURE__ */ jsxRuntime.jsx(
1387
+ recharts.XAxis,
1388
+ {
1389
+ dataKey: "date",
1390
+ tickLine: false,
1391
+ interval: xAxisInterval,
1392
+ minTickGap: 30,
1393
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1394
+ stroke: "#FFFFFF",
1395
+ strokeOpacity: 0.04
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ jsxRuntime.jsx(
1399
+ recharts.Bar,
1400
+ {
1401
+ dataKey: "fees",
1402
+ shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle4, {}),
1403
+ minPointSize: 1,
1404
+ isAnimationActive: false,
1405
+ children: transformedData.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
1406
+ recharts.Cell,
1407
+ {
1408
+ fill: entry.fees === 0 ? "rgba(255,255,255,0.2)" : colors.loss,
1409
+ opacity: 0.8
1410
+ },
1411
+ `cell-${index}`
1412
+ ))
1413
+ }
1414
+ ),
1415
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
1416
+ recharts.Area,
1417
+ {
1418
+ type: "natural",
1419
+ dataKey: "cumulativeFees",
1420
+ fill: "url(#feesGradient)",
1421
+ stroke: "none",
1422
+ isAnimationActive: false
1423
+ }
1424
+ ),
1425
+ showCumulative && /* @__PURE__ */ jsxRuntime.jsx(
1426
+ recharts.Line,
1427
+ {
1428
+ type: "natural",
1429
+ dataKey: "cumulativeFees",
1430
+ stroke: colors.loss,
1431
+ strokeWidth: 2,
1432
+ dot: false,
1433
+ isAnimationActive: false,
1434
+ strokeLinecap: "round",
1435
+ strokeLinejoin: "round"
1436
+ }
1437
+ )
1438
+ ]
1439
+ }
1440
+ )
1441
+ }
1442
+ ) });
1443
+ };
1444
+ function tickFormatter4(value) {
1445
+ const abbreviations = ["", "K", "M", "B", "T"];
1446
+ let index = 0;
1447
+ let num = Math.abs(value);
1448
+ while (num >= 1e3 && index < abbreviations.length - 1) {
1449
+ num /= 1e3;
1450
+ index++;
1451
+ }
1452
+ const sign = value < 0 ? "-" : "";
1453
+ const decimalPlaces = num <= 10 ? 1 : 0;
1454
+ const rounded = num.toFixed(decimalPlaces);
1455
+ return `${sign}${rounded}${abbreviations[index]}`;
1456
+ }
1457
+ var CustomizedCross5 = (props) => {
1458
+ const { width, height } = props;
1459
+ return /* @__PURE__ */ jsxRuntime.jsx(
1460
+ recharts.Cross,
1461
+ {
1462
+ x: props.x + props.width / 2,
1463
+ top: props.top,
1464
+ height,
1465
+ width: 1,
1466
+ stroke: "rgba(255,255,255,0.16)",
1467
+ strokeDasharray: "3 2",
1468
+ fill: "none"
1469
+ }
1470
+ );
1471
+ };
1472
+ var CustomTooltip4 = (props) => {
1473
+ const { active, payload, label } = props;
1474
+ if (active && payload && payload.length >= 1) {
1475
+ const data = payload[0].payload;
1476
+ const hasPrice = data.close !== null && data.close !== void 0;
1477
+ if (!hasPrice) {
1478
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1479
+ orderlyUi.Box,
1480
+ {
1481
+ intensity: 600,
1482
+ p: 3,
1483
+ r: "md",
1484
+ className: "oui-flex oui-flex-col oui-gap-2",
1485
+ children: [
1486
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-text-base-contrast-54", children: "Price data unavailable" }),
1487
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16", children: [
1488
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Time:" }),
1489
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: label })
1490
+ ] })
1491
+ ]
1492
+ }
1493
+ );
1494
+ }
1495
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1496
+ orderlyUi.Box,
1497
+ {
1498
+ intensity: 600,
1499
+ p: 3,
1500
+ r: "md",
1501
+ className: "oui-flex oui-flex-col oui-gap-2",
1502
+ children: [
1503
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1504
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Open:" }),
1505
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: data.open?.toFixed(2) ?? "--" })
1506
+ ] }),
1507
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1508
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "High:" }),
1509
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: data.high?.toFixed(2) ?? "--" })
1510
+ ] }),
1511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1512
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Low:" }),
1513
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: data.low?.toFixed(2) ?? "--" })
1514
+ ] }),
1515
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
1516
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Close:" }),
1517
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: data.close.toFixed(2) })
1518
+ ] }),
1519
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16", children: [
1520
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-text-base-contrast-54", children: "Time:" }),
1521
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-font-semibold", children: label })
1522
+ ] })
1523
+ ]
1524
+ }
1525
+ );
1526
+ }
1527
+ return null;
1528
+ };
1529
+ var calculateOptimalInterval4 = (dataLength, aggregationWindow, isMobile = false) => {
1530
+ if (dataLength <= 12 && !isMobile) return 0;
1531
+ let targetLabels;
1532
+ if (dataLength > 500) {
1533
+ targetLabels = 6;
1534
+ } else if (dataLength > 200) {
1535
+ targetLabels = 6;
1536
+ } else if (dataLength > 100) {
1537
+ targetLabels = 7;
1538
+ } else if (dataLength > 50) {
1539
+ targetLabels = 8;
1540
+ } else {
1541
+ targetLabels = 12;
1542
+ }
1543
+ if (isMobile) {
1544
+ targetLabels = Math.ceil(targetLabels / 2);
1545
+ }
1546
+ const baseInterval = Math.ceil(dataLength / targetLabels);
1547
+ if (aggregationWindow === "15m") {
1548
+ if (baseInterval >= 96) return Math.ceil(baseInterval / 56) * 56;
1549
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
1550
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 16) * 16;
1551
+ return Math.max(8, Math.ceil(baseInterval / 4) * 4);
1552
+ }
1553
+ if (aggregationWindow === "1h") {
1554
+ if (baseInterval >= 48) return Math.ceil(baseInterval / 28) * 28;
1555
+ if (baseInterval >= 24) return Math.ceil(baseInterval / 12) * 12;
1556
+ return Math.max(4, Math.ceil(baseInterval / 4) * 4);
1557
+ }
1558
+ if (aggregationWindow === "1d") {
1559
+ if (baseInterval >= 14) return Math.ceil(baseInterval / 14) * 14;
1560
+ if (baseInterval >= 3) return Math.ceil(baseInterval / 7) * 7;
1561
+ }
1562
+ return baseInterval;
1563
+ };
1564
+ function tickFormatter5(value) {
1565
+ return value.toFixed(2);
1566
+ }
1567
+ var CombinedPriceChart = (props) => {
1568
+ const {
1569
+ data,
1570
+ aggregationWindow = "1d",
1571
+ isMobile = false,
1572
+ invisible,
1573
+ responsiveContainerProps,
1574
+ className
1575
+ } = props;
1576
+ useColors();
1577
+ const xAxisInterval = react.useMemo(
1578
+ () => calculateOptimalInterval4(data.length, aggregationWindow, isMobile),
1579
+ [data.length, aggregationWindow, isMobile]
1580
+ );
1581
+ const yAxisDomainAndTicks = react.useMemo(() => {
1582
+ if (data.length === 0) return { domain: [0, 1], ticks: [0, 1] };
1583
+ const closePrices = data.map((item) => item.close).filter((price) => price !== null && price !== void 0);
1584
+ if (closePrices.length === 0) return { domain: [0, 1], ticks: [0, 1] };
1585
+ const minPrice = Math.min(...closePrices);
1586
+ const maxPrice = Math.max(...closePrices);
1587
+ const range = maxPrice - minPrice;
1588
+ if (range === 0)
1589
+ return {
1590
+ domain: [minPrice - 1, maxPrice + 1],
1591
+ ticks: [minPrice - 1, maxPrice + 1]
1592
+ };
1593
+ const padding = range * 0.1;
1594
+ const lower = minPrice - padding;
1595
+ const upper = maxPrice + padding;
1596
+ const magnitude = Math.pow(10, Math.floor(Math.log10(range)));
1597
+ let step = magnitude;
1598
+ const rangeWidth = upper - lower;
1599
+ for (const divisor of [1, 2, 2.5, 5]) {
1600
+ const candidate = magnitude * divisor;
1601
+ const tickCount = Math.ceil(rangeWidth / candidate);
1602
+ if (tickCount >= 4 && tickCount <= 6) {
1603
+ step = candidate;
1604
+ break;
1605
+ }
1606
+ }
1607
+ const roundedLower = Math.floor(lower / step) * step;
1608
+ const roundedUpper = Math.ceil(upper / step) * step;
1609
+ const ticks = [];
1610
+ for (let tick = roundedLower; tick <= roundedUpper; tick += step) {
1611
+ ticks.push(Number(tick.toFixed(10)));
1612
+ }
1613
+ return { domain: [roundedLower, roundedUpper], ticks };
1614
+ }, [data]);
1615
+ if (invisible || data.length === 0) {
1616
+ return /* @__PURE__ */ jsxRuntime.jsx(
1617
+ ChartEmptyState,
1618
+ {
1619
+ title: "No Price Data",
1620
+ description: "No price data available for the selected period",
1621
+ height: "100%",
1622
+ className
1623
+ }
1624
+ );
1625
+ }
1626
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
1627
+ recharts.ResponsiveContainer,
1628
+ {
1629
+ width: "100%",
1630
+ height: "100%",
1631
+ ...responsiveContainerProps,
1632
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1633
+ recharts.ComposedChart,
1634
+ {
1635
+ data,
1636
+ margin: { left: 45, top: 10, right: 50, bottom: 20 },
1637
+ syncId: "symbol-performance",
1638
+ children: [
1639
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, { cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross5, {}), content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip4, {}) }),
1640
+ /* @__PURE__ */ jsxRuntime.jsx(
1641
+ recharts.CartesianGrid,
1642
+ {
1643
+ vertical: false,
1644
+ stroke: "#FFFFFF",
1645
+ strokeOpacity: 0.04
1646
+ }
1647
+ ),
1648
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
1649
+ /* @__PURE__ */ jsxRuntime.jsx(
1650
+ recharts.YAxis,
1651
+ {
1652
+ domain: yAxisDomainAndTicks.domain,
1653
+ ticks: yAxisDomainAndTicks.ticks,
1654
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1655
+ tickLine: false,
1656
+ axisLine: false,
1657
+ tickFormatter: tickFormatter5,
1658
+ width: 50
1659
+ }
1660
+ ),
1661
+ /* @__PURE__ */ jsxRuntime.jsx(
1662
+ recharts.XAxis,
1663
+ {
1664
+ dataKey: "date",
1665
+ tickLine: false,
1666
+ interval: xAxisInterval,
1667
+ minTickGap: 50,
1668
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1669
+ stroke: "#FFFFFF",
1670
+ strokeOpacity: 0.04
1671
+ }
1672
+ ),
1673
+ /* @__PURE__ */ jsxRuntime.jsx(
1674
+ recharts.Line,
1675
+ {
1676
+ type: "natural",
1677
+ dataKey: "close",
1678
+ stroke: "#00B49E",
1679
+ strokeWidth: 2,
1680
+ dot: false,
1681
+ isAnimationActive: false,
1682
+ strokeLinecap: "round",
1683
+ strokeLinejoin: "round"
1684
+ }
1685
+ )
1686
+ ]
1687
+ }
1688
+ )
1689
+ }
1690
+ ) });
1691
+ };
1692
+ var CustomTooltip5 = (props) => {
1693
+ const { active, payload, label } = props;
1694
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
1695
+ const { t } = orderlyI18n.useTranslation();
1696
+ if (active && payload && payload.length) {
1697
+ return /* @__PURE__ */ jsxRuntime.jsx(
1698
+ OrderlyChartTooltip,
1699
+ {
1700
+ label: label === todayStr.current ? t("chart.now") : label,
1701
+ value: payload[0].value
1702
+ }
1703
+ );
1704
+ }
1705
+ return null;
1706
+ };
1707
+ var AssetLineChart = (props) => {
1708
+ const { responsiveContainerProps } = props;
1709
+ const colors = useColors(props.colors);
1710
+ const colorId = react.useId();
1711
+ const { isMobile } = orderlyUi.useScreen();
1712
+ const chartComponent = isMobile ? /* @__PURE__ */ jsxRuntime.jsxs(
1713
+ recharts.AreaChart,
1714
+ {
1715
+ width: 530,
1716
+ height: 180,
1717
+ data: props.data,
1718
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
1719
+ children: [
1720
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
1721
+ /* @__PURE__ */ jsxRuntime.jsx(
1722
+ recharts.XAxis,
1723
+ {
1724
+ dataKey: "date",
1725
+ interval: props.data.length - 2,
1726
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
1727
+ stroke: "#FFFFFF",
1728
+ strokeOpacity: 0.04
1729
+ }
1730
+ ),
1731
+ /* @__PURE__ */ jsxRuntime.jsx(
1732
+ recharts.YAxis,
1733
+ {
1734
+ dataKey: "account_value",
1735
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1736
+ tickLine: false,
1737
+ axisLine: false,
1738
+ tickFormatter: (value) => tickFormatter(value)
1739
+ }
1740
+ ),
1741
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1742
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
1743
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
1744
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
1745
+ ] }) }),
1746
+ /* @__PURE__ */ jsxRuntime.jsx(
1747
+ recharts.Area,
1748
+ {
1749
+ type: "natural",
1750
+ dataKey: "account_value",
1751
+ stroke: colors.profit,
1752
+ strokeWidth: isMobile ? 1.5 : 2,
1753
+ dot: false,
1754
+ isAnimationActive: false,
1755
+ fill: `url(#${colorId})`
1756
+ }
1757
+ )
1758
+ ] })
1759
+ ]
1760
+ }
1761
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(
1762
+ recharts.LineChart,
1763
+ {
1764
+ width: 530,
1765
+ height: 180,
1766
+ data: props.data,
1767
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
1768
+ children: [
1769
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
1770
+ /* @__PURE__ */ jsxRuntime.jsx(
1771
+ recharts.XAxis,
1772
+ {
1773
+ dataKey: "date",
1774
+ interval: props.data.length - 2,
1775
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
1776
+ stroke: "#FFFFFF",
1777
+ strokeOpacity: 0.04
1778
+ }
1779
+ ),
1780
+ /* @__PURE__ */ jsxRuntime.jsx(
1781
+ recharts.YAxis,
1782
+ {
1783
+ dataKey: "account_value",
1784
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1785
+ tickLine: false,
1786
+ axisLine: false,
1787
+ tickFormatter
1788
+ }
1789
+ ),
1790
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
1791
+ recharts.Tooltip,
1792
+ {
1793
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
1794
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip5, {})
1795
+ }
1796
+ ),
1797
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
1798
+ recharts.Line,
1799
+ {
1800
+ type: "natural",
1801
+ dataKey: "account_value",
1802
+ stroke: colors.profit,
1803
+ strokeWidth: isMobile ? 1.5 : 2,
1804
+ dot: false,
1805
+ isAnimationActive: false
1806
+ }
1807
+ )
1808
+ ]
1809
+ }
1810
+ );
1811
+ return /* @__PURE__ */ jsxRuntime.jsx(
1812
+ recharts.ResponsiveContainer,
1813
+ {
1814
+ className: props.invisible ? "chart-invisible" : void 0,
1815
+ ...responsiveContainerProps,
1816
+ children: chartComponent
1817
+ }
1818
+ );
1819
+ };
1820
+ var CustomTooltip6 = (props) => {
1821
+ const { active, payload, label } = props;
1822
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
1823
+ const { t } = orderlyI18n.useTranslation();
1824
+ if (active && payload && payload.length) {
1825
+ return /* @__PURE__ */ jsxRuntime.jsx(
1826
+ OrderlyChartTooltip,
1827
+ {
1828
+ label: label === todayStr.current ? t("chart.now") : label,
1829
+ value: payload[0].value
1830
+ }
1831
+ );
1832
+ }
1833
+ return null;
1834
+ };
1835
+ var AssetAreaChart = (props) => {
1836
+ const { responsiveContainerProps } = props;
1837
+ const colors = useColors(props.colors);
1838
+ const colorId = react.useId();
1839
+ const { isMobile } = orderlyUi.useScreen();
1840
+ const chartComponent = /* @__PURE__ */ jsxRuntime.jsxs(
1841
+ recharts.AreaChart,
1842
+ {
1843
+ width: 530,
1844
+ height: 180,
1845
+ data: props.data,
1846
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
1847
+ children: [
1848
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
1849
+ /* @__PURE__ */ jsxRuntime.jsx(
1850
+ recharts.XAxis,
1851
+ {
1852
+ dataKey: "date",
1853
+ interval: props.data.length - 2,
1854
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
1855
+ stroke: "#FFFFFF",
1856
+ strokeOpacity: 0.04
1857
+ }
1858
+ ),
1859
+ /* @__PURE__ */ jsxRuntime.jsx(
1860
+ recharts.YAxis,
1861
+ {
1862
+ dataKey: "account_value",
1863
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
1864
+ tickLine: false,
1865
+ axisLine: false,
1866
+ tickFormatter
1867
+ }
1868
+ ),
1869
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
1870
+ recharts.Tooltip,
1871
+ {
1872
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
1873
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip6, {})
1874
+ }
1875
+ ),
1876
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1877
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
1878
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
1879
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
1880
+ ] }) }),
1881
+ /* @__PURE__ */ jsxRuntime.jsx(
1882
+ recharts.Area,
1883
+ {
1884
+ type: "natural",
1885
+ dataKey: "account_value",
1886
+ stroke: colors.profit,
1887
+ strokeWidth: isMobile ? 1.5 : 2,
1888
+ dot: false,
1889
+ isAnimationActive: false,
1890
+ fill: `url(#${colorId})`
1891
+ }
1892
+ )
1893
+ ] })
1894
+ ]
1895
+ }
1896
+ );
1897
+ return /* @__PURE__ */ jsxRuntime.jsx(
1898
+ recharts.ResponsiveContainer,
1899
+ {
1900
+ className: props.invisible ? "chart-invisible" : void 0,
1901
+ ...responsiveContainerProps,
1902
+ children: chartComponent
1903
+ }
1904
+ );
1905
+ };
1906
+ var RoundedRectangle5 = (props) => {
1907
+ const { fill, x, y, width, height, opacity } = props;
1908
+ const absHeight = Math.abs(height);
1909
+ return /* @__PURE__ */ jsxRuntime.jsx(
1910
+ "rect",
1911
+ {
1912
+ rx: 2,
1913
+ x,
1914
+ y: height > 0 ? y : y + height,
1915
+ width,
1916
+ height: absHeight,
1917
+ stroke: "none",
1918
+ fill,
1919
+ opacity
1920
+ }
1921
+ );
1922
+ };
1923
+ var CustomizedCross6 = (props) => {
1924
+ const { width, height, payload, stroke, fill } = props;
1925
+ if (payload?.[0]?.value === 0) {
1926
+ return null;
1927
+ }
1928
+ return (
1929
+ // @ts-ignore
1930
+ /* @__PURE__ */ jsxRuntime.jsx(
1931
+ recharts.Cross,
1932
+ {
1933
+ x: props.x + props.width / 2,
1934
+ top: props.top,
1935
+ height,
1936
+ width: 1,
1937
+ stroke: "rgba(255,255,255,0.16)",
1938
+ strokeDasharray: "3 2",
1939
+ fill: "none"
1940
+ }
1941
+ )
1942
+ );
1943
+ };
1944
+ var CustomTooltip7 = (props) => {
1945
+ const { active, payload, label, tooltip } = props;
1946
+ if (payload?.[0]?.value === 0) {
1947
+ return null;
1948
+ }
1949
+ if (active && payload && payload.length) {
1950
+ return /* @__PURE__ */ jsxRuntime.jsx(
1951
+ OrderlyChartTooltip,
1952
+ {
1953
+ label,
1954
+ value: payload[0].value,
1955
+ titleClassName: "oui-gap-4",
1956
+ rm: tooltip?.rm,
1957
+ dp: tooltip?.dp
1958
+ }
1959
+ );
1960
+ }
1961
+ return null;
1962
+ };
1963
+ var VolBarChart = (props) => {
1964
+ const colors = useColors(
1965
+ props.colors?.fill ? { profit: props.colors?.fill, loss: props.colors?.fill } : void 0
1966
+ );
1967
+ const isEmpty = props.data?.reduce((pre, cur) => pre + cur.volume, 0) === 0;
1968
+ const maxVolume = props.data?.reduce(
1969
+ (pre, cur) => pre > cur.volume ? pre : cur.volume,
1970
+ 0
1971
+ );
1972
+ const decimal = maxVolume <= 10 ? 2 : maxVolume <= 100 ? 1 : 0;
1973
+ return (
1974
+ // @ts-ignore
1975
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn(props.className), children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1976
+ recharts.BarChart,
1977
+ {
1978
+ data: props.data,
1979
+ margin: { left: -0, top: 6, right: 0, bottom: 20 },
1980
+ children: [
1981
+ /* @__PURE__ */ jsxRuntime.jsx(
1982
+ recharts.Tooltip,
1983
+ {
1984
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross6, {}),
1985
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip7, { tooltip: props.tooltip })
1986
+ }
1987
+ ),
1988
+ /* @__PURE__ */ jsxRuntime.jsx(
1989
+ recharts.CartesianGrid,
1990
+ {
1991
+ vertical: false,
1992
+ stroke: "#FFFFFF",
1993
+ strokeOpacity: 0.08,
1994
+ repeatCount: 6
1995
+ }
1996
+ ),
1997
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "#000" }),
1998
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { dataKey: "volume", shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle5, {}), minPointSize: 1, children: props.data.map((entry, index) => {
1999
+ return (
2000
+ // @ts-ignore
2001
+ /* @__PURE__ */ jsxRuntime.jsx(
2002
+ recharts.Cell,
2003
+ {
2004
+ fill: entry.volume > 0 ? colors.profit : colors.loss,
2005
+ opacity: entry.opacity
2006
+ },
2007
+ `cell-${index}`
2008
+ )
2009
+ );
2010
+ }) }),
2011
+ /* @__PURE__ */ jsxRuntime.jsx(
2012
+ recharts.YAxis,
2013
+ {
2014
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
2015
+ tickLine: false,
2016
+ axisLine: false,
2017
+ dataKey: "volume",
2018
+ tickFormatter: (value, index) => {
2019
+ if (isEmpty) return `${index * 100}`;
2020
+ return numberToHumanStyle2(value, decimal);
2021
+ },
2022
+ width: 45
2023
+ }
2024
+ ),
2025
+ /* @__PURE__ */ jsxRuntime.jsx(
2026
+ recharts.XAxis,
2027
+ {
2028
+ dataKey: "date",
2029
+ tickLine: false,
2030
+ interval: props.data.length - 2,
2031
+ height: 1,
2032
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
2033
+ stroke: "rgb(229, 231, 235)",
2034
+ strokeOpacity: 0.2
2035
+ }
2036
+ )
2037
+ ]
2038
+ }
2039
+ ) }) })
2040
+ );
2041
+ };
2042
+ function numberToHumanStyle2(number, decimalPlaces = 0) {
2043
+ const abbreviations = ["", "K", "M", "B", "T"];
2044
+ let index = 0;
2045
+ while (number >= 1e3 && index < abbreviations.length - 1) {
2046
+ number /= 1e3;
2047
+ index++;
2048
+ }
2049
+ const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);
2050
+ return `${roundedNumber}${abbreviations[index]}`;
2051
+ }
2052
+ function toFixedWithoutRounding(num, fix) {
2053
+ const numStr = num.toString();
2054
+ const decimalIndex = numStr.indexOf(".");
2055
+ if (decimalIndex === -1 || fix === 0) {
2056
+ return numStr.split(".")[0];
2057
+ }
2058
+ const cutoffIndex = decimalIndex + fix + 1;
2059
+ return numStr.slice(0, cutoffIndex);
2060
+ }
2061
+ var CustomizedCross7 = (props) => {
2062
+ const { width, height } = props;
2063
+ return /* @__PURE__ */ jsxRuntime.jsx(
2064
+ recharts.Cross,
2065
+ {
2066
+ x: props.x + props.width / 2,
2067
+ top: props.top,
2068
+ height,
2069
+ width: 1,
2070
+ stroke: "rgba(255,255,255,0.16)",
2071
+ strokeDasharray: "3 2",
2072
+ fill: "none"
2073
+ }
2074
+ );
2075
+ };
2076
+ var UnifiedChartTooltip = (props) => {
2077
+ const { active, payload, label } = props;
2078
+ if (active && payload && payload.length > 0) {
2079
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2080
+ orderlyUi.Box,
2081
+ {
2082
+ intensity: 600,
2083
+ p: 3,
2084
+ r: "md",
2085
+ className: "oui-flex oui-flex-col oui-gap-2",
2086
+ children: [
2087
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-font-semibold", children: label }),
2088
+ payload.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-flex oui-gap-2", children: [
2089
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: entry.color }, className: "oui-font-semibold", children: [
2090
+ entry.name,
2091
+ ":"
2092
+ ] }),
2093
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: entry.value?.toFixed(2) || 0 })
2094
+ ] }, index))
2095
+ ]
2096
+ }
2097
+ );
2098
+ }
2099
+ return null;
2100
+ };
2101
+ var UnifiedSymbolPerformanceChart = ({
2102
+ volumeData,
2103
+ feesData,
2104
+ priceData,
2105
+ aggregationWindow,
2106
+ includeFees,
2107
+ className
2108
+ }) => {
2109
+ const mergedData = react.useMemo(() => {
2110
+ const dataMap = /* @__PURE__ */ new Map();
2111
+ volumeData.forEach((item) => {
2112
+ dataMap.set(item.date, {
2113
+ ...dataMap.get(item.date),
2114
+ date: item.date,
2115
+ volume: item.volume
2116
+ });
2117
+ });
2118
+ feesData.forEach((item) => {
2119
+ dataMap.set(item.date, {
2120
+ ...dataMap.get(item.date),
2121
+ date: item.date,
2122
+ fees: item.fees
2123
+ });
2124
+ });
2125
+ priceData.forEach((item) => {
2126
+ dataMap.set(item.date, {
2127
+ ...dataMap.get(item.date),
2128
+ date: item.date,
2129
+ open: item.open,
2130
+ high: item.high,
2131
+ low: item.low,
2132
+ close: item.close
2133
+ });
2134
+ });
2135
+ return Array.from(dataMap.values());
2136
+ }, [volumeData, feesData, priceData]);
2137
+ if (mergedData.length === 0) {
2138
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-center oui-text-base-contrast-54 oui-py-10", children: "No data available" }) });
2139
+ }
2140
+ return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { className: orderlyUi.cn("oui-w-full oui-h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
2141
+ recharts.ComposedChart,
2142
+ {
2143
+ data: mergedData,
2144
+ margin: { left: 0, top: 10, right: 10, bottom: 20 },
2145
+ children: [
2146
+ /* @__PURE__ */ jsxRuntime.jsx(
2147
+ recharts.CartesianGrid,
2148
+ {
2149
+ vertical: false,
2150
+ stroke: "#FFFFFF",
2151
+ strokeOpacity: 0.04
2152
+ }
2153
+ ),
2154
+ /* @__PURE__ */ jsxRuntime.jsx(
2155
+ recharts.XAxis,
2156
+ {
2157
+ dataKey: "date",
2158
+ tickLine: false,
2159
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
2160
+ stroke: "#FFFFFF",
2161
+ strokeOpacity: 0.04
2162
+ }
2163
+ ),
2164
+ /* @__PURE__ */ jsxRuntime.jsx(
2165
+ recharts.YAxis,
2166
+ {
2167
+ yAxisId: "left",
2168
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
2169
+ tickLine: false,
2170
+ axisLine: false,
2171
+ width: 45,
2172
+ label: {
2173
+ value: "Volume / Fees",
2174
+ angle: -90,
2175
+ position: "insideLeft"
2176
+ }
2177
+ }
2178
+ ),
2179
+ /* @__PURE__ */ jsxRuntime.jsx(
2180
+ recharts.YAxis,
2181
+ {
2182
+ yAxisId: "right",
2183
+ orientation: "right",
2184
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
2185
+ tickLine: false,
2186
+ axisLine: false,
2187
+ width: 50,
2188
+ label: { value: "Price", angle: 90, position: "insideRight" }
2189
+ }
2190
+ ),
2191
+ /* @__PURE__ */ jsxRuntime.jsx(
2192
+ recharts.Tooltip,
2193
+ {
2194
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross7, {}),
2195
+ content: /* @__PURE__ */ jsxRuntime.jsx(UnifiedChartTooltip, {})
2196
+ }
2197
+ ),
2198
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
2199
+ /* @__PURE__ */ jsxRuntime.jsx(
2200
+ recharts.Bar,
2201
+ {
2202
+ yAxisId: "left",
2203
+ dataKey: "volume",
2204
+ fill: "rgba(0, 180, 158, 0.6)",
2205
+ name: "Volume"
2206
+ }
2207
+ ),
2208
+ /* @__PURE__ */ jsxRuntime.jsx(
2209
+ recharts.Bar,
2210
+ {
2211
+ yAxisId: "left",
2212
+ dataKey: "fees",
2213
+ fill: "rgba(255, 107, 107, 0.6)",
2214
+ name: "Fees"
2215
+ }
2216
+ ),
2217
+ /* @__PURE__ */ jsxRuntime.jsx(
2218
+ recharts.Line,
2219
+ {
2220
+ yAxisId: "right",
2221
+ type: "natural",
2222
+ dataKey: "close",
2223
+ stroke: "#00B49E",
2224
+ strokeWidth: 2,
2225
+ dot: false,
2226
+ isAnimationActive: false,
2227
+ name: "Price",
2228
+ strokeLinecap: "round",
2229
+ strokeLinejoin: "round"
2230
+ }
2231
+ )
2232
+ ]
2233
+ }
2234
+ ) }) });
2235
+ };
2236
+
2237
+ // src/tailwindcss/theme.ts
2238
+ var import_plugin = __toESM(require_plugin());
2239
+ var chartPlugin = () => (0, import_plugin.default)(function({ addComponents, addBase }) {
2240
+ addComponents(
2241
+ {
2242
+ ".xAxis": {
2243
+ ".recharts-cartesian-axis-tick:first-child text": {
2244
+ "text-anchor": "start"
2245
+ },
2246
+ ".recharts-cartesian-axis-tick:last-child text": {
2247
+ "text-anchor": "end"
2248
+ }
2249
+ }
2250
+ },
2251
+ {
2252
+ respectPrefix: false
2253
+ }
2254
+ );
2255
+ });
2256
+
2257
+ Object.defineProperty(exports, "Area", {
2258
+ enumerable: true,
2259
+ get: function () { return recharts.Area; }
2260
+ });
2261
+ Object.defineProperty(exports, "AreaChart", {
2262
+ enumerable: true,
2263
+ get: function () { return recharts.AreaChart; }
2264
+ });
2265
+ Object.defineProperty(exports, "Bar", {
2266
+ enumerable: true,
2267
+ get: function () { return recharts.Bar; }
2268
+ });
2269
+ Object.defineProperty(exports, "BarChart", {
2270
+ enumerable: true,
2271
+ get: function () { return recharts.BarChart; }
2272
+ });
2273
+ Object.defineProperty(exports, "Cell", {
2274
+ enumerable: true,
2275
+ get: function () { return recharts.Cell; }
2276
+ });
2277
+ Object.defineProperty(exports, "Line", {
2278
+ enumerable: true,
2279
+ get: function () { return recharts.Line; }
2280
+ });
2281
+ Object.defineProperty(exports, "LineChart", {
2282
+ enumerable: true,
2283
+ get: function () { return recharts.LineChart; }
2284
+ });
2285
+ exports.AssetAreaChart = AssetAreaChart;
2286
+ exports.AssetLineChart = AssetLineChart;
2287
+ exports.ChartEmptyState = ChartEmptyState;
2288
+ exports.CombinedFeesChart = CombinedFeesChart;
2289
+ exports.CombinedPnLChart = CombinedPnLChart;
2290
+ exports.CombinedPriceChart = CombinedPriceChart;
2291
+ exports.CombinedVolumeChart = CombinedVolumeChart;
2292
+ exports.PnLBarChart = PnLBarChart;
2293
+ exports.PnlAreaChart = PnlAreaChart;
2294
+ exports.PnlLineChart = PnlLineChart;
2295
+ exports.UnifiedSymbolPerformanceChart = UnifiedSymbolPerformanceChart;
2296
+ exports.VolBarChart = VolBarChart;
2297
+ exports.chartPlugin = chartPlugin;
2298
+ //# sourceMappingURL=index.js.map
2
2299
  //# sourceMappingURL=index.js.map