diff --git a/websites/kibo.money/index.html b/websites/kibo.money/index.html index 796863e0e..3dc986890 100644 --- a/websites/kibo.money/index.html +++ b/websites/kibo.money/index.html @@ -920,10 +920,15 @@ align-items: center; gap: 0.5rem; + &[data-size="sm"] { + font-size: var(--font-size-sm); + line-height: var(--line-height-sm); + } + &[data-size="xs"] { font-size: var(--font-size-xs); line-height: var(--line-height-xs); - font-weight: 500; + font-weight: 450; } > div.field { @@ -940,6 +945,10 @@ > hr { min-width: 2rem; + fieldset[data-size="sm"] & { + min-width: 1.5rem; + } + fieldset[data-size="xs"] & { min-width: 1rem; } @@ -954,6 +963,10 @@ display: flex; gap: 1.5rem; + fieldset[data-size="xs"] & { + gap: 1.25rem; + } + fieldset[data-size="xs"] & { gap: 1rem; } @@ -983,6 +996,9 @@ padding-bottom: 1rem; overflow-x: auto; min-width: 0; + font-size: var(--font-size-sm); + line-height: var(--line-height-sm); + height: 2rem; > div { flex: 0; @@ -1031,6 +1047,17 @@ min-height: 0; height: 100%; margin-right: var(--negative-main-padding); + margin-left: var(--negative-main-padding); + + fieldset { + padding-left: var(--main-padding); + padding-top: 0.5rem; + z-index: 10; + position: absolute; + left: 0; + top: 0; + gap: 0; + } } > .panes { diff --git a/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/script.js b/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/script.js index 03f0c6c27..2b815fa1d 100644 --- a/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/script.js +++ b/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/script.js @@ -1,8 +1,8 @@ // @ts-nocheck /*! * @license - * TradingView Lightweight Charts™ v5.0.5-treeshaked-dev+202504031205 + * TradingView Lightweight Charts™ v5.0.5-dev+202504041513 * Copyright (c) 2025 TradingView, Inc. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ -const t={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var i,s;function n(t,i){const s={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function l(t){if(null===t)throw new Error("Value is null");return t}function a(t){return l(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(s||(s={}));class o{constructor(){this.t=[]}i(t,i,s){const n={h:t,l:i,o:!0===s};this.t.push(n)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,s){const n=[...this.t];this.t=this.t.filter((t=>!t.o)),n.forEach((n=>n.h(t,i,s)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:_(t[i],s[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?p(e):e);return s}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,s){return void 0===i&&(i=w),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class b{constructor(t){this.M={S:1,P:5,C:NaN,T:"",k:"",R:"",D:"",V:0,I:0,A:0,B:0,L:0},this.O=t}N(){const t=this.M,i=this.F(),s=this.W();return t.C===i&&t.k===s||(t.C=i,t.k=s,t.T=g(i,s),t.B=2.5/12*i,t.V=t.B,t.I=i/12*t.P,t.A=i/12*t.P,t.L=0),t.R=this.H(),t.D=this.$(),this.M}H(){return this.O.N().layout.textColor}$(){return this.O.U()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function M(t){return t<0?0:t>255?255:Math.round(t)||0}function x(t){return.199*t[0]+.687*t[1]+.114*t[2]}class S{constructor(t,i){this.j=new Map,this.Y=t,i&&(this.j=i)}Z(t,i){if("transparent"===t)return t;const s=this.X(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}q(t){const i=this.X(t);return{K:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,G:x(i)>160?"black":"white"}}J(t){return x(this.X(t))}tt(t,i,s){const[n,e,r,h]=this.X(t),[l,a,o,_]=this.X(i),u=[M(n+s*(l-n)),M(e+s*(a-e)),M(r+s*(o-r)),(c=h+s*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}X(t){const i=this.j.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),n=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.j.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.j.set(t,e),e}}class y{constructor(){this.it=[]}st(t){this.it=t}nt(t,i,s){this.it.forEach((n=>{n.nt(t,i,s)}))}}class P{nt(t,i,s){t.useBitmapCoordinateSpace((t=>this.et(t,i,s)))}}class C extends P{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.rt||null===this.rt.lt)return;const n=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let l=n.to-1;l>=n.from;--l){const n=e.ot[l],a=Math.round(n._t*i)+r,o=n.ut*s,_=h*s+r;t.moveTo(a,o),t.arc(a,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function T(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const k={from:0,to:1};class R{constructor(t,i,s){this.bt=new y,this.Mt=[],this.xt=[],this.St=!0,this.O=t,this.yt=i,this.Pt=s,this.bt.st(this.Mt)}Ct(t){this.Tt(),this.St=!0}kt(){return this.St&&(this.Rt(),this.St=!1),this.bt}Tt(){const t=this.Pt.Dt();t.length!==this.Mt.length&&(this.xt=t.map(T),this.Mt=this.xt.map((t=>{const i=new C;return i.ht(t),i})),this.bt.st(this.Mt))}Rt(){const t=2===this.yt.N().mode||!this.yt.Et(),i=this.Pt.zt(),s=this.yt.Vt(),n=this.O.It();this.Tt(),i.forEach(((i,e)=>{const r=this.xt[e],h=i.At(s),l=i.Bt();!t&&null!==h&&i.Et()&&null!==l?(r.vt=h.Lt,r.ft=h.ft,r.ct=h.Ot,r.ot[0].gt=h.gt,r.ot[0].ut=i.Ft().Nt(h.gt,l.Wt),r.dt=h.Ht??this.O.$t(r.ot[0].ut/i.Ft().Ut()),r.ot[0].wt=s,r.ot[0]._t=n.jt(s),r.lt=k):r.lt=null}))}}class D extends P{constructor(t){super(),this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;const h=this.Yt.Zt.Et,l=this.Yt.Xt.Et;if(!h&&!l)return;const a=Math.round(this.Yt._t*s),o=Math.round(this.Yt.ut*r);t.lineCap="butt",h&&a>=0&&(t.lineWidth=Math.floor(this.Yt.Zt.ct*s),t.strokeStyle=this.Yt.Zt.R,t.fillStyle=this.Yt.Zt.R,n(t,this.Yt.Zt.qt),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,a,0,i.height)),l&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Xt.ct*r),t.strokeStyle=this.Yt.Xt.R,t.fillStyle=this.Yt.Xt.R,n(t,this.Yt.Xt.qt),e(t,o,0,i.width))}}class E{constructor(t,i){this.St=!0,this.Kt={Zt:{ct:1,qt:0,R:"",Et:!1},Xt:{ct:1,qt:0,R:"",Et:!1},_t:0,ut:0},this.Gt=new D(this.Kt),this.Jt=t,this.Pt=i}Ct(){this.St=!0}kt(t){return this.St&&(this.Rt(),this.St=!1),this.Gt}Rt(){const t=this.Jt.Et(),i=this.Pt.Qt().N().crosshair,s=this.Kt;if(2===i.mode)return s.Xt.Et=!1,void(s.Zt.Et=!1);s.Xt.Et=t&&this.Jt.ti(this.Pt),s.Zt.Et=t&&this.Jt.ii(),s.Xt.ct=i.horzLine.width,s.Xt.qt=i.horzLine.style,s.Xt.R=i.horzLine.color,s.Zt.ct=i.vertLine.width,s.Zt.qt=i.vertLine.style,s.Zt.R=i.vertLine.color,s._t=this.Jt.si(),s.ut=this.Jt.ni()}}function z(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function V(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function I(t,i,s,n,e,r){t.beginPath(),t.roundRect?t.roundRect(i,s,n,e,r):(t.lineTo(i+n-r[1],s),0!==r[1]&&t.arcTo(i+n,s,i+n,s+r[1],r[1]),t.lineTo(i+n,s+e-r[2]),0!==r[2]&&t.arcTo(i+n,s+e,i+n-r[2],s+e,r[2]),t.lineTo(i+r[3],s+e),0!==r[3]&&t.arcTo(i,s+e,i,s+e-r[3],r[3]),t.lineTo(i,s+r[0]),0!==r[0]&&t.arcTo(i,s,i+r[0],s,r[0]))}function A(t,i,s,n,e,r,h=0,l=[0,0,0,0],a=""){if(t.save(),!h||!a||a===r)return I(t,i,s,n,e,l),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;I(t,i+o,s+o,n-h,e-h,(_=-o,l.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==a&&(t.lineWidth=h,t.strokeStyle=a,t.closePath(),t.stroke()),t.restore()}function B(t,i,s,n,e,r,h){t.save(),t.globalCompositeOperation="copy";const l=t.createLinearGradient(0,0,0,e);l.addColorStop(0,r),l.addColorStop(1,h),t.fillStyle=l,t.fillRect(i,s,n,e),t.restore()}class L{constructor(t,i){this.ht(t,i)}ht(t,i){this.Yt=t,this.ei=i}Ut(t,i){return this.Yt.Et?t.C+t.B+t.V:0}nt(t,i,s,n){if(!this.Yt.Et||0===this.Yt.ri.length)return;const e=this.Yt.R,r=this.ei.K,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.T;const l=this.hi(t,i,s,n),a=l.li;return l.ai?A(h,a.oi,a._i,a.ui,a.ci,r,a.di,[a.ft,0,0,a.ft],r):A(h,a.fi,a._i,a.ui,a.ci,r,a.di,[0,a.ft,a.ft,0],r),this.Yt.pi&&(h.fillStyle=e,h.fillRect(a.fi,a.mi,a.wi-a.fi,a.gi)),this.Yt.bi&&(h.fillStyle=i.D,h.fillRect(l.ai?a.Mi-a.di:0,a._i,a.di,a.xi-a._i)),l}));t.useMediaCoordinateSpace((({context:t})=>{const s=h.Si;t.font=i.T,t.textAlign=h.ai?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Yt.ri,s.yi,(s._i+s.xi)/2+s.Pi)}))}hi(t,i,s,n){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,o=this.Yt.pi||!this.Yt.Ci?i.P:0,_=this.Yt.Ti?i.S:0,u=i.B+this.ei.ki,c=i.V+this.ei.Ri,d=i.I,f=i.A,p=this.Yt.ri,v=i.C,m=s.Di(e,p),w=Math.ceil(s.Ei(e,p)),g=v+u+c,b=i.S+d+f+w+o,M=Math.max(1,Math.floor(a));let x=Math.round(g*a);x%2!=M%2&&(x+=1);const S=_>0?Math.max(1,Math.floor(_*l)):0,y=Math.round(b*l),P=Math.round(o*l),C=this.ei.zi??this.ei.Vi,T=Math.round(C*a)-Math.floor(.5*a),k=Math.floor(T+M/2-x/2),R=k+x,D="right"===n,E=D?h.width-_:_,z=D?r.width-S:S;let V,I,A;return D?(V=z-y,I=z-P,A=E-o-d-_):(V=z+y,I=z+P,A=E+o+d),{ai:D,li:{_i:k,mi:T,xi:R,ui:y,ci:x,ft:2*l,di:S,oi:V,fi:z,wi:I,gi:M,Mi:r.width},Si:{_i:k/a,xi:R/a,yi:A,Pi:m}}}}class O{constructor(t){this.Ii={Vi:0,K:"#000",Ri:0,ki:0},this.Ai={ri:"",Et:!1,pi:!0,Ci:!1,Ht:"",R:"#FFF",bi:!1,Ti:!1},this.Bi={ri:"",Et:!1,pi:!1,Ci:!0,Ht:"",R:"#FFF",bi:!0,Ti:!0},this.St=!0,this.Li=new(t||L)(this.Ai,this.Ii),this.Oi=new(t||L)(this.Bi,this.Ii)}ri(){return this.Ni(),this.Ai.ri}Vi(){return this.Ni(),this.Ii.Vi}Ct(){this.St=!0}Ut(t,i=!1){return Math.max(this.Li.Ut(t,i),this.Oi.Ut(t,i))}Fi(){return this.Ii.zi||0}Wi(t){this.Ii.zi=t}Hi(){return this.Ni(),this.Ai.Et||this.Bi.Et}$i(){return this.Ni(),this.Ai.Et}kt(t){return this.Ni(),this.Ai.pi=this.Ai.pi&&t.N().ticksVisible,this.Bi.pi=this.Bi.pi&&t.N().ticksVisible,this.Li.ht(this.Ai,this.Ii),this.Oi.ht(this.Bi,this.Ii),this.Li}Ui(){return this.Ni(),this.Li.ht(this.Ai,this.Ii),this.Oi.ht(this.Bi,this.Ii),this.Oi}Ni(){this.St&&(this.Ai.pi=!0,this.Bi.pi=!1,this.ji(this.Ai,this.Bi,this.Ii))}}class N extends O{constructor(t,i,s){super(),this.Jt=t,this.Yi=i,this.Zi=s}ji(t,i,s){if(t.Et=!1,2===this.Jt.N().mode)return;const n=this.Jt.N().horzLine;if(!n.labelVisible)return;const e=this.Yi.Bt();if(!this.Jt.Et()||this.Yi.Xi()||null===e)return;const r=this.Yi.qi().q(n.labelBackgroundColor);s.K=r.K,t.R=r.G;const h=2/12*this.Yi.C();s.ki=h,s.Ri=h;const l=this.Zi(this.Yi);s.Vi=l.Vi,t.ri=this.Yi.Ki(l.gt,e),t.Et=!0}}const F=/[1-9]/g;class W{constructor(){this.Yt=null}ht(t){this.Yt=t}nt(t,i){if(null===this.Yt||!1===this.Yt.Et||0===this.Yt.ri.length)return;const s=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.T,Math.round(i.Gi.Ei(t,l(this.Yt).ri,F)))));if(s<=0)return;const n=i.Ji,e=s+2*n,r=e/2,h=this.Yt.Qi;let a=this.Yt.Vi,o=Math.floor(a-r)+.5;o<0?(a+=Math.abs(0-o),o=Math.floor(a-r)+.5):o+e>h&&(a-=Math.abs(h-(o+e)),o=Math.floor(a-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.P+i.B+i.C+i.V);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=l(this.Yt);t.fillStyle=e.K;const r=Math.round(o*s),h=Math.round(0*n),a=Math.round(_*s),c=Math.round(u*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(a-d,c),t.arcTo(a,c,a,c-d,d),t.lineTo(a,h),t.fill(),e.pi){const r=Math.round(e.Vi*s),l=h,a=Math.round((l+i.P)*n);t.fillStyle=e.R;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,l,o,a-l)}})),t.useMediaCoordinateSpace((({context:t})=>{const s=l(this.Yt),e=0+i.S+i.P+i.B+i.C/2;t.font=i.T,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.R;const r=i.Gi.Di(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.ri,0,0)}))}}class H{constructor(t,i,s){this.St=!0,this.Gt=new W,this.Kt={Et:!1,K:"#4c525e",R:"white",ri:"",Qi:0,Vi:NaN,pi:!0},this.yt=t,this.ts=i,this.Zi=s}Ct(){this.St=!0}kt(){return this.St&&(this.Rt(),this.St=!1),this.Gt.ht(this.Kt),this.Gt}Rt(){const t=this.Kt;if(t.Et=!1,2===this.yt.N().mode)return;const i=this.yt.N().vertLine;if(!i.labelVisible)return;const s=this.ts.It();if(s.Xi())return;t.Qi=s.Qi();const n=this.Zi();if(null===n)return;t.Vi=n.Vi;const e=s.ss(this.yt.Vt());t.ri=s.ns(l(e)),t.Et=!0;const r=this.ts.qi().q(i.labelBackgroundColor);t.K=r.K,t.R=r.G,t.pi=s.N().ticksVisible}}class ${constructor(){this.es=null,this.rs=0}hs(){return this.rs}ls(t){this.rs=t}Ft(){return this.es}os(t){this.es=t}_s(t){return[]}us(){return[]}Et(){return!0}}var U;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}(U||(U={}));class j extends ${constructor(t,i){super(),this.Pt=null,this.cs=NaN,this.ds=0,this.fs=!1,this.ps=new Map,this.vs=!1,this.ws=new WeakMap,this.gs=new WeakMap,this.bs=NaN,this.Ms=NaN,this.xs=NaN,this.Ss=NaN,this.ts=t,this.ys=i;this.Ps=((t,i)=>s=>{const n=i(),e=t();if(s===l(this.Pt).Cs())return{gt:e,Vi:n};{const t=l(s.Bt());return{gt:s.Ts(n,t),Vi:n}}})((()=>this.cs),(()=>this.Ms));const s=((t,i)=>()=>{const s=this.ts.It().ks(t()),n=i();return s&&Number.isFinite(n)?{wt:s,Vi:n}:null})((()=>this.ds),(()=>this.si()));this.Rs=new H(this,t,s)}N(){return this.ys}Ds(t,i){this.xs=t,this.Ss=i}Es(){this.xs=NaN,this.Ss=NaN}zs(){return this.xs}Vs(){return this.Ss}Is(t,i,s){this.vs||(this.vs=!0),this.fs=!0,this.As(t,i,s)}Vt(){return this.ds}si(){return this.bs}ni(){return this.Ms}Et(){return this.fs}Bs(){this.fs=!1,this.Ls(),this.cs=NaN,this.bs=NaN,this.Ms=NaN,this.Pt=null,this.Es(),this.Os()}Ns(t){let i=this.ws.get(t);i||(i=new E(this,t),this.ws.set(t,i));let s=this.gs.get(t);return s||(s=new R(this.ts,this,t),this.gs.set(t,s)),[i,s]}ti(t){return t===this.Pt&&this.ys.horzLine.visible}ii(){return this.ys.vertLine.visible}Fs(t,i){this.fs&&this.Pt===t||this.ps.clear();const s=[];return this.Pt===t&&s.push(this.Ws(this.ps,i,this.Ps)),s}us(){return this.fs?[this.Rs]:[]}Hs(){return this.Pt}Os(){this.ts.$s().forEach((t=>{this.ws.get(t)?.Ct(),this.gs.get(t)?.Ct()})),this.ps.forEach((t=>t.Ct())),this.Rs.Ct()}Us(t){return t&&!t.Cs().Xi()?t.Cs():null}As(t,i,s){this.js(t,i,s)&&this.Os()}js(t,i,s){const n=this.bs,e=this.Ms,r=this.cs,h=this.ds,l=this.Pt,a=this.Us(s);this.ds=t,this.bs=isNaN(t)?NaN:this.ts.It().jt(t),this.Pt=s;const o=null!==a?a.Bt():null;return null!==a&&null!==o?(this.cs=i,this.Ms=a.Nt(i,o)):(this.cs=NaN,this.Ms=NaN),n!==this.bs||e!==this.Ms||h!==this.ds||r!==this.cs||l!==this.Pt}Ls(){const t=this.ts.Ys().map((t=>t.Xs().Zs())).filter(v),i=0===t.length?null:Math.max(...t);this.ds=null!==i?i:NaN}Ws(t,i,s){let n=t.get(i);return void 0===n&&(n=new N(this,i,s),t.set(i,n)),n}}function Y(t){return"left"===t||"right"===t}class Z{constructor(t){this.qs=new Map,this.Ks=[],this.Gs=t}Js(t,i){const s=function(t,i){return void 0===t?i:{Qs:Math.max(t.Qs,i.Qs),tn:t.tn||i.tn}}(this.qs.get(t),i);this.qs.set(t,s)}sn(){return this.Gs}nn(t){const i=this.qs.get(t);return void 0===i?{Qs:this.Gs}:{Qs:Math.max(this.Gs,i.Qs),tn:i.tn}}en(){this.rn(),this.Ks=[{hn:0}]}ln(t){this.rn(),this.Ks=[{hn:1,Wt:t}]}an(t){this._n(),this.Ks.push({hn:5,Wt:t})}rn(){this._n(),this.Ks.push({hn:6})}un(){this.rn(),this.Ks=[{hn:4}]}cn(t){this.rn(),this.Ks.push({hn:2,Wt:t})}dn(t){this.rn(),this.Ks.push({hn:3,Wt:t})}fn(){return this.Ks}pn(t){for(const i of t.Ks)this.vn(i);this.Gs=Math.max(this.Gs,t.Gs),t.qs.forEach(((t,i)=>{this.Js(i,t)}))}static mn(){return new Z(2)}static wn(){return new Z(3)}vn(t){switch(t.hn){case 0:this.en();break;case 1:this.ln(t.Wt);break;case 2:this.cn(t.Wt);break;case 3:this.dn(t.Wt);break;case 4:this.un();break;case 5:this.an(t.Wt);break;case 6:this._n()}}_n(){const t=this.Ks.findIndex((t=>5===t.hn));-1!==t&&this.Ks.splice(t,1)}}const X=".";function q(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class K{constructor(t,i){if(i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.gn=i,this.bn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Mn(t)}bn(){if(this.xn=0,this.Yi>0&&this.gn>0){let t=this.Yi;for(;t>1;)t/=10,this.xn++}}Mn(t){const i=this.Yi/this.gn;let s=Math.floor(t),n="";const e=void 0!==this.xn?this.xn:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.xn);r>=i&&(r-=i,s+=1),n=X+q(+r.toFixed(this.xn)*this.gn,e)}else s=Math.round(s*i)/i,e>0&&(n=X+q(0,e));return s.toFixed(0)+n}}class G extends K{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class J{constructor(t){this.Sn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.yn(t):t<999995?i+this.yn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.yn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.yn(t/1e9)+"B")}yn(t){let i;const s=Math.pow(10,this.Sn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Sn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const Q=/[2-9]/g;class tt{constructor(t=50){this.Pn=0,this.Cn=1,this.Tn=1,this.kn={},this.Rn=new Map,this.Dn=t}En(){this.Pn=0,this.Rn.clear(),this.Cn=1,this.Tn=1,this.kn={}}Ei(t,i,s){return this.zn(t,i,s).width}Di(t,i,s){const n=this.zn(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}zn(t,i,s){const n=s||Q,e=String(i).replace(n,"0");if(this.Rn.has(e))return h(this.Rn.get(e)).Vn;if(this.Pn===this.Dn){const t=this.kn[this.Tn];delete this.kn[this.Tn],this.Rn.delete(t),this.Tn++,this.Pn--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.Rn.set(e,{Vn:r,In:this.Cn}),this.kn[this.Cn]=e,this.Pn++,this.Cn++),r}}class it{constructor(t){this.An=null,this.M=null,this.Bn="right",this.Ln=t}On(t,i,s){this.An=t,this.M=i,this.Bn=s}nt(t){null!==this.M&&null!==this.An&&this.An.nt(t,this.M,this.Ln,this.Bn)}}class st{constructor(t,i,s){this.Nn=t,this.Ln=new tt(50),this.Fn=i,this.O=s,this.F=-1,this.Gt=new it(this.Ln)}kt(){const t=this.O.Wn(this.Fn);if(null===t)return null;const i=t.Hn(this.Fn)?t.$n():this.Fn.Ft();if(null===i)return null;const s=t.Un(i);if("overlay"===s)return null;const n=this.O.jn();return n.C!==this.F&&(this.F=n.C,this.Ln.En()),this.Gt.On(this.Nn.Ui(),n,s),this.Gt}}class nt extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}Yn(t,i){if(!this.Yt?.Et)return null;const{ut:s,ct:n,Zn:e}=this.Yt;return i>=s-n-7&&i<=s+n+7?{Xn:this.Yt,Zn:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;if(!1===this.Yt.Et)return;const h=Math.round(this.Yt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.R,t.lineWidth=Math.floor(this.Yt.ct*s),n(t,this.Yt.qt),e(t,h,0,i.width))}}class et{constructor(t){this.qn={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,qt:0,Et:!1},this.Kn=new nt,this.St=!0,this.Gn=t,this.Jn=t.Qt(),this.Kn.ht(this.qn)}Ct(){this.St=!0}kt(){return this.Gn.Et()?(this.St&&(this.Qn(),this.St=!1),this.Kn):null}}class rt extends et{constructor(t){super(t)}Qn(){this.qn.Et=!1;const t=this.Gn.Ft(),i=t.te().te;if(2!==i&&3!==i)return;const s=this.Gn.N();if(!s.baseLineVisible||!this.Gn.Et())return;const n=this.Gn.Bt();null!==n&&(this.qn.Et=!0,this.qn.ut=t.Nt(n.Wt,n.Wt),this.qn.R=s.baseLineColor,this.qn.ct=s.baseLineWidth,this.qn.qt=s.baseLineStyle)}}class ht extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}ie(){return this.Yt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Yt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.se.x*i)+r,l=n.se.y*s;t.fillStyle=n.ne,t.beginPath();const a=Math.max(2,1.5*n.ee)*i;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.re,t.beginPath(),t.arc(h,l,n.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.he,t.beginPath(),t.arc(h,l,n.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{le:0,ae:.25,oe:4,_e:10,ue:.25,ce:0,de:.4,fe:.8},{le:.25,ae:.525,oe:10,_e:14,ue:0,ce:0,de:.8,fe:0},{le:.525,ae:1,oe:14,_e:14,ue:0,ce:0,de:0,fe:0}];class at{constructor(t){this.Gt=new ht,this.St=!0,this.pe=!0,this.ve=performance.now(),this.me=this.ve-1,this.we=t}ge(){this.me=this.ve-1,this.Ct()}be(){if(this.Ct(),2===this.we.N().lastPriceAnimation){const t=performance.now(),i=this.me-t;if(i>0)return void(i<650&&(this.me+=2600));this.ve=t,this.me=t+2600}}Ct(){this.St=!0}Me(){this.pe=!0}Et(){return 0!==this.we.N().lastPriceAnimation}xe(){switch(this.we.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.me}}kt(){return this.St?(this.Rt(),this.St=!1,this.pe=!1):this.pe&&(this.Se(),this.pe=!1),this.Gt}Rt(){this.Gt.ht(null);const t=this.we.Qt().It(),i=t.ye(),s=this.we.Bt();if(null===i||null===s)return;const n=this.we.Pe(!0);if(n.Ce||!i.Te(n.ke))return;const e={x:t.jt(n.ke),y:this.we.Ft().Nt(n.gt,s.Wt)},r=n.R,h=this.we.N().lineWidth,l=this.Re(this.De(),r);this.Gt.ht({ne:r,ee:h,re:l.re,he:l.he,ft:l.ft,se:e})}Se(){const t=this.Gt.ie();if(null!==t){const i=this.Re(this.De(),t.ne);t.re=i.re,t.he=i.he,t.ft=i.ft}}De(){return this.xe()?performance.now()-this.ve:2599}Ee(t,i,s,n){const e=s+(n-s)*i;return this.we.Qt().qi().Z(t,e)}Re(t,i){const s=t%2600/2600;let n;for(const t of lt)if(s>=t.le&&s<=t.ae){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.le)/(n.ae-n.le);return{re:this.Ee(i,e,n.ue,n.ce),he:this.Ee(i,e,n.de,n.fe),ft:(h=e,l=n.oe,a=n._e,l+(a-l)*h)};var h,l,a}}class ot extends et{constructor(t){super(t)}Qn(){const t=this.qn;t.Et=!1;const i=this.Gn.N();if(!i.priceLineVisible||!this.Gn.Et())return;const s=this.Gn.Pe(0===i.priceLineSource);s.Ce||(t.Et=!0,t.ut=s.Vi,t.R=this.Gn.ze(s.R),t.ct=i.priceLineWidth,t.qt=i.priceLineStyle)}}class _t extends O{constructor(t){super(),this.Jt=t}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.Jt;if(!n.Et())return;const e=n.N(),r=e.lastValueVisible,h=""!==n.Ve(),l=0===e.seriesLastValueMode,a=n.Pe(!1);if(a.Ce)return;r&&(t.ri=this.Ie(a,r,l),t.Et=0!==t.ri.length),(h||l)&&(i.ri=this.Ae(a,r,h,l),i.Et=i.ri.length>0);const o=n.ze(a.R),_=this.Jt.Qt().qi().q(o);s.K=_.K,s.Vi=a.Vi,i.Ht=n.Qt().$t(a.Vi/n.Ft().Ut()),t.Ht=o,t.R=_.G,i.R=_.G}Ae(t,i,s,n){let e="";const r=this.Jt.Ve();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.Jt.Ft().Be()?t.Le:t.Oe),e.trim()}Ie(t,i,s){return i?s?this.Jt.Ft().Be()?t.Oe:t.Le:t.ri:""}}function ut(t,i,s,n){const e=Number.isFinite(i),r=Number.isFinite(s);return e&&r?t(i,s):e||r?e?i:s:n}class ct{constructor(t,i){this.Ne=t,this.Fe=i}We(t){return null!==t&&(this.Ne===t.Ne&&this.Fe===t.Fe)}He(){return new ct(this.Ne,this.Fe)}$e(){return this.Ne}Ue(){return this.Fe}je(){return this.Fe-this.Ne}Xi(){return this.Fe===this.Ne||Number.isNaN(this.Fe)||Number.isNaN(this.Ne)}pn(t){return null===t?this:new ct(ut(Math.min,this.$e(),t.$e(),-1/0),ut(Math.max,this.Ue(),t.Ue(),1/0))}Ye(t){if(!u(t))return;if(0===this.Fe-this.Ne)return;const i=.5*(this.Fe+this.Ne);let s=this.Fe-i,n=this.Ne-i;s*=t,n*=t,this.Fe=i+s,this.Ne=i+n}Ze(t){u(t)&&(this.Fe+=t,this.Ne+=t)}Xe(){return{minValue:this.Ne,maxValue:this.Fe}}static qe(t){return null===t?null:new ct(t.minValue,t.maxValue)}}class dt{constructor(t,i){this.Ke=t,this.Ge=i||null}Je(){return this.Ke}Qe(){return this.Ge}Xe(){return{priceRange:null===this.Ke?null:this.Ke.Xe(),margins:this.Ge||void 0}}static qe(t){return null===t?null:new dt(ct.qe(t.priceRange),t.margins)}}class ft extends et{constructor(t,i){super(t),this.tr=i}Qn(){const t=this.qn;t.Et=!1;const i=this.tr.N();if(!this.Gn.Et()||!i.lineVisible)return;const s=this.tr.ir();null!==s&&(t.Et=!0,t.ut=s,t.R=i.color,t.ct=i.lineWidth,t.qt=i.lineStyle,t.Zn=this.tr.N().id)}}class pt extends O{constructor(t,i){super(),this.we=t,this.tr=i}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.tr.N(),e=n.axisLabelVisible,r=""!==n.title,h=this.we;if(!e||!h.Et())return;const l=this.tr.ir();if(null===l)return;r&&(i.ri=n.title,i.Et=!0),i.Ht=h.Qt().$t(l/h.Ft().Ut()),t.ri=this.sr(n.price),t.Et=!0;const a=this.we.Qt().qi().q(n.axisLabelColor||n.color);s.K=a.K;const o=n.axisLabelTextColor||a.G;t.R=o,i.R=o,s.Vi=l}sr(t){const i=this.we.Bt();return null===i?"":this.we.Ft().Ki(t,i.Wt)}}class vt{constructor(t,i){this.we=t,this.ys=i,this.nr=new ft(t,this),this.Nn=new pt(t,this),this.er=new st(this.Nn,t,t.Qt())}rr(t){_(this.ys,t),this.Ct(),this.we.Qt().hr()}N(){return this.ys}lr(){return this.nr}ar(){return this.er}_r(){return this.Nn}Ct(){this.nr.Ct(),this.Nn.Ct()}ir(){const t=this.we,i=t.Ft();if(t.Qt().It().Xi()||i.Xi())return null;const s=t.Bt();return null===s?null:i.Nt(this.ys.price,s.Wt)}}class mt extends ${constructor(t){super(),this.ts=t}Qt(){return this.ts}}const wt={Bar:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=l(t(s,n)),o=a(h.Wt[0])<=a(h.Wt[3]);return{ur:h.R??(o?e:r)}},Candlestick:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=l(t(s,n)),d=a(c.Wt[0])<=a(c.Wt[3]);return{ur:c.R??(d?e:r),cr:c.Ht??(d?h:o),dr:c.pr??(d?_:u)}},Custom:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color}),Area:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.vt??i.lineColor,vt:e.vt??i.lineColor,vr:e.vr??i.topColor,mr:e.mr??i.bottomColor}},Baseline:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.Wt[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,wr:e.wr??i.topLineColor,gr:e.gr??i.bottomLineColor,br:e.br??i.topFillColor1,Mr:e.Mr??i.topFillColor2,Sr:e.Sr??i.bottomFillColor1,yr:e.yr??i.bottomFillColor2}},Line:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color})};class gt{constructor(t){this.Pr=(t,i)=>void 0!==i?i.Wt:this.we.Xs().Cr(t),this.we=t,this.Tr=wt[t.kr()]}Rr(t,i){return this.Tr(this.Pr,this.we.N(),t,i)}}function bt(t,i,s,n,e=0,r=i.length){let h=r-e;for(;0>1,l=e+r;n(i[l],s)===t?(e=l+1,h-=r+1):h=r}return e}const Mt=bt.bind(null,!0),xt=bt.bind(null,!1);var St;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(St||(St={}));const yt=30;class Pt{constructor(){this.Dr=[],this.Er=new Map,this.zr=new Map,this.Vr=[]}Ir(){return this.Ar()>0?this.Dr[this.Dr.length-1]:null}Br(){return this.Ar()>0?this.Lr(0):null}Zs(){return this.Ar()>0?this.Lr(this.Dr.length-1):null}Ar(){return this.Dr.length}Xi(){return 0===this.Ar()}Te(t){return null!==this.Or(t,0)}Cr(t){return this.Nr(t)}Nr(t,i=0){const s=this.Or(t,i);return null===s?null:{...this.Fr(s),ke:this.Lr(s)}}Wr(){return this.Dr}Hr(t,i,s){if(this.Xi())return null;let n=null;for(const e of s){n=Ct(n,this.$r(t,i,e))}return n}ht(t){this.zr.clear(),this.Er.clear(),this.Dr=t,this.Vr=t.map((t=>t.ke))}Ur(){return this.Vr}Lr(t){return this.Dr[t].ke}Fr(t){return this.Dr[t]}Or(t,i){const s=this.jr(t);if(null===s&&0!==i)switch(i){case-1:return this.Yr(t);case 1:return this.Zr(t);default:throw new TypeError("Unknown search mode")}return s}Yr(t){let i=this.Xr(t);return i>0&&(i-=1),i!==this.Dr.length&&this.Lr(i)t.ket.ke>i))}Kr(t,i,s){let n=null;for(let e=t;en.Jr&&(n.Jr=t)))}return n}$r(t,i,s){if(this.Xi())return null;let n=null;const e=l(this.Br()),r=l(this.Zs()),h=Math.max(t,e),a=Math.min(i,r),o=Math.ceil(h/yt)*yt,_=Math.max(o,Math.floor(a/yt)*yt);{const t=this.Xr(h),e=this.qr(Math.min(a,o,i));n=Ct(n,this.Kr(t,e,s))}let u=this.Er.get(s);void 0===u&&(u=new Map,this.Er.set(s,u));for(let t=Math.max(o+1,h);t<_;t+=yt){const i=Math.floor(t/yt);let e=u.get(i);if(void 0===e){const t=this.Xr(i*yt),n=this.qr((i+1)*yt-1);e=this.Kr(t,n,s),u.set(i,e)}n=Ct(n,e)}{const t=this.Xr(_),i=this.qr(a);n=Ct(n,this.Kr(t,i,s))}return n}}function Ct(t,i){if(null===t)return i;if(null===i)return t;return{Gr:Math.min(t.Gr,i.Gr),Jr:Math.max(t.Jr,i.Jr)}}class Tt{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class kt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Tt(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}class Rt{constructor(t){this.rh=null,this.hh=t}ah(){return this.hh}Os(){this.hh.updateAllViews?.()}Ns(){const t=this.hh.paneViews?.()??[];if(this.rh?.sh===t)return this.rh.nh;const i=t.map((t=>new kt(t)));return this.rh={sh:t,nh:i},i}Yn(t,i){return this.hh.hitTest?.(t,i)??null}}class Dt extends Rt{_s(){return[]}}class Et{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class zt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Et(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}function Vt(t){return{ri:t.text(),Vi:t.coordinate(),zi:t.fixedCoordinate?.(),R:t.textColor(),K:t.backColor(),Et:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class It{constructor(t,i){this.Gt=new W,this.oh=t,this._h=i}kt(){return this.Gt.ht({Qi:this._h.Qi(),...Vt(this.oh)}),this.Gt}}class At extends O{constructor(t,i){super(),this.oh=t,this.Yi=i}ji(t,i,s){const n=Vt(this.oh);s.K=n.K,t.R=n.R;const e=2/12*this.Yi.C();s.ki=e,s.Ri=e,s.Vi=n.Vi,s.zi=n.zi,t.ri=n.ri,t.Et=n.Et,t.pi=n.pi}}class Bt extends Rt{constructor(t,i){super(t),this.uh=null,this.dh=null,this.fh=null,this.ph=null,this.we=i}us(){const t=this.hh.timeAxisViews?.()??[];if(this.uh?.sh===t)return this.uh.nh;const i=this.we.Qt().It(),s=t.map((t=>new It(t,i)));return this.uh={sh:t,nh:s},s}Fs(){const t=this.hh.priceAxisViews?.()??[];if(this.dh?.sh===t)return this.dh.nh;const i=this.we.Ft(),s=t.map((t=>new At(t,i)));return this.dh={sh:t,nh:s},s}mh(){const t=this.hh.priceAxisPaneViews?.()??[];if(this.fh?.sh===t)return this.fh.nh;const i=t.map((t=>new zt(t)));return this.fh={sh:t,nh:i},i}wh(){const t=this.hh.timeAxisPaneViews?.()??[];if(this.ph?.sh===t)return this.ph.nh;const i=t.map((t=>new zt(t)));return this.ph={sh:t,nh:i},i}gh(t,i){return this.hh.autoscaleInfo?.(t,i)??null}}function Lt(t,i,s,n){t.forEach((t=>{i(t).forEach((t=>{t.eh()===s&&n.push(t)}))}))}function Ot(t){return t.Ns()}function Nt(t){return t.mh()}function Ft(t){return t.wh()}const Wt=["Area","Line","Baseline"];class Ht extends mt{constructor(t,i,s,n,e){super(t),this.Yt=new Pt,this.nr=new ot(this),this.bh=[],this.Mh=new rt(this),this.xh=null,this.Sh=null,this.yh=null,this.Ph=[],this.ys=s,this.Ch=i;const r=new _t(this);this.ps=[r],this.er=new st(r,this,t),Wt.includes(this.Ch)&&(this.xh=new at(this)),this.Th(),this.ih=n(this,this.Qt(),e)}m(){null!==this.yh&&clearTimeout(this.yh)}ze(t){return this.ys.priceLineColor||t}Pe(t){const i={Ce:!0},s=this.Ft();if(this.Qt().It().Xi()||s.Xi()||this.Yt.Xi())return i;const n=this.Qt().It().ye(),e=this.Bt();if(null===n||null===e)return i;let r,h;if(t){const t=this.Yt.Ir();if(null===t)return i;r=t,h=t.ke}else{const t=this.Yt.Nr(n.Mi(),-1);if(null===t)return i;if(r=this.Yt.Cr(t.ke),null===r)return i;h=t.ke}const l=r.Wt[3],a=this.kh().Rr(h,{Wt:r}),o=s.Nt(l,e.Wt);return{Ce:!1,gt:l,ri:s.Ki(l,e.Wt),Le:s.Rh(l),Oe:s.Dh(l,e.Wt),R:a.ur,Vi:o,ke:h}}kh(){return null!==this.Sh||(this.Sh=new gt(this)),this.Sh}N(){return this.ys}rr(t){const i=t.priceScaleId;void 0!==i&&i!==this.ys.priceScaleId&&this.Qt().Eh(this,i),_(this.ys,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().zh()),this.Qt().Vh(this),this.Qt().Ih(),this.ih.Ct("options")}ht(t,i){this.Yt.ht(t),this.ih.Ct("data"),null!==this.xh&&(i&&i.Ah?this.xh.be():0===t.length&&this.xh.ge());const s=this.Qt().Wn(this);this.Qt().Bh(s),this.Qt().Vh(this),this.Qt().Ih(),this.Qt().hr()}Lh(t){const i=new vt(this,t);return this.bh.push(i),this.Qt().Vh(this),i}Oh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().Vh(this)}Nh(){return this.bh}kr(){return this.Ch}Bt(){const t=this.Fh();return null===t?null:{Wt:t.Wt[3],Wh:t.wt}}Fh(){const t=this.Qt().It().ye();if(null===t)return null;const i=t.Hh();return this.Yt.Nr(i,1)}Xs(){return this.Yt}$h(t){const i=this.Yt.Cr(t);return null===i?null:"Bar"===this.Ch||"Candlestick"===this.Ch||"Custom"===this.Ch?{Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Zh:i.Wt[3]}:i.Wt[3]}Xh(t){const i=[];Lt(this.Ph,Ot,"top",i);const s=this.xh;return null!==s&&s.Et()?(null===this.yh&&s.xe()&&(this.yh=setTimeout((()=>{this.yh=null,this.Qt().qh()}),0)),s.Me(),i.unshift(s),i):i}Ns(){const t=[];this.Kh()||t.push(this.Mh),t.push(this.ih,this.nr);const i=this.bh.map((t=>t.lr()));return t.push(...i),Lt(this.Ph,Ot,"normal",t),t}Gh(){return this.Jh(Ot,"bottom")}Qh(t){return this.Jh(Nt,t)}tl(t){return this.Jh(Ft,t)}il(t,i){return this.Ph.map((s=>s.Yn(t,i))).filter((t=>null!==t))}_s(){return[this.er,...this.bh.map((t=>t.ar()))]}Fs(t,i){if(i!==this.es&&!this.Kh())return[];const s=[...this.ps];for(const t of this.bh)s.push(t._r());return this.Ph.forEach((t=>{s.push(...t.Fs())})),s}us(){const t=[];return this.Ph.forEach((i=>{t.push(...i.us())})),t}gh(t,i){if(void 0!==this.ys.autoscaleInfoProvider){const s=this.ys.autoscaleInfoProvider((()=>{const s=this.sl(t,i);return null===s?null:s.Xe()}));return dt.qe(s)}return this.sl(t,i)}nl(){return this.ys.priceFormat.minMove}el(){return this.rl}Os(){this.ih.Ct();for(const t of this.ps)t.Ct();for(const t of this.bh)t.Ct();this.nr.Ct(),this.Mh.Ct(),this.xh?.Ct(),this.Ph.forEach((t=>t.Os()))}Ft(){return l(super.Ft())}At(t){if(!(("Line"===this.Ch||"Area"===this.Ch||"Baseline"===this.Ch)&&this.ys.crosshairMarkerVisible))return null;const i=this.Yt.Cr(t);if(null===i)return null;return{gt:i.Wt[3],ft:this.hl(),Ht:this.ll(),Ot:this.al(),Lt:this.ol(t)}}Ve(){return this.ys.title}Et(){return this.ys.visible}_l(t){this.Ph.push(new Bt(t,this))}ul(t){this.Ph=this.Ph.filter((i=>i.ah()!==t))}cl(){if("Custom"===this.Ch)return t=>this.ih.dl(t)}fl(){if("Custom"===this.Ch)return t=>this.ih.pl(t)}vl(){return this.Yt.Ur()}Kh(){return!Y(this.Ft().ml())}sl(t,i){if(!c(t)||!c(i)||this.Yt.Xi())return null;const s="Line"===this.Ch||"Area"===this.Ch||"Baseline"===this.Ch||"Histogram"===this.Ch?[3]:[2,1],n=this.Yt.Hr(t,i,s);let e=null!==n?new ct(n.Gr,n.Jr):null,r=null;if("Histogram"===this.kr()){const t=this.ys.base,i=new ct(t,t);e=null!==e?e.pn(i):i}return this.Ph.forEach((s=>{const n=s.gh(t,i);if(n?.priceRange){const t=new ct(n.priceRange.minValue,n.priceRange.maxValue);e=null!==e?e.pn(t):t}n?.margins&&(r=n.margins)})),new dt(e,r)}hl(){switch(this.Ch){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerRadius}return 0}ll(){switch(this.Ch){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}al(){switch(this.Ch){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerBorderWidth}return 0}ol(t){switch(this.Ch){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.kh().Rr(t).ur}Th(){switch(this.ys.priceFormat.type){case"custom":this.rl={format:this.ys.priceFormat.formatter};break;case"volume":this.rl=new J(this.ys.priceFormat.precision);break;case"percent":this.rl=new G(this.ys.priceFormat.precision);break;default:{const t=Math.pow(10,this.ys.priceFormat.precision);this.rl=new K(t,this.ys.priceFormat.minMove*t)}}null!==this.es&&this.es.wl()}Jh(t,i){const s=[];return Lt(this.Ph,t,i,s),s}}const $t=[3],Ut=[0,1,2,3];class jt{constructor(t){this.ys=t}gl(t,i,s){let n=t;if(0===this.ys.mode)return n;const e=s.Cs(),r=e.Bt();if(null===r)return n;const h=e.Nt(t,r),l=s.bl().filter((t=>t instanceof Ht)).reduce(((t,n)=>{if(s.Hn(n)||!n.Et())return t;const e=n.Ft(),r=n.Xs();if(e.Xi()||!r.Te(i))return t;const h=r.Cr(i);if(null===h)return t;const l=a(n.Bt()),o=3===this.ys.mode?Ut:$t;return t.concat(o.map((t=>e.Nt(h.Wt[t],l.Wt))))}),[]);if(0===l.length)return n;l.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=l[0];return n=e.Ts(o,r),n}}class Yt extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=l(this.Yt);if(h.Ml){t.strokeStyle=h.xl,n(t,h.Sl),t.beginPath();for(const n of h.yl){const e=Math.round(n.Pl*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Cl){t.strokeStyle=h.Tl,n(t,h.kl),t.beginPath();for(const s of h.Rl){const n=Math.round(s.Pl*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}}))}}class Zt{constructor(t){this.Gt=new Yt,this.St=!0,this.Pt=t}Ct(){this.St=!0}kt(){if(this.St){const t=this.Pt.Qt().N().grid,i={Cl:t.horzLines.visible,Ml:t.vertLines.visible,Tl:t.horzLines.color,xl:t.vertLines.color,kl:t.horzLines.style,Sl:t.vertLines.style,Rl:this.Pt.Cs().Dl(),yl:(this.Pt.Qt().It().Dl()||[]).map((t=>({Pl:t.coord})))};this.Gt.ht(i),this.St=!1}return this.Gt}}class Xt{constructor(t){this.ih=new Zt(t)}lr(){return this.ih}}const qt={El:4,zl:1e-4};function Kt(t,i){const s=100*(t-i)/i;return i<0?-s:s}function Gt(t,i){const s=Kt(t.$e(),i),n=Kt(t.Ue(),i);return new ct(s,n)}function Jt(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function Qt(t,i){const s=Jt(t.$e(),i),n=Jt(t.Ue(),i);return new ct(s,n)}function ti(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.log10(s+i.zl)+i.El;return t<0?-n:n}function ii(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.El)-i.zl;return t<0?-n:n}function si(t,i){if(null===t)return null;const s=ti(t.$e(),i),n=ti(t.Ue(),i);return new ct(s,n)}function ni(t,i){if(null===t)return null;const s=ii(t.$e(),i),n=ii(t.Ue(),i);return new ct(s,n)}function ei(t){if(null===t)return qt;const i=Math.abs(t.Ue()-t.$e());if(i>=1||i<1e-15)return qt;const s=Math.ceil(Math.abs(Math.log10(i))),n=qt.El+s;return{El:n,zl:1/Math.pow(10,n)}}function ri(t,i,s){return Math.min(Math.max(t,i),s)}function hi(t,i,s){return i-t<=s}class li{constructor(t,i){if(this.Vl=t,this.Il=i,function(t){if(t<0)return!1;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Vl))this.Al=[2,2.5,2];else{this.Al=[];for(let t=this.Vl;1!==t;){if(t%2==0)this.Al.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Al.push(2,2.5),t/=5}if(this.Al.length>100)throw new Error("something wrong with base")}}}Bl(t,i,s){const n=0===this.Vl?0:1/this.Vl;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Il[0];for(;;){const t=hi(e,n,1e-14)&&e>n+1e-14,i=hi(e,s*h,1e-14),l=hi(e,1,1e-14);if(!(t&&i&&l))break;e/=h,h=this.Il[++r%this.Il.length]}if(e<=n+1e-14&&(e=n),e=Math.max(1,e),this.Al.length>0&&(l=e,a=1,o=1e-14,Math.abs(l-a)n+1e-14;)e/=h,h=this.Al[++r%this.Al.length];var l,a,o;return e}}class ai{constructor(t,i,s,n){this.Ll=[],this.Yi=t,this.Vl=i,this.Ol=s,this.Nl=n}Bl(t,i){if(t=o?1:-1;let d=null,f=0;for(let s=a-u;s>o;s-=_){const n=this.Nl(s,i,!0);null!==d&&Math.abs(n-d)l||(fl(t.hs())-l(i.hs())))}var _i;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(_i||(_i={}));const ui=new G,ci=new K(100,1);class di{constructor(t,i,s,n,e){this.Yl=0,this.Zl=null,this.Ke=null,this.Xl=null,this.ql={Kl:!1,Gl:null},this.Jl=0,this.Ql=0,this.ta=new o,this.ia=new o,this.sa=[],this.na=null,this.ea=null,this.ra=null,this.ha=null,this.rl=ci,this.la=ei(null),this.aa=t,this.ys=i,this.oa=s,this._a=n,this.ua=e,this.ca=new ai(this,100,this.da.bind(this),this.fa.bind(this))}ml(){return this.aa}N(){return this.ys}rr(t){if(_(this.ys,t),this.wl(),void 0!==t.mode&&this.pa({te:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.va(),this.ea=null}}ma(){return this.ys.autoScale}jl(){return 1===this.ys.mode}Be(){return 2===this.ys.mode}wa(){return 3===this.ys.mode}te(){return{tn:this.ys.autoScale,ga:this.ys.invertScale,te:this.ys.mode}}pa(t){const i=this.te();let s=null;void 0!==t.tn&&(this.ys.autoScale=t.tn),void 0!==t.te&&(this.ys.mode=t.te,2!==t.te&&3!==t.te||(this.ys.autoScale=!0),this.ql.Kl=!1),1===i.te&&t.te!==i.te&&(!function(t,i){if(null===t)return!1;const s=ii(t.$e(),i),n=ii(t.Ue(),i);return isFinite(s)&&isFinite(n)}(this.Ke,this.la)?this.ys.autoScale=!0:(s=ni(this.Ke,this.la),null!==s&&this.ba(s))),1===t.te&&t.te!==i.te&&(s=si(this.Ke,this.la),null!==s&&this.ba(s));const n=i.te!==this.ys.mode;n&&(2===i.te||this.Be())&&this.wl(),n&&(3===i.te||this.wa())&&this.wl(),void 0!==t.ga&&i.ga!==t.ga&&(this.ys.invertScale=t.ga,this.Ma()),this.ia.p(i,this.te())}xa(){return this.ia}C(){return this.oa.fontSize}Ut(){return this.Yl}Sa(t){this.Yl!==t&&(this.Yl=t,this.va(),this.ea=null)}ya(){if(this.Zl)return this.Zl;const t=this.Ut()-this.Pa()-this.Ca();return this.Zl=t,t}Je(){return this.Ta(),this.Ke}ba(t,i){const s=this.Ke;(i||null===s&&null!==t||null!==s&&!s.We(t))&&(this.ea=null,this.Ke=t)}Xi(){return this.Ta(),0===this.Yl||!this.Ke||this.Ke.Xi()}ka(t){return this.ga()?t:this.Ut()-1-t}Nt(t,i){return this.Be()?t=Kt(t,i):this.wa()&&(t=Jt(t,i)),this.fa(t,i)}Ra(t,i,s){this.Ta();const n=this.Ca(),e=l(this.Je()),r=e.$e(),h=e.Ue(),a=this.ya()-1,o=this.ga(),_=a/(h-r),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,d=this.Da();for(let s=u;st.Os()))}wl(){this.ea=null;const t=this.qa();let i=100;null!==t&&(i=Math.round(1/t.nl())),this.rl=ci,this.Be()?(this.rl=ui,i=100):this.wa()?(this.rl=new K(100,1),i=100):null!==t&&(this.rl=t.el()),this.ca=new ai(this,i,this.da.bind(this),this.fa.bind(this)),this.ca.Wl()}Oa(){this.na=null}qi(){return this.ua}qa(){return this.sa[0]||null}Pa(){return this.ga()?this.ys.scaleMargins.bottom*this.Ut()+this.Ql:this.ys.scaleMargins.top*this.Ut()+this.Jl}Ca(){return this.ga()?this.ys.scaleMargins.top*this.Ut()+this.Jl:this.ys.scaleMargins.bottom*this.Ut()+this.Ql}Ta(){this.ql.Kl||(this.ql.Kl=!0,this.Ja())}va(){this.Zl=null}fa(t,i){if(this.Ta(),this.Xi())return 0;t=this.jl()&&t?ti(t,this.la):t;const s=l(this.Je()),n=this.Ca()+(this.ya()-1)*(t-s.$e())/s.je();return this.ka(n)}da(t,i){if(this.Ta(),this.Xi())return 0;const s=this.ka(t),n=l(this.Je()),e=n.$e()+n.je()*((s-this.Ca())/(this.ya()-1));return this.jl()?ii(e,this.la):e}Ma(){this.ea=null,this.ca.Wl()}Ja(){const t=this.ql.Gl;if(null===t)return;let i=null;const s=this.Ka();let n=0,e=0;for(const r of s){if(!r.Et())continue;const s=r.Bt();if(null===s)continue;const h=r.gh(t.Hh(),t.Mi());let a=h&&h.Je();if(null!==a){switch(this.ys.mode){case 1:a=si(a,this.la);break;case 2:a=Gt(a,s.Wt);break;case 3:a=Qt(a,s.Wt)}if(i=null===i?a:i.pn(l(a)),null!==h){const t=h.Qe();null!==t&&(n=Math.max(n,t.above),e=Math.max(e,t.below))}}}if(n===this.Jl&&e===this.Ql||(this.Jl=n,this.Ql=e,this.ea=null,this.va()),null!==i){if(i.$e()===i.Ue()){const t=this.qa(),s=5*(null===t||this.Be()||this.wa()?1:t.nl());this.jl()&&(i=ni(i,this.la)),i=new ct(i.$e()-s,i.Ue()+s),this.jl()&&(i=si(i,this.la))}if(this.jl()){const t=ni(i,this.la),s=ei(t);if(r=s,h=this.la,r.El!==h.El||r.zl!==h.zl){const n=null!==this.Xl?ni(this.Xl,this.la):null;this.la=s,i=si(t,s),null!==n&&(this.Xl=si(n,s))}}this.ba(i)}else null===this.Ke&&(this.ba(new ct(-.5,.5)),this.la=ei(null));var r,h;this.ql.Kl=!0}Da(){return this.Be()?Kt:this.wa()?Jt:this.jl()?t=>ti(t,this.la):null}Qa(t,i,s){return void 0===i?(void 0===s&&(s=this.el()),s.format(t)):i(t)}sr(t,i){return this.Qa(t,this._a.priceFormatter,i)}Xa(t,i){return this.Qa(t,this._a.percentageFormatter,i)}}function fi(t){return t instanceof Ht}class pi{constructor(t,i){this.sa=[],this.io=new Map,this.Yl=0,this.so=0,this.no=1e3,this.na=null,this.eo=new o,this.Ph=[],this._h=t,this.ts=i,this.ro=new Xt(this);const s=i.N();this.ho=this.lo("left",s.leftPriceScale),this.ao=this.lo("right",s.rightPriceScale),this.ho.xa().i(this.oo.bind(this,this.ho),this),this.ao.xa().i(this.oo.bind(this,this.ao),this),this._o(s)}_o(t){if(t.leftPriceScale&&this.ho.rr(t.leftPriceScale),t.rightPriceScale&&this.ao.rr(t.rightPriceScale),t.localization&&(this.ho.wl(),this.ao.wl()),t.overlayPriceScales){const i=Array.from(this.io.values());for(const s of i){const i=l(s[0].Ft());i.rr(t.overlayPriceScales),t.localization&&i.wl()}}}uo(t){switch(t){case"left":return this.ho;case"right":return this.ao}return this.io.has(t)?h(this.io.get(t))[0].Ft():null}m(){this.Qt().co().u(this),this.ho.xa().u(this),this.ao.xa().u(this),this.sa.forEach((t=>{t.m&&t.m()})),this.Ph=this.Ph.filter((t=>{const i=t.ah();return i.detached&&i.detached(),!1})),this.eo.p()}do(){return this.no}fo(t){this.no=t}Qt(){return this.ts}Qi(){return this.so}Ut(){return this.Yl}po(t){this.so=t,this.vo()}Sa(t){this.Yl=t,this.ho.Sa(t),this.ao.Sa(t),this.sa.forEach((i=>{if(this.Hn(i)){const s=i.Ft();null!==s&&s.Sa(t)}})),this.vo()}mo(){return this.sa.filter(fi)}bl(){return this.sa}Hn(t){const i=t.Ft();return null===i||this.ho!==i&&this.ao!==i}La(t,i,s){const n=void 0!==s?s:this.bo().wo+1;this.Mo(t,i,n)}Na(t){const i=this.sa.indexOf(t);r(-1!==i,"removeDataSource: invalid data source"),this.sa.splice(i,1);const s=l(t.Ft()).ml();if(this.io.has(s)){const i=h(this.io.get(s)),n=i.indexOf(t);-1!==n&&(i.splice(n,1),0===i.length&&this.io.delete(s))}const n=t.Ft();n&&n.bl().indexOf(t)>=0&&n.Na(t),null!==n&&(n.Oa(),this.xo(n)),this.na=null}Un(t){return t===this.ho?"left":t===this.ao?"right":"overlay"}So(){return this.ho}yo(){return this.ao}Po(t,i){t.Ha(i)}Co(t,i){t.$a(i),this.vo()}To(t){t.Ua()}ko(t,i){t.ja(i)}Ro(t,i){t.Ya(i),this.vo()}Do(t){t.Za()}vo(){this.sa.forEach((t=>{t.Os()}))}Cs(){let t=null;return this.ts.N().rightPriceScale.visible&&0!==this.ao.bl().length?t=this.ao:this.ts.N().leftPriceScale.visible&&0!==this.ho.bl().length?t=this.ho:0!==this.sa.length&&(t=this.sa[0].Ft()),null===t&&(t=this.ao),t}$n(){let t=null;return this.ts.N().rightPriceScale.visible?t=this.ao:this.ts.N().leftPriceScale.visible&&(t=this.ho),t}xo(t){null!==t&&t.ma()&&this.Eo(t)}zo(t){const i=this._h.ye();t.pa({tn:!0}),null!==i&&t.Ga(i),this.vo()}Vo(){this.Eo(this.ho),this.Eo(this.ao)}Io(){this.xo(this.ho),this.xo(this.ao),this.sa.forEach((t=>{this.Hn(t)&&this.xo(t.Ft())})),this.vo(),this.ts.hr()}Dt(){return null===this.na&&(this.na=oi(this.sa)),this.na}zt(){return this.Dt().filter(fi)}Ao(){return this.eo}Bo(){return this.ro}_l(t){this.Ph.push(new Dt(t))}ul(t){this.Ph=this.Ph.filter((i=>i.ah()!==t)),t.detached&&t.detached(),this.ts.hr()}Lo(){return this.Ph}il(t,i){return this.Ph.map((s=>s.Yn(t,i))).filter((t=>null!==t))}Eo(t){const i=t.Ka();if(i&&i.length>0&&!this._h.Xi()){const i=this._h.ye();null!==i&&t.Ga(i)}t.Os()}bo(){const t=this.Dt();if(0===t.length)return{Oo:0,wo:0};let i=0,s=0;for(let n=0;ns&&(s=e))}return{Oo:i,wo:s}}Mo(t,i,s){let n=this.uo(i);if(null===n&&(n=this.lo(i,this.ts.N().overlayPriceScales)),this.sa.push(t),!Y(i)){const s=this.io.get(i)||[];s.push(t),this.io.set(i,s)}n.La(t),t.os(n),t.ls(s),this.xo(n),this.na=null}oo(t,i,s){i.te!==s.te&&this.Eo(t)}lo(t,i){const s={visible:!0,autoScale:!0,...p(i)},n=new di(t,s,this.ts.N().layout,this.ts.N().localization,this.ts.qi());return n.Sa(this.Ut()),n}}function vi(t){return{No:t.No,Fo:{Zn:t.Wo.externalId},Ho:t.Wo.cursorStyle}}function mi(t,i,s,n){for(const e of t){const t=e.kt(n);if(null!==t&&t.Yn){const n=t.Yn(i,s);if(null!==n)return{$o:e,Fo:n}}}return null}function wi(t){return void 0!==t.Ns}function gi(t,i,s){const n=[t,...t.Dt()],e=function(t,i,s){let n,e;for(const l of t){const t=l.il?.(i,s)??[];for(const i of t)r=i.zOrder,h=n?.zOrder,(!h||"top"===r&&"top"!==h||"normal"===r&&"bottom"===h)&&(n=i,e=l)}var r,h;return n&&e?{Wo:n,No:e}:null}(n,i,s);if("top"===e?.Wo.zOrder)return vi(e);for(const r of n){if(e&&e.No===r&&"bottom"!==e.Wo.zOrder&&!e.Wo.isBackground)return vi(e);if(wi(r)){const n=mi(r.Ns(t),i,s,t);if(null!==n)return{No:r,$o:n.$o,Fo:n.Fo}}if(e&&e.No===r&&"bottom"!==e.Wo.zOrder&&e.Wo.isBackground)return vi(e)}return e?.Wo?vi(e):null}class bi{constructor(t,i,s=50){this.Pn=0,this.Cn=1,this.Tn=1,this.Rn=new Map,this.kn=new Map,this.Uo=t,this.jo=i,this.Dn=s}Yo(t){const i=t.time,s=this.jo.cacheKey(i),n=this.Rn.get(s);if(void 0!==n)return n.Zo;if(this.Pn===this.Dn){const t=this.kn.get(this.Tn);this.kn.delete(this.Tn),this.Rn.delete(h(t)),this.Tn++,this.Pn--}const e=this.Uo(t);return this.Rn.set(s,{Zo:e,In:this.Cn}),this.kn.set(this.Cn,s),this.Pn++,this.Cn++,e}}class Mi{constructor(t,i){r(t<=i,"right should be >= left"),this.Xo=t,this.qo=i}Hh(){return this.Xo}Mi(){return this.qo}Ko(){return this.qo-this.Xo+1}Te(t){return this.Xo<=t&&t<=this.qo}We(t){return this.Xo===t.Hh()&&this.qo===t.Mi()}}function xi(t,i){return null===t||null===i?t===i:t.We(i)}class Si{constructor(){this.Go=new Map,this.Rn=null,this.Jo=!1}Qo(t){this.Jo=t,this.Rn=null}t_(t,i){this.i_(i),this.Rn=null;for(let s=i;s{t<=s[0].index?i.push(n):s.splice(Mt(s,t,(i=>i.index!i||s.has(t.index);for(const i of Array.from(this.Go.keys()).sort(((t,i)=>i-t))){if(!this.Go.get(i))continue;const s=n;n=[];const r=s.length;let l=0;const a=h(this.Go.get(i)),o=a.length;let _=1/0,u=-1/0;for(let i=0;i=t&&o-u>=t&&e(h))n.push(h),u=o;else if(this.Jo)return s}for(;li.weight?t:i}class Ci{constructor(t,i,s,n){this.so=0,this.u_=null,this.c_=[],this.ha=null,this.ra=null,this.d_=new Si,this.f_=new Map,this.p_=yi.__(),this.v_=!0,this.m_=new o,this.w_=new o,this.g_=new o,this.b_=null,this.M_=null,this.x_=new Map,this.S_=-1,this.y_=[],this.ys=i,this._a=s,this.P_=i.rightOffset,this.C_=i.barSpacing,this.ts=t,this.jo=n,this.T_(),this.d_.Qo(i.uniformDistribution),this.k_()}N(){return this.ys}R_(t){_(this._a,t),this.D_(),this.T_()}rr(t,i){_(this.ys,t),this.ys.fixLeftEdge&&this.E_(),this.ys.fixRightEdge&&this.z_(),void 0!==t.barSpacing&&this.ts.cn(t.barSpacing),void 0!==t.rightOffset&&this.ts.dn(t.rightOffset),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ts.cn(t.barSpacing??this.C_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.ys.ignoreWhitespaceIndices&&this.k_(),this.D_(),this.T_(),this.g_.p()}ks(t){return this.c_[t]?.time??null}ss(t){return this.c_[t]??null}V_(t,i){if(this.c_.length<1)return null;if(this.jo.key(t)>this.jo.key(this.c_[this.c_.length-1].time))return i?this.c_.length-1:null;const s=Mt(this.c_,this.jo.key(t),((t,i)=>this.jo.key(t.time)0}ye(){return this.A_(),this.p_.a_()}B_(){return this.A_(),this.p_.o_()}L_(){const t=this.ye();if(null===t)return null;const i={from:t.Hh(),to:t.Mi()};return this.O_(i)}O_(t){const i=Math.round(t.from),s=Math.round(t.to),n=l(this.N_()),e=l(this.F_());return{from:l(this.ss(Math.max(n,i))),to:l(this.ss(Math.min(e,s)))}}W_(t){return{from:l(this.V_(t.from,!0)),to:l(this.V_(t.to,!0))}}Qi(){return this.so}po(t){if(!isFinite(t)||t<=0)return;if(this.so===t)return;const i=this.B_(),s=this.so;if(this.so=t,this.v_=!0,this.ys.lockVisibleTimeRangeOnResize&&0!==s){const i=this.C_*t/s;this.C_=i}if(this.ys.fixLeftEdge&&null!==i&&i.Hh()<=0){const i=s-t;this.P_-=Math.round(i/this.C_)+1,this.v_=!0}this.H_(),this.U_()}jt(t){if(this.Xi()||!c(t))return 0;const i=this.j_()+this.P_-t;return this.so-(i+.5)*this.C_-1}Y_(t,i){const s=this.j_(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;ii/2&&!_?s.needAlignCoordinate=!1:s.needAlignCoordinate=u&&t.index<=a||c&&t.index>=o,d++}return this.y_.length=d,this.M_=this.y_,this.y_}nu(){this.v_=!0,this.cn(this.ys.barSpacing),this.dn(this.ys.rightOffset)}eu(t){this.v_=!0,this.u_=t,this.U_(),this.E_()}ru(t,i){const s=this.X_(t),n=this.J_(),e=n+i*(n/10);this.cn(e),this.ys.rightBarStaysOnScroll||this.dn(this.tu()+(s-this.X_(t)))}Ha(t){this.ha&&this.Za(),null===this.ra&&null===this.b_&&(this.Xi()||(this.ra=t,this.hu()))}$a(t){if(null===this.b_)return;const i=ri(this.so-t,0,this.so),s=ri(this.so-l(this.ra),0,this.so);0!==i&&0!==s&&this.cn(this.b_.J_*i/s)}Ua(){null!==this.ra&&(this.ra=null,this.lu())}ja(t){null===this.ha&&null===this.b_&&(this.Xi()||(this.ha=t,this.hu()))}Ya(t){if(null===this.ha)return;const i=(this.ha-t)/this.J_();this.P_=l(this.b_).tu+i,this.v_=!0,this.U_()}Za(){null!==this.ha&&(this.ha=null,this.lu())}au(){this.ou(this.ys.rightOffset)}ou(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.P_,n=performance.now();this.ts.an({_u:t=>(t-n)/i>=1,uu:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}Ct(t,i){this.v_=!0,this.c_=t,this.d_.t_(t,i),this.U_()}cu(){return this.m_}du(){return this.w_}fu(){return this.g_}j_(){return this.u_||0}pu(t){const i=t.Ko();this.Q_(this.so/i),this.P_=t.Mi()-this.j_(),this.U_(),this.v_=!0,this.ts.G_(),this.ts.hr()}vu(){const t=this.N_(),i=this.F_();null!==t&&null!==i&&this.pu(new Mi(t,i+this.ys.rightOffset))}mu(t){const i=new Mi(t.from,t.to);this.pu(i)}ns(t){return void 0!==this._a.timeFormatter?this._a.timeFormatter(t.originalTime):this.jo.formatHorzItem(t.time)}k_(){if(!this.ys.ignoreWhitespaceIndices)return;this.x_.clear();const t=this.ts.Ys();for(const i of t)for(const t of i.vl())this.x_.set(t,!0);this.S_++}iu(){const t=this.ts.N().handleScroll,i=this.ts.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}N_(){return 0===this.c_.length?null:0}F_(){return 0===this.c_.length?null:this.c_.length-1}wu(t){return(this.so-1-t)/this.C_}X_(t){const i=this.wu(t),s=this.j_()+this.P_-i;return Math.round(1e6*s)/1e6}Q_(t){const i=this.C_;this.C_=t,this.H_(),i!==this.C_&&(this.v_=!0,this.gu())}A_(){if(!this.v_)return;if(this.v_=!1,this.Xi())return void this.bu(yi.__());const t=this.j_(),i=this.so/this.C_,s=this.P_+t,n=new Mi(s-i+1,s);this.bu(new yi(n))}H_(){const t=ri(this.C_,this.Mu(),this.xu());this.C_!==t&&(this.C_=t,this.v_=!0)}xu(){return this.ys.maxBarSpacing>0?this.ys.maxBarSpacing:.5*this.so}Mu(){return this.ys.fixLeftEdge&&this.ys.fixRightEdge&&0!==this.c_.length?this.so/this.c_.length:this.ys.minBarSpacing}U_(){const t=this.Su();null!==t&&this.P_i&&(this.P_=i,this.v_=!0)}Su(){const t=this.N_(),i=this.u_;if(null===t||null===i)return null;return t-i-1+(this.ys.fixLeftEdge?this.so/this.C_:Math.min(2,this.c_.length))}yu(){return this.ys.fixRightEdge?0:this.so/this.C_-Math.min(2,this.c_.length)}hu(){this.b_={J_:this.J_(),tu:this.tu()}}lu(){this.b_=null}su(t){let i=this.f_.get(t.weight);return void 0===i&&(i=new bi((t=>this.Pu(t)),this.jo),this.f_.set(t.weight,i)),i.Yo(t)}Pu(t){return this.jo.formatTickmark(t,this._a)}bu(t){const i=this.p_;this.p_=t,xi(i.a_(),this.p_.a_())||this.m_.p(),xi(i.o_(),this.p_.o_())||this.w_.p(),this.gu()}gu(){this.M_=null}D_(){this.gu(),this.f_.clear()}T_(){this.jo.updateFormatter(this._a)}E_(){if(!this.ys.fixLeftEdge)return;const t=this.N_();if(null===t)return;const i=this.ye();if(null===i)return;const s=i.Hh()-t;if(s<0){const t=this.P_-s-1;this.dn(t)}this.H_()}z_(){this.U_(),this.H_()}q_(t){return!this.ys.ignoreWhitespaceIndices||(this.x_.get(t)||!1)}K_(t){const i=function*(t){const i=Math.round(t),s=is)break}return t}}var Ti,ki,Ri,Di,Ei;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ti||(Ti={}));class zi{constructor(t,i,s){this.Cu=[],this.Tu=[],this.so=0,this.ku=null,this.Ru=new o,this.Du=new o,this.Eu=null,this.zu=t,this.ys=i,this.jo=s,this.ua=new S(this.ys.layout.colorParsers),this.Vu=new b(this),this._h=new Ci(this,i.timeScale,this.ys.localization,s),this.yt=new j(this,i.crosshair),this.Iu=new jt(i.crosshair),this.Au(0),this.Cu[0].fo(2e3),this.Bu=this.Lu(0),this.Ou=this.Lu(1)}zh(){this.Nu(Z.wn())}hr(){this.Nu(Z.mn())}qh(){this.Nu(new Z(1))}Vh(t){const i=this.Fu(t);this.Nu(i)}Wu(){return this.ku}Hu(t){if(this.ku?.No===t?.No&&this.ku?.Fo?.Zn===t?.Fo?.Zn)return;const i=this.ku;this.ku=t,null!==i&&this.Vh(i.No),null!==t&&t.No!==i?.No&&this.Vh(t.No)}N(){return this.ys}rr(t){_(this.ys,t),this.Cu.forEach((i=>i._o(t))),void 0!==t.timeScale&&this._h.rr(t.timeScale),void 0!==t.localization&&this._h.R_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Ru.p(),this.Bu=this.Lu(0),this.Ou=this.Lu(1),this.zh()}$u(t,i,s=0){const n=this.Cu[s];if(void 0===n)return;if("left"===t)return _(this.ys,{leftPriceScale:i}),n._o({leftPriceScale:i}),this.Ru.p(),void this.zh();if("right"===t)return _(this.ys,{rightPriceScale:i}),n._o({rightPriceScale:i}),this.Ru.p(),void this.zh();const e=this.Uu(t,s);null!==e&&(e.Ft.rr(i),this.Ru.p())}Uu(t,i){const s=this.Cu[i];if(void 0===s)return null;const n=s.uo(t);return null!==n?{Hs:s,Ft:n}:null}It(){return this._h}$s(){return this.Cu}ju(){return this.yt}Yu(){return this.Du}Zu(t,i){t.Sa(i),this.G_()}po(t){this.so=t,this._h.po(this.so),this.Cu.forEach((i=>i.po(t))),this.G_()}Xu(t){1!==this.Cu.length&&(r(t>=0&&t=0&&tt+i.do()),0),e=this.Cu.reduce(((t,i)=>t+i.Ut()),0),h=e-30*(this.Cu.length-1);i=Math.min(h,Math.max(30,i));const l=n/e,a=s.Ut();s.fo(i*l);let o=i-a,_=this.Cu.length-1;for(const t of this.Cu)if(t!==s){const i=Math.min(h,Math.max(30,t.Ut()-o/_));o-=t.Ut()-i,_-=1;const s=i*l;t.fo(s)}this.zh()}Ku(t,i){r(t>=0&&t=0&&ithis.jo.key(e),a=null!==t&&t>r&&!l,o=this._h.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===s)||o)&&this._h.N().shiftVisibleRangeOnNewBar;if(a&&!_){const i=t-r;this._h.dn(this._h.tu()-i)}}this._h.eu(t)}Bh(t){null!==t&&t.Io()}Wn(t){if(function(t){return t instanceof pi}(t))return t;const i=this.Cu.find((i=>i.Dt().includes(t)));return void 0===i?null:i}G_(){this.Cu.forEach((t=>t.Io())),this.Ih()}m(){this.Cu.forEach((t=>t.m())),this.Cu.length=0,this.ys.localization.priceFormatter=void 0,this.ys.localization.percentageFormatter=void 0,this.ys.localization.timeFormatter=void 0}uc(){return this.Vu}jn(){return this.Vu.N()}co(){return this.Ru}cc(t,i){const s=this.Au(i);this.dc(t,s),this.Tu.push(t),1===this.Tu.length?this.zh():this.hr()}fc(t){const i=this.Wn(t),s=this.Tu.indexOf(t);r(-1!==s,"Series not found");const n=l(i);this.Tu.splice(s,1),n.Na(t),t.m&&t.m(),this._h.k_(),this.vc(n)}Eh(t,i){const s=l(this.Wn(t));s.Na(t),s.La(t,i,l(t.hs()))}vu(){const t=Z.mn();t.en(),this.Nu(t)}mc(t){const i=Z.mn();i.ln(t),this.Nu(i)}un(){const t=Z.mn();t.un(),this.Nu(t)}cn(t){const i=Z.mn();i.cn(t),this.Nu(i)}dn(t){const i=Z.mn();i.dn(t),this.Nu(i)}an(t){const i=Z.mn();i.an(t),this.Nu(i)}rn(){const t=Z.mn();t.rn(),this.Nu(t)}wc(){return this.ys.rightPriceScale.visible?"right":"left"}gc(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.bc(t))return;const s=l(this.Wn(t));s.Na(t);const n=this.Au(i);this.dc(t,n),0===s.bl().length&&this.vc(s)}Mc(){return this.Ou}U(){return this.Bu}$t(t){const i=this.Ou,s=this.Bu;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Eu||this.Eu.vr!==s||this.Eu.mr!==i)this.Eu={vr:s,mr:i,xc:new Map};else{const i=this.Eu.xc.get(t);if(void 0!==i)return i}const n=this.ua.tt(s,i,t/100);return this.Eu.xc.set(t,n),n}Sc(t){return this.Cu.indexOf(t)}qi(){return this.ua}Au(t){if(r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.Cu.length,t))i.mo().includes(t)))}Gu(t,i){const s=new Z(i);if(null!==t){const n=this.Cu.indexOf(t);s.Js(n,{Qs:i})}return s}Fu(t,i){return void 0===i&&(i=2),this.Gu(this.Wn(t),i)}Nu(t){this.zu&&this.zu(t),this.Cu.forEach((t=>t.Bo().lr().Ct()))}dc(t,i){const s=t.N().priceScaleId,n=void 0!==s?s:this.wc();i.La(t,n),Y(n)||t.rr(t.N())}Lu(t){const i=this.ys.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}vc(t){0===t.bl().length&&this.Cu.length>1&&(this.Cu.splice(this.Sc(t),1),this.zh())}}function Vi(t){return!u(t)&&!d(t)}function Ii(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(ki||(ki={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ri||(Ri={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Di||(Di={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Ei||(Ei={}));const Ai=t=>t.getUTCFullYear();function Bi(t,i,s){return i.replace(/yyyy/g,(t=>q(Ai(t),4))(t)).replace(/yy/g,(t=>q(Ai(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>q((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>q((t=>t.getUTCDate())(t),2))(t))}class Li{constructor(t="yyyy-MM-dd",i="default"){this.yc=t,this.Pc=i}Yo(t){return Bi(t,this.yc,this.Pc)}}class Oi{constructor(t){this.Cc=t||"%h:%m:%s"}Yo(t){return this.Cc.replace("%h",q(t.getUTCHours(),2)).replace("%m",q(t.getUTCMinutes(),2)).replace("%s",q(t.getUTCSeconds(),2))}}const Ni={Tc:"yyyy-MM-dd",kc:"%h:%m:%s",Rc:" ",Dc:"default"};class Fi{constructor(t={}){const i={...Ni,...t};this.Ec=new Li(i.Tc,i.Dc),this.zc=new Oi(i.kc),this.Vc=i.Rc}Yo(t){return`${this.Ec.Yo(t)}${this.Vc}${this.zc.Yo(t)}`}}function Wi(t){return 60*t*60*1e3}function Hi(t){return 60*t*1e3}const $i=[{Ic:(Ui=1,1e3*Ui),Ac:10},{Ic:Hi(1),Ac:20},{Ic:Hi(5),Ac:21},{Ic:Hi(30),Ac:22},{Ic:Wi(1),Ac:30},{Ic:Wi(3),Ac:31},{Ic:Wi(6),Ac:32},{Ic:Wi(12),Ac:33}];var Ui;function ji(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=$i.length-1;s>=0;--s)if(Math.floor(i.getTime()/$i[s].Ic)!==Math.floor(t.getTime()/$i[s].Ic))return $i[s].Ac;return 0}function Yi(t){let i=t;if(d(t)&&(i=Xi(t)),!Vi(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Bc:Math.round(s.getTime()/1e3),Lc:i}}function Zi(t){if(!Ii(t))throw new Error("time must be of type isUTCTimestamp");return{Bc:t}}function Xi(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function qi(t){d(t.time)&&(t.time=Xi(t.time))}class Ki{options(){return this.ys}setOptions(t){this.ys=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(qi)}(t):qi(t)}createConverterToInternalObj(t){return l(function(t){return 0===t.length?null:Vi(t[0].time)||d(t[0].time)?Yi:Zi}(t))}key(t){return"object"==typeof t&&"Bc"in t?t.Bc:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.Lc?new Date(1e3*i.Bc).getTime():new Date(Date.UTC(i.Lc.year,i.Lc.month-1,i.Lc.day)).getTime()}convertHorzItemToInternal(t){return Ii(i=t)?Zi(i):Vi(i)?Yi(i):Yi(Xi(i));var i}updateFormatter(t){if(!this.ys)return;const i=t.dateFormat;this.ys.timeScale.timeVisible?this.Oc=new Fi({Tc:i,kc:this.ys.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Rc:" ",Dc:t.locale}):this.Oc=new Li(i,t.locale)}formatHorzItem(t){const i=t;return this.Oc.Yo(new Date(1e3*i.Bc))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.ys.timeScale.timeVisible,this.ys.timeScale.secondsVisible),n=this.ys.timeScale;if(void 0!==n.tickMarkFormatter){const e=n.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==e)return e}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.Lc?new Date(1e3*t.Bc):new Date(Date.UTC(t.Lc.year,t.Lc.month-1,t.Lc.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Pi,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.Bc,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0].time.Bc-i));t[0].timeWeight=ji(new Date(1e3*t[0].time.Bc),s)}}(t,i)}static Nc(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function Gi(t){var i=t.width,s=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(s<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:s}}function Ji(t,i){return t.width===i.width&&t.height===i.height}var Qi=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==s}))}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach((function(i){return i.next(t._window.devicePixelRatio)})),this._reinstallResolutionListener()},t}();var ts=function(){function t(t,i,s){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Gi({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(n=null==s?void 0:s.allowResizeObserver)||void 0===n||n,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return Gi({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Gi(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;Ji(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=Gi(this._transformBitmapSize(t,this._canvasElementClientSize)),n=Ji(this.bitmapSize,s)?null:s;null===i&&null===n||null!==i&&null!==n&&Ji(i,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(i,n))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(s){t(s.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=is(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new Qi(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=is(this._canvasElement);if(null!==s){var n=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return Gi({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],n):Gi({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var s=i.find((function(i){return i.target===t._canvasElement}));if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var n=s.devicePixelContentBoxSize[0],e=Gi({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function is(t){return t.ownerDocument.defaultView}var ss=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function ns(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var n=t.bitmapSize;if(0===n.width||0===n.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new ss(e,s,n)}const es="undefined"!=typeof window;function rs(){return!!es&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function hs(){return!!es&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ls(t){return t+t%2}function as(t){es&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class os{constructor(t,i,s){this.Fc=0,this.Wc=null,this.Hc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.$c=0,this.Uc=null,this.jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Yc=null,this.Zc=!1,this.Xc=null,this.qc=null,this.Kc=!1,this.Gc=!1,this.Jc=!1,this.Qc=null,this.td=null,this.sd=null,this.nd=null,this.ed=null,this.rd=null,this.hd=null,this.ld=0,this.ad=!1,this.od=!1,this._d=!1,this.ud=0,this.dd=null,this.fd=!hs(),this.pd=t=>{this.vd(t)},this.md=t=>{if(this.wd(t)){const i=this.gd(t);if(++this.$c,this.Uc&&this.$c>1){const{bd:s}=this.Md(cs(t),this.jc);s<30&&!this.Jc&&this.xd(i,this.yd.Sd),this.Pd()}}else{const i=this.gd(t);if(++this.Fc,this.Wc&&this.Fc>1){const{bd:s}=this.Md(cs(t),this.Hc);s<5&&!this.Gc&&this.Cd(i,this.yd.Td),this.kd()}}},this.Rd=t,this.yd=i,this.ys=s,this.Dd()}m(){null!==this.Qc&&(this.Qc(),this.Qc=null),null!==this.td&&(this.td(),this.td=null),null!==this.nd&&(this.nd(),this.nd=null),null!==this.ed&&(this.ed(),this.ed=null),null!==this.rd&&(this.rd(),this.rd=null),null!==this.sd&&(this.sd(),this.sd=null),this.Ed(),this.kd()}zd(t){this.nd&&this.nd();const i=this.Vd.bind(this);if(this.nd=()=>{this.Rd.removeEventListener("mousemove",i)},this.Rd.addEventListener("mousemove",i),this.wd(t))return;const s=this.gd(t);this.Cd(s,this.yd.Id),this.fd=!0}kd(){null!==this.Wc&&clearTimeout(this.Wc),this.Fc=0,this.Wc=null,this.Hc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Pd(){null!==this.Uc&&clearTimeout(this.Uc),this.$c=0,this.Uc=null,this.jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Vd(t){if(this._d||null!==this.qc)return;if(this.wd(t))return;const i=this.gd(t);this.Cd(i,this.yd.Ad),this.fd=!0}Bd(t){const i=fs(t.changedTouches,l(this.dd));if(null===i)return;if(this.ud=ds(t),null!==this.hd)return;if(this.od)return;this.ad=!0;const s=this.Md(cs(i),l(this.qc)),{Ld:n,Od:e,bd:r}=s;if(this.Kc||!(r<5)){if(!this.Kc){const t=.5*n,i=e>=t&&!this.ys.Nd(),s=t>e&&!this.ys.Fd();i||s||(this.od=!0),this.Kc=!0,this.Jc=!0,this.Ed(),this.Pd()}if(!this.od){const s=this.gd(t,i);this.xd(s,this.yd.Wd),us(t)}}}Hd(t){if(0!==t.button)return;const i=this.Md(cs(t),l(this.Xc)),{bd:s}=i;if(s>=5&&(this.Gc=!0,this.kd()),this.Gc){const i=this.gd(t);this.Cd(i,this.yd.$d)}}Md(t,i){const s=Math.abs(i._t-t._t),n=Math.abs(i.ut-t.ut);return{Ld:s,Od:n,bd:s+n}}Ud(t){let i=fs(t.changedTouches,l(this.dd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.dd=null,this.ud=ds(t),this.Ed(),this.qc=null,this.rd&&(this.rd(),this.rd=null);const s=this.gd(t,i);if(this.xd(s,this.yd.jd),++this.$c,this.Uc&&this.$c>1){const{bd:t}=this.Md(cs(i),this.jc);t<30&&!this.Jc&&this.xd(s,this.yd.Sd),this.Pd()}else this.Jc||(this.xd(s,this.yd.Yd),this.yd.Yd&&us(t));0===this.$c&&us(t),0===t.touches.length&&this.Zc&&(this.Zc=!1,us(t))}vd(t){if(0!==t.button)return;const i=this.gd(t);if(this.Xc=null,this._d=!1,this.ed&&(this.ed(),this.ed=null),rs()){this.Rd.ownerDocument.documentElement.removeEventListener("mouseleave",this.pd)}if(!this.wd(t))if(this.Cd(i,this.yd.Zd),++this.Fc,this.Wc&&this.Fc>1){const{bd:s}=this.Md(cs(t),this.Hc);s<5&&!this.Gc&&this.Cd(i,this.yd.Td),this.kd()}else this.Gc||this.Cd(i,this.yd.Xd)}Ed(){null!==this.Yc&&(clearTimeout(this.Yc),this.Yc=null)}qd(t){if(null!==this.dd)return;const i=t.changedTouches[0];this.dd=i.identifier,this.ud=ds(t);const s=this.Rd.ownerDocument.documentElement;this.Jc=!1,this.Kc=!1,this.od=!1,this.qc=cs(i),this.rd&&(this.rd(),this.rd=null);{const i=this.Bd.bind(this),n=this.Ud.bind(this);this.rd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.Ed(),this.Yc=setTimeout(this.Kd.bind(this,t),240)}const n=this.gd(t,i);this.xd(n,this.yd.Gd),this.Uc||(this.$c=0,this.Uc=setTimeout(this.Pd.bind(this),500),this.jc=cs(i))}Jd(t){if(0!==t.button)return;const i=this.Rd.ownerDocument.documentElement;rs()&&i.addEventListener("mouseleave",this.pd),this.Gc=!1,this.Xc=cs(t),this.ed&&(this.ed(),this.ed=null);{const t=this.Hd.bind(this),s=this.vd.bind(this);this.ed=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this._d=!0,this.wd(t))return;const s=this.gd(t);this.Cd(s,this.yd.Qd),this.Wc||(this.Fc=0,this.Wc=setTimeout(this.kd.bind(this),500),this.Hc=cs(t))}Dd(){this.Rd.addEventListener("mouseenter",this.zd.bind(this)),this.Rd.addEventListener("touchcancel",this.Ed.bind(this));{const t=this.Rd.ownerDocument,i=t=>{this.yd.tf&&(t.composed&&this.Rd.contains(t.composedPath()[0])||t.target&&this.Rd.contains(t.target)||this.yd.tf())};this.td=()=>{t.removeEventListener("touchstart",i)},this.Qc=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}hs()&&(this.sd=()=>{this.Rd.removeEventListener("dblclick",this.md)},this.Rd.addEventListener("dblclick",this.md)),this.Rd.addEventListener("mouseleave",this.if.bind(this)),this.Rd.addEventListener("touchstart",this.qd.bind(this),{passive:!0}),as(this.Rd),this.Rd.addEventListener("mousedown",this.Jd.bind(this)),this.sf(),this.Rd.addEventListener("touchmove",(()=>{}),{passive:!1})}sf(){void 0===this.yd.nf&&void 0===this.yd.ef&&void 0===this.yd.rf||(this.Rd.addEventListener("touchstart",(t=>this.hf(t.touches)),{passive:!0}),this.Rd.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.hd&&void 0!==this.yd.ef){const i=_s(t.touches[0],t.touches[1])/this.ld;this.yd.ef(this.hd,i),us(t)}}),{passive:!1}),this.Rd.addEventListener("touchend",(t=>{this.hf(t.touches)})))}hf(t){1===t.length&&(this.ad=!1),2!==t.length||this.ad||this.Zc?this.lf():this.af(t)}af(t){const i=this.Rd.getBoundingClientRect()||{left:0,top:0};this.hd={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.ld=_s(t[0],t[1]),void 0!==this.yd.nf&&this.yd.nf(),this.Ed()}lf(){null!==this.hd&&(this.hd=null,void 0!==this.yd.rf&&this.yd.rf())}if(t){if(this.nd&&this.nd(),this.wd(t))return;if(!this.fd)return;const i=this.gd(t);this.Cd(i,this.yd._f),this.fd=!hs()}Kd(t){const i=fs(t.touches,l(this.dd));if(null===i)return;const s=this.gd(t,i);this.xd(s,this.yd.uf),this.Jc=!0,this.Zc=!0}wd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:ds(t){"touchstart"!==t.type&&us(t)}}}}function _s(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function us(t){t.cancelable&&t.preventDefault()}function cs(t){return{_t:t.pageX,ut:t.pageY}}function ds(t){return t.timeStamp||performance.now()}function fs(t,i){for(let s=0;s!1,Fd:()=>!0}),this.vf={Vf:s,zf:t}}Cf(){this.Pf.style.background=this.bf.N().layout.panes.separatorColor}If(t){null!==this.vf&&(this.vf.Vf.style.backgroundColor=this.bf.N().layout.panes.separatorHoverColor)}Af(t){null!==this.vf&&null===this.gf&&(this.vf.Vf.style.backgroundColor="")}Bf(t){if(null===this.vf)return;const i=this.Mf.Nf().do()+this.Sf.Nf().do(),s=i/(this.Mf.Rf().height+this.Sf.Rf().height),n=30*s;i<=2*n||(this.gf={Ff:t.pageY,Wf:this.Mf.Nf().do(),Hf:i-n,$f:i,Uf:s,jf:n},this.vf.zf.style.display="block")}Lf(t){const i=this.gf;if(null===i)return;const s=(t.pageY-i.Ff)*i.Uf,n=ri(i.Wf+s,i.jf,i.Hf);this.Mf.Nf().fo(n),this.Sf.Nf().fo(i.$f-n),this.bf.Qt().zh()}Of(t){null!==this.gf&&null!==this.vf&&(this.gf=null,this.vf.zf.style.display="none")}}function vs(t,i){return t.Yf-i.Yf}function ms(t,i,s){const n=(t.Yf-i.Yf)/(t.wt-i.wt);return Math.sign(n)*Math.min(Math.abs(n),s)}class ws{constructor(t,i,s,n){this.Zf=null,this.Xf=null,this.qf=null,this.Kf=null,this.Gf=null,this.Jf=0,this.Qf=0,this.tp=t,this.ip=i,this.sp=s,this.gn=n}np(t,i){if(null!==this.Zf){if(this.Zf.wt===i)return void(this.Zf.Yf=t);if(Math.abs(this.Zf.Yf-t)50)return;let s=0;const n=ms(this.Zf,this.Xf,this.ip),e=vs(this.Zf,this.Xf),r=[n],h=[e];if(s+=e,null!==this.qf){const t=ms(this.Xf,this.qf,this.ip);if(Math.sign(t)===Math.sign(n)){const i=vs(this.Xf,this.qf);if(r.push(t),h.push(i),s+=i,null!==this.Kf){const t=ms(this.qf,this.Kf,this.ip);if(Math.sign(t)===Math.sign(n)){const i=vs(this.qf,this.Kf);r.push(t),h.push(i),s+=i}}}}let l=0;for(let t=0;t160?"dark":"light"}dp(){return this.op.N().layout.attributionLogo}pp(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}_p(){this.cp()&&(this.up(),this.fs=this.dp(),this.fs&&(this.lp=this.fp(),this.hp=document.createElement("style"),this.hp.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.rp=document.createElement("a"),this.rp.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.pp()}`,this.rp.title="Charting by TradingView",this.rp.id="tv-attr-logo",this.rp.target="_blank",this.rp.innerHTML='',this.rp.toggleAttribute("data-dark","dark"===this.lp),this.ap.appendChild(this.hp),this.ap.appendChild(this.rp)))}}function bs(t,i){const s=l(t.ownerDocument).createElement("canvas");t.appendChild(s);const n=function(t,i){if("device-pixel-content-box"===i.type)return new ts(t,i.transform,i.options);throw new Error("Unsupported binding target")}(s,{type:"device-pixel-content-box",options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})});return n.resizeCanvasElement(i),n}function Ms(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function xs(t,i,s,n){t.th&&t.th(i,s,n)}function Ss(t,i,s,n){t.nt(i,s,n)}function ys(t,i,s,n){const e=t(s,n);for(const t of e){const s=t.kt(n);null!==s&&i(s)}}function Ps(t,i){return s=>{if(!function(t){return void 0!==t.Ft}(s))return[];return(s.Ft()?.ml()??"")!==i?[]:s.Qh?.(t)??[]}}function Cs(t,i,s,n){if(!t.length)return;let e=0;const r=t[0].Ut(n,!0);let h=1===i?s/2-(t[0].Fi()-r/2):t[0].Fi()-r/2-s/2;h=Math.max(0,h);for(let r=1;ru-o:_s)&&h>0){const n=1===i?-1-r:r-s,l=Math.min(n,h);for(let s=e;s{this.Mp||this.Pt.Sp().Qt().hr()},this.yp=()=>{this.Mp||this.Pt.Sp().Qt().hr()},this.Pt=t,this.ys=i,this.oa=i.layout,this.Vu=s,this.Pp="left"===n,this.Cp=Ps("normal",n),this.Tp=Ps("top",n),this.kp=Ps("bottom",n),this.Pf=document.createElement("div"),this.Pf.style.height="100%",this.Pf.style.overflow="hidden",this.Pf.style.width="25px",this.Pf.style.left="0",this.Pf.style.position="relative",this.Rp=bs(this.Pf,Gi({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const e=this.Rp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.Dp=bs(this.Pf,Gi({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.yp);const r=this.Dp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={Qd:this.Bf.bind(this),Gd:this.Bf.bind(this),$d:this.Lf.bind(this),Wd:this.Lf.bind(this),tf:this.Ep.bind(this),Zd:this.Of.bind(this),jd:this.Of.bind(this),Td:this.zp.bind(this),Sd:this.zp.bind(this),Id:this.Vp.bind(this),_f:this.Af.bind(this)};this.mf=new os(this.Dp.canvasElement,h,{Nd:()=>!this.ys.handleScroll.vertTouchDrag,Fd:()=>!0})}m(){this.mf.m(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose(),null!==this.Yi&&this.Yi.Wa().u(this),this.Yi=null}kf(){return this.Pf}C(){return this.oa.fontSize}Ip(){const t=this.Vu.N();return this.gp!==t.T&&(this.wp.En(),this.gp=t.T),t}Ap(){if(null===this.Yi)return 0;let t=0;const i=this.Ip(),s=l(this.Rp.canvasElement.getContext("2d",{colorSpace:this.Pt.Sp().N().layout.colorSpace}));s.save();const n=this.Yi.Dl();s.font=this.Bp(),n.length>0&&(t=Math.max(this.wp.Ei(s,n[0].$l),this.wp.Ei(s,n[n.length-1].$l)));const e=this.Lp();for(let i=e.length;i--;){const n=this.wp.Ei(s,e[i].ri());n>t&&(t=n)}const r=this.Yi.Bt();if(null!==r&&null!==this.vp&&(2!==(h=this.ys.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Yi.Ts(1,r),n=this.Yi.Ts(this.vp.height-2,r);t=Math.max(t,this.wp.Ei(s,this.Yi.Ki(Math.floor(Math.min(i,n))+.11111111111111,r)),this.wp.Ei(s,this.Yi.Ki(Math.ceil(Math.max(i,n))-.11111111111111,r)))}var h;s.restore();const a=t||34;return ls(Math.ceil(i.S+i.P+i.I+i.A+5+a))}Op(t){null!==this.vp&&Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.Pf.style.width=`${t.width}px`,this.Pf.style.height=`${t.height}px`)}Np(){return l(this.vp).width}os(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.Wa().u(this),this.Yi=t,t.Wa().i(this.ta.bind(this),this))}Ft(){return this.Yi}En(){const t=this.Pt.Nf();this.Pt.Sp().Qt().zo(t,l(this.Ft()))}Fp(t){if(null===this.vp)return;const i={colorSpace:this.Pt.Sp().N().layout.colorSpace};if(1!==t){this.Wp(),this.Rp.applySuggestedBitmapSize();const t=ns(this.Rp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t)})),this.Pt.Up(t,this.kp),this.jp(t),this.Pt.Up(t,this.Cp),this.Yp(t))}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Zp(s),this.Pt.Up(s,this.Tp))}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Ct(){this.Yi?.Dl()}Bf(t){if(null===this.Yi||this.Yi.Xi()||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Sp().Qt(),s=this.Pt.Nf();this.mp=!0,i.Po(s,this.Yi,t.localY)}Lf(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Sp().Qt(),s=this.Pt.Nf(),n=this.Yi;i.Co(s,n,t.localY)}Ep(){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const t=this.Pt.Sp().Qt(),i=this.Pt.Nf(),s=this.Yi;this.mp&&(this.mp=!1,t.To(i,s))}Of(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Sp().Qt(),s=this.Pt.Nf();this.mp=!1,i.To(s,this.Yi)}zp(t){this.ys.handleScale.axisDoubleClickReset.price&&this.En()}Vp(t){if(null===this.Yi)return;!this.Pt.Sp().Qt().N().handleScale.axisPressedMouseMove.price||this.Yi.Be()||this.Yi.wa()||this.Xp(1)}Af(t){this.Xp(0)}Lp(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let n=0;n{t.fillStyle=s.borderColor;const l=Math.max(1,Math.floor(h)),a=Math.floor(.5*h),o=Math.round(n.P*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.Pl*h)-a,o,l);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Bp(),t.fillStyle=s.textColor??this.oa.textColor,t.textAlign=this.Pp?"right":"left",t.textBaseline="middle";const r=this.Pp?Math.round(e-n.I):Math.round(e+n.P+n.I),h=i.map((i=>this.wp.Di(t,i.$l)));for(let s=i.length;s--;){const n=i[s];t.fillText(n.$l,r,n.Pl+h[s])}}))}Wp(){if(null===this.vp||null===this.Yi)return;let t=this.vp.height/2;const i=[],s=this.Yi.Dt().slice(),n=this.Pt.Nf(),e=this.Ip();this.Yi===n.$n()&&this.Pt.Nf().Dt().forEach((t=>{n.Hn(t)&&s.push(t)}));const r=this.Yi.bl()[0],h=this.Yi;s.forEach((s=>{const e=s.Fs(n,h);e.forEach((t=>{t.Wi(null),t.Hi()&&i.push(t)})),r===s&&e.length>0&&(t=e[0].Vi())})),i.forEach((t=>t.Wi(t.Vi())));this.Yi.N().alignLabels&&this.qp(i,e,t)}qp(t,i,s){if(null===this.vp)return;const n=t.filter((t=>t.Vi()<=s)),e=t.filter((t=>t.Vi()>s));n.sort(((t,i)=>i.Vi()-t.Vi())),n.length&&e.length&&e.push(n[0]),e.sort(((t,i)=>t.Vi()-i.Vi()));for(const s of t){const t=Math.floor(s.Ut(i)/2),n=s.Vi();n>-t&&nthis.vp.height-t&&n{if(i.$i()){i.kt(l(this.Yi)).nt(t,s,this.wp,n)}}))}Zp(t){if(null===this.vp||null===this.Yi)return;const i=this.Pt.Sp().Qt(),s=[],n=this.Pt.Nf(),e=i.ju().Fs(n,this.Yi);e.length&&s.push(e);const r=this.Ip(),h=this.Pp?"right":"left";s.forEach((i=>{i.forEach((i=>{i.kt(l(this.Yi)).nt(t,r,this.wp,h)}))}))}Xp(t){this.Pf.style.cursor=1===t?"ns-resize":"default"}ta(){const t=this.Ap();this.bp{this.Mp||null===this.ov||this.ts().hr()},this.yp=()=>{this.Mp||null===this.ov||this.ts().hr()},this.op=t,this.ov=i,this.ov.Ao().i(this._v.bind(this),this,!0),this.uv=document.createElement("td"),this.uv.style.padding="0",this.uv.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.cv=document.createElement("td"),this.cv.style.padding="0",this.dv=document.createElement("td"),this.dv.style.padding="0",this.uv.appendChild(s),this.Rp=bs(s,Gi({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const n=this.Rp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Dp=bs(s,Gi({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.yp);const e=this.Dp.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.yf=document.createElement("tr"),this.yf.appendChild(this.cv),this.yf.appendChild(this.uv),this.yf.appendChild(this.dv),this.fv(),this.mf=new os(this.Dp.canvasElement,this,{Nd:()=>null===this.rv&&!this.op.N().handleScroll.vertTouchDrag,Fd:()=>null===this.rv&&!this.op.N().handleScroll.horzTouchDrag})}m(){null!==this.Kp&&this.Kp.m(),null!==this.Gp&&this.Gp.m(),this.Jp=null,this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose(),null!==this.ov&&(this.ov.Ao().u(this),this.ov.m()),this.mf.m()}Nf(){return l(this.ov)}pv(t){null!==this.ov&&this.ov.Ao().u(this),this.ov=t,null!==this.ov&&this.ov.Ao().i(zs.prototype._v.bind(this),this,!0),this.fv(),this.op.xf().indexOf(this)===this.op.xf().length-1?(this.Jp=this.Jp??new gs(this.uv,this.op),this.Jp.Ct()):(this.Jp?.up(),this.Jp=null)}Sp(){return this.op}kf(){return this.yf}fv(){if(null!==this.ov&&(this.vv(),0!==this.ts().Ys().length)){if(null!==this.Kp){const t=this.ov.So();this.Kp.os(l(t))}if(null!==this.Gp){const t=this.ov.yo();this.Gp.os(l(t))}}}mv(){null!==this.Kp&&this.Kp.Ct(),null!==this.Gp&&this.Gp.Ct()}do(){return null!==this.ov?this.ov.do():0}fo(t){this.ov&&this.ov.fo(t)}Id(t){if(!this.ov)return;this.wv();const i=t.localX,s=t.localY;this.gv(i,s,t)}Qd(t){this.wv(),this.bv(),this.gv(t.localX,t.localY,t)}Ad(t){if(!this.ov)return;this.wv();const i=t.localX,s=t.localY;this.gv(i,s,t)}Xd(t){null!==this.ov&&(this.wv(),this.Mv(t))}Td(t){null!==this.ov&&this.xv(this.sv,t)}Sd(t){this.Td(t)}$d(t){this.wv(),this.Sv(t),this.gv(t.localX,t.localY,t)}Zd(t){null!==this.ov&&(this.wv(),this.ev=!1,this.yv(t))}Yd(t){null!==this.ov&&this.Mv(t)}uf(t){if(this.ev=!0,null===this.rv){const i={x:t.localX,y:t.localY};this.Pv(i,i,t)}}_f(t){null!==this.ov&&(this.wv(),this.ov.Qt().Hu(null),this.Cv())}Tv(){return this.iv}kv(){return this.sv}nf(){this.nv=1,this.ts().rn()}ef(t,i){if(!this.op.N().handleScale.pinch)return;const s=5*(i-this.nv);this.nv=i,this.ts().Qu(t._t,s)}Gd(t){this.ev=!1,this.hv=null!==this.rv,this.bv();const i=this.ts().ju();null!==this.rv&&i.Et()&&(this.lv={x:i.si(),y:i.ni()},this.rv={x:t.localX,y:t.localY})}Wd(t){if(null===this.ov)return;const i=t.localX,s=t.localY;if(null===this.rv)this.Sv(t);else{this.hv=!1;const n=l(this.lv),e=n.x+(i-this.rv.x),r=n.y+(s-this.rv.y);this.gv(e,r,t)}}jd(t){0===this.Sp().N().trackingMode.exitMode&&(this.hv=!0),this.Rv(),this.yv(t)}Yn(t,i){const s=this.ov;return null===s?null:gi(s,t,i)}Dv(t,i){l("left"===i?this.Kp:this.Gp).Op(Gi({width:t,height:this.vp.height}))}Rf(){return this.vp}Op(t){Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.uv.style.width=t.width+"px",this.uv.style.height=t.height+"px")}Ev(){const t=l(this.ov);t.xo(t.So()),t.xo(t.yo());for(const i of t.bl())if(t.Hn(i)){const s=i.Ft();null!==s&&t.xo(s),i.Os()}for(const i of t.Lo())i.Os()}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Fp(t){if(0===t)return;if(null===this.ov)return;t>1&&this.Ev(),null!==this.Kp&&this.Kp.Fp(t),null!==this.Gp&&this.Gp.Fp(t);const i={colorSpace:this.op.N().layout.colorSpace};if(1!==t){this.Rp.applySuggestedBitmapSize();const t=ns(this.Rp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Hp(t)})),this.ov&&(this.zv(t,ks),this.Vv(t),this.zv(t,Rs),this.zv(t,Ds)))}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Iv(s),this.zv(s,Es),this.zv(s,Ds))}Av(){return this.Kp}Bv(){return this.Gp}Up(t,i){this.zv(t,i)}_v(){null!==this.ov&&this.ov.Ao().u(this),this.ov=null}Mv(t){this.xv(this.iv,t)}xv(t,i){const s=i.localX,n=i.localY;t.v()&&t.p(this.ts().It().Z_(s),{x:s,y:n},i)}Hp({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ts(),r=e.U(),h=e.Mc();r===h?V(t,0,0,s,n,h):B(t,0,0,s,n,r,h)}Vv(t){const i=l(this.ov),s=i.Bo().lr().kt(i);null!==s&&s.nt(t,!1)}Iv(t){this.Lv(t,Rs,Ss,this.ts().ju())}zv(t,i){const s=l(this.ov),n=s.Dt(),e=s.Lo();for(const s of e)this.Lv(t,i,xs,s);for(const s of n)this.Lv(t,i,xs,s);for(const s of e)this.Lv(t,i,Ss,s);for(const s of n)this.Lv(t,i,Ss,s)}Lv(t,i,s,n){const e=l(this.ov),r=e.Qt().Wu(),h=null!==r&&r.No===n,a=null!==r&&h&&void 0!==r.Fo?r.Fo.Xn:void 0;ys(i,(i=>s(i,t,h,a)),n,e)}vv(){if(null===this.ov)return;const t=this.op,i=this.ov.So().N().visible,s=this.ov.yo().N().visible;i||null===this.Kp||(this.cv.removeChild(this.Kp.kf()),this.Kp.m(),this.Kp=null),s||null===this.Gp||(this.dv.removeChild(this.Gp.kf()),this.Gp.m(),this.Gp=null);const n=t.Qt().uc();i&&null===this.Kp&&(this.Kp=new Ts(this,t.N(),n,"left"),this.cv.appendChild(this.Kp.kf())),s&&null===this.Gp&&(this.Gp=new Ts(this,t.N(),n,"right"),this.dv.appendChild(this.Gp.kf()))}Ov(t){return t.cf&&this.ev||null!==this.rv}Nv(t){return Math.max(0,Math.min(t,this.vp.width-1))}Fv(t){return Math.max(0,Math.min(t,this.vp.height-1))}gv(t,i,s){this.ts().lc(this.Nv(t),this.Fv(i),s,l(this.ov))}Cv(){this.ts().oc()}Rv(){this.hv&&(this.rv=null,this.Cv())}Pv(t,i,s){this.rv=t,this.hv=!1,this.gv(i.x,i.y,s);const n=this.ts().ju();this.lv={x:n.si(),y:n.ni()}}ts(){return this.op.Qt()}yv(t){if(!this.tv)return;const i=this.ts(),s=this.Nf();if(i.Do(s,s.Cs()),this.Qp=null,this.tv=!1,i.ec(),null!==this.av){const t=performance.now(),s=i.It();this.av.le(s.tu(),t),this.av._u(t)||i.an(this.av)}}wv(){this.rv=null}bv(){if(!this.ov)return;if(this.ts().rn(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)l(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.ov.Cs().Xi()&&this.ts().It().Xi()}Sv(t){if(null===this.ov)return;const i=this.ts(),s=i.It();if(s.Xi())return;const n=this.op.N(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t.cf)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.cf))return;const h=this.ov.Cs(),l=performance.now();if(null!==this.Qp||this.Ov(t)||(this.Qp={x:t.clientX,y:t.clientY,Bc:l,Wv:t.localX,Hv:t.localY}),null!==this.Qp&&!this.tv&&(this.Qp.x!==t.clientX||this.Qp.y!==t.clientY)){if(t.cf&&r.touch||!t.cf&&r.mouse){const t=s.J_();this.av=new ws(.2/t,7/t,.997,15/t),this.av.np(s.tu(),this.Qp.Bc)}else this.av=null;h.Xi()||i.ko(this.ov,h,t.localY),i.sc(t.localX),this.tv=!0}this.tv&&(h.Xi()||i.Ro(this.ov,h,t.localY),i.nc(t.localX),null!==this.av&&this.av.np(s.tu(),l))}}class Vs{constructor(t,i,s,n,e){this.St=!0,this.vp=Gi({width:0,height:0}),this.xp=()=>this.Fp(3),this.Pp="left"===t,this.Vu=s.uc,this.ys=i,this.$v=n,this.Uv=e,this.Pf=document.createElement("div"),this.Pf.style.width="25px",this.Pf.style.height="100%",this.Pf.style.overflow="hidden",this.Rp=bs(this.Pf,Gi({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp)}m(){this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose()}kf(){return this.Pf}Rf(){return this.vp}Op(t){Ji(this.vp,t)||(this.vp=t,this.Rp.resizeCanvasElement(t),this.Pf.style.width=`${t.width}px`,this.Pf.style.height=`${t.height}px`,this.St=!0)}Fp(t){if(t<3&&!this.St)return;if(0===this.vp.width||0===this.vp.height)return;this.St=!1,this.Rp.applySuggestedBitmapSize();const i=ns(this.Rp,{colorSpace:this.ys.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t)}))}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}$p({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.$v())return;t.fillStyle=this.ys.timeScale.borderColor;const e=Math.floor(this.Vu.N().S*s),r=Math.floor(this.Vu.N().S*n),h=this.Pp?i.width-e:0;t.fillRect(h,0,e,r)}Hp({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.Uv())}}function Is(t){return i=>i.tl?.(t)??[]}const As=Is("normal"),Bs=Is("top"),Ls=Is("bottom");class Os{constructor(t,i){this.jv=null,this.Yv=null,this.M=null,this.Zv=!1,this.vp=Gi({width:0,height:0}),this.Xv=new o,this.wp=new tt(5),this.Mp=!1,this.xp=()=>{this.Mp||this.op.Qt().hr()},this.yp=()=>{this.Mp||this.op.Qt().hr()},this.op=t,this.jo=i,this.ys=t.N().layout,this.rp=document.createElement("tr"),this.qv=document.createElement("td"),this.qv.style.padding="0",this.Kv=document.createElement("td"),this.Kv.style.padding="0",this.Pf=document.createElement("td"),this.Pf.style.height="25px",this.Pf.style.padding="0",this.Gv=document.createElement("div"),this.Gv.style.width="100%",this.Gv.style.height="100%",this.Gv.style.position="relative",this.Gv.style.overflow="hidden",this.Pf.appendChild(this.Gv),this.Rp=bs(this.Gv,Gi({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const s=this.Rp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Dp=bs(this.Gv,Gi({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.yp);const n=this.Dp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.rp.appendChild(this.qv),this.rp.appendChild(this.Pf),this.rp.appendChild(this.Kv),this.Jv(),this.op.Qt().co().i(this.Jv.bind(this),this),this.mf=new os(this.Dp.canvasElement,this,{Nd:()=>!0,Fd:()=>!this.op.N().handleScroll.horzTouchDrag})}m(){this.mf.m(),null!==this.jv&&this.jv.m(),null!==this.Yv&&this.Yv.m(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose()}kf(){return this.rp}Qv(){return this.jv}tm(){return this.Yv}Qd(t){if(this.Zv)return;this.Zv=!0;const i=this.op.Qt();!i.It().Xi()&&this.op.N().handleScale.axisPressedMouseMove.time&&i.Ju(t.localX)}Gd(t){this.Qd(t)}tf(){const t=this.op.Qt();!t.It().Xi()&&this.Zv&&(this.Zv=!1,this.op.N().handleScale.axisPressedMouseMove.time&&t.hc())}$d(t){const i=this.op.Qt();!i.It().Xi()&&this.op.N().handleScale.axisPressedMouseMove.time&&i.rc(t.localX)}Wd(t){this.$d(t)}Zd(){this.Zv=!1;const t=this.op.Qt();t.It().Xi()&&!this.op.N().handleScale.axisPressedMouseMove.time||t.hc()}jd(){this.Zd()}Td(){this.op.N().handleScale.axisDoubleClickReset.time&&this.op.Qt().un()}Sd(){this.Td()}Id(){this.op.Qt().N().handleScale.axisPressedMouseMove.time&&this.Xp(1)}_f(){this.Xp(0)}Rf(){return this.vp}im(){return this.Xv}sm(t,i,s){Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.Pf.style.width=`${t.width}px`,this.Pf.style.height=`${t.height}px`,this.Xv.p(t)),null!==this.jv&&this.jv.Op(Gi({width:i,height:t.height})),null!==this.Yv&&this.Yv.Op(Gi({width:s,height:t.height}))}nm(){const t=this.rm();return Math.ceil(t.S+t.P+t.C+t.B+t.V+t.hm)}Ct(){this.op.Qt().It().Dl()}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Fp(t){if(0===t)return;const i={colorSpace:this.ys.colorSpace};if(1!==t){this.Rp.applySuggestedBitmapSize();const s=ns(this.Rp,i);null!==s&&(s.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t),this.lm(s,Ls)})),this.jp(s),this.lm(s,As)),null!==this.jv&&this.jv.Fp(t),null!==this.Yv&&this.Yv.Fp(t)}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.am([...this.op.Qt().Ys(),this.op.Qt().ju()],s),this.lm(s,Bs))}lm(t,i){const s=this.op.Qt().Ys();for(const n of s)ys(i,(i=>xs(i,t,!1,void 0)),n,void 0);for(const n of s)ys(i,(i=>Ss(i,t,!1,void 0)),n,void 0)}Hp({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.op.Qt().Mc())}$p({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.op.N().timeScale.borderVisible){t.fillStyle=this.om();const n=Math.max(1,Math.floor(this.rm().S*s));t.fillRect(0,0,i.width,n)}}jp(t){const i=this.op.Qt().It(),s=i.Dl();if(!s||0===s.length)return;const n=this.jo.maxTickMarkWeight(s),e=this.rm(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.om(),t.fillStyle=this.om();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const l=Math.round(e.P*n);for(let n=s.length;n--;){const e=Math.round(s[n].coord*i);t.rect(e-h,0,r,l)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.S+e.P+e.B+e.C/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this.Bp();for(const e of s)if(e.weight=n){const s=e.needAlignCoordinate?this._m(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}}))}_m(t,i,s){const n=this.wp.Ei(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.vp.width&&(i-=Math.abs(this.vp.width-(r+n))),i}am(t,i){const s=this.rm();for(const n of t)for(const t of n.us())t.kt().nt(i,s)}om(){return this.op.N().timeScale.borderColor}H(){return this.ys.textColor}F(){return this.ys.fontSize}Bp(){return g(this.F(),this.ys.fontFamily)}um(){return g(this.F(),this.ys.fontFamily,"bold")}rm(){null===this.M&&(this.M={S:1,L:NaN,B:NaN,V:NaN,Ji:NaN,P:5,C:NaN,T:"",Gi:new tt,hm:0});const t=this.M,i=this.Bp();if(t.T!==i){const s=this.F();t.C=s,t.T=i,t.B=3*s/12,t.V=3*s/12,t.Ji=9*s/12,t.L=0,t.hm=4*s/12,t.Gi.En()}return this.M}Xp(t){this.Pf.style.cursor=1===t?"ew-resize":"default"}Jv(){const t=this.op.Qt(),i=t.N();i.leftPriceScale.visible||null===this.jv||(this.qv.removeChild(this.jv.kf()),this.jv.m(),this.jv=null),i.rightPriceScale.visible||null===this.Yv||(this.Kv.removeChild(this.Yv.kf()),this.Yv.m(),this.Yv=null);const s={uc:this.op.Qt().uc()},n=()=>i.leftPriceScale.borderVisible&&t.It().N().borderVisible,e=()=>t.Mc();i.leftPriceScale.visible&&null===this.jv&&(this.jv=new Vs("left",i,s,n,e),this.qv.appendChild(this.jv.kf())),i.rightPriceScale.visible&&null===this.Yv&&(this.Yv=new Vs("right",i,s,n,e),this.Kv.appendChild(this.Yv.kf()))}}const Ns=!!es&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!es&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Fs{constructor(t,i,s){var n;this.dm=[],this.fm=[],this.pm=0,this.Yl=0,this.so=0,this.vm=0,this.wm=0,this.gm=null,this.bm=!1,this.iv=new o,this.sv=new o,this.Du=new o,this.Mm=null,this.xm=null,this.ap=t,this.ys=i,this.jo=s,this.rp=document.createElement("div"),this.rp.classList.add("tv-lightweight-charts"),this.rp.style.overflow="hidden",this.rp.style.direction="ltr",this.rp.style.width="100%",this.rp.style.height="100%",(n=this.rp).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.Sm=document.createElement("table"),this.Sm.setAttribute("cellspacing","0"),this.rp.appendChild(this.Sm),this.ym=this.Pm.bind(this),Ws(this.ys)&&this.Cm(!0),this.ts=new zi(this.zu.bind(this),this.ys,s),this.Qt().Yu().i(this.Tm.bind(this),this),this.km=new Os(this,this.jo),this.Sm.appendChild(this.km.kf());const e=i.autoSize&&this.Rm();let r=this.ys.width,h=this.ys.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.Dm(r,h),this.Em(),t.appendChild(this.rp),this.zm(),this.ts.It().fu().i(this.ts.zh.bind(this.ts),this),this.ts.co().i(this.ts.zh.bind(this.ts),this)}Qt(){return this.ts}N(){return this.ys}xf(){return this.dm}Vm(){return this.km}m(){this.Cm(!1),0!==this.pm&&window.cancelAnimationFrame(this.pm),this.ts.Yu().u(this),this.ts.It().fu().u(this),this.ts.co().u(this),this.ts.m();for(const t of this.dm)this.Sm.removeChild(t.kf()),t.Tv().u(this),t.kv().u(this),t.m();this.dm=[];for(const t of this.fm)this.Im(t);this.fm=[],l(this.km).m(),null!==this.rp.parentElement&&this.rp.parentElement.removeChild(this.rp),this.Du.m(),this.iv.m(),this.sv.m(),this.Am()}Dm(t,i,s=!1){if(this.Yl===i&&this.so===t)return;const n=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return Gi({width:i-i%2,height:s-s%2})}(Gi({width:t,height:i}));this.Yl=n.height,this.so=n.width;const e=this.Yl+"px",r=this.so+"px";l(this.rp).style.height=e,l(this.rp).style.width=r,this.Sm.style.height=e,this.Sm.style.width=r,s?this.Bm(Z.wn(),performance.now()):this.ts.zh()}Fp(t){void 0===t&&(t=Z.wn());for(let i=0;i{t.Ct()}))}Om(t){(void 0!==t.autoSize||!this.Mm||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.Mm&&this.Rm(),!1===t.autoSize&&null!==this.Mm&&this.Am(),t.autoSize||void 0===t.width&&void 0===t.height||this.Dm(t.width||this.so,t.height||this.Yl))}Fm(t){let i=0,s=0;const n=this.dm[0],e=(i,s)=>{let n=0;for(let e=0;e{l("left"===i?this.km.Qv():this.km.tm()).Ef(l(t),s,n)};if(this.ys.timeScale.visible){const i=this.km.Df();if(null!==t){let e=0;this.Hm()&&(r("left",e,s),e=l(n.Av()).Df().width),this.km.Ef(t,e,s),e+=i.width,this.$m()&&r("right",e,s)}s+=i.height}return Gi({width:i,height:s})}Xm(){let t=0,i=0,s=0;for(const n of this.dm)this.Hm()&&(i=Math.max(i,l(n.Av()).Ap(),this.ys.leftPriceScale.minimumWidth)),this.$m()&&(s=Math.max(s,l(n.Bv()).Ap(),this.ys.rightPriceScale.minimumWidth)),t+=n.do();i=ls(i),s=ls(s);const n=this.so,e=this.Yl,r=Math.max(n-i-s,0),h=1*this.fm.length,a=this.ys.timeScale.visible;let o=a?Math.max(this.km.nm(),this.ys.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e{t.mv()})),3===this.gm?.sn()&&(this.gm.pn(t),this.Km(),this.Gm(this.gm),this.Jm(this.gm,i),t=this.gm,this.gm=null)),this.Fp(t)}Jm(t,i){for(const s of t.fn())this.vn(s,i)}Gm(t){const i=this.ts.$s();for(let s=0;s{if(this.bm=!1,this.pm=0,null!==this.gm){const i=this.gm;this.gm=null,this.Bm(i,t);for(const s of i.fn())if(5===s.hn&&!s.Wt._u(t)){this.Qt().an(s.Wt);break}}})))}Km(){this.Em()}Im(t){this.Sm.removeChild(t.kf()),t.m()}Em(){const t=this.ts.$s(),i=t.length,s=this.dm.length;for(let t=i;t0){const t=new ps(this,n-1,n);this.fm.push(t),this.Sm.insertBefore(t.kf(),this.km.kf())}this.Sm.insertBefore(i.kf(),this.km.kf())}for(let s=0;s{const s=i.Xs().Nr(t);null!==s&&e.set(i,s)}))}let r;if(null!==t){const i=this.ts.It().ss(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().Wu(),l=null!==h&&h.No instanceof Ht?h.No:void 0,a=null!==h&&void 0!==h.Fo?h.Fo.Zn:void 0,o=this.sw(n);return{nw:r,ke:t??void 0,ew:i??void 0,rw:-1!==o?o:void 0,hw:l,lw:e,aw:a,ow:s??void 0}}sw(t){let i=-1;if(t)i=this.dm.indexOf(t);else{const t=this.Qt().ju().Hs();null!==t&&(i=this.Qt().$s().indexOf(t))}return i}Qm(t,i,s,n){this.iv.p((()=>this.iw(i,s,n,t)))}tw(t,i,s,n){this.sv.p((()=>this.iw(i,s,n,t)))}Tm(t,i,s){this.jm(this.Qt().Wu()?.Ho??null),this.Du.p((()=>this.iw(t,i,s)))}zm(){const t=this.ys.timeScale.visible?"":"none";this.km.kf().style.display=t}Hm(){return this.dm[0].Nf().So().N().visible}$m(){return this.dm[0].Nf().yo().N().visible}Rm(){return"ResizeObserver"in window&&(this.Mm=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.Dm(i.contentRect.width,i.contentRect.height)})),this.Mm.observe(this.ap,{box:"border-box"}),!0)}Am(){null!==this.Mm&&this.Mm.disconnect(),this.Mm=null}}function Ws(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Hs(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function $s(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.color&&(r.R=s.color),r}function Us(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.lineColor&&(r.vt=s.lineColor),void 0!==s.topColor&&(r.vr=s.topColor),void 0!==s.bottomColor&&(r.mr=s.bottomColor),r}function js(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.topLineColor&&(r.wr=s.topLineColor),void 0!==s.bottomLineColor&&(r.gr=s.bottomLineColor),void 0!==s.topFillColor1&&(r.br=s.topFillColor1),void 0!==s.topFillColor2&&(r.Mr=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.Sr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.yr=s.bottomFillColor2),r}function Ys(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],nw:n};return void 0!==s.color&&(e.R=s.color),e}function Zs(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],nw:n};return void 0!==s.color&&(e.R=s.color),void 0!==s.borderColor&&(e.Ht=s.borderColor),void 0!==s.wickColor&&(e.pr=s.wickColor),e}function Xs(t,i,s,n,e){const r=h(e)(s),l=Math.max(...r),a=Math.min(...r),o=r[r.length-1],_=[o,l,a,o],{time:u,color:c,...d}=s;return{ke:i,wt:t,Wt:_,nw:n,ie:d,R:c}}function qs(t){return void 0!==t.Wt}function Ks(t,i){return void 0!==i.customValues&&(t._w=i.customValues),t}function Gs(t){return(i,s,n,e,r,h)=>function(t,i){return i?i(t):void 0===(s=t).open&&void 0===s.value;var s}(n,h)?Ks({wt:i,ke:s,nw:e},n):Ks(t(i,s,n,e,r),n)}function Js(t){return{Candlestick:Gs(Zs),Bar:Gs(Ys),Area:Gs(Us),Baseline:Gs(js),Histogram:Gs($s),Line:Gs($s),Custom:Gs(Xs)}[t]}function Qs(t){return{ke:0,uw:new Map,Wh:t}}function tn(t,i){if(void 0!==t&&0!==t.length)return{cw:i.key(t[0].wt),dw:i.key(t[t.length-1].wt)}}function sn(t){let i;return t.forEach((t=>{void 0===i&&(i=t.nw)})),h(i)}class nn{constructor(t){this.fw=new Map,this.pw=new Map,this.mw=new Map,this.ww=[],this.jo=t}m(){this.fw.clear(),this.pw.clear(),this.mw.clear(),this.ww=[]}gw(t,i){let s=0!==this.fw.size,n=!1;const e=this.pw.get(t);if(void 0!==e)if(1===this.pw.size)s=!1,n=!0,this.fw.clear();else for(const i of this.ww)i.pointData.uw.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i.map((t=>t.time)),e=this.jo.createConverterToInternalObj(i),h=Js(t.kr()),l=t.cl(),a=t.fl();r=i.map(((i,r)=>{const o=e(i.time),_=this.jo.key(o);let u=this.fw.get(_);void 0===u&&(u=Qs(o),this.fw.set(_,u),n=!0);const c=h(o,u.ke,i,s[r],l,a);return u.uw.set(t,c),c}))}s&&this.bw(),this.Mw(t,r);let h=-1;if(n){const t=[];this.fw.forEach((i=>{t.push({timeWeight:0,time:i.Wh,pointData:i,originalTime:sn(i.uw)})})),t.sort(((t,i)=>this.jo.key(t.time)-this.jo.key(i.time))),h=this.xw(t)}return this.Sw(t,h,function(t,i,s){const n=tn(t,s),e=tn(i,s);if(void 0!==n&&void 0!==e)return{yw:!1,Ah:n.dw>=e.dw&&n.cw>=e.cw}}(this.pw.get(t),e,this.jo))}fc(t){return this.gw(t,[])}Pw(t,i,s){const n=i;!function(t){void 0===t.nw&&(t.nw=t.time)}(n),this.jo.preprocessData(i);const e=this.jo.createConverterToInternalObj([i])(i.time),r=this.mw.get(t);if(!s&&void 0!==r&&this.jo.key(e)this.jo.key(t.time)this.jo.key(n.wt)?qs(i)&&s.push(i):qs(i)?s[s.length-1]=i:s.splice(-1,1),this.mw.set(t,i.wt)}Cw(t,i,s){const n=this.pw.get(t);if(void 0===n)return;const e=Mt(n,s,((t,i)=>t.ke{0!==i.length&&(t=Math.max(t,i[i.length-1].ke))})),t}Sw(t,i,s){const n={mo:new Map,It:{j_:this.kw()}};if(-1!==i)this.pw.forEach(((i,e)=>{n.mo.set(e,{ie:i,Rw:e===t?s:void 0})})),this.pw.has(t)||n.mo.set(t,{ie:[],Rw:s}),n.It.Dw=this.ww,n.It.Ew=i;else{const i=this.pw.get(t);n.mo.set(t,{ie:i||[],Rw:s})}return n}}function en(t,i){t.ke=i,t.uw.forEach((t=>{t.ke=i}))}function rn(t,i){return t.wt({...t,...this.Gn.kh().Rr(t.wt)})))}Ww(){this.Bw=null}Ow(){this.Vw&&(this.Hw(),this.Vw=!1),this.Iw&&(this.Fw(),this.Iw=!1),this.zw&&(this.$w(),this.zw=!1)}$w(){const t=this.Gn.Ft(),i=this.Jn.It();if(this.Ww(),i.Xi()||t.Xi())return;const s=i.ye();if(null===s)return;if(0===this.Gn.Xs().Ar())return;const n=this.Gn.Bt();null!==n&&(this.Bw=function(t,i,s){const n=i.Hh(),e=i.Mi(),r=Mt(t,n,rn),h=xt(t,e,hn);if(!s)return{from:r,to:h};let l=r,a=h;return r>0&&r=n&&(l=r-1),h>0&&h{const s=t.Bt();return null===s?null:t.Ft().Nt(i,s.Wt)}))}dl(t){return this.ih.priceValueBuilder(t)}pl(t){return this.ih.isWhitespace(t)}Hw(){const t=this.Gn.kh();this.Aw=this.Gn.Xs().Wr().map((i=>({wt:i.ke,_t:NaN,...t.Rr(i.ke),Zw:i.ie})))}Uw(t,i){i.Y_(this.Aw,m(this.Bw))}jw(){this.ih.update({bars:this.Aw.map(_n),barSpacing:this.Jn.It().J_(),visibleRange:this.Bw},this.Gn.N())}}function _n(t){return{x:t._t,time:t.wt,originalData:t.Zw,barColor:t.ur}}const un={color:"#2196f3"},cn=(t,i,s)=>{const n=a(s);return new on(t,i,n)};function dn(t){const i={value:t.Wt[3],time:t.nw};return void 0!==t._w&&(i.customValues=t._w),i}function fn(t){const i=dn(t);return void 0!==t.R&&(i.color=t.R),i}function pn(t){const i=dn(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.vr&&(i.topColor=t.vr),void 0!==t.mr&&(i.bottomColor=t.mr),i}function vn(t){const i=dn(t);return void 0!==t.wr&&(i.topLineColor=t.wr),void 0!==t.gr&&(i.bottomLineColor=t.gr),void 0!==t.br&&(i.topFillColor1=t.br),void 0!==t.Mr&&(i.topFillColor2=t.Mr),void 0!==t.Sr&&(i.bottomFillColor1=t.Sr),void 0!==t.yr&&(i.bottomFillColor2=t.yr),i}function mn(t){const i={open:t.Wt[0],high:t.Wt[1],low:t.Wt[2],close:t.Wt[3],time:t.nw};return void 0!==t._w&&(i.customValues=t._w),i}function wn(t){const i=mn(t);return void 0!==t.R&&(i.color=t.R),i}function gn(t){const i=mn(t),{R:s,Ht:n,pr:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}function bn(t){return{Area:pn,Line:fn,Baseline:vn,Histogram:fn,Bar:wn,Candlestick:gn,Custom:Mn}[t]}function Mn(t){const i=t.nw;return{...t.ie,time:i}}const xn={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},Sn={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},yn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:w,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Pn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},Cn={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function Tn(){return{width:0,height:0,autoSize:!1,layout:yn,crosshair:xn,grid:Sn,overlayPriceScales:{...Pn},leftPriceScale:{...Pn,visible:!1},rightPriceScale:{...Pn,visible:!0},timeScale:Cn,localization:{locale:es?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class kn{constructor(t,i,s){this.bf=t,this.Xw=i,this.qw=s??0}applyOptions(t){this.bf.Qt().$u(this.Xw,t,this.qw)}options(){return this.Yi().N()}width(){return Y(this.Xw)?this.bf.Wm(this.Xw):0}Yi(){return l(this.bf.Qt().Uu(this.Xw,this.qw)).Ft}}class Rn{constructor(t,i,s,n){this.bf=t,this.Pt=s,this.Kw=i,this.Gw=n}getHeight(){return this.Pt.Ut()}setHeight(t){const i=this.bf.Qt(),s=i.Sc(this.Pt);i.qu(s,t)}paneIndex(){return this.bf.Qt().Sc(this.Pt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&tthis.Kw(t)))??[]}getHTMLElement(){return this.bf.xf()[this.paneIndex()].kf()}attachPrimitive(t){this.Pt._l(t),t.attached&&t.attached({chart:this.Gw,requestUpdate:()=>this.Pt.Qt().zh()})}detachPrimitive(t){this.Pt.ul(t)}priceScale(t){if(null===this.Pt.uo(t))throw new Error(`Cannot find price scale with id: ${t}`);return new kn(this.bf,t,this.paneIndex())}}const Dn={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class En{constructor(t){this.tr=t}applyOptions(t){this.tr.rr(t)}options(){return this.tr.N()}Jw(){return this.tr}}class zn{constructor(t,i,s,n,e,r){this.Qw=new o,this.Gn=t,this.tg=i,this.ig=s,this.jo=e,this.Gw=n,this.sg=r}m(){this.Qw.m()}priceFormatter(){return this.Gn.el()}priceToCoordinate(t){const i=this.Gn.Bt();return null===i?null:this.Gn.Ft().Nt(t,i.Wt)}coordinateToPrice(t){const i=this.Gn.Bt();return null===i?null:this.Gn.Ft().Ts(t,i.Wt)}barsInLogicalRange(t){if(null===t)return null;const i=new yi(new Mi(t.from,t.to)).a_(),s=this.Gn.Xs();if(s.Xi())return null;const n=s.Nr(i.Hh(),1),e=s.Nr(i.Mi(),-1),r=l(s.Br()),h=l(s.Zs());if(null!==n&&null!==e&&n.ke>e.ke)return{barsBefore:t.from-r,barsAfter:h-t.to};const a={barsBefore:null===n||n.ke===r?t.from-r:n.ke-r,barsAfter:null===e||e.ke===h?h-t.to:h-e.ke};return null!==n&&null!==e&&(a.from=n.nw,a.to=e.nw),a}setData(t){this.jo,this.Gn.kr(),this.tg.ng(this.Gn,t),this.eg("full")}update(t,i=!1){this.Gn.kr(),this.tg.rg(this.Gn,t,i),this.eg("update")}dataByIndex(t,i){const s=this.Gn.Xs().Nr(t,i);if(null===s)return null;return bn(this.seriesType())(s)}data(){const t=bn(this.seriesType());return this.Gn.Xs().Wr().map((i=>t(i)))}subscribeDataChanged(t){this.Qw.i(t)}unsubscribeDataChanged(t){this.Qw._(t)}applyOptions(t){this.Gn.rr(t)}options(){return p(this.Gn.N())}priceScale(){return this.ig.priceScale(this.Gn.Ft().ml(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(Dn),t),s=this.Gn.Lh(i);return new En(s)}removePriceLine(t){this.Gn.Oh(t.Jw())}priceLines(){return this.Gn.Nh().map((t=>new En(t)))}seriesType(){return this.Gn.kr()}attachPrimitive(t){this.Gn._l(t),t.attached&&t.attached({chart:this.Gw,series:this,requestUpdate:()=>this.Gn.Qt().zh(),horzScaleBehavior:this.jo})}detachPrimitive(t){this.Gn.ul(t),t.detached&&t.detached(),this.Gn.Qt().zh()}getPane(){const t=this.Gn,i=l(this.Gn.Qt().Wn(t));return this.sg(i)}moveToPane(t){this.Gn.Qt().gc(this.Gn,t)}eg(t){this.Qw.v()&&this.Qw.p(t)}}class Vn{constructor(t,i,s){this.hg=new o,this.w_=new o,this.Xv=new o,this.ts=t,this._h=t.It(),this.km=i,this._h.cu().i(this.lg.bind(this)),this._h.du().i(this.ag.bind(this)),this.km.im().i(this.og.bind(this)),this.jo=s}m(){this._h.cu().u(this),this._h.du().u(this),this.km.im().u(this),this.hg.m(),this.w_.m(),this.Xv.m()}scrollPosition(){return this._h.tu()}scrollToPosition(t,i){i?this._h.ou(t,1e3):this.ts.dn(t)}scrollToRealTime(){this._h.au()}getVisibleRange(){const t=this._h.L_();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.jo.convertHorzItemToInternal(t.from),to:this.jo.convertHorzItemToInternal(t.to)},s=this._h.W_(i);this.ts.mc(s)}getVisibleLogicalRange(){const t=this._h.B_();return null===t?null:{from:t.Hh(),to:t.Mi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.ts.mc(t)}resetTimeScale(){this.ts.un()}fitContent(){this.ts.vu()}logicalToCoordinate(t){const i=this.ts.It();return i.Xi()?null:i.jt(t)}coordinateToLogical(t){return this._h.Xi()?null:this._h.Z_(t)}timeToIndex(t,i){const s=this.jo.convertHorzItemToInternal(t);return this._h.V_(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this._h.jt(i)}coordinateToTime(t){const i=this.ts.It(),s=i.Z_(t),n=i.ss(s);return null===n?null:n.originalTime}width(){return this.km.Rf().width}height(){return this.km.Rf().height}subscribeVisibleTimeRangeChange(t){this.hg.i(t)}unsubscribeVisibleTimeRangeChange(t){this.hg._(t)}subscribeVisibleLogicalRangeChange(t){this.w_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.w_._(t)}subscribeSizeChange(t){this.Xv.i(t)}unsubscribeSizeChange(t){this.Xv._(t)}applyOptions(t){this._h.rr(t)}options(){return{...p(this._h.N()),barSpacing:this._h.J_()}}lg(){this.hg.v()&&this.hg.p(this.getVisibleRange())}ag(){this.w_.v()&&this.w_.p(this.getVisibleLogicalRange())}og(t){this.Xv.p(t.width,t.height)}}function In(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=function(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}(i.minMove))}function An(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Bn{constructor(t,i,s){this._g=new Map,this.ug=new Map,this.cg=new o,this.dg=new o,this.fg=new o,this.Cu=new WeakMap,this.pg=new nn(i);const n=void 0===s?p(Tn()):_(p(Tn()),An(s));this.vg=i,this.bf=new Fs(t,n,i),this.bf.Tv().i((t=>{this.cg.v()&&this.cg.p(this.mg(t()))}),this),this.bf.kv().i((t=>{this.dg.v()&&this.dg.p(this.mg(t()))}),this),this.bf.Yu().i((t=>{this.fg.v()&&this.fg.p(this.mg(t()))}),this);const e=this.bf.Qt();this.wg=new Vn(e,this.bf.Vm(),this.vg)}remove(){this.bf.Tv().u(this),this.bf.kv().u(this),this.bf.Yu().u(this),this.wg.m(),this.bf.m(),this._g.clear(),this.ug.clear(),this.cg.m(),this.dg.m(),this.fg.m(),this.pg.m()}resize(t,i,s){this.autoSizeActive()||this.bf.Dm(t,i,s)}addCustomSeries(t,i={},s=0){const n=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...un,...t.defaultOptions()},gg:cn,bg:t}))(a(t));return this.Mg(n,i,s)}addSeries(t,i={},s=0){return this.Mg(t,i,s)}removeSeries(t){const i=h(this._g.get(t)),s=this.pg.fc(i);this.bf.Qt().fc(i),this.xg(s),this._g.delete(t),this.ug.delete(i)}ng(t,i){this.xg(this.pg.gw(t,i))}rg(t,i,s){this.xg(this.pg.Pw(t,i,s))}subscribeClick(t){this.cg.i(t)}unsubscribeClick(t){this.cg._(t)}subscribeCrosshairMove(t){this.fg.i(t)}unsubscribeCrosshairMove(t){this.fg._(t)}subscribeDblClick(t){this.dg.i(t)}unsubscribeDblClick(t){this.dg._(t)}priceScale(t,i=0){return new kn(this.bf,t,i)}timeScale(){return this.wg}applyOptions(t){this.bf.rr(An(t))}options(){return this.bf.N()}takeScreenshot(){return this.bf.Nm()}removePane(t){this.bf.Qt().Xu(t)}swapPanes(t,i){this.bf.Qt().Ku(t,i)}autoSizeActive(){return this.bf.Um()}chartElement(){return this.bf.Vf()}panes(){return this.bf.Qt().$s().map((t=>this.Sg(t)))}paneSize(t=0){const i=this.bf.Zm(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const n=this._g.get(s);if(void 0===n)return;const e=this.bf.Qt().Wn(n);null!==e&&this.bf.Qt().ac(t,i,e)}clearCrosshairPosition(){this.bf.Qt().oc(!0)}horzBehaviour(){return this.vg}Mg(i,s={},n=0){r(void 0!==i.gg),In(s.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(s);const e=_(p(t),p(i.defaultOptions),s),h=i.gg,l=new Ht(this.bf.Qt(),i.type,e,h,i.bg);this.bf.Qt().cc(l,n);const a=new zn(l,this,this,this,this.vg,(t=>this.Sg(t)));return this._g.set(a,l),this.ug.set(l,a),a}xg(t){const i=this.bf.Qt();i._c(t.It.j_,t.It.Dw,t.It.Ew),t.mo.forEach(((t,i)=>i.ht(t.ie,t.Rw))),i.It().k_(),i.G_()}yg(t){return h(this.ug.get(t))}mg(t){const i=new Map;t.lw.forEach(((t,s)=>{const n=s.kr(),e=bn(n)(t);if("Custom"!==n)r(Hs(e));else{const t=s.fl();r(!t||!1===t(e))}i.set(this.yg(s),e)}));const s=void 0!==t.hw&&this.ug.has(t.hw)?this.yg(t.hw):void 0;return{time:t.nw,logical:t.ke,point:t.ew,paneIndex:t.rw,hoveredSeries:s,hoveredObjectId:t.aw,seriesData:i,sourceEvent:t.ow}}Sg(t){let i=this.Cu.get(t);return i||(i=new Rn(this.bf,(t=>this.yg(t)),t,this),this.Cu.set(t,i)),i}}function Ln(t,i,s){const n=function(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}(t),e=new Bn(n,i,s);return i.setOptions(e.options()),e}function On(t,i){return Ln(t,new Ki,Ki.Nc(i))}class Nn extends ln{constructor(t,i){super(t,i,!0)}Uw(t,i,s){i.Y_(this.Aw,m(this.Bw)),t.Ra(this.Aw,s,m(this.Bw))}Pg(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}Hw(){const t=this.Gn.kh();this.Aw=this.Gn.Xs().Wr().map((i=>{const s=i.Wt[3];return this.Cg(i.ke,s,t)}))}}const Fn=6;function Wn(t,i){return{_t:t._t-i._t,ut:t.ut-i.ut}}function Hn(t,i){return{_t:t._t/i,ut:t.ut/i}}function $n(t,i,s){const n=Math.max(0,i-1),e=Math.min(t.length-1,s+1);var r,h;return[(r=t[i],h=Hn(Wn(t[s],t[n]),Fn),{_t:r._t+h._t,ut:r.ut+h.ut}),Wn(t[s],Hn(Wn(t[e],t[i]),Fn))]}function Un(t,i){const s=t.context;s.strokeStyle=i,s.stroke()}class jn extends P{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:s,Tg:e,kg:r,ct:h,qt:l,Rg:a}=this.rt;if(null===s)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,n(o,l),o.lineJoin="round";const _=this.Dg.bind(this);void 0!==r&&function(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const{context:l,horizontalPixelRatio:a,verticalPixelRatio:o}=t,_=i[n.from];let u=r(t,_),c=_;if(n.to-n.from<2){const i=e/2;l.beginPath();const s={_t:_._t-i,ut:_.ut},n={_t:_._t+i,ut:_.ut};l.moveTo(s._t*a,s.ut*o),l.lineTo(n._t*a,n.ut*o),h(t,u,s,n)}else{const e=(i,s)=>{h(t,u,c,s),l.beginPath(),u=i,c=s};let d=c;l.beginPath(),l.moveTo(_._t*a,_.ut*o);for(let h=n.from+1;h=n.from;--s){const n=i[s];if(n){const i=e(t,n);i!==a&&(l.beginPath(),null!==a&&l.fill(),l.fillStyle=i,a=i);const s=Math.round(n._t*r)+o,u=n.ut*h;l.moveTo(s,u),l.arc(s,u,_,0,2*Math.PI)}}l.fill()}(t,i,a,s,_)}}class Yn extends jn{Dg(t,i){return i.vt}}class Zn extends Nn{constructor(){super(...arguments),this.Nw=new Yn}Cg(t,i,s){return{...this.Pg(t,i),...s.Rr(t)}}jw(){const t=this.Gn.N(),i={ot:this.Aw,qt:t.lineStyle,kg:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Rg:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Bw,Tg:this.Jn.It().J_()};this.Nw.ht(i)}}const Xn={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},gg:(t,i)=>new Zn(t,i)};class qn extends P{constructor(){super(...arguments),this.Yt=null,this.Eg=0}ht(t){this.Yt=t}et(t){if(null===this.Yt||0===this.Yt.Xs.length||null===this.Yt.lt)return;const{horizontalPixelRatio:i}=t;if(this.Eg=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Yt.J_,i),this.Eg>=2){Math.floor(i)%2!=this.Eg%2&&this.Eg--}const s=this.Yt.Xs;this.Yt.zg&&this.Vg(t,s,this.Yt.lt),this.Yt.bi&&this.$p(t,s,this.Yt.lt);const n=this.Ig(i);(!this.Yt.bi||this.Eg>2*n)&&this.Ag(t,s,this.Yt.lt)}Vg(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",l=Math.min(Math.floor(e),Math.floor(this.Yt.J_*e));l=Math.max(Math.floor(e),Math.min(l,this.Eg));const a=Math.floor(.5*l);let o=null;for(let t=s.from;t2*l)z(n,o,u,_-o+1,c-u+1,l);else{const t=_-o+1;n.fillRect(o,u,t,c-u+1)}a=_}}Ag(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const l=this.Ig(e);for(let t=s.from;to||n.fillRect(_,a,u-_+1,o-a+1)}}}class Kn extends ln{constructor(t,i){super(t,i,!1)}Uw(t,i,s){i.Y_(this.Aw,m(this.Bw)),t.Ea(this.Aw,s,m(this.Bw))}Bg(t,i,s){return{wt:t,Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Zh:i.Wt[3],_t:NaN,za:NaN,Va:NaN,Ia:NaN,Aa:NaN}}Hw(){const t=this.Gn.kh();this.Aw=this.Gn.Xs().Wr().map((i=>this.Cg(i.ke,i,t)))}}class Gn extends Kn{constructor(){super(...arguments),this.Nw=new qn}Cg(t,i,s){return{...this.Bg(t,i,s),...s.Rr(t)}}jw(){const t=this.Gn.N();this.Nw.ht({Xs:this.Aw,J_:this.Jn.It().J_(),zg:t.wickVisible,bi:t.borderVisible,lt:this.Bw})}}const Jn={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},gg:(t,i)=>new Gn(t,i)},Qn={...t,color:"#2196f3"};export{Jn as CandlestickSeries,Di as ColorType,U as CrosshairMode,ki as LastPriceAnimationMode,Xn as LineSeries,s as LineStyle,i as LineType,St as MismatchDirection,Ri as PriceLineSource,_i as PriceScaleMode,Ei as TickMarkType,Ti as TrackingModeExitMode,On as createChart,Qn as customSeriesDefaultOptions,Vi as isBusinessDay,Ii as isUTCTimestamp}; +const t={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var i,s;function n(t,i){const s={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function l(t){if(null===t)throw new Error("Value is null");return t}function a(t){return l(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(s||(s={}));class o{constructor(){this.t=[]}i(t,i,s){const n={h:t,l:i,o:!0===s};this.t.push(n)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,s){const n=[...this.t];this.t=this.t.filter((t=>!t.o)),n.forEach((n=>n.h(t,i,s)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:_(t[i],s[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?p(e):e);return s}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,s){return void 0===i&&(i=w),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class b{constructor(t){this.M={S:1,C:5,P:NaN,T:"",k:"",R:"",D:"",V:0,I:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,i=this.F(),s=this.W();return t.P===i&&t.k===s||(t.P=i,t.k=s,t.T=g(i,s),t.A=2.5/12*i,t.V=t.A,t.I=i/12*t.C,t.B=i/12*t.C,t.L=0),t.R=this.H(),t.D=this.$(),this.M}H(){return this.O.N().layout.textColor}$(){return this.O.U()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function M(t){return t<0?0:t>255?255:Math.round(t)||0}function x(t){return.199*t[0]+.687*t[1]+.114*t[2]}class S{constructor(t,i){this.j=new Map,this.Y=t,i&&(this.j=i)}Z(t,i){if("transparent"===t)return t;const s=this.X(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}q(t){const i=this.X(t);return{G:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,K:x(i)>160?"black":"white"}}J(t){return x(this.X(t))}tt(t,i,s){const[n,e,r,h]=this.X(t),[l,a,o,_]=this.X(i),u=[M(n+s*(l-n)),M(e+s*(a-e)),M(r+s*(o-r)),(c=h+s*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}X(t){const i=this.j.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),n=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.j.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.j.set(t,e),e}}class C{constructor(){this.it=[]}st(t){this.it=t}nt(t,i,s){this.it.forEach((n=>{n.nt(t,i,s)}))}}class y{nt(t,i,s){t.useBitmapCoordinateSpace((t=>this.et(t,i,s)))}}class P extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.rt||null===this.rt.lt)return;const n=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let l=n.to-1;l>=n.from;--l){const n=e.ot[l],a=Math.round(n._t*i)+r,o=n.ut*s,_=h*s+r;t.moveTo(a,o),t.arc(a,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function T(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const k={from:0,to:1};class R{constructor(t,i,s){this.bt=new C,this.Mt=[],this.xt=[],this.St=!0,this.O=t,this.Ct=i,this.yt=s,this.bt.st(this.Mt)}Pt(t){this.Tt(),this.St=!0}kt(){return this.St&&(this.Rt(),this.St=!1),this.bt}Tt(){const t=this.yt.Dt();t.length!==this.Mt.length&&(this.xt=t.map(T),this.Mt=this.xt.map((t=>{const i=new P;return i.ht(t),i})),this.bt.st(this.Mt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.Et(),i=this.yt.Vt(),s=this.Ct.zt(),n=this.O.It();this.Tt(),i.forEach(((i,e)=>{const r=this.xt[e],h=i.Bt(s),l=i.At();!t&&null!==h&&i.Et()&&null!==l?(r.vt=h.Lt,r.ft=h.ft,r.ct=h.Ot,r.ot[0].gt=h.gt,r.ot[0].ut=i.Ft().Nt(h.gt,l.Wt),r.dt=h.Ht??this.O.$t(r.ot[0].ut/i.Ft().Ut()),r.ot[0].wt=s,r.ot[0]._t=n.jt(s),r.lt=k):r.lt=null}))}}class D extends y{constructor(t){super(),this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;const h=this.Yt.Zt.Et,l=this.Yt.Xt.Et;if(!h&&!l)return;const a=Math.round(this.Yt._t*s),o=Math.round(this.Yt.ut*r);t.lineCap="butt",h&&a>=0&&(t.lineWidth=Math.floor(this.Yt.Zt.ct*s),t.strokeStyle=this.Yt.Zt.R,t.fillStyle=this.Yt.Zt.R,n(t,this.Yt.Zt.qt),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,a,0,i.height)),l&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Xt.ct*r),t.strokeStyle=this.Yt.Xt.R,t.fillStyle=this.Yt.Xt.R,n(t,this.Yt.Xt.qt),e(t,o,0,i.width))}}class E{constructor(t,i){this.St=!0,this.Gt={Zt:{ct:1,qt:0,R:"",Et:!1},Xt:{ct:1,qt:0,R:"",Et:!1},_t:0,ut:0},this.Kt=new D(this.Gt),this.Jt=t,this.yt=i}Pt(){this.St=!0}kt(t){return this.St&&(this.Rt(),this.St=!1),this.Kt}Rt(){const t=this.Jt.Et(),i=this.yt.Qt().N().crosshair,s=this.Gt;if(2===i.mode)return s.Xt.Et=!1,void(s.Zt.Et=!1);s.Xt.Et=t&&this.Jt.ti(this.yt),s.Zt.Et=t&&this.Jt.ii(),s.Xt.ct=i.horzLine.width,s.Xt.qt=i.horzLine.style,s.Xt.R=i.horzLine.color,s.Zt.ct=i.vertLine.width,s.Zt.qt=i.vertLine.style,s.Zt.R=i.vertLine.color,s._t=this.Jt.si(),s.ut=this.Jt.ni()}}function V(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function z(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function I(t,i,s,n,e,r){t.beginPath(),t.roundRect?t.roundRect(i,s,n,e,r):(t.lineTo(i+n-r[1],s),0!==r[1]&&t.arcTo(i+n,s,i+n,s+r[1],r[1]),t.lineTo(i+n,s+e-r[2]),0!==r[2]&&t.arcTo(i+n,s+e,i+n-r[2],s+e,r[2]),t.lineTo(i+r[3],s+e),0!==r[3]&&t.arcTo(i,s+e,i,s+e-r[3],r[3]),t.lineTo(i,s+r[0]),0!==r[0]&&t.arcTo(i,s,i+r[0],s,r[0]))}function B(t,i,s,n,e,r,h=0,l=[0,0,0,0],a=""){if(t.save(),!h||!a||a===r)return I(t,i,s,n,e,l),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;I(t,i+o,s+o,n-h,e-h,(_=-o,l.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==a&&(t.lineWidth=h,t.strokeStyle=a,t.closePath(),t.stroke()),t.restore()}function A(t,i,s,n,e,r,h){t.save(),t.globalCompositeOperation="copy";const l=t.createLinearGradient(0,0,0,e);l.addColorStop(0,r),l.addColorStop(1,h),t.fillStyle=l,t.fillRect(i,s,n,e),t.restore()}class L{constructor(t,i){this.ht(t,i)}ht(t,i){this.Yt=t,this.ei=i}Ut(t,i){return this.Yt.Et?t.P+t.A+t.V:0}nt(t,i,s,n){if(!this.Yt.Et||0===this.Yt.ri.length)return;const e=this.Yt.R,r=this.ei.G,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.T;const l=this.hi(t,i,s,n),a=l.li;return l.ai?B(h,a.oi,a._i,a.ui,a.ci,r,a.di,[a.ft,0,0,a.ft],r):B(h,a.fi,a._i,a.ui,a.ci,r,a.di,[0,a.ft,a.ft,0],r),this.Yt.pi&&(h.fillStyle=e,h.fillRect(a.fi,a.mi,a.wi-a.fi,a.gi)),this.Yt.bi&&(h.fillStyle=i.D,h.fillRect(l.ai?a.Mi-a.di:0,a._i,a.di,a.xi-a._i)),l}));t.useMediaCoordinateSpace((({context:t})=>{const s=h.Si;t.font=i.T,t.textAlign=h.ai?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Yt.ri,s.Ci,(s._i+s.xi)/2+s.yi)}))}hi(t,i,s,n){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,o=this.Yt.pi||!this.Yt.Pi?i.C:0,_=this.Yt.Ti?i.S:0,u=i.A+this.ei.ki,c=i.V+this.ei.Ri,d=i.I,f=i.B,p=this.Yt.ri,v=i.P,m=s.Di(e,p),w=Math.ceil(s.Ei(e,p)),g=v+u+c,b=i.S+d+f+w+o,M=Math.max(1,Math.floor(a));let x=Math.round(g*a);x%2!=M%2&&(x+=1);const S=_>0?Math.max(1,Math.floor(_*l)):0,C=Math.round(b*l),y=Math.round(o*l),P=this.ei.Vi??this.ei.zi,T=Math.round(P*a)-Math.floor(.5*a),k=Math.floor(T+M/2-x/2),R=k+x,D="right"===n,E=D?h.width-_:_,V=D?r.width-S:S;let z,I,B;return D?(z=V-C,I=V-y,B=E-o-d-_):(z=V+C,I=V+y,B=E+o+d),{ai:D,li:{_i:k,mi:T,xi:R,ui:C,ci:x,ft:2*l,di:S,oi:z,fi:V,wi:I,gi:M,Mi:r.width},Si:{_i:k/a,xi:R/a,Ci:B,yi:m}}}}class O{constructor(t){this.Ii={zi:0,G:"#000",Ri:0,ki:0},this.Bi={ri:"",Et:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",bi:!1,Ti:!1},this.Ai={ri:"",Et:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",bi:!0,Ti:!0},this.St=!0,this.Li=new(t||L)(this.Bi,this.Ii),this.Oi=new(t||L)(this.Ai,this.Ii)}ri(){return this.Ni(),this.Bi.ri}zi(){return this.Ni(),this.Ii.zi}Pt(){this.St=!0}Ut(t,i=!1){return Math.max(this.Li.Ut(t,i),this.Oi.Ut(t,i))}Fi(){return this.Ii.Vi||0}Wi(t){this.Ii.Vi=t}Hi(){return this.Ni(),this.Bi.Et||this.Ai.Et}$i(){return this.Ni(),this.Bi.Et}kt(t){return this.Ni(),this.Bi.pi=this.Bi.pi&&t.N().ticksVisible,this.Ai.pi=this.Ai.pi&&t.N().ticksVisible,this.Li.ht(this.Bi,this.Ii),this.Oi.ht(this.Ai,this.Ii),this.Li}Ui(){return this.Ni(),this.Li.ht(this.Bi,this.Ii),this.Oi.ht(this.Ai,this.Ii),this.Oi}Ni(){this.St&&(this.Bi.pi=!0,this.Ai.pi=!1,this.ji(this.Bi,this.Ai,this.Ii))}}class N extends O{constructor(t,i,s){super(),this.Jt=t,this.Yi=i,this.Zi=s}ji(t,i,s){if(t.Et=!1,2===this.Jt.N().mode)return;const n=this.Jt.N().horzLine;if(!n.labelVisible)return;const e=this.Yi.At();if(!this.Jt.Et()||this.Yi.Xi()||null===e)return;const r=this.Yi.qi().q(n.labelBackgroundColor);s.G=r.G,t.R=r.K;const h=2/12*this.Yi.P();s.ki=h,s.Ri=h;const l=this.Zi(this.Yi);s.zi=l.zi,t.ri=this.Yi.Gi(l.gt,e),t.Et=!0}}const F=/[1-9]/g;class W{constructor(){this.Yt=null}ht(t){this.Yt=t}nt(t,i){if(null===this.Yt||!1===this.Yt.Et||0===this.Yt.ri.length)return;const s=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.T,Math.round(i.Ki.Ei(t,l(this.Yt).ri,F)))));if(s<=0)return;const n=i.Ji,e=s+2*n,r=e/2,h=this.Yt.Qi;let a=this.Yt.zi,o=Math.floor(a-r)+.5;o<0?(a+=Math.abs(0-o),o=Math.floor(a-r)+.5):o+e>h&&(a-=Math.abs(h-(o+e)),o=Math.floor(a-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.C+i.A+i.P+i.V);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=l(this.Yt);t.fillStyle=e.G;const r=Math.round(o*s),h=Math.round(0*n),a=Math.round(_*s),c=Math.round(u*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(a-d,c),t.arcTo(a,c,a,c-d,d),t.lineTo(a,h),t.fill(),e.pi){const r=Math.round(e.zi*s),l=h,a=Math.round((l+i.C)*n);t.fillStyle=e.R;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,l,o,a-l)}})),t.useMediaCoordinateSpace((({context:t})=>{const s=l(this.Yt),e=0+i.S+i.C+i.A+i.P/2;t.font=i.T,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.R;const r=i.Ki.Di(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.ri,0,0)}))}}class H{constructor(t,i,s){this.St=!0,this.Kt=new W,this.Gt={Et:!1,G:"#4c525e",R:"white",ri:"",Qi:0,zi:NaN,pi:!0},this.Ct=t,this.ts=i,this.Zi=s}Pt(){this.St=!0}kt(){return this.St&&(this.Rt(),this.St=!1),this.Kt.ht(this.Gt),this.Kt}Rt(){const t=this.Gt;if(t.Et=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const s=this.ts.It();if(s.Xi())return;t.Qi=s.Qi();const n=this.Zi();if(null===n)return;t.zi=n.zi;const e=s.ss(this.Ct.zt());t.ri=s.ns(l(e)),t.Et=!0;const r=this.ts.qi().q(i.labelBackgroundColor);t.G=r.G,t.R=r.K,t.pi=s.N().ticksVisible}}class ${constructor(){this.es=null,this.rs=0}hs(){return this.rs}ls(t){this.rs=t}Ft(){return this.es}os(t){this.es=t}_s(t){return[]}us(){return[]}Et(){return!0}}var U;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}(U||(U={}));class j extends ${constructor(t,i){super(),this.yt=null,this.cs=NaN,this.ds=0,this.fs=!1,this.ps=new Map,this.vs=!1,this.ws=new WeakMap,this.gs=new WeakMap,this.bs=NaN,this.Ms=NaN,this.xs=NaN,this.Ss=NaN,this.ts=t,this.Cs=i;this.ys=((t,i)=>s=>{const n=i(),e=t();if(s===l(this.yt).Ps())return{gt:e,zi:n};{const t=l(s.At());return{gt:s.Ts(n,t),zi:n}}})((()=>this.cs),(()=>this.Ms));const s=((t,i)=>()=>{const s=this.ts.It().ks(t()),n=i();return s&&Number.isFinite(n)?{wt:s,zi:n}:null})((()=>this.ds),(()=>this.si()));this.Rs=new H(this,t,s)}N(){return this.Cs}Ds(t,i){this.xs=t,this.Ss=i}Es(){this.xs=NaN,this.Ss=NaN}Vs(){return this.xs}zs(){return this.Ss}Is(t,i,s){this.vs||(this.vs=!0),this.fs=!0,this.Bs(t,i,s)}zt(){return this.ds}si(){return this.bs}ni(){return this.Ms}Et(){return this.fs}As(){this.fs=!1,this.Ls(),this.cs=NaN,this.bs=NaN,this.Ms=NaN,this.yt=null,this.Es(),this.Os()}Ns(t){let i=this.ws.get(t);i||(i=new E(this,t),this.ws.set(t,i));let s=this.gs.get(t);return s||(s=new R(this.ts,this,t),this.gs.set(t,s)),[i,s]}ti(t){return t===this.yt&&this.Cs.horzLine.visible}ii(){return this.Cs.vertLine.visible}Fs(t,i){this.fs&&this.yt===t||this.ps.clear();const s=[];return this.yt===t&&s.push(this.Ws(this.ps,i,this.ys)),s}us(){return this.fs?[this.Rs]:[]}Hs(){return this.yt}Os(){this.ts.$s().forEach((t=>{this.ws.get(t)?.Pt(),this.gs.get(t)?.Pt()})),this.ps.forEach((t=>t.Pt())),this.Rs.Pt()}Us(t){return t&&!t.Ps().Xi()?t.Ps():null}Bs(t,i,s){this.js(t,i,s)&&this.Os()}js(t,i,s){const n=this.bs,e=this.Ms,r=this.cs,h=this.ds,l=this.yt,a=this.Us(s);this.ds=t,this.bs=isNaN(t)?NaN:this.ts.It().jt(t),this.yt=s;const o=null!==a?a.At():null;return null!==a&&null!==o?(this.cs=i,this.Ms=a.Nt(i,o)):(this.cs=NaN,this.Ms=NaN),n!==this.bs||e!==this.Ms||h!==this.ds||r!==this.cs||l!==this.yt}Ls(){const t=this.ts.Ys().map((t=>t.Xs().Zs())).filter(v),i=0===t.length?null:Math.max(...t);this.ds=null!==i?i:NaN}Ws(t,i,s){let n=t.get(i);return void 0===n&&(n=new N(this,i,s),t.set(i,n)),n}}function Y(t){return"left"===t||"right"===t}class Z{constructor(t){this.qs=new Map,this.Gs=[],this.Ks=t}Js(t,i){const s=function(t,i){return void 0===t?i:{Qs:Math.max(t.Qs,i.Qs),tn:t.tn||i.tn}}(this.qs.get(t),i);this.qs.set(t,s)}sn(){return this.Ks}nn(t){const i=this.qs.get(t);return void 0===i?{Qs:this.Ks}:{Qs:Math.max(this.Ks,i.Qs),tn:i.tn}}en(){this.rn(),this.Gs=[{hn:0}]}ln(t){this.rn(),this.Gs=[{hn:1,Wt:t}]}an(t){this._n(),this.Gs.push({hn:5,Wt:t})}rn(){this._n(),this.Gs.push({hn:6})}un(){this.rn(),this.Gs=[{hn:4}]}cn(t){this.rn(),this.Gs.push({hn:2,Wt:t})}dn(t){this.rn(),this.Gs.push({hn:3,Wt:t})}fn(){return this.Gs}pn(t){for(const i of t.Gs)this.vn(i);this.Ks=Math.max(this.Ks,t.Ks),t.qs.forEach(((t,i)=>{this.Js(i,t)}))}static mn(){return new Z(2)}static wn(){return new Z(3)}vn(t){switch(t.hn){case 0:this.en();break;case 1:this.ln(t.Wt);break;case 2:this.cn(t.Wt);break;case 3:this.dn(t.Wt);break;case 4:this.un();break;case 5:this.an(t.Wt);break;case 6:this._n()}}_n(){const t=this.Gs.findIndex((t=>5===t.hn));-1!==t&&this.Gs.splice(t,1)}}const X=".";function q(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class G{constructor(t,i){if(i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.gn=i,this.bn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Mn(t)}bn(){if(this.xn=0,this.Yi>0&&this.gn>0){let t=this.Yi;for(;t>1;)t/=10,this.xn++}}Mn(t){const i=this.Yi/this.gn;let s=Math.floor(t),n="";const e=void 0!==this.xn?this.xn:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.xn);r>=i&&(r-=i,s+=1),n=X+q(+r.toFixed(this.xn)*this.gn,e)}else s=Math.round(s*i)/i,e>0&&(n=X+q(0,e));return s.toFixed(0)+n}}class K extends G{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class J{constructor(t){this.Sn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.Cn(t):t<999995?i+this.Cn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Cn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Cn(t/1e9)+"B")}Cn(t){let i;const s=Math.pow(10,this.Sn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Sn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const Q=/[2-9]/g;class tt{constructor(t=50){this.yn=0,this.Pn=1,this.Tn=1,this.kn={},this.Rn=new Map,this.Dn=t}En(){this.yn=0,this.Rn.clear(),this.Pn=1,this.Tn=1,this.kn={}}Ei(t,i,s){return this.Vn(t,i,s).width}Di(t,i,s){const n=this.Vn(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}Vn(t,i,s){const n=s||Q,e=String(i).replace(n,"0");if(this.Rn.has(e))return h(this.Rn.get(e)).zn;if(this.yn===this.Dn){const t=this.kn[this.Tn];delete this.kn[this.Tn],this.Rn.delete(t),this.Tn++,this.yn--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.Rn.set(e,{zn:r,In:this.Pn}),this.kn[this.Pn]=e,this.yn++,this.Pn++),r}}class it{constructor(t){this.Bn=null,this.M=null,this.An="right",this.Ln=t}On(t,i,s){this.Bn=t,this.M=i,this.An=s}nt(t){null!==this.M&&null!==this.Bn&&this.Bn.nt(t,this.M,this.Ln,this.An)}}class st{constructor(t,i,s){this.Nn=t,this.Ln=new tt(50),this.Fn=i,this.O=s,this.F=-1,this.Kt=new it(this.Ln)}kt(){const t=this.O.Wn(this.Fn);if(null===t)return null;const i=t.Hn(this.Fn)?t.$n():this.Fn.Ft();if(null===i)return null;const s=t.Un(i);if("overlay"===s)return null;const n=this.O.jn();return n.P!==this.F&&(this.F=n.P,this.Ln.En()),this.Kt.On(this.Nn.Ui(),n,s),this.Kt}}class nt extends y{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}Yn(t,i){if(!this.Yt?.Et)return null;const{ut:s,ct:n,Zn:e}=this.Yt;return i>=s-n-7&&i<=s+n+7?{Xn:this.Yt,Zn:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;if(!1===this.Yt.Et)return;const h=Math.round(this.Yt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.R,t.lineWidth=Math.floor(this.Yt.ct*s),n(t,this.Yt.qt),e(t,h,0,i.width))}}class et{constructor(t){this.qn={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,qt:0,Et:!1},this.Gn=new nt,this.St=!0,this.Kn=t,this.Jn=t.Qt(),this.Gn.ht(this.qn)}Pt(){this.St=!0}kt(){return this.Kn.Et()?(this.St&&(this.Qn(),this.St=!1),this.Gn):null}}class rt extends et{constructor(t){super(t)}Qn(){this.qn.Et=!1;const t=this.Kn.Ft(),i=t.te().te;if(2!==i&&3!==i)return;const s=this.Kn.N();if(!s.baseLineVisible||!this.Kn.Et())return;const n=this.Kn.At();null!==n&&(this.qn.Et=!0,this.qn.ut=t.Nt(n.Wt,n.Wt),this.qn.R=s.baseLineColor,this.qn.ct=s.baseLineWidth,this.qn.qt=s.baseLineStyle)}}class ht extends y{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}ie(){return this.Yt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Yt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.se.x*i)+r,l=n.se.y*s;t.fillStyle=n.ne,t.beginPath();const a=Math.max(2,1.5*n.ee)*i;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.re,t.beginPath(),t.arc(h,l,n.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.he,t.beginPath(),t.arc(h,l,n.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{le:0,ae:.25,oe:4,_e:10,ue:.25,ce:0,de:.4,fe:.8},{le:.25,ae:.525,oe:10,_e:14,ue:0,ce:0,de:.8,fe:0},{le:.525,ae:1,oe:14,_e:14,ue:0,ce:0,de:0,fe:0}];class at{constructor(t){this.Kt=new ht,this.St=!0,this.pe=!0,this.ve=performance.now(),this.me=this.ve-1,this.we=t}ge(){this.me=this.ve-1,this.Pt()}be(){if(this.Pt(),2===this.we.N().lastPriceAnimation){const t=performance.now(),i=this.me-t;if(i>0)return void(i<650&&(this.me+=2600));this.ve=t,this.me=t+2600}}Pt(){this.St=!0}Me(){this.pe=!0}Et(){return 0!==this.we.N().lastPriceAnimation}xe(){switch(this.we.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.me}}kt(){return this.St?(this.Rt(),this.St=!1,this.pe=!1):this.pe&&(this.Se(),this.pe=!1),this.Kt}Rt(){this.Kt.ht(null);const t=this.we.Qt().It(),i=t.Ce(),s=this.we.At();if(null===i||null===s)return;const n=this.we.ye(!0);if(n.Pe||!i.Te(n.ke))return;const e={x:t.jt(n.ke),y:this.we.Ft().Nt(n.gt,s.Wt)},r=n.R,h=this.we.N().lineWidth,l=this.Re(this.De(),r);this.Kt.ht({ne:r,ee:h,re:l.re,he:l.he,ft:l.ft,se:e})}Se(){const t=this.Kt.ie();if(null!==t){const i=this.Re(this.De(),t.ne);t.re=i.re,t.he=i.he,t.ft=i.ft}}De(){return this.xe()?performance.now()-this.ve:2599}Ee(t,i,s,n){const e=s+(n-s)*i;return this.we.Qt().qi().Z(t,e)}Re(t,i){const s=t%2600/2600;let n;for(const t of lt)if(s>=t.le&&s<=t.ae){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.le)/(n.ae-n.le);return{re:this.Ee(i,e,n.ue,n.ce),he:this.Ee(i,e,n.de,n.fe),ft:(h=e,l=n.oe,a=n._e,l+(a-l)*h)};var h,l,a}}class ot extends et{constructor(t){super(t)}Qn(){const t=this.qn;t.Et=!1;const i=this.Kn.N();if(!i.priceLineVisible||!this.Kn.Et())return;const s=this.Kn.ye(0===i.priceLineSource);s.Pe||(t.Et=!0,t.ut=s.zi,t.R=this.Kn.Ve(s.R),t.ct=i.priceLineWidth,t.qt=i.priceLineStyle)}}class _t extends O{constructor(t){super(),this.Jt=t}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.Jt;if(!n.Et())return;const e=n.N(),r=e.lastValueVisible,h=""!==n.ze(),l=0===e.seriesLastValueMode,a=n.ye(!1);if(a.Pe)return;r&&(t.ri=this.Ie(a,r,l),t.Et=0!==t.ri.length),(h||l)&&(i.ri=this.Be(a,r,h,l),i.Et=i.ri.length>0);const o=n.Ve(a.R),_=this.Jt.Qt().qi().q(o);s.G=_.G,s.zi=a.zi,i.Ht=n.Qt().$t(a.zi/n.Ft().Ut()),t.Ht=o,t.R=_.K,i.R=_.K}Be(t,i,s,n){let e="";const r=this.Jt.ze();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.Jt.Ft().Ae()?t.Le:t.Oe),e.trim()}Ie(t,i,s){return i?s?this.Jt.Ft().Ae()?t.Oe:t.Le:t.ri:""}}function ut(t,i,s,n){const e=Number.isFinite(i),r=Number.isFinite(s);return e&&r?t(i,s):e||r?e?i:s:n}class ct{constructor(t,i){this.Ne=t,this.Fe=i}We(t){return null!==t&&(this.Ne===t.Ne&&this.Fe===t.Fe)}He(){return new ct(this.Ne,this.Fe)}$e(){return this.Ne}Ue(){return this.Fe}je(){return this.Fe-this.Ne}Xi(){return this.Fe===this.Ne||Number.isNaN(this.Fe)||Number.isNaN(this.Ne)}pn(t){return null===t?this:new ct(ut(Math.min,this.$e(),t.$e(),-1/0),ut(Math.max,this.Ue(),t.Ue(),1/0))}Ye(t){if(!u(t))return;if(0===this.Fe-this.Ne)return;const i=.5*(this.Fe+this.Ne);let s=this.Fe-i,n=this.Ne-i;s*=t,n*=t,this.Fe=i+s,this.Ne=i+n}Ze(t){u(t)&&(this.Fe+=t,this.Ne+=t)}Xe(){return{minValue:this.Ne,maxValue:this.Fe}}static qe(t){return null===t?null:new ct(t.minValue,t.maxValue)}}class dt{constructor(t,i){this.Ge=t,this.Ke=i||null}Je(){return this.Ge}Qe(){return this.Ke}Xe(){return{priceRange:null===this.Ge?null:this.Ge.Xe(),margins:this.Ke||void 0}}static qe(t){return null===t?null:new dt(ct.qe(t.priceRange),t.margins)}}class ft extends et{constructor(t,i){super(t),this.tr=i}Qn(){const t=this.qn;t.Et=!1;const i=this.tr.N();if(!this.Kn.Et()||!i.lineVisible)return;const s=this.tr.ir();null!==s&&(t.Et=!0,t.ut=s,t.R=i.color,t.ct=i.lineWidth,t.qt=i.lineStyle,t.Zn=this.tr.N().id)}}class pt extends O{constructor(t,i){super(),this.we=t,this.tr=i}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.tr.N(),e=n.axisLabelVisible,r=""!==n.title,h=this.we;if(!e||!h.Et())return;const l=this.tr.ir();if(null===l)return;r&&(i.ri=n.title,i.Et=!0),i.Ht=h.Qt().$t(l/h.Ft().Ut()),t.ri=this.sr(n.price),t.Et=!0;const a=this.we.Qt().qi().q(n.axisLabelColor||n.color);s.G=a.G;const o=n.axisLabelTextColor||a.K;t.R=o,i.R=o,s.zi=l}sr(t){const i=this.we.At();return null===i?"":this.we.Ft().Gi(t,i.Wt)}}class vt{constructor(t,i){this.we=t,this.Cs=i,this.nr=new ft(t,this),this.Nn=new pt(t,this),this.er=new st(this.Nn,t,t.Qt())}rr(t){_(this.Cs,t),this.Pt(),this.we.Qt().hr()}N(){return this.Cs}lr(){return this.nr}ar(){return this.er}_r(){return this.Nn}Pt(){this.nr.Pt(),this.Nn.Pt()}ir(){const t=this.we,i=t.Ft();if(t.Qt().It().Xi()||i.Xi())return null;const s=t.At();return null===s?null:i.Nt(this.Cs.price,s.Wt)}}class mt extends ${constructor(t){super(),this.ts=t}Qt(){return this.ts}}const wt={Bar:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=l(t(s,n)),o=a(h.Wt[0])<=a(h.Wt[3]);return{ur:h.R??(o?e:r)}},Candlestick:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=l(t(s,n)),d=a(c.Wt[0])<=a(c.Wt[3]);return{ur:c.R??(d?e:r),cr:c.Ht??(d?h:o),dr:c.pr??(d?_:u)}},Custom:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color}),Area:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.vt??i.lineColor,vt:e.vt??i.lineColor,vr:e.vr??i.topColor,mr:e.mr??i.bottomColor}},Baseline:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.Wt[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,wr:e.wr??i.topLineColor,gr:e.gr??i.bottomLineColor,br:e.br??i.topFillColor1,Mr:e.Mr??i.topFillColor2,Sr:e.Sr??i.bottomFillColor1,Cr:e.Cr??i.bottomFillColor2}},Line:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color})};class gt{constructor(t){this.yr=(t,i)=>void 0!==i?i.Wt:this.we.Xs().Pr(t),this.we=t,this.Tr=wt[t.kr()]}Rr(t,i){return this.Tr(this.yr,this.we.N(),t,i)}}function bt(t,i,s,n,e=0,r=i.length){let h=r-e;for(;0>1,l=e+r;n(i[l],s)===t?(e=l+1,h-=r+1):h=r}return e}const Mt=bt.bind(null,!0),xt=bt.bind(null,!1);var St;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(St||(St={}));const Ct=30;class yt{constructor(){this.Dr=[],this.Er=new Map,this.Vr=new Map,this.zr=[]}Ir(){return this.Br()>0?this.Dr[this.Dr.length-1]:null}Ar(){return this.Br()>0?this.Lr(0):null}Zs(){return this.Br()>0?this.Lr(this.Dr.length-1):null}Br(){return this.Dr.length}Xi(){return 0===this.Br()}Te(t){return null!==this.Or(t,0)}Pr(t){return this.Nr(t)}Nr(t,i=0){const s=this.Or(t,i);return null===s?null:{...this.Fr(s),ke:this.Lr(s)}}Wr(){return this.Dr}Hr(t,i,s){if(this.Xi())return null;let n=null;for(const e of s){n=Pt(n,this.$r(t,i,e))}return n}ht(t){this.Vr.clear(),this.Er.clear(),this.Dr=t,this.zr=t.map((t=>t.ke))}Ur(){return this.zr}Lr(t){return this.Dr[t].ke}Fr(t){return this.Dr[t]}Or(t,i){const s=this.jr(t);if(null===s&&0!==i)switch(i){case-1:return this.Yr(t);case 1:return this.Zr(t);default:throw new TypeError("Unknown search mode")}return s}Yr(t){let i=this.Xr(t);return i>0&&(i-=1),i!==this.Dr.length&&this.Lr(i)t.ket.ke>i))}Gr(t,i,s){let n=null;for(let e=t;en.Jr&&(n.Jr=t)))}return n}$r(t,i,s){if(this.Xi())return null;let n=null;const e=l(this.Ar()),r=l(this.Zs()),h=Math.max(t,e),a=Math.min(i,r),o=Math.ceil(h/Ct)*Ct,_=Math.max(o,Math.floor(a/Ct)*Ct);{const t=this.Xr(h),e=this.qr(Math.min(a,o,i));n=Pt(n,this.Gr(t,e,s))}let u=this.Er.get(s);void 0===u&&(u=new Map,this.Er.set(s,u));for(let t=Math.max(o+1,h);t<_;t+=Ct){const i=Math.floor(t/Ct);let e=u.get(i);if(void 0===e){const t=this.Xr(i*Ct),n=this.qr((i+1)*Ct-1);e=this.Gr(t,n,s),u.set(i,e)}n=Pt(n,e)}{const t=this.Xr(_),i=this.qr(a);n=Pt(n,this.Gr(t,i,s))}return n}}function Pt(t,i){if(null===t)return i;if(null===i)return t;return{Kr:Math.min(t.Kr,i.Kr),Jr:Math.max(t.Jr,i.Jr)}}class Tt{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class kt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Tt(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}class Rt{constructor(t){this.rh=null,this.hh=t}ah(){return this.hh}Os(){this.hh.updateAllViews?.()}Ns(){const t=this.hh.paneViews?.()??[];if(this.rh?.sh===t)return this.rh.nh;const i=t.map((t=>new kt(t)));return this.rh={sh:t,nh:i},i}Yn(t,i){return this.hh.hitTest?.(t,i)??null}}class Dt extends Rt{_s(){return[]}}class Et{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class Vt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Et(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}function zt(t){return{ri:t.text(),zi:t.coordinate(),Vi:t.fixedCoordinate?.(),R:t.textColor(),G:t.backColor(),Et:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class It{constructor(t,i){this.Kt=new W,this.oh=t,this._h=i}kt(){return this.Kt.ht({Qi:this._h.Qi(),...zt(this.oh)}),this.Kt}}class Bt extends O{constructor(t,i){super(),this.oh=t,this.Yi=i}ji(t,i,s){const n=zt(this.oh);s.G=n.G,t.R=n.R;const e=2/12*this.Yi.P();s.ki=e,s.Ri=e,s.zi=n.zi,s.Vi=n.Vi,t.ri=n.ri,t.Et=n.Et,t.pi=n.pi}}class At extends Rt{constructor(t,i){super(t),this.uh=null,this.dh=null,this.fh=null,this.ph=null,this.we=i}us(){const t=this.hh.timeAxisViews?.()??[];if(this.uh?.sh===t)return this.uh.nh;const i=this.we.Qt().It(),s=t.map((t=>new It(t,i)));return this.uh={sh:t,nh:s},s}Fs(){const t=this.hh.priceAxisViews?.()??[];if(this.dh?.sh===t)return this.dh.nh;const i=this.we.Ft(),s=t.map((t=>new Bt(t,i)));return this.dh={sh:t,nh:s},s}mh(){const t=this.hh.priceAxisPaneViews?.()??[];if(this.fh?.sh===t)return this.fh.nh;const i=t.map((t=>new Vt(t)));return this.fh={sh:t,nh:i},i}wh(){const t=this.hh.timeAxisPaneViews?.()??[];if(this.ph?.sh===t)return this.ph.nh;const i=t.map((t=>new Vt(t)));return this.ph={sh:t,nh:i},i}gh(t,i){return this.hh.autoscaleInfo?.(t,i)??null}}function Lt(t,i,s,n){t.forEach((t=>{i(t).forEach((t=>{t.eh()===s&&n.push(t)}))}))}function Ot(t){return t.Ns()}function Nt(t){return t.mh()}function Ft(t){return t.wh()}const Wt=["Area","Line","Baseline"];class Ht extends mt{constructor(t,i,s,n,e){super(t),this.Yt=new yt,this.nr=new ot(this),this.bh=[],this.Mh=new rt(this),this.xh=null,this.Sh=null,this.Ch=null,this.yh=[],this.Cs=s,this.Ph=i;const r=new _t(this);this.ps=[r],this.er=new st(r,this,t),Wt.includes(this.Ph)&&(this.xh=new at(this)),this.Th(),this.ih=n(this,this.Qt(),e)}m(){null!==this.Ch&&clearTimeout(this.Ch)}Ve(t){return this.Cs.priceLineColor||t}ye(t){const i={Pe:!0},s=this.Ft();if(this.Qt().It().Xi()||s.Xi()||this.Yt.Xi())return i;const n=this.Qt().It().Ce(),e=this.At();if(null===n||null===e)return i;let r,h;if(t){const t=this.Yt.Ir();if(null===t)return i;r=t,h=t.ke}else{const t=this.Yt.Nr(n.Mi(),-1);if(null===t)return i;if(r=this.Yt.Pr(t.ke),null===r)return i;h=t.ke}const l=r.Wt[3],a=this.kh().Rr(h,{Wt:r}),o=s.Nt(l,e.Wt);return{Pe:!1,gt:l,ri:s.Gi(l,e.Wt),Le:s.Rh(l),Oe:s.Dh(l,e.Wt),R:a.ur,zi:o,ke:h}}kh(){return null!==this.Sh||(this.Sh=new gt(this)),this.Sh}N(){return this.Cs}rr(t){const i=t.priceScaleId;void 0!==i&&i!==this.Cs.priceScaleId&&this.Qt().Eh(this,i),_(this.Cs,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().Vh()),this.Qt().zh(this),this.Qt().Ih(),this.ih.Pt("options")}ht(t,i){this.Yt.ht(t),this.ih.Pt("data"),null!==this.xh&&(i&&i.Bh?this.xh.be():0===t.length&&this.xh.ge());const s=this.Qt().Wn(this);this.Qt().Ah(s),this.Qt().zh(this),this.Qt().Ih(),this.Qt().hr()}Lh(t){const i=new vt(this,t);return this.bh.push(i),this.Qt().zh(this),i}Oh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().zh(this)}Nh(){return this.bh}kr(){return this.Ph}At(){const t=this.Fh();return null===t?null:{Wt:t.Wt[3],Wh:t.wt}}Fh(){const t=this.Qt().It().Ce();if(null===t)return null;const i=t.Hh();return this.Yt.Nr(i,1)}Xs(){return this.Yt}$h(t){const i=this.Yt.Pr(t);return null===i?null:"Bar"===this.Ph||"Candlestick"===this.Ph||"Custom"===this.Ph?{Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Zh:i.Wt[3]}:i.Wt[3]}Xh(t){const i=[];Lt(this.yh,Ot,"top",i);const s=this.xh;return null!==s&&s.Et()?(null===this.Ch&&s.xe()&&(this.Ch=setTimeout((()=>{this.Ch=null,this.Qt().qh()}),0)),s.Me(),i.unshift(s),i):i}Ns(){const t=[];this.Gh()||t.push(this.Mh),t.push(this.ih,this.nr);const i=this.bh.map((t=>t.lr()));return t.push(...i),Lt(this.yh,Ot,"normal",t),t}Kh(){return this.Jh(Ot,"bottom")}Qh(t){return this.Jh(Nt,t)}tl(t){return this.Jh(Ft,t)}il(t,i){return this.yh.map((s=>s.Yn(t,i))).filter((t=>null!==t))}_s(){return[this.er,...this.bh.map((t=>t.ar()))]}Fs(t,i){if(i!==this.es&&!this.Gh())return[];const s=[...this.ps];for(const t of this.bh)s.push(t._r());return this.yh.forEach((t=>{s.push(...t.Fs())})),s}us(){const t=[];return this.yh.forEach((i=>{t.push(...i.us())})),t}gh(t,i){if(void 0!==this.Cs.autoscaleInfoProvider){const s=this.Cs.autoscaleInfoProvider((()=>{const s=this.sl(t,i);return null===s?null:s.Xe()}));return dt.qe(s)}return this.sl(t,i)}nl(){return this.Cs.priceFormat.minMove}el(){return this.rl}Os(){this.ih.Pt();for(const t of this.ps)t.Pt();for(const t of this.bh)t.Pt();this.nr.Pt(),this.Mh.Pt(),this.xh?.Pt(),this.yh.forEach((t=>t.Os()))}Ft(){return l(super.Ft())}Bt(t){if(!(("Line"===this.Ph||"Area"===this.Ph||"Baseline"===this.Ph)&&this.Cs.crosshairMarkerVisible))return null;const i=this.Yt.Pr(t);if(null===i)return null;return{gt:i.Wt[3],ft:this.hl(),Ht:this.ll(),Ot:this.al(),Lt:this.ol(t)}}ze(){return this.Cs.title}Et(){return this.Cs.visible}_l(t){this.yh.push(new At(t,this))}ul(t){this.yh=this.yh.filter((i=>i.ah()!==t))}cl(){if("Custom"===this.Ph)return t=>this.ih.dl(t)}fl(){if("Custom"===this.Ph)return t=>this.ih.pl(t)}vl(){return this.Yt.Ur()}Gh(){return!Y(this.Ft().ml())}sl(t,i){if(!c(t)||!c(i)||this.Yt.Xi())return null;const s="Line"===this.Ph||"Area"===this.Ph||"Baseline"===this.Ph||"Histogram"===this.Ph?[3]:[2,1],n=this.Yt.Hr(t,i,s);let e=null!==n?new ct(n.Kr,n.Jr):null,r=null;if("Histogram"===this.kr()){const t=this.Cs.base,i=new ct(t,t);e=null!==e?e.pn(i):i}return this.yh.forEach((s=>{const n=s.gh(t,i);if(n?.priceRange){const t=new ct(n.priceRange.minValue,n.priceRange.maxValue);e=null!==e?e.pn(t):t}n?.margins&&(r=n.margins)})),new dt(e,r)}hl(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.Cs.crosshairMarkerRadius}return 0}ll(){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.Cs.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}al(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.Cs.crosshairMarkerBorderWidth}return 0}ol(t){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.Cs.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.kh().Rr(t).ur}Th(){switch(this.Cs.priceFormat.type){case"custom":this.rl={format:this.Cs.priceFormat.formatter};break;case"volume":this.rl=new J(this.Cs.priceFormat.precision);break;case"percent":this.rl=new K(this.Cs.priceFormat.precision);break;default:{const t=Math.pow(10,this.Cs.priceFormat.precision);this.rl=new G(t,this.Cs.priceFormat.minMove*t)}}null!==this.es&&this.es.wl()}Jh(t,i){const s=[];return Lt(this.yh,t,i,s),s}}const $t=[3],Ut=[0,1,2,3];class jt{constructor(t){this.Cs=t}gl(t,i,s){let n=t;if(0===this.Cs.mode)return n;const e=s.Ps(),r=e.At();if(null===r)return n;const h=e.Nt(t,r),l=s.bl().filter((t=>t instanceof Ht)).reduce(((t,n)=>{if(s.Hn(n)||!n.Et())return t;const e=n.Ft(),r=n.Xs();if(e.Xi()||!r.Te(i))return t;const h=r.Pr(i);if(null===h)return t;const l=a(n.At()),o=3===this.Cs.mode?Ut:$t;return t.concat(o.map((t=>e.Nt(h.Wt[t],l.Wt))))}),[]);if(0===l.length)return n;l.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=l[0];return n=e.Ts(o,r),n}}class Yt extends y{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=l(this.Yt);if(h.Ml){t.strokeStyle=h.xl,n(t,h.Sl),t.beginPath();for(const n of h.Cl){const e=Math.round(n.yl*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Pl){t.strokeStyle=h.Tl,n(t,h.kl),t.beginPath();for(const s of h.Rl){const n=Math.round(s.yl*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}}))}}class Zt{constructor(t){this.Kt=new Yt,this.St=!0,this.yt=t}Pt(){this.St=!0}kt(){if(this.St){const t=this.yt.Qt().N().grid,i={Pl:t.horzLines.visible,Ml:t.vertLines.visible,Tl:t.horzLines.color,xl:t.vertLines.color,kl:t.horzLines.style,Sl:t.vertLines.style,Rl:this.yt.Ps().Dl(),Cl:(this.yt.Qt().It().Dl()||[]).map((t=>({yl:t.coord})))};this.Kt.ht(i),this.St=!1}return this.Kt}}class Xt{constructor(t){this.ih=new Zt(t)}lr(){return this.ih}}const qt={El:4,Vl:1e-4};function Gt(t,i){const s=100*(t-i)/i;return i<0?-s:s}function Kt(t,i){const s=Gt(t.$e(),i),n=Gt(t.Ue(),i);return new ct(s,n)}function Jt(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function Qt(t,i){const s=Jt(t.$e(),i),n=Jt(t.Ue(),i);return new ct(s,n)}function ti(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.log10(s+i.Vl)+i.El;return t<0?-n:n}function ii(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.El)-i.Vl;return t<0?-n:n}function si(t,i){if(null===t)return null;const s=ti(t.$e(),i),n=ti(t.Ue(),i);return new ct(s,n)}function ni(t,i){if(null===t)return null;const s=ii(t.$e(),i),n=ii(t.Ue(),i);return new ct(s,n)}function ei(t){if(null===t)return qt;const i=Math.abs(t.Ue()-t.$e());if(i>=1||i<1e-15)return qt;const s=Math.ceil(Math.abs(Math.log10(i))),n=qt.El+s;return{El:n,Vl:1/Math.pow(10,n)}}function ri(t,i,s){return Math.min(Math.max(t,i),s)}function hi(t,i,s){return i-t<=s}class li{constructor(t,i){if(this.zl=t,this.Il=i,function(t){if(t<0)return!1;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.zl))this.Bl=[2,2.5,2];else{this.Bl=[];for(let t=this.zl;1!==t;){if(t%2==0)this.Bl.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Bl.push(2,2.5),t/=5}if(this.Bl.length>100)throw new Error("something wrong with base")}}}Al(t,i,s){const n=0===this.zl?0:1/this.zl;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Il[0];for(;;){const t=hi(e,n,1e-14)&&e>n+1e-14,i=hi(e,s*h,1e-14),l=hi(e,1,1e-14);if(!(t&&i&&l))break;e/=h,h=this.Il[++r%this.Il.length]}if(e<=n+1e-14&&(e=n),e=Math.max(1,e),this.Bl.length>0&&(l=e,a=1,o=1e-14,Math.abs(l-a)n+1e-14;)e/=h,h=this.Bl[++r%this.Bl.length];var l,a,o;return e}}class ai{constructor(t,i,s,n){this.Ll=[],this.Yi=t,this.zl=i,this.Ol=s,this.Nl=n}Al(t,i){if(t=o?1:-1;let d=null,f=0;for(let s=a-u;s>o;s-=_){const n=this.Nl(s,i,!0);null!==d&&Math.abs(n-d)l||(fl(t.hs())-l(i.hs())))}var _i;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(_i||(_i={}));const ui=new K,ci=new G(100,1);class di{constructor(t,i,s,n,e){this.Yl=0,this.Zl=null,this.Ge=null,this.Xl=null,this.ql={Gl:!1,Kl:null},this.Jl=0,this.Ql=0,this.ta=new o,this.ia=new o,this.sa=[],this.na=null,this.ea=null,this.ra=null,this.ha=null,this.rl=ci,this.la=ei(null),this.aa=t,this.Cs=i,this.oa=s,this._a=n,this.ua=e,this.ca=new ai(this,100,this.da.bind(this),this.fa.bind(this))}ml(){return this.aa}N(){return this.Cs}rr(t){if(_(this.Cs,t),this.wl(),void 0!==t.mode&&this.pa({te:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.va(),this.ea=null}}ma(){return this.Cs.autoScale}jl(){return 1===this.Cs.mode}Ae(){return 2===this.Cs.mode}wa(){return 3===this.Cs.mode}te(){return{tn:this.Cs.autoScale,ga:this.Cs.invertScale,te:this.Cs.mode}}pa(t){const i=this.te();let s=null;void 0!==t.tn&&(this.Cs.autoScale=t.tn),void 0!==t.te&&(this.Cs.mode=t.te,2!==t.te&&3!==t.te||(this.Cs.autoScale=!0),this.ql.Gl=!1),1===i.te&&t.te!==i.te&&(!function(t,i){if(null===t)return!1;const s=ii(t.$e(),i),n=ii(t.Ue(),i);return isFinite(s)&&isFinite(n)}(this.Ge,this.la)?this.Cs.autoScale=!0:(s=ni(this.Ge,this.la),null!==s&&this.ba(s))),1===t.te&&t.te!==i.te&&(s=si(this.Ge,this.la),null!==s&&this.ba(s));const n=i.te!==this.Cs.mode;n&&(2===i.te||this.Ae())&&this.wl(),n&&(3===i.te||this.wa())&&this.wl(),void 0!==t.ga&&i.ga!==t.ga&&(this.Cs.invertScale=t.ga,this.Ma()),this.ia.p(i,this.te())}xa(){return this.ia}P(){return this.oa.fontSize}Ut(){return this.Yl}Sa(t){this.Yl!==t&&(this.Yl=t,this.va(),this.ea=null)}Ca(){if(this.Zl)return this.Zl;const t=this.Ut()-this.ya()-this.Pa();return this.Zl=t,t}Je(){return this.Ta(),this.Ge}ba(t,i){const s=this.Ge;(i||null===s&&null!==t||null!==s&&!s.We(t))&&(this.ea=null,this.Ge=t)}Xi(){return this.Ta(),0===this.Yl||!this.Ge||this.Ge.Xi()}ka(t){return this.ga()?t:this.Ut()-1-t}Nt(t,i){return this.Ae()?t=Gt(t,i):this.wa()&&(t=Jt(t,i)),this.fa(t,i)}Ra(t,i,s){this.Ta();const n=this.Pa(),e=l(this.Je()),r=e.$e(),h=e.Ue(),a=this.Ca()-1,o=this.ga(),_=a/(h-r),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,d=this.Da();for(let s=u;st.Os()))}wl(){this.ea=null;const t=this.qa();let i=100;null!==t&&(i=Math.round(1/t.nl())),this.rl=ci,this.Ae()?(this.rl=ui,i=100):this.wa()?(this.rl=new G(100,1),i=100):null!==t&&(this.rl=t.el()),this.ca=new ai(this,i,this.da.bind(this),this.fa.bind(this)),this.ca.Wl()}Oa(){this.na=null}qi(){return this.ua}qa(){return this.sa[0]||null}ya(){return this.ga()?this.Cs.scaleMargins.bottom*this.Ut()+this.Ql:this.Cs.scaleMargins.top*this.Ut()+this.Jl}Pa(){return this.ga()?this.Cs.scaleMargins.top*this.Ut()+this.Jl:this.Cs.scaleMargins.bottom*this.Ut()+this.Ql}Ta(){this.ql.Gl||(this.ql.Gl=!0,this.Ja())}va(){this.Zl=null}fa(t,i){if(this.Ta(),this.Xi())return 0;t=this.jl()&&t?ti(t,this.la):t;const s=l(this.Je()),n=this.Pa()+(this.Ca()-1)*(t-s.$e())/s.je();return this.ka(n)}da(t,i){if(this.Ta(),this.Xi())return 0;const s=this.ka(t),n=l(this.Je()),e=n.$e()+n.je()*((s-this.Pa())/(this.Ca()-1));return this.jl()?ii(e,this.la):e}Ma(){this.ea=null,this.ca.Wl()}Ja(){const t=this.ql.Kl;if(null===t)return;let i=null;const s=this.Ga();let n=0,e=0;for(const r of s){if(!r.Et())continue;const s=r.At();if(null===s)continue;const h=r.gh(t.Hh(),t.Mi());let a=h&&h.Je();if(null!==a){switch(this.Cs.mode){case 1:a=si(a,this.la);break;case 2:a=Kt(a,s.Wt);break;case 3:a=Qt(a,s.Wt)}if(i=null===i?a:i.pn(l(a)),null!==h){const t=h.Qe();null!==t&&(n=Math.max(n,t.above),e=Math.max(e,t.below))}}}if(n===this.Jl&&e===this.Ql||(this.Jl=n,this.Ql=e,this.ea=null,this.va()),null!==i){if(i.$e()===i.Ue()){const t=this.qa(),s=5*(null===t||this.Ae()||this.wa()?1:t.nl());this.jl()&&(i=ni(i,this.la)),i=new ct(i.$e()-s,i.Ue()+s),this.jl()&&(i=si(i,this.la))}if(this.jl()){const t=ni(i,this.la),s=ei(t);if(r=s,h=this.la,r.El!==h.El||r.Vl!==h.Vl){const n=null!==this.Xl?ni(this.Xl,this.la):null;this.la=s,i=si(t,s),null!==n&&(this.Xl=si(n,s))}}this.ba(i)}else null===this.Ge&&(this.ba(new ct(-.5,.5)),this.la=ei(null));var r,h;this.ql.Gl=!0}Da(){return this.Ae()?Gt:this.wa()?Jt:this.jl()?t=>ti(t,this.la):null}Qa(t,i,s){return void 0===i?(void 0===s&&(s=this.el()),s.format(t)):i(t)}sr(t,i){return this.Qa(t,this._a.priceFormatter,i)}Xa(t,i){return this.Qa(t,this._a.percentageFormatter,i)}}function fi(t){return t instanceof Ht}class pi{constructor(t,i){this.sa=[],this.io=new Map,this.Yl=0,this.so=0,this.no=1e3,this.na=null,this.eo=new o,this.yh=[],this._h=t,this.ts=i,this.ro=new Xt(this);const s=i.N();this.ho=this.lo("left",s.leftPriceScale),this.ao=this.lo("right",s.rightPriceScale),this.ho.xa().i(this.oo.bind(this,this.ho),this),this.ao.xa().i(this.oo.bind(this,this.ao),this),this._o(s)}_o(t){if(t.leftPriceScale&&this.ho.rr(t.leftPriceScale),t.rightPriceScale&&this.ao.rr(t.rightPriceScale),t.localization&&(this.ho.wl(),this.ao.wl()),t.overlayPriceScales){const i=Array.from(this.io.values());for(const s of i){const i=l(s[0].Ft());i.rr(t.overlayPriceScales),t.localization&&i.wl()}}}uo(t){switch(t){case"left":return this.ho;case"right":return this.ao}return this.io.has(t)?h(this.io.get(t))[0].Ft():null}m(){this.Qt().co().u(this),this.ho.xa().u(this),this.ao.xa().u(this),this.sa.forEach((t=>{t.m&&t.m()})),this.yh=this.yh.filter((t=>{const i=t.ah();return i.detached&&i.detached(),!1})),this.eo.p()}do(){return this.no}fo(t){this.no=t}Qt(){return this.ts}Qi(){return this.so}Ut(){return this.Yl}po(t){this.so=t,this.vo()}Sa(t){this.Yl=t,this.ho.Sa(t),this.ao.Sa(t),this.sa.forEach((i=>{if(this.Hn(i)){const s=i.Ft();null!==s&&s.Sa(t)}})),this.vo()}mo(){return this.sa.filter(fi)}bl(){return this.sa}Hn(t){const i=t.Ft();return null===i||this.ho!==i&&this.ao!==i}La(t,i,s){const n=void 0!==s?s:this.bo().wo+1;this.Mo(t,i,n)}Na(t){const i=this.sa.indexOf(t);r(-1!==i,"removeDataSource: invalid data source"),this.sa.splice(i,1);const s=l(t.Ft()).ml();if(this.io.has(s)){const i=h(this.io.get(s)),n=i.indexOf(t);-1!==n&&(i.splice(n,1),0===i.length&&this.io.delete(s))}const n=t.Ft();n&&n.bl().indexOf(t)>=0&&n.Na(t),null!==n&&(n.Oa(),this.xo(n)),this.na=null}Un(t){return t===this.ho?"left":t===this.ao?"right":"overlay"}So(){return this.ho}Co(){return this.ao}yo(t,i){t.Ha(i)}Po(t,i){t.$a(i),this.vo()}To(t){t.Ua()}ko(t,i){t.ja(i)}Ro(t,i){t.Ya(i),this.vo()}Do(t){t.Za()}vo(){this.sa.forEach((t=>{t.Os()}))}Ps(){let t=null;return this.ts.N().rightPriceScale.visible&&0!==this.ao.bl().length?t=this.ao:this.ts.N().leftPriceScale.visible&&0!==this.ho.bl().length?t=this.ho:0!==this.sa.length&&(t=this.sa[0].Ft()),null===t&&(t=this.ao),t}$n(){let t=null;return this.ts.N().rightPriceScale.visible?t=this.ao:this.ts.N().leftPriceScale.visible&&(t=this.ho),t}xo(t){null!==t&&t.ma()&&this.Eo(t)}Vo(t){const i=this._h.Ce();t.pa({tn:!0}),null!==i&&t.Ka(i),this.vo()}zo(){this.Eo(this.ho),this.Eo(this.ao)}Io(){this.xo(this.ho),this.xo(this.ao),this.sa.forEach((t=>{this.Hn(t)&&this.xo(t.Ft())})),this.vo(),this.ts.hr()}Dt(){return null===this.na&&(this.na=oi(this.sa)),this.na}Vt(){return this.Dt().filter(fi)}Bo(){return this.eo}Ao(){return this.ro}_l(t){this.yh.push(new Dt(t))}ul(t){this.yh=this.yh.filter((i=>i.ah()!==t)),t.detached&&t.detached(),this.ts.hr()}Lo(){return this.yh}il(t,i){return this.yh.map((s=>s.Yn(t,i))).filter((t=>null!==t))}Eo(t){const i=t.Ga();if(i&&i.length>0&&!this._h.Xi()){const i=this._h.Ce();null!==i&&t.Ka(i)}t.Os()}bo(){const t=this.Dt();if(0===t.length)return{Oo:0,wo:0};let i=0,s=0;for(let n=0;ns&&(s=e))}return{Oo:i,wo:s}}Mo(t,i,s){let n=this.uo(i);if(null===n&&(n=this.lo(i,this.ts.N().overlayPriceScales)),this.sa.push(t),!Y(i)){const s=this.io.get(i)||[];s.push(t),this.io.set(i,s)}n.La(t),t.os(n),t.ls(s),this.xo(n),this.na=null}oo(t,i,s){i.te!==s.te&&this.Eo(t)}lo(t,i){const s={visible:!0,autoScale:!0,...p(i)},n=new di(t,s,this.ts.N().layout,this.ts.N().localization,this.ts.qi());return n.Sa(this.Ut()),n}}function vi(t){return{No:t.No,Fo:{Zn:t.Wo.externalId},Ho:t.Wo.cursorStyle}}function mi(t,i,s,n){for(const e of t){const t=e.kt(n);if(null!==t&&t.Yn){const n=t.Yn(i,s);if(null!==n)return{$o:e,Fo:n}}}return null}function wi(t){return void 0!==t.Ns}function gi(t,i,s){const n=[t,...t.Dt()],e=function(t,i,s){let n,e;for(const l of t){const t=l.il?.(i,s)??[];for(const i of t)r=i.zOrder,h=n?.zOrder,(!h||"top"===r&&"top"!==h||"normal"===r&&"bottom"===h)&&(n=i,e=l)}var r,h;return n&&e?{Wo:n,No:e}:null}(n,i,s);if("top"===e?.Wo.zOrder)return vi(e);for(const r of n){if(e&&e.No===r&&"bottom"!==e.Wo.zOrder&&!e.Wo.isBackground)return vi(e);if(wi(r)){const n=mi(r.Ns(t),i,s,t);if(null!==n)return{No:r,$o:n.$o,Fo:n.Fo}}if(e&&e.No===r&&"bottom"!==e.Wo.zOrder&&e.Wo.isBackground)return vi(e)}return e?.Wo?vi(e):null}class bi{constructor(t,i,s=50){this.yn=0,this.Pn=1,this.Tn=1,this.Rn=new Map,this.kn=new Map,this.Uo=t,this.jo=i,this.Dn=s}Yo(t){const i=t.time,s=this.jo.cacheKey(i),n=this.Rn.get(s);if(void 0!==n)return n.Zo;if(this.yn===this.Dn){const t=this.kn.get(this.Tn);this.kn.delete(this.Tn),this.Rn.delete(h(t)),this.Tn++,this.yn--}const e=this.Uo(t);return this.Rn.set(s,{Zo:e,In:this.Pn}),this.kn.set(this.Pn,s),this.yn++,this.Pn++,e}}class Mi{constructor(t,i){r(t<=i,"right should be >= left"),this.Xo=t,this.qo=i}Hh(){return this.Xo}Mi(){return this.qo}Go(){return this.qo-this.Xo+1}Te(t){return this.Xo<=t&&t<=this.qo}We(t){return this.Xo===t.Hh()&&this.qo===t.Mi()}}function xi(t,i){return null===t||null===i?t===i:t.We(i)}class Si{constructor(){this.Ko=new Map,this.Rn=null,this.Jo=!1}Qo(t){this.Jo=t,this.Rn=null}t_(t,i){this.i_(i),this.Rn=null;for(let s=i;s{t<=s[0].index?i.push(n):s.splice(Mt(s,t,(i=>i.index!i||s.has(t.index);for(const i of Array.from(this.Ko.keys()).sort(((t,i)=>i-t))){if(!this.Ko.get(i))continue;const s=n;n=[];const r=s.length;let l=0;const a=h(this.Ko.get(i)),o=a.length;let _=1/0,u=-1/0;for(let i=0;i=t&&o-u>=t&&e(h))n.push(h),u=o;else if(this.Jo)return s}for(;li.weight?t:i}class Pi{constructor(t,i,s,n){this.so=0,this.u_=null,this.c_=[],this.ha=null,this.ra=null,this.d_=new Si,this.f_=new Map,this.p_=Ci.__(),this.v_=!0,this.m_=new o,this.w_=new o,this.g_=new o,this.b_=null,this.M_=null,this.x_=new Map,this.S_=-1,this.C_=[],this.Cs=i,this._a=s,this.y_=i.rightOffset,this.P_=i.barSpacing,this.ts=t,this.jo=n,this.T_(),this.d_.Qo(i.uniformDistribution),this.k_()}N(){return this.Cs}R_(t){_(this._a,t),this.D_(),this.T_()}rr(t,i){_(this.Cs,t),this.Cs.fixLeftEdge&&this.E_(),this.Cs.fixRightEdge&&this.V_(),void 0!==t.barSpacing&&this.ts.cn(t.barSpacing),void 0!==t.rightOffset&&this.ts.dn(t.rightOffset),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ts.cn(t.barSpacing??this.P_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.Cs.ignoreWhitespaceIndices&&this.k_(),this.D_(),this.T_(),this.g_.p()}ks(t){return this.c_[t]?.time??null}ss(t){return this.c_[t]??null}z_(t,i){if(this.c_.length<1)return null;if(this.jo.key(t)>this.jo.key(this.c_[this.c_.length-1].time))return i?this.c_.length-1:null;const s=Mt(this.c_,this.jo.key(t),((t,i)=>this.jo.key(t.time)0}Ce(){return this.B_(),this.p_.a_()}A_(){return this.B_(),this.p_.o_()}L_(){const t=this.Ce();if(null===t)return null;const i={from:t.Hh(),to:t.Mi()};return this.O_(i)}O_(t){const i=Math.round(t.from),s=Math.round(t.to),n=l(this.N_()),e=l(this.F_());return{from:l(this.ss(Math.max(n,i))),to:l(this.ss(Math.min(e,s)))}}W_(t){return{from:l(this.z_(t.from,!0)),to:l(this.z_(t.to,!0))}}Qi(){return this.so}po(t){if(!isFinite(t)||t<=0)return;if(this.so===t)return;const i=this.A_(),s=this.so;if(this.so=t,this.v_=!0,this.Cs.lockVisibleTimeRangeOnResize&&0!==s){const i=this.P_*t/s;this.P_=i}if(this.Cs.fixLeftEdge&&null!==i&&i.Hh()<=0){const i=s-t;this.y_-=Math.round(i/this.P_)+1,this.v_=!0}this.H_(),this.U_()}jt(t){if(this.Xi()||!c(t))return 0;const i=this.j_()+this.y_-t;return this.so-(i+.5)*this.P_-1}Y_(t,i){const s=this.j_(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;ii/2&&!_?s.needAlignCoordinate=!1:s.needAlignCoordinate=u&&t.index<=a||c&&t.index>=o,d++}return this.C_.length=d,this.M_=this.C_,this.C_}nu(){this.v_=!0,this.cn(this.Cs.barSpacing),this.dn(this.Cs.rightOffset)}eu(t){this.v_=!0,this.u_=t,this.U_(),this.E_()}ru(t,i){const s=this.X_(t),n=this.J_(),e=n+i*(n/10);this.cn(e),this.Cs.rightBarStaysOnScroll||this.dn(this.tu()+(s-this.X_(t)))}Ha(t){this.ha&&this.Za(),null===this.ra&&null===this.b_&&(this.Xi()||(this.ra=t,this.hu()))}$a(t){if(null===this.b_)return;const i=ri(this.so-t,0,this.so),s=ri(this.so-l(this.ra),0,this.so);0!==i&&0!==s&&this.cn(this.b_.J_*i/s)}Ua(){null!==this.ra&&(this.ra=null,this.lu())}ja(t){null===this.ha&&null===this.b_&&(this.Xi()||(this.ha=t,this.hu()))}Ya(t){if(null===this.ha)return;const i=(this.ha-t)/this.J_();this.y_=l(this.b_).tu+i,this.v_=!0,this.U_()}Za(){null!==this.ha&&(this.ha=null,this.lu())}au(){this.ou(this.Cs.rightOffset)}ou(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.y_,n=performance.now();this.ts.an({_u:t=>(t-n)/i>=1,uu:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}Pt(t,i){this.v_=!0,this.c_=t,this.d_.t_(t,i),this.U_()}cu(){return this.m_}du(){return this.w_}fu(){return this.g_}j_(){return this.u_||0}pu(t){const i=t.Go();this.Q_(this.so/i),this.y_=t.Mi()-this.j_(),this.U_(),this.v_=!0,this.ts.K_(),this.ts.hr()}vu(){const t=this.N_(),i=this.F_();null!==t&&null!==i&&this.pu(new Mi(t,i+this.Cs.rightOffset))}mu(t){const i=new Mi(t.from,t.to);this.pu(i)}ns(t){return void 0!==this._a.timeFormatter?this._a.timeFormatter(t.originalTime):this.jo.formatHorzItem(t.time)}k_(){if(!this.Cs.ignoreWhitespaceIndices)return;this.x_.clear();const t=this.ts.Ys();for(const i of t)for(const t of i.vl())this.x_.set(t,!0);this.S_++}iu(){const t=this.ts.N().handleScroll,i=this.ts.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}N_(){return 0===this.c_.length?null:0}F_(){return 0===this.c_.length?null:this.c_.length-1}wu(t){return(this.so-1-t)/this.P_}X_(t){const i=this.wu(t),s=this.j_()+this.y_-i;return Math.round(1e6*s)/1e6}Q_(t){const i=this.P_;this.P_=t,this.H_(),i!==this.P_&&(this.v_=!0,this.gu())}B_(){if(!this.v_)return;if(this.v_=!1,this.Xi())return void this.bu(Ci.__());const t=this.j_(),i=this.so/this.P_,s=this.y_+t,n=new Mi(s-i+1,s);this.bu(new Ci(n))}H_(){const t=ri(this.P_,this.Mu(),this.xu());this.P_!==t&&(this.P_=t,this.v_=!0)}xu(){return this.Cs.maxBarSpacing>0?this.Cs.maxBarSpacing:.5*this.so}Mu(){return this.Cs.fixLeftEdge&&this.Cs.fixRightEdge&&0!==this.c_.length?this.so/this.c_.length:this.Cs.minBarSpacing}U_(){const t=this.Su();null!==t&&this.y_i&&(this.y_=i,this.v_=!0)}Su(){const t=this.N_(),i=this.u_;if(null===t||null===i)return null;return t-i-1+(this.Cs.fixLeftEdge?this.so/this.P_:Math.min(2,this.c_.length))}Cu(){return this.Cs.fixRightEdge?0:this.so/this.P_-Math.min(2,this.c_.length)}hu(){this.b_={J_:this.J_(),tu:this.tu()}}lu(){this.b_=null}su(t){let i=this.f_.get(t.weight);return void 0===i&&(i=new bi((t=>this.yu(t)),this.jo),this.f_.set(t.weight,i)),i.Yo(t)}yu(t){return this.jo.formatTickmark(t,this._a)}bu(t){const i=this.p_;this.p_=t,xi(i.a_(),this.p_.a_())||this.m_.p(),xi(i.o_(),this.p_.o_())||this.w_.p(),this.gu()}gu(){this.M_=null}D_(){this.gu(),this.f_.clear()}T_(){this.jo.updateFormatter(this._a)}E_(){if(!this.Cs.fixLeftEdge)return;const t=this.N_();if(null===t)return;const i=this.Ce();if(null===i)return;const s=i.Hh()-t;if(s<0){const t=this.y_-s-1;this.dn(t)}this.H_()}V_(){this.U_(),this.H_()}q_(t){return!this.Cs.ignoreWhitespaceIndices||(this.x_.get(t)||!1)}G_(t){const i=function*(t){const i=Math.round(t),s=is)break}return t}}var Ti,ki,Ri,Di,Ei;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ti||(Ti={}));class Vi{constructor(t,i,s){this.Pu=[],this.Tu=[],this.so=0,this.ku=null,this.Ru=new o,this.Du=new o,this.Eu=null,this.Vu=t,this.Cs=i,this.jo=s,this.ua=new S(this.Cs.layout.colorParsers),this.zu=new b(this),this._h=new Pi(this,i.timeScale,this.Cs.localization,s),this.Ct=new j(this,i.crosshair),this.Iu=new jt(i.crosshair),this.Bu(0),this.Pu[0].fo(2e3),this.Au=this.Lu(0),this.Ou=this.Lu(1)}Vh(){this.Nu(Z.wn())}hr(){this.Nu(Z.mn())}qh(){this.Nu(new Z(1))}zh(t){const i=this.Fu(t);this.Nu(i)}Wu(){return this.ku}Hu(t){if(this.ku?.No===t?.No&&this.ku?.Fo?.Zn===t?.Fo?.Zn)return;const i=this.ku;this.ku=t,null!==i&&this.zh(i.No),null!==t&&t.No!==i?.No&&this.zh(t.No)}N(){return this.Cs}rr(t){_(this.Cs,t),this.Pu.forEach((i=>i._o(t))),void 0!==t.timeScale&&this._h.rr(t.timeScale),void 0!==t.localization&&this._h.R_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Ru.p(),this.Au=this.Lu(0),this.Ou=this.Lu(1),this.Vh()}$u(t,i,s=0){const n=this.Pu[s];if(void 0===n)return;if("left"===t)return _(this.Cs,{leftPriceScale:i}),n._o({leftPriceScale:i}),this.Ru.p(),void this.Vh();if("right"===t)return _(this.Cs,{rightPriceScale:i}),n._o({rightPriceScale:i}),this.Ru.p(),void this.Vh();const e=this.Uu(t,s);null!==e&&(e.Ft.rr(i),this.Ru.p())}Uu(t,i){const s=this.Pu[i];if(void 0===s)return null;const n=s.uo(t);return null!==n?{Hs:s,Ft:n}:null}It(){return this._h}$s(){return this.Pu}ju(){return this.Ct}Yu(){return this.Du}Zu(t,i){t.Sa(i),this.K_()}po(t){this.so=t,this._h.po(this.so),this.Pu.forEach((i=>i.po(t))),this.K_()}Xu(t){1!==this.Pu.length&&(r(t>=0&&t=0&&tt+i.do()),0),e=this.Pu.reduce(((t,i)=>t+i.Ut()),0),h=e-30*(this.Pu.length-1);i=Math.min(h,Math.max(30,i));const l=n/e,a=s.Ut();s.fo(i*l);let o=i-a,_=this.Pu.length-1;for(const t of this.Pu)if(t!==s){const i=Math.min(h,Math.max(30,t.Ut()-o/_));o-=t.Ut()-i,_-=1;const s=i*l;t.fo(s)}this.Vh()}Gu(t,i){r(t>=0&&t=0&&ithis.jo.key(e),a=null!==t&&t>r&&!l,o=this._h.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===s)||o)&&this._h.N().shiftVisibleRangeOnNewBar;if(a&&!_){const i=t-r;this._h.dn(this._h.tu()-i)}}this._h.eu(t)}Ah(t){null!==t&&t.Io()}Wn(t){if(function(t){return t instanceof pi}(t))return t;const i=this.Pu.find((i=>i.Dt().includes(t)));return void 0===i?null:i}K_(){this.Pu.forEach((t=>t.Io())),this.Ih()}m(){this.Pu.forEach((t=>t.m())),this.Pu.length=0,this.Cs.localization.priceFormatter=void 0,this.Cs.localization.percentageFormatter=void 0,this.Cs.localization.timeFormatter=void 0}uc(){return this.zu}jn(){return this.zu.N()}co(){return this.Ru}cc(t,i){const s=this.Bu(i);this.dc(t,s),this.Tu.push(t),1===this.Tu.length?this.Vh():this.hr()}fc(t){const i=this.Wn(t),s=this.Tu.indexOf(t);r(-1!==s,"Series not found");const n=l(i);this.Tu.splice(s,1),n.Na(t),t.m&&t.m(),this._h.k_(),this.vc(n)}Eh(t,i){const s=l(this.Wn(t));s.Na(t),s.La(t,i,l(t.hs()))}vu(){const t=Z.mn();t.en(),this.Nu(t)}mc(t){const i=Z.mn();i.ln(t),this.Nu(i)}un(){const t=Z.mn();t.un(),this.Nu(t)}cn(t){const i=Z.mn();i.cn(t),this.Nu(i)}dn(t){const i=Z.mn();i.dn(t),this.Nu(i)}an(t){const i=Z.mn();i.an(t),this.Nu(i)}rn(){const t=Z.mn();t.rn(),this.Nu(t)}wc(){return this.Cs.rightPriceScale.visible?"right":"left"}gc(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.bc(t))return;const s=l(this.Wn(t));s.Na(t);const n=this.Bu(i);this.dc(t,n),0===s.bl().length&&this.vc(s)}Mc(){return this.Ou}U(){return this.Au}$t(t){const i=this.Ou,s=this.Au;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Eu||this.Eu.vr!==s||this.Eu.mr!==i)this.Eu={vr:s,mr:i,xc:new Map};else{const i=this.Eu.xc.get(t);if(void 0!==i)return i}const n=this.ua.tt(s,i,t/100);return this.Eu.xc.set(t,n),n}Sc(t){return this.Pu.indexOf(t)}qi(){return this.ua}Bu(t){if(r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.Pu.length,t))i.mo().includes(t)))}Ku(t,i){const s=new Z(i);if(null!==t){const n=this.Pu.indexOf(t);s.Js(n,{Qs:i})}return s}Fu(t,i){return void 0===i&&(i=2),this.Ku(this.Wn(t),i)}Nu(t){this.Vu&&this.Vu(t),this.Pu.forEach((t=>t.Ao().lr().Pt()))}dc(t,i){const s=t.N().priceScaleId,n=void 0!==s?s:this.wc();i.La(t,n),Y(n)||t.rr(t.N())}Lu(t){const i=this.Cs.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}vc(t){0===t.bl().length&&this.Pu.length>1&&(this.Pu.splice(this.Sc(t),1),this.Vh())}}function zi(t){return!u(t)&&!d(t)}function Ii(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(ki||(ki={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ri||(Ri={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Di||(Di={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Ei||(Ei={}));const Bi=t=>t.getUTCFullYear();function Ai(t,i,s){return i.replace(/yyyy/g,(t=>q(Bi(t),4))(t)).replace(/yy/g,(t=>q(Bi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>q((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>q((t=>t.getUTCDate())(t),2))(t))}class Li{constructor(t="yyyy-MM-dd",i="default"){this.Cc=t,this.yc=i}Yo(t){return Ai(t,this.Cc,this.yc)}}class Oi{constructor(t){this.Pc=t||"%h:%m:%s"}Yo(t){return this.Pc.replace("%h",q(t.getUTCHours(),2)).replace("%m",q(t.getUTCMinutes(),2)).replace("%s",q(t.getUTCSeconds(),2))}}const Ni={Tc:"yyyy-MM-dd",kc:"%h:%m:%s",Rc:" ",Dc:"default"};class Fi{constructor(t={}){const i={...Ni,...t};this.Ec=new Li(i.Tc,i.Dc),this.Vc=new Oi(i.kc),this.zc=i.Rc}Yo(t){return`${this.Ec.Yo(t)}${this.zc}${this.Vc.Yo(t)}`}}function Wi(t){return 60*t*60*1e3}function Hi(t){return 60*t*1e3}const $i=[{Ic:(Ui=1,1e3*Ui),Bc:10},{Ic:Hi(1),Bc:20},{Ic:Hi(5),Bc:21},{Ic:Hi(30),Bc:22},{Ic:Wi(1),Bc:30},{Ic:Wi(3),Bc:31},{Ic:Wi(6),Bc:32},{Ic:Wi(12),Bc:33}];var Ui;function ji(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=$i.length-1;s>=0;--s)if(Math.floor(i.getTime()/$i[s].Ic)!==Math.floor(t.getTime()/$i[s].Ic))return $i[s].Bc;return 0}function Yi(t){let i=t;if(d(t)&&(i=Xi(t)),!zi(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Ac:Math.round(s.getTime()/1e3),Lc:i}}function Zi(t){if(!Ii(t))throw new Error("time must be of type isUTCTimestamp");return{Ac:t}}function Xi(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function qi(t){d(t.time)&&(t.time=Xi(t.time))}class Gi{options(){return this.Cs}setOptions(t){this.Cs=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(qi)}(t):qi(t)}createConverterToInternalObj(t){return l(function(t){return 0===t.length?null:zi(t[0].time)||d(t[0].time)?Yi:Zi}(t))}key(t){return"object"==typeof t&&"Ac"in t?t.Ac:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.Lc?new Date(1e3*i.Ac).getTime():new Date(Date.UTC(i.Lc.year,i.Lc.month-1,i.Lc.day)).getTime()}convertHorzItemToInternal(t){return Ii(i=t)?Zi(i):zi(i)?Yi(i):Yi(Xi(i));var i}updateFormatter(t){if(!this.Cs)return;const i=t.dateFormat;this.Cs.timeScale.timeVisible?this.Oc=new Fi({Tc:i,kc:this.Cs.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Rc:" ",Dc:t.locale}):this.Oc=new Li(i,t.locale)}formatHorzItem(t){const i=t;return this.Oc.Yo(new Date(1e3*i.Ac))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.Cs.timeScale.timeVisible,this.Cs.timeScale.secondsVisible),n=this.Cs.timeScale;if(void 0!==n.tickMarkFormatter){const e=n.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==e)return e}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.Lc?new Date(1e3*t.Ac):new Date(Date.UTC(t.Lc.year,t.Lc.month-1,t.Lc.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(yi,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.Ac,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0].time.Ac-i));t[0].timeWeight=ji(new Date(1e3*t[0].time.Ac),s)}}(t,i)}static Nc(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function Ki(t){var i=t.width,s=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(s<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:s}}function Ji(t,i){return t.width===i.width&&t.height===i.height}var Qi=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==s}))}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach((function(i){return i.next(t._window.devicePixelRatio)})),this._reinstallResolutionListener()},t}();var ts=function(){function t(t,i,s){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Ki({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(n=null==s?void 0:s.allowResizeObserver)||void 0===n||n,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return Ki({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Ki(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;Ji(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=Ki(this._transformBitmapSize(t,this._canvasElementClientSize)),n=Ji(this.bitmapSize,s)?null:s;null===i&&null===n||null!==i&&null!==n&&Ji(i,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(i,n))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(s){t(s.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=is(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new Qi(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=is(this._canvasElement);if(null!==s){var n=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return Ki({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],n):Ki({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var s=i.find((function(i){return i.target===t._canvasElement}));if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var n=s.devicePixelContentBoxSize[0],e=Ki({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function is(t){return t.ownerDocument.defaultView}var ss=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function ns(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var n=t.bitmapSize;if(0===n.width||0===n.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new ss(e,s,n)}const es="undefined"!=typeof window;function rs(){return!!es&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function hs(){return!!es&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ls(t){return t+t%2}function as(t){es&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class os{constructor(t,i,s){this.Fc=0,this.Wc=null,this.Hc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.$c=0,this.Uc=null,this.jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Yc=null,this.Zc=!1,this.Xc=null,this.qc=null,this.Gc=!1,this.Kc=!1,this.Jc=!1,this.Qc=null,this.td=null,this.sd=null,this.nd=null,this.ed=null,this.rd=null,this.hd=null,this.ld=0,this.ad=!1,this.od=!1,this._d=!1,this.ud=0,this.dd=null,this.fd=!hs(),this.pd=t=>{this.vd(t)},this.md=t=>{if(this.wd(t)){const i=this.gd(t);if(++this.$c,this.Uc&&this.$c>1){const{bd:s}=this.Md(cs(t),this.jc);s<30&&!this.Jc&&this.xd(i,this.Cd.Sd),this.yd()}}else{const i=this.gd(t);if(++this.Fc,this.Wc&&this.Fc>1){const{bd:s}=this.Md(cs(t),this.Hc);s<5&&!this.Kc&&this.Pd(i,this.Cd.Td),this.kd()}}},this.Rd=t,this.Cd=i,this.Cs=s,this.Dd()}m(){null!==this.Qc&&(this.Qc(),this.Qc=null),null!==this.td&&(this.td(),this.td=null),null!==this.nd&&(this.nd(),this.nd=null),null!==this.ed&&(this.ed(),this.ed=null),null!==this.rd&&(this.rd(),this.rd=null),null!==this.sd&&(this.sd(),this.sd=null),this.Ed(),this.kd()}Vd(t){this.nd&&this.nd();const i=this.zd.bind(this);if(this.nd=()=>{this.Rd.removeEventListener("mousemove",i)},this.Rd.addEventListener("mousemove",i),this.wd(t))return;const s=this.gd(t);this.Pd(s,this.Cd.Id),this.fd=!0}kd(){null!==this.Wc&&clearTimeout(this.Wc),this.Fc=0,this.Wc=null,this.Hc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}yd(){null!==this.Uc&&clearTimeout(this.Uc),this.$c=0,this.Uc=null,this.jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}zd(t){if(this._d||null!==this.qc)return;if(this.wd(t))return;const i=this.gd(t);this.Pd(i,this.Cd.Bd),this.fd=!0}Ad(t){const i=fs(t.changedTouches,l(this.dd));if(null===i)return;if(this.ud=ds(t),null!==this.hd)return;if(this.od)return;this.ad=!0;const s=this.Md(cs(i),l(this.qc)),{Ld:n,Od:e,bd:r}=s;if(this.Gc||!(r<5)){if(!this.Gc){const t=.5*n,i=e>=t&&!this.Cs.Nd(),s=t>e&&!this.Cs.Fd();i||s||(this.od=!0),this.Gc=!0,this.Jc=!0,this.Ed(),this.yd()}if(!this.od){const s=this.gd(t,i);this.xd(s,this.Cd.Wd),us(t)}}}Hd(t){if(0!==t.button)return;const i=this.Md(cs(t),l(this.Xc)),{bd:s}=i;if(s>=5&&(this.Kc=!0,this.kd()),this.Kc){const i=this.gd(t);this.Pd(i,this.Cd.$d)}}Md(t,i){const s=Math.abs(i._t-t._t),n=Math.abs(i.ut-t.ut);return{Ld:s,Od:n,bd:s+n}}Ud(t){let i=fs(t.changedTouches,l(this.dd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.dd=null,this.ud=ds(t),this.Ed(),this.qc=null,this.rd&&(this.rd(),this.rd=null);const s=this.gd(t,i);if(this.xd(s,this.Cd.jd),++this.$c,this.Uc&&this.$c>1){const{bd:t}=this.Md(cs(i),this.jc);t<30&&!this.Jc&&this.xd(s,this.Cd.Sd),this.yd()}else this.Jc||(this.xd(s,this.Cd.Yd),this.Cd.Yd&&us(t));0===this.$c&&us(t),0===t.touches.length&&this.Zc&&(this.Zc=!1,us(t))}vd(t){if(0!==t.button)return;const i=this.gd(t);if(this.Xc=null,this._d=!1,this.ed&&(this.ed(),this.ed=null),rs()){this.Rd.ownerDocument.documentElement.removeEventListener("mouseleave",this.pd)}if(!this.wd(t))if(this.Pd(i,this.Cd.Zd),++this.Fc,this.Wc&&this.Fc>1){const{bd:s}=this.Md(cs(t),this.Hc);s<5&&!this.Kc&&this.Pd(i,this.Cd.Td),this.kd()}else this.Kc||this.Pd(i,this.Cd.Xd)}Ed(){null!==this.Yc&&(clearTimeout(this.Yc),this.Yc=null)}qd(t){if(null!==this.dd)return;const i=t.changedTouches[0];this.dd=i.identifier,this.ud=ds(t);const s=this.Rd.ownerDocument.documentElement;this.Jc=!1,this.Gc=!1,this.od=!1,this.qc=cs(i),this.rd&&(this.rd(),this.rd=null);{const i=this.Ad.bind(this),n=this.Ud.bind(this);this.rd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.Ed(),this.Yc=setTimeout(this.Gd.bind(this,t),240)}const n=this.gd(t,i);this.xd(n,this.Cd.Kd),this.Uc||(this.$c=0,this.Uc=setTimeout(this.yd.bind(this),500),this.jc=cs(i))}Jd(t){if(0!==t.button)return;const i=this.Rd.ownerDocument.documentElement;rs()&&i.addEventListener("mouseleave",this.pd),this.Kc=!1,this.Xc=cs(t),this.ed&&(this.ed(),this.ed=null);{const t=this.Hd.bind(this),s=this.vd.bind(this);this.ed=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this._d=!0,this.wd(t))return;const s=this.gd(t);this.Pd(s,this.Cd.Qd),this.Wc||(this.Fc=0,this.Wc=setTimeout(this.kd.bind(this),500),this.Hc=cs(t))}Dd(){this.Rd.addEventListener("mouseenter",this.Vd.bind(this)),this.Rd.addEventListener("touchcancel",this.Ed.bind(this));{const t=this.Rd.ownerDocument,i=t=>{this.Cd.tf&&(t.composed&&this.Rd.contains(t.composedPath()[0])||t.target&&this.Rd.contains(t.target)||this.Cd.tf())};this.td=()=>{t.removeEventListener("touchstart",i)},this.Qc=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}hs()&&(this.sd=()=>{this.Rd.removeEventListener("dblclick",this.md)},this.Rd.addEventListener("dblclick",this.md)),this.Rd.addEventListener("mouseleave",this.if.bind(this)),this.Rd.addEventListener("touchstart",this.qd.bind(this),{passive:!0}),as(this.Rd),this.Rd.addEventListener("mousedown",this.Jd.bind(this)),this.sf(),this.Rd.addEventListener("touchmove",(()=>{}),{passive:!1})}sf(){void 0===this.Cd.nf&&void 0===this.Cd.ef&&void 0===this.Cd.rf||(this.Rd.addEventListener("touchstart",(t=>this.hf(t.touches)),{passive:!0}),this.Rd.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.hd&&void 0!==this.Cd.ef){const i=_s(t.touches[0],t.touches[1])/this.ld;this.Cd.ef(this.hd,i),us(t)}}),{passive:!1}),this.Rd.addEventListener("touchend",(t=>{this.hf(t.touches)})))}hf(t){1===t.length&&(this.ad=!1),2!==t.length||this.ad||this.Zc?this.lf():this.af(t)}af(t){const i=this.Rd.getBoundingClientRect()||{left:0,top:0};this.hd={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.ld=_s(t[0],t[1]),void 0!==this.Cd.nf&&this.Cd.nf(),this.Ed()}lf(){null!==this.hd&&(this.hd=null,void 0!==this.Cd.rf&&this.Cd.rf())}if(t){if(this.nd&&this.nd(),this.wd(t))return;if(!this.fd)return;const i=this.gd(t);this.Pd(i,this.Cd._f),this.fd=!hs()}Gd(t){const i=fs(t.touches,l(this.dd));if(null===i)return;const s=this.gd(t,i);this.xd(s,this.Cd.uf),this.Jc=!0,this.Zc=!0}wd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:ds(t){"touchstart"!==t.type&&us(t)}}}}function _s(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function us(t){t.cancelable&&t.preventDefault()}function cs(t){return{_t:t.pageX,ut:t.pageY}}function ds(t){return t.timeStamp||performance.now()}function fs(t,i){for(let s=0;s!1,Fd:()=>!0}),this.vf={zf:s,Vf:t}}Pf(){this.yf.style.background=this.bf.N().layout.panes.separatorColor}If(t){null!==this.vf&&(this.vf.zf.style.backgroundColor=this.bf.N().layout.panes.separatorHoverColor)}Bf(t){null!==this.vf&&null===this.gf&&(this.vf.zf.style.backgroundColor="")}Af(t){if(null===this.vf)return;const i=this.Mf.Nf().do()+this.Sf.Nf().do(),s=i/(this.Mf.Rf().height+this.Sf.Rf().height),n=30*s;i<=2*n||(this.gf={Ff:t.pageY,Wf:this.Mf.Nf().do(),Hf:i-n,$f:i,Uf:s,jf:n},this.vf.Vf.style.display="block")}Lf(t){const i=this.gf;if(null===i)return;const s=(t.pageY-i.Ff)*i.Uf,n=ri(i.Wf+s,i.jf,i.Hf);this.Mf.Nf().fo(n),this.Sf.Nf().fo(i.$f-n),this.bf.Qt().Vh()}Of(t){null!==this.gf&&null!==this.vf&&(this.gf=null,this.vf.Vf.style.display="none")}}function vs(t,i){return t.Yf-i.Yf}function ms(t,i,s){const n=(t.Yf-i.Yf)/(t.wt-i.wt);return Math.sign(n)*Math.min(Math.abs(n),s)}class ws{constructor(t,i,s,n){this.Zf=null,this.Xf=null,this.qf=null,this.Gf=null,this.Kf=null,this.Jf=0,this.Qf=0,this.tp=t,this.ip=i,this.sp=s,this.gn=n}np(t,i){if(null!==this.Zf){if(this.Zf.wt===i)return void(this.Zf.Yf=t);if(Math.abs(this.Zf.Yf-t)50)return;let s=0;const n=ms(this.Zf,this.Xf,this.ip),e=vs(this.Zf,this.Xf),r=[n],h=[e];if(s+=e,null!==this.qf){const t=ms(this.Xf,this.qf,this.ip);if(Math.sign(t)===Math.sign(n)){const i=vs(this.Xf,this.qf);if(r.push(t),h.push(i),s+=i,null!==this.Gf){const t=ms(this.qf,this.Gf,this.ip);if(Math.sign(t)===Math.sign(n)){const i=vs(this.qf,this.Gf);r.push(t),h.push(i),s+=i}}}}let l=0;for(let t=0;t160?"dark":"light"}dp(){return this.op.N().layout.attributionLogo}pp(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}_p(){this.cp()&&(this.up(),this.fs=this.dp(),this.fs&&(this.lp=this.fp(),this.hp=document.createElement("style"),this.hp.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.rp=document.createElement("a"),this.rp.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.pp()}`,this.rp.title="Charting by TradingView",this.rp.id="tv-attr-logo",this.rp.target="_blank",this.rp.innerHTML='',this.rp.toggleAttribute("data-dark","dark"===this.lp),this.ap.appendChild(this.hp),this.ap.appendChild(this.rp)))}}function bs(t,i){const s=l(t.ownerDocument).createElement("canvas");t.appendChild(s);const n=function(t,i){if("device-pixel-content-box"===i.type)return new ts(t,i.transform,i.options);throw new Error("Unsupported binding target")}(s,{type:"device-pixel-content-box",options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})});return n.resizeCanvasElement(i),n}function Ms(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function xs(t,i,s,n){t.th&&t.th(i,s,n)}function Ss(t,i,s,n){t.nt(i,s,n)}function Cs(t,i,s,n){const e=t(s,n);for(const t of e){const s=t.kt(n);null!==s&&i(s)}}function ys(t,i){return s=>{if(!function(t){return void 0!==t.Ft}(s))return[];return(s.Ft()?.ml()??"")!==i?[]:s.Qh?.(t)??[]}}function Ps(t,i,s,n){if(!t.length)return;let e=0;const r=t[0].Ut(n,!0);let h=1===i?s/2-(t[0].Fi()-r/2):t[0].Fi()-r/2-s/2;h=Math.max(0,h);for(let r=1;ru-o:_s)&&h>0){const n=1===i?-1-r:r-s,l=Math.min(n,h);for(let s=e;s{this.Mp||this.yt.Sp().Qt().hr()},this.Cp=()=>{this.Mp||this.yt.Sp().Qt().hr()},this.yt=t,this.Cs=i,this.oa=i.layout,this.zu=s,this.yp="left"===n,this.Pp=ys("normal",n),this.Tp=ys("top",n),this.kp=ys("bottom",n),this.yf=document.createElement("div"),this.yf.style.height="100%",this.yf.style.overflow="hidden",this.yf.style.width="25px",this.yf.style.left="0",this.yf.style.position="relative",this.Rp=bs(this.yf,Ki({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const e=this.Rp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.Dp=bs(this.yf,Ki({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Cp);const r=this.Dp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={Qd:this.Af.bind(this),Kd:this.Af.bind(this),$d:this.Lf.bind(this),Wd:this.Lf.bind(this),tf:this.Ep.bind(this),Zd:this.Of.bind(this),jd:this.Of.bind(this),Td:this.Vp.bind(this),Sd:this.Vp.bind(this),Id:this.zp.bind(this),_f:this.Bf.bind(this)};this.mf=new os(this.Dp.canvasElement,h,{Nd:()=>!this.Cs.handleScroll.vertTouchDrag,Fd:()=>!0})}m(){this.mf.m(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Cp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose(),null!==this.Yi&&this.Yi.Wa().u(this),this.Yi=null}kf(){return this.yf}P(){return this.oa.fontSize}Ip(){const t=this.zu.N();return this.gp!==t.T&&(this.wp.En(),this.gp=t.T),t}Bp(){if(null===this.Yi)return 0;let t=0;const i=this.Ip(),s=l(this.Rp.canvasElement.getContext("2d",{colorSpace:this.yt.Sp().N().layout.colorSpace}));s.save();const n=this.Yi.Dl();s.font=this.Ap(),n.length>0&&(t=Math.max(this.wp.Ei(s,n[0].$l),this.wp.Ei(s,n[n.length-1].$l)));const e=this.Lp();for(let i=e.length;i--;){const n=this.wp.Ei(s,e[i].ri());n>t&&(t=n)}const r=this.Yi.At();if(null!==r&&null!==this.vp&&(2!==(h=this.Cs.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Yi.Ts(1,r),n=this.Yi.Ts(this.vp.height-2,r);t=Math.max(t,this.wp.Ei(s,this.Yi.Gi(Math.floor(Math.min(i,n))+.11111111111111,r)),this.wp.Ei(s,this.Yi.Gi(Math.ceil(Math.max(i,n))-.11111111111111,r)))}var h;s.restore();const a=t||34;return ls(Math.ceil(i.S+i.C+i.I+i.B+5+a))}Op(t){null!==this.vp&&Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.yf.style.width=`${t.width}px`,this.yf.style.height=`${t.height}px`)}Np(){return l(this.vp).width}os(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.Wa().u(this),this.Yi=t,t.Wa().i(this.ta.bind(this),this))}Ft(){return this.Yi}En(){const t=this.yt.Nf();this.yt.Sp().Qt().Vo(t,l(this.Ft()))}Fp(t){if(null===this.vp)return;const i={colorSpace:this.yt.Sp().N().layout.colorSpace};if(1!==t){this.Wp(),this.Rp.applySuggestedBitmapSize();const t=ns(this.Rp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t)})),this.yt.Up(t,this.kp),this.jp(t),this.yt.Up(t,this.Pp),this.Yp(t))}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Zp(s),this.yt.Up(s,this.Tp))}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Pt(){this.Yi?.Dl()}Af(t){if(null===this.Yi||this.Yi.Xi()||!this.Cs.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Sp().Qt(),s=this.yt.Nf();this.mp=!0,i.yo(s,this.Yi,t.localY)}Lf(t){if(null===this.Yi||!this.Cs.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Sp().Qt(),s=this.yt.Nf(),n=this.Yi;i.Po(s,n,t.localY)}Ep(){if(null===this.Yi||!this.Cs.handleScale.axisPressedMouseMove.price)return;const t=this.yt.Sp().Qt(),i=this.yt.Nf(),s=this.Yi;this.mp&&(this.mp=!1,t.To(i,s))}Of(t){if(null===this.Yi||!this.Cs.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Sp().Qt(),s=this.yt.Nf();this.mp=!1,i.To(s,this.Yi)}Vp(t){this.Cs.handleScale.axisDoubleClickReset.price&&this.En()}zp(t){if(null===this.Yi)return;!this.yt.Sp().Qt().N().handleScale.axisPressedMouseMove.price||this.Yi.Ae()||this.Yi.wa()||this.Xp(1)}Bf(t){this.Xp(0)}Lp(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let n=0;n{t.fillStyle=s.borderColor;const l=Math.max(1,Math.floor(h)),a=Math.floor(.5*h),o=Math.round(n.C*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.yl*h)-a,o,l);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Ap(),t.fillStyle=s.textColor??this.oa.textColor,t.textAlign=this.yp?"right":"left",t.textBaseline="middle";const r=this.yp?Math.round(e-n.I):Math.round(e+n.C+n.I),h=i.map((i=>this.wp.Di(t,i.$l)));for(let s=i.length;s--;){const n=i[s];t.fillText(n.$l,r,n.yl+h[s])}}))}Wp(){if(null===this.vp||null===this.Yi)return;let t=this.vp.height/2;const i=[],s=this.Yi.Dt().slice(),n=this.yt.Nf(),e=this.Ip();this.Yi===n.$n()&&this.yt.Nf().Dt().forEach((t=>{n.Hn(t)&&s.push(t)}));const r=this.Yi.bl()[0],h=this.Yi;s.forEach((s=>{const e=s.Fs(n,h);e.forEach((t=>{t.Wi(null),t.Hi()&&i.push(t)})),r===s&&e.length>0&&(t=e[0].zi())})),i.forEach((t=>t.Wi(t.zi())));this.Yi.N().alignLabels&&this.qp(i,e,t)}qp(t,i,s){if(null===this.vp)return;const n=t.filter((t=>t.zi()<=s)),e=t.filter((t=>t.zi()>s));n.sort(((t,i)=>i.zi()-t.zi())),n.length&&e.length&&e.push(n[0]),e.sort(((t,i)=>t.zi()-i.zi()));for(const s of t){const t=Math.floor(s.Ut(i)/2),n=s.zi();n>-t&&nthis.vp.height-t&&n{if(i.$i()){i.kt(l(this.Yi)).nt(t,s,this.wp,n)}}))}Zp(t){if(null===this.vp||null===this.Yi)return;const i=this.yt.Sp().Qt(),s=[],n=this.yt.Nf(),e=i.ju().Fs(n,this.Yi);e.length&&s.push(e);const r=this.Ip(),h=this.yp?"right":"left";s.forEach((i=>{i.forEach((i=>{i.kt(l(this.Yi)).nt(t,r,this.wp,h)}))}))}Xp(t){this.yf.style.cursor=1===t?"ns-resize":"default"}ta(){const t=this.Bp();this.bp{this.Mp||null===this.ov||this.ts().hr()},this.Cp=()=>{this.Mp||null===this.ov||this.ts().hr()},this.op=t,this.ov=i,this.ov.Bo().i(this._v.bind(this),this,!0),this.uv=document.createElement("td"),this.uv.style.padding="0",this.uv.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.cv=document.createElement("td"),this.cv.style.padding="0",this.dv=document.createElement("td"),this.dv.style.padding="0",this.uv.appendChild(s),this.Rp=bs(s,Ki({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const n=this.Rp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Dp=bs(s,Ki({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Cp);const e=this.Dp.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.Cf=document.createElement("tr"),this.Cf.appendChild(this.cv),this.Cf.appendChild(this.uv),this.Cf.appendChild(this.dv),this.fv(),this.mf=new os(this.Dp.canvasElement,this,{Nd:()=>null===this.rv&&!this.op.N().handleScroll.vertTouchDrag,Fd:()=>null===this.rv&&!this.op.N().handleScroll.horzTouchDrag})}m(){null!==this.Gp&&this.Gp.m(),null!==this.Kp&&this.Kp.m(),this.Jp=null,this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Cp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose(),null!==this.ov&&(this.ov.Bo().u(this),this.ov.m()),this.mf.m()}Nf(){return l(this.ov)}pv(t){null!==this.ov&&this.ov.Bo().u(this),this.ov=t,null!==this.ov&&this.ov.Bo().i(Vs.prototype._v.bind(this),this,!0),this.fv(),this.op.xf().indexOf(this)===this.op.xf().length-1?(this.Jp=this.Jp??new gs(this.uv,this.op),this.Jp.Pt()):(this.Jp?.up(),this.Jp=null)}Sp(){return this.op}kf(){return this.Cf}fv(){if(null!==this.ov&&(this.vv(),0!==this.ts().Ys().length)){if(null!==this.Gp){const t=this.ov.So();this.Gp.os(l(t))}if(null!==this.Kp){const t=this.ov.Co();this.Kp.os(l(t))}}}mv(){null!==this.Gp&&this.Gp.Pt(),null!==this.Kp&&this.Kp.Pt()}do(){return null!==this.ov?this.ov.do():0}fo(t){this.ov&&this.ov.fo(t)}Id(t){if(!this.ov)return;this.wv();const i=t.localX,s=t.localY;this.gv(i,s,t)}Qd(t){this.wv(),this.bv(),this.gv(t.localX,t.localY,t)}Bd(t){if(!this.ov)return;this.wv();const i=t.localX,s=t.localY;this.gv(i,s,t)}Xd(t){null!==this.ov&&(this.wv(),this.Mv(t))}Td(t){null!==this.ov&&this.xv(this.sv,t)}Sd(t){this.Td(t)}$d(t){this.wv(),this.Sv(t),this.gv(t.localX,t.localY,t)}Zd(t){null!==this.ov&&(this.wv(),this.ev=!1,this.Cv(t))}Yd(t){null!==this.ov&&this.Mv(t)}uf(t){if(this.ev=!0,null===this.rv){const i={x:t.localX,y:t.localY};this.yv(i,i,t)}}_f(t){null!==this.ov&&(this.wv(),this.ov.Qt().Hu(null),this.Pv())}Tv(){return this.iv}kv(){return this.sv}nf(){this.nv=1,this.ts().rn()}ef(t,i){if(!this.op.N().handleScale.pinch)return;const s=5*(i-this.nv);this.nv=i,this.ts().Qu(t._t,s)}Kd(t){this.ev=!1,this.hv=null!==this.rv,this.bv();const i=this.ts().ju();null!==this.rv&&i.Et()&&(this.lv={x:i.si(),y:i.ni()},this.rv={x:t.localX,y:t.localY})}Wd(t){if(null===this.ov)return;const i=t.localX,s=t.localY;if(null===this.rv)this.Sv(t);else{this.hv=!1;const n=l(this.lv),e=n.x+(i-this.rv.x),r=n.y+(s-this.rv.y);this.gv(e,r,t)}}jd(t){0===this.Sp().N().trackingMode.exitMode&&(this.hv=!0),this.Rv(),this.Cv(t)}Yn(t,i){const s=this.ov;return null===s?null:gi(s,t,i)}Dv(t,i){l("left"===i?this.Gp:this.Kp).Op(Ki({width:t,height:this.vp.height}))}Rf(){return this.vp}Op(t){Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.uv.style.width=t.width+"px",this.uv.style.height=t.height+"px")}Ev(){const t=l(this.ov);t.xo(t.So()),t.xo(t.Co());for(const i of t.bl())if(t.Hn(i)){const s=i.Ft();null!==s&&t.xo(s),i.Os()}for(const i of t.Lo())i.Os()}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Fp(t){if(0===t)return;if(null===this.ov)return;t>1&&this.Ev(),null!==this.Gp&&this.Gp.Fp(t),null!==this.Kp&&this.Kp.Fp(t);const i={colorSpace:this.op.N().layout.colorSpace};if(1!==t){this.Rp.applySuggestedBitmapSize();const t=ns(this.Rp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Hp(t)})),this.ov&&(this.Vv(t,ks),this.zv(t),this.Vv(t,Rs),this.Vv(t,Ds)))}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Iv(s),this.Vv(s,Es),this.Vv(s,Ds))}Bv(){return this.Gp}Av(){return this.Kp}Up(t,i){this.Vv(t,i)}_v(){null!==this.ov&&this.ov.Bo().u(this),this.ov=null}Mv(t){this.xv(this.iv,t)}xv(t,i){const s=i.localX,n=i.localY;t.v()&&t.p(this.ts().It().Z_(s),{x:s,y:n},i)}Hp({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ts(),r=e.U(),h=e.Mc();r===h?z(t,0,0,s,n,h):A(t,0,0,s,n,r,h)}zv(t){const i=l(this.ov),s=i.Ao().lr().kt(i);null!==s&&s.nt(t,!1)}Iv(t){this.Lv(t,Rs,Ss,this.ts().ju())}Vv(t,i){const s=l(this.ov),n=s.Dt(),e=s.Lo();for(const s of e)this.Lv(t,i,xs,s);for(const s of n)this.Lv(t,i,xs,s);for(const s of e)this.Lv(t,i,Ss,s);for(const s of n)this.Lv(t,i,Ss,s)}Lv(t,i,s,n){const e=l(this.ov),r=e.Qt().Wu(),h=null!==r&&r.No===n,a=null!==r&&h&&void 0!==r.Fo?r.Fo.Xn:void 0;Cs(i,(i=>s(i,t,h,a)),n,e)}vv(){if(null===this.ov)return;const t=this.op,i=this.ov.So().N().visible,s=this.ov.Co().N().visible;i||null===this.Gp||(this.cv.removeChild(this.Gp.kf()),this.Gp.m(),this.Gp=null),s||null===this.Kp||(this.dv.removeChild(this.Kp.kf()),this.Kp.m(),this.Kp=null);const n=t.Qt().uc();i&&null===this.Gp&&(this.Gp=new Ts(this,t.N(),n,"left"),this.cv.appendChild(this.Gp.kf())),s&&null===this.Kp&&(this.Kp=new Ts(this,t.N(),n,"right"),this.dv.appendChild(this.Kp.kf()))}Ov(t){return t.cf&&this.ev||null!==this.rv}Nv(t){return Math.max(0,Math.min(t,this.vp.width-1))}Fv(t){return Math.max(0,Math.min(t,this.vp.height-1))}gv(t,i,s){this.ts().lc(this.Nv(t),this.Fv(i),s,l(this.ov))}Pv(){this.ts().oc()}Rv(){this.hv&&(this.rv=null,this.Pv())}yv(t,i,s){this.rv=t,this.hv=!1,this.gv(i.x,i.y,s);const n=this.ts().ju();this.lv={x:n.si(),y:n.ni()}}ts(){return this.op.Qt()}Cv(t){if(!this.tv)return;const i=this.ts(),s=this.Nf();if(i.Do(s,s.Ps()),this.Qp=null,this.tv=!1,i.ec(),null!==this.av){const t=performance.now(),s=i.It();this.av.le(s.tu(),t),this.av._u(t)||i.an(this.av)}}wv(){this.rv=null}bv(){if(!this.ov)return;if(this.ts().rn(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)l(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.ov.Ps().Xi()&&this.ts().It().Xi()}Sv(t){if(null===this.ov)return;const i=this.ts(),s=i.It();if(s.Xi())return;const n=this.op.N(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t.cf)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.cf))return;const h=this.ov.Ps(),l=performance.now();if(null!==this.Qp||this.Ov(t)||(this.Qp={x:t.clientX,y:t.clientY,Ac:l,Wv:t.localX,Hv:t.localY}),null!==this.Qp&&!this.tv&&(this.Qp.x!==t.clientX||this.Qp.y!==t.clientY)){if(t.cf&&r.touch||!t.cf&&r.mouse){const t=s.J_();this.av=new ws(.2/t,7/t,.997,15/t),this.av.np(s.tu(),this.Qp.Ac)}else this.av=null;h.Xi()||i.ko(this.ov,h,t.localY),i.sc(t.localX),this.tv=!0}this.tv&&(h.Xi()||i.Ro(this.ov,h,t.localY),i.nc(t.localX),null!==this.av&&this.av.np(s.tu(),l))}}class zs{constructor(t,i,s,n,e){this.St=!0,this.vp=Ki({width:0,height:0}),this.xp=()=>this.Fp(3),this.yp="left"===t,this.zu=s.uc,this.Cs=i,this.$v=n,this.Uv=e,this.yf=document.createElement("div"),this.yf.style.width="25px",this.yf.style.height="100%",this.yf.style.overflow="hidden",this.Rp=bs(this.yf,Ki({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp)}m(){this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose()}kf(){return this.yf}Rf(){return this.vp}Op(t){Ji(this.vp,t)||(this.vp=t,this.Rp.resizeCanvasElement(t),this.yf.style.width=`${t.width}px`,this.yf.style.height=`${t.height}px`,this.St=!0)}Fp(t){if(t<3&&!this.St)return;if(0===this.vp.width||0===this.vp.height)return;this.St=!1,this.Rp.applySuggestedBitmapSize();const i=ns(this.Rp,{colorSpace:this.Cs.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t)}))}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}$p({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.$v())return;t.fillStyle=this.Cs.timeScale.borderColor;const e=Math.floor(this.zu.N().S*s),r=Math.floor(this.zu.N().S*n),h=this.yp?i.width-e:0;t.fillRect(h,0,e,r)}Hp({context:t,bitmapSize:i}){z(t,0,0,i.width,i.height,this.Uv())}}function Is(t){return i=>i.tl?.(t)??[]}const Bs=Is("normal"),As=Is("top"),Ls=Is("bottom");class Os{constructor(t,i){this.jv=null,this.Yv=null,this.M=null,this.Zv=!1,this.vp=Ki({width:0,height:0}),this.Xv=new o,this.wp=new tt(5),this.Mp=!1,this.xp=()=>{this.Mp||this.op.Qt().hr()},this.Cp=()=>{this.Mp||this.op.Qt().hr()},this.op=t,this.jo=i,this.Cs=t.N().layout,this.rp=document.createElement("tr"),this.qv=document.createElement("td"),this.qv.style.padding="0",this.Gv=document.createElement("td"),this.Gv.style.padding="0",this.yf=document.createElement("td"),this.yf.style.height="25px",this.yf.style.padding="0",this.Kv=document.createElement("div"),this.Kv.style.width="100%",this.Kv.style.height="100%",this.Kv.style.position="relative",this.Kv.style.overflow="hidden",this.yf.appendChild(this.Kv),this.Rp=bs(this.Kv,Ki({width:16,height:16})),this.Rp.subscribeSuggestedBitmapSizeChanged(this.xp);const s=this.Rp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Dp=bs(this.Kv,Ki({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Cp);const n=this.Dp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.rp.appendChild(this.qv),this.rp.appendChild(this.yf),this.rp.appendChild(this.Gv),this.Jv(),this.op.Qt().co().i(this.Jv.bind(this),this),this.mf=new os(this.Dp.canvasElement,this,{Nd:()=>!0,Fd:()=>!this.op.N().handleScroll.horzTouchDrag})}m(){this.mf.m(),null!==this.jv&&this.jv.m(),null!==this.Yv&&this.Yv.m(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Cp),Ms(this.Dp.canvasElement),this.Dp.dispose(),this.Rp.unsubscribeSuggestedBitmapSizeChanged(this.xp),Ms(this.Rp.canvasElement),this.Rp.dispose()}kf(){return this.rp}Qv(){return this.jv}tm(){return this.Yv}Qd(t){if(this.Zv)return;this.Zv=!0;const i=this.op.Qt();!i.It().Xi()&&this.op.N().handleScale.axisPressedMouseMove.time&&i.Ju(t.localX)}Kd(t){this.Qd(t)}tf(){const t=this.op.Qt();!t.It().Xi()&&this.Zv&&(this.Zv=!1,this.op.N().handleScale.axisPressedMouseMove.time&&t.hc())}$d(t){const i=this.op.Qt();!i.It().Xi()&&this.op.N().handleScale.axisPressedMouseMove.time&&i.rc(t.localX)}Wd(t){this.$d(t)}Zd(){this.Zv=!1;const t=this.op.Qt();t.It().Xi()&&!this.op.N().handleScale.axisPressedMouseMove.time||t.hc()}jd(){this.Zd()}Td(){this.op.N().handleScale.axisDoubleClickReset.time&&this.op.Qt().un()}Sd(){this.Td()}Id(){this.op.Qt().N().handleScale.axisPressedMouseMove.time&&this.Xp(1)}_f(){this.Xp(0)}Rf(){return this.vp}im(){return this.Xv}sm(t,i,s){Ji(this.vp,t)||(this.vp=t,this.Mp=!0,this.Rp.resizeCanvasElement(t),this.Dp.resizeCanvasElement(t),this.Mp=!1,this.yf.style.width=`${t.width}px`,this.yf.style.height=`${t.height}px`,this.Xv.p(t)),null!==this.jv&&this.jv.Op(Ki({width:i,height:t.height})),null!==this.Yv&&this.Yv.Op(Ki({width:s,height:t.height}))}nm(){const t=this.rm();return Math.ceil(t.S+t.C+t.P+t.A+t.V+t.hm)}Pt(){this.op.Qt().It().Dl()}Df(){return this.Rp.bitmapSize}Ef(t,i,s){const n=this.Df();n.width>0&&n.height>0&&t.drawImage(this.Rp.canvasElement,i,s)}Fp(t){if(0===t)return;const i={colorSpace:this.Cs.colorSpace};if(1!==t){this.Rp.applySuggestedBitmapSize();const s=ns(this.Rp,i);null!==s&&(s.useBitmapCoordinateSpace((t=>{this.Hp(t),this.$p(t),this.lm(s,Ls)})),this.jp(s),this.lm(s,Bs)),null!==this.jv&&this.jv.Fp(t),null!==this.Yv&&this.Yv.Fp(t)}this.Dp.applySuggestedBitmapSize();const s=ns(this.Dp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.am([...this.op.Qt().Ys(),this.op.Qt().ju()],s),this.lm(s,As))}lm(t,i){const s=this.op.Qt().Ys();for(const n of s)Cs(i,(i=>xs(i,t,!1,void 0)),n,void 0);for(const n of s)Cs(i,(i=>Ss(i,t,!1,void 0)),n,void 0)}Hp({context:t,bitmapSize:i}){z(t,0,0,i.width,i.height,this.op.Qt().Mc())}$p({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.op.N().timeScale.borderVisible){t.fillStyle=this.om();const n=Math.max(1,Math.floor(this.rm().S*s));t.fillRect(0,0,i.width,n)}}jp(t){const i=this.op.Qt().It(),s=i.Dl();if(!s||0===s.length)return;const n=this.jo.maxTickMarkWeight(s),e=this.rm(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.om(),t.fillStyle=this.om();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const l=Math.round(e.C*n);for(let n=s.length;n--;){const e=Math.round(s[n].coord*i);t.rect(e-h,0,r,l)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.S+e.C+e.A+e.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this.Ap();for(const e of s)if(e.weight=n){const s=e.needAlignCoordinate?this._m(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}}))}_m(t,i,s){const n=this.wp.Ei(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.vp.width&&(i-=Math.abs(this.vp.width-(r+n))),i}am(t,i){const s=this.rm();for(const n of t)for(const t of n.us())t.kt().nt(i,s)}om(){return this.op.N().timeScale.borderColor}H(){return this.Cs.textColor}F(){return this.Cs.fontSize}Ap(){return g(this.F(),this.Cs.fontFamily)}um(){return g(this.F(),this.Cs.fontFamily,"bold")}rm(){null===this.M&&(this.M={S:1,L:NaN,A:NaN,V:NaN,Ji:NaN,C:5,P:NaN,T:"",Ki:new tt,hm:0});const t=this.M,i=this.Ap();if(t.T!==i){const s=this.F();t.P=s,t.T=i,t.A=3*s/12,t.V=3*s/12,t.Ji=9*s/12,t.L=0,t.hm=4*s/12,t.Ki.En()}return this.M}Xp(t){this.yf.style.cursor=1===t?"ew-resize":"default"}Jv(){const t=this.op.Qt(),i=t.N();i.leftPriceScale.visible||null===this.jv||(this.qv.removeChild(this.jv.kf()),this.jv.m(),this.jv=null),i.rightPriceScale.visible||null===this.Yv||(this.Gv.removeChild(this.Yv.kf()),this.Yv.m(),this.Yv=null);const s={uc:this.op.Qt().uc()},n=()=>i.leftPriceScale.borderVisible&&t.It().N().borderVisible,e=()=>t.Mc();i.leftPriceScale.visible&&null===this.jv&&(this.jv=new zs("left",i,s,n,e),this.qv.appendChild(this.jv.kf())),i.rightPriceScale.visible&&null===this.Yv&&(this.Yv=new zs("right",i,s,n,e),this.Gv.appendChild(this.Yv.kf()))}}const Ns=!!es&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!es&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Fs{constructor(t,i,s){var n;this.dm=[],this.fm=[],this.pm=0,this.Yl=0,this.so=0,this.vm=0,this.wm=0,this.gm=null,this.bm=!1,this.iv=new o,this.sv=new o,this.Du=new o,this.Mm=null,this.xm=null,this.ap=t,this.Cs=i,this.jo=s,this.rp=document.createElement("div"),this.rp.classList.add("tv-lightweight-charts"),this.rp.style.overflow="hidden",this.rp.style.direction="ltr",this.rp.style.width="100%",this.rp.style.height="100%",(n=this.rp).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.Sm=document.createElement("table"),this.Sm.setAttribute("cellspacing","0"),this.rp.appendChild(this.Sm),this.Cm=this.ym.bind(this),Ws(this.Cs)&&this.Pm(!0),this.ts=new Vi(this.Vu.bind(this),this.Cs,s),this.Qt().Yu().i(this.Tm.bind(this),this),this.km=new Os(this,this.jo),this.Sm.appendChild(this.km.kf());const e=i.autoSize&&this.Rm();let r=this.Cs.width,h=this.Cs.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.Dm(r,h),this.Em(),t.appendChild(this.rp),this.Vm(),this.ts.It().fu().i(this.ts.Vh.bind(this.ts),this),this.ts.co().i(this.ts.Vh.bind(this.ts),this)}Qt(){return this.ts}N(){return this.Cs}xf(){return this.dm}zm(){return this.km}m(){this.Pm(!1),0!==this.pm&&window.cancelAnimationFrame(this.pm),this.ts.Yu().u(this),this.ts.It().fu().u(this),this.ts.co().u(this),this.ts.m();for(const t of this.dm)this.Sm.removeChild(t.kf()),t.Tv().u(this),t.kv().u(this),t.m();this.dm=[];for(const t of this.fm)this.Im(t);this.fm=[],l(this.km).m(),null!==this.rp.parentElement&&this.rp.parentElement.removeChild(this.rp),this.Du.m(),this.iv.m(),this.sv.m(),this.Bm()}Dm(t,i,s=!1){if(this.Yl===i&&this.so===t)return;const n=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return Ki({width:i-i%2,height:s-s%2})}(Ki({width:t,height:i}));this.Yl=n.height,this.so=n.width;const e=this.Yl+"px",r=this.so+"px";l(this.rp).style.height=e,l(this.rp).style.width=r,this.Sm.style.height=e,this.Sm.style.width=r,s?this.Am(Z.wn(),performance.now()):this.ts.Vh()}Fp(t){void 0===t&&(t=Z.wn());for(let i=0;i{t.Pt()}))}Om(t){(void 0!==t.autoSize||!this.Mm||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.Mm&&this.Rm(),!1===t.autoSize&&null!==this.Mm&&this.Bm(),t.autoSize||void 0===t.width&&void 0===t.height||this.Dm(t.width||this.so,t.height||this.Yl))}Fm(t){let i=0,s=0;const n=this.dm[0],e=(i,s)=>{let n=0;for(let e=0;e{l("left"===i?this.km.Qv():this.km.tm()).Ef(l(t),s,n)};if(this.Cs.timeScale.visible){const i=this.km.Df();if(null!==t){let e=0;this.Hm()&&(r("left",e,s),e=l(n.Bv()).Df().width),this.km.Ef(t,e,s),e+=i.width,this.$m()&&r("right",e,s)}s+=i.height}return Ki({width:i,height:s})}Xm(){let t=0,i=0,s=0;for(const n of this.dm)this.Hm()&&(i=Math.max(i,l(n.Bv()).Bp(),this.Cs.leftPriceScale.minimumWidth)),this.$m()&&(s=Math.max(s,l(n.Av()).Bp(),this.Cs.rightPriceScale.minimumWidth)),t+=n.do();i=ls(i),s=ls(s);const n=this.so,e=this.Yl,r=Math.max(n-i-s,0),h=1*this.fm.length,a=this.Cs.timeScale.visible;let o=a?Math.max(this.km.nm(),this.Cs.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e{t.mv()})),3===this.gm?.sn()&&(this.gm.pn(t),this.Gm(),this.Km(this.gm),this.Jm(this.gm,i),t=this.gm,this.gm=null)),this.Fp(t)}Jm(t,i){for(const s of t.fn())this.vn(s,i)}Km(t){const i=this.ts.$s();for(let s=0;s{if(this.bm=!1,this.pm=0,null!==this.gm){const i=this.gm;this.gm=null,this.Am(i,t);for(const s of i.fn())if(5===s.hn&&!s.Wt._u(t)){this.Qt().an(s.Wt);break}}})))}Gm(){this.Em()}Im(t){this.Sm.removeChild(t.kf()),t.m()}Em(){const t=this.ts.$s(),i=t.length,s=this.dm.length;for(let t=i;t0){const t=new ps(this,n-1,n);this.fm.push(t),this.Sm.insertBefore(t.kf(),this.km.kf())}this.Sm.insertBefore(i.kf(),this.km.kf())}for(let s=0;s{const s=i.Xs().Nr(t);null!==s&&e.set(i,s)}))}let r;if(null!==t){const i=this.ts.It().ss(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().Wu(),l=null!==h&&h.No instanceof Ht?h.No:void 0,a=null!==h&&void 0!==h.Fo?h.Fo.Zn:void 0,o=this.sw(n);return{nw:r,ke:t??void 0,ew:i??void 0,rw:-1!==o?o:void 0,hw:l,lw:e,aw:a,ow:s??void 0}}sw(t){let i=-1;if(t)i=this.dm.indexOf(t);else{const t=this.Qt().ju().Hs();null!==t&&(i=this.Qt().$s().indexOf(t))}return i}Qm(t,i,s,n){this.iv.p((()=>this.iw(i,s,n,t)))}tw(t,i,s,n){this.sv.p((()=>this.iw(i,s,n,t)))}Tm(t,i,s){this.jm(this.Qt().Wu()?.Ho??null),this.Du.p((()=>this.iw(t,i,s)))}Vm(){const t=this.Cs.timeScale.visible?"":"none";this.km.kf().style.display=t}Hm(){return this.dm[0].Nf().So().N().visible}$m(){return this.dm[0].Nf().Co().N().visible}Rm(){return"ResizeObserver"in window&&(this.Mm=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.Dm(i.contentRect.width,i.contentRect.height)})),this.Mm.observe(this.ap,{box:"border-box"}),!0)}Bm(){null!==this.Mm&&this.Mm.disconnect(),this.Mm=null}}function Ws(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Hs(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function $s(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.color&&(r.R=s.color),r}function Us(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.lineColor&&(r.vt=s.lineColor),void 0!==s.topColor&&(r.vr=s.topColor),void 0!==s.bottomColor&&(r.mr=s.bottomColor),r}function js(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],nw:n};return void 0!==s.topLineColor&&(r.wr=s.topLineColor),void 0!==s.bottomLineColor&&(r.gr=s.bottomLineColor),void 0!==s.topFillColor1&&(r.br=s.topFillColor1),void 0!==s.topFillColor2&&(r.Mr=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.Sr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.Cr=s.bottomFillColor2),r}function Ys(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],nw:n};return void 0!==s.color&&(e.R=s.color),e}function Zs(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],nw:n};return void 0!==s.color&&(e.R=s.color),void 0!==s.borderColor&&(e.Ht=s.borderColor),void 0!==s.wickColor&&(e.pr=s.wickColor),e}function Xs(t,i,s,n,e){const r=h(e)(s),l=Math.max(...r),a=Math.min(...r),o=r[r.length-1],_=[o,l,a,o],{time:u,color:c,...d}=s;return{ke:i,wt:t,Wt:_,nw:n,ie:d,R:c}}function qs(t){return void 0!==t.Wt}function Gs(t,i){return void 0!==i.customValues&&(t._w=i.customValues),t}function Ks(t){return(i,s,n,e,r,h)=>function(t,i){return i?i(t):void 0===(s=t).open&&void 0===s.value;var s}(n,h)?Gs({wt:i,ke:s,nw:e},n):Gs(t(i,s,n,e,r),n)}function Js(t){return{Candlestick:Ks(Zs),Bar:Ks(Ys),Area:Ks(Us),Baseline:Ks(js),Histogram:Ks($s),Line:Ks($s),Custom:Ks(Xs)}[t]}function Qs(t){return{ke:0,uw:new Map,Wh:t}}function tn(t,i){if(void 0!==t&&0!==t.length)return{cw:i.key(t[0].wt),dw:i.key(t[t.length-1].wt)}}function sn(t){let i;return t.forEach((t=>{void 0===i&&(i=t.nw)})),h(i)}class nn{constructor(t){this.fw=new Map,this.pw=new Map,this.mw=new Map,this.ww=[],this.jo=t}m(){this.fw.clear(),this.pw.clear(),this.mw.clear(),this.ww=[]}gw(t,i){let s=0!==this.fw.size,n=!1;const e=this.pw.get(t);if(void 0!==e)if(1===this.pw.size)s=!1,n=!0,this.fw.clear();else for(const i of this.ww)i.pointData.uw.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i.map((t=>t.time)),e=this.jo.createConverterToInternalObj(i),h=Js(t.kr()),l=t.cl(),a=t.fl();r=i.map(((i,r)=>{const o=e(i.time),_=this.jo.key(o);let u=this.fw.get(_);void 0===u&&(u=Qs(o),this.fw.set(_,u),n=!0);const c=h(o,u.ke,i,s[r],l,a);return u.uw.set(t,c),c}))}s&&this.bw(),this.Mw(t,r);let h=-1;if(n){const t=[];this.fw.forEach((i=>{t.push({timeWeight:0,time:i.Wh,pointData:i,originalTime:sn(i.uw)})})),t.sort(((t,i)=>this.jo.key(t.time)-this.jo.key(i.time))),h=this.xw(t)}return this.Sw(t,h,function(t,i,s){const n=tn(t,s),e=tn(i,s);if(void 0!==n&&void 0!==e)return{Cw:!1,Bh:n.dw>=e.dw&&n.cw>=e.cw}}(this.pw.get(t),e,this.jo))}fc(t){return this.gw(t,[])}yw(t,i,s){const n=i;!function(t){void 0===t.nw&&(t.nw=t.time)}(n),this.jo.preprocessData(i);const e=this.jo.createConverterToInternalObj([i])(i.time),r=this.mw.get(t);if(!s&&void 0!==r&&this.jo.key(e)this.jo.key(t.time)this.jo.key(n.wt)?qs(i)&&s.push(i):qs(i)?s[s.length-1]=i:s.splice(-1,1),this.mw.set(t,i.wt)}Pw(t,i,s){const n=this.pw.get(t);if(void 0===n)return;const e=Mt(n,s,((t,i)=>t.ke{0!==i.length&&(t=Math.max(t,i[i.length-1].ke))})),t}Sw(t,i,s){const n={mo:new Map,It:{j_:this.kw()}};if(-1!==i)this.pw.forEach(((i,e)=>{n.mo.set(e,{ie:i,Rw:e===t?s:void 0})})),this.pw.has(t)||n.mo.set(t,{ie:[],Rw:s}),n.It.Dw=this.ww,n.It.Ew=i;else{const i=this.pw.get(t);n.mo.set(t,{ie:i||[],Rw:s})}return n}}function en(t,i){t.ke=i,t.uw.forEach((t=>{t.ke=i}))}function rn(t,i){return t.wt({...t,...this.Kn.kh().Rr(t.wt)})))}Ww(){this.Aw=null}Ow(){this.zw&&(this.Hw(),this.zw=!1),this.Iw&&(this.Fw(),this.Iw=!1),this.Vw&&(this.$w(),this.Vw=!1)}$w(){const t=this.Kn.Ft(),i=this.Jn.It();if(this.Ww(),i.Xi()||t.Xi())return;const s=i.Ce();if(null===s)return;if(0===this.Kn.Xs().Br())return;const n=this.Kn.At();null!==n&&(this.Aw=function(t,i,s){const n=i.Hh(),e=i.Mi(),r=Mt(t,n,rn),h=xt(t,e,hn);if(!s)return{from:r,to:h};let l=r,a=h;return r>0&&r=n&&(l=r-1),h>0&&h{const s=t.At();return null===s?null:t.Ft().Nt(i,s.Wt)}))}dl(t){return this.ih.priceValueBuilder(t)}pl(t){return this.ih.isWhitespace(t)}Hw(){const t=this.Kn.kh();this.Bw=this.Kn.Xs().Wr().map((i=>({wt:i.ke,_t:NaN,...t.Rr(i.ke),Zw:i.ie})))}Uw(t,i){i.Y_(this.Bw,m(this.Aw))}jw(){this.ih.update({bars:this.Bw.map(_n),barSpacing:this.Jn.It().J_(),visibleRange:this.Aw},this.Kn.N())}}function _n(t){return{x:t._t,time:t.wt,originalData:t.Zw,barColor:t.ur}}const un={color:"#2196f3"},cn=(t,i,s)=>{const n=a(s);return new on(t,i,n)};function dn(t){const i={value:t.Wt[3],time:t.nw};return void 0!==t._w&&(i.customValues=t._w),i}function fn(t){const i=dn(t);return void 0!==t.R&&(i.color=t.R),i}function pn(t){const i=dn(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.vr&&(i.topColor=t.vr),void 0!==t.mr&&(i.bottomColor=t.mr),i}function vn(t){const i=dn(t);return void 0!==t.wr&&(i.topLineColor=t.wr),void 0!==t.gr&&(i.bottomLineColor=t.gr),void 0!==t.br&&(i.topFillColor1=t.br),void 0!==t.Mr&&(i.topFillColor2=t.Mr),void 0!==t.Sr&&(i.bottomFillColor1=t.Sr),void 0!==t.Cr&&(i.bottomFillColor2=t.Cr),i}function mn(t){const i={open:t.Wt[0],high:t.Wt[1],low:t.Wt[2],close:t.Wt[3],time:t.nw};return void 0!==t._w&&(i.customValues=t._w),i}function wn(t){const i=mn(t);return void 0!==t.R&&(i.color=t.R),i}function gn(t){const i=mn(t),{R:s,Ht:n,pr:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}function bn(t){return{Area:pn,Line:fn,Baseline:vn,Histogram:fn,Bar:wn,Candlestick:gn,Custom:Mn}[t]}function Mn(t){const i=t.nw;return{...t.ie,time:i}}const xn={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},Sn={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Cn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:w,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},yn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},Pn={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function Tn(){return{width:0,height:0,autoSize:!1,layout:Cn,crosshair:xn,grid:Sn,overlayPriceScales:{...yn},leftPriceScale:{...yn,visible:!1},rightPriceScale:{...yn,visible:!0},timeScale:Pn,localization:{locale:es?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class kn{constructor(t,i,s){this.bf=t,this.Xw=i,this.qw=s??0}applyOptions(t){this.bf.Qt().$u(this.Xw,t,this.qw)}options(){return this.Yi().N()}width(){return Y(this.Xw)?this.bf.Wm(this.Xw):0}Yi(){return l(this.bf.Qt().Uu(this.Xw,this.qw)).Ft}}class Rn{constructor(t,i,s,n){this.bf=t,this.yt=s,this.Gw=i,this.Kw=n}getHeight(){return this.yt.Ut()}setHeight(t){const i=this.bf.Qt(),s=i.Sc(this.yt);i.qu(s,t)}paneIndex(){return this.bf.Qt().Sc(this.yt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&tthis.Gw(t)))??[]}getHTMLElement(){return this.bf.xf()[this.paneIndex()].kf()}attachPrimitive(t){this.yt._l(t),t.attached&&t.attached({chart:this.Kw,requestUpdate:()=>this.yt.Qt().Vh()})}detachPrimitive(t){this.yt.ul(t)}priceScale(t){if(null===this.yt.uo(t))throw new Error(`Cannot find price scale with id: ${t}`);return new kn(this.bf,t,this.paneIndex())}}const Dn={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class En{constructor(t){this.tr=t}applyOptions(t){this.tr.rr(t)}options(){return this.tr.N()}Jw(){return this.tr}}class Vn{constructor(t,i,s,n,e,r){this.Qw=new o,this.Kn=t,this.tg=i,this.ig=s,this.jo=e,this.Kw=n,this.sg=r}m(){this.Qw.m()}priceFormatter(){return this.Kn.el()}priceToCoordinate(t){const i=this.Kn.At();return null===i?null:this.Kn.Ft().Nt(t,i.Wt)}coordinateToPrice(t){const i=this.Kn.At();return null===i?null:this.Kn.Ft().Ts(t,i.Wt)}barsInLogicalRange(t){if(null===t)return null;const i=new Ci(new Mi(t.from,t.to)).a_(),s=this.Kn.Xs();if(s.Xi())return null;const n=s.Nr(i.Hh(),1),e=s.Nr(i.Mi(),-1),r=l(s.Ar()),h=l(s.Zs());if(null!==n&&null!==e&&n.ke>e.ke)return{barsBefore:t.from-r,barsAfter:h-t.to};const a={barsBefore:null===n||n.ke===r?t.from-r:n.ke-r,barsAfter:null===e||e.ke===h?h-t.to:h-e.ke};return null!==n&&null!==e&&(a.from=n.nw,a.to=e.nw),a}setData(t){this.jo,this.Kn.kr(),this.tg.ng(this.Kn,t),this.eg("full")}update(t,i=!1){this.Kn.kr(),this.tg.rg(this.Kn,t,i),this.eg("update")}dataByIndex(t,i){const s=this.Kn.Xs().Nr(t,i);if(null===s)return null;return bn(this.seriesType())(s)}data(){const t=bn(this.seriesType());return this.Kn.Xs().Wr().map((i=>t(i)))}subscribeDataChanged(t){this.Qw.i(t)}unsubscribeDataChanged(t){this.Qw._(t)}applyOptions(t){this.Kn.rr(t)}options(){return p(this.Kn.N())}priceScale(){return this.ig.priceScale(this.Kn.Ft().ml(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(Dn),t),s=this.Kn.Lh(i);return new En(s)}removePriceLine(t){this.Kn.Oh(t.Jw())}priceLines(){return this.Kn.Nh().map((t=>new En(t)))}seriesType(){return this.Kn.kr()}attachPrimitive(t){this.Kn._l(t),t.attached&&t.attached({chart:this.Kw,series:this,requestUpdate:()=>this.Kn.Qt().Vh(),horzScaleBehavior:this.jo})}detachPrimitive(t){this.Kn.ul(t),t.detached&&t.detached(),this.Kn.Qt().Vh()}getPane(){const t=this.Kn,i=l(this.Kn.Qt().Wn(t));return this.sg(i)}moveToPane(t){this.Kn.Qt().gc(this.Kn,t)}eg(t){this.Qw.v()&&this.Qw.p(t)}}class zn{constructor(t,i,s){this.hg=new o,this.w_=new o,this.Xv=new o,this.ts=t,this._h=t.It(),this.km=i,this._h.cu().i(this.lg.bind(this)),this._h.du().i(this.ag.bind(this)),this.km.im().i(this.og.bind(this)),this.jo=s}m(){this._h.cu().u(this),this._h.du().u(this),this.km.im().u(this),this.hg.m(),this.w_.m(),this.Xv.m()}scrollPosition(){return this._h.tu()}scrollToPosition(t,i){i?this._h.ou(t,1e3):this.ts.dn(t)}scrollToRealTime(){this._h.au()}getVisibleRange(){const t=this._h.L_();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.jo.convertHorzItemToInternal(t.from),to:this.jo.convertHorzItemToInternal(t.to)},s=this._h.W_(i);this.ts.mc(s)}getVisibleLogicalRange(){const t=this._h.A_();return null===t?null:{from:t.Hh(),to:t.Mi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.ts.mc(t)}resetTimeScale(){this.ts.un()}fitContent(){this.ts.vu()}logicalToCoordinate(t){const i=this.ts.It();return i.Xi()?null:i.jt(t)}coordinateToLogical(t){return this._h.Xi()?null:this._h.Z_(t)}timeToIndex(t,i){const s=this.jo.convertHorzItemToInternal(t);return this._h.z_(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this._h.jt(i)}coordinateToTime(t){const i=this.ts.It(),s=i.Z_(t),n=i.ss(s);return null===n?null:n.originalTime}width(){return this.km.Rf().width}height(){return this.km.Rf().height}subscribeVisibleTimeRangeChange(t){this.hg.i(t)}unsubscribeVisibleTimeRangeChange(t){this.hg._(t)}subscribeVisibleLogicalRangeChange(t){this.w_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.w_._(t)}subscribeSizeChange(t){this.Xv.i(t)}unsubscribeSizeChange(t){this.Xv._(t)}applyOptions(t){this._h.rr(t)}options(){return{...p(this._h.N()),barSpacing:this._h.J_()}}lg(){this.hg.v()&&this.hg.p(this.getVisibleRange())}ag(){this.w_.v()&&this.w_.p(this.getVisibleLogicalRange())}og(t){this.Xv.p(t.width,t.height)}}function In(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=function(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}(i.minMove))}function Bn(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class An{constructor(t,i,s){this._g=new Map,this.ug=new Map,this.cg=new o,this.dg=new o,this.fg=new o,this.Pu=new WeakMap,this.pg=new nn(i);const n=void 0===s?p(Tn()):_(p(Tn()),Bn(s));this.vg=i,this.bf=new Fs(t,n,i),this.bf.Tv().i((t=>{this.cg.v()&&this.cg.p(this.mg(t()))}),this),this.bf.kv().i((t=>{this.dg.v()&&this.dg.p(this.mg(t()))}),this),this.bf.Yu().i((t=>{this.fg.v()&&this.fg.p(this.mg(t()))}),this);const e=this.bf.Qt();this.wg=new zn(e,this.bf.zm(),this.vg)}remove(){this.bf.Tv().u(this),this.bf.kv().u(this),this.bf.Yu().u(this),this.wg.m(),this.bf.m(),this._g.clear(),this.ug.clear(),this.cg.m(),this.dg.m(),this.fg.m(),this.pg.m()}resize(t,i,s){this.autoSizeActive()||this.bf.Dm(t,i,s)}addCustomSeries(t,i={},s=0){const n=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...un,...t.defaultOptions()},gg:cn,bg:t}))(a(t));return this.Mg(n,i,s)}addSeries(t,i={},s=0){return this.Mg(t,i,s)}removeSeries(t){const i=h(this._g.get(t)),s=this.pg.fc(i);this.bf.Qt().fc(i),this.xg(s),this._g.delete(t),this.ug.delete(i)}ng(t,i){this.xg(this.pg.gw(t,i))}rg(t,i,s){this.xg(this.pg.yw(t,i,s))}subscribeClick(t){this.cg.i(t)}unsubscribeClick(t){this.cg._(t)}subscribeCrosshairMove(t){this.fg.i(t)}unsubscribeCrosshairMove(t){this.fg._(t)}subscribeDblClick(t){this.dg.i(t)}unsubscribeDblClick(t){this.dg._(t)}priceScale(t,i=0){return new kn(this.bf,t,i)}timeScale(){return this.wg}applyOptions(t){this.bf.rr(Bn(t))}options(){return this.bf.N()}takeScreenshot(){return this.bf.Nm()}removePane(t){this.bf.Qt().Xu(t)}swapPanes(t,i){this.bf.Qt().Gu(t,i)}autoSizeActive(){return this.bf.Um()}chartElement(){return this.bf.zf()}panes(){return this.bf.Qt().$s().map((t=>this.Sg(t)))}paneSize(t=0){const i=this.bf.Zm(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const n=this._g.get(s);if(void 0===n)return;const e=this.bf.Qt().Wn(n);null!==e&&this.bf.Qt().ac(t,i,e)}clearCrosshairPosition(){this.bf.Qt().oc(!0)}horzBehaviour(){return this.vg}Mg(i,s={},n=0){r(void 0!==i.gg),In(s.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(s);const e=_(p(t),p(i.defaultOptions),s),h=i.gg,l=new Ht(this.bf.Qt(),i.type,e,h,i.bg);this.bf.Qt().cc(l,n);const a=new Vn(l,this,this,this,this.vg,(t=>this.Sg(t)));return this._g.set(a,l),this.ug.set(l,a),a}xg(t){const i=this.bf.Qt();i._c(t.It.j_,t.It.Dw,t.It.Ew),t.mo.forEach(((t,i)=>i.ht(t.ie,t.Rw))),i.It().k_(),i.K_()}Cg(t){return h(this.ug.get(t))}mg(t){const i=new Map;t.lw.forEach(((t,s)=>{const n=s.kr(),e=bn(n)(t);if("Custom"!==n)r(Hs(e));else{const t=s.fl();r(!t||!1===t(e))}i.set(this.Cg(s),e)}));const s=void 0!==t.hw&&this.ug.has(t.hw)?this.Cg(t.hw):void 0;return{time:t.nw,logical:t.ke,point:t.ew,paneIndex:t.rw,hoveredSeries:s,hoveredObjectId:t.aw,seriesData:i,sourceEvent:t.ow}}Sg(t){let i=this.Pu.get(t);return i||(i=new Rn(this.bf,(t=>this.Cg(t)),t,this),this.Pu.set(t,i)),i}}function Ln(t,i,s){const n=function(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}(t),e=new An(n,i,s);return i.setOptions(e.options()),e}function On(t,i){return Ln(t,new Gi,Gi.Nc(i))}class Nn extends ln{constructor(t,i){super(t,i,!0)}Uw(t,i,s){i.Y_(this.Bw,m(this.Aw)),t.Ra(this.Bw,s,m(this.Aw))}yg(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}Hw(){const t=this.Kn.kh();this.Bw=this.Kn.Xs().Wr().map((i=>{const s=i.Wt[3];return this.Pg(i.ke,s,t)}))}}function Fn(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const{context:l,horizontalPixelRatio:a,verticalPixelRatio:o}=t,_=i[n.from];let u=r(t,_),c=_;if(n.to-n.from<2){const i=e/2;l.beginPath();const s={_t:_._t-i,ut:_.ut},n={_t:_._t+i,ut:_.ut};l.moveTo(s._t*a,s.ut*o),l.lineTo(n._t*a,n.ut*o),h(t,u,s,n)}else{const e=(i,s)=>{h(t,u,c,s),l.beginPath(),u=i,c=s};let d=c;l.beginPath(),l.moveTo(_._t*a,_.ut*o);for(let h=n.from+1;h=n.from;--s){const n=i[s];if(n){const i=e(t,n);i!==a&&(l.beginPath(),null!==a&&l.fill(),l.fillStyle=i,a=i);const s=Math.round(n._t*r)+o,u=n.ut*h;l.moveTo(s,u),l.arc(s,u,_,0,2*Math.PI)}}l.fill()}(t,i,a,s,_)}}class Zn extends Yn{Dg(t,i){return i.vt}}class Xn extends Nn{constructor(){super(...arguments),this.Nw=new Zn}Pg(t,i,s){return{...this.yg(t,i),...s.Rr(t)}}jw(){const t=this.Kn.N(),i={ot:this.Bw,qt:t.lineStyle,kg:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Rg:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Aw,Tg:this.Jn.It().J_()};this.Nw.ht(i)}}const qn={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},gg:(t,i)=>new Xn(t,i)};function Gn(t,i,s,n,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:l}=i;r.lineTo(e._t*h,t*l),r.lineTo(n._t*h,t*l),r.closePath(),r.fillStyle=s,r.fill()}class Kn extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:s,Tg:e,ct:r,qt:h,kg:l}=this.rt,a=this.rt.Eg??(this.rt.Vg?0:t.mediaSize.height);if(null===s)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,n(o,h),o.lineWidth=1,Fn(t,i,l,s,e,this.zg.bind(this),Gn.bind(null,a))}}class Jn{Ig(t,i){const s=this.Bg,{Ag:n,Lg:e,Og:r,Ng:h,Eg:l,Fg:a,Wg:o}=i;if(void 0===this.Hg||void 0===s||s.Ag!==n||s.Lg!==e||s.Og!==r||s.Ng!==h||s.Eg!==l||s.Fg!==a||s.Wg!==o){const{verticalPixelRatio:s}=t,_=l||a>0?s:1,u=a*_,c=o===t.bitmapSize.height?o:o*_,d=(l??0)*_,f=t.context.createLinearGradient(0,u,0,c);if(f.addColorStop(0,n),null!=l){const t=ri((d-u)/(c-u),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.Hg=f,this.Bg=i}return this.Hg}}class Qn extends Kn{constructor(){super(...arguments),this.$g=new Jn}zg(t,i){const s=this.rt;return this.$g.Ig(t,{Ag:i.br,Lg:i.Mr,Og:i.Sr,Ng:i.Cr,Eg:s.Eg,Fg:s.Fg??0,Wg:s.Wg??t.bitmapSize.height})}}class te extends Yn{constructor(){super(...arguments),this.Ug=new Jn}Dg(t,i){const s=this.rt;return this.Ug.Ig(t,{Ag:i.wr,Lg:i.wr,Og:i.gr,Ng:i.gr,Eg:s.Eg,Fg:s.Fg??0,Wg:s.Wg??t.bitmapSize.height})}}class ie extends Nn{constructor(t,i){super(t,i),this.Nw=new C,this.jg=new Qn,this.Yg=new te,this.Nw.st([this.jg,this.Yg])}Pg(t,i,s){return{...this.yg(t,i),...s.Rr(t)}}jw(){const t=this.Kn.At();if(null===t)return;const i=this.Kn.N(),s=this.Kn.Ft().Nt(i.baseValue.price,t.Wt),n=this.Jn.It().J_();if(null===this.Aw||0===this.Bw.length)return;let e,r;if(i.relativeGradient){e=this.Bw[this.Aw.from].ut,r=this.Bw[this.Aw.from].ut;for(let t=this.Aw.from;tr&&(r=i.ut)}}this.jg.ht({ot:this.Bw,ct:i.lineWidth,qt:i.lineStyle,kg:i.lineType,Eg:s,Fg:e,Wg:r,Vg:!1,lt:this.Aw,Tg:n}),this.Yg.ht({ot:this.Bw,ct:i.lineWidth,qt:i.lineStyle,kg:i.lineVisible?i.lineType:void 0,Rg:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,Eg:s,Fg:e,Wg:r,lt:this.Aw,Tg:n})}}const se={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},gg:(t,i)=>new ie(t,i)};class ne extends y{constructor(){super(...arguments),this.Yt=null,this.Zg=0}ht(t){this.Yt=t}et(t){if(null===this.Yt||0===this.Yt.Xs.length||null===this.Yt.lt)return;const{horizontalPixelRatio:i}=t;if(this.Zg=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Yt.J_,i),this.Zg>=2){Math.floor(i)%2!=this.Zg%2&&this.Zg--}const s=this.Yt.Xs;this.Yt.Xg&&this.qg(t,s,this.Yt.lt),this.Yt.bi&&this.$p(t,s,this.Yt.lt);const n=this.Gg(i);(!this.Yt.bi||this.Zg>2*n)&&this.Kg(t,s,this.Yt.lt)}qg(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",l=Math.min(Math.floor(e),Math.floor(this.Yt.J_*e));l=Math.max(Math.floor(e),Math.min(l,this.Zg));const a=Math.floor(.5*l);let o=null;for(let t=s.from;t2*l)V(n,o,u,_-o+1,c-u+1,l);else{const t=_-o+1;n.fillRect(o,u,t,c-u+1)}a=_}}Kg(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const l=this.Gg(e);for(let t=s.from;to||n.fillRect(_,a,u-_+1,o-a+1)}}}class ee extends ln{constructor(t,i){super(t,i,!1)}Uw(t,i,s){i.Y_(this.Bw,m(this.Aw)),t.Ea(this.Bw,s,m(this.Aw))}Jg(t,i,s){return{wt:t,Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Zh:i.Wt[3],_t:NaN,Va:NaN,za:NaN,Ia:NaN,Ba:NaN}}Hw(){const t=this.Kn.kh();this.Bw=this.Kn.Xs().Wr().map((i=>this.Pg(i.ke,i,t)))}}class re extends ee{constructor(){super(...arguments),this.Nw=new ne}Pg(t,i,s){return{...this.Jg(t,i,s),...s.Rr(t)}}jw(){const t=this.Kn.N();this.Nw.ht({Xs:this.Bw,J_:this.Jn.It().J_(),Xg:t.wickVisible,bi:t.borderVisible,lt:this.Aw})}}const he={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},gg:(t,i)=>new re(t,i)},le={...t,color:"#2196f3"};export{se as BaselineSeries,he as CandlestickSeries,Di as ColorType,U as CrosshairMode,ki as LastPriceAnimationMode,qn as LineSeries,s as LineStyle,i as LineType,St as MismatchDirection,Ri as PriceLineSource,_i as PriceScaleMode,Ei as TickMarkType,Ti as TrackingModeExitMode,On as createChart,le as customSeriesDefaultOptions,zi as isBusinessDay,Ii as isUTCTimestamp}; diff --git a/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/types.d.ts b/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/types.d.ts index b77fd8c1e..6b7b7671e 100644 --- a/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/types.d.ts +++ b/websites/kibo.money/packages/lightweight-charts/v5.0.5-treeshaked/types.d.ts @@ -3,6 +3,7 @@ // import { CanvasRenderingTarget2D } from "fancy-canvas"; type CanvasRenderingTarget2D = any; +declare const baselineSeries: SeriesDefinition<"Baseline">; declare const candlestickSeries: SeriesDefinition<"Candlestick">; declare const lineSeries: SeriesDefinition<"Line">; export declare const customSeriesDefaultOptions: CustomSeriesOptions; @@ -4032,6 +4033,10 @@ export type UTCTimestamp = Nominal; */ export type VisiblePriceScaleOptions = PriceScaleOptions; -export { candlestickSeries as CandlestickSeries, lineSeries as LineSeries }; +export { + baselineSeries as BaselineSeries, + candlestickSeries as CandlestickSeries, + lineSeries as LineSeries, +}; export {}; diff --git a/websites/kibo.money/packages/lightweight-charts/wrapper.js b/websites/kibo.money/packages/lightweight-charts/wrapper.js index 4fad3fb37..4a18d8454 100644 --- a/websites/kibo.money/packages/lightweight-charts/wrapper.js +++ b/websites/kibo.money/packages/lightweight-charts/wrapper.js @@ -1,6 +1,6 @@ // @ts-check -/** @import {IChartApi, ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData} from './v5.0.5-treeshaked/types' */ +/** @import {IChartApi, ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, BaselineData, SeriesType} from './v5.0.5-treeshaked/types' */ /** * @typedef {[number, number, number, number]} OHLCTuple @@ -47,7 +47,7 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { autoSize: true, layout: { fontFamily: "Geist mono", - fontSize: 14, + fontSize: 13, background: { color: "transparent" }, attributionLogo: false, colorSpace: "display-p3", @@ -130,15 +130,18 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { * @param {VecsResources} args.vecsResources * @param {Owner | null} [args.owner] * @param {true} [args.fitContentOnResize] + * @param {{unit: Unit; blueprints: AnySeriesBlueprint[]}[]} [args.config] */ function createChartElement({ parent, signals, colors, utils, + id, vecsResources, owner: _owner, fitContentOnResize, + config, }) { let owner = _owner || signals.getOwner(); @@ -179,7 +182,7 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { * @param {ISeriesApi} series * @param {VecResource} valuesResource */ - function createSetDataEffect(series, valuesResource) { + function createSetFetchedDataEffect(series, valuesResource) { signals.runWithOwner(owner, () => signals.createEffect( () => [timeResource?.fetched(), valuesResource.fetched()], @@ -244,7 +247,7 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { }), ); - return { + const chart = { inner: () => ichart, /** * @param {Object} args @@ -272,12 +275,23 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { colors, utils, }); + + if (fitContentOnResize) { + ichart.applyOptions({ + handleScroll: false, + handleScale: false, + timeScale: { + minBarSpacing: 0.001, + }, + }); + } }, /** * @param {Object} args - * @param {VecId} args.vecId * @param {string} args.name * @param {Unit} args.unit + * @param {VecId} [args.vecId] + * @param {Accessor} [args.data] * @param {number} [args.paneIndex] * @param {boolean} [args.defaultActive] */ @@ -287,15 +301,12 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { unit, paneIndex: _paneIndex, defaultActive, + data, }) { const paneIndex = _paneIndex ?? 0; if (!ichart || !timeResource) throw Error("Chart not fully set"); - const valuesResource = vecsResources.getOrCreate(vecIndex, vecId); - valuesResource.fetch(); - activeResources.push(valuesResource); - const green = colors.green(); const red = colors.red(); const series = ichart.addSeries( @@ -311,31 +322,56 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { paneIndex, ); + let url = /** @type {string | undefined} */ (undefined); + + if (vecId) { + const valuesResource = vecsResources.getOrCreate(vecIndex, vecId); + valuesResource.fetch(); + activeResources.push(valuesResource); + createSetFetchedDataEffect(series, valuesResource); + + url = valuesResource.url; + } else if (data) { + signals.runWithOwner(owner, () => + signals.createEffect(data, (data) => { + series.setData(data); + }), + ); + } + legend.add({ series, name, defaultActive, colors: [colors.green, colors.red], - url: valuesResource.url, + url, + }); + + createPaneHeightObserver({ + ichart, + paneIndex, + signals, + utils, }); createPriceScaleSelectorIfNeeded({ ichart, paneIndex, + seriesType: "Candlestick", signals, + id, unit, utils, }); - createSetDataEffect(series, valuesResource); - return series; }, /** * @param {Object} args - * @param {VecId} args.vecId * @param {string} args.name * @param {Unit} args.unit + * @param {Accessor} [args.data] + * @param {VecId} [args.vecId] * @param {Color} [args.color] * @param {number} [args.paneIndex] * @param {boolean} [args.defaultActive] @@ -347,15 +383,12 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { color, paneIndex: _paneIndex, defaultActive, + data, }) { if (!ichart || !timeResource) throw Error("Chart not fully set"); const paneIndex = _paneIndex ?? 0; - const valuesResource = vecsResources.getOrCreate(vecIndex, vecId); - valuesResource.fetch(); - activeResources.push(valuesResource); - color ||= colors.orange; const series = ichart.addSeries( @@ -369,16 +402,34 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { paneIndex, ); + let url = /** @type {string | undefined} */ (undefined); + + if (vecId) { + const valuesResource = vecsResources.getOrCreate(vecIndex, vecId); + valuesResource.fetch(); + activeResources.push(valuesResource); + createSetFetchedDataEffect(series, valuesResource); + + url = valuesResource.url; + } else if (data) { + signals.runWithOwner(owner, () => + signals.createEffect(data, (data) => { + series.setData(data); + ichart + ?.timeScale() + .setVisibleLogicalRange({ from: -1, to: data.length }); + }), + ); + } + legend.add({ series, colors: [color], name, defaultActive, - url: valuesResource.url, + url, }); - createSetDataEffect(series, valuesResource); - createPaneHeightObserver({ ichart, paneIndex, @@ -390,6 +441,94 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { ichart, paneIndex, signals, + seriesType: "Line", + id, + unit, + utils, + }); + + return series; + }, + /** + * @param {Object} args + * @param {string} args.name + * @param {Unit} args.unit + * @param {Accessor} [args.data] + * @param {VecId} [args.vecId] + * @param {number} [args.paneIndex] + * @param {boolean} [args.defaultActive] + */ + addBaselineSeries({ + vecId, + name, + unit, + paneIndex: _paneIndex, + defaultActive, + data, + }) { + if (!ichart || !timeResource) throw Error("Chart not fully set"); + + const paneIndex = _paneIndex ?? 0; + + const series = ichart.addSeries( + /** @type {SeriesDefinition<'Baseline'>} */ (lc.BaselineSeries), + { + lineWidth: /** @type {any} */ (1.5), + visible: defaultActive !== false, + topLineColor: colors.green(), + bottomLineColor: colors.red(), + baseValue: { + price: 0, + }, + baseLineStyle: 0, + baseLineWidth: 1, + baseLineVisible: true, + lineVisible: true, + }, + paneIndex, + ); + + let url = /** @type {string | undefined} */ (undefined); + + if (vecId) { + const valuesResource = vecsResources.getOrCreate(vecIndex, vecId); + valuesResource.fetch(); + activeResources.push(valuesResource); + createSetFetchedDataEffect(series, valuesResource); + + url = valuesResource.url; + } else if (data) { + signals.runWithOwner(owner, () => + signals.createEffect(data, (data) => { + series.setData(data); + ichart + ?.timeScale() + .setVisibleLogicalRange({ from: -1, to: data.length }); + }), + ); + } + + legend.add({ + series, + colors: [colors.green, colors.red], + name, + defaultActive, + url, + }); + + createPaneHeightObserver({ + ichart, + paneIndex, + signals, + utils, + }); + + createPriceScaleSelectorIfNeeded({ + ichart, + paneIndex, + signals, + seriesType: "Baseline", + id, unit, utils, }); @@ -410,6 +549,41 @@ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { legend.reset(); }, }; + + config?.forEach(({ unit, blueprints }, paneIndex) => { + chart.create({ index: /** @satisfies {Dateindex} */ (1) }); + + blueprints.forEach((blueprint) => { + if (blueprint.type === "Candlestick") { + chart.addCandlestickSeries({ + name: blueprint.title, + unit, + data: blueprint.data, + defaultActive: blueprint.defaultActive, + paneIndex, + }); + } else if (blueprint.type === "Baseline") { + chart.addBaselineSeries({ + name: blueprint.title, + unit, + data: blueprint.data, + defaultActive: blueprint.defaultActive, + paneIndex, + }); + } else { + chart.addLineSeries({ + name: blueprint.title, + unit, + data: blueprint.data, + defaultActive: blueprint.defaultActive, + paneIndex, + color: blueprint.color, + }); + } + }); + }); + + return chart; } return { @@ -678,7 +852,6 @@ function createPaneHeightObserver({ ichart, paneIndex, signals, utils }) { if (!paneIndex) return; const owner = signals.getOwner(); - if (!owner) throw Error("Expect owner"); const one = "1"; @@ -729,6 +902,8 @@ function createPaneHeightObserver({ ichart, paneIndex, signals, utils }) { * @param {Object} args * @param {IChartApi} args.ichart * @param {Unit} args.unit + * @param {string} args.id + * @param {SeriesType} args.seriesType * @param {number} args.paneIndex * @param {Signals} args.signals * @param {Utilities} args.utils @@ -737,11 +912,12 @@ function createPriceScaleSelectorIfNeeded({ ichart, unit, paneIndex, + id, + seriesType, signals, utils, }) { const owner = signals.getOwner(); - if (!owner) throw Error("Expect owner"); setTimeout( () => { @@ -759,16 +935,20 @@ function createPriceScaleSelectorIfNeeded({ return; } + console.log(id); + const choices = /**@type {const} */ (["lin", "log"]); /** @typedef {(typeof choices)[number]} Choices */ const serializedValue = signals.createSignal( - /** @satisfies {Choices} */ (paneIndex ? "lin" : "log"), + /** @satisfies {Choices} */ ( + unit === "US Dollars" && seriesType !== "Baseline" ? "log" : "lin" + ), { save: { ...utils.serde.string, - keyPrefix: "charts", - key: `price-scale-${paneIndex}`, + keyPrefix: "", + key: `${id}-price-scale-${paneIndex}`, }, }, ); @@ -777,7 +957,7 @@ function createPriceScaleSelectorIfNeeded({ title: unit, selected: serializedValue(), choices: choices, - id: unit, + id: `${id}-${unit.replace(" ", "-")}`, signals, }); @@ -789,6 +969,7 @@ function createPriceScaleSelectorIfNeeded({ const element = window.document.createElement(tagName); element.dataset.size = "xs"; + element.id = `${id}-price-scale-${paneIndex}`; element.append(field); const mode = signals.createMemo(() => { diff --git a/websites/kibo.money/scripts/chart.js b/websites/kibo.money/scripts/chart.js index 163a0c80d..1af3f13b9 100644 --- a/websites/kibo.money/scripts/chart.js +++ b/websites/kibo.money/scripts/chart.js @@ -35,7 +35,7 @@ export function init({ parent: elements.charts, signals, colors, - id: "chart", + id: "charts", utils, vecsResources, }); @@ -174,6 +174,7 @@ function createIndexSelector({ elements, signals, utils }) { const fieldset = window.document.createElement("fieldset"); fieldset.append(indexesField); + fieldset.dataset.size = "sm"; elements.charts.append(fieldset); const index = signals.createMemo( diff --git a/websites/kibo.money/scripts/main.js b/websites/kibo.money/scripts/main.js index 5b56f6d85..4851f6b9e 100644 --- a/websites/kibo.money/scripts/main.js +++ b/websites/kibo.money/scripts/main.js @@ -1,7 +1,7 @@ // @ts-check /** - * @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Unit } from "./options" + * @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Unit, AnySeriesBlueprint } from "./options" * @import {Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple} from "../packages/lightweight-charts/wrapper" * @import * as _ from "../packages/ufuzzy/v1.0.14/types" * @import { createChart as CreateClassicChart, LineStyleOptions, DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, ISeriesApi, Time, LineData, LogicalRange, SeriesType, BaselineStyleOptions, SeriesOptionsCommon, BaselineData, CandlestickStyleOptions } from "../packages/lightweight-charts/v5.0.5-treeshaked/types" @@ -952,11 +952,22 @@ function createUtils() { }, /** * @param {Date} date - * @returns {string} */ toString(date) { return date.toJSON().split("T")[0]; }, + /** + * @param {Date} date + */ + toDateIndex(date) { + if ( + date.getUTCFullYear() === 2009 && + date.getUTCMonth() === 0 && + date.getUTCDate() === 3 + ) + return 0; + return this.differenceBetween(date, new Date("2009-01-09")); + }, /** * @param {Time} time */ @@ -988,7 +999,6 @@ function createUtils() { /** * @param {Date} date1 * @param {Date} date2 - * @returns */ differenceBetween(date1, date2) { return Math.abs(date1.valueOf() - date2.valueOf()) / this.ONE_DAY_IN_MS; diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index 461018510..b9905e32a 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -23,7 +23,6 @@ * * @typedef {Object} BaseSeriesBlueprint * @property {string} title - * @property {VecId} key * @property {boolean} [defaultActive] * * @typedef {Object} BaselineSeriesBlueprintSpecific @@ -49,6 +48,8 @@ * * @typedef {BaselineSeriesBlueprint | CandlestickSeriesBlueprint | LineSeriesBlueprint} AnySeriesBlueprint * + * @typedef {AnySeriesBlueprint & {key: VecId}} AnyFetchedSeriesBlueprint + * * @typedef {Object} PartialOption * @property {string} name * @@ -61,8 +62,8 @@ * @property {"chart"} [kind] * @property {Unit} [unit] * @property {string} [title] - * @property {AnySeriesBlueprint[]} [top] - * @property {AnySeriesBlueprint[]} [bottom] + * @property {AnyFetchedSeriesBlueprint[]} [top] + * @property {AnyFetchedSeriesBlueprint[]} [bottom] * @typedef {PartialOption & PartialChartOptionSpecific} PartialChartOption * @typedef {Required & ProcessedOptionAddons} ChartOption * diff --git a/websites/kibo.money/scripts/simulation.js b/websites/kibo.money/scripts/simulation.js index 4c7610852..289c496cf 100644 --- a/websites/kibo.money/scripts/simulation.js +++ b/websites/kibo.money/scripts/simulation.js @@ -263,7 +263,8 @@ export function init({ * @param {string} param0.text */ function createColoredSpan({ color, text }) { - return `${text}`; + return `${text}`; } parametersElement.append( @@ -550,24 +551,19 @@ export function init({ parent: resultsElement, signals, colors, - id: `simulation-0`, + id: `result`, fitContentOnResize: true, + vecsResources, utils, config: [ { unit: "US Dollars", - config: [ + blueprints: [ { - title: "Fees Paid", + title: "Bitcoin Value", type: "Line", - color: colors.rose, - data: totalFeesPaidData, - }, - { - title: "Dollars Left", - type: "Line", - color: colors.offDollars, - data: dollarsLeftData, + color: colors.amber, + data: bitcoinValueData, }, { title: "Dollars Converted", @@ -576,10 +572,18 @@ export function init({ data: totalInvestedAmountData, }, { - title: "Bitcoin Value", + title: "Dollars Left", type: "Line", - color: colors.amber, - data: bitcoinValueData, + color: colors.offDollars, + data: dollarsLeftData, + defaultActive: false, + }, + { + title: "Fees Paid", + type: "Line", + color: colors.rose, + data: totalFeesPaidData, + defaultActive: false, }, ], }, @@ -590,13 +594,14 @@ export function init({ parent: resultsElement, signals, colors, - id: `simulation-1`, + id: `bitcoin`, fitContentOnResize: true, + vecsResources, utils, config: [ { - unit: "US Dollars", - config: [ + unit: "Bitcoin", + blueprints: [ { title: "Bitcoin Stack", type: "Line", @@ -612,13 +617,14 @@ export function init({ parent: resultsElement, signals, colors, - id: `simulation-average-price`, + id: `average-price`, fitContentOnResize: true, + vecsResources, utils, config: [ { unit: "US Dollars", - config: [ + blueprints: [ { title: "Bitcoin Price", type: "Line", @@ -640,27 +646,18 @@ export function init({ parent: resultsElement, signals, colors, - id: `simulation-return-ratio`, + vecsResources, + id: `return-ratio`, fitContentOnResize: true, utils, config: [ { unit: "US Dollars", - config: [ + blueprints: [ { title: "Return Of Investment", type: "Baseline", data: resultData, - // TODO: Doesn't work for some reason - // options: { - // baseLineColor: "#888", - // baseLineVisible: true, - // baseLineWidth: 1, - // baseValue: { - // price: 0, - // type: "price", - // }, - // }, }, ], }, @@ -673,333 +670,336 @@ export function init({ colors, id: `simulation-profitability-ratios`, fitContentOnResize: true, + vecsResources, utils, owner, config: [ { unit: "Percentage", - config: [ - { - title: "Unprofitable Days Ratio", - type: "Line", - color: colors.red, - data: unprofitableDaysRatioData, - }, + blueprints: [ { title: "Profitable Days Ratio", type: "Line", color: colors.green, data: profitableDaysRatioData, }, + { + title: "Unprofitable Days Ratio", + type: "Line", + color: colors.red, + data: unprofitableDaysRatioData, + }, ], }, ], }); - const closes = vecsResources.getOrCreate( - /** @satisfies {Dateindex} */ (1), - "close", - ); + vecsResources + .getOrCreate(/** @satisfies {Dateindex} */ (1), "close") + .fetch() + .then((_closes) => { + if (!_closes) return; + const closes = /** @type {number[]} */ (_closes); - closes.fetch().then((_closes) => { - const closes = /** @type {OHLCTuple[] | null} */ (_closes); - signals.runWithOwner(owner, () => { - signals.createEffect( - () => ({ - initialDollarAmount: settings.dollars.initial.amount() || 0, - topUpAmount: settings.dollars.topUp.amount() || 0, - topUpFrequency: settings.dollars.topUp.frenquency(), - initialSwap: settings.bitcoin.investment.initial() || 0, - recurrentSwap: settings.bitcoin.investment.recurrent() || 0, - swapFrequency: settings.bitcoin.investment.frequency(), - start: settings.interval.start(), - end: settings.interval.end(), - fees: settings.fees.percentage(), - }), - ({ - initialDollarAmount, - topUpAmount, - topUpFrequency, - initialSwap, - recurrentSwap, - swapFrequency, - start, - end, - fees, - }) => { - if (!start || !end || start > end) return; + signals.runWithOwner(owner, () => { + signals.createEffect( + () => ({ + initialDollarAmount: settings.dollars.initial.amount() || 0, + topUpAmount: settings.dollars.topUp.amount() || 0, + topUpFrequency: settings.dollars.topUp.frenquency(), + initialSwap: settings.bitcoin.investment.initial() || 0, + recurrentSwap: settings.bitcoin.investment.recurrent() || 0, + swapFrequency: settings.bitcoin.investment.frequency(), + start: settings.interval.start(), + end: settings.interval.end(), + fees: settings.fees.percentage(), + }), + ({ + initialDollarAmount, + topUpAmount, + topUpFrequency, + initialSwap, + recurrentSwap, + swapFrequency, + start, + end, + fees, + }) => { + if (!start || !end || start > end) return; - const range = utils.date.getRange(start, end); + const range = utils.date.getRange(start, end); - totalInvestedAmountData().length = 0; - bitcoinValueData().length = 0; - bitcoinData().length = 0; - resultData().length = 0; - dollarsLeftData().length = 0; - totalValueData().length = 0; - investmentData().length = 0; - bitcoinAddedData().length = 0; - averagePricePaidData().length = 0; - bitcoinPriceData().length = 0; - buyCountData().length = 0; - totalFeesPaidData().length = 0; - daysCountData().length = 0; - profitableDaysRatioData().length = 0; - unprofitableDaysRatioData().length = 0; + totalInvestedAmountData().length = 0; + bitcoinValueData().length = 0; + bitcoinData().length = 0; + resultData().length = 0; + dollarsLeftData().length = 0; + totalValueData().length = 0; + investmentData().length = 0; + bitcoinAddedData().length = 0; + averagePricePaidData().length = 0; + bitcoinPriceData().length = 0; + buyCountData().length = 0; + totalFeesPaidData().length = 0; + daysCountData().length = 0; + profitableDaysRatioData().length = 0; + unprofitableDaysRatioData().length = 0; - let bitcoin = 0; - let sats = 0; - let dollars = initialDollarAmount; - let investedAmount = 0; - let postFeesInvestedAmount = 0; - let buyCount = 0; - let averagePricePaid = 0; - let bitcoinValue = 0; - let roi = 0; - let totalValue = 0; - let totalFeesPaid = 0; - let daysCount = range.length; - let profitableDays = 0; - let unprofitableDays = 0; - let profitableDaysRatio = 0; - let unprofitableDaysRatio = 0; - let lastInvestDay = range[0]; - let dailyInvestment = 0; - let bitcoinAdded = 0; - let satsAdded = 0; - let lastSatsAdded = 0; + let bitcoin = 0; + let sats = 0; + let dollars = initialDollarAmount; + let investedAmount = 0; + let postFeesInvestedAmount = 0; + let buyCount = 0; + let averagePricePaid = 0; + let bitcoinValue = 0; + let roi = 0; + let totalValue = 0; + let totalFeesPaid = 0; + let daysCount = range.length; + let profitableDays = 0; + let unprofitableDays = 0; + let profitableDaysRatio = 0; + let unprofitableDaysRatio = 0; + let lastInvestDay = range[0]; + let dailyInvestment = 0; + let bitcoinAdded = 0; + let satsAdded = 0; + let lastSatsAdded = 0; - range.forEach((date, index) => { - const year = date.getUTCFullYear(); - const time = utils.date.toString(date); + range.forEach((date, index) => { + const year = date.getUTCFullYear(); + const time = utils.date.toString(date); - if (topUpFrequency.isTriggerDay(date)) { - dollars += topUpAmount; - } - - const close = closes.ranges - .at(utils.chunkIdToIndex("date", year)) - ?.json()?.dataset.map[utils.date.toString(date)]; - - if (!close) return; - - dailyInvestment = 0; - /** @param {number} value */ - function invest(value) { - value = Math.min(dollars, value); - dailyInvestment += value; - dollars -= value; - buyCount += 1; - lastInvestDay = date; - } - if (!index) { - invest(initialSwap); - } - if (swapFrequency.isTriggerDay(date) && dollars > 0) { - invest(recurrentSwap); - } - - investedAmount += dailyInvestment; - - let dailyInvestmentPostFees = - dailyInvestment * (1 - (fees || 0) / 100); - - totalFeesPaid += dailyInvestment - dailyInvestmentPostFees; - - bitcoinAdded = dailyInvestmentPostFees / close; - bitcoin += bitcoinAdded; - satsAdded = Math.floor(bitcoinAdded * 100_000_000); - if (satsAdded > 0) { - lastSatsAdded = satsAdded; - } - sats += satsAdded; - - postFeesInvestedAmount += dailyInvestmentPostFees; - - bitcoinValue = close * bitcoin; - - totalValue = dollars + bitcoinValue; - - averagePricePaid = postFeesInvestedAmount / bitcoin; - - roi = (bitcoinValue / postFeesInvestedAmount - 1) * 100; - - const daysCount = index + 1; - profitableDaysRatio = profitableDays / daysCount; - unprofitableDaysRatio = unprofitableDays / daysCount; - - if (roi >= 0) { - profitableDays += 1; - } else { - unprofitableDays += 1; - } - - bitcoinPriceData().push({ - time, - value: close, - }); - - bitcoinData().push({ - time, - value: bitcoin, - }); - - totalInvestedAmountData().push({ - time, - value: investedAmount, - }); - - bitcoinValueData().push({ - time, - value: bitcoinValue, - }); - - resultData().push({ - time, - value: roi, - }); - - dollarsLeftData().push({ - time, - value: dollars, - }); - - totalValueData().push({ - time, - value: totalValue, - }); - - investmentData().push({ - time, - value: dailyInvestment, - }); - - bitcoinAddedData().push({ - time, - value: bitcoinAdded, - }); - - averagePricePaidData().push({ - time, - value: averagePricePaid, - }); - - buyCountData().push({ - time, - value: buyCount, - }); - - totalFeesPaidData().push({ - time, - value: totalFeesPaid, - }); - - daysCountData().push({ - time, - value: daysCount, - }); - - profitableDaysRatioData().push({ - time, - value: profitableDaysRatio * 100, - }); - - unprofitableDaysRatioData().push({ - time, - value: unprofitableDaysRatio * 100, - }); - }); - - const f = utils.locale.numberToUSFormat; - /** @param {number} v */ - const fd = (v) => utils.formatters.dollars.format(v); - /** @param {number} v */ - const fp = (v) => utils.formatters.percentage.format(v); - /** - * @param {ColorName} c - * @param {string} t - */ - const c = (c, t) => createColoredSpan({ color: c, text: t }); - - const serInvestedAmount = c("dollars", fd(investedAmount)); - const serDaysCount = c("sky", f(daysCount)); - const serSats = c("orange", f(sats)); - const serBitcoin = c("orange", `~${f(bitcoin)}`); - const serBitcoinValue = c("amber", fd(bitcoinValue)); - const serAveragePricePaid = c("lightDollars", fd(averagePricePaid)); - const serRoi = c("yellow", fp(roi / 100)); - const serDollars = c("offDollars", fd(dollars)); - const serTotalFeesPaid = c("rose", fd(totalFeesPaid)); - - p1.innerHTML = `After exchanging ${serInvestedAmount} in the span of ${serDaysCount} days, you would have accumulated ${serSats} Satoshis (${serBitcoin} Bitcoin) worth today ${serBitcoinValue} at an average price of ${serAveragePricePaid} per Bitcoin with a return of investment of ${serRoi}, have ${serDollars} left and paid a total of ${serTotalFeesPaid} in fees.`; - - const dayDiff = Math.floor( - utils.date.differenceBetween(new Date(), lastInvestDay), - ); - const serDailyInvestment = c("offDollars", fd(dailyInvestment)); - const setLastSatsAdded = c("bitcoin", f(lastSatsAdded)); - p2.innerHTML = `You would've last bought ${c("blue", dayDiff ? `${f(dayDiff)} ${dayDiff > 1 ? "days" : "day"} ago` : "today")} and exchanged ${serDailyInvestment} for approximately ${setLastSatsAdded} Satoshis`; - - const serProfitableDaysRatio = c("green", fp(profitableDaysRatio)); - const serUnprofitableDaysRatio = c("red", fp(unprofitableDaysRatio)); - - p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`; - - signals.createEffect( - () => 0.2368, - (lowestAnnual4YReturn) => { - const serLowestAnnual4YReturn = c( - "cyan", - `${fp(lowestAnnual4YReturn)}`, - ); - - const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn; - /** - * @param {number} power - */ - function bitcoinValueReturn(power) { - return ( - bitcoinValue * Math.pow(lowestAnnual4YReturnPercentage, power) - ); + if (topUpFrequency.isTriggerDay(date)) { + dollars += topUpAmount; } - const bitcoinValueAfter4y = bitcoinValueReturn(4); - const serBitcoinValueAfter4y = c( - "purple", - fd(bitcoinValueAfter4y), - ); - const bitcoinValueAfter10y = bitcoinValueReturn(10); - const serBitcoinValueAfter10y = c( - "fuchsia", - fd(bitcoinValueAfter10y), - ); - const bitcoinValueAfter21y = bitcoinValueReturn(21); - const serBitcoinValueAfter21y = c( - "pink", - fd(bitcoinValueAfter21y), - ); - /** @param {number} v */ - p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.
Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`; - }, - ); + const close = closes[utils.date.toDateIndex(date)]; - totalInvestedAmountData.set((a) => a); - bitcoinValueData.set((a) => a); - bitcoinData.set((a) => a); - resultData.set((a) => a); - dollarsLeftData.set((a) => a); - totalValueData.set((a) => a); - investmentData.set((a) => a); - bitcoinAddedData.set((a) => a); - averagePricePaidData.set((a) => a); - bitcoinPriceData.set((a) => a); - buyCountData.set((a) => a); - totalFeesPaidData.set((a) => a); - daysCountData.set((a) => a); - profitableDaysRatioData.set((a) => a); - unprofitableDaysRatioData.set((a) => a); - }, - ); + if (!close) return; + + dailyInvestment = 0; + /** @param {number} value */ + function invest(value) { + value = Math.min(dollars, value); + dailyInvestment += value; + dollars -= value; + buyCount += 1; + lastInvestDay = date; + } + if (!index) { + invest(initialSwap); + } + if (swapFrequency.isTriggerDay(date) && dollars > 0) { + invest(recurrentSwap); + } + + investedAmount += dailyInvestment; + + let dailyInvestmentPostFees = + dailyInvestment * (1 - (fees || 0) / 100); + + totalFeesPaid += dailyInvestment - dailyInvestmentPostFees; + + bitcoinAdded = dailyInvestmentPostFees / close; + bitcoin += bitcoinAdded; + satsAdded = Math.floor(bitcoinAdded * 100_000_000); + if (satsAdded > 0) { + lastSatsAdded = satsAdded; + } + sats += satsAdded; + + postFeesInvestedAmount += dailyInvestmentPostFees; + + bitcoinValue = close * bitcoin; + + totalValue = dollars + bitcoinValue; + + averagePricePaid = postFeesInvestedAmount / bitcoin; + + roi = (bitcoinValue / postFeesInvestedAmount - 1) * 100; + + const daysCount = index + 1; + profitableDaysRatio = profitableDays / daysCount; + unprofitableDaysRatio = unprofitableDays / daysCount; + + if (roi >= 0) { + profitableDays += 1; + } else { + unprofitableDays += 1; + } + + bitcoinPriceData().push({ + time, + value: close, + }); + + bitcoinData().push({ + time, + value: bitcoin, + }); + + totalInvestedAmountData().push({ + time, + value: investedAmount, + }); + + bitcoinValueData().push({ + time, + value: bitcoinValue, + }); + + resultData().push({ + time, + value: roi, + }); + + dollarsLeftData().push({ + time, + value: dollars, + }); + + totalValueData().push({ + time, + value: totalValue, + }); + + investmentData().push({ + time, + value: dailyInvestment, + }); + + bitcoinAddedData().push({ + time, + value: bitcoinAdded, + }); + + averagePricePaidData().push({ + time, + value: averagePricePaid, + }); + + buyCountData().push({ + time, + value: buyCount, + }); + + totalFeesPaidData().push({ + time, + value: totalFeesPaid, + }); + + daysCountData().push({ + time, + value: daysCount, + }); + + profitableDaysRatioData().push({ + time, + value: profitableDaysRatio * 100, + }); + + unprofitableDaysRatioData().push({ + time, + value: unprofitableDaysRatio * 100, + }); + }); + + const f = utils.locale.numberToUSFormat; + /** @param {number} v */ + const fd = (v) => utils.formatters.dollars.format(v); + /** @param {number} v */ + const fp = (v) => utils.formatters.percentage.format(v); + /** + * @param {ColorName} c + * @param {string} t + */ + const c = (c, t) => createColoredSpan({ color: c, text: t }); + + const serInvestedAmount = c("dollars", fd(investedAmount)); + const serDaysCount = c("sky", f(daysCount)); + const serSats = c("orange", f(sats)); + const serBitcoin = c("orange", `~${f(bitcoin)}`); + const serBitcoinValue = c("amber", fd(bitcoinValue)); + const serAveragePricePaid = c("lightDollars", fd(averagePricePaid)); + const serRoi = c("yellow", fp(roi / 100)); + const serDollars = c("offDollars", fd(dollars)); + const serTotalFeesPaid = c("rose", fd(totalFeesPaid)); + + p1.innerHTML = `After exchanging ${serInvestedAmount} in the span of ${serDaysCount} days, you would have accumulated ${serSats} Satoshis (${serBitcoin} Bitcoin) worth today ${serBitcoinValue} at an average price of ${serAveragePricePaid} per Bitcoin with a return of investment of ${serRoi}, have ${serDollars} left and paid a total of ${serTotalFeesPaid} in fees.`; + + const dayDiff = Math.floor( + utils.date.differenceBetween(new Date(), lastInvestDay), + ); + const serDailyInvestment = c("offDollars", fd(dailyInvestment)); + const setLastSatsAdded = c("bitcoin", f(lastSatsAdded)); + p2.innerHTML = `You would've last bought ${c("blue", dayDiff ? `${f(dayDiff)} ${dayDiff > 1 ? "days" : "day"} ago` : "today")} and exchanged ${serDailyInvestment} for approximately ${setLastSatsAdded} Satoshis`; + + const serProfitableDaysRatio = c("green", fp(profitableDaysRatio)); + const serUnprofitableDaysRatio = c( + "red", + fp(unprofitableDaysRatio), + ); + + p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`; + + signals.createEffect( + () => 0.2368, + (lowestAnnual4YReturn) => { + const serLowestAnnual4YReturn = c( + "cyan", + `${fp(lowestAnnual4YReturn)}`, + ); + + const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn; + /** + * @param {number} power + */ + function bitcoinValueReturn(power) { + return ( + bitcoinValue * + Math.pow(lowestAnnual4YReturnPercentage, power) + ); + } + const bitcoinValueAfter4y = bitcoinValueReturn(4); + const serBitcoinValueAfter4y = c( + "purple", + fd(bitcoinValueAfter4y), + ); + const bitcoinValueAfter10y = bitcoinValueReturn(10); + const serBitcoinValueAfter10y = c( + "fuchsia", + fd(bitcoinValueAfter10y), + ); + const bitcoinValueAfter21y = bitcoinValueReturn(21); + const serBitcoinValueAfter21y = c( + "pink", + fd(bitcoinValueAfter21y), + ); + + /** @param {number} v */ + p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.
Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`; + }, + ); + + totalInvestedAmountData.set((a) => a); + bitcoinValueData.set((a) => a); + bitcoinData.set((a) => a); + resultData.set((a) => a); + dollarsLeftData.set((a) => a); + totalValueData.set((a) => a); + investmentData.set((a) => a); + bitcoinAddedData.set((a) => a); + averagePricePaidData.set((a) => a); + bitcoinPriceData.set((a) => a); + buyCountData.set((a) => a); + totalFeesPaidData.set((a) => a); + daysCountData.set((a) => a); + profitableDaysRatioData.set((a) => a); + unprofitableDaysRatioData.set((a) => a); + }, + ); + }); }); - }); } diff --git a/websites/kibo.money/styles/chart.css b/websites/kibo.money/styles/chart.css index 7a89068bc..26a0e194e 100644 --- a/websites/kibo.money/styles/chart.css +++ b/websites/kibo.money/styles/chart.css @@ -26,19 +26,5 @@ .chart { flex: 1; - - .lightweight-chart { - margin-left: var(--negative-main-padding); - - fieldset { - padding-left: var(--main-padding); - padding-top: 0.5rem; - z-index: 10; - position: absolute; - left: 0; - top: 0; - gap: 0; - } - } } } diff --git a/websites/kibo.money/styles/simulation.css b/websites/kibo.money/styles/simulation.css index bb0f02d59..88adf12ef 100644 --- a/websites/kibo.money/styles/simulation.css +++ b/websites/kibo.money/styles/simulation.css @@ -5,13 +5,8 @@ > div { display: flex; flex-direction: column; - gap: 1.5rem; + gap: 2rem; padding: var(--main-padding); - - > div { - display: flex; - flex-direction: column; - } } @media (max-width: 767px) { @@ -67,11 +62,16 @@ } .chart { - flex-shrink: 0; + flex: none; height: 400px; .lightweight-chart { - margin-left: calc(var(--negative-main-padding) / 2); + margin-left: calc(var(--negative-main-padding) * 0.75); + + fieldset { + margin-left: -0.5rem; + } + } } } }