lightweight-charts
Version:
Performant financial charts built with HTML5 canvas
8 lines • 140 kB
JavaScript
/*!
* @license
* TradingView Lightweight Charts™ v4.0.1
* Copyright (c) 2023 TradingView, Inc.
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/
"use strict";var t,i,s=require("fancy-canvas");function n(t,i){const s={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function l(t){if(null===t)throw new Error("Value is null");return t}function a(t){return l(h(t))}exports.LineType=void 0,(t=exports.LineType||(exports.LineType={}))[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved",exports.LineStyle=void 0,(i=exports.LineStyle||(exports.LineStyle={}))[i.Solid=0]="Solid",i[i.Dotted=1]="Dotted",i[i.Dashed=2]="Dashed",i[i.LargeDashed=3]="LargeDashed",i[i.SparseDotted=4]="SparseDotted";const o={khaki:"#f0e68c",azure:"#f0ffff",aliceblue:"#f0f8ff",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",gray:"#808080",green:"#008000",honeydew:"#f0fff0",floralwhite:"#fffaf0",lightblue:"#add8e6",lightcoral:"#f08080",lemonchiffon:"#fffacd",hotpink:"#ff69b4",lightyellow:"#ffffe0",greenyellow:"#adff2f",lightgoldenrodyellow:"#fafad2",limegreen:"#32cd32",linen:"#faf0e6",lightcyan:"#e0ffff",magenta:"#f0f",maroon:"#800000",olive:"#808000",orange:"#ffa500",oldlace:"#fdf5e6",mediumblue:"#0000cd",transparent:"#0000",lime:"#0f0",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",midnightblue:"#191970",orchid:"#da70d6",mediumorchid:"#ba55d3",mediumturquoise:"#48d1cc",orangered:"#ff4500",royalblue:"#4169e1",powderblue:"#b0e0e6",red:"#f00",coral:"#ff7f50",turquoise:"#40e0d0",white:"#fff",whitesmoke:"#f5f5f5",wheat:"#f5deb3",teal:"#008080",steelblue:"#4682b4",bisque:"#ffe4c4",aquamarine:"#7fffd4",aqua:"#0ff",sienna:"#a0522d",silver:"#c0c0c0",springgreen:"#00ff7f",antiquewhite:"#faebd7",burlywood:"#deb887",brown:"#a52a2a",beige:"#f5f5dc",chocolate:"#d2691e",chartreuse:"#7fff00",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cadetblue:"#5f9ea0",tomato:"#ff6347",fuchsia:"#f0f",blue:"#00f",salmon:"#fa8072",blanchedalmond:"#ffebcd",slateblue:"#6a5acd",slategray:"#708090",thistle:"#d8bfd8",tan:"#d2b48c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",blueviolet:"#8a2be2",black:"#000",darkmagenta:"#8b008b",darkslateblue:"#483d8b",darkkhaki:"#bdb76b",darkorchid:"#9932cc",darkorange:"#ff8c00",darkgreen:"#006400",darkred:"#8b0000",dodgerblue:"#1e90ff",darkslategray:"#2f4f4f",dimgray:"#696969",deepskyblue:"#00bfff",firebrick:"#b22222",forestgreen:"#228b22",indigo:"#4b0082",ivory:"#fffff0",lavenderblush:"#fff0f5",feldspar:"#d19275",indianred:"#cd5c5c",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightskyblue:"#87cefa",lightslategray:"#789",lightslateblue:"#8470ff",snow:"#fffafa",lightseagreen:"#20b2aa",lightsalmon:"#ffa07a",darksalmon:"#e9967a",darkviolet:"#9400d3",mediumpurple:"#9370d8",mediumaquamarine:"#66cdaa",skyblue:"#87ceeb",lavender:"#e6e6fa",lightsteelblue:"#b0c4de",mediumvioletred:"#c71585",mintcream:"#f5fffa",navajowhite:"#ffdead",navy:"#000080",olivedrab:"#6b8e23",palevioletred:"#d87093",violetred:"#d02090",yellow:"#ff0",yellowgreen:"#9acd32",lawngreen:"#7cfc00",pink:"#ffc0cb",paleturquoise:"#afeeee",palegoldenrod:"#eee8aa",darkolivegreen:"#556b2f",darkseagreen:"#8fbc8f",darkturquoise:"#00ced1",peachpuff:"#ffdab9",deeppink:"#ff1493",violet:"#ee82ee",palegreen:"#98fb98",mediumseagreen:"#3cb371",peru:"#cd853f",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",purple:"#800080",seagreen:"#2e8b57",seashell:"#fff5ee",papayawhip:"#ffefd5",mediumslateblue:"#7b68ee",plum:"#dda0dd",mediumspringgreen:"#00fa9a"};function _(t){return t<0?0:t>255?255:Math.round(t)||0}function u(t){return t<=0||t>0?t<0?0:t>1?1:Math.round(1e4*t)/1e4:0}const c=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,d=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,f=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,p=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/;function v(t){(t=t.toLowerCase())in o&&(t=o[t]);{const i=p.exec(t)||f.exec(t);if(i)return[_(parseInt(i[1],10)),_(parseInt(i[2],10)),_(parseInt(i[3],10)),u(i.length<5?1:parseFloat(i[4]))]}{const i=d.exec(t);if(i)return[_(parseInt(i[1],16)),_(parseInt(i[2],16)),_(parseInt(i[3],16)),1]}{const i=c.exec(t);if(i)return[_(17*parseInt(i[1],16)),_(17*parseInt(i[2],16)),_(17*parseInt(i[3],16)),1]}throw new Error(`Cannot parse color: ${t}`)}function m(t){const i=v(t);return{t:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,i:(s=i,.199*s[0]+.687*s[1]+.114*s[2]>160?"black":"white")};var s}class b{constructor(){this.h=[]}l(t,i,s){const n={o:t,_:i,u:!0===s};this.h.push(n)}p(t){const i=this.h.findIndex((i=>t===i.o));i>-1&&this.h.splice(i,1)}v(t){this.h=this.h.filter((i=>i._!==t))}m(t,i,s){const n=[...this.h];this.h=this.h.filter((t=>!t.u)),n.forEach((n=>n.o(t,i,s)))}g(){return this.h.length>0}M(){this.h=[]}}function g(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&("object"!=typeof s[i]||void 0===t[i]?t[i]=s[i]:g(t[i],s[i]));return t}function w(t){return"number"==typeof t&&isFinite(t)}function M(t){return"number"==typeof t&&t%1==0}function x(t){return"string"==typeof t}function S(t){return"boolean"==typeof t}function y(t){const i=t;if(!i||"object"!=typeof i)return i;let s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?y(e):e);return s}function k(t){return null!==t}function C(t){return null===t?void 0:t}const T="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function P(t,i,s){return void 0===i&&(i=T),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class R{constructor(t){this.S={k:1,C:5,T:NaN,P:"",R:"",D:"",B:"",A:0,O:0,L:0,I:0,V:0},this.N=t}F(){const t=this.S,i=this.W(),s=this.j();return t.T===i&&t.R===s||(t.T=i,t.R=s,t.P=P(i,s),t.I=2.5/12*i,t.A=t.I,t.O=i/12*t.C,t.L=i/12*t.C,t.V=0),t.D=this.$(),t.B=this.H(),this.S}$(){return this.N.F().layout.textColor}H(){return this.N.U()}W(){return this.N.F().layout.fontSize}j(){return this.N.F().layout.fontFamily}}class D{constructor(){this.q=[]}Y(t){this.q=t}X(t,i,s){this.q.forEach((n=>{n.X(t,i,s)}))}}class B{X(t,i,s){t.useMediaCoordinateSpace((t=>this.Z(t,i,s)))}K(t,i,s){t.useMediaCoordinateSpace((t=>this.G(t,i,s)))}G(t,i,s){}}class A extends B{constructor(){super(...arguments),this.J=null}tt(t){this.J=t}Z({context:t}){if(null===this.J||null===this.J.it)return;const i=this.J.it,s=this.J,n=n=>{t.beginPath();for(let e=i.to-1;e>=i.from;--e){const i=s.st[e];t.moveTo(i.nt,i.et),t.arc(i.nt,i.et,n,0,2*Math.PI)}t.fill()};s.rt>0&&(t.fillStyle=s.ht,n(s.lt+s.rt)),t.fillStyle=s.ot,n(s.lt)}}function O(){return{st:[{nt:0,et:0,_t:0,ut:0}],ot:"",ht:"",lt:0,rt:0,it:null}}const L={from:0,to:1};class I{constructor(t,i){this.ct=new D,this.dt=[],this.ft=[],this.vt=!0,this.N=t,this.bt=i,this.ct.Y(this.dt)}gt(t){const i=this.N.wt();i.length!==this.dt.length&&(this.ft=i.map(O),this.dt=this.ft.map((t=>{const i=new A;return i.tt(t),i})),this.ct.Y(this.dt)),this.vt=!0}Mt(){return this.vt&&(this.xt(),this.vt=!1),this.ct}xt(){const t=this.N.wt(),i=this.bt.St(),s=this.N.yt();t.forEach(((t,n)=>{var e;const r=this.ft[n],h=t.kt(i);if(null===h||!t.Ct())return void(r.it=null);const a=l(t.Tt());r.ot=h.Pt,r.lt=h.lt,r.rt=h.Rt,r.st[0].ut=h.ut,r.st[0].et=t.Bt().Dt(h.ut,a.At),r.ht=null!==(e=h.Ot)&&void 0!==e?e:this.N.Lt(r.st[0].et/t.Bt().It()),r.st[0]._t=i,r.st[0].nt=s.Et(i),r.it=L}))}}class E{X(t,i,s){t.useBitmapCoordinateSpace((t=>this.Z(t,i,s)))}}class V extends E{constructor(t){super(),this.Vt=t}Z({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Vt)return;const h=this.Vt.zt.Ct,l=this.Vt.Nt.Ct;if(!h&&!l)return;const a=Math.round(this.Vt.nt*s),o=Math.round(this.Vt.et*r);t.lineCap="butt",h&&a>=0&&(t.lineWidth=Math.floor(this.Vt.zt.rt*s),t.strokeStyle=this.Vt.zt.D,t.fillStyle=this.Vt.zt.D,n(t,this.Vt.zt.Ft),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,a,0,i.height)),l&&o>=0&&(t.lineWidth=Math.floor(this.Vt.Nt.rt*r),t.strokeStyle=this.Vt.Nt.D,t.fillStyle=this.Vt.Nt.D,n(t,this.Vt.Nt.Ft),e(t,o,0,i.width))}}class z{constructor(t){this.vt=!0,this.Wt={zt:{rt:1,Ft:0,D:"",Ct:!1},Nt:{rt:1,Ft:0,D:"",Ct:!1},nt:0,et:0},this.jt=new V(this.Wt),this.$t=t}gt(){this.vt=!0}Mt(){return this.vt&&(this.xt(),this.vt=!1),this.jt}xt(){const t=this.$t.Ct(),i=l(this.$t.Ht()),s=i.Ut().F().crosshair,n=this.Wt;n.Nt.Ct=t&&this.$t.qt(i),n.zt.Ct=t&&this.$t.Yt(),n.Nt.rt=s.horzLine.width,n.Nt.Ft=s.horzLine.style,n.Nt.D=s.horzLine.color,n.zt.rt=s.vertLine.width,n.zt.Ft=s.vertLine.style,n.zt.D=s.vertLine.color,n.nt=this.$t.Xt(),n.et=this.$t.Zt()}}function N(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function F(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function W(t,i){return Array.isArray(t)?t.map((t=>0===t?t:t+i)):t+i}function j(t,i,s,n,e,r){let h,l,a,o;if(Array.isArray(r))if(2===r.length){const t=Math.max(0,r[0]),i=Math.max(0,r[1]);h=t,l=t,a=i,o=i}else{if(4!==r.length)throw new Error("Wrong border radius - it should be like css border radius");h=Math.max(0,r[0]),l=Math.max(0,r[1]),a=Math.max(0,r[2]),o=Math.max(0,r[3])}else{const t=Math.max(0,r);h=t,l=t,a=t,o=t}t.beginPath(),t.moveTo(i+h,s),t.lineTo(i+n-l,s),0!==l&&t.arcTo(i+n,s,i+n,s+l,l),t.lineTo(i+n,s+e-a),0!==a&&t.arcTo(i+n,s+e,i+n-a,s+e,a),t.lineTo(i+o,s+e),0!==o&&t.arcTo(i,s+e,i,s+e-o,o),t.lineTo(i,s+h),0!==h&&t.arcTo(i,s,i+h,s,h)}function $(t,i,s,n,e,r,h=0,l=0,a=""){if(t.save(),!h||!a||a===r)return j(t,i,s,n,e,l),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;if("transparent"!==r){j(t,i+h,s+h,n-2*h,e-2*h,W(l,-h)),t.fillStyle=r,t.fill()}if("transparent"!==a){j(t,i+o,s+o,n-h,e-h,W(l,-o)),t.lineWidth=h,t.strokeStyle=a,t.closePath(),t.stroke()}t.restore()}function H(t,i,s,n,e,r,h){t.save(),t.globalCompositeOperation="copy";const l=t.createLinearGradient(0,0,0,e);l.addColorStop(0,r),l.addColorStop(1,h),t.fillStyle=l,t.fillRect(i,s,n,e),t.restore()}class U{constructor(t,i){this.tt(t,i)}tt(t,i){this.Vt=t,this.Kt=i}It(t,i){return this.Vt.Ct?t.T+t.I+t.A:0}X(t,i,s,n){if(!this.Vt.Ct||0===this.Vt.Gt.length)return;const e=this.Vt.D,r=this.Kt.t,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.P;const l=this.Jt(t,i,s,n),a=l.Qt,o=(t,i)=>{l.ti?$(h,a.ii,a.si,a.ni,a.ei,t,a.ri,[a.lt,0,0,a.lt],i):$(h,a.hi,a.si,a.ni,a.ei,t,a.ri,[0,a.lt,a.lt,0],i)};return o(r,"transparent"),this.Vt.li&&(h.fillStyle=e,h.fillRect(a.hi,a.ai,a.oi-a.hi,a._i)),o("transparent",r),this.Vt.ui&&(h.fillStyle=i.B,h.fillRect(l.ti?a.ci-a.ri:0,a.si,a.ri,a.di-a.si)),l}));t.useMediaCoordinateSpace((({context:t})=>{const s=h.fi;t.font=i.P,t.textAlign=h.ti?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Vt.Gt,s.pi,(s.si+s.di)/2+s.vi)}))}Jt(t,i,s,n){var e;const{context:r,bitmapSize:h,mediaSize:l,horizontalPixelRatio:a,verticalPixelRatio:o}=t,_=this.Vt.li||!this.Vt.mi?i.C:0,u=this.Vt.bi?i.k:0,c=i.I+this.Kt.gi,d=i.A+this.Kt.wi,f=i.O,p=i.L,v=this.Vt.Gt,m=i.T,b=s.Mi(r,v),g=Math.ceil(s.xi(r,v)),w=m+c+d,M=i.k+f+p+g+_,x=Math.max(1,Math.floor(o));let S=Math.round(w*o);S%2!=x%2&&(S+=1);const y=u>0?Math.max(1,Math.floor(u*a)):0,k=Math.round(M*a),C=Math.round(_*a),T=null!==(e=this.Kt.Si)&&void 0!==e?e:this.Kt.yi,P=Math.round(T*o)-Math.floor(.5*o),R=Math.floor(P+x/2-S/2),D=R+S,B="right"===n,A=B?l.width-u:u,O=B?h.width-y:y;let L,I,E;return B?(L=O-k,I=O-C,E=A-_-f-u):(L=O+k,I=O+C,E=A+_+f),{ti:B,Qt:{si:R,ai:P,di:D,ni:k,ei:S,lt:2*a,ri:y,ii:L,hi:O,oi:I,_i:x,ci:h.width},fi:{si:R/o,di:D/o,pi:E,vi:b}}}}class q{constructor(t){this.ki={yi:0,t:"#000",wi:0,gi:0},this.Ci={Gt:"",Ct:!1,li:!0,mi:!1,Ot:"",D:"#FFF",ui:!1,bi:!1},this.Ti={Gt:"",Ct:!1,li:!1,mi:!0,Ot:"",D:"#FFF",ui:!0,bi:!0},this.vt=!0,this.Pi=new(t||U)(this.Ci,this.ki),this.Ri=new(t||U)(this.Ti,this.ki)}Gt(){return this.Di(),this.Ci.Gt}yi(){return this.Di(),this.ki.yi}gt(){this.vt=!0}It(t,i=!1){return Math.max(this.Pi.It(t,i),this.Ri.It(t,i))}Bi(){return this.ki.Si||0}Ai(t){this.ki.Si=t}Oi(){return this.Di(),this.Ci.Ct||this.Ti.Ct}Li(){return this.Di(),this.Ci.Ct}Mt(t){return this.Di(),this.Ci.li=this.Ci.li&&t.F().ticksVisible,this.Ti.li=this.Ti.li&&t.F().ticksVisible,this.Pi.tt(this.Ci,this.ki),this.Ri.tt(this.Ti,this.ki),this.Pi}Ii(){return this.Di(),this.Pi.tt(this.Ci,this.ki),this.Ri.tt(this.Ti,this.ki),this.Ri}Di(){this.vt&&(this.Ci.li=!0,this.Ti.li=!1,this.Ei(this.Ci,this.Ti,this.ki))}}class Y extends q{constructor(t,i,s){super(),this.$t=t,this.Vi=i,this.zi=s}Ei(t,i,s){t.Ct=!1;const n=this.$t.F().horzLine;if(!n.labelVisible)return;const e=this.Vi.Tt();if(!this.$t.Ct()||this.Vi.Ni()||null===e)return;const r=m(n.labelBackgroundColor);s.t=r.t,t.D=r.i;const h=2/12*this.Vi.T();s.gi=h,s.wi=h;const l=this.zi(this.Vi);s.yi=l.yi,t.Gt=this.Vi.Fi(l.ut,e),t.Ct=!0}}const X=/[1-9]/g;class Z{constructor(){this.Vt=null}tt(t){this.Vt=t}X(t,i){if(null===this.Vt||!1===this.Vt.Ct||0===this.Vt.Gt.length)return;const s=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.P,Math.round(i.Wi.xi(t,l(this.Vt).Gt,X)))));if(s<=0)return;const n=i.ji,e=s+2*n,r=e/2,h=this.Vt.$i;let a=this.Vt.yi,o=Math.floor(a-r)+.5;o<0?(a+=Math.abs(0-o),o=Math.floor(a-r)+.5):o+e>h&&(a-=Math.abs(h-(o+e)),o=Math.floor(a-r)+.5);const _=o+e,u=Math.ceil(0+i.k+i.C+i.I+i.T+i.A);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=l(this.Vt);t.fillStyle=e.t;const r=Math.round(o*s),h=Math.round(0*n),a=Math.round(_*s),c=Math.round(u*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(a-d,c),t.arcTo(a,c,a,c-d,d),t.lineTo(a,h),t.fill(),e.li){const r=Math.round(e.yi*s),l=h,a=Math.round((l+i.C)*n);t.fillStyle=e.D;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,l,o,a-l)}})),t.useMediaCoordinateSpace((({context:t})=>{const s=l(this.Vt),e=0+i.k+i.C+i.I+i.T/2;t.font=i.P,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.D;const r=i.Wi.Mi(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.Gt,0,0)}))}}class K{constructor(t,i,s){this.vt=!0,this.jt=new Z,this.Wt={Ct:!1,t:"#4c525e",D:"white",Gt:"",$i:0,yi:NaN,li:!0},this.bt=t,this.Hi=i,this.zi=s}gt(){this.vt=!0}Mt(){return this.vt&&(this.xt(),this.vt=!1),this.jt.tt(this.Wt),this.jt}xt(){const t=this.Wt;t.Ct=!1;const i=this.bt.F().vertLine;if(!i.labelVisible)return;const s=this.Hi.yt();if(s.Ni())return;t.$i=s.$i();const n=this.zi();if(null===n)return;t.yi=n.yi;const e=s.Ui(this.bt.St());t.Gt=s.qi(l(e)),t.Ct=!0;const r=m(i.labelBackgroundColor);t.t=r.t,t.D=r.i,t.li=s.F().ticksVisible}}class G{constructor(){this.Yi=null,this.Xi=0}Zi(){return this.Xi}Ki(t){this.Xi=t}Bt(){return this.Yi}Gi(t){this.Yi=t}Ji(t){return[]}Qi(){return[]}Ct(){return!0}}var J;exports.CrosshairMode=void 0,(J=exports.CrosshairMode||(exports.CrosshairMode={}))[J.Normal=0]="Normal",J[J.Magnet=1]="Magnet";class Q extends G{constructor(t,i){super(),this.ts=null,this.ss=NaN,this.ns=0,this.es=!0,this.rs=new Map,this.hs=!1,this.ls=NaN,this.os=NaN,this._s=NaN,this.us=NaN,this.Hi=t,this.cs=i,this.ds=new I(t,this);this.fs=((t,i)=>s=>{const n=i(),e=t();if(s===l(this.ts).ps())return{ut:e,yi:n};{const t=l(s.Tt());return{ut:s.vs(n,t),yi:n}}})((()=>this.ss),(()=>this.os));const s=((t,i)=>()=>{const s=this.Hi.yt().bs(t()),n=i();return s&&Number.isFinite(n)?{_t:s,yi:n}:null})((()=>this.ns),(()=>this.Xt()));this.gs=new K(this,t,s),this.ws=new z(this)}F(){return this.cs}Ms(t,i){this._s=t,this.us=i}xs(){this._s=NaN,this.us=NaN}Ss(){return this._s}ys(){return this.us}ks(t,i,s){this.hs||(this.hs=!0),this.es=!0,this.Cs(t,i,s)}St(){return this.ns}Xt(){return this.ls}Zt(){return this.os}Ct(){return this.es}Ts(){this.es=!1,this.Ps(),this.ss=NaN,this.ls=NaN,this.os=NaN,this.ts=null,this.xs()}Rs(t){return null!==this.ts?[this.ws,this.ds]:[]}qt(t){return t===this.ts&&this.cs.horzLine.visible}Yt(){return this.cs.vertLine.visible}Ds(t,i){this.es&&this.ts===t||this.rs.clear();const s=[];return this.ts===t&&s.push(this.Bs(this.rs,i,this.fs)),s}Qi(){return this.es?[this.gs]:[]}Ht(){return this.ts}As(){this.ws.gt(),this.rs.forEach((t=>t.gt())),this.gs.gt(),this.ds.gt()}Os(t){return t&&!t.ps().Ni()?t.ps():null}Cs(t,i,s){this.Ls(t,i,s)&&this.As()}Ls(t,i,s){const n=this.ls,e=this.os,r=this.ss,h=this.ns,l=this.ts,a=this.Os(s);this.ns=t,this.ls=isNaN(t)?NaN:this.Hi.yt().Et(t),this.ts=s;const o=null!==a?a.Tt():null;return null!==a&&null!==o?(this.ss=i,this.os=a.Dt(i,o)):(this.ss=NaN,this.os=NaN),n!==this.ls||e!==this.os||h!==this.ns||r!==this.ss||l!==this.ts}Ps(){const t=this.Hi.wt().map((t=>t.Es().Is())).filter(k),i=0===t.length?null:Math.max(...t);this.ns=null!==i?i:NaN}Bs(t,i,s){let n=t.get(i);return void 0===n&&(n=new Y(this,i,s),t.set(i,n)),n}}function tt(t){return"left"===t||"right"===t}class it{constructor(t){this.Vs=new Map,this.zs=[],this.Ns=t}Fs(t,i){const s=function(t,i){return void 0===t?i:{Ws:Math.max(t.Ws,i.Ws),js:t.js||i.js}}(this.Vs.get(t),i);this.Vs.set(t,s)}$s(){return this.Ns}Hs(t){const i=this.Vs.get(t);return void 0===i?{Ws:this.Ns}:{Ws:Math.max(this.Ns,i.Ws),js:i.js}}Us(){this.qs(),this.zs=[{Ys:0}]}Xs(t){this.qs(),this.zs=[{Ys:1,At:t}]}Zs(t){this.Ks(),this.zs.push({Ys:5,At:t})}qs(){this.Ks(),this.zs.push({Ys:6})}Gs(){this.qs(),this.zs=[{Ys:4}]}Js(t){this.qs(),this.zs.push({Ys:2,At:t})}Qs(t){this.qs(),this.zs.push({Ys:3,At:t})}tn(){return this.zs}sn(t){for(const i of t.zs)this.nn(i);this.Ns=Math.max(this.Ns,t.Ns),t.Vs.forEach(((t,i)=>{this.Fs(i,t)}))}static en(){return new it(2)}static rn(){return new it(3)}nn(t){switch(t.Ys){case 0:this.Us();break;case 1:this.Xs(t.At);break;case 2:this.Js(t.At);break;case 3:this.Qs(t.At);break;case 4:this.Gs();break;case 5:this.Zs(t.At);break;case 6:this.Ks()}}Ks(){const t=this.zs.findIndex((t=>5===t.Ys));-1!==t&&this.zs.splice(t,1)}}const st=".";function nt(t,i){if(!w(t))return"n/a";if(!M(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 et{constructor(t,i){if(i||(i=1),w(t)&&M(t)||(t=100),t<0)throw new TypeError("invalid base");this.Vi=t,this.hn=i,this.ln()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.an(t)}ln(){if(this.on=0,this.Vi>0&&this.hn>0){let t=this.Vi;for(;t>1;)t/=10,this.on++}}an(t){const i=this.Vi/this.hn;let s=Math.floor(t),n="";const e=void 0!==this.on?this.on:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.on);r>=i&&(r-=i,s+=1),n=st+nt(+r.toFixed(this.on)*this.hn,e)}else s=Math.round(s*i)/i,e>0&&(n=st+nt(0,e));return s.toFixed(0)+n}}class rt extends et{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class ht{constructor(t){this._n=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.un(t):t<999995?i+this.un(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.un(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.un(t/1e9)+"B")}un(t){let i;const s=Math.pow(10,this._n);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this._n).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}function lt(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const l=t.context,a=i[n.from];let o=r(t,a),_=a;if(n.to-n.from<2){const t=e/2;l.beginPath();const i={nt:a.nt-t,et:a.et},s={nt:a.nt+t,et:a.et};return l.moveTo(i.nt,i.et),l.lineTo(s.nt,s.et),void h(l,o,i,s)}const u=(t,i)=>{h(l,o,_,i),l.beginPath(),o=t,_=i};let c=_;l.beginPath(),l.moveTo(a.nt,a.et);for(let e=n.from+1;e<n.to;++e){c=i[e];const n=r(t,c);switch(s){case 0:l.lineTo(c.nt,c.et);break;case 1:l.lineTo(c.nt,i[e-1].et),n!==o&&(u(n,c),l.lineTo(c.nt,i[e-1].et)),l.lineTo(c.nt,c.et);break;case 2:{const[t,s]=ut(i,e-1,e);l.bezierCurveTo(t.nt,t.et,s.nt,s.et,c.nt,c.et);break}}1!==s&&n!==o&&(u(n,c),l.moveTo(c.nt,c.et))}(_!==c||_===c&&1===s)&&h(l,o,_,c)}const at=6;function ot(t,i){return{nt:t.nt-i.nt,et:t.et-i.et}}function _t(t,i){return{nt:t.nt/i,et:t.et/i}}function ut(t,i,s){const n=Math.max(0,i-1),e=Math.min(t.length-1,s+1);var r,h;return[(r=t[i],h=_t(ot(t[s],t[n]),at),{nt:r.nt+h.nt,et:r.et+h.et}),ot(t[s],_t(ot(t[e],t[i]),at))]}function ct(t,i,s,n,e){i.lineTo(e.nt,t),i.lineTo(n.nt,t),i.closePath(),i.fillStyle=s,i.fill()}class dt extends B{constructor(){super(...arguments),this.J=null}tt(t){this.J=t}Z(t){var i;if(null===this.J)return;const{st:s,it:e,cn:r,rt:h,Ft:l,dn:a}=this.J,o=null!==(i=this.J.fn)&&void 0!==i?i:this.J.pn?0:t.mediaSize.height;if(null===e)return;const _=t.context;_.lineCap="butt",_.lineJoin="round",_.lineWidth=h,n(_,l),_.lineWidth=1,lt(t,s,a,e,r,this.vn.bind(this),ct.bind(null,o))}}class ft extends dt{constructor(){super(...arguments),this.mn=null}vn(t,i){const{context:s,mediaSize:n}=t,{bn:e,gn:r}=i,h=n.height;if(null!==this.mn&&this.mn.topColor===e&&this.mn.bottomColor===r&&this.mn.bottom===h)return this.mn.fillStyle;const l=s.createLinearGradient(0,0,0,h);return l.addColorStop(0,e),l.addColorStop(1,r),this.mn={topColor:e,bottomColor:r,fillStyle:l,bottom:h},l}}function pt(t,i){t.strokeStyle=i,t.stroke()}class vt extends B{constructor(){super(...arguments),this.J=null}tt(t){this.J=t}Z(t){if(null===this.J)return;const{st:i,it:s,cn:e,dn:r,rt:h,Ft:l}=this.J;if(null===s)return;const a=t.context;a.lineCap="butt",a.lineWidth=h,n(a,l),a.lineJoin="round",lt(t,i,r,s,e,this.wn.bind(this),pt)}}class mt extends vt{wn(t,i){return i.ot}}function bt(t,i,s,n=0,e=t.length){let r=e-n;for(;0<r;){const e=r>>1,h=n+e;s(t[h],i)?(n=h+1,r-=e+1):r=e}return n}function gt(t,i,s,n=0,e=t.length){let r=e-n;for(;0<r;){const e=r>>1,h=n+e;s(i,t[h])?r=e:(n=h+1,r-=e+1)}return n}function wt(t,i){return t._t<i}function Mt(t,i){return t<i._t}function xt(t,i,s){const n=i.Mn(),e=i.ci(),r=bt(t,n,wt),h=gt(t,e,Mt);if(!s)return{from:r,to:h};let l=r,a=h;return r>0&&r<t.length&&t[r]._t>=n&&(l=r-1),h>0&&h<t.length&&t[h-1]._t<=e&&(a=h+1),{from:l,to:a}}class St{constructor(t,i,s){this.xn=!0,this.Sn=!0,this.yn=!0,this.kn=[],this.Cn=null,this.Tn=t,this.Pn=i,this.Rn=s}gt(t){this.xn=!0,"data"===t&&(this.Sn=!0),"options"===t&&(this.yn=!0)}Mt(){return this.Tn.Ct()?(this.Dn(),null===this.Cn?null:this.Bn):null}An(){this.kn=this.kn.map((t=>Object.assign(Object.assign({},t),this.Tn.Ln().On(t._t))))}In(){this.Cn=null}Dn(){this.Sn&&(this.En(),this.Sn=!1),this.yn&&(this.An(),this.yn=!1),this.xn&&(this.Vn(),this.xn=!1)}Vn(){const t=this.Tn.Bt(),i=this.Pn.yt();if(this.In(),i.Ni()||t.Ni())return;const s=i.zn();if(null===s)return;if(0===this.Tn.Es().Nn())return;const n=this.Tn.Tt();null!==n&&(this.Cn=xt(this.kn,s,this.Rn),this.Fn(t,i,n.At),this.Wn())}}class yt extends St{constructor(t,i){super(t,i,!0)}Fn(t,i,s){i.jn(this.kn,C(this.Cn)),t.$n(this.kn,s,C(this.Cn))}Hn(t,i){return{_t:t,ut:i,nt:NaN,et:NaN}}En(){const t=this.Tn.Ln();this.kn=this.Tn.Es().Un().map((i=>{const s=i.At[3];return this.qn(i.Yn,s,t)}))}}class kt extends yt{constructor(t,i){super(t,i),this.Bn=new D,this.Xn=new ft,this.Zn=new mt,this.Bn.Y([this.Xn,this.Zn])}qn(t,i,s){return Object.assign(Object.assign({},this.Hn(t,i)),s.On(t))}Wn(){const t=this.Tn.F();this.Xn.tt({dn:t.lineType,st:this.kn,Ft:t.lineStyle,rt:t.lineWidth,fn:null,pn:t.invertFilledArea,it:this.Cn,cn:this.Pn.yt().Kn()}),this.Zn.tt({dn:t.lineType,st:this.kn,Ft:t.lineStyle,rt:t.lineWidth,it:this.Cn,cn:this.Pn.yt().Kn()})}}class Ct extends E{constructor(){super(...arguments),this.Vt=null,this.Gn=0,this.Jn=0}tt(t){this.Vt=t}Z({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Vt||0===this.Vt.Es.length||null===this.Vt.it)return;if(this.Gn=this.Qn(i),this.Gn>=2){Math.max(1,Math.floor(i))%2!=this.Gn%2&&this.Gn--}this.Jn=this.Vt.te?Math.min(this.Gn,Math.floor(i)):this.Gn;let n=null;const e=this.Jn<=this.Gn&&this.Vt.Kn>=Math.floor(1.5*i);for(let r=this.Vt.it.from;r<this.Vt.it.to;++r){const h=this.Vt.Es[r];n!==h.ie&&(t.fillStyle=h.ie,n=h.ie);const l=Math.floor(.5*this.Jn),a=Math.round(h.nt*i),o=a-l,_=this.Jn,u=o+_-1,c=Math.min(h.se,h.ne),d=Math.max(h.se,h.ne),f=Math.round(c*s)-l,p=Math.round(d*s)+l,v=Math.max(p-f,this.Jn);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.Gn);if(e){if(this.Vt.ee){const i=a-m;let n=Math.max(f,Math.round(h.re*s)-l),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(i,n,o-i,e-n+1)}const i=a+m;let n=Math.max(f,Math.round(h.he*s)-l),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(u+1,n,i-u,e-n+1)}}}Qn(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(l(this.Vt).Kn,t)))}}class Tt extends St{constructor(t,i){super(t,i,!1)}Fn(t,i,s){i.jn(this.kn,C(this.Cn)),t.le(this.kn,s,C(this.Cn))}ae(t,i,s){return{_t:t,oe:i.At[0],_e:i.At[1],ue:i.At[2],ce:i.At[3],nt:NaN,re:NaN,se:NaN,ne:NaN,he:NaN}}En(){const t=this.Tn.Ln();this.kn=this.Tn.Es().Un().map((i=>this.qn(i.Yn,i,t)))}}class Pt extends Tt{constructor(){super(...arguments),this.Bn=new Ct}qn(t,i,s){return Object.assign(Object.assign({},this.ae(t,i,s)),s.On(t))}Wn(){const t=this.Tn.F();this.Bn.tt({Es:this.kn,Kn:this.Pn.yt().Kn(),ee:t.openVisible,te:t.thinBars,it:this.Cn})}}function Rt(t,i,s){return Math.min(Math.max(t,i),s)}function Dt(t,i,s){return i-t<=s}function Bt(t){return t<=0?NaN:Math.log(t)/Math.log(10)}function At(t){const i=Math.ceil(t);return i%2==0?i-1:i}class Ot extends dt{constructor(){super(...arguments),this.mn=null}vn(t,i){var s;const{context:n,mediaSize:e}=t,r=this.J,{de:h,fe:l,pe:a,ve:o}=i,_=null!==(s=r.fn)&&void 0!==s?s:e.height,u=e.height;if(null!==this.mn&&this.mn.topFillColor1===h&&this.mn.topFillColor2===l&&this.mn.bottomFillColor1===a&&this.mn.bottomFillColor2===o&&this.mn.baseLevelCoordinate===_&&this.mn.bottom===u)return this.mn.fillStyle;const c=n.createLinearGradient(0,0,0,u),d=Rt(_/u,0,1);return c.addColorStop(0,h),c.addColorStop(d,l),c.addColorStop(d,a),c.addColorStop(1,o),this.mn={topFillColor1:h,topFillColor2:l,bottomFillColor1:a,bottomFillColor2:o,fillStyle:c,baseLevelCoordinate:_,bottom:u},c}}class Lt extends vt{constructor(){super(...arguments),this.me=null}wn(t,i){const{context:s,mediaSize:n}=t,e=this.J,{be:r,ge:h}=i,{fn:l}=e,a=n.height;if(null!==this.me&&this.me.topLineColor===r&&this.me.bottomLineColor===h&&this.me.baseLevelCoordinate===l&&this.me.bottom===a)return this.me.strokeStyle;const o=s.createLinearGradient(0,0,0,a),_=Rt(l/a,0,1);return o.addColorStop(0,r),o.addColorStop(_,r),o.addColorStop(_,h),o.addColorStop(1,h),this.me={topLineColor:r,bottomLineColor:h,strokeStyle:o,baseLevelCoordinate:l,bottom:a},o}}class It extends yt{constructor(t,i){super(t,i),this.Bn=new D,this.we=new Ot,this.Me=new Lt,this.Bn.Y([this.we,this.Me])}qn(t,i,s){return Object.assign(Object.assign({},this.Hn(t,i)),s.On(t))}Wn(){const t=this.Tn.Tt();if(null===t)return;const i=this.Tn.F(),s=this.Tn.Bt().Dt(i.baseValue.price,t.At),n=this.Pn.yt().Kn();this.we.tt({st:this.kn,rt:i.lineWidth,Ft:i.lineStyle,dn:i.lineType,fn:s,pn:!1,it:this.Cn,cn:n}),this.Me.tt({st:this.kn,rt:i.lineWidth,Ft:i.lineStyle,dn:i.lineType,fn:s,it:this.Cn,cn:n})}}class Et extends E{constructor(){super(...arguments),this.Vt=null,this.Gn=0}tt(t){this.Vt=t}Z(t){if(null===this.Vt||0===this.Vt.Es.length||null===this.Vt.it)return;const{horizontalPixelRatio:i}=t;if(this.Gn=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Vt.Kn,i),this.Gn>=2){Math.floor(i)%2!=this.Gn%2&&this.Gn--}const s=this.Vt.Es;this.Vt.xe&&this.Se(t,s,this.Vt.it),this.Vt.ui&&this.ye(t,s,this.Vt.it);const n=this.ke(i);(!this.Vt.ui||this.Gn>2*n)&&this.Ce(t,s,this.Vt.it)}Se(t,i,s){if(null===this.Vt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",l=Math.min(Math.floor(e),Math.floor(this.Vt.Kn*e));l=Math.max(Math.floor(e),Math.min(l,this.Gn));const a=Math.floor(.5*l);let o=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.Te!==h&&(n.fillStyle=s.Te,h=s.Te);const _=Math.round(Math.min(s.re,s.he)*r),u=Math.round(Math.max(s.re,s.he)*r),c=Math.round(s.se*r),d=Math.round(s.ne*r);let f=Math.round(e*s.nt)-a;const p=f+l-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;n.fillRect(f,c,v,_-c),n.fillRect(f,u+1,v,d-u),o=p}}ke(t){let i=Math.floor(1*t);this.Gn<=2*i&&(i=Math.floor(.5*(this.Gn-1)));const s=Math.max(Math.floor(t),i);return this.Gn<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}ye(t,i,s){if(null===this.Vt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const l=this.ke(e);let a=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.Pe!==h&&(n.fillStyle=s.Pe,h=s.Pe);let o=Math.round(s.nt*e)-Math.floor(.5*this.Gn);const _=o+this.Gn-1,u=Math.round(Math.min(s.re,s.he)*r),c=Math.round(Math.max(s.re,s.he)*r);if(null!==a&&(o=Math.max(a+1,o),o=Math.min(o,_)),this.Vt.Kn*e>2*l)N(n,o,u,_-o+1,c-u+1,l);else{const t=_-o+1;n.fillRect(o,u,t,c-u+1)}a=_}}Ce(t,i,s){if(null===this.Vt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const l=this.ke(e);for(let t=s.from;t<s.to;t++){const s=i[t];let a=Math.round(Math.min(s.re,s.he)*r),o=Math.round(Math.max(s.re,s.he)*r),_=Math.round(s.nt*e)-Math.floor(.5*this.Gn),u=_+this.Gn-1;if(s.ie!==h){const t=s.ie;n.fillStyle=t,h=t}this.Vt.ui&&(_+=l,a+=l,u-=l,o-=l),a>o||n.fillRect(_,a,u-_+1,o-a+1)}}}class Vt extends Tt{constructor(){super(...arguments),this.Bn=new Et}qn(t,i,s){return Object.assign(Object.assign({},this.ae(t,i,s)),s.On(t))}Wn(){const t=this.Tn.F();this.Bn.tt({Es:this.kn,Kn:this.Pn.yt().Kn(),xe:t.wickVisible,ui:t.borderVisible,it:this.Cn})}}class zt extends E{constructor(){super(...arguments),this.Vt=null,this.Re=[]}tt(t){this.Vt=t,this.Re=[]}Z({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Vt||0===this.Vt.st.length||null===this.Vt.it)return;this.Re.length||this.De(i);const n=Math.max(1,Math.floor(s)),e=Math.round(this.Vt.Be*s)-Math.floor(n/2),r=e+n;for(let i=this.Vt.it.from;i<this.Vt.it.to;i++){const h=this.Vt.st[i],l=this.Re[i-this.Vt.it.from],a=Math.round(h.et*s);let o,_;t.fillStyle=h.ie,a<=e?(o=a,_=r):(o=e,_=a-Math.floor(n/2)+n),t.fillRect(l.Mn,o,l.ci-l.Mn+1,_-o)}}De(t){if(null===this.Vt||0===this.Vt.st.length||null===this.Vt.it)return void(this.Re=[]);const i=Math.ceil(this.Vt.Kn*t)<=1?0:Math.max(1,Math.floor(t)),s=Math.round(this.Vt.Kn*t)-i;this.Re=new Array(this.Vt.it.to-this.Vt.it.from);for(let i=this.Vt.it.from;i<this.Vt.it.to;i++){const n=this.Vt.st[i],e=Math.round(n.nt*t);let r,h;if(s%2){const t=(s-1)/2;r=e-t,h=e+t}else{const t=s/2;r=e-t,h=e+t-1}this.Re[i-this.Vt.it.from]={Mn:r,ci:h,Ae:e,Oe:n.nt*t,_t:n._t}}for(let t=this.Vt.it.from+1;t<this.Vt.it.to;t++){const s=this.Re[t-this.Vt.it.from],n=this.Re[t-this.Vt.it.from-1];s._t===n._t+1&&(s.Mn-n.ci!==i+1&&(n.Ae>n.Oe?n.ci=s.Mn-i-1:s.Mn=n.ci+i+1))}let n=Math.ceil(this.Vt.Kn*t);for(let t=this.Vt.it.from;t<this.Vt.it.to;t++){const i=this.Re[t-this.Vt.it.from];i.ci<i.Mn&&(i.ci=i.Mn);const s=i.ci-i.Mn+1;n=Math.min(s,n)}if(i>0&&n<4)for(let t=this.Vt.it.from;t<this.Vt.it.to;t++){const i=this.Re[t-this.Vt.it.from];i.ci-i.Mn+1>n&&(i.Ae>i.Oe?i.ci-=1:i.Mn+=1)}}}class Nt extends yt{constructor(){super(...arguments),this.Bn=new zt}qn(t,i,s){return Object.assign(Object.assign({},this.Hn(t,i)),s.On(t))}Wn(){const t={st:this.kn,Kn:this.Pn.yt().Kn(),it:this.Cn,Be:this.Tn.Bt().Dt(this.Tn.F().base,l(this.Tn.Tt()).At)};this.Bn.tt(t)}}class Ft extends yt{constructor(){super(...arguments),this.Bn=new mt}qn(t,i,s){return Object.assign(Object.assign({},this.Hn(t,i)),s.On(t))}Wn(){const t=this.Tn.F(),i={st:this.kn,Ft:t.lineStyle,dn:t.lineType,rt:t.lineWidth,it:this.Cn,cn:this.Pn.yt().Kn()};this.Bn.tt(i)}}const Wt=/[2-9]/g;class jt{constructor(t=50){this.Le=0,this.Ie=1,this.Ee=1,this.Ve={},this.ze=new Map,this.Ne=t}Fe(){this.Le=0,this.ze.clear(),this.Ie=1,this.Ee=1,this.Ve={}}xi(t,i,s){return this.We(t,i,s).width}Mi(t,i,s){const n=this.We(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}We(t,i,s){const n=s||Wt,e=String(i).replace(n,"0");if(this.ze.has(e))return h(this.ze.get(e)).je;if(this.Le===this.Ne){const t=this.Ve[this.Ee];delete this.Ve[this.Ee],this.ze.delete(t),this.Ee++,this.Le--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.ze.set(e,{je:r,$e:this.Ie}),this.Ve[this.Ie]=e,this.Le++,this.Ie++),r}}class $t{constructor(t){this.He=null,this.S=null,this.Ue="right",this.qe=t}Ye(t,i,s){this.He=t,this.S=i,this.Ue=s}X(t){null!==this.S&&null!==this.He&&this.He.X(t,this.S,this.qe,this.Ue)}}class Ht{constructor(t,i,s){this.Xe=t,this.qe=new jt(50),this.Ze=i,this.N=s,this.W=-1,this.jt=new $t(this.qe)}Mt(){const t=this.N.Ke(this.Ze);if(null===t)return null;const i=t.Ge(this.Ze)?t.Je():this.Ze.Bt();if(null===i)return null;const s=t.Qe(i);if("overlay"===s)return null;const n=this.N.tr();return n.T!==this.W&&(this.W=n.T,this.qe.Fe()),this.jt.Ye(this.Xe.Ii(),n,s),this.jt}}class Ut extends E{constructor(){super(...arguments),this.Vt=null}tt(t){this.Vt=t}ir(t,i){var s;if(!(null===(s=this.Vt)||void 0===s?void 0:s.Ct))return null;const{et:n,rt:e,sr:r}=this.Vt;return i>=n-e-7&&i<=n+e+7?{nr:this.Vt,sr:r}:null}Z({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Vt)return;if(!1===this.Vt.Ct)return;const h=Math.round(this.Vt.et*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Vt.D,t.lineWidth=Math.floor(this.Vt.rt*s),n(t,this.Vt.Ft),e(t,h,0,i.width))}}class qt{constructor(t){this.er={et:0,D:"rgba(0, 0, 0, 0)",rt:1,Ft:0,Ct:!1},this.rr=new Ut,this.vt=!0,this.Tn=t,this.Pn=t.Ut(),this.rr.tt(this.er)}gt(){this.vt=!0}Mt(){return this.Tn.Ct()?(this.vt&&(this.hr(),this.vt=!1),this.rr):null}}class Yt extends qt{constructor(t){super(t)}hr(){this.er.Ct=!1;const t=this.Tn.Bt(),i=t.lr().lr;if(2!==i&&3!==i)return;const s=this.Tn.F();if(!s.baseLineVisible||!this.Tn.Ct())return;const n=this.Tn.Tt();null!==n&&(this.er.Ct=!0,this.er.et=t.Dt(n.At,n.At),this.er.D=s.baseLineColor,this.er.rt=s.baseLineWidth,this.er.Ft=s.baseLineStyle)}}class Xt extends E{constructor(){super(...arguments),this.Vt=null}tt(t){this.Vt=t}ar(){return this.Vt}Z({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Vt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.Oe.x*i)+r,l=n.Oe.y*s;t.fillStyle=n._r,t.beginPath();const a=Math.max(2,1.5*n.ur)*i;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.cr,t.beginPath(),t.arc(h,l,n.lt*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.dr,t.beginPath(),t.arc(h,l,n.lt*i+e/2,0,2*Math.PI,!1),t.stroke()}}const Zt=[{pr:0,vr:.25,mr:4,br:10,gr:.25,wr:0,Mr:.4,Sr:.8},{pr:.25,vr:.525,mr:10,br:14,gr:0,wr:0,Mr:.8,Sr:0},{pr:.525,vr:1,mr:14,br:14,gr:0,wr:0,Mr:0,Sr:0}];function Kt(t,i,s,n){return function(t,i){if("transparent"===t)return t;const s=v(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}(t,s+(n-s)*i)}function Gt(t,i){const s=t%2600/2600;let n;for(const t of Zt)if(s>=t.pr&&s<=t.vr){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.pr)/(n.vr-n.pr);return{cr:Kt(i,e,n.gr,n.wr),dr:Kt(i,e,n.Mr,n.Sr),lt:(h=e,l=n.mr,a=n.br,l+(a-l)*h)};var h,l,a}class Jt{constructor(t){this.jt=new Xt,this.vt=!0,this.yr=!0,this.kr=performance.now(),this.Cr=this.kr-1,this.Tr=t}Pr(){this.Cr=this.kr-1,this.gt()}Rr(){if(this.gt(),2===this.Tr.F().lastPriceAnimation){const t=performance.now(),i=this.Cr-t;if(i>0)return void(i<650&&(this.Cr+=2600));this.kr=t,this.Cr=t+2600}}gt(){this.vt=!0}Dr(){this.yr=!0}Ct(){return 0!==this.Tr.F().lastPriceAnimation}Br(){switch(this.Tr.F().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Cr}}Mt(){return this.vt?(this.xt(),this.vt=!1,this.yr=!1):this.yr&&(this.Ar(),this.yr=!1),this.jt}xt(){this.jt.tt(null);const t=this.Tr.Ut().yt(),i=t.zn(),s=this.Tr.Tt();if(null===i||null===s)return;const n=this.Tr.Or(!0);if(n.Lr||!i.Ir(n.Yn))return;const e={x:t.Et(n.Yn),y:this.Tr.Bt().Dt(n.ut,s.At)},r=n.D,h=this.Tr.F().lineWidth,l=Gt(this.Er(),r);this.jt.tt({_r:r,ur:h,cr:l.cr,dr:l.dr,lt:l.lt,Oe:e})}Ar(){const t=this.jt.ar();if(null!==t){const i=Gt(this.Er(),t._r);t.cr=i.cr,t.dr=i.dr,t.lt=i.lt}}Er(){return this.Br()?performance.now()-this.kr:2599}}function Qt(t,i){return At(Math.min(Math.max(t,12),30)*i)}function ti(t,i){switch(t){case"arrowDown":case"arrowUp":return Qt(i,1);case"circle":return Qt(i,.8);case"square":return Qt(i,.7)}}function ii(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(Qt(t,1))}function si(t){return Math.max(Qt(t,.1),3)}function ni(t,i,s,n,e){const r=ti("square",s),h=(r-1)/2,l=t-h,a=i-h;return n>=l&&n<=l+r&&e>=a&&e<=a+r}function ei(t,i,s,n,e){const r=(ti("arrowUp",e)-1)/2,h=(At(e/2)-1)/2;i.beginPath(),t?(i.moveTo(s-r,n),i.lineTo(s,n-r),i.lineTo(s+r,n),i.lineTo(s+h,n),i.lineTo(s+h,n+r),i.lineTo(s-h,n+r),i.lineTo(s-h,n)):(i.moveTo(s-r,n),i.lineTo(s,n+r),i.lineTo(s+r,n),i.lineTo(s+h,n),i.lineTo(s+h,n-r),i.lineTo(s-h,n-r),i.lineTo(s-h,n)),i.fill()}function ri(t,i,s,n,e,r){return ni(i,s,n,e,r)}class hi extends B{constructor(){super(...arguments),this.Vt=null,this.qe=new jt,this.W=-1,this.j="",this.Vr=""}tt(t){this.Vt=t}Ye(t,i){this.W===t&&this.j===i||(this.W=t,this.j=i,this.Vr=P(t,i),this.qe.Fe())}ir(t,i){if(null===this.Vt||null===this.Vt.it)return null;for(let s=this.Vt.it.from;s<this.Vt.it.to;s++){const n=this.Vt.st[s];if(ai(n,t,i))return{nr:n.zr,sr:n.sr}}return null}Z({context:t},i,s){if(null!==this.Vt&&null!==this.Vt.it){t.textBaseline="middle",t.font=this.Vr;for(let i=this.Vt.it.from;i<this.Vt.it.to;i++){const s=this.Vt.st[i];void 0!==s.Gt&&(s.Gt.$i=this.qe.xi(t,s.Gt.Nr),s.Gt.It=this.W,s.Gt.nt=s.nt-s.Gt.$i/2),li(s,t)}}}}function li(t,i){i.fillStyle=t.D,void 0!==t.Gt&&function(t,i,s,n){t.fillText(i,s,n)}(i,t.Gt.Nr,t.Gt.nt,t.Gt.et),function(t,i){if(0===t.Nn)return;switch(t.Fr){case"arrowDown":return void ei(!1,i,t.nt,t.et,t.Nn);case"arrowUp":return void ei(!0,i,t.nt,t.et,t.Nn);case"circle":return void function(t,i,s,n){const e=(ti("circle",n)-1)/2;t.beginPath(),t.arc(i,s,e,0,2*Math.PI,!1),t.fill()}(i,t.nt,t.et,t.Nn);case"square":return void function(t,i,s,n){const e=ti("square",n),r=(e-1)/2,h=i-r,l=s-r;t.fillRect(h,l,e,e)}(i,t.nt,t.et,t.Nn)}t.Fr}(t,i)}function ai(t,i,s){return!(void 0===t.Gt||!function(t,i,s,n,e,r){const h=n/2;return e>=t&&e<=t+s&&r>=i-h&&r<=i+h}(t.Gt.nt,t.Gt.et,t.Gt.$i,t.Gt.It,i,s))||function(t,i,s){if(0===t.Nn)return!1;switch(t.Fr){case"arrowDown":case"arrowUp":return ri(0,t.nt,t.et,t.Nn,i,s);case"circle":return function(t,i,s,n,e){const r=2+ti("circle",s)/2,h=t-n,l=i-e;return Math.sqrt(h*h+l*l)<=r}(t.nt,t.et,t.Nn,i,s);case"square":return ni(t.nt,t.et,t.Nn,i,s)}}(t,i,s)}function oi(t,i,s,n,e,r,h,l,a){const o=w(s)?s:s.ce,_=w(s)?s:s._e,u=w(s)?s:s.ue,c=w(i.size)?Math.max(i.size,0):1,d=ii(l.Kn())*c,f=d/2;switch(t.Nn=d,i.position){case"inBar":return t.et=h.Dt(o,a),void(void 0!==t.Gt&&(t.Gt.et=t.et+f+r+.6*e));case"aboveBar":return t.et=h.Dt(_,a)-f-n.Wr,void 0!==t.Gt&&(t.Gt.et=t.et-f-.6*e,n.Wr+=1.2*e),void(n.Wr+=d+r);case"belowBar":return t.et=h.Dt(u,a)+f+n.jr,void 0!==t.Gt&&(t.Gt.et=t.et+f+r+.6*e,n.jr+=1.2*e),void(n.jr+=d+r)}i.position}class _i{constructor(t,i){this.vt=!0,this.$r=!0,this.Hr=!0,this.Ur=null,this.jt=new hi,this.Tr=t,this.Hi=i,this.Vt={st:[],it:null}}gt(t){this.vt=!0,this.Hr=!0,"data"===t&&(this.$r=!0)}Mt(t){if(!this.Tr.Ct())return null;this.vt&&this.qr();const i=this.Hi.F().layout;return this.jt.Ye(i.fontSize,i.fontFamily),this.jt.tt(this.Vt),this.jt}Yr(){if(this.Hr){if(this.Tr.Xr().length>0){const t=this.Hi.yt().Kn(),i=si(t),s=1.5*ii(t)+2*i;this.Ur={above:s,below:s}}else this.Ur=null;this.Hr=!1}return this.Ur}qr(){const t=this.Tr.Bt(),i=this.Hi.yt(),s=this.Tr.Xr();this.$r&&(this.Vt.st=s.map((t=>({_t:t.time,nt:0,et:0,Nn:0,Fr:t.shape,D:t.color,zr:t.internalId,sr:t.id,Gt:void 0}))),this.$r=!1);const n=this.Hi.F().layout;this.Vt.it=null;const e=i.zn();if(null===e)return;const r=this.Tr.Tt();if(null===r)return;if(0===this.Vt.st.length)return;let h=NaN;const l=si(i.Kn()),a={Wr:l,jr:l};this.Vt.it=xt(this.Vt.st,e,!0);for(let e=this.Vt.it.from;e<this.Vt.it.to;e++){const o=s[e];o.time!==h&&(a.Wr=l,a.jr=l,h=o.time);const _=this.Vt.st[e];_.nt=i.Et(o.time),void 0!==o.text&&o.text.length>0&&(_.Gt={Nr:o.text,nt:0,et:0,$i:0,It:0});const u=this.Tr.Zr(o.time);null!==u&&oi(_,o,u,a,n.fontSize,l,t,i,r.At)}this.vt=!1}}class ui extends qt{constructor(t){super(t)}hr(){const t=this.er;t.Ct=!1;const i=this.Tn.F();if(!i.priceLineVisible||!this.Tn.Ct())return;const s=this.Tn.Or(0===i.priceLineSource);s.Lr||(t.Ct=!0,t.et=s.yi,t.D=this.Tn.Kr(s.D),t.rt=i.priceLineWidth,t.Ft=i.priceLineStyle)}}class ci extends q{constructor(t){super(),this.$t=t}Ei(t,i,s){t.Ct=!1,i.Ct=!1;const n=this.$t;if(!n.Ct())return;const e=n.F(),r=e.lastValueVisible,h=""!==n.Gr(),l=0===e.seriesLastValueMode,a=n.Or(!1);if(a.Lr)return;r&&(t.Gt=this.Jr(a,r,l),t.Ct=0!==t.Gt.length),(h||l)&&(i.Gt=this.Qr(a,r,h,l),i.Ct=i.Gt.length>0);const o=n.Kr(a.D),_=m(o);s.t=_.t,s.yi=a.yi,i.Ot=n.Ut().Lt(a.yi/n.Bt().It()),t.Ot=o,t.D=_.i,i.D=_.i}Qr(t,i,s,n){let e="";const r=this.$t.Gr();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.$t.Bt().th()?t.ih:t.sh),e.trim()}Jr(t,i,s){return i?s?this.$t.Bt().th()?t.sh:t.ih:t.Gt:""}}class di{constructor(t,i){this.nh=t,this.eh=i}rh(t){return null!==t&&(this.nh===t.nh&&this.eh===t.eh)}hh(){return new di(this.nh,this.eh)}lh(){return this.nh}ah(){return this.eh}oh(){return this.eh-this.nh}Ni(){return this.eh===this.nh||Number.isNaN(this.eh)||Number.isNaN(this.nh)}sn(t){return null===t?this:new di(Math.min(this.lh(),t.lh()),Math.max(this.ah(),t.ah()))}_h(t){if(!w(t))return;if(0===this.eh-this.nh)return;const i=.5*(this.eh+this.nh);let s=this.eh-i,n=this.nh-i;s*=t,n*=t,this.eh=i+s,this.nh=i+n}uh(t){w(t)&&(this.eh+=t,this.nh+=t)}dh(){return{minValue:this.nh,maxValue:this.eh}}static fh(t){return null===t?null:new di(t.minValue,t.maxValue)}}class fi{constructor(t,i){this.ph=t,this.mh=i||null}bh(){return this.ph}gh(){return this.mh}dh(){return null===this.ph?null:{priceRange:this.ph.dh(),margins:this.mh||void 0}}static fh(t){return null===t?null:new fi(di.fh(t.priceRange),t.margins)}}class pi extends qt{constructor(t,i){super(t),this.wh=i}hr(){const t=this.er;t.Ct=!1;const i=this.wh.F();if(!this.Tn.Ct()||!i.lineVisible)return;const s=this.wh.Mh();null!==s&&(t.Ct=!0,t.et=s,t.D=i.color,t.rt=i.lineWidth,t.Ft=i.lineStyle,t.sr=this.wh.F().id)}}class vi extends q{constructor(t,i){super(),this.Tr=t,this.wh=i}Ei(t,i,s){t.Ct=!1,i.Ct=!1;const n=this.wh.F(),e=n.axisLabelVisible,r=""!==n.title,h=this.Tr;if(!e||!h.Ct())return;const l=this.wh.Mh();if(null===l)return;r&&(i.Gt=n.title,i.Ct=!0),i.Ot=h.Ut().Lt(l/h.Bt().It()),t.Gt=this.xh(n.price),t.Ct=!0;const a=m(n.axisLabelColor||n.color);s.t=a.t;const o=n.axisLabelTextColor||a.i;t.D=o,i.D=o,s.yi=l}xh(t){const i=this.Tr.Tt();return null===i?"":this.Tr.Bt().Fi(t,i.At)}}class mi{constructor(t,i){this.Tr=t,this.cs=i,this.Sh=new pi(t,this),this.Xe=new vi(t,this),this.yh=new Ht(this.Xe,t,t.Ut())}kh(t){g(this.cs,t),this.gt(),this.Tr.Ut().Ch()}F(){return this.cs}Th(){return this.Sh}Ph(){return this.yh}Rh(){return this.Xe}gt(){this.Sh.gt(),this.Xe.gt()}Mh(){const t=this.Tr,i=t.Bt();if(t.Ut().yt().Ni()||i.Ni())return null;const s=t.Tt();return null===s?null:i.Dt(this.cs.price,s.At)}}class bi extends G{constructor(t){super(),this.Hi=t}Ut(){return this.Hi}}const gi={Bar:(t,i,s,n)=>{var e;const r=i.upColor,h=i.downColor,o=l(t(s,n)),_=a(o.At[0])<=a(o.At[3]);return{ie:null!==(e=o.D)&&void 0!==e?e:_?r:h}},Candlestick:(t,i,s,n)=>{var e,r,h;const o=i.upColor,_=i.downColor,u=i.borderUpColor,c=i.borderDownColor,d=i.wickUpColor,f=i.wickDownColor,p=l(t(s,n)),v=a(p.At[0])<=a(p.At[3]);return{ie:null!==(e=p.D)&&void 0!==e?e:v?o:_,Pe:null!==(r=p.Ot)&&void 0!==r?r:v?u:c,Te:null!==(h=p.Dh)&&void 0!==h?h:v?d:f}},Area:(t,i,s,n)=>{var e,r,h,a;const o=l(t(s,n));return{ie:null!==(e=o.ot)&&void 0!==e?e:i.lineColor,ot:null!==(r=o.ot)&&void 0!==r?r:i.lineColor,bn:null!==(h=o.bn)&&void 0!==h?h:i.topColor,gn:null!==(a=o.gn)&&void 0!==a?a:i.bottomColor}},Baseline:(t,i,s,n)=>{var e,r,h,a,o,_;const u=l(t(s,n));return{ie:u.At[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,be:null!==(e=u.be)&&void 0!==e?e:i.topLineColor,ge:null!==(r=u.ge)&&void 0!==r?r:i.bottomLineColor,de:null!==(h=u.de)&&void 0!==h?h:i.topFillColor1,fe:null!==(a=u.fe)&&void 0!==a?a:i.topFillColor2,pe:null!==(o=u.pe)&&void 0!==o?o:i.bottomFillColor1,ve:null!==(_=u.ve)&&void 0!==_?_:i.bottomFillColor2}},Line:(t,i,s,n)=>{var e,r;const h=l(t(s,n));return{ie:null!==(e=h.D)&&void 0!==e?e:i.color,ot:null!==(r=h.D)&&void 0!==r?r:i.color}},Histogram:(t,i,s,n)=>{var e;return{ie:null!==(e=l(t(s,n)).D)&&void 0!==e?e:i.color}}};class wi{constructor(t){this.Bh=(t,i)=>void 0!==i?i.At:this.Tr.Es().Ah(t),this.Tr=t,this.Oh=gi[t.Lh()]}On(t,i){return this.Oh(this.Bh,this.Tr.F(),t,i)}}var Mi;exports.MismatchDirection=void 0,(Mi=exports.MismatchDirection||(exports.MismatchDirection={}))[Mi.NearestLeft=-1]="NearestLeft",Mi[Mi.None=0]="None",Mi[Mi.NearestRight=1]="NearestRight";const xi=30;class Si{constructor(){this.Ih=[],this.Eh=new Map,this.Vh=new Map}zh(){return this.Nn()>0?this.Ih[this.Ih.length-1]:null}Nh(){return this.Nn()>0?this.Fh(0):null}Is(){return this.Nn()>0?this.Fh(this.Ih.length-1):null}Nn(){return this.Ih.length}Ni(){return 0===this.Nn()}Ir(t){return null!==this.Wh(t,0)}Ah(t){return this.jh(t)}jh(t,i=0){const s=this.Wh(t,i);return null===s?null:Object.assign(Object.assign({},this.$h(s)),{Yn:this.Fh(s)})}Un(){return this.Ih}Hh(t,i,s){if(this.Ni())return null;let n=null;for(const e of s){n=yi(n,this.Uh(t,i,e))}return n}tt(t){this.Vh.clear(),this.Eh.clear(),this.Ih=t}Fh(t){return this.Ih[t].Yn}$h(t){return this.Ih[t]}Wh(t,i){const s=this.qh(t);if(null===s&&0!==i)switch(i){case-1:return this.Yh(t);case 1:return this.Xh(t);default:throw new TypeError("Unknown search mode")}return s}Yh(t){let i=this.Zh(t);return i>0&&(i-=1),i!==this.Ih.length&&this.Fh(i)<t?i:null}Xh(t){const i=this.Kh(t);return i!==this.Ih.length&&t<this.Fh(i)?i:null}qh(t){const i=this.Zh(t);return i===this.Ih.length||t<this.Ih[i].Yn?null:i}Zh(t){return bt(this.Ih,t,((t,i)=>t.Yn<i))}Kh(t){return gt(this.Ih,t,((t,i)=>i.Yn>t))}Gh(t,i,s){let n=null;for(let e=t;e<i;e++){const t=this.Ih[e].At[s];Number.isNaN(t)||(null===n?n={Jh:t,Qh:t}:(t<n.Jh&&(n.Jh=t),t>n.Qh&&(n.Qh=t)))}return n}Uh(t,i,s){if(this.Ni())return null;let n=null;const e=l(this.Nh()),r=l(this.Is()),h=Math.max(t,e),a=Math.min(i,r),o=Math.ceil(h/xi)*xi,_=Math.max(o,Math.floor(a/xi)*xi);{const t=this.Zh(h),e=this.Kh(Math.min(a,o,i));n=yi(n,this.Gh(t,e,s))}let u=this.Eh.get(s);void 0===u&&(u=new Map,this.Eh.set(s,u));for(let t=Math.max(o+1,h);t<_;t+=xi){const i=Math.floor(t/xi);let e=u.get(i);if(void 0===e){const t=this.Zh(i*xi),n=this.Kh((i+1)*xi-1);e=this.Gh(t,n,s),u.set(i,e)}n=yi(n,e)}{const t=this.Zh(_),i=this.Kh(a);n=yi(n,this.Gh(t,i,s))}return n}}function yi(t,i){if(null===t)return i;if(null===i)return t;return{Jh:Math.min(t.Jh,i.Jh),Qh:Math.max(t.Qh,i.Qh)}}class ki extends bi{constructor(t,i,s){super(t),this.Vt=new Si,this.Sh=new ui(this),this.tl=[],this.il=new Yt(this),this.sl=null,this.nl=null,this.el=[],this.rl=[],this.hl=null,this.cs=i,this.ll=s;const n=new ci(this);this.rs=[n],this.yh=new Ht(n,this,t),"Area"!==s&&"Line"!==s&&"Baseline"!==s||(this.sl=new Jt(this)),this.al(),this.ol()}M(){null!==this.hl&&clearTimeout(this.hl)}Kr(t){return this.cs.priceLineColor||t}Or(t){const i={Lr:!0},s=this.Bt();if(this.Ut().yt().Ni()||s.Ni()||this.Vt.Ni())return i;const n=this.Ut().yt().zn(),e=this.Tt();if(null===n||null===e)return i;let r,h;if(t){const t=this.Vt.zh();if(null===t)return i;r=t,h=t.Yn}else{const t=this.Vt.jh(n.ci(),-1);if(null===t)return i;if(r=this.Vt.Ah(t.Yn),null===r)return i;h=t.Yn}const l=r.At[3],a=this.Ln().On(h,{At:r}),o=s.Dt(l,e.At);return{Lr:!1,ut:l,Gt:s.Fi(l,e.At),ih:s._l(l),sh:s.ul(l,e.At),D:a.ie,yi:o,Yn:h}}Ln(){return null!==this.nl||(this.nl=new wi(this)),this.nl}F(){return this.cs}kh(t){const i=t.priceScaleId;void 0!==i&&i!==this.cs.priceScaleId&&this.Ut().cl(this,i),g(this.cs,t),void 0!==t.priceFormat&&(this.al(),this.Ut().dl()),this.Ut().fl(this),this.Ut().pl(),this.ws.gt("options")}tt(t,i){this.Vt.tt(t),this.vl(),this.ws.gt("data"),this.ds.gt("data"),null!==this.sl&&(i&&i.ml?this.sl.Rr():0===t.length&&this.sl.Pr());const s=this.Ut().Ke(this);this.Ut().bl(s),this.Ut().fl(this),this.Ut().pl(),this.Ut().Ch()}gl(t){this.el=t,this.vl();const i=this.Ut().Ke(this);this.ds.gt("data"),this.Ut().bl(i),this.Ut().fl(this),this.Ut().pl(),this.Ut().Ch()}wl(){return this.el}Xr(){return this.rl}Ml(t){const i=new mi(this,t);return this.tl.push(i),this.Ut().fl(this),i}xl(t){const i=this.tl.indexOf(t);-1!==i&&this.tl.splice(i,1),this.Ut().fl(this)}Lh(){return this.ll}Tt(){const t=this.Sl();return null===t?null:{At:t.At[3],yl:t._t}}Sl(){const t=this.Ut().yt().zn();if(null===t)return null;const i=t.Mn();return this.Vt.jh(i,1)}Es(){return this.Vt}Zr(t){const i=this.Vt.Ah(t);return null===i?null:"Bar"===this.ll||"Candlestick"===this.ll?{oe:i.At[0],_e:i.At[1],ue:i.At[2],ce:i.At[3]}:i.At[3]}kl(t){const i=this.sl;return null!==i&&i.Ct()?(null===this.hl&&i.Br()&&(this.hl=setTimeout((()=>{this.hl=null,this.Ut().Cl()}),0)),i.Dr(),[i]):[]}Rs(){const t=[];this.Tl()||t.push(this.il),t.push(this.ws,this.Sh,this.ds);const i=this.tl.map((t=>t.Th()));return t.push(...i),t}Ji(t){return[this.yh,...this.tl.map((t=>t.Ph()))]}Ds(t,i){if(i!==this.Yi&&!this.Tl())return[];const s=[...this.rs];for(const t of this.tl)s.push(t.Rh());return s}Pl(t,i){if(void 0!==this.cs.autoscaleInfoProvider){const s=this.cs.autoscaleInfoProvider((()=>{const s=this.Rl(t,i);return null===s?null:s.dh()}));return fi.fh(s)}return this.Rl(t,i)}Dl(){return this.cs.priceFormat.minMove}Bl(){return this.Al}As(){var t;this.ws.gt(),this.ds.gt();for(const t of this.rs)t.gt();for(const t of this.tl)t.gt();this.Sh.gt(),this.il.gt(),null===(t=this.sl)||void 0===t||t.gt()}Bt(){return l(super.Bt())}kt(t){if(!(("Line"===this.ll||"Area"===this.ll||"Baseline"===this.ll)&&this.cs.crosshairMarkerVisible))return null;const i=this.Vt.Ah(t);if(null===i)return null;return{ut:i.At[3],lt:this.Ol(),Ot:this.Ll(),Rt:this.Il(),Pt:this.El(t)}}Gr(){return this.cs.title}Ct(){return this.cs.visible}Tl(){return!tt(this.Bt().Vl())}Rl(t,i){if(!M(t)||!M(i)||this.Vt.Ni())return null;const s="Line"===this.ll||"Area"===this.ll||"Baseline"===this.ll||"Histogram"===this.ll?[3]:[2,1],n=this.Vt.Hh(t,i,s);let e=null!==n?new di(n.Jh,n.Qh):null;if("Histogram"===this.Lh()){const t=this.cs.base,i=new di(t,t);e=null!==e?e.sn(i):i}return new fi(e,this.ds.Yr())}Ol(){switch(this.ll){case"Line":case"Area":case"Baseline":return this.cs.crosshairMarkerRadius}return 0}Ll(){switch(this.ll){case"Line":case"Area":case"Baseline":{const t=this.cs.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}Il(){switch(this.ll){case"Line":case"Area":case"Baseline":return this.cs.crosshairMarkerBorderWidth}return 0}El(t){switch(this.ll){case"Line":case"Area":case"Baseline":{const t=this.cs.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Ln().On(t).ie}al(){switch(this.cs.priceFormat.type){case"custom":this.Al={format:this.cs.priceFormat.formatter};break;case"volume":this.Al=new ht(this.cs.priceFormat.precision);break;case"percent":this.Al=new rt(this.cs.priceFormat.precision);break;default:{const t=Math.pow(10,this.cs.priceFormat.precision);this.Al=new et(t,this.cs.priceFormat.minMove*t)}}null!==this.Yi&&this.Yi.zl()}vl(){const t=this.Ut().yt();if(!t.Nl()||this.Vt.Ni())return void(this.rl=[]);const i=l(this.Vt.Nh());this.rl=this.el.map(((s,n)=>{const e=l(t.Fl(s.time,!0)),r=e<i?1:-1;return{time:l(this.Vt.jh(e,r)).Yn,position:s.position,shape:s.shape,color:s.color,id:s.id,internalId:n,text:s.text,size:s.size}}))}ol(){switch(this.ds=new _i(this,this.Ut()),this.ll){case"Bar":this.ws=new Pt(this,this.Ut());break;case"Candlestick":this.ws=new Vt(this,this.Ut());break;case"Line":this.ws=new Ft(this,this.Ut());break;case"Area":this.ws=new kt(this,this.Ut());break;case"Baseline":this.ws=new It(this,this.Ut());break;case"Histogram":this.ws=new Nt(this,this.Ut());break;default:throw Error("Unknown chart style assigned: "+this.ll)}}}class Ci{constructor(t){this.cs=t}Wl(t,i,s){let n=t;if(0===this.cs.mode)return n;const e=s.ps(),r=e.Tt();if(null===r)return n;const h=e.Dt(t,r),l=s.jl().filter((t=>t instanceof ki)).reduce(((t,n)=>{if(s.Ge(n)||!n.Ct())return t;const e=n.Bt(),r=n.Es();if(e.Ni()||!r.Ir(i))return t;const h=r.Ah(i);if(null===h)return t;const l=a(n.Tt());return t.concat([e.Dt(h.At[3],l.At)])}),[]);if(0===l.length)return n;l.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=l[0];return n=e.vs(o,r),n}}class Ti extends E{constructor(){super(...arguments),this.Vt=null}tt(t){this.Vt=t}Z({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Vt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=l(this.Vt);if(h.$l){t.strokeStyle=h.Hl,n(t,h.Ul),t.beginPath();for(const n of h.ql){const e=Math.round(n.Yl*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Xl){t.strokeStyle=h.Zl,n(t,h.Kl),t.beginPath();for(const s of h.Gl){const n=Math.round(s.Yl*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}}))}}class Pi{constructor(t){this.jt=new Ti,this.vt=!0,this.ts=t}gt(){this.vt=!0}Mt(){if(this.vt){const t=this.ts.Ut().F().grid,i={Xl:t.horzLines.visible,$l:t.vertLines.visible,Zl:t.horzLines.color,Hl:t.vertLines.color,Kl:t.horzLines.style,Ul:t.vertLines.style,Gl:this.ts.ps().Jl(),ql:this.ts.Ut().yt().Jl()||[]};this.jt.tt(i),this.vt=!1}return this.jt}}class Ri{constructor(t){this.ws=new Pi(t)}Th(){return this.ws}}const Di={Ql:4,ta:1e-4};function Bi(t,i){const s=100*(t-i)/i;return i<0?-s:s}function Ai(t,i){const s=Bi(t.lh(),i),n=Bi(t.ah(),i);return new di(s,n)}function Oi(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function Li(t,i){const s=Oi(t.lh(),i),n=Oi(t.ah(),i);return new di(s,n)}function Ii(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Bt(s+i.ta)+i.Ql;return t<0?-n:n}function Ei(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.Ql)-i.ta;return t<0?-n:n}function Vi(t,i){if(null===t)return null;const s=Ii(t.lh(),i),n=Ii(t.ah(),i);return new di(s,n)}function zi(t,i){if(null===t)return null;const s=Ei(t.lh(),i),n=Ei(t.ah(),i);return new di(s,n)}function Ni(t){if(null===t)return Di;const i=Math.abs(t.ah()-t.lh());if(i>=1||i<1e-15)return Di;const s=Math.ceil(Math.abs(Math.log10(i))),n=Di.Ql+s;return{Ql:n,ta:1/Math.pow(10,n)}}class Fi{constructor(t,i){if(this.ia=t,this.sa=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.ia))this.na=[2,2.5,2];else{this.na=[];for(let t=this.ia;1!==t;){if(t%2==0)this.na.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.na.push(2,2.5),t/=5}if(this.na.length>100)throw new Error("something wrong with base")}}}ea(t,i,s){const n=0===this.ia?0:1/this.ia;let e=Math.pow(10,Math.max(0,Math.ceil(Bt(t-i)))),r=0,h=this.sa[0];for(;;){const t=Dt(e,n,1e-14)&&e>n+1e-14,i=Dt(e,s*h,1e-14),l=Dt(e,1,1e-14);if(!(t&&i&&l))break;e/=h,h=this.sa[++r%this.sa.length]}if(e<=n+1e-14&&(e=n),e=Math.max(1,e),this.na.length>0&&(l=e,a=1,o=1e-14,Math.abs(l-a)<o))for(r=0,h=this.na[0];Dt(e,s*h,1e-14)&&e>n+1e-14;)e/=h,h=this.na[++r%this.na.length];var l,a,o;return e}}class Wi{constructor(t,i,s,n){this.ra=[],this.Vi=t,this.ia=i,this.ha=s,this.la=n}ea(t,i){if(t<i)throw new Error("high < low");const s=this.Vi.It(),n=(t-i)*this.aa()/s,e=new Fi(this.ia,[2,2.5,2]),r=new Fi(this.ia,[2,2,2.5]),h=new Fi(this.ia,[2.5,2,2]),l=[];return l.push(e.ea(t,i,n),r.ea(t,i,n),h.ea(t,i,n)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let s=1;s<t.length;++s)t[s]<i&&(i=t[s]);return i}(l)}oa(){const t=this.Vi,i=t.Tt();if(null===i)return void(this.ra=[]);const s=t.It(),n=this.ha(s-1,i),e=this.ha(0,i),r=this.Vi.F().entireTextOnly?this._a()/2:0,h=r,l=s-1-r,a=Math.max(n,e),o=Math.min(n,e);if(a===o)return void(this.ra=[]);let _=this.ea(a,o),u=a%_;u+=u<0?_:0;const c=a>=o?1:-1;let d=null,f=0;for(let s=a-u;s>o;s-=_){const n=this.la(s,i,!0);null!==d&&Math.abs(n-d)<this.aa()||(n<h||n>l||(f<this.ra.length?(this.ra[f].Yl=n,this.ra[f].ua=t.ca(s)):this.ra.push({Yl:n,ua:t.ca(s)}),f++,d=n,t.da()&&(_=this.ea(s*c,o))))}this.ra.length=f}Jl(){return this.ra}_a(){return this.Vi.T()}aa(){return Math.ceil(2.5*this._a())}}function ji(t){return t.slice().sort(((t,i)=>l(t.Zi())-l(i.Zi())))}var $i;exports.PriceScaleMode=void 0,($i=exports.PriceScaleMode||(exports.PriceScaleMode={}))[$i.Normal=0]="Normal",$i[$i.Logarithmic=1]="Logarithmic",$i[$i.Percentage=2]="Percentage",$i[$i.IndexedTo100=3]="IndexedTo100";const Hi=new rt,Ui=new et(100,1);class qi{constructor(t,i,s,n){this.fa=0,this.pa=null,this.ph=null,this.va=null,this.ma={ba:!1,ga:null},this.wa=0,this.Ma=0,this.xa=new b,this.Sa=new b,this.ya=[],this.ka=null,this.Ca=null,this.Ta=null,this.Pa=null,this.Al=Ui,this.Ra=Ni(null),this.Da=t,this.cs=i,this.Ba=s,this.Aa=n,this.Oa=new Wi(this,100,this.La.bind(this),this.Ia.bind(this))}Vl(){return this.Da}F(){return this.cs}kh(t){if(g(this.cs,t),this.zl(),void 0!==t.mode&&this.Ea({lr:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1||i+s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.Va(),this.Ca=null}}za(){return this.cs.autoScale}da(){return 1===this.cs.mode}th(){return 2===this.cs.mode}Na(){return 3===this.cs.mode}lr(){return{js:this.cs.autoScale,Fa:this.cs.invertScale,lr:this.cs.mode}}Ea(t){const i=this.lr();let s=null;void 0!==t.js&&(this.cs.autoScale=t.js),void 0!==t.lr&&(this.cs.mode=t.lr,2!==t.lr&&3!==t.lr||(this.cs.autoScale=!0),this.ma.ba=!1),1===i.lr&&t.lr!==i.lr&&(!function(t,i){if(null===t)return!1;const s=Ei(t.lh(),i),n=Ei(t.ah(),i);return isFinite(s)&&isFinite(n)}(this.ph,this.Ra)?this.cs.autoScale=!0:(s=zi(this.ph,this.Ra),null!==s&&this.Wa(s))),1===t.lr&&t.lr!==i.lr&&(s=Vi(this.ph,this.Ra),null!==s&&this.Wa(s));const n=i.lr!==this.cs.mode;n&&(2===i.lr||this.th())&&this.zl(),n&&(3===i.lr||this.Na())&&this.zl(),void 0!==t.Fa&&i.Fa!==t.Fa&&(this.cs.invertScale=t.Fa,this.ja()),this.Sa.m(i,this.lr())}$a(){return this.Sa}T(){return this.Ba.fontSize}It(){return this.fa}Ha(t){this.fa!==t&&(this.fa=t,this.Va(),this.Ca=null)}Ua(){if(this.pa)return this.pa;const t=this.It()-this.qa()-this.Ya();return this.pa=t,t}bh(){return this.Xa(),this.ph}Wa(t,i){const s=this.ph;(i||null===s&&null!==t||null!==s&&!s.rh(t))&&(this.Ca=null,this.ph=t)}Ni(){return this.Xa(),0===this.fa||!this.ph||this.ph.Ni()}Za(t){return this.Fa()?t:this.It()-1-t}Dt(t,i){return this.th()?t=Bi(t,i):this.Na()&&(t=Oi(t,i)),this.Ia(t,i)}$n(t,i,s){this.Xa();const n=this.Ya(),e=l(this.bh()),r=e.lh(),h=e.ah(),a=this.Ua()-1,o=this.Fa(),_=a/(h-r),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,d=this.Ka();for(let s=u;s<c;s++){const e=t[s],h=e.ut;if(isNaN(h))continue;let l=h;null!==d&&(l=d(e.ut,i));const a=n+_*(l-r),u=o?a:this.fa-1-a;e.et=u}}le(t,i,s){this.Xa();const n=this.Ya(),e=l(this.bh()),r=e.lh(),h=e.ah(),a=this.Ua()-1,o=this.Fa(),_=a/(h-r),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,d=this.Ka();for(let s=u;s<c;s++){const e=t[s];let h=e.oe,l=e._e,a=e.ue,u=e.ce;null!==d&&(h=d(e.oe,i),l=d(e._e,i),a=d(e.ue,i),u=d(e.ce,i));let c=n+_*(h-r),f=o?c:this.fa-1-c;e.re=f,c=n+_*(l-r),f=o?c:this.fa-1-c,e.se=f,c=n+_*(a-r),f=o?c:this.fa-1-c,e.ne=f,c=n+_*(u-r),f=o?c:this.fa-1-c,e.he=f}}vs(t,i){const s=this.La(t,i);return this.Ga(s,i)}Ga(t,i){let s=t;return this.th()?s=function(t,i){return i<0&&(t=-t),t/100*i+i}(s,i):this.Na()&&(s=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(s,i)),s}jl(){return this.ya}Ja(){if(this.ka)return this.ka;let t=[];for(let i=0;i<this.ya.length;i++){const s=this.ya[i];null===s.Zi()&&s.Ki(i+1),t.push(s)}return t=ji(t),this.ka=t,this.ka}Qa(t){-1===this.ya.indexOf(t)&&(this.ya.push(t),this.zl(),this.io())}so(t){const i=this.ya.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.ya.splice(i,1),0===this.ya.length&&(this.Ea({js:!0}),this.Wa(null)),this.zl(),this.io()}Tt(){let t=null;for(const i of this.ya){const s=i.Tt();null!==s&&((null===t||s.yl<t.yl)&&(t=s))}return null===t?null:t.At}Fa(){return this.cs.invertScale}Jl(){const t=null===this.Tt();if(null!==this.Ca&&(t||this.Ca.no===t))return this.Ca.Jl;this.Oa.oa();const i=this.Oa.Jl();return this.Ca={Jl:i,no:t},this.xa.m(),i}eo(){return this.xa}ro(t){this.th()||this.Na()||null===this.Ta&&null===this.va&&(this.Ni()||(this.Ta=this.fa-t,this.va=l(this.bh()).hh()))}ho(t){if(this.th()||this.Na())return;if(null===this.Ta)return;this.Ea({js:!1}),(t=this.fa-t)<0&&(t=0);let i=(this.Ta+.2*(this.fa-1))/(t+.2*(this.fa-1));const s=l(this.va).hh();i=Math.max(i,.1),s._h(i),this.Wa(s)}lo(){this.th()||this.Na()||(this.Ta=null,this.va=null)}ao(t){this.za()||null===this.Pa&&null===this.va&&(this.Ni()||(this.Pa=t,this.va=l(this.bh()).hh()))}oo(t){if(this.za())return;if(null===this.Pa)return;const i=l(this.bh()).oh()/(this.Ua()-1);let s=t-this.Pa;this.Fa()&&(s*=-1);const n=s*i,e=l(this.va).hh();e.uh(n),this.Wa(e,!0),this.Ca=null}_o(){this.za()||null!==this.Pa&&(this.Pa=null,this.va=null)}Bl(){return this.Al||this.zl(),this.Al}Fi(t,i){switch(this.cs.mode){case 2:return this.Bl().format(Bi(t,i));case 3:return this.Bl().format(Oi(t,i));default:return this.xh(t)}}ca(t){switch(this.cs.mode){case 2:case 3:return this.Bl().format(t);default:return this.xh(t)}}_l(t){return this.xh(t,l(this.uo()).Bl())}ul(t,i){return t=Bi(t,i),Hi.format(t)}co(){return this.ya}do(t){this.ma={ga:t,ba:!1}}As(){this.ya.forEach((t=>t.As()))}zl(){this.Ca=null;const t=this.uo();let i=100;null!==t&&(i=Math.round(1/t.Dl())),this.Al=Ui,this.th()?(this.Al=Hi,i=100):this.Na()?(this.Al=new et(100,1),i=100):null!==t&&(this.Al=t.Bl()),this.Oa=new Wi(this,i,this.La.bind(this),this.Ia.bind(this)),this.Oa.oa()}io(){this.ka=null}uo(){return this.ya[0]||null}qa(){return this.Fa()?this.cs.scaleMargins.bottom*this.It()+this.Ma:this.cs.scaleMargins.top*this.It()+this.wa}Ya(){return this.Fa()?this.cs.scaleMargins.top*this.It()+this.wa:this.cs.scaleMargins.bottom*this.It()+this.Ma}Xa(){this.ma.ba||(this.ma.ba=!0,this.fo())}Va(){this.pa=null}Ia(t,i){if(this.Xa(),this.Ni())return 0;t=this.da()&&t?Ii(t,this.Ra):t;const s=l(this.bh()),n=this.Ya()+(this.Ua()-1)*(t-s.lh())/s.oh();return this.Za(n)}La(t,i){if(this.Xa(),this.Ni())return 0;const s=this.Za(t),n=l(this.bh()),e=n.lh()+n.oh()*((s-this.Ya())/(this.Ua()-1));return this.da()?Ei(e,this.Ra):e}ja(){this.Ca=null,this.Oa.oa()}fo(){const t=this.ma.ga;if(null===t)return;let i=null;const s=this.co();let n=0,e=0;for(const r of s){if(!r.Ct())continue;const s=r.Tt();if(null===s)continue;const h=r.Pl(t.Mn(),t.ci());let a=h&&h.bh();if(null!==a){switch(this.cs.mode){case 1:a=Vi(a,this.Ra);break;case 2:a=Ai(a,s.At);break;case 3:a=Li(a,s.At)}if(i=null===i?a:i.sn(l(a)),null!==h){const t=h.gh();null!==t&&(n=Math.max(n,t.above),e=Math.max(n,t.below))}}}if(n===this.wa&&e===this.Ma||(this.wa=n,this.Ma=e,this.Ca=null,this.Va()),null!==i){if(i.lh()===i.ah()){const t=this.uo(),s=5*(null===t||this.th()||this.Na()?1:t.Dl());this.da()&&(i=zi(i,this.Ra)),i=new di(i.lh()-s,i.ah()+s),this.da()&&(i=Vi(i,this.Ra))}if(this.da()){const t=zi(i,this.Ra),s=Ni(t);if(r=s,h=this.Ra,r.Ql!==h.Ql||r.ta!==h.ta){const n=null!==this.va?zi(this.va,this.Ra):null;this.Ra=s,i=Vi(t,s),null!==n&&(this.va=Vi(n,s))}}this.Wa(i)}else null===this.ph&&(this.Wa(new di(-.5,.5)),this.Ra=Ni(null));var r,h;this.ma.ba=!0}Ka(){return this.th()?Bi:this.Na()?Oi:this.da()?t=>Ii(t,this.Ra):null}xh(t,i){return void 0===this.Aa.priceFormatter?(void 0===i&&(i=this.Bl()),i.format(t)):this.Aa.priceFormatter(t)}}class Yi{constructor(t,i){this.ya=[],this.po=new Map,this.fa=0,this.vo=0,this.mo=1e3,this.ka=null,this.bo=new b,this.wo=t,this.Hi=i,this.Mo=new Ri(this);const s=i.F();this.xo=this.So("left",s.leftPriceScale),this.yo=this.So("right",s.rightPriceScale),this.xo.$a().l(this.ko.bind(this,this.xo),this),this.yo.$a().l(this.ko.bind(this,this.yo),this),this.Co(s)}Co(t){if(t.leftPriceScale&&this.xo.kh(t.leftPriceScale),t.rightPriceScale&&this.yo.kh(t.rightPriceScale),t.localization&&(this.xo.zl(),this.yo.zl()),t.overlayPriceScales){const i=Array.from(this.po.values());for(const s of i){const i=l(s[0].Bt());i.kh(t.overlayPriceScales),t.localization&&i.zl()}}}To(t){switch(t){case"left":return this.xo;case"right":return this.yo}return this.po.has(t)?h(this.po.get(t))[0].Bt():null}M(){this.Ut().Po().v(this),this.xo.$a().v(this),this.yo.$a().v(this),this.ya.forEach((t=>{t.M&&t.M()})),this.bo.m()}Ro(){return this.mo}Do(t){this.mo=t}Ut(){return this.Hi}$i(){return this.vo}It(){return this.fa}Bo(t){this.vo=t,this.Ao()}Ha(t){this.fa=t,this.xo.Ha(t),this.yo.Ha(t),this.ya.forEach((i=>{if(this.Ge(i)){const s=i.Bt();null!==s&&s.Ha(t)}})),this.Ao()}jl(){return this.ya}Ge(t){const i=t.Bt();return null===i||this.xo!==i&&this.yo!==i}Qa(t,i,s){const n=void 0!==s?s:this.Lo().Oo+1;this.Io(t,i,n)}so(t){const i=this.ya.indexOf(t);r(-1!==i,"removeDataSource: invalid data source"),this.ya.splice(i,1);const s=l(t.Bt()).Vl();if(this.po.has(s)){const i=h(this.po.get(s)),n=i.indexOf(t);-1!==n&&(i.splice(n,1),0===i.length&&this.po.delete(s))}const n=t.Bt();n&&n.jl().indexOf(t)>=0&&n.so(t),null!==n&&(n.io(),this.Eo(n)),this.ka=null}Qe(t){return t===this.xo?"left":t===this.yo?"right":"overlay"}Vo(){return this.xo}zo(){return this.yo}No(t,i){t.ro(i)}Fo(t,i){t.ho(i),this.Ao()}Wo(t){t.lo()}jo(t,i){t.ao(i)}$o(t,i){t.oo(i),this.Ao()}Ho(t){t._o()}Ao(){this.ya.forEach((t=>{t.As()}))}ps(){let t=null;return this.Hi.F().rightPriceScale.visible&&0!==this.yo.jl().length?t=this.yo:this.Hi.F().leftPriceScale.visible&&0!==this.xo.jl().length?t=this.xo:0!==this.ya.length&&(t=this.ya[0].Bt()),null===t&&(t=this.yo),t}Je(){let t=null;return this.Hi.F().rightPriceScale.visible?t=this.yo:this.Hi.F().leftPriceScale.visible&&(t=this.xo),t}Eo(t){null!==t&&t.za()&&this.Uo(t)}qo(t){const i=this.wo.zn();t.Ea({js:!0}),null!==i&&t.do(i),this.Ao()}Yo(){this.Uo(this.xo),this.Uo(this.yo)}Xo(){this.Eo(this.xo),this.Eo(this.yo),this.ya.forEach((t=>{this.Ge(t)&&this.Eo(t.Bt())})),this.Ao(),this.Hi.Ch()}Ja(){return null===this.ka&&(this.ka=ji(this.ya)),this.ka}Zo(){return this.bo}Ko(){return this.Mo}Uo(t){const i=t.co();if(i&&i.length>0&&!this.wo.Ni()){const i=this.wo.zn();null!==i&&t.do(i)}t.As()}Lo(){const t=this.Ja();if(0===t.length)return{Go:0,Oo:0};let i=0,s=0;for(let n=0;n<t.length;n++){const e=t[n].Zi();null!==e&&(e<i&&(i=e),e>s&&(s=e))}return{Go:i,Oo:s}}Io(t,i,s){let n=this.To(i);if(null===n&&(n=this.So(i,this.Hi.F().overlayPriceScales)),this.ya.push(t),!tt(i)){const s=this.po.get(i)||[];s.push(t),this.po.set(i,s)}n.Qa(t),t.Gi(n),t.Ki(s),this.Eo(n),this.ka=null}ko(t,i,s){i.lr!==s.lr&&this.Uo(t)}So(t,i){const s=Object.assign({visible:!0,autoScale:!0},y(i)),n=new qi(t,s,this.Hi.F().layout,this.Hi.F().localization);return n.Ha(this.It()),n}}const Xi=t=>t.getUTCFullYear(),Zi=t=>nt((t=>t.getUTCDate())(t),2),Ki=(t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}),Gi=(t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}),Ji=t=>nt((t=>t.getUTCMonth()+1)(t),2),Qi=t=>nt(Xi(t)%100,2),ts=t=>nt(Xi(t),4);class is{constructor(t="yyyy-MM-dd",i="default"){this.Jo=t,this.Qo=i}t_(t){return function(t,i,s){return i.replace(/yyyy/g,ts(t)).replace(/yy/g,Qi(t)).replace(/MMMM/g,Ki(t,s)).replace(/MMM/g,Gi(t,s)).replace(/MM/g,Ji(t)).replace(/dd/g,Zi(t))}(t,this.Jo,this.Qo)}}class ss{constructor(t){this.i_=t||"%h:%m:%s"}t_(t){return this.i_.replace("%h",nt(t.getUTCHours(),2)).replace("%m",nt(t.getUTCMinutes(),2)).replace("%s",nt(t.getUTCSeconds(),2))}}const ns={s_:"yyyy-MM-dd",n_:"%h:%m:%s",e_:" ",r_:"default"};class es{constructor(t={}){const i=Object.assign(Object.assign({},ns),t);this.h_=new is(i.s_,i.r_),this.l_=new ss(i.n_),this.a_=i.e_}t_(t){return`${this.h_.t_(t)}${this.a_}${this.l_.t_(t)}`}}class rs{constructor(t,i=50){this.Le=0,this.Ie=1,this.Ee=1,this.ze=new Map,this.Ve=new Map,this.o_=t,this.Ne=i}t_(t){const i=t._t,s=void 0===i.__?new Date(1e3*i.u_).getTime():new Date(Date.UTC(i.__.year,i.__.month-1,i.__.day)).getTime(),n=this.ze.get(s);if(void 0!==n)return n.c_;if(this.Le===this.Ne){const t=this.Ve.get(this.Ee);this.Ve.delete(this.Ee),this.ze.delete(h(t)),this.Ee++,this.Le--}const e=this.o_(t);return this.ze.set(s,{c_:e,$e:this.Ie}),this.Ve.set(this.Ie,s),this.Le++,this.Ie++,e}}class hs{constructor(t,i){r(t<=i,"right should be >= left"),this.d_=t,this.f_=i}Mn(){return this.d_}ci(){return this.f_}p_(){return this.f_-this.d_+1}Ir(t){return this.d_<=t&&t<=this.f_}rh(t){return this.d_===t.Mn()&&this.f_===t.ci()}}function ls(t,i){return null===t||null===i?t===i:t.rh(i)}class as{constructor(){this.v_=new Map,this.ze=null}m_(t,i){this.b_(i),this.ze=null;for(let s=i;s<t.length;++s){const i=t[s];let n=this.v_.get(i.g_);void 0===n&&(n=[],this.v_.set(i.g_,n)),n.push({Yn:s,_t:i._t,w_:i.g_,M_:i.M_})}}x_(t,i){const s=Math.ceil(i/t);return null!==this.ze&&this.ze.S_===s||(this.ze={Jl:this.y_(s),S_:s}),this.ze.Jl}b_(t){if(0===t)return void this.v_.clear();const i=[];this.v_.forEach(((s,n)=>{t<=s[0].Yn?i.push(n):s.splice(bt(s,t,(i=>i.Yn<t)),1/0)}));for(const t of i)this.v_.delete(t)}y_(t){let i=[];for(const s of Array.from(this.v_.keys()).sort(((t,i)=>i-t))){if(!this.v_.get(s))continue;const n=i;i=[];const e=n.length;let r=0;const l=h(this.v_.get(s)),a=l.length;let o=1/0,_=-1/0;for(let s=0;s<a;s++){const h=l[s],a=h.Yn;for(;r<e;){const t=n[r],s=t.Yn;if(!(s<a)){o=s;break}r++,i.push(t),_=s,o=1/0}o-a>=t&&a-_>=t&&(i.push(h),_=a)}for(;r<e;r++)i.push(n[r])}return i}}class os{constructor(t){this.k_=t}C_(){return null===this.k_?null:new hs(Math.floor(this.k_.Mn()),Math.ceil(this.k_.ci()))}T_(){return this.k_}static P_(){return new os(null)}}var _s,us,cs,ds,fs;exports.TickMarkType=void 0,(_s=exports.TickMarkType||(exports.TickMarkType={}))[_s.Year=0]="Year",_s[_s.Month=1]="Month",_s[_s.DayOfMonth=2]="DayOfMonth",_s[_s.Time=3]="Time",_s[_s.TimeWithSeconds=4]="TimeWithSeconds";class ps{constructor(t,i,s){this.vo=0,this.R_=null,this.D_=[],this.Pa=null,this.Ta=null,this.B_=new as,this.A_=new Map,this.O_=os.P_(),this.L_=!0,this.I_=new b,this.E_=new b,this.V_=new b,this.z_=null,this.N_=null,this.F_=[],this.cs=i,this.Aa=s,this.W_=i.rightOffset,this.j_=i.barSpacing,this.Hi=t,this.H_()}F(){return this.cs}U_(t){g(this.Aa,t),this.q_(),this.H_()}kh(t,i){var s;g(this.cs,t),this.cs.fixLeftEdge&&this.Y_(),this.cs.fixRightEdge&&this.X_(),void 0!==t.barSpacing&&this.Hi.Js(t.barSpacing),void 0!==t.rightOffset&&this.Hi.Qs(t.rightOffset),void 0!==t.minBarSpacing&&this.Hi.Js(null!==(s=t.barSpacing)&&void 0!==s?s:this.j_),this.q_(),this.H_(),this.V_.m()}bs(t){var i,s;return null!==(s=null===(i=this.D_[t])||void 0===i?void 0:i._t)&&void 0!==s?s:null}Ui(t){var i;return null!==(i=this.D_[t])&&void 0!==i?i:null}Fl(t,i){if(this.D_.length<1)return null;if(t.u_>this.D_[this.D_.length-1]._t.u_)return i?this.D_.length-1:null;const s=bt(this.D_,t.u_,((t,i)=>t._t.u_<i));return t.u_<this.D_[s]._t.u_?i?s:null:s}Ni(){return 0===this.vo||0===this.D_.length||null===this.R_}Nl(){return this.D_.length>0}zn(){return this.Z_(),this.O_.C_()}K_(){return this.Z_(),this.O_.T_()}G_(){const t=this.zn();if(null===t)return null;const i={from:t.Mn(),to:t.ci()};return this.J_(i)}J_(t){const i=Math.round(t.from),s=Math.round(t.to),n=l(this.Q_()),e=l(this.tu());return{from:l(this.bs(Math.max(n,i))),to:l(this.bs(Math.min(e,s)))}}iu(t){return{from:l(this.Fl(t.from,!0)),to:l(this.Fl(t.to,!0))}}$i(){return this.vo}Bo(t){if(!isFinite(t)||t<=0)return;if(this.vo===t)return;const i=this.K_(),s=this.vo;if(this.vo=t,this.L_=!0,this.cs.lockVisibleTimeRangeOnResize&&0!==s){const i=this.j_*t/s;this.j_=i}if(this.cs.fixLeftEdge&&null!==i&&i.Mn()<=0){const i=s-t;this.W_-=Math.round(i/this.j_)+1,this.L_=!0}this.su(),this.nu()}Et(t){if(this.Ni()||!M(t))return 0;const i=this.eu()+this.W_-t;return this.vo-(i+.5)*this.j_-1}jn(t,i){const s=this.eu(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;i<e;i++){const n=t[i]._t,e=s+this.W_-n,r=this.vo-(e+.5)*this.j_-1;t[i].nt=r}}ru(t){return Math.ceil(this.hu(t))}Qs(t){this.L_=!0,this.W_=t,this.nu(),this.Hi.lu(),this.Hi.Ch()}Kn(){return this.j_}Js(t){this.au(t),this.nu(),this.Hi.lu(),this.Hi.Ch()}ou(){return this.W_}Jl(){if(this.Ni())return null;if(null!==this.N_)return this.N_;const t=this.j_,i=5*(this.Hi.F().layout.fontSize+4),s=Math.round(i/t),n=l(this.zn()),e=Math.max(n.Mn(),n.Mn()-s),r=Math.max(n.ci(),n.ci()-s),h=this.B_.x_(t,i),a=this.Q_()+s,o=this.tu()-s,_=this._u(),u=this.cs.fixLeftEdge||_,c=this.cs.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.Yn&&t.Yn<=r))continue;let s;d<this.F_.length?(s=this.F_[d],s.Yl=this.Et(t.Yn),s.ua=this.uu(t),s.w_=t.w_):(s={cu:!1,Yl:this.Et(t.Yn),ua:this.uu(t),w_:t.w_},this.F_.push(s)),this.j_>i/2&&!_?s.cu=!1:s.cu=u&&t.Yn<=a||c&&t.Yn>=o,d++}return this.F_.length=d,this.N_=this.F_,this.F_}du(){this.L_=!0,this.Js(this.cs.barSpacing),this.Qs(this.cs.rightOffset)}fu(t){this.L_=!0,this.R_=t,this.nu(),this.Y_()}pu(t,i){const s=this.hu(t),n=this.Kn(),e=n+i*(n/10);this.Js(e),this.cs.rightBarStaysOnScroll||this.Qs(this.ou()+(s-this.hu(t)))}ro(t){this.Pa&&this._o(),null===this.Ta&&null===this.z_&&(this.Ni()||(this.Ta=t,this.vu()))}ho(t){if(null===this.z_)return;const i=Rt(this.vo-t,0,this.vo),s=Rt(this.vo-l(this.Ta),0,this.vo);0!==i&&0!==s&&this.Js(this.z_.Kn*i/s)}lo(){null!==this.Ta&&(this.Ta=null,this.mu())}ao(t){null===this.Pa&&null===this.z_&&(this.Ni()||(this.Pa=t,this.vu()))}oo(t){if(null===this.Pa)return;const i=(this.Pa-t)/this.Kn();this.W_=l(this.z_).ou+i,this.L_=!0,this.nu()}_o(){null!==this.Pa&&(this.Pa=null,this.mu())}bu(){this.gu(this.cs.rightOffset)}gu(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.W_,n=performance.now();this.Hi.Zs({wu:t=>(t-n)/i>=1,Mu:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}gt(t,i){this.L_=!0,this.D_=t,this.B_.m_(t,i),this.nu()}xu(){return this.I_}Su(){return this.E_}yu(){return this.V_}eu(){return this.R_||0}ku(t){const i=t.p_();this.au(this.vo/i),this.W_=t.ci()-this.eu(),this.nu(),this.L_=!0,this.Hi.lu(),this.Hi.Ch()}Cu(){const t=this.Q_(),i=this.tu();null!==t&&null!==i&&this.ku(new hs(t,i+this.cs.rightOffset))}Tu(t){const i=new hs(t.from,t.to);this.ku(i)}qi(t){return void 0!==this.Aa.timeFormatter?this.Aa.timeFormatter(t.M_):this.Pu.t_(new Date(1e3*t._t.u_))}_u(){const{handleScroll:t,handleScale:i}=this.Hi.F();return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}Q_(){return 0===this.D_.length?null:0}tu(){return 0===this.D_.length?null:this.D_.length-1}Ru(t){return(this.vo-1-t)/this.j_}hu(t){const i=this.Ru(t),s=this.eu()+this.W_-i;return Math.round(1e6*s)/1e6}au(t){const i=this.j_;this.j_=t,this.su(),i!==this.j_&&(this.L_=!0,this.Du())}Z_(){if(!this.L_)return;if(this.L_=!1,this.Ni())return void this.Bu(os.P_());const t=this.eu(),i=this.vo/this.j_,s=this.W_+t,n=new hs(s-i+1,s);this.Bu(new os(n))}su(){const t=this.Au();if(this.j_<t&&(this.j_=t,this.L_=!0),0!==this.vo){const t=.5*this.vo;this.j_>t&&(this.j_=t,this.L_=!0)}}Au(){return this.cs.fixLeftEdge&&this.cs.fixRightEdge&&0!==this.D_.length?this.vo/this.D_.length:this.cs.minBarSpacing}nu(){const t=this.Ou();this.W_>t&&(this.W_=t,this.L_=!0);const i=this.Lu();null!==i&&this.W_<i&&(this.W_=i,this.L_=!0)}Lu(){const t=this.Q_(),i=this.R_;if(null===t||null===i)return null;return t-i-1+(this.cs.fixLeftEdge?this.vo/this.j_:Math.min(2,this.D_.length))}Ou(){return this.cs.fixRightEdge?0:this.vo/this.j_-Math.min(2,this.D_.length)}vu(){this.z_={Kn:this.Kn(),ou:this.ou()}}mu(){this.z_=null}uu(t){let i=this.A_.get(t.w_);return void 0===i&&(i=new rs((t=>this.Iu(t))),this.A_.set(t.w_,i)),i.t_(t)}Iu(t){const i=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.w_,this.cs.timeVisible,this.cs.secondsVisible);if(void 0!==this.cs.tickMarkFormatter){const s=this.cs.tickMarkFormatter(t.M_,i,this.Aa.locale);if(null!==s)return s}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.__?new Date(1e3*t.u_):new Date(Date.UTC(t.__.year,t.__.month-1,t.__.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t._t,i,this.Aa.locale)}Bu(t){const i=this.O_;this.O_=t,ls(i.C_(),this.O_.C_())||this.I_.m(),ls(i.T_(),this.O_.T_())||this.E_.m(),this.Du()}Du(){this.N_=null}q_(){this.Du(),this.A_.clear()}H_(){const t=this.Aa.dateFormat;this.cs.timeVisible?this.Pu=new es({s_:t,n_:this.cs.secondsVisible?"%h:%m:%s":"%h:%m",e_:" ",r_:this.Aa.locale}):this.Pu=new is(t,this.Aa.locale)}Y_(){if(!this.cs.fixLeftEdge)return;const t=this.Q_();if(null===t)return;const i=this.zn();if(null===i)return;const s=i.Mn()-t;if(s<0){const t=this.W_-s-1;this.Qs(t)}this.su()}X_(){this.nu(),this.su()}}class vs extends B{constructor(t){super(),this.Eu=new Map,this.Vt=t}Z(t){}G(t){if(!this.Vt.Ct)return;const{context:i,mediaSize:s}=t;let n=0;for(const t of this.Vt.Vu){if(0===t.Gt.length)continue;i.font=t.P;const e=this.zu(i,t.Gt);e>s.width?t.pu=s.width/e:t.pu=1,n+=t.Nu*t.pu}let e=0;switch(this.Vt.Fu){case"top":e=0;break;case"center":e=Math.max((s.height-n)/2,0);break;case"bottom":e=Math.max(s.height-n,0)}i.fillStyle=this.Vt.D;for(const t of this.Vt.Vu){i.save();let n=0;switch(this.Vt.Wu){case"left":i.textAlign="left",n=t.Nu/2;break;case"center":i.textAlign="center",n=s.width/2;break;case"right":i.textAlign="right",n=s.width-1-t.Nu/2}i.translate(n,e),i.textBaseline="top",i.font=t.P,i.scale(t.pu,t.pu),i.fillText(t.Gt,0,t.ju),i.restore(),e+=t.Nu*t.pu}}zu(t,i){const s=this.$u(t.font);let n=s.get(i);return void 0===n&&(n=t.measureText(i).width,s.set(i,n)),n}$u(t){let i=this.Eu.get(t);return void 0===i&&(i=new Map,this.Eu.set(t,i)),i}}class ms{constructor(t){this.vt=!0,this.Wt={Ct:!1,D:"",Vu:[],Fu:"center",Wu:"center"},this.jt=new vs(this.Wt),this.$t=t}gt(){this.vt=!0}Mt(){return this.vt&&(this.xt(),this.vt=!1),this.jt}xt(){const t=this.$t.F(),i=this.Wt;i.Ct=t.visible,i.Ct&&(i.D=t.color,i.Wu=t.horzAlign,i.Fu=t.vertAlign,i.Vu=[{Gt:t.text,P:P(t.fontSize,t.fontFamily,t.fontStyle),Nu:1.2*t.fontSize,ju:0,pu:0}])}}class bs extends G{constructor(t,i){super(),this.cs=i,this.ws=new ms(this)}Ds(){return[]}Rs(){return[this.ws]}F(){return this.cs}As(){this.ws.gt()}}exports.TrackingModeExitMode=void 0,(us=exports.TrackingModeExitMode||(exports.TrackingModeExitMode={}))[us.OnTouchEnd=0]="OnTouchEnd",us[us.OnNextTap=1]="OnNextTap";class gs{constructor(t,i){this.Hu=[],this.Uu=[],this.vo=0,this.qu=null,this.Yu=new b,this.Xu=new b,this.Zu=null,this.Ku=t,this.cs=i,this.Gu=new R(this),this.wo=new ps(this,i.timeScale,this.cs.localization),this.bt=new Q(this,i.crosshair),this.Ju=new Ci(i.crosshair),this.Qu=new bs(this,i.watermark),this.tc(),this.Hu[0].Do(2e3),this.ic=this.sc(0),this.nc=this.sc(1)}dl(){this.ec(it.rn())}Ch(){this.ec(it.en())}Cl(){this.ec(new it(1))}fl(t){const i=this.rc(t);this.ec(i)}hc(){return this.qu}lc(t){const i=this.qu;this.qu=t,null!==i&&this.fl(i.ac),null!==t&&this.fl(t.ac)}F(){return this.cs}kh(t){g(this.cs,t),this.Hu.forEach((i=>i.Co(t))),void 0!==t.timeScale&&this.wo.kh(t.timeScale),void 0!==t.localization&&this.wo.U_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Yu.m(),this.ic=this.sc(0),this.nc=this.sc(1),this.dl()}oc(t,i){if("left"===t)return void this.kh({leftPriceScale:i});if("right"===t)return void this.kh({rightPriceScale:i});const s=this._c(t);null!==s&&(s.Bt.kh(i),this.Yu.m())}_c(t){for(const i of this.Hu){const s=i.To(t);if(null!==s)return{Ht:i,Bt:s}}return null}yt(){return this.wo}uc(){return this.Hu}cc(){return this.Qu}dc(){return this.bt}fc(){return this.Xu}vc(t,i){t.Ha(i),this.lu()}Bo(t){this.vo=t,this.wo.Bo(this.vo),this.Hu.forEach((i=>i.Bo(t))),this.lu()}tc(t){const i=new Yi(this.wo,this);void 0!==t?this.Hu.splice(t,0,i):this.Hu.push(i);const s=void 0===t?this.Hu.length-1:t,n=it.rn();return n.Fs(s,{Ws:0,js:!0}),this.ec(n),i}No(t,i,s){t.No(i,s)}Fo(t,i,s){t.Fo(i,s),this.pl(),this.ec(this.mc(t,2))}Wo(t,i){t.Wo(i),this.ec(this.mc(t,2))}jo(t,i,s){i.za()||t.jo(i,s)}$o(t,i,s){i.za()||(t.$o(i,s),this.pl(),this.ec(this.mc(t,2)))}Ho(t,i){i.za()||(t.Ho(i),this.ec(this.mc(t,2)))}qo(t,i){t.qo(i),this.ec(this.mc(t,2))}bc(t){this.wo.ro(t)}gc(t,i){const s=this.yt();if(s.Ni()||0===i)return;const n=s.$i();t=Math.max(1,Math.min(t,n)),s.pu(t,i),this.lu()}wc(t){this.Mc(0),this.xc(t),this.Sc()}yc(t){this.wo.ho(t),this.lu()}kc(){this.wo.lo(),this.Ch()}Mc(t){this.wo.ao(t)}xc(t){this.wo.oo(t),this.lu()}Sc(){this.wo._o(),this.Ch()}wt(){return this.Uu}Cc(t,i,s,n){this.bt.Ms(t,i);let e=NaN,r=this.wo.ru(t);const h=this.wo.zn();null!==h&&(r=Math.min(Math.max(h.Mn(),r),h.ci()));const l=n.ps(),a=l.Tt();null!==a&&(e=l.vs(i,a)),e=this.Ju.Wl(e,r,n),this.bt.ks(r,e,n),this.Cl(),this.Xu.m(this.bt.St(),{x:t,y:i},s)}Tc(){this.dc().Ts(),this.Cl(),this.Xu.m(null,null,null)}pl(){const t=this.bt.Ht();if(null!==t){const i=this.bt.Ss(),s=this.bt.ys();this.Cc(i,s,null,t)}this.bt.As()}Pc(t,i,s){const n=this.wo.bs(0);void 0!==i&&void 0!==s&&this.wo.gt(i,s);const e=this.wo.bs(0),r=this.wo.eu(),h=this.wo.zn();if(null!==h&&null!==n&&null!==e){const i=h.Ir(r),s=n.u_>e.u_,l=null!==t&&t>r&&!s,a=i&&this.wo.F().shiftVisibleRangeOnNewBar;if(l&&!a){const i=t-r;this.wo.Qs(this.wo.ou()-i)}}this.wo.fu(t)}bl(t){null!==t&&t.Xo()}Ke(t){const i=this.Hu.find((i=>i.Ja().includes(t)));return void 0===i?null:i}lu(){this.Qu.As(),this.Hu.forEach((t=>t.Xo())),this.pl()}M(){this.Hu.forEach((t=>t.M())),this.Hu.length=0,this.cs.localization.priceFormatter=void 0,this.cs.localization.timeFormatter=void 0}Rc(){return this.Gu}tr(){return this.Gu.F()}Po(){return this.Yu}Dc(t,i){const s=this.Hu[0],n=this.Bc(i,t,s);return this.Uu.push(n),1===this.Uu.length?this.dl():this.Ch(),n}Ac(t){const i=this.Ke(t),s=this.Uu.indexOf(t);r(-1!==s,"Series not found"),this.Uu.splice(s,1),l(i).so(t),t.M&&t.M()}cl(t,i){const s=l(this.Ke(t));s.so(t);const n=this._c(i);if(null===n){const n=t.Zi();s.Qa(t,i,n)}else{const e=n.Ht===s?t.Zi():void 0;n.Ht.Qa(t,i,e)}}Cu(){const t=it.en();t.Us(),this.ec(t)}Oc(t){const i=it.en();i.Xs(t),this.ec(i)}Gs(){const t=it.en();t.Gs(),this.ec(t)}Js(t){const i=it.en();i.Js(t),this.ec(i)}Qs(t){const i=it.en();i.Qs(t),this.ec(i)}Zs(t){const i=it.en();i.Zs(t),this.ec(i)}qs(){const t=it.en();t.qs(),this.ec(t)}Lc(){return this.cs.rightPriceScale.visible?"right":"left"}Ic(){return this.nc}U(){return this.ic}Lt(t){const i=this.nc,s=this.ic;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Zu||this.Zu.bn!==s||this.Zu.gn!==i)this.Zu={bn:s,gn:i,Ec:new Map};else{const i=this.Zu.Ec.get(t);if(void 0!==i)return i}const n=function(t,i,s){const[n,e,r,h]=v(t),[l,a,o,c]=v(i),d=[_(n+s*(l-n)),_(e+s*(a-e)),_(r+s*(o-r)),u(h+s*(c-h))];return`rgba(${d[0]}, ${d[1]}, ${d[2]}, ${d[3]})`}(s,i,t/100);return this.Zu.Ec.set(t,n),n}mc(t,i){const s=new it(i);if(null!==t){const n=this.Hu.indexOf(t);s.Fs(n,{Ws:i})}return s}rc(t,i){return void 0===i&&(i=2),this.mc(this.Ke(t),i)}ec(t){this.Ku&&this.Ku(t),this.Hu.forEach((t=>t.Ko().Th().gt()))}Bc(t,i,s){const n=new ki(this,t,i),e=void 0!==t.priceScaleId?t.priceScaleId:this.Lc();return s.Qa(n,e),tt(e)||n.kh(t),n}sc(t){const i=this.cs.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}}function ws(t){return!w(t)&&!x(t)}function Ms(t){return w(t)}exports.LastPriceAnimationMode=void 0,(cs=exports.LastPriceAnimationMode||(exports.LastPriceAnimationMode={}))[cs.Disabled=0]="Disabled",cs[cs.Continuous=1]="Continuous",cs[cs.OnDataUpdate=2]="OnDataUpdate",exports.PriceLineSource=void 0,(ds=exports.PriceLineSource||(exports.PriceLineSource={}))[ds.LastBar=0]="LastBar",ds[ds.LastVisible=1]="LastVisible",exports.ColorType=void 0,(fs=exports.ColorType||(exports.ColorType={})).Solid="solid",fs.VerticalGradient="gradient";const xs="undefined"!=typeof window;function Ss(){return!!xs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function ys(){return!!xs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ks(t){return t+t%2}function Cs(t,i){return t.Vc-i.Vc}function Ts(t,i,s){const n=(t.Vc-i.Vc)/(t._t-i._t);return Math.sign(n)*Math.min(Math.abs(n),s)}class Ps{constructor(t,i,s,n){this.zc=null,this.Nc=null,this.Fc=null,this.Wc=null,this.jc=null,this.$c=0,this.Hc=0,this.Uc=t,this.qc=i,this.Yc=s,this.hn=n}Xc(t,i){if(null!==this.zc){if(this.zc._t===i)return void(this.zc.Vc=t);if(Math.abs(this.zc.Vc-t)<this.hn)return}this.Wc=this.Fc,this.Fc=this.Nc,this.Nc=this.zc,this.zc={_t:i,Vc:t}}pr(t,i){if(null===this.zc||null===this.Nc)return;if(i-this.zc._t>50)return;let s=0;const n=Ts(this.zc,this.Nc,this.qc),e=Cs(this.zc,this.Nc),r=[n],h=[e];if(s+=e,null!==this.Fc){const t=Ts(this.Nc,this.Fc,this.qc);if(Math.sign(t)===Math.sign(n)){const i=Cs(this.Nc,this.Fc);if(r.push(t),h.push(i),s+=i,null!==this.Wc){const t=Ts(this.Fc,this.Wc,this.qc);if(Math.sign(t)===Math.sign(n)){const i=Cs(this.Fc,this.Wc);r.push(t),h.push(i),s+=i}}}}let l=0;for(let t=0;t<r.length;++t)l+=h[t]/s*r[t];Math.abs(l)<this.Uc||(this.jc={Vc:t,_t:i},this.Hc=l,this.$c=function(t,i){const s=Math.log(i);return Math.log(1*s/-t)/s}(Math.abs(l),this.Yc))}Mu(t){const i=l(this.jc),s=t-i._t;return i.Vc+this.Hc*(Math.pow(this.Yc,s)-1)/Math.log(this.Yc)}wu(t){return null===this.jc||this.Zc(t)===this.$c}Zc(t){const i=t-l(this.jc)._t;return Math.min(i,this.$c)}}function Rs(t,i){const n=l(t.ownerDocument).createElement("canvas");t.appendChild(n);const e=s.bindCanvasElementBitmapSizeTo(n,{type:"device-pixel-content-box",options:{allowResizeObserver:!1},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})});return e.resizeCanvasElement(i),e}function Ds(t){xs&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class Bs{constructor(t,i,s){this.Kc=0,this.Gc=null,this.Jc={nt:Number.NEGATIVE_INFINITY,et:Number.POSITIVE_INFINITY},this.Qc=0,this.td=null,this.sd={nt:Number.NEGATIVE_INFINITY,et:Number.POSITIVE_INFINITY},this.nd=null,this.ed=!1,this.rd=null,this.hd=null,this.ld=!1,this.ad=!1,this.od=!1,this._d=null,this.ud=null,this.dd=null,this.fd=null,this.pd=null,this.vd=null,this.md=null,this.bd=0,this.gd=!1,this.wd=!1,this.Md=!1,this.xd=0,this.Sd=null,this.yd=!ys(),this.kd=t=>{this.Cd(t)},this.Td=t=>{if(this.Pd(t)){const i=this.Rd(t);if(++this.Qc,this.td&&this.Qc>1){const{Dd:s}=this.Bd(Ls(t),this.sd);s<30&&!this.od&&this.Ad(i,this.Ld.Od),this.Id()}}else{const i=this.Rd(t);if(++this.Kc,this.Gc&&this.Kc>1){const{Dd:s}=this.Bd(Ls(t),this.Jc);s<5&&!this.ad&&this.Ed(i,this.Ld.Vd),this.zd()}}},this.Nd=t,this.Ld=i,this.cs=s,this.Fd()}M(){null!==this._d&&(this._d(),this._d=null),null!==this.ud&&(this.ud(),this.ud=null),null!==this.fd&&(this.fd(),this.fd=null),null!==this.pd&&(this.pd(),this.pd=null),null!==this.vd&&(this.vd(),this.vd=null),null!==this.dd&&(this.dd(),this.dd=null),this.Wd(),this.zd()}jd(t){this.fd&&this.fd();const i=this.$d.bind(this);if(this.fd=()=>{this.Nd.removeEventListener("mousemove",i)},this.Nd.addEventListener("mousemove",i),this.Pd(t))return;const s=this.Rd(t);this.Ed(s,this.Ld.Hd),this.yd=!0}zd(){null!==this.Gc&&clearTimeout(this.Gc),this.Kc=0,this.Gc=null,this.Jc={nt:Number.NEGATIVE_INFINITY,et:Number.POSITIVE_INFINITY}}Id(){null!==this.td&&clearTimeout(this.td),this.Qc=0,this.td=null,this.sd={nt:Number.NEGATIVE_INFINITY,et:Number.POSITIVE_INFINITY}}$d(t){if(this.Md||null!==this.hd)return;if(this.Pd(t))return;const i=this.Rd(t);this.Ed(i,this.Ld.Ud),this.yd=!0}qd(t){const i=Es(t.changedTouches,l(this.Sd));if(null===i)return;if(this.xd=Is(t),null!==this.md)return;if(this.wd)return;this.gd=!0;const s=this.Bd(Ls(i),l(this.hd)),{Yd:n,Xd:e,Dd:r}=s;if(this.ld||!(r<5)){if(!this.ld){const t=.5*n,i=e>=t&&!this.cs.Zd(),s=t>e&&!this.cs.Kd();i||s||(this.wd=!0),this.ld=!0,this.od=!0,this.Wd(),this.Id()}if(!this.wd){const s=this.Rd(t,i);this.Ad(s,this.Ld.Gd),Os(t)}}}Jd(t){if(0!==t.button)return;const i=this.Bd(Ls(t),l(this.rd)),{Dd:s}=i;if(s>=5&&(this.ad=!0,this.zd()),this.ad){const i=this.Rd(t);this.Ed(i,this.Ld.Qd)}}Bd(t,i){const s=Math.abs(i.nt-t.nt),n=Math.abs(i.et-t.et);return{Yd:s,Xd:n,Dd:s+n}}tf(t){let i=Es(t.changedTouches,l(this.Sd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.Sd=null,this.xd=Is(t),this.Wd(),this.hd=null,this.vd&&(this.vd(),this.vd=null);const s=this.Rd(t,i);if(this.Ad(s,this.Ld.if),++this.Qc,this.td&&this.Qc>1){const{Dd:t}=this.Bd(Ls(i),this.sd);t<30&&!this.od&&this.Ad(s,this.Ld.Od),this.Id()}else this.od||(this.Ad(s,this.Ld.sf),this.Ld.sf&&Os(t));0===this.Qc&&Os(t),0===t.touches.length&&this.ed&&(this.ed=!1,Os(t))}Cd(t){if(0!==t.button)return;const i=this.Rd(t);if(this.rd=null,this.Md=!1,this.pd&&(this.pd(),this.pd=null),Ss()){this.Nd.ownerDocument.documentElement.removeEventListener("mouseleave",this.kd)}if(!this.Pd(t))if(this.Ed(i,this.Ld.nf),++this.Kc,this.Gc&&this.Kc>1){const{Dd:s}=this.Bd(Ls(t),this.Jc);s<5&&!this.ad&&this.Ed(i,this.Ld.Vd),this.zd()}else this.ad||this.Ed(i,this.Ld.ef)}Wd(){null!==this.nd&&(clearTimeout(this.nd),this.nd=null)}rf(t){if(null!==this.Sd)return;const i=t.changedTouches[0];this.Sd=i.identifier,this.xd=Is(t);const s=this.Nd.ownerDocument.documentElement;this.od=!1,this.ld=!1,this.wd=!1,this.hd=Ls(i),this.vd&&(this.vd(),this.vd=null);{const i=this.qd.bind(this),n=this.tf.bind(this);this.vd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.Wd(),this.nd=setTimeout(this.hf.bind(this,t),240)}const n=this.Rd(t,i);this.Ad(n,this.Ld.lf),this.td||(this.Qc=0,this.td=setTimeout(this.Id.bind(this),500),this.sd=Ls(i))}af(t){if(0!==t.button)return;const i=this.Nd.ownerDocument.documentElement;Ss()&&i.addEventListener("mouseleave",this.kd),this.ad=!1,this.rd=Ls(t),this.pd&&(this.pd(),this.pd=null);{const t=this.Jd.bind(this),s=this.Cd.bind(this);this.pd=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this.Md=!0,this.Pd(t))return;const s=this.Rd(t);this.Ed(s,this.Ld._f),this.Gc||(this.Kc=0,this.Gc=setTimeout(this.zd.bind(this),500),this.Jc=Ls(t))}Fd(){this.Nd.addEventListener("mouseenter",this.jd.bind(this)),this.Nd.addEventListener("touchcancel",this.Wd.bind(this));{const t=this.Nd.ownerDocument,i=t=>{this.Ld.uf&&(t.composed&&this.Nd.contains(t.composedPath()[0])||t.target&&this.Nd.contains(t.target)||this.Ld.uf())};this.ud=()=>{t.removeEventListener("touchstart",i)},this._d=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}ys()&&(this.dd=()=>{this.Nd.removeEventListener("dblclick",this.Td)},this.Nd.addEventListener("dblclick",this.Td)),this.Nd.addEventListener("mouseleave",this.cf.bind(this)),this.Nd.addEventListener("touchstart",this.rf.bind(this),{passive:!0}),Ds(this.Nd),this.Nd.addEventListener("mousedown",this.af.bind(this)),this.df(),this.Nd.addEventListener("touchmove",(()=>{}),{passive:!1})}df(){void 0===this.Ld.ff&&void 0===this.Ld.pf&&void 0===this.Ld.vf||(this.Nd.addEventListener("touchstart",(t=>this.mf(t.touches)),{passive:!0}),this.Nd.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.md&&void 0!==this.Ld.pf){const i=As(t.touches[0],t.touches[1])/this.bd;this.Ld.pf(this.md,i),Os(t)}}),{passive:!1}),this.Nd.addEventListener("touchend",(t=>{this.mf(t.touches)})))}mf(t){1===t.length&&(this.gd=!1),2!==t.length||this.gd||this.ed?this.bf():this.gf(t)}gf(t){const i=this.Nd.getBoundingClientRect()||{left:0,top:0};this.md={nt:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,et:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.bd=As(t[0],t[1]),void 0!==this.Ld.ff&&this.Ld.ff(),this.Wd()}bf(){null!==this.md&&(this.md=null,void 0!==this.Ld.vf&&this.Ld.vf())}cf(t){if(this.fd&&this.fd(),this.Pd(t))return;if(!this.yd)return;const i=this.Rd(t);this.Ed(i,this.Ld.wf),this.yd=!ys()}hf(t){const i=Es(t.touches,l(this.Sd));if(null===i)return;const s=this.Rd(t,i);this.Ad(s,this.Ld.Mf),this.od=!0,this.ed=!0}Pd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:Is(t)<this.xd+500}Ad(t,i){i&&i.call(this.Ld,t)}Ed(t,i){i&&i.call(this.Ld,t)}Rd(t,i){const s=i||t,n=this.Nd.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-n.left,localY:s.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,xf:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,Sf:t.type,yf:s.target,kf:t.view,Cf:()=>{"touchstart"!==t.type&&Os(t)}}}}function As(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function Os(t){t.cancelable&&t.preventDefault()}function Ls(t){return{nt:t.pageX,et:t.pageY}}function Is(t){return t.timeStamp||performance.now()}function Es(t,i){for(let s=0;s<t.length;++s)if(t[s].identifier===i)return t[s];return null}class Vs{constructor(t,i,n,e){this.Vi=null,this.Tf=null,this.Pf=!1,this.Rf=new jt(200),this.Vr=null,this.Df=0,this.Bf=!1,this.Af=()=>{this.Bf||this.ts.Of().Ut().Ch()},this.Lf=()=>{this.Bf||this.ts.Of().Ut().Ch()},this.ts=t,this.cs=i,this.Ba=i.layout,this.Gu=n,this.If="left"===e,this.Ef=document.createElement("div"),this.Ef.style.height="100%",this.Ef.style.overflow="hidden",this.Ef.style.width="25px",this.Ef.style.left="0",this.Ef.style.position="relative",this.Vf=Rs(this.Ef,s.size({width:16,height:16})),this.Vf.subscribeSuggestedBitmapSizeChanged(this.Af);const r=this.Vf.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.zf=Rs(this.Ef,s.size({width:16,height:16})),this.zf.subscribeSuggestedBitmapSizeChanged(this.Lf);const h=this.zf.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0";const l={_f:this.Nf.bind(this),lf:this.Nf.bind(this),Qd:this.Ff.bind(this),Gd:this.Ff.bind(this),uf:this.Wf.bind(this),nf:this.jf.bind(this),if:this.jf.bind(this),Vd:this.$f.bind(this),Od:this.$f.bind(this),Hd:this.Hf.bind(this),wf:this.Uf.bind(this)};this.qf=new Bs(this.zf.canvasElement,l,{Zd:()=>!1,Kd:()=>!0})}M(){this.qf.M(),this.zf.unsubscribeSuggestedBitmapSizeChanged(this.Lf),this.zf.dispose(),this.Vf.unsubscribeSuggestedBitmapSizeChanged(this.Af),this.Vf.dispose(),null!==this.Vi&&this.Vi.eo().v(this),this.Vi=null}Yf(){return this.Ef}T(){return this.Ba.fontSize}Xf(){const t=this.Gu.F();return this.Vr!==t.P&&(this.Rf.Fe(),this.Vr=t.P),t}Zf(){if(null===this.Vi)return 0;let t=0;const i=this.Xf(),s=l(this.Vf.canvasElement.getContext("2d"));s.save();const n=this.Vi.Jl();s.font=this.Kf(),n.length>0&&(t=Math.max(this.Rf.xi(s,n[0].ua),this.Rf.xi(s,n[n.length-1].ua)));const e=this.Gf();for(let i=e.length;i--;){const n=this.Rf.xi(s,e[i].Gt());n>t&&(t=n)}const r=this.Vi.Tt();if(null!==r&&null!==this.Tf){const i=this.Vi.vs(1,r),n=this.Vi.vs(this.Tf.height-2,r);t=Math.max(t,this.Rf.xi(s,this.Vi.Fi(Math.floor(Math.min(i,n))+.11111111111111,r)),this.Rf.xi(s,this.Vi.Fi(Math.ceil(Math.max(i,n))-.11111111111111,r)))}s.restore();const h=t||34;return ks(Math.ceil(i.k+i.C+i.O+i.L+5+h))}Jf(t){null!==this.Tf&&s.equalSizes(this.Tf,t)||(this.Tf=t,this.Bf=!0,this.Vf.resizeCanvasElement(t),this.zf.resizeCanvasElement(t),this.Bf=!1,this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`)}Qf(){return l(this.Tf).width}Gi(t){this.Vi!==t&&(null!==this.Vi&&this.Vi.eo().v(this),this.Vi=t,t.eo().l(this.xa.bind(this),this))}Bt(){return this.Vi}Fe(){const t=this.ts.tp();this.ts.Of().Ut().qo(t,l(this.Bt()))}ip(t){if(null===this.Tf)return;if(1!==t){this.sp(),this.Vf.applySuggestedBitmapSize();const t=s.tryCreateCanvasRenderingTarget2D(this.Vf);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.np(t),this.ye(t)})),this.ep(t),this.rp(t))}this.zf.applySuggestedBitmapSize();const i=s.tryCreateCanvasRenderingTarget2D(this.zf);null!==i&&(i.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.hp(i))}lp(){return this.Vf.bitmapSize}ap(t,i,s){const n=this.lp();n.width>0&&n.height>0&&t.drawImage(this.Vf.canvasElement,i,s)}gt(){var t;null===(t=this.Vi)||void 0===t||t.Jl()}Nf(t){if(null===this.Vi||this.Vi.Ni()||!this.cs.handleScale.axisPressedMouseMove.price)return;const i=this.ts.Of().Ut(),s=this.ts.tp();this.Pf=!0,i.No(s,this.Vi,t.localY)}Ff(t){if(null===this.Vi||!this.cs.handleScale.axisPressedMouseMove.price)return;const i=this.ts.Of().Ut(),s=this.ts.tp(),n=this.Vi;i.Fo(s,n,t.localY)}Wf(){if(null===this.Vi||!this.cs.handleScale.axisPressedMouseMove.price)return;const t=this.ts.Of().Ut(),i=this.ts.tp(),s=this.Vi;this.Pf&&(this.Pf=!1,t.Wo(i,s))}jf(t){if(null===this.Vi||!this.cs.handleScale.axisPressedMouseMove.price)return;const i=this.ts.Of().Ut(),s=this.ts.tp();this.Pf=!1,i.Wo(s,this.Vi)}$f(t){this.cs.handleScale.axisDoubleClickReset.price&&this.Fe()}Hf(t){if(null===this.Vi)return;!this.ts.Of().Ut().F().handleScale.axisPressedMouseMove.price||this.Vi.th()||this.Vi.Na()||this.op(1)}Uf(t){this.op(0)}Gf(){const t=[],i=null===this.Vi?void 0:this.Vi;return(s=>{for(let n=0;n<s.length;++n){const e=s[n].Ds(this.ts.tp(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.ts.tp().Ja()),t}np({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ts.tp().Ut(),r=e.U(),h=e.Ic();r===h?F(t,0,0,s,n,r):H(t,0,0,s,n,r,h)}ye({context:t,bitmapSize:i,horizontalPixelRatio:s}){if(null===this.Tf||null===this.Vi||!this.Vi.F().borderVisible)return;t.fillStyle=this.Vi.F().borderColor;const n=Math.max(1,Math.floor(this.Xf().k*s));let e;e=this.If?i.width-n:0,t.fillRect(e,0,n,i.height)}ep(t){if(null===this.Tf||null===this.Vi)return;const i=this.Vi.Jl(),s=this.Vi.F(),n=this.Xf(),e=this.If?this.Tf.width-n.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=s.borderColor;const l=Math.max(1,Math.floor(h)),a=Math.floor(.5*h),o=Math.round(n.C*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.Yl*h)-a,o,l);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{var r;t.font=this.Kf(),t.fillStyle=null!==(r=s.textColor)&&void 0!==r?r:this.Ba.textColor,t.textAlign=this.If?"right":"left",t.textBaseline="middle";const h=this.If?Math.round(e-n.O):Math.round(e+n.C+n.O),l=i.map((i=>this.Rf.Mi(t,i.ua)));for(let s=i.length;s--;){const n=i[s];t.fillText(n.ua,h,n.Yl+l[s])}}))}sp(){if(null===this.Tf||null===this.Vi)return;let t=this.Tf.height/2;const i=[],s=this.Vi.Ja().slice(),n=this.ts.tp(),e=this.Xf();this.Vi===n.Je()&&this.ts.tp().Ja().forEach((t=>{n.Ge(t)&&s.push(t)}));const r=this.Vi.jl()[0],h=this.Vi;s.forEach((s=>{const e=s.Ds(n,h);e.forEach((t=>{t.Ai(null),t.Oi()&&i.push(t)})),r===s&&e.length>0&&(t=e[0].yi())})),i.forEach((t=>t.Ai(t.yi())));this.Vi.F().alignLabels&&this._p(i,e,t)}_p(t,i,s){if(null===this.Tf)return;const n=t.filter((t=>t.yi()<=s)),e=t.filter((t=>t.yi()>s));n.sort(((t,i)=>i.yi()-t.yi())),n.length&&e.length&&e.push(n[0]),e.sort(((t,i)=>t.yi()-i.yi()));for(const s of t){const t=Math.floor(s.It(i)/2),n=s.yi();n>-t&&n<t&&s.Ai(t),n>this.Tf.height-t&&n<this.Tf.height+t&&s.Ai(this.Tf.height-t)}for(let t=1;t<n.length;t++){const s=n[t],e=n[t-1],r=e.It(i,!1),h=s.yi(),l=e.Bi();h>l-r&&s.Ai(l-r)}for(let t=1;t<e.length;t++){const s=e[t],n=e[t-1],r=n.It(i,!0),h=s.yi(),l=n.Bi();h<l+r&&s.Ai(l+r)}}rp(t){if(null===this.Tf)return;const i=this.Gf(),s=this.Xf(),n=this.If?"right":"left";i.forEach((i=>{if(i.Li()){i.Mt(l(this.Vi)).X(t,s,this.Rf,n)}}))}hp(t){if(null===this.Tf||null===this.Vi)return;const i=this.ts.Of().Ut(),s=[],n=this.ts.tp(),e=i.dc().Ds(n,this.Vi);e.length&&s.push(e);const r=this.Xf(),h=this.If?"right":"left";s.forEach((i=>{i.forEach((i=>{i.Mt(l(this.Vi)).X(t,r,this.Rf,h)}))}))}op(t){this.Ef.style.cursor=1===t?"ns-resize":"default"}xa(){const t=this.Zf();this.Df<t&&this.ts.Of().Ut().dl(),this.Df=t}Kf(){return P(this.Ba.fontSize,this.Ba.fontFamily)}}function zs(t,i,s,n){t.K&&t.K(i,s,n)}function Ns(t,i,s,n){t.X(i,s,n)}function Fs(t,i){return t.Rs(i)}function Ws(t,i){return t.Ji(i)}function js(t,i){return void 0!==t.kl?t.kl(i):[]}class $s{constructor(t,i){this.Tf=s.size({width:0,height:0}),this.up=null,this.cp=null,this.dp=null,this.fp=!1,this.pp=new b,this.vp=0,this.mp=!1,this.bp=null,this.gp=!1,this.wp=null,this.Mp=null,this.Bf=!1,this.Af=()=>{this.Bf||null===this.xp||this.Hi().Ch()},this.Lf=()=>{this.Bf||null===this.xp||this.Hi().Ch()},this.Sp=t,this.xp=i,this.xp.Zo().l(this.yp.bind(this),this,!0),this.kp=document.createElement("td"),this.kp.style.padding="0",this.kp.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.Cp=document.createElement("td"),this.Cp.style.padding="0",this.Tp=document.createElement("td"),this.Tp.style.padding="0",this.kp.appendChild(n),this.Vf=Rs(n,s.size({width:16,height:16})),this.Vf.subscribeSuggestedBitmapSizeChanged(this.Af);const e=this.Vf.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.zf=Rs(n,s.size({width:16,height:16})),this.zf.subscribeSuggestedBitmapSizeChanged(this.Lf);const r=this.zf.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this.Pp=document.createElement("tr"),this.Pp.appendChild(this.Cp),this.Pp.appendChild(this.kp),this.Pp.appendChild(this.Tp),this.Rp(),this.qf=new Bs(this.zf.canvasElement,this,{Zd:()=>null===this.bp&&!this.Sp.F().handleScroll.vertTouchDrag,Kd:()=>null===this.bp&&!this.Sp.F().handleScroll.horzTouchDrag})}M(){null!==this.up&&this.up.M(),null!==this.cp&&this.cp.M(),this.zf.unsubscribeSuggestedBitmapSizeChanged(this.Lf),this.zf.dispose(),this.Vf.unsubscribeSuggestedBitmapSizeChanged(this.Af),this.Vf.dispose(),null!==this.xp&&this.xp.Zo().v(this),this.qf.M()}tp(){return l(this.xp)}Dp(t){null!==this.xp&&this.xp.Zo().v(this),this.xp=t,null!==this.xp&&this.xp.Zo().l($s.prototype.yp.bind(this),this,!0),this.Rp()}Of(){return this.Sp}Yf(){return this.Pp}Rp(){if(null!==this.xp&&(this.Bp(),0!==this.Hi().wt().length)){if(null!==this.up){const t=this.xp.Vo();this.up.Gi(l(t))}if(null!==this.cp){const t=this.xp.zo();this.cp.Gi(l(t))}}}Ap(){null!==this.up&&this.up.gt(),null!==this.cp&&this.cp.gt()}Ro(){return null!==this.xp?this.xp.Ro():0}Do(t){this.xp&&this.xp.Do(t)}Hd(t){if(!this.xp)return;this.Op();const i=t.localX,s=t.localY;this.Lp(i,s,t)}_f(t){this.Op(),this.Ip(),this.Lp(t.localX,t.localY,t)}Ud(t){if(!this.xp)return;this.Op();const i=t.localX,s=t.localY;this.Lp(i,s,t);const n=this.ir(i,s);this.Hi().lc(n&&{ac:n.ac,Ep:n.Ep})}ef(t){null!==this.xp&&(this.Op(),this.Vp(t))}Qd(t){this.Op(),this.zp(t),this.Lp(t.localX,t.localY,t)}nf(t){null!==this.xp&&(this.Op(),this.mp=!1,this.Np(t))}sf(t){null!==this.xp&&this.Vp(t)}Mf(t){if(this.mp=!0,null===this.bp){const i={x:t.localX,y:t.localY};this.Fp(i,i,t)}}wf(t){null!==this.xp&&(this.Op(),this.xp.Ut().lc(null),this.Wp())}jp(){return this.pp}ff(){this.vp=1,this.Hi().qs()}pf(t,i){if(!this.Sp.F().handleScale.pinch)return;const s=5*(i-this.vp);this.vp=i,this.Hi().gc(t.nt,s)}lf(t){if(this.mp=!1,this.gp=null!==this.bp,this.Ip(),null!==this.bp){const i=this.Hi().dc();this.wp={x:i.Xt(),y:i.Zt()},this.bp={x:t.localX,y:t.localY}}}Gd(t){if(null===this.xp)return;const i=t.localX,s=t.localY;if(null===this.bp)this.zp(t);else{this.gp=!1;const n=l(this.wp),e=n.x+(i-this.bp.x),r=n.y+(s-this.bp.y);this.Lp(e,r,t)}}if(t){0===this.Of().F().trackingMode.exitMode&&(this.gp=!0),this.$p(),this.Np(t)}ir(t,i){const s=this.xp;if(null===s)return null;const n=s.Ja();for(const e of n){const n=this.Hp(e.Rs(s),t,i);if(null!==n)return{ac:e,kf:n.kf,Ep:n.Ep}}return null}Up(t,i){l("left"===i?this.up:this.cp).Jf(s.size({width:t,height:this.Tf.height}))}qp(){return this.Tf}Jf(t){s.equalSizes(this.Tf,t)||(this.Tf=t,this.Bf=!0,this.Vf.resizeCanvasElement(t),this.zf.resizeCanvasElement(t),this.Bf=!1,this.kp.style.width=t.width+"px",this.kp.style.height=t.height+"px")}Yp(){const t=l(this.xp);t.Eo(t.Vo()),t.Eo(t.zo());for(const i of t.jl())if(t.Ge(i)){const s=i.Bt();null!==s&&t.Eo(s),i.As()}}lp(){return this.Vf.bitmapSize}ap(t,i,s){const n=this.lp();n.width>0&&n.height>0&&t.drawImage(this.Vf.canvasElement,i,s)}ip(t){if(0===t)return;if(null===this.xp)return;if(t>1&&this.Yp(),null!==this.up&&this.up.ip(t),null!==this.cp&&this.cp.ip(t),1!==t){this.Vf.applySuggestedBitmapSize();const t=s.tryCreateCanvasRenderingTarget2D(this.Vf);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.np(t)})),this.xp&&(this.Xp(t),this.Zp(t),this.Kp(t,Fs),this.Kp(t,Ws)))}this.zf.applySuggestedBitmapSize();const i=s.tryCreateCanvasRenderingTarget2D(this.zf);null!==i&&(i.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Kp(i,js),this.Gp(i))}Jp(){return this.up}Qp(){return this.cp}yp(){null!==this.xp&&this.xp.Zo().v(this),this.xp=null}Vp(t){const i=t.localX,s=t.localY;this.pp.g()&&this.pp.m(this.Hi().yt().ru(i),{x:i,y:s},t)}np({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.Hi(),r=e.U(),h=e.Ic();r===h?F(t,0,0,s,n,h):H(t,0,0,s,n,r,h)}Xp(t){const i=l(this.xp).Ko().Th().Mt();null!==i&&i.X(t,!1)}Zp(t){const i=this.Hi().cc();this.tv(t,Fs,zs,i),this.tv(t,Fs,Ns,i)}Gp(t){this.tv(t,Fs,Ns,this.Hi().dc())}Kp(t,i){const s=l(this.xp).Ja();for(const n of s)this.tv(t,i,zs,n);for(const n of s)this.tv(t,i,Ns,n)}tv(t,i,s,n){const e=l(this.xp),r=i(n,e),h=e.Ut().hc(),a=null!==h&&h.ac===n,o=null!==h&&a&&void 0!==h.Ep?h.Ep.nr:void 0;for(const i of r){const n=i.Mt();null!==n&&s(n,t,a,o)}}Hp(t,i,s){for(const n of t){const t=n.Mt();if(null!==t&&t.ir){const e=t.ir(i,s);if(null!==e)return{kf:n,Ep:e}}}return null}Bp(){if(null===this.xp)return;const t=this.Sp,i=this.xp.Vo().F().visible,s=this.xp.zo().F().visible;i||null===this.up||(this.Cp.removeChild(this.up.Yf()),this.up.M(),this.up=null),s||null===this.cp||(this.Tp.removeChild(this.cp.Yf()),this.cp.M(),this.cp=null);const n=t.Ut().Rc();i&&null===this.up&&(this.up=new Vs(this,t.F(),n,"left"),this.Cp.appendChild(this.up.Yf())),s&&null===this.cp&&(this.cp=new Vs(this,t.F(),n,"right"),this.Tp.appendChild(this.cp.Yf()))}iv(t){return t.xf&&this.mp||null!==this.bp}sv(t){return Math.max(0,Math.min(t,this.Tf.width-1))}nv(t){return Math.max(0,Math.min(t,this.Tf.height-1))}Lp(t,i,s){this.Hi().Cc(this.sv(t),this.nv(i),s,l(this.xp))}Wp(){this.Hi().Tc()}$p(){this.gp&&(this.bp=null,this.Wp())}Fp(t,i,s){this.bp=t,this.gp=!1,this.Lp(i.x,i.y,s);const n=this.Hi().dc();this.wp={x:n.Xt(),y:n.Zt()}}Hi(){return this.Sp.Ut()}Np(t){if(!this.fp)return;const i=this.Hi(),s=this.tp();if(i.Ho(s,s.ps()),this.dp=null,this.fp=!1,i.Sc(),null!==this.Mp){const t=performance.now(),s=i.yt();this.Mp.pr(s.ou(),t),this.Mp.wu(t)||i.Zs(this.Mp)}}Op(){this.bp=null}Ip(){if(!this.xp)return;if(this.Hi().qs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)l(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.xp.ps().Ni()&&this.Hi().yt().Ni()}zp(t){if(null===this.xp)return;const i=this.Hi(),s=i.yt();if(s.Ni())return;const n=this.Sp.F(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t.xf)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.xf))return;const h=this.xp.ps(),l=performance.now();if(null!==this.dp||this.iv(t)||(this.dp={x:t.clientX,y:t.clientY,u_:l,ev:t.localX,rv:t.localY}),null!==this.dp&&!this.fp&&(this.dp.x!==t.clientX||this.dp.y!==t.clientY)){if(t.xf&&r.touch||!t.xf&&r.mouse){const t=s.Kn();this.Mp=new Ps(.2/t,7/t,.997,15/t),this.Mp.Xc(s.ou(),this.dp.u_)}else this.Mp=null;h.Ni()||i.jo(this.xp,h,t.localY),i.Mc(t.localX),this.fp=!0}this.fp&&(h.Ni()||i.$o(this.xp,h,t.localY),i.xc(t.localX),null!==this.Mp&&this.Mp.Xc(s.ou(),l))}}class Hs{constructor(t,i,n,e,r){this.vt=!0,this.Tf=s.size({width:0,height:0}),this.Af=()=>this.ip(3),this.If="left"===t,this.Gu=n.Rc,this.cs=i,this.hv=e,this.lv=r,this.Ef=document.createElement("div"),this.Ef.style.width="25px",this.Ef.style.height="100%",this.Ef.style.overflow="hidden",this.Vf=Rs(this.Ef,s.size({width:16,height:16})),this.Vf.subscribeSuggestedBitmapSizeChanged(this.Af)}M(){this.Vf.unsubscribeSuggestedBitmapSizeChanged(this.Af),this.Vf.dispose()}Yf(){return this.Ef}qp(){return this.Tf}Jf(t){s.equalSizes(this.Tf,t)||(this.Tf=t,this.Vf.resizeCanvasElement(t),this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`,this.vt=!0)}ip(t){if(t<3&&!this.vt)return;if(0===this.Tf.width||0===this.Tf.height)return;this.vt=!1,this.Vf.applySuggestedBitmapSize();const i=s.tryCreateCanvasRenderingTarget2D(this.Vf);null!==i&&i.useBitmapCoordinateSpace((t=>{this.np(t),this.ye(t)}))}lp(){return this.Vf.bitmapSize}ap(t,i,s){const n=this.lp();n.width>0&&n.height>0&&t.drawImage(this.Vf.canvasElement,i,s)}ye({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.hv())return;t.fillStyle=this.cs.timeScale.borderColor;const e=Math.floor(this.Gu.F().k*s),r=Math.floor(this.Gu.F().k*n),h=this.If?i.width-e:0;t.fillRect(h,0,e,r)}np({context:t,bitmapSize:i}){F(t,0,0,i.width,i.height,this.lv())}}function Us(t,i){return t.w_>i.w_?t:i}class qs{constructor(t){this.av=null,this.ov=null,this.S=null,this._v=!1,this.Tf=s.size({width:0,height:0}),this.uv=new b,this.Rf=new jt(5),this.Bf=!1,this.Af=()=>{this.Bf||this.Sp.Ut().Ch()},this.Lf=()=>{this.Bf||this.Sp.Ut().Ch()},this.Sp=t,this.cs=t.F().layout,this.cv=document.createElement("tr"),this.dv=document.createElement("td"),this.dv.style.padding="0",this.fv=document.createElement("td"),this.fv.style.padding="0",this.Ef=document.createElement("td"),this.Ef.style.height="25px",this.Ef.style.padding="0",this.pv=document.createElement("div"),this.pv.style.width="100%",this.pv.style.height="100%",this.pv.style.position="relative",this.pv.style.overflow="hidden",this.Ef.appendChild(this.pv),this.Vf=Rs(this.pv,s.size({width:16,height:16})),this.Vf.subscribeSuggestedBitmapSizeChanged(this.Af);const i=this.Vf.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.zf=Rs(this.pv,s.size({width:16,height:16})),this.zf.subscribeSuggestedBitmapSizeChanged(this.Lf);const n=this.zf.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.cv.appendChild(this.dv),this.cv.appendChild(this.Ef),this.cv.appendChild(this.fv),this.vv(),this.Sp.Ut().Po().l(this.vv.bind(this),this),this.qf=new Bs(this.zf.canvasElement,this,{Zd:()=>!0,Kd:()=>!1})}M(){this.qf.M(),null!==this.av&&this.av.M(),null!==this.ov&&this.ov.M(),this.zf.unsubscribeSuggestedBitmapSizeChanged(this.Lf),this.zf.dispose(),this.Vf.unsubscribeSuggestedBitmapSizeChanged(this.Af),this.Vf.dispose()}Yf(){return this.cv}mv(){return this.av}bv(){return this.ov}_f(t){if(this._v)return;this._v=!0;const i=this.Sp.Ut();!i.yt().Ni()&&this.Sp.F().handleScale.axisPressedMouseMove.time&&i.bc(t.localX)}lf(t){this._f(t)}uf(){const t=this.Sp.Ut();!t.yt().Ni()&&this._v&&(this._v=!1,this.Sp.F().handleScale.axisPressedMouseMove.time&&t.kc())}Qd(t){const i=this.Sp.Ut();!i.yt().Ni()&&this.Sp.F().handleScale.axisPressedMouseMove.time&&i.yc(t.localX)}Gd(t){this.Qd(t)}nf(){this._v=!1;const t=this.Sp.Ut();t.yt().Ni()&&!this.Sp.F().handleScale.axisPressedMouseMove.time||t.kc()}if(){this.nf()}Vd(){this.Sp.F().handleScale.axisDoubleClickReset.time&&this.Sp.Ut().Gs()}Od(){this.Vd()}Hd(){this.Sp.Ut().F().handleScale.axisPressedMouseMove.time&&this.op(1)}wf(){this.op(0)}qp(){return this.Tf}gv(){return this.uv}wv(t,i,n){s.equalSizes(this.Tf,t)||(this.Tf=t,this.Bf=!0,this.Vf.resizeCanvasElement(t),this.zf.resizeCanvasElement(t),this.Bf=!1,this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`,this.uv.m(t)),null!==this.av&&this.av.Jf(s.size({width:i,height:t.height})),null!==this.ov&&this.ov.Jf(s.size({width:n,height:t.height}))}Mv(){const t=this.xv();return Math.ceil(t.k+t.C+t.T+t.I+t.A+t.Sv)}gt(){this.Sp.Ut().yt().Jl()}lp(){return this.Vf.bitmapSize}ap(t,i,s){const n=this.lp();n.width>0&&n.height>0&&t.drawImage(this.Vf.canvasElement,i,s)}ip(t){if(0===t)return;if(1!==t){this.Vf.applySuggestedBitmapSize();const i=s.tryCreateCanvasRenderingTarget2D(this.Vf);null!==i&&(i.useBitmapCoordinateSpace((t=>{this.np(t),this.ye(t)})),this.ep(i)),null!==this.av&&this.av.ip(t),null!==this.ov&&this.ov.ip(t)}this.zf.applySuggestedBitmapSize();const i=s.tryCreateCanvasRenderingTarget2D(this.zf);null!==i&&(i.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.yv([this.Sp.Ut().dc()],i))}np({context:t,bitmapSize:i}){F(t,0,0,i.width,i.height,this.Sp.Ut().Ic())}ye({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.Sp.F().timeScale.borderVisible){t.fillStyle=this.kv();const n=Math.max(1,Math.floor(this.xv().k*s));t.fillRect(0,0,i.width,n)}}ep(t){const i=this.Sp.Ut().yt(),s=i.Jl();if(!s||0===s.length)return;let n=s.reduce(Us,s[0]).w_;n>30&&n<50&&(n=30);const e=this.xv(),r=i.F();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.kv(),t.fillStyle=this.kv();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const l=Math.round(e.C*n);for(let n=s.length;n--;){const e=Math.round(s[n].Yl*i);t.rect(e-h,0,r,l)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.k+e.C+e.I+e.T/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.$(),t.font=this.Kf();for(const e of s)if(e.w_<n){const s=e.cu?this.Cv(t,e.Yl,e.ua):e.Yl;t.fillText(e.ua,s,i)}t.font=this.Tv();for(const e of s)if(e.w_>=n){const s=e.cu?this.Cv(t,e.Yl,e.ua):e.Yl;t.fillText(e.ua,s,i)}}))}Cv(t,i,s){const n=this.Rf.xi(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.Tf.width&&(i-=Math.abs(this.Tf.width-(r+n))),i}yv(t,i){const s=this.xv();for(const n of t)for(const t of n.Qi())t.Mt().X(i,s)}kv(){return this.Sp.F().timeScale.borderColor}$(){return this.cs.textColor}W(){return this.cs.fontSize}Kf(){return P(this.W(),this.cs.fontFamily)}Tv(){return P(this.W(),this.cs.fontFamily,"bold")}xv(){null===this.S&&(this.S={k:1,V:NaN,I:NaN,A:NaN,ji:NaN,C:5,T:NaN,P:"",Wi:new jt,Sv:0});const t=this.S,i=this.Kf();if(t.P!==i){const s=this.W();t.T=s,t.P=i,t.I=3*s/12,t.A=3*s/12,t.ji=9*s/12,t.V=0,t.Sv=4*s/12,t.Wi.Fe()}return this.S}op(t){this.Ef.style.cursor=1===t?"ew-resize":"default"}vv(){const t=this.Sp.Ut(),i=t.F();i.leftPriceScale.visible||null===this.av||(this.dv.removeChild(this.av.Yf()),this.av.M(),this.av=null),i.rightPriceScale.visible||null===this.ov||(this.fv.removeChild(this.ov.Yf()),this.ov.M(),this.ov=null);const s={Rc:this.Sp.Ut().Rc()},n=()=>i.leftPriceScale.borderVisible&&t.yt().F().borderVisible,e=()=>t.Ic();i.leftPriceScale.visible&&null===this.av&&(this.av=new Hs("left",i,s,n,e),this.dv.appendChild(this.av.Yf())),i.rightPriceScale.visible&&null===this.ov&&(this.ov=new Hs("right",i,s,n,e),this.fv.appendChild(this.ov.Yf()))}}const Ys=!!xs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!xs&&((null===(Xs=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===Xs?void 0:Xs.platform)?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);var Xs;class Zs{constructor(t,i){var s;this.Pv=[],this.Rv=0,this.fa=0,this.vo=0,this.Dv=0,this.Bv=0,this.Av=null,this.Ov=!1,this.pp=new b,this.Xu=new b,this.Lv=null,this.Iv=t,this.cs=i,this.cv=document.createElement("div"),this.cv.classList.add("tv-lightweight-charts"),this.cv.style.overflow="hidden",this.cv.style.width="100%",this.cv.style.height="100%",(s=this.cv).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.Ev=document.createElement("table"),this.Ev.setAttribute("cellspacing","0"),this.cv.appendChild(this.Ev),this.Vv=this.zv.bind(this),Ks(this.cs)&&this.Nv(!0),this.Hi=new gs(this.Ku.bind(this),this.cs),this.Ut().fc().l(this.Fv.bind(this),this),this.Wv=new qs(this),this.Ev.appendChild(this.Wv.Yf());const n=i.autoSize&&this.jv();let e=this.cs.width,r=this.cs.height;if(n||0===e||0===r){const i=t.getBoundingClientRect();e=e||i.width,r=r||i.height}this.$v(e,r),this.Hv(),t.appendChild(this.cv),this.Uv(),this.Hi.yt().yu().l(this.Hi.dl.bind(this.Hi),this),this.Hi.Po().l(this.Hi.dl.bind(this.Hi),this)}Ut(){return this.Hi}F(){return this.cs}qv(){return this.Pv}Yv(){return this.Wv}M(){this.Nv(!1),0!==this.Rv&&window.cancelAnimationFrame(this.Rv),this.Hi.fc().v(this),this.Hi.yt().yu().v(this),this.Hi.Po().v(this),this.Hi.M();for(const t of this.Pv)this.Ev.removeChild(t.Yf()),t.jp().v(this),t.M();this.Pv=[],l(this.Wv).M(),null!==this.cv.parentElement&&this.cv.parentElement.removeChild(this.cv),this.Xu.M(),this.pp.M(),this.Xv()}$v(t,i,n=!1){if(this.fa===i&&this.vo===t)return;const e=function(t){const i=Math.floor(t.width),n=Math.floor(t.height),e=i-i%2,r=n-n%2;return s.size({width:e,height:r})}(s.size({width:t,height:i}));this.fa=e.height,this.vo=e.width;const r=this.fa+"px",h=this.vo+"px";l(this.cv).style.height=r,l(this.cv).style.width=h,this.Ev.style.height=r,this.Ev.style.width=h,n?this.Zv(it.rn(),performance.now()):this.Hi.dl()}ip(t){void 0===t&&(t=it.rn());for(let i=0;i<this.Pv.length;i++)this.Pv[i].ip(t.Hs(i).Ws);this.cs.timeScale.visible&&this.Wv.ip(t.$s())}kh(t){const i=Ks(this.cs);this.Hi.kh(t);const s=Ks(this.cs);s!==i&&this.Nv(s),this.Uv(),this.Kv(t)}jp(){return this.pp}fc(){return this.Xu}Gv(){null!==this.Av&&(this.Zv(this.Av,performance.now()),this.Av=null);const t=this.Jv(null),i=document.createElement("canvas");i.width=t.width,i.height=t.height;const s=l(i.getContext("2d"));return this.Jv(s),i}Qv(t){if("left"===t&&!this.tm())return 0;if("right"===t&&!this.im())return 0;if(0===this.Pv.length)return 0;return l("left"===t?this.Pv[0].Jp():this.Pv[0].Qp()).Qf()}sm(){return this.cs.autoSize&&null!==this.Lv}Kv(t){(void 0!==t.autoSize||!this.Lv||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.Lv&&this.jv(),!1===t.autoSize&&null!==this.Lv&&this.Xv(),t.autoSize||void 0===t.width&&void 0===t.height||this.$v(t.width||this.vo,t.height||this.fa))}Jv(t){let i=0,n=0;const e=this.Pv[0],r=(i,s)=>{let n=0;for(let e=0;e<this.Pv.length;e++){const r=this.Pv[e],h=l("left"===i?r.Jp():r.Qp()),a=h.lp();null!==t&&h.ap(t,s,n),n+=a.height}};if(this.tm()){r("left",0);i+=l(e.Jp()).lp().width}for(let s=0;s<this.Pv.length;s++){const e=this.Pv[s],r=e.lp();null!==t&&e.ap(t,i,n),n+=r.height}if(i+=e.lp().width,this.im()){r("right",i);i+=l(e.Qp()).lp().width}const h=(i,s,n)=>{l("left"===i?this.Wv.mv():this.Wv.bv()).ap(l(t),s,n)};if(this.cs.timeScale.visible){const i=this.Wv.lp();if(null!==t){let s=0;this.tm()&&(h("left",s,n),s=l(e.Jp()).lp().width),this.Wv.ap(t,s,n),s+=i.width,this.im()&&h("right",s,n)}n+=i.height}return s.size({width:i,height:n})}nm(){let t=0,i=0,n=0;for(const s of this.Pv)this.tm()&&(i=Math.max(i,l(s.Jp()).Zf())),this.im()&&(n=Math.max(n,l(s.Qp()).Zf())),t+=s.Ro();i=ks(i),n=ks(n);const e=this.vo,r=this.fa,h=Math.max(e-i-n,0),a=this.cs.timeScale.visible;let o=a?this.Wv.Mv():0;var _;o=(_=o)+_%2;const u=0+o,c=r<u?0:r-u,d=c/t;let f=0;for(let t=0;t<this.Pv.length;++t){const e=this.Pv[t];e.Dp(this.Hi.uc()[t]);let r=0,l=0;l=t===this.Pv.length-1?c-f:Math.round(e.Ro()*d),r=Math.max(l,2),f+=r,e.Jf(s.size({width:h,height:r})),this.tm()&&e.Up(i,"left"),this.im()&&e.Up(n,"right"),e.tp()&&this.Hi.vc(e.tp(),r)}this.Wv.wv(s.size({width:a?h:0,height:o}),a?i:0,a?n:0),this.Hi.Bo(h),this.Dv!==i&&(this.Dv=i),this.Bv!==n&&(this.Bv=n)}Nv(t){t?this.cv.addEventListener("wheel",this.Vv,{passive:!1}):this.cv.removeEventListener("wheel",this.Vv)}rm(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Ys?1/window.devicePixelRatio:1}zv(t){if(!(0!==t.deltaX&&this.cs.handleScroll.mouseWheel||0!==t.deltaY&&this.cs.handleScale.mouseWheel))return;const i=this.rm(t),s=i*t.deltaX/100,n=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==n&&this.cs.handleScale.mouseWheel){const i=Math.sign(n)*Math.min(1,Math.abs(n)),s=t.clientX-this.cv.getBoundingClientRect().left;this.Ut().gc(s,i)}0!==s&&this.cs.handleScroll.mouseWheel&&this.Ut().wc(-80*s)}Zv(t,i){var s;const n=t.$s();3===n&&this.hm(),3!==n&&2!==n||(this.lm(t),this.am(t,i),this.Wv.gt(),this.Pv.forEach((t=>{t.Ap()})),3===(null===(s=this.Av)||void 0===s?void 0:s.$s())&&(this.Av.sn(t),this.hm(),this.lm(this.Av),this.am(this.Av,i),t=this.Av,this.Av=null)),this.ip(t)}am(t,i){for(const s of t.tn())this.nn(s,i)}lm(t){const i=this.Hi.uc();for(let s=0;s<i.length;s++)t.Hs(s).js&&i[s].Yo()}nn(t,i){const s=this.Hi.yt();switch(t.Ys){case 0:s.Cu();break;case 1:s.Tu(t.At);break;case 2:s.Js(t.At);break;case 3:s.Qs(t.At);break;case 4:s.du();break;case 5:t.At.wu(i)||s.Qs(t.At.Mu(i))}}Ku(t){null!==this.Av?this.Av.sn(t):this.Av=t,this.Ov||(this.Ov=!0,this.Rv=window.requestAnimationFrame((t=>{if(this.Ov=!1,this.Rv=0,null!==this.Av){const i=this.Av;this.Av=null,this.Zv(i,t);for(const s of i.tn())if(5===s.Ys&&!s.At.wu(t)){this.Ut().Zs(s.At);break}}})))}hm(){this.Hv()}Hv(){const t=this.Hi.uc(),i=t.length,s=this.Pv.length;for(let t=i;t<s;t++){const t=h(this.Pv.pop());this.Ev.removeChild(t.Yf()),t.jp().v(this),t.M()}for(let n=s;n<i;n++){const i=new $s(this,t[n]);i.jp().l(this.om.bind(this),this),this.Pv.push(i),this.Ev.insertBefore(i.Yf(),this.Wv.Yf())}for(let s=0;s<i;s++){const i=t[s],n=this.Pv[s];n.tp()!==i?n.Dp(i):n.Rp()}this.Uv(),this.nm()}_m(t,i,s){var n;const e=new Map;if(null!==t){this.Hi.wt().forEach((i=>{const s=i.Es().jh(t);null!==s&&e.set(i,s)}))}let r;if(null!==t){const i=null===(n=this.Hi.yt().Ui(t))||void 0===n?void 0:n.M_;void 0!==i&&(r=i)}const h=this.Ut().hc(),l=null!==h&&h.ac instanceof ki?h.ac:void 0,a=null!==h&&void 0!==h.Ep?h.Ep.sr:void 0;return{_t:r,Yn:null!=t?t:void 0,um:null!=i?i:void 0,dm:l,fm:e,pm:a,vm:null!=s?s:void 0}}om(t,i,s){this.pp.m((()=>this._m(t,i,s)))}Fv(t,i,s){this.Xu.m((()=>this._m(t,i,s)))}Uv(){const t=this.cs.timeScale.visible?"":"none";this.Wv.Yf().style.display=t}tm(){return this.Pv[0].tp().Vo().F().visible}im(){return this.Pv[0].tp().zo().F().visible}jv(){return"ResizeObserver"in window&&(this.Lv=new ResizeObserver((t=>{const i=t.find((t=>t.target===this.Iv));i&&this.$v(i.contentRect.width,i.contentRect.height)})),this.Lv.observe(this.Iv,{box:"border-box"}),!0)}Xv(){null!==this.Lv&&this.Lv.disconnect()}}function Ks(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Gs(t,i,s,n){const e=s.value,r={Yn:i,_t:t,At:[e,e,e,e],M_:n};return void 0!==s.color&&(r.D=s.color),r}function Js(t){return void 0!==t.At}function Qs(t){return(i,s,n,e)=>{return void 0===(r=n).open&&void 0===r.value?{_t:i,Yn:s,M_:e}:t(i,s,n,e);var r}}const tn={Candlestick:Qs((function(t,i,s,n){const e={Yn:i,_t:t,At:[s.open,s.high,s.low,s.close],M_:n};return void 0!==s.color&&(e.D=s.color),void 0!==s.borderColor&&(e.Ot=s.borderColor),void 0!==s.wickColor&&(e.Dh=s.wickColor),e})),Bar:Qs((function(t,i,s,n){const e={Yn:i,_t:t,At:[s.open,s.high,s.low,s.close],M_:n};return void 0!==s.color&&(e.D=s.color),e})),Area:Qs((function(t,i,s,n){const e=s.value,r={Yn:i,_t:t,At:[e,e,e,e],M_:n};return void 0!==s.lineColor&&(r.ot=s.lineColor),void 0!==s.topColor&&(r.bn=s.topColor),void 0!==s.bottomColor&&(r.gn=s.bottomColor),r})),Baseline:Qs((function(t,i,s,n){const e=s.value,r={Yn:i,_t:t,At:[e,e,e,e],M_:n};return void 0!==s.topLineColor&&(r.be=s.topLineColor),void 0!==s.bottomLineColor&&(r.ge=s.bottomLineColor),void 0!==s.topFillColor1&&(r.de=s.topFillColor1),void 0!==s.topFillColor2&&(r.fe=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.pe=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.ve=s.bottomFillColor2),r})),Histogram:Qs(Gs),Line:Qs(Gs)};function sn(t){return tn[t]}function nn(t){return 60*t*60*1e3}function en(t){return 60*t*1e3}const rn=[{bm:(hn=1,1e3*hn),w_:10},{bm:en(1),w_:20},{bm:en(5),w_:21},{bm:en(30),w_:22},{bm:nn(1),w_:30},{bm:nn(3),w_:31},{bm:nn(6),w_:32},{bm:nn(12),w_:33}];var hn;function ln(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=rn.length-1;s>=0;--s)if(Math.floor(i.getTime()/rn[s].bm)!==Math.floor(t.getTime()/rn[s].bm))return rn[s].w_;return 0}function an(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1]._t.u_,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*i._t.u_);null!==n&&(i.g_=ln(h,n)),e+=i._t.u_-(s||i._t.u_),s=i._t.u_,n=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0]._t.u_-i));t[0].g_=ln(new Date(1e3*t[0]._t.u_),s)}}function on(t){if(!ws(t))throw new Error("time must be of type BusinessDay");const i=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{u_:Math.round(i.getTime()/1e3),__:t}}function _n(t){if(!Ms(t))throw new Error("time must be of type isUTCTimestamp");return{u_:t}}function un(t){return 0===t.length?null:ws(t[0].time)?on:_n}function cn(t){return Ms(t)?_n(t):ws(t)?on(t):on(dn(t))}function dn(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 fn(t){x(t.time)&&(t.time=dn(t.time))}function pn(t){return{Yn:0,gm:new Map,yl:t}}function vn(t){if(void 0!==t&&0!==t.length)return{wm:t[0]._t.u_,Mm:t[t.length-1]._t.u_}}function mn(t){let i;return t.forEach((t=>{void 0===i&&(i=t.M_)})),h(i)}function bn(t){void 0===t.M_&&(t.M_=t.time)}class gn{constructor(){this.xm=new Map,this.Sm=new Map,this.ym=new Map,this.km=[]}M(){this.xm.clear(),this.Sm.clear(),this.ym.clear(),this.km=[]}Cm(t,i){let s=0!==this.xm.size,n=!1;const e=this.Sm.get(t);if(void 0!==e)if(1===this.Sm.size)s=!1,n=!0,this.xm.clear();else for(const i of this.km)i.pointData.gm.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i;s.forEach((t=>bn(t))),function(t){t.forEach(fn)}(i);const e=l(un(i)),h=sn(t.Lh());r=s.map((i=>{const s=e(i.time);let r=this.xm.get(s.u_);void 0===r&&(r=pn(s),this.xm.set(s.u_,r),n=!0);const l=h(s,r.Yn,i,i.M_);return r.gm.set(t,l),l}))}s&&this.Tm(),this.Pm(t,r);let h=-1;if(n){const t=[];this.xm.forEach((i=>{t.push({g_:0,_t:i.yl,pointData:i,M_:mn(i.gm)})})),t.sort(((t,i)=>t._t.u_-i._t.u_)),h=this.Rm(t)}return this.Dm(t,h,function(t,i){const s=vn(t),n=vn(i);if(void 0!==s&&void 0!==n)return{ml:s.Mm>=n.Mm&&s.wm>=n.wm}}(this.Sm.get(t),e))}Ac(t){return this.Cm(t,[])}Bm(t,i){const s=i;bn(s),fn(i);const n=l(un([i]))(i.time),e=this.ym.get(t);if(void 0!==e&&n.u_<e.u_)throw new Error(`Cannot update oldest data, last time=${e.u_}, new time=${n.u_}`);let r=this.xm.get(n.u_);const h=void 0===r;void 0===r&&(r=pn(n),this.xm.set(n.u_,r));const a=sn(t.Lh())(n,r.Yn,i,s.M_);r.gm.set(t,a),this.Am(t,a);const o={ml:Js(a)};if(!h)return this.Dm(t,-1,o);const _={g_:0,_t:r.yl,pointData:r,M_:mn(r.gm)},u=bt(this.km,_._t.u_,((t,i)=>t._t.u_<i));this.km.splice(u,0,_);for(let t=u;t<this.km.length;++t)wn(this.km[t].pointData,t);return an(this.km,u),this.Dm(t,u,o)}Am(t,i){let s=this.Sm.get(t);void 0===s&&(s=[],this.Sm.set(t,s));const n=0!==s.length?s[s.length-1]:null;null===n||i._t.u_>n._t.u_?Js(i)&&s.push(i):Js(i)?s[s.length-1]=i:s.splice(-1,1),this.ym.set(t,i._t)}Pm(t,i){0!==i.length?(this.Sm.set(t,i.filter(Js)),this.ym.set(t,i[i.length-1]._t)):(this.Sm.delete(t),this.ym.delete(t))}Tm(){for(const t of this.km)0===t.pointData.gm.size&&this.xm.delete(t._t.u_)}Rm(t){let i=-1;for(let s=0;s<this.km.length&&s<t.length;++s){const n=this.km[s],e=t[s];if(n._t.u_!==e._t.u_){i=s;break}e.g_=n.g_,wn(e.pointData,s)}if(-1===i&&this.km.length!==t.length&&(i=Math.min(this.km.length,t.length)),-1===i)return-1;for(let s=i;s<t.length;++s)wn(t[s].pointData,s);return an(t,i),this.km=t,i}Om(){if(0===this.Sm.size)return null;let t=0;return this.Sm.forEach((i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].Yn))})),t}Dm(t,i,s){const n={Lm:new Map,yt:{eu:this.Om()}};if(-1!==i)this.Sm.forEach(((i,e)=>{n.Lm.set(e,{ar:i,Im:e===t?s:void 0})})),this.Sm.has(t)||n.Lm.set(t,{ar:[],Im:s}),n.yt.Em=this.km,n.yt.Vm=i;else{const i=this.Sm.get(t);n.Lm.set(t,{ar:i||[],Im:s})}return n}}function wn(t,i){t.Yn=i,t.gm.forEach((t=>{t.Yn=i}))}function Mn(t){return{value:t.At[3],time:t.M_}}function xn(t){const i=Mn(t);return void 0!==t.D&&(i.color=t.D),i}function Sn(t){return{open:t.At[0],high:t.At[1],low:t.At[2],close:t.At[3],time:t.M_}}const yn={Area:function(t){const i=Mn(t);return void 0!==t.ot&&(i.lineColor=t.ot),void 0!==t.bn&&(i.topColor=t.bn),void 0!==t.gn&&(i.bottomColor=t.gn),i},Line:xn,Baseline:function(t){const i=Mn(t);return void 0!==t.be&&(i.topLineColor=t.be),void 0!==t.ge&&(i.bottomLineColor=t.ge),void 0!==t.de&&(i.topFillColor1=t.de),void 0!==t.fe&&(i.topFillColor2=t.fe),void 0!==t.pe&&(i.bottomFillColor1=t.pe),void 0!==t.ve&&(i.bottomFillColor2=t.ve),i},Histogram:xn,Bar:function(t){const i=Sn(t);return void 0!==t.D&&(i.color=t.D),i},Candlestick:function(t){const i=Sn(t),{D:s,Ot:n,Dh:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}};function kn(t){return yn[t]}const Cn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2}},Tn={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:T,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"},Pn={width:0,height:0,autoSize:!1,layout:{background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:T},crosshair:{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},grid:{vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},overlayPriceScales:Object.assign({},Cn),leftPriceScale:Object.assign(Object.assign({},Cn),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Cn),{visible:!0}),timeScale:{rightOffset:0,barSpacing:6,minBarSpacing:.5,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,ticksVisible:!1},watermark:Tn,localization:{locale:xs?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}},Rn={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},Dn={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},Bn={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0},An={topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0},On={baseValue:{type:"price",price:0},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,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0},Ln={color:"#26a69a",base:0},In={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}};class En{constructor(t,i){this.zm=t,this.Nm=i}applyOptions(t){this.zm.Ut().oc(this.Nm,t)}options(){return this.Vi().F()}width(){return tt(this.Nm)?this.zm.Qv(this.Nm):0}Vi(){return l(this.zm.Ut()._c(this.Nm)).Bt}}const Vn={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class zn{constructor(t){this.wh=t}applyOptions(t){this.wh.kh(t)}options(){return this.wh.F()}Fm(){return this.wh}}class Nn{constructor(t,i,s){this.Tn=t,this.Wm=i,this.jm=s}priceFormatter(){return this.Tn.Bl()}priceToCoordinate(t){const i=this.Tn.Tt();return null===i?null:this.Tn.Bt().Dt(t,i.At)}coordinateToPrice(t){const i=this.Tn.Tt();return null===i?null:this.Tn.Bt().vs(t,i.At)}barsInLogicalRange(t){if(null===t)return null;const i=new os(new hs(t.from,t.to)).C_(),s=this.Tn.Es();if(s.Ni())return null;const n=s.jh(i.Mn(),1),e=s.jh(i.ci(),-1),r=l(s.Nh()),h=l(s.Is());if(null!==n&&null!==e&&n.Yn>e.Yn)return{barsBefore:t.from-r,barsAfter:h-t.to};const a={barsBefore:null===n||n.Yn===r?t.from-r:n.Yn-r,barsAfter:null===e||e.Yn===h?h-t.to:h-e.Yn};return null!==n&&null!==e&&(a.from=n._t.__||n._t.u_,a.to=e._t.__||e._t.u_),a}setData(t){this.Tn.Lh(),this.Wm.$m(this.Tn,t)}update(t){this.Tn.Lh(),this.Wm.Hm(this.Tn,t)}dataByIndex(t,i){const s=this.Tn.Es().jh(t,i);return null===s?null:kn(this.seriesType())(s)}setMarkers(t){const i=t.map((t=>Object.assign(Object.assign({},t),{originalTime:t.time,time:cn(t.time)})));this.Tn.gl(i)}markers(){return this.Tn.wl().map((t=>{const{originalTime:i,time:s}=t,n=function(t,i){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(n=Object.getOwnPropertySymbols(t);e<n.length;e++)i.indexOf(n[e])<0&&Object.prototype.propertyIsEnumerable.call(t,n[e])&&(s[n[e]]=t[n[e]])}return s}(t,["originalTime","time"]);return Object.assign({time:i},n)}))}applyOptions(t){this.Tn.kh(t)}options(){return y(this.Tn.F())}priceScale(){return this.jm.priceScale(this.Tn.Bt().Vl())}createPriceLine(t){const i=g(y(Vn),t),s=this.Tn.Ml(i);return new zn(s)}removePriceLine(t){this.Tn.xl(t.Fm())}seriesType(){return this.Tn.Lh()}}class Fn{constructor(t,i){this.Um=new b,this.E_=new b,this.uv=new b,this.Hi=t,this.wo=t.yt(),this.Wv=i,this.wo.xu().l(this.qm.bind(this)),this.wo.Su().l(this.Ym.bind(this)),this.Wv.gv().l(this.Xm.bind(this))}M(){this.wo.xu().v(this),this.wo.Su().v(this),this.Wv.gv().v(this),this.Um.M(),this.E_.M(),this.uv.M()}scrollPosition(){return this.wo.ou()}scrollToPosition(t,i){i?this.wo.gu(t,1e3):this.Hi.Qs(t)}scrollToRealTime(){this.wo.bu()}getVisibleRange(){var t,i;const s=this.wo.G_();return null===s?null:{from:null!==(t=s.from.__)&&void 0!==t?t:s.from.u_,to:null!==(i=s.to.__)&&void 0!==i?i:s.to.u_}}setVisibleRange(t){const i={from:cn(t.from),to:cn(t.to)},s=this.wo.iu(i);this.Hi.Oc(s)}getVisibleLogicalRange(){const t=this.wo.K_();return null===t?null:{from:t.Mn(),to:t.ci()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.Hi.Oc(t)}resetTimeScale(){this.Hi.Gs()}fitContent(){this.Hi.Cu()}logicalToCoordinate(t){const i=this.Hi.yt();return i.Ni()?null:i.Et(t)}coordinateToLogical(t){return this.wo.Ni()?null:this.wo.ru(t)}timeToCoordinate(t){const i=cn(t),s=this.wo.Fl(i,!1);return null===s?null:this.wo.Et(s)}coordinateToTime(t){var i;const s=this.Hi.yt(),n=s.ru(t),e=s.bs(n);return null===e?null:null!==(i=e.__)&&void 0!==i?i:e.u_}width(){return this.Wv.qp().width}height(){return this.Wv.qp().height}subscribeVisibleTimeRangeChange(t){this.Um.l(t)}unsubscribeVisibleTimeRangeChange(t){this.Um.p(t)}subscribeVisibleLogicalRangeChange(t){this.E_.l(t)}unsubscribeVisibleLogicalRangeChange(t){this.E_.p(t)}subscribeSizeChange(t){this.uv.l(t)}unsubscribeSizeChange(t){this.uv.p(t)}applyOptions(t){this.wo.kh(t)}options(){return y(this.wo.F())}qm(){this.Um.g()&&this.Um.m(this.getVisibleRange())}Ym(){this.E_.g()&&this.E_.m(this.getVisibleLogicalRange())}Xm(t){this.uv.m(t.width,t.height)}}function Wn(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=function(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}(i.minMove))}function jn(t){return function(t){if(S(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;S(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),S(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;S(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class $n{constructor(t,i){this.Zm=new gn,this.Km=new Map,this.Gm=new Map,this.Jm=new b,this.Qm=new b;const s=void 0===i?y(Pn):g(y(Pn),jn(i));this.zm=new Zs(t,s),this.zm.jp().l((t=>{this.Jm.g()&&this.Jm.m(this.tb(t()))}),this),this.zm.fc().l((t=>{this.Qm.g()&&this.Qm.m(this.tb(t()))}),this);const n=this.zm.Ut();this.ib=new Fn(n,this.zm.Yv())}remove(){this.zm.jp().v(this),this.zm.fc().v(this),this.ib.M(),this.zm.M(),this.Km.clear(),this.Gm.clear(),this.Jm.M(),this.Qm.M(),this.Zm.M()}resize(t,i,s){this.autoSizeActive()||this.zm.$v(t,i,s)}addAreaSeries(t){return this.sb("Area",An,t)}addBaselineSeries(t){return this.sb("Baseline",On,t)}addBarSeries(t){return this.sb("Bar",Dn,t)}addCandlestickSeries(t={}){return 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)}(t),this.sb("Candlestick",Rn,t)}addHistogramSeries(t){return this.sb("Histogram",Ln,t)}addLineSeries(t){return this.sb("Line",Bn,t)}removeSeries(t){const i=h(this.Km.get(t)),s=this.Zm.Ac(i);this.zm.Ut().Ac(i),this.nb(s),this.Km.delete(t),this.Gm.delete(i)}$m(t,i){this.nb(this.Zm.Cm(t,i))}Hm(t,i){this.nb(this.Zm.Bm(t,i))}subscribeClick(t){this.Jm.l(t)}unsubscribeClick(t){this.Jm.p(t)}subscribeCrosshairMove(t){this.Qm.l(t)}unsubscribeCrosshairMove(t){this.Qm.p(t)}priceScale(t){return new En(this.zm,t)}timeScale(){return this.ib}applyOptions(t){this.zm.kh(jn(t))}options(){return this.zm.F()}takeScreenshot(){return this.zm.Gv()}autoSizeActive(){return this.zm.sm()}sb(t,i,s={}){Wn(s.priceFormat);const n=g(y(In),y(i),s),e=this.zm.Ut().Dc(t,n),r=new Nn(e,this,this);return this.Km.set(r,e),this.Gm.set(e,r),r}nb(t){const i=this.zm.Ut();i.Pc(t.yt.eu,t.yt.Em,t.yt.Vm),t.Lm.forEach(((t,i)=>i.tt(t.ar,t.Im))),i.lu()}eb(t){return h(this.Gm.get(t))}tb(t){const i=new Map;t.fm.forEach(((t,s)=>{const n=kn(s.Lh())(t);r(function(t){return void 0!==t.open||void 0!==t.value}(n)),i.set(this.eb(s),n)}));const s=void 0===t.dm?void 0:this.eb(t.dm);return{time:t._t,logical:t.Yn,point:t.um,hoveredSeries:s,hoveredObjectId:t.pm,seriesData:i,sourceEvent:t.vm}}}exports.createChart=function(t,i){let s;if(x(t)){const i=document.getElementById(t);r(null!==i,`Cannot find element in DOM with id=${t}`),s=i}else s=t;return new $n(s,i)},exports.isBusinessDay=ws,exports.isUTCTimestamp=Ms,exports.version=function(){return"4.0.1"};