Files
brk/websites/kibo.money/packages/lightweight-charts/v5.0.5/script.js
2025-03-29 13:01:46 +01:00

9 lines
173 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @ts-nocheck
/*!
* @license
* TradingView Lightweight Charts™ v5.0.5
* 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,n;function s(t,i){const n={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(n)}function e(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(n,i+e),t.lineTo(s,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 a(t){if(null===t)throw new Error("Value is null");return t}function l(t){return a(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"}(n||(n={}));class o{constructor(){this.t=[]}i(t,i,n){const s={h:t,l:i,o:!0===n};this.t.push(s)}_(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,n){const s=[...this.t];this.t=this.t.filter((t=>!t.o)),s.forEach((s=>s.h(t,i,n)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const n of i)for(const i in n)void 0!==n[i]&&Object.prototype.hasOwnProperty.call(n,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof n[i]||void 0===t[i]||Array.isArray(n[i])?t[i]=n[i]:_(t[i],n[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 n,s,e;for(s in n=Array.isArray(i)?[]:{},i)i.hasOwnProperty(s)&&(e=i[s],n[s]=e&&"object"==typeof e?p(e):e);return n}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,n){return void 0===i&&(i=w),`${n=void 0!==n?`${n} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",V:0,I:0,B:0,A:0,O:0},this.L=t}N(){const t=this.M,i=this.W(),n=this.F();return t.P===i&&t.T===n||(t.P=i,t.T=n,t.k=g(i,n),t.A=2.5/12*i,t.V=t.A,t.I=i/12*t.C,t.B=i/12*t.C,t.O=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.L.N().layout.textColor}U(){return this.L.$()}W(){return this.L.N().layout.fontSize}F(){return this.L.N().layout.fontFamily}}function b(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.q=t,i&&(this.j=i)}Y(t,i){if("transparent"===t)return t;const n=this.Z(t),s=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${i*s})`}K(t){const i=this.Z(t);return{X:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,G:x(i)>160?"black":"white"}}J(t){return x(this.Z(t))}tt(t,i,n){const[s,e,r,h]=this.Z(t),[a,l,o,_]=this.Z(i),u=[b(s+n*(a-s)),b(e+n*(l-e)),b(r+n*(o-r)),(c=h+n*(_-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]})`}Z(t){const i=this.j.get(t);if(i)return i;const n=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const n=window.getComputedStyle(i).color;return document.body.removeChild(i),n}(t),s=n.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!s){if(this.q.length)for(const i of this.q){const n=i(t);if(n)return this.j.set(t,n),n}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(s[1],10),parseInt(s[2],10),parseInt(s[3],10),s[4]?parseFloat(s[4]):1];return this.j.set(t,e),e}}class C{constructor(){this.it=[]}nt(t){this.it=t}st(t,i,n){this.it.forEach((s=>{s.st(t,i,n)}))}}class y{st(t,i,n){t.useBitmapCoordinateSpace((t=>this.et(t,i,n)))}}class P extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.rt||null===this.rt.lt)return;const s=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=s.to-1;a>=s.from;--a){const s=e.ot[a],l=Math.round(s._t*i)+r,o=s.ut*n,_=h*n+r;t.moveTo(l,o),t.arc(l,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 k(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const T={from:0,to:1};class R{constructor(t,i,n){this.Mt=new C,this.bt=[],this.xt=[],this.St=!0,this.L=t,this.Ct=i,this.yt=n,this.Mt.nt(this.bt)}Pt(t){this.kt(),this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Mt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.xt=t.map(k),this.bt=this.xt.map((t=>{const i=new P;return i.ht(t),i})),this.Mt.nt(this.bt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.Vt(),i=this.yt.Et(),n=this.Ct.It(),s=this.L.Bt();this.kt(),i.forEach(((i,e)=>{const r=this.xt[e],h=i.At(n),a=i.zt();!t&&null!==h&&i.Vt()&&null!==a?(r.vt=h.Ot,r.ft=h.ft,r.ct=h.Lt,r.ot[0].gt=h.gt,r.ot[0].ut=i.Wt().Nt(h.gt,a.Ft),r.dt=h.Ht??this.L.Ut(r.ot[0].ut/i.Wt().$t()),r.ot[0].wt=n,r.ot[0]._t=s.jt(n),r.lt=T):r.lt=null}))}}class D extends y{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;const h=this.qt.Yt.Vt,a=this.qt.Zt.Vt;if(!h&&!a)return;const l=Math.round(this.qt._t*n),o=Math.round(this.qt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*n),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,s(t,this.qt.Yt.Kt),function(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,n),t.lineTo(i+e,s),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.qt.Zt.ct*r),t.strokeStyle=this.qt.Zt.R,t.fillStyle=this.qt.Zt.R,s(t,this.qt.Zt.Kt),e(t,o,0,i.width))}}class V{constructor(t,i){this.St=!0,this.Xt={Yt:{ct:1,Kt:0,R:"",Vt:!1},Zt:{ct:1,Kt:0,R:"",Vt:!1},_t:0,ut:0},this.Gt=new D(this.Xt),this.Jt=t,this.yt=i}Pt(){this.St=!0}Tt(t){return this.St&&(this.Rt(),this.St=!1),this.Gt}Rt(){const t=this.Jt.Vt(),i=this.yt.Qt().N().crosshair,n=this.Xt;if(2===i.mode)return n.Zt.Vt=!1,void(n.Yt.Vt=!1);n.Zt.Vt=t&&this.Jt.ti(this.yt),n.Yt.Vt=t&&this.Jt.ii(),n.Zt.ct=i.horzLine.width,n.Zt.Kt=i.horzLine.style,n.Zt.R=i.horzLine.color,n.Yt.ct=i.vertLine.width,n.Yt.Kt=i.vertLine.style,n.Yt.R=i.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}}function E(t,i,n,s,e,r){t.fillRect(i+r,n,s-2*r,r),t.fillRect(i+r,n+e-r,s-2*r,r),t.fillRect(i,n,r,e),t.fillRect(i+s-r,n,r,e)}function I(t,i,n,s,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,s,e),t.restore()}function B(t,i,n,s,e,r){t.beginPath(),t.roundRect?t.roundRect(i,n,s,e,r):(t.lineTo(i+s-r[1],n),0!==r[1]&&t.arcTo(i+s,n,i+s,n+r[1],r[1]),t.lineTo(i+s,n+e-r[2]),0!==r[2]&&t.arcTo(i+s,n+e,i+s-r[2],n+e,r[2]),t.lineTo(i+r[3],n+e),0!==r[3]&&t.arcTo(i,n+e,i,n+e-r[3],r[3]),t.lineTo(i,n+r[0]),0!==r[0]&&t.arcTo(i,n,i+r[0],n,r[0]))}function A(t,i,n,s,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return B(t,i,n,s,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;B(t,i+o,n+o,s-h,e-h,(_=-o,a.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=h,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function z(t,i,n,s,e,r,h){t.save(),t.globalCompositeOperation="copy";const a=t.createLinearGradient(0,0,0,e);a.addColorStop(0,r),a.addColorStop(1,h),t.fillStyle=a,t.fillRect(i,n,s,e),t.restore()}class O{constructor(t,i){this.ht(t,i)}ht(t,i){this.qt=t,this.ei=i}$t(t,i){return this.qt.Vt?t.P+t.A+t.V:0}st(t,i,n,s){if(!this.qt.Vt||0===this.qt.ri.length)return;const e=this.qt.R,r=this.ei.X,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.k;const a=this.hi(t,i,n,s),l=a.ai;return a.li?A(h,l.oi,l._i,l.ui,l.ci,r,l.di,[l.ft,0,0,l.ft],r):A(h,l.fi,l._i,l.ui,l.ci,r,l.di,[0,l.ft,l.ft,0],r),this.qt.pi&&(h.fillStyle=e,h.fillRect(l.fi,l.mi,l.wi-l.fi,l.gi)),this.qt.Mi&&(h.fillStyle=i.D,h.fillRect(a.li?l.bi-l.di:0,l._i,l.di,l.xi-l._i)),a}));t.useMediaCoordinateSpace((({context:t})=>{const n=h.Si;t.font=i.k,t.textAlign=h.li?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.qt.ri,n.Ci,(n._i+n.xi)/2+n.yi)}))}hi(t,i,n,s){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.qt.pi||!this.qt.Pi?i.C:0,_=this.qt.ki?i.S:0,u=i.A+this.ei.Ti,c=i.V+this.ei.Ri,d=i.I,f=i.B,p=this.qt.ri,v=i.P,m=n.Di(e,p),w=Math.ceil(n.Vi(e,p)),g=v+u+c,M=i.S+d+f+w+o,b=Math.max(1,Math.floor(l));let x=Math.round(g*l);x%2!=b%2&&(x+=1);const S=_>0?Math.max(1,Math.floor(_*a)):0,C=Math.round(M*a),y=Math.round(o*a),P=this.ei.Ei??this.ei.Ii,k=Math.round(P*l)-Math.floor(.5*l),T=Math.floor(k+b/2-x/2),R=T+x,D="right"===s,V=D?h.width-_:_,E=D?r.width-S:S;let I,B,A;return D?(I=E-C,B=E-y,A=V-o-d-_):(I=E+C,B=E+y,A=V+o+d),{li:D,ai:{_i:T,mi:k,xi:R,ui:C,ci:x,ft:2*a,di:S,oi:I,fi:E,wi:B,gi:b,bi:r.width},Si:{_i:T/l,xi:R/l,Ci:A,yi:m}}}}class L{constructor(t){this.Bi={Ii:0,X:"#000",Ri:0,Ti:0},this.Ai={ri:"",Vt:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",Mi:!1,ki:!1},this.zi={ri:"",Vt:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",Mi:!0,ki:!0},this.St=!0,this.Oi=new(t||O)(this.Ai,this.Bi),this.Li=new(t||O)(this.zi,this.Bi)}ri(){return this.Ni(),this.Ai.ri}Ii(){return this.Ni(),this.Bi.Ii}Pt(){this.St=!0}$t(t,i=!1){return Math.max(this.Oi.$t(t,i),this.Li.$t(t,i))}Wi(){return this.Bi.Ei||0}Fi(t){this.Bi.Ei=t}Hi(){return this.Ni(),this.Ai.Vt||this.zi.Vt}Ui(){return this.Ni(),this.Ai.Vt}Tt(t){return this.Ni(),this.Ai.pi=this.Ai.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Ai,this.Bi),this.Li.ht(this.zi,this.Bi),this.Oi}$i(){return this.Ni(),this.Oi.ht(this.Ai,this.Bi),this.Li.ht(this.zi,this.Bi),this.Li}Ni(){this.St&&(this.Ai.pi=!0,this.zi.pi=!1,this.ji(this.Ai,this.zi,this.Bi))}}class N extends L{constructor(t,i,n){super(),this.Jt=t,this.qi=i,this.Yi=n}ji(t,i,n){if(t.Vt=!1,2===this.Jt.N().mode)return;const s=this.Jt.N().horzLine;if(!s.labelVisible)return;const e=this.qi.zt();if(!this.Jt.Vt()||this.qi.Zi()||null===e)return;const r=this.qi.Ki().K(s.labelBackgroundColor);n.X=r.X,t.R=r.G;const h=2/12*this.qi.P();n.Ti=h,n.Ri=h;const a=this.Yi(this.qi);n.Ii=a.Ii,t.ri=this.qi.Xi(a.gt,e),t.Vt=!0}}const W=/[1-9]/g;class F{constructor(){this.qt=null}ht(t){this.qt=t}st(t,i){if(null===this.qt||!1===this.qt.Vt||0===this.qt.ri.length)return;const n=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.k,Math.round(i.Gi.Vi(t,a(this.qt).ri,W)))));if(n<=0)return;const s=i.Ji,e=n+2*s,r=e/2,h=this.qt.Qi;let l=this.qt.Ii,o=Math.floor(l-r)+.5;o<0?(l+=Math.abs(0-o),o=Math.floor(l-r)+.5):o+e>h&&(l-=Math.abs(h-(o+e)),o=Math.floor(l-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.C+i.A+i.P+i.V);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:n,verticalPixelRatio:s})=>{const e=a(this.qt);t.fillStyle=e.X;const r=Math.round(o*n),h=Math.round(0*s),l=Math.round(_*n),c=Math.round(u*s),d=Math.round(2*n);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(l-d,c),t.arcTo(l,c,l,c-d,d),t.lineTo(l,h),t.fill(),e.pi){const r=Math.round(e.Ii*n),a=h,l=Math.round((a+i.C)*s);t.fillStyle=e.R;const o=Math.max(1,Math.floor(n)),_=Math.floor(.5*n);t.fillRect(r-_,a,o,l-a)}})),t.useMediaCoordinateSpace((({context:t})=>{const n=a(this.qt),e=0+i.S+i.C+i.A+i.P/2;t.font=i.k,t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.R;const r=i.Gi.Di(t,"Apr0");t.translate(o+s,e+r),t.fillText(n.ri,0,0)}))}}class H{constructor(t,i,n){this.St=!0,this.Gt=new F,this.Xt={Vt:!1,X:"#4c525e",R:"white",ri:"",Qi:0,Ii:NaN,pi:!0},this.Ct=t,this.tn=i,this.Yi=n}Pt(){this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Gt.ht(this.Xt),this.Gt}Rt(){const t=this.Xt;if(t.Vt=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const n=this.tn.Bt();if(n.Zi())return;t.Qi=n.Qi();const s=this.Yi();if(null===s)return;t.Ii=s.Ii;const e=n.nn(this.Ct.It());t.ri=n.sn(a(e)),t.Vt=!0;const r=this.tn.Ki().K(i.labelBackgroundColor);t.X=r.X,t.R=r.G,t.pi=n.N().ticksVisible}}class U{constructor(){this.en=null,this.rn=0}hn(){return this.rn}an(t){this.rn=t}Wt(){return this.en}ln(t){this.en=t}_n(t){return[]}un(){return[]}Vt(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}($||($={}));class j extends U{constructor(t,i){super(),this.yt=null,this.cn=NaN,this.dn=0,this.fn=!1,this.pn=new Map,this.vn=!1,this.mn=new WeakMap,this.wn=new WeakMap,this.gn=NaN,this.Mn=NaN,this.bn=NaN,this.xn=NaN,this.tn=t,this.Sn=i;this.Cn=((t,i)=>n=>{const s=i(),e=t();if(n===a(this.yt).yn())return{gt:e,Ii:s};{const t=a(n.zt());return{gt:n.Pn(s,t),Ii:s}}})((()=>this.cn),(()=>this.Mn));const n=((t,i)=>()=>{const n=this.tn.Bt().kn(t()),s=i();return n&&Number.isFinite(s)?{wt:n,Ii:s}:null})((()=>this.dn),(()=>this.ni()));this.Tn=new H(this,t,n)}N(){return this.Sn}Rn(t,i){this.bn=t,this.xn=i}Dn(){this.bn=NaN,this.xn=NaN}Vn(){return this.bn}En(){return this.xn}In(t,i,n){this.vn||(this.vn=!0),this.fn=!0,this.Bn(t,i,n)}It(){return this.dn}ni(){return this.gn}si(){return this.Mn}Vt(){return this.fn}An(){this.fn=!1,this.zn(),this.cn=NaN,this.gn=NaN,this.Mn=NaN,this.yt=null,this.Dn(),this.On()}Ln(t){let i=this.mn.get(t);i||(i=new V(this,t),this.mn.set(t,i));let n=this.wn.get(t);return n||(n=new R(this.tn,this,t),this.wn.set(t,n)),[i,n]}ti(t){return t===this.yt&&this.Sn.horzLine.visible}ii(){return this.Sn.vertLine.visible}Nn(t,i){this.fn&&this.yt===t||this.pn.clear();const n=[];return this.yt===t&&n.push(this.Wn(this.pn,i,this.Cn)),n}un(){return this.fn?[this.Tn]:[]}Fn(){return this.yt}On(){this.tn.Hn().forEach((t=>{this.mn.get(t)?.Pt(),this.wn.get(t)?.Pt()})),this.pn.forEach((t=>t.Pt())),this.Tn.Pt()}Un(t){return t&&!t.yn().Zi()?t.yn():null}Bn(t,i,n){this.$n(t,i,n)&&this.On()}$n(t,i,n){const s=this.gn,e=this.Mn,r=this.cn,h=this.dn,a=this.yt,l=this.Un(n);this.dn=t,this.gn=isNaN(t)?NaN:this.tn.Bt().jt(t),this.yt=n;const o=null!==l?l.zt():null;return null!==l&&null!==o?(this.cn=i,this.Mn=l.Nt(i,o)):(this.cn=NaN,this.Mn=NaN),s!==this.gn||e!==this.Mn||h!==this.dn||r!==this.cn||a!==this.yt}zn(){const t=this.tn.jn().map((t=>t.Yn().qn())).filter(v),i=0===t.length?null:Math.max(...t);this.dn=null!==i?i:NaN}Wn(t,i,n){let s=t.get(i);return void 0===s&&(s=new N(this,i,n),t.set(i,s)),s}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.Zn=new Map,this.Kn=[],this.Xn=t}Gn(t,i){const n=function(t,i){return void 0===t?i:{Jn:Math.max(t.Jn,i.Jn),Qn:t.Qn||i.Qn}}(this.Zn.get(t),i);this.Zn.set(t,n)}ts(){return this.Xn}ns(t){const i=this.Zn.get(t);return void 0===i?{Jn:this.Xn}:{Jn:Math.max(this.Xn,i.Jn),Qn:i.Qn}}ss(){this.es(),this.Kn=[{rs:0}]}hs(t){this.es(),this.Kn=[{rs:1,Ft:t}]}ls(t){this._s(),this.Kn.push({rs:5,Ft:t})}es(){this._s(),this.Kn.push({rs:6})}us(){this.es(),this.Kn=[{rs:4}]}cs(t){this.es(),this.Kn.push({rs:2,Ft:t})}ds(t){this.es(),this.Kn.push({rs:3,Ft:t})}fs(){return this.Kn}ps(t){for(const i of t.Kn)this.vs(i);this.Xn=Math.max(this.Xn,t.Xn),t.Zn.forEach(((t,i)=>{this.Gn(i,t)}))}static ws(){return new Y(2)}static gs(){return new Y(3)}vs(t){switch(t.rs){case 0:this.ss();break;case 1:this.hs(t.Ft);break;case 2:this.cs(t.Ft);break;case 3:this.ds(t.Ft);break;case 4:this.us();break;case 5:this.ls(t.Ft);break;case 6:this._s()}}_s(){const t=this.Kn.findIndex((t=>5===t.rs));-1!==t&&this.Kn.splice(t,1)}}const Z=".";function K(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 X{constructor(t,i){if(i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.qi=t,this.Ms=i,this.bs()}format(t){const i=t<0?"":"";return t=Math.abs(t),i+this.xs(t)}bs(){if(this.Ss=0,this.qi>0&&this.Ms>0){let t=this.qi;for(;t>1;)t/=10,this.Ss++}}xs(t){const i=this.qi/this.Ms;let n=Math.floor(t),s="";const e=void 0!==this.Ss?this.Ss:NaN;if(i>1){let r=+(Math.round(t*i)-n*i).toFixed(this.Ss);r>=i&&(r-=i,n+=1),s=Z+K(+r.toFixed(this.Ss)*this.Ms,e)}else n=Math.round(n*i)/i,e>0&&(s=Z+K(0,e));return n.toFixed(0)+s}}class G extends X{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class J{constructor(t){this.Cs=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.ys(t):t<999995?i+this.ys(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.ys(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.ys(t/1e9)+"B")}ys(t){let i;const n=Math.pow(10,this.Cs);return i=(t=Math.round(t*n)/n)>=1e-15&&t<1?t.toFixed(this.Cs).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const Q=/[2-9]/g;class tt{constructor(t=50){this.Ps=0,this.ks=1,this.Ts=1,this.Rs={},this.Ds=new Map,this.Vs=t}Es(){this.Ps=0,this.Ds.clear(),this.ks=1,this.Ts=1,this.Rs={}}Vi(t,i,n){return this.Is(t,i,n).width}Di(t,i,n){const s=this.Is(t,i,n);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}Is(t,i,n){const s=n||Q,e=String(i).replace(s,"0");if(this.Ds.has(e))return h(this.Ds.get(e)).Bs;if(this.Ps===this.Vs){const t=this.Rs[this.Ts];delete this.Rs[this.Ts],this.Ds.delete(t),this.Ts++,this.Ps--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.Ds.set(e,{Bs:r,As:this.ks}),this.Rs[this.ks]=e,this.Ps++,this.ks++),r}}class it{constructor(t){this.zs=null,this.M=null,this.Os="right",this.Ls=t}Ns(t,i,n){this.zs=t,this.M=i,this.Os=n}st(t){null!==this.M&&null!==this.zs&&this.zs.st(t,this.M,this.Ls,this.Os)}}class nt{constructor(t,i,n){this.Ws=t,this.Ls=new tt(50),this.Fs=i,this.L=n,this.W=-1,this.Gt=new it(this.Ls)}Tt(){const t=this.L.Hs(this.Fs);if(null===t)return null;const i=t.Us(this.Fs)?t.$s():this.Fs.Wt();if(null===i)return null;const n=t.js(i);if("overlay"===n)return null;const s=this.L.qs();return s.P!==this.W&&(this.W=s.P,this.Ls.Es()),this.Gt.Ns(this.Ws.$i(),s,n),this.Gt}}class st extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Ys(t,i){if(!this.qt?.Vt)return null;const{ut:n,ct:s,Zs:e}=this.qt;return i>=n-s-7&&i<=n+s+7?{Ks:this.qt,Zs:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;if(!1===this.qt.Vt)return;const h=Math.round(this.qt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*n),s(t,this.qt.Kt),e(t,h,0,i.width))}}class et{constructor(t){this.Xs={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Kt:0,Vt:!1},this.Gs=new st,this.St=!0,this.Js=t,this.Qs=t.Qt(),this.Gs.ht(this.Xs)}Pt(){this.St=!0}Tt(){return this.Js.Vt()?(this.St&&(this.te(),this.St=!1),this.Gs):null}}class rt extends et{constructor(t){super(t)}te(){this.Xs.Vt=!1;const t=this.Js.Wt(),i=t.ie().ie;if(2!==i&&3!==i)return;const n=this.Js.N();if(!n.baseLineVisible||!this.Js.Vt())return;const s=this.Js.zt();null!==s&&(this.Xs.Vt=!0,this.Xs.ut=t.Nt(s.Ft,s.Ft),this.Xs.R=n.baseLineColor,this.Xs.ct=n.baseLineWidth,this.Xs.Kt=n.baseLineStyle)}}class ht extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ne(){return this.qt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){const s=this.qt;if(null===s)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(s.se.x*i)+r,a=s.se.y*n;t.fillStyle=s.ee,t.beginPath();const l=Math.max(2,1.5*s.re)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.he,t.beginPath(),t.arc(h,a,s.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=s.ae,t.beginPath(),t.arc(h,a,s.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const at=[{le:0,oe:.25,_e:4,ue:10,ce:.25,de:0,fe:.4,pe:.8},{le:.25,oe:.525,_e:10,ue:14,ce:0,de:0,fe:.8,pe:0},{le:.525,oe:1,_e:14,ue:14,ce:0,de:0,fe:0,pe:0}];class lt{constructor(t){this.Gt=new ht,this.St=!0,this.ve=!0,this.me=performance.now(),this.we=this.me-1,this.ge=t}Me(){this.we=this.me-1,this.Pt()}be(){if(this.Pt(),2===this.ge.N().lastPriceAnimation){const t=performance.now(),i=this.we-t;if(i>0)return void(i<650&&(this.we+=2600));this.me=t,this.we=t+2600}}Pt(){this.St=!0}xe(){this.ve=!0}Vt(){return 0!==this.ge.N().lastPriceAnimation}Se(){switch(this.ge.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.we}}Tt(){return this.St?(this.Rt(),this.St=!1,this.ve=!1):this.ve&&(this.Ce(),this.ve=!1),this.Gt}Rt(){this.Gt.ht(null);const t=this.ge.Qt().Bt(),i=t.ye(),n=this.ge.zt();if(null===i||null===n)return;const s=this.ge.Pe(!0);if(s.ke||!i.Te(s.Re))return;const e={x:t.jt(s.Re),y:this.ge.Wt().Nt(s.gt,n.Ft)},r=s.R,h=this.ge.N().lineWidth,a=this.De(this.Ve(),r);this.Gt.ht({ee:r,re:h,he:a.he,ae:a.ae,ft:a.ft,se:e})}Ce(){const t=this.Gt.ne();if(null!==t){const i=this.De(this.Ve(),t.ee);t.he=i.he,t.ae=i.ae,t.ft=i.ft}}Ve(){return this.Se()?performance.now()-this.me:2599}Ee(t,i,n,s){const e=n+(s-n)*i;return this.ge.Qt().Ki().Y(t,e)}De(t,i){const n=t%2600/2600;let s;for(const t of at)if(n>=t.le&&n<=t.oe){s=t;break}r(void 0!==s,"Last price animation internal logic error");const e=(n-s.le)/(s.oe-s.le);return{he:this.Ee(i,e,s.ce,s.de),ae:this.Ee(i,e,s.fe,s.pe),ft:(h=e,a=s._e,l=s.ue,a+(l-a)*h)};var h,a,l}}class ot extends et{constructor(t){super(t)}te(){const t=this.Xs;t.Vt=!1;const i=this.Js.N();if(!i.priceLineVisible||!this.Js.Vt())return;const n=this.Js.Pe(0===i.priceLineSource);n.ke||(t.Vt=!0,t.ut=n.Ii,t.R=this.Js.Ie(n.R),t.ct=i.priceLineWidth,t.Kt=i.priceLineStyle)}}class _t extends L{constructor(t){super(),this.Jt=t}ji(t,i,n){t.Vt=!1,i.Vt=!1;const s=this.Jt;if(!s.Vt())return;const e=s.N(),r=e.lastValueVisible,h=""!==s.Be(),a=0===e.seriesLastValueMode,l=s.Pe(!1);if(l.ke)return;r&&(t.ri=this.Ae(l,r,a),t.Vt=0!==t.ri.length),(h||a)&&(i.ri=this.ze(l,r,h,a),i.Vt=i.ri.length>0);const o=s.Ie(l.R),_=this.Jt.Qt().Ki().K(o);n.X=_.X,n.Ii=l.Ii,i.Ht=s.Qt().Ut(l.Ii/s.Wt().$t()),t.Ht=o,t.R=_.G,i.R=_.G}ze(t,i,n,s){let e="";const r=this.Jt.Be();return n&&0!==r.length&&(e+=`${r} `),i&&s&&(e+=this.Jt.Wt().Oe()?t.Le:t.Ne),e.trim()}Ae(t,i,n){return i?n?this.Jt.Wt().Oe()?t.Ne:t.Le:t.ri:""}}function ut(t,i,n,s){const e=Number.isFinite(i),r=Number.isFinite(n);return e&&r?t(i,n):e||r?e?i:n:s}class ct{constructor(t,i){this.We=t,this.Fe=i}He(t){return null!==t&&(this.We===t.We&&this.Fe===t.Fe)}Ue(){return new ct(this.We,this.Fe)}$e(){return this.We}je(){return this.Fe}qe(){return this.Fe-this.We}Zi(){return this.Fe===this.We||Number.isNaN(this.Fe)||Number.isNaN(this.We)}ps(t){return null===t?this:new ct(ut(Math.min,this.$e(),t.$e(),-1/0),ut(Math.max,this.je(),t.je(),1/0))}Ye(t){if(!u(t))return;if(0===this.Fe-this.We)return;const i=.5*(this.Fe+this.We);let n=this.Fe-i,s=this.We-i;n*=t,s*=t,this.Fe=i+n,this.We=i+s}Ze(t){u(t)&&(this.Fe+=t,this.We+=t)}Ke(){return{minValue:this.We,maxValue:this.Fe}}static Xe(t){return null===t?null:new ct(t.minValue,t.maxValue)}}class dt{constructor(t,i){this.Ge=t,this.Je=i||null}Qe(){return this.Ge}tr(){return this.Je}Ke(){return{priceRange:null===this.Ge?null:this.Ge.Ke(),margins:this.Je||void 0}}static Xe(t){return null===t?null:new dt(ct.Xe(t.priceRange),t.margins)}}class ft extends et{constructor(t,i){super(t),this.ir=i}te(){const t=this.Xs;t.Vt=!1;const i=this.ir.N();if(!this.Js.Vt()||!i.lineVisible)return;const n=this.ir.nr();null!==n&&(t.Vt=!0,t.ut=n,t.R=i.color,t.ct=i.lineWidth,t.Kt=i.lineStyle,t.Zs=this.ir.N().id)}}class pt extends L{constructor(t,i){super(),this.ge=t,this.ir=i}ji(t,i,n){t.Vt=!1,i.Vt=!1;const s=this.ir.N(),e=s.axisLabelVisible,r=""!==s.title,h=this.ge;if(!e||!h.Vt())return;const a=this.ir.nr();if(null===a)return;r&&(i.ri=s.title,i.Vt=!0),i.Ht=h.Qt().Ut(a/h.Wt().$t()),t.ri=this.sr(s.price),t.Vt=!0;const l=this.ge.Qt().Ki().K(s.axisLabelColor||s.color);n.X=l.X;const o=s.axisLabelTextColor||l.G;t.R=o,i.R=o,n.Ii=a}sr(t){const i=this.ge.zt();return null===i?"":this.ge.Wt().Xi(t,i.Ft)}}class vt{constructor(t,i){this.ge=t,this.Sn=i,this.er=new ft(t,this),this.Ws=new pt(t,this),this.rr=new nt(this.Ws,t,t.Qt())}hr(t){_(this.Sn,t),this.Pt(),this.ge.Qt().ar()}N(){return this.Sn}lr(){return this.er}_r(){return this.rr}ur(){return this.Ws}Pt(){this.er.Pt(),this.Ws.Pt()}nr(){const t=this.ge,i=t.Wt();if(t.Qt().Bt().Zi()||i.Zi())return null;const n=t.zt();return null===n?null:i.Nt(this.Sn.price,n.Ft)}}class mt extends U{constructor(t){super(),this.tn=t}Qt(){return this.tn}}const wt={Bar:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=a(t(n,s)),o=l(h.Ft[0])<=l(h.Ft[3]);return{cr:h.R??(o?e:r)}},Candlestick:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=a(t(n,s)),d=l(c.Ft[0])<=l(c.Ft[3]);return{cr:c.R??(d?e:r),dr:c.Ht??(d?h:o),pr:c.vr??(d?_:u)}},Custom:(t,i,n,s)=>({cr:a(t(n,s)).R??i.color}),Area:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.vt??i.lineColor,vt:e.vt??i.lineColor,mr:e.mr??i.topColor,wr:e.wr??i.bottomColor}},Baseline:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.Ft[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,gr:e.gr??i.topLineColor,Mr:e.Mr??i.bottomLineColor,br:e.br??i.topFillColor1,Sr:e.Sr??i.topFillColor2,Cr:e.Cr??i.bottomFillColor1,yr:e.yr??i.bottomFillColor2}},Line:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,n,s)=>({cr:a(t(n,s)).R??i.color})};class gt{constructor(t){this.Pr=(t,i)=>void 0!==i?i.Ft:this.ge.Yn().kr(t),this.ge=t,this.Tr=wt[t.Rr()]}Dr(t,i){return this.Tr(this.Pr,this.ge.N(),t,i)}}function Mt(t,i,n,s,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;s(i[a],n)===t?(e=a+1,h-=r+1):h=r}return e}const bt=Mt.bind(null,!0),xt=Mt.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.Vr=[],this.Er=new Map,this.Ir=new Map,this.Br=[]}Ar(){return this.zr()>0?this.Vr[this.Vr.length-1]:null}Or(){return this.zr()>0?this.Lr(0):null}qn(){return this.zr()>0?this.Lr(this.Vr.length-1):null}zr(){return this.Vr.length}Zi(){return 0===this.zr()}Te(t){return null!==this.Nr(t,0)}kr(t){return this.Wr(t)}Wr(t,i=0){const n=this.Nr(t,i);return null===n?null:{...this.Fr(n),Re:this.Lr(n)}}Hr(){return this.Vr}Ur(t,i,n){if(this.Zi())return null;let s=null;for(const e of n){s=Pt(s,this.$r(t,i,e))}return s}ht(t){this.Ir.clear(),this.Er.clear(),this.Vr=t,this.Br=t.map((t=>t.Re))}jr(){return this.Br}Lr(t){return this.Vr[t].Re}Fr(t){return this.Vr[t]}Nr(t,i){const n=this.qr(t);if(null===n&&0!==i)switch(i){case-1:return this.Yr(t);case 1:return this.Zr(t);default:throw new TypeError("Unknown search mode")}return n}Yr(t){let i=this.Kr(t);return i>0&&(i-=1),i!==this.Vr.length&&this.Lr(i)<t?i:null}Zr(t){const i=this.Xr(t);return i!==this.Vr.length&&t<this.Lr(i)?i:null}qr(t){const i=this.Kr(t);return i===this.Vr.length||t<this.Vr[i].Re?null:i}Kr(t){return bt(this.Vr,t,((t,i)=>t.Re<i))}Xr(t){return xt(this.Vr,t,((t,i)=>t.Re>i))}Gr(t,i,n){let s=null;for(let e=t;e<i;e++){const t=this.Vr[e].Ft[n];Number.isNaN(t)||(null===s?s={Jr:t,Qr:t}:(t<s.Jr&&(s.Jr=t),t>s.Qr&&(s.Qr=t)))}return s}$r(t,i,n){if(this.Zi())return null;let s=null;const e=a(this.Or()),r=a(this.qn()),h=Math.max(t,e),l=Math.min(i,r),o=Math.ceil(h/Ct)*Ct,_=Math.max(o,Math.floor(l/Ct)*Ct);{const t=this.Kr(h),e=this.Xr(Math.min(l,o,i));s=Pt(s,this.Gr(t,e,n))}let u=this.Er.get(n);void 0===u&&(u=new Map,this.Er.set(n,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.Kr(i*Ct),s=this.Xr((i+1)*Ct-1);e=this.Gr(t,s,n),u.set(i,e)}s=Pt(s,e)}{const t=this.Kr(_),i=this.Xr(l);s=Pt(s,this.Gr(t,i,n))}return s}}function Pt(t,i){if(null===t)return i;if(null===i)return t;return{Jr:Math.min(t.Jr,i.Jr),Qr:Math.max(t.Qr,i.Qr)}}class kt{constructor(t){this.th=t}st(t,i,n){this.th.draw(t)}ih(t,i,n){this.th.drawBackground?.(t)}}class Tt{constructor(t){this.Ds=null,this.nh=t}Tt(){const t=this.nh.renderer();if(null===t)return null;if(this.Ds?.sh===t)return this.Ds.eh;const i=new kt(t);return this.Ds={sh:t,eh:i},i}rh(){return this.nh.zOrder?.()??"normal"}}class Rt{constructor(t){this.hh=null,this.ah=t}oh(){return this.ah}On(){this.ah.updateAllViews?.()}Ln(){const t=this.ah.paneViews?.()??[];if(this.hh?.sh===t)return this.hh.eh;const i=t.map((t=>new Tt(t)));return this.hh={sh:t,eh:i},i}Ys(t,i){return this.ah.hitTest?.(t,i)??null}}let Dt=class extends Rt{_n(){return[]}};class Vt{constructor(t){this.th=t}st(t,i,n){this.th.draw(t)}ih(t,i,n){this.th.drawBackground?.(t)}}class Et{constructor(t){this.Ds=null,this.nh=t}Tt(){const t=this.nh.renderer();if(null===t)return null;if(this.Ds?.sh===t)return this.Ds.eh;const i=new Vt(t);return this.Ds={sh:t,eh:i},i}rh(){return this.nh.zOrder?.()??"normal"}}function It(t){return{ri:t.text(),Ii:t.coordinate(),Ei:t.fixedCoordinate?.(),R:t.textColor(),X:t.backColor(),Vt:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class Bt{constructor(t,i){this.Gt=new F,this._h=t,this.uh=i}Tt(){return this.Gt.ht({Qi:this.uh.Qi(),...It(this._h)}),this.Gt}}class At extends L{constructor(t,i){super(),this._h=t,this.qi=i}ji(t,i,n){const s=It(this._h);n.X=s.X,t.R=s.R;const e=2/12*this.qi.P();n.Ti=e,n.Ri=e,n.Ii=s.Ii,n.Ei=s.Ei,t.ri=s.ri,t.Vt=s.Vt,t.pi=s.pi}}class zt extends Rt{constructor(t,i){super(t),this.dh=null,this.fh=null,this.ph=null,this.mh=null,this.ge=i}un(){const t=this.ah.timeAxisViews?.()??[];if(this.dh?.sh===t)return this.dh.eh;const i=this.ge.Qt().Bt(),n=t.map((t=>new Bt(t,i)));return this.dh={sh:t,eh:n},n}Nn(){const t=this.ah.priceAxisViews?.()??[];if(this.fh?.sh===t)return this.fh.eh;const i=this.ge.Wt(),n=t.map((t=>new At(t,i)));return this.fh={sh:t,eh:n},n}wh(){const t=this.ah.priceAxisPaneViews?.()??[];if(this.ph?.sh===t)return this.ph.eh;const i=t.map((t=>new Et(t)));return this.ph={sh:t,eh:i},i}gh(){const t=this.ah.timeAxisPaneViews?.()??[];if(this.mh?.sh===t)return this.mh.eh;const i=t.map((t=>new Et(t)));return this.mh={sh:t,eh:i},i}Mh(t,i){return this.ah.autoscaleInfo?.(t,i)??null}}function Ot(t,i,n,s){t.forEach((t=>{i(t).forEach((t=>{t.rh()===n&&s.push(t)}))}))}function Lt(t){return t.Ln()}function Nt(t){return t.wh()}function Wt(t){return t.gh()}const Ft=["Area","Line","Baseline"];class Ht extends mt{constructor(t,i,n,s,e){super(t),this.qt=new yt,this.er=new ot(this),this.bh=[],this.xh=new rt(this),this.Sh=null,this.Ch=null,this.yh=null,this.Ph=[],this.Sn=n,this.kh=i;const r=new _t(this);this.pn=[r],this.rr=new nt(r,this,t),Ft.includes(this.kh)&&(this.Sh=new lt(this)),this.Th(),this.nh=s(this,this.Qt(),e)}m(){null!==this.yh&&clearTimeout(this.yh)}Ie(t){return this.Sn.priceLineColor||t}Pe(t){const i={ke:!0},n=this.Wt();if(this.Qt().Bt().Zi()||n.Zi()||this.qt.Zi())return i;const s=this.Qt().Bt().ye(),e=this.zt();if(null===s||null===e)return i;let r,h;if(t){const t=this.qt.Ar();if(null===t)return i;r=t,h=t.Re}else{const t=this.qt.Wr(s.bi(),-1);if(null===t)return i;if(r=this.qt.kr(t.Re),null===r)return i;h=t.Re}const a=r.Ft[3],l=this.Rh().Dr(h,{Ft:r}),o=n.Nt(a,e.Ft);return{ke:!1,gt:a,ri:n.Xi(a,e.Ft),Le:n.Dh(a),Ne:n.Vh(a,e.Ft),R:l.cr,Ii:o,Re:h}}Rh(){return null!==this.Ch||(this.Ch=new gt(this)),this.Ch}N(){return this.Sn}hr(t){const i=t.priceScaleId;void 0!==i&&i!==this.Sn.priceScaleId&&this.Qt().Eh(this,i),_(this.Sn,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().Ih()),this.Qt().Bh(this),this.Qt().Ah(),this.nh.Pt("options")}ht(t,i){this.qt.ht(t),this.nh.Pt("data"),null!==this.Sh&&(i&&i.zh?this.Sh.be():0===t.length&&this.Sh.Me());const n=this.Qt().Hs(this);this.Qt().Oh(n),this.Qt().Bh(this),this.Qt().Ah(),this.Qt().ar()}Lh(t){const i=new vt(this,t);return this.bh.push(i),this.Qt().Bh(this),i}Nh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().Bh(this)}Wh(){return this.bh}Rr(){return this.kh}zt(){const t=this.Fh();return null===t?null:{Ft:t.Ft[3],Hh:t.wt}}Fh(){const t=this.Qt().Bt().ye();if(null===t)return null;const i=t.Uh();return this.qt.Wr(i,1)}Yn(){return this.qt}$h(t){const i=this.qt.kr(t);return null===i?null:"Bar"===this.kh||"Candlestick"===this.kh||"Custom"===this.kh?{jh:i.Ft[0],qh:i.Ft[1],Yh:i.Ft[2],Zh:i.Ft[3]}:i.Ft[3]}Kh(t){const i=[];Ot(this.Ph,Lt,"top",i);const n=this.Sh;return null!==n&&n.Vt()?(null===this.yh&&n.Se()&&(this.yh=setTimeout((()=>{this.yh=null,this.Qt().Xh()}),0)),n.xe(),i.unshift(n),i):i}Ln(){const t=[];this.Gh()||t.push(this.xh),t.push(this.nh,this.er);const i=this.bh.map((t=>t.lr()));return t.push(...i),Ot(this.Ph,Lt,"normal",t),t}Jh(){return this.Qh(Lt,"bottom")}ta(t){return this.Qh(Nt,t)}ia(t){return this.Qh(Wt,t)}na(t,i){return this.Ph.map((n=>n.Ys(t,i))).filter((t=>null!==t))}_n(){return[this.rr,...this.bh.map((t=>t._r()))]}Nn(t,i){if(i!==this.en&&!this.Gh())return[];const n=[...this.pn];for(const t of this.bh)n.push(t.ur());return this.Ph.forEach((t=>{n.push(...t.Nn())})),n}un(){const t=[];return this.Ph.forEach((i=>{t.push(...i.un())})),t}Mh(t,i){if(void 0!==this.Sn.autoscaleInfoProvider){const n=this.Sn.autoscaleInfoProvider((()=>{const n=this.sa(t,i);return null===n?null:n.Ke()}));return dt.Xe(n)}return this.sa(t,i)}ea(){return this.Sn.priceFormat.minMove}ra(){return this.ha}On(){this.nh.Pt();for(const t of this.pn)t.Pt();for(const t of this.bh)t.Pt();this.er.Pt(),this.xh.Pt(),this.Sh?.Pt(),this.Ph.forEach((t=>t.On()))}Wt(){return a(super.Wt())}At(t){if(!(("Line"===this.kh||"Area"===this.kh||"Baseline"===this.kh)&&this.Sn.crosshairMarkerVisible))return null;const i=this.qt.kr(t);if(null===i)return null;return{gt:i.Ft[3],ft:this.aa(),Ht:this.la(),Lt:this.oa(),Ot:this._a(t)}}Be(){return this.Sn.title}Vt(){return this.Sn.visible}ua(t){this.Ph.push(new zt(t,this))}ca(t){this.Ph=this.Ph.filter((i=>i.oh()!==t))}da(){if("Custom"===this.kh)return t=>this.nh.fa(t)}pa(){if("Custom"===this.kh)return t=>this.nh.va(t)}ma(){return this.qt.jr()}Gh(){return!q(this.Wt().wa())}sa(t,i){if(!c(t)||!c(i)||this.qt.Zi())return null;const n="Line"===this.kh||"Area"===this.kh||"Baseline"===this.kh||"Histogram"===this.kh?[3]:[2,1],s=this.qt.Ur(t,i,n);let e=null!==s?new ct(s.Jr,s.Qr):null,r=null;if("Histogram"===this.Rr()){const t=this.Sn.base,i=new ct(t,t);e=null!==e?e.ps(i):i}return this.Ph.forEach((n=>{const s=n.Mh(t,i);if(s?.priceRange){const t=new ct(s.priceRange.minValue,s.priceRange.maxValue);e=null!==e?e.ps(t):t}s?.margins&&(r=s.margins)})),new dt(e,r)}aa(){switch(this.kh){case"Line":case"Area":case"Baseline":return this.Sn.crosshairMarkerRadius}return 0}la(){switch(this.kh){case"Line":case"Area":case"Baseline":{const t=this.Sn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}oa(){switch(this.kh){case"Line":case"Area":case"Baseline":return this.Sn.crosshairMarkerBorderWidth}return 0}_a(t){switch(this.kh){case"Line":case"Area":case"Baseline":{const t=this.Sn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Rh().Dr(t).cr}Th(){switch(this.Sn.priceFormat.type){case"custom":this.ha={format:this.Sn.priceFormat.formatter};break;case"volume":this.ha=new J(this.Sn.priceFormat.precision);break;case"percent":this.ha=new G(this.Sn.priceFormat.precision);break;default:{const t=Math.pow(10,this.Sn.priceFormat.precision);this.ha=new X(t,this.Sn.priceFormat.minMove*t)}}null!==this.en&&this.en.ga()}Qh(t,i){const n=[];return Ot(this.Ph,t,i,n),n}}const Ut=[3],$t=[0,1,2,3];class jt{constructor(t){this.Sn=t}Ma(t,i,n){let s=t;if(0===this.Sn.mode)return s;const e=n.yn(),r=e.zt();if(null===r)return s;const h=e.Nt(t,r),a=n.ba().filter((t=>t instanceof Ht)).reduce(((t,s)=>{if(n.Us(s)||!s.Vt())return t;const e=s.Wt(),r=s.Yn();if(e.Zi()||!r.Te(i))return t;const h=r.kr(i);if(null===h)return t;const a=l(s.zt()),o=3===this.Sn.mode?$t:Ut;return t.concat(o.map((t=>e.Nt(h.Ft[t],a.Ft))))}),[]);if(0===a.length)return s;a.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=a[0];return s=e.Pn(o,r),s}}class qt extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:e}){if(null===this.qt)return;const r=Math.max(1,Math.floor(n));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=a(this.qt);if(h.xa){t.strokeStyle=h.Sa,s(t,h.Ca),t.beginPath();for(const s of h.ya){const e=Math.round(s.Pa*n);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.ka){t.strokeStyle=h.Ta,s(t,h.Ra),t.beginPath();for(const n of h.Da){const s=Math.round(n.Pa*e);t.moveTo(-r,s),t.lineTo(i.width+r,s)}t.stroke()}}))}}class Yt{constructor(t){this.Gt=new qt,this.St=!0,this.yt=t}Pt(){this.St=!0}Tt(){if(this.St){const t=this.yt.Qt().N().grid,i={ka:t.horzLines.visible,xa:t.vertLines.visible,Ta:t.horzLines.color,Sa:t.vertLines.color,Ra:t.horzLines.style,Ca:t.vertLines.style,Da:this.yt.yn().Va(),ya:(this.yt.Qt().Bt().Va()||[]).map((t=>({Pa:t.coord})))};this.Gt.ht(i),this.St=!1}return this.Gt}}class Zt{constructor(t){this.nh=new Yt(t)}lr(){return this.nh}}const Kt={Ea:4,Ia:1e-4};function Xt(t,i){const n=100*(t-i)/i;return i<0?-n:n}function Gt(t,i){const n=Xt(t.$e(),i),s=Xt(t.je(),i);return new ct(n,s)}function Jt(t,i){const n=100*(t-i)/i+100;return i<0?-n:n}function Qt(t,i){const n=Jt(t.$e(),i),s=Jt(t.je(),i);return new ct(n,s)}function ti(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.log10(n+i.Ia)+i.Ea;return t<0?-s:s}function ii(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.pow(10,n-i.Ea)-i.Ia;return t<0?-s:s}function ni(t,i){if(null===t)return null;const n=ti(t.$e(),i),s=ti(t.je(),i);return new ct(n,s)}function si(t,i){if(null===t)return null;const n=ii(t.$e(),i),s=ii(t.je(),i);return new ct(n,s)}function ei(t){if(null===t)return Kt;const i=Math.abs(t.je()-t.$e());if(i>=1||i<1e-15)return Kt;const n=Math.ceil(Math.abs(Math.log10(i))),s=Kt.Ea+n;return{Ea:s,Ia:1/Math.pow(10,s)}}function ri(t,i,n){return Math.min(Math.max(t,i),n)}function hi(t,i,n){return i-t<=n}function ai(t){const i=Math.ceil(t);return i%2==0?i-1:i}class li{constructor(t,i){if(this.Ba=t,this.Aa=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.Ba))this.za=[2,2.5,2];else{this.za=[];for(let t=this.Ba;1!==t;){if(t%2==0)this.za.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.za.push(2,2.5),t/=5}if(this.za.length>100)throw new Error("something wrong with base")}}}Oa(t,i,n){const s=0===this.Ba?0:1/this.Ba;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Aa[0];for(;;){const t=hi(e,s,1e-14)&&e>s+1e-14,i=hi(e,n*h,1e-14),a=hi(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.Aa[++r%this.Aa.length]}if(e<=s+1e-14&&(e=s),e=Math.max(1,e),this.za.length>0&&(a=e,l=1,o=1e-14,Math.abs(a-l)<o))for(r=0,h=this.za[0];hi(e,n*h,1e-14)&&e>s+1e-14;)e/=h,h=this.za[++r%this.za.length];var a,l,o;return e}}class oi{constructor(t,i,n,s){this.La=[],this.qi=t,this.Ba=i,this.Na=n,this.Wa=s}Oa(t,i){if(t<i)throw new Error("high < low");const n=this.qi.$t(),s=(t-i)*this.Fa()/n,e=new li(this.Ba,[2,2.5,2]),r=new li(this.Ba,[2,2,2.5]),h=new li(this.Ba,[2.5,2,2]),a=[];return a.push(e.Oa(t,i,s),r.Oa(t,i,s),h.Oa(t,i,s)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(a)}Ha(){const t=this.qi,i=t.zt();if(null===i)return void(this.La=[]);const n=t.$t(),s=this.Na(n-1,i),e=this.Na(0,i),r=this.qi.N().entireTextOnly?this.Ua()/2:0,h=r,a=n-1-r,l=Math.max(s,e),o=Math.min(s,e);if(l===o)return void(this.La=[]);let _=this.Oa(l,o),u=l%_;u+=u<0?_:0;const c=l>=o?1:-1;let d=null,f=0;for(let n=l-u;n>o;n-=_){const s=this.Wa(n,i,!0);null!==d&&Math.abs(s-d)<this.Fa()||(s<h||s>a||(f<this.La.length?(this.La[f].Pa=s,this.La[f].$a=t.ja(n)):this.La.push({Pa:s,$a:t.ja(n)}),f++,d=s,t.qa()&&(_=this.Oa(n*c,o))))}this.La.length=f}Va(){return this.La}Ua(){return this.qi.P()}Fa(){return Math.ceil(2.5*this.Ua())}}function _i(t){return t.slice().sort(((t,i)=>a(t.hn())-a(i.hn())))}var ui;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(ui||(ui={}));const ci=new G,di=new X(100,1);class fi{constructor(t,i,n,s,e){this.Ya=0,this.Za=null,this.Ge=null,this.Ka=null,this.Xa={Ga:!1,Ja:null},this.Qa=0,this.tl=0,this.il=new o,this.nl=new o,this.sl=[],this.el=null,this.rl=null,this.hl=null,this.al=null,this.ha=di,this.ll=ei(null),this.ol=t,this.Sn=i,this._l=n,this.ul=s,this.cl=e,this.dl=new oi(this,100,this.fl.bind(this),this.pl.bind(this))}wa(){return this.ol}N(){return this.Sn}hr(t){if(_(this.Sn,t),this.ga(),void 0!==t.mode&&this.vl({ie:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),n=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(n<0||n>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(i+n>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+n}`);this.ml(),this.rl=null}}wl(){return this.Sn.autoScale}qa(){return 1===this.Sn.mode}Oe(){return 2===this.Sn.mode}gl(){return 3===this.Sn.mode}ie(){return{Qn:this.Sn.autoScale,Ml:this.Sn.invertScale,ie:this.Sn.mode}}vl(t){const i=this.ie();let n=null;void 0!==t.Qn&&(this.Sn.autoScale=t.Qn),void 0!==t.ie&&(this.Sn.mode=t.ie,2!==t.ie&&3!==t.ie||(this.Sn.autoScale=!0),this.Xa.Ga=!1),1===i.ie&&t.ie!==i.ie&&(!function(t,i){if(null===t)return!1;const n=ii(t.$e(),i),s=ii(t.je(),i);return isFinite(n)&&isFinite(s)}(this.Ge,this.ll)?this.Sn.autoScale=!0:(n=si(this.Ge,this.ll),null!==n&&this.bl(n))),1===t.ie&&t.ie!==i.ie&&(n=ni(this.Ge,this.ll),null!==n&&this.bl(n));const s=i.ie!==this.Sn.mode;s&&(2===i.ie||this.Oe())&&this.ga(),s&&(3===i.ie||this.gl())&&this.ga(),void 0!==t.Ml&&i.Ml!==t.Ml&&(this.Sn.invertScale=t.Ml,this.xl()),this.nl.p(i,this.ie())}Sl(){return this.nl}P(){return this._l.fontSize}$t(){return this.Ya}Cl(t){this.Ya!==t&&(this.Ya=t,this.ml(),this.rl=null)}yl(){if(this.Za)return this.Za;const t=this.$t()-this.Pl()-this.kl();return this.Za=t,t}Qe(){return this.Tl(),this.Ge}bl(t,i){const n=this.Ge;(i||null===n&&null!==t||null!==n&&!n.He(t))&&(this.rl=null,this.Ge=t)}Zi(){return this.Tl(),0===this.Ya||!this.Ge||this.Ge.Zi()}Rl(t){return this.Ml()?t:this.$t()-1-t}Nt(t,i){return this.Oe()?t=Xt(t,i):this.gl()&&(t=Jt(t,i)),this.pl(t,i)}Dl(t,i,n){this.Tl();const s=this.kl(),e=a(this.Qe()),r=e.$e(),h=e.je(),l=this.yl()-1,o=this.Ml(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Vl();for(let n=u;n<c;n++){const e=t[n],h=e.gt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.gt,i));const l=s+_*(a-r),u=o?l:this.Ya-1-l;e.ut=u}}El(t,i,n){this.Tl();const s=this.kl(),e=a(this.Qe()),r=e.$e(),h=e.je(),l=this.yl()-1,o=this.Ml(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Vl();for(let n=u;n<c;n++){const e=t[n];let h=e.jh,a=e.qh,l=e.Yh,u=e.Zh;null!==d&&(h=d(e.jh,i),a=d(e.qh,i),l=d(e.Yh,i),u=d(e.Zh,i));let c=s+_*(h-r),f=o?c:this.Ya-1-c;e.Il=f,c=s+_*(a-r),f=o?c:this.Ya-1-c,e.Bl=f,c=s+_*(l-r),f=o?c:this.Ya-1-c,e.Al=f,c=s+_*(u-r),f=o?c:this.Ya-1-c,e.zl=f}}Pn(t,i){const n=this.fl(t,i);return this.Ol(n,i)}Ol(t,i){let n=t;return this.Oe()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this.gl()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n}ba(){return this.sl}Dt(){if(this.el)return this.el;let t=[];for(let i=0;i<this.sl.length;i++){const n=this.sl[i];null===n.hn()&&n.an(i+1),t.push(n)}return t=_i(t),this.el=t,this.el}Ll(t){-1===this.sl.indexOf(t)&&(this.sl.push(t),this.ga(),this.Nl())}Wl(t){const i=this.sl.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.sl.splice(i,1),0===this.sl.length&&(this.vl({Qn:!0}),this.bl(null)),this.ga(),this.Nl()}zt(){let t=null;for(const i of this.sl){const n=i.zt();null!==n&&((null===t||n.Hh<t.Hh)&&(t=n))}return null===t?null:t.Ft}Ml(){return this.Sn.invertScale}Va(){const t=null===this.zt();if(null!==this.rl&&(t||this.rl.Fl===t))return this.rl.Va;this.dl.Ha();const i=this.dl.Va();return this.rl={Va:i,Fl:t},this.il.p(),i}Hl(){return this.il}Ul(t){this.Oe()||this.gl()||null===this.hl&&null===this.Ka&&(this.Zi()||(this.hl=this.Ya-t,this.Ka=a(this.Qe()).Ue()))}$l(t){if(this.Oe()||this.gl())return;if(null===this.hl)return;this.vl({Qn:!1}),(t=this.Ya-t)<0&&(t=0);let i=(this.hl+.2*(this.Ya-1))/(t+.2*(this.Ya-1));const n=a(this.Ka).Ue();i=Math.max(i,.1),n.Ye(i),this.bl(n)}jl(){this.Oe()||this.gl()||(this.hl=null,this.Ka=null)}ql(t){this.wl()||null===this.al&&null===this.Ka&&(this.Zi()||(this.al=t,this.Ka=a(this.Qe()).Ue()))}Yl(t){if(this.wl())return;if(null===this.al)return;const i=a(this.Qe()).qe()/(this.yl()-1);let n=t-this.al;this.Ml()&&(n*=-1);const s=n*i,e=a(this.Ka).Ue();e.Ze(s),this.bl(e,!0),this.rl=null}Zl(){this.wl()||null!==this.al&&(this.al=null,this.Ka=null)}ra(){return this.ha||this.ga(),this.ha}Xi(t,i){switch(this.Sn.mode){case 2:return this.Kl(Xt(t,i));case 3:return this.ra().format(Jt(t,i));default:return this.sr(t)}}ja(t){switch(this.Sn.mode){case 2:return this.Kl(t);case 3:return this.ra().format(t);default:return this.sr(t)}}Dh(t){return this.sr(t,a(this.Xl()).ra())}Vh(t,i){return t=Xt(t,i),this.Kl(t,ci)}Gl(){return this.sl}Jl(t){this.Xa={Ja:t,Ga:!1}}On(){this.sl.forEach((t=>t.On()))}ga(){this.rl=null;const t=this.Xl();let i=100;null!==t&&(i=Math.round(1/t.ea())),this.ha=di,this.Oe()?(this.ha=ci,i=100):this.gl()?(this.ha=new X(100,1),i=100):null!==t&&(this.ha=t.ra()),this.dl=new oi(this,i,this.fl.bind(this),this.pl.bind(this)),this.dl.Ha()}Nl(){this.el=null}Ki(){return this.cl}Xl(){return this.sl[0]||null}Pl(){return this.Ml()?this.Sn.scaleMargins.bottom*this.$t()+this.tl:this.Sn.scaleMargins.top*this.$t()+this.Qa}kl(){return this.Ml()?this.Sn.scaleMargins.top*this.$t()+this.Qa:this.Sn.scaleMargins.bottom*this.$t()+this.tl}Tl(){this.Xa.Ga||(this.Xa.Ga=!0,this.Ql())}ml(){this.Za=null}pl(t,i){if(this.Tl(),this.Zi())return 0;t=this.qa()&&t?ti(t,this.ll):t;const n=a(this.Qe()),s=this.kl()+(this.yl()-1)*(t-n.$e())/n.qe();return this.Rl(s)}fl(t,i){if(this.Tl(),this.Zi())return 0;const n=this.Rl(t),s=a(this.Qe()),e=s.$e()+s.qe()*((n-this.kl())/(this.yl()-1));return this.qa()?ii(e,this.ll):e}xl(){this.rl=null,this.dl.Ha()}Ql(){const t=this.Xa.Ja;if(null===t)return;let i=null;const n=this.Gl();let s=0,e=0;for(const r of n){if(!r.Vt())continue;const n=r.zt();if(null===n)continue;const h=r.Mh(t.Uh(),t.bi());let l=h&&h.Qe();if(null!==l){switch(this.Sn.mode){case 1:l=ni(l,this.ll);break;case 2:l=Gt(l,n.Ft);break;case 3:l=Qt(l,n.Ft)}if(i=null===i?l:i.ps(a(l)),null!==h){const t=h.tr();null!==t&&(s=Math.max(s,t.above),e=Math.max(e,t.below))}}}if(s===this.Qa&&e===this.tl||(this.Qa=s,this.tl=e,this.rl=null,this.ml()),null!==i){if(i.$e()===i.je()){const t=this.Xl(),n=5*(null===t||this.Oe()||this.gl()?1:t.ea());this.qa()&&(i=si(i,this.ll)),i=new ct(i.$e()-n,i.je()+n),this.qa()&&(i=ni(i,this.ll))}if(this.qa()){const t=si(i,this.ll),n=ei(t);if(r=n,h=this.ll,r.Ea!==h.Ea||r.Ia!==h.Ia){const s=null!==this.Ka?si(this.Ka,this.ll):null;this.ll=n,i=ni(t,n),null!==s&&(this.Ka=ni(s,n))}}this.bl(i)}else null===this.Ge&&(this.bl(new ct(-.5,.5)),this.ll=ei(null));var r,h;this.Xa.Ga=!0}Vl(){return this.Oe()?Xt:this.gl()?Jt:this.qa()?t=>ti(t,this.ll):null}io(t,i,n){return void 0===i?(void 0===n&&(n=this.ra()),n.format(t)):i(t)}sr(t,i){return this.io(t,this.ul.priceFormatter,i)}Kl(t,i){return this.io(t,this.ul.percentageFormatter,i)}}function pi(t){return t instanceof Ht}class vi{constructor(t,i){this.sl=[],this.no=new Map,this.Ya=0,this.so=0,this.eo=1e3,this.el=null,this.ro=new o,this.Ph=[],this.uh=t,this.tn=i,this.ho=new Zt(this);const n=i.N();this.ao=this.lo("left",n.leftPriceScale),this.oo=this.lo("right",n.rightPriceScale),this.ao.Sl().i(this._o.bind(this,this.ao),this),this.oo.Sl().i(this._o.bind(this,this.oo),this),this.uo(n)}uo(t){if(t.leftPriceScale&&this.ao.hr(t.leftPriceScale),t.rightPriceScale&&this.oo.hr(t.rightPriceScale),t.localization&&(this.ao.ga(),this.oo.ga()),t.overlayPriceScales){const i=Array.from(this.no.values());for(const n of i){const i=a(n[0].Wt());i.hr(t.overlayPriceScales),t.localization&&i.ga()}}}co(t){switch(t){case"left":return this.ao;case"right":return this.oo}return this.no.has(t)?h(this.no.get(t))[0].Wt():null}m(){this.Qt().do().u(this),this.ao.Sl().u(this),this.oo.Sl().u(this),this.sl.forEach((t=>{t.m&&t.m()})),this.Ph=this.Ph.filter((t=>{const i=t.oh();return i.detached&&i.detached(),!1})),this.ro.p()}fo(){return this.eo}po(t){this.eo=t}Qt(){return this.tn}Qi(){return this.so}$t(){return this.Ya}vo(t){this.so=t,this.mo()}Cl(t){this.Ya=t,this.ao.Cl(t),this.oo.Cl(t),this.sl.forEach((i=>{if(this.Us(i)){const n=i.Wt();null!==n&&n.Cl(t)}})),this.mo()}wo(){return this.sl.filter(pi)}ba(){return this.sl}Us(t){const i=t.Wt();return null===i||this.ao!==i&&this.oo!==i}Ll(t,i,n){const s=void 0!==n?n:this.bo().Mo+1;this.xo(t,i,s)}Wl(t){const i=this.sl.indexOf(t);r(-1!==i,"removeDataSource: invalid data source"),this.sl.splice(i,1);const n=a(t.Wt()).wa();if(this.no.has(n)){const i=h(this.no.get(n)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.no.delete(n))}const s=t.Wt();s&&s.ba().indexOf(t)>=0&&s.Wl(t),null!==s&&(s.Nl(),this.So(s)),this.el=null}js(t){return t===this.ao?"left":t===this.oo?"right":"overlay"}Co(){return this.ao}yo(){return this.oo}Po(t,i){t.Ul(i)}ko(t,i){t.$l(i),this.mo()}To(t){t.jl()}Ro(t,i){t.ql(i)}Do(t,i){t.Yl(i),this.mo()}Vo(t){t.Zl()}mo(){this.sl.forEach((t=>{t.On()}))}yn(){let t=null;return this.tn.N().rightPriceScale.visible&&0!==this.oo.ba().length?t=this.oo:this.tn.N().leftPriceScale.visible&&0!==this.ao.ba().length?t=this.ao:0!==this.sl.length&&(t=this.sl[0].Wt()),null===t&&(t=this.oo),t}$s(){let t=null;return this.tn.N().rightPriceScale.visible?t=this.oo:this.tn.N().leftPriceScale.visible&&(t=this.ao),t}So(t){null!==t&&t.wl()&&this.Eo(t)}Io(t){const i=this.uh.ye();t.vl({Qn:!0}),null!==i&&t.Jl(i),this.mo()}Bo(){this.Eo(this.ao),this.Eo(this.oo)}Ao(){this.So(this.ao),this.So(this.oo),this.sl.forEach((t=>{this.Us(t)&&this.So(t.Wt())})),this.mo(),this.tn.ar()}Dt(){return null===this.el&&(this.el=_i(this.sl)),this.el}Et(){return this.Dt().filter(pi)}zo(){return this.ro}Oo(){return this.ho}ua(t){this.Ph.push(new Dt(t))}ca(t){this.Ph=this.Ph.filter((i=>i.oh()!==t)),t.detached&&t.detached(),this.tn.ar()}Lo(){return this.Ph}na(t,i){return this.Ph.map((n=>n.Ys(t,i))).filter((t=>null!==t))}Eo(t){const i=t.Gl();if(i&&i.length>0&&!this.uh.Zi()){const i=this.uh.ye();null!==i&&t.Jl(i)}t.On()}bo(){const t=this.Dt();if(0===t.length)return{No:0,Mo:0};let i=0,n=0;for(let s=0;s<t.length;s++){const e=t[s].hn();null!==e&&(e<i&&(i=e),e>n&&(n=e))}return{No:i,Mo:n}}xo(t,i,n){let s=this.co(i);if(null===s&&(s=this.lo(i,this.tn.N().overlayPriceScales)),this.sl.push(t),!q(i)){const n=this.no.get(i)||[];n.push(t),this.no.set(i,n)}s.Ll(t),t.ln(s),t.an(n),this.So(s),this.el=null}_o(t,i,n){i.ie!==n.ie&&this.Eo(t)}lo(t,i){const n={visible:!0,autoScale:!0,...p(i)},s=new fi(t,n,this.tn.N().layout,this.tn.N().localization,this.tn.Ki());return s.Cl(this.$t()),s}}function mi(t){return{Wo:t.Wo,Fo:{Zs:t.Ho.externalId},Uo:t.Ho.cursorStyle}}function wi(t,i,n,s){for(const e of t){const t=e.Tt(s);if(null!==t&&t.Ys){const s=t.Ys(i,n);if(null!==s)return{$o:e,Fo:s}}}return null}function gi(t){return void 0!==t.Ln}function Mi(t,i,n){const s=[t,...t.Dt()],e=function(t,i,n){let s,e;for(const a of t){const t=a.na?.(i,n)??[];for(const i of t)r=i.zOrder,h=s?.zOrder,(!h||"top"===r&&"top"!==h||"normal"===r&&"bottom"===h)&&(s=i,e=a)}var r,h;return s&&e?{Ho:s,Wo:e}:null}(s,i,n);if("top"===e?.Ho.zOrder)return mi(e);for(const r of s){if(e&&e.Wo===r&&"bottom"!==e.Ho.zOrder&&!e.Ho.isBackground)return mi(e);if(gi(r)){const s=wi(r.Ln(t),i,n,t);if(null!==s)return{Wo:r,$o:s.$o,Fo:s.Fo}}if(e&&e.Wo===r&&"bottom"!==e.Ho.zOrder&&e.Ho.isBackground)return mi(e)}return e?.Ho?mi(e):null}class bi{constructor(t,i,n=50){this.Ps=0,this.ks=1,this.Ts=1,this.Ds=new Map,this.Rs=new Map,this.jo=t,this.qo=i,this.Vs=n}Yo(t){const i=t.time,n=this.qo.cacheKey(i),s=this.Ds.get(n);if(void 0!==s)return s.Zo;if(this.Ps===this.Vs){const t=this.Rs.get(this.Ts);this.Rs.delete(this.Ts),this.Ds.delete(h(t)),this.Ts++,this.Ps--}const e=this.jo(t);return this.Ds.set(n,{Zo:e,As:this.ks}),this.Rs.set(this.ks,n),this.Ps++,this.ks++,e}}class xi{constructor(t,i){r(t<=i,"right should be >= left"),this.Ko=t,this.Xo=i}Uh(){return this.Ko}bi(){return this.Xo}Go(){return this.Xo-this.Ko+1}Te(t){return this.Ko<=t&&t<=this.Xo}He(t){return this.Ko===t.Uh()&&this.Xo===t.bi()}}function Si(t,i){return null===t||null===i?t===i:t.He(i)}class Ci{constructor(){this.Jo=new Map,this.Ds=null,this.Qo=!1}t_(t){this.Qo=t,this.Ds=null}i_(t,i){this.n_(i),this.Ds=null;for(let n=i;n<t.length;++n){const i=t[n];let s=this.Jo.get(i.timeWeight);void 0===s&&(s=[],this.Jo.set(i.timeWeight,s)),s.push({index:n,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}s_(t,i,n,s,e){const r=Math.ceil(i/t);return null!==this.Ds&&this.Ds.e_===r&&e===this.Ds.r_&&n===this.Ds.h_||(this.Ds={r_:e,h_:n,Va:this.a_(r,n,s),e_:r}),this.Ds.Va}n_(t){if(0===t)return void this.Jo.clear();const i=[];this.Jo.forEach(((n,s)=>{t<=n[0].index?i.push(s):n.splice(bt(n,t,(i=>i.index<t)),1/0)}));for(const t of i)this.Jo.delete(t)}a_(t,i,n){let s=[];const e=t=>!i||n.has(t.index);for(const i of Array.from(this.Jo.keys()).sort(((t,i)=>i-t))){if(!this.Jo.get(i))continue;const n=s;s=[];const r=n.length;let a=0;const l=h(this.Jo.get(i)),o=l.length;let _=1/0,u=-1/0;for(let i=0;i<o;i++){const h=l[i],o=h.index;for(;a<r;){const t=n[a],i=t.index;if(!(i<o&&e(t))){_=i;break}a++,s.push(t),u=i,_=1/0}if(_-o>=t&&o-u>=t&&e(h))s.push(h),u=o;else if(this.Qo)return n}for(;a<r;a++)e(n[a])&&s.push(n[a])}return s}}class yi{constructor(t){this.l_=t}o_(){return null===this.l_?null:new xi(Math.floor(this.l_.Uh()),Math.ceil(this.l_.bi()))}__(){return this.l_}static u_(){return new yi(null)}}function Pi(t,i){return t.weight>i.weight?t:i}class ki{constructor(t,i,n,s){this.so=0,this.c_=null,this.d_=[],this.al=null,this.hl=null,this.f_=new Ci,this.p_=new Map,this.v_=yi.u_(),this.m_=!0,this.w_=new o,this.g_=new o,this.M_=new o,this.b_=null,this.x_=null,this.S_=new Map,this.C_=-1,this.y_=[],this.Sn=i,this.ul=n,this.P_=i.rightOffset,this.k_=i.barSpacing,this.tn=t,this.qo=s,this.T_(),this.f_.t_(i.uniformDistribution),this.R_()}N(){return this.Sn}D_(t){_(this.ul,t),this.V_(),this.T_()}hr(t,i){_(this.Sn,t),this.Sn.fixLeftEdge&&this.E_(),this.Sn.fixRightEdge&&this.I_(),void 0!==t.barSpacing&&this.tn.cs(t.barSpacing),void 0!==t.rightOffset&&this.tn.ds(t.rightOffset),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.tn.cs(t.barSpacing??this.k_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.Sn.ignoreWhitespaceIndices&&this.R_(),this.V_(),this.T_(),this.M_.p()}kn(t){return this.d_[t]?.time??null}nn(t){return this.d_[t]??null}B_(t,i){if(this.d_.length<1)return null;if(this.qo.key(t)>this.qo.key(this.d_[this.d_.length-1].time))return i?this.d_.length-1:null;const n=bt(this.d_,this.qo.key(t),((t,i)=>this.qo.key(t.time)<i));return this.qo.key(t)<this.qo.key(this.d_[n].time)?i?n:null:n}Zi(){return 0===this.so||0===this.d_.length||null===this.c_}A_(){return this.d_.length>0}ye(){return this.z_(),this.v_.o_()}O_(){return this.z_(),this.v_.__()}L_(){const t=this.ye();if(null===t)return null;const i={from:t.Uh(),to:t.bi()};return this.N_(i)}N_(t){const i=Math.round(t.from),n=Math.round(t.to),s=a(this.W_()),e=a(this.F_());return{from:a(this.nn(Math.max(s,i))),to:a(this.nn(Math.min(e,n)))}}H_(t){return{from:a(this.B_(t.from,!0)),to:a(this.B_(t.to,!0))}}Qi(){return this.so}vo(t){if(!isFinite(t)||t<=0)return;if(this.so===t)return;const i=this.O_(),n=this.so;if(this.so=t,this.m_=!0,this.Sn.lockVisibleTimeRangeOnResize&&0!==n){const i=this.k_*t/n;this.k_=i}if(this.Sn.fixLeftEdge&&null!==i&&i.Uh()<=0){const i=n-t;this.P_-=Math.round(i/this.k_)+1,this.m_=!0}this.U_(),this.j_()}jt(t){if(this.Zi()||!c(t))return 0;const i=this.q_()+this.P_-t;return this.so-(i+.5)*this.k_-1}Y_(t,i){const n=this.q_(),s=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=s;i<e;i++){const s=t[i].wt,e=n+this.P_-s,r=this.so-(e+.5)*this.k_-1;t[i]._t=r}}Z_(t,i){const n=Math.ceil(this.K_(t));return i&&this.Sn.ignoreWhitespaceIndices&&!this.X_(n)?this.G_(n):n}ds(t){this.m_=!0,this.P_=t,this.j_(),this.tn.J_(),this.tn.ar()}Q_(){return this.k_}cs(t){this.tu(t),this.j_(),this.tn.J_(),this.tn.ar()}iu(){return this.P_}Va(){if(this.Zi())return null;if(null!==this.x_)return this.x_;const t=this.k_,i=5*(this.tn.N().layout.fontSize+4)/8*(this.Sn.tickMarkMaxCharacterLength||8),n=Math.round(i/t),s=a(this.ye()),e=Math.max(s.Uh(),s.Uh()-n),r=Math.max(s.bi(),s.bi()-n),h=this.f_.s_(t,i,this.Sn.ignoreWhitespaceIndices,this.S_,this.C_),l=this.W_()+n,o=this.F_()-n,_=this.nu(),u=this.Sn.fixLeftEdge||_,c=this.Sn.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.index&&t.index<=r))continue;let n;d<this.y_.length?(n=this.y_[d],n.coord=this.jt(t.index),n.label=this.su(t),n.weight=t.weight):(n={needAlignCoordinate:!1,coord:this.jt(t.index),label:this.su(t),weight:t.weight},this.y_.push(n)),this.k_>i/2&&!_?n.needAlignCoordinate=!1:n.needAlignCoordinate=u&&t.index<=l||c&&t.index>=o,d++}return this.y_.length=d,this.x_=this.y_,this.y_}eu(){this.m_=!0,this.cs(this.Sn.barSpacing),this.ds(this.Sn.rightOffset)}ru(t){this.m_=!0,this.c_=t,this.j_(),this.E_()}hu(t,i){const n=this.K_(t),s=this.Q_(),e=s+i*(s/10);this.cs(e),this.Sn.rightBarStaysOnScroll||this.ds(this.iu()+(n-this.K_(t)))}Ul(t){this.al&&this.Zl(),null===this.hl&&null===this.b_&&(this.Zi()||(this.hl=t,this.au()))}$l(t){if(null===this.b_)return;const i=ri(this.so-t,0,this.so),n=ri(this.so-a(this.hl),0,this.so);0!==i&&0!==n&&this.cs(this.b_.Q_*i/n)}jl(){null!==this.hl&&(this.hl=null,this.lu())}ql(t){null===this.al&&null===this.b_&&(this.Zi()||(this.al=t,this.au()))}Yl(t){if(null===this.al)return;const i=(this.al-t)/this.Q_();this.P_=a(this.b_).iu+i,this.m_=!0,this.j_()}Zl(){null!==this.al&&(this.al=null,this.lu())}ou(){this._u(this.Sn.rightOffset)}_u(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 n=this.P_,s=performance.now();this.tn.ls({uu:t=>(t-s)/i>=1,cu:e=>{const r=(e-s)/i;return r>=1?t:n+(t-n)*r}})}Pt(t,i){this.m_=!0,this.d_=t,this.f_.i_(t,i),this.j_()}du(){return this.w_}fu(){return this.g_}pu(){return this.M_}q_(){return this.c_||0}vu(t){const i=t.Go();this.tu(this.so/i),this.P_=t.bi()-this.q_(),this.j_(),this.m_=!0,this.tn.J_(),this.tn.ar()}mu(){const t=this.W_(),i=this.F_();null!==t&&null!==i&&this.vu(new xi(t,i+this.Sn.rightOffset))}wu(t){const i=new xi(t.from,t.to);this.vu(i)}sn(t){return void 0!==this.ul.timeFormatter?this.ul.timeFormatter(t.originalTime):this.qo.formatHorzItem(t.time)}R_(){if(!this.Sn.ignoreWhitespaceIndices)return;this.S_.clear();const t=this.tn.jn();for(const i of t)for(const t of i.ma())this.S_.set(t,!0);this.C_++}nu(){const t=this.tn.N().handleScroll,i=this.tn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}W_(){return 0===this.d_.length?null:0}F_(){return 0===this.d_.length?null:this.d_.length-1}gu(t){return(this.so-1-t)/this.k_}K_(t){const i=this.gu(t),n=this.q_()+this.P_-i;return Math.round(1e6*n)/1e6}tu(t){const i=this.k_;this.k_=t,this.U_(),i!==this.k_&&(this.m_=!0,this.Mu())}z_(){if(!this.m_)return;if(this.m_=!1,this.Zi())return void this.bu(yi.u_());const t=this.q_(),i=this.so/this.k_,n=this.P_+t,s=new xi(n-i+1,n);this.bu(new yi(s))}U_(){const t=ri(this.k_,this.xu(),this.Su());this.k_!==t&&(this.k_=t,this.m_=!0)}Su(){return this.Sn.maxBarSpacing>0?this.Sn.maxBarSpacing:.5*this.so}xu(){return this.Sn.fixLeftEdge&&this.Sn.fixRightEdge&&0!==this.d_.length?this.so/this.d_.length:this.Sn.minBarSpacing}j_(){const t=this.Cu();null!==t&&this.P_<t&&(this.P_=t,this.m_=!0);const i=this.yu();this.P_>i&&(this.P_=i,this.m_=!0)}Cu(){const t=this.W_(),i=this.c_;if(null===t||null===i)return null;return t-i-1+(this.Sn.fixLeftEdge?this.so/this.k_:Math.min(2,this.d_.length))}yu(){return this.Sn.fixRightEdge?0:this.so/this.k_-Math.min(2,this.d_.length)}au(){this.b_={Q_:this.Q_(),iu:this.iu()}}lu(){this.b_=null}su(t){let i=this.p_.get(t.weight);return void 0===i&&(i=new bi((t=>this.Pu(t)),this.qo),this.p_.set(t.weight,i)),i.Yo(t)}Pu(t){return this.qo.formatTickmark(t,this.ul)}bu(t){const i=this.v_;this.v_=t,Si(i.o_(),this.v_.o_())||this.w_.p(),Si(i.__(),this.v_.__())||this.g_.p(),this.Mu()}Mu(){this.x_=null}V_(){this.Mu(),this.p_.clear()}T_(){this.qo.updateFormatter(this.ul)}E_(){if(!this.Sn.fixLeftEdge)return;const t=this.W_();if(null===t)return;const i=this.ye();if(null===i)return;const n=i.Uh()-t;if(n<0){const t=this.P_-n-1;this.ds(t)}this.U_()}I_(){this.j_(),this.U_()}X_(t){return!this.Sn.ignoreWhitespaceIndices||(this.S_.get(t)||!1)}G_(t){const i=function*(t){const i=Math.round(t),n=i<t;let s=1;for(;;)n?(yield i+s,yield i-s):(yield i-s,yield i+s),s++}(t),n=this.F_();for(;n;){const t=i.next().value;if(this.S_.get(t))return t;if(t<0||t>n)break}return t}}var Ti,Ri,Di,Vi,Ei;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ti||(Ti={}));class Ii{constructor(t,i,n){this.ku=[],this.Tu=[],this.so=0,this.Ru=null,this.Du=new o,this.Vu=new o,this.Eu=null,this.Iu=t,this.Sn=i,this.qo=n,this.cl=new S(this.Sn.layout.colorParsers),this.Bu=new M(this),this.uh=new ki(this,i.timeScale,this.Sn.localization,n),this.Ct=new j(this,i.crosshair),this.Au=new jt(i.crosshair),this.zu(0),this.ku[0].po(2e3),this.Ou=this.Lu(0),this.Nu=this.Lu(1)}Ih(){this.Wu(Y.gs())}ar(){this.Wu(Y.ws())}Xh(){this.Wu(new Y(1))}Bh(t){const i=this.Fu(t);this.Wu(i)}Hu(){return this.Ru}Uu(t){if(this.Ru?.Wo===t?.Wo&&this.Ru?.Fo?.Zs===t?.Fo?.Zs)return;const i=this.Ru;this.Ru=t,null!==i&&this.Bh(i.Wo),null!==t&&t.Wo!==i?.Wo&&this.Bh(t.Wo)}N(){return this.Sn}hr(t){_(this.Sn,t),this.ku.forEach((i=>i.uo(t))),void 0!==t.timeScale&&this.uh.hr(t.timeScale),void 0!==t.localization&&this.uh.D_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Du.p(),this.Ou=this.Lu(0),this.Nu=this.Lu(1),this.Ih()}$u(t,i,n=0){const s=this.ku[n];if(void 0===s)return;if("left"===t)return _(this.Sn,{leftPriceScale:i}),s.uo({leftPriceScale:i}),this.Du.p(),void this.Ih();if("right"===t)return _(this.Sn,{rightPriceScale:i}),s.uo({rightPriceScale:i}),this.Du.p(),void this.Ih();const e=this.ju(t,n);null!==e&&(e.Wt.hr(i),this.Du.p())}ju(t,i){const n=this.ku[i];if(void 0===n)return null;const s=n.co(t);return null!==s?{Fn:n,Wt:s}:null}Bt(){return this.uh}Hn(){return this.ku}qu(){return this.Ct}Yu(){return this.Vu}Zu(t,i){t.Cl(i),this.J_()}vo(t){this.so=t,this.uh.vo(this.so),this.ku.forEach((i=>i.vo(t))),this.J_()}Ku(t){1!==this.ku.length&&(r(t>=0&&t<this.ku.length,"Invalid pane index"),this.ku.splice(t,1),this.Ih())}Xu(t,i){if(this.ku.length<2)return;r(t>=0&&t<this.ku.length,"Invalid pane index");const n=this.ku[t],s=this.ku.reduce(((t,i)=>t+i.fo()),0),e=this.ku.reduce(((t,i)=>t+i.$t()),0),h=e-30*(this.ku.length-1);i=Math.min(h,Math.max(30,i));const a=s/e,l=n.$t();n.po(i*a);let o=i-l,_=this.ku.length-1;for(const t of this.ku)if(t!==n){const i=Math.min(h,Math.max(30,t.$t()-o/_));o-=t.$t()-i,_-=1;const n=i*a;t.po(n)}this.Ih()}Gu(t,i){r(t>=0&&t<this.ku.length&&i>=0&&i<this.ku.length,"Invalid pane index");const n=this.ku[t],s=this.ku[i];this.ku[t]=s,this.ku[i]=n,this.Ih()}Po(t,i,n){t.Po(i,n)}ko(t,i,n){t.ko(i,n),this.Ah(),this.Wu(this.Ju(t,2))}To(t,i){t.To(i),this.Wu(this.Ju(t,2))}Ro(t,i,n){i.wl()||t.Ro(i,n)}Do(t,i,n){i.wl()||(t.Do(i,n),this.Ah(),this.Wu(this.Ju(t,2)))}Vo(t,i){i.wl()||(t.Vo(i),this.Wu(this.Ju(t,2)))}Io(t,i){t.Io(i),this.Wu(this.Ju(t,2))}Qu(t){this.uh.Ul(t)}tc(t,i){const n=this.Bt();if(n.Zi()||0===i)return;const s=n.Qi();t=Math.max(1,Math.min(t,s)),n.hu(t,i),this.J_()}nc(t){this.sc(0),this.ec(t),this.rc()}hc(t){this.uh.$l(t),this.J_()}ac(){this.uh.jl(),this.ar()}sc(t){this.uh.ql(t)}ec(t){this.uh.Yl(t),this.J_()}rc(){this.uh.Zl(),this.ar()}jn(){return this.Tu}lc(t,i,n,s,e){this.Ct.Rn(t,i);let r=NaN,h=this.uh.Z_(t,!0);const a=this.uh.ye();null!==a&&(h=Math.min(Math.max(a.Uh(),h),a.bi()));const l=s.yn(),o=l.zt();if(null!==o&&(r=l.Pn(i,o)),r=this.Au.Ma(r,h,s),this.Ct.In(h,r,s),this.Xh(),!e){const e=Mi(s,t,i);this.Uu(e&&{Wo:e.Wo,Fo:e.Fo,Uo:e.Uo||null}),this.Vu.p(this.Ct.It(),{x:t,y:i},n)}}oc(t,i,n){const s=n.yn(),e=s.zt(),r=s.Nt(t,a(e)),h=this.uh.B_(i,!0),l=this.uh.jt(a(h));this.lc(l,r,null,n,!0)}_c(t){this.qu().An(),this.Xh(),t||this.Vu.p(null,null,null)}Ah(){const t=this.Ct.Fn();if(null!==t){const i=this.Ct.Vn(),n=this.Ct.En();this.lc(i,n,null,t)}this.Ct.On()}uc(t,i,n){const s=this.uh.kn(0);void 0!==i&&void 0!==n&&this.uh.Pt(i,n);const e=this.uh.kn(0),r=this.uh.q_(),h=this.uh.ye();if(null!==h&&null!==s&&null!==e){const i=h.Te(r),a=this.qo.key(s)>this.qo.key(e),l=null!==t&&t>r&&!a,o=this.uh.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===n)||o)&&this.uh.N().shiftVisibleRangeOnNewBar;if(l&&!_){const i=t-r;this.uh.ds(this.uh.iu()-i)}}this.uh.ru(t)}Oh(t){null!==t&&t.Ao()}Hs(t){if(function(t){return t instanceof vi}(t))return t;const i=this.ku.find((i=>i.Dt().includes(t)));return void 0===i?null:i}J_(){this.ku.forEach((t=>t.Ao())),this.Ah()}m(){this.ku.forEach((t=>t.m())),this.ku.length=0,this.Sn.localization.priceFormatter=void 0,this.Sn.localization.percentageFormatter=void 0,this.Sn.localization.timeFormatter=void 0}cc(){return this.Bu}qs(){return this.Bu.N()}do(){return this.Du}dc(t,i){const n=this.zu(i);this.fc(t,n),this.Tu.push(t),1===this.Tu.length?this.Ih():this.ar()}vc(t){const i=this.Hs(t),n=this.Tu.indexOf(t);r(-1!==n,"Series not found");const s=a(i);this.Tu.splice(n,1),s.Wl(t),t.m&&t.m(),this.uh.R_(),this.mc(s)}Eh(t,i){const n=a(this.Hs(t));n.Wl(t),n.Ll(t,i,a(t.hn()))}mu(){const t=Y.ws();t.ss(),this.Wu(t)}wc(t){const i=Y.ws();i.hs(t),this.Wu(i)}us(){const t=Y.ws();t.us(),this.Wu(t)}cs(t){const i=Y.ws();i.cs(t),this.Wu(i)}ds(t){const i=Y.ws();i.ds(t),this.Wu(i)}ls(t){const i=Y.ws();i.ls(t),this.Wu(i)}es(){const t=Y.ws();t.es(),this.Wu(t)}gc(){return this.Sn.rightPriceScale.visible?"right":"left"}Mc(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.bc(t))return;const n=a(this.Hs(t));n.Wl(t);const s=this.zu(i);this.fc(t,s),0===n.ba().length&&this.mc(n)}xc(){return this.Nu}$(){return this.Ou}Ut(t){const i=this.Nu,n=this.Ou;if(i===n)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Eu||this.Eu.mr!==n||this.Eu.wr!==i)this.Eu={mr:n,wr:i,Sc:new Map};else{const i=this.Eu.Sc.get(t);if(void 0!==i)return i}const s=this.cl.tt(n,i,t/100);return this.Eu.Sc.set(t,s),s}Cc(t){return this.ku.indexOf(t)}Ki(){return this.cl}zu(t){if(r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.ku.length,t))<this.ku.length)return this.ku[t];const i=new vi(this.uh,this);this.ku.push(i);const n=Y.gs();return n.Gn(t,{Jn:0,Qn:!0}),this.Wu(n),i}bc(t){return this.ku.findIndex((i=>i.wo().includes(t)))}Ju(t,i){const n=new Y(i);if(null!==t){const s=this.ku.indexOf(t);n.Gn(s,{Jn:i})}return n}Fu(t,i){return void 0===i&&(i=2),this.Ju(this.Hs(t),i)}Wu(t){this.Iu&&this.Iu(t),this.ku.forEach((t=>t.Oo().lr().Pt()))}fc(t,i){const n=t.N().priceScaleId,s=void 0!==n?n:this.gc();i.Ll(t,s),q(s)||t.hr(t.N())}Lu(t){const i=this.Sn.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}mc(t){0===t.ba().length&&this.ku.length>1&&(this.ku.splice(this.Cc(t),1),this.Ih())}}function Bi(t){return!u(t)&&!d(t)}function Ai(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Ri||(Ri={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Di||(Di={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Vi||(Vi={})),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 zi=t=>t.getUTCFullYear();function Oi(t,i,n){return i.replace(/yyyy/g,(t=>K(zi(t),4))(t)).replace(/yy/g,(t=>K(zi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,n)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,n)).replace(/MM/g,(t=>K((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>K((t=>t.getUTCDate())(t),2))(t))}class Li{constructor(t="yyyy-MM-dd",i="default"){this.yc=t,this.Pc=i}Yo(t){return Oi(t,this.yc,this.Pc)}}class Ni{constructor(t){this.kc=t||"%h:%m:%s"}Yo(t){return this.kc.replace("%h",K(t.getUTCHours(),2)).replace("%m",K(t.getUTCMinutes(),2)).replace("%s",K(t.getUTCSeconds(),2))}}const Wi={Tc:"yyyy-MM-dd",Rc:"%h:%m:%s",Dc:" ",Vc:"default"};class Fi{constructor(t={}){const i={...Wi,...t};this.Ec=new Li(i.Tc,i.Vc),this.Ic=new Ni(i.Rc),this.Bc=i.Dc}Yo(t){return`${this.Ec.Yo(t)}${this.Bc}${this.Ic.Yo(t)}`}}function Hi(t){return 60*t*60*1e3}function Ui(t){return 60*t*1e3}const $i=[{Ac:(ji=1,1e3*ji),zc:10},{Ac:Ui(1),zc:20},{Ac:Ui(5),zc:21},{Ac:Ui(30),zc:22},{Ac:Hi(1),zc:30},{Ac:Hi(3),zc:31},{Ac:Hi(6),zc:32},{Ac:Hi(12),zc:33}];var ji;function qi(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 n=$i.length-1;n>=0;--n)if(Math.floor(i.getTime()/$i[n].Ac)!==Math.floor(t.getTime()/$i[n].Ac))return $i[n].zc;return 0}function Yi(t){let i=t;if(d(t)&&(i=Ki(t)),!Bi(i))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Oc:Math.round(n.getTime()/1e3),Lc:i}}function Zi(t){if(!Ai(t))throw new Error("time must be of type isUTCTimestamp");return{Oc:t}}function Ki(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 Xi(t){d(t.time)&&(t.time=Ki(t.time))}class Gi{options(){return this.Sn}setOptions(t){this.Sn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(Xi)}(t):Xi(t)}createConverterToInternalObj(t){return a(function(t){return 0===t.length?null:Bi(t[0].time)||d(t[0].time)?Yi:Zi}(t))}key(t){return"object"==typeof t&&"Oc"in t?t.Oc:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.Lc?new Date(1e3*i.Oc).getTime():new Date(Date.UTC(i.Lc.year,i.Lc.month-1,i.Lc.day)).getTime()}convertHorzItemToInternal(t){return Ai(i=t)?Zi(i):Bi(i)?Yi(i):Yi(Ki(i));var i}updateFormatter(t){if(!this.Sn)return;const i=t.dateFormat;this.Sn.timeScale.timeVisible?this.Nc=new Fi({Tc:i,Rc:this.Sn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Dc:" ",Vc:t.locale}):this.Nc=new Li(i,t.locale)}formatHorzItem(t){const i=t;return this.Nc.Yo(new Date(1e3*i.Oc))}formatTickmark(t,i){const n=function(t,i,n){switch(t){case 0:case 10:return i?n?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.Sn.timeScale.timeVisible,this.Sn.timeScale.secondsVisible),s=this.Sn.timeScale;if(void 0!==s.tickMarkFormatter){const e=s.tickMarkFormatter(t.originalTime,n,i.locale);if(null!==e)return e}return function(t,i,n){const s={};switch(i){case 0:s.year="numeric";break;case 1:s.month="short";break;case 2:s.day="numeric";break;case 3:s.hour12=!1,s.hour="2-digit",s.minute="2-digit";break;case 4:s.hour12=!1,s.hour="2-digit",s.minute="2-digit",s.second="2-digit"}const e=void 0===t.Lc?new Date(1e3*t.Oc):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(n,s)}(t.time,n,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 n=0===i?null:t[i-1].time.Oc,s=null!==n?new Date(1e3*n):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*i.time.Oc);null!==s&&(i.timeWeight=qi(h,s)),e+=i.time.Oc-(n||i.time.Oc),n=i.time.Oc,s=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),n=new Date(1e3*(t[0].time.Oc-i));t[0].timeWeight=qi(new Date(1e3*t[0].time.Oc),n)}}(t,i)}static Wc(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function Ji(t){var i=t.width,n=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:n}}function Qi(t,i){return t.width===i.width&&t.height===i.height}var tn=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,n={next:t};return this._observers.push(n),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==n}))}}},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 nn=function(){function t(t,i,n){var s;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Ji({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(s=null==n?void 0:n.allowResizeObserver)||void 0===s||s,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 Ji({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Ji(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;Qi(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var n=this;this._bitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,n=Ji(this._transformBitmapSize(t,this._canvasElementClientSize)),s=Qi(this.bitmapSize,n)?null:n;null===i&&null===s||null!==i&&null!==s&&Qi(i,s)||(this._suggestedBitmapSize=s,this._emitSuggestedBitmapSizeChanged(i,s))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var n=this;this._suggestedBitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(n){t(n.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=sn(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new tn(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var n=sn(this._canvasElement);if(null!==n){var s=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:n.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return Ji({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],s):Ji({width:this._canvasElementClientSize.width*s,height:this._canvasElementClientSize.height*s});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var n=i.find((function(i){return i.target===t._canvasElement}));if(n&&n.devicePixelContentBoxSize&&n.devicePixelContentBoxSize[0]){var s=n.devicePixelContentBoxSize[0],e=Ji({width:s.inlineSize,height:s.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function sn(t){return t.ownerDocument.defaultView}var en=function(){function t(t,i,n){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===n.width||0===n.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=n,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 rn(t,i){var n=t.canvasElementClientSize;if(0===n.width||0===n.height)return null;var s=t.bitmapSize;if(0===s.width||0===s.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new en(e,n,s)}const hn="undefined"!=typeof window;function an(){return!!hn&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function ln(){return!!hn&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function on(t){return t+t%2}function _n(t){hn&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class un{constructor(t,i,n){this.Fc=0,this.Hc=null,this.Uc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.$c=0,this.jc=null,this.qc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Yc=null,this.Zc=!1,this.Kc=null,this.Xc=null,this.Gc=!1,this.Jc=!1,this.Qc=!1,this.td=null,this.nd=null,this.sd=null,this.ed=null,this.rd=null,this.hd=null,this.ad=null,this.ld=0,this.od=!1,this._d=!1,this.ud=!1,this.dd=0,this.fd=null,this.pd=!ln(),this.vd=t=>{this.md(t)},this.wd=t=>{if(this.gd(t)){const i=this.Md(t);if(++this.$c,this.jc&&this.$c>1){const{bd:n}=this.xd(fn(t),this.qc);n<30&&!this.Qc&&this.Sd(i,this.yd.Cd),this.Pd()}}else{const i=this.Md(t);if(++this.Fc,this.Hc&&this.Fc>1){const{bd:n}=this.xd(fn(t),this.Uc);n<5&&!this.Jc&&this.kd(i,this.yd.Td),this.Rd()}}},this.Dd=t,this.yd=i,this.Sn=n,this.Vd()}m(){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.hd&&(this.hd(),this.hd=null),null!==this.sd&&(this.sd(),this.sd=null),this.Ed(),this.Rd()}Id(t){this.ed&&this.ed();const i=this.Bd.bind(this);if(this.ed=()=>{this.Dd.removeEventListener("mousemove",i)},this.Dd.addEventListener("mousemove",i),this.gd(t))return;const n=this.Md(t);this.kd(n,this.yd.Ad),this.pd=!0}Rd(){null!==this.Hc&&clearTimeout(this.Hc),this.Fc=0,this.Hc=null,this.Uc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Pd(){null!==this.jc&&clearTimeout(this.jc),this.$c=0,this.jc=null,this.qc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Bd(t){if(this.ud||null!==this.Xc)return;if(this.gd(t))return;const i=this.Md(t);this.kd(i,this.yd.zd),this.pd=!0}Od(t){const i=vn(t.changedTouches,a(this.fd));if(null===i)return;if(this.dd=pn(t),null!==this.ad)return;if(this._d)return;this.od=!0;const n=this.xd(fn(i),a(this.Xc)),{Ld:s,Nd:e,bd:r}=n;if(this.Gc||!(r<5)){if(!this.Gc){const t=.5*s,i=e>=t&&!this.Sn.Wd(),n=t>e&&!this.Sn.Fd();i||n||(this._d=!0),this.Gc=!0,this.Qc=!0,this.Ed(),this.Pd()}if(!this._d){const n=this.Md(t,i);this.Sd(n,this.yd.Hd),dn(t)}}}Ud(t){if(0!==t.button)return;const i=this.xd(fn(t),a(this.Kc)),{bd:n}=i;if(n>=5&&(this.Jc=!0,this.Rd()),this.Jc){const i=this.Md(t);this.kd(i,this.yd.$d)}}xd(t,i){const n=Math.abs(i._t-t._t),s=Math.abs(i.ut-t.ut);return{Ld:n,Nd:s,bd:n+s}}jd(t){let i=vn(t.changedTouches,a(this.fd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.fd=null,this.dd=pn(t),this.Ed(),this.Xc=null,this.hd&&(this.hd(),this.hd=null);const n=this.Md(t,i);if(this.Sd(n,this.yd.qd),++this.$c,this.jc&&this.$c>1){const{bd:t}=this.xd(fn(i),this.qc);t<30&&!this.Qc&&this.Sd(n,this.yd.Cd),this.Pd()}else this.Qc||(this.Sd(n,this.yd.Yd),this.yd.Yd&&dn(t));0===this.$c&&dn(t),0===t.touches.length&&this.Zc&&(this.Zc=!1,dn(t))}md(t){if(0!==t.button)return;const i=this.Md(t);if(this.Kc=null,this.ud=!1,this.rd&&(this.rd(),this.rd=null),an()){this.Dd.ownerDocument.documentElement.removeEventListener("mouseleave",this.vd)}if(!this.gd(t))if(this.kd(i,this.yd.Zd),++this.Fc,this.Hc&&this.Fc>1){const{bd:n}=this.xd(fn(t),this.Uc);n<5&&!this.Jc&&this.kd(i,this.yd.Td),this.Rd()}else this.Jc||this.kd(i,this.yd.Kd)}Ed(){null!==this.Yc&&(clearTimeout(this.Yc),this.Yc=null)}Xd(t){if(null!==this.fd)return;const i=t.changedTouches[0];this.fd=i.identifier,this.dd=pn(t);const n=this.Dd.ownerDocument.documentElement;this.Qc=!1,this.Gc=!1,this._d=!1,this.Xc=fn(i),this.hd&&(this.hd(),this.hd=null);{const i=this.Od.bind(this),s=this.jd.bind(this);this.hd=()=>{n.removeEventListener("touchmove",i),n.removeEventListener("touchend",s)},n.addEventListener("touchmove",i,{passive:!1}),n.addEventListener("touchend",s,{passive:!1}),this.Ed(),this.Yc=setTimeout(this.Gd.bind(this,t),240)}const s=this.Md(t,i);this.Sd(s,this.yd.Jd),this.jc||(this.$c=0,this.jc=setTimeout(this.Pd.bind(this),500),this.qc=fn(i))}Qd(t){if(0!==t.button)return;const i=this.Dd.ownerDocument.documentElement;an()&&i.addEventListener("mouseleave",this.vd),this.Jc=!1,this.Kc=fn(t),this.rd&&(this.rd(),this.rd=null);{const t=this.Ud.bind(this),n=this.md.bind(this);this.rd=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",n)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",n)}if(this.ud=!0,this.gd(t))return;const n=this.Md(t);this.kd(n,this.yd.tf),this.Hc||(this.Fc=0,this.Hc=setTimeout(this.Rd.bind(this),500),this.Uc=fn(t))}Vd(){this.Dd.addEventListener("mouseenter",this.Id.bind(this)),this.Dd.addEventListener("touchcancel",this.Ed.bind(this));{const t=this.Dd.ownerDocument,i=t=>{this.yd.if&&(t.composed&&this.Dd.contains(t.composedPath()[0])||t.target&&this.Dd.contains(t.target)||this.yd.if())};this.nd=()=>{t.removeEventListener("touchstart",i)},this.td=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}ln()&&(this.sd=()=>{this.Dd.removeEventListener("dblclick",this.wd)},this.Dd.addEventListener("dblclick",this.wd)),this.Dd.addEventListener("mouseleave",this.nf.bind(this)),this.Dd.addEventListener("touchstart",this.Xd.bind(this),{passive:!0}),_n(this.Dd),this.Dd.addEventListener("mousedown",this.Qd.bind(this)),this.sf(),this.Dd.addEventListener("touchmove",(()=>{}),{passive:!1})}sf(){void 0===this.yd.ef&&void 0===this.yd.rf&&void 0===this.yd.hf||(this.Dd.addEventListener("touchstart",(t=>this.af(t.touches)),{passive:!0}),this.Dd.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.ad&&void 0!==this.yd.rf){const i=cn(t.touches[0],t.touches[1])/this.ld;this.yd.rf(this.ad,i),dn(t)}}),{passive:!1}),this.Dd.addEventListener("touchend",(t=>{this.af(t.touches)})))}af(t){1===t.length&&(this.od=!1),2!==t.length||this.od||this.Zc?this.lf():this._f(t)}_f(t){const i=this.Dd.getBoundingClientRect()||{left:0,top:0};this.ad={_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=cn(t[0],t[1]),void 0!==this.yd.ef&&this.yd.ef(),this.Ed()}lf(){null!==this.ad&&(this.ad=null,void 0!==this.yd.hf&&this.yd.hf())}nf(t){if(this.ed&&this.ed(),this.gd(t))return;if(!this.pd)return;const i=this.Md(t);this.kd(i,this.yd.uf),this.pd=!ln()}Gd(t){const i=vn(t.touches,a(this.fd));if(null===i)return;const n=this.Md(t,i);this.Sd(n,this.yd.cf),this.Qc=!0,this.Zc=!0}gd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:pn(t)<this.dd+500}Sd(t,i){i&&i.call(this.yd,t)}kd(t,i){i&&i.call(this.yd,t)}Md(t,i){const n=i||t,s=this.Dd.getBoundingClientRect()||{left:0,top:0};return{clientX:n.clientX,clientY:n.clientY,pageX:n.pageX,pageY:n.pageY,screenX:n.screenX,screenY:n.screenY,localX:n.clientX-s.left,localY:n.clientY-s.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,df:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,ff:t.type,pf:n.target,$o:t.view,vf:()=>{"touchstart"!==t.type&&dn(t)}}}}function cn(t,i){const n=t.clientX-i.clientX,s=t.clientY-i.clientY;return Math.sqrt(n*n+s*s)}function dn(t){t.cancelable&&t.preventDefault()}function fn(t){return{_t:t.pageX,ut:t.pageY}}function pn(t){return t.timeStamp||performance.now()}function vn(t,i){for(let n=0;n<t.length;++n)if(t[n].identifier===i)return t[n];return null}class mn{constructor(t,i,n){this.mf=null,this.wf=null,this.gf=!0,this.Mf=null,this.bf=t,this.xf=t.Sf()[i],this.Cf=t.Sf()[n],this.yf=document.createElement("tr"),this.yf.style.height="1px",this.Pf=document.createElement("td"),this.Pf.style.position="relative",this.Pf.style.padding="0",this.Pf.style.margin="0",this.Pf.setAttribute("colspan","3"),this.kf(),this.yf.appendChild(this.Pf),this.gf=this.bf.N().layout.panes.enableResize,this.gf?this.Tf():(this.mf=null,this.wf=null)}m(){null!==this.wf&&this.wf.m()}Rf(){return this.yf}Df(){return Ji({width:this.xf.Df().width,height:1})}Vf(){return Ji({width:this.xf.Vf().width,height:1*window.devicePixelRatio})}Ef(t,i,n){const s=this.Vf();t.fillStyle=this.bf.N().layout.panes.separatorColor,t.fillRect(i,n,s.width,s.height)}Pt(){this.kf(),this.bf.N().layout.panes.enableResize!==this.gf&&(this.gf=this.bf.N().layout.panes.enableResize,this.gf?this.Tf():(null!==this.mf&&(this.Pf.removeChild(this.mf.If),this.Pf.removeChild(this.mf.Bf),this.mf=null),null!==this.wf&&(this.wf.m(),this.wf=null)))}Tf(){const t=document.createElement("div"),i=t.style;i.position="fixed",i.display="none",i.zIndex="49",i.top="0",i.left="0",i.width="100%",i.height="100%",i.cursor="row-resize",this.Pf.appendChild(t);const n=document.createElement("div"),s=n.style;s.position="absolute",s.zIndex="50",s.top="-4px",s.height="9px",s.width="100%",s.backgroundColor="",s.cursor="row-resize",this.Pf.appendChild(n);const e={Ad:this.Af.bind(this),uf:this.zf.bind(this),tf:this.Of.bind(this),Jd:this.Of.bind(this),$d:this.Lf.bind(this),Hd:this.Lf.bind(this),Zd:this.Nf.bind(this),qd:this.Nf.bind(this)};this.wf=new un(n,e,{Wd:()=>!1,Fd:()=>!0}),this.mf={Bf:n,If:t}}kf(){this.Pf.style.background=this.bf.N().layout.panes.separatorColor}Af(t){null!==this.mf&&(this.mf.Bf.style.backgroundColor=this.bf.N().layout.panes.separatorHoverColor)}zf(t){null!==this.mf&&null===this.Mf&&(this.mf.Bf.style.backgroundColor="")}Of(t){if(null===this.mf)return;const i=this.xf.Wf().fo()+this.Cf.Wf().fo(),n=i/(this.xf.Df().height+this.Cf.Df().height),s=30*n;i<=2*s||(this.Mf={Ff:t.pageY,Hf:this.xf.Wf().fo(),Uf:i-s,$f:i,jf:n,qf:s},this.mf.If.style.display="block")}Lf(t){const i=this.Mf;if(null===i)return;const n=(t.pageY-i.Ff)*i.jf,s=ri(i.Hf+n,i.qf,i.Uf);this.xf.Wf().po(s),this.Cf.Wf().po(i.$f-s),this.bf.Qt().Ih()}Nf(t){null!==this.Mf&&null!==this.mf&&(this.Mf=null,this.mf.If.style.display="none")}}function wn(t,i){return t.Yf-i.Yf}function gn(t,i,n){const s=(t.Yf-i.Yf)/(t.wt-i.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class Mn{constructor(t,i,n,s){this.Zf=null,this.Kf=null,this.Xf=null,this.Gf=null,this.Jf=null,this.Qf=0,this.tp=0,this.ip=t,this.np=i,this.sp=n,this.Ms=s}ep(t,i){if(null!==this.Zf){if(this.Zf.wt===i)return void(this.Zf.Yf=t);if(Math.abs(this.Zf.Yf-t)<this.Ms)return}this.Gf=this.Xf,this.Xf=this.Kf,this.Kf=this.Zf,this.Zf={wt:i,Yf:t}}le(t,i){if(null===this.Zf||null===this.Kf)return;if(i-this.Zf.wt>50)return;let n=0;const s=gn(this.Zf,this.Kf,this.np),e=wn(this.Zf,this.Kf),r=[s],h=[e];if(n+=e,null!==this.Xf){const t=gn(this.Kf,this.Xf,this.np);if(Math.sign(t)===Math.sign(s)){const i=wn(this.Kf,this.Xf);if(r.push(t),h.push(i),n+=i,null!==this.Gf){const t=gn(this.Xf,this.Gf,this.np);if(Math.sign(t)===Math.sign(s)){const i=wn(this.Xf,this.Gf);r.push(t),h.push(i),n+=i}}}}let a=0;for(let t=0;t<r.length;++t)a+=h[t]/n*r[t];Math.abs(a)<this.ip||(this.Jf={Yf:t,wt:i},this.tp=a,this.Qf=function(t,i){const n=Math.log(i);return Math.log(1*n/-t)/n}(Math.abs(a),this.sp))}cu(t){const i=a(this.Jf),n=t-i.wt;return i.Yf+this.tp*(Math.pow(this.sp,n)-1)/Math.log(this.sp)}uu(t){return null===this.Jf||this.rp(t)===this.Qf}rp(t){const i=t-a(this.Jf).wt;return Math.min(i,this.Qf)}}class bn{constructor(t,i){this.hp=void 0,this.ap=void 0,this.lp=void 0,this.fn=!1,this.op=t,this._p=i,this.up()}Pt(){this.up()}cp(){this.hp&&this.op.removeChild(this.hp),this.ap&&this.op.removeChild(this.ap),this.hp=void 0,this.ap=void 0}dp(){return this.fn!==this.fp()||this.lp!==this.pp()}pp(){return this._p.Qt().Ki().J(this._p.N().layout.textColor)>160?"dark":"light"}fp(){return this._p.N().layout.attributionLogo}vp(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}up(){this.dp()&&(this.cp(),this.fn=this.fp(),this.fn&&(this.lp=this.pp(),this.ap=document.createElement("style"),this.ap.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.hp=document.createElement("a"),this.hp.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.vp()}`,this.hp.title="Charting by TradingView",this.hp.id="tv-attr-logo",this.hp.target="_blank",this.hp.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.hp.toggleAttribute("data-dark","dark"===this.lp),this.op.appendChild(this.ap),this.op.appendChild(this.hp)))}}function xn(t,i){const n=a(t.ownerDocument).createElement("canvas");t.appendChild(n);const s=function(t,i){if("device-pixel-content-box"===i.type)return new nn(t,i.transform,i.options);throw new Error("Unsupported binding target")}(n,{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 s.resizeCanvasElement(i),s}function Sn(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function Cn(t,i,n,s){t.ih&&t.ih(i,n,s)}function yn(t,i,n,s){t.st(i,n,s)}function Pn(t,i,n,s){const e=t(n,s);for(const t of e){const n=t.Tt(s);null!==n&&i(n)}}function kn(t,i){return n=>{if(!function(t){return void 0!==t.Wt}(n))return[];return(n.Wt()?.wa()??"")!==i?[]:n.ta?.(t)??[]}}function Tn(t,i,n,s){if(!t.length)return;let e=0;const r=t[0].$t(s,!0);let h=1===i?n/2-(t[0].Wi()-r/2):t[0].Wi()-r/2-n/2;h=Math.max(0,h);for(let r=1;r<t.length;r++){const a=t[r],l=t[r-1],o=l.$t(s,!1),_=a.Wi(),u=l.Wi();if(1===i?_>u-o:_<u+o){const s=u-o*i;a.Fi(s);const r=s-i*o/2;if((1===i?r<0:r>n)&&h>0){const s=1===i?-1-r:r-n,a=Math.min(s,h);for(let n=e;n<t.length;n++)t[n].Fi(t[n].Wi()+i*a);h-=a}}else e=r,h=1===i?u-o-_:_-(u+o)}}class Rn{constructor(t,i,n,s){this.qi=null,this.mp=null,this.wp=!1,this.gp=new tt(200),this.Mp=null,this.bp=0,this.xp=!1,this.Sp=()=>{this.xp||this.yt.Cp().Qt().ar()},this.yp=()=>{this.xp||this.yt.Cp().Qt().ar()},this.yt=t,this.Sn=i,this._l=i.layout,this.Bu=n,this.Pp="left"===s,this.kp=kn("normal",s),this.Tp=kn("top",s),this.Rp=kn("bottom",s),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.Dp=xn(this.Pf,Ji({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Sp);const e=this.Dp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.Vp=xn(this.Pf,Ji({width:16,height:16})),this.Vp.subscribeSuggestedBitmapSizeChanged(this.yp);const r=this.Vp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={tf:this.Of.bind(this),Jd:this.Of.bind(this),$d:this.Lf.bind(this),Hd:this.Lf.bind(this),if:this.Ep.bind(this),Zd:this.Nf.bind(this),qd:this.Nf.bind(this),Td:this.Ip.bind(this),Cd:this.Ip.bind(this),Ad:this.Bp.bind(this),uf:this.zf.bind(this)};this.wf=new un(this.Vp.canvasElement,h,{Wd:()=>!this.Sn.handleScroll.vertTouchDrag,Fd:()=>!0})}m(){this.wf.m(),this.Vp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Sn(this.Vp.canvasElement),this.Vp.dispose(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Sn(this.Dp.canvasElement),this.Dp.dispose(),null!==this.qi&&this.qi.Hl().u(this),this.qi=null}Rf(){return this.Pf}P(){return this._l.fontSize}Ap(){const t=this.Bu.N();return this.Mp!==t.k&&(this.gp.Es(),this.Mp=t.k),t}zp(){if(null===this.qi)return 0;let t=0;const i=this.Ap(),n=a(this.Dp.canvasElement.getContext("2d",{colorSpace:this.yt.Cp().N().layout.colorSpace}));n.save();const s=this.qi.Va();n.font=this.Op(),s.length>0&&(t=Math.max(this.gp.Vi(n,s[0].$a),this.gp.Vi(n,s[s.length-1].$a)));const e=this.Lp();for(let i=e.length;i--;){const s=this.gp.Vi(n,e[i].ri());s>t&&(t=s)}const r=this.qi.zt();if(null!==r&&null!==this.mp&&(2!==(h=this.Sn.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.qi.Pn(1,r),s=this.qi.Pn(this.mp.height-2,r);t=Math.max(t,this.gp.Vi(n,this.qi.Xi(Math.floor(Math.min(i,s))+.11111111111111,r)),this.gp.Vi(n,this.qi.Xi(Math.ceil(Math.max(i,s))-.11111111111111,r)))}var h;n.restore();const l=t||34;return on(Math.ceil(i.S+i.C+i.I+i.B+5+l))}Np(t){null!==this.mp&&Qi(this.mp,t)||(this.mp=t,this.xp=!0,this.Dp.resizeCanvasElement(t),this.Vp.resizeCanvasElement(t),this.xp=!1,this.Pf.style.width=`${t.width}px`,this.Pf.style.height=`${t.height}px`)}Wp(){return a(this.mp).width}ln(t){this.qi!==t&&(null!==this.qi&&this.qi.Hl().u(this),this.qi=t,t.Hl().i(this.il.bind(this),this))}Wt(){return this.qi}Es(){const t=this.yt.Wf();this.yt.Cp().Qt().Io(t,a(this.Wt()))}Fp(t){if(null===this.mp)return;const i={colorSpace:this.yt.Cp().N().layout.colorSpace};if(1!==t){this.Hp(),this.Dp.applySuggestedBitmapSize();const t=rn(this.Dp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Up(t),this.$p(t)})),this.yt.jp(t,this.Rp),this.qp(t),this.yt.jp(t,this.kp),this.Yp(t))}this.Vp.applySuggestedBitmapSize();const n=rn(this.Vp,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Zp(n),this.yt.jp(n,this.Tp))}Vf(){return this.Dp.bitmapSize}Ef(t,i,n){const s=this.Vf();s.width>0&&s.height>0&&t.drawImage(this.Dp.canvasElement,i,n)}Pt(){this.qi?.Va()}Of(t){if(null===this.qi||this.qi.Zi()||!this.Sn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Cp().Qt(),n=this.yt.Wf();this.wp=!0,i.Po(n,this.qi,t.localY)}Lf(t){if(null===this.qi||!this.Sn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Cp().Qt(),n=this.yt.Wf(),s=this.qi;i.ko(n,s,t.localY)}Ep(){if(null===this.qi||!this.Sn.handleScale.axisPressedMouseMove.price)return;const t=this.yt.Cp().Qt(),i=this.yt.Wf(),n=this.qi;this.wp&&(this.wp=!1,t.To(i,n))}Nf(t){if(null===this.qi||!this.Sn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Cp().Qt(),n=this.yt.Wf();this.wp=!1,i.To(n,this.qi)}Ip(t){this.Sn.handleScale.axisDoubleClickReset.price&&this.Es()}Bp(t){if(null===this.qi)return;!this.yt.Cp().Qt().N().handleScale.axisPressedMouseMove.price||this.qi.Oe()||this.qi.gl()||this.Kp(1)}zf(t){this.Kp(0)}Lp(){const t=[],i=null===this.qi?void 0:this.qi;return(n=>{for(let s=0;s<n.length;++s){const e=n[s].Nn(this.yt.Wf(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.yt.Wf().Dt()),t}Up({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.yt.Wf().Qt(),r=e.$(),h=e.xc();r===h?I(t,0,0,n,s,r):z(t,0,0,n,s,r,h)}$p({context:t,bitmapSize:i,horizontalPixelRatio:n}){if(null===this.mp||null===this.qi||!this.qi.N().borderVisible)return;t.fillStyle=this.qi.N().borderColor;const s=Math.max(1,Math.floor(this.Ap().S*n));let e;e=this.Pp?i.width-s:0,t.fillRect(e,0,s,i.height)}qp(t){if(null===this.mp||null===this.qi)return;const i=this.qi.Va(),n=this.qi.N(),s=this.Ap(),e=this.Pp?this.mp.width-s.C:0;n.borderVisible&&n.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=n.borderColor;const a=Math.max(1,Math.floor(h)),l=Math.floor(.5*h),o=Math.round(s.C*r);t.beginPath();for(const n of i)t.rect(Math.floor(e*r),Math.round(n.Pa*h)-l,o,a);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Op(),t.fillStyle=n.textColor??this._l.textColor,t.textAlign=this.Pp?"right":"left",t.textBaseline="middle";const r=this.Pp?Math.round(e-s.I):Math.round(e+s.C+s.I),h=i.map((i=>this.gp.Di(t,i.$a)));for(let n=i.length;n--;){const s=i[n];t.fillText(s.$a,r,s.Pa+h[n])}}))}Hp(){if(null===this.mp||null===this.qi)return;let t=this.mp.height/2;const i=[],n=this.qi.Dt().slice(),s=this.yt.Wf(),e=this.Ap();this.qi===s.$s()&&this.yt.Wf().Dt().forEach((t=>{s.Us(t)&&n.push(t)}));const r=this.qi.ba()[0],h=this.qi;n.forEach((n=>{const e=n.Nn(s,h);e.forEach((t=>{t.Fi(null),t.Hi()&&i.push(t)})),r===n&&e.length>0&&(t=e[0].Ii())})),i.forEach((t=>t.Fi(t.Ii())));this.qi.N().alignLabels&&this.Xp(i,e,t)}Xp(t,i,n){if(null===this.mp)return;const s=t.filter((t=>t.Ii()<=n)),e=t.filter((t=>t.Ii()>n));s.sort(((t,i)=>i.Ii()-t.Ii())),s.length&&e.length&&e.push(s[0]),e.sort(((t,i)=>t.Ii()-i.Ii()));for(const n of t){const t=Math.floor(n.$t(i)/2),s=n.Ii();s>-t&&s<t&&n.Fi(t),s>this.mp.height-t&&s<this.mp.height+t&&n.Fi(this.mp.height-t)}Tn(s,1,this.mp.height,i),Tn(e,-1,this.mp.height,i)}Yp(t){if(null===this.mp)return;const i=this.Lp(),n=this.Ap(),s=this.Pp?"right":"left";i.forEach((i=>{if(i.Ui()){i.Tt(a(this.qi)).st(t,n,this.gp,s)}}))}Zp(t){if(null===this.mp||null===this.qi)return;const i=this.yt.Cp().Qt(),n=[],s=this.yt.Wf(),e=i.qu().Nn(s,this.qi);e.length&&n.push(e);const r=this.Ap(),h=this.Pp?"right":"left";n.forEach((i=>{i.forEach((i=>{i.Tt(a(this.qi)).st(t,r,this.gp,h)}))}))}Kp(t){this.Pf.style.cursor=1===t?"ns-resize":"default"}il(){const t=this.zp();this.bp<t&&this.yt.Cp().Qt().Ih(),this.bp=t}Op(){return g(this._l.fontSize,this._l.fontFamily)}}function Dn(t,i){return t.Jh?.(i)??[]}function Vn(t,i){return t.Ln?.(i)??[]}function En(t,i){return t._n?.(i)??[]}function In(t,i){return t.Kh?.(i)??[]}class Bn{constructor(t,i){this.mp=Ji({width:0,height:0}),this.Gp=null,this.Jp=null,this.Qp=null,this.tv=null,this.iv=!1,this.nv=new o,this.sv=new o,this.ev=0,this.rv=!1,this.hv=null,this.av=!1,this.lv=null,this.ov=null,this.xp=!1,this.Sp=()=>{this.xp||null===this._v||this.tn().ar()},this.yp=()=>{this.xp||null===this._v||this.tn().ar()},this._p=t,this._v=i,this._v.zo().i(this.uv.bind(this),this,!0),this.cv=document.createElement("td"),this.cv.style.padding="0",this.cv.style.position="relative";const n=document.createElement("div");n.style.width="100%",n.style.height="100%",n.style.position="relative",n.style.overflow="hidden",this.dv=document.createElement("td"),this.dv.style.padding="0",this.fv=document.createElement("td"),this.fv.style.padding="0",this.cv.appendChild(n),this.Dp=xn(n,Ji({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Sp);const s=this.Dp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Vp=xn(n,Ji({width:16,height:16})),this.Vp.subscribeSuggestedBitmapSizeChanged(this.yp);const e=this.Vp.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.dv),this.yf.appendChild(this.cv),this.yf.appendChild(this.fv),this.pv(),this.wf=new un(this.Vp.canvasElement,this,{Wd:()=>null===this.hv&&!this._p.N().handleScroll.vertTouchDrag,Fd:()=>null===this.hv&&!this._p.N().handleScroll.horzTouchDrag})}m(){null!==this.Gp&&this.Gp.m(),null!==this.Jp&&this.Jp.m(),this.Qp=null,this.Vp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Sn(this.Vp.canvasElement),this.Vp.dispose(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Sn(this.Dp.canvasElement),this.Dp.dispose(),null!==this._v&&(this._v.zo().u(this),this._v.m()),this.wf.m()}Wf(){return a(this._v)}vv(t){null!==this._v&&this._v.zo().u(this),this._v=t,null!==this._v&&this._v.zo().i(Bn.prototype.uv.bind(this),this,!0),this.pv(),this._p.Sf().indexOf(this)===this._p.Sf().length-1?(this.Qp=this.Qp??new bn(this.cv,this._p),this.Qp.Pt()):(this.Qp?.cp(),this.Qp=null)}Cp(){return this._p}Rf(){return this.yf}pv(){if(null!==this._v&&(this.mv(),0!==this.tn().jn().length)){if(null!==this.Gp){const t=this._v.Co();this.Gp.ln(a(t))}if(null!==this.Jp){const t=this._v.yo();this.Jp.ln(a(t))}}}wv(){null!==this.Gp&&this.Gp.Pt(),null!==this.Jp&&this.Jp.Pt()}fo(){return null!==this._v?this._v.fo():0}po(t){this._v&&this._v.po(t)}Ad(t){if(!this._v)return;this.gv();const i=t.localX,n=t.localY;this.Mv(i,n,t)}tf(t){this.gv(),this.bv(),this.Mv(t.localX,t.localY,t)}zd(t){if(!this._v)return;this.gv();const i=t.localX,n=t.localY;this.Mv(i,n,t)}Kd(t){null!==this._v&&(this.gv(),this.xv(t))}Td(t){null!==this._v&&this.Sv(this.sv,t)}Cd(t){this.Td(t)}$d(t){this.gv(),this.Cv(t),this.Mv(t.localX,t.localY,t)}Zd(t){null!==this._v&&(this.gv(),this.rv=!1,this.yv(t))}Yd(t){null!==this._v&&this.xv(t)}cf(t){if(this.rv=!0,null===this.hv){const i={x:t.localX,y:t.localY};this.Pv(i,i,t)}}uf(t){null!==this._v&&(this.gv(),this._v.Qt().Uu(null),this.kv())}Tv(){return this.nv}Rv(){return this.sv}ef(){this.ev=1,this.tn().es()}rf(t,i){if(!this._p.N().handleScale.pinch)return;const n=5*(i-this.ev);this.ev=i,this.tn().tc(t._t,n)}Jd(t){this.rv=!1,this.av=null!==this.hv,this.bv();const i=this.tn().qu();null!==this.hv&&i.Vt()&&(this.lv={x:i.ni(),y:i.si()},this.hv={x:t.localX,y:t.localY})}Hd(t){if(null===this._v)return;const i=t.localX,n=t.localY;if(null===this.hv)this.Cv(t);else{this.av=!1;const s=a(this.lv),e=s.x+(i-this.hv.x),r=s.y+(n-this.hv.y);this.Mv(e,r,t)}}qd(t){0===this.Cp().N().trackingMode.exitMode&&(this.av=!0),this.Dv(),this.yv(t)}Ys(t,i){const n=this._v;return null===n?null:Mi(n,t,i)}Vv(t,i){a("left"===i?this.Gp:this.Jp).Np(Ji({width:t,height:this.mp.height}))}Df(){return this.mp}Np(t){Qi(this.mp,t)||(this.mp=t,this.xp=!0,this.Dp.resizeCanvasElement(t),this.Vp.resizeCanvasElement(t),this.xp=!1,this.cv.style.width=t.width+"px",this.cv.style.height=t.height+"px")}Ev(){const t=a(this._v);t.So(t.Co()),t.So(t.yo());for(const i of t.ba())if(t.Us(i)){const n=i.Wt();null!==n&&t.So(n),i.On()}for(const i of t.Lo())i.On()}Vf(){return this.Dp.bitmapSize}Ef(t,i,n){const s=this.Vf();s.width>0&&s.height>0&&t.drawImage(this.Dp.canvasElement,i,n)}Fp(t){if(0===t)return;if(null===this._v)return;t>1&&this.Ev(),null!==this.Gp&&this.Gp.Fp(t),null!==this.Jp&&this.Jp.Fp(t);const i={colorSpace:this._p.N().layout.colorSpace};if(1!==t){this.Dp.applySuggestedBitmapSize();const t=rn(this.Dp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Up(t)})),this._v&&(this.Iv(t,Dn),this.Bv(t),this.Iv(t,Vn),this.Iv(t,En)))}this.Vp.applySuggestedBitmapSize();const n=rn(this.Vp,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Av(n),this.Iv(n,In),this.Iv(n,En))}zv(){return this.Gp}Ov(){return this.Jp}jp(t,i){this.Iv(t,i)}uv(){null!==this._v&&this._v.zo().u(this),this._v=null}xv(t){this.Sv(this.nv,t)}Sv(t,i){const n=i.localX,s=i.localY;t.v()&&t.p(this.tn().Bt().Z_(n),{x:n,y:s},i)}Up({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.tn(),r=e.$(),h=e.xc();r===h?I(t,0,0,n,s,h):z(t,0,0,n,s,r,h)}Bv(t){const i=a(this._v),n=i.Oo().lr().Tt(i);null!==n&&n.st(t,!1)}Av(t){this.Lv(t,Vn,yn,this.tn().qu())}Iv(t,i){const n=a(this._v),s=n.Dt(),e=n.Lo();for(const n of e)this.Lv(t,i,Cn,n);for(const n of s)this.Lv(t,i,Cn,n);for(const n of e)this.Lv(t,i,yn,n);for(const n of s)this.Lv(t,i,yn,n)}Lv(t,i,n,s){const e=a(this._v),r=e.Qt().Hu(),h=null!==r&&r.Wo===s,l=null!==r&&h&&void 0!==r.Fo?r.Fo.Ks:void 0;Pn(i,(i=>n(i,t,h,l)),s,e)}mv(){if(null===this._v)return;const t=this._p,i=this._v.Co().N().visible,n=this._v.yo().N().visible;i||null===this.Gp||(this.dv.removeChild(this.Gp.Rf()),this.Gp.m(),this.Gp=null),n||null===this.Jp||(this.fv.removeChild(this.Jp.Rf()),this.Jp.m(),this.Jp=null);const s=t.Qt().cc();i&&null===this.Gp&&(this.Gp=new Rn(this,t.N(),s,"left"),this.dv.appendChild(this.Gp.Rf())),n&&null===this.Jp&&(this.Jp=new Rn(this,t.N(),s,"right"),this.fv.appendChild(this.Jp.Rf()))}Nv(t){return t.df&&this.rv||null!==this.hv}Wv(t){return Math.max(0,Math.min(t,this.mp.width-1))}Fv(t){return Math.max(0,Math.min(t,this.mp.height-1))}Mv(t,i,n){this.tn().lc(this.Wv(t),this.Fv(i),n,a(this._v))}kv(){this.tn()._c()}Dv(){this.av&&(this.hv=null,this.kv())}Pv(t,i,n){this.hv=t,this.av=!1,this.Mv(i.x,i.y,n);const s=this.tn().qu();this.lv={x:s.ni(),y:s.si()}}tn(){return this._p.Qt()}yv(t){if(!this.iv)return;const i=this.tn(),n=this.Wf();if(i.Vo(n,n.yn()),this.tv=null,this.iv=!1,i.rc(),null!==this.ov){const t=performance.now(),n=i.Bt();this.ov.le(n.iu(),t),this.ov.uu(t)||i.ls(this.ov)}}gv(){this.hv=null}bv(){if(!this._v)return;if(this.tn().es(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)a(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this._v.yn().Zi()&&this.tn().Bt().Zi()}Cv(t){if(null===this._v)return;const i=this.tn(),n=i.Bt();if(n.Zi())return;const s=this._p.N(),e=s.handleScroll,r=s.kineticScroll;if((!e.pressedMouseMove||t.df)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.df))return;const h=this._v.yn(),a=performance.now();if(null!==this.tv||this.Nv(t)||(this.tv={x:t.clientX,y:t.clientY,Oc:a,Hv:t.localX,Uv:t.localY}),null!==this.tv&&!this.iv&&(this.tv.x!==t.clientX||this.tv.y!==t.clientY)){if(t.df&&r.touch||!t.df&&r.mouse){const t=n.Q_();this.ov=new Mn(.2/t,7/t,.997,15/t),this.ov.ep(n.iu(),this.tv.Oc)}else this.ov=null;h.Zi()||i.Ro(this._v,h,t.localY),i.sc(t.localX),this.iv=!0}this.iv&&(h.Zi()||i.Do(this._v,h,t.localY),i.ec(t.localX),null!==this.ov&&this.ov.ep(n.iu(),a))}}class An{constructor(t,i,n,s,e){this.St=!0,this.mp=Ji({width:0,height:0}),this.Sp=()=>this.Fp(3),this.Pp="left"===t,this.Bu=n.cc,this.Sn=i,this.$v=s,this.jv=e,this.Pf=document.createElement("div"),this.Pf.style.width="25px",this.Pf.style.height="100%",this.Pf.style.overflow="hidden",this.Dp=xn(this.Pf,Ji({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Sp)}m(){this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Sn(this.Dp.canvasElement),this.Dp.dispose()}Rf(){return this.Pf}Df(){return this.mp}Np(t){Qi(this.mp,t)||(this.mp=t,this.Dp.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.mp.width||0===this.mp.height)return;this.St=!1,this.Dp.applySuggestedBitmapSize();const i=rn(this.Dp,{colorSpace:this.Sn.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Up(t),this.$p(t)}))}Vf(){return this.Dp.bitmapSize}Ef(t,i,n){const s=this.Vf();s.width>0&&s.height>0&&t.drawImage(this.Dp.canvasElement,i,n)}$p({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:s}){if(!this.$v())return;t.fillStyle=this.Sn.timeScale.borderColor;const e=Math.floor(this.Bu.N().S*n),r=Math.floor(this.Bu.N().S*s),h=this.Pp?i.width-e:0;t.fillRect(h,0,e,r)}Up({context:t,bitmapSize:i}){I(t,0,0,i.width,i.height,this.jv())}}function zn(t){return i=>i.ia?.(t)??[]}const On=zn("normal"),Ln=zn("top"),Nn=zn("bottom");class Wn{constructor(t,i){this.qv=null,this.Yv=null,this.M=null,this.Zv=!1,this.mp=Ji({width:0,height:0}),this.Kv=new o,this.gp=new tt(5),this.xp=!1,this.Sp=()=>{this.xp||this._p.Qt().ar()},this.yp=()=>{this.xp||this._p.Qt().ar()},this._p=t,this.qo=i,this.Sn=t.N().layout,this.hp=document.createElement("tr"),this.Xv=document.createElement("td"),this.Xv.style.padding="0",this.Gv=document.createElement("td"),this.Gv.style.padding="0",this.Pf=document.createElement("td"),this.Pf.style.height="25px",this.Pf.style.padding="0",this.Jv=document.createElement("div"),this.Jv.style.width="100%",this.Jv.style.height="100%",this.Jv.style.position="relative",this.Jv.style.overflow="hidden",this.Pf.appendChild(this.Jv),this.Dp=xn(this.Jv,Ji({width:16,height:16})),this.Dp.subscribeSuggestedBitmapSizeChanged(this.Sp);const n=this.Dp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Vp=xn(this.Jv,Ji({width:16,height:16})),this.Vp.subscribeSuggestedBitmapSizeChanged(this.yp);const s=this.Vp.canvasElement;s.style.position="absolute",s.style.zIndex="2",s.style.left="0",s.style.top="0",this.hp.appendChild(this.Xv),this.hp.appendChild(this.Pf),this.hp.appendChild(this.Gv),this.Qv(),this._p.Qt().do().i(this.Qv.bind(this),this),this.wf=new un(this.Vp.canvasElement,this,{Wd:()=>!0,Fd:()=>!this._p.N().handleScroll.horzTouchDrag})}m(){this.wf.m(),null!==this.qv&&this.qv.m(),null!==this.Yv&&this.Yv.m(),this.Vp.unsubscribeSuggestedBitmapSizeChanged(this.yp),Sn(this.Vp.canvasElement),this.Vp.dispose(),this.Dp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Sn(this.Dp.canvasElement),this.Dp.dispose()}Rf(){return this.hp}tm(){return this.qv}im(){return this.Yv}tf(t){if(this.Zv)return;this.Zv=!0;const i=this._p.Qt();!i.Bt().Zi()&&this._p.N().handleScale.axisPressedMouseMove.time&&i.Qu(t.localX)}Jd(t){this.tf(t)}if(){const t=this._p.Qt();!t.Bt().Zi()&&this.Zv&&(this.Zv=!1,this._p.N().handleScale.axisPressedMouseMove.time&&t.ac())}$d(t){const i=this._p.Qt();!i.Bt().Zi()&&this._p.N().handleScale.axisPressedMouseMove.time&&i.hc(t.localX)}Hd(t){this.$d(t)}Zd(){this.Zv=!1;const t=this._p.Qt();t.Bt().Zi()&&!this._p.N().handleScale.axisPressedMouseMove.time||t.ac()}qd(){this.Zd()}Td(){this._p.N().handleScale.axisDoubleClickReset.time&&this._p.Qt().us()}Cd(){this.Td()}Ad(){this._p.Qt().N().handleScale.axisPressedMouseMove.time&&this.Kp(1)}uf(){this.Kp(0)}Df(){return this.mp}nm(){return this.Kv}sm(t,i,n){Qi(this.mp,t)||(this.mp=t,this.xp=!0,this.Dp.resizeCanvasElement(t),this.Vp.resizeCanvasElement(t),this.xp=!1,this.Pf.style.width=`${t.width}px`,this.Pf.style.height=`${t.height}px`,this.Kv.p(t)),null!==this.qv&&this.qv.Np(Ji({width:i,height:t.height})),null!==this.Yv&&this.Yv.Np(Ji({width:n,height:t.height}))}rm(){const t=this.hm();return Math.ceil(t.S+t.C+t.P+t.A+t.V+t.am)}Pt(){this._p.Qt().Bt().Va()}Vf(){return this.Dp.bitmapSize}Ef(t,i,n){const s=this.Vf();s.width>0&&s.height>0&&t.drawImage(this.Dp.canvasElement,i,n)}Fp(t){if(0===t)return;const i={colorSpace:this.Sn.colorSpace};if(1!==t){this.Dp.applySuggestedBitmapSize();const n=rn(this.Dp,i);null!==n&&(n.useBitmapCoordinateSpace((t=>{this.Up(t),this.$p(t),this.lm(n,Nn)})),this.qp(n),this.lm(n,On)),null!==this.qv&&this.qv.Fp(t),null!==this.Yv&&this.Yv.Fp(t)}this.Vp.applySuggestedBitmapSize();const n=rn(this.Vp,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.om([...this._p.Qt().jn(),this._p.Qt().qu()],n),this.lm(n,Ln))}lm(t,i){const n=this._p.Qt().jn();for(const s of n)Pn(i,(i=>Cn(i,t,!1,void 0)),s,void 0);for(const s of n)Pn(i,(i=>yn(i,t,!1,void 0)),s,void 0)}Up({context:t,bitmapSize:i}){I(t,0,0,i.width,i.height,this._p.Qt().xc())}$p({context:t,bitmapSize:i,verticalPixelRatio:n}){if(this._p.N().timeScale.borderVisible){t.fillStyle=this._m();const s=Math.max(1,Math.floor(this.hm().S*n));t.fillRect(0,0,i.width,s)}}qp(t){const i=this._p.Qt().Bt(),n=i.Va();if(!n||0===n.length)return;const s=this.qo.maxTickMarkWeight(n),e=this.hm(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:s})=>{t.strokeStyle=this._m(),t.fillStyle=this._m();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const a=Math.round(e.C*s);for(let s=n.length;s--;){const e=Math.round(n[s].coord*i);t.rect(e-h,0,r,a)}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.Op();for(const e of n)if(e.weight<s){const n=e.needAlignCoordinate?this.um(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}this._p.N().timeScale.allowBoldLabels&&(t.font=this.dm());for(const e of n)if(e.weight>=s){const n=e.needAlignCoordinate?this.um(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}}))}um(t,i,n){const s=this.gp.Vi(t,n),e=s/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+s>this.mp.width&&(i-=Math.abs(this.mp.width-(r+s))),i}om(t,i){const n=this.hm();for(const s of t)for(const t of s.un())t.Tt().st(i,n)}_m(){return this._p.N().timeScale.borderColor}H(){return this.Sn.textColor}W(){return this.Sn.fontSize}Op(){return g(this.W(),this.Sn.fontFamily)}dm(){return g(this.W(),this.Sn.fontFamily,"bold")}hm(){null===this.M&&(this.M={S:1,O:NaN,A:NaN,V:NaN,Ji:NaN,C:5,P:NaN,k:"",Gi:new tt,am:0});const t=this.M,i=this.Op();if(t.k!==i){const n=this.W();t.P=n,t.k=i,t.A=3*n/12,t.V=3*n/12,t.Ji=9*n/12,t.O=0,t.am=4*n/12,t.Gi.Es()}return this.M}Kp(t){this.Pf.style.cursor=1===t?"ew-resize":"default"}Qv(){const t=this._p.Qt(),i=t.N();i.leftPriceScale.visible||null===this.qv||(this.Xv.removeChild(this.qv.Rf()),this.qv.m(),this.qv=null),i.rightPriceScale.visible||null===this.Yv||(this.Gv.removeChild(this.Yv.Rf()),this.Yv.m(),this.Yv=null);const n={cc:this._p.Qt().cc()},s=()=>i.leftPriceScale.borderVisible&&t.Bt().N().borderVisible,e=()=>t.xc();i.leftPriceScale.visible&&null===this.qv&&(this.qv=new An("left",i,n,s,e),this.Xv.appendChild(this.qv.Rf())),i.rightPriceScale.visible&&null===this.Yv&&(this.Yv=new An("right",i,n,s,e),this.Gv.appendChild(this.Yv.Rf()))}}const Fn=!!hn&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!hn&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Hn{constructor(t,i,n){var s;this.fm=[],this.pm=[],this.vm=0,this.Ya=0,this.so=0,this.wm=0,this.gm=0,this.Mm=null,this.bm=!1,this.nv=new o,this.sv=new o,this.Vu=new o,this.xm=null,this.Sm=null,this.op=t,this.Sn=i,this.qo=n,this.hp=document.createElement("div"),this.hp.classList.add("tv-lightweight-charts"),this.hp.style.overflow="hidden",this.hp.style.direction="ltr",this.hp.style.width="100%",this.hp.style.height="100%",(s=this.hp).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.Cm=document.createElement("table"),this.Cm.setAttribute("cellspacing","0"),this.hp.appendChild(this.Cm),this.ym=this.Pm.bind(this),Un(this.Sn)&&this.km(!0),this.tn=new Ii(this.Iu.bind(this),this.Sn,n),this.Qt().Yu().i(this.Tm.bind(this),this),this.Rm=new Wn(this,this.qo),this.Cm.appendChild(this.Rm.Rf());const e=i.autoSize&&this.Dm();let r=this.Sn.width,h=this.Sn.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.Vm(r,h),this.Em(),t.appendChild(this.hp),this.Im(),this.tn.Bt().pu().i(this.tn.Ih.bind(this.tn),this),this.tn.do().i(this.tn.Ih.bind(this.tn),this)}Qt(){return this.tn}N(){return this.Sn}Sf(){return this.fm}Bm(){return this.Rm}m(){this.km(!1),0!==this.vm&&window.cancelAnimationFrame(this.vm),this.tn.Yu().u(this),this.tn.Bt().pu().u(this),this.tn.do().u(this),this.tn.m();for(const t of this.fm)this.Cm.removeChild(t.Rf()),t.Tv().u(this),t.Rv().u(this),t.m();this.fm=[];for(const t of this.pm)this.Am(t);this.pm=[],a(this.Rm).m(),null!==this.hp.parentElement&&this.hp.parentElement.removeChild(this.hp),this.Vu.m(),this.nv.m(),this.sv.m(),this.zm()}Vm(t,i,n=!1){if(this.Ya===i&&this.so===t)return;const s=function(t){const i=Math.floor(t.width),n=Math.floor(t.height);return Ji({width:i-i%2,height:n-n%2})}(Ji({width:t,height:i}));this.Ya=s.height,this.so=s.width;const e=this.Ya+"px",r=this.so+"px";a(this.hp).style.height=e,a(this.hp).style.width=r,this.Cm.style.height=e,this.Cm.style.width=r,n?this.Om(Y.gs(),performance.now()):this.tn.Ih()}Fp(t){void 0===t&&(t=Y.gs());for(let i=0;i<this.fm.length;i++)this.fm[i].Fp(t.ns(i).Jn);this.Sn.timeScale.visible&&this.Rm.Fp(t.ts())}hr(t){const i=Un(this.Sn);this.tn.hr(t);const n=Un(this.Sn);n!==i&&this.km(n),t.layout?.panes&&this.Lm(),this.Im(),this.Nm(t)}Tv(){return this.nv}Rv(){return this.sv}Yu(){return this.Vu}Wm(){null!==this.Mm&&(this.Om(this.Mm,performance.now()),this.Mm=null);const t=this.Fm(null),i=document.createElement("canvas");i.width=t.width,i.height=t.height;const n=a(i.getContext("2d"));return this.Fm(n),i}Hm(t){if("left"===t&&!this.Um())return 0;if("right"===t&&!this.$m())return 0;if(0===this.fm.length)return 0;return a("left"===t?this.fm[0].zv():this.fm[0].Ov()).Wp()}jm(){return this.Sn.autoSize&&null!==this.xm}Bf(){return this.hp}qm(t){this.Sm=t,this.Sm?this.Bf().style.setProperty("cursor",t):this.Bf().style.removeProperty("cursor")}Ym(){return this.Sm}Zm(t){return h(this.fm[t]).Df()}Lm(){this.pm.forEach((t=>{t.Pt()}))}Nm(t){(void 0!==t.autoSize||!this.xm||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.xm&&this.Dm(),!1===t.autoSize&&null!==this.xm&&this.zm(),t.autoSize||void 0===t.width&&void 0===t.height||this.Vm(t.width||this.so,t.height||this.Ya))}Fm(t){let i=0,n=0;const s=this.fm[0],e=(i,n)=>{let s=0;for(let e=0;e<this.fm.length;e++){const r=this.fm[e],h=a("left"===i?r.zv():r.Ov()),l=h.Vf();if(null!==t&&h.Ef(t,n,s),s+=l.height,e<this.fm.length-1){const i=this.pm[e],r=i.Vf();null!==t&&i.Ef(t,n,s),s+=r.height}}};if(this.Um()){e("left",0);i+=a(s.zv()).Vf().width}for(let s=0;s<this.fm.length;s++){const e=this.fm[s],r=e.Vf();if(null!==t&&e.Ef(t,i,n),n+=r.height,s<this.fm.length-1){const e=this.pm[s],r=e.Vf();null!==t&&e.Ef(t,i,n),n+=r.height}}if(i+=s.Vf().width,this.$m()){e("right",i);i+=a(s.Ov()).Vf().width}const r=(i,n,s)=>{a("left"===i?this.Rm.tm():this.Rm.im()).Ef(a(t),n,s)};if(this.Sn.timeScale.visible){const i=this.Rm.Vf();if(null!==t){let e=0;this.Um()&&(r("left",e,n),e=a(s.zv()).Vf().width),this.Rm.Ef(t,e,n),e+=i.width,this.$m()&&r("right",e,n)}n+=i.height}return Ji({width:i,height:n})}Km(){let t=0,i=0,n=0;for(const s of this.fm)this.Um()&&(i=Math.max(i,a(s.zv()).zp(),this.Sn.leftPriceScale.minimumWidth)),this.$m()&&(n=Math.max(n,a(s.Ov()).zp(),this.Sn.rightPriceScale.minimumWidth)),t+=s.fo();i=on(i),n=on(n);const s=this.so,e=this.Ya,r=Math.max(s-i-n,0),h=1*this.pm.length,l=this.Sn.timeScale.visible;let o=l?Math.max(this.Rm.rm(),this.Sn.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e<u?0:e-u,d=c/t;let f=0;const p=window.devicePixelRatio||1;for(let t=0;t<this.fm.length;++t){const s=this.fm[t];s.vv(this.tn.Hn()[t]);let e=0,h=0;h=t===this.fm.length-1?Math.ceil((c-f)*p)/p:Math.round(s.fo()*d*p)/p,e=Math.max(h,2),f+=e,s.Np(Ji({width:r,height:e})),this.Um()&&s.Vv(i,"left"),this.$m()&&s.Vv(n,"right"),s.Wf()&&this.tn.Zu(s.Wf(),e)}this.Rm.sm(Ji({width:l?r:0,height:o}),l?i:0,l?n:0),this.tn.vo(r),this.wm!==i&&(this.wm=i),this.gm!==n&&(this.gm=n)}km(t){t?this.hp.addEventListener("wheel",this.ym,{passive:!1}):this.hp.removeEventListener("wheel",this.ym)}Xm(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Fn?1/window.devicePixelRatio:1}Pm(t){if(!(0!==t.deltaX&&this.Sn.handleScroll.mouseWheel||0!==t.deltaY&&this.Sn.handleScale.mouseWheel))return;const i=this.Xm(t),n=i*t.deltaX/100,s=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==s&&this.Sn.handleScale.mouseWheel){const i=Math.sign(s)*Math.min(1,Math.abs(s)),n=t.clientX-this.hp.getBoundingClientRect().left;this.Qt().tc(n,i)}0!==n&&this.Sn.handleScroll.mouseWheel&&this.Qt().nc(-80*n)}Om(t,i){const n=t.ts();3===n&&this.Gm(),3!==n&&2!==n||(this.Jm(t),this.Qm(t,i),this.Rm.Pt(),this.fm.forEach((t=>{t.wv()})),3===this.Mm?.ts()&&(this.Mm.ps(t),this.Gm(),this.Jm(this.Mm),this.Qm(this.Mm,i),t=this.Mm,this.Mm=null)),this.Fp(t)}Qm(t,i){for(const n of t.fs())this.vs(n,i)}Jm(t){const i=this.tn.Hn();for(let n=0;n<i.length;n++)t.ns(n).Qn&&i[n].Bo()}vs(t,i){const n=this.tn.Bt();switch(t.rs){case 0:n.mu();break;case 1:n.wu(t.Ft);break;case 2:n.cs(t.Ft);break;case 3:n.ds(t.Ft);break;case 4:n.eu();break;case 5:t.Ft.uu(i)||n.ds(t.Ft.cu(i))}}Iu(t){null!==this.Mm?this.Mm.ps(t):this.Mm=t,this.bm||(this.bm=!0,this.vm=window.requestAnimationFrame((t=>{if(this.bm=!1,this.vm=0,null!==this.Mm){const i=this.Mm;this.Mm=null,this.Om(i,t);for(const n of i.fs())if(5===n.rs&&!n.Ft.uu(t)){this.Qt().ls(n.Ft);break}}})))}Gm(){this.Em()}Am(t){this.Cm.removeChild(t.Rf()),t.m()}Em(){const t=this.tn.Hn(),i=t.length,n=this.fm.length;for(let t=i;t<n;t++){const t=h(this.fm.pop());this.Cm.removeChild(t.Rf()),t.Tv().u(this),t.Rv().u(this),t.m();const i=this.pm.pop();void 0!==i&&this.Am(i)}for(let s=n;s<i;s++){const i=new Bn(this,t[s]);if(i.Tv().i(this.tw.bind(this,i),this),i.Rv().i(this.iw.bind(this,i),this),this.fm.push(i),s>0){const t=new mn(this,s-1,s);this.pm.push(t),this.Cm.insertBefore(t.Rf(),this.Rm.Rf())}this.Cm.insertBefore(i.Rf(),this.Rm.Rf())}for(let n=0;n<i;n++){const i=t[n],s=this.fm[n];s.Wf()!==i?s.vv(i):s.pv()}this.Im(),this.Km()}nw(t,i,n,s){const e=new Map;if(null!==t){this.tn.jn().forEach((i=>{const n=i.Yn().Wr(t);null!==n&&e.set(i,n)}))}let r;if(null!==t){const i=this.tn.Bt().nn(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().Hu(),a=null!==h&&h.Wo instanceof Ht?h.Wo:void 0,l=null!==h&&void 0!==h.Fo?h.Fo.Zs:void 0,o=this.sw(s);return{ew:r,Re:t??void 0,rw:i??void 0,hw:-1!==o?o:void 0,aw:a,lw:e,ow:l,_w:n??void 0}}sw(t){let i=-1;if(t)i=this.fm.indexOf(t);else{const t=this.Qt().qu().Fn();null!==t&&(i=this.Qt().Hn().indexOf(t))}return i}tw(t,i,n,s){this.nv.p((()=>this.nw(i,n,s,t)))}iw(t,i,n,s){this.sv.p((()=>this.nw(i,n,s,t)))}Tm(t,i,n){this.qm(this.Qt().Hu()?.Uo??null),this.Vu.p((()=>this.nw(t,i,n)))}Im(){const t=this.Sn.timeScale.visible?"":"none";this.Rm.Rf().style.display=t}Um(){return this.fm[0].Wf().Co().N().visible}$m(){return this.fm[0].Wf().yo().N().visible}Dm(){return"ResizeObserver"in window&&(this.xm=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.Vm(i.contentRect.width,i.contentRect.height)})),this.xm.observe(this.op,{box:"border-box"}),!0)}zm(){null!==this.xm&&this.xm.disconnect(),this.xm=null}}function Un(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function $n(t){return void 0===t.open&&void 0===t.value}function jn(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function qn(t,i,n,s){const e=n.value,r={Re:i,wt:t,Ft:[e,e,e,e],ew:s};return void 0!==n.color&&(r.R=n.color),r}function Yn(t,i,n,s){const e=n.value,r={Re:i,wt:t,Ft:[e,e,e,e],ew:s};return void 0!==n.lineColor&&(r.vt=n.lineColor),void 0!==n.topColor&&(r.mr=n.topColor),void 0!==n.bottomColor&&(r.wr=n.bottomColor),r}function Zn(t,i,n,s){const e=n.value,r={Re:i,wt:t,Ft:[e,e,e,e],ew:s};return void 0!==n.topLineColor&&(r.gr=n.topLineColor),void 0!==n.bottomLineColor&&(r.Mr=n.bottomLineColor),void 0!==n.topFillColor1&&(r.br=n.topFillColor1),void 0!==n.topFillColor2&&(r.Sr=n.topFillColor2),void 0!==n.bottomFillColor1&&(r.Cr=n.bottomFillColor1),void 0!==n.bottomFillColor2&&(r.yr=n.bottomFillColor2),r}function Kn(t,i,n,s){const e={Re:i,wt:t,Ft:[n.open,n.high,n.low,n.close],ew:s};return void 0!==n.color&&(e.R=n.color),e}function Xn(t,i,n,s){const e={Re:i,wt:t,Ft:[n.open,n.high,n.low,n.close],ew:s};return void 0!==n.color&&(e.R=n.color),void 0!==n.borderColor&&(e.Ht=n.borderColor),void 0!==n.wickColor&&(e.vr=n.wickColor),e}function Gn(t,i,n,s,e){const r=h(e)(n),a=Math.max(...r),l=Math.min(...r),o=r[r.length-1],_=[o,a,l,o],{time:u,color:c,...d}=n;return{Re:i,wt:t,Ft:_,ew:s,ne:d,R:c}}function Jn(t){return void 0!==t.Ft}function Qn(t,i){return void 0!==i.customValues&&(t.uw=i.customValues),t}function ts(t){return(i,n,s,e,r,h)=>function(t,i){return i?i(t):$n(t)}(s,h)?Qn({wt:i,Re:n,ew:e},s):Qn(t(i,n,s,e,r),s)}function is(t){return{Candlestick:ts(Xn),Bar:ts(Kn),Area:ts(Yn),Baseline:ts(Zn),Histogram:ts(qn),Line:ts(qn),Custom:ts(Gn)}[t]}function ns(t){return{Re:0,cw:new Map,Hh:t}}function ss(t,i){if(void 0!==t&&0!==t.length)return{dw:i.key(t[0].wt),fw:i.key(t[t.length-1].wt)}}function es(t){let i;return t.forEach((t=>{void 0===i&&(i=t.ew)})),h(i)}class rs{constructor(t){this.pw=new Map,this.mw=new Map,this.ww=new Map,this.gw=[],this.qo=t}m(){this.pw.clear(),this.mw.clear(),this.ww.clear(),this.gw=[]}Mw(t,i){let n=0!==this.pw.size,s=!1;const e=this.mw.get(t);if(void 0!==e)if(1===this.mw.size)n=!1,s=!0,this.pw.clear();else for(const i of this.gw)i.pointData.cw.delete(t)&&(s=!0);let r=[];if(0!==i.length){const n=i.map((t=>t.time)),e=this.qo.createConverterToInternalObj(i),h=is(t.Rr()),a=t.da(),l=t.pa();r=i.map(((i,r)=>{const o=e(i.time),_=this.qo.key(o);let u=this.pw.get(_);void 0===u&&(u=ns(o),this.pw.set(_,u),s=!0);const c=h(o,u.Re,i,n[r],a,l);return u.cw.set(t,c),c}))}n&&this.bw(),this.xw(t,r);let h=-1;if(s){const t=[];this.pw.forEach((i=>{t.push({timeWeight:0,time:i.Hh,pointData:i,originalTime:es(i.cw)})})),t.sort(((t,i)=>this.qo.key(t.time)-this.qo.key(i.time))),h=this.Sw(t)}return this.Cw(t,h,function(t,i,n){const s=ss(t,n),e=ss(i,n);if(void 0!==s&&void 0!==e)return{yw:!1,zh:s.fw>=e.fw&&s.dw>=e.dw}}(this.mw.get(t),e,this.qo))}vc(t){return this.Mw(t,[])}Pw(t,i,n){const s=i;!function(t){void 0===t.ew&&(t.ew=t.time)}(s),this.qo.preprocessData(i);const e=this.qo.createConverterToInternalObj([i])(i.time),r=this.ww.get(t);if(!n&&void 0!==r&&this.qo.key(e)<this.qo.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${e}`);let h=this.pw.get(this.qo.key(e));if(n&&void 0===h)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const a=void 0===h;void 0===h&&(h=ns(e),this.pw.set(this.qo.key(e),h));const l=is(t.Rr()),o=t.da(),_=t.pa(),u=l(e,h.Re,i,s.ew,o,_);h.cw.set(t,u),n?this.kw(t,u,h.Re):this.Tw(t,u);const c={zh:Jn(u),yw:n};if(!a)return this.Cw(t,-1,c);const d={timeWeight:0,time:h.Hh,pointData:h,originalTime:es(h.cw)},f=bt(this.gw,this.qo.key(d.time),((t,i)=>this.qo.key(t.time)<i));this.gw.splice(f,0,d);for(let t=f;t<this.gw.length;++t)hs(this.gw[t].pointData,t);return this.qo.fillWeightsForPoints(this.gw,f),this.Cw(t,f,c)}Tw(t,i){let n=this.mw.get(t);void 0===n&&(n=[],this.mw.set(t,n));const s=0!==n.length?n[n.length-1]:null;null===s||this.qo.key(i.wt)>this.qo.key(s.wt)?Jn(i)&&n.push(i):Jn(i)?n[n.length-1]=i:n.splice(-1,1),this.ww.set(t,i.wt)}kw(t,i,n){const s=this.mw.get(t);if(void 0===s)return;const e=bt(s,n,((t,i)=>t.Re<i));Jn(i)?s[e]=i:s.splice(e,1)}xw(t,i){0!==i.length?(this.mw.set(t,i.filter(Jn)),this.ww.set(t,i[i.length-1].wt)):(this.mw.delete(t),this.ww.delete(t))}bw(){for(const t of this.gw)0===t.pointData.cw.size&&this.pw.delete(this.qo.key(t.time))}Sw(t){let i=-1;for(let n=0;n<this.gw.length&&n<t.length;++n){const s=this.gw[n],e=t[n];if(this.qo.key(s.time)!==this.qo.key(e.time)){i=n;break}e.timeWeight=s.timeWeight,hs(e.pointData,n)}if(-1===i&&this.gw.length!==t.length&&(i=Math.min(this.gw.length,t.length)),-1===i)return-1;for(let n=i;n<t.length;++n)hs(t[n].pointData,n);return this.qo.fillWeightsForPoints(t,i),this.gw=t,i}Rw(){if(0===this.mw.size)return null;let t=0;return this.mw.forEach((i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].Re))})),t}Cw(t,i,n){const s={wo:new Map,Bt:{q_:this.Rw()}};if(-1!==i)this.mw.forEach(((i,e)=>{s.wo.set(e,{ne:i,Dw:e===t?n:void 0})})),this.mw.has(t)||s.wo.set(t,{ne:[],Dw:n}),s.Bt.Vw=this.gw,s.Bt.Ew=i;else{const i=this.mw.get(t);s.wo.set(t,{ne:i||[],Dw:n})}return s}}function hs(t,i){t.Re=i,t.cw.forEach((t=>{t.Re=i}))}function as(t,i){return t.wt<i}function ls(t,i){return i<t.wt}function os(t,i,n){const s=i.Uh(),e=i.bi(),r=bt(t,s,as),h=xt(t,e,ls);if(!n)return{from:r,to:h};let a=r,l=h;return r>0&&r<t.length&&t[r].wt>=s&&(a=r-1),h>0&&h<t.length&&t[h-1].wt<=e&&(l=h+1),{from:a,to:l}}class _s{constructor(t,i,n){this.Iw=!0,this.Bw=!0,this.Aw=!0,this.zw=[],this.Ow=null,this.Js=t,this.Qs=i,this.Lw=n}Pt(t){this.Iw=!0,"data"===t&&(this.Bw=!0),"options"===t&&(this.Aw=!0)}Tt(){return this.Js.Vt()?(this.Nw(),null===this.Ow?null:this.Ww):null}Fw(){this.zw=this.zw.map((t=>({...t,...this.Js.Rh().Dr(t.wt)})))}Hw(){this.Ow=null}Nw(){this.Bw&&(this.Uw(),this.Bw=!1),this.Aw&&(this.Fw(),this.Aw=!1),this.Iw&&(this.$w(),this.Iw=!1)}$w(){const t=this.Js.Wt(),i=this.Qs.Bt();if(this.Hw(),i.Zi()||t.Zi())return;const n=i.ye();if(null===n)return;if(0===this.Js.Yn().zr())return;const s=this.Js.zt();null!==s&&(this.Ow=os(this.zw,n,this.Lw),this.jw(t,i,s.Ft),this.qw())}}class us{constructor(t,i){this.Yw=t,this.qi=i}st(t,i,n){this.Yw.draw(t,this.qi,i,n)}}class cs extends _s{constructor(t,i,n){super(t,i,!1),this.nh=n,this.Ww=new us(this.nh.renderer(),(i=>{const n=t.zt();return null===n?null:t.Wt().Nt(i,n.Ft)}))}fa(t){return this.nh.priceValueBuilder(t)}va(t){return this.nh.isWhitespace(t)}Uw(){const t=this.Js.Rh();this.zw=this.Js.Yn().Hr().map((i=>({wt:i.Re,_t:NaN,...t.Dr(i.Re),Zw:i.ne})))}jw(t,i){i.Y_(this.zw,m(this.Ow))}qw(){this.nh.update({bars:this.zw.map(ds),barSpacing:this.Qs.Bt().Q_(),visibleRange:this.Ow},this.Js.N())}}function ds(t){return{x:t._t,time:t.wt,originalData:t.Zw,barColor:t.cr}}const fs={color:"#2196f3"},ps=(t,i,n)=>{const s=l(n);return new cs(t,i,s)};function vs(t){const i={value:t.Ft[3],time:t.ew};return void 0!==t.uw&&(i.customValues=t.uw),i}function ms(t){const i=vs(t);return void 0!==t.R&&(i.color=t.R),i}function ws(t){const i=vs(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.mr&&(i.topColor=t.mr),void 0!==t.wr&&(i.bottomColor=t.wr),i}function gs(t){const i=vs(t);return void 0!==t.gr&&(i.topLineColor=t.gr),void 0!==t.Mr&&(i.bottomLineColor=t.Mr),void 0!==t.br&&(i.topFillColor1=t.br),void 0!==t.Sr&&(i.topFillColor2=t.Sr),void 0!==t.Cr&&(i.bottomFillColor1=t.Cr),void 0!==t.yr&&(i.bottomFillColor2=t.yr),i}function Ms(t){const i={open:t.Ft[0],high:t.Ft[1],low:t.Ft[2],close:t.Ft[3],time:t.ew};return void 0!==t.uw&&(i.customValues=t.uw),i}function bs(t){const i=Ms(t);return void 0!==t.R&&(i.color=t.R),i}function xs(t){const i=Ms(t),{R:n,Ht:s,vr:e}=t;return void 0!==n&&(i.color=n),void 0!==s&&(i.borderColor=s),void 0!==e&&(i.wickColor=e),i}function Ss(t){return{Area:ws,Line:ms,Baseline:gs,Histogram:ms,Bar:bs,Candlestick:xs,Custom:Cs}[t]}function Cs(t){const i=t.ew;return{...t.ne,time:i}}const ys={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},Ps={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},ks={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:[]},Ts={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},Rs={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 Ds(){return{width:0,height:0,autoSize:!1,layout:ks,crosshair:ys,grid:Ps,overlayPriceScales:{...Ts},leftPriceScale:{...Ts,visible:!1},rightPriceScale:{...Ts,visible:!0},timeScale:Rs,localization:{locale:hn?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 Vs{constructor(t,i,n){this.bf=t,this.Kw=i,this.Xw=n??0}applyOptions(t){this.bf.Qt().$u(this.Kw,t,this.Xw)}options(){return this.qi().N()}width(){return q(this.Kw)?this.bf.Hm(this.Kw):0}qi(){return a(this.bf.Qt().ju(this.Kw,this.Xw)).Wt}}class Es{constructor(t,i,n,s){this.bf=t,this.yt=n,this.Gw=i,this.Jw=s}getHeight(){return this.yt.$t()}setHeight(t){const i=this.bf.Qt(),n=i.Cc(this.yt);i.Xu(n,t)}paneIndex(){return this.bf.Qt().Cc(this.yt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&t<this.bf.Sf().length,"Invalid pane index"),this.bf.Qt().Gu(i,t))}getSeries(){return this.yt.wo().map((t=>this.Gw(t)))??[]}getHTMLElement(){return this.bf.Sf()[this.paneIndex()].Rf()}attachPrimitive(t){this.yt.ua(t),t.attached&&t.attached({chart:this.Jw,requestUpdate:()=>this.yt.Qt().Ih()})}detachPrimitive(t){this.yt.ca(t)}priceScale(t){if(null===this.yt.co(t))throw new Error(`Cannot find price scale with id: ${t}`);return new Vs(this.bf,t,this.paneIndex())}}const Is={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Bs{constructor(t){this.ir=t}applyOptions(t){this.ir.hr(t)}options(){return this.ir.N()}Qw(){return this.ir}}class As{constructor(t,i,n,s,e,r){this.tg=new o,this.Js=t,this.ig=i,this.ng=n,this.qo=e,this.Jw=s,this.sg=r}m(){this.tg.m()}priceFormatter(){return this.Js.ra()}priceToCoordinate(t){const i=this.Js.zt();return null===i?null:this.Js.Wt().Nt(t,i.Ft)}coordinateToPrice(t){const i=this.Js.zt();return null===i?null:this.Js.Wt().Pn(t,i.Ft)}barsInLogicalRange(t){if(null===t)return null;const i=new yi(new xi(t.from,t.to)).o_(),n=this.Js.Yn();if(n.Zi())return null;const s=n.Wr(i.Uh(),1),e=n.Wr(i.bi(),-1),r=a(n.Or()),h=a(n.qn());if(null!==s&&null!==e&&s.Re>e.Re)return{barsBefore:t.from-r,barsAfter:h-t.to};const l={barsBefore:null===s||s.Re===r?t.from-r:s.Re-r,barsAfter:null===e||e.Re===h?h-t.to:h-e.Re};return null!==s&&null!==e&&(l.from=s.ew,l.to=e.ew),l}setData(t){this.qo,this.Js.Rr(),this.ig.eg(this.Js,t),this.rg("full")}update(t,i=!1){this.Js.Rr(),this.ig.hg(this.Js,t,i),this.rg("update")}dataByIndex(t,i){const n=this.Js.Yn().Wr(t,i);if(null===n)return null;return Ss(this.seriesType())(n)}data(){const t=Ss(this.seriesType());return this.Js.Yn().Hr().map((i=>t(i)))}subscribeDataChanged(t){this.tg.i(t)}unsubscribeDataChanged(t){this.tg._(t)}applyOptions(t){this.Js.hr(t)}options(){return p(this.Js.N())}priceScale(){return this.ng.priceScale(this.Js.Wt().wa(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(Is),t),n=this.Js.Lh(i);return new Bs(n)}removePriceLine(t){this.Js.Nh(t.Qw())}priceLines(){return this.Js.Wh().map((t=>new Bs(t)))}seriesType(){return this.Js.Rr()}attachPrimitive(t){this.Js.ua(t),t.attached&&t.attached({chart:this.Jw,series:this,requestUpdate:()=>this.Js.Qt().Ih(),horzScaleBehavior:this.qo})}detachPrimitive(t){this.Js.ca(t),t.detached&&t.detached(),this.Js.Qt().Ih()}getPane(){const t=this.Js,i=a(this.Js.Qt().Hs(t));return this.sg(i)}moveToPane(t){this.Js.Qt().Mc(this.Js,t)}rg(t){this.tg.v()&&this.tg.p(t)}}class zs{constructor(t,i,n){this.ag=new o,this.g_=new o,this.Kv=new o,this.tn=t,this.uh=t.Bt(),this.Rm=i,this.uh.du().i(this.lg.bind(this)),this.uh.fu().i(this.og.bind(this)),this.Rm.nm().i(this._g.bind(this)),this.qo=n}m(){this.uh.du().u(this),this.uh.fu().u(this),this.Rm.nm().u(this),this.ag.m(),this.g_.m(),this.Kv.m()}scrollPosition(){return this.uh.iu()}scrollToPosition(t,i){i?this.uh._u(t,1e3):this.tn.ds(t)}scrollToRealTime(){this.uh.ou()}getVisibleRange(){const t=this.uh.L_();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.qo.convertHorzItemToInternal(t.from),to:this.qo.convertHorzItemToInternal(t.to)},n=this.uh.H_(i);this.tn.wc(n)}getVisibleLogicalRange(){const t=this.uh.O_();return null===t?null:{from:t.Uh(),to:t.bi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.tn.wc(t)}resetTimeScale(){this.tn.us()}fitContent(){this.tn.mu()}logicalToCoordinate(t){const i=this.tn.Bt();return i.Zi()?null:i.jt(t)}coordinateToLogical(t){return this.uh.Zi()?null:this.uh.Z_(t)}timeToIndex(t,i){const n=this.qo.convertHorzItemToInternal(t);return this.uh.B_(n,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.uh.jt(i)}coordinateToTime(t){const i=this.tn.Bt(),n=i.Z_(t),s=i.nn(n);return null===s?null:s.originalTime}width(){return this.Rm.Df().width}height(){return this.Rm.Df().height}subscribeVisibleTimeRangeChange(t){this.ag.i(t)}unsubscribeVisibleTimeRangeChange(t){this.ag._(t)}subscribeVisibleLogicalRangeChange(t){this.g_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.g_._(t)}subscribeSizeChange(t){this.Kv.i(t)}unsubscribeSizeChange(t){this.Kv._(t)}applyOptions(t){this.uh.hr(t)}options(){return{...p(this.uh.N()),barSpacing:this.uh.Q_()}}lg(){this.ag.v()&&this.ag.p(this.getVisibleRange())}og(){this.g_.v()&&this.g_.p(this.getVisibleLogicalRange())}_g(t){this.Kv.p(t.width,t.height)}}function Os(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 n=Math.round(t);if(Math.abs(n-t)<1e-8)return i;t*=10}return i}(i.minMove))}function Ls(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:n}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Ns{constructor(t,i,n){this.ug=new Map,this.cg=new Map,this.dg=new o,this.fg=new o,this.pg=new o,this.ku=new WeakMap,this.vg=new rs(i);const s=void 0===n?p(Ds()):_(p(Ds()),Ls(n));this.mg=i,this.bf=new Hn(t,s,i),this.bf.Tv().i((t=>{this.dg.v()&&this.dg.p(this.wg(t()))}),this),this.bf.Rv().i((t=>{this.fg.v()&&this.fg.p(this.wg(t()))}),this),this.bf.Yu().i((t=>{this.pg.v()&&this.pg.p(this.wg(t()))}),this);const e=this.bf.Qt();this.gg=new zs(e,this.bf.Bm(),this.mg)}remove(){this.bf.Tv().u(this),this.bf.Rv().u(this),this.bf.Yu().u(this),this.gg.m(),this.bf.m(),this.ug.clear(),this.cg.clear(),this.dg.m(),this.fg.m(),this.pg.m(),this.vg.m()}resize(t,i,n){this.autoSizeActive()||this.bf.Vm(t,i,n)}addCustomSeries(t,i={},n=0){const s=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...fs,...t.defaultOptions()},Mg:ps,bg:t}))(l(t));return this.xg(s,i,n)}addSeries(t,i={},n=0){return this.xg(t,i,n)}removeSeries(t){const i=h(this.ug.get(t)),n=this.vg.vc(i);this.bf.Qt().vc(i),this.Sg(n),this.ug.delete(t),this.cg.delete(i)}eg(t,i){this.Sg(this.vg.Mw(t,i))}hg(t,i,n){this.Sg(this.vg.Pw(t,i,n))}subscribeClick(t){this.dg.i(t)}unsubscribeClick(t){this.dg._(t)}subscribeCrosshairMove(t){this.pg.i(t)}unsubscribeCrosshairMove(t){this.pg._(t)}subscribeDblClick(t){this.fg.i(t)}unsubscribeDblClick(t){this.fg._(t)}priceScale(t,i=0){return new Vs(this.bf,t,i)}timeScale(){return this.gg}applyOptions(t){this.bf.hr(Ls(t))}options(){return this.bf.N()}takeScreenshot(){return this.bf.Wm()}removePane(t){this.bf.Qt().Ku(t)}swapPanes(t,i){this.bf.Qt().Gu(t,i)}autoSizeActive(){return this.bf.jm()}chartElement(){return this.bf.Bf()}panes(){return this.bf.Qt().Hn().map((t=>this.Cg(t)))}paneSize(t=0){const i=this.bf.Zm(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,n){const s=this.ug.get(n);if(void 0===s)return;const e=this.bf.Qt().Hs(s);null!==e&&this.bf.Qt().oc(t,i,e)}clearCrosshairPosition(){this.bf.Qt()._c(!0)}horzBehaviour(){return this.mg}xg(i,n={},s=0){r(void 0!==i.Mg),Os(n.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)}(n);const e=_(p(t),p(i.defaultOptions),n),h=i.Mg,a=new Ht(this.bf.Qt(),i.type,e,h,i.bg);this.bf.Qt().dc(a,s);const l=new As(a,this,this,this,this.mg,(t=>this.Cg(t)));return this.ug.set(l,a),this.cg.set(a,l),l}Sg(t){const i=this.bf.Qt();i.uc(t.Bt.q_,t.Bt.Vw,t.Bt.Ew),t.wo.forEach(((t,i)=>i.ht(t.ne,t.Dw))),i.Bt().R_(),i.J_()}yg(t){return h(this.cg.get(t))}wg(t){const i=new Map;t.lw.forEach(((t,n)=>{const s=n.Rr(),e=Ss(s)(t);if("Custom"!==s)r(jn(e));else{const t=n.pa();r(!t||!1===t(e))}i.set(this.yg(n),e)}));const n=void 0!==t.aw&&this.cg.has(t.aw)?this.yg(t.aw):void 0;return{time:t.ew,logical:t.Re,point:t.rw,paneIndex:t.hw,hoveredSeries:n,hoveredObjectId:t.ow,seriesData:i,sourceEvent:t._w}}Cg(t){let i=this.ku.get(t);return i||(i=new Es(this.bf,(t=>this.yg(t)),t,this),this.ku.set(t,i)),i}}function Ws(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function Fs(t,i,n){const s=Ws(t),e=new Ns(s,i,n);return i.setOptions(e.options()),e}function Hs(t,i){return Fs(t,new Gi,Gi.Wc(i))}function Us(){return Gi}class $s extends _s{constructor(t,i){super(t,i,!0)}jw(t,i,n){i.Y_(this.zw,m(this.Ow)),t.Dl(this.zw,n,m(this.Ow))}Pg(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}Uw(){const t=this.Js.Rh();this.zw=this.Js.Yn().Hr().map((i=>{const n=i.Ft[3];return this.kg(i.Re,n,t)}))}}function js(t,i,n,s,e,r,h){if(0===i.length||s.from>=i.length||s.to<=0)return;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:o}=t,_=i[s.from];let u=r(t,_),c=_;if(s.to-s.from<2){const i=e/2;a.beginPath();const n={_t:_._t-i,ut:_.ut},s={_t:_._t+i,ut:_.ut};a.moveTo(n._t*l,n.ut*o),a.lineTo(s._t*l,s.ut*o),h(t,u,n,s)}else{const e=(i,n)=>{h(t,u,c,n),a.beginPath(),u=i,c=n};let d=c;a.beginPath(),a.moveTo(_._t*l,_.ut*o);for(let h=s.from+1;h<s.to;++h){d=i[h];const s=r(t,d);switch(n){case 0:a.lineTo(d._t*l,d.ut*o);break;case 1:a.lineTo(d._t*l,i[h-1].ut*o),s!==u&&(e(s,d),a.lineTo(d._t*l,i[h-1].ut*o)),a.lineTo(d._t*l,d.ut*o);break;case 2:{const[t,n]=Ks(i,h-1,h);a.bezierCurveTo(t._t*l,t.ut*o,n._t*l,n.ut*o,d._t*l,d.ut*o);break}}1!==n&&s!==u&&(e(s,d),a.moveTo(d._t*l,d.ut*o))}(c!==d||c===d&&1===n)&&h(t,u,c,d)}}const qs=6;function Ys(t,i){return{_t:t._t-i._t,ut:t.ut-i.ut}}function Zs(t,i){return{_t:t._t/i,ut:t.ut/i}}function Ks(t,i,n){const s=Math.max(0,i-1),e=Math.min(t.length-1,n+1);var r,h;return[(r=t[i],h=Zs(Ys(t[n],t[s]),qs),{_t:r._t+h._t,ut:r.ut+h.ut}),Ys(t[n],Zs(Ys(t[e],t[i]),qs))]}function Xs(t,i){const n=t.context;n.strokeStyle=i,n.stroke()}class Gs extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,Tg:e,Rg:r,ct:h,Kt:a,Dg:l}=this.rt;if(null===n)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,s(o,a),o.lineJoin="round";const _=this.Vg.bind(this);void 0!==r&&js(t,i,r,n,e,_,Xs),l&&function(t,i,n,s,e){if(s.to-s.from<=0)return;const{horizontalPixelRatio:r,verticalPixelRatio:h,context:a}=t;let l=null;const o=Math.max(1,Math.floor(r))%2/2,_=n*h+o;for(let n=s.to-1;n>=s.from;--n){const s=i[n];if(s){const i=e(t,s);i!==l&&(a.beginPath(),null!==l&&a.fill(),a.fillStyle=i,l=i);const n=Math.round(s._t*r)+o,u=s.ut*h;a.moveTo(n,u),a.arc(n,u,_,0,2*Math.PI)}}a.fill()}(t,i,l,n,_)}}class Js extends Gs{Vg(t,i){return i.vt}}class Qs extends $s{constructor(){super(...arguments),this.Ww=new Js}kg(t,i,n){return{...this.Pg(t,i),...n.Dr(t)}}qw(){const t=this.Js.N(),i={ot:this.zw,Kt:t.lineStyle,Rg:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Dg:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Ow,Tg:this.Qs.Bt().Q_()};this.Ww.ht(i)}}const te={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},Mg:(t,i)=>new Qs(t,i)};function ie(t,i){return t.weight>i.weight?t:i}class ne{constructor(){this.Eg=new o,this.Ig=function(t){let i=!1;return function(...n){i||(i=!0,queueMicrotask((()=>{t(...n),i=!1})))}}((()=>this.Eg.p(this.Bg))),this.Bg=0}Ag(){return this.Eg}m(){this.Eg.m()}options(){return this.Sn}setOptions(t){this.Sn=t}preprocessData(t){}updateFormatter(t){this.Sn&&(this.Sn.localization=t)}createConverterToInternalObj(t){return this.Ig(),t=>(t>this.Bg&&(this.Bg=t),t)}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return this.zg(t)}formatTickmark(t){return this.zg(t.time)}maxTickMarkWeight(t){return t.reduce(ie,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)%120==0?10:n%60==0?9:n%36==0?8:n%12==0?7:n%6==0?6:n%3==0?5:n%1==0?4:0;var n;this.Bg=t[t.length-1].time,this.Ig()}zg(t){if(this.Sn.localization?.timeFormatter)return this.Sn.localization.timeFormatter(t);if(t<12)return`${t}M`;const i=Math.floor(t/12),n=t%12;return 0===n?`${i}Y`:`${i}Y${n}M`}}const se={yieldCurve:{baseResolution:1,minimumTimeRange:120,startTimeRange:0},timeScale:{ignoreWhitespaceIndices:!0},leftPriceScale:{visible:!0},rightPriceScale:{visible:!1},localization:{priceFormatter:t=>t.toFixed(3)+"%"}},ee={lastValueVisible:!1,priceLineVisible:!1};class re extends Ns{constructor(t,i){const n=_(se,i||{}),s=new ne;super(t,s,n),s.setOptions(this.options()),this._initWhitespaceSeries()}addSeries(t,i={},n=0){if(t.isBuiltIn&&!1===["Area","Line"].includes(t.type))throw new Error("Yield curve only support Area and Line series");const s={...ee,...i};return super.addSeries(t,s,n)}_initWhitespaceSeries(){const t=this.horzBehaviour(),i=this.addSeries(te);let n;function s(s){const e=function(t,i){return{le:Math.max(0,t.startTimeRange),oe:Math.max(0,t.minimumTimeRange,i||0),Og:Math.max(1,t.baseResolution)}}(t.options().yieldCurve,s),r=(({le:t,oe:i,Og:n})=>`${t}~${i}~${n}`)(e);r!==n&&(n=r,i.setData(function({le:t,oe:i,Og:n}){return Array.from({length:Math.floor((i-t)/n)+1},((i,s)=>({time:t+s*n})))}(e)))}s(0),t.Ag().i(s)}}function he(t,i){const n=Ws(t);return new re(n,i)}function ae(t,i){return t.weight>i.weight?t:i}class le{options(){return this.Sn}setOptions(t){this.Sn=t}preprocessData(t){}updateFormatter(t){this.Sn&&(this.Sn.localization=t)}createConverterToInternalObj(t){return t=>t}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return t.toFixed(this.Cs())}formatTickmark(t,i){return t.time.toFixed(this.Cs())}maxTickMarkWeight(t){return t.reduce(ae,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)===100*Math.ceil(n/100)?8:n===50*Math.ceil(n/50)?7:n===25*Math.ceil(n/25)?6:n===10*Math.ceil(n/10)?5:n===5*Math.ceil(n/5)?4:n===Math.ceil(n)?3:2*n===Math.ceil(2*n)?1:0;var n}Cs(){return this.Sn.localization.precision}}function oe(t,i){return Fs(t,new le,i)}function _e(t,i,n,s,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:a}=i;r.lineTo(e._t*h,t*a),r.lineTo(s._t*h,t*a),r.closePath(),r.fillStyle=n,r.fill()}class ue extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,Tg:e,ct:r,Kt:h,Rg:a}=this.rt,l=this.rt.Lg??(this.rt.Ng?0:t.mediaSize.height);if(null===n)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,s(o,h),o.lineWidth=1,js(t,i,a,n,e,this.Wg.bind(this),_e.bind(null,l))}}class ce{Fg(t,i){const n=this.Hg,{Ug:s,$g:e,jg:r,qg:h,Lg:a,Yg:l,Zg:o}=i;if(void 0===this.Kg||void 0===n||n.Ug!==s||n.$g!==e||n.jg!==r||n.qg!==h||n.Lg!==a||n.Yg!==l||n.Zg!==o){const{verticalPixelRatio:n}=t,_=a||l>0?n:1,u=l*_,c=o===t.bitmapSize.height?o:o*_,d=(a??0)*_,f=t.context.createLinearGradient(0,u,0,c);if(f.addColorStop(0,s),null!=a){const t=ri((d-u)/(c-u),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.Kg=f,this.Hg=i}return this.Kg}}class de extends ue{constructor(){super(...arguments),this.Xg=new ce}Wg(t,i){const n=this.rt;return this.Xg.Fg(t,{Ug:i.br,$g:i.Sr,jg:i.Cr,qg:i.yr,Lg:n.Lg,Yg:n.Yg??0,Zg:n.Zg??t.bitmapSize.height})}}class fe extends Gs{constructor(){super(...arguments),this.Gg=new ce}Vg(t,i){const n=this.rt;return this.Gg.Fg(t,{Ug:i.gr,$g:i.gr,jg:i.Mr,qg:i.Mr,Lg:n.Lg,Yg:n.Yg??0,Zg:n.Zg??t.bitmapSize.height})}}class pe extends $s{constructor(t,i){super(t,i),this.Ww=new C,this.Jg=new de,this.Qg=new fe,this.Ww.nt([this.Jg,this.Qg])}kg(t,i,n){return{...this.Pg(t,i),...n.Dr(t)}}qw(){const t=this.Js.zt();if(null===t)return;const i=this.Js.N(),n=this.Js.Wt().Nt(i.baseValue.price,t.Ft),s=this.Qs.Bt().Q_();if(null===this.Ow||0===this.zw.length)return;let e,r;if(i.relativeGradient){e=this.zw[this.Ow.from].ut,r=this.zw[this.Ow.from].ut;for(let t=this.Ow.from;t<this.Ow.to;t++){const i=this.zw[t];i.ut<e&&(e=i.ut),i.ut>r&&(r=i.ut)}}this.Jg.ht({ot:this.zw,ct:i.lineWidth,Kt:i.lineStyle,Rg:i.lineType,Lg:n,Yg:e,Zg:r,Ng:!1,lt:this.Ow,Tg:s}),this.Qg.ht({ot:this.zw,ct:i.lineWidth,Kt:i.lineStyle,Rg:i.lineVisible?i.lineType:void 0,Dg:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,Lg:n,Yg:e,Zg:r,lt:this.Ow,Tg:s})}}const ve={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},Mg:(t,i)=>new pe(t,i)};class me extends ue{constructor(){super(...arguments),this.Xg=new ce}Wg(t,i){return this.Xg.Fg(t,{Ug:i.mr,$g:"",jg:"",qg:i.wr,Yg:this.rt?.Yg??0,Zg:t.bitmapSize.height})}}class we extends $s{constructor(t,i){super(t,i),this.Ww=new C,this.tM=new me,this.iM=new Js,this.Ww.nt([this.tM,this.iM])}kg(t,i,n){return{...this.Pg(t,i),...n.Dr(t)}}qw(){const t=this.Js.N();if(null===this.Ow||0===this.zw.length)return;let i;if(t.relativeGradient){i=this.zw[this.Ow.from].ut;for(let t=this.Ow.from;t<this.Ow.to;t++){const n=this.zw[t];n.ut<i&&(i=n.ut)}}this.tM.ht({Rg:t.lineType,ot:this.zw,Kt:t.lineStyle,ct:t.lineWidth,Lg:null,Yg:i,Ng:t.invertFilledArea,lt:this.Ow,Tg:this.Qs.Bt().Q_()}),this.iM.ht({Rg:t.lineVisible?t.lineType:void 0,ot:this.zw,Kt:t.lineStyle,ct:t.lineWidth,lt:this.Ow,Tg:this.Qs.Bt().Q_(),Dg:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}const ge={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},Mg:(t,i)=>new we(t,i)};class Me extends y{constructor(){super(...arguments),this.qt=null,this.nM=0,this.sM=0}ht(t){this.qt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.Yn.length||null===this.qt.lt)return;if(this.nM=this.eM(i),this.nM>=2){Math.max(1,Math.floor(i))%2!=this.nM%2&&this.nM--}this.sM=this.qt.rM?Math.min(this.nM,Math.floor(i)):this.nM;let s=null;const e=this.sM<=this.nM&&this.qt.Q_>=Math.floor(1.5*i);for(let r=this.qt.lt.from;r<this.qt.lt.to;++r){const h=this.qt.Yn[r];s!==h.cr&&(t.fillStyle=h.cr,s=h.cr);const a=Math.floor(.5*this.sM),l=Math.round(h._t*i),o=l-a,_=this.sM,u=o+_-1,c=Math.min(h.Bl,h.Al),d=Math.max(h.Bl,h.Al),f=Math.round(c*n)-a,p=Math.round(d*n)+a,v=Math.max(p-f,this.sM);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.nM);if(e){if(this.qt.hM){const i=l-m;let s=Math.max(f,Math.round(h.Il*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(i,s,o-i,e-s+1)}const i=l+m;let s=Math.max(f,Math.round(h.zl*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(u+1,s,i-u,e-s+1)}}}eM(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(a(this.qt).Q_,t)))}}class be extends _s{constructor(t,i){super(t,i,!1)}jw(t,i,n){i.Y_(this.zw,m(this.Ow)),t.El(this.zw,n,m(this.Ow))}aM(t,i,n){return{wt:t,jh:i.Ft[0],qh:i.Ft[1],Yh:i.Ft[2],Zh:i.Ft[3],_t:NaN,Il:NaN,Bl:NaN,Al:NaN,zl:NaN}}Uw(){const t=this.Js.Rh();this.zw=this.Js.Yn().Hr().map((i=>this.kg(i.Re,i,t)))}}class xe extends be{constructor(){super(...arguments),this.Ww=new Me}kg(t,i,n){return{...this.aM(t,i,n),...n.Dr(t)}}qw(){const t=this.Js.N();this.Ww.ht({Yn:this.zw,Q_:this.Qs.Bt().Q_(),hM:t.openVisible,rM:t.thinBars,lt:this.Ow})}}const Se={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},Mg:(t,i)=>new xe(t,i)};class Ce extends y{constructor(){super(...arguments),this.qt=null,this.nM=0}ht(t){this.qt=t}et(t){if(null===this.qt||0===this.qt.Yn.length||null===this.qt.lt)return;const{horizontalPixelRatio:i}=t;if(this.nM=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const n=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),s=Math.floor(t*n*i),e=Math.floor(t*i),r=Math.min(s,e);return Math.max(Math.floor(i),r)}(this.qt.Q_,i),this.nM>=2){Math.floor(i)%2!=this.nM%2&&this.nM--}const n=this.qt.Yn;this.qt.lM&&this.oM(t,n,this.qt.lt),this.qt.Mi&&this.$p(t,n,this.qt.lt);const s=this._M(i);(!this.qt.Mi||this.nM>2*s)&&this.uM(t,n,this.qt.lt)}oM(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",a=Math.min(Math.floor(e),Math.floor(this.qt.Q_*e));a=Math.max(Math.floor(e),Math.min(a,this.nM));const l=Math.floor(.5*a);let o=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.pr!==h&&(s.fillStyle=n.pr,h=n.pr);const _=Math.round(Math.min(n.Il,n.zl)*r),u=Math.round(Math.max(n.Il,n.zl)*r),c=Math.round(n.Bl*r),d=Math.round(n.Al*r);let f=Math.round(e*n._t)-l;const p=f+a-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;s.fillRect(f,c,v,_-c),s.fillRect(f,u+1,v,d-u),o=p}}_M(t){let i=Math.floor(1*t);this.nM<=2*i&&(i=Math.floor(.5*(this.nM-1)));const n=Math.max(Math.floor(t),i);return this.nM<=2*n?Math.max(Math.floor(t),Math.floor(1*t)):n}$p(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this._M(e);let l=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.dr!==h&&(s.fillStyle=n.dr,h=n.dr);let o=Math.round(n._t*e)-Math.floor(.5*this.nM);const _=o+this.nM-1,u=Math.round(Math.min(n.Il,n.zl)*r),c=Math.round(Math.max(n.Il,n.zl)*r);if(null!==l&&(o=Math.max(l+1,o),o=Math.min(o,_)),this.qt.Q_*e>2*a)E(s,o,u,_-o+1,c-u+1,a);else{const t=_-o+1;s.fillRect(o,u,t,c-u+1)}l=_}}uM(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this._M(e);for(let t=n.from;t<n.to;t++){const n=i[t];let l=Math.round(Math.min(n.Il,n.zl)*r),o=Math.round(Math.max(n.Il,n.zl)*r),_=Math.round(n._t*e)-Math.floor(.5*this.nM),u=_+this.nM-1;if(n.cr!==h){const t=n.cr;s.fillStyle=t,h=t}this.qt.Mi&&(_+=a,l+=a,u-=a,o-=a),l>o||s.fillRect(_,l,u-_+1,o-l+1)}}}class ye extends be{constructor(){super(...arguments),this.Ww=new Ce}kg(t,i,n){return{...this.aM(t,i,n),...n.Dr(t)}}qw(){const t=this.Js.N();this.Ww.ht({Yn:this.zw,Q_:this.Qs.Bt().Q_(),lM:t.wickVisible,Mi:t.borderVisible,lt:this.Ow})}}const Pe={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"},Mg:(t,i)=>new ye(t,i)};class ke extends y{constructor(){super(...arguments),this.qt=null,this.cM=[]}ht(t){this.qt=t,this.cM=[]}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return;this.cM.length||this.dM(i);const s=Math.max(1,Math.floor(n)),e=Math.round(this.qt.fM*n)-Math.floor(s/2),r=e+s;for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const h=this.qt.ot[i],a=this.cM[i-this.qt.lt.from],l=Math.round(h.ut*n);let o,_;t.fillStyle=h.cr,l<=e?(o=l,_=r):(o=e,_=l-Math.floor(s/2)+s),t.fillRect(a.Uh,o,a.bi-a.Uh+1,_-o)}}dM(t){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return void(this.cM=[]);const i=Math.ceil(this.qt.Q_*t)<=1?0:Math.max(1,Math.floor(t)),n=Math.round(this.qt.Q_*t)-i;this.cM=new Array(this.qt.lt.to-this.qt.lt.from);for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const s=this.qt.ot[i],e=Math.round(s._t*t);let r,h;if(n%2){const t=(n-1)/2;r=e-t,h=e+t}else{const t=n/2;r=e-t,h=e+t-1}this.cM[i-this.qt.lt.from]={Uh:r,bi:h,pM:e,se:s._t*t,wt:s.wt}}for(let t=this.qt.lt.from+1;t<this.qt.lt.to;t++){const n=this.cM[t-this.qt.lt.from],s=this.cM[t-this.qt.lt.from-1];n.wt===s.wt+1&&(n.Uh-s.bi!==i+1&&(s.pM>s.se?s.bi=n.Uh-i-1:n.Uh=s.bi+i+1))}let s=Math.ceil(this.qt.Q_*t);for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.cM[t-this.qt.lt.from];i.bi<i.Uh&&(i.bi=i.Uh);const n=i.bi-i.Uh+1;s=Math.min(n,s)}if(i>0&&s<4)for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.cM[t-this.qt.lt.from];i.bi-i.Uh+1>s&&(i.pM>i.se?i.bi-=1:i.Uh+=1)}}}class Te extends $s{constructor(){super(...arguments),this.Ww=new ke}kg(t,i,n){return{...this.Pg(t,i),...n.Dr(t)}}qw(){const t={ot:this.zw,Q_:this.Qs.Bt().Q_(),lt:this.Ow,fM:this.Js.Wt().Nt(this.Js.N().base,a(this.Js.zt()).Ft)};this.Ww.ht(t)}}const Re={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},Mg:(t,i)=>new Te(t,i)};class De{constructor(t,i){this.yt=t,this.vM=i,this.mM()}detach(){this.yt.detachPrimitive(this.vM)}getPane(){return this.yt}applyOptions(t){this.vM.hr?.(t)}mM(){this.yt.attachPrimitive(this.vM)}}const Ve={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},Ee={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:w,fontStyle:"",text:""};class Ie{constructor(t){this.wM=new Map,this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{if(!this.qt.visible)return;const{context:i,mediaSize:n}=t;let s=0;for(const t of this.qt.lines){if(0===t.text.length)continue;i.font=t.k;const e=this.gM(i,t.text);e>n.width?t.hu=n.width/e:t.hu=1,s+=t.lineHeight*t.hu}let e=0;switch(this.qt.vertAlign){case"top":e=0;break;case"center":e=Math.max((n.height-s)/2,0);break;case"bottom":e=Math.max(n.height-s,0)}for(const t of this.qt.lines){i.save(),i.fillStyle=t.color;let s=0;switch(this.qt.horzAlign){case"left":i.textAlign="left",s=t.lineHeight/2;break;case"center":i.textAlign="center",s=n.width/2;break;case"right":i.textAlign="right",s=n.width-1-t.lineHeight/2}i.translate(s,e),i.textBaseline="top",i.font=t.k,i.scale(t.hu,t.hu),i.fillText(t.text,0,t.MM),i.restore(),e+=t.lineHeight*t.hu}}))}gM(t,i){const n=this.bM(t.font);let s=n.get(i);return void 0===s&&(s=t.measureText(i).width,n.set(i,s)),s}bM(t){let i=this.wM.get(t);return void 0===i&&(i=new Map,this.wM.set(t,i)),i}}class Be{constructor(t){this.Sn=ze(t)}Pt(t){this.Sn=ze(t)}renderer(){return new Ie(this.Sn)}}function Ae(t){return{...t,k:g(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,MM:0,hu:0}}function ze(t){return{...t,lines:t.lines.map(Ae)}}function Oe(t){return{...Ee,...t}}function Le(t){return{...Ve,...t,lines:t.lines?.map(Oe)??[]}}class Ne{constructor(t){this.Sn=Le(t),this.xM=[new Be(this.Sn)]}updateAllViews(){this.xM.forEach((t=>t.Pt(this.Sn)))}paneViews(){return this.xM}attached({requestUpdate:t}){this.SM=t}detached(){this.SM=void 0}hr(t){this.Sn=Le({...this.Sn,...t}),this.SM&&this.SM()}}function We(t,i){return new De(t,new Ne(i))}const Fe={alpha:1,padding:0};class He{constructor(t){this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{const i=t.context,n=this.CM(this.qt,t.mediaSize);n&&this.qt.yM&&(i.globalAlpha=this.qt.alpha??1,i.drawImage(this.qt.yM,n._t,n.ut,n.Qi,n.$t))}))}CM(t,i){const{maxHeight:n,maxWidth:s,PM:e,kM:r,padding:h}=t,a=Math.round(i.width/2),l=Math.round(i.height/2),o=h??0;let _=i.width-2*o,u=i.height-2*o;n&&(u=Math.min(u,n)),s&&(_=Math.min(_,s));const c=_/r,d=u/e,f=Math.min(c,d),p=r*f,v=e*f;return{_t:a-.5*p,ut:l-.5*v,$t:v,Qi:p}}}class Ue{constructor(t){this.TM=null,this.RM=0,this.DM=0,this.Sn=t,this.M=$e(this.Sn,this.TM,this.RM,this.DM)}VM(t){void 0!==t.EM&&(this.RM=t.EM),void 0!==t.IM&&(this.DM=t.IM),void 0!==t.BM&&(this.TM=t.BM),this.Pt()}AM(t){this.Sn=t,this.Pt()}zOrder(){return"bottom"}Pt(){this.M=$e(this.Sn,this.TM,this.RM,this.DM)}renderer(){return new He(this.M)}}function $e(t,i,n,s){return{...t,yM:i,kM:n,PM:s}}function je(t){return{...Fe,...t}}class qe{constructor(t,i){this.zM=null,this.OM=t,this.Sn=je(i),this.xM=[new Ue(this.Sn)]}updateAllViews(){this.xM.forEach((t=>t.Pt()))}paneViews(){return this.xM}attached(t){const{requestUpdate:i}=t;this.LM=i,this.zM=new Image,this.zM.onload=()=>{const t=this.zM?.naturalHeight??1,i=this.zM?.naturalWidth??1;this.xM.forEach((n=>n.VM({IM:t,EM:i,BM:this.zM}))),this.LM&&this.LM()},this.zM.src=this.OM}detached(){this.LM=void 0,this.zM=null}hr(t){this.Sn=je({...this.Sn,...t}),this.NM(),this.SM&&this.SM()}SM(){this.LM&&this.LM()}NM(){this.xM.forEach((t=>t.AM(this.Sn)))}}function Ye(t,i,n){return new De(t,new qe(i,n))}class Ze{constructor(t,i){this.Js=t,this.ah=i,this.mM()}detach(){this.Js.detachPrimitive(this.ah)}getSeries(){return this.Js}applyOptions(t){this.ah&&this.ah.hr&&this.ah.hr(t)}mM(){this.Js.attachPrimitive(this.ah)}}function Ke(t,i){return ai(Math.min(Math.max(t,12),30)*i)}function Xe(t,i){switch(t){case"arrowDown":case"arrowUp":return Ke(i,1);case"circle":return Ke(i,.8);case"square":return Ke(i,.7)}}function Ge(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(Ke(t,1))}function Je(t){return Math.max(Ke(t,.1),3)}function Qe(t,i,n){return i?t:n?Math.ceil(t/2):0}function tr(t,i,n,s){const e=(Xe("arrowUp",s)-1)/2*n.WM,r=(ai(s/2)-1)/2*n.WM;i.beginPath(),t?(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut-e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut+e),i.lineTo(n._t-r,n.ut+e),i.lineTo(n._t-r,n.ut)):(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut+e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut-e),i.lineTo(n._t-r,n.ut-e),i.lineTo(n._t-r,n.ut)),i.fill()}function ir(t,i,n,s,e,r){const h=(Xe("arrowUp",s)-1)/2,a=(ai(s/2)-1)/2;if(e>=i-a-2&&e<=i+a+2&&r>=(t?n:n-h)-2&&r<=(t?n+h:n)+2)return!0;return(()=>{if(e<i-h-3||e>i+h+3||r<(t?n-h-3:n)||r>(t?n:n+h+3))return!1;const s=Math.abs(e-i);return Math.abs(r-n)+3>=s/2})()}class nr{constructor(){this.qt=null,this.Ls=new tt,this.W=-1,this.F="",this.Mp=""}ht(t){this.qt=t}Ns(t,i){this.W===t&&this.F===i||(this.W=t,this.F=i,this.Mp=g(t,i),this.Ls.Es())}Ys(t,i){if(null===this.qt||null===this.qt.lt)return null;for(let n=this.qt.lt.from;n<this.qt.lt.to;n++){const s=this.qt.ot[n];if(s&&er(s,t,i))return{zOrder:"normal",externalId:s.Zs??""}}return null}draw(t){t.useBitmapCoordinateSpace((t=>{this.et(t)}))}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null!==this.qt&&null!==this.qt.lt){t.textBaseline="middle",t.font=this.Mp;for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=this.qt.ot[s];void 0!==e.ri&&(e.ri.Qi=this.Ls.Vi(t,e.ri.FM),e.ri.$t=this.W,e.ri._t=e._t-e.ri.Qi/2),sr(e,t,i,n)}}}}function sr(t,i,n,s){i.fillStyle=t.R,void 0!==t.ri&&function(t,i,n,s,e,r){t.save(),t.scale(e,r),t.fillText(i,n,s),t.restore()}(i,t.ri.FM,t.ri._t,t.ri.ut,n,s),function(t,i,n){if(0===t.zr)return;switch(t.HM){case"arrowDown":return void tr(!1,i,n,t.zr);case"arrowUp":return void tr(!0,i,n,t.zr);case"circle":return void function(t,i,n){const s=(Xe("circle",n)-1)/2;t.beginPath(),t.arc(i._t,i.ut,s*i.WM,0,2*Math.PI,!1),t.fill()}(i,n,t.zr);case"square":return void function(t,i,n){const s=Xe("square",n),e=(s-1)*i.WM/2,r=i._t-e,h=i.ut-e;t.fillRect(r,h,s*i.WM,s*i.WM)}(i,n,t.zr)}t.HM}(t,i,function(t,i,n){const s=Math.max(1,Math.floor(i))%2/2;return{_t:Math.round(t._t*i)+s,ut:t.ut*n,WM:i}}(t,n,s))}function er(t,i,n){return!(void 0===t.ri||!function(t,i,n,s,e,r){const h=s/2;return e>=t&&e<=t+n&&r>=i-h&&r<=i+h}(t.ri._t,t.ri.ut,t.ri.Qi,t.ri.$t,i,n))||function(t,i,n){if(0===t.zr)return!1;switch(t.HM){case"arrowDown":return ir(!0,t._t,t.ut,t.zr,i,n);case"arrowUp":return ir(!1,t._t,t.ut,t.zr,i,n);case"circle":return function(t,i,n,s,e){const r=2+Xe("circle",n)/2,h=t-s,a=i-e;return Math.sqrt(h*h+a*a)<=r}(t._t,t.ut,t.zr,i,n);case"square":return function(t,i,n,s,e){const r=Xe("square",n),h=(r-1)/2,a=t-h,l=i-h;return s>=a&&s<=a+r&&e>=l&&e<=l+r}(t._t,t.ut,t.zr,i,n)}}(t,i,n)}function rr(t){return"atPriceTop"===t||"atPriceBottom"===t||"atPriceMiddle"===t}function hr(t,i,n,s,e,r,h,l){const o=function(t,i){if(rr(i.position)&&void 0!==i.price)return i.price;if("value"in(n=t)&&"number"==typeof n.value)return t.value;var n;if(function(t){return"open"in t&&"high"in t&&"low"in t&&"close"in t}(t)){if("inBar"===i.position)return t.close;if("aboveBar"===i.position)return t.high;if("belowBar"===i.position)return t.low}}(n,i);if(void 0===o)return;const _=rr(i.position),c=l.timeScale(),d=u(i.size)?Math.max(i.size,0):1,f=Ge(c.options().barSpacing)*d,p=f/2;t.zr=f;switch(i.position){case"inBar":case"atPriceMiddle":return t.ut=a(h.priceToCoordinate(o)),void(void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e));case"aboveBar":case"atPriceTop":{const i=_?0:s.UM;return t.ut=a(h.priceToCoordinate(o))-p-i,void 0!==t.ri&&(t.ri.ut=t.ut-p-.6*e,s.UM+=1.2*e),void(_||(s.UM+=f+r))}case"belowBar":case"atPriceBottom":{const i=_?0:s.$M;return t.ut=a(h.priceToCoordinate(o))+p+i,void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e,s.$M+=1.2*e),void(_||(s.$M+=f+r))}}}class ar{constructor(t,i){this.jM=[],this.St=!0,this.qM=!0,this.Gt=new nr,this.ge=t,this._p=i,this.qt={ot:[],lt:null}}renderer(){if(!this.ge.options().visible)return null;this.St&&this.YM();const t=this._p.options().layout;return this.Gt.Ns(t.fontSize,t.fontFamily),this.Gt.ht(this.qt),this.Gt}ZM(t){this.jM=t,this.Pt("data")}Pt(t){this.St=!0,"data"===t&&(this.qM=!0)}YM(){const t=this._p.timeScale(),i=this.jM;this.qM&&(this.qt.ot=i.map((t=>({wt:t.time,_t:0,ut:0,zr:0,HM:t.shape,R:t.color,Zs:t.id,KM:t.KM,ri:void 0}))),this.qM=!1);const n=this._p.options().layout;this.qt.lt=null;const s=t.getVisibleLogicalRange();if(null===s)return;const e=new xi(Math.floor(s.from),Math.ceil(s.to));if(null===this.ge.data()[0])return;if(0===this.qt.ot.length)return;let r=NaN;const h=Je(t.options().barSpacing),l={UM:h,$M:h};this.qt.lt=os(this.qt.ot,e,!0);for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=i[s];e.time!==r&&(l.UM=h,l.$M=h,r=e.time);const o=this.qt.ot[s];o._t=a(t.logicalToCoordinate(e.time)),void 0!==e.text&&e.text.length>0&&(o.ri={FM:e.text,_t:0,ut:0,Qi:0,$t:0});const _=this.ge.dataByIndex(e.time,0);null!==_&&hr(o,e,_,l,n.fontSize,h,this.ge,this._p)}this.St=!1}}class lr{constructor(){this.nh=null,this.jM=[],this.XM=[],this.GM=null,this.ge=null,this._p=null,this.JM=!0,this.QM=null,this.tb=null,this.ib=null,this.nb=!0}attached(t){this.sb(),this._p=t.chart,this.ge=t.series,this.nh=new ar(this.ge,a(this._p)),this.LM=t.requestUpdate,this.ge.subscribeDataChanged((t=>this.rg(t))),this.nb=!0,this.SM()}SM(){this.LM&&this.LM()}detached(){this.ge&&this.GM&&this.ge.unsubscribeDataChanged(this.GM),this._p=null,this.ge=null,this.nh=null,this.GM=null}ZM(t){this.nb=!0,this.jM=t,this.sb(),this.JM=!0,this.tb=null,this.SM()}eb(){return this.jM}paneViews(){return this.nh?[this.nh]:[]}updateAllViews(){this.rb()}hitTest(t,i){return this.nh?this.nh.renderer()?.Ys(t,i)??null:null}autoscaleInfo(t,i){if(this.nh){const t=this.hb();if(t)return{priceRange:null,margins:t}}return null}hb(){const t=a(this._p).timeScale().options().barSpacing;if(this.JM||t!==this.ib){if(this.ib=t,this.jM.length>0){const i=Je(t),n=1.5*Ge(t)+2*i,s=this.ab();this.QM={above:Qe(n,s.aboveBar,s.inBar),below:Qe(n,s.belowBar,s.inBar)}}else this.QM=null;this.JM=!1}return this.QM}ab(){return null===this.tb&&(this.tb=this.jM.reduce(((t,i)=>(t[i.position]||(t[i.position]=!0),t)),{inBar:!1,aboveBar:!1,belowBar:!1,atPriceTop:!1,atPriceBottom:!1,atPriceMiddle:!1})),this.tb}sb(){if(!this.nb||!this._p||!this.ge)return;const t=this._p.timeScale(),i=this.ge?.data();if(null==t.getVisibleLogicalRange()||!this.ge||0===i.length)return void(this.XM=[]);const n=t.timeToIndex(a(i[0].time),!0);this.XM=this.jM.map(((i,s)=>{const e=t.timeToIndex(i.time,!0),r=e<n?1:-1,h=a(this.ge).dataByIndex(e,r),l={time:t.timeToIndex(a(h).time,!1),position:i.position,shape:i.shape,color:i.color,id:i.id,KM:s,text:i.text,size:i.size,price:i.price,ew:i.time};if("atPriceTop"===i.position||"atPriceBottom"===i.position||"atPriceMiddle"===i.position){if(void 0===i.price)throw new Error(`Price is required for position ${i.position}`);return{...l,position:i.position,price:i.price}}return{...l,position:i.position,price:i.price}})),this.nb=!1}rb(t){this.nh&&(this.sb(),this.nh.ZM(this.XM),this.nh.Pt(t))}rg(t){this.nb=!0,this.SM()}}class or extends Ze{constructor(t,i,n){super(t,i),n&&this.setMarkers(n)}setMarkers(t){this.ah.ZM(t)}markers(){return this.ah.eb()}}function _r(t,i){const n=new or(t,new lr);return i&&n.setMarkers(i),n}class ur{constructor(t){this.jM=new Map,this.lb=t}ob(t,i,n){if(this._b(i),void 0!==n){const s=window.setTimeout((()=>{this.jM.delete(i),this.ub()}),n),e={...t,cb:s,fb:Date.now()+n};this.jM.set(i,e)}else this.jM.set(i,{...t,cb:void 0,fb:void 0});this.ub()}_b(t){const i=this.jM.get(t);i&&void 0!==i.cb&&window.clearTimeout(i.cb),this.jM.delete(t),this.ub()}pb(){for(const[t]of this.jM)this._b(t)}mb(){const t=Date.now(),i=[];for(const[n,s]of this.jM)!s.fb||s.fb>t?i.push({time:s.time,sign:s.sign,value:s.value}):this._b(n);return i}wb(t){this.lb=t}ub(){this.lb&&this.lb()}}const cr={positiveColor:"#22AB94",negativeColor:"#F7525F",updateVisibilityDuration:5e3};class dr{constructor(t,i,n,s){this.qt=t,this.gb=i,this.Mb=n,this.bb=s}draw(t){t.useBitmapCoordinateSpace((t=>{const i=t.context,n=Math.max(1,Math.floor(t.horizontalPixelRatio))%2/2,s=4*t.verticalPixelRatio+n;this.qt.forEach((e=>{const r=Math.round(e._t*t.horizontalPixelRatio)+n;i.beginPath();const h=this.xb(e.Sb);i.fillStyle=h,i.arc(r,e.ut*t.verticalPixelRatio,s,0,2*Math.PI,!1),i.fill(),e.Sb&&(i.strokeStyle=h,i.lineWidth=Math.floor(2*t.horizontalPixelRatio),i.beginPath(),i.moveTo((e._t-4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.Sb)*t.verticalPixelRatio),i.lineTo(e._t*t.horizontalPixelRatio+n,(e.ut-7*e.Sb-7*e.Sb*.5)*t.verticalPixelRatio),i.lineTo((e._t+4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.Sb)*t.verticalPixelRatio),i.stroke())}))}))}xb(t){return 0===t?this.gb:t>0?this.bb:this.Mb}}class fr{constructor(t,i,n){this.qt=[],this.ge=t,this.uh=i,this.Sn=n}Pt(t){this.qt=t.map((t=>{const i=this.ge.priceToCoordinate(t.value);if(null===i)return null;return{_t:a(this.uh.timeToCoordinate(t.time)),ut:i,Sb:t.sign}})).filter(v)}renderer(){const t=function(t,i){return function(t,i){return"Area"===i}(0,i)?t.lineColor:t.color}(this.ge.options(),this.ge.seriesType());return new dr(this.qt,t,this.Sn.negativeColor,this.Sn.positiveColor)}}function pr(t,i){return"Line"===i||"Area"===i}class vr{constructor(t){this._p=void 0,this.ge=void 0,this.xM=[],this.qo=null,this.Cb=new Map,this.yb=new ur((()=>this.SM())),this.Sn={...cr,...t}}hr(t){this.Sn={...this.Sn,...t},this.SM()}ZM(t){this.yb.pb();const i=this.qo;i&&t.forEach((t=>{this.yb.ob(t,i.key(t.time))}))}eb(){return this.yb.mb()}SM(){this.LM?.()}attached(t){const{chart:i,series:n,requestUpdate:s,horzScaleBehavior:e}=t;this._p=i,this.ge=n,this.qo=e;const r=this.ge.seriesType();if("Area"!==r&&"Line"!==r)throw new Error("UpDownMarkersPrimitive is only supported for Area and Line series types");this.xM=[new fr(this.ge,this._p.timeScale(),this.Sn)],this.LM=s,this.SM()}detached(){this._p=void 0,this.ge=void 0,this.LM=void 0}Cp(){return h(this._p)}wo(){return h(this.ge)}updateAllViews(){this.xM.forEach((t=>t.Pt(this.eb())))}paneViews(){return this.xM}ht(t){if(!this.ge)throw new Error("Primitive not attached to series");const i=this.ge.seriesType();this.Cb.clear();const n=this.qo;n&&t.forEach((t=>{jn(t)&&pr(0,i)&&this.Cb.set(n.key(t.time),t.value)})),h(this.ge).setData(t)}Pt(t,i){if(!this.ge||!this.qo)throw new Error("Primitive not attached to series");const n=this.ge.seriesType(),s=this.qo.key(t.time);if($n(t)&&this.Cb.delete(s),jn(t)&&pr(0,n)){const i=this.Cb.get(s);i&&this.yb.ob({time:t.time,value:t.value,sign:mr(t.value,i)},s,this.Sn.updateVisibilityDuration)}h(this.ge).update(t,i)}Pb(){this.yb.pb()}}function mr(t,i){return t===i?0:t-i>0?1:-1}class wr extends Ze{setData(t){return this.ah.ht(t)}update(t,i){return this.ah.Pt(t,i)}markers(){return this.ah.eb()}setMarkers(t){return this.ah.ZM(t)}clearMarkers(){return this.ah.Pb()}}function gr(t,i={}){return new wr(t,new vr(i))}const Mr={...t,color:"#2196f3"};function br(){return"5.0.5"}export{ge as AreaSeries,Se as BarSeries,ve as BaselineSeries,Pe as CandlestickSeries,Vi as ColorType,$ as CrosshairMode,Re as HistogramSeries,Ri as LastPriceAnimationMode,te as LineSeries,n as LineStyle,i as LineType,St as MismatchDirection,Di as PriceLineSource,ui as PriceScaleMode,Ei as TickMarkType,Ti as TrackingModeExitMode,Hs as createChart,Fs as createChartEx,Ye as createImageWatermark,oe as createOptionsChart,_r as createSeriesMarkers,We as createTextWatermark,gr as createUpDownMarkers,he as createYieldCurveChart,Mr as customSeriesDefaultOptions,Us as defaultHorzScaleBehavior,Bi as isBusinessDay,Ai as isUTCTimestamp,br as version};