@gearbox-protocol/permissionless-ui 1.17.3 → 1.17.4

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 u=require("react/jsx-runtime"),s=require("@gearbox-protocol/sdk"),R=require("react"),i=require("../../utils/cn.cjs");require("sonner");function f(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,c.get?c:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const N=f(R),E=e=>e.reduce((r,t)=>r+t.balanceInUSD,0n),C={0:"bg-[#4976FE]",1:"bg-[#FFE55A]",2:"bg-[#CA5AFF]"},A="bg-[#5ABAFF]";function p({assets:e,className:r}){const[t,c]=N.useMemo(()=>{const o=e.slice(0,3),n=E(e),l=E(e.slice(3)),b=o.map(m=>n>0?Number(m.balanceInUSD*s.PERCENTAGE_FACTOR*s.PERCENTAGE_DECIMALS/n)/Number(s.PERCENTAGE_FACTOR):Number(s.PERCENTAGE_FACTOR)),d=n>0n?Number(l*s.PERCENTAGE_FACTOR*s.PERCENTAGE_DECIMALS/n)/Number(s.PERCENTAGE_FACTOR):0;return[b,d]},[e]),a=c>0;return u.jsxs("span",{className:i.cn("relative inline-flex overflow-hidden w-full h-[10px] bg-muted border-2 border-muted rounded-[20px]",r),children:[t.map((o,n,l)=>u.jsx("span",{className:i.cn("relative inline-flex h-full",C[n]||A,!a&&n===l.length-1?"":"border-r-2 border-muted"),style:{width:`${o}%`}},`${o}-${n}-${e.length}`)),a&&u.jsx("span",{className:i.cn("relative inline-flex h-full",A),style:{width:`${c}%`}})]})}exports.AssetsRatio=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),i=require("@gearbox-protocol/sdk"),h=require("react"),T=require("../tooltip/tooltip.cjs"),N=require("../../utils/cn.cjs");require("sonner");function j(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return n.default=e,Object.freeze(n)}const O=j(h),R=e=>e.reduce((n,o)=>n+o.balanceInUSD,0n),P={0:"bg-[#4976FE]",1:"bg-[#FFE55A]",2:"bg-[#CA5AFF]"},g="bg-[#5ABAFF]",c=4;function F(e){const n=e.filter(t=>t>0);if(n.length===0)return e;const o=n.length*c;if(e.reduce((t,s)=>t+s,0)===0||!n.some(t=>t<c))return e;const E=100-o,l=n.filter(t=>t>c).reduce((t,s)=>t+s-c,0);return e.map(t=>{if(t===0)return 0;if(t<c)return c;if(l===0)return t;const s=t-c;return c+s/l*E})}function S({assets:e,labels:n,className:o}){const[a,b]=O.useMemo(()=>{const d=e.slice(0,3),r=R(e),m=R(e.slice(3)),p=d.map(_=>r>0?Number(_.balanceInUSD*i.PERCENTAGE_FACTOR*i.PERCENTAGE_DECIMALS/r)/Number(i.PERCENTAGE_FACTOR):Number(i.PERCENTAGE_FACTOR)),A=r>0n?Number(m*i.PERCENTAGE_FACTOR*i.PERCENTAGE_DECIMALS/r)/Number(i.PERCENTAGE_FACTOR):0,f=[...p,A],C=F(f);return[C.slice(0,3),C[3]||0]},[e]),E=b>0,l=n?.slice(3),t=l&&l.length>0?l.join(", "):void 0,s=(d,r,m,p,A)=>{const f=u.jsx("span",{className:N.cn("relative inline-flex h-full",m,p?"border-r-2 border-muted":""),style:{width:`${d}%`}});return A?u.jsxs(T.Tooltip,{children:[u.jsx(T.TooltipTrigger,{asChild:!0,children:f}),u.jsx(T.TooltipContent,{children:A})]},`tooltip-${r}-${e.length}`):f};return u.jsx(T.TooltipProvider,{children:u.jsxs("span",{className:N.cn("relative inline-flex overflow-hidden w-full h-[10px] bg-muted border-2 border-muted rounded-[20px]",o),children:[a.map((d,r,m)=>s(d,r,P[r]||g,E||r!==m.length-1,n?.[r])),E&&s(b,3,g,!1,t)]})})}exports.AssetsRatio=S;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),me=require("lightweight-charts"),i=require("react"),he=require("../../hooks/use-media-query.cjs"),se=require("../../utils/cn.cjs"),I=require("../../utils/colors.cjs"),$=require("./default-config.cjs"),ee=require("./formatters.cjs"),pe=require("./graph-current-value.cjs"),be=require("./graph-tooltip.cjs"),ve=require("./plugins/vertical-line.cjs");function Ce(e){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const h in e)if(h!=="default"){const _=Object.getOwnPropertyDescriptor(e,h);Object.defineProperty(L,h,_.get?_:{enumerable:!0,get:()=>e[h]})}}return L.default=e,Object.freeze(L)}const te=Ce(i),B=[{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:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 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:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function Se({series:e,className:L,showLegend:h=!1,onUnselectSeries:_,xMeasureUnit:P="time",yMeasureUnit:k="token",optionsOverrides:A,verticalLineOptions:D}){const S=i.useRef(null),x=i.useRef(new Map),X=i.useRef(!1),oe=i.useRef(new Set),re=i.useRef(null),ne=i.useRef(!0),M=i.useRef(null),W=i.useRef(null),E=he.useIsMobile(),V=te.useMemo(()=>e.flatMap(t=>t.data),[e]),ce=te.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ae,Y]=i.useState(()=>{if(!ce)return;const t=new Map;for(const n of e)n.data.length>0&&t.set(n.label,n.data[n.data.length-1]);return t}),[le,j]=i.useState(null);i.useEffect(()=>{const t=()=>{if(S.current&&M.current){const u=M.current.clientWidth,a=M.current.clientHeight;S.current.resize(u,a),S.current.timeScale().fitContent()}},n=M.current,l=n?new ResizeObserver(t):null;return n&&l?.observe(n),()=>{n&&l?.unobserve(n)}},[]),i.useEffect(()=>{if(!W.current||X.current)return;const t=$.getDefaultOptions(),n=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=me.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!E,textColor:n},...A});return S.current=l,X.current=!0,()=>{l.remove(),S.current=null,X.current=!1,x.current.clear()}},[E,A]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=P==="time"?ee.getXFormatter(P,V):ee.getXFormatter(P),l=ee.getYFormatter(k),u=$.getDefaultOptions();t.applyOptions({localization:{...u.localization||{},timeFormatter:n?(o=>n(parseFloat(o),void 0)):void 0},timeScale:{...u.timeScale||{},tickMarkFormatter:n?(o=>n(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const g=(V.length>0?Math.min(...V.map(o=>o.value)):0)<0,R=V.some(o=>o.value===0),T=!g&&R,s=e.length>1,F=s||E,y=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!E,textColor:y,...T&&{scaleMargins:{top:.3,bottom:0}}}});const b=new Set(x.current.keys()),c=new Set(e.map(o=>o.label));for(const o of b)if(!c.has(o)){const r=x.current.get(o);r&&(t.removeSeries(r),x.current.delete(o))}const v=$.getDefaultSeries(),f=[];let C=0;for(let o=0;o<e.length;o++){const r=e[o],K=B[o%B.length],z=r.color||K.line;let N,O;if(r.color)if(r.topColor&&r.bottomColor)N=r.topColor,O=r.bottomColor;else if(r.topColor){const d=I.generateColorsFromBase(z);N=r.topColor,O=d.bottomColor}else if(r.bottomColor)N=I.generateColorsFromBase(z).topColor,O=r.bottomColor;else{const d=I.generateColorsFromBase(z);N=d.topColor,O=d.bottomColor}else N=r.topColor||K.top,O=r.bottomColor||K.bottom;if(r.data.length===0){const d=x.current.get(r.label);d&&(t.removeSeries(d),x.current.delete(r.label));continue}const fe=(r.data.length>0?Math.min(...r.data.map(d=>d.value)):0)<0,ge=r.data.some(d=>d.value===0),de=!fe&&ge,U=s?C===0?void 0:`scale-${C}`:void 0;s&&f.push({priceScaleId:U||"right",shouldPreventNegativeAxis:de,seriesIndex:C});let q=x.current.get(r.label);q?(q.applyOptions({lineColor:z,topColor:N,bottomColor:O,priceScaleId:U}),q.setData(r.data)):(q=t.addAreaSeries({...v,lineColor:z,topColor:N,bottomColor:O,priceScaleId:U,priceFormat:{type:"custom",formatter:d=>l(parseFloat(d.toString()),void 0,"short")}}),q.setData(r.data),x.current.set(r.label,q)),C++}if(s&&f.length>0)for(const o of f)try{const r=t.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!F,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:y})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}let p=null;if(V.length>0){const o=V.map(r=>typeof r.time=="number"?r.time:Number(r.time));p={from:Math.min(...o),to:Math.max(...o)}}const w=new Set(e.map(o=>o.label)),G=oe.current,Q=w.size!==G.size||[...w].some(o=>!G.has(o)),H=re.current,ue=p&&H&&(p.from!==H.from||p.to!==H.to);(ne.current||Q||ue||!H||E)&&(requestAnimationFrame(()=>{S.current&&S.current.timeScale().fitContent()}),ne.current=!1),oe.current=w,re.current=p;const J=new Map;for(const o of e)o.data.length>0&&J.set(o.label,o.data[o.data.length-1]);Y(J.size>0?J:void 0)},[e,V,P,k,E]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const u=a=>{const{time:g=l,seriesData:R,point:T}=a||{},s=Array.from(x.current.values());if(!T||!g){const b=new Map;for(const c of e)c.data.length>0&&b.set(c.label,c.data[c.data.length-1]);if(Y(b.size>0?b:void 0),n)j(null);else if(s[0]&&l){const v=t.timeScale().timeToCoordinate(l),f=e[0];if(f.data.length>0){const C=f.data[f.data.length-1].value,p=s[0].priceToCoordinate(C);v!==null&&p!==null&&j({x:v,y:p})}}return}const F=new Map;let y;for(let b=0;b<e.length;b++){const c=e[b],v=s[b];if(!v)continue;const f=R?.get(v),C=f&&"value"in f?f.value:void 0,p=c.data[c.data.length-1],w=C!==void 0?C:p?.value??0;b===0&&(y=w),F.set(c.label,{value:w,time:g})}if(Y(F),y!==void 0&&s[0]){const c=t.timeScale().timeToCoordinate(g),v=s[0].priceToCoordinate(y);if(c!==null&&v!==null){const f=M.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const p=C.getBoundingClientRect(),w=f.getBoundingClientRect(),G=c+(p.left-w.left),Q=v+(p.top-w.top);j({x:G,y:Q})}else j({x:c,y:v})}else j({x:c,y:v})}else j(null)}else j(null)};return t.subscribeCrosshairMove(u),n||requestAnimationFrame(()=>{const a=Array.from(x.current.values());if(a[0]&&l&&e[0]?.data.length>0){const R=t.timeScale().timeToCoordinate(l),T=e[0].data[e[0].data.length-1].value,s=a[0].priceToCoordinate(T);R!==null&&s!==null&&j({x:R,y:s})}}),()=>{t.unsubscribeCrosshairMove(u)}},[e]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),u=()=>{if(l===0)return;const a=n.getVisibleLogicalRange();if(!a)return;const g={from:0,to:l-1},R=typeof a.from=="number"?a.from:0,T=typeof a.to=="number"?a.to:l-1,s=.01;let F=!1;const y={...a};R<g.from-s&&(y.from=g.from,F=!0),T>g.to+s&&(y.to=g.to,F=!0),F&&n.setVisibleLogicalRange(y)};return n.subscribeVisibleLogicalRangeChange(u),()=>{n.unsubscribeVisibleLogicalRangeChange(u)}},[e]),i.useEffect(()=>{const t=S.current,n=Array.from(x.current.values()),l=[];if(t&&n.length>0&&D){const u=$.getDefaultVerticalLine(),a=n[0];for(const g of D){const R=new ve.VertLine(t,a,g.xCoordinate,{...u,...g.options||{}});a.attachPrimitive(R),l.push(R)}}return()=>{if(n.length>0){const u=n[0];for(const a of l)u.detachPrimitive(a)}}},[D]);const Z=e.length===1,ie=te.useMemo(()=>{if(Z&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Z,e]);return m.jsxs("div",{ref:M,className:se.cn("relative z-[1] w-full h-full overflow-hidden p-0",L),children:[Z&&ie&&m.jsx(pe.GraphCurrentValue,{point:ie,xMeasureUnit:P,yMeasureUnit:k}),ae&&le&&m.jsx(be.GraphTooltip,{points:ae,xMeasureUnit:P,yMeasureUnit:k,series:e,position:le,containerRef:M}),h&&m.jsx(xe,{series:e,onUnselect:_}),m.jsx("div",{ref:W,className:"LightweightChart w-full h-full overflow-hidden"})]})}function xe({series:e,onUnselect:L}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((h,_)=>{const P=B[_%B.length],k=h.color||P.line,A=h.data.length===0;return m.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",A&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:k}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[h.label,A&&" (no data)"]}),L&&m.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),L(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:m.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:[m.jsx("title",{children:"Close"}),m.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h.label)})})}exports.DEFAULT_SERIES_COLORS=B;exports.Graph=Se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),fe=require("lightweight-charts"),s=require("react"),ge=require("../../hooks/use-media-query.cjs"),le=require("../../utils/cn.cjs"),B=require("../../utils/colors.cjs"),H=require("./default-config.cjs"),U=require("./formatters.cjs"),de=require("./graph-current-value.cjs"),he=require("./graph-tooltip.cjs"),me=require("./plugins/vertical-line.cjs");function pe(e){const w=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const m in e)if(m!=="default"){const T=Object.getOwnPropertyDescriptor(e,m);Object.defineProperty(w,m,T.get?T:{enumerable:!0,get:()=>e[m]})}}return w.default=e,Object.freeze(w)}const ee=pe(s),G=[{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:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 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:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function be({series:e,className:w,showLegend:m=!1,onUnselectSeries:T,xMeasureUnit:P="time",yMeasureUnit:k="token",optionsOverrides:A,verticalLineOptions:D}){const y=s.useRef(null),v=s.useRef(new Map),$=s.useRef(!1),X=s.useRef(new Set),te=s.useRef(0),oe=s.useRef(!0),V=s.useRef(null),W=s.useRef(null),E=ge.useIsMobile(),M=ee.useMemo(()=>e.flatMap(t=>t.data),[e]),se=ee.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[re,Y]=s.useState(()=>{if(!se)return;const t=new Map;for(const r of e)r.data.length>0&&t.set(r.label,r.data[r.data.length-1]);return t}),[ne,L]=s.useState(null);s.useEffect(()=>{const t=()=>{if(y.current&&V.current){const u=V.current.clientWidth,a=V.current.clientHeight;y.current.resize(u,a),y.current.timeScale().fitContent()}},r=V.current,l=r?new ResizeObserver(t):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),s.useEffect(()=>{if(!W.current||$.current)return;const t=H.getDefaultOptions(),r=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=fe.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!E,textColor:r},...A});return y.current=l,$.current=!0,()=>{l.remove(),y.current=null,$.current=!1,v.current.clear()}},[E,A]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=P==="time"?U.getXFormatter(P,M):U.getXFormatter(P),l=U.getYFormatter(k),u=H.getDefaultOptions();t.applyOptions({localization:{...u.localization||{},timeFormatter:r?(o=>r(parseFloat(o),void 0)):void 0},timeScale:{...u.timeScale||{},tickMarkFormatter:r?(o=>r(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const g=(M.length>0?Math.min(...M.map(o=>o.value)):0)<0,S=M.some(o=>o.value===0),F=!g&&S,i=e.length>1,j=i||E,R=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!E,textColor:R,...F&&{scaleMargins:{top:.3,bottom:0}}}});const p=new Set(v.current.keys()),c=new Set(e.map(o=>o.label));for(const o of p)if(!c.has(o)){const n=v.current.get(o);n&&(t.removeSeries(n),v.current.delete(o))}const b=H.getDefaultSeries(),f=[];let C=0;for(let o=0;o<e.length;o++){const n=e[o],J=G[o%G.length],I=n.color||J.line;let _,N;if(n.color)if(n.topColor&&n.bottomColor)_=n.topColor,N=n.bottomColor;else if(n.topColor){const d=B.generateColorsFromBase(I);_=n.topColor,N=d.bottomColor}else if(n.bottomColor)_=B.generateColorsFromBase(I).topColor,N=n.bottomColor;else{const d=B.generateColorsFromBase(I);_=d.topColor,N=d.bottomColor}else _=n.topColor||J.top,N=n.bottomColor||J.bottom;if(n.data.length===0){const d=v.current.get(n.label);d&&(t.removeSeries(d),v.current.delete(n.label));continue}const ie=(n.data.length>0?Math.min(...n.data.map(d=>d.value)):0)<0,ce=n.data.some(d=>d.value===0),ue=!ie&&ce,K=i?C===0?void 0:`scale-${C}`:void 0;i&&f.push({priceScaleId:K||"right",shouldPreventNegativeAxis:ue,seriesIndex:C});let q=v.current.get(n.label);q?(q.applyOptions({lineColor:I,topColor:_,bottomColor:N,priceScaleId:K}),q.setData(n.data)):(q=t.addAreaSeries({...b,lineColor:I,topColor:_,bottomColor:N,priceScaleId:K,priceFormat:{type:"custom",formatter:d=>l(parseFloat(d.toString()),void 0,"short")}}),q.setData(n.data),v.current.set(n.label,q)),C++}if(i&&f.length>0)for(const o of f)try{const n=t.priceScale(o.priceScaleId);n&&n.applyOptions({visible:!j,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:R})}catch(n){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,n)}const x=new Set(e.map(o=>o.label)),O=x.size!==X.current.size||[...x].some(o=>!X.current.has(o)),Q=M.length!==te.current;(oe.current||O||Q||E)&&(t.timeScale().fitContent(),oe.current=!1),X.current=x,te.current=M.length;const z=new Map;for(const o of e)o.data.length>0&&z.set(o.label,o.data[o.data.length-1]);Y(z.size>0?z:void 0)},[e,M,P,k,E]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const u=a=>{const{time:g=l,seriesData:S,point:F}=a||{},i=Array.from(v.current.values());if(!F||!g){const p=new Map;for(const c of e)c.data.length>0&&p.set(c.label,c.data[c.data.length-1]);if(Y(p.size>0?p:void 0),r)L(null);else if(i[0]&&l){const b=t.timeScale().timeToCoordinate(l),f=e[0];if(f.data.length>0){const C=f.data[f.data.length-1].value,x=i[0].priceToCoordinate(C);b!==null&&x!==null&&L({x:b,y:x})}}return}const j=new Map;let R;for(let p=0;p<e.length;p++){const c=e[p],b=i[p];if(!b)continue;const f=S?.get(b),C=f&&"value"in f?f.value:void 0,x=c.data[c.data.length-1],O=C!==void 0?C:x?.value??0;p===0&&(R=O),j.set(c.label,{value:O,time:g})}if(Y(j),R!==void 0&&i[0]){const c=t.timeScale().timeToCoordinate(g),b=i[0].priceToCoordinate(R);if(c!==null&&b!==null){const f=V.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const x=C.getBoundingClientRect(),O=f.getBoundingClientRect(),Q=c+(x.left-O.left),z=b+(x.top-O.top);L({x:Q,y:z})}else L({x:c,y:b})}else L({x:c,y:b})}else L(null)}else L(null)};return t.subscribeCrosshairMove(u),r||requestAnimationFrame(()=>{const a=Array.from(v.current.values());if(a[0]&&l&&e[0]?.data.length>0){const S=t.timeScale().timeToCoordinate(l),F=e[0].data[e[0].data.length-1].value,i=a[0].priceToCoordinate(F);S!==null&&i!==null&&L({x:S,y:i})}}),()=>{t.unsubscribeCrosshairMove(u)}},[e]),s.useEffect(()=>{const t=y.current;if(!t||e.length===0)return;const r=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),u=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const g={from:0,to:l-1},S=typeof a.from=="number"?a.from:0,F=typeof a.to=="number"?a.to:l-1,i=.01;let j=!1;const R={...a};S<g.from-i&&(R.from=g.from,j=!0),F>g.to+i&&(R.to=g.to,j=!0),j&&r.setVisibleLogicalRange(R)};return r.subscribeVisibleLogicalRangeChange(u),()=>{r.unsubscribeVisibleLogicalRangeChange(u)}},[e]),s.useEffect(()=>{const t=y.current,r=Array.from(v.current.values()),l=[];if(t&&r.length>0&&D){const u=H.getDefaultVerticalLine(),a=r[0];for(const g of D){const S=new me.VertLine(t,a,g.xCoordinate,{...u,...g.options||{}});a.attachPrimitive(S),l.push(S)}}return()=>{if(r.length>0){const u=r[0];for(const a of l)u.detachPrimitive(a)}}},[D]);const Z=e.length===1,ae=ee.useMemo(()=>{if(Z&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Z,e]);return h.jsxs("div",{ref:V,className:le.cn("relative z-[1] w-full h-full overflow-hidden p-0",w),children:[Z&&ae&&h.jsx(de.GraphCurrentValue,{point:ae,xMeasureUnit:P,yMeasureUnit:k}),re&&ne&&h.jsx(he.GraphTooltip,{points:re,xMeasureUnit:P,yMeasureUnit:k,series:e,position:ne,containerRef:V}),m&&h.jsx(Ce,{series:e,onUnselect:T}),h.jsx("div",{ref:W,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ce({series:e,onUnselect:w}){return h.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((m,T)=>{const P=G[T%G.length],k=m.color||P.line,A=m.data.length===0;return h.jsxs("div",{className:le.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",A&&"opacity-50"),children:[h.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:k}}),h.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[m.label,A&&" (no data)"]}),w&&h.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),w(m.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 ${m.label}`,children:h.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:[h.jsx("title",{children:"Close"}),h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},m.label)})})}exports.DEFAULT_SERIES_COLORS=G;exports.Graph=be;
@@ -1,56 +1,79 @@
1
- import { jsxs as N, jsx as a } from "react/jsx-runtime";
2
- import { PERCENTAGE_FACTOR as r, PERCENTAGE_DECIMALS as u } from "@gearbox-protocol/sdk";
3
- import * as E from "react";
4
- import { cn as m } from "../../utils/cn.js";
1
+ import { jsx as h, jsxs as E } from "react/jsx-runtime";
2
+ import { PERCENTAGE_FACTOR as m, PERCENTAGE_DECIMALS as N } from "@gearbox-protocol/sdk";
3
+ import * as P from "react";
4
+ import { TooltipProvider as R, Tooltip as _, TooltipTrigger as v, TooltipContent as x } from "../tooltip/tooltip.js";
5
+ import { cn as g } from "../../utils/cn.js";
5
6
  import "sonner";
6
- const b = (t) => t.reduce((s, o) => s + o.balanceInUSD, 0n), h = {
7
+ const C = (e) => e.reduce((n, i) => n + i.balanceInUSD, 0n), D = {
7
8
  0: "bg-[#4976FE]",
8
9
  1: "bg-[#FFE55A]",
9
10
  2: "bg-[#CA5AFF]"
10
- }, p = "bg-[#5ABAFF]";
11
- function x({
12
- assets: t,
13
- className: s
11
+ }, F = "bg-[#5ABAFF]", s = 4;
12
+ function L(e) {
13
+ const n = e.filter((t) => t > 0);
14
+ if (n.length === 0) return e;
15
+ const i = n.length * s;
16
+ if (e.reduce((t, o) => t + o, 0) === 0 || !n.some((t) => t < s)) return e;
17
+ const d = 100 - i, c = n.filter((t) => t > s).reduce((t, o) => t + o - s, 0);
18
+ return e.map((t) => {
19
+ if (t === 0) return 0;
20
+ if (t < s) return s;
21
+ if (c === 0) return t;
22
+ const o = t - s;
23
+ return s + o / c * d;
24
+ });
25
+ }
26
+ function G({
27
+ assets: e,
28
+ labels: n,
29
+ className: i
14
30
  }) {
15
- const [o, c] = E.useMemo(() => {
16
- const n = t.slice(0, 3), e = b(t), l = b(t.slice(3)), A = n.map(
17
- (f) => e > 0 ? Number(
18
- f.balanceInUSD * r * u / e
19
- ) / Number(r) : Number(r)
20
- ), d = e > 0n ? Number(l * r * u / e) / Number(r) : 0;
21
- return [A, d];
22
- }, [t]), i = c > 0;
23
- return /* @__PURE__ */ N(
31
+ const [p, A] = P.useMemo(() => {
32
+ const l = e.slice(0, 3), r = C(e), u = C(e.slice(3)), b = l.map(
33
+ (I) => r > 0 ? Number(
34
+ I.balanceInUSD * m * N / r
35
+ ) / Number(m) : Number(m)
36
+ ), a = r > 0n ? Number(u * m * N / r) / Number(m) : 0, f = [...b, a], T = L(f);
37
+ return [T.slice(0, 3), T[3] || 0];
38
+ }, [e]), d = A > 0, c = n?.slice(3), t = c && c.length > 0 ? c.join(", ") : void 0, o = (l, r, u, b, a) => {
39
+ const f = /* @__PURE__ */ h(
40
+ "span",
41
+ {
42
+ className: g(
43
+ "relative inline-flex h-full",
44
+ u,
45
+ b ? "border-r-2 border-muted" : ""
46
+ ),
47
+ style: { width: `${l}%` }
48
+ }
49
+ );
50
+ return a ? /* @__PURE__ */ E(_, { children: [
51
+ /* @__PURE__ */ h(v, { asChild: !0, children: f }),
52
+ /* @__PURE__ */ h(x, { children: a })
53
+ ] }, `tooltip-${r}-${e.length}`) : f;
54
+ };
55
+ return /* @__PURE__ */ h(R, { children: /* @__PURE__ */ E(
24
56
  "span",
25
57
  {
26
- className: m(
58
+ className: g(
27
59
  "relative inline-flex overflow-hidden w-full h-[10px] bg-muted border-2 border-muted rounded-[20px]",
28
- s
60
+ i
29
61
  ),
30
62
  children: [
31
- o.map((n, e, l) => /* @__PURE__ */ a(
32
- "span",
33
- {
34
- className: m(
35
- "relative inline-flex h-full",
36
- h[e] || p,
37
- !i && e === l.length - 1 ? "" : "border-r-2 border-muted"
38
- ),
39
- style: { width: `${n}%` }
40
- },
41
- `${n}-${e}-${t.length}`
42
- )),
43
- i && /* @__PURE__ */ a(
44
- "span",
45
- {
46
- className: m("relative inline-flex h-full", p),
47
- style: { width: `${c}%` }
48
- }
49
- )
63
+ p.map(
64
+ (l, r, u) => o(
65
+ l,
66
+ r,
67
+ D[r] || F,
68
+ d || r !== u.length - 1,
69
+ n?.[r]
70
+ )
71
+ ),
72
+ d && o(A, 3, F, !1, t)
50
73
  ]
51
74
  }
52
- );
75
+ ) });
53
76
  }
54
77
  export {
55
- x as AssetsRatio
78
+ G as AssetsRatio
56
79
  };
@@ -1,16 +1,16 @@
1
- import { jsxs as $, jsx as x } from "react/jsx-runtime";
2
- import { createChart as vt } from "lightweight-charts";
3
- import * as tt from "react";
4
- import { useRef as V, useState as st, useEffect as D } from "react";
5
- import { useIsMobile as Ct } from "../../hooks/use-media-query.js";
6
- import { cn as dt } from "../../utils/cn.js";
7
- import { resolveCSSColor as ct, generateColorsFromBase as et } from "../../utils/colors.js";
8
- import { getDefaultOptions as ut, getDefaultSeries as St, getDefaultVerticalLine as xt } from "./default-config.js";
9
- import { getXFormatter as ft, getYFormatter as Rt } from "./formatters.js";
10
- import { GraphCurrentValue as wt } from "./graph-current-value.js";
11
- import { GraphTooltip as yt } from "./graph-tooltip.js";
12
- import { VertLine as Lt } from "./plugins/vertical-line.js";
13
- const q = [
1
+ import { jsxs as H, jsx as S } from "react/jsx-runtime";
2
+ import { createChart as ht } from "lightweight-charts";
3
+ import * as U from "react";
4
+ import { useRef as L, useState as lt, useEffect as D } from "react";
5
+ import { useIsMobile as pt } from "../../hooks/use-media-query.js";
6
+ import { cn as ut } from "../../utils/cn.js";
7
+ import { resolveCSSColor as it, generateColorsFromBase as tt } from "../../utils/colors.js";
8
+ import { getDefaultOptions as st, getDefaultSeries as bt, getDefaultVerticalLine as vt } from "./default-config.js";
9
+ import { getXFormatter as ct, getYFormatter as Ct } from "./formatters.js";
10
+ import { GraphCurrentValue as St } from "./graph-current-value.js";
11
+ import { GraphTooltip as xt } from "./graph-tooltip.js";
12
+ import { VertLine as wt } from "./plugins/vertical-line.js";
13
+ const $ = [
14
14
  {
15
15
  line: "#02c39a",
16
16
  top: "rgba(2, 195, 154, 0.56)",
@@ -52,78 +52,78 @@ const q = [
52
52
  bottom: "rgba(6, 182, 212, 0.04)"
53
53
  }
54
54
  ];
55
- function Bt({
55
+ function Dt({
56
56
  series: e,
57
- className: B,
57
+ className: G,
58
58
  showLegend: w = !1,
59
- onUnselectSeries: W,
59
+ onUnselectSeries: q,
60
60
  xMeasureUnit: y = "time",
61
61
  yMeasureUnit: A = "token",
62
62
  optionsOverrides: O,
63
63
  verticalLineOptions: E
64
64
  }) {
65
- const b = V(null), v = V(/* @__PURE__ */ new Map()), X = V(!1), ot = V(/* @__PURE__ */ new Set()), rt = V(null), nt = V(!0), M = V(null), Y = V(null), z = Ct(), F = tt.useMemo(() => e.flatMap((t) => t.data), [e]), mt = tt.useMemo(() => {
65
+ const x = L(null), p = L(/* @__PURE__ */ new Map()), W = L(!1), X = L(/* @__PURE__ */ new Set()), et = L(0), ot = L(!0), V = L(null), Y = L(null), z = pt(), M = U.useMemo(() => e.flatMap((t) => t.data), [e]), ft = U.useMemo(() => {
66
66
  if (e.length > 0) {
67
67
  const t = e[e.length - 1];
68
68
  if (t.data.length > 0)
69
69
  return t.data[t.data.length - 1];
70
70
  }
71
- }, [e]), [at, Z] = st(() => {
72
- if (!mt) return;
71
+ }, [e]), [rt, Z] = lt(() => {
72
+ if (!ft) return;
73
73
  const t = /* @__PURE__ */ new Map();
74
- for (const n of e)
75
- n.data.length > 0 && t.set(n.label, n.data[n.data.length - 1]);
74
+ for (const r of e)
75
+ r.data.length > 0 && t.set(r.label, r.data[r.data.length - 1]);
76
76
  return t;
77
- }), [lt, L] = st(null);
77
+ }), [nt, R] = lt(null);
78
78
  D(() => {
79
79
  const t = () => {
80
- if (b.current && M.current) {
81
- const c = M.current.clientWidth, a = M.current.clientHeight;
82
- b.current.resize(c, a), b.current.timeScale().fitContent();
80
+ if (x.current && V.current) {
81
+ const c = V.current.clientWidth, a = V.current.clientHeight;
82
+ x.current.resize(c, a), x.current.timeScale().fitContent();
83
83
  }
84
- }, n = M.current, l = n ? new ResizeObserver(t) : null;
85
- return n && l?.observe(n), () => {
86
- n && l?.unobserve(n);
84
+ }, r = V.current, l = r ? new ResizeObserver(t) : null;
85
+ return r && l?.observe(r), () => {
86
+ r && l?.unobserve(r);
87
87
  };
88
88
  }, []), D(() => {
89
- if (!Y.current || X.current) return;
90
- const t = ut(), n = ct(
89
+ if (!Y.current || W.current) return;
90
+ const t = st(), r = it(
91
91
  "hsl(var(--foreground))",
92
92
  "rgb(0, 0, 0)"
93
- ), l = vt(Y.current, {
93
+ ), l = ht(Y.current, {
94
94
  ...t,
95
95
  rightPriceScale: {
96
96
  ...t.rightPriceScale || {},
97
97
  visible: !z,
98
- textColor: n
98
+ textColor: r
99
99
  },
100
100
  ...O
101
101
  });
102
- return b.current = l, X.current = !0, () => {
103
- l.remove(), b.current = null, X.current = !1, v.current.clear();
102
+ return x.current = l, W.current = !0, () => {
103
+ l.remove(), x.current = null, W.current = !1, p.current.clear();
104
104
  };
105
105
  }, [z, O]), D(() => {
106
- const t = b.current;
106
+ const t = x.current;
107
107
  if (!t || e.length === 0) return;
108
- const n = y === "time" ? ft(y, F) : ft(y), l = Rt(A), c = ut();
108
+ const r = y === "time" ? ct(y, M) : ct(y), l = Ct(A), c = st();
109
109
  t.applyOptions({
110
110
  localization: {
111
111
  ...c.localization || {},
112
- timeFormatter: n ? (
112
+ timeFormatter: r ? (
113
113
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
114
- ((o) => n(parseFloat(o), void 0))
114
+ ((o) => r(parseFloat(o), void 0))
115
115
  ) : void 0
116
116
  },
117
117
  timeScale: {
118
118
  ...c.timeScale || {},
119
- tickMarkFormatter: n ? (
119
+ tickMarkFormatter: r ? (
120
120
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
121
- ((o) => n(parseFloat(o), void 0))
121
+ ((o) => r(parseFloat(o), void 0))
122
122
  ) : void 0,
123
123
  minBarSpacing: 0
124
124
  }
125
125
  });
126
- const f = (F.length > 0 ? Math.min(...F.map((o) => o.value)) : 0) < 0, C = F.some((o) => o.value === 0), N = !f && C, i = e.length > 1, P = i || z, S = ct(
126
+ const f = (M.length > 0 ? Math.min(...M.map((o) => o.value)) : 0) < 0, b = M.some((o) => o.value === 0), F = !f && b, i = e.length > 1, P = i || z, C = it(
127
127
  "hsl(var(--foreground))",
128
128
  "rgb(0, 0, 0)"
129
129
  );
@@ -131,8 +131,8 @@ function Bt({
131
131
  rightPriceScale: {
132
132
  ...c.rightPriceScale || {},
133
133
  visible: !z,
134
- textColor: S,
135
- ...N && {
134
+ textColor: C,
135
+ ...F && {
136
136
  scaleMargins: {
137
137
  top: 0.3,
138
138
  bottom: 0
@@ -140,65 +140,65 @@ function Bt({
140
140
  }
141
141
  }
142
142
  });
143
- const g = new Set(v.current.keys()), s = new Set(e.map((o) => o.label));
143
+ const g = new Set(p.current.keys()), s = new Set(e.map((o) => o.label));
144
144
  for (const o of g)
145
145
  if (!s.has(o)) {
146
- const r = v.current.get(o);
147
- r && (t.removeSeries(r), v.current.delete(o));
146
+ const n = p.current.get(o);
147
+ n && (t.removeSeries(n), p.current.delete(o));
148
148
  }
149
- const h = St(), u = [];
150
- let p = 0;
149
+ const m = bt(), u = [];
150
+ let h = 0;
151
151
  for (let o = 0; o < e.length; o++) {
152
- const r = e[o], Q = q[o % q.length], j = r.color || Q.line;
153
- let T, k;
154
- if (r.color)
155
- if (r.topColor && r.bottomColor)
156
- T = r.topColor, k = r.bottomColor;
157
- else if (r.topColor) {
158
- const d = et(j);
159
- T = r.topColor, k = d.bottomColor;
160
- } else if (r.bottomColor)
161
- T = et(j).topColor, k = r.bottomColor;
152
+ const n = e[o], K = $[o % $.length], B = n.color || K.line;
153
+ let k, T;
154
+ if (n.color)
155
+ if (n.topColor && n.bottomColor)
156
+ k = n.topColor, T = n.bottomColor;
157
+ else if (n.topColor) {
158
+ const d = tt(B);
159
+ k = n.topColor, T = d.bottomColor;
160
+ } else if (n.bottomColor)
161
+ k = tt(B).topColor, T = n.bottomColor;
162
162
  else {
163
- const d = et(j);
164
- T = d.topColor, k = d.bottomColor;
163
+ const d = tt(B);
164
+ k = d.topColor, T = d.bottomColor;
165
165
  }
166
166
  else
167
- T = r.topColor || Q.top, k = r.bottomColor || Q.bottom;
168
- if (r.data.length === 0) {
169
- const d = v.current.get(r.label);
170
- d && (t.removeSeries(d), v.current.delete(r.label));
167
+ k = n.topColor || K.top, T = n.bottomColor || K.bottom;
168
+ if (n.data.length === 0) {
169
+ const d = p.current.get(n.label);
170
+ d && (t.removeSeries(d), p.current.delete(n.label));
171
171
  continue;
172
172
  }
173
- const ht = (r.data.length > 0 ? Math.min(...r.data.map((d) => d.value)) : 0) < 0, pt = r.data.some((d) => d.value === 0), bt = !ht && pt, U = i ? p === 0 ? void 0 : `scale-${p}` : void 0;
173
+ const dt = (n.data.length > 0 ? Math.min(...n.data.map((d) => d.value)) : 0) < 0, gt = n.data.some((d) => d.value === 0), mt = !dt && gt, Q = i ? h === 0 ? void 0 : `scale-${h}` : void 0;
174
174
  i && u.push({
175
- priceScaleId: U || "right",
176
- shouldPreventNegativeAxis: bt,
177
- seriesIndex: p
175
+ priceScaleId: Q || "right",
176
+ shouldPreventNegativeAxis: mt,
177
+ seriesIndex: h
178
178
  });
179
- let I = v.current.get(r.label);
179
+ let I = p.current.get(n.label);
180
180
  I ? (I.applyOptions({
181
- lineColor: j,
182
- topColor: T,
183
- bottomColor: k,
184
- priceScaleId: U
185
- }), I.setData(r.data)) : (I = t.addAreaSeries({
186
- ...h,
187
- lineColor: j,
188
- topColor: T,
189
- bottomColor: k,
190
- priceScaleId: U,
181
+ lineColor: B,
182
+ topColor: k,
183
+ bottomColor: T,
184
+ priceScaleId: Q
185
+ }), I.setData(n.data)) : (I = t.addAreaSeries({
186
+ ...m,
187
+ lineColor: B,
188
+ topColor: k,
189
+ bottomColor: T,
190
+ priceScaleId: Q,
191
191
  priceFormat: {
192
192
  type: "custom",
193
193
  formatter: (d) => l(parseFloat(d.toString()), void 0, "short")
194
194
  }
195
- }), I.setData(r.data), v.current.set(r.label, I)), p++;
195
+ }), I.setData(n.data), p.current.set(n.label, I)), h++;
196
196
  }
197
197
  if (i && u.length > 0)
198
198
  for (const o of u)
199
199
  try {
200
- const r = t.priceScale(o.priceScaleId);
201
- r && r.applyOptions({
200
+ const n = t.priceScale(o.priceScaleId);
201
+ n && n.applyOptions({
202
202
  visible: !P,
203
203
  autoScale: !0,
204
204
  scaleMargins: {
@@ -213,36 +213,24 @@ function Bt({
213
213
  borderVisible: !0,
214
214
  borderColor: "rgba(224, 227, 235, 0.1)",
215
215
  entireTextOnly: !1,
216
- textColor: S
216
+ textColor: C
217
217
  });
218
- } catch (r) {
218
+ } catch (n) {
219
219
  console.warn(
220
220
  `Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,
221
- r
221
+ n
222
222
  );
