@orderly.network/chart 2.8.1 → 2.8.2-alpha.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,944 @@
1
- 'use strict';var react=require('react'),recharts=require('recharts'),i18n=require('@orderly.network/i18n'),ui=require('@orderly.network/ui'),utils=require('@orderly.network/utils'),jsxRuntime=require('react/jsx-runtime');var Y=Object.create;var L=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var F=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var J=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of q(r))!U.call(t,a)&&a!==e&&L(t,a,{get:()=>r[a],enumerable:!(o=H(r,a))||o.enumerable});return t};var Z=(t,r,e)=>(e=t!=null?Y(Q(t)):{},J(!t||!t.__esModule?L(e,"default",{value:t,enumerable:true}):e,t));var $=F(R=>{Object.defineProperty(R,"__esModule",{value:true});Object.defineProperty(R,"default",{enumerable:true,get:function(){return Xe}});function M(t,r){return {handler:t,config:r}}M.withOptions=function(t,r=()=>({})){let e=function(o){return {__options:o,handler:t(o),config:r(o)}};return e.__isOptionsFunction=true,e.__pluginFunction=t,e.__configFunction=r,e};var Xe=M;});var G=F(A=>{Object.defineProperty(A,"__esModule",{value:true});Object.defineProperty(A,"default",{enumerable:true,get:function(){return Ye}});var We=Ee($());function Ee(t){return t&&t.__esModule?t:{default:t}}var Ye=We.default;});var W=F((ho,X)=>{var T=G();X.exports=(T.__esModule?T:{default:T}).default;});var d=t=>{let r=Math.abs(t),e=r===0?0:r<=10?2:r<=100?1:0,o=utils.numberToHumanStyle(r,e);return t<0?`-${o}`:o};var p=t=>{let{label:r,value:e,prefix:o,unit:a="USDC",coloring:i=false,dp:n,rm:y}=t;return jsxRuntime.jsxs(ui.Box,{intensity:600,p:3,r:"md",children:[jsxRuntime.jsxs(ui.Flex,{direction:"row",className:t.titleClassName,children:[o,jsxRuntime.jsx(ui.Text.numeral,{unit:a,as:"div",size:"sm",coloring:i,showIdentifier:i,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:y,dp:n,children:e})]}),jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:54,weight:"semibold",children:r})]})};var _=()=>{let t=document.documentElement,r=getComputedStyle(t);return {primary:h(r.getPropertyValue("--oui-color-primary")),primaryLight:h(r.getPropertyValue("--oui-color-primary-light")),secondary:h(r.getPropertyValue("--oui-color-secondary")),success:h(r.getPropertyValue("--oui-color-success")),warning:h(r.getPropertyValue("--oui-color-warning")),danger:h(r.getPropertyValue("--oui-color-danger")),info:h(r.getPropertyValue("--oui-color-info")),loss:h(r.getPropertyValue("--oui-color-trading-loss")),profit:h(r.getPropertyValue("--oui-color-trading-profit"))}},h=t=>`rgb(${t.split(" ").join(",")})`;var m=t=>react.useMemo(()=>{let e=_();return {profit:t?.profit||e.profit,loss:t?.loss||e.loss,primary:e.primary,primaryLight:e.primaryLight}},[t]);var dt=t=>{let{fill:r,x:e,y:o,width:a,height:i}=t,n=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:e,y:i>0?o:o+i,width:a,height:n,stroke:"none",fill:r})},yt=t=>{let{x:r,y:e,stroke:o,payload:a,index:i,width:n,containerWidth:y}=t,{t:v}=i18n.useTranslation(),x=i===0?48:y>0?y-10:n+a.offset;return jsxRuntime.jsx("g",{transform:`translate(${x},${e-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?a.value:v("chart.now")})})},ht=t=>{let{width:r,height:e,stroke:o,fill:a}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Ct=t=>{let{active:r,payload:e,label:o}=t,a=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=i18n.useTranslation();return r&&e&&e.length?jsxRuntime.jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},gt=t=>{let{invisible:r,data:e,responsiveContainerProps:o}=t,a=m(t.colors),i=react.useRef(0);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:ui.cn(r&&"chart-invisible"),onResize:n=>{i.current=n;},...o,children:jsxRuntime.jsxs(recharts.BarChart,{data:e,margin:{left:-10,top:10,right:10,bottom:30},children:[!r&&jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(ht,{}),content:jsxRuntime.jsx(Ct,{})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!r&&jsxRuntime.jsx(recharts.Bar,{dataKey:"pnl",shape:jsxRuntime.jsx(dt,{}),children:e.map((n,y)=>jsxRuntime.jsx(recharts.Cell,{fill:n.pnl>0?a.profit:a.loss},`cell-${y}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:n=>d(n),tickLine:false,axisLine:false,dataKey:"pnl"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:e.length-2,height:1,tick:jsxRuntime.jsx(yt,{containerWidth:i.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var C=t=>{let{x:r,y:e,stroke:o,payload:a,index:i}=t,{t:n}=i18n.useTranslation();return jsxRuntime.jsx("g",{transform:`translate(${r},${e-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?a.value:n("chart.now")})})};var _t=t=>{let{active:r,payload:e,label:o}=t,a=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=i18n.useTranslation();return r&&e&&e.length?jsxRuntime.jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},Bt=t=>{let r=[];return t?.reduce((e,o)=>(e+=o.pnl,r.push({...o,pnl:e,_pnl:o.pnl}),e),0),r},It=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),{isMobile:o}=ui.useScreen(),a=react.useMemo(()=>Bt(t.data),[t.data]),i=jsxRuntime.jsxs(recharts.LineChart,{data:a,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(C,{}),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:d}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(_t,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:o?1.5:2,dot:false,isAnimationActive:false})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var Ht=t=>{let{active:r,payload:e,label:o}=t,a=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=i18n.useTranslation();return r&&e&&e.length?jsxRuntime.jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},qt=t=>{let r=[];return t?.reduce((e,o)=>(e+=o.pnl,r.push({...o,pnl:e,_pnl:o.pnl}),e),0),r},Qt=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),{isMobile:o}=ui.useScreen(),a=react.useId(),i=react.useMemo(()=>qt(t.data),[t.data]),n=react.useMemo(()=>i.map(v=>v.pnl).sort((v,x)=>v-x)[0]||0,[i]),y=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(C,{}),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:d}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(Ht,{})}),!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:e.primary,offset:"0%",stopOpacity:.5}),jsxRuntime.jsx("stop",{stopColor:e.primary,offset:"100%",stopOpacity:0})]})}),jsxRuntime.jsx(recharts.Area,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:o?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`,baseValue:n||0})]})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:y})};var se=t=>{let{active:r,payload:e,label:o}=t,a=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=i18n.useTranslation();return r&&e&&e.length?jsxRuntime.jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value}):null},le=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),o=react.useId(),{isMobile:a}=ui.useScreen(),i=a?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(C,{}),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=>d(n)}),!t.invisible&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:o,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:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${o})`})]})]}):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(C,{}),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:d}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(se,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var xe=t=>{let{active:r,payload:e,label:o}=t,a=react.useRef(new Date().toISOString().split("T")[0]),{t:i}=i18n.useTranslation();return r&&e&&e.length?jsxRuntime.jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value}):null},Fe=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),o=react.useId(),{isMobile:a}=ui.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(C,{}),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:d}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(xe,{})}),!t.invisible&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:o,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:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${o})`})]})]});return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var Ve=t=>{let{fill:r,x:e,y:o,width:a,height:i,opacity:n}=t,y=Math.abs(i);return jsxRuntime.jsx("rect",{rx:2,x:e,y:i>0?o:o+i,width:a,height:y,stroke:"none",fill:r,opacity:n})},Ke=t=>{let{width:r,height:e,payload:o,stroke:a,fill:i}=t;return o?.[0]?.value===0?null:jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ze=t=>{let{active:r,payload:e,label:o,tooltip:a}=t;return e?.[0]?.value===0?null:r&&e&&e.length?jsxRuntime.jsx(p,{label:o,value:e[0].value,titleClassName:"oui-gap-4",rm:a?.rm,dp:a?.dp}):null},Ne=t=>{let r=m(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),e=t.data?.reduce((i,n)=>i+n.volume,0)===0,o=t.data?.reduce((i,n)=>i>n.volume?i:n.volume,0),a=o<=10?2:o<=100?1:0;return jsxRuntime.jsx(ui.Box,{className:ui.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(Ke,{}),content:jsxRuntime.jsx(ze,{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(Ve,{}),minPointSize:1,children:t.data.map((i,n)=>jsxRuntime.jsx(recharts.Cell,{fill:i.volume>0?r.profit:r.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)=>e?`${n*100}`:Me(i,a),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 Me(t,r=0){let e=["","K","M","B","T"],o=0;for(;t>=1e3&&o<e.length-1;)t/=1e3,o++;return `${$e(t,r)}${e[o]}`}function $e(t,r){let e=t.toString(),o=e.indexOf(".");if(o===-1||r===0)return e.split(".")[0];let a=o+r+1;return e.slice(0,a)}var E=Z(W()),He=()=>(0, E.default)(function({addComponents:t,addBase:r}){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=Fe;exports.AssetLineChart=le;exports.PnLBarChart=gt;exports.PnlAreaChart=Qt;exports.PnlLineChart=It;exports.VolBarChart=Ne;exports.chartPlugin=He;//# sourceMappingURL=index.js.map
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var recharts = require('recharts');
5
+ var i18n = require('@orderly.network/i18n');
6
+ var ui = require('@orderly.network/ui');
7
+ var utils = require('@orderly.network/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 = utils.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(ui.Box, { intensity: 600, p: 3, r: "md", children: [
117
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", className: props.titleClassName, children: [
118
+ prefix,
119
+ /* @__PURE__ */ jsxRuntime.jsx(
120
+ ui.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(ui.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 } = i18n.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 } = i18n.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: ui.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 } = i18n.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 } = i18n.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 } = ui.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 } = i18n.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 } = ui.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 CustomTooltip4 = (props) => {
519
+ const { active, payload, label } = props;
520
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
521
+ const { t } = i18n.useTranslation();
522
+ if (active && payload && payload.length) {
523
+ return /* @__PURE__ */ jsxRuntime.jsx(
524
+ OrderlyChartTooltip,
525
+ {
526
+ label: label === todayStr.current ? t("chart.now") : label,
527
+ value: payload[0].value
528
+ }
529
+ );
530
+ }
531
+ return null;
532
+ };
533
+ var AssetLineChart = (props) => {
534
+ const { responsiveContainerProps } = props;
535
+ const colors = useColors(props.colors);
536
+ const colorId = react.useId();
537
+ const { isMobile } = ui.useScreen();
538
+ const chartComponent = isMobile ? /* @__PURE__ */ jsxRuntime.jsxs(
539
+ recharts.AreaChart,
540
+ {
541
+ width: 530,
542
+ height: 180,
543
+ data: props.data,
544
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
545
+ children: [
546
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
547
+ /* @__PURE__ */ jsxRuntime.jsx(
548
+ recharts.XAxis,
549
+ {
550
+ dataKey: "date",
551
+ interval: props.data.length - 2,
552
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
553
+ stroke: "#FFFFFF",
554
+ strokeOpacity: 0.04
555
+ }
556
+ ),
557
+ /* @__PURE__ */ jsxRuntime.jsx(
558
+ recharts.YAxis,
559
+ {
560
+ dataKey: "account_value",
561
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
562
+ tickLine: false,
563
+ axisLine: false,
564
+ tickFormatter: (value) => tickFormatter(value)
565
+ }
566
+ ),
567
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
568
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
569
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
570
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
571
+ ] }) }),
572
+ /* @__PURE__ */ jsxRuntime.jsx(
573
+ recharts.Area,
574
+ {
575
+ type: "natural",
576
+ dataKey: "account_value",
577
+ stroke: colors.profit,
578
+ strokeWidth: isMobile ? 1.5 : 2,
579
+ dot: false,
580
+ isAnimationActive: false,
581
+ fill: `url(#${colorId})`
582
+ }
583
+ )
584
+ ] })
585
+ ]
586
+ }
587
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(
588
+ recharts.LineChart,
589
+ {
590
+ width: 530,
591
+ height: 180,
592
+ data: props.data,
593
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
594
+ children: [
595
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
596
+ /* @__PURE__ */ jsxRuntime.jsx(
597
+ recharts.XAxis,
598
+ {
599
+ dataKey: "date",
600
+ interval: props.data.length - 2,
601
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
602
+ stroke: "#FFFFFF",
603
+ strokeOpacity: 0.04
604
+ }
605
+ ),
606
+ /* @__PURE__ */ jsxRuntime.jsx(
607
+ recharts.YAxis,
608
+ {
609
+ dataKey: "account_value",
610
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
611
+ tickLine: false,
612
+ axisLine: false,
613
+ tickFormatter
614
+ }
615
+ ),
616
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
617
+ recharts.Tooltip,
618
+ {
619
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
620
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip4, {})
621
+ }
622
+ ),
623
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
624
+ recharts.Line,
625
+ {
626
+ type: "natural",
627
+ dataKey: "account_value",
628
+ stroke: colors.profit,
629
+ strokeWidth: isMobile ? 1.5 : 2,
630
+ dot: false,
631
+ isAnimationActive: false
632
+ }
633
+ )
634
+ ]
635
+ }
636
+ );
637
+ return /* @__PURE__ */ jsxRuntime.jsx(
638
+ recharts.ResponsiveContainer,
639
+ {
640
+ className: props.invisible ? "chart-invisible" : void 0,
641
+ ...responsiveContainerProps,
642
+ children: chartComponent
643
+ }
644
+ );
645
+ };
646
+ var CustomTooltip5 = (props) => {
647
+ const { active, payload, label } = props;
648
+ const todayStr = react.useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
649
+ const { t } = i18n.useTranslation();
650
+ if (active && payload && payload.length) {
651
+ return /* @__PURE__ */ jsxRuntime.jsx(
652
+ OrderlyChartTooltip,
653
+ {
654
+ label: label === todayStr.current ? t("chart.now") : label,
655
+ value: payload[0].value
656
+ }
657
+ );
658
+ }
659
+ return null;
660
+ };
661
+ var AssetAreaChart = (props) => {
662
+ const { responsiveContainerProps } = props;
663
+ const colors = useColors(props.colors);
664
+ const colorId = react.useId();
665
+ const { isMobile } = ui.useScreen();
666
+ const chartComponent = /* @__PURE__ */ jsxRuntime.jsxs(
667
+ recharts.AreaChart,
668
+ {
669
+ width: 530,
670
+ height: 180,
671
+ data: props.data,
672
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
673
+ children: [
674
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
675
+ /* @__PURE__ */ jsxRuntime.jsx(
676
+ recharts.XAxis,
677
+ {
678
+ dataKey: "date",
679
+ interval: props.data.length - 2,
680
+ tick: /* @__PURE__ */ jsxRuntime.jsx(XAxisLabel2, {}),
681
+ stroke: "#FFFFFF",
682
+ strokeOpacity: 0.04
683
+ }
684
+ ),
685
+ /* @__PURE__ */ jsxRuntime.jsx(
686
+ recharts.YAxis,
687
+ {
688
+ dataKey: "account_value",
689
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
690
+ tickLine: false,
691
+ axisLine: false,
692
+ tickFormatter
693
+ }
694
+ ),
695
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsx(
696
+ recharts.Tooltip,
697
+ {
698
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
699
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip5, {})
700
+ }
701
+ ),
702
+ !props.invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
703
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
704
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
705
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
706
+ ] }) }),
707
+ /* @__PURE__ */ jsxRuntime.jsx(
708
+ recharts.Area,
709
+ {
710
+ type: "natural",
711
+ dataKey: "account_value",
712
+ stroke: colors.profit,
713
+ strokeWidth: isMobile ? 1.5 : 2,
714
+ dot: false,
715
+ isAnimationActive: false,
716
+ fill: `url(#${colorId})`
717
+ }
718
+ )
719
+ ] })
720
+ ]
721
+ }
722
+ );
723
+ return /* @__PURE__ */ jsxRuntime.jsx(
724
+ recharts.ResponsiveContainer,
725
+ {
726
+ className: props.invisible ? "chart-invisible" : void 0,
727
+ ...responsiveContainerProps,
728
+ children: chartComponent
729
+ }
730
+ );
731
+ };
732
+ var RoundedRectangle2 = (props) => {
733
+ const { fill, x, y, width, height, opacity } = props;
734
+ const absHeight = Math.abs(height);
735
+ return /* @__PURE__ */ jsxRuntime.jsx(
736
+ "rect",
737
+ {
738
+ rx: 2,
739
+ x,
740
+ y: height > 0 ? y : y + height,
741
+ width,
742
+ height: absHeight,
743
+ stroke: "none",
744
+ fill,
745
+ opacity
746
+ }
747
+ );
748
+ };
749
+ var CustomizedCross2 = (props) => {
750
+ const { width, height, payload, stroke, fill } = props;
751
+ if (payload?.[0]?.value === 0) {
752
+ return null;
753
+ }
754
+ return (
755
+ // @ts-ignore
756
+ /* @__PURE__ */ jsxRuntime.jsx(
757
+ recharts.Cross,
758
+ {
759
+ x: props.x + props.width / 2,
760
+ top: props.top,
761
+ height,
762
+ width: 1,
763
+ stroke: "rgba(255,255,255,0.16)",
764
+ strokeDasharray: "3 2",
765
+ fill: "none"
766
+ }
767
+ )
768
+ );
769
+ };
770
+ var CustomTooltip6 = (props) => {
771
+ const { active, payload, label, tooltip } = props;
772
+ if (payload?.[0]?.value === 0) {
773
+ return null;
774
+ }
775
+ if (active && payload && payload.length) {
776
+ return /* @__PURE__ */ jsxRuntime.jsx(
777
+ OrderlyChartTooltip,
778
+ {
779
+ label,
780
+ value: payload[0].value,
781
+ titleClassName: "oui-gap-4",
782
+ rm: tooltip?.rm,
783
+ dp: tooltip?.dp
784
+ }
785
+ );
786
+ }
787
+ return null;
788
+ };
789
+ var VolBarChart = (props) => {
790
+ const colors = useColors(
791
+ props.colors?.fill ? { profit: props.colors?.fill, loss: props.colors?.fill } : void 0
792
+ );
793
+ const isEmpty = props.data?.reduce((pre, cur) => pre + cur.volume, 0) === 0;
794
+ const maxVolume = props.data?.reduce(
795
+ (pre, cur) => pre > cur.volume ? pre : cur.volume,
796
+ 0
797
+ );
798
+ const decimal = maxVolume <= 10 ? 2 : maxVolume <= 100 ? 1 : 0;
799
+ return (
800
+ // @ts-ignore
801
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: ui.cn(props.className), children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(
802
+ recharts.BarChart,
803
+ {
804
+ data: props.data,
805
+ margin: { left: -0, top: 6, right: 0, bottom: 20 },
806
+ children: [
807
+ /* @__PURE__ */ jsxRuntime.jsx(
808
+ recharts.Tooltip,
809
+ {
810
+ cursor: /* @__PURE__ */ jsxRuntime.jsx(CustomizedCross2, {}),
811
+ content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip6, { tooltip: props.tooltip })
812
+ }
813
+ ),
814
+ /* @__PURE__ */ jsxRuntime.jsx(
815
+ recharts.CartesianGrid,
816
+ {
817
+ vertical: false,
818
+ stroke: "#FFFFFF",
819
+ strokeOpacity: 0.08,
820
+ repeatCount: 6
821
+ }
822
+ ),
823
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ReferenceLine, { y: 0, stroke: "#000" }),
824
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { dataKey: "volume", shape: /* @__PURE__ */ jsxRuntime.jsx(RoundedRectangle2, {}), minPointSize: 1, children: props.data.map((entry, index) => {
825
+ return (
826
+ // @ts-ignore
827
+ /* @__PURE__ */ jsxRuntime.jsx(
828
+ recharts.Cell,
829
+ {
830
+ fill: entry.volume > 0 ? colors.profit : colors.loss,
831
+ opacity: entry.opacity
832
+ },
833
+ `cell-${index}`
834
+ )
835
+ );
836
+ }) }),
837
+ /* @__PURE__ */ jsxRuntime.jsx(
838
+ recharts.YAxis,
839
+ {
840
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
841
+ tickLine: false,
842
+ axisLine: false,
843
+ dataKey: "volume",
844
+ tickFormatter: (value, index) => {
845
+ if (isEmpty) return `${index * 100}`;
846
+ return numberToHumanStyle2(value, decimal);
847
+ },
848
+ width: 45
849
+ }
850
+ ),
851
+ /* @__PURE__ */ jsxRuntime.jsx(
852
+ recharts.XAxis,
853
+ {
854
+ dataKey: "date",
855
+ tickLine: false,
856
+ interval: props.data.length - 2,
857
+ height: 1,
858
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
859
+ stroke: "rgb(229, 231, 235)",
860
+ strokeOpacity: 0.2
861
+ }
862
+ )
863
+ ]
864
+ }
865
+ ) }) })
866
+ );
867
+ };
868
+ function numberToHumanStyle2(number, decimalPlaces = 0) {
869
+ const abbreviations = ["", "K", "M", "B", "T"];
870
+ let index = 0;
871
+ while (number >= 1e3 && index < abbreviations.length - 1) {
872
+ number /= 1e3;
873
+ index++;
874
+ }
875
+ const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);
876
+ return `${roundedNumber}${abbreviations[index]}`;
877
+ }
878
+ function toFixedWithoutRounding(num, fix) {
879
+ const numStr = num.toString();
880
+ const decimalIndex = numStr.indexOf(".");
881
+ if (decimalIndex === -1 || fix === 0) {
882
+ return numStr.split(".")[0];
883
+ }
884
+ const cutoffIndex = decimalIndex + fix + 1;
885
+ return numStr.slice(0, cutoffIndex);
886
+ }
887
+
888
+ // src/tailwindcss/theme.ts
889
+ var import_plugin = __toESM(require_plugin());
890
+ var chartPlugin = () => (0, import_plugin.default)(function({ addComponents, addBase }) {
891
+ addComponents(
892
+ {
893
+ ".xAxis": {
894
+ ".recharts-cartesian-axis-tick:first-child text": {
895
+ "text-anchor": "start"
896
+ },
897
+ ".recharts-cartesian-axis-tick:last-child text": {
898
+ "text-anchor": "end"
899
+ }
900
+ }
901
+ },
902
+ {
903
+ respectPrefix: false
904
+ }
905
+ );
906
+ });
907
+
908
+ Object.defineProperty(exports, "Area", {
909
+ enumerable: true,
910
+ get: function () { return recharts.Area; }
911
+ });
912
+ Object.defineProperty(exports, "AreaChart", {
913
+ enumerable: true,
914
+ get: function () { return recharts.AreaChart; }
915
+ });
916
+ Object.defineProperty(exports, "Bar", {
917
+ enumerable: true,
918
+ get: function () { return recharts.Bar; }
919
+ });
920
+ Object.defineProperty(exports, "BarChart", {
921
+ enumerable: true,
922
+ get: function () { return recharts.BarChart; }
923
+ });
924
+ Object.defineProperty(exports, "Cell", {
925
+ enumerable: true,
926
+ get: function () { return recharts.Cell; }
927
+ });
928
+ Object.defineProperty(exports, "Line", {
929
+ enumerable: true,
930
+ get: function () { return recharts.Line; }
931
+ });
932
+ Object.defineProperty(exports, "LineChart", {
933
+ enumerable: true,
934
+ get: function () { return recharts.LineChart; }
935
+ });
936
+ exports.AssetAreaChart = AssetAreaChart;
937
+ exports.AssetLineChart = AssetLineChart;
938
+ exports.PnLBarChart = PnLBarChart;
939
+ exports.PnlAreaChart = PnlAreaChart;
940
+ exports.PnlLineChart = PnlLineChart;
941
+ exports.VolBarChart = VolBarChart;
942
+ exports.chartPlugin = chartPlugin;
943
+ //# sourceMappingURL=index.js.map
2
944
  //# sourceMappingURL=index.js.map