@gearbox-protocol/ui-kit 3.14.0-next.35 → 3.14.0-next.37
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"),m=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(t){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const c in t)if(c!=="default"){const h=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(i,c,h.get?h:{enumerable:!0,get:()=>t[c]})}}return i.default=t,Object.freeze(i)}const Se=tt(m);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,R=this._yTop===null?0:this._yTop*p,H=this._yBottom===null?c.bitmapSize.height:this._yBottom*p,w=Math.min(R,H),M=Math.max(R,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(t,i,c){const h=t.labelText??"",p=t.value,R=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:R}}function $e(t,i){for(let c=t.length-1;c>=0;c--)if(Number(t[c].time)<=i)return t[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(t){if(t<ce.length)return ce[t];const c=(t-ce.length)*lt%360,h=E.hslToHex(c,70,50),{topColor:p,bottomColor:R}=E.generateColorsFromBase(h);return{line:h,top:p,bottom:R}}function at({series:t,className:i,showLegend:c=!1,onUnselectSeries:h,xMeasureUnit:p="time",yMeasureUnit:R="token",optionsOverrides:H,verticalLineOptions:w,priceLineOptions:M,zoneOptions:$,currentValueDecimals:ue,useSharedPriceScale:q=!1,dualYAxis:j=!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=m.useRef(null),S=m.useRef(new Map),he=m.useRef(!1),Ne=m.useRef(!0),_e=m.useRef([]),Z=m.useRef(null),de=m.useRef(null),ae=m.useRef(null),V=Je.useIsMobile(),A=Se.useMemo(()=>t.flatMap(o=>o.data),[t]),Ge=Se.useMemo(()=>{if(t.length>0){const o=t[t.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[t]),[Ve,pe]=m.useState(()=>{if(!Ge)return;const o=new Map;for(const a of t)a.data.length>0&&o.set(a.label,a.data[a.data.length-1]);return o}),[Pe,O]=m.useState(null),[Le,Me]=m.useState([]);m.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}},[]),m.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:!V,textColor:a},...V&&{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,S.current.clear()}},[V,H,le]),m.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]),m.useEffect(()=>{const o=I.current;if(!o||t.length===0)return;const l=t.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 e of t)e.data.length!==0&&(s.set(e.label,e.priceScaleId??(r===0?"left":"right")),r++)}const g=(r,e,u)=>{const{formatter:k,tickmarksFormatter:_,updateVisibleRange:z,updateLastValues:Fe}=ee.createAdaptiveYAxisFormatter(r,e,{yScaleMin:l}),me=t.filter(K=>K.data.length>0&&u.has(K.label)).map(K=>K.data[K.data.length-1].value);return Fe(me),{formatter:k,tickmarksFormatter:_,updateVisibleRange:z,labels:u}},f=[];if(j)for(const r of["left","right"]){const e=new Set,u=[];let k=R;for(const _ of t)if(_.data.length!==0&&s.get(_.label)===r){e.size===0&&_.yMeasureUnit&&(k=_.yMeasureUnit),e.add(_.label);for(const z of _.data)u.push(z.value)}e.size>0&&f.push(g(u,k,e))}else{const r=A.map(u=>u.value),e=new Set(t.filter(u=>u.data.length>0).map(u=>u.label));f.push(g(r,R,e))}_e.current=f;const C=new Map;for(const r of f)for(const e of r.labels)C.set(e,r);const x=ie.getDefaultOptions();o.applyOptions({localization:{...x.localization||{},timeFormatter:r=>n.timeFormatter(parseFloat(r),void 0)},timeScale:{...x.timeScale||{},tickMarkFormatter:n.tickMarkFormatter,minBarSpacing:0}});const F=(A.length>0?Math.min(...A.map(r=>r.value)):0)<0,T=A.some(r=>r.value===0),b=!F&&T,y=!j&&t.length>1&&!q,P=j?V:t.length>1&&!q||V,L=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({...j&&{defaultVisiblePriceScaleId:ye},leftPriceScale:{...x.leftPriceScale||{},visible:j&&!V,textColor:L,...j&&we&&{}},rightPriceScale:{...x.rightPriceScale||{},visible:j?!V:!P,textColor:L,...b&&!j&&{scaleMargins:{top:.3,bottom:0}}}});const N=new Set(S.current.keys()),Q=new Set(t.map(r=>r.label));for(const r of N)if(!Q.has(r)){const e=S.current.get(r);e&&(o.removeSeries(e),S.current.delete(r))}const J=ie.getDefaultSeries(),te=[];let oe=0;const je=t.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 e=r.seriesLabel??je?.label;if(!e)continue;const u=re.get(e)??[];u.push(r.price),re.set(e,u)}if($&&$.length>0)for(const r of $){const e=r.seriesLabel??je?.label;if(!e)continue;const u=re.get(e)??[];Number.isFinite(r.priceTop)&&u.push(r.priceTop),Number.isFinite(r.priceBottom)&&u.push(r.priceBottom),re.set(e,u)}for(let r=0;r<t.length;r++){const e=t[r],u=xe(r),k=e.lineColor??e.color??u.line;let _,z;if(e.lineColor??e.color)if(e.topColor&&e.bottomColor)_=e.topColor,z=e.bottomColor;else if(e.topColor){const d=E.generateColorsFromBase(k);_=e.topColor,z=d.bottomColor}else if(e.bottomColor)_=E.generateColorsFromBase(k).topColor,z=e.bottomColor;else{const d=E.generateColorsFromBase(k);_=d.topColor,z=d.bottomColor}else _=e.topColor||u.top,z=e.bottomColor||u.bottom;if(e.data.length===0){const d=S.current.get(e.label);d&&(o.removeSeries(d),S.current.delete(e.label));continue}const me=(e.data.length>0?Math.min(...e.data.map(d=>d.value)):0)<0,K=e.data.some(d=>d.value===0),He=!me&&K,Be=j?e.priceScaleId??(oe===0?"left":"right"):q||!y||oe===0?"right":`scale-${oe}`;y&&te.push({priceScaleId:Be||"right",shouldPreventNegativeAxis:He,seriesIndex:oe});const De=(q||!y)&&l!==void 0&&typeof l=="number",Xe=re.get(e.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(e.label)??f[0],Ie=Ee.formatter,Ke=Ee.tickmarksFormatter,ve={lineColor:k,topColor:_,bottomColor:z,priceScaleId:Be,...e.seriesType==="line"&&{lineStyle:e.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=e.seriesType==="line";let B=S.current.get(e.label);const Y=e.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)}B&&B.seriesType()!==(ze?"Line":"Area")&&(o.removeSeries(B),S.current.delete(e.label),B=void 0),B?(B.applyOptions(ve),B.setData(Y)):(ze?B=o.addSeries(U.LineSeries,{...J,...ve}):B=o.addSeries(U.AreaSeries,{...J,...ve}),B.setData(Y),S.current.set(e.label,B)),oe++}if(j)try{const r=o.priceScale("left"),e=o.priceScale("right"),u={visible:!V,autoScale:!0,scaleMargins:{top:.1,bottom:.1},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:L};r?.applyOptions(u),e?.applyOptions(u)}catch{}else if(y&&te.length>0)for(const r of te)try{const e=o.priceScale(r.priceScaleId);e&&e.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(e){console.warn(`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,e)}else if(!y)try{const r=o.priceScale("right");r&&r.applyOptions({visible:!V,autoScale:!0,scaleMargins:{top:.1,bottom:l!==void 0||b?0:.1,...b&&{top:.3}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:L})}catch{}if(l!==void 0&&!V&&(q||!y)&&o.applyOptions({handleScroll:{vertTouchDrag:!1}}),A.length>0){const r=A.map(e=>Number(e.time)).filter(e=>Number.isFinite(e));if(r.length>0){const e=Math.min(...r),u=X!==void 0?Math.min(X,e):e,k=Math.max(...r);if(Number(u)<=Number(k))try{o.timeScale().setVisibleRange({from:u,to:k})}catch{try{o.timeScale().fitContent()}catch{}}}}Ne.current&&(Ne.current=!1);const be=new Map;for(const r of t)r.data.length>0&&be.set(r.label,r.data[r.data.length-1]);pe(be.size>0?be:void 0)},[t,A,p,R,V,q,j,ye,we,Re,Te,X,M,$]),m.useEffect(()=>{const o=I.current;if(!o||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:g=l,seriesData:f,point:C}=s||{},x=Array.from(S.current.values());if(!C||!g){const T=new Map;for(const b of t)b.data.length>0&&T.set(b.label,b.data[b.data.length-1]);if(pe(T.size>0?T:void 0),a||q||ge)O(null);else if(x[0]&&l){const y=o.timeScale().timeToCoordinate(l),P=t[0];if(P.data.length>0){const L=P.data[P.data.length-1].value,N=x[0].priceToCoordinate(L);y!==null&&N!==null&&O({x:y,y:N})}}return}const G=new Map;let F;for(let T=0;T<t.length;T++){const b=t[T],y=S.current.get(b.label);if(!y)continue;const P=f?.get(y),L=P&&"value"in P?P.value:void 0;let N;if(L!==void 0)N=L;else if(a){const Q=Number(g),J=b.data.length>0?Number(b.data[0].time):Number.POSITIVE_INFINITY;Q<J?N=Number.NaN:N=b.data[b.data.length-1]?.value??0}else N=$e(b.data,Number(g));Number.isNaN(N)||(F===void 0&&(F=N),G.set(b.label,{value:N,time:g}))}if(pe(G),F!==void 0&&x[0]){const b=o.timeScale().timeToCoordinate(g),y=x[0].priceToCoordinate(F);if(b!==null&&y!==null){const P=Z.current;if(P){const L=P.querySelector(".LightweightChart");if(L){const N=L.getBoundingClientRect(),Q=P.getBoundingClientRect(),J=b+(N.left-Q.left),te=y+(N.top-Q.top);O({x:J,y:te})}else O({x:b,y})}else O({x:b,y})}else O(null)}else O(null)};return o.subscribeCrosshairMove(n),V&&o.subscribeClick(n),!a&&!q&&!ge&&requestAnimationFrame(()=>{const s=Array.from(S.current.values());if(s[0]&&l&&t[0]?.data.length>0){const f=o.timeScale().timeToCoordinate(l),C=t[0].data[t[0].data.length-1].value,x=s[0].priceToCoordinate(C);f!==null&&x!==null&&O({x:f,y:x})}}),()=>{o.unsubscribeCrosshairMove(n),V&&o.unsubscribeClick(n)}},[t,q,V,ge]),m.useEffect(()=>{const o=I.current;if(!o||t.length===0)return;const a=o.timeScale(),l=()=>{const n=_e.current;if(n.length===0)return;const s=a.getVisibleRange();if(!s)return;const g=Number(s.from),f=Number(s.to);for(const C of n){const x=[];for(const G of t)if(C.labels.has(G.label))for(const F of G.data){const T=Number(F.time);T>=g&&T<=f&&x.push(F.value)}x.length>0&&C.updateVisibleRange(x)}};return a.subscribeVisibleLogicalRangeChange(l),()=>{a.unsubscribeVisibleLogicalRangeChange(l)}},[t]),m.useEffect(()=>{const o=I.current,a=Array.from(S.current.values()),l=[];if(o&&a.length>0&&w){const n=ie.getDefaultVerticalLine(),s=a[0];for(const g of w){const f={...n,...g.options||{}};f.color&&(f.color=E.resolveCSSColor(f.color,f.color));const C=new et.VertLine(o,s,g.xCoordinate,f);s.attachPrimitive(C),l.push(C)}}return()=>{if(a.length>0){const n=a[0];for(const s of l)n.detachPrimitive(s)}}},[w,t]),m.useEffect(()=>{const o=[];if(M&&M.length>0){const a=Array.from(S.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?S.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,t]),m.useEffect(()=>{const o=[];if($&&$.length>0){const a=Array.from(S.current.values())[0],l="rgba(239, 68, 68, 0.12)";for(const n of $){const s=n.seriesLabel?S.current.get(n.seriesLabel):a;if(!s)continue;const g=n.color?E.resolveCSSColor(n.color,l):l,f=new nt(s,n.priceTop,n.priceBottom,g);s.attachPrimitive(f),o.push({series:s,zone:f})}}return()=>{for(const{series:a,zone:l}of o)try{a.detachPrimitive(l)}catch{}}},[$,t]),m.useEffect(()=>{const o=I.current;if(!o||!w?.length){Me([]);return}const a=()=>{const s=o.timeScale(),g=w.map(f=>s.timeToCoordinate(f.xCoordinate)??null);Me(g)};a();const l=o.timeScale(),n=()=>{a()};return l.subscribeVisibleLogicalRangeChange(n),()=>{l.unsubscribeVisibleLogicalRangeChange(n)}},[w,t]);const se=t.length===1,ke=Se.useMemo(()=>{if(se&&t.length>0){const o=t[0];if(o.data.length>0)return o.data[o.data.length-1]}},[se,t]);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:R,decimals:ue}),Ve&&Pe&&v.jsx(Ue.GraphTooltip,{points:Ve,xMeasureUnit:p,yMeasureUnit:R,series:t,position:Pe,containerRef:Z,decimals:ue}),c&&v.jsx(Ae,{series:t,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:f}=We(n,R,ue),C=n.tooltipText??"";if(!(g||f||C))return null;const G=n.labelBackgroundColor??n.color??"hsl(var(--background))",F=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:F},children:[g&&v.jsx("span",{className:"block",children:g}),f&&v.jsx("span",{className:ne.cn("block",g&&"mt-0.5"),children:f}),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:t,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:t.map((h,p)=>{const R=xe(p),H=(h.lineColor??h.color)||R.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;
|