223
223
  }
224
- let m = null;
225
- if (F.length > 0) {
226
- const o = F.map(
227
- (r) => typeof r.time == "number" ? r.time : Number(r.time)
228
- );
229
- m = {
230
- from: Math.min(...o),
231
- to: Math.max(...o)
232
- };
233
- }
234
- const R = new Set(e.map((o) => o.label)), G = ot.current, J = R.size !== G.size || [...R].some((o) => !G.has(o)), H = rt.current, gt = m && H && (m.from !== H.from || m.to !== H.to);
235
- (nt.current || J || gt || !H || z) && (requestAnimationFrame(() => {
236
- b.current && b.current.timeScale().fitContent();
237
- }), nt.current = !1), ot.current = R, rt.current = m;
238
- const K = /* @__PURE__ */ new Map();
224
+ const v = new Set(e.map((o) => o.label)), N = v.size !== X.current.size || [...v].some((o) => !X.current.has(o)), J = M.length !== et.current;
225
+ (ot.current || N || J || z) && (t.timeScale().fitContent(), ot.current = !1), X.current = v, et.current = M.length;
226
+ const j = /* @__PURE__ */ new Map();
239
227
  for (const o of e)
240
- o.data.length > 0 && K.set(o.label, o.data[o.data.length - 1]);
241
- Z(K.size > 0 ? K : void 0);
242
- }, [e, F, y, A, z]), D(() => {
243
- const t = b.current;
228
+ o.data.length > 0 && j.set(o.label, o.data[o.data.length - 1]);
229
+ Z(j.size > 0 ? j : void 0);
230
+ }, [e, M, y, A, z]), D(() => {
231
+ const t = x.current;
244
232
  if (!t || e.length === 0) return;
245
- const n = e.length === 1;
233
+ const r = e.length === 1;
246
234
  let l;
247
235
  for (const a of e)
248
236
  if (a.data.length > 0) {
@@ -251,136 +239,136 @@ function Bt({
251
239
  }
252
240
  if (!l) return;
253
241
  const c = (a) => {
254
- const { time: f = l, seriesData: C, point: N } = a || {}, i = Array.from(v.current.values());
255
- if (!N || !f) {
242
+ const { time: f = l, seriesData: b, point: F } = a || {}, i = Array.from(p.current.values());
243
+ if (!F || !f) {
256
244
  const g = /* @__PURE__ */ new Map();
257
245
  for (const s of e)
258
246
  s.data.length > 0 && g.set(s.label, s.data[s.data.length - 1]);
259
- if (Z(g.size > 0 ? g : void 0), n)
260
- L(null);
247
+ if (Z(g.size > 0 ? g : void 0), r)
248
+ R(null);
261
249
  else if (i[0] && l) {
262
- const h = t.timeScale().timeToCoordinate(l), u = e[0];
250
+ const m = t.timeScale().timeToCoordinate(l), u = e[0];
263
251
  if (u.data.length > 0) {
264
- const p = u.data[u.data.length - 1].value, m = i[0].priceToCoordinate(p);
265
- h !== null && m !== null && L({ x: h, y: m });
252
+ const h = u.data[u.data.length - 1].value, v = i[0].priceToCoordinate(h);
253
+ m !== null && v !== null && R({ x: m, y: v });
266
254
  }
267
255
  }
268
256
  return;
269
257
  }
270
258
  const P = /* @__PURE__ */ new Map();
271
- let S;
259
+ let C;
272
260
  for (let g = 0; g < e.length; g++) {
273
- const s = e[g], h = i[g];
274
- if (!h) continue;
275
- const u = C?.get(h), p = u && "value" in u ? u.value : void 0, m = s.data[s.data.length - 1], R = p !== void 0 ? p : m?.value ?? 0;
276
- g === 0 && (S = R), P.set(s.label, { value: R, time: f });
261
+ const s = e[g], m = i[g];
262
+ if (!m) continue;
263
+ const u = b?.get(m), h = u && "value" in u ? u.value : void 0, v = s.data[s.data.length - 1], N = h !== void 0 ? h : v?.value ?? 0;
264
+ g === 0 && (C = N), P.set(s.label, { value: N, time: f });
277
265
  }
278
- if (Z(P), S !== void 0 && i[0]) {
279
- const s = t.timeScale().timeToCoordinate(f), h = i[0].priceToCoordinate(S);
280
- if (s !== null && h !== null) {
281
- const u = M.current;
266
+ if (Z(P), C !== void 0 && i[0]) {
267
+ const s = t.timeScale().timeToCoordinate(f), m = i[0].priceToCoordinate(C);
268
+ if (s !== null && m !== null) {
269
+ const u = V.current;
282
270
  if (u) {
283
- const p = u.querySelector(
271
+ const h = u.querySelector(
284
272
  ".LightweightChart"
285
273
  );
286
- if (p) {
287
- const m = p.getBoundingClientRect(), R = u.getBoundingClientRect(), G = s + (m.left - R.left), J = h + (m.top - R.top);
288
- L({ x: G, y: J });
274
+ if (h) {
275
+ const v = h.getBoundingClientRect(), N = u.getBoundingClientRect(), J = s + (v.left - N.left), j = m + (v.top - N.top);
276
+ R({ x: J, y: j });
289
277
  } else
290
- L({ x: s, y: h });
278
+ R({ x: s, y: m });
291
279
  } else
292
- L({ x: s, y: h });
280
+ R({ x: s, y: m });
293
281
  } else
294
- L(null);
282
+ R(null);
295
283
  } else
296
- L(null);
284
+ R(null);
297
285
  };
298
- return t.subscribeCrosshairMove(c), n || requestAnimationFrame(() => {
299
- const a = Array.from(v.current.values());
286
+ return t.subscribeCrosshairMove(c), r || requestAnimationFrame(() => {
287
+ const a = Array.from(p.current.values());
300
288
  if (a[0] && l && e[0]?.data.length > 0) {
301
- const C = t.timeScale().timeToCoordinate(l), N = e[0].data[e[0].data.length - 1].value, i = a[0].priceToCoordinate(N);
302
- C !== null && i !== null && L({ x: C, y: i });
289
+ const b = t.timeScale().timeToCoordinate(l), F = e[0].data[e[0].data.length - 1].value, i = a[0].priceToCoordinate(F);
290
+ b !== null && i !== null && R({ x: b, y: i });
303
291
  }
304
292
  }), () => {
305
293
  t.unsubscribeCrosshairMove(c);
306
294
  };
307
295
  }, [e]), D(() => {
308
- const t = b.current;
296
+ const t = x.current;
309
297
  if (!t || e.length === 0) return;
310
- const n = t.timeScale(), l = Math.max(...e.map((a) => a.data.length)), c = () => {
298
+ const r = t.timeScale(), l = Math.max(...e.map((a) => a.data.length)), c = () => {
311
299
  if (l === 0) return;
312
- const a = n.getVisibleLogicalRange();
300
+ const a = r.getVisibleLogicalRange();
313
301
  if (!a) return;
314
302
  const f = {
315
303
  from: 0,
316
304
  to: l - 1
317
- }, C = typeof a.from == "number" ? a.from : 0, N = typeof a.to == "number" ? a.to : l - 1, i = 0.01;
305
+ }, b = typeof a.from == "number" ? a.from : 0, F = typeof a.to == "number" ? a.to : l - 1, i = 0.01;
318
306
  let P = !1;
319
- const S = { ...a };
320
- C < f.from - i && (S.from = f.from, P = !0), N > f.to + i && (S.to = f.to, P = !0), P && n.setVisibleLogicalRange(S);
307
+ const C = { ...a };
308
+ b < f.from - i && (C.from = f.from, P = !0), F > f.to + i && (C.to = f.to, P = !0), P && r.setVisibleLogicalRange(C);
321
309
  };
322
- return n.subscribeVisibleLogicalRangeChange(c), () => {
323
- n.unsubscribeVisibleLogicalRangeChange(
310
+ return r.subscribeVisibleLogicalRangeChange(c), () => {
311
+ r.unsubscribeVisibleLogicalRangeChange(
324
312
  c
325
313
  );
326
314
  };
327
315
  }, [e]), D(() => {
328
- const t = b.current, n = Array.from(v.current.values()), l = [];
329
- if (t && n.length > 0 && E) {
330
- const c = xt(), a = n[0];
316
+ const t = x.current, r = Array.from(p.current.values()), l = [];
317
+ if (t && r.length > 0 && E) {
318
+ const c = vt(), a = r[0];
331
319
  for (const f of E) {
332
- const C = new Lt(t, a, f.xCoordinate, {
320
+ const b = new wt(t, a, f.xCoordinate, {
333
321
  ...c,
334
322
  ...f.options || {}
335
323
  });
336
- a.attachPrimitive(C), l.push(C);
324
+ a.attachPrimitive(b), l.push(b);
337
325
  }
338
326
  }
339
327
  return () => {
340
- if (n.length > 0) {
341
- const c = n[0];
328
+ if (r.length > 0) {
329
+ const c = r[0];
342
330
  for (const a of l)
343
331
  c.detachPrimitive(a);
344
332
  }
345
333
  };
346
334
  }, [E]);
347
- const _ = e.length === 1, it = tt.useMemo(() => {
335
+ const _ = e.length === 1, at = U.useMemo(() => {
348
336
  if (_ && e.length > 0) {
349
337
  const t = e[0];
350
338
  if (t.data.length > 0)
351
339
  return t.data[t.data.length - 1];
352
340
  }
353
341
  }, [_, e]);
354
- return /* @__PURE__ */ $(
342
+ return /* @__PURE__ */ H(
355
343
  "div",
356
344
  {
357
- ref: M,
358
- className: dt(
345
+ ref: V,
346
+ className: ut(
359
347
  "relative z-[1] w-full h-full overflow-hidden p-0",
360
- B
348
+ G
361
349
  ),
362
350
  children: [
363
- _ && it && /* @__PURE__ */ x(
364
- wt,
351
+ _ && at && /* @__PURE__ */ S(
352
+ St,
365
353
  {
366
- point: it,
354
+ point: at,
367
355
  xMeasureUnit: y,
368
356
  yMeasureUnit: A
369
357
  }
370
358
  ),
371
- at && lt && /* @__PURE__ */ x(
372
- yt,
359
+ rt && nt && /* @__PURE__ */ S(
360
+ xt,
373
361
  {
374
- points: at,
362
+ points: rt,
375
363
  xMeasureUnit: y,
376
364
  yMeasureUnit: A,
377
365
  series: e,
378
- position: lt,
379
- containerRef: M
366
+ position: nt,
367
+ containerRef: V
380
368
  }
381
369
  ),
382
- w && /* @__PURE__ */ x(Pt, { series: e, onUnselect: W }),
383
- /* @__PURE__ */ x(
370
+ w && /* @__PURE__ */ S(yt, { series: e, onUnselect: q }),
371
+ /* @__PURE__ */ S(
384
372
  "div",
385
373
  {
386
374
  ref: Y,
@@ -391,41 +379,41 @@ function Bt({
391
379
  }
392
380
  );
393
381
  }
394
- function Pt({
382
+ function yt({
395
383
  series: e,
396
- onUnselect: B
384
+ onUnselect: G
397
385
  }) {
398
- return /* @__PURE__ */ x("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((w, W) => {
399
- const y = q[W % q.length], A = w.color || y.line, O = w.data.length === 0;
400
- return /* @__PURE__ */ $(
386
+ return /* @__PURE__ */ S("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((w, q) => {
387
+ const y = $[q % $.length], A = w.color || y.line, O = w.data.length === 0;
388
+ return /* @__PURE__ */ H(
401
389
  "div",
402
390
  {
403
- className: dt(
391
+ className: ut(
404
392
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
405
393
  O && "opacity-50"
406
394
  ),
407
395
  children: [
408
- /* @__PURE__ */ x(
396
+ /* @__PURE__ */ S(
409
397
  "div",
410
398
  {
411
399
  className: "w-3 h-3 rounded-sm",
412
400
  style: { backgroundColor: A }
413
401
  }
414
402
  ),
415
- /* @__PURE__ */ $("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
403
+ /* @__PURE__ */ H("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
416
404
  w.label,
417
405
  O && " (no data)"
418
406
  ] }),
419
- B && /* @__PURE__ */ x(
407
+ G && /* @__PURE__ */ S(
420
408
  "button",
421
409
  {
422
410
  type: "button",
423
411
  onClick: (E) => {
424
- E.stopPropagation(), B(w.label);
412
+ E.stopPropagation(), G(w.label);
425
413
  },
426
414
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
427
415
  "aria-label": `Remove ${w.label}`,
428
- children: /* @__PURE__ */ $(
416
+ children: /* @__PURE__ */ H(
429
417
  "svg",
430
418
  {
431
419
  xmlns: "http://www.w3.org/2000/svg",
@@ -440,9 +428,9 @@ function Pt({
440
428
  className: "text-muted-foreground hover:text-foreground",
441
429
  "aria-hidden": "true",
442
430
  children: [
443
- /* @__PURE__ */ x("title", { children: "Close" }),
444
- /* @__PURE__ */ x("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
445
- /* @__PURE__ */ x("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
431
+ /* @__PURE__ */ S("title", { children: "Close" }),
432
+ /* @__PURE__ */ S("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
433
+ /* @__PURE__ */ S("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
446
434
  ]
447
435
  }
448
436
  )
@@ -455,6 +443,6 @@ function Pt({
455
443
  }) });
456
444
  }
457
445
  export {
458
- q as DEFAULT_SERIES_COLORS,
459
- Bt as Graph
446
+ $ as DEFAULT_SERIES_COLORS,
447
+ Dt as Graph
460
448
  };
@@ -4,6 +4,8 @@ export interface AssetsRatioProps {
4
4
  assets: Array<Asset & {
5
5
  balanceInUSD: bigint;
6
6
  }>;
7
+ /** Labels for tooltips (e.g., token symbols). Index corresponds to asset index */
8
+ labels?: string[];
7
9
  className?: string;
8
10
  }
9
- export declare function AssetsRatio({ assets, className, }: AssetsRatioProps): React.ReactElement;
11
+ export declare function AssetsRatio({ assets, labels, className, }: AssetsRatioProps): React.ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/permissionless-ui",
3
- "version": "1.17.3",
3
+ "version": "1.17.4",
4
4
  "description": "Internal UI components",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",