@wick-charts/react 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),k=require("react/jsx-runtime");var wn=Object.defineProperty,ks=s=>{throw TypeError(s)},Sn=(s,t,e)=>t in s?wn(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,C=(s,t,e)=>Sn(s,typeof t!="symbol"?t+"":t,e),zi=(s,t,e)=>t.has(s)||ks("Cannot "+e),o=(s,t,e)=>(zi(s,t,"read from private field"),e?e.call(s):t.get(s)),A=(s,t,e)=>t.has(s)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),I=(s,t,e,i)=>(zi(s,t,"write to private field"),t.set(s,e),e),z=(s,t,e)=>(zi(s,t,"access private method"),e),Ri=(s,t,e,i)=>({set _(n){I(s,t,n)},get _(){return o(s,t,i)}});class Ue{constructor(){C(this,"listeners",new Map)}on(t,e){let i=this.listeners.get(t);i||(i=new Set,this.listeners.set(t,i)),i.add(e)}off(t,e){var i;(i=this.listeners.get(t))==null||i.delete(e)}emit(t,...e){var i;(i=this.listeners.get(t))==null||i.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function Ji(s,t){const e=new Map;return new Proxy(s,{get(i,n){const r=Reflect.get(i,n,i);if(typeof r!="function")return r;const a=e.get(n);if(a)return a;const l=typeof n=="string"?n:String(n),h=r,d=(...c)=>(t.set(l,(t.get(l)??0)+1),h.apply(i,c));return e.set(n,d),d},set(i,n,r){return Reflect.set(i,n,r,i)}})}function Qi(s,t,e){const i=document.createElement("canvas");return i.style.position="absolute",i.style.inset="0",i.style.width="100%",i.style.height="100%",i.style.display="block",i.style.zIndex=String(t),s.appendChild(i),i}class Mn extends Ue{constructor(t,e){super(),C(this,"mainCanvas"),C(this,"mainCtx"),C(this,"overlayCanvas"),C(this,"overlayCtx"),C(this,"resizeObserver"),C(this,"_size"),C(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=Qi(t,0),this.overlayCanvas=Qi(t,1);const i=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!i||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?Ji(i,e.drawCallsMain):i,this.overlayCtx=e?Ji(n,e.drawCallsOverlay):n;const r=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:r,verticalPixelRatio:r},this.resizeObserver=new ResizeObserver(l=>{this.handleResize(l[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const a=t.getBoundingClientRect();if(a.width>0&&a.height>0){const l=window.devicePixelRatio||1,h=l,d=Math.round(a.width*l),c=Math.round(a.height*h);this.mainCanvas.width=d,this.mainCanvas.height=c,this.overlayCanvas.width=d,this.overlayCanvas.height=c,this._size={media:{width:a.width,height:a.height},bitmap:{width:d,height:c},horizontalPixelRatio:d/a.width,verticalPixelRatio:c/a.height}}}handleResize(t){var e,i;let n,r,a,l;if(this.supportsDevicePixelContentBox&&(e=t.devicePixelContentBoxSize)!=null&&e[0]){const c=t.devicePixelContentBoxSize[0];n=c.inlineSize,r=c.blockSize;const u=t.contentBoxSize[0];a=u.inlineSize,l=u.blockSize}else{const c=(i=t.contentBoxSize)==null?void 0:i[0];if(c)a=c.inlineSize,l=c.blockSize;else{const f=t.contentRect;a=f.width,l=f.height}const u=window.devicePixelRatio||1;n=Math.round(a*u),r=Math.round(l*u)}if(n===0||r===0)return;this.mainCanvas.width=n,this.mainCanvas.height=r,this.overlayCanvas.width=n,this.overlayCanvas.height=r;const h=n/a,d=r/l;this._size={media:{width:a,height:l},bitmap:{width:n,height:r},horizontalPixelRatio:h,verticalPixelRatio:d},this.emit("resize",this._size)}get size(){return this._size}useMainLayer(t){this.mainCtx.save(),t({context:this.mainCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.mainCtx.restore()}useOverlayLayer(t){const{width:e,height:i}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,i),this.overlayCtx.save(),t({context:this.overlayCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.overlayCtx.restore()}get canvas(){return this.overlayCanvas}destroy(){this.resizeObserver.disconnect(),this.mainCanvas.remove(),this.overlayCanvas.remove(),this.removeAllListeners()}}function kn(s,t,e,i){const{context:n,bitmapSize:r,horizontalPixelRatio:a}=s;n.strokeStyle=i.crosshair.color,n.lineWidth=1,n.setLineDash([4*a,4*a]);const l=Math.round(t)+.5,h=Math.round(e)+.5;n.beginPath(),n.moveTo(l,0),n.lineTo(l,r.height),n.moveTo(0,h),n.lineTo(r.width,h),n.stroke(),n.setLineDash([])}const Cn=3,Tn=8,Zi=900,Rn=24,Ln=11,In=10,Bn=18;function Pn(s){const{state:t}=s;if(t==="idle"||t==="has-more")return;const e=s.timeScale.timeToX(s.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){Fn(s,e);return}t==="no-data"&&Wn(s,e)}}function Fn({scope:s,theme:t,chartMediaHeight:e,side:i,now:n},r){const{context:a,horizontalPixelRatio:l,verticalPixelRatio:h}=s,d=Cn*l,c=Tn*l,u=Rn*l,f=r*l,m=i==="right"?f+u:f-u,p=e/2*h,g=n%Zi/Zi,M=Math.floor(g*3),v=Cs(t.axis.textColor??"#787b86",.3),w=t.axis.textColor??"#787b86";a.save();for(let y=0;y<3;y++){const S=(y-1)*c,x=m+S;a.beginPath(),a.arc(x,p,d,0,Math.PI*2),a.fillStyle=y===M?w:v,a.fill()}a.restore()}function Wn({scope:s,theme:t,chartMediaHeight:e,side:i},n){const{context:r,horizontalPixelRatio:a,verticalPixelRatio:l}=s,h=Math.round(n*a)+.5;r.save(),r.strokeStyle=Cs(t.axis.textColor??"#787b86",.6),r.lineWidth=1,r.setLineDash([4*a,4*a]),r.beginPath(),r.moveTo(h,0),r.lineTo(h,e*l),r.stroke(),r.setLineDash([]);const d=In*a,c=i==="right"?h-d:h+d,u=Bn*l;r.fillStyle=t.axis.textColor??"#787b86",r.font=`${Ln*a}px ${t.typography.fontFamily}`,r.textAlign=i==="right"?"right":"left",r.textBaseline="top",r.fillText("No more data",c,u),r.restore()}function Cs(s,t){const e=/^#([0-9a-f]{6})$/i.exec(s.trim());if(!e)return s;const i=parseInt(e[1].slice(0,2),16),n=parseInt(e[1].slice(2,4),16),r=parseInt(e[1].slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${t})`}function An(s,t,e,i,n){const{context:r,bitmapSize:a,horizontalPixelRatio:l,verticalPixelRatio:h}=s;r.strokeStyle=i.grid.color,r.lineWidth=1,i.grid.style==="dashed"?r.setLineDash([4*l,4*l]):i.grid.style==="dotted"&&r.setLineDash([1*l,3*l]);const d=e.niceTickValues();r.beginPath();for(const u of d){const f=Math.round(e.valueToBitmapY(u))+.5;r.moveTo(0,f),r.lineTo(a.width,f)}r.stroke();const{ticks:c}=t.niceTickValues(n);r.beginPath();for(const u of c){const f=Math.round(t.timeToBitmapX(u))+.5;r.moveTo(f,0),r.lineTo(f,a.height)}r.stroke(),r.setLineDash([])}function Se(s,t,e){return Math.max(t,Math.min(e,s))}function mt(s,t,e){return s+(t-s)*e}function Jt(s,t,e,i){const n=Math.exp(-e*i);return t+(s-t)*n}function Ts(s){return 1-(1-s)**3}function yi(s,t,e){let i=0,n=s.length-1;for(;i<=n;){const r=i+n>>>1,a=e(s[r]);if(a<t)i=r+1;else if(a>t)n=r-1;else return r}return i}class Rs extends Ue{constructor(){super(...arguments),C(this,"data",[]),C(this,"_visible",!0),C(this,"cachedRange",null),C(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let i=1;i<t.length;i++)if(t[i].time<t[i-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((i,n)=>i.time-n.time),this.cachedRange=null,this.emit("update")}append(t){if(this.data.length>0&&t.time<=this.data[this.data.length-1].time){this.updateLast(t);return}this.data.push(t),this.cachedRange=null,this.emit("update")}updateLast(t){this.data.length!==0&&(this.data[this.data.length-1]=t,this.cachedRange=null,this.emit("update"))}getAll(){return this.data}getVisibleData(t,e){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===e)return this.cachedResult;const i=Math.max(0,yi(this.data,t,r=>r.time)-1),n=Math.min(this.data.length,yi(this.data,e,r=>r.time)+1);return this.cachedResult=this.data.slice(i,n),this.cachedRange={from:t,to:e},this.cachedResult}first(){return this.data[0]}last(){return this.data[this.data.length-1]}get length(){return this.data.length}isEmpty(){return this.data.length===0}findNearest(t,e){if(this.data.length===0)return null;const i=yi(this.data,t,a=>a.time);let n=null,r=e;for(let a=Math.max(0,i-1);a<=Math.min(this.data.length-1,i+1);a++){const l=Math.abs(this.data[a].time-t);l<=r&&(r=l,n=this.data[a])}return n}}class zn{constructor(t,e,i){C(this,"dragging",!1),C(this,"lastX",0),this.viewport=t,this.timeScale=e,this.canvas=i}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const e=t.clientX-this.lastX;this.lastX=t.clientX;const i=this.timeScale.pixelDeltaToTimeDelta(-e);this.viewport.pan(i,this.timeScale.getMediaWidth())}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair",this.viewport.startRebound(this.timeScale.getMediaWidth()))}isDragging(){return this.dragging}}const Dn=150;class En{constructor(t,e){C(this,"reboundTimer",null),this.viewport=t,this.timeScale=e}handleWheel(t){t.preventDefault();const e=Vn(t.deltaY,t.deltaMode),i=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),r=Math.min(t.offsetX,n),a=this.timeScale.xToTime(r);this.viewport.zoomAt(a,i,n),this.reboundTimer!==null&&clearTimeout(this.reboundTimer),this.reboundTimer=setTimeout(()=>{this.reboundTimer=null,this.viewport.startRebound(n)},Dn)}cancelPendingRebound(){this.reboundTimer!==null&&(clearTimeout(this.reboundTimer),this.reboundTimer=null)}}function Vn(s,t){return t===WheelEvent.DOM_DELTA_LINE?s*8:t===WheelEvent.DOM_DELTA_PAGE?s*24:s}class Yn extends Ue{constructor(t,e,i,n){super(),C(this,"zoom"),C(this,"pan"),C(this,"canvas"),C(this,"timeScale"),C(this,"yScale"),C(this,"viewport"),C(this,"onWheel",r=>{this.zoom.handleWheel(r)}),C(this,"onMouseDown",r=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(r)}),C(this,"onMouseMove",r=>{this.pan.isDragging()&&this.pan.handleMouseMove(r),this.emitCrosshair(r.offsetX,r.offsetY)}),C(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),C(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),C(this,"onDblClick",()=>{}),C(this,"lastTouchDist",0),C(this,"lastTouchCenter",0),C(this,"touchCount",0),C(this,"onTouchStart",r=>{r.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=r.touches.length,r.touches.length===1?this.pan.handleMouseDown({button:0,clientX:r.touches[0].clientX}):r.touches.length===2&&(this.lastTouchDist=Math.abs(r.touches[0].clientX-r.touches[1].clientX),this.lastTouchCenter=(r.touches[0].clientX+r.touches[1].clientX)/2)}),C(this,"onTouchMove",r=>{if(r.preventDefault(),r.touches.length===1&&this.touchCount===1)this.pan.handleMouseMove({clientX:r.touches[0].clientX});else if(r.touches.length===2){const a=Math.abs(r.touches[0].clientX-r.touches[1].clientX),l=(r.touches[0].clientX+r.touches[1].clientX)/2,h=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const d=this.lastTouchDist/a,c=this.timeScale.xToTime(l-h.left);this.viewport.zoomAt(c,d,this.timeScale.getMediaWidth())}this.lastTouchDist=a,this.lastTouchCenter=l}}),C(this,"onTouchEnd",r=>{if(r.touches.length===0){const a=this.touchCount===2;this.pan.handleMouseUp(),a&&this.viewport.startRebound(this.timeScale.getMediaWidth()),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null)}}),this.canvas=t,this.viewport=e,this.timeScale=i,this.yScale=n,this.zoom=new En(e,i),this.pan=new zn(e,i,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd)}emitCrosshair(t,e){const i=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:i,y:n})}destroy(){this.zoom.cancelPendingRebound(),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.removeAllListeners()}}const jn=new WeakMap;function On(s,t){jn.set(s,t)}const Hn=100,$n={position:"absolute",top:"4px",right:"4px",padding:"4px 6px",background:"rgba(0, 0, 0, 0.6)",color:"#e0e0e0",font:"11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace",borderRadius:"3px",pointerEvents:"none",zIndex:"20",whiteSpace:"pre",letterSpacing:"0.01em"};function ts(s){let t=0;for(const e of Object.values(s))t+=e;return t}const _e=9,Di=7,Lt=6,Ei=9;function Nn(s,t){return Math.round(s*t).toLocaleString("en-US")}function es(s,t,e,i,n){return[s.padEnd(_e),t.toFixed(1).padStart(Di),e.toFixed(2).padStart(Lt),i.toFixed(2).padStart(Lt),Nn(n,t).padStart(Ei)].join(" ")}function is(s){return[s.padEnd(_e),"—".padStart(Di),"—".padStart(Lt),"—".padStart(Lt),"idle".padStart(Ei)].join(" ")}function Xn(){return["".padEnd(_e),"FPS".padStart(Di),"ms".padStart(Lt),"worst".padStart(Lt),"calls/s".padStart(Ei)].join(" ")}function _n(s){const t=ts(s.drawCalls.main),e=ts(s.drawCalls.overlay),i=s.frameCount.main===0?is("Main"):es("Main",s.mainRendersPerSec,s.mainFrameMs.last,s.mainFrameMs.p95,t),n=s.frameCount.overlay===0?is("Overlay"):es("Overlay",s.overlayRendersPerSec,s.overlayFrameMs.last,s.overlayFrameMs.p95,e),r=[Xn(),i,n],a=Object.keys(s.perSeries);if(a.length>1){r.push(""),r.push("Per series (main pass)"),r.push(["".padEnd(_e),"ms".padStart(Lt),"worst".padStart(Lt)].join(" "));for(const l of a){const h=s.perSeries[l];r.push([` ${l}`.padEnd(_e),h.last.toFixed(2).padStart(Lt),h.p95.toFixed(2).padStart(Lt)].join(" "))}}return r.join(`
2
- `)}class Un{constructor(t,e,i=Hn){C(this,"element"),C(this,"unsubscribe"),C(this,"updateIntervalMs"),C(this,"lastUpdate",0),this.updateIntervalMs=i;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,$n),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=_n(t))}}const Gn=5e3,Kn=2e3,qn=30;function xi(s,t,e){let i=0;for(;i<t.length&&t[i]<e;)i++;i>0&&(s.splice(0,i),t.splice(0,i))}function wi(s,t,e){const i=s.length-e;i>0&&(s.splice(0,i),t.splice(0,i))}function Si(s){if(s.length===0)return{last:0,p50:0,p95:0};const t=[...s].sort((e,i)=>e-i);return{last:s[s.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function ss(s){if(s.length<2)return 0;const t=s[s.length-1]-s[0];return t<=0?0:(s.length-1)*1e3/t}function ns(s){const t={};for(const[e,i]of s)t[e]=i;return t}class Mi{constructor(t={}){C(this,"drawCallsMain",new Map),C(this,"drawCallsOverlay",new Map),C(this,"mainMs",[]),C(this,"overlayMs",[]),C(this,"mainStamps",[]),C(this,"overlayStamps",[]),C(this,"perSeriesMs",new Map),C(this,"perSeriesStamps",new Map),C(this,"listeners",new Set),C(this,"windowMs"),C(this,"maxSamples"),C(this,"heapInterval"),C(this,"heapCounter",0),C(this,"heapMb",null),C(this,"mainFrameCount",0),C(this,"overlayFrameCount",0),C(this,"lastStamp",0),this.windowMs=t.windowMs??Gn,this.maxSamples=t.maxSamples??Kn,this.heapInterval=t.heapSampleEveryNFrames??qn}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,i){if(this.lastStamp=i,t==="main"?(this.mainMs.push(e),this.mainStamps.push(i),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(i),this.overlayFrameCount++),this.trimAll(i),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,i=this.lastStamp){let n=this.perSeriesMs.get(t),r=this.perSeriesStamps.get(t);(!n||!r)&&(n=[],r=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,r)),n.push(e),r.push(i)}trimAll(t){const e=t-this.windowMs;xi(this.mainMs,this.mainStamps,e),xi(this.overlayMs,this.overlayStamps,e),wi(this.mainMs,this.mainStamps,this.maxSamples),wi(this.overlayMs,this.overlayStamps,this.maxSamples);for(const i of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(i),r=this.perSeriesStamps.get(i);!n||!r||(xi(n,r,e),wi(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[i,n]of this.perSeriesMs)t[i]=Si(n);const e=ss(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:ss(this.overlayStamps),fps:e,mainFrameMs:Si(this.mainMs),overlayFrameMs:Si(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:ns(this.drawCallsMain),overlay:ns(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}class ti{constructor(t){C(this,"dirty",!1),C(this,"rafId",null),C(this,"callback"),C(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const ce=6e4,ee=36e5,Gt=864e5;function ut(s){return s instanceof Date?s.getTime():s}function Jn(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ut(t.time)}))}function Qn(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ut(t.time)}))}function Ls(s){if(s.length<2)return Gt;const t=[];for(let e=1;e<Math.min(s.length,20);e++)t.push(s[e]-s[e-1]);return t.sort((e,i)=>e-i),t[Math.floor(t.length/2)]}function Ge(s,t){const e=new Date(s);return t>=Gt?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=ee?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Is(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Zn(s){const t=[1e3,5e3,1e4,15e3,3e4],e=[ce,5*ce,10*ce,15*ce,30*ce],i=[ee,2*ee,4*ee,6*ee,12*ee],n=[Gt,7*Gt,30*Gt,90*Gt,365*Gt];return s<ce?[...t,...e,...i,...n]:s<ee?[...e,...i,...n]:s<Gt?[...i,...n]:n}const tr=50,er=80;class Bs{constructor(){C(this,"from",0),C(this,"to",0),C(this,"width",1),C(this,"pixelRatio",1),C(this,"dataInterval",null),C(this,"labelCountHintValue",null),C(this,"minSpacingValue",null),C(this,"resolvedInterval",null),C(this,"lastInterval",null),C(this,"lastWant",null),C(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??er}update(t,e,i,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=i,n!==void 0&&n>0){const r=rs(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=ir(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=sr(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const a=rs(t);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,i=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(tr,Math.floor((this.to-i)/e)+1)),r=[];for(let a=0;a<n;a++)r.push(i+a*e);return{ticks:r,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=Zn(this.dataInterval),e=this.to-this.from,i=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,i)}else n=i;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=i;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],a=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){r=t[l],a=l;break}if(this.labelCountHint!=null&&a>0&&this.countTicks(r)<this.labelCountHint){const l=t[a-1];l>=i&&(r=l)}this.resolvedInterval=r,this.lastInterval=r,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function rs(s){return s<6e4?0:s<36e5?1:s<864e5?2:3}function ir(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function sr(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Ps(s){const t=Math.abs(s);if(t===0)return"0";if(t<1e-12)return s.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),i=Math.min(12,e+4),n=s.toFixed(i);return n.includes(".")?n.replace(/\.?0+$/,""):n}function Fs(s){return Number.isNaN(s)?"—":s===1/0?"∞":s===-1/0?"−∞":null}function te(s,t){const e=Fs(s);if(e!==null)return e;const i=Math.abs(s),n=(t==null?void 0:t.decimals)??2,r=(a,l,h)=>{const d=a/l,c=Number.parseFloat(d.toFixed(n));return Math.abs(c)>=1e3?null:`${d.toFixed(n)}${h}`};return i>=1e15?s.toExponential(2):i>=1e12?r(s,1e12,"T")??s.toExponential(2):i>=1e9?r(s,1e9,"B")??`${(s/1e12).toFixed(n)}T`:i>=1e6?r(s,1e6,"M")??`${(s/1e9).toFixed(n)}B`:i>=1e3?r(s,1e3,"K")??`${(s/1e6).toFixed(n)}M`:i<1?Ps(s):i<100?s.toFixed(2):s.toFixed(0)}function Vi(s){const t=Fs(s);if(t!==null)return t;const e=Math.abs(s);return e===0?"0":e<1?Ps(s):e<100?s.toFixed(4):e>=1e7?te(s):e<1e4?s.toFixed(2):s.toFixed(0)}function nr(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function rr(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e>=5?5:e>=2?2:1)*t}const ar=50,or=50;class Ws{constructor(){C(this,"min",0),C(this,"max",0),C(this,"height",1),C(this,"pixelRatio",1),C(this,"labelCountHintValue",null),C(this,"minSpacingValue",null),C(this,"resolvedInterval",null),C(this,"lastInterval",null),C(this,"lastRawInterval",null),C(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??or}update(t,e,i){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=i,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=lr(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=hr(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,i=Math.max(0,Math.min(ar,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<i;r++)n.push(e+r*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return te(t);const e=this.resolvedInterval,i=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(i)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,i=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/i;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const a=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(a&&l){this.resolvedInterval=this.lastInterval;return}}let r=nr(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const a=rr(n);a>=e&&a>0&&(r=a)}this.resolvedInterval=r,this.lastInterval=r,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function lr(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function hr(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Zt(s,t){return s===!1?0:s===void 0?t:s}function de(s,t){const e=Math.max(1e-4,Math.abs(t)*1e-5);return Math.abs(s-t)>e}function cr(s,t,e,i){const n=s==null?void 0:s.get(t);if(!n)return 1;if(i<=0)return s==null||s.delete(t),1;const r=Se((e-n.startTime)/i,0,1),a=Ts(r);return r>=1&&(s==null||s.delete(t)),a}function ur(s){let t=0,e=0;for(const i of s)i>0?t+=i:i<0&&(e+=i);return{positive:t,negative:e}}function dr(s){return s.positive>0?s.positive:s.negative<0?s.negative:0}function fr(s){return s.positive>0?100:s.negative<0?-100:0}class As{constructor(t){C(this,"stores"),C(this,"displayedLastValues"),C(this,"lastSeededTimes"),C(this,"entries"),C(this,"lastRenderTime",0),this.stores=Array.from({length:t},()=>new Rs),this.displayedLastValues=new Array(t).fill(null),this.lastSeededTimes=new Array(t).fill(Number.NaN),this.entries=Array.from({length:t},()=>new Map)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=Qn(t??[]);n.setData(r),(i=this.entries[e])==null||i.clear()}appendPoint(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=t,a=ut(r.time),l=this.createEntry(e,a,performance.now());n.append({...r,time:a}),l&&((i=this.entries[e])==null||i.set(a,l))}updateLastPoint(t,e=0){const i=this.stores[e];if(!i)return;const n=t;i.updateLast({...n,time:ut(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var i;(i=this.stores[t])==null||i.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners();for(const t of this.entries)t.clear();this.displayedLastValues=this.displayedLastValues.map(()=>null),this.lastSeededTimes=this.lastSeededTimes.map(()=>Number.NaN),this.lastRenderTime=0}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}get needsAnimation(){for(const t of this.entries)if(t.size>0)return!0;for(let t=0;t<this.stores.length;t++){const e=this.displayedLastValues[t],i=this.stores[t].last();if(!(e==null||!i)&&this.lastSeededTimes[t]===i.time&&de(e,i.value))return!0}return!1}advanceLiveTracking(t){if(t===this.lastRenderTime)return;const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=Zt(this.getCommonOptions().smoothMs,70),n=i>0?1e3/i:0;for(let r=0;r<this.stores.length;r++){const a=this.stores[r].last();if(!a){this.displayedLastValues[r]=null,this.lastSeededTimes[r]=Number.NaN;continue}const l=this.displayedLastValues[r],h=this.lastSeededTimes[r]!==a.time;if(l===null||h||n<=0){this.displayedLastValues[r]=a.value,this.lastSeededTimes[r]=a.time;continue}this.displayedLastValues[r]=Jt(l,a.value,n,e)}}entranceProgress(t,e,i){const n=Zt(this.getCommonOptions().entryMs,400);return cr(this.entries[t],e,i,n)}effectiveValue(t,e,i){const n=this.displayedLastValues[t];return n==null||this.lastSeededTimes[t]!==e?i:n}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var i;return((i=this.stores[0])==null?void 0:i.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const i=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const a=this.stores[r].getVisibleData(t-e,t+e);if(a.length===0)continue;let l=a[0],h=Math.abs(a[0].time-t);for(let d=1;d<a.length;d++){const c=Math.abs(a[d].time-t);c<=h&&(h=c,l=a[d])}n.push({layerIndex:r,time:l.time,value:l.value,color:i[r%i.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const a=(t=this.stores[0])==null?void 0:t.last();return a?{value:a.value,isLive:!0}:null}let e=-1/0;for(const a of this.stores){if(!a.isVisible())continue;const l=a.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const i=this.getCommonOptions().stacking;if(i==="off"){for(let a=this.stores.length-1;a>=0;a--){if(!this.stores[a].isVisible())continue;const l=this.stores[a].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const a of this.stores){if(!a.isVisible())continue;const l=a.last();n.push(l&&l.time===e?l.value:0)}const r=ur(n);return{value:i==="percent"?fr(r):dr(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();n&&e.push({layerIndex:i,time:n.time,value:n.value,color:t[i%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getValueRange(t,e){const i=this.getCommonOptions().stacking;if(i==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(i==="off"){let h=1/0,d=-1/0;for(const c of n)for(const u of c)Number.isFinite(u.value)&&(u.value<h&&(h=u.value),u.value>d&&(d=u.value));return h<1/0?{min:h,max:d}:null}const r=new Map;for(let h=0;h<n.length;h++)for(const d of n[h]){let c=r.get(d.time);c||(c=new Array(n.length).fill(0),r.set(d.time,c)),c[h]=Number.isFinite(d.value)?d.value:0}let a=0,l=0;for(const h of r.values()){let d=0,c=0;for(const u of h)u>0?d+=u:c+=u;d>l&&(l=d),c<a&&(a=c)}return l>a?{min:a,max:l}:null}}const mr={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function as(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class gr extends As{constructor(t,e){super(t),C(this,"options"),this.options={...mr,...as(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...as(t)}}getCommonOptions(){return this.options}createEntry(t,e,i){const n=this.options.entryAnimation??"fade-grow",r=Zt(this.options.entryMs,400);return n==="none"||r<=0?null:{startTime:i}}applyTheme(t,e){const i=e.seriesColors,n=this.options.colors.map((r,a)=>r===i[a]?t.seriesColors[a]??r:r);this.updateOptions({colors:n})}applyBarTransform(t,e,i,n,r,a){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:i,barHeight:n,x:r,barWidth:a,alpha:1};let h=i,d=n,c=r,u=1;if((l==="fade"||l==="fade-grow")&&(u=t),l==="grow"||l==="fade-grow"){const f=n*t;i<e?h=e-f:h=e,d=Math.max(1,f)}return l==="slide"&&(c=r+(1-t)*a,u=t),{topY:h,barHeight:d,x:c,barWidth:a,alpha:u}}render(t){switch(this.advanceLiveTracking(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:l}=e,h=i.getRange(),d=performance.now();let c=0;for(const w of this.stores){if(!w.isVisible())continue;const y=w.getVisibleData(h.from,h.to).length;if(y>c&&(c=y),c>2)break}const u=i.barWidthBitmap(r),f=Math.round(30*l),m=c<=2?Math.min(f,u):u,p=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),g=Math.floor(p/2),M=n.getRange().min<0,v=M?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const w=this.options.colors[0],y=this.options.colors.length>1?this.options.colors[1]:w,S=this.stores[0].getVisibleData(h.from,h.to);for(const x of S){if(!Number.isFinite(x.value))continue;const P=this.effectiveValue(0,x.time,x.value),b=this.entranceProgress(0,x.time,d),R=i.timeToBitmapX(x.time);if(P>=0){const L=n.valueToBitmapY(P),T=Math.max(1,v-L);this.drawAnimatedBar(a,b,v,L,T,R-g,p,P>=0?w:y)}else{const L=n.valueToBitmapY(P),T=Math.max(1,L-v);this.drawAnimatedBar(a,b,v,v,T,R-g,p,y)}}}else{const w=this.stores.map(S=>S.isVisible()?S.getVisibleData(h.from,h.to):[]),y=new Map;for(let S=0;S<w.length;S++)for(const x of w[S]){if(!Number.isFinite(x.value))continue;let P=y.get(x.time);P||(P=[],y.set(x.time,P)),P.push({layer:S,value:this.effectiveValue(S,x.time,x.value)})}for(const[S,x]of y){x.sort((b,R)=>Math.abs(R.value)-Math.abs(b.value));const P=i.timeToBitmapX(S);for(const{layer:b,value:R}of x){const L=this.options.colors[b%this.options.colors.length],T=this.entranceProgress(b,S,d);if(R>=0){const F=n.valueToBitmapY(R),W=Math.max(1,v-F);this.drawAnimatedBar(a,T,v,F,W,P-g,p,L)}else{const F=n.valueToBitmapY(R),W=Math.max(1,F-v);this.drawAnimatedBar(a,T,v,v,W,P-g,p,L)}}}}if(M){a.strokeStyle=t.theme.grid.color,a.lineWidth=1;const w=Math.round(v)+.5;a.beginPath(),a.moveTo(0,w),a.lineTo(e.bitmapSize.width,w),a.stroke()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r,dataInterval:a}=t,{context:l,horizontalPixelRatio:h}=i,d=n.getRange(),c=performance.now();let u=0;for(const y of this.stores){if(!y.isVisible())continue;const S=y.getVisibleData(d.from,d.to).length;if(S>u&&(u=S),u>2)break}const f=n.barWidthBitmap(a),m=Math.round(30*h),p=u<=2?Math.min(m,f):f,g=Math.max(1,Math.round(p*this.options.barWidthRatio)-2),M=Math.floor(g/2),v=this.stores.map(y=>y.isVisible()?y.getVisibleData(d.from,d.to):[]);if(v.every(y=>y.length===0))return;const w=new Map;for(let y=0;y<v.length;y++)for(const S of v[y]){let x=w.get(S.time);x||(x=new Array(v.length).fill(0),w.set(S.time,x));const P=Number.isFinite(S.value)?S.value:0;x[y]=this.stores[y].isVisible()?this.effectiveValue(y,S.time,P):0}for(let y=0;y<v.length;y++){const S=this.options.colors[y%this.options.colors.length];for(const[x,P]of w){const b=P[y];if(b===0)continue;const R=n.timeToBitmapX(x);let L=0,T=0;for(let W=0;W<y;W++){const V=P[W];V>0?L+=V:T+=V}const F=this.entranceProgress(y,x,c);if(e){let W=0,V=0;for(const D of P)D>0?W+=D:V+=D;if(b>0&&W>0){const D=L/W*100,j=(L+b)/W*100,H=r.valueToBitmapY(j),X=r.valueToBitmapY(D),it=Math.max(1,X-H);this.drawAnimatedBar(l,F,X,H,it,R-M,g,S)}else if(b<0&&V<0){const D=T/V*-100,j=(T+b)/V*-100,H=r.valueToBitmapY(D),X=r.valueToBitmapY(j),it=Math.max(1,X-H);this.drawAnimatedBar(l,F,H,H,it,R-M,g,S)}}else if(b>0){const W=r.valueToBitmapY(L+b),V=r.valueToBitmapY(L),D=Math.max(1,V-W);this.drawAnimatedBar(l,F,V,W,D,R-M,g,S)}else{const W=r.valueToBitmapY(T),V=r.valueToBitmapY(T+b),D=Math.max(1,V-W);this.drawAnimatedBar(l,F,W,W,D,R-M,g,S)}}}}fillBar(t,e,i,n,r,a){t.fillStyle=a,t.fillRect(e,i,n,r)}drawAnimatedBar(t,e,i,n,r,a,l,h){const d=this.options.entryAnimation??"fade-grow";if(e>=1||d==="none"){this.fillBar(t,a,n,l,r,h);return}const c=this.applyBarTransform(e,i,n,r,a,l);t.save(),t.globalAlpha=c.alpha,t.fillStyle=h,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function os(s,t){return s.length<=t?s:br(s,t,e=>e.time,e=>e.value)}function pr(s,t){if(s.length<=t)return s;const e=Math.ceil(s.length/t),i=[];for(let n=0;n<s.length;n+=e){const r=Math.min(n+e,s.length);let a=-1/0,l=1/0,h=0;for(let d=n;d<r;d++)s[d].high>a&&(a=s[d].high),s[d].low<l&&(l=s[d].low),h+=s[d].volume??0;i.push({time:s[n].time,open:s[n].open,high:a,low:l,close:s[r-1].close,volume:h})}return i}function br(s,t,e,i){if(t>=s.length||t<3)return s;const n=[s[0]],r=(s.length-2)/(t-2);let a=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*r)+1,d=Math.min(Math.floor((l+2)*r)+1,s.length-1);let c=0,u=0;const f=d,m=Math.min(Math.floor((l+3)*r)+1,s.length),p=m-f;if(p>0){for(let y=f;y<m;y++)c+=e(s[y]),u+=i(s[y]);c/=p,u/=p}let g=-1,M=h;const v=e(s[a]),w=i(s[a]);for(let y=h;y<d;y++){const S=Math.abs((v-c)*(i(s[y])-w)-(v-e(s[y]))*(u-w));S>g&&(g=S,M=y)}n.push(s[M]),a=M}return n.push(s[s.length-1]),n}function Yi(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.fontSize)!==void 0?s.axis.x.fontSize:t==="y"&&((i=s.axis.y)==null?void 0:i.fontSize)!==void 0?s.axis.y.fontSize:s.axis.fontSize}function ji(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.textColor)!==void 0?s.axis.x.textColor:t==="y"&&((i=s.axis.y)==null?void 0:i.textColor)!==void 0?s.axis.y.textColor:s.axis.textColor}function gt(s){return Array.isArray(s)?s.source??s[0]:s}const ls=new Map;function vr(s){return[parseInt(s.slice(1,3),16),parseInt(s.slice(3,5),16),parseInt(s.slice(5,7),16)]}function ye(s,t){if(s.startsWith("rgba"))return s.replace(/[\d.]+\)\s*$/,`${t})`);if(s.startsWith("rgb("))return s.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=s+t;let i=ls.get(e);if(i)return i;const[n,r,a]=vr(s);return i=`rgba(${n}, ${r}, ${a}, ${t})`,ls.set(e,i),i}const yr={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6};function hs(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class xr{constructor(t,e){C(this,"store"),C(this,"options"),C(this,"displayedLast",null),C(this,"lastSeededTime",Number.NaN),C(this,"lastRenderTime",0),C(this,"entries",new Map),this.store=t,this.options={...yr,...hs(e)}}updateOptions(t){this.options={...this.options,...hs(t)}}getColor(){return gt(this.options.up.body)}setData(t){this.store.setData(Jn(t??[])),this.entries.clear()}appendPoint(t){const e=t,i=ut(e.time);this.store.append({...e,time:i});const n=this.options.entryAnimation??"unfold",r=Zt(this.options.entryMs,400);n!=="none"&&r>0&&this.entries.set(i,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:ut(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[gt(this.options.up.body)]}applyTheme(t,e){this.updateOptions({up:{...t.candlestick.up},down:{...t.candlestick.down}})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners(),this.displayedLast=null,this.lastSeededTime=Number.NaN,this.lastRenderTime=0,this.entries.clear()}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}cancelEntranceAnimations(){this.entries.clear()}get needsAnimation(){if(this.entries.size>0)return!0;if(!this.displayedLast)return!1;const t=this.store.last();if(!t||t.time!==this.displayedLast.time)return!1;if(de(this.displayedLast.open,t.open)||de(this.displayedLast.high,t.high)||de(this.displayedLast.low,t.low)||de(this.displayedLast.close,t.close))return!0;const e=this.displayedLast.volume,i=t.volume;return e===void 0||i===void 0?!1:de(e,i)}entranceProgress(t,e){const i=this.entries.get(t);if(!i)return 1;const n=Zt(this.options.entryMs,400);if(n<=0)return this.entries.delete(t),1;const r=Se((e-i.startTime)/n,0,1),a=Ts(r);return r>=1&&this.entries.delete(t),a}advanceLiveTracking(t){const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=this.store.last();if(!i){this.displayedLast=null,this.lastSeededTime=Number.NaN;return}const n=this.lastSeededTime!==i.time,r=Zt(this.options.smoothMs,70),a=r>0?1e3/r:0;if(this.displayedLast===null||n||a<=0){this.displayedLast={...i},this.lastSeededTime=i.time;return}const l=this.displayedLast,h=l.volume??0,d=i.volume??0;this.displayedLast={time:i.time,open:Jt(l.open,i.open,a,e),high:Jt(l.high,i.high,a,e),low:Jt(l.low,i.low,a,e),close:Jt(l.close,i.close,a,e),volume:i.volume===void 0?void 0:Jt(h,d,a,e)}}render(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:l}=e,h=i.getRange(),d=performance.now();this.advanceLiveTracking(d);let c=this.store.getVisibleData(h.from,h.to);const u=e.mediaSize.width,f=c.length>u*2;if(f&&(c=pr(c,Math.round(u*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const R=c.length-1;c[R].time===this.displayedLast.time&&(c=[...c.slice(0,R),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const R of c)this.entries.has(R.time)&&m.set(R.time,this.entranceProgress(R.time,d));const p=i.barWidthBitmap(r),g=Math.round(30*l),M=c.length<=2?Math.min(g,p):p,v=Math.max(1,Math.round(l));let w=Math.max(1,Math.round(M*this.options.bodyWidthRatio)-2);(w&1)!==(v&1)&&(w=w>1?w-1:2);const y=Math.floor(w/2),S=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:a,data:c,timeScale:i,chartHeight:S,barWidth:M,wickWidth:v,entranceByTime:m});const x=[],P=[];for(const R of c)R.close>=R.open?x.push(R):P.push(R);const b={ctx:a,timeScale:i,yScale:n,halfBody:y,bodyWidth:w,wickWidth:v,entranceByTime:m};this.drawCandles({...b,candles:x,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...b,candles:P,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:i,chartHeight:n,barWidth:r,wickWidth:a,entranceByTime:l}){let h=0;for(const g of e)Number.isFinite(g.volume)&&g.volume>h&&(h=g.volume);if(h===0)return;const d=n*.2;let c=Math.max(1,r-2);(c&1)!==(a&1)&&(c=c>1?c-1:2);const u=Math.floor(c/2),f=ye(gt(this.options.up.body),.2),m=ye(gt(this.options.down.body),.2),p=this.options.entryAnimation??"unfold";for(const g of e){if(!Number.isFinite(g.volume)||g.volume<=0)continue;const M=g.volume,v=i.timeToBitmapX(g.time),w=Math.max(1,M/h*d),y=g.close>=g.open;t.fillStyle=y?f:m;const S=(l==null?void 0:l.get(g.time))??1;if(S>=1||p==="none"){t.fillRect(v-u,n-w,c,w);continue}const x=ki(S,p,{x:v-u,barWidth:c,anchorY:n,topY:n-w,bottomY:n});t.save(),t.globalAlpha=x.alpha,t.fillRect(x.x,x.topY,c,Math.max(1,x.bottomY-x.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:i,yScale:n,halfBody:r,bodyWidth:a,wickWidth:l,body:h,wickColor:d,entranceByTime:c}){if(e.length===0)return;const u=this.options.entryAnimation??"unfold",f=a+2;t.fillStyle=d;for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,M=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),w=n.valueToBitmapY(p.high),y=n.valueToBitmapY(p.low),S=M-Math.floor(l/2);if(g>=1||u==="none"){t.fillRect(S,w,l,y-w);continue}const x=ki(g,u,{x:S,barWidth:f,anchorY:v,topY:w,bottomY:y});t.save(),t.globalAlpha=x.alpha,t.fillRect(x.x,x.topY,l,Math.max(1,x.bottomY-x.topY)),t.restore()}const m=Array.isArray(h);for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,M=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),w=n.valueToBitmapY(p.close),y=Math.min(v,w),S=Math.max(v,w),x=Math.max(1,S-y),P=g<1&&u!=="none";let b=M-r,R=y,L=x,T=1;if(P){const F=ki(g,u,{x:M-r,barWidth:f,anchorY:v,topY:y,bottomY:S});b=F.x,R=F.topY,L=Math.max(1,F.bottomY-F.topY),T=F.alpha}if(P&&t.save(),m&&L>2){const F=t.createLinearGradient(0,R,0,R+L);F.addColorStop(0,h[0]),F.addColorStop(1,h[1]),t.fillStyle=F}else t.fillStyle=m?h[0]:h;P&&(t.globalAlpha=T),t.fillRect(b,R,a,L),P&&t.restore()}}}function ki(s,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:s};case"unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,s),bottomY:mt(e.anchorY,e.bottomY,s),alpha:1};case"slide":return{x:e.x+(1-s)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:s};case"fade-unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,s),bottomY:mt(e.anchorY,e.bottomY,s),alpha:s}}}const wr={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function cs(s){if(!s)return{};const t={...s};return s.areaFill!==void 0&&s.area===void 0&&(t.area={visible:!!s.areaFill}),s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class Sr extends As{constructor(t,e){super(t),C(this,"options"),C(this,"areaGradientCache",new Map),this.options={...wr,...cs(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...cs(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,i){var n;const r=this.options.entryAnimation??"grow",a=Zt(this.options.entryMs,400);if(r==="none"||a<=0)return null;const l=(n=this.stores[t])==null?void 0:n.last();return{startTime:i,fromTime:l?l.time:e}}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)}),this.options.strokeWidth===e.line.width&&this.updateOptions({strokeWidth:t.line.width})}peekEntry(t,e){var i;return(i=this.entries[t])==null?void 0:i.get(e)}resolvedPulseMs(){return Zt(this.options.pulseMs,600)}get hasPulse(){return this.options.pulse&&this.resolvedPulseMs()>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();if(n&&n.time>=t)return!0}return!1}render(t){this.advanceLiveTracking(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e,i,n){const r=this.stores[t],a=r.last();if(!a)return null;const l=e.timeToBitmapX(a.time),h=i.valueToBitmapY(this.effectiveValue(t,a.time,a.value)),d=this.options.entryAnimation??"grow";if(!this.peekEntry(t,a.time)||d!=="grow")return{x:l,y:h};const c=this.entranceProgress(t,a.time,n);if(c>=1)return{x:l,y:h};const u=r.getAll();if(u.length<2)return{x:l,y:h};const f=u[u.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=e.timeToBitmapX(f.time),p=i.valueToBitmapY(f.value);return{x:mt(m,l,c),y:mt(p,h,c)}}renderOff(t){var e;const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,l=n.getRange(),{verticalPixelRatio:h}=i,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=performance.now(),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){if(!this.stores[m].isVisible())continue;let p=this.stores[m].getVisibleData(l.from,l.to);const g=i.mediaSize.width;if(p.length>g*2&&(p=os(p,Math.round(g*1.5))),p.length<2)continue;const M=this.options.colors[m%this.options.colors.length],v=p[p.length-1],w=this.peekEntry(m,v.time),y=this.entranceProgress(m,v.time,u),S=w&&f==="fade"&&y<1,x=this.trailingEndpoint(m,n,r,u)??{x:n.timeToBitmapX(v.time),y:r.valueToBitmapY(this.effectiveValue(m,v.time,v.value))},P=x.x,b=x.y;S&&(a.save(),a.globalAlpha=y);const R=p.length-1,L=[];let T=null;for(let W=0;W<R;W++){const V=p[W].value;if(!Number.isFinite(V)){T=null;continue}T||(T=[],L.push(T)),T.push({x:n.timeToBitmapX(p[W].time),y:r.valueToBitmapY(V)})}const F=(e=p[R])==null?void 0:e.value;if(Number.isFinite(P)&&Number.isFinite(b)&&Number.isFinite(F)&&(T?T.push({x:P,y:b}):L.push([{x:P,y:b}])),d&&L.some(W=>W.length>=2)){a.beginPath();for(const W of L)if(!(W.length<2)){a.moveTo(W[0].x,W[0].y);for(let V=1;V<W.length;V++)a.lineTo(W[V].x,W[V].y)}a.strokeStyle=M,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}if(d){const W=Math.max(1,c/2);let V=!1;for(const D of L)D.length===1&&(V||(a.beginPath(),V=!0),a.moveTo(D[0].x+W,D[0].y),a.arc(D[0].x,D[0].y,W,0,Math.PI*2));V&&(a.fillStyle=M,a.fill())}if(this.options.area.visible){const W=i.bitmapSize.height,V=String(m),D=this.areaGradientCache.get(V);let j;D&&D.bottomY===W&&D.color===M?j=D.gradient:(j=a.createLinearGradient(0,0,0,W),j.addColorStop(0,ye(M,.12)),j.addColorStop(1,ye(M,.01)),this.areaGradientCache.set(V,{gradient:j,bottomY:W,color:M})),a.fillStyle=j;for(const H of L)if(!(H.length<2)){a.beginPath(),a.moveTo(H[0].x,H[0].y);for(let X=1;X<H.length;X++)a.lineTo(H[X].x,H[X].y);a.lineTo(H[H.length-1].x,W),a.lineTo(H[0].x,W),a.closePath(),a.fill()}}S&&a.restore()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,l=n.getRange(),{verticalPixelRatio:h}=i,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=i.mediaSize.width,f=this.stores.map(b=>{let R=b.getVisibleData(l.from,l.to);return R.length>u*2&&(R=os(R,Math.round(u*1.5))),R}),m=new Set;for(const b of f)for(const R of b)m.add(R.time);const p=Array.from(m).sort((b,R)=>b-R);if(p.length<2)return;const g=f.map((b,R)=>{const L=new Map;for(const T of b)L.set(T.time,this.effectiveValue(R,T.time,T.value));return L}),M=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let b=0;b<p.length;b++){const R=p[b];let L=0;if(e)for(let F=0;F<this.stores.length;F++){if(!this.stores[F].isVisible())continue;const W=g[F].get(R);Number.isFinite(W)&&(L+=W)}let T=0;for(let F=0;F<this.stores.length;F++){const W=this.stores[F].isVisible()?g[F].get(R):0,V=Number.isFinite(W)?W:0;T+=e&&L>0?V/L*100:V,M[F][b]=T}}const v=performance.now(),w=this.options.entryAnimation??"grow",y=new Map;for(let b=0;b<p.length;b++)y.set(p[b],b);const S=p.length-1,x=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const R=this.stores[b].last();if(!R)continue;const L=this.peekEntry(b,R.time);if(!L)continue;const T=y.get(R.time);T!==S||y.get(L.fromTime)!==T-1||(x[b]=this.entranceProgress(b,R.time,v))}const P=(b,R)=>{if(R>=1||b.length<2)return;const L=b.length-1,T=b[L-1],F=b[L];b[L]=[mt(T[0],F[0],R),mt(T[1],F[1],R)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const R=this.options.colors[b%this.options.colors.length],L=x[b],T=b>0&&this.stores[b-1].isVisible()?x[b-1]:1,F=[];for(let D=0;D<p.length;D++)F.push([n.timeToBitmapX(p[D]),r.valueToBitmapY(M[b][D])]);w==="grow"&&P(F,L);const W=[];for(let D=0;D<p.length;D++){const j=b>0?M[b-1][D]:0;W.push([n.timeToBitmapX(p[D]),r.valueToBitmapY(j)])}w==="grow"&&P(W,T);const V=w==="fade"&&L<1;if(V&&(a.save(),a.globalAlpha=L),this.options.area.visible){a.beginPath(),a.moveTo(F[0][0],F[0][1]);for(let D=1;D<F.length;D++)a.lineTo(F[D][0],F[D][1]);for(let D=W.length-1;D>=0;D--)a.lineTo(W[D][0],W[D][1]);a.closePath(),a.fillStyle=ye(R,.25),a.fill()}if(d){a.beginPath(),a.moveTo(F[0][0],F[0][1]);for(let D=1;D<F.length;D++)a.lineTo(F[D][0],F[D][1]);a.strokeStyle=R,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}V&&a.restore()}}drawOverlay(t){const{scope:e,timeScale:i,yScale:n,crosshair:r,dataInterval:a}=t,l=e,h=this.resolvedPulseMs();if(r){const d=this.options.colors,c=this.options.stacking,u=4*l.horizontalPixelRatio,f=[],m=[];for(let g=0;g<this.stores.length;g++){const M=this.stores[g].findNearest(r.time,a);M?(f.push(M.value),m.push(M.time)):(f.push(0),m.push(null))}const p=[];if(c==="off")for(const g of f)p.push(g);else{let g=0;if(c==="percent")for(let v=0;v<f.length;v++)this.stores[v].isVisible()&&(g+=f[v]);let M=0;for(let v=0;v<f.length;v++){const w=this.stores[v].isVisible()?f[v]:0;M+=c==="percent"&&g>0?w/g*100:w,p.push(M)}}for(let g=0;g<this.stores.length;g++){const M=m[g];if(M===null||!this.stores[g].isVisible())continue;const v=d[g%d.length],w=i.timeToBitmapX(M),y=n.valueToBitmapY(p[g]);e.context.beginPath(),e.context.arc(w,y,u+3*l.horizontalPixelRatio,0,Math.PI*2);const S=v.startsWith("#")?v+"40":/^rgb\(/i.test(v)?v.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):v.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=S,e.context.fill(),e.context.beginPath(),e.context.arc(w,y,u,0,Math.PI*2),e.context.fillStyle=v,e.context.fill()}}if(this.hasPulse&&h>0){const d=performance.now();this.advanceLiveTracking(d);const c=this.options.stacking;for(let u=0;u<this.stores.length;u++){if(!this.stores[u].isVisible())continue;const f=this.options.colors[u%this.options.colors.length];if(c==="off"){const x=this.trailingEndpoint(u,i,n,d);if(!x)continue;this.drawPulse({ctx:e.context,x:x.x,y:x.y,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h});continue}const m=this.stores[u].last();if(!m)continue;const p=m.time,g=c==="percent",M=x=>{const P=L=>{const T=L===u&&x===p?m:this.stores[L].findNearest(x,0);return!T||T.time!==x?0:this.effectiveValue(L,x,T.value)};let b=0;if(g)for(let L=0;L<this.stores.length;L++)this.stores[L].isVisible()&&(b+=P(L));let R=0;for(let L=0;L<=u;L++){if(!this.stores[L].isVisible())continue;const T=P(L);R+=g&&b>0?T/b*100:T}return R};let v=i.timeToBitmapX(p),w=n.valueToBitmapY(M(p));const y=this.options.entryAnimation??"grow",S=this.peekEntry(u,p);if(y==="grow"&&S){const x=this.entranceProgress(u,p,d);if(x<1&&S.fromTime!==p){const P=i.timeToBitmapX(S.fromTime),b=n.valueToBitmapY(M(S.fromTime));v=mt(P,v,x),w=mt(b,w,x)}}this.drawPulse({ctx:e.context,x:v,y:w,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h})}}}drawPulse({ctx:t,x:e,y:i,color:n,pixelRatio:r,pulseMs:a}){const l=3*r,h=.4+.6*Math.abs(Math.sin(performance.now()/a)),d=l+4*r*h;t.beginPath(),t.arc(e,i,d,0,Math.PI*2),t.fillStyle=ye(n,h*.3),t.fill(),t.beginPath(),t.arc(e,i,l,0,Math.PI*2),t.fillStyle=n,t.fill()}}const zs={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},Mr={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...zs},animate:!1},Li=Math.PI/180;function kr(s,t){return{...s??{},...t}}function Cr(s){return{...zs,...s??{}}}function Tr(s){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return s===!0||s===!1?t:{...t,...s}}function Rr(s){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return s===!0||s===!1?t:{...t,...s}}const xe=Math.PI*2,Ds=.85;function us(s){const{bitmapWidth:t,bitmapHeight:e,padTop:i,padBottom:n}=s,r=Math.max(0,s.labelReserve??0),a=Math.min(Math.max(0,i),e),l=Math.min(Math.max(0,n),e-a),h=e-a-l,d=Math.max(0,t-2*r),c=t/2,u=a+h/2,f=Math.max(0,Math.min(d,h)/2*Ds);return{cx:c,cy:u,maxR:f}}function Lr(s){if(!s.startsWith("#"))return!1;const t=parseInt(s.slice(1,3),16),e=parseInt(s.slice(3,5),16),i=parseInt(s.slice(5,7),16);return t*.299+e*.587+i*.114>150}function Ir(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,parseInt(s.slice(1,3),16)+Math.round(255*t)),i=Math.min(255,parseInt(s.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(s.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function ds(s){if(s.startsWith("#"))return{r:parseInt(s.slice(1,3),16)||0,g:parseInt(s.slice(3,5),16)||0,b:parseInt(s.slice(5,7),16)||0,a:1};const t=s.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(i=>i.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function Br(s,t){const e=ds(s),i=ds(t),n=i.a,r=Math.round(i.r*n+e.r*(1-n)),a=Math.round(i.g*n+e.g*(1-n)),l=Math.round(i.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var _,G,Mt,at,fe,Xt,yt,ie,Tt,Ii,ii,Es,Vs,Ys;class si{constructor(t){A(this,Tt),A(this,_,[]),A(this,G),A(this,Mt,-1),A(this,at,[]),A(this,fe,0),A(this,Xt,1),A(this,yt,null),A(this,ie,[]),I(this,G,z(this,Tt,Ii).call(this,Mr,t??{}))}getData(){return o(this,_)}setData(t){const e=t??[];I(this,_,e),I(this,at,new Array(e.length).fill(0)),I(this,Xt,o(this,G).animate?0:1),I(this,yt,null);for(const i of o(this,ie))i()}onDataChanged(t){return o(this,ie).push(t),()=>{const e=o(this,ie).indexOf(t);e>=0&&o(this,ie).splice(e,1)}}updateOptions(t){var e,i;const n=(e=o(this,G).sliceLabels)==null?void 0:e.mode;I(this,G,z(this,Tt,Ii).call(this,o(this,G),t??{})),((i=o(this,G).sliceLabels)==null?void 0:i.mode)==="outside"&&n!=="outside"&&I(this,Xt,o(this,G).animate?0:1),I(this,yt,null)}getColor(){var t,e;return((t=o(this,_)[0])==null?void 0:t.color)??((e=o(this,G).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&I(this,yt,null)}hitTest(t,e,i,n,r){var a;if(o(this,_).length===0)return-1;const l=o(this,_).reduce((y,S)=>y+S.value,0);if(l<=0)return-1;const h=((a=o(this,yt))==null?void 0:a.reserve)??0,{cx:d,cy:c,maxR:u}=us({bitmapWidth:i,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:h}),f=u,m=f*o(this,G).innerRadiusRatio,p=t-d,g=e-c,M=Math.sqrt(p*p+g*g);if(M>f||M<m)return-1;let v=Math.atan2(g,p)+Math.PI/2;v<0&&(v+=xe);let w=0;for(let y=0;y<o(this,_).length;y++){const S=o(this,_)[y].value/l*xe;if(v>=w&&v<w+S)return y;w+=S}return-1}setHoverIndex(t){return o(this,Mt)===t?!1:(I(this,Mt,t),!0)}getHoverIndex(){return o(this,Mt)}getHoverInfo(t){if(o(this,Mt)<0)return null;const e=o(this,_)[o(this,Mt)];if(!e)return null;const i=o(this,_).reduce((r,a)=>r+a.value,0),n=o(this,G).colors??t.seriesColors;return{label:e.label,value:e.value,percent:i>0?e.value/i*100:0,color:e.color??n[o(this,Mt)%n.length]}}getSliceInfo(t){if(o(this,_).length===0)return null;const e=o(this,_).reduce((n,r)=>n+r.value,0),i=o(this,G).colors??t.seriesColors;return o(this,_).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??i[r%i.length]}))}get needsAnimation(){var t;if(!o(this,G).animate)return!1;for(let e=0;e<o(this,at).length;e++){const i=e===o(this,Mt)?1:0;if(Math.abs(o(this,at)[e]-i)>.01)return!0}return((t=o(this,G).sliceLabels)==null?void 0:t.mode)==="outside"&&o(this,Xt)<.99}dispose(){I(this,ie,[]),I(this,_,[]),I(this,at,[]),I(this,fe,0)}_inspectSliceOffsets(){return o(this,at)}render(t){if(o(this,_).length===0)return;const{scope:e,theme:i,padding:n}=t,{context:r,bitmapSize:a,horizontalPixelRatio:l,verticalPixelRatio:h}=e,d=performance.now(),c=o(this,fe)?Math.min(.05,(d-o(this,fe))/1e3):0;I(this,fe,d);const u=o(this,_).reduce((j,H)=>j+H.value,0);if(u<=0)return;const f=12;for(;o(this,at).length<o(this,_).length;)o(this,at).push(0);if(o(this,G).animate)for(let j=0;j<o(this,_).length;j++){const H=j===o(this,Mt)?1:0;o(this,at)[j]=Jt(o(this,at)[j],H,f,c)}const m=Cr(o(this,G).sliceLabels);r.font=`${m.fontSize*l}px ${i.typography.fontFamily}`,m.mode==="outside"&&o(this,G).animate&&I(this,Xt,Jt(o(this,Xt),1,6,c));const p=o(this,G).colors??i.seriesColors,g=m.mode==="outside"?z(this,Tt,Es).call(this,r,m,u,l):0,{cx:M,cy:v,maxR:w}=us({bitmapWidth:a.width,bitmapHeight:a.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:g}),y=w,S=y*o(this,G).innerRadiusRatio,x=o(this,G).padAngle*Li,P=8*l,b=o(this,G).shadow??!1,R=Tr(b),L=o(this,G).innerShadow??!1,T=Rr(L);let F=-Math.PI/2;for(let j=0;j<o(this,_).length;j++){const H=o(this,_)[j],X=H.value/u*xe,it=F+x/2,U=F+X-x/2,xt=F+X/2,lt=H.color??p[j%p.length];if(U<=it){F+=X;continue}const It=o(this,at)[j]*P,Q=Math.cos(xt)*It,Ot=Math.sin(xt)*It,pt=M+Q,dt=v+Ot;r.beginPath(),r.arc(pt,dt,y,it,U),S>0?r.arc(pt,dt,S,U,it,!0):r.lineTo(pt,dt),r.closePath();const ht=r.createRadialGradient(pt,dt,S||0,pt,dt,y);if(ht.addColorStop(0,Ir(lt,.15)),L){const wt=Math.max(0,Math.min(.999,1-T.depth));ht.addColorStop(wt,lt),ht.addColorStop(1,Br(lt,T.color))}else ht.addColorStop(1,lt);r.fillStyle=ht;const Bt=o(this,at)[j];if(b||Bt>.01){const wt=b?1:0,Ht=Bt;r.shadowColor=b?R.color:"rgba(0,0,0,0.25)",r.shadowBlur=(R.blur*wt+12*Ht)*l,r.shadowOffsetX=R.offsetX*wt*l+Q*.3*Ht,r.shadowOffsetY=R.offsetY*wt*h+Ot*.3*Ht}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,F+=X}if(m.mode==="none")return;F=-Math.PI/2;const W=i.tooltip.textColor;if(m.mode==="outside"){const j=z(this,Tt,Ys).call(this,{cx:M,cy:v,outerR:y,total:u,palette:p,labels:m,hpr:l,bitmapHeight:a.height}),H=j.length>1?Math.min(.06,.9/(j.length-1)):0;for(let X=0;X<j.length;X++){const it=j[X];if(it===null)continue;const U=X*H,xt=Se((o(this,Xt)-U)/(1-U),0,1);z(this,Tt,Vs).call(this,{context:r,entry:it,textColor:W,labels:m,hpr:l,progress:xt})}return}const V=S>0?(y+S)/2:y*.65;r.textAlign="center",r.textBaseline="middle";const D=m.minSliceAngle*Li;for(let j=0;j<o(this,_).length;j++){const H=o(this,_)[j],X=H.value/u*xe;if(X>=D){const it=F+X/2,U=o(this,at)[j]*P,xt=H.color??p[j%p.length],lt=z(this,Tt,ii).call(this,H,u,m.content),It=r.measureText(lt).width,Q=m.fontSize*1.2*l,Ot=X<Math.PI?2*V*Math.sin(X/2):2*V,pt=It>Ot-4*l,dt=S>0&&V-S<Q;if(!pt&&!dt){const ht=M+Math.cos(it)*(V+U),Bt=v+Math.sin(it)*(V+U);r.fillStyle=Lr(xt)?"#000000":"#ffffff",r.fillText(lt,ht,Bt)}}F+=X}}}_=new WeakMap,G=new WeakMap,Mt=new WeakMap,at=new WeakMap,fe=new WeakMap,Xt=new WeakMap,yt=new WeakMap,ie=new WeakMap,Tt=new WeakSet,Ii=function(s,t){const e={...s,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=kr(s.sliceLabels,t.sliceLabels)),e},ii=function(s,t,e){const i=t>0?s.value/t*100:0,n=`${i.toFixed(i>=10?0:1)}%`;return e==="percent"?n:e==="label"?s.label:`${s.label} ${n}`},Es=function(s,t,e,i){const n=s.font;if(o(this,yt)&&o(this,yt).fontScale===i&&o(this,yt).font===n)return o(this,yt).reserve;let r=0;for(const h of o(this,_)){const d=z(this,Tt,ii).call(this,h,e,t.content),c=s.measureText(d).width;c>r&&(r=c)}const a=Math.max(t.distance,t.elbowLen),l=(r+(a+Math.max(0,t.railWidth)+t.legPad+4)*i)/Ds;return I(this,yt,{fontScale:i,font:n,reserve:l}),l},Vs=function(s){const{context:t,entry:e,textColor:i,labels:n,hpr:r,progress:a}=s;if(a<=0)return;const{anchorX:l,anchorY:h,elbowX:d,elbowY:c,side:u,text:f,color:m,labelX:p,labelY:g}=e,M=p+u*n.legPad*r,v=Se(a/.15,0,1),w=Se((a-.15)/.45,0,1),y=Se((a-.6)/.4,0,1);if(t.save(),t.globalAlpha=v,t.fillStyle=m,t.beginPath(),t.arc(l,h,2.5*r,0,xe),t.fill(),t.restore(),w>0){t.save(),t.globalAlpha=w,t.strokeStyle=m,t.lineWidth=1*r,t.lineCap="round",t.beginPath(),t.moveTo(l,h);const S=l+(d-l)*w,x=h+(c-h)*w;if(t.lineTo(S,x),y>0){const P=d+(p-d)*y,b=c+(g-c)*y;t.lineTo(P,b)}t.stroke(),t.restore()}y>0&&(t.save(),t.globalAlpha=y,t.fillStyle=i,t.textAlign=u>=0?"left":"right",t.textBaseline="middle",t.fillText(f,M,g),t.restore())},Ys=function(s){const{cx:t,cy:e,outerR:i,total:n,palette:r,labels:a,hpr:l,bitmapHeight:h}=s,d=new Array(o(this,_).length).fill(null),c=a.elbowLen*l,u=Math.max(a.distance,a.elbowLen)*l,f=Math.max(0,a.railWidth)*l,m=[];let p=-Math.PI/2;const g=a.minSliceAngle*Li;for(let y=0;y<o(this,_).length;y++){const S=o(this,_)[y],x=S.value/n*xe;if(x>=g){const P=p+x/2,b=o(this,at)[y]*(8*l),R=Math.cos(P),L=Math.sin(P),T=R>=0?1:-1,F=t+R*(i+b),W=e+L*(i+b),V=t+R*(i+b+c),D=e+L*(i+b+c),j=t+R*(i+b+u)+T*f,H=e+L*(i+b+u),X={anchorX:F,anchorY:W,elbowX:V,elbowY:D,side:T,labelX:j,labelY:H,text:z(this,Tt,ii).call(this,S,n,a.content),color:S.color??r[y%r.length]};d[y]=X,m.push({entry:X})}p+=x}const M=Math.max(1,a.fontSize*a.labelGap)*l,v=a.fontSize*l,w=h-a.fontSize*l;for(const y of[1,-1]){const S=[];for(const b of m)b.entry.side===y&&S.push(b.entry);if(S.length===0)continue;S.sort((b,R)=>b.labelY-R.labelY);const x=[];for(let b=0;b<S.length;b++)for(x.push({count:1,sumIdeal:S[b].labelY,startIdx:b});x.length>=2;){const R=x[x.length-2],L=x[x.length-1],T=R.sumIdeal/R.count,F=L.sumIdeal/L.count,W=T+(R.count-1)*M/2;if(F-(L.count-1)*M/2>=W+M)break;R.count+=L.count,R.sumIdeal+=L.sumIdeal,x.pop()}if(x.length>0){const b=x[0],R=b.sumIdeal/b.count-(b.count-1)*M/2;if(R<v)for(b.sumIdeal+=(v-R)*b.count;x.length>=2;){const L=x[0],T=x[1],F=L.sumIdeal/L.count,W=T.sumIdeal/T.count,V=F+(L.count-1)*M/2;if(W-(T.count-1)*M/2>=V+M)break;L.count+=T.count,L.sumIdeal+=T.sumIdeal,x.splice(1,1)}}if(x.length>0){const b=x[x.length-1],R=b.sumIdeal/b.count+(b.count-1)*M/2;if(R>w)for(b.sumIdeal-=(R-w)*b.count;x.length>=2;){const L=x[x.length-2],T=x[x.length-1],F=L.sumIdeal/L.count,W=T.sumIdeal/T.count,V=F+(L.count-1)*M/2;if(W-(T.count-1)*M/2>=V+M)break;L.count+=T.count,L.sumIdeal+=T.sumIdeal,x.pop()}}const P=(v+w)/2;for(const b of x){const R=(b.count-1)*M,L=b.sumIdeal/b.count;R>w-v&&L-R/2<v&&(b.sumIdeal=P*b.count)}for(const b of x){const R=b.sumIdeal/b.count;for(let L=0;L<b.count;L++)S[b.startIdx+L].labelY=R+(L-(b.count-1)/2)*M}}for(const y of m){const S=y.entry,x=S.labelY-S.anchorY;let P;if(Math.abs(x)<=c){const L=S.side*Math.sqrt(Math.max(0,c*c-x*x));P=S.anchorX+L}else P=(S.anchorX+S.labelX)/2;const b=Math.min(S.anchorX,S.labelX),R=Math.max(S.anchorX,S.labelX);S.elbowX=Math.max(b,Math.min(R,P)),S.elbowY=S.labelY}return d};function Pr(s){return parseInt(s.slice(1,3),16)*.299+parseInt(s.slice(3,5),16)*.587+parseInt(s.slice(5,7),16)*.114<128}function J(s){var t,e,i,n,r,a,l,h,d,c,u,f,m,p,g,M,v,w,y,S,x,P,b,R,L,T,F,W,V,D,j,H,X,it;const{background:U,name:xt="Custom",description:lt,fontUrl:It=null}=s,Q=Pr(U),Ot=Q?"#d1d4dc":"#24292f",pt=Q?"#787b86":"#8b949e",dt=Q?"#26a69a":"#2da44e",ht=Q?"#ef5350":"#cf222e",Bt=Q?"#2962ff":"#0969da",wt=Q?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",Ht=Q?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Me=Q?Be(U,.1):Bi(U,.05),Qe=Q?me(U,.92):me(U,.95),nt=Q?me(Be(U,.15),.6):"rgba(200,200,200,0.5)",St=gi,$t=((e=(t=s.candlestick)==null?void 0:t.up)==null?void 0:e.body)??dt,bi=((n=(i=s.candlestick)==null?void 0:i.down)==null?void 0:n.body)??ht,vi=gt($t),Ze=gt(bi),ke=((r=s.line)==null?void 0:r.color)??Bt,Gi=((a=s.tooltip)==null?void 0:a.textColor)??Ot,Ki=((l=s.axis)==null?void 0:l.textColor)??pt,vn=((h=s.typography)==null?void 0:h.fontFamily)??St,qi=((d=s.typography)==null?void 0:d.fontSize)??12,yn=s.chartGradient??(Q?[Be(U,.04),Bi(U,.06)]:[Be(U,.06),U]),xn={background:U,chartGradient:yn,typography:{fontFamily:vn,fontSize:qi},grid:{color:((c=s.grid)==null?void 0:c.color)??wt,style:((u=s.grid)==null?void 0:u.style)??"dashed"},candlestick:{up:{body:$t,wick:((m=(f=s.candlestick)==null?void 0:f.up)==null?void 0:m.wick)??vi},down:{body:bi,wick:((g=(p=s.candlestick)==null?void 0:p.down)==null?void 0:g.wick)??Ze}},line:{color:ke,width:((M=s.line)==null?void 0:M.width)??1,areaTopColor:((v=s.line)==null?void 0:v.areaTopColor)??me(ke,.08),areaBottomColor:((w=s.line)==null?void 0:w.areaBottomColor)??me(ke,.01)},seriesColors:s.seriesColors??[ke,dt,ht],bands:{upper:((y=s.bands)==null?void 0:y.upper)??ke,lower:((S=s.bands)==null?void 0:S.lower)??Ze},crosshair:{color:((x=s.crosshair)==null?void 0:x.color)??Ht,labelBackground:((P=s.crosshair)==null?void 0:P.labelBackground)??Me,labelTextColor:((b=s.crosshair)==null?void 0:b.labelTextColor)??Gi},axis:{fontSize:((R=s.axis)==null?void 0:R.fontSize)??10,textColor:Ki,...(L=s.axis)!=null&&L.x?{x:{...s.axis.x}}:{},...(T=s.axis)!=null&&T.y?{y:{...s.axis.y}}:{}},yLabel:{fontSize:((F=s.yLabel)==null?void 0:F.fontSize)??11,upBackground:((W=s.yLabel)==null?void 0:W.upBackground)??vi,downBackground:((V=s.yLabel)==null?void 0:V.downBackground)??Ze,neutralBackground:((D=s.yLabel)==null?void 0:D.neutralBackground)??Me,textColor:((j=s.yLabel)==null?void 0:j.textColor)??"#ffffff"},tooltip:{fontSize:((H=s.tooltip)==null?void 0:H.fontSize)??qi,background:((X=s.tooltip)==null?void 0:X.background)??Qe,textColor:Gi,borderColor:((it=s.tooltip)==null?void 0:it.borderColor)??nt},navigator:Fr({dark:Q,bg:U,neutralFg:Ki,upBody:$t,downBody:bi,upBase:vi,downBase:Ze,config:s.navigator})};return{name:xt,description:lt,fontUrl:It,dark:Q,theme:xn}}function Fr(s){var t,e,i,n,r,a,l,h,d,c,u,f,m,p,g,M,v,w;const{dark:y,bg:S,neutralFg:x,upBody:P,downBody:b,upBase:R,downBase:L,config:T}=s,F=(T==null?void 0:T.background)??"transparent",W=y?"rgba(255,255,255,1)":"rgba(0,0,0,1)",V=((t=T==null?void 0:T.handle)==null?void 0:t.color)??Ce(W,.3),D=((e=T==null?void 0:T.mask)==null?void 0:e.fill)??Ce(S,y?.78:.82);return{height:(T==null?void 0:T.height)??48,background:F,borderColor:(T==null?void 0:T.borderColor)??Ce(x,y?.18:.22),line:{color:((i=T==null?void 0:T.line)==null?void 0:i.color)??x,width:((n=T==null?void 0:T.line)==null?void 0:n.width)??1,areaTopColor:((r=T==null?void 0:T.line)==null?void 0:r.areaTopColor)??Ce(x,y?.22:.18),areaBottomColor:((a=T==null?void 0:T.line)==null?void 0:a.areaBottomColor)??Ce(x,0)},candlestick:{up:{body:((h=(l=T==null?void 0:T.candlestick)==null?void 0:l.up)==null?void 0:h.body)??P,wick:((c=(d=T==null?void 0:T.candlestick)==null?void 0:d.up)==null?void 0:c.wick)??R},down:{body:((f=(u=T==null?void 0:T.candlestick)==null?void 0:u.down)==null?void 0:f.body)??b,wick:((p=(m=T==null?void 0:T.candlestick)==null?void 0:m.down)==null?void 0:p.wick)??L}},window:{fill:((g=T==null?void 0:T.window)==null?void 0:g.fill)??"transparent",border:((M=T==null?void 0:T.window)==null?void 0:M.border)??"transparent",borderWidth:((v=T==null?void 0:T.window)==null?void 0:v.borderWidth)??0},handle:{color:V,width:((w=T==null?void 0:T.handle)==null?void 0:w.width)??6},mask:{fill:D}}}function Ce(s,t){if(s.startsWith("#")&&s.length===7)return me(s,t);const e=s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:s}function me(s,t){const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function Be(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,Math.round(parseInt(s.slice(1,3),16)+255*t)),i=Math.min(255,Math.round(parseInt(s.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(s.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Bi(s,t){if(!s.startsWith("#"))return s;const e=Math.max(0,Math.round(parseInt(s.slice(1,3),16)*(1-t))),i=Math.max(0,Math.round(parseInt(s.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(s.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function E(s){const t=s.startsWith("#")&&s.length===7?[Be(s,.2),Bi(s,.15)]:[s,s];return Object.defineProperty(t,"source",{value:s,enumerable:!1}),t}const fi="'JetBrains Mono', 'Fira Code', monospace",mi="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",gi="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Oi="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",js="'Roboto Mono', monospace",Os="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Wr="'IBM Plex Mono', monospace",Ar="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Hi="'Fira Code', monospace",$i="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",Hs="'Source Code Pro', monospace",$s="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",zr="'Space Mono', monospace",Dr="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",Ni="'Plus Jakarta Sans', sans-serif",Xi="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",Er="'Caveat', 'Comic Sans MS', cursive",Vr="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Ns={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"},navigator:{height:48,background:"transparent",borderColor:"rgba(120, 123, 134, 0.18)",line:{color:"#787b86",width:1,areaTopColor:"rgba(120, 123, 134, 0.22)",areaBottomColor:"rgba(120, 123, 134, 0)"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(255, 255, 255, 0.30)",width:6},mask:{fill:"rgba(19, 23, 34, 0.78)"}}},Nt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},Yr=.1,jr=.3,Or=.4,Hr=.5,$r=4;var _t,st;class Nr extends Ue{constructor({padding:t,reboundMs:e}={}){super(),C(this,"_visibleRange",{from:0,to:0}),C(this,"_yRange",{min:0,max:0}),C(this,"_autoScroll",!0),C(this,"padding"),C(this,"reboundMs"),C(this,"dataInterval",6e4),A(this,_t,null),A(this,st,null),C(this,"_prevDataEnd",null),C(this,"_animating",!1),C(this,"animStartTime",0),C(this,"animDuration",0),C(this,"animFrom",{from:0,to:0}),C(this,"animTo",{from:0,to:0}),C(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??Nt.top,bottom:(t==null?void 0:t.bottom)??Nt.bottom,right:(t==null?void 0:t.right)??Nt.right,left:(t==null?void 0:t.left)??Nt.left},this.reboundMs=e??350}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,i){return typeof t=="object"?t.intervals*this.dataInterval:i<=0?0:t/i*e}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}get dataStart(){return o(this,_t)}get dataEnd(){return o(this,st)}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??Nt.top,bottom:(t==null?void 0:t.bottom)??Nt.bottom,right:(t==null?void 0:t.right)??Nt.right,left:(t==null?void 0:t.left)??Nt.left}}getPadding(){return this.padding}setDataStart(t){I(this,_t,t)}setDataEnd(t){this._prevDataEnd=o(this,st),I(this,st,t)}cancelAnimation(){this._animating=!1}getSoftBounds(t,e){const i=a=>typeof a=="object"||a===0||e>0,n=o(this,_t)!==null&&i(this.padding.left)?o(this,_t)-this.resolveHPad(this.padding.left,t,e):null,r=o(this,st)!==null&&i(this.padding.right)?o(this,st)+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}softMaxRange(){if(o(this,_t)===null||o(this,st)===null)return null;const t=o(this,st)-o(this,_t);if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,i=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||i!==null?t+(e??0)+(i??0):t+this.dataInterval*5}setRange(t){const{from:e,to:i}=t;if(!Number.isFinite(e)||!Number.isFinite(i)||i<=e||(i-e)/this.dataInterval<2)return;this.cancelAnimation();const n=o(this,st)!==null&&o(this,st)>=e&&o(this,st)<=i;this._autoScroll=n,this.applyRange(e,i)}applyRange(t,e){e<=t||(e-t)/this.dataInterval<2||(this._visibleRange={from:t,to:e},this.emit("change"))}animateTo(t,e,i=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:e},this.animDuration=i,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this.animStartTime,i=Math.min(1,e/this.animDuration),n=1-(1-i)**3,r=mt(this.animFrom.from,this.animTo.from,n),a=mt(this.animFrom.to,this.animTo.to,n);return a>r&&this.applyRange(r,a),i>=1&&(this._animating=!1),this._animating}setYRange(t,e,i,n=!1,r=!1){const a=e-t,l=i>0?this.padding.top/i*a:0,h=i>0?this.padding.bottom/i*a:0;this._yRange={min:n?t:t-h,max:r?e:e+l}}zoomAt(t,e,i=this._lastChartWidth){this.cancelAnimation(),i>0&&(this._lastChartWidth=i);const{from:n,to:r}=this._visibleRange,a=r-n;if(a<=0)return;const l=this.softMinRange,{left:h,right:d}=this.getSoftBounds(a,i),c=h!==null&&d!==null?d-h:this.softMaxRange();let u=e;const f=l*Or;if(e<1&&a<l){const v=l-a,w=(1-Math.min(1,v/f))**2;u=1-(1-e)*w}let m=a*u;m<l-f&&(m=l-f),e>1&&c!==null&&m>c&&(m=c);const p=(t-n)/a;let g=t-p*m,M=g+m;if(e<1&&M<r){const v=r-M;g+=v,M+=v}if(e>1){if(d!==null&&M>d){const v=M-d;g-=v,M-=v}if(h!==null&&g<h){const v=h-g;g+=v,M+=v}}this.applyRange(g,M),this.emit("interact")}pan(t,e=0){this.cancelAnimation(),e>0&&(this._lastChartWidth=e);const{from:i,to:n}=this._visibleRange,r=n-i;if(r<=0)return;const{left:a,right:l}=this.getSoftBounds(r,e),h=r*jr;let d=t;if(t>0&&l!==null){const m=Math.max(0,n-l);m>0&&(d*=1/(m/h+1))}else if(t<0&&a!==null){const m=Math.max(0,a-i);m>0&&(d*=1/(m/h+1))}let c=i+d,u=n+d;if(l!==null&&u>l+h){const m=u-(l+h);c-=m,u-=m}if(a!==null&&c<a-h){const m=a-h-c;c+=m,u+=m}const f=o(this,st)!==null&&o(this,st)>=c&&o(this,st)<=u;this._autoScroll=f,this.applyRange(c,u),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:i}=this._visibleRange,n=i-e;if(n<=0)return;const r=this.softMinRange,a=this.softMaxRange();let l=n;l<r&&(l=r),a!==null&&l>a&&(l=a);let h=e,d=i;if(l!==n){const w=(e+i)/2;h=w-l/2,d=w+l/2}const{left:c,right:u}=this.getSoftBounds(l,t);if(u!==null&&d>u){const w=d-u;h-=w,d-=w}if(c!==null&&h<c){const w=c-h;h+=w,d+=w}const f=Math.abs(h-e),m=Math.abs(d-i);if(f<1&&m<1)return;const p=n*Yr;let g=null,M=0,v=0;u!==null&&i-u>p?(g="right",M=i-u,v=u):c!==null&&c-e>p&&(g="left",M=c-e,v=c),this.reboundMs<=0?this.applyRange(h,d):this.animateTo(h,d,this.reboundMs),g!==null&&this.emit("edgeReached",{side:g,overshoot:M,boundaryTime:v})}fitToData(t,e,i=0,n=!1){this._autoScroll=!0,i>0&&(this._lastChartWidth=i);const r=400*this.dataInterval,a=e-t,l=a>0?a:this.dataInterval*10,h=this.resolveHPad(this.padding.right,l,i),d=this.resolveHPad(this.padding.left,l,i);let c=e+h,u=t-d;c-u>r&&(c=e+h,u=c-r),n&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(u,c,450):this.applyRange(u,c)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const i=this._visibleRange.to-this._visibleRange.from;if(i<=0)return;const n=this.resolveHPad(this.padding.right,i,e),r=this._animating?this.animTo.to:this._visibleRange.to,a=this._prevDataEnd!==null?r-this._prevDataEnd:n,l=Math.max(0,Math.min(n,a)),h=t+l,d=h-i;this._autoScroll=!0;const c=Hr*this.dataInterval,u=e>0?$r/e*i:c,f=Math.min(c,u);if(this._animating){if(Math.abs(h-this.animTo.to)<f)return;this.animFrom={...this._visibleRange},this.animTo={from:d,to:h},this._prevDataEnd=o(this,st)}else{if(Math.abs(h-this._visibleRange.to)<f)return;this.animateTo(d,h,150),this._prevDataEnd=o(this,st)}}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}_t=new WeakMap,st=new WeakMap;function Te(s,t){return s===!1||s===0?0:s===void 0?t:s}function Xr(s){if(s===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0}};const t=s===!0||s===void 0?void 0:s,e=t==null?void 0:t.points,i=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:Te(e==null?void 0:e.enterMs,400),smoothMs:Te(e==null?void 0:e.smoothMs,70),pulseMs:Te(e==null?void 0:e.pulseMs,600)},r=i===!1?{reboundMs:0,yAxisMs:0}:{reboundMs:Te(i==null?void 0:i.reboundMs,350),yAxisMs:Te(i==null?void 0:i.yAxisMs,80)};return{points:n,viewport:r}}function _r(s){if(!s)return{monitor:null,ownsMonitor:!1,showHud:!1};if(s===!0)return{monitor:new Mi,ownsMonitor:!0,showHud:!0};if(s instanceof Mi)return{monitor:s,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...i}=s,n=e!==void 0;return{monitor:e??new Mi(i),ownsMonitor:!n,showHud:t??!n}}let Ur=0;var tt,$,q,Pt,Pe,Y,Z,Fe,ct,Ft,rt,Kt,Pi,ge,kt,ni,ri,zt,We,se,Xe,ci,le,Wt,Ae,ze,K,qt,fs,ai,De,Ee,Xs,_s,oi,bt,vt,pe;class Us extends Ue{constructor(t,e){var i,n,r,a;super(),A(this,K),A(this,tt),A(this,$),A(this,q),A(this,Pt),C(this,"timeScale"),C(this,"yScale"),A(this,Pe),A(this,Y,[]),A(this,Z),A(this,Fe),A(this,ct,6e4),A(this,Ft,null),A(this,rt,{}),A(this,Kt,null),A(this,Pi,!1),A(this,ge,{}),A(this,kt,{left:"idle",right:"idle"}),A(this,ni,{left:null,right:null}),A(this,ri),A(this,zt,0),A(this,We,!1),A(this,se,!1),A(this,Xe,!1),A(this,ci,0),A(this,le),A(this,Wt),A(this,Ae,!1),A(this,ze,null),A(this,oi,0),A(this,bt,0),A(this,vt,0),A(this,pe,!1),e!=null&&e.axis&&(I(this,ge,e.axis),I(this,rt,{min:(i=e.axis.y)==null?void 0:i.min,max:(n=e.axis.y)==null?void 0:n.max})),I(this,Z,(e==null?void 0:e.theme)??Ns),I(this,Fe,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),I(this,le,Xr(e==null?void 0:e.animations)),I(this,ri,e==null?void 0:e.onEdgeReached);const l=_r(e==null?void 0:e.perf);I(this,Wt,l.monitor),I(this,Ae,l.ownsMonitor),I(this,tt,new Mn(t,o(this,Wt)??void 0)),I(this,$,new Nr({padding:e==null?void 0:e.padding,reboundMs:o(this,le).viewport.reboundMs})),On(this,o(this,$)),this.timeScale=new Bs,this.yScale=new Ws;const h=o(this,Wt);h?(I(this,q,new ti(c=>{h.resetDrawCalls("main");const u=performance.now();this.renderMain(c),h.recordFrame("main",performance.now()-u,c)})),I(this,Pt,new ti(c=>{h.resetDrawCalls("overlay");const u=performance.now();this.renderOverlay(c),h.recordFrame("overlay",performance.now()-u,c)})),l.showHud&&I(this,ze,new Un(t,h))):(I(this,q,new ti(c=>this.renderMain(c))),I(this,Pt,new ti(c=>this.renderOverlay(c))));const d=(e==null?void 0:e.interactive)!==!1;I(this,Pe,d?new Yn(o(this,tt).canvas,o(this,$),this.timeScale,this.yScale):null),o(this,$).on("change",()=>{this.syncScales(),o(this,q).markDirty(),this.emit("viewportChange")}),o(this,$).on("edgeReached",c=>{var u;o(this,ni)[c.side]=c.boundaryTime,(u=o(this,ri))==null||u.call(this,c)}),o(this,tt).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(a=o(this,Pe))==null||a.on("crosshairMove",c=>{I(this,Ft,c),o(this,Pt).markDirty(),this.emit("crosshairMove",c),z(this,K,_s).call(this,c)})}get yAxisWidth(){const t=o(this,ge).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=o(this,ge).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return o(this,ci)}addCandlestickSeries(t){const e=new Rs,i=new xr(e,{up:{...o(this,Z).candlestick.up},down:{...o(this,Z).candlestick.down},bodyWidthRatio:.6,...z(this,K,ai).call(this,"candle"),...t,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,i,i.store,t??{})}addLineSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new Sr(n,{colors:n===1?[o(this,Z).line.color]:o(this,Z).seriesColors.slice(0,n),strokeWidth:o(this,Z).line.width,area:{visible:!0},...z(this,K,ai).call(this,"line"),...i,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,r,r.store,i)}addBarSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new gr(n,{colors:o(this,Z).seriesColors.slice(0,n),barWidthRatio:.6,...z(this,K,ai).call(this,"bar"),...i,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,r,r.store,i)}addPieSeries(t){const e=new si(t);return z(this,K,Ee).call(this,e,null,t??{})}removeSeries(t){const e=o(this,Y).findIndex(i=>i.id===t);e>=0&&(o(this,Y)[e].renderer.dispose(),o(this,Y).splice(e,1),I(this,Kt,null),this.updateViewportPadding(),o(this,q).markDirty(),this.emit("seriesChange"),z(this,K,qt).call(this))}setSeriesData(t,e,i){const n=o(this,Y).find(r=>r.id===t);n==null||n.renderer.setData(e,i)}appendData(t,e,i){var n,r;const a=o(this,Y).find(l=>l.id===t);(r=a==null?void 0:(n=a.renderer).appendPoint)==null||r.call(n,e,i)}updateData(t,e,i){var n,r;const a=o(this,Y).find(l=>l.id===t);(r=a==null?void 0:(n=a.renderer).updateLastPoint)==null||r.call(n,e,i)}updateSeriesOptions(t,e){const i=o(this,Y).find(d=>d.id===t);if(!i)return;const n=i.label,r=i.renderer.getLayerColors().slice();i.renderer.updateOptions({...e,...z(this,K,De).call(this)}),"label"in e&&typeof e.label=="string"&&(i.label=e.label),o(this,q).markDirty();const a=i.renderer.getLayerColors(),l=r.length!==a.length||r.some((d,c)=>d!==a[c]),h=n!==i.label;(l||h)&&z(this,K,qt).call(this)}batch(t){Ri(this,zt)._++;try{t()}finally{--Ri(this,zt)._<=0&&(I(this,zt,0),o(this,We)?(I(this,We,!1),I(this,se,!1),this.onDataChanged()):o(this,se)&&(I(this,se,!1),this.updateYRange(!0),o(this,q).markDirty()),o(this,Xe)&&(I(this,Xe,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const i=o(this,Y).find(n=>n.id===t);if(!(!i||i.visible===e)){if(i.visible=e,z(this,K,qt).call(this),o(this,zt)>0){I(this,se,!0);return}this.updateYRange(!0),o(this,q).markDirty()}}isSeriesVisible(t){var e;return((e=o(this,Y).find(i=>i.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,i){const n=o(this,Y).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==i){if(n.renderer.setLayerVisible(e,i),z(this,K,qt).call(this),o(this,zt)>0){I(this,se,!0);return}this.updateYRange(!0),o(this,q).markDirty()}}isLayerVisible(t,e){const i=o(this,Y).find(n=>n.id===t);return(i==null?void 0:i.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const i=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(t,e,i,!0)}getVisibleRange(){return o(this,$).visibleRange}getDataRange(){const t=o(this,$).dataStart,e=o(this,$).dataEnd;return t===null||e===null?null:{from:t,to:e}}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:i}=this.getDataBounds();if(e===void 0||i===void 0)return;const n=Math.max(e,i-(t-1)*o(this,ct)),r=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(n,i,r,!1);return}o(this,$).setRange(t)}getYRange(){return o(this,$).yRange}getCrosshairPosition(){return o(this,Ft)}getLastValue(t){const e=o(this,Y).find(h=>h.id===t);if(!(e!=null&&e.store))return null;const i=e.store.last();if(!i)return null;const n=h=>"close"in h?h.close:h.value,{from:r,to:a}=o(this,$).visibleRange;if(i.time>=r&&i.time<=a)return{value:n(i),isLive:!0};const l=e.store.getVisibleData(r,a);return l.length===0?null:{value:n(l[l.length-1]),isLive:!1}}getPreviousClose(t){const e=o(this,Y).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const i=e.store.getAll();if(i.length<2)return null;const n=i[i.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=o(this,Y).find(i=>i.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var i,n;const r=o(this,Y).find(a=>a.id===t);return r?((n=(i=r.renderer).getDataAtTime)==null?void 0:n.call(i,e,o(this,ct)))??null:null}getLayerSnapshots(t,e){var i,n;const r=o(this,Y).find(a=>a.id===t);return r!=null&&r.visible?((n=(i=r.renderer).getLayerSnapshots)==null?void 0:n.call(i,e,o(this,ct)))??null:null}getSeriesIds(){return o(this,Kt)||I(this,Kt,o(this,Y).map(t=>t.id)),o(this,Kt).slice()}getSeriesType(t){const e=o(this,Y).find(i=>i.id===t);return e?e.renderer instanceof si?"pie":"time":null}getSeriesIdsByType(t,e){const i=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const a of o(this,Y)){const l=a.renderer instanceof si;if(t==="pie"&&!l||t==="time"&&l)continue;const h=a.renderer.getLayerCount();if(!(n&&h>1)){if(i){if(!a.visible)continue;if(h>1){let d=!1;for(let c=0;c<h;c++)if(a.renderer.isLayerVisible(c)){d=!0;break}if(!d)continue}}r.push(a.id)}}return r}getStackedLastValue(t){var e,i;const n=o(this,Y).find(a=>a.id===t);return n?((i=(e=n.renderer).getStackedLastValue)==null?void 0:i.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:i.call(e))??null}listSeriesForTest(){return o(this,Y).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=o(this,Y).find(i=>i.id===t);return e?e.renderer.getLayerColors()[0]??o(this,Z).line.color:null}getSeriesLabel(t){var e;return(e=o(this,Y).find(i=>i.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=o(this,Y).find(r=>r.id===t);if(!e)return null;const i=e.renderer.getLayerCount();if(i<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:i},(r,a)=>({color:n[a%n.length]}))}getSliceInfo(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:i.call(e,o(this,Z)))??null}getHoverInfo(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:i.call(e,o(this,Z)))??null}setTheme(t){const e=o(this,Z);I(this,Z,t);for(const i of o(this,Y))i.renderer.applyTheme(t,e);o(this,q).markDirty(),z(this,K,qt).call(this)}getTheme(){return o(this,Z)}setAxis(t){var e,i;const n=this.yAxisWidth,r=this.xAxisHeight;I(this,ge,t),I(this,rt,{min:(e=t.y)==null?void 0:e.min,max:(i=t.y)==null?void 0:i.max}),I(this,pe,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),o(this,q).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),o(this,q).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),o(this,q).markDirty())}getMediaSize(){return o(this,tt).size.media}getLayout(){const t=o(this,tt).size.media,e=this.yAxisWidth,i=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-i},yAxisWidth:e,xAxisHeight:i}}getDataInterval(){return o(this,ct)}setPadding(t){const e=o(this,$).getPadding();o(this,$).setPadding(t);const i=o(this,$).getPadding(),n=!ms(e.left,i.left)||!ms(e.right,i.right),r=e.top!==i.top||e.bottom!==i.bottom;if(n){const{first:a,last:l}=this.getDataBounds();if(a!==void 0&&l!==void 0){const h=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(a,l,h,!1)}}r&&this.updateYRange(!0),this.syncScales(),o(this,q).markDirty(),r&&this.emit("viewportChange")}setGrid(t){I(this,Fe,t.visible),o(this,q).markDirty()}setEdgeState(t,e){o(this,kt)[t]!==e&&(o(this,kt)[t]=e,o(this,Pt).markDirty())}getEdgeState(t){return o(this,kt)[t]}setYLabel(t){I(this,Pi,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,i;for(const n of o(this,Y))n.renderer.dispose();I(this,Y,[]),I(this,Kt,null),o(this,$).destroy(),o(this,q).destroy(),o(this,Pt).destroy(),(t=o(this,Pe))==null||t.destroy(),o(this,tt).destroy(),(e=o(this,ze))==null||e.destroy(),I(this,ze,null),o(this,Ae)&&((i=o(this,Wt))==null||i.destroy()),I(this,Wt,null),I(this,Ae,!1),this.removeAllListeners()}getPerfMonitor(){return o(this,Wt)}getDataBounds(){let t,e;for(const i of o(this,Y)){if(!i.visible||!i.store)continue;const n=i.store.first(),r=i.store.last();n&&(t===void 0||n.time<t)&&(t=n.time),r&&(e===void 0||r.time>e)&&(e=r.time)}return{first:t,last:e}}onDataChanged(){if(o(this,zt)>0){I(this,We,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&o(this,$).setDataStart(t),e!==void 0&&o(this,$).setDataEnd(e);let i=0;for(const r of o(this,Y))r.renderer.getTotalLength?i+=r.renderer.getTotalLength():r.store&&(i+=r.store.length);const n=i-o(this,oi)>5;if(I(this,oi,i),t!==void 0&&e!==void 0){const{from:r,to:a}=o(this,$).visibleRange,l=r===0&&a===0,h=o(this,tt).size.media.width-this.yAxisWidth;l?o(this,$).fitToData(t,e,h,!1):n&&o(this,$).autoScroll?o(this,$).fitToData(t,e,h,!0):!n&&o(this,$).autoScroll&&o(this,$).scrollToEnd(e,h)}this.updateYRange(n),this.syncScales(),o(this,q).markDirty(),this.emit("dataUpdate"),z(this,K,qt).call(this)}updateDataInterval(){for(const t of o(this,Y)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const i=e.slice(0,20).map(n=>n.time);I(this,ct,Ls(i)),o(this,$).setDataInterval(o(this,ct));break}}}updateYRange(t=!1){let e=1/0,i=-1/0;const n=o(this,$).visibleRange,r=o(this,rt).min!==void 0&&o(this,rt).min!=="auto"&&typeof o(this,rt).min!="number"||o(this,rt).max!==void 0&&o(this,rt).max!=="auto"&&typeof o(this,rt).max!="number"?[]:null;for(const c of o(this,Y)){if(!c.visible)continue;if(c.renderer.getValueRange){const f=c.renderer.getValueRange(n.from,n.to);if(f){f.max>i&&(i=f.max),f.min<e&&(e=f.min),r==null||r.push(f.min,f.max);continue}}if(!c.store)continue;const u=c.store.getVisibleData(n.from,n.to);for(const f of u)if("high"in f){const m=f;Number.isFinite(m.high)&&(m.high>i&&(i=m.high),r==null||r.push(m.high)),Number.isFinite(m.low)&&(m.low<e&&(e=m.low),r==null||r.push(m.low))}else{const m=f;Number.isFinite(m.value)&&(m.value>i&&(i=m.value),m.value<e&&(e=m.value),r==null||r.push(m.value))}}if(e===1/0||i===-1/0){I(this,pe,!1);return}e=this.resolveBound(o(this,rt).min,e,i,r??[],"min"),i=this.resolveBound(o(this,rt).max,i,e,r??[],"max");const a=o(this,le).viewport.yAxisMs;if(!o(this,pe)||t||a<=0)I(this,bt,e),I(this,vt,i),I(this,pe,!0);else{const c=Math.min(1,16/a);I(this,bt,o(this,bt)+(e-o(this,bt))*c),I(this,vt,o(this,vt)+(i-o(this,vt))*c),e<o(this,bt)&&I(this,bt,e),i>o(this,vt)&&I(this,vt,i);const u=Math.max(Math.abs(o(this,vt)-o(this,bt))*1e-4,.001);(Math.abs(o(this,bt)-e)>u||Math.abs(o(this,vt)-i)>u)&&o(this,q).markDirty()}const l=o(this,rt).min!==void 0&&o(this,rt).min!=="auto",h=o(this,rt).max!==void 0&&o(this,rt).max!=="auto",d=o(this,tt).size.media.height-this.xAxisHeight;o(this,$).setYRange(o(this,bt),o(this,vt),d,l,h)}resolveBound(t,e,i,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const a=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const l=a[1]==="-"?-1:1,h=parseFloat(a[2])/100,d=Math.abs(i-e)||Math.abs(e)||1;return e+l*h*d*(r==="max"?1:-1)}return e}syncScales(){const t=o(this,tt).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,i=t.media.height-this.xAxisHeight;this.timeScale.update(o(this,$).visibleRange,e,t.horizontalPixelRatio,o(this,ct)),this.yScale.update(o(this,$).yRange,i,t.verticalPixelRatio)}updateScales(t=!1){const e=o(this,tt).size;if(e.media.width===0||e.media.height===0)return;const i=e.media.width-this.yAxisWidth,n=e.media.height-this.xAxisHeight;this.timeScale.update(o(this,$).visibleRange,i,e.horizontalPixelRatio,o(this,ct)),this.yScale.update(o(this,$).yRange,n,e.verticalPixelRatio),this.updateYRange(t),this.yScale.update(o(this,$).yRange,n,e.verticalPixelRatio)}renderMain(t){const e=o(this,tt).size;if(e.media.width===0||e.media.height===0)return;const i=typeof t=="number"?t:performance.now();o(this,$).tick(i)&&o(this,q).markDirty(),this.updateScales(),o(this,tt).useMainLayer(n=>{const{context:r,bitmapSize:a}=n,l=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,h=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,a.width,a.height),r.save(),r.beginPath(),r.rect(0,0,l,h),r.clip(),o(this,Fe)&&An(n,this.timeScale,this.yScale,o(this,Z),o(this,ct));const d=o(this,$).getPadding(),c={top:d.top,bottom:d.bottom},u=o(this,Wt);for(const f of o(this,Y)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:o(this,Z),dataInterval:o(this,ct),padding:c};if(u){const p=performance.now();f.renderer.render(m),u.recordSeries(f.id,performance.now()-p,i)}else f.renderer.render(m)}r.restore()});for(const n of o(this,Y))if(n.renderer.needsAnimation){o(this,q).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,i;const n=o(this,tt).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const h of o(this,Y))if(h.visible&&h.renderer.overlayNeedsAnimation){r=!0;break}const a=o(this,kt).left==="loading"||o(this,kt).right==="loading",l=o(this,kt).left!=="idle"||o(this,kt).right!=="idle";if(o(this,tt).useOverlayLayer(h=>{var d,c;if(!o(this,Ft)&&!r&&!l)return;const u=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,u,f),h.context.clip(),o(this,Ft)&&z(this,K,Xs).call(this)){const g=o(this,Ft).mediaX*n.horizontalPixelRatio,M=o(this,Ft).mediaY*n.verticalPixelRatio;kn(h,g,M,o(this,Z))}const m=o(this,$).getPadding(),p={top:m.top,bottom:m.bottom};for(const g of o(this,Y))g.visible&&((c=(d=g.renderer).drawOverlay)==null||c.call(d,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:o(this,Z),dataInterval:o(this,ct),padding:p,crosshair:o(this,Ft)}));l&&this.drawEdgeIndicators(h,n.media.height-this.xAxisHeight),h.context.restore()}),r){const{from:h,to:d}=this.timeScale.getRange();let c=!1;for(const u of o(this,Y))if(!(!u.visible||!u.renderer.overlayNeedsAnimation)&&(((i=(e=u.renderer).hasOverlayContentInRange)==null?void 0:i.call(e,h,d))??!0)){c=!0;break}c&&o(this,Pt).markDirty()}a&&o(this,Pt).markDirty()}drawEdgeIndicators(t,e){const i=performance.now();for(const n of["left","right"]){const r=o(this,kt)[n];if(r==="idle"||r==="has-more")continue;const a=this.resolveEdgeBoundary(n);a!==null&&Pn({scope:t,timeScale:this.timeScale,theme:o(this,Z),chartMediaHeight:e,boundaryTime:a,side:n,state:r,now:i})}}resolveEdgeBoundary(t){const e=o(this,ni)[t];if(e!==null)return e;const{first:i,last:n}=this.getDataBounds();return t==="left"?i??null:n??null}}tt=new WeakMap,$=new WeakMap,q=new WeakMap,Pt=new WeakMap,Pe=new WeakMap,Y=new WeakMap,Z=new WeakMap,Fe=new WeakMap,ct=new WeakMap,Ft=new WeakMap,rt=new WeakMap,Kt=new WeakMap,Pi=new WeakMap,ge=new WeakMap,kt=new WeakMap,ni=new WeakMap,ri=new WeakMap,zt=new WeakMap,We=new WeakMap,se=new WeakMap,Xe=new WeakMap,ci=new WeakMap,le=new WeakMap,Wt=new WeakMap,Ae=new WeakMap,ze=new WeakMap,K=new WeakSet,qt=function(){if(Ri(this,ci)._++,o(this,zt)>0){I(this,Xe,!0);return}this.emit("overlayChange")},fs=function(s){if(s&&!o(this,Y).some(e=>e.id===s))return s;let t;do t=`series_${++Ur}`;while(o(this,Y).some(e=>e.id===t));return t},ai=function(s){const{enterMs:t,smoothMs:e,pulseMs:i}=o(this,le).points;return s==="line"?{enterMs:t,smoothMs:e,pulseMs:i}:{enterMs:t,smoothMs:e}},De=function(){const{enterMs:s,smoothMs:t,pulseMs:e}=o(this,le).points,i={};return s===0&&(i.enterMs=0),t===0&&(i.smoothMs=0),e===0&&(i.pulseMs=0),i},Ee=function(s,t,e){var i;const n=z(this,K,fs).call(this,e.id);return(i=s.onDataChanged)==null||i.call(s,()=>this.onDataChanged()),o(this,Y).push({id:n,label:e.label,renderer:s,store:t,visible:!0}),I(this,Kt,null),this.updateViewportPadding(),this.emit("seriesChange"),z(this,K,qt).call(this),n},Xs=function(){for(const s of o(this,Y))if(s.visible&&!(s.renderer instanceof si))return!0;return!1},_s=function(s){const t=o(this,tt).size,e=o(this,$).getPadding(),i={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of o(this,Y)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let a=-1;if(s){const l=s.mediaX*t.horizontalPixelRatio,h=s.mediaY*t.verticalPixelRatio;a=r.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,i)}r.renderer.setHoverIndex(a)&&(n=!0)}n&&o(this,q).markDirty()},oi=new WeakMap,bt=new WeakMap,vt=new WeakMap,pe=new WeakMap;function ms(s,t){return typeof s=="number"&&typeof t=="number"?s===t:typeof s=="object"&&typeof t=="object"?s.intervals===t.intervals:!1}function Gr(s,t){if(s.length<=t||t<=0)return s;const e=s[0].time,i=s[s.length-1].time,n=i-e;if(n<=0)return s;const r=n/t,a=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?i+1:e+(h+1)*r;let c=null,u=null;for(;l<s.length&&s[l].time<d;){const f=s[l];(c===null||f.value<c.value)&&(c=f),(u===null||f.value>u.value)&&(u=f),l++}if(!(c===null||u===null)){if(c===u){a.push(c);continue}c.time<u.time?a.push(c,u):a.push(u,c)}}return a}function Kr(s,t){if(s.length<=t||t<=0)return s;const e=s[0].time,i=s[s.length-1].time,n=i-e;if(n<=0)return s;const r=n/t,a=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?i+1:e+(h+1)*r;let c=null;for(;l<s.length&&s[l].time<d;){const u=s[l];c===null?c={time:u.time,open:u.open,high:u.high,low:u.low,close:u.close}:(u.high>c.high&&(c.high=u.high),u.low<c.low&&(c.low=u.low),c.close=u.close),l++}c!==null&&a.push(c)}return a}const gs=8;function Gs(s,t){return Math.abs(s-t.left)<=gs?{gesture:"resize-left",snapToCenter:!1}:Math.abs(s-t.right)<=gs?{gesture:"resize-right",snapToCenter:!1}:s>t.left&&s<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function qr(s){const{startVisible:t,deltaPx:e,pixelsPerTime:i,dataRange:n}=s,r=t.to-t.from,a=e/i;let l=t.from+a,h=t.to+a;return l<n.from&&(l=n.from,h=l+r),h>n.to&&(h=n.to,l=h-r),l<n.from&&(l=n.from),{from:l,to:h}}function Jr(s){const{edge:t,startVisible:e,deltaPx:i,pixelsPerTime:n,dataRange:r,minSpan:a}=s,l=i/n;if(t==="left"){let c=e.from+l,u=e.to;return c<r.from&&(c=r.from),u-c<a&&(c=u-a),c<r.from&&(c=r.from,u=Math.min(r.to,c+a)),{from:c,to:u}}let h=e.from,d=e.to+l;return d>r.to&&(d=r.to),d-h<a&&(d=h+a),d>r.to&&(d=r.to,h=Math.max(r.from,d-a)),{from:h,to:d}}function Qr(s){const{time:t,startVisible:e,dataRange:i}=s,n=e.to-e.from;let r=t-n/2,a=r+n;return r<i.from&&(r=i.from,a=r+n),a>i.to&&(a=i.to,r=a-n),r<i.from&&(r=i.from),{from:r,to:a}}function Zr(s){const{ctx:t,theme:e,mediaWidth:i,mediaHeight:n}=s;t.fillStyle=e.background,t.fillRect(0,0,i,n)}function ta(s,t,e=!0){if(t.length<2)return;const{ctx:i,timeScale:n,yScale:r,mediaHeight:a,theme:l}=s;if(e){i.beginPath();for(let d=0;d<t.length;d++){const c=t[d],u=n.timeToX(c.time),f=r.valueToY(c.value);d===0?i.moveTo(u,f):i.lineTo(u,f)}i.lineTo(n.timeToX(t[t.length-1].time),a),i.lineTo(n.timeToX(t[0].time),a),i.closePath();const h=i.createLinearGradient(0,0,0,a);h.addColorStop(0,l.line.areaTopColor),h.addColorStop(1,l.line.areaBottomColor),i.fillStyle=h,i.fill()}i.beginPath();for(let h=0;h<t.length;h++){const d=t[h],c=n.timeToX(d.time),u=r.valueToY(d.value);h===0?i.moveTo(c,u):i.lineTo(c,u)}i.strokeStyle=l.line.color,i.lineWidth=l.line.width,i.stroke()}function ea(s,t){if(t.length===0)return;const{ctx:e,timeScale:i,yScale:n,mediaHeight:r,theme:a}=s,l=Math.max(1,t.length>1?Math.abs(i.timeToX(t[1].time)-i.timeToX(t[0].time))*.8:2);e.fillStyle=a.line.color;for(const h of t){const d=i.timeToX(h.time),c=n.valueToY(h.value),u=Math.max(1,r-c);e.fillRect(d-l/2,c,l,u)}}function ia(s,t){if(t.length===0)return;const{ctx:e,timeScale:i,yScale:n,theme:r}=s,a=Math.max(1,t.length>1?Math.abs(i.timeToX(t[1].time)-i.timeToX(t[0].time))*.75:2);for(const l of t){const h=l.close>=l.open?r.candlestick.up:r.candlestick.down,d=gt(h.body),c=i.timeToX(l.time),u=n.valueToY(l.open),f=n.valueToY(l.close),m=n.valueToY(l.high),p=n.valueToY(l.low);e.strokeStyle=h.wick,e.lineWidth=1,e.beginPath(),e.moveTo(c,m),e.lineTo(c,p),e.stroke();const g=Math.min(u,f),M=Math.max(1,Math.abs(f-u));e.fillStyle=d,e.fillRect(c-a/2,g,a,M)}}function sa(s,t,e){const i=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),r=s.timeToX(i),a=s.timeToX(n),l=Math.min(r,a),h=Math.max(r,a);return{left:l,right:h,width:Math.max(1,h-l)}}var Ct,N,ui,et,Rt,Qt,Vt,Yt,Dt,Et,he,we,Ut,li,hi,ne,At,jt,Ve,Ye,ae,je,Oe,He,$e,re,Ne,O,Fi,ft,Ks,Wi,oe,Re,Ci,ei,ps,qs,Js,Qs,bs,vs,ue,ys;class Zs{constructor(t){A(this,O),A(this,Ct),A(this,N),A(this,ui),A(this,et),A(this,Rt),A(this,Qt),A(this,Vt),A(this,Yt),A(this,Dt),A(this,Et),A(this,he),A(this,we),A(this,Ut,new Bs),A(this,li,new Ws),A(this,hi,0),A(this,ne,0),A(this,At,1),A(this,jt,null),A(this,Ve,!0),A(this,Ye),A(this,ae,null),A(this,je),A(this,Oe),A(this,He),A(this,$e),A(this,re),A(this,Ne),I(this,Ct,t.container),I(this,et,t.chart),I(this,he,t.data),I(this,we,t.options??{}),window.getComputedStyle(o(this,Ct)).position==="static"&&(o(this,Ct).style.position="relative"),I(this,N,document.createElement("canvas")),o(this,N).style.position="absolute",o(this,N).style.left="0",o(this,N).style.top="0",o(this,N).style.height="100%",o(this,N).style.touchAction="none",o(this,Ct).appendChild(o(this,N));const e=o(this,N).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");I(this,ui,e),I(this,Rt,document.createElement("div")),o(this,Rt).dataset.chartNavigatorOverlay="",o(this,Rt).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",I(this,Qt,document.createElement("div")),o(this,Qt).style.cssText="position:absolute;left:0;top:0;bottom:0;",I(this,Vt,document.createElement("div")),o(this,Vt).style.cssText="position:absolute;top:0;bottom:0;",I(this,Yt,document.createElement("div")),o(this,Yt).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",I(this,Dt,ws()),I(this,Et,ws()),o(this,Rt).append(o(this,Qt),o(this,Vt),o(this,Yt),o(this,Dt),o(this,Et)),o(this,Ct).appendChild(o(this,Rt)),I(this,je,()=>z(this,O,oe).call(this)),I(this,Oe,()=>z(this,O,oe).call(this)),o(this,et).on("viewportChange",o(this,je)),o(this,et).on("overlayChange",o(this,Oe)),I(this,He,n=>z(this,O,qs).call(this,n)),I(this,$e,n=>z(this,O,Js).call(this,n)),I(this,re,n=>z(this,O,Qs).call(this,n)),I(this,Ne,()=>{o(this,ae)===null&&(o(this,N).style.cursor="default")}),o(this,N).addEventListener("pointerdown",o(this,He)),o(this,N).addEventListener("pointermove",o(this,$e)),o(this,N).addEventListener("pointerup",o(this,re)),o(this,N).addEventListener("pointercancel",o(this,re)),o(this,N).addEventListener("pointerleave",o(this,Ne)),I(this,Ye,new ResizeObserver(n=>z(this,O,Ks).call(this,n[0]))),o(this,Ye).observe(o(this,Ct)),z(this,O,Fi).call(this);const i=o(this,Ct).getBoundingClientRect();i.width>0&&i.height>0&&z(this,O,Wi).call(this,i.width,i.height),z(this,O,oe).call(this)}setData(t){I(this,he,t),z(this,O,oe).call(this)}setOptions(t){I(this,we,t),z(this,O,Fi).call(this),z(this,O,oe).call(this)}destroy(){o(this,et).off("viewportChange",o(this,je)),o(this,et).off("overlayChange",o(this,Oe)),o(this,N).removeEventListener("pointerdown",o(this,He)),o(this,N).removeEventListener("pointermove",o(this,$e)),o(this,N).removeEventListener("pointerup",o(this,re)),o(this,N).removeEventListener("pointercancel",o(this,re)),o(this,N).removeEventListener("pointerleave",o(this,Ne)),o(this,Ye).disconnect(),o(this,jt)!==null&&(cancelAnimationFrame(o(this,jt)),I(this,jt,null)),o(this,N).remove(),o(this,Rt).remove()}get height(){return o(this,we).height??o(this,et).getTheme().navigator.height}}Ct=new WeakMap,N=new WeakMap,ui=new WeakMap,et=new WeakMap,Rt=new WeakMap,Qt=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Dt=new WeakMap,Et=new WeakMap,he=new WeakMap,we=new WeakMap,Ut=new WeakMap,li=new WeakMap,hi=new WeakMap,ne=new WeakMap,At=new WeakMap,jt=new WeakMap,Ve=new WeakMap,Ye=new WeakMap,ae=new WeakMap,je=new WeakMap,Oe=new WeakMap,He=new WeakMap,$e=new WeakMap,re=new WeakMap,Ne=new WeakMap,O=new WeakSet,Fi=function(){const s=o(this,we).height;s!==void 0&&(o(this,Ct).style.height=`${s}px`)},ft=function(){return Math.max(0,o(this,hi)-o(this,et).yAxisWidth)},Ks=function(s){var t;if(!s)return;const e=(t=s.contentBoxSize)==null?void 0:t[0],i=(e==null?void 0:e.inlineSize)??s.contentRect.width,n=(e==null?void 0:e.blockSize)??s.contentRect.height;i<=0||n<=0||(z(this,O,Wi).call(this,i,n),z(this,O,oe).call(this))},Wi=function(s,t){const e=window.devicePixelRatio||1;I(this,hi,s),I(this,ne,t),I(this,At,e);const i=o(this,O,ft);o(this,N).width=Math.round(i*e),o(this,N).height=Math.round(t*e),o(this,N).style.width=`${i}px`,o(this,Rt).style.width=`${i}px`},oe=function(){o(this,Ve)&&o(this,jt)!==null||(I(this,Ve,!0),o(this,jt)===null&&I(this,jt,requestAnimationFrame(()=>{I(this,jt,null),I(this,Ve,!1),z(this,O,bs).call(this)})))},Re=function(s){const t=o(this,N).getBoundingClientRect();return s.clientX-t.left},Ci=function(){const s=z(this,O,ue).call(this),t=z(this,O,ys).call(this);return o(this,Ut).update(s,o(this,O,ft),o(this,At)),o(this,li).update(t,o(this,ne),o(this,At)),{dataRange:s,yRange:t}},ei=function(){return z(this,O,Ci).call(this),sa(o(this,Ut),o(this,et).getVisibleRange(),z(this,O,ue).call(this))},ps=function(){const s=z(this,O,ue).call(this),t=s.to-s.from;return t<=0||o(this,O,ft)<=0?0:o(this,O,ft)/t},qs=function(s){if(s.button!==void 0&&s.button!==0)return;const t=z(this,O,Re).call(this,s),e=z(this,O,ue).call(this);if(e.to<=e.from)return;const i=z(this,O,ei).call(this),n=Gs(t,i),r=z(this,O,ps).call(this);if(r===0)return;let a=o(this,et).getVisibleRange();if(n.snapToCenter){const l=o(this,Ut).xToTime(t),h=Qr({time:l,startVisible:a,dataRange:e});o(this,et).setVisibleRange(h),a=h}I(this,ae,{pointerId:s.pointerId,gesture:n.gesture,startX:t,startVisible:a,pixelsPerTime:r}),o(this,N).setPointerCapture(s.pointerId),o(this,N).style.cursor=tn(n.gesture,!0),s.preventDefault()},Js=function(s){const t=o(this,ae);if(t===null){o(this,N).style.cursor=xs(z(this,O,Re).call(this,s),z(this,O,ei).call(this));return}if(s.pointerId!==t.pointerId)return;const e=z(this,O,Re).call(this,s)-t.startX,i=z(this,O,ue).call(this);let n;if(t.gesture==="pan")n=qr({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:i});else{const r=t.gesture==="resize-left"?"left":"right";n=Jr({edge:r,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:i,minSpan:2*o(this,et).getDataInterval()})}o(this,et).setVisibleRange(n)},Qs=function(s){const t=o(this,ae);t===null||s.pointerId!==t.pointerId||(I(this,ae,null),o(this,N).hasPointerCapture(s.pointerId)&&o(this,N).releasePointerCapture(s.pointerId),o(this,N).style.cursor=xs(z(this,O,Re).call(this,s),z(this,O,ei).call(this)))},bs=function(){if(o(this,O,ft)<=0||o(this,ne)<=0)return;const s=o(this,et).getTheme().navigator,{dataRange:t}=z(this,O,Ci).call(this);o(this,N).width=Math.round(o(this,O,ft)*o(this,At)),o(this,N).height=Math.round(o(this,ne)*o(this,At)),o(this,N).style.width=`${o(this,O,ft)}px`,o(this,Rt).style.width=`${o(this,O,ft)}px`;const e=o(this,ui),i=o(this,N).width,n=o(this,N).height;e.save(),e.clearRect(0,0,i,n),e.scale(o(this,At),o(this,At));const r={ctx:e,timeScale:o(this,Ut),yScale:o(this,li),mediaWidth:o(this,O,ft),mediaHeight:o(this,ne),theme:s};o(this,N).style.boxShadow=`inset 0 1px 0 ${s.borderColor}, inset 0 -1px 0 ${s.borderColor}`,Zr(r);const a=Math.max(1,Math.round(o(this,O,ft))),l=o(this,he);if(l.type==="candlestick")ia(r,Kr(l.points,a));else{const h=Ti(l),d=h.length===1;for(const c of h){const u=Gr(c,a);l.type==="bar"?ea(r,u):ta(r,u,d)}}e.restore(),z(this,O,vs).call(this,s,t)},vs=function(s,t){if(t.to<=t.from)return;const e=o(this,et).getVisibleRange(),i=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),r=o(this,Ut).timeToX(i),a=o(this,Ut).timeToX(n),l=Math.min(r,a),h=Math.max(r,a),d=Math.max(1,h-l);o(this,Qt).style.width=`${l}px`,o(this,Qt).style.background=s.mask.fill,o(this,Qt).style.display=l>0?"block":"none";const c=Math.max(0,o(this,O,ft)-(l+d));o(this,Vt).style.left=`${l+d}px`,o(this,Vt).style.width=`${c}px`,o(this,Vt).style.background=s.mask.fill,o(this,Vt).style.display=c>0?"block":"none",o(this,Yt).style.left=`${l}px`,o(this,Yt).style.width=`${d}px`,o(this,Yt).style.background=s.window.fill,o(this,Yt).style.border=s.window.borderWidth>0?`${s.window.borderWidth}px solid ${s.window.border}`:"none";const u=s.handle.width,f=Math.max(1,u/2),m=o(this,et).getTheme().background;o(this,Dt).style.left=`${l-u/2}px`,o(this,Dt).style.width=`${u}px`,o(this,Dt).style.background=s.handle.color,o(this,Dt).style.borderRadius=`${f}px`,o(this,Et).style.left=`${l+d-u/2}px`,o(this,Et).style.width=`${u}px`,o(this,Et).style.background=s.handle.color,o(this,Et).style.borderRadius=`${f}px`;for(const p of o(this,Dt).children)p.style.background=m;for(const p of o(this,Et).children)p.style.background=m},ue=function(){const s=o(this,he);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,i=0;if(s.type==="candlestick")i=s.points.length,i>0&&(t=s.points[0].time,e=s.points[i-1].time);else for(const r of Ti(s))r.length!==0&&(i+=r.length,r[0].time<t&&(t=r[0].time),r[r.length-1].time>e&&(e=r[r.length-1].time));if(i>=2&&e>t)return{from:t,to:e};if(i===1)return{...o(this,et).getVisibleRange()};const n=o(this,et).getDataRange();return n&&n.to>n.from?n:{...o(this,et).getVisibleRange()}},ys=function(){const s=o(this,he);let t=1/0,e=-1/0;if(s.type==="candlestick")for(const n of s.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of Ti(s))for(const r of n)r.value<t&&(t=r.value),r.value>e&&(e=r.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const i=(e-t)*.2;return{min:t-i,max:e+i}};function Ti(s){return"series"in s?s.series:[s.points]}function tn(s,t){return s==="resize-left"||s==="resize-right"?"ew-resize":t?"grabbing":"grab"}function xs(s,t){return tn(na(s,t),!1)}function na(s,t){return Gs(s,t).gesture}function ws(){const s=document.createElement("div");s.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",s.appendChild(e)}return s}const Ai=new WeakMap;function en(s,t){var e;return(e=Ai.get(s))==null?void 0:e.get(t)}function sn(s,t,e){let i=Ai.get(s);i||(i=new Map,Ai.set(s,i)),i.set(t,e)}function Ss(s){return"close"in s?s.close:s.value}function nn(s,t){if(t==="none"||s.length<=1)return s;const e=[...s];return e.sort((i,n)=>{const r=Ss(i.data),a=Ss(n.data);return t==="asc"?r-a:a-r}),e}function di(s){const t=Object.freeze({...s.data}),e={id:s.id,seriesId:s.seriesId,layerIndex:s.layerIndex,label:s.label,data:t,color:s.color};return Object.freeze(e)}function _i(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=en(s,t.cacheKey);if(n&&n.version===i&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const l of s.getSeriesIds()){if(!s.isSeriesVisible(l))continue;const h=s.getSeriesLabel(l);if(s.getSeriesLayers(l)!==null){const c=s.getLayerSnapshots(l,t.time);if(!c)continue;for(const u of c)r.push(di({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const d=s.getDataAtTime(l,t.time);d&&r.push(di({id:l,seriesId:l,label:h,data:d,color:s.getSeriesColor(l)??"#888"}))}const a=Object.freeze(nn(r,e));return sn(s,t.cacheKey,{version:i,time:t.time,sort:e,data:a}),a}function rn(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=en(s,t.cacheKey);if(n&&n.version===i&&n.time===null&&n.sort===e)return n.data;const r=[];for(const l of s.getSeriesIds()){if(!s.isSeriesVisible(l))continue;const h=s.getSeriesLabel(l),d=s.getLayerLastSnapshots(l);if(d){for(const u of d)r.push(di({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const c=s.getLastData(l);c&&r.push(di({id:l,seriesId:l,label:h,data:c,color:s.getSeriesColor(l)??"#888"}))}const a=Object.freeze(nn(r,e));return sn(s,t.cacheKey,{version:i,time:null,sort:e,data:a}),a}const ra={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"},navigator:{height:48,background:"transparent",borderColor:"rgba(139, 148, 158, 0.22)",line:{color:"#8b949e",width:1,areaTopColor:"rgba(139, 148, 158, 0.18)",areaBottomColor:"rgba(139, 148, 158, 0)"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0, 0, 0, 0.30)",width:6},mask:{fill:"rgba(255, 255, 255, 0.82)"}}},aa=J({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{up:{body:E("#96e072"),wick:"#96e072"},down:{body:E("#ee5d43"),wick:"#ee5d43"}},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:js},fontUrl:Os}),oa=J({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{up:{body:E("#bae67e"),wick:"#bae67e"},down:{body:E("#f27983"),wick:"#f27983"}},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:gi},fontUrl:Oi}),la=J({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{up:{body:E("#a6e3a1"),wick:"#a6e3a1"},down:{body:E("#f38ba8"),wick:"#f38ba8"}},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:gi},fontUrl:Oi}),ha=J({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{up:{body:E("#50fa7b"),wick:"#50fa7b"},down:{body:E("#ff5555"),wick:"#ff5555"}},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),ca=J({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{up:{body:E("#2da44e"),wick:"#2da44e"},down:{body:E("#cf222e"),wick:"#cf222e"}},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:Ni},fontUrl:Xi}),ua=J({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{up:{body:E("#b8bb26"),wick:"#b8bb26"},down:{body:E("#fb4934"),wick:"#fb4934"}},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),da={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Vr,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:Er,fontSize:18},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{fontSize:13,textColor:"#a09880"},yLabel:{fontSize:15,upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{fontSize:14,background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},fa="'Silkscreen', cursive",ma="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",ga=J({name:"Matrix",background:"#000000",candlestick:{up:{body:E("#00ff41"),wick:"#00ff41"},down:{body:E("#00802a"),wick:"#00802a"}},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:fa},fontUrl:ma,chartGradient:["#010a01","#000000"]}),pa=J({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:E("#6b8e5e"),wick:"#6b8e5e"},down:{body:E("#b85468"),wick:"#b85468"}},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:Ni},fontUrl:Xi,chartGradient:["#f8f4f7","#f5f0f4"]}),ba=J({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{up:{body:E("#6a9a6e"),wick:"#6a9a6e"},down:{body:E("#c45070"),wick:"#c45070"}},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:gi},fontUrl:Oi}),va=J({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{up:{body:E("#c3e88d"),wick:"#c3e88d"},down:{body:E("#f07178"),wick:"#f07178"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:js},fontUrl:Os}),ya="'Silkscreen', cursive",xa="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",wa=J({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{up:{body:E("#111111"),wick:"#111111"},down:{body:E("#bbbbbb"),wick:"#bbbbbb"}},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{fontSize:9,background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:ya},fontUrl:xa}),Sa=J({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:E("#2e9070"),wick:"#2e9070"},down:{body:E("#d04848"),wick:"#d04848"}},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:zr},fontUrl:Dr,chartGradient:["#f8f7f0","#f6f5ee"]}),Ma=J({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{up:{body:E("#8ab862"),wick:"#8ab862"},down:{body:E("#d05470"),wick:"#d05470"}},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),ka=J({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{up:{body:E("#7ec699"),wick:"#7ec699"},down:{body:E("#e06c75"),wick:"#e06c75"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#495a5a"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),Ca=J({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{up:{body:E("#98c379"),wick:"#98c379"},down:{body:E("#e06c75"),wick:"#e06c75"}},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),Ta=J({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{up:{body:E("#19f9d8"),wick:"#19f9d8"},down:{body:E("#ff75b5"),wick:"#ff75b5"}},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),Ra=J({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:E("#5a9a68"),wick:"#5a9a68"},down:{body:E("#d06848"),wick:"#d06848"}},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:Ni},fontUrl:Xi,chartGradient:["#fff8f2","#fef6f0"]}),La=J({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",grid:{color:"rgba(200,200,200,0.5)"},candlestick:{up:{body:E("#448c27"),wick:"#448c27"},down:{body:E("#aa3731"),wick:"#aa3731"}},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Wr},fontUrl:Ar}),Ia=J({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:E("#56949f"),wick:"#56949f"},down:{body:E("#b4637a"),wick:"#b4637a"}},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:Hs},fontUrl:$s}),Ba=J({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:E("#5a8a50"),wick:"#5a8a50"},down:{body:E("#b85040"),wick:"#b85040"}},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:Hs},fontUrl:$s,chartGradient:["#f8f4ec","#f4f0e8"]}),Pa=J({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{up:{body:E("#859900"),wick:"#859900"},down:{body:E("#dc322f"),wick:"#dc322f"}},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:fi},fontUrl:mi});function Ke(s){const{x:t,y:e,chartWidth:i,chartHeight:n,tooltipWidth:r,tooltipHeight:a,offsetX:l=16,offsetY:h=16}=s,d=t+l+r>i?t-l-r:t+l,c=e+h+a>n?e-h-a:e+h,u=Math.max(0,i-r),f=Math.max(0,n-a);return{left:Math.max(0,Math.min(u,d)),top:Math.max(0,Math.min(f,c))}}const be=B.createContext(null);function ot(){const s=B.useContext(be);if(!s)throw new Error("useChartInstance must be used within <ChartContainer>");return s}const Fa=20;function an({data:s,options:t,id:e}){var h;const i=ot(),n=B.useRef(null),r=B.useRef([]),a=B.useRef([]),l=B.useRef([]);return B.useLayoutEffect(()=>{const d=i.addBarSeries({...t,layers:s.length,id:e});return n.current=d,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),l.current=new Array(s.length).fill(null),()=>{i.removeSeries(d),n.current=null,r.current=[],a.current=[],l.current=[]}},[i,s.length,e]),B.useLayoutEffect(()=>{const d=n.current;d&&i.batch(()=>{for(let c=0;c<s.length;c++){const u=s[c],f=r.current[c]??0,m=a.current[c]??null;if(u.length===0){i.setSeriesData(d,[],c),r.current[c]=0,a.current[c]=null,l.current[c]=null;continue}const p=ut(u[0].time),g=ut(u[u.length-1].time),M=l.current[c]??null,v=m!==null&&m!==p,w=u.length-f;if(v&&w===0&&(M!==null&&M!==g))i.setSeriesData(d,u.slice(0,-1),c),i.appendData(d,u[u.length-1],c);else if(f===0||u.length<f||w>Fa||v)i.setSeriesData(d,u,c);else if(u.length===f)i.updateData(d,u[u.length-1],c);else for(let S=f;S<u.length;S++)i.appendData(d,u[S],c);r.current[c]=u.length,a.current[c]=p,l.current[c]=g}})},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(h=t==null?void 0:t.colors)==null?void 0:h.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const Wa=20;function Aa({data:s,options:t,id:e}){var h,d,c,u,f,m;const i=ot(),n=B.useRef(null),r=B.useRef(0),a=B.useRef(null),l=B.useRef(null);return B.useLayoutEffect(()=>{const p=i.addCandlestickSeries({...t,id:e});return n.current=p,()=>{i.removeSeries(p),n.current=null,r.current=0,a.current=null,l.current=null}},[i,e]),B.useLayoutEffect(()=>{const p=n.current;if(!p)return;if(s.length===0){i.setSeriesData(p,[]),r.current=0,a.current=null,l.current=null;return}const g=r.current,M=a.current,v=l.current,w=ut(s[0].time),y=ut(s[s.length-1].time),S=M!==null&&M!==w,x=s.length-g;if(S&&x===0&&(v!==null&&v!==y))i.setSeriesData(p,s.slice(0,-1)),i.appendData(p,s[s.length-1]);else if(g===0||s.length<g||x>Wa||S)i.setSeriesData(p,s);else if(s.length===g)i.updateData(p,s[s.length-1]);else for(let b=g;b<s.length;b++)i.appendData(p,s[b]);r.current=s.length,a.current=w,l.current=y},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,Array.isArray((h=t==null?void 0:t.up)==null?void 0:h.body)?t.up.body.join(","):(d=t==null?void 0:t.up)==null?void 0:d.body,Array.isArray((c=t==null?void 0:t.down)==null?void 0:c.body)?t.down.body.join(","):(u=t==null?void 0:t.down)==null?void 0:u.body,(f=t==null?void 0:t.up)==null?void 0:f.wick,(m=t==null?void 0:t.down)==null?void 0:m.wick,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const Ui=B.createContext(null),ve=Ui.Provider;function qe(){const s=B.useContext(Ui);if(!s)throw new Error("useTheme must be used within <ThemeProvider>");return s}function za(){return B.useContext(Ui)}function pi(s,t,e){const i=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const a of i)s.on(a,r);return()=>{for(const a of i)s.off(a,r)}},getSnapshot:e}}function on(s){const t=B.useMemo(()=>pi(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getVisibleRange()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}function ln(s){const t=B.useMemo(()=>pi(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getYRange()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Da(s,t){const e=B.useMemo(()=>{let i=s.getLastValue(t),n=i?s.yScale.valueToY(i.value):null;const r=()=>i,a=()=>{const l=s.getLastValue(t),h=l?s.yScale.valueToY(l.value):null;return(i==null?void 0:i.value)===(l==null?void 0:l.value)&&(i==null?void 0:i.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(i=l,n=h,!0)};return{subscribe:l=>{a();const h=()=>{a()&&l()};return s.on("dataUpdate",h),s.on("viewportChange",h),()=>{s.off("dataUpdate",h),s.off("viewportChange",h)}},getSnapshot:r}},[s,t]);return B.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Ea(s,t){const e=B.useMemo(()=>pi(s,"dataUpdate",()=>s.getPreviousClose(t)),[s,t]);return B.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Je(s){const t=B.useMemo(()=>pi(s,"crosshairMove",()=>s.getCrosshairPosition()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}const Va=(s,t)=>t==="volume"?te(s):Vi(s);function hn({sort:s="none",format:t=Va,children:e}){const i=ot(),n=qe(),r=Je(i),[,a]=B.useState(0);B.useLayoutEffect(()=>{const f=()=>a(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&a(m=>m+1),()=>{i.off("overlayChange",f)}},[i]);const l=rn(i,{sort:s,cacheKey:"infobar-last"});let h=l,d=l.length===0?0:Math.max(...l.map(f=>f.data.time)),c=!1;if(r!==null){const f=_i(i,{time:r.time,sort:s,cacheKey:"infobar-hover"});f.length>0&&(h=f,d=r.time,c=!0)}if(h.length===0)return null;if(e)return k.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:h,time:d,isHover:c})});const u=i.getDataInterval();return k.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[k.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:Ge(d,u)}),h.map(f=>{if("open"in f.data){const g=f.data,M=g.close>=g.open,v=gt(M?n.candlestick.up.body:n.candlestick.down.body);return k.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[k.jsx(Le,{label:"O",display:t(g.open,"open"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"H",display:t(g.high,"high"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"L",display:t(g.low,"low"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"C",display:t(g.close,"close"),color:v,dim:n.axis.textColor}),g.volume!=null&&k.jsx(Le,{label:"V",display:t(g.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const p=f.data;return k.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[k.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.color,flexShrink:0}}),k.jsx("span",{style:{color:f.color,fontWeight:500},children:t(p.value,"value")})]},f.id)})]})}function Le({label:s,display:t,color:e,dim:i}){return k.jsxs(k.Fragment,{children:[k.jsx("span",{style:{color:i,opacity:.5,marginLeft:5},children:s}),k.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function Ya({chart:s,isolatedIdRef:t,setIsolatedId:e}){const i=[],n=s.getSeriesIds();for(const r of n){const a=s.getSeriesLayers(r);if(a){const l=s.getSeriesLabel(r);for(let h=0;h<a.length;h++){const d=`${r}_layer${h}`,c=s.isSeriesVisible(r)&&s.isLayerVisible(r,h);i.push(Ms({id:d,seriesId:r,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:a[h].color,isDisabled:!c,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=s.getSeriesColor(r);if(!l)continue;const h=s.getSeriesLabel(r),d=s.isSeriesVisible(r);i.push(Ms({id:r,seriesId:r,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!d,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}return i}function Ms(s){const{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,chart:l,isolatedIdRef:h,setIsolatedId:d}=s;return{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,toggle:()=>{i!==void 0?l.setLayerVisible(e,i,!l.isLayerVisible(e,i)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const f of l.getSeriesIds()){l.setSeriesVisible(f,!0);const m=l.getSeriesLayers(f);if(m)for(let p=0;p<m.length;p++)l.setLayerVisible(f,p,!0)}}),h.current=null,d(null);return}l.batch(()=>{for(const f of l.getSeriesIds()){const m=l.getSeriesLayers(f);if(m){l.setSeriesVisible(f,f===e);for(let p=0;p<m.length;p++)l.setLayerVisible(f,p,f===e&&p===i)}else l.setSeriesVisible(f,f===t)}}),h.current=t,d(t)}}}function cn({items:s,position:t="bottom",mode:e="toggle",children:i}){const n=ot(),r=qe(),[a,l]=B.useState(null),[h,d]=B.useState(0),c=B.useRef(a);c.current=a,B.useLayoutEffect(()=>{const g=()=>d(v=>v+1),M=()=>l(null);return n.on("overlayChange",g),n.on("seriesChange",M),n.getSeriesIds().length>0&&d(v=>v+1),()=>{n.off("overlayChange",g),n.off("seriesChange",M)}},[n]);const u=B.useMemo(()=>Ya({chart:n,isolatedIdRef:c,setIsolatedId:l}),[n,a,h]),f=t==="right",m={display:"flex",flexDirection:f?"column":"row",flexWrap:"wrap",gap:f?6:14,padding:f?"8px 6px":"6px 8px",alignItems:f?"flex-start":"center",justifyContent:f?"flex-start":"center",fontFamily:r.typography.fontFamily,fontSize:r.axis.fontSize,color:r.axis.textColor,pointerEvents:"auto",flexShrink:0};if(i)return u.length===0?null:k.jsx("div",{"data-legend":t,style:m,children:i({items:u})});if(s)return s.length===0?null:k.jsx("div",{"data-legend":t,style:m,children:s.map((g,M)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),k.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},M))});if(u.length===0)return null;const p=g=>{e==="isolate"||e==="solo"?g.isolate():g.toggle()};return k.jsx("div",{"data-legend":t,style:m,children:u.map(g=>k.jsxs("div",{onClick:()=>p(g),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:g.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),k.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},g.id))})}function un({data:s,height:t,style:e,className:i}){const n=ot(),r=qe(),a=B.useRef(null),l=B.useRef(null);B.useLayoutEffect(()=>{if(!a.current)return;const d=new Zs({container:a.current,chart:n,data:s,options:t!==void 0?{height:t}:void 0});return l.current=d,()=>{d.destroy(),l.current=null}},[n]),B.useEffect(()=>{var d;(d=l.current)==null||d.setData(s)},[s]),B.useEffect(()=>{var d;(d=l.current)==null||d.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??r.navigator.height;return k.jsx("div",{ref:a,className:i,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function ja(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function dn({seriesId:s,mode:t,format:e,position:i,children:n}){const r=t??"both",a=i??"bottom",l=e??te,h=ot(),d=h.getTheme(),[,c]=B.useState(0);B.useLayoutEffect(()=>{const p=()=>c(g=>g+1);return h.on("overlayChange",p),h.getSeriesIds().length>0&&p(),()=>{h.off("overlayChange",p)}},[h]);const u=ja(h,s),f=u!==null?h.getSliceInfo(u):null;if(!f||f.length===0)return null;if(n)return k.jsx(k.Fragment,{children:n({slices:f,mode:r,format:l})});const m=a==="overlay";return k.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":a,style:{display:"flex",flexDirection:"column",gap:6,padding:m?"8px 12px":"6px 10px",fontFamily:d.typography.fontFamily,fontSize:d.typography.fontSize,color:d.tooltip.textColor,pointerEvents:"auto"},children:f.map((p,g)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[k.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:p.color,flexShrink:0}}),k.jsx("span",{style:{flex:1,opacity:.8},children:p.label}),(r==="value"||r==="both")&&k.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:l(p.value)}),(r==="percent"||r==="both")&&k.jsxs("span",{style:{opacity:r==="percent"?1:.5,fontWeight:r==="percent"?600:400,fontSize:r==="percent"?d.typography.fontSize:d.axis.fontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[p.percent.toFixed(1),"%"]})]},g))})}function fn({children:s,sub:t,style:e}){const i=qe();return k.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:i.typography.fontFamily,fontSize:i.typography.fontSize,fontWeight:600,color:i.tooltip.textColor,pointerEvents:"none",...e},children:[s!=null&&s!==!1&&k.jsx("span",{children:s}),t!=null&&t!==!1&&k.jsx("span",{style:{fontWeight:400,color:i.axis.textColor,fontSize:i.axis.fontSize},children:t})]})}function Oa(s){let t=null,e=null,i=null,n=null,r=null;const a=[],l=h=>{if(B.isValidElement(h)&&h.type===B.Fragment){B.Children.forEach(h.props.children,l);return}if(B.isValidElement(h)){if(h.type===fn){t=h;return}if(h.type===cn){e=h;return}if(h.type===dn){const d=h;d.props.position==="overlay"?a.push(h):i=d;return}if(h.type===hn){n=h;return}if(h.type===un){r=h;return}}a.push(h)};return B.Children.forEach(s,l),{titleEl:t,legendEl:e,pieLegendEl:i,tooltipLegendEl:n,navigatorEl:r,overlay:a}}function mn({children:s,theme:t,axis:e,padding:i,gradient:n=!0,interactive:r,grid:a,headerLayout:l="overlay",perf:h,style:d,className:c}){var ht,Bt,wt,Ht,Me,Qe;const u=B.useRef(h),f=za(),m=t??f??void 0,p=B.useRef(null),g=B.useRef(null),[M,v]=B.useState(0);B.useLayoutEffect(()=>{if(!p.current||g.current)return;const nt={};return e&&(nt.axis=e),m&&(nt.theme=m),i&&(nt.padding=i),r!==void 0&&(nt.interactive=r),a!==void 0&&(nt.grid=a),u.current!==void 0&&(nt.perf=u.current),g.current=new Us(p.current,nt),v(St=>St+1),()=>{var St;(St=g.current)==null||St.destroy(),g.current=null}},[]),B.useEffect(()=>{g.current&&m&&g.current.setTheme(m)},[m]),B.useEffect(()=>{g.current&&e&&g.current.setAxis(e)},[(ht=e==null?void 0:e.y)==null?void 0:ht.width,(Bt=e==null?void 0:e.y)==null?void 0:Bt.min,(wt=e==null?void 0:e.y)==null?void 0:wt.max,(Ht=e==null?void 0:e.y)==null?void 0:Ht.visible,(Me=e==null?void 0:e.x)==null?void 0:Me.height,(Qe=e==null?void 0:e.x)==null?void 0:Qe.visible]);const w=B.useRef(null),[y,S]=B.useState(0),x=l==="overlay"?y:0;B.useEffect(()=>{const nt=g.current;if(!nt)return;const $t={top:((i==null?void 0:i.top)??20)+x,...(i==null?void 0:i.bottom)!==void 0?{bottom:i.bottom}:{},...(i==null?void 0:i.right)!==void 0?{right:i.right}:{},...(i==null?void 0:i.left)!==void 0?{left:i.left}:{}};nt.setPadding($t)},[i==null?void 0:i.top,i==null?void 0:i.bottom,typeof(i==null?void 0:i.right)=="object"?i.right.intervals:i==null?void 0:i.right,typeof(i==null?void 0:i.left)=="object"?i.left.intervals:i==null?void 0:i.left,x]),B.useEffect(()=>{g.current&&a!==void 0&&g.current.setGrid(a)},[a==null?void 0:a.visible]);const P=g.current,{titleEl:b,legendEl:R,pieLegendEl:L,tooltipLegendEl:T,navigatorEl:F,overlay:W}=Oa(s),V=(R==null?void 0:R.props.position)??"bottom",D=(L==null?void 0:L.props.position)??"bottom",j=V==="right"||D==="right",H=m??(P==null?void 0:P.getTheme()),[X,it]=(H==null?void 0:H.chartGradient)??["transparent","transparent"],U=(H==null?void 0:H.background)??"transparent",xt=n?`linear-gradient(to bottom, ${X} 0%, ${U} 70%, ${it} 100%)`:U;B.useLayoutEffect(()=>{if(l!=="overlay"){S(0);return}const nt=w.current;if(!nt){S(0);return}const St=()=>S(nt.getBoundingClientRect().height);St();const $t=new ResizeObserver(St);return $t.observe(nt),()=>$t.disconnect()},[b!==null,T!==null,l,P!==null]);const lt=(b||T)&&k.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":l==="overlay"?"":void 0,ref:w,style:l==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[b,T]}),It=k.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:P&&k.jsx(be.Provider,{value:P,children:k.jsxs(ve,{value:m??P.getTheme(),children:[l==="overlay"&&lt,k.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:W})]})})}),Q=l==="inline"?k.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[P&&lt&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:lt})}),It]}):It,Ot=P&&R&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:R})}),pt=P&&L&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:L})}),dt=P&&F&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:F})});return k.jsxs("div",{className:c,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:xt,...d},children:[k.jsxs("div",{style:{display:"flex",flexDirection:j?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Q,Ot,pt]}),dt]})}const Ha=20;function gn({data:s,options:t,id:e}){var h,d;const i=ot(),n=B.useRef(null),r=B.useRef([]),a=B.useRef([]),l=B.useRef([]);return B.useLayoutEffect(()=>{const c=i.addLineSeries({...t,layers:s.length,id:e});return n.current=c,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),l.current=new Array(s.length).fill(null),()=>{i.removeSeries(c),n.current=null,r.current=[],a.current=[],l.current=[]}},[i,s.length,e]),B.useLayoutEffect(()=>{const c=n.current;c&&i.batch(()=>{for(let u=0;u<s.length;u++){const f=s[u],m=r.current[u]??0,p=a.current[u]??null;if(f.length===0){i.setSeriesData(c,[],u),r.current[u]=0,a.current[u]=null,l.current[u]=null;continue}const g=ut(f[0].time),M=ut(f[f.length-1].time),v=l.current[u]??null,w=p!==null&&p!==g,y=f.length-m;if(w&&y===0&&(v!==null&&v!==M))i.setSeriesData(c,f.slice(0,-1),u),i.appendData(c,f[f.length-1],u);else if(m===0||f.length<m||y>Ha||w)i.setSeriesData(c,f,u);else if(f.length===m)i.updateData(c,f[f.length-1],u);else for(let x=m;x<f.length;x++)i.appendData(c,f[x],u);r.current[u]=f.length,a.current[u]=g,l.current[u]=M}})},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(h=t==null?void 0:t.colors)==null?void 0:h.join(","),t==null?void 0:t.strokeWidth,(d=t==null?void 0:t.area)==null?void 0:d.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}function $a({data:s,options:t,id:e}){var r,a,l,h,d,c,u,f,m,p;const i=ot(),n=B.useRef(null);return B.useLayoutEffect(()=>{const g=i.addPieSeries({...t,id:e});return n.current=g,()=>{i.removeSeries(g),n.current=null}},[i,e]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(r=t==null?void 0:t.sliceLabels)==null?void 0:r.mode,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.minSliceAngle,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.elbowLen,(c=t==null?void 0:t.sliceLabels)==null?void 0:c.legPad,(u=t==null?void 0:t.sliceLabels)==null?void 0:u.labelGap,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.distance,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.railWidth,(p=t==null?void 0:t.sliceLabels)==null?void 0:p.balanceSides]),B.useLayoutEffect(()=>{n.current&&i.setSeriesData(n.current,s)},[i,s]),null}function Na(){const s=ot(),t=Je(s);if(!t)return null;const e=s.getTheme(),i=s.getDataInterval(),n={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.axis.fontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return k.jsxs(k.Fragment,{children:[k.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:s.yScale.formatY(t.y)}),k.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:Ge(t.time,i)})]})}const Xa=["0","1","2","3","4","5","6","7","8","9"];function _a(s){const t=[];for(const e of s)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function pn({value:s,format:t,locale:e="en-US",spinDuration:i=350,className:n,style:r}){const l=B.useMemo(()=>{if(typeof t=="function")return t;const d=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return c=>d.format(c)},[t,e])(s),h=_a(l);return k.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:h.map((d,c)=>d.type==="digit"?k.jsx(Ua,{digit:parseInt(d.value,10),duration:i},`d${c}`):k.jsx("span",{style:{display:"inline-block"},children:d.value},`s${c}`))})}function Ua({digit:s,duration:t}){const e=B.useRef(!1);return B.useEffect(()=>{e.current=!0},[]),k.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:k.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-s*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Xa.map(i=>k.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:i},i))})})}function Ga(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Ka=160,qa=70;function Ja({seriesId:s,format:t=te,children:e}){const i=ot(),n=Je(i),[,r]=B.useState(0);B.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),()=>{i.off("overlayChange",f)}},[i]);const a=Ga(i,s),l=a!==null?i.getHoverInfo(a):null;if(!l||!n)return null;const h=i.getTheme(),d=i.getMediaSize();if(e)return k.jsx(Qa,{x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,children:e({info:l,format:t})});const{left:c,top:u}=Ke({x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,tooltipWidth:Ka,tooltipHeight:qa,offsetX:16,offsetY:16});return k.jsxs("div",{style:{position:"absolute",left:c,top:u,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:l.color,flexShrink:0}}),k.jsx("span",{style:{fontWeight:600},children:l.label})]}),k.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[k.jsx("span",{style:{opacity:.6},children:t(l.value)}),k.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function Qa({x:s,y:t,chartWidth:e,chartHeight:i,children:n}){const r=B.useRef(null),[a,l]=B.useState(null);B.useEffect(()=>{const d=r.current;if(!d||typeof ResizeObserver>"u")return;const c=new ResizeObserver(u=>{var m;const f=(m=u[0])==null?void 0:m.contentRect;f&&l(p=>p&&p.width===f.width&&p.height===f.height?p:{width:f.width,height:f.height})});return c.observe(d),()=>c.disconnect()},[]);const h=a?Ke({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:a.width,tooltipHeight:a.height,offsetX:16,offsetY:16}):{left:0,top:0};return k.jsx("div",{ref:r,"data-measured":a?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:a?"visible":"hidden"},children:n})}function Za(s,t){if(s.startsWith("rgba")||!s.startsWith("#"))return s;const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function to(s){if(s.length<2)return{value:0,pct:0,positive:!0};const t=s[0].value,i=s[s.length-1].value-t,n=t!==0?i/t*100:0;return{value:i,pct:n,positive:i>=0}}function eo({data:s,theme:t,variant:e="line",valuePosition:i="right",formatValue:n=te,label:r,sublabel:a,color:l,negativeColor:h,area:d,areaFill:c,width:u=140,height:f=48,strokeWidth:m=1.5,gradient:p=!0,style:g}){const M=(d==null?void 0:d.visible)??c??!0,v=s.length>0?s[s.length-1].value:0,w=B.useMemo(()=>to(s),[s]),y=l??t.seriesColors[0],S=h??gt(t.candlestick.down.body),x=gt(w.positive?t.candlestick.up.body:t.candlestick.down.body),P=i!=="none"&&k.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[r&&k.jsx("div",{style:{fontSize:t.axis.fontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),k.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(v)}),a!==void 0?k.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:a}):k.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:x,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[w.positive?"+":"",w.pct.toFixed(1),"%"]})]}),b=k.jsx("div",{style:{width:u,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:k.jsx(mn,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:{visible:!1},children:e==="line"?k.jsx(gn,{data:[s],options:{colors:[y],strokeWidth:m,area:{visible:M},pulse:!1,stacking:"off"}}):k.jsx(an,{data:[s],options:{colors:[y,S],barWidthRatio:.7,stacking:"off"}})})});return k.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Za(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...g},children:[i==="left"&&P,b,i==="right"&&P]})}function bn({labelCount:s,minLabelSpacing:t}={}){const e=ot();on(e),B.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:s??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,s,t]);const i=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:a}=e.timeScale.niceTickValues(n),l=new Set(r),d=B.useRef(new Map).current,c=performance.now();for(const f of r)d.has(f)?d.get(f).opacity=1:d.set(f,{opacity:1,addedAt:c});for(const[f,m]of d)l.has(f)||m.opacity!==0&&(m.opacity=0,m.fadedAt=c);for(const[f,m]of d)m.opacity===0&&m.fadedAt!==void 0&&c-m.fadedAt>600&&d.delete(f);const u=Array.from(d.entries());return k.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:u.map(([f,m])=>{const p=e.timeScale.timeToX(f);return k.jsx("span",{style:{position:"absolute",left:p,transform:"translateX(-50%)",color:ji(i,"x"),fontSize:Yi(i,"x"),fontFamily:i.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:Ge(f,a)},f)})})}const io=(s,t)=>t==="volume"?te(s):Vi(s);function so({sort:s="none",format:t=io,children:e}){const i=ot(),n=Je(i),[,r]=B.useState(0);if(B.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&r(m=>m+1),()=>{i.off("overlayChange",f)}},[i]),!n)return null;const a=_i(i,{time:n.time,sort:s,cacheKey:"tooltip"});if(a.length===0)return null;const l=i.getTheme(),h=i.getDataInterval(),d=i.getMediaSize(),c=d.width-i.yAxisWidth,u=d.height-i.xAxisHeight;return e?k.jsx(no,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,children:e({snapshots:a,time:n.time})}):k.jsx(ro,{snapshots:a,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,dataInterval:h,format:t})}function no({x:s,y:t,chartWidth:e,chartHeight:i,theme:n,children:r}){const a=B.useRef(null),[l,h]=B.useState(null);B.useEffect(()=>{const c=a.current;if(!c||typeof ResizeObserver>"u")return;const u=new ResizeObserver(f=>{var p;const m=(p=f[0])==null?void 0:p.contentRect;m&&h(g=>g&&g.width===m.width&&g.height===m.height?g:{width:m.width,height:m.height})});return u.observe(c),()=>u.disconnect()},[]);const d=l?Ke({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return k.jsx("div",{ref:a,"data-measured":l?"true":"false",style:{position:"absolute",left:d.left,top:d.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.tooltip.fontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:l?"visible":"hidden"},children:r})}function ro({snapshots:s,displayTime:t,x:e,y:i,chartWidth:n,chartHeight:r,theme:a,dataInterval:l,format:h}){const d=s.some(w=>"open"in w.data),c=s.filter(w=>!("open"in w.data)).length,u=160,f=d?140:40+c*22,{left:m,top:p}=Ke({x:e,y:i,chartWidth:n,chartHeight:r,tooltipWidth:u,tooltipHeight:f}),g=a.tooltip.background,M=a.tooltip.borderColor;return k.jsxs("div",{style:{position:"absolute",left:m,top:p,pointerEvents:"none",background:g,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${M}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:a.tooltip.fontSize,fontFamily:a.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:a.tooltip.textColor,width:u,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[k.jsxs("div",{style:{fontSize:a.axis.fontSize,color:a.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${M}`,letterSpacing:"0.02em"},children:[Is(t)," ",Ge(t,l)]}),s.map(w=>{if("open"in w.data){const x=w.data,P=x.close>=x.open,b=gt(P?a.candlestick.up.body:a.candlestick.down.body);return k.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[k.jsx(Ie,{label:"Open",color:b,display:h(x.open,"open")}),k.jsx(Ie,{label:"High",color:b,display:h(x.high,"high")}),k.jsx(Ie,{label:"Low",color:b,display:h(x.low,"low")}),k.jsx(Ie,{label:"Close",color:b,display:h(x.close,"close")}),x.volume!=null&&k.jsx(Ie,{label:"Volume",color:a.tooltip.textColor,display:h(x.volume,"volume")})]},w.id)}const S=w.data;return k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:w.color,flexShrink:0}}),k.jsx("span",{style:{opacity:.6,flex:1},children:w.label??"Value"}),k.jsx("span",{style:{fontWeight:600,color:w.color},children:h(S.value,"value")})]},w.id)})]})}function Ie({label:s,color:t,display:e}){return k.jsxs(k.Fragment,{children:[k.jsx("span",{style:{opacity:.5},children:s}),k.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function ao({format:s,labelCount:t,minLabelSpacing:e}={}){const i=ot();ln(i),B.useLayoutEffect(()=>(i.yScale.setFormat(s??null),()=>i.yScale.setFormat(null)),[i,s]),B.useLayoutEffect(()=>(i.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{i.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[i,t,e]);const n=i.getTheme(),r=i.yScale.niceTickValues(),a=new Set(r),h=B.useRef(new Map).current,d=performance.now();for(const u of r)h.has(u)?h.get(u).opacity=1:h.set(u,{opacity:1,addedAt:d});for(const[u,f]of h)a.has(u)||f.opacity!==0&&(f.opacity=0,f.fadedAt=d);for(const[u,f]of h)f.opacity===0&&f.fadedAt!==void 0&&d-f.fadedAt>600&&h.delete(u);const c=Array.from(h.entries());return k.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:i.xAxisHeight,width:i.yAxisWidth,pointerEvents:"none"},children:c.map(([u,f])=>{const m=i.yScale.valueToY(u);return k.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:ji(n,"y"),fontSize:Yi(n,"y"),fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:i.yScale.formatY(u)},u)})})}function oo(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const i=s.getSeriesIdsByType("time",{visibleOnly:!0});return i.length>0?i[0]:null}function lo({seriesId:s,color:t,format:e,children:i}){const n=ot();B.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=B.useState(0);B.useLayoutEffect(()=>{const y=()=>r(S=>S+1);return n.on("overlayChange",y),n.on("viewportChange",y),n.getSeriesIds().length>0&&r(S=>S+1),()=>{n.off("overlayChange",y),n.off("viewportChange",y)}},[n]);const a=oo(n,s),l=a!==null?n.getStackedLastValue(a):null,h=a!==null?n.getPreviousClose(a):null,d=n.yScale.getRange(),c=d.max-d.min,u=c<.1?6:c<10?4:c<1e3?2:0,f=B.useMemo(()=>{if(e)return e;const y=new Intl.NumberFormat("en-US",{minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!1});return S=>y.format(S)},[e,u]);if(!l||a===null)return null;const{value:m,isLive:p}=l,g=n.getTheme(),M=n.yScale.valueToY(m),v=h===null?"neutral":m>h?"up":m<h?"down":"neutral";let w;return p?t?w=t:w=v==="up"?g.yLabel.upBackground:v==="down"?g.yLabel.downBackground:g.yLabel.neutralBackground:w=g.axis.textColor,i?k.jsx(k.Fragment,{children:i({value:m,y:M,bgColor:w,isLive:p,direction:v,format:f})}):k.jsxs(k.Fragment,{children:[k.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:M,height:0,borderTop:`1px dashed ${w}`,opacity:.5,pointerEvents:"none",zIndex:2}}),k.jsx("div",{style:{position:"absolute",right:4,top:M,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:w,color:g.yLabel.textColor,fontSize:g.yLabel.fontSize,fontFamily:g.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:k.jsx(pn,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=an;exports.CandlestickSeries=Aa;exports.ChartContainer=mn;exports.ChartInstance=Us;exports.Crosshair=Na;exports.InfoBar=hn;exports.Legend=cn;exports.LineSeries=gn;exports.Navigator=un;exports.NavigatorController=Zs;exports.NumberFlow=pn;exports.PieLegend=dn;exports.PieSeries=$a;exports.PieTooltip=Ja;exports.Sparkline=eo;exports.ThemeProvider=ve;exports.TimeAxis=bn;exports.Title=fn;exports.Tooltip=so;exports.XAxis=bn;exports.YAxis=ao;exports.YLabel=lo;exports.andromeda=aa;exports.autoGradient=E;exports.ayuMirage=oa;exports.buildHoverSnapshots=_i;exports.buildLastSnapshots=rn;exports.catppuccin=la;exports.computeTooltipPosition=Ke;exports.createTheme=J;exports.darkTheme=Ns;exports.detectInterval=Ls;exports.dracula=ha;exports.formatCompact=te;exports.formatDate=Is;exports.formatPriceAdaptive=Vi;exports.formatTime=Ge;exports.githubLight=ca;exports.gruvbox=ua;exports.handwritten=da;exports.highContrast=ga;exports.lavenderMist=pa;exports.lightPink=ba;exports.lightTheme=ra;exports.materialPalenight=va;exports.minimalLight=wa;exports.mintBreeze=Sa;exports.monokaiPro=Ma;exports.nightOwl=ka;exports.normalizeTime=ut;exports.oneDarkPro=Ca;exports.panda=Ta;exports.peachCream=Ra;exports.quietLight=La;exports.resolveAxisFontSize=Yi;exports.resolveAxisTextColor=ji;exports.resolveCandlestickBodyColor=gt;exports.rosePineDawn=Ia;exports.sandDune=Ba;exports.solarizedLight=Pa;exports.useChartInstance=ot;exports.useCrosshairPosition=Je;exports.useLastYValue=Da;exports.usePreviousClose=Ea;exports.useTheme=qe;exports.useVisibleRange=on;exports.useYRange=ln;
2
+ `)}class Un{constructor(t,e,i=Hn){C(this,"element"),C(this,"unsubscribe"),C(this,"updateIntervalMs"),C(this,"lastUpdate",0),this.updateIntervalMs=i;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,$n),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=_n(t))}}const Gn=5e3,Kn=2e3,qn=30;function xi(s,t,e){let i=0;for(;i<t.length&&t[i]<e;)i++;i>0&&(s.splice(0,i),t.splice(0,i))}function wi(s,t,e){const i=s.length-e;i>0&&(s.splice(0,i),t.splice(0,i))}function Si(s){if(s.length===0)return{last:0,p50:0,p95:0};const t=[...s].sort((e,i)=>e-i);return{last:s[s.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function ss(s){if(s.length<2)return 0;const t=s[s.length-1]-s[0];return t<=0?0:(s.length-1)*1e3/t}function ns(s){const t={};for(const[e,i]of s)t[e]=i;return t}class Mi{constructor(t={}){C(this,"drawCallsMain",new Map),C(this,"drawCallsOverlay",new Map),C(this,"mainMs",[]),C(this,"overlayMs",[]),C(this,"mainStamps",[]),C(this,"overlayStamps",[]),C(this,"perSeriesMs",new Map),C(this,"perSeriesStamps",new Map),C(this,"listeners",new Set),C(this,"windowMs"),C(this,"maxSamples"),C(this,"heapInterval"),C(this,"heapCounter",0),C(this,"heapMb",null),C(this,"mainFrameCount",0),C(this,"overlayFrameCount",0),C(this,"lastStamp",0),this.windowMs=t.windowMs??Gn,this.maxSamples=t.maxSamples??Kn,this.heapInterval=t.heapSampleEveryNFrames??qn}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,i){if(this.lastStamp=i,t==="main"?(this.mainMs.push(e),this.mainStamps.push(i),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(i),this.overlayFrameCount++),this.trimAll(i),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,i=this.lastStamp){let n=this.perSeriesMs.get(t),r=this.perSeriesStamps.get(t);(!n||!r)&&(n=[],r=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,r)),n.push(e),r.push(i)}trimAll(t){const e=t-this.windowMs;xi(this.mainMs,this.mainStamps,e),xi(this.overlayMs,this.overlayStamps,e),wi(this.mainMs,this.mainStamps,this.maxSamples),wi(this.overlayMs,this.overlayStamps,this.maxSamples);for(const i of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(i),r=this.perSeriesStamps.get(i);!n||!r||(xi(n,r,e),wi(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[i,n]of this.perSeriesMs)t[i]=Si(n);const e=ss(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:ss(this.overlayStamps),fps:e,mainFrameMs:Si(this.mainMs),overlayFrameMs:Si(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:ns(this.drawCallsMain),overlay:ns(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}class ti{constructor(t){C(this,"dirty",!1),C(this,"rafId",null),C(this,"callback"),C(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const ce=6e4,ee=36e5,Gt=864e5;function ut(s){return s instanceof Date?s.getTime():s}function Jn(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ut(t.time)}))}function Qn(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ut(t.time)}))}function Ls(s){if(s.length<2)return Gt;const t=[];for(let e=1;e<Math.min(s.length,20);e++)t.push(s[e]-s[e-1]);return t.sort((e,i)=>e-i),t[Math.floor(t.length/2)]}function Ge(s,t){const e=new Date(s);return t>=Gt?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=ee?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Is(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Zn(s){const t=[1e3,5e3,1e4,15e3,3e4],e=[ce,5*ce,10*ce,15*ce,30*ce],i=[ee,2*ee,4*ee,6*ee,12*ee],n=[Gt,7*Gt,30*Gt,90*Gt,365*Gt];return s<ce?[...t,...e,...i,...n]:s<ee?[...e,...i,...n]:s<Gt?[...i,...n]:n}const tr=50,er=80;class Bs{constructor(){C(this,"from",0),C(this,"to",0),C(this,"width",1),C(this,"pixelRatio",1),C(this,"dataInterval",null),C(this,"labelCountHintValue",null),C(this,"minSpacingValue",null),C(this,"resolvedInterval",null),C(this,"lastInterval",null),C(this,"lastWant",null),C(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??er}update(t,e,i,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=i,n!==void 0&&n>0){const r=rs(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=ir(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=sr(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const a=rs(t);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,i=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(tr,Math.floor((this.to-i)/e)+1)),r=[];for(let a=0;a<n;a++)r.push(i+a*e);return{ticks:r,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=Zn(this.dataInterval),e=this.to-this.from,i=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,i)}else n=i;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=i;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],a=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){r=t[l],a=l;break}if(this.labelCountHint!=null&&a>0&&this.countTicks(r)<this.labelCountHint){const l=t[a-1];l>=i&&(r=l)}this.resolvedInterval=r,this.lastInterval=r,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function rs(s){return s<6e4?0:s<36e5?1:s<864e5?2:3}function ir(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function sr(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Ps(s){const t=Math.abs(s);if(t===0)return"0";if(t<1e-12)return s.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),i=Math.min(12,e+4),n=s.toFixed(i);return n.includes(".")?n.replace(/\.?0+$/,""):n}function Fs(s){return Number.isNaN(s)?"—":s===1/0?"∞":s===-1/0?"−∞":null}function te(s,t){const e=Fs(s);if(e!==null)return e;const i=Math.abs(s),n=(t==null?void 0:t.decimals)??2,r=(a,l,h)=>{const d=a/l,c=Number.parseFloat(d.toFixed(n));return Math.abs(c)>=1e3?null:`${d.toFixed(n)}${h}`};return i>=1e15?s.toExponential(2):i>=1e12?r(s,1e12,"T")??s.toExponential(2):i>=1e9?r(s,1e9,"B")??`${(s/1e12).toFixed(n)}T`:i>=1e6?r(s,1e6,"M")??`${(s/1e9).toFixed(n)}B`:i>=1e3?r(s,1e3,"K")??`${(s/1e6).toFixed(n)}M`:i<1?Ps(s):i<100?s.toFixed(2):s.toFixed(0)}function Vi(s){const t=Fs(s);if(t!==null)return t;const e=Math.abs(s);return e===0?"0":e<1?Ps(s):e<100?s.toFixed(4):e>=1e7?te(s):e<1e4?s.toFixed(2):s.toFixed(0)}function nr(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function rr(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e>=5?5:e>=2?2:1)*t}const ar=50,or=50;class Ws{constructor(){C(this,"min",0),C(this,"max",0),C(this,"height",1),C(this,"pixelRatio",1),C(this,"labelCountHintValue",null),C(this,"minSpacingValue",null),C(this,"resolvedInterval",null),C(this,"lastInterval",null),C(this,"lastRawInterval",null),C(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??or}update(t,e,i){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=i,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=lr(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=hr(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,i=Math.max(0,Math.min(ar,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<i;r++)n.push(e+r*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return te(t);const e=this.resolvedInterval,i=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(i)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,i=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/i;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const a=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(a&&l){this.resolvedInterval=this.lastInterval;return}}let r=nr(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const a=rr(n);a>=e&&a>0&&(r=a)}this.resolvedInterval=r,this.lastInterval=r,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function lr(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function hr(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Zt(s,t){return s===!1?0:s===void 0?t:s}function de(s,t){const e=Math.max(1e-4,Math.abs(t)*1e-5);return Math.abs(s-t)>e}function cr(s,t,e,i){const n=s==null?void 0:s.get(t);if(!n)return 1;if(i<=0)return s==null||s.delete(t),1;const r=Se((e-n.startTime)/i,0,1),a=Ts(r);return r>=1&&(s==null||s.delete(t)),a}function ur(s){let t=0,e=0;for(const i of s)i>0?t+=i:i<0&&(e+=i);return{positive:t,negative:e}}function dr(s){return s.positive>0?s.positive:s.negative<0?s.negative:0}function fr(s){return s.positive>0?100:s.negative<0?-100:0}class As{constructor(t){C(this,"stores"),C(this,"displayedLastValues"),C(this,"lastSeededTimes"),C(this,"entries"),C(this,"lastRenderTime",0),this.stores=Array.from({length:t},()=>new Rs),this.displayedLastValues=new Array(t).fill(null),this.lastSeededTimes=new Array(t).fill(Number.NaN),this.entries=Array.from({length:t},()=>new Map)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=Qn(t??[]);n.setData(r),(i=this.entries[e])==null||i.clear()}appendPoint(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=t,a=ut(r.time),l=this.createEntry(e,a,performance.now());n.append({...r,time:a}),l&&((i=this.entries[e])==null||i.set(a,l))}updateLastPoint(t,e=0){const i=this.stores[e];if(!i)return;const n=t;i.updateLast({...n,time:ut(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var i;(i=this.stores[t])==null||i.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners();for(const t of this.entries)t.clear();this.displayedLastValues=this.displayedLastValues.map(()=>null),this.lastSeededTimes=this.lastSeededTimes.map(()=>Number.NaN),this.lastRenderTime=0}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}get needsAnimation(){for(const t of this.entries)if(t.size>0)return!0;for(let t=0;t<this.stores.length;t++){const e=this.displayedLastValues[t],i=this.stores[t].last();if(!(e==null||!i)&&this.lastSeededTimes[t]===i.time&&de(e,i.value))return!0}return!1}advanceLiveTracking(t){if(t===this.lastRenderTime)return;const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=Zt(this.getCommonOptions().smoothMs,70),n=i>0?1e3/i:0;for(let r=0;r<this.stores.length;r++){const a=this.stores[r].last();if(!a){this.displayedLastValues[r]=null,this.lastSeededTimes[r]=Number.NaN;continue}const l=this.displayedLastValues[r],h=this.lastSeededTimes[r]!==a.time;if(l===null||h||n<=0){this.displayedLastValues[r]=a.value,this.lastSeededTimes[r]=a.time;continue}this.displayedLastValues[r]=Jt(l,a.value,n,e)}}entranceProgress(t,e,i){const n=Zt(this.getCommonOptions().entryMs,400);return cr(this.entries[t],e,i,n)}effectiveValue(t,e,i){const n=this.displayedLastValues[t];return n==null||this.lastSeededTimes[t]!==e?i:n}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var i;return((i=this.stores[0])==null?void 0:i.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const i=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const a=this.stores[r].getVisibleData(t-e,t+e);if(a.length===0)continue;let l=a[0],h=Math.abs(a[0].time-t);for(let d=1;d<a.length;d++){const c=Math.abs(a[d].time-t);c<=h&&(h=c,l=a[d])}n.push({layerIndex:r,time:l.time,value:l.value,color:i[r%i.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const a=(t=this.stores[0])==null?void 0:t.last();return a?{value:a.value,isLive:!0}:null}let e=-1/0;for(const a of this.stores){if(!a.isVisible())continue;const l=a.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const i=this.getCommonOptions().stacking;if(i==="off"){for(let a=this.stores.length-1;a>=0;a--){if(!this.stores[a].isVisible())continue;const l=this.stores[a].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const a of this.stores){if(!a.isVisible())continue;const l=a.last();n.push(l&&l.time===e?l.value:0)}const r=ur(n);return{value:i==="percent"?fr(r):dr(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();n&&e.push({layerIndex:i,time:n.time,value:n.value,color:t[i%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getValueRange(t,e){const i=this.getCommonOptions().stacking;if(i==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(i==="off"){let h=1/0,d=-1/0;for(const c of n)for(const u of c)Number.isFinite(u.value)&&(u.value<h&&(h=u.value),u.value>d&&(d=u.value));return h<1/0?{min:h,max:d}:null}const r=new Map;for(let h=0;h<n.length;h++)for(const d of n[h]){let c=r.get(d.time);c||(c=new Array(n.length).fill(0),r.set(d.time,c)),c[h]=Number.isFinite(d.value)?d.value:0}let a=0,l=0;for(const h of r.values()){let d=0,c=0;for(const u of h)u>0?d+=u:c+=u;d>l&&(l=d),c<a&&(a=c)}return l>a?{min:a,max:l}:null}}const mr={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function as(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class gr extends As{constructor(t,e){super(t),C(this,"options"),this.options={...mr,...as(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...as(t)}}getCommonOptions(){return this.options}createEntry(t,e,i){const n=this.options.entryAnimation??"fade-grow",r=Zt(this.options.entryMs,400);return n==="none"||r<=0?null:{startTime:i}}applyTheme(t,e){const i=e.seriesColors,n=this.options.colors.map((r,a)=>r===i[a]?t.seriesColors[a]??r:r);this.updateOptions({colors:n})}applyBarTransform(t,e,i,n,r,a){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:i,barHeight:n,x:r,barWidth:a,alpha:1};let h=i,d=n,c=r,u=1;if((l==="fade"||l==="fade-grow")&&(u=t),l==="grow"||l==="fade-grow"){const f=n*t;i<e?h=e-f:h=e,d=Math.max(1,f)}return l==="slide"&&(c=r+(1-t)*a,u=t),{topY:h,barHeight:d,x:c,barWidth:a,alpha:u}}render(t){switch(this.advanceLiveTracking(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:l}=e,h=i.getRange(),d=performance.now();let c=0;for(const w of this.stores){if(!w.isVisible())continue;const y=w.getVisibleData(h.from,h.to).length;if(y>c&&(c=y),c>2)break}const u=i.barWidthBitmap(r),f=Math.round(30*l),m=c<=2?Math.min(f,u):u,p=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),g=Math.floor(p/2),M=n.getRange().min<0,v=M?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const w=this.options.colors[0],y=this.options.colors.length>1?this.options.colors[1]:w,S=this.stores[0].getVisibleData(h.from,h.to);for(const x of S){if(!Number.isFinite(x.value))continue;const P=this.effectiveValue(0,x.time,x.value),b=this.entranceProgress(0,x.time,d),R=i.timeToBitmapX(x.time);if(P>=0){const L=n.valueToBitmapY(P),T=Math.max(1,v-L);this.drawAnimatedBar(a,b,v,L,T,R-g,p,P>=0?w:y)}else{const L=n.valueToBitmapY(P),T=Math.max(1,L-v);this.drawAnimatedBar(a,b,v,v,T,R-g,p,y)}}}else{const w=this.stores.map(S=>S.isVisible()?S.getVisibleData(h.from,h.to):[]),y=new Map;for(let S=0;S<w.length;S++)for(const x of w[S]){if(!Number.isFinite(x.value))continue;let P=y.get(x.time);P||(P=[],y.set(x.time,P)),P.push({layer:S,value:this.effectiveValue(S,x.time,x.value)})}for(const[S,x]of y){x.sort((b,R)=>Math.abs(R.value)-Math.abs(b.value));const P=i.timeToBitmapX(S);for(const{layer:b,value:R}of x){const L=this.options.colors[b%this.options.colors.length],T=this.entranceProgress(b,S,d);if(R>=0){const F=n.valueToBitmapY(R),W=Math.max(1,v-F);this.drawAnimatedBar(a,T,v,F,W,P-g,p,L)}else{const F=n.valueToBitmapY(R),W=Math.max(1,F-v);this.drawAnimatedBar(a,T,v,v,W,P-g,p,L)}}}}if(M){a.strokeStyle=t.theme.grid.color,a.lineWidth=1;const w=Math.round(v)+.5;a.beginPath(),a.moveTo(0,w),a.lineTo(e.bitmapSize.width,w),a.stroke()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r,dataInterval:a}=t,{context:l,horizontalPixelRatio:h}=i,d=n.getRange(),c=performance.now();let u=0;for(const y of this.stores){if(!y.isVisible())continue;const S=y.getVisibleData(d.from,d.to).length;if(S>u&&(u=S),u>2)break}const f=n.barWidthBitmap(a),m=Math.round(30*h),p=u<=2?Math.min(m,f):f,g=Math.max(1,Math.round(p*this.options.barWidthRatio)-2),M=Math.floor(g/2),v=this.stores.map(y=>y.isVisible()?y.getVisibleData(d.from,d.to):[]);if(v.every(y=>y.length===0))return;const w=new Map;for(let y=0;y<v.length;y++)for(const S of v[y]){let x=w.get(S.time);x||(x=new Array(v.length).fill(0),w.set(S.time,x));const P=Number.isFinite(S.value)?S.value:0;x[y]=this.stores[y].isVisible()?this.effectiveValue(y,S.time,P):0}for(let y=0;y<v.length;y++){const S=this.options.colors[y%this.options.colors.length];for(const[x,P]of w){const b=P[y];if(b===0)continue;const R=n.timeToBitmapX(x);let L=0,T=0;for(let W=0;W<y;W++){const V=P[W];V>0?L+=V:T+=V}const F=this.entranceProgress(y,x,c);if(e){let W=0,V=0;for(const D of P)D>0?W+=D:V+=D;if(b>0&&W>0){const D=L/W*100,j=(L+b)/W*100,H=r.valueToBitmapY(j),X=r.valueToBitmapY(D),it=Math.max(1,X-H);this.drawAnimatedBar(l,F,X,H,it,R-M,g,S)}else if(b<0&&V<0){const D=T/V*-100,j=(T+b)/V*-100,H=r.valueToBitmapY(D),X=r.valueToBitmapY(j),it=Math.max(1,X-H);this.drawAnimatedBar(l,F,H,H,it,R-M,g,S)}}else if(b>0){const W=r.valueToBitmapY(L+b),V=r.valueToBitmapY(L),D=Math.max(1,V-W);this.drawAnimatedBar(l,F,V,W,D,R-M,g,S)}else{const W=r.valueToBitmapY(T),V=r.valueToBitmapY(T+b),D=Math.max(1,V-W);this.drawAnimatedBar(l,F,W,W,D,R-M,g,S)}}}}fillBar(t,e,i,n,r,a){t.fillStyle=a,t.fillRect(e,i,n,r)}drawAnimatedBar(t,e,i,n,r,a,l,h){const d=this.options.entryAnimation??"fade-grow";if(e>=1||d==="none"){this.fillBar(t,a,n,l,r,h);return}const c=this.applyBarTransform(e,i,n,r,a,l);t.save(),t.globalAlpha=c.alpha,t.fillStyle=h,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function os(s,t){return s.length<=t?s:br(s,t,e=>e.time,e=>e.value)}function pr(s,t){if(s.length<=t)return s;const e=Math.ceil(s.length/t),i=[];for(let n=0;n<s.length;n+=e){const r=Math.min(n+e,s.length);let a=-1/0,l=1/0,h=0;for(let d=n;d<r;d++)s[d].high>a&&(a=s[d].high),s[d].low<l&&(l=s[d].low),h+=s[d].volume??0;i.push({time:s[n].time,open:s[n].open,high:a,low:l,close:s[r-1].close,volume:h})}return i}function br(s,t,e,i){if(t>=s.length||t<3)return s;const n=[s[0]],r=(s.length-2)/(t-2);let a=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*r)+1,d=Math.min(Math.floor((l+2)*r)+1,s.length-1);let c=0,u=0;const f=d,m=Math.min(Math.floor((l+3)*r)+1,s.length),p=m-f;if(p>0){for(let y=f;y<m;y++)c+=e(s[y]),u+=i(s[y]);c/=p,u/=p}let g=-1,M=h;const v=e(s[a]),w=i(s[a]);for(let y=h;y<d;y++){const S=Math.abs((v-c)*(i(s[y])-w)-(v-e(s[y]))*(u-w));S>g&&(g=S,M=y)}n.push(s[M]),a=M}return n.push(s[s.length-1]),n}function Yi(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.fontSize)!==void 0?s.axis.x.fontSize:t==="y"&&((i=s.axis.y)==null?void 0:i.fontSize)!==void 0?s.axis.y.fontSize:s.axis.fontSize}function ji(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.textColor)!==void 0?s.axis.x.textColor:t==="y"&&((i=s.axis.y)==null?void 0:i.textColor)!==void 0?s.axis.y.textColor:s.axis.textColor}function gt(s){return Array.isArray(s)?s.source??s[0]:s}const ls=new Map;function vr(s){return[parseInt(s.slice(1,3),16),parseInt(s.slice(3,5),16),parseInt(s.slice(5,7),16)]}function ye(s,t){if(s.startsWith("rgba"))return s.replace(/[\d.]+\)\s*$/,`${t})`);if(s.startsWith("rgb("))return s.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=s+t;let i=ls.get(e);if(i)return i;const[n,r,a]=vr(s);return i=`rgba(${n}, ${r}, ${a}, ${t})`,ls.set(e,i),i}const yr={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6};function hs(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class xr{constructor(t,e){C(this,"store"),C(this,"options"),C(this,"displayedLast",null),C(this,"lastSeededTime",Number.NaN),C(this,"lastRenderTime",0),C(this,"entries",new Map),this.store=t,this.options={...yr,...hs(e)}}updateOptions(t){this.options={...this.options,...hs(t)}}getColor(){return gt(this.options.up.body)}setData(t){this.store.setData(Jn(t??[])),this.entries.clear()}appendPoint(t){const e=t,i=ut(e.time);this.store.append({...e,time:i});const n=this.options.entryAnimation??"unfold",r=Zt(this.options.entryMs,400);n!=="none"&&r>0&&this.entries.set(i,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:ut(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[gt(this.options.up.body)]}applyTheme(t,e){this.updateOptions({up:{...t.candlestick.up},down:{...t.candlestick.down}})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners(),this.displayedLast=null,this.lastSeededTime=Number.NaN,this.lastRenderTime=0,this.entries.clear()}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}cancelEntranceAnimations(){this.entries.clear()}get needsAnimation(){if(this.entries.size>0)return!0;if(!this.displayedLast)return!1;const t=this.store.last();if(!t||t.time!==this.displayedLast.time)return!1;if(de(this.displayedLast.open,t.open)||de(this.displayedLast.high,t.high)||de(this.displayedLast.low,t.low)||de(this.displayedLast.close,t.close))return!0;const e=this.displayedLast.volume,i=t.volume;return e===void 0||i===void 0?!1:de(e,i)}entranceProgress(t,e){const i=this.entries.get(t);if(!i)return 1;const n=Zt(this.options.entryMs,400);if(n<=0)return this.entries.delete(t),1;const r=Se((e-i.startTime)/n,0,1),a=Ts(r);return r>=1&&this.entries.delete(t),a}advanceLiveTracking(t){const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=this.store.last();if(!i){this.displayedLast=null,this.lastSeededTime=Number.NaN;return}const n=this.lastSeededTime!==i.time,r=Zt(this.options.smoothMs,70),a=r>0?1e3/r:0;if(this.displayedLast===null||n||a<=0){this.displayedLast={...i},this.lastSeededTime=i.time;return}const l=this.displayedLast,h=l.volume??0,d=i.volume??0;this.displayedLast={time:i.time,open:Jt(l.open,i.open,a,e),high:Jt(l.high,i.high,a,e),low:Jt(l.low,i.low,a,e),close:Jt(l.close,i.close,a,e),volume:i.volume===void 0?void 0:Jt(h,d,a,e)}}render(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:l}=e,h=i.getRange(),d=performance.now();this.advanceLiveTracking(d);let c=this.store.getVisibleData(h.from,h.to);const u=e.mediaSize.width,f=c.length>u*2;if(f&&(c=pr(c,Math.round(u*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const R=c.length-1;c[R].time===this.displayedLast.time&&(c=[...c.slice(0,R),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const R of c)this.entries.has(R.time)&&m.set(R.time,this.entranceProgress(R.time,d));const p=i.barWidthBitmap(r),g=Math.round(30*l),M=c.length<=2?Math.min(g,p):p,v=Math.max(1,Math.round(l));let w=Math.max(1,Math.round(M*this.options.bodyWidthRatio)-2);(w&1)!==(v&1)&&(w=w>1?w-1:2);const y=Math.floor(w/2),S=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:a,data:c,timeScale:i,chartHeight:S,barWidth:M,wickWidth:v,entranceByTime:m});const x=[],P=[];for(const R of c)R.close>=R.open?x.push(R):P.push(R);const b={ctx:a,timeScale:i,yScale:n,halfBody:y,bodyWidth:w,wickWidth:v,entranceByTime:m};this.drawCandles({...b,candles:x,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...b,candles:P,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:i,chartHeight:n,barWidth:r,wickWidth:a,entranceByTime:l}){let h=0;for(const g of e)Number.isFinite(g.volume)&&g.volume>h&&(h=g.volume);if(h===0)return;const d=n*.2;let c=Math.max(1,r-2);(c&1)!==(a&1)&&(c=c>1?c-1:2);const u=Math.floor(c/2),f=ye(gt(this.options.up.body),.2),m=ye(gt(this.options.down.body),.2),p=this.options.entryAnimation??"unfold";for(const g of e){if(!Number.isFinite(g.volume)||g.volume<=0)continue;const M=g.volume,v=i.timeToBitmapX(g.time),w=Math.max(1,M/h*d),y=g.close>=g.open;t.fillStyle=y?f:m;const S=(l==null?void 0:l.get(g.time))??1;if(S>=1||p==="none"){t.fillRect(v-u,n-w,c,w);continue}const x=ki(S,p,{x:v-u,barWidth:c,anchorY:n,topY:n-w,bottomY:n});t.save(),t.globalAlpha=x.alpha,t.fillRect(x.x,x.topY,c,Math.max(1,x.bottomY-x.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:i,yScale:n,halfBody:r,bodyWidth:a,wickWidth:l,body:h,wickColor:d,entranceByTime:c}){if(e.length===0)return;const u=this.options.entryAnimation??"unfold",f=a+2;t.fillStyle=d;for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,M=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),w=n.valueToBitmapY(p.high),y=n.valueToBitmapY(p.low),S=M-Math.floor(l/2);if(g>=1||u==="none"){t.fillRect(S,w,l,y-w);continue}const x=ki(g,u,{x:S,barWidth:f,anchorY:v,topY:w,bottomY:y});t.save(),t.globalAlpha=x.alpha,t.fillRect(x.x,x.topY,l,Math.max(1,x.bottomY-x.topY)),t.restore()}const m=Array.isArray(h);for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,M=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),w=n.valueToBitmapY(p.close),y=Math.min(v,w),S=Math.max(v,w),x=Math.max(1,S-y),P=g<1&&u!=="none";let b=M-r,R=y,L=x,T=1;if(P){const F=ki(g,u,{x:M-r,barWidth:f,anchorY:v,topY:y,bottomY:S});b=F.x,R=F.topY,L=Math.max(1,F.bottomY-F.topY),T=F.alpha}if(P&&t.save(),m&&L>2){const F=t.createLinearGradient(0,R,0,R+L);F.addColorStop(0,h[0]),F.addColorStop(1,h[1]),t.fillStyle=F}else t.fillStyle=m?h[0]:h;P&&(t.globalAlpha=T),t.fillRect(b,R,a,L),P&&t.restore()}}}function ki(s,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:s};case"unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,s),bottomY:mt(e.anchorY,e.bottomY,s),alpha:1};case"slide":return{x:e.x+(1-s)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:s};case"fade-unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,s),bottomY:mt(e.anchorY,e.bottomY,s),alpha:s}}}const wr={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function cs(s){if(!s)return{};const t={...s};return s.areaFill!==void 0&&s.area===void 0&&(t.area={visible:!!s.areaFill}),s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class Sr extends As{constructor(t,e){super(t),C(this,"options"),C(this,"areaGradientCache",new Map),this.options={...wr,...cs(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...cs(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,i){var n;const r=this.options.entryAnimation??"grow",a=Zt(this.options.entryMs,400);if(r==="none"||a<=0)return null;const l=(n=this.stores[t])==null?void 0:n.last();return{startTime:i,fromTime:l?l.time:e}}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)}),this.options.strokeWidth===e.line.width&&this.updateOptions({strokeWidth:t.line.width})}peekEntry(t,e){var i;return(i=this.entries[t])==null?void 0:i.get(e)}resolvedPulseMs(){return Zt(this.options.pulseMs,600)}get hasPulse(){return this.options.pulse&&this.resolvedPulseMs()>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();if(n&&n.time>=t)return!0}return!1}render(t){this.advanceLiveTracking(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e,i,n){const r=this.stores[t],a=r.last();if(!a)return null;const l=e.timeToBitmapX(a.time),h=i.valueToBitmapY(this.effectiveValue(t,a.time,a.value)),d=this.options.entryAnimation??"grow";if(!this.peekEntry(t,a.time)||d!=="grow")return{x:l,y:h};const c=this.entranceProgress(t,a.time,n);if(c>=1)return{x:l,y:h};const u=r.getAll();if(u.length<2)return{x:l,y:h};const f=u[u.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=e.timeToBitmapX(f.time),p=i.valueToBitmapY(f.value);return{x:mt(m,l,c),y:mt(p,h,c)}}renderOff(t){var e;const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,l=n.getRange(),{verticalPixelRatio:h}=i,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=performance.now(),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){if(!this.stores[m].isVisible())continue;let p=this.stores[m].getVisibleData(l.from,l.to);const g=i.mediaSize.width;if(p.length>g*2&&(p=os(p,Math.round(g*1.5))),p.length<2)continue;const M=this.options.colors[m%this.options.colors.length],v=p[p.length-1],w=this.peekEntry(m,v.time),y=this.entranceProgress(m,v.time,u),S=w&&f==="fade"&&y<1,x=this.trailingEndpoint(m,n,r,u)??{x:n.timeToBitmapX(v.time),y:r.valueToBitmapY(this.effectiveValue(m,v.time,v.value))},P=x.x,b=x.y;S&&(a.save(),a.globalAlpha=y);const R=p.length-1,L=[];let T=null;for(let W=0;W<R;W++){const V=p[W].value;if(!Number.isFinite(V)){T=null;continue}T||(T=[],L.push(T)),T.push({x:n.timeToBitmapX(p[W].time),y:r.valueToBitmapY(V)})}const F=(e=p[R])==null?void 0:e.value;if(Number.isFinite(P)&&Number.isFinite(b)&&Number.isFinite(F)&&(T?T.push({x:P,y:b}):L.push([{x:P,y:b}])),d&&L.some(W=>W.length>=2)){a.beginPath();for(const W of L)if(!(W.length<2)){a.moveTo(W[0].x,W[0].y);for(let V=1;V<W.length;V++)a.lineTo(W[V].x,W[V].y)}a.strokeStyle=M,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}if(d){const W=Math.max(1,c/2);let V=!1;for(const D of L)D.length===1&&(V||(a.beginPath(),V=!0),a.moveTo(D[0].x+W,D[0].y),a.arc(D[0].x,D[0].y,W,0,Math.PI*2));V&&(a.fillStyle=M,a.fill())}if(this.options.area.visible){const W=i.bitmapSize.height,V=String(m),D=this.areaGradientCache.get(V);let j;D&&D.bottomY===W&&D.color===M?j=D.gradient:(j=a.createLinearGradient(0,0,0,W),j.addColorStop(0,ye(M,.12)),j.addColorStop(1,ye(M,.01)),this.areaGradientCache.set(V,{gradient:j,bottomY:W,color:M})),a.fillStyle=j;for(const H of L)if(!(H.length<2)){a.beginPath(),a.moveTo(H[0].x,H[0].y);for(let X=1;X<H.length;X++)a.lineTo(H[X].x,H[X].y);a.lineTo(H[H.length-1].x,W),a.lineTo(H[0].x,W),a.closePath(),a.fill()}}S&&a.restore()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,l=n.getRange(),{verticalPixelRatio:h}=i,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=i.mediaSize.width,f=this.stores.map(b=>{let R=b.getVisibleData(l.from,l.to);return R.length>u*2&&(R=os(R,Math.round(u*1.5))),R}),m=new Set;for(const b of f)for(const R of b)m.add(R.time);const p=Array.from(m).sort((b,R)=>b-R);if(p.length<2)return;const g=f.map((b,R)=>{const L=new Map;for(const T of b)L.set(T.time,this.effectiveValue(R,T.time,T.value));return L}),M=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let b=0;b<p.length;b++){const R=p[b];let L=0;if(e)for(let F=0;F<this.stores.length;F++){if(!this.stores[F].isVisible())continue;const W=g[F].get(R);Number.isFinite(W)&&(L+=W)}let T=0;for(let F=0;F<this.stores.length;F++){const W=this.stores[F].isVisible()?g[F].get(R):0,V=Number.isFinite(W)?W:0;T+=e&&L>0?V/L*100:V,M[F][b]=T}}const v=performance.now(),w=this.options.entryAnimation??"grow",y=new Map;for(let b=0;b<p.length;b++)y.set(p[b],b);const S=p.length-1,x=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const R=this.stores[b].last();if(!R)continue;const L=this.peekEntry(b,R.time);if(!L)continue;const T=y.get(R.time);T!==S||y.get(L.fromTime)!==T-1||(x[b]=this.entranceProgress(b,R.time,v))}const P=(b,R)=>{if(R>=1||b.length<2)return;const L=b.length-1,T=b[L-1],F=b[L];b[L]=[mt(T[0],F[0],R),mt(T[1],F[1],R)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const R=this.options.colors[b%this.options.colors.length],L=x[b],T=b>0&&this.stores[b-1].isVisible()?x[b-1]:1,F=[];for(let D=0;D<p.length;D++)F.push([n.timeToBitmapX(p[D]),r.valueToBitmapY(M[b][D])]);w==="grow"&&P(F,L);const W=[];for(let D=0;D<p.length;D++){const j=b>0?M[b-1][D]:0;W.push([n.timeToBitmapX(p[D]),r.valueToBitmapY(j)])}w==="grow"&&P(W,T);const V=w==="fade"&&L<1;if(V&&(a.save(),a.globalAlpha=L),this.options.area.visible){a.beginPath(),a.moveTo(F[0][0],F[0][1]);for(let D=1;D<F.length;D++)a.lineTo(F[D][0],F[D][1]);for(let D=W.length-1;D>=0;D--)a.lineTo(W[D][0],W[D][1]);a.closePath(),a.fillStyle=ye(R,.25),a.fill()}if(d){a.beginPath(),a.moveTo(F[0][0],F[0][1]);for(let D=1;D<F.length;D++)a.lineTo(F[D][0],F[D][1]);a.strokeStyle=R,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}V&&a.restore()}}drawOverlay(t){const{scope:e,timeScale:i,yScale:n,crosshair:r,dataInterval:a}=t,l=e,h=this.resolvedPulseMs();if(r){const d=this.options.colors,c=this.options.stacking,u=4*l.horizontalPixelRatio,f=[],m=[];for(let g=0;g<this.stores.length;g++){const M=this.stores[g].findNearest(r.time,a);M?(f.push(M.value),m.push(M.time)):(f.push(0),m.push(null))}const p=[];if(c==="off")for(const g of f)p.push(g);else{let g=0;if(c==="percent")for(let v=0;v<f.length;v++)this.stores[v].isVisible()&&(g+=f[v]);let M=0;for(let v=0;v<f.length;v++){const w=this.stores[v].isVisible()?f[v]:0;M+=c==="percent"&&g>0?w/g*100:w,p.push(M)}}for(let g=0;g<this.stores.length;g++){const M=m[g];if(M===null||!this.stores[g].isVisible())continue;const v=d[g%d.length],w=i.timeToBitmapX(M),y=n.valueToBitmapY(p[g]);e.context.beginPath(),e.context.arc(w,y,u+3*l.horizontalPixelRatio,0,Math.PI*2);const S=v.startsWith("#")?v+"40":/^rgb\(/i.test(v)?v.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):v.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=S,e.context.fill(),e.context.beginPath(),e.context.arc(w,y,u,0,Math.PI*2),e.context.fillStyle=v,e.context.fill()}}if(this.hasPulse&&h>0){const d=performance.now();this.advanceLiveTracking(d);const c=this.options.stacking;for(let u=0;u<this.stores.length;u++){if(!this.stores[u].isVisible())continue;const f=this.options.colors[u%this.options.colors.length];if(c==="off"){const x=this.trailingEndpoint(u,i,n,d);if(!x)continue;this.drawPulse({ctx:e.context,x:x.x,y:x.y,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h});continue}const m=this.stores[u].last();if(!m)continue;const p=m.time,g=c==="percent",M=x=>{const P=L=>{const T=L===u&&x===p?m:this.stores[L].findNearest(x,0);return!T||T.time!==x?0:this.effectiveValue(L,x,T.value)};let b=0;if(g)for(let L=0;L<this.stores.length;L++)this.stores[L].isVisible()&&(b+=P(L));let R=0;for(let L=0;L<=u;L++){if(!this.stores[L].isVisible())continue;const T=P(L);R+=g&&b>0?T/b*100:T}return R};let v=i.timeToBitmapX(p),w=n.valueToBitmapY(M(p));const y=this.options.entryAnimation??"grow",S=this.peekEntry(u,p);if(y==="grow"&&S){const x=this.entranceProgress(u,p,d);if(x<1&&S.fromTime!==p){const P=i.timeToBitmapX(S.fromTime),b=n.valueToBitmapY(M(S.fromTime));v=mt(P,v,x),w=mt(b,w,x)}}this.drawPulse({ctx:e.context,x:v,y:w,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h})}}}drawPulse({ctx:t,x:e,y:i,color:n,pixelRatio:r,pulseMs:a}){const l=3*r,h=.4+.6*Math.abs(Math.sin(performance.now()/a)),d=l+4*r*h;t.beginPath(),t.arc(e,i,d,0,Math.PI*2),t.fillStyle=ye(n,h*.3),t.fill(),t.beginPath(),t.arc(e,i,l,0,Math.PI*2),t.fillStyle=n,t.fill()}}const zs={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},Mr={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...zs},animate:!1},Li=Math.PI/180;function kr(s,t){return{...s??{},...t}}function Cr(s){return{...zs,...s??{}}}function Tr(s){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return s===!0||s===!1?t:{...t,...s}}function Rr(s){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return s===!0||s===!1?t:{...t,...s}}const xe=Math.PI*2,Ds=.85;function us(s){const{bitmapWidth:t,bitmapHeight:e,padTop:i,padBottom:n}=s,r=Math.max(0,s.labelReserve??0),a=Math.min(Math.max(0,i),e),l=Math.min(Math.max(0,n),e-a),h=e-a-l,d=Math.max(0,t-2*r),c=t/2,u=a+h/2,f=Math.max(0,Math.min(d,h)/2*Ds);return{cx:c,cy:u,maxR:f}}function Lr(s){if(!s.startsWith("#"))return!1;const t=parseInt(s.slice(1,3),16),e=parseInt(s.slice(3,5),16),i=parseInt(s.slice(5,7),16);return t*.299+e*.587+i*.114>150}function Ir(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,parseInt(s.slice(1,3),16)+Math.round(255*t)),i=Math.min(255,parseInt(s.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(s.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function ds(s){if(s.startsWith("#"))return{r:parseInt(s.slice(1,3),16)||0,g:parseInt(s.slice(3,5),16)||0,b:parseInt(s.slice(5,7),16)||0,a:1};const t=s.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(i=>i.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function Br(s,t){const e=ds(s),i=ds(t),n=i.a,r=Math.round(i.r*n+e.r*(1-n)),a=Math.round(i.g*n+e.g*(1-n)),l=Math.round(i.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var _,G,Mt,at,fe,Xt,yt,ie,Tt,Ii,ii,Es,Vs,Ys;class si{constructor(t){A(this,Tt),A(this,_,[]),A(this,G),A(this,Mt,-1),A(this,at,[]),A(this,fe,0),A(this,Xt,1),A(this,yt,null),A(this,ie,[]),I(this,G,z(this,Tt,Ii).call(this,Mr,t??{}))}getData(){return o(this,_)}setData(t){const e=t??[];I(this,_,e),I(this,at,new Array(e.length).fill(0)),I(this,Xt,o(this,G).animate?0:1),I(this,yt,null);for(const i of o(this,ie))i()}onDataChanged(t){return o(this,ie).push(t),()=>{const e=o(this,ie).indexOf(t);e>=0&&o(this,ie).splice(e,1)}}updateOptions(t){var e,i;const n=(e=o(this,G).sliceLabels)==null?void 0:e.mode;I(this,G,z(this,Tt,Ii).call(this,o(this,G),t??{})),((i=o(this,G).sliceLabels)==null?void 0:i.mode)==="outside"&&n!=="outside"&&I(this,Xt,o(this,G).animate?0:1),I(this,yt,null)}getColor(){var t,e;return((t=o(this,_)[0])==null?void 0:t.color)??((e=o(this,G).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&I(this,yt,null)}hitTest(t,e,i,n,r){var a;if(o(this,_).length===0)return-1;const l=o(this,_).reduce((y,S)=>y+S.value,0);if(l<=0)return-1;const h=((a=o(this,yt))==null?void 0:a.reserve)??0,{cx:d,cy:c,maxR:u}=us({bitmapWidth:i,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:h}),f=u,m=f*o(this,G).innerRadiusRatio,p=t-d,g=e-c,M=Math.sqrt(p*p+g*g);if(M>f||M<m)return-1;let v=Math.atan2(g,p)+Math.PI/2;v<0&&(v+=xe);let w=0;for(let y=0;y<o(this,_).length;y++){const S=o(this,_)[y].value/l*xe;if(v>=w&&v<w+S)return y;w+=S}return-1}setHoverIndex(t){return o(this,Mt)===t?!1:(I(this,Mt,t),!0)}getHoverIndex(){return o(this,Mt)}getHoverInfo(t){if(o(this,Mt)<0)return null;const e=o(this,_)[o(this,Mt)];if(!e)return null;const i=o(this,_).reduce((r,a)=>r+a.value,0),n=o(this,G).colors??t.seriesColors;return{label:e.label,value:e.value,percent:i>0?e.value/i*100:0,color:e.color??n[o(this,Mt)%n.length]}}getSliceInfo(t){if(o(this,_).length===0)return null;const e=o(this,_).reduce((n,r)=>n+r.value,0),i=o(this,G).colors??t.seriesColors;return o(this,_).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??i[r%i.length]}))}get needsAnimation(){var t;if(!o(this,G).animate)return!1;for(let e=0;e<o(this,at).length;e++){const i=e===o(this,Mt)?1:0;if(Math.abs(o(this,at)[e]-i)>.01)return!0}return((t=o(this,G).sliceLabels)==null?void 0:t.mode)==="outside"&&o(this,Xt)<.99}dispose(){I(this,ie,[]),I(this,_,[]),I(this,at,[]),I(this,fe,0)}_inspectSliceOffsets(){return o(this,at)}render(t){if(o(this,_).length===0)return;const{scope:e,theme:i,padding:n}=t,{context:r,bitmapSize:a,horizontalPixelRatio:l,verticalPixelRatio:h}=e,d=performance.now(),c=o(this,fe)?Math.min(.05,(d-o(this,fe))/1e3):0;I(this,fe,d);const u=o(this,_).reduce((j,H)=>j+H.value,0);if(u<=0)return;const f=12;for(;o(this,at).length<o(this,_).length;)o(this,at).push(0);if(o(this,G).animate)for(let j=0;j<o(this,_).length;j++){const H=j===o(this,Mt)?1:0;o(this,at)[j]=Jt(o(this,at)[j],H,f,c)}const m=Cr(o(this,G).sliceLabels);r.font=`${m.fontSize*l}px ${i.typography.fontFamily}`,m.mode==="outside"&&o(this,G).animate&&I(this,Xt,Jt(o(this,Xt),1,6,c));const p=o(this,G).colors??i.seriesColors,g=m.mode==="outside"?z(this,Tt,Es).call(this,r,m,u,l):0,{cx:M,cy:v,maxR:w}=us({bitmapWidth:a.width,bitmapHeight:a.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:g}),y=w,S=y*o(this,G).innerRadiusRatio,x=o(this,G).padAngle*Li,P=8*l,b=o(this,G).shadow??!1,R=Tr(b),L=o(this,G).innerShadow??!1,T=Rr(L);let F=-Math.PI/2;for(let j=0;j<o(this,_).length;j++){const H=o(this,_)[j],X=H.value/u*xe,it=F+x/2,U=F+X-x/2,xt=F+X/2,lt=H.color??p[j%p.length];if(U<=it){F+=X;continue}const It=o(this,at)[j]*P,Q=Math.cos(xt)*It,Ot=Math.sin(xt)*It,pt=M+Q,dt=v+Ot;r.beginPath(),r.arc(pt,dt,y,it,U),S>0?r.arc(pt,dt,S,U,it,!0):r.lineTo(pt,dt),r.closePath();const ht=r.createRadialGradient(pt,dt,S||0,pt,dt,y);if(ht.addColorStop(0,Ir(lt,.15)),L){const wt=Math.max(0,Math.min(.999,1-T.depth));ht.addColorStop(wt,lt),ht.addColorStop(1,Br(lt,T.color))}else ht.addColorStop(1,lt);r.fillStyle=ht;const Bt=o(this,at)[j];if(b||Bt>.01){const wt=b?1:0,Ht=Bt;r.shadowColor=b?R.color:"rgba(0,0,0,0.25)",r.shadowBlur=(R.blur*wt+12*Ht)*l,r.shadowOffsetX=R.offsetX*wt*l+Q*.3*Ht,r.shadowOffsetY=R.offsetY*wt*h+Ot*.3*Ht}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,F+=X}if(m.mode==="none")return;F=-Math.PI/2;const W=i.tooltip.textColor;if(m.mode==="outside"){const j=z(this,Tt,Ys).call(this,{cx:M,cy:v,outerR:y,total:u,palette:p,labels:m,hpr:l,bitmapHeight:a.height}),H=j.length>1?Math.min(.06,.9/(j.length-1)):0;for(let X=0;X<j.length;X++){const it=j[X];if(it===null)continue;const U=X*H,xt=Se((o(this,Xt)-U)/(1-U),0,1);z(this,Tt,Vs).call(this,{context:r,entry:it,textColor:W,labels:m,hpr:l,progress:xt})}return}const V=S>0?(y+S)/2:y*.65;r.textAlign="center",r.textBaseline="middle";const D=m.minSliceAngle*Li;for(let j=0;j<o(this,_).length;j++){const H=o(this,_)[j],X=H.value/u*xe;if(X>=D){const it=F+X/2,U=o(this,at)[j]*P,xt=H.color??p[j%p.length],lt=z(this,Tt,ii).call(this,H,u,m.content),It=r.measureText(lt).width,Q=m.fontSize*1.2*l,Ot=X<Math.PI?2*V*Math.sin(X/2):2*V,pt=It>Ot-4*l,dt=S>0&&V-S<Q;if(!pt&&!dt){const ht=M+Math.cos(it)*(V+U),Bt=v+Math.sin(it)*(V+U);r.fillStyle=Lr(xt)?"#000000":"#ffffff",r.fillText(lt,ht,Bt)}}F+=X}}}_=new WeakMap,G=new WeakMap,Mt=new WeakMap,at=new WeakMap,fe=new WeakMap,Xt=new WeakMap,yt=new WeakMap,ie=new WeakMap,Tt=new WeakSet,Ii=function(s,t){const e={...s,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=kr(s.sliceLabels,t.sliceLabels)),e},ii=function(s,t,e){const i=t>0?s.value/t*100:0,n=`${i.toFixed(i>=10?0:1)}%`;return e==="percent"?n:e==="label"?s.label:`${s.label} ${n}`},Es=function(s,t,e,i){const n=s.font;if(o(this,yt)&&o(this,yt).fontScale===i&&o(this,yt).font===n)return o(this,yt).reserve;let r=0;for(const h of o(this,_)){const d=z(this,Tt,ii).call(this,h,e,t.content),c=s.measureText(d).width;c>r&&(r=c)}const a=Math.max(t.distance,t.elbowLen),l=(r+(a+Math.max(0,t.railWidth)+t.legPad+4)*i)/Ds;return I(this,yt,{fontScale:i,font:n,reserve:l}),l},Vs=function(s){const{context:t,entry:e,textColor:i,labels:n,hpr:r,progress:a}=s;if(a<=0)return;const{anchorX:l,anchorY:h,elbowX:d,elbowY:c,side:u,text:f,color:m,labelX:p,labelY:g}=e,M=p+u*n.legPad*r,v=Se(a/.15,0,1),w=Se((a-.15)/.45,0,1),y=Se((a-.6)/.4,0,1);if(t.save(),t.globalAlpha=v,t.fillStyle=m,t.beginPath(),t.arc(l,h,2.5*r,0,xe),t.fill(),t.restore(),w>0){t.save(),t.globalAlpha=w,t.strokeStyle=m,t.lineWidth=1*r,t.lineCap="round",t.beginPath(),t.moveTo(l,h);const S=l+(d-l)*w,x=h+(c-h)*w;if(t.lineTo(S,x),y>0){const P=d+(p-d)*y,b=c+(g-c)*y;t.lineTo(P,b)}t.stroke(),t.restore()}y>0&&(t.save(),t.globalAlpha=y,t.fillStyle=i,t.textAlign=u>=0?"left":"right",t.textBaseline="middle",t.fillText(f,M,g),t.restore())},Ys=function(s){const{cx:t,cy:e,outerR:i,total:n,palette:r,labels:a,hpr:l,bitmapHeight:h}=s,d=new Array(o(this,_).length).fill(null),c=a.elbowLen*l,u=Math.max(a.distance,a.elbowLen)*l,f=Math.max(0,a.railWidth)*l,m=[];let p=-Math.PI/2;const g=a.minSliceAngle*Li;for(let y=0;y<o(this,_).length;y++){const S=o(this,_)[y],x=S.value/n*xe;if(x>=g){const P=p+x/2,b=o(this,at)[y]*(8*l),R=Math.cos(P),L=Math.sin(P),T=R>=0?1:-1,F=t+R*(i+b),W=e+L*(i+b),V=t+R*(i+b+c),D=e+L*(i+b+c),j=t+R*(i+b+u)+T*f,H=e+L*(i+b+u),X={anchorX:F,anchorY:W,elbowX:V,elbowY:D,side:T,labelX:j,labelY:H,text:z(this,Tt,ii).call(this,S,n,a.content),color:S.color??r[y%r.length]};d[y]=X,m.push({entry:X})}p+=x}const M=Math.max(1,a.fontSize*a.labelGap)*l,v=a.fontSize*l,w=h-a.fontSize*l;for(const y of[1,-1]){const S=[];for(const b of m)b.entry.side===y&&S.push(b.entry);if(S.length===0)continue;S.sort((b,R)=>b.labelY-R.labelY);const x=[];for(let b=0;b<S.length;b++)for(x.push({count:1,sumIdeal:S[b].labelY,startIdx:b});x.length>=2;){const R=x[x.length-2],L=x[x.length-1],T=R.sumIdeal/R.count,F=L.sumIdeal/L.count,W=T+(R.count-1)*M/2;if(F-(L.count-1)*M/2>=W+M)break;R.count+=L.count,R.sumIdeal+=L.sumIdeal,x.pop()}if(x.length>0){const b=x[0],R=b.sumIdeal/b.count-(b.count-1)*M/2;if(R<v)for(b.sumIdeal+=(v-R)*b.count;x.length>=2;){const L=x[0],T=x[1],F=L.sumIdeal/L.count,W=T.sumIdeal/T.count,V=F+(L.count-1)*M/2;if(W-(T.count-1)*M/2>=V+M)break;L.count+=T.count,L.sumIdeal+=T.sumIdeal,x.splice(1,1)}}if(x.length>0){const b=x[x.length-1],R=b.sumIdeal/b.count+(b.count-1)*M/2;if(R>w)for(b.sumIdeal-=(R-w)*b.count;x.length>=2;){const L=x[x.length-2],T=x[x.length-1],F=L.sumIdeal/L.count,W=T.sumIdeal/T.count,V=F+(L.count-1)*M/2;if(W-(T.count-1)*M/2>=V+M)break;L.count+=T.count,L.sumIdeal+=T.sumIdeal,x.pop()}}const P=(v+w)/2;for(const b of x){const R=(b.count-1)*M,L=b.sumIdeal/b.count;R>w-v&&L-R/2<v&&(b.sumIdeal=P*b.count)}for(const b of x){const R=b.sumIdeal/b.count;for(let L=0;L<b.count;L++)S[b.startIdx+L].labelY=R+(L-(b.count-1)/2)*M}}for(const y of m){const S=y.entry,x=S.labelY-S.anchorY;let P;if(Math.abs(x)<=c){const L=S.side*Math.sqrt(Math.max(0,c*c-x*x));P=S.anchorX+L}else P=(S.anchorX+S.labelX)/2;const b=Math.min(S.anchorX,S.labelX),R=Math.max(S.anchorX,S.labelX);S.elbowX=Math.max(b,Math.min(R,P)),S.elbowY=S.labelY}return d};function Pr(s){return parseInt(s.slice(1,3),16)*.299+parseInt(s.slice(3,5),16)*.587+parseInt(s.slice(5,7),16)*.114<128}function J(s){var t,e,i,n,r,a,l,h,d,c,u,f,m,p,g,M,v,w,y,S,x,P,b,R,L,T,F,W,V,D,j,H,X,it;const{background:U,name:xt="Custom",description:lt,fontUrl:It=null}=s,Q=Pr(U),Ot=Q?"#d1d4dc":"#24292f",pt=Q?"#787b86":"#8b949e",dt=Q?"#26a69a":"#2da44e",ht=Q?"#ef5350":"#cf222e",Bt=Q?"#2962ff":"#0969da",wt=Q?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",Ht=Q?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Me=Q?Be(U,.1):Bi(U,.05),Qe=Q?me(U,.92):me(U,.95),nt=Q?me(Be(U,.15),.6):"rgba(200,200,200,0.5)",St=gi,$t=((e=(t=s.candlestick)==null?void 0:t.up)==null?void 0:e.body)??dt,bi=((n=(i=s.candlestick)==null?void 0:i.down)==null?void 0:n.body)??ht,vi=gt($t),Ze=gt(bi),ke=((r=s.line)==null?void 0:r.color)??Bt,Gi=((a=s.tooltip)==null?void 0:a.textColor)??Ot,Ki=((l=s.axis)==null?void 0:l.textColor)??pt,vn=((h=s.typography)==null?void 0:h.fontFamily)??St,qi=((d=s.typography)==null?void 0:d.fontSize)??12,yn=s.chartGradient??(Q?[Be(U,.04),Bi(U,.06)]:[Be(U,.06),U]),xn={background:U,chartGradient:yn,typography:{fontFamily:vn,fontSize:qi},grid:{color:((c=s.grid)==null?void 0:c.color)??wt,style:((u=s.grid)==null?void 0:u.style)??"dashed"},candlestick:{up:{body:$t,wick:((m=(f=s.candlestick)==null?void 0:f.up)==null?void 0:m.wick)??vi},down:{body:bi,wick:((g=(p=s.candlestick)==null?void 0:p.down)==null?void 0:g.wick)??Ze}},line:{color:ke,width:((M=s.line)==null?void 0:M.width)??1,areaTopColor:((v=s.line)==null?void 0:v.areaTopColor)??me(ke,.08),areaBottomColor:((w=s.line)==null?void 0:w.areaBottomColor)??me(ke,.01)},seriesColors:s.seriesColors??[ke,dt,ht],bands:{upper:((y=s.bands)==null?void 0:y.upper)??ke,lower:((S=s.bands)==null?void 0:S.lower)??Ze},crosshair:{color:((x=s.crosshair)==null?void 0:x.color)??Ht,labelBackground:((P=s.crosshair)==null?void 0:P.labelBackground)??Me,labelTextColor:((b=s.crosshair)==null?void 0:b.labelTextColor)??Gi},axis:{fontSize:((R=s.axis)==null?void 0:R.fontSize)??10,textColor:Ki,...(L=s.axis)!=null&&L.x?{x:{...s.axis.x}}:{},...(T=s.axis)!=null&&T.y?{y:{...s.axis.y}}:{}},yLabel:{fontSize:((F=s.yLabel)==null?void 0:F.fontSize)??11,upBackground:((W=s.yLabel)==null?void 0:W.upBackground)??vi,downBackground:((V=s.yLabel)==null?void 0:V.downBackground)??Ze,neutralBackground:((D=s.yLabel)==null?void 0:D.neutralBackground)??Me,textColor:((j=s.yLabel)==null?void 0:j.textColor)??"#ffffff"},tooltip:{fontSize:((H=s.tooltip)==null?void 0:H.fontSize)??qi,background:((X=s.tooltip)==null?void 0:X.background)??Qe,textColor:Gi,borderColor:((it=s.tooltip)==null?void 0:it.borderColor)??nt},navigator:Fr({dark:Q,bg:U,neutralFg:Ki,upBody:$t,downBody:bi,upBase:vi,downBase:Ze,config:s.navigator})};return{name:xt,description:lt,fontUrl:It,dark:Q,theme:xn}}function Fr(s){var t,e,i,n,r,a,l,h,d,c,u,f,m,p,g,M,v,w;const{dark:y,bg:S,neutralFg:x,upBody:P,downBody:b,upBase:R,downBase:L,config:T}=s,F=(T==null?void 0:T.background)??"transparent",W=y?"rgba(255,255,255,1)":"rgba(0,0,0,1)",V=((t=T==null?void 0:T.handle)==null?void 0:t.color)??Ce(W,.3),D=((e=T==null?void 0:T.mask)==null?void 0:e.fill)??Ce(S,y?.78:.82);return{height:(T==null?void 0:T.height)??48,background:F,borderColor:(T==null?void 0:T.borderColor)??Ce(x,y?.18:.22),line:{color:((i=T==null?void 0:T.line)==null?void 0:i.color)??x,width:((n=T==null?void 0:T.line)==null?void 0:n.width)??1,areaTopColor:((r=T==null?void 0:T.line)==null?void 0:r.areaTopColor)??Ce(x,y?.22:.18),areaBottomColor:((a=T==null?void 0:T.line)==null?void 0:a.areaBottomColor)??Ce(x,0)},candlestick:{up:{body:((h=(l=T==null?void 0:T.candlestick)==null?void 0:l.up)==null?void 0:h.body)??P,wick:((c=(d=T==null?void 0:T.candlestick)==null?void 0:d.up)==null?void 0:c.wick)??R},down:{body:((f=(u=T==null?void 0:T.candlestick)==null?void 0:u.down)==null?void 0:f.body)??b,wick:((p=(m=T==null?void 0:T.candlestick)==null?void 0:m.down)==null?void 0:p.wick)??L}},window:{fill:((g=T==null?void 0:T.window)==null?void 0:g.fill)??"transparent",border:((M=T==null?void 0:T.window)==null?void 0:M.border)??"transparent",borderWidth:((v=T==null?void 0:T.window)==null?void 0:v.borderWidth)??0},handle:{color:V,width:((w=T==null?void 0:T.handle)==null?void 0:w.width)??6},mask:{fill:D}}}function Ce(s,t){if(s.startsWith("#")&&s.length===7)return me(s,t);const e=s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:s}function me(s,t){const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function Be(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,Math.round(parseInt(s.slice(1,3),16)+255*t)),i=Math.min(255,Math.round(parseInt(s.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(s.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Bi(s,t){if(!s.startsWith("#"))return s;const e=Math.max(0,Math.round(parseInt(s.slice(1,3),16)*(1-t))),i=Math.max(0,Math.round(parseInt(s.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(s.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function E(s){const t=s.startsWith("#")&&s.length===7?[Be(s,.2),Bi(s,.15)]:[s,s];return Object.defineProperty(t,"source",{value:s,enumerable:!1}),t}const fi="'JetBrains Mono', 'Fira Code', monospace",mi="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",gi="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Oi="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",js="'Roboto Mono', monospace",Os="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Wr="'IBM Plex Mono', monospace",Ar="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Hi="'Fira Code', monospace",$i="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",Hs="'Source Code Pro', monospace",$s="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",zr="'Space Mono', monospace",Dr="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",Ni="'Plus Jakarta Sans', sans-serif",Xi="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",Er="'Caveat', 'Comic Sans MS', cursive",Vr="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Ns={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"},navigator:{height:48,background:"transparent",borderColor:"rgba(120, 123, 134, 0.18)",line:{color:"#787b86",width:1,areaTopColor:"rgba(120, 123, 134, 0.22)",areaBottomColor:"rgba(120, 123, 134, 0)"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(255, 255, 255, 0.30)",width:6},mask:{fill:"rgba(19, 23, 34, 0.78)"}}},Nt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},Yr=.1,jr=.3,Or=.4,Hr=.5,$r=4;var _t,st;class Nr extends Ue{constructor({padding:t,reboundMs:e}={}){super(),C(this,"_visibleRange",{from:0,to:0}),C(this,"_yRange",{min:0,max:0}),C(this,"_autoScroll",!0),C(this,"padding"),C(this,"reboundMs"),C(this,"dataInterval",6e4),A(this,_t,null),A(this,st,null),C(this,"_prevDataEnd",null),C(this,"_animating",!1),C(this,"animStartTime",0),C(this,"animDuration",0),C(this,"animFrom",{from:0,to:0}),C(this,"animTo",{from:0,to:0}),C(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??Nt.top,bottom:(t==null?void 0:t.bottom)??Nt.bottom,right:(t==null?void 0:t.right)??Nt.right,left:(t==null?void 0:t.left)??Nt.left},this.reboundMs=e??350}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,i){return typeof t=="object"?t.intervals*this.dataInterval:i<=0?0:t/i*e}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}get dataStart(){return o(this,_t)}get dataEnd(){return o(this,st)}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??Nt.top,bottom:(t==null?void 0:t.bottom)??Nt.bottom,right:(t==null?void 0:t.right)??Nt.right,left:(t==null?void 0:t.left)??Nt.left}}getPadding(){return this.padding}setDataStart(t){I(this,_t,t)}setDataEnd(t){this._prevDataEnd=o(this,st),I(this,st,t)}cancelAnimation(){this._animating=!1}getSoftBounds(t,e){const i=a=>typeof a=="object"||a===0||e>0,n=o(this,_t)!==null&&i(this.padding.left)?o(this,_t)-this.resolveHPad(this.padding.left,t,e):null,r=o(this,st)!==null&&i(this.padding.right)?o(this,st)+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}softMaxRange(){if(o(this,_t)===null||o(this,st)===null)return null;const t=o(this,st)-o(this,_t);if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,i=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||i!==null?t+(e??0)+(i??0):t+this.dataInterval*5}setRange(t){const{from:e,to:i}=t;if(!Number.isFinite(e)||!Number.isFinite(i)||i<=e||(i-e)/this.dataInterval<2)return;this.cancelAnimation();const n=o(this,st)!==null&&o(this,st)>=e&&o(this,st)<=i;this._autoScroll=n,this.applyRange(e,i)}applyRange(t,e){e<=t||(e-t)/this.dataInterval<2||(this._visibleRange={from:t,to:e},this.emit("change"))}animateTo(t,e,i=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:e},this.animDuration=i,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this.animStartTime,i=Math.min(1,e/this.animDuration),n=1-(1-i)**3,r=mt(this.animFrom.from,this.animTo.from,n),a=mt(this.animFrom.to,this.animTo.to,n);return a>r&&this.applyRange(r,a),i>=1&&(this._animating=!1),this._animating}setYRange(t,e,i,n=!1,r=!1){const a=e-t,l=i>0?this.padding.top/i*a:0,h=i>0?this.padding.bottom/i*a:0;this._yRange={min:n?t:t-h,max:r?e:e+l}}zoomAt(t,e,i=this._lastChartWidth){this.cancelAnimation(),i>0&&(this._lastChartWidth=i);const{from:n,to:r}=this._visibleRange,a=r-n;if(a<=0)return;const l=this.softMinRange,{left:h,right:d}=this.getSoftBounds(a,i),c=h!==null&&d!==null?d-h:this.softMaxRange();let u=e;const f=l*Or;if(e<1&&a<l){const v=l-a,w=(1-Math.min(1,v/f))**2;u=1-(1-e)*w}let m=a*u;m<l-f&&(m=l-f),e>1&&c!==null&&m>c&&(m=c);const p=(t-n)/a;let g=t-p*m,M=g+m;if(e<1&&M<r){const v=r-M;g+=v,M+=v}if(e>1){if(d!==null&&M>d){const v=M-d;g-=v,M-=v}if(h!==null&&g<h){const v=h-g;g+=v,M+=v}}this.applyRange(g,M),this.emit("interact")}pan(t,e=0){this.cancelAnimation(),e>0&&(this._lastChartWidth=e);const{from:i,to:n}=this._visibleRange,r=n-i;if(r<=0)return;const{left:a,right:l}=this.getSoftBounds(r,e),h=r*jr;let d=t;if(t>0&&l!==null){const m=Math.max(0,n-l);m>0&&(d*=1/(m/h+1))}else if(t<0&&a!==null){const m=Math.max(0,a-i);m>0&&(d*=1/(m/h+1))}let c=i+d,u=n+d;if(l!==null&&u>l+h){const m=u-(l+h);c-=m,u-=m}if(a!==null&&c<a-h){const m=a-h-c;c+=m,u+=m}const f=o(this,st)!==null&&o(this,st)>=c&&o(this,st)<=u;this._autoScroll=f,this.applyRange(c,u),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:i}=this._visibleRange,n=i-e;if(n<=0)return;const r=this.softMinRange,a=this.softMaxRange();let l=n;l<r&&(l=r),a!==null&&l>a&&(l=a);let h=e,d=i;if(l!==n){const w=(e+i)/2;h=w-l/2,d=w+l/2}const{left:c,right:u}=this.getSoftBounds(l,t);if(u!==null&&d>u){const w=d-u;h-=w,d-=w}if(c!==null&&h<c){const w=c-h;h+=w,d+=w}const f=Math.abs(h-e),m=Math.abs(d-i);if(f<1&&m<1)return;const p=n*Yr;let g=null,M=0,v=0;u!==null&&i-u>p?(g="right",M=i-u,v=u):c!==null&&c-e>p&&(g="left",M=c-e,v=c),this.reboundMs<=0?this.applyRange(h,d):this.animateTo(h,d,this.reboundMs),g!==null&&this.emit("edgeReached",{side:g,overshoot:M,boundaryTime:v})}fitToData(t,e,i=0,n=!1){this._autoScroll=!0,i>0&&(this._lastChartWidth=i);const r=400*this.dataInterval,a=e-t,l=a>0?a:this.dataInterval*10,h=this.resolveHPad(this.padding.right,l,i),d=this.resolveHPad(this.padding.left,l,i);let c=e+h,u=t-d;c-u>r&&(c=e+h,u=c-r),n&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(u,c,450):this.applyRange(u,c)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const i=this._visibleRange.to-this._visibleRange.from;if(i<=0)return;const n=this.resolveHPad(this.padding.right,i,e),r=this._animating?this.animTo.to:this._visibleRange.to,a=this._prevDataEnd!==null?r-this._prevDataEnd:n,l=Math.max(0,Math.min(n,a)),h=t+l,d=h-i;this._autoScroll=!0;const c=Hr*this.dataInterval,u=e>0?$r/e*i:c,f=Math.min(c,u);if(this._animating){if(Math.abs(h-this.animTo.to)<f)return;this.animFrom={...this._visibleRange},this.animTo={from:d,to:h},this._prevDataEnd=o(this,st)}else{if(Math.abs(h-this._visibleRange.to)<f)return;this.animateTo(d,h,150),this._prevDataEnd=o(this,st)}}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}_t=new WeakMap,st=new WeakMap;function Te(s,t){return s===!1||s===0?0:s===void 0?t:s}function Xr(s){if(s===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0}};const t=s===!0||s===void 0?void 0:s,e=t==null?void 0:t.points,i=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:Te(e==null?void 0:e.enterMs,400),smoothMs:Te(e==null?void 0:e.smoothMs,70),pulseMs:Te(e==null?void 0:e.pulseMs,600)},r=i===!1?{reboundMs:0,yAxisMs:0}:{reboundMs:Te(i==null?void 0:i.reboundMs,350),yAxisMs:Te(i==null?void 0:i.yAxisMs,80)};return{points:n,viewport:r}}function _r(s){if(!s)return{monitor:null,ownsMonitor:!1,showHud:!1};if(s===!0)return{monitor:new Mi,ownsMonitor:!0,showHud:!0};if(s instanceof Mi)return{monitor:s,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...i}=s,n=e!==void 0;return{monitor:e??new Mi(i),ownsMonitor:!n,showHud:t??!n}}let Ur=0;var tt,$,q,Pt,Pe,Y,Z,Fe,ct,Ft,rt,Kt,Pi,ge,kt,ni,ri,zt,We,se,Xe,ci,le,Wt,Ae,ze,K,qt,fs,ai,De,Ee,Xs,_s,oi,bt,vt,pe;class Us extends Ue{constructor(t,e){var i,n,r,a;super(),A(this,K),A(this,tt),A(this,$),A(this,q),A(this,Pt),C(this,"timeScale"),C(this,"yScale"),A(this,Pe),A(this,Y,[]),A(this,Z),A(this,Fe),A(this,ct,6e4),A(this,Ft,null),A(this,rt,{}),A(this,Kt,null),A(this,Pi,!1),A(this,ge,{}),A(this,kt,{left:"idle",right:"idle"}),A(this,ni,{left:null,right:null}),A(this,ri),A(this,zt,0),A(this,We,!1),A(this,se,!1),A(this,Xe,!1),A(this,ci,0),A(this,le),A(this,Wt),A(this,Ae,!1),A(this,ze,null),A(this,oi,0),A(this,bt,0),A(this,vt,0),A(this,pe,!1),e!=null&&e.axis&&(I(this,ge,e.axis),I(this,rt,{min:(i=e.axis.y)==null?void 0:i.min,max:(n=e.axis.y)==null?void 0:n.max})),I(this,Z,(e==null?void 0:e.theme)??Ns),I(this,Fe,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),I(this,le,Xr(e==null?void 0:e.animations)),I(this,ri,e==null?void 0:e.onEdgeReached);const l=_r(e==null?void 0:e.perf);I(this,Wt,l.monitor),I(this,Ae,l.ownsMonitor),I(this,tt,new Mn(t,o(this,Wt)??void 0)),I(this,$,new Nr({padding:e==null?void 0:e.padding,reboundMs:o(this,le).viewport.reboundMs})),On(this,o(this,$)),this.timeScale=new Bs,this.yScale=new Ws;const h=o(this,Wt);h?(I(this,q,new ti(c=>{h.resetDrawCalls("main");const u=performance.now();this.renderMain(c),h.recordFrame("main",performance.now()-u,c)})),I(this,Pt,new ti(c=>{h.resetDrawCalls("overlay");const u=performance.now();this.renderOverlay(c),h.recordFrame("overlay",performance.now()-u,c)})),l.showHud&&I(this,ze,new Un(t,h))):(I(this,q,new ti(c=>this.renderMain(c))),I(this,Pt,new ti(c=>this.renderOverlay(c))));const d=(e==null?void 0:e.interactive)!==!1;I(this,Pe,d?new Yn(o(this,tt).canvas,o(this,$),this.timeScale,this.yScale):null),o(this,$).on("change",()=>{this.syncScales(),o(this,q).markDirty(),this.emit("viewportChange")}),o(this,$).on("edgeReached",c=>{var u;o(this,ni)[c.side]=c.boundaryTime,(u=o(this,ri))==null||u.call(this,c)}),o(this,tt).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(a=o(this,Pe))==null||a.on("crosshairMove",c=>{I(this,Ft,c),o(this,Pt).markDirty(),this.emit("crosshairMove",c),z(this,K,_s).call(this,c)})}get yAxisWidth(){const t=o(this,ge).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=o(this,ge).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return o(this,ci)}addCandlestickSeries(t){const e=new Rs,i=new xr(e,{up:{...o(this,Z).candlestick.up},down:{...o(this,Z).candlestick.down},bodyWidthRatio:.6,...z(this,K,ai).call(this,"candle"),...t,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,i,i.store,t??{})}addLineSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new Sr(n,{colors:n===1?[o(this,Z).line.color]:o(this,Z).seriesColors.slice(0,n),strokeWidth:o(this,Z).line.width,area:{visible:!0},...z(this,K,ai).call(this,"line"),...i,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,r,r.store,i)}addBarSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new gr(n,{colors:o(this,Z).seriesColors.slice(0,n),barWidthRatio:.6,...z(this,K,ai).call(this,"bar"),...i,...z(this,K,De).call(this)});return z(this,K,Ee).call(this,r,r.store,i)}addPieSeries(t){const e=new si(t);return z(this,K,Ee).call(this,e,null,t??{})}removeSeries(t){const e=o(this,Y).findIndex(i=>i.id===t);e>=0&&(o(this,Y)[e].renderer.dispose(),o(this,Y).splice(e,1),I(this,Kt,null),this.updateViewportPadding(),o(this,q).markDirty(),this.emit("seriesChange"),z(this,K,qt).call(this))}setSeriesData(t,e,i){const n=o(this,Y).find(r=>r.id===t);n==null||n.renderer.setData(e,i)}appendData(t,e,i){var n,r;const a=o(this,Y).find(l=>l.id===t);(r=a==null?void 0:(n=a.renderer).appendPoint)==null||r.call(n,e,i)}updateData(t,e,i){var n,r;const a=o(this,Y).find(l=>l.id===t);(r=a==null?void 0:(n=a.renderer).updateLastPoint)==null||r.call(n,e,i)}updateSeriesOptions(t,e){const i=o(this,Y).find(d=>d.id===t);if(!i)return;const n=i.label,r=i.renderer.getLayerColors().slice();i.renderer.updateOptions({...e,...z(this,K,De).call(this)}),"label"in e&&typeof e.label=="string"&&(i.label=e.label),o(this,q).markDirty();const a=i.renderer.getLayerColors(),l=r.length!==a.length||r.some((d,c)=>d!==a[c]),h=n!==i.label;(l||h)&&z(this,K,qt).call(this)}batch(t){Ri(this,zt)._++;try{t()}finally{--Ri(this,zt)._<=0&&(I(this,zt,0),o(this,We)?(I(this,We,!1),I(this,se,!1),this.onDataChanged()):o(this,se)&&(I(this,se,!1),this.updateYRange(!0),o(this,q).markDirty()),o(this,Xe)&&(I(this,Xe,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const i=o(this,Y).find(n=>n.id===t);if(!(!i||i.visible===e)){if(i.visible=e,z(this,K,qt).call(this),o(this,zt)>0){I(this,se,!0);return}this.updateYRange(!0),o(this,q).markDirty()}}isSeriesVisible(t){var e;return((e=o(this,Y).find(i=>i.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,i){const n=o(this,Y).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==i){if(n.renderer.setLayerVisible(e,i),z(this,K,qt).call(this),o(this,zt)>0){I(this,se,!0);return}this.updateYRange(!0),o(this,q).markDirty()}}isLayerVisible(t,e){const i=o(this,Y).find(n=>n.id===t);return(i==null?void 0:i.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const i=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(t,e,i,!0)}getVisibleRange(){return o(this,$).visibleRange}getDataRange(){const t=o(this,$).dataStart,e=o(this,$).dataEnd;return t===null||e===null?null:{from:t,to:e}}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:i}=this.getDataBounds();if(e===void 0||i===void 0)return;const n=Math.max(e,i-(t-1)*o(this,ct)),r=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(n,i,r,!1);return}o(this,$).setRange(t)}getYRange(){return o(this,$).yRange}getCrosshairPosition(){return o(this,Ft)}getLastValue(t){const e=o(this,Y).find(h=>h.id===t);if(!(e!=null&&e.store))return null;const i=e.store.last();if(!i)return null;const n=h=>"close"in h?h.close:h.value,{from:r,to:a}=o(this,$).visibleRange;if(i.time>=r&&i.time<=a)return{value:n(i),isLive:!0};const l=e.store.getVisibleData(r,a);return l.length===0?null:{value:n(l[l.length-1]),isLive:!1}}getPreviousClose(t){const e=o(this,Y).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const i=e.store.getAll();if(i.length<2)return null;const n=i[i.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=o(this,Y).find(i=>i.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var i,n;const r=o(this,Y).find(a=>a.id===t);return r?((n=(i=r.renderer).getDataAtTime)==null?void 0:n.call(i,e,o(this,ct)))??null:null}getLayerSnapshots(t,e){var i,n;const r=o(this,Y).find(a=>a.id===t);return r!=null&&r.visible?((n=(i=r.renderer).getLayerSnapshots)==null?void 0:n.call(i,e,o(this,ct)))??null:null}getSeriesIds(){return o(this,Kt)||I(this,Kt,o(this,Y).map(t=>t.id)),o(this,Kt).slice()}getSeriesType(t){const e=o(this,Y).find(i=>i.id===t);return e?e.renderer instanceof si?"pie":"time":null}getSeriesIdsByType(t,e){const i=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const a of o(this,Y)){const l=a.renderer instanceof si;if(t==="pie"&&!l||t==="time"&&l)continue;const h=a.renderer.getLayerCount();if(!(n&&h>1)){if(i){if(!a.visible)continue;if(h>1){let d=!1;for(let c=0;c<h;c++)if(a.renderer.isLayerVisible(c)){d=!0;break}if(!d)continue}}r.push(a.id)}}return r}getStackedLastValue(t){var e,i;const n=o(this,Y).find(a=>a.id===t);return n?((i=(e=n.renderer).getStackedLastValue)==null?void 0:i.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:i.call(e))??null}listSeriesForTest(){return o(this,Y).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=o(this,Y).find(i=>i.id===t);return e?e.renderer.getLayerColors()[0]??o(this,Z).line.color:null}getSeriesLabel(t){var e;return(e=o(this,Y).find(i=>i.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=o(this,Y).find(r=>r.id===t);if(!e)return null;const i=e.renderer.getLayerCount();if(i<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:i},(r,a)=>({color:n[a%n.length]}))}getSliceInfo(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:i.call(e,o(this,Z)))??null}getHoverInfo(t){var e,i;const n=o(this,Y).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:i.call(e,o(this,Z)))??null}setTheme(t){const e=o(this,Z);I(this,Z,t);for(const i of o(this,Y))i.renderer.applyTheme(t,e);o(this,q).markDirty(),z(this,K,qt).call(this)}getTheme(){return o(this,Z)}setAxis(t){var e,i;const n=this.yAxisWidth,r=this.xAxisHeight;I(this,ge,t),I(this,rt,{min:(e=t.y)==null?void 0:e.min,max:(i=t.y)==null?void 0:i.max}),I(this,pe,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),o(this,q).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),o(this,q).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),o(this,q).markDirty())}getMediaSize(){return o(this,tt).size.media}getLayout(){const t=o(this,tt).size.media,e=this.yAxisWidth,i=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-i},yAxisWidth:e,xAxisHeight:i}}getDataInterval(){return o(this,ct)}setPadding(t){const e=o(this,$).getPadding();o(this,$).setPadding(t);const i=o(this,$).getPadding(),n=!ms(e.left,i.left)||!ms(e.right,i.right),r=e.top!==i.top||e.bottom!==i.bottom;if(n){const{first:a,last:l}=this.getDataBounds();if(a!==void 0&&l!==void 0){const h=o(this,tt).size.media.width-this.yAxisWidth;o(this,$).fitToData(a,l,h,!1)}}r&&this.updateYRange(!0),this.syncScales(),o(this,q).markDirty(),r&&this.emit("viewportChange")}setGrid(t){I(this,Fe,t.visible),o(this,q).markDirty()}setEdgeState(t,e){o(this,kt)[t]!==e&&(o(this,kt)[t]=e,o(this,Pt).markDirty())}getEdgeState(t){return o(this,kt)[t]}setYLabel(t){I(this,Pi,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,i;for(const n of o(this,Y))n.renderer.dispose();I(this,Y,[]),I(this,Kt,null),o(this,$).destroy(),o(this,q).destroy(),o(this,Pt).destroy(),(t=o(this,Pe))==null||t.destroy(),o(this,tt).destroy(),(e=o(this,ze))==null||e.destroy(),I(this,ze,null),o(this,Ae)&&((i=o(this,Wt))==null||i.destroy()),I(this,Wt,null),I(this,Ae,!1),this.removeAllListeners()}getPerfMonitor(){return o(this,Wt)}getDataBounds(){let t,e;for(const i of o(this,Y)){if(!i.visible||!i.store)continue;const n=i.store.first(),r=i.store.last();n&&(t===void 0||n.time<t)&&(t=n.time),r&&(e===void 0||r.time>e)&&(e=r.time)}return{first:t,last:e}}onDataChanged(){if(o(this,zt)>0){I(this,We,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&o(this,$).setDataStart(t),e!==void 0&&o(this,$).setDataEnd(e);let i=0;for(const r of o(this,Y))r.renderer.getTotalLength?i+=r.renderer.getTotalLength():r.store&&(i+=r.store.length);const n=i-o(this,oi)>5;if(I(this,oi,i),t!==void 0&&e!==void 0){const{from:r,to:a}=o(this,$).visibleRange,l=r===0&&a===0,h=o(this,tt).size.media.width-this.yAxisWidth;l?o(this,$).fitToData(t,e,h,!1):n&&o(this,$).autoScroll?o(this,$).fitToData(t,e,h,!0):!n&&o(this,$).autoScroll&&o(this,$).scrollToEnd(e,h)}this.updateYRange(n),this.syncScales(),o(this,q).markDirty(),this.emit("dataUpdate"),z(this,K,qt).call(this)}updateDataInterval(){for(const t of o(this,Y)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const i=e.slice(0,20).map(n=>n.time);I(this,ct,Ls(i)),o(this,$).setDataInterval(o(this,ct));break}}}updateYRange(t=!1){let e=1/0,i=-1/0;const n=o(this,$).visibleRange,r=o(this,rt).min!==void 0&&o(this,rt).min!=="auto"&&typeof o(this,rt).min!="number"||o(this,rt).max!==void 0&&o(this,rt).max!=="auto"&&typeof o(this,rt).max!="number"?[]:null;for(const c of o(this,Y)){if(!c.visible)continue;if(c.renderer.getValueRange){const f=c.renderer.getValueRange(n.from,n.to);if(f){f.max>i&&(i=f.max),f.min<e&&(e=f.min),r==null||r.push(f.min,f.max);continue}}if(!c.store)continue;const u=c.store.getVisibleData(n.from,n.to);for(const f of u)if("high"in f){const m=f;Number.isFinite(m.high)&&(m.high>i&&(i=m.high),r==null||r.push(m.high)),Number.isFinite(m.low)&&(m.low<e&&(e=m.low),r==null||r.push(m.low))}else{const m=f;Number.isFinite(m.value)&&(m.value>i&&(i=m.value),m.value<e&&(e=m.value),r==null||r.push(m.value))}}if(e===1/0||i===-1/0){I(this,pe,!1);return}e=this.resolveBound(o(this,rt).min,e,i,r??[],"min"),i=this.resolveBound(o(this,rt).max,i,e,r??[],"max");const a=o(this,le).viewport.yAxisMs;if(!o(this,pe)||t||a<=0)I(this,bt,e),I(this,vt,i),I(this,pe,!0);else{const c=Math.min(1,16/a);I(this,bt,o(this,bt)+(e-o(this,bt))*c),I(this,vt,o(this,vt)+(i-o(this,vt))*c),e<o(this,bt)&&I(this,bt,e),i>o(this,vt)&&I(this,vt,i);const u=Math.max(Math.abs(o(this,vt)-o(this,bt))*1e-4,.001);(Math.abs(o(this,bt)-e)>u||Math.abs(o(this,vt)-i)>u)&&o(this,q).markDirty()}const l=o(this,rt).min!==void 0&&o(this,rt).min!=="auto",h=o(this,rt).max!==void 0&&o(this,rt).max!=="auto",d=o(this,tt).size.media.height-this.xAxisHeight;o(this,$).setYRange(o(this,bt),o(this,vt),d,l,h)}resolveBound(t,e,i,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const a=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const l=a[1]==="-"?-1:1,h=parseFloat(a[2])/100,d=Math.abs(i-e)||Math.abs(e)||1;return e+l*h*d*(r==="max"?1:-1)}return e}syncScales(){const t=o(this,tt).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,i=t.media.height-this.xAxisHeight;this.timeScale.update(o(this,$).visibleRange,e,t.horizontalPixelRatio,o(this,ct)),this.yScale.update(o(this,$).yRange,i,t.verticalPixelRatio)}updateScales(t=!1){const e=o(this,tt).size;if(e.media.width===0||e.media.height===0)return;const i=e.media.width-this.yAxisWidth,n=e.media.height-this.xAxisHeight;this.timeScale.update(o(this,$).visibleRange,i,e.horizontalPixelRatio,o(this,ct)),this.yScale.update(o(this,$).yRange,n,e.verticalPixelRatio),this.updateYRange(t),this.yScale.update(o(this,$).yRange,n,e.verticalPixelRatio)}renderMain(t){const e=o(this,tt).size;if(e.media.width===0||e.media.height===0)return;const i=typeof t=="number"?t:performance.now();o(this,$).tick(i)&&o(this,q).markDirty(),this.updateScales(),o(this,tt).useMainLayer(n=>{const{context:r,bitmapSize:a}=n,l=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,h=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,a.width,a.height),r.save(),r.beginPath(),r.rect(0,0,l,h),r.clip(),o(this,Fe)&&An(n,this.timeScale,this.yScale,o(this,Z),o(this,ct));const d=o(this,$).getPadding(),c={top:d.top,bottom:d.bottom},u=o(this,Wt);for(const f of o(this,Y)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:o(this,Z),dataInterval:o(this,ct),padding:c};if(u){const p=performance.now();f.renderer.render(m),u.recordSeries(f.id,performance.now()-p,i)}else f.renderer.render(m)}r.restore()});for(const n of o(this,Y))if(n.renderer.needsAnimation){o(this,q).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,i;const n=o(this,tt).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const h of o(this,Y))if(h.visible&&h.renderer.overlayNeedsAnimation){r=!0;break}const a=o(this,kt).left==="loading"||o(this,kt).right==="loading",l=o(this,kt).left!=="idle"||o(this,kt).right!=="idle";if(o(this,tt).useOverlayLayer(h=>{var d,c;if(!o(this,Ft)&&!r&&!l)return;const u=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,u,f),h.context.clip(),o(this,Ft)&&z(this,K,Xs).call(this)){const g=o(this,Ft).mediaX*n.horizontalPixelRatio,M=o(this,Ft).mediaY*n.verticalPixelRatio;kn(h,g,M,o(this,Z))}const m=o(this,$).getPadding(),p={top:m.top,bottom:m.bottom};for(const g of o(this,Y))g.visible&&((c=(d=g.renderer).drawOverlay)==null||c.call(d,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:o(this,Z),dataInterval:o(this,ct),padding:p,crosshair:o(this,Ft)}));l&&this.drawEdgeIndicators(h,n.media.height-this.xAxisHeight),h.context.restore()}),r){const{from:h,to:d}=this.timeScale.getRange();let c=!1;for(const u of o(this,Y))if(!(!u.visible||!u.renderer.overlayNeedsAnimation)&&(((i=(e=u.renderer).hasOverlayContentInRange)==null?void 0:i.call(e,h,d))??!0)){c=!0;break}c&&o(this,Pt).markDirty()}a&&o(this,Pt).markDirty()}drawEdgeIndicators(t,e){const i=performance.now();for(const n of["left","right"]){const r=o(this,kt)[n];if(r==="idle"||r==="has-more")continue;const a=this.resolveEdgeBoundary(n);a!==null&&Pn({scope:t,timeScale:this.timeScale,theme:o(this,Z),chartMediaHeight:e,boundaryTime:a,side:n,state:r,now:i})}}resolveEdgeBoundary(t){const e=o(this,ni)[t];if(e!==null)return e;const{first:i,last:n}=this.getDataBounds();return t==="left"?i??null:n??null}}tt=new WeakMap,$=new WeakMap,q=new WeakMap,Pt=new WeakMap,Pe=new WeakMap,Y=new WeakMap,Z=new WeakMap,Fe=new WeakMap,ct=new WeakMap,Ft=new WeakMap,rt=new WeakMap,Kt=new WeakMap,Pi=new WeakMap,ge=new WeakMap,kt=new WeakMap,ni=new WeakMap,ri=new WeakMap,zt=new WeakMap,We=new WeakMap,se=new WeakMap,Xe=new WeakMap,ci=new WeakMap,le=new WeakMap,Wt=new WeakMap,Ae=new WeakMap,ze=new WeakMap,K=new WeakSet,qt=function(){if(Ri(this,ci)._++,o(this,zt)>0){I(this,Xe,!0);return}this.emit("overlayChange")},fs=function(s){if(s&&!o(this,Y).some(e=>e.id===s))return s;let t;do t=`series_${++Ur}`;while(o(this,Y).some(e=>e.id===t));return t},ai=function(s){const{enterMs:t,smoothMs:e,pulseMs:i}=o(this,le).points;return s==="line"?{enterMs:t,smoothMs:e,pulseMs:i}:{enterMs:t,smoothMs:e}},De=function(){const{enterMs:s,smoothMs:t,pulseMs:e}=o(this,le).points,i={};return s===0&&(i.enterMs=0),t===0&&(i.smoothMs=0),e===0&&(i.pulseMs=0),i},Ee=function(s,t,e){var i;const n=z(this,K,fs).call(this,e.id);return(i=s.onDataChanged)==null||i.call(s,()=>this.onDataChanged()),o(this,Y).push({id:n,label:e.label,renderer:s,store:t,visible:!0}),I(this,Kt,null),this.updateViewportPadding(),this.emit("seriesChange"),z(this,K,qt).call(this),n},Xs=function(){for(const s of o(this,Y))if(s.visible&&!(s.renderer instanceof si))return!0;return!1},_s=function(s){const t=o(this,tt).size,e=o(this,$).getPadding(),i={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of o(this,Y)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let a=-1;if(s){const l=s.mediaX*t.horizontalPixelRatio,h=s.mediaY*t.verticalPixelRatio;a=r.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,i)}r.renderer.setHoverIndex(a)&&(n=!0)}n&&o(this,q).markDirty()},oi=new WeakMap,bt=new WeakMap,vt=new WeakMap,pe=new WeakMap;function ms(s,t){return typeof s=="number"&&typeof t=="number"?s===t:typeof s=="object"&&typeof t=="object"?s.intervals===t.intervals:!1}function Gr(s,t){if(s.length<=t||t<=0)return s;const e=s[0].time,i=s[s.length-1].time,n=i-e;if(n<=0)return s;const r=n/t,a=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?i+1:e+(h+1)*r;let c=null,u=null;for(;l<s.length&&s[l].time<d;){const f=s[l];(c===null||f.value<c.value)&&(c=f),(u===null||f.value>u.value)&&(u=f),l++}if(!(c===null||u===null)){if(c===u){a.push(c);continue}c.time<u.time?a.push(c,u):a.push(u,c)}}return a}function Kr(s,t){if(s.length<=t||t<=0)return s;const e=s[0].time,i=s[s.length-1].time,n=i-e;if(n<=0)return s;const r=n/t,a=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?i+1:e+(h+1)*r;let c=null;for(;l<s.length&&s[l].time<d;){const u=s[l];c===null?c={time:u.time,open:u.open,high:u.high,low:u.low,close:u.close}:(u.high>c.high&&(c.high=u.high),u.low<c.low&&(c.low=u.low),c.close=u.close),l++}c!==null&&a.push(c)}return a}const gs=8;function Gs(s,t){return Math.abs(s-t.left)<=gs?{gesture:"resize-left",snapToCenter:!1}:Math.abs(s-t.right)<=gs?{gesture:"resize-right",snapToCenter:!1}:s>t.left&&s<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function qr(s){const{startVisible:t,deltaPx:e,pixelsPerTime:i,dataRange:n}=s,r=t.to-t.from,a=e/i;let l=t.from+a,h=t.to+a;return l<n.from&&(l=n.from,h=l+r),h>n.to&&(h=n.to,l=h-r),l<n.from&&(l=n.from),{from:l,to:h}}function Jr(s){const{edge:t,startVisible:e,deltaPx:i,pixelsPerTime:n,dataRange:r,minSpan:a}=s,l=i/n;if(t==="left"){let c=e.from+l,u=e.to;return c<r.from&&(c=r.from),u-c<a&&(c=u-a),c<r.from&&(c=r.from,u=Math.min(r.to,c+a)),{from:c,to:u}}let h=e.from,d=e.to+l;return d>r.to&&(d=r.to),d-h<a&&(d=h+a),d>r.to&&(d=r.to,h=Math.max(r.from,d-a)),{from:h,to:d}}function Qr(s){const{time:t,startVisible:e,dataRange:i}=s,n=e.to-e.from;let r=t-n/2,a=r+n;return r<i.from&&(r=i.from,a=r+n),a>i.to&&(a=i.to,r=a-n),r<i.from&&(r=i.from),{from:r,to:a}}function Zr(s){const{ctx:t,theme:e,mediaWidth:i,mediaHeight:n}=s;t.fillStyle=e.background,t.fillRect(0,0,i,n)}function ta(s,t,e=!0){if(t.length<2)return;const{ctx:i,timeScale:n,yScale:r,mediaHeight:a,theme:l}=s;if(e){i.beginPath();for(let d=0;d<t.length;d++){const c=t[d],u=n.timeToX(c.time),f=r.valueToY(c.value);d===0?i.moveTo(u,f):i.lineTo(u,f)}i.lineTo(n.timeToX(t[t.length-1].time),a),i.lineTo(n.timeToX(t[0].time),a),i.closePath();const h=i.createLinearGradient(0,0,0,a);h.addColorStop(0,l.line.areaTopColor),h.addColorStop(1,l.line.areaBottomColor),i.fillStyle=h,i.fill()}i.beginPath();for(let h=0;h<t.length;h++){const d=t[h],c=n.timeToX(d.time),u=r.valueToY(d.value);h===0?i.moveTo(c,u):i.lineTo(c,u)}i.strokeStyle=l.line.color,i.lineWidth=l.line.width,i.stroke()}function ea(s,t){if(t.length===0)return;const{ctx:e,timeScale:i,yScale:n,mediaHeight:r,theme:a}=s,l=Math.max(1,t.length>1?Math.abs(i.timeToX(t[1].time)-i.timeToX(t[0].time))*.8:2);e.fillStyle=a.line.color;for(const h of t){const d=i.timeToX(h.time),c=n.valueToY(h.value),u=Math.max(1,r-c);e.fillRect(d-l/2,c,l,u)}}function ia(s,t){if(t.length===0)return;const{ctx:e,timeScale:i,yScale:n,theme:r}=s,a=Math.max(1,t.length>1?Math.abs(i.timeToX(t[1].time)-i.timeToX(t[0].time))*.75:2);for(const l of t){const h=l.close>=l.open?r.candlestick.up:r.candlestick.down,d=gt(h.body),c=i.timeToX(l.time),u=n.valueToY(l.open),f=n.valueToY(l.close),m=n.valueToY(l.high),p=n.valueToY(l.low);e.strokeStyle=h.wick,e.lineWidth=1,e.beginPath(),e.moveTo(c,m),e.lineTo(c,p),e.stroke();const g=Math.min(u,f),M=Math.max(1,Math.abs(f-u));e.fillStyle=d,e.fillRect(c-a/2,g,a,M)}}function sa(s,t,e){const i=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),r=s.timeToX(i),a=s.timeToX(n),l=Math.min(r,a),h=Math.max(r,a);return{left:l,right:h,width:Math.max(1,h-l)}}var Ct,N,ui,et,Rt,Qt,Vt,Yt,Dt,Et,he,we,Ut,li,hi,ne,At,jt,Ve,Ye,ae,je,Oe,He,$e,re,Ne,O,Fi,ft,Ks,Wi,oe,Re,Ci,ei,ps,qs,Js,Qs,bs,vs,ue,ys;class Zs{constructor(t){A(this,O),A(this,Ct),A(this,N),A(this,ui),A(this,et),A(this,Rt),A(this,Qt),A(this,Vt),A(this,Yt),A(this,Dt),A(this,Et),A(this,he),A(this,we),A(this,Ut,new Bs),A(this,li,new Ws),A(this,hi,0),A(this,ne,0),A(this,At,1),A(this,jt,null),A(this,Ve,!0),A(this,Ye),A(this,ae,null),A(this,je),A(this,Oe),A(this,He),A(this,$e),A(this,re),A(this,Ne),I(this,Ct,t.container),I(this,et,t.chart),I(this,he,t.data),I(this,we,t.options??{}),window.getComputedStyle(o(this,Ct)).position==="static"&&(o(this,Ct).style.position="relative"),I(this,N,document.createElement("canvas")),o(this,N).style.position="absolute",o(this,N).style.left="0",o(this,N).style.top="0",o(this,N).style.height="100%",o(this,N).style.touchAction="none",o(this,Ct).appendChild(o(this,N));const e=o(this,N).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");I(this,ui,e),I(this,Rt,document.createElement("div")),o(this,Rt).dataset.chartNavigatorOverlay="",o(this,Rt).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",I(this,Qt,document.createElement("div")),o(this,Qt).style.cssText="position:absolute;left:0;top:0;bottom:0;",I(this,Vt,document.createElement("div")),o(this,Vt).style.cssText="position:absolute;top:0;bottom:0;",I(this,Yt,document.createElement("div")),o(this,Yt).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",I(this,Dt,ws()),I(this,Et,ws()),o(this,Rt).append(o(this,Qt),o(this,Vt),o(this,Yt),o(this,Dt),o(this,Et)),o(this,Ct).appendChild(o(this,Rt)),I(this,je,()=>z(this,O,oe).call(this)),I(this,Oe,()=>z(this,O,oe).call(this)),o(this,et).on("viewportChange",o(this,je)),o(this,et).on("overlayChange",o(this,Oe)),I(this,He,n=>z(this,O,qs).call(this,n)),I(this,$e,n=>z(this,O,Js).call(this,n)),I(this,re,n=>z(this,O,Qs).call(this,n)),I(this,Ne,()=>{o(this,ae)===null&&(o(this,N).style.cursor="default")}),o(this,N).addEventListener("pointerdown",o(this,He)),o(this,N).addEventListener("pointermove",o(this,$e)),o(this,N).addEventListener("pointerup",o(this,re)),o(this,N).addEventListener("pointercancel",o(this,re)),o(this,N).addEventListener("pointerleave",o(this,Ne)),I(this,Ye,new ResizeObserver(n=>z(this,O,Ks).call(this,n[0]))),o(this,Ye).observe(o(this,Ct)),z(this,O,Fi).call(this);const i=o(this,Ct).getBoundingClientRect();i.width>0&&i.height>0&&z(this,O,Wi).call(this,i.width,i.height),z(this,O,oe).call(this)}setData(t){I(this,he,t),z(this,O,oe).call(this)}setOptions(t){I(this,we,t),z(this,O,Fi).call(this),z(this,O,oe).call(this)}destroy(){o(this,et).off("viewportChange",o(this,je)),o(this,et).off("overlayChange",o(this,Oe)),o(this,N).removeEventListener("pointerdown",o(this,He)),o(this,N).removeEventListener("pointermove",o(this,$e)),o(this,N).removeEventListener("pointerup",o(this,re)),o(this,N).removeEventListener("pointercancel",o(this,re)),o(this,N).removeEventListener("pointerleave",o(this,Ne)),o(this,Ye).disconnect(),o(this,jt)!==null&&(cancelAnimationFrame(o(this,jt)),I(this,jt,null)),o(this,N).remove(),o(this,Rt).remove()}get height(){return o(this,we).height??o(this,et).getTheme().navigator.height}}Ct=new WeakMap,N=new WeakMap,ui=new WeakMap,et=new WeakMap,Rt=new WeakMap,Qt=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Dt=new WeakMap,Et=new WeakMap,he=new WeakMap,we=new WeakMap,Ut=new WeakMap,li=new WeakMap,hi=new WeakMap,ne=new WeakMap,At=new WeakMap,jt=new WeakMap,Ve=new WeakMap,Ye=new WeakMap,ae=new WeakMap,je=new WeakMap,Oe=new WeakMap,He=new WeakMap,$e=new WeakMap,re=new WeakMap,Ne=new WeakMap,O=new WeakSet,Fi=function(){const s=o(this,we).height;s!==void 0&&(o(this,Ct).style.height=`${s}px`)},ft=function(){return Math.max(0,o(this,hi)-o(this,et).yAxisWidth)},Ks=function(s){var t;if(!s)return;const e=(t=s.contentBoxSize)==null?void 0:t[0],i=(e==null?void 0:e.inlineSize)??s.contentRect.width,n=(e==null?void 0:e.blockSize)??s.contentRect.height;i<=0||n<=0||(z(this,O,Wi).call(this,i,n),z(this,O,oe).call(this))},Wi=function(s,t){const e=window.devicePixelRatio||1;I(this,hi,s),I(this,ne,t),I(this,At,e);const i=o(this,O,ft);o(this,N).width=Math.round(i*e),o(this,N).height=Math.round(t*e),o(this,N).style.width=`${i}px`,o(this,Rt).style.width=`${i}px`},oe=function(){o(this,Ve)&&o(this,jt)!==null||(I(this,Ve,!0),o(this,jt)===null&&I(this,jt,requestAnimationFrame(()=>{I(this,jt,null),I(this,Ve,!1),z(this,O,bs).call(this)})))},Re=function(s){const t=o(this,N).getBoundingClientRect();return s.clientX-t.left},Ci=function(){const s=z(this,O,ue).call(this),t=z(this,O,ys).call(this);return o(this,Ut).update(s,o(this,O,ft),o(this,At)),o(this,li).update(t,o(this,ne),o(this,At)),{dataRange:s,yRange:t}},ei=function(){return z(this,O,Ci).call(this),sa(o(this,Ut),o(this,et).getVisibleRange(),z(this,O,ue).call(this))},ps=function(){const s=z(this,O,ue).call(this),t=s.to-s.from;return t<=0||o(this,O,ft)<=0?0:o(this,O,ft)/t},qs=function(s){if(s.button!==void 0&&s.button!==0)return;const t=z(this,O,Re).call(this,s),e=z(this,O,ue).call(this);if(e.to<=e.from)return;const i=z(this,O,ei).call(this),n=Gs(t,i),r=z(this,O,ps).call(this);if(r===0)return;let a=o(this,et).getVisibleRange();if(n.snapToCenter){const l=o(this,Ut).xToTime(t),h=Qr({time:l,startVisible:a,dataRange:e});o(this,et).setVisibleRange(h),a=h}I(this,ae,{pointerId:s.pointerId,gesture:n.gesture,startX:t,startVisible:a,pixelsPerTime:r}),o(this,N).setPointerCapture(s.pointerId),o(this,N).style.cursor=tn(n.gesture,!0),s.preventDefault()},Js=function(s){const t=o(this,ae);if(t===null){o(this,N).style.cursor=xs(z(this,O,Re).call(this,s),z(this,O,ei).call(this));return}if(s.pointerId!==t.pointerId)return;const e=z(this,O,Re).call(this,s)-t.startX,i=z(this,O,ue).call(this);let n;if(t.gesture==="pan")n=qr({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:i});else{const r=t.gesture==="resize-left"?"left":"right";n=Jr({edge:r,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:i,minSpan:2*o(this,et).getDataInterval()})}o(this,et).setVisibleRange(n)},Qs=function(s){const t=o(this,ae);t===null||s.pointerId!==t.pointerId||(I(this,ae,null),o(this,N).hasPointerCapture(s.pointerId)&&o(this,N).releasePointerCapture(s.pointerId),o(this,N).style.cursor=xs(z(this,O,Re).call(this,s),z(this,O,ei).call(this)))},bs=function(){if(o(this,O,ft)<=0||o(this,ne)<=0)return;const s=o(this,et).getTheme().navigator,{dataRange:t}=z(this,O,Ci).call(this);o(this,N).width=Math.round(o(this,O,ft)*o(this,At)),o(this,N).height=Math.round(o(this,ne)*o(this,At)),o(this,N).style.width=`${o(this,O,ft)}px`,o(this,Rt).style.width=`${o(this,O,ft)}px`;const e=o(this,ui),i=o(this,N).width,n=o(this,N).height;e.save(),e.clearRect(0,0,i,n),e.scale(o(this,At),o(this,At));const r={ctx:e,timeScale:o(this,Ut),yScale:o(this,li),mediaWidth:o(this,O,ft),mediaHeight:o(this,ne),theme:s};o(this,N).style.boxShadow=`inset 0 1px 0 ${s.borderColor}, inset 0 -1px 0 ${s.borderColor}`,Zr(r);const a=Math.max(1,Math.round(o(this,O,ft))),l=o(this,he);if(l.type==="candlestick")ia(r,Kr(l.points,a));else{const h=Ti(l),d=h.length===1;for(const c of h){const u=Gr(c,a);l.type==="bar"?ea(r,u):ta(r,u,d)}}e.restore(),z(this,O,vs).call(this,s,t)},vs=function(s,t){if(t.to<=t.from)return;const e=o(this,et).getVisibleRange(),i=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),r=o(this,Ut).timeToX(i),a=o(this,Ut).timeToX(n),l=Math.min(r,a),h=Math.max(r,a),d=Math.max(1,h-l);o(this,Qt).style.width=`${l}px`,o(this,Qt).style.background=s.mask.fill,o(this,Qt).style.display=l>0?"block":"none";const c=Math.max(0,o(this,O,ft)-(l+d));o(this,Vt).style.left=`${l+d}px`,o(this,Vt).style.width=`${c}px`,o(this,Vt).style.background=s.mask.fill,o(this,Vt).style.display=c>0?"block":"none",o(this,Yt).style.left=`${l}px`,o(this,Yt).style.width=`${d}px`,o(this,Yt).style.background=s.window.fill,o(this,Yt).style.border=s.window.borderWidth>0?`${s.window.borderWidth}px solid ${s.window.border}`:"none";const u=s.handle.width,f=Math.max(1,u/2),m=o(this,et).getTheme().background;o(this,Dt).style.left=`${l-u/2}px`,o(this,Dt).style.width=`${u}px`,o(this,Dt).style.background=s.handle.color,o(this,Dt).style.borderRadius=`${f}px`,o(this,Et).style.left=`${l+d-u/2}px`,o(this,Et).style.width=`${u}px`,o(this,Et).style.background=s.handle.color,o(this,Et).style.borderRadius=`${f}px`;for(const p of o(this,Dt).children)p.style.background=m;for(const p of o(this,Et).children)p.style.background=m},ue=function(){const s=o(this,he);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,i=0;if(s.type==="candlestick")i=s.points.length,i>0&&(t=s.points[0].time,e=s.points[i-1].time);else for(const r of Ti(s))r.length!==0&&(i+=r.length,r[0].time<t&&(t=r[0].time),r[r.length-1].time>e&&(e=r[r.length-1].time));if(i>=2&&e>t)return{from:t,to:e};if(i===1)return{...o(this,et).getVisibleRange()};const n=o(this,et).getDataRange();return n&&n.to>n.from?n:{...o(this,et).getVisibleRange()}},ys=function(){const s=o(this,he);let t=1/0,e=-1/0;if(s.type==="candlestick")for(const n of s.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of Ti(s))for(const r of n)r.value<t&&(t=r.value),r.value>e&&(e=r.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const i=(e-t)*.2;return{min:t-i,max:e+i}};function Ti(s){return"series"in s?s.series:[s.points]}function tn(s,t){return s==="resize-left"||s==="resize-right"?"ew-resize":t?"grabbing":"grab"}function xs(s,t){return tn(na(s,t),!1)}function na(s,t){return Gs(s,t).gesture}function ws(){const s=document.createElement("div");s.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",s.appendChild(e)}return s}const Ai=new WeakMap;function en(s,t){var e;return(e=Ai.get(s))==null?void 0:e.get(t)}function sn(s,t,e){let i=Ai.get(s);i||(i=new Map,Ai.set(s,i)),i.set(t,e)}function Ss(s){return"close"in s?s.close:s.value}function nn(s,t){if(t==="none"||s.length<=1)return s;const e=[...s];return e.sort((i,n)=>{const r=Ss(i.data),a=Ss(n.data);return t==="asc"?r-a:a-r}),e}function di(s){const t=Object.freeze({...s.data}),e={id:s.id,seriesId:s.seriesId,layerIndex:s.layerIndex,label:s.label,data:t,color:s.color};return Object.freeze(e)}function _i(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=en(s,t.cacheKey);if(n&&n.version===i&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const l of s.getSeriesIds()){if(!s.isSeriesVisible(l))continue;const h=s.getSeriesLabel(l);if(s.getSeriesLayers(l)!==null){const c=s.getLayerSnapshots(l,t.time);if(!c)continue;for(const u of c)r.push(di({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const d=s.getDataAtTime(l,t.time);d&&r.push(di({id:l,seriesId:l,label:h,data:d,color:s.getSeriesColor(l)??"#888"}))}const a=Object.freeze(nn(r,e));return sn(s,t.cacheKey,{version:i,time:t.time,sort:e,data:a}),a}function rn(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=en(s,t.cacheKey);if(n&&n.version===i&&n.time===null&&n.sort===e)return n.data;const r=[];for(const l of s.getSeriesIds()){if(!s.isSeriesVisible(l))continue;const h=s.getSeriesLabel(l),d=s.getLayerLastSnapshots(l);if(d){for(const u of d)r.push(di({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const c=s.getLastData(l);c&&r.push(di({id:l,seriesId:l,label:h,data:c,color:s.getSeriesColor(l)??"#888"}))}const a=Object.freeze(nn(r,e));return sn(s,t.cacheKey,{version:i,time:null,sort:e,data:a}),a}const ra={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"},navigator:{height:48,background:"transparent",borderColor:"rgba(139, 148, 158, 0.22)",line:{color:"#8b949e",width:1,areaTopColor:"rgba(139, 148, 158, 0.18)",areaBottomColor:"rgba(139, 148, 158, 0)"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0, 0, 0, 0.30)",width:6},mask:{fill:"rgba(255, 255, 255, 0.82)"}}},aa=J({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{up:{body:E("#96e072"),wick:"#96e072"},down:{body:E("#ee5d43"),wick:"#ee5d43"}},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:js},fontUrl:Os}),oa=J({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{up:{body:E("#bae67e"),wick:"#bae67e"},down:{body:E("#f27983"),wick:"#f27983"}},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:gi},fontUrl:Oi}),la=J({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{up:{body:E("#a6e3a1"),wick:"#a6e3a1"},down:{body:E("#f38ba8"),wick:"#f38ba8"}},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:gi},fontUrl:Oi}),ha=J({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{up:{body:E("#50fa7b"),wick:"#50fa7b"},down:{body:E("#ff5555"),wick:"#ff5555"}},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),ca=J({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{up:{body:E("#2da44e"),wick:"#2da44e"},down:{body:E("#cf222e"),wick:"#cf222e"}},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:Ni},fontUrl:Xi}),ua=J({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{up:{body:E("#b8bb26"),wick:"#b8bb26"},down:{body:E("#fb4934"),wick:"#fb4934"}},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),da={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Vr,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:Er,fontSize:15},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{fontSize:13,textColor:"#a09880"},yLabel:{fontSize:15,upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{fontSize:14,background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},fa="'Silkscreen', cursive",ma="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",ga=J({name:"Matrix",background:"#000000",candlestick:{up:{body:E("#00ff41"),wick:"#00ff41"},down:{body:E("#00802a"),wick:"#00802a"}},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:fa},fontUrl:ma,chartGradient:["#010a01","#000000"]}),pa=J({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:E("#6b8e5e"),wick:"#6b8e5e"},down:{body:E("#b85468"),wick:"#b85468"}},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:Ni},fontUrl:Xi,chartGradient:["#f8f4f7","#f5f0f4"]}),ba=J({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{up:{body:E("#6a9a6e"),wick:"#6a9a6e"},down:{body:E("#c45070"),wick:"#c45070"}},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:gi},fontUrl:Oi}),va=J({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{up:{body:E("#c3e88d"),wick:"#c3e88d"},down:{body:E("#f07178"),wick:"#f07178"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:js},fontUrl:Os}),ya="'Silkscreen', cursive",xa="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",wa=J({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{up:{body:E("#111111"),wick:"#111111"},down:{body:E("#bbbbbb"),wick:"#bbbbbb"}},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{fontSize:9,background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:ya},fontUrl:xa}),Sa=J({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:E("#2e9070"),wick:"#2e9070"},down:{body:E("#d04848"),wick:"#d04848"}},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:zr},fontUrl:Dr,chartGradient:["#f8f7f0","#f6f5ee"]}),Ma=J({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{up:{body:E("#8ab862"),wick:"#8ab862"},down:{body:E("#d05470"),wick:"#d05470"}},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),ka=J({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{up:{body:E("#7ec699"),wick:"#7ec699"},down:{body:E("#e06c75"),wick:"#e06c75"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#4d5a6c"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),Ca=J({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{up:{body:E("#98c379"),wick:"#98c379"},down:{body:E("#e06c75"),wick:"#e06c75"}},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:fi},fontUrl:mi}),Ta=J({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{up:{body:E("#19f9d8"),wick:"#19f9d8"},down:{body:E("#ff75b5"),wick:"#ff75b5"}},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Hi},fontUrl:$i}),Ra=J({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:E("#5a9a68"),wick:"#5a9a68"},down:{body:E("#d06848"),wick:"#d06848"}},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:Ni},fontUrl:Xi,chartGradient:["#fff8f2","#fef6f0"]}),La=J({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",chartGradient:["#fdfdfd","#f5f5f5"],grid:{color:"rgba(200,200,200,0.5)"},candlestick:{up:{body:E("#448c27"),wick:"#448c27"},down:{body:E("#aa3731"),wick:"#aa3731"}},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Wr},fontUrl:Ar}),Ia=J({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:E("#56949f"),wick:"#56949f"},down:{body:E("#b4637a"),wick:"#b4637a"}},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:Hs},fontUrl:$s}),Ba=J({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:E("#5a8a50"),wick:"#5a8a50"},down:{body:E("#b85040"),wick:"#b85040"}},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:Hs},fontUrl:$s,chartGradient:["#f8f4ec","#f4f0e8"]}),Pa=J({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{up:{body:E("#859900"),wick:"#859900"},down:{body:E("#dc322f"),wick:"#dc322f"}},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:fi},fontUrl:mi});function Ke(s){const{x:t,y:e,chartWidth:i,chartHeight:n,tooltipWidth:r,tooltipHeight:a,offsetX:l=16,offsetY:h=16}=s,d=t+l+r>i?t-l-r:t+l,c=e+h+a>n?e-h-a:e+h,u=Math.max(0,i-r),f=Math.max(0,n-a);return{left:Math.max(0,Math.min(u,d)),top:Math.max(0,Math.min(f,c))}}const be=B.createContext(null);function ot(){const s=B.useContext(be);if(!s)throw new Error("useChartInstance must be used within <ChartContainer>");return s}const Fa=20;function an({data:s,options:t,id:e}){var h;const i=ot(),n=B.useRef(null),r=B.useRef([]),a=B.useRef([]),l=B.useRef([]);return B.useLayoutEffect(()=>{const d=i.addBarSeries({...t,layers:s.length,id:e});return n.current=d,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),l.current=new Array(s.length).fill(null),()=>{i.removeSeries(d),n.current=null,r.current=[],a.current=[],l.current=[]}},[i,s.length,e]),B.useLayoutEffect(()=>{const d=n.current;d&&i.batch(()=>{for(let c=0;c<s.length;c++){const u=s[c],f=r.current[c]??0,m=a.current[c]??null;if(u.length===0){i.setSeriesData(d,[],c),r.current[c]=0,a.current[c]=null,l.current[c]=null;continue}const p=ut(u[0].time),g=ut(u[u.length-1].time),M=l.current[c]??null,v=m!==null&&m!==p,w=u.length-f;if(v&&w===0&&(M!==null&&M!==g))i.setSeriesData(d,u.slice(0,-1),c),i.appendData(d,u[u.length-1],c);else if(f===0||u.length<f||w>Fa||v)i.setSeriesData(d,u,c);else if(u.length===f)i.updateData(d,u[u.length-1],c);else for(let S=f;S<u.length;S++)i.appendData(d,u[S],c);r.current[c]=u.length,a.current[c]=p,l.current[c]=g}})},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(h=t==null?void 0:t.colors)==null?void 0:h.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const Wa=20;function Aa({data:s,options:t,id:e}){var h,d,c,u,f,m;const i=ot(),n=B.useRef(null),r=B.useRef(0),a=B.useRef(null),l=B.useRef(null);return B.useLayoutEffect(()=>{const p=i.addCandlestickSeries({...t,id:e});return n.current=p,()=>{i.removeSeries(p),n.current=null,r.current=0,a.current=null,l.current=null}},[i,e]),B.useLayoutEffect(()=>{const p=n.current;if(!p)return;if(s.length===0){i.setSeriesData(p,[]),r.current=0,a.current=null,l.current=null;return}const g=r.current,M=a.current,v=l.current,w=ut(s[0].time),y=ut(s[s.length-1].time),S=M!==null&&M!==w,x=s.length-g;if(S&&x===0&&(v!==null&&v!==y))i.setSeriesData(p,s.slice(0,-1)),i.appendData(p,s[s.length-1]);else if(g===0||s.length<g||x>Wa||S)i.setSeriesData(p,s);else if(s.length===g)i.updateData(p,s[s.length-1]);else for(let b=g;b<s.length;b++)i.appendData(p,s[b]);r.current=s.length,a.current=w,l.current=y},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,Array.isArray((h=t==null?void 0:t.up)==null?void 0:h.body)?t.up.body.join(","):(d=t==null?void 0:t.up)==null?void 0:d.body,Array.isArray((c=t==null?void 0:t.down)==null?void 0:c.body)?t.down.body.join(","):(u=t==null?void 0:t.down)==null?void 0:u.body,(f=t==null?void 0:t.up)==null?void 0:f.wick,(m=t==null?void 0:t.down)==null?void 0:m.wick,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const Ui=B.createContext(null),ve=Ui.Provider;function qe(){const s=B.useContext(Ui);if(!s)throw new Error("useTheme must be used within <ThemeProvider>");return s}function za(){return B.useContext(Ui)}function pi(s,t,e){const i=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const a of i)s.on(a,r);return()=>{for(const a of i)s.off(a,r)}},getSnapshot:e}}function on(s){const t=B.useMemo(()=>pi(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getVisibleRange()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}function ln(s){const t=B.useMemo(()=>pi(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getYRange()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Da(s,t){const e=B.useMemo(()=>{let i=s.getLastValue(t),n=i?s.yScale.valueToY(i.value):null;const r=()=>i,a=()=>{const l=s.getLastValue(t),h=l?s.yScale.valueToY(l.value):null;return(i==null?void 0:i.value)===(l==null?void 0:l.value)&&(i==null?void 0:i.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(i=l,n=h,!0)};return{subscribe:l=>{a();const h=()=>{a()&&l()};return s.on("dataUpdate",h),s.on("viewportChange",h),()=>{s.off("dataUpdate",h),s.off("viewportChange",h)}},getSnapshot:r}},[s,t]);return B.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Ea(s,t){const e=B.useMemo(()=>pi(s,"dataUpdate",()=>s.getPreviousClose(t)),[s,t]);return B.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Je(s){const t=B.useMemo(()=>pi(s,"crosshairMove",()=>s.getCrosshairPosition()),[s]);return B.useSyncExternalStore(t.subscribe,t.getSnapshot)}const Va=(s,t)=>t==="volume"?te(s):Vi(s);function hn({sort:s="none",format:t=Va,children:e}){const i=ot(),n=qe(),r=Je(i),[,a]=B.useState(0);B.useLayoutEffect(()=>{const f=()=>a(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&a(m=>m+1),()=>{i.off("overlayChange",f)}},[i]);const l=rn(i,{sort:s,cacheKey:"infobar-last"});let h=l,d=l.length===0?0:Math.max(...l.map(f=>f.data.time)),c=!1;if(r!==null){const f=_i(i,{time:r.time,sort:s,cacheKey:"infobar-hover"});f.length>0&&(h=f,d=r.time,c=!0)}if(h.length===0)return null;if(e)return k.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:h,time:d,isHover:c})});const u=i.getDataInterval();return k.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[k.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:Ge(d,u)}),h.map(f=>{if("open"in f.data){const g=f.data,M=g.close>=g.open,v=gt(M?n.candlestick.up.body:n.candlestick.down.body);return k.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[k.jsx(Le,{label:"O",display:t(g.open,"open"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"H",display:t(g.high,"high"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"L",display:t(g.low,"low"),color:v,dim:n.axis.textColor}),k.jsx(Le,{label:"C",display:t(g.close,"close"),color:v,dim:n.axis.textColor}),g.volume!=null&&k.jsx(Le,{label:"V",display:t(g.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const p=f.data;return k.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[k.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.color,flexShrink:0}}),k.jsx("span",{style:{color:f.color,fontWeight:500},children:t(p.value,"value")})]},f.id)})]})}function Le({label:s,display:t,color:e,dim:i}){return k.jsxs(k.Fragment,{children:[k.jsx("span",{style:{color:i,opacity:.5,marginLeft:5},children:s}),k.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function Ya({chart:s,isolatedIdRef:t,setIsolatedId:e}){const i=[],n=s.getSeriesIds();for(const r of n){const a=s.getSeriesLayers(r);if(a){const l=s.getSeriesLabel(r);for(let h=0;h<a.length;h++){const d=`${r}_layer${h}`,c=s.isSeriesVisible(r)&&s.isLayerVisible(r,h);i.push(Ms({id:d,seriesId:r,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:a[h].color,isDisabled:!c,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=s.getSeriesColor(r);if(!l)continue;const h=s.getSeriesLabel(r),d=s.isSeriesVisible(r);i.push(Ms({id:r,seriesId:r,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!d,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}return i}function Ms(s){const{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,chart:l,isolatedIdRef:h,setIsolatedId:d}=s;return{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,toggle:()=>{i!==void 0?l.setLayerVisible(e,i,!l.isLayerVisible(e,i)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const f of l.getSeriesIds()){l.setSeriesVisible(f,!0);const m=l.getSeriesLayers(f);if(m)for(let p=0;p<m.length;p++)l.setLayerVisible(f,p,!0)}}),h.current=null,d(null);return}l.batch(()=>{for(const f of l.getSeriesIds()){const m=l.getSeriesLayers(f);if(m){l.setSeriesVisible(f,f===e);for(let p=0;p<m.length;p++)l.setLayerVisible(f,p,f===e&&p===i)}else l.setSeriesVisible(f,f===t)}}),h.current=t,d(t)}}}function cn({items:s,position:t="bottom",mode:e="toggle",children:i}){const n=ot(),r=qe(),[a,l]=B.useState(null),[h,d]=B.useState(0),c=B.useRef(a);c.current=a,B.useLayoutEffect(()=>{const g=()=>d(v=>v+1),M=()=>l(null);return n.on("overlayChange",g),n.on("seriesChange",M),n.getSeriesIds().length>0&&d(v=>v+1),()=>{n.off("overlayChange",g),n.off("seriesChange",M)}},[n]);const u=B.useMemo(()=>Ya({chart:n,isolatedIdRef:c,setIsolatedId:l}),[n,a,h]),f=t==="right",m={display:"flex",flexDirection:f?"column":"row",flexWrap:"wrap",gap:f?6:14,padding:f?"8px 6px":"6px 8px",alignItems:f?"flex-start":"center",justifyContent:f?"flex-start":"center",fontFamily:r.typography.fontFamily,fontSize:r.axis.fontSize,color:r.axis.textColor,pointerEvents:"auto",flexShrink:0};if(i)return u.length===0?null:k.jsx("div",{"data-legend":t,style:m,children:i({items:u})});if(s)return s.length===0?null:k.jsx("div",{"data-legend":t,style:m,children:s.map((g,M)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),k.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},M))});if(u.length===0)return null;const p=g=>{e==="isolate"||e==="solo"?g.isolate():g.toggle()};return k.jsx("div",{"data-legend":t,style:m,children:u.map(g=>k.jsxs("div",{onClick:()=>p(g),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:g.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),k.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},g.id))})}function un({data:s,height:t,style:e,className:i}){const n=ot(),r=qe(),a=B.useRef(null),l=B.useRef(null);B.useLayoutEffect(()=>{if(!a.current)return;const d=new Zs({container:a.current,chart:n,data:s,options:t!==void 0?{height:t}:void 0});return l.current=d,()=>{d.destroy(),l.current=null}},[n]),B.useEffect(()=>{var d;(d=l.current)==null||d.setData(s)},[s]),B.useEffect(()=>{var d;(d=l.current)==null||d.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??r.navigator.height;return k.jsx("div",{ref:a,className:i,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function ja(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function dn({seriesId:s,mode:t,format:e,position:i,children:n}){const r=t??"both",a=i??"bottom",l=e??te,h=ot(),d=h.getTheme(),[,c]=B.useState(0);B.useLayoutEffect(()=>{const p=()=>c(g=>g+1);return h.on("overlayChange",p),h.getSeriesIds().length>0&&p(),()=>{h.off("overlayChange",p)}},[h]);const u=ja(h,s),f=u!==null?h.getSliceInfo(u):null;if(!f||f.length===0)return null;if(n)return k.jsx(k.Fragment,{children:n({slices:f,mode:r,format:l})});const m=a==="overlay";return k.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":a,style:{display:"flex",flexDirection:"column",gap:6,padding:m?"8px 12px":"6px 10px",fontFamily:d.typography.fontFamily,fontSize:d.typography.fontSize,color:d.tooltip.textColor,pointerEvents:"auto"},children:f.map((p,g)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[k.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:p.color,flexShrink:0}}),k.jsx("span",{style:{flex:1,opacity:.8},children:p.label}),(r==="value"||r==="both")&&k.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:l(p.value)}),(r==="percent"||r==="both")&&k.jsxs("span",{style:{opacity:r==="percent"?1:.5,fontWeight:r==="percent"?600:400,fontSize:r==="percent"?d.typography.fontSize:d.axis.fontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[p.percent.toFixed(1),"%"]})]},g))})}function fn({children:s,sub:t,style:e}){const i=qe();return k.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:i.typography.fontFamily,fontSize:i.typography.fontSize,fontWeight:600,color:i.tooltip.textColor,pointerEvents:"none",...e},children:[s!=null&&s!==!1&&k.jsx("span",{children:s}),t!=null&&t!==!1&&k.jsx("span",{style:{fontWeight:400,color:i.axis.textColor,fontSize:i.axis.fontSize},children:t})]})}function Oa(s){let t=null,e=null,i=null,n=null,r=null;const a=[],l=h=>{if(B.isValidElement(h)&&h.type===B.Fragment){B.Children.forEach(h.props.children,l);return}if(B.isValidElement(h)){if(h.type===fn){t=h;return}if(h.type===cn){e=h;return}if(h.type===dn){const d=h;d.props.position==="overlay"?a.push(h):i=d;return}if(h.type===hn){n=h;return}if(h.type===un){r=h;return}}a.push(h)};return B.Children.forEach(s,l),{titleEl:t,legendEl:e,pieLegendEl:i,tooltipLegendEl:n,navigatorEl:r,overlay:a}}function mn({children:s,theme:t,axis:e,padding:i,gradient:n=!0,interactive:r,grid:a,headerLayout:l="overlay",perf:h,style:d,className:c}){var ht,Bt,wt,Ht,Me,Qe;const u=B.useRef(h),f=za(),m=t??f??void 0,p=B.useRef(null),g=B.useRef(null),[M,v]=B.useState(0);B.useLayoutEffect(()=>{if(!p.current||g.current)return;const nt={};return e&&(nt.axis=e),m&&(nt.theme=m),i&&(nt.padding=i),r!==void 0&&(nt.interactive=r),a!==void 0&&(nt.grid=a),u.current!==void 0&&(nt.perf=u.current),g.current=new Us(p.current,nt),v(St=>St+1),()=>{var St;(St=g.current)==null||St.destroy(),g.current=null}},[]),B.useEffect(()=>{g.current&&m&&g.current.setTheme(m)},[m]),B.useEffect(()=>{g.current&&e&&g.current.setAxis(e)},[(ht=e==null?void 0:e.y)==null?void 0:ht.width,(Bt=e==null?void 0:e.y)==null?void 0:Bt.min,(wt=e==null?void 0:e.y)==null?void 0:wt.max,(Ht=e==null?void 0:e.y)==null?void 0:Ht.visible,(Me=e==null?void 0:e.x)==null?void 0:Me.height,(Qe=e==null?void 0:e.x)==null?void 0:Qe.visible]);const w=B.useRef(null),[y,S]=B.useState(0),x=l==="overlay"?y:0;B.useEffect(()=>{const nt=g.current;if(!nt)return;const $t={top:((i==null?void 0:i.top)??20)+x,...(i==null?void 0:i.bottom)!==void 0?{bottom:i.bottom}:{},...(i==null?void 0:i.right)!==void 0?{right:i.right}:{},...(i==null?void 0:i.left)!==void 0?{left:i.left}:{}};nt.setPadding($t)},[i==null?void 0:i.top,i==null?void 0:i.bottom,typeof(i==null?void 0:i.right)=="object"?i.right.intervals:i==null?void 0:i.right,typeof(i==null?void 0:i.left)=="object"?i.left.intervals:i==null?void 0:i.left,x]),B.useEffect(()=>{g.current&&a!==void 0&&g.current.setGrid(a)},[a==null?void 0:a.visible]);const P=g.current,{titleEl:b,legendEl:R,pieLegendEl:L,tooltipLegendEl:T,navigatorEl:F,overlay:W}=Oa(s),V=(R==null?void 0:R.props.position)??"bottom",D=(L==null?void 0:L.props.position)??"bottom",j=V==="right"||D==="right",H=m??(P==null?void 0:P.getTheme()),[X,it]=(H==null?void 0:H.chartGradient)??["transparent","transparent"],U=(H==null?void 0:H.background)??"transparent",xt=n?`linear-gradient(to bottom, ${X} 0%, ${U} 70%, ${it} 100%)`:U;B.useLayoutEffect(()=>{if(l!=="overlay"){S(0);return}const nt=w.current;if(!nt){S(0);return}const St=()=>S(nt.getBoundingClientRect().height);St();const $t=new ResizeObserver(St);return $t.observe(nt),()=>$t.disconnect()},[b!==null,T!==null,l,P!==null]);const lt=(b||T)&&k.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":l==="overlay"?"":void 0,ref:w,style:l==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[b,T]}),It=k.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:P&&k.jsx(be.Provider,{value:P,children:k.jsxs(ve,{value:m??P.getTheme(),children:[l==="overlay"&&lt,k.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:W})]})})}),Q=l==="inline"?k.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[P&&lt&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:lt})}),It]}):It,Ot=P&&R&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:R})}),pt=P&&L&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:L})}),dt=P&&F&&k.jsx(be.Provider,{value:P,children:k.jsx(ve,{value:m??P.getTheme(),children:F})});return k.jsxs("div",{className:c,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:xt,...d},children:[k.jsxs("div",{style:{display:"flex",flexDirection:j?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Q,Ot,pt]}),dt]})}const Ha=20;function gn({data:s,options:t,id:e}){var h,d;const i=ot(),n=B.useRef(null),r=B.useRef([]),a=B.useRef([]),l=B.useRef([]);return B.useLayoutEffect(()=>{const c=i.addLineSeries({...t,layers:s.length,id:e});return n.current=c,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),l.current=new Array(s.length).fill(null),()=>{i.removeSeries(c),n.current=null,r.current=[],a.current=[],l.current=[]}},[i,s.length,e]),B.useLayoutEffect(()=>{const c=n.current;c&&i.batch(()=>{for(let u=0;u<s.length;u++){const f=s[u],m=r.current[u]??0,p=a.current[u]??null;if(f.length===0){i.setSeriesData(c,[],u),r.current[u]=0,a.current[u]=null,l.current[u]=null;continue}const g=ut(f[0].time),M=ut(f[f.length-1].time),v=l.current[u]??null,w=p!==null&&p!==g,y=f.length-m;if(w&&y===0&&(v!==null&&v!==M))i.setSeriesData(c,f.slice(0,-1),u),i.appendData(c,f[f.length-1],u);else if(m===0||f.length<m||y>Ha||w)i.setSeriesData(c,f,u);else if(f.length===m)i.updateData(c,f[f.length-1],u);else for(let x=m;x<f.length;x++)i.appendData(c,f[x],u);r.current[u]=f.length,a.current[u]=g,l.current[u]=M}})},[i,s]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(h=t==null?void 0:t.colors)==null?void 0:h.join(","),t==null?void 0:t.strokeWidth,(d=t==null?void 0:t.area)==null?void 0:d.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}function $a({data:s,options:t,id:e}){var r,a,l,h,d,c,u,f,m,p;const i=ot(),n=B.useRef(null);return B.useLayoutEffect(()=>{const g=i.addPieSeries({...t,id:e});return n.current=g,()=>{i.removeSeries(g),n.current=null}},[i,e]),B.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(r=t==null?void 0:t.sliceLabels)==null?void 0:r.mode,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.minSliceAngle,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.elbowLen,(c=t==null?void 0:t.sliceLabels)==null?void 0:c.legPad,(u=t==null?void 0:t.sliceLabels)==null?void 0:u.labelGap,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.distance,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.railWidth,(p=t==null?void 0:t.sliceLabels)==null?void 0:p.balanceSides]),B.useLayoutEffect(()=>{n.current&&i.setSeriesData(n.current,s)},[i,s]),null}function Na(){const s=ot(),t=Je(s);if(!t)return null;const e=s.getTheme(),i=s.getDataInterval(),n={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.axis.fontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return k.jsxs(k.Fragment,{children:[k.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:s.yScale.formatY(t.y)}),k.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:Ge(t.time,i)})]})}const Xa=["0","1","2","3","4","5","6","7","8","9"];function _a(s){const t=[];for(const e of s)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function pn({value:s,format:t,locale:e="en-US",spinDuration:i=350,className:n,style:r}){const l=B.useMemo(()=>{if(typeof t=="function")return t;const d=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return c=>d.format(c)},[t,e])(s),h=_a(l);return k.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:h.map((d,c)=>d.type==="digit"?k.jsx(Ua,{digit:parseInt(d.value,10),duration:i},`d${c}`):k.jsx("span",{style:{display:"inline-block"},children:d.value},`s${c}`))})}function Ua({digit:s,duration:t}){const e=B.useRef(!1);return B.useEffect(()=>{e.current=!0},[]),k.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:k.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-s*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Xa.map(i=>k.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:i},i))})})}function Ga(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Ka=160,qa=70;function Ja({seriesId:s,format:t=te,children:e}){const i=ot(),n=Je(i),[,r]=B.useState(0);B.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),()=>{i.off("overlayChange",f)}},[i]);const a=Ga(i,s),l=a!==null?i.getHoverInfo(a):null;if(!l||!n)return null;const h=i.getTheme(),d=i.getMediaSize();if(e)return k.jsx(Qa,{x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,children:e({info:l,format:t})});const{left:c,top:u}=Ke({x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,tooltipWidth:Ka,tooltipHeight:qa,offsetX:16,offsetY:16});return k.jsxs("div",{style:{position:"absolute",left:c,top:u,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:l.color,flexShrink:0}}),k.jsx("span",{style:{fontWeight:600},children:l.label})]}),k.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[k.jsx("span",{style:{opacity:.6},children:t(l.value)}),k.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function Qa({x:s,y:t,chartWidth:e,chartHeight:i,children:n}){const r=B.useRef(null),[a,l]=B.useState(null);B.useEffect(()=>{const d=r.current;if(!d||typeof ResizeObserver>"u")return;const c=new ResizeObserver(u=>{var m;const f=(m=u[0])==null?void 0:m.contentRect;f&&l(p=>p&&p.width===f.width&&p.height===f.height?p:{width:f.width,height:f.height})});return c.observe(d),()=>c.disconnect()},[]);const h=a?Ke({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:a.width,tooltipHeight:a.height,offsetX:16,offsetY:16}):{left:0,top:0};return k.jsx("div",{ref:r,"data-measured":a?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:a?"visible":"hidden"},children:n})}function Za(s,t){if(s.startsWith("rgba")||!s.startsWith("#"))return s;const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function to(s){if(s.length<2)return{value:0,pct:0,positive:!0};const t=s[0].value,i=s[s.length-1].value-t,n=t!==0?i/t*100:0;return{value:i,pct:n,positive:i>=0}}function eo({data:s,theme:t,variant:e="line",valuePosition:i="right",formatValue:n=te,label:r,sublabel:a,color:l,negativeColor:h,area:d,areaFill:c,width:u=140,height:f=48,strokeWidth:m=1.5,gradient:p=!0,style:g}){const M=(d==null?void 0:d.visible)??c??!0,v=s.length>0?s[s.length-1].value:0,w=B.useMemo(()=>to(s),[s]),y=l??t.seriesColors[0],S=h??gt(t.candlestick.down.body),x=gt(w.positive?t.candlestick.up.body:t.candlestick.down.body),P=i!=="none"&&k.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[r&&k.jsx("div",{style:{fontSize:t.axis.fontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),k.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(v)}),a!==void 0?k.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:a}):k.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:x,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[w.positive?"+":"",w.pct.toFixed(1),"%"]})]}),b=k.jsx("div",{style:{width:u,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:k.jsx(mn,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:{visible:!1},children:e==="line"?k.jsx(gn,{data:[s],options:{colors:[y],strokeWidth:m,area:{visible:M},pulse:!1,stacking:"off"}}):k.jsx(an,{data:[s],options:{colors:[y,S],barWidthRatio:.7,stacking:"off"}})})});return k.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Za(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...g},children:[i==="left"&&P,b,i==="right"&&P]})}function bn({labelCount:s,minLabelSpacing:t}={}){const e=ot();on(e),B.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:s??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,s,t]);const i=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:a}=e.timeScale.niceTickValues(n),l=new Set(r),d=B.useRef(new Map).current,c=performance.now();for(const f of r)d.has(f)?d.get(f).opacity=1:d.set(f,{opacity:1,addedAt:c});for(const[f,m]of d)l.has(f)||m.opacity!==0&&(m.opacity=0,m.fadedAt=c);for(const[f,m]of d)m.opacity===0&&m.fadedAt!==void 0&&c-m.fadedAt>600&&d.delete(f);const u=Array.from(d.entries());return k.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:u.map(([f,m])=>{const p=e.timeScale.timeToX(f);return k.jsx("span",{style:{position:"absolute",left:p,transform:"translateX(-50%)",color:ji(i,"x"),fontSize:Yi(i,"x"),fontFamily:i.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:Ge(f,a)},f)})})}const io=(s,t)=>t==="volume"?te(s):Vi(s);function so({sort:s="none",format:t=io,children:e}){const i=ot(),n=Je(i),[,r]=B.useState(0);if(B.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&r(m=>m+1),()=>{i.off("overlayChange",f)}},[i]),!n)return null;const a=_i(i,{time:n.time,sort:s,cacheKey:"tooltip"});if(a.length===0)return null;const l=i.getTheme(),h=i.getDataInterval(),d=i.getMediaSize(),c=d.width-i.yAxisWidth,u=d.height-i.xAxisHeight;return e?k.jsx(no,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,children:e({snapshots:a,time:n.time})}):k.jsx(ro,{snapshots:a,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,dataInterval:h,format:t})}function no({x:s,y:t,chartWidth:e,chartHeight:i,theme:n,children:r}){const a=B.useRef(null),[l,h]=B.useState(null);B.useEffect(()=>{const c=a.current;if(!c||typeof ResizeObserver>"u")return;const u=new ResizeObserver(f=>{var p;const m=(p=f[0])==null?void 0:p.contentRect;m&&h(g=>g&&g.width===m.width&&g.height===m.height?g:{width:m.width,height:m.height})});return u.observe(c),()=>u.disconnect()},[]);const d=l?Ke({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return k.jsx("div",{ref:a,"data-measured":l?"true":"false",style:{position:"absolute",left:d.left,top:d.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.tooltip.fontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:l?"visible":"hidden"},children:r})}function ro({snapshots:s,displayTime:t,x:e,y:i,chartWidth:n,chartHeight:r,theme:a,dataInterval:l,format:h}){const d=s.some(w=>"open"in w.data),c=s.filter(w=>!("open"in w.data)).length,u=160,f=d?140:40+c*22,{left:m,top:p}=Ke({x:e,y:i,chartWidth:n,chartHeight:r,tooltipWidth:u,tooltipHeight:f}),g=a.tooltip.background,M=a.tooltip.borderColor;return k.jsxs("div",{style:{position:"absolute",left:m,top:p,pointerEvents:"none",background:g,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${M}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:a.tooltip.fontSize,fontFamily:a.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:a.tooltip.textColor,width:u,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[k.jsxs("div",{style:{fontSize:a.axis.fontSize,color:a.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${M}`,letterSpacing:"0.02em"},children:[Is(t)," ",Ge(t,l)]}),s.map(w=>{if("open"in w.data){const x=w.data,P=x.close>=x.open,b=gt(P?a.candlestick.up.body:a.candlestick.down.body);return k.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[k.jsx(Ie,{label:"Open",color:b,display:h(x.open,"open")}),k.jsx(Ie,{label:"High",color:b,display:h(x.high,"high")}),k.jsx(Ie,{label:"Low",color:b,display:h(x.low,"low")}),k.jsx(Ie,{label:"Close",color:b,display:h(x.close,"close")}),x.volume!=null&&k.jsx(Ie,{label:"Volume",color:a.tooltip.textColor,display:h(x.volume,"volume")})]},w.id)}const S=w.data;return k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[k.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:w.color,flexShrink:0}}),k.jsx("span",{style:{opacity:.6,flex:1},children:w.label??"Value"}),k.jsx("span",{style:{fontWeight:600,color:w.color},children:h(S.value,"value")})]},w.id)})]})}function Ie({label:s,color:t,display:e}){return k.jsxs(k.Fragment,{children:[k.jsx("span",{style:{opacity:.5},children:s}),k.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function ao({format:s,labelCount:t,minLabelSpacing:e}={}){const i=ot();ln(i),B.useLayoutEffect(()=>(i.yScale.setFormat(s??null),()=>i.yScale.setFormat(null)),[i,s]),B.useLayoutEffect(()=>(i.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{i.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[i,t,e]);const n=i.getTheme(),r=i.yScale.niceTickValues(),a=new Set(r),h=B.useRef(new Map).current,d=performance.now();for(const u of r)h.has(u)?h.get(u).opacity=1:h.set(u,{opacity:1,addedAt:d});for(const[u,f]of h)a.has(u)||f.opacity!==0&&(f.opacity=0,f.fadedAt=d);for(const[u,f]of h)f.opacity===0&&f.fadedAt!==void 0&&d-f.fadedAt>600&&h.delete(u);const c=Array.from(h.entries());return k.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:i.xAxisHeight,width:i.yAxisWidth,pointerEvents:"none"},children:c.map(([u,f])=>{const m=i.yScale.valueToY(u);return k.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:ji(n,"y"),fontSize:Yi(n,"y"),fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:i.yScale.formatY(u)},u)})})}function oo(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const i=s.getSeriesIdsByType("time",{visibleOnly:!0});return i.length>0?i[0]:null}function lo({seriesId:s,color:t,format:e,children:i}){const n=ot();B.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=B.useState(0);B.useLayoutEffect(()=>{const y=()=>r(S=>S+1);return n.on("overlayChange",y),n.on("viewportChange",y),n.getSeriesIds().length>0&&r(S=>S+1),()=>{n.off("overlayChange",y),n.off("viewportChange",y)}},[n]);const a=oo(n,s),l=a!==null?n.getStackedLastValue(a):null,h=a!==null?n.getPreviousClose(a):null,d=n.yScale.getRange(),c=d.max-d.min,u=c<.1?6:c<10?4:c<1e3?2:0,f=B.useMemo(()=>{if(e)return e;const y=new Intl.NumberFormat("en-US",{minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!1});return S=>y.format(S)},[e,u]);if(!l||a===null)return null;const{value:m,isLive:p}=l,g=n.getTheme(),M=n.yScale.valueToY(m),v=h===null?"neutral":m>h?"up":m<h?"down":"neutral";let w;return p?t?w=t:w=v==="up"?g.yLabel.upBackground:v==="down"?g.yLabel.downBackground:g.yLabel.neutralBackground:w=g.axis.textColor,i?k.jsx(k.Fragment,{children:i({value:m,y:M,bgColor:w,isLive:p,direction:v,format:f})}):k.jsxs(k.Fragment,{children:[k.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:M,height:0,borderTop:`1px dashed ${w}`,opacity:.5,pointerEvents:"none",zIndex:2}}),k.jsx("div",{style:{position:"absolute",right:4,top:M,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:w,color:g.yLabel.textColor,fontSize:g.yLabel.fontSize,fontFamily:g.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:k.jsx(pn,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=an;exports.CandlestickSeries=Aa;exports.ChartContainer=mn;exports.ChartInstance=Us;exports.Crosshair=Na;exports.InfoBar=hn;exports.Legend=cn;exports.LineSeries=gn;exports.Navigator=un;exports.NavigatorController=Zs;exports.NumberFlow=pn;exports.PieLegend=dn;exports.PieSeries=$a;exports.PieTooltip=Ja;exports.Sparkline=eo;exports.ThemeProvider=ve;exports.TimeAxis=bn;exports.Title=fn;exports.Tooltip=so;exports.XAxis=bn;exports.YAxis=ao;exports.YLabel=lo;exports.andromeda=aa;exports.autoGradient=E;exports.ayuMirage=oa;exports.buildHoverSnapshots=_i;exports.buildLastSnapshots=rn;exports.catppuccin=la;exports.computeTooltipPosition=Ke;exports.createTheme=J;exports.darkTheme=Ns;exports.detectInterval=Ls;exports.dracula=ha;exports.formatCompact=te;exports.formatDate=Is;exports.formatPriceAdaptive=Vi;exports.formatTime=Ge;exports.githubLight=ca;exports.gruvbox=ua;exports.handwritten=da;exports.highContrast=ga;exports.lavenderMist=pa;exports.lightPink=ba;exports.lightTheme=ra;exports.materialPalenight=va;exports.minimalLight=wa;exports.mintBreeze=Sa;exports.monokaiPro=Ma;exports.nightOwl=ka;exports.normalizeTime=ut;exports.oneDarkPro=Ca;exports.panda=Ta;exports.peachCream=Ra;exports.quietLight=La;exports.resolveAxisFontSize=Yi;exports.resolveAxisTextColor=ji;exports.resolveCandlestickBodyColor=gt;exports.rosePineDawn=Ia;exports.sandDune=Ba;exports.solarizedLight=Pa;exports.useChartInstance=ot;exports.useCrosshairPosition=Je;exports.useLastYValue=Da;exports.usePreviousClose=Ea;exports.useTheme=qe;exports.useVisibleRange=on;exports.useYRange=ln;
package/dist/index.js CHANGED
@@ -4495,9 +4495,13 @@ const Na = {
4495
4495
  theme: {
4496
4496
  background: "#fdf5e6",
4497
4497
  chartGradient: ["#fef6e3", "#fdf5e6"],
4498
+ // Caveat reads larger than monospace at the same px size, but `18` was
4499
+ // overshooting — sidebar items and prop descriptions sat ~50 % taller
4500
+ // than every other theme. `15` lands in the same visual weight class
4501
+ // while still feeling distinctly handwritten.
4498
4502
  typography: {
4499
4503
  fontFamily: Ar,
4500
- fontSize: 18
4504
+ fontSize: 15
4501
4505
  },
4502
4506
  grid: {
4503
4507
  color: "rgba(180,170,150,0.3)",
@@ -4801,7 +4805,9 @@ const Na = {
4801
4805
  ],
4802
4806
  bands: { upper: "#6bc5e0", lower: "#d47084" },
4803
4807
  crosshair: { color: "rgba(99,119,119,0.4)", labelBackground: "#1d3b53" },
4804
- axis: { textColor: "#495a5a" },
4808
+ // Hue nudged from cyan (`#495a5a`) toward navy so the muted text shares
4809
+ // the page bg's blue family instead of reading as a separate teal-grey.
4810
+ axis: { textColor: "#4d5a6c" },
4805
4811
  tooltip: { background: "rgba(1,22,39,0.92)", textColor: "#d6deeb", borderColor: "rgba(31,52,72,0.6)" },
4806
4812
  typography: { fontFamily: bi },
4807
4813
  fontUrl: vi
@@ -4893,6 +4899,10 @@ const Na = {
4893
4899
  name: "Quiet Light",
4894
4900
  description: "Subdued and easy on the eyes",
4895
4901
  background: "#f5f5f5",
4902
+ // Pin the gradient top stop instead of letting `createTheme` derive it
4903
+ // from `lightenHex(bg, 0.06)` — that landed at `#ffffff`, which read as
4904
+ // a hard white seam against the rest of the chrome.
4905
+ chartGradient: ["#fdfdfd", "#f5f5f5"],
4896
4906
  grid: { color: "rgba(200,200,200,0.5)" },
4897
4907
  candlestick: {
4898
4908
  up: { body: D("#448c27"), wick: "#448c27" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wick-charts/react",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "High-performance canvas timeseries charts for React — candlestick, line, bar, pie. Tree-shakeable, zero runtime deps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,7 +49,7 @@
49
49
  "react-dom": ">=18.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@wick-charts/core": "^0.3.2"
52
+ "@wick-charts/core": "^0.3.3"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "vite build"