@gearbox-protocol/ui-kit 3.14.0-next.35 → 3.14.0-next.36
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),J=require("lightweight-charts"),h=require("react"),Qe=require("../../hooks/use-media-query.cjs"),se=require("../../utils/cn.cjs"),D=require("../../utils/colors.cjs"),le=require("./default-config.cjs"),Y=require("./formatters.cjs"),Je=require("./graph-current-value.cjs"),Ye=require("./graph-tooltip.cjs"),Ue=require("./plugins/vertical-line.cjs");function et(t){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const c in t)if(c!=="default"){const f=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(i,c,f.get?f:{enumerable:!0,get:()=>t[c]})}}return i.default=t,Object.freeze(i)}const Se=et(h);class tt{_yTop;_yBottom;_color;constructor(i,c,f){this._yTop=i,this._yBottom=c,this._color=f}draw(i){i.useBitmapCoordinateSpace(c=>{const f=c.context,d=c.verticalPixelRatio,w=this._yTop===null?0:this._yTop*d,G=this._yBottom===null?c.bitmapSize.height:this._yBottom*d,v=Math.min(w,G),_=Math.max(w,G);f.fillStyle=this._color,f.fillRect(0,v,c.bitmapSize.width,_-v)})}}class ot{_source;_yTop=null;_yBottom=null;constructor(i){this._source=i}update(){const i=this._source.series;this._yTop=this._source.priceTop===void 0?null:i.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:i.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new tt(this._yTop,this._yBottom,this._source.color)}}class rt{series;priceTop;priceBottom;color;_paneViews;constructor(i,c,f,d){this.series=i,this.priceTop=c,this.priceBottom=f,this.color=d,this._paneViews=[new ot(this)]}updateAllViews(){for(const i of this._paneViews)i.update()}paneViews(){return this._paneViews}}function Ie(t,i,c){const f=t.labelText??"",d=t.value,w=d===void 0?"":typeof d=="number"?i==="$"?`$${Y.formatExactValue(d,void 0,c)}`:i==="%"?`${Y.formatExactValue(d,void 0,c)}%`:Y.formatExactValue(d,i!=="none"&&i!=="%"&&i!=="$"?i:void 0,c):String(d);return{labelText:f,valueStr:w}}function ze(t,i){for(let c=t.length-1;c>=0;c--)if(Number(t[c].time)<=i)return t[c].value;return 0}const ae=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],nt=137.5;function xe(t){if(t<ae.length)return ae[t];const c=(t-ae.length)*nt%360,f=D.hslToHex(c,70,50),{topColor:d,bottomColor:w}=D.generateColorsFromBase(f);return{line:f,top:d,bottom:w}}function lt({series:t,className:i,showLegend:c=!1,onUnselectSeries:f,xMeasureUnit:d="time",yMeasureUnit:w="token",optionsOverrides:G,verticalLineOptions:v,priceLineOptions:_,zoneOptions:W,currentValueDecimals:ie,useSharedPriceScale:E=!1,dualYAxis:k=!1,defaultVisiblePriceScaleId:ye="right",leftPriceScaleTitle:Re,rightPriceScaleTitle:at,showCurrentValue:We=!0,graphTitle:ce,yScaleMin:we,yScaleMinMultiple:Te,visibleTimeFrom:H,disableZoom:oe=!1,hideDefaultTooltip:ue=!1}){const j=h.useRef(null),C=h.useRef(new Map),fe=h.useRef(!1),Ve=h.useRef(!0),ge=h.useRef(null),Ae=h.useRef(null),X=h.useRef(null),he=h.useRef(null),re=h.useRef(null),T=Qe.useIsMobile(),A=Se.useMemo(()=>t.flatMap(e=>e.data),[t]),$e=Se.useMemo(()=>{if(t.length>0){const e=t[t.length-1];if(e.data.length>0)return e.data[e.data.length-1]}},[t]),[_e,de]=h.useState(()=>{if(!$e)return;const e=new Map;for(const a of t)a.data.length>0&&e.set(a.label,a.data[a.data.length-1]);return e}),[Ne,$]=h.useState(null),[Pe,Le]=h.useState([]);h.useEffect(()=>{const e=()=>{try{if(j.current&&X.current){const n=X.current.clientWidth,s=X.current.clientHeight;j.current.resize(n,s)}}catch{}},a=X.current,l=a?new ResizeObserver(e):null;return re.current=l,a&&l?.observe(a),()=>{a&&l?.unobserve(a),l?.disconnect(),re.current=null}},[]),h.useEffect(()=>{if(!he.current||fe.current)return;const e=le.getDefaultOptions(),a=D.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=oe?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{},n=J.createChart(he.current,{...e,leftPriceScale:{...e.leftPriceScale||{},visible:!1,textColor:a},rightPriceScale:{...e.rightPriceScale||{},visible:!T,textColor:a},...T&&{crosshair:{...e.crosshair,mode:J.CrosshairMode.Magnet}},...l,...G});return j.current=n,fe.current=!0,()=>{re.current?.disconnect(),re.current=null,n.remove(),j.current=null,fe.current=!1,C.current.clear()}},[T,G,oe]),h.useEffect(()=>{const e=j.current;e&&e.applyOptions(oe?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:!0,axisDoubleClickReset:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}})},[oe]),h.useEffect(()=>{const e=j.current;if(!e||t.length===0)return;const l=t.filter(o=>o.data.length>0).length<=1?we:Te,n=d==="time"?Y.getXFormatters(d,A):Y.getXFormatters(d),s=A.map(o=>o.value),{formatter:u,tickmarksFormatter:p,updateVisibleRange:I,updateLastValues:S}=Y.createAdaptiveYAxisFormatter(s,w,{yScaleMin:l});ge.current=I,Ae.current=S;const z=t.filter(o=>o.data.length>0).map(o=>o.data[o.data.length-1].value);S(z);const P=le.getDefaultOptions();e.applyOptions({localization:{...P.localization||{},timeFormatter:o=>n.timeFormatter(parseFloat(o),void 0)},timeScale:{...P.timeScale||{},tickMarkFormatter:n.tickMarkFormatter,minBarSpacing:0}});const m=(A.length>0?Math.min(...A.map(o=>o.value)):0)<0,N=A.some(o=>o.value===0),x=!m&&N,V=!k&&t.length>1&&!E,y=k?T:t.length>1&&!E||T,B=D.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");e.applyOptions({...k&&{defaultVisiblePriceScaleId:ye},leftPriceScale:{...P.leftPriceScale||{},visible:k&&!T,textColor:B,...k&&Re&&{}},rightPriceScale:{...P.rightPriceScale||{},visible:k?!T:!y,textColor:B,...x&&!k&&{scaleMargins:{top:.3,bottom:0}}}});const U=new Set(C.current.keys()),pe=new Set(t.map(o=>o.label));for(const o of U)if(!pe.has(o)){const r=C.current.get(o);r&&(e.removeSeries(r),C.current.delete(o))}const ke=le.getDefaultSeries(),be=[];let ee=0;const je=t.find(o=>o.data.length>0),te=new Map;if(_&&_.length>0)for(const o of _){if(!Number.isFinite(o.price))continue;const r=o.seriesLabel??je?.label;if(!r)continue;const R=te.get(r)??[];R.push(o.price),te.set(r,R)}if(W&&W.length>0)for(const o of W){const r=o.seriesLabel??je?.label;if(!r)continue;const R=te.get(r)??[];Number.isFinite(o.priceTop)&&R.push(o.priceTop),Number.isFinite(o.priceBottom)&&R.push(o.priceBottom),te.set(r,R)}for(let o=0;o<t.length;o++){const r=t[o],R=xe(o),Z=r.lineColor??r.color??R.line;let O,K;if(r.lineColor??r.color)if(r.topColor&&r.bottomColor)O=r.topColor,K=r.bottomColor;else if(r.topColor){const g=D.generateColorsFromBase(Z);O=r.topColor,K=g.bottomColor}else if(r.bottomColor)O=D.generateColorsFromBase(Z).topColor,K=r.bottomColor;else{const g=D.generateColorsFromBase(Z);O=g.topColor,K=g.bottomColor}else O=r.topColor||R.top,K=r.bottomColor||R.bottom;if(r.data.length===0){const g=C.current.get(r.label);g&&(e.removeSeries(g),C.current.delete(r.label));continue}const Oe=(r.data.length>0?Math.min(...r.data.map(g=>g.value)):0)<0,Ge=r.data.some(g=>g.value===0),He=!Oe&&Ge,Fe=k?r.priceScaleId??(ee===0?"left":"right"):E||!V||ee===0?"right":`scale-${ee}`;V&&be.push({priceScaleId:Fe||"right",shouldPreventNegativeAxis:He,seriesIndex:ee});const Be=(E||!V)&&l!==void 0&&typeof l=="number",Xe=te.get(r.label)??[],Ze=g=>{const M=g();if(M?.priceRange){Be&&(M.priceRange.minValue=l);for(const q of Xe)q<M.priceRange.minValue&&(M.priceRange.minValue=q),q>M.priceRange.maxValue&&(M.priceRange.maxValue=q)}return M},ve={lineColor:Z,topColor:O,bottomColor:K,priceScaleId:Fe,...r.seriesType==="line"&&{lineStyle:r.lineStyle??J.LineStyle.Solid},priceFormat:{type:"custom",minMove:.01,formatter:Be&&typeof l=="number"?g=>u(g<l?l:g):u,tickmarksFormatter:p},autoscaleInfoProvider:Ze},De=r.seriesType==="line";let L=C.current.get(r.label);const Q=r.data.map(g=>({...g,time:g.time}));if(H!==void 0&&Q.length>0&&Number(Q[0].time)>H){const g=Number(Q[0].time),M=g-H,q=86400,Ke=M>180*q?7*q:M>30*q?q:6*3600,Ee=[];for(let Ce=H;Ce<g;Ce+=Ke)Ee.push({time:Ce});Q.unshift(...Ee)}L&&L.seriesType()!==(De?"Line":"Area")&&(e.removeSeries(L),C.current.delete(r.label),L=void 0),L?(L.applyOptions(ve),L.setData(Q)):(De?L=e.addSeries(J.LineSeries,{...ke,...ve}):L=e.addSeries(J.AreaSeries,{...ke,...ve}),L.setData(Q),C.current.set(r.label,L)),ee++}if(k)try{const o=e.priceScale("left"),r=e.priceScale("right"),R={visible:!T,autoScale:!0,scaleMargins:{top:.1,bottom:.1},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:B};o?.applyOptions(R),r?.applyOptions(R)}catch{}else if(V&&be.length>0)for(const o of be)try{const r=e.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...o.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:B})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}else if(!V)try{const o=e.priceScale("right");o&&o.applyOptions({visible:!T,autoScale:!0,scaleMargins:{top:.1,bottom:l!==void 0||x?0:.1,...x&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:B})}catch{}if(l!==void 0&&!T&&(E||!V)&&e.applyOptions({handleScroll:{vertTouchDrag:!1}}),A.length>0){const o=A.map(O=>Number(O.time)),r=Math.min(...o),R=H!==void 0?Math.min(H,r):r,Z=Math.max(...o);e.timeScale().setVisibleRange({from:R,to:Z})}Ve.current&&(Ve.current=!1);const me=new Map;for(const o of t)o.data.length>0&&me.set(o.label,o.data[o.data.length-1]);de(me.size>0?me:void 0)},[t,A,d,w,T,E,k,ye,Re,we,Te,H,_,W]),h.useEffect(()=>{const e=j.current;if(!e||t.length===0)return;const a=t.length===1;let l;for(const s of t)if(s.data.length>0){l=s.data[s.data.length-1].time;break}if(!l)return;const n=s=>{const{time:u=l,seriesData:p,point:I}=s||{},S=Array.from(C.current.values());if(!I||!u){const F=new Map;for(const m of t)m.data.length>0&&F.set(m.label,m.data[m.data.length-1]);if(de(F.size>0?F:void 0),a||E||ue)$(null);else if(S[0]&&l){const N=e.timeScale().timeToCoordinate(l),x=t[0];if(x.data.length>0){const V=x.data[x.data.length-1].value,y=S[0].priceToCoordinate(V);N!==null&&y!==null&&$({x:N,y})}}return}const z=new Map;let P;for(let F=0;F<t.length;F++){const m=t[F],N=S[F];if(!N)continue;const x=p?.get(N),V=x&&"value"in x?x.value:void 0;let y;if(V!==void 0)y=V;else if(a){const B=Number(u),U=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;B<U?y=Number.NaN:y=m.data[m.data.length-1]?.value??0}else y=ze(m.data,Number(u));Number.isNaN(y)||(P===void 0&&(P=y),z.set(m.label,{value:y,time:u}))}if(de(z),P!==void 0&&S[0]){const m=e.timeScale().timeToCoordinate(u),N=S[0].priceToCoordinate(P);if(m!==null&&N!==null){const x=X.current;if(x){const V=x.querySelector(".LightweightChart");if(V){const y=V.getBoundingClientRect(),B=x.getBoundingClientRect(),U=m+(y.left-B.left),pe=N+(y.top-B.top);$({x:U,y:pe})}else $({x:m,y:N})}else $({x:m,y:N})}else $(null)}else $(null)};return e.subscribeCrosshairMove(n),T&&e.subscribeClick(n),!a&&!E&&!ue&&requestAnimationFrame(()=>{const s=Array.from(C.current.values());if(s[0]&&l&&t[0]?.data.length>0){const p=e.timeScale().timeToCoordinate(l),I=t[0].data[t[0].data.length-1].value,S=s[0].priceToCoordinate(I);p!==null&&S!==null&&$({x:p,y:S})}}),()=>{e.unsubscribeCrosshairMove(n),T&&e.unsubscribeClick(n)}},[t,E,T,ue]),h.useEffect(()=>{const e=j.current;if(!e||t.length===0)return;const a=e.timeScale(),l=()=>{if(!ge.current)return;const n=a.getVisibleRange();if(!n)return;const s=Number(n.from),u=Number(n.to),p=[];for(const I of t)for(const S of I.data){const z=Number(S.time);z>=s&&z<=u&&p.push(S.value)}p.length>0&&ge.current(p)};return a.subscribeVisibleLogicalRangeChange(l),()=>{a.unsubscribeVisibleLogicalRangeChange(l)}},[t]),h.useEffect(()=>{const e=j.current,a=Array.from(C.current.values()),l=[];if(e&&a.length>0&&v){const n=le.getDefaultVerticalLine(),s=a[0];for(const u of v){const p=new Ue.VertLine(e,s,u.xCoordinate,{...n,...u.options||{}});s.attachPrimitive(p),l.push(p)}}return()=>{if(a.length>0){const n=a[0];for(const s of l)n.detachPrimitive(s)}}},[v,t]),h.useEffect(()=>{const e=[];if(_&&_.length>0){const a=Array.from(C.current.values())[0],l=D.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const n of _){if(!Number.isFinite(n.price))continue;const s=n.seriesLabel?C.current.get(n.seriesLabel):a;if(!s)continue;const u=s.createPriceLine({price:n.price,color:n.color?D.resolveCSSColor(n.color,n.color):l,lineWidth:n.lineWidth??1,lineStyle:n.lineStyle??J.LineStyle.Dashed,axisLabelVisible:n.axisLabelVisible??!0,title:n.title??""});e.push({series:s,line:u})}}return()=>{for(const{series:a,line:l}of e)try{a.removePriceLine(l)}catch{}}},[_,t]),h.useEffect(()=>{const e=[];if(W&&W.length>0){const a=Array.from(C.current.values())[0],l="rgba(239, 68, 68, 0.12)";for(const n of W){const s=n.seriesLabel?C.current.get(n.seriesLabel):a;if(!s)continue;const u=n.color?D.resolveCSSColor(n.color,l):l,p=new rt(s,n.priceTop,n.priceBottom,u);s.attachPrimitive(p),e.push({series:s,zone:p})}}return()=>{for(const{series:a,zone:l}of e)try{a.detachPrimitive(l)}catch{}}},[W,t]),h.useEffect(()=>{const e=j.current;if(!e||!v?.length){Le([]);return}const a=()=>{const s=e.timeScale(),u=v.map(p=>s.timeToCoordinate(p.xCoordinate)??null);Le(u)};a();const l=e.timeScale(),n=()=>{a()};return l.subscribeVisibleLogicalRangeChange(n),()=>{l.unsubscribeVisibleLogicalRangeChange(n)}},[v,t]);const ne=t.length===1,Me=Se.useMemo(()=>{if(ne&&t.length>0){const e=t[0];if(e.data.length>0)return e.data[e.data.length-1]}},[ne,t]);return b.jsxs("div",{ref:X,className:se.cn("relative z-[1] w-full h-full overflow-hidden p-0",i),children:[ce!=null&&ce!==!1&&ne?b.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:b.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:ce})}):We&&ne&&Me&&b.jsx(Je.GraphCurrentValue,{point:Me,xMeasureUnit:d,yMeasureUnit:w,decimals:ie}),_e&&Ne&&b.jsx(Ye.GraphTooltip,{points:_e,xMeasureUnit:d,yMeasureUnit:w,series:t,position:Ne,containerRef:X,decimals:ie}),c&&b.jsx(qe,{series:t,onUnselect:f}),v&&v.length>0&&Pe.length===v.length&&b.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:v.map((e,a)=>{const l=Pe[a],n=e.options??{},s=n.showLabel!==!1;if(l===null||!s)return null;const{labelText:u,valueStr:p}=Ie(n,w,ie);if(!(u||p))return null;const S=n.labelBackgroundColor??n.color??"hsl(var(--background))",z=n.labelTextColor??"hsl(var(--foreground))",P=`${String(e.xCoordinate)}-${u}`;return b.jsxs("div",{className:"absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",style:{left:l,transform:"translateX(-50%)",backgroundColor:S,color:z},children:[u&&b.jsx("span",{className:"block",children:u}),p&&b.jsx("span",{className:se.cn("block",u&&"mt-0.5"),children:p})]},P)})}),b.jsx("div",{ref:he,className:"LightweightChart w-full h-full overflow-hidden"})]})}function qe({series:t,onUnselect:i,inline:c=!1}){return b.jsx("div",{className:se.cn("flex flex-wrap gap-2",c?"items-center":"absolute top-0 left-2 z-[10]"),children:t.map((f,d)=>{const w=xe(d),G=(f.lineColor??f.color)||w.line,v=f.data.length===0;return b.jsxs("div",{className:se.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",v&&"opacity-50"),children:[b.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:G}}),b.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[f.label,v&&" (no data)"]}),i&&b.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),i(f.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${f.label}`,children:b.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[b.jsx("title",{children:"Close"}),b.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},f.label)})})}exports.DEFAULT_SERIES_COLORS=ae;exports.Graph=lt;exports.GraphLegend=qe;exports.getSeriesColorPalette=xe;exports.getStepForwardValue=ze;exports.getVerticalLineTooltipContent=Ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),U=require("lightweight-charts"),b=require("react"),Je=require("../../hooks/use-media-query.cjs"),ne=require("../../utils/cn.cjs"),E=require("../../utils/colors.cjs"),ie=require("./default-config.cjs"),ee=require("./formatters.cjs"),Ye=require("./graph-current-value.cjs"),Ue=require("./graph-tooltip.cjs"),et=require("./plugins/vertical-line.cjs");function tt(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const c in e)if(c!=="default"){const h=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(i,c,h.get?h:{enumerable:!0,get:()=>e[c]})}}return i.default=e,Object.freeze(i)}const Se=tt(b);class ot{_yTop;_yBottom;_color;constructor(i,c,h){this._yTop=i,this._yBottom=c,this._color=h}draw(i){i.useBitmapCoordinateSpace(c=>{const h=c.context,p=c.verticalPixelRatio,_=this._yTop===null?0:this._yTop*p,H=this._yBottom===null?c.bitmapSize.height:this._yBottom*p,w=Math.min(_,H),M=Math.max(_,H);h.fillStyle=this._color,h.fillRect(0,w,c.bitmapSize.width,M-w)})}}class rt{_source;_yTop=null;_yBottom=null;constructor(i){this._source=i}update(){const i=this._source.series;this._yTop=this._source.priceTop===void 0?null:i.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:i.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new ot(this._yTop,this._yBottom,this._source.color)}}class nt{series;priceTop;priceBottom;color;_paneViews;constructor(i,c,h,p){this.series=i,this.priceTop=c,this.priceBottom=h,this.color=p,this._paneViews=[new rt(this)]}updateAllViews(){for(const i of this._paneViews)i.update()}paneViews(){return this._paneViews}}function We(e,i,c){const h=e.labelText??"",p=e.value,_=p===void 0?"":typeof p=="number"?i==="$"?`$${ee.formatExactValue(p,void 0,c)}`:i==="%"?`${ee.formatExactValue(p,void 0,c)}%`:ee.formatExactValue(p,i!=="none"&&i!=="%"&&i!=="$"?i:void 0,c):String(p);return{labelText:h,valueStr:_}}function $e(e,i){for(let c=e.length-1;c>=0;c--)if(Number(e[c].time)<=i)return e[c].value;return 0}const ce=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],lt=137.5;function xe(e){if(e<ce.length)return ce[e];const c=(e-ce.length)*lt%360,h=E.hslToHex(c,70,50),{topColor:p,bottomColor:_}=E.generateColorsFromBase(h);return{line:h,top:p,bottom:_}}function at({series:e,className:i,showLegend:c=!1,onUnselectSeries:h,xMeasureUnit:p="time",yMeasureUnit:_="token",optionsOverrides:H,verticalLineOptions:w,priceLineOptions:M,zoneOptions:$,currentValueDecimals:ue,useSharedPriceScale:q=!1,dualYAxis:k=!1,defaultVisiblePriceScaleId:ye="right",leftPriceScaleTitle:we,rightPriceScaleTitle:st,showCurrentValue:Oe=!0,graphTitle:fe,yScaleMin:Re,yScaleMinMultiple:Te,visibleTimeFrom:X,disableZoom:le=!1,hideDefaultTooltip:ge=!1}){const I=b.useRef(null),R=b.useRef(new Map),he=b.useRef(!1),_e=b.useRef(!0),Ve=b.useRef([]),Z=b.useRef(null),de=b.useRef(null),ae=b.useRef(null),N=Je.useIsMobile(),A=Se.useMemo(()=>e.flatMap(o=>o.data),[e]),Ge=Se.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[Ne,pe]=b.useState(()=>{if(!Ge)return;const o=new Map;for(const a of e)a.data.length>0&&o.set(a.label,a.data[a.data.length-1]);return o}),[Pe,O]=b.useState(null),[Le,Me]=b.useState([]);b.useEffect(()=>{const o=()=>{try{if(I.current&&Z.current){const n=Z.current.clientWidth,s=Z.current.clientHeight;I.current.resize(n,s)}}catch{}},a=Z.current,l=a?new ResizeObserver(o):null;return ae.current=l,a&&l?.observe(a),()=>{a&&l?.unobserve(a),l?.disconnect(),ae.current=null}},[]),b.useEffect(()=>{if(!de.current||he.current)return;const o=ie.getDefaultOptions(),a=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=le?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{},n=U.createChart(de.current,{...o,leftPriceScale:{...o.leftPriceScale||{},visible:!1,textColor:a},rightPriceScale:{...o.rightPriceScale||{},visible:!N,textColor:a},...N&&{crosshair:{...o.crosshair,mode:U.CrosshairMode.Magnet}},...l,...H});return I.current=n,he.current=!0,()=>{ae.current?.disconnect(),ae.current=null,n.remove(),I.current=null,he.current=!1,R.current.clear()}},[N,H,le]),b.useEffect(()=>{const o=I.current;o&&o.applyOptions(le?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:!0,axisDoubleClickReset:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}})},[le]),b.useEffect(()=>{const o=I.current;if(!o||e.length===0)return;const l=e.filter(r=>r.data.length>0).length<=1?Re:Te,n=p==="time"?ee.getXFormatters(p,A):ee.getXFormatters(p),s=new Map;{let r=0;for(const t of e)t.data.length!==0&&(s.set(t.label,t.priceScaleId??(r===0?"left":"right")),r++)}const g=(r,t,f)=>{const{formatter:B,tickmarksFormatter:y,updateVisibleRange:z,updateLastValues:Be}=ee.createAdaptiveYAxisFormatter(r,t,{yScaleMin:l}),me=e.filter(K=>K.data.length>0&&f.has(K.label)).map(K=>K.data[K.data.length-1].value);return Be(me),{formatter:B,tickmarksFormatter:y,updateVisibleRange:z,labels:f}},u=[];if(k)for(const r of["left","right"]){const t=new Set,f=[];let B=_;for(const y of e)if(y.data.length!==0&&s.get(y.label)===r){t.size===0&&y.yMeasureUnit&&(B=y.yMeasureUnit),t.add(y.label);for(const z of y.data)f.push(z.value)}t.size>0&&u.push(g(f,B,t))}else{const r=A.map(f=>f.value),t=new Set(e.filter(f=>f.data.length>0).map(f=>f.label));u.push(g(r,_,t))}Ve.current=u;const C=new Map;for(const r of u)for(const t of r.labels)C.set(t,r);const S=ie.getDefaultOptions();o.applyOptions({localization:{...S.localization||{},timeFormatter:r=>n.timeFormatter(parseFloat(r),void 0)},timeScale:{...S.timeScale||{},tickMarkFormatter:n.tickMarkFormatter,minBarSpacing:0}});const j=(A.length>0?Math.min(...A.map(r=>r.value)):0)<0,T=A.some(r=>r.value===0),m=!j&&T,x=!k&&e.length>1&&!q,P=k?N:e.length>1&&!q||N,L=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({...k&&{defaultVisiblePriceScaleId:ye},leftPriceScale:{...S.leftPriceScale||{},visible:k&&!N,textColor:L,...k&&we&&{}},rightPriceScale:{...S.rightPriceScale||{},visible:k?!N:!P,textColor:L,...m&&!k&&{scaleMargins:{top:.3,bottom:0}}}});const V=new Set(R.current.keys()),Q=new Set(e.map(r=>r.label));for(const r of V)if(!Q.has(r)){const t=R.current.get(r);t&&(o.removeSeries(t),R.current.delete(r))}const J=ie.getDefaultSeries(),te=[];let oe=0;const je=e.find(r=>r.data.length>0),re=new Map;if(M&&M.length>0)for(const r of M){if(!Number.isFinite(r.price))continue;const t=r.seriesLabel??je?.label;if(!t)continue;const f=re.get(t)??[];f.push(r.price),re.set(t,f)}if($&&$.length>0)for(const r of $){const t=r.seriesLabel??je?.label;if(!t)continue;const f=re.get(t)??[];Number.isFinite(r.priceTop)&&f.push(r.priceTop),Number.isFinite(r.priceBottom)&&f.push(r.priceBottom),re.set(t,f)}for(let r=0;r<e.length;r++){const t=e[r],f=xe(r),B=t.lineColor??t.color??f.line;let y,z;if(t.lineColor??t.color)if(t.topColor&&t.bottomColor)y=t.topColor,z=t.bottomColor;else if(t.topColor){const d=E.generateColorsFromBase(B);y=t.topColor,z=d.bottomColor}else if(t.bottomColor)y=E.generateColorsFromBase(B).topColor,z=t.bottomColor;else{const d=E.generateColorsFromBase(B);y=d.topColor,z=d.bottomColor}else y=t.topColor||f.top,z=t.bottomColor||f.bottom;if(t.data.length===0){const d=R.current.get(t.label);d&&(o.removeSeries(d),R.current.delete(t.label));continue}const me=(t.data.length>0?Math.min(...t.data.map(d=>d.value)):0)<0,K=t.data.some(d=>d.value===0),He=!me&&K,Fe=k?t.priceScaleId??(oe===0?"left":"right"):q||!x||oe===0?"right":`scale-${oe}`;x&&te.push({priceScaleId:Fe||"right",shouldPreventNegativeAxis:He,seriesIndex:oe});const De=(q||!x)&&l!==void 0&&typeof l=="number",Xe=re.get(t.label)??[],Ze=d=>{const D=d();if(D?.priceRange){De&&(D.priceRange.minValue=l);for(const W of Xe)W<D.priceRange.minValue&&(D.priceRange.minValue=W),W>D.priceRange.maxValue&&(D.priceRange.maxValue=W)}return D},Ee=C.get(t.label)??u[0],Ie=Ee.formatter,Ke=Ee.tickmarksFormatter,ve={lineColor:B,topColor:y,bottomColor:z,priceScaleId:Fe,...t.seriesType==="line"&&{lineStyle:t.lineStyle??U.LineStyle.Solid},priceFormat:{type:"custom",minMove:.01,formatter:De&&typeof l=="number"?d=>Ie(d<l?l:d):Ie,tickmarksFormatter:Ke},autoscaleInfoProvider:Ze},ze=t.seriesType==="line";let F=R.current.get(t.label);const Y=t.data.map(d=>({...d,time:d.time}));if(X!==void 0&&Y.length>0&&Number(Y[0].time)>X){const d=Number(Y[0].time),D=d-X,W=86400,Qe=D>180*W?7*W:D>30*W?W:6*3600,qe=[];for(let Ce=X;Ce<d;Ce+=Qe)qe.push({time:Ce});Y.unshift(...qe)}F&&F.seriesType()!==(ze?"Line":"Area")&&(o.removeSeries(F),R.current.delete(t.label),F=void 0),F?(F.applyOptions(ve),F.setData(Y)):(ze?F=o.addSeries(U.LineSeries,{...J,...ve}):F=o.addSeries(U.AreaSeries,{...J,...ve}),F.setData(Y),R.current.set(t.label,F)),oe++}if(k)try{const r=o.priceScale("left"),t=o.priceScale("right"),f={visible:!N,autoScale:!0,scaleMargins:{top:.1,bottom:.1},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:L};r?.applyOptions(f),t?.applyOptions(f)}catch{}else if(x&&te.length>0)for(const r of te)try{const t=o.priceScale(r.priceScaleId);t&&t.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...r.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:L})}catch(t){console.warn(`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,t)}else if(!x)try{const r=o.priceScale("right");r&&r.applyOptions({visible:!N,autoScale:!0,scaleMargins:{top:.1,bottom:l!==void 0||m?0:.1,...m&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:L})}catch{}if(l!==void 0&&!N&&(q||!x)&&o.applyOptions({handleScroll:{vertTouchDrag:!1}}),A.length>0){const r=A.map(y=>Number(y.time)),t=Math.min(...r),f=X!==void 0?Math.min(X,t):t,B=Math.max(...r);o.timeScale().setVisibleRange({from:f,to:B})}_e.current&&(_e.current=!1);const be=new Map;for(const r of e)r.data.length>0&&be.set(r.label,r.data[r.data.length-1]);pe(be.size>0?be:void 0)},[e,A,p,_,N,q,k,ye,we,Re,Te,X,M,$]),b.useEffect(()=>{const o=I.current;if(!o||e.length===0)return;const a=e.length===1;let l;for(const s of e)if(s.data.length>0){l=s.data[s.data.length-1].time;break}if(!l)return;const n=s=>{const{time:g=l,seriesData:u,point:C}=s||{},S=Array.from(R.current.values());if(!C||!g){const T=new Map;for(const m of e)m.data.length>0&&T.set(m.label,m.data[m.data.length-1]);if(pe(T.size>0?T:void 0),a||q||ge)O(null);else if(S[0]&&l){const x=o.timeScale().timeToCoordinate(l),P=e[0];if(P.data.length>0){const L=P.data[P.data.length-1].value,V=S[0].priceToCoordinate(L);x!==null&&V!==null&&O({x,y:V})}}return}const G=new Map;let j;for(let T=0;T<e.length;T++){const m=e[T],x=S[T];if(!x)continue;const P=u?.get(x),L=P&&"value"in P?P.value:void 0;let V;if(L!==void 0)V=L;else if(a){const Q=Number(g),J=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;Q<J?V=Number.NaN:V=m.data[m.data.length-1]?.value??0}else V=$e(m.data,Number(g));Number.isNaN(V)||(j===void 0&&(j=V),G.set(m.label,{value:V,time:g}))}if(pe(G),j!==void 0&&S[0]){const m=o.timeScale().timeToCoordinate(g),x=S[0].priceToCoordinate(j);if(m!==null&&x!==null){const P=Z.current;if(P){const L=P.querySelector(".LightweightChart");if(L){const V=L.getBoundingClientRect(),Q=P.getBoundingClientRect(),J=m+(V.left-Q.left),te=x+(V.top-Q.top);O({x:J,y:te})}else O({x:m,y:x})}else O({x:m,y:x})}else O(null)}else O(null)};return o.subscribeCrosshairMove(n),N&&o.subscribeClick(n),!a&&!q&&!ge&&requestAnimationFrame(()=>{const s=Array.from(R.current.values());if(s[0]&&l&&e[0]?.data.length>0){const u=o.timeScale().timeToCoordinate(l),C=e[0].data[e[0].data.length-1].value,S=s[0].priceToCoordinate(C);u!==null&&S!==null&&O({x:u,y:S})}}),()=>{o.unsubscribeCrosshairMove(n),N&&o.unsubscribeClick(n)}},[e,q,N,ge]),b.useEffect(()=>{const o=I.current;if(!o||e.length===0)return;const a=o.timeScale(),l=()=>{const n=Ve.current;if(n.length===0)return;const s=a.getVisibleRange();if(!s)return;const g=Number(s.from),u=Number(s.to);for(const C of n){const S=[];for(const G of e)if(C.labels.has(G.label))for(const j of G.data){const T=Number(j.time);T>=g&&T<=u&&S.push(j.value)}S.length>0&&C.updateVisibleRange(S)}};return a.subscribeVisibleLogicalRangeChange(l),()=>{a.unsubscribeVisibleLogicalRangeChange(l)}},[e]),b.useEffect(()=>{const o=I.current,a=Array.from(R.current.values()),l=[];if(o&&a.length>0&&w){const n=ie.getDefaultVerticalLine(),s=a[0];for(const g of w){const u={...n,...g.options||{}};u.color&&(u.color=E.resolveCSSColor(u.color,u.color));const C=new et.VertLine(o,s,g.xCoordinate,u);s.attachPrimitive(C),l.push(C)}}return()=>{if(a.length>0){const n=a[0];for(const s of l)n.detachPrimitive(s)}}},[w,e]),b.useEffect(()=>{const o=[];if(M&&M.length>0){const a=Array.from(R.current.values())[0],l=E.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const n of M){if(!Number.isFinite(n.price))continue;const s=n.seriesLabel?R.current.get(n.seriesLabel):a;if(!s)continue;const g=s.createPriceLine({price:n.price,color:n.color?E.resolveCSSColor(n.color,n.color):l,lineWidth:n.lineWidth??1,lineStyle:n.lineStyle??U.LineStyle.Dashed,axisLabelVisible:n.axisLabelVisible??!0,title:n.title??""});o.push({series:s,line:g})}}return()=>{for(const{series:a,line:l}of o)try{a.removePriceLine(l)}catch{}}},[M,e]),b.useEffect(()=>{const o=[];if($&&$.length>0){const a=Array.from(R.current.values())[0],l="rgba(239, 68, 68, 0.12)";for(const n of $){const s=n.seriesLabel?R.current.get(n.seriesLabel):a;if(!s)continue;const g=n.color?E.resolveCSSColor(n.color,l):l,u=new nt(s,n.priceTop,n.priceBottom,g);s.attachPrimitive(u),o.push({series:s,zone:u})}}return()=>{for(const{series:a,zone:l}of o)try{a.detachPrimitive(l)}catch{}}},[$,e]),b.useEffect(()=>{const o=I.current;if(!o||!w?.length){Me([]);return}const a=()=>{const s=o.timeScale(),g=w.map(u=>s.timeToCoordinate(u.xCoordinate)??null);Me(g)};a();const l=o.timeScale(),n=()=>{a()};return l.subscribeVisibleLogicalRangeChange(n),()=>{l.unsubscribeVisibleLogicalRangeChange(n)}},[w,e]);const se=e.length===1,ke=Se.useMemo(()=>{if(se&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[se,e]);return v.jsxs("div",{ref:Z,className:ne.cn("relative z-[1] w-full h-full overflow-hidden p-0",i),children:[fe!=null&&fe!==!1&&se?v.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:v.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:fe})}):Oe&&se&&ke&&v.jsx(Ye.GraphCurrentValue,{point:ke,xMeasureUnit:p,yMeasureUnit:_,decimals:ue}),Ne&&Pe&&v.jsx(Ue.GraphTooltip,{points:Ne,xMeasureUnit:p,yMeasureUnit:_,series:e,position:Pe,containerRef:Z,decimals:ue}),c&&v.jsx(Ae,{series:e,onUnselect:h}),w&&w.length>0&&Le.length===w.length&&v.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:w.map((o,a)=>{const l=Le[a],n=o.options??{},s=n.showLabel!==!1;if(l===null||!s)return null;const{labelText:g,valueStr:u}=We(n,_,ue),C=n.tooltipText??"";if(!(g||u||C))return null;const G=n.labelBackgroundColor??n.color??"hsl(var(--background))",j=n.labelTextColor??"hsl(var(--foreground))",T=`${String(o.xCoordinate)}-${g}-${C}`;return v.jsxs("div",{className:ne.cn("group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",C&&"pointer-events-auto cursor-default"),style:{left:l,transform:"translateX(-50%)",backgroundColor:G,color:j},children:[g&&v.jsx("span",{className:"block",children:g}),u&&v.jsx("span",{className:ne.cn("block",g&&"mt-0.5"),children:u}),C&&v.jsx("span",{className:"pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",role:"tooltip",children:C})]},T)})}),v.jsx("div",{ref:de,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ae({series:e,onUnselect:i,inline:c=!1}){return v.jsx("div",{className:ne.cn("flex flex-wrap gap-2",c?"items-center":"absolute top-0 left-2 z-[10]"),children:e.map((h,p)=>{const _=xe(p),H=(h.lineColor??h.color)||_.line,w=h.data.length===0;return v.jsxs("div",{className:ne.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",w&&"opacity-50"),children:[v.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:H}}),v.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[h.label,w&&" (no data)"]}),i&&v.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),i(h.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${h.label}`,children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[v.jsx("title",{children:"Close"}),v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h.label)})})}exports.DEFAULT_SERIES_COLORS=ce;exports.Graph=at;exports.GraphLegend=Ae;exports.getSeriesColorPalette=xe;exports.getStepForwardValue=$e;exports.getVerticalLineTooltipContent=We;
|