funhi-chart 1.1.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -4,5 +4,5 @@ import t,{useState as e,useEffect as i,useCallback as s,useMemo as n,useRef as r
4
4
  * TradingView Lightweight Charts™ v4.2.3
5
5
  * Copyright (c) 2025 TradingView, Inc.
6
6
  * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
7
- */const f={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},m={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},p={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},g={topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},v={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,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},b={color:"#26a69a",base:0},w={color:"#2196f3"},y={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var S,x,C;function M(t,e){const i={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]}[e];t.setLineDash(i)}function _(t,e,i,s){t.beginPath();const n=t.lineWidth%2?.5:0;t.moveTo(i,e+n),t.lineTo(s,e+n),t.stroke()}function E(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:""))}function z(t){if(void 0===t)throw new Error("Value is undefined");return t}function k(t){if(null===t)throw new Error("Value is null");return t}function R(t){return k(z(t))}(C=S||(S={}))[C.Simple=0]="Simple",C[C.WithSteps=1]="WithSteps",C[C.Curved=2]="Curved",function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(x||(x={}));const L={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(t){return t<0?0:t>255?255:Math.round(t)||0}function N(t){return t<=0||t>1?Math.min(Math.max(t,0),1):Math.round(1e4*t)/1e4}const O=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,$=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,P=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,V=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d*\.?\d+)\s*\)$/;function D(t){(t=t.toLowerCase())in L&&(t=L[t]);{const e=V.exec(t)||P.exec(t);if(e)return[T(parseInt(e[1],10)),T(parseInt(e[2],10)),T(parseInt(e[3],10)),N(e.length<5?1:parseFloat(e[4]))]}{const e=$.exec(t);if(e)return[T(parseInt(e[1],16)),T(parseInt(e[2],16)),T(parseInt(e[3],16)),1]}{const e=O.exec(t);if(e)return[T(17*parseInt(e[1],16)),T(17*parseInt(e[2],16)),T(17*parseInt(e[3],16)),1]}throw new Error(`Cannot parse color: ${t}`)}function B(t){return.199*t[0]+.687*t[1]+.114*t[2]}function F(t){const e=D(t);return{t:`rgb(${e[0]}, ${e[1]}, ${e[2]})`,i:B(e)>160?"black":"white"}}class A{constructor(){this.h=[]}l(t,e,i){const s={o:t,_:e,u:!0===i};this.h.push(s)}v(t){const e=this.h.findIndex(e=>t===e.o);e>-1&&this.h.splice(e,1)}p(t){this.h=this.h.filter(e=>e._!==t)}m(t,e,i){const s=[...this.h];this.h=this.h.filter(t=>!t.u),s.forEach(s=>s.o(t,e,i))}M(){return this.h.length>0}S(){this.h=[]}}function I(t,...e){for(const i of e)for(const e in i)void 0!==i[e]&&Object.prototype.hasOwnProperty.call(i,e)&&!["__proto__","constructor","prototype"].includes(e)&&("object"!=typeof i[e]||void 0===t[e]||Array.isArray(i[e])?t[e]=i[e]:I(t[e],i[e]));return t}function W(t){return"number"==typeof t&&isFinite(t)}function j(t){return"number"==typeof t&&t%1==0}function U(t){return"string"==typeof t}function H(t){return"boolean"==typeof t}function K(t){const e=t;if(!e||"object"!=typeof e)return e;let i,s,n;for(s in i=Array.isArray(e)?[]:{},e)e.hasOwnProperty(s)&&(n=e[s],i[s]=n&&"object"==typeof n?K(n):n);return i}function q(t){return null!==t}function X(t){return null===t?void 0:t}const J="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function G(t,e,i){return void 0===e&&(e=J),`${i=void 0!==i?`${i} `:""}${t}px ${e}`}class Q{constructor(t){this.k={C:1,T:5,P:NaN,R:"",D:"",V:"",O:"",B:0,A:0,I:0,L:0,N:0},this.F=t}W(){const t=this.k,e=this.j(),i=this.H();return t.P===e&&t.D===i||(t.P=e,t.D=i,t.R=G(e,i),t.L=2.5/12*e,t.B=t.L,t.A=e/12*t.T,t.I=e/12*t.T,t.N=0),t.V=this.$(),t.O=this.U(),this.k}$(){return this.F.W().layout.textColor}U(){return this.F.q()}j(){return this.F.W().layout.fontSize}H(){return this.F.W().layout.fontFamily}}class Y{constructor(){this.Y=[]}Z(t){this.Y=t}X(t,e,i){this.Y.forEach(s=>{s.X(t,e,i)})}}class Z{X(t,e,i){t.useBitmapCoordinateSpace(t=>this.K(t,e,i))}}class tt extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.G||null===this.G.tt)return;const s=this.G.tt,n=this.G,r=Math.max(1,Math.floor(e))%2/2,o=o=>{t.beginPath();for(let h=s.to-1;h>=s.from;--h){const s=n.it[h],l=Math.round(s.nt*e)+r,a=s.st*i,c=o*i+r;t.moveTo(l,a),t.arc(l,a,c,0,2*Math.PI)}t.fill()};n.et>0&&(t.fillStyle=n.rt,o(n.ht+n.et)),t.fillStyle=n.lt,o(n.ht)}}function et(){return{it:[{nt:0,st:0,ot:0,_t:0}],lt:"",rt:"",ht:0,et:0,tt:null}}const it={from:0,to:1};class st{constructor(t,e){this.ut=new Y,this.ct=[],this.dt=[],this.ft=!0,this.F=t,this.vt=e,this.ut.Z(this.ct)}bt(t){const e=this.F.wt();e.length!==this.ct.length&&(this.dt=e.map(et),this.ct=this.dt.map(t=>{const e=new tt;return e.J(t),e}),this.ut.Z(this.ct)),this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.ut}Mt(){const t=2===this.vt.W().mode,e=this.F.wt(),i=this.vt.xt(),s=this.F.St();e.forEach((e,n)=>{var r;const o=this.dt[n],h=e.kt(i);if(t||null===h||!e.yt())return void(o.tt=null);const l=k(e.Ct());o.lt=h.Tt,o.ht=h.ht,o.et=h.Pt,o.it[0]._t=h._t,o.it[0].st=e.Dt().Rt(h._t,l.Vt),o.rt=null!==(r=h.Ot)&&void 0!==r?r:this.F.Bt(o.it[0].st/e.Dt().At()),o.it[0].ot=i,o.it[0].nt=s.It(i),o.tt=it})}}class nt extends Z{constructor(t){super(),this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;const n=this.zt.Lt.yt,r=this.zt.Et.yt;if(!n&&!r)return;const o=Math.round(this.zt.nt*i),h=Math.round(this.zt.st*s);t.lineCap="butt",n&&o>=0&&(t.lineWidth=Math.floor(this.zt.Lt.et*i),t.strokeStyle=this.zt.Lt.V,t.fillStyle=this.zt.Lt.V,M(t,this.zt.Lt.Nt),function(t,e,i,s){t.beginPath();const n=t.lineWidth%2?.5:0;t.moveTo(e+n,0),t.lineTo(e+n,s),t.stroke()}(t,o,0,e.height)),r&&h>=0&&(t.lineWidth=Math.floor(this.zt.Et.et*s),t.strokeStyle=this.zt.Et.V,t.fillStyle=this.zt.Et.V,M(t,this.zt.Et.Nt),_(t,h,0,e.width))}}class rt{constructor(t){this.ft=!0,this.Ft={Lt:{et:1,Nt:0,V:"",yt:!1},Et:{et:1,Nt:0,V:"",yt:!1},nt:0,st:0},this.Wt=new nt(this.Ft),this.jt=t}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt}Mt(){const t=this.jt.yt(),e=k(this.jt.Ht()),i=e.$t().W().crosshair,s=this.Ft;if(2===i.mode)return s.Et.yt=!1,void(s.Lt.yt=!1);s.Et.yt=t&&this.jt.Ut(e),s.Lt.yt=t&&this.jt.qt(),s.Et.et=i.horzLine.width,s.Et.Nt=i.horzLine.style,s.Et.V=i.horzLine.color,s.Lt.et=i.vertLine.width,s.Lt.Nt=i.vertLine.style,s.Lt.V=i.vertLine.color,s.nt=this.jt.Yt(),s.st=this.jt.Zt()}}function ot(t,e,i,s,n,r){t.fillRect(e+r,i,s-2*r,r),t.fillRect(e+r,i+n-r,s-2*r,r),t.fillRect(e,i,r,n),t.fillRect(e+s-r,i,r,n)}function ht(t,e,i,s,n,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(e,i,s,n),t.restore()}function lt(t,e,i,s,n,r){t.beginPath(),t.roundRect?t.roundRect(e,i,s,n,r):(t.lineTo(e+s-r[1],i),0!==r[1]&&t.arcTo(e+s,i,e+s,i+r[1],r[1]),t.lineTo(e+s,i+n-r[2]),0!==r[2]&&t.arcTo(e+s,i+n,e+s-r[2],i+n,r[2]),t.lineTo(e+r[3],i+n),0!==r[3]&&t.arcTo(e,i+n,e,i+n-r[3],r[3]),t.lineTo(e,i+r[0]),0!==r[0]&&t.arcTo(e,i,e+r[0],i,r[0]))}function at(t,e,i,s,n,r,o=0,h=[0,0,0,0],l=""){if(t.save(),!o||!l||l===r)return lt(t,e,i,s,n,h),t.fillStyle=r,t.fill(),void t.restore();const a=o/2;var c;lt(t,e+a,i+a,s-o,n-o,(c=-a,h.map(t=>0===t?t:t+c))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=o,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function ct(t,e,i,s,n,r,o){t.save(),t.globalCompositeOperation="copy";const h=t.createLinearGradient(0,0,0,n);h.addColorStop(0,r),h.addColorStop(1,o),t.fillStyle=h,t.fillRect(e,i,s,n),t.restore()}class ut{constructor(t,e){this.J(t,e)}J(t,e){this.zt=t,this.Xt=e}At(t,e){return this.zt.yt?t.P+t.L+t.B:0}X(t,e,i,s){if(!this.zt.yt||0===this.zt.Kt.length)return;const n=this.zt.V,r=this.Xt.t,o=t.useBitmapCoordinateSpace(t=>{const o=t.context;o.font=e.R;const h=this.Gt(t,e,i,s),l=h.Jt;return h.Qt?at(o,l.ti,l.ii,l.ni,l.si,r,l.ei,[l.ht,0,0,l.ht],r):at(o,l.ri,l.ii,l.ni,l.si,r,l.ei,[0,l.ht,l.ht,0],r),this.zt.hi&&(o.fillStyle=n,o.fillRect(l.ri,l.li,l.ai-l.ri,l.oi)),this.zt._i&&(o.fillStyle=e.O,o.fillRect(h.Qt?l.ui-l.ei:0,l.ii,l.ei,l.ci-l.ii)),h});t.useMediaCoordinateSpace(({context:t})=>{const i=o.di;t.font=e.R,t.textAlign=o.Qt?"right":"left",t.textBaseline="middle",t.fillStyle=n,t.fillText(this.zt.Kt,i.fi,(i.ii+i.ci)/2+i.pi)})}Gt(t,e,i,s){var n;const{context:r,bitmapSize:o,mediaSize:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,c=this.zt.hi||!this.zt.mi?e.T:0,u=this.zt.bi?e.C:0,d=e.L+this.Xt.wi,f=e.B+this.Xt.gi,m=e.A,p=e.I,g=this.zt.Kt,v=e.P,b=i.Mi(r,g),w=Math.ceil(i.xi(r,g)),y=v+d+f,S=e.C+m+p+w+c,x=Math.max(1,Math.floor(a));let C=Math.round(y*a);C%2!=x%2&&(C+=1);const M=u>0?Math.max(1,Math.floor(u*l)):0,_=Math.round(S*l),E=Math.round(c*l),z=null!==(n=this.Xt.Si)&&void 0!==n?n:this.Xt.ki,k=Math.round(z*a)-Math.floor(.5*a),R=Math.floor(k+x/2-C/2),L=R+C,T="right"===s,N=T?h.width-u:u,O=T?o.width-M:M;let $,P,V;return T?($=O-_,P=O-E,V=N-c-m-u):($=O+_,P=O+E,V=N+c+m),{Qt:T,Jt:{ii:R,li:k,ci:L,ni:_,si:C,ht:2*l,ei:M,ti:$,ri:O,ai:P,oi:x,ui:o.width},di:{ii:R/a,ci:L/a,fi:V,pi:b}}}}class dt{constructor(t){this.yi={ki:0,t:"#000",gi:0,wi:0},this.Ci={Kt:"",yt:!1,hi:!0,mi:!1,Ot:"",V:"#FFF",_i:!1,bi:!1},this.Ti={Kt:"",yt:!1,hi:!1,mi:!0,Ot:"",V:"#FFF",_i:!0,bi:!0},this.ft=!0,this.Pi=new(t||ut)(this.Ci,this.yi),this.Ri=new(t||ut)(this.Ti,this.yi)}Kt(){return this.Di(),this.Ci.Kt}ki(){return this.Di(),this.yi.ki}bt(){this.ft=!0}At(t,e=!1){return Math.max(this.Pi.At(t,e),this.Ri.At(t,e))}Vi(){return this.yi.Si||0}Oi(t){this.yi.Si=t}Bi(){return this.Di(),this.Ci.yt||this.Ti.yt}Ai(){return this.Di(),this.Ci.yt}gt(t){return this.Di(),this.Ci.hi=this.Ci.hi&&t.W().ticksVisible,this.Ti.hi=this.Ti.hi&&t.W().ticksVisible,this.Pi.J(this.Ci,this.yi),this.Ri.J(this.Ti,this.yi),this.Pi}Ii(){return this.Di(),this.Pi.J(this.Ci,this.yi),this.Ri.J(this.Ti,this.yi),this.Ri}Di(){this.ft&&(this.Ci.hi=!0,this.Ti.hi=!1,this.zi(this.Ci,this.Ti,this.yi))}}class ft extends dt{constructor(t,e,i){super(),this.jt=t,this.Li=e,this.Ei=i}zi(t,e,i){if(t.yt=!1,2===this.jt.W().mode)return;const s=this.jt.W().horzLine;if(!s.labelVisible)return;const n=this.Li.Ct();if(!this.jt.yt()||this.Li.Ni()||null===n)return;const r=F(s.labelBackgroundColor);i.t=r.t,t.V=r.i;const o=2/12*this.Li.P();i.wi=o,i.gi=o;const h=this.Ei(this.Li);i.ki=h.ki,t.Kt=this.Li.Fi(h._t,n),t.yt=!0}}const mt=/[1-9]/g;class pt{constructor(){this.zt=null}J(t){this.zt=t}X(t,e){if(null===this.zt||!1===this.zt.yt||0===this.zt.Kt.length)return;const i=t.useMediaCoordinateSpace(({context:t})=>(t.font=e.R,Math.round(e.Wi.xi(t,k(this.zt).Kt,mt))));if(i<=0)return;const s=e.ji,n=i+2*s,r=n/2,o=this.zt.Hi;let h=this.zt.ki,l=Math.floor(h-r)+.5;l<0?(h+=Math.abs(0-l),l=Math.floor(h-r)+.5):l+n>o&&(h-=Math.abs(o-(l+n)),l=Math.floor(h-r)+.5);const a=l+n,c=Math.ceil(0+e.C+e.T+e.L+e.P+e.B);t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:i,verticalPixelRatio:s})=>{const n=k(this.zt);t.fillStyle=n.t;const r=Math.round(l*i),o=Math.round(0*s),h=Math.round(a*i),u=Math.round(c*s),d=Math.round(2*i);if(t.beginPath(),t.moveTo(r,o),t.lineTo(r,u-d),t.arcTo(r,u,r+d,u,d),t.lineTo(h-d,u),t.arcTo(h,u,h,u-d,d),t.lineTo(h,o),t.fill(),n.hi){const r=Math.round(n.ki*i),h=o,l=Math.round((h+e.T)*s);t.fillStyle=n.V;const a=Math.max(1,Math.floor(i)),c=Math.floor(.5*i);t.fillRect(r-c,h,a,l-h)}}),t.useMediaCoordinateSpace(({context:t})=>{const i=k(this.zt),n=0+e.C+e.T+e.L+e.P/2;t.font=e.R,t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.V;const r=e.Wi.Mi(t,"Apr0");t.translate(l+s,n+r),t.fillText(i.Kt,0,0)})}}class gt{constructor(t,e,i){this.ft=!0,this.Wt=new pt,this.Ft={yt:!1,t:"#4c525e",V:"white",Kt:"",Hi:0,ki:NaN,hi:!0},this.vt=t,this.$i=e,this.Ei=i}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt.J(this.Ft),this.Wt}Mt(){const t=this.Ft;if(t.yt=!1,2===this.vt.W().mode)return;const e=this.vt.W().vertLine;if(!e.labelVisible)return;const i=this.$i.St();if(i.Ni())return;t.Hi=i.Hi();const s=this.Ei();if(null===s)return;t.ki=s.ki;const n=i.Ui(this.vt.xt());t.Kt=i.qi(k(n)),t.yt=!0;const r=F(e.labelBackgroundColor);t.t=r.t,t.V=r.i,t.hi=i.W().ticksVisible}}class vt{constructor(){this.Yi=null,this.Zi=0}Xi(){return this.Zi}Ki(t){this.Zi=t}Dt(){return this.Yi}Gi(t){this.Yi=t}Ji(t){return[]}Qi(){return[]}yt(){return!0}}var bt;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden"}(bt||(bt={}));class wt extends vt{constructor(t,e){super(),this.tn=null,this.nn=NaN,this.sn=0,this.en=!0,this.rn=new Map,this.hn=!1,this.ln=NaN,this.an=NaN,this._n=NaN,this.un=NaN,this.$i=t,this.cn=e,this.dn=new st(t,this),this.fn=((t,e)=>i=>{const s=e(),n=t();if(i===k(this.tn).vn())return{_t:n,ki:s};{const t=k(i.Ct());return{_t:i.pn(s,t),ki:s}}})(()=>this.nn,()=>this.an);const i=((t,e)=>()=>{const i=this.$i.St().mn(t()),s=e();return i&&Number.isFinite(s)?{ot:i,ki:s}:null})(()=>this.sn,()=>this.Yt());this.bn=new gt(this,t,i),this.wn=new rt(this)}W(){return this.cn}gn(t,e){this._n=t,this.un=e}Mn(){this._n=NaN,this.un=NaN}xn(){return this._n}Sn(){return this.un}kn(t,e,i){this.hn||(this.hn=!0),this.en=!0,this.yn(t,e,i)}xt(){return this.sn}Yt(){return this.ln}Zt(){return this.an}yt(){return this.en}Cn(){this.en=!1,this.Tn(),this.nn=NaN,this.ln=NaN,this.an=NaN,this.tn=null,this.Mn()}Pn(t){return null!==this.tn?[this.wn,this.dn]:[]}Ut(t){return t===this.tn&&this.cn.horzLine.visible}qt(){return this.cn.vertLine.visible}Rn(t,e){this.en&&this.tn===t||this.rn.clear();const i=[];return this.tn===t&&i.push(this.Dn(this.rn,e,this.fn)),i}Qi(){return this.en?[this.bn]:[]}Ht(){return this.tn}Vn(){this.wn.bt(),this.rn.forEach(t=>t.bt()),this.bn.bt(),this.dn.bt()}On(t){return t&&!t.vn().Ni()?t.vn():null}yn(t,e,i){this.Bn(t,e,i)&&this.Vn()}Bn(t,e,i){const s=this.ln,n=this.an,r=this.nn,o=this.sn,h=this.tn,l=this.On(i);this.sn=t,this.ln=isNaN(t)?NaN:this.$i.St().It(t),this.tn=i;const a=null!==l?l.Ct():null;return null!==l&&null!==a?(this.nn=e,this.an=l.Rt(e,a)):(this.nn=NaN,this.an=NaN),s!==this.ln||n!==this.an||o!==this.sn||r!==this.nn||h!==this.tn}Tn(){const t=this.$i.wt().map(t=>t.In().An()).filter(q),e=0===t.length?null:Math.max(...t);this.sn=null!==e?e:NaN}Dn(t,e,i){let s=t.get(e);return void 0===s&&(s=new ft(this,e,i),t.set(e,s)),s}}function yt(t){return"left"===t||"right"===t}class St{constructor(t){this.zn=new Map,this.Ln=[],this.En=t}Nn(t,e){const i=function(t,e){return void 0===t?e:{Fn:Math.max(t.Fn,e.Fn),Wn:t.Wn||e.Wn}}(this.zn.get(t),e);this.zn.set(t,i)}jn(){return this.En}Hn(t){const e=this.zn.get(t);return void 0===e?{Fn:this.En}:{Fn:Math.max(this.En,e.Fn),Wn:e.Wn}}$n(){this.Un(),this.Ln=[{qn:0}]}Yn(t){this.Un(),this.Ln=[{qn:1,Vt:t}]}Zn(t){this.Xn(),this.Ln.push({qn:5,Vt:t})}Un(){this.Xn(),this.Ln.push({qn:6})}Kn(){this.Un(),this.Ln=[{qn:4}]}Gn(t){this.Un(),this.Ln.push({qn:2,Vt:t})}Jn(t){this.Un(),this.Ln.push({qn:3,Vt:t})}Qn(){return this.Ln}ts(t){for(const e of t.Ln)this.ns(e);this.En=Math.max(this.En,t.En),t.zn.forEach((t,e)=>{this.Nn(e,t)})}static ss(){return new St(2)}static es(){return new St(3)}ns(t){switch(t.qn){case 0:this.$n();break;case 1:this.Yn(t.Vt);break;case 2:this.Gn(t.Vt);break;case 3:this.Jn(t.Vt);break;case 4:this.Kn();break;case 5:this.Zn(t.Vt);break;case 6:this.Xn()}}Xn(){const t=this.Ln.findIndex(t=>5===t.qn);-1!==t&&this.Ln.splice(t,1)}}function xt(t,e){if(!W(t))return"n/a";if(!j(e))throw new TypeError("invalid length");if(e<0||e>16)throw new TypeError("invalid length");return 0===e?t.toString():("0000000000000000"+t.toString()).slice(-e)}class Ct{constructor(t,e){if(e||(e=1),W(t)&&j(t)||(t=100),t<0)throw new TypeError("invalid base");this.Li=t,this.rs=e,this.hs()}format(t){const e=t<0?"−":"";return t=Math.abs(t),e+this.ls(t)}hs(){if(this._s=0,this.Li>0&&this.rs>0){let t=this.Li;for(;t>1;)t/=10,this._s++}}ls(t){const e=this.Li/this.rs;let i=Math.floor(t),s="";const n=void 0!==this._s?this._s:NaN;if(e>1){let r=+(Math.round(t*e)-i*e).toFixed(this._s);r>=e&&(r-=e,i+=1),s="."+xt(+r.toFixed(this._s)*this.rs,n)}else i=Math.round(i*e)/e,n>0&&(s="."+xt(0,n));return i.toFixed(0)+s}}class Mt extends Ct{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class _t{constructor(t){this.us=t}format(t){let e="";return t<0&&(e="-",t=-t),t<995?e+this.cs(t):t<999995?e+this.cs(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),e+this.cs(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),e+this.cs(t/1e9)+"B")}cs(t){let e;const i=Math.pow(10,this.us);return e=(t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this.us).replace(/\.?0+$/,""):String(t),e.replace(/(\.[1-9]*)0+$/,(t,e)=>e)}}function Et(t,e,i,s,n,r,o){if(0===e.length||s.from>=e.length||s.to<=0)return;const{context:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,c=e[s.from];let u=r(t,c),d=c;if(s.to-s.from<2){const e=n/2;h.beginPath();const i={nt:c.nt-e,st:c.st},s={nt:c.nt+e,st:c.st};h.moveTo(i.nt*l,i.st*a),h.lineTo(s.nt*l,s.st*a),o(t,u,i,s)}else{const n=(e,i)=>{o(t,u,d,i),h.beginPath(),u=e,d=i};let f=d;h.beginPath(),h.moveTo(c.nt*l,c.st*a);for(let o=s.from+1;o<s.to;++o){f=e[o];const s=r(t,f);switch(i){case 0:h.lineTo(f.nt*l,f.st*a);break;case 1:h.lineTo(f.nt*l,e[o-1].st*a),s!==u&&(n(s,f),h.lineTo(f.nt*l,e[o-1].st*a)),h.lineTo(f.nt*l,f.st*a);break;case 2:{const[t,i]=Lt(e,o-1,o);h.bezierCurveTo(t.nt*l,t.st*a,i.nt*l,i.st*a,f.nt*l,f.st*a);break}}1!==i&&s!==u&&(n(s,f),h.moveTo(f.nt*l,f.st*a))}(d!==f||d===f&&1===i)&&o(t,u,d,f)}}const zt=6;function kt(t,e){return{nt:t.nt-e.nt,st:t.st-e.st}}function Rt(t,e){return{nt:t.nt/e,st:t.st/e}}function Lt(t,e,i){const s=Math.max(0,e-1),n=Math.min(t.length-1,i+1);var r,o;return[(r=t[e],o=Rt(kt(t[i],t[s]),zt),{nt:r.nt+o.nt,st:r.st+o.st}),kt(t[i],Rt(kt(t[n],t[e]),zt))]}function Tt(t,e,i,s,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:h}=e;r.lineTo(n.nt*o,t*h),r.lineTo(s.nt*o,t*h),r.closePath(),r.fillStyle=i,r.fill()}class Nt extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){var e;if(null===this.G)return;const{it:i,tt:s,ds:n,et:r,Nt:o,fs:h}=this.G,l=null!==(e=this.G.vs)&&void 0!==e?e:this.G.ps?0:t.mediaSize.height;if(null===s)return;const a=t.context;a.lineCap="butt",a.lineJoin="round",a.lineWidth=r,M(a,o),a.lineWidth=1,Et(t,i,h,s,n,this.bs.bind(this),Tt.bind(null,l))}}function Ot(t,e,i){return Math.min(Math.max(t,e),i)}function $t(t,e,i){return e-t<=i}function Pt(t){const e=Math.ceil(t);return e%2==0?e-1:e}class Vt{ws(t,e){const i=this.gs,{Ms:s,xs:n,Ss:r,ks:o,ys:h,vs:l}=e;if(void 0===this.Cs||void 0===i||i.Ms!==s||i.xs!==n||i.Ss!==r||i.ks!==o||i.vs!==l||i.ys!==h){const i=t.context.createLinearGradient(0,0,0,h);if(i.addColorStop(0,s),null!=l){const e=Ot(l*t.verticalPixelRatio/h,0,1);i.addColorStop(e,n),i.addColorStop(e,r)}i.addColorStop(1,o),this.Cs=i,this.gs=e}return this.Cs}}class Dt extends Nt{constructor(){super(...arguments),this.Ts=new Vt}bs(t,e){return this.Ts.ws(t,{Ms:e.Ps,xs:"",Ss:"",ks:e.Rs,ys:t.bitmapSize.height})}}function Bt(t,e){const i=t.context;i.strokeStyle=e,i.stroke()}class Ft extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){if(null===this.G)return;const{it:e,tt:i,ds:s,fs:n,et:r,Nt:o,Ds:h}=this.G;if(null===i)return;const l=t.context;l.lineCap="butt",l.lineWidth=r*t.verticalPixelRatio,M(l,o),l.lineJoin="round";const a=this.Vs.bind(this);void 0!==n&&Et(t,e,n,i,s,a,Bt),h&&function(t,e,i,s,n){const{horizontalPixelRatio:r,verticalPixelRatio:o,context:h}=t;let l=null;const a=Math.max(1,Math.floor(r))%2/2,c=i*o+a;for(let i=s.to-1;i>=s.from;--i){const s=e[i];if(s){const e=n(t,s);e!==l&&(h.beginPath(),null!==l&&h.fill(),h.fillStyle=e,l=e);const i=Math.round(s.nt*r)+a,u=s.st*o;h.moveTo(i,u),h.arc(i,u,c,0,2*Math.PI)}}h.fill()}(t,e,h,i,a)}}class At extends Ft{Vs(t,e){return e.lt}}function It(t,e,i,s,n=0,r=e.length){let o=r-n;for(;0<o;){const r=o>>1,h=n+r;s(e[h],i)===t?(n=h+1,o-=r+1):o=r}return n}const Wt=It.bind(null,!0),jt=It.bind(null,!1);function Ut(t,e){return t.ot<e}function Ht(t,e){return e<t.ot}function Kt(t,e,i){const s=e.Os(),n=e.ui(),r=Wt(t,s,Ut),o=jt(t,n,Ht);if(!i)return{from:r,to:o};let h=r,l=o;return r>0&&r<t.length&&t[r].ot>=s&&(h=r-1),o>0&&o<t.length&&t[o-1].ot<=n&&(l=o+1),{from:h,to:l}}class qt{constructor(t,e,i){this.Bs=!0,this.As=!0,this.Is=!0,this.zs=[],this.Ls=null,this.Es=t,this.Ns=e,this.Fs=i}bt(t){this.Bs=!0,"data"===t&&(this.As=!0),"options"===t&&(this.Is=!0)}gt(){return this.Es.yt()?(this.Ws(),null===this.Ls?null:this.js):null}Hs(){this.zs=this.zs.map(t=>Object.assign(Object.assign({},t),this.Es.Us().$s(t.ot)))}qs(){this.Ls=null}Ws(){this.As&&(this.Ys(),this.As=!1),this.Is&&(this.Hs(),this.Is=!1),this.Bs&&(this.Zs(),this.Bs=!1)}Zs(){const t=this.Es.Dt(),e=this.Ns.St();if(this.qs(),e.Ni()||t.Ni())return;const i=e.Xs();if(null===i)return;if(0===this.Es.In().Ks())return;const s=this.Es.Ct();null!==s&&(this.Ls=Kt(this.zs,i,this.Fs),this.Gs(t,e,s.Vt),this.Js())}}class Xt extends qt{constructor(t,e){super(t,e,!0)}Gs(t,e,i){e.Qs(this.zs,X(this.Ls)),t.te(this.zs,i,X(this.Ls))}ie(t,e){return{ot:t,_t:e,nt:NaN,st:NaN}}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>{const i=e.Vt[3];return this.se(e.ee,i,t)})}}class Jt extends Xt{constructor(t,e){super(t,e),this.js=new Y,this.re=new Dt,this.he=new At,this.js.Z([this.re,this.he])}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.W();this.re.J({fs:t.lineType,it:this.zs,Nt:t.lineStyle,et:t.lineWidth,vs:null,ps:t.invertFilledArea,tt:this.Ls,ds:this.Ns.St().le()}),this.he.J({fs:t.lineVisible?t.lineType:void 0,it:this.zs,Nt:t.lineStyle,et:t.lineWidth,tt:this.Ls,ds:this.Ns.St().le(),Ds:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}class Gt extends Z{constructor(){super(...arguments),this.zt=null,this.ae=0,this.oe=0}J(t){this.zt=t}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.zt||0===this.zt.In.length||null===this.zt.tt)return;this.ae=this._e(e),this.ae>=2&&Math.max(1,Math.floor(e))%2!=this.ae%2&&this.ae--,this.oe=this.zt.ue?Math.min(this.ae,Math.floor(e)):this.ae;let s=null;const n=this.oe<=this.ae&&this.zt.le>=Math.floor(1.5*e);for(let r=this.zt.tt.from;r<this.zt.tt.to;++r){const o=this.zt.In[r];s!==o.ce&&(t.fillStyle=o.ce,s=o.ce);const h=Math.floor(.5*this.oe),l=Math.round(o.nt*e),a=l-h,c=this.oe,u=a+c-1,d=Math.min(o.de,o.fe),f=Math.max(o.de,o.fe),m=Math.round(d*i)-h,p=Math.round(f*i)+h,g=Math.max(p-m,this.oe);t.fillRect(a,m,c,g);const v=Math.ceil(1.5*this.ae);if(n){if(this.zt.ve){const e=l-v;let s=Math.max(m,Math.round(o.pe*i)-h),n=s+c-1;n>m+g-1&&(n=m+g-1,s=n-c+1),t.fillRect(e,s,a-e,n-s+1)}const e=l+v;let s=Math.max(m,Math.round(o.me*i)-h),n=s+c-1;n>m+g-1&&(n=m+g-1,s=n-c+1),t.fillRect(u+1,s,e-u,n-s+1)}}}_e(t){const e=Math.floor(t);return Math.max(e,Math.floor(function(t,e){return Math.floor(.3*t*e)}(k(this.zt).le,t)))}}class Qt extends qt{constructor(t,e){super(t,e,!1)}Gs(t,e,i){e.Qs(this.zs,X(this.Ls)),t.be(this.zs,i,X(this.Ls))}we(t,e,i){return{ot:t,ge:e.Vt[0],Me:e.Vt[1],xe:e.Vt[2],Se:e.Vt[3],nt:NaN,pe:NaN,de:NaN,fe:NaN,me:NaN}}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>this.se(e.ee,e,t))}}class Yt extends Qt{constructor(){super(...arguments),this.js=new Gt}se(t,e,i){return Object.assign(Object.assign({},this.we(t,e,i)),i.$s(t))}Js(){const t=this.Es.W();this.js.J({In:this.zs,le:this.Ns.St().le(),ve:t.openVisible,ue:t.thinBars,tt:this.Ls})}}class Zt extends Nt{constructor(){super(...arguments),this.Ts=new Vt}bs(t,e){const i=this.G;return this.Ts.ws(t,{Ms:e.ke,xs:e.ye,Ss:e.Ce,ks:e.Te,ys:t.bitmapSize.height,vs:i.vs})}}class te extends Ft{constructor(){super(...arguments),this.Pe=new Vt}Vs(t,e){const i=this.G;return this.Pe.ws(t,{Ms:e.Re,xs:e.Re,Ss:e.De,ks:e.De,ys:t.bitmapSize.height,vs:i.vs})}}class ee extends Xt{constructor(t,e){super(t,e),this.js=new Y,this.Ve=new Zt,this.Oe=new te,this.js.Z([this.Ve,this.Oe])}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.Ct();if(null===t)return;const e=this.Es.W(),i=this.Es.Dt().Rt(e.baseValue.price,t.Vt),s=this.Ns.St().le();this.Ve.J({it:this.zs,et:e.lineWidth,Nt:e.lineStyle,fs:e.lineType,vs:i,ps:!1,tt:this.Ls,ds:s}),this.Oe.J({it:this.zs,et:e.lineWidth,Nt:e.lineStyle,fs:e.lineVisible?e.lineType:void 0,Ds:e.pointMarkersVisible?e.pointMarkersRadius||e.lineWidth/2+2:void 0,vs:i,tt:this.Ls,ds:s})}}class ie extends Z{constructor(){super(...arguments),this.zt=null,this.ae=0}J(t){this.zt=t}K(t){if(null===this.zt||0===this.zt.In.length||null===this.zt.tt)return;const{horizontalPixelRatio:e}=t;this.ae=function(t,e){if(t>=2.5&&t<=4)return Math.floor(3*e);const i=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),s=Math.floor(t*i*e),n=Math.floor(t*e),r=Math.min(s,n);return Math.max(Math.floor(e),r)}(this.zt.le,e),this.ae>=2&&Math.floor(e)%2!=this.ae%2&&this.ae--;const i=this.zt.In;this.zt.Be&&this.Ae(t,i,this.zt.tt),this.zt._i&&this.Ie(t,i,this.zt.tt);const s=this.ze(e);(!this.zt._i||this.ae>2*s)&&this.Le(t,i,this.zt.tt)}Ae(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="",h=Math.min(Math.floor(n),Math.floor(this.zt.le*n));h=Math.max(Math.floor(n),Math.min(h,this.ae));const l=Math.floor(.5*h);let a=null;for(let t=i.from;t<i.to;t++){const i=e[t];i.Ee!==o&&(s.fillStyle=i.Ee,o=i.Ee);const c=Math.round(Math.min(i.pe,i.me)*r),u=Math.round(Math.max(i.pe,i.me)*r),d=Math.round(i.de*r),f=Math.round(i.fe*r);let m=Math.round(n*i.nt)-l;const p=m+h-1;null!==a&&(m=Math.max(a+1,m),m=Math.min(m,p));const g=p-m+1;s.fillRect(m,d,g,c-d),s.fillRect(m,u+1,g,f-u),a=p}}ze(t){let e=Math.floor(1*t);this.ae<=2*e&&(e=Math.floor(.5*(this.ae-1)));const i=Math.max(Math.floor(t),e);return this.ae<=2*i?Math.max(Math.floor(t),Math.floor(1*t)):i}Ie(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="";const h=this.ze(n);let l=null;for(let t=i.from;t<i.to;t++){const i=e[t];i.Ne!==o&&(s.fillStyle=i.Ne,o=i.Ne);let a=Math.round(i.nt*n)-Math.floor(.5*this.ae);const c=a+this.ae-1,u=Math.round(Math.min(i.pe,i.me)*r),d=Math.round(Math.max(i.pe,i.me)*r);if(null!==l&&(a=Math.max(l+1,a),a=Math.min(a,c)),this.zt.le*n>2*h)ot(s,a,u,c-a+1,d-u+1,h);else{const t=c-a+1;s.fillRect(a,u,t,d-u+1)}l=c}}Le(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="";const h=this.ze(n);for(let t=i.from;t<i.to;t++){const i=e[t];let l=Math.round(Math.min(i.pe,i.me)*r),a=Math.round(Math.max(i.pe,i.me)*r),c=Math.round(i.nt*n)-Math.floor(.5*this.ae),u=c+this.ae-1;if(i.ce!==o){const t=i.ce;s.fillStyle=t,o=t}this.zt._i&&(c+=h,l+=h,u-=h,a-=h),l>a||s.fillRect(c,l,u-c+1,a-l+1)}}}class se extends Qt{constructor(){super(...arguments),this.js=new ie}se(t,e,i){return Object.assign(Object.assign({},this.we(t,e,i)),i.$s(t))}Js(){const t=this.Es.W();this.js.J({In:this.zs,le:this.Ns.St().le(),Be:t.wickVisible,_i:t.borderVisible,tt:this.Ls})}}class ne{constructor(t,e){this.Fe=t,this.Li=e}X(t,e,i){this.Fe.draw(t,this.Li,e,i)}}class re extends qt{constructor(t,e,i){super(t,e,!1),this.wn=i,this.js=new ne(this.wn.renderer(),e=>{const i=t.Ct();return null===i?null:t.Dt().Rt(e,i.Vt)})}We(t){return this.wn.priceValueBuilder(t)}je(t){return this.wn.isWhitespace(t)}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>Object.assign(Object.assign({ot:e.ee,nt:NaN},t.$s(e.ee)),{He:e.$e}))}Gs(t,e){e.Qs(this.zs,X(this.Ls))}Js(){this.wn.update({bars:this.zs.map(oe),barSpacing:this.Ns.St().le(),visibleRange:this.Ls},this.Es.W())}}function oe(t){return{x:t.nt,time:t.ot,originalData:t.He,barColor:t.ce}}class he extends Z{constructor(){super(...arguments),this.zt=null,this.Ue=[]}J(t){this.zt=t,this.Ue=[]}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.zt||0===this.zt.it.length||null===this.zt.tt)return;this.Ue.length||this.qe(e);const s=Math.max(1,Math.floor(i)),n=Math.round(this.zt.Ye*i)-Math.floor(s/2),r=n+s;for(let e=this.zt.tt.from;e<this.zt.tt.to;e++){const o=this.zt.it[e],h=this.Ue[e-this.zt.tt.from],l=Math.round(o.st*i);let a,c;t.fillStyle=o.ce,l<=n?(a=l,c=r):(a=n,c=l-Math.floor(s/2)+s),t.fillRect(h.Os,a,h.ui-h.Os+1,c-a)}}qe(t){if(null===this.zt||0===this.zt.it.length||null===this.zt.tt)return void(this.Ue=[]);const e=Math.ceil(this.zt.le*t)<=1?0:Math.max(1,Math.floor(t)),i=Math.round(this.zt.le*t)-e;this.Ue=new Array(this.zt.tt.to-this.zt.tt.from);for(let e=this.zt.tt.from;e<this.zt.tt.to;e++){const s=this.zt.it[e],n=Math.round(s.nt*t);let r,o;if(i%2){const t=(i-1)/2;r=n-t,o=n+t}else{const t=i/2;r=n-t,o=n+t-1}this.Ue[e-this.zt.tt.from]={Os:r,ui:o,Ze:n,Xe:s.nt*t,ot:s.ot}}for(let t=this.zt.tt.from+1;t<this.zt.tt.to;t++){const i=this.Ue[t-this.zt.tt.from],s=this.Ue[t-this.zt.tt.from-1];i.ot===s.ot+1&&i.Os-s.ui!==e+1&&(s.Ze>s.Xe?s.ui=i.Os-e-1:i.Os=s.ui+e+1)}let s=Math.ceil(this.zt.le*t);for(let t=this.zt.tt.from;t<this.zt.tt.to;t++){const e=this.Ue[t-this.zt.tt.from];e.ui<e.Os&&(e.ui=e.Os);const i=e.ui-e.Os+1;s=Math.min(i,s)}if(e>0&&s<4)for(let t=this.zt.tt.from;t<this.zt.tt.to;t++){const e=this.Ue[t-this.zt.tt.from];e.ui-e.Os+1>s&&(e.Ze>e.Xe?e.ui-=1:e.Os+=1)}}}class le extends Xt{constructor(){super(...arguments),this.js=new he}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t={it:this.zs,le:this.Ns.St().le(),tt:this.Ls,Ye:this.Es.Dt().Rt(this.Es.W().base,k(this.Es.Ct()).Vt)};this.js.J(t)}}class ae extends Xt{constructor(){super(...arguments),this.js=new At}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.W(),e={it:this.zs,Nt:t.lineStyle,fs:t.lineVisible?t.lineType:void 0,et:t.lineWidth,Ds:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,tt:this.Ls,ds:this.Ns.St().le()};this.js.J(e)}}const ce=/[2-9]/g;class ue{constructor(t=50){this.Ke=0,this.Ge=1,this.Je=1,this.Qe={},this.tr=new Map,this.ir=t}nr(){this.Ke=0,this.tr.clear(),this.Ge=1,this.Je=1,this.Qe={}}xi(t,e,i){return this.sr(t,e,i).width}Mi(t,e,i){const s=this.sr(t,e,i);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}sr(t,e,i){const s=i||ce,n=String(e).replace(s,"0");if(this.tr.has(n))return z(this.tr.get(n)).er;if(this.Ke===this.ir){const t=this.Qe[this.Je];delete this.Qe[this.Je],this.tr.delete(t),this.Je++,this.Ke--}t.save(),t.textBaseline="middle";const r=t.measureText(n);return t.restore(),0===r.width&&e.length||(this.tr.set(n,{er:r,rr:this.Ge}),this.Qe[this.Ge]=n,this.Ke++,this.Ge++),r}}class de{constructor(t){this.hr=null,this.k=null,this.lr="right",this.ar=t}_r(t,e,i){this.hr=t,this.k=e,this.lr=i}X(t){null!==this.k&&null!==this.hr&&this.hr.X(t,this.k,this.ar,this.lr)}}class fe{constructor(t,e,i){this.ur=t,this.ar=new ue(50),this.cr=e,this.F=i,this.j=-1,this.Wt=new de(this.ar)}gt(){const t=this.F.dr(this.cr);if(null===t)return null;const e=t.vr(this.cr)?t.pr():this.cr.Dt();if(null===e)return null;const i=t.mr(e);if("overlay"===i)return null;const s=this.F.br();return s.P!==this.j&&(this.j=s.P,this.ar.nr()),this.Wt._r(this.ur.Ii(),s,i),this.Wt}}class me extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}wr(t,e){var i;if(!(null===(i=this.zt)||void 0===i?void 0:i.yt))return null;const{st:s,et:n,gr:r}=this.zt;return e>=s-n-7&&e<=s+n+7?{Mr:this.zt,gr:r}:null}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;if(!1===this.zt.yt)return;const n=Math.round(this.zt.st*s);n<0||n>e.height||(t.lineCap="butt",t.strokeStyle=this.zt.V,t.lineWidth=Math.floor(this.zt.et*i),M(t,this.zt.Nt),_(t,n,0,e.width))}}class pe{constructor(t){this.Sr={st:0,V:"rgba(0, 0, 0, 0)",et:1,Nt:0,yt:!1},this.kr=new me,this.ft=!0,this.Es=t,this.Ns=t.$t(),this.kr.J(this.Sr)}bt(){this.ft=!0}gt(){return this.Es.yt()?(this.ft&&(this.yr(),this.ft=!1),this.kr):null}}class ge extends pe{constructor(t){super(t)}yr(){this.Sr.yt=!1;const t=this.Es.Dt(),e=t.Cr().Cr;if(2!==e&&3!==e)return;const i=this.Es.W();if(!i.baseLineVisible||!this.Es.yt())return;const s=this.Es.Ct();null!==s&&(this.Sr.yt=!0,this.Sr.st=t.Rt(s.Vt,s.Vt),this.Sr.V=i.baseLineColor,this.Sr.et=i.baseLineWidth,this.Sr.Nt=i.baseLineStyle)}}class ve extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}$e(){return this.zt}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){const s=this.zt;if(null===s)return;const n=Math.max(1,Math.floor(e)),r=n%2/2,o=Math.round(s.Xe.x*e)+r,h=s.Xe.y*i;t.fillStyle=s.Tr,t.beginPath();const l=Math.max(2,1.5*s.Pr)*e;t.arc(o,h,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.Rr,t.beginPath(),t.arc(o,h,s.ht*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=n,t.strokeStyle=s.Dr,t.beginPath(),t.arc(o,h,s.ht*e+n/2,0,2*Math.PI,!1),t.stroke()}}const be=[{Vr:0,Or:.25,Br:4,Ar:10,Ir:.25,zr:0,Lr:.4,Er:.8},{Vr:.25,Or:.525,Br:10,Ar:14,Ir:0,zr:0,Lr:.8,Er:0},{Vr:.525,Or:1,Br:14,Ar:14,Ir:0,zr:0,Lr:0,Er:0}];function we(t,e,i,s){return function(t,e){if("transparent"===t)return t;const i=D(t),s=i[3];return`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${e*s})`}(t,i+(s-i)*e)}function ye(t,e){const i=t%2600/2600;let s;for(const t of be)if(i>=t.Vr&&i<=t.Or){s=t;break}E(void 0!==s,"Last price animation internal logic error");const n=(i-s.Vr)/(s.Or-s.Vr);return{Rr:we(e,n,s.Ir,s.zr),Dr:we(e,n,s.Lr,s.Er),ht:(r=n,o=s.Br,h=s.Ar,o+(h-o)*r)};var r,o,h}class Se{constructor(t){this.Wt=new ve,this.ft=!0,this.Nr=!0,this.Fr=performance.now(),this.Wr=this.Fr-1,this.jr=t}Hr(){this.Wr=this.Fr-1,this.bt()}$r(){if(this.bt(),2===this.jr.W().lastPriceAnimation){const t=performance.now(),e=this.Wr-t;if(e>0)return void(e<650&&(this.Wr+=2600));this.Fr=t,this.Wr=t+2600}}bt(){this.ft=!0}Ur(){this.Nr=!0}yt(){return 0!==this.jr.W().lastPriceAnimation}qr(){switch(this.jr.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Wr}}gt(){return this.ft?(this.Mt(),this.ft=!1,this.Nr=!1):this.Nr&&(this.Yr(),this.Nr=!1),this.Wt}Mt(){this.Wt.J(null);const t=this.jr.$t().St(),e=t.Xs(),i=this.jr.Ct();if(null===e||null===i)return;const s=this.jr.Zr(!0);if(s.Xr||!e.Kr(s.ee))return;const n={x:t.It(s.ee),y:this.jr.Dt().Rt(s._t,i.Vt)},r=s.V,o=this.jr.W().lineWidth,h=ye(this.Gr(),r);this.Wt.J({Tr:r,Pr:o,Rr:h.Rr,Dr:h.Dr,ht:h.ht,Xe:n})}Yr(){const t=this.Wt.$e();if(null!==t){const e=ye(this.Gr(),t.Tr);t.Rr=e.Rr,t.Dr=e.Dr,t.ht=e.ht}}Gr(){return this.qr()?performance.now()-this.Fr:2599}}function xe(t,e){return Pt(Math.min(Math.max(t,12),30)*e)}function Ce(t,e){switch(t){case"arrowDown":case"arrowUp":return xe(e,1);case"circle":return xe(e,.8);case"square":return xe(e,.7)}}function Me(t){return function(t){const e=Math.ceil(t);return e%2!=0?e-1:e}(xe(t,1))}function _e(t){return Math.max(xe(t,.1),3)}function Ee(t,e,i){return e?t:i?Math.ceil(t/2):0}function ze(t,e,i,s,n){const r=Ce("square",i),o=(r-1)/2,h=t-o,l=e-o;return s>=h&&s<=h+r&&n>=l&&n<=l+r}function ke(t,e,i,s){const n=(Ce("arrowUp",s)-1)/2*i.Jr,r=(Pt(s/2)-1)/2*i.Jr;e.beginPath(),t?(e.moveTo(i.nt-n,i.st),e.lineTo(i.nt,i.st-n),e.lineTo(i.nt+n,i.st),e.lineTo(i.nt+r,i.st),e.lineTo(i.nt+r,i.st+n),e.lineTo(i.nt-r,i.st+n),e.lineTo(i.nt-r,i.st)):(e.moveTo(i.nt-n,i.st),e.lineTo(i.nt,i.st+n),e.lineTo(i.nt+n,i.st),e.lineTo(i.nt+r,i.st),e.lineTo(i.nt+r,i.st-n),e.lineTo(i.nt-r,i.st-n),e.lineTo(i.nt-r,i.st)),e.fill()}class Re extends Z{constructor(){super(...arguments),this.zt=null,this.ar=new ue,this.j=-1,this.H="",this.Qr=""}J(t){this.zt=t}_r(t,e){this.j===t&&this.H===e||(this.j=t,this.H=e,this.Qr=G(t,e),this.ar.nr())}wr(t,e){if(null===this.zt||null===this.zt.tt)return null;for(let i=this.zt.tt.from;i<this.zt.tt.to;i++){const s=this.zt.it[i];if(Te(s,t,e))return{Mr:s.th,gr:s.gr}}return null}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i},s,n){if(null!==this.zt&&null!==this.zt.tt){t.textBaseline="middle",t.font=this.Qr;for(let s=this.zt.tt.from;s<this.zt.tt.to;s++){const n=this.zt.it[s];void 0!==n.Kt&&(n.Kt.Hi=this.ar.xi(t,n.Kt.ih),n.Kt.At=this.j,n.Kt.nt=n.nt-n.Kt.Hi/2),Le(n,t,e,i)}}}}function Le(t,e,i,s){e.fillStyle=t.V,void 0!==t.Kt&&function(t,e,i,s,n,r){t.save(),t.scale(n,r),t.fillText(e,i,s),t.restore()}(e,t.Kt.ih,t.Kt.nt,t.Kt.st,i,s),function(t,e,i){if(0!==t.Ks){switch(t.nh){case"arrowDown":return void ke(!1,e,i,t.Ks);case"arrowUp":return void ke(!0,e,i,t.Ks);case"circle":return void function(t,e,i){const s=(Ce("circle",i)-1)/2;t.beginPath(),t.arc(e.nt,e.st,s*e.Jr,0,2*Math.PI,!1),t.fill()}(e,i,t.Ks);case"square":return void function(t,e,i){const s=Ce("square",i),n=(s-1)*e.Jr/2,r=e.nt-n,o=e.st-n;t.fillRect(r,o,s*e.Jr,s*e.Jr)}(e,i,t.Ks)}t.nh}}(t,e,function(t,e,i){const s=Math.max(1,Math.floor(e))%2/2;return{nt:Math.round(t.nt*e)+s,st:t.st*i,Jr:e}}(t,i,s))}function Te(t,e,i){return!(void 0===t.Kt||!function(t,e,i,s,n,r){const o=s/2;return n>=t&&n<=t+i&&r>=e-o&&r<=e+o}(t.Kt.nt,t.Kt.st,t.Kt.Hi,t.Kt.At,e,i))||function(t,e,i){if(0===t.Ks)return!1;switch(t.nh){case"arrowDown":case"arrowUp":return function(t,e,i,s,n,r){return ze(e,i,s,n,r)}(0,t.nt,t.st,t.Ks,e,i);case"circle":return function(t,e,i,s,n){const r=2+Ce("circle",i)/2,o=t-s,h=e-n;return Math.sqrt(o*o+h*h)<=r}(t.nt,t.st,t.Ks,e,i);case"square":return ze(t.nt,t.st,t.Ks,e,i)}}(t,e,i)}function Ne(t,e,i,s,n,r,o,h,l){const a=W(i)?i:i.Se,c=W(i)?i:i.Me,u=W(i)?i:i.xe,d=W(e.size)?Math.max(e.size,0):1,f=Me(h.le())*d,m=f/2;switch(t.Ks=f,e.position){case"inBar":return t.st=o.Rt(a,l),void(void 0!==t.Kt&&(t.Kt.st=t.st+m+r+.6*n));case"aboveBar":return t.st=o.Rt(c,l)-m-s.sh,void 0!==t.Kt&&(t.Kt.st=t.st-m-.6*n,s.sh+=1.2*n),void(s.sh+=f+r);case"belowBar":return t.st=o.Rt(u,l)+m+s.eh,void 0!==t.Kt&&(t.Kt.st=t.st+m+r+.6*n,s.eh+=1.2*n),void(s.eh+=f+r)}e.position}class Oe{constructor(t,e){this.ft=!0,this.rh=!0,this.hh=!0,this.ah=null,this.oh=null,this.Wt=new Re,this.jr=t,this.$i=e,this.zt={it:[],tt:null}}bt(t){this.ft=!0,this.hh=!0,"data"===t&&(this.rh=!0,this.oh=null)}gt(t){if(!this.jr.yt())return null;this.ft&&this._h();const e=this.$i.W().layout;return this.Wt._r(e.fontSize,e.fontFamily),this.Wt.J(this.zt),this.Wt}uh(){if(this.hh){if(this.jr.dh().length>0){const t=this.$i.St().le(),e=_e(t),i=1.5*Me(t)+2*e,s=this.fh();this.ah={above:Ee(i,s.aboveBar,s.inBar),below:Ee(i,s.belowBar,s.inBar)}}else this.ah=null;this.hh=!1}return this.ah}fh(){return null===this.oh&&(this.oh=this.jr.dh().reduce((t,e)=>(t[e.position]||(t[e.position]=!0),t),{inBar:!1,aboveBar:!1,belowBar:!1})),this.oh}_h(){const t=this.jr.Dt(),e=this.$i.St(),i=this.jr.dh();this.rh&&(this.zt.it=i.map(t=>({ot:t.time,nt:0,st:0,Ks:0,nh:t.shape,V:t.color,th:t.th,gr:t.id,Kt:void 0})),this.rh=!1);const s=this.$i.W().layout;this.zt.tt=null;const n=e.Xs();if(null===n)return;const r=this.jr.Ct();if(null===r)return;if(0===this.zt.it.length)return;let o=NaN;const h=_e(e.le()),l={sh:h,eh:h};this.zt.tt=Kt(this.zt.it,n,!0);for(let n=this.zt.tt.from;n<this.zt.tt.to;n++){const a=i[n];a.time!==o&&(l.sh=h,l.eh=h,o=a.time);const c=this.zt.it[n];c.nt=e.It(a.time),void 0!==a.text&&a.text.length>0&&(c.Kt={ih:a.text,nt:0,st:0,Hi:0,At:0});const u=this.jr.ph(a.time);null!==u&&Ne(c,a,u,l,s.fontSize,h,t,e,r.Vt)}this.ft=!1}}class $e extends pe{constructor(t){super(t)}yr(){const t=this.Sr;t.yt=!1;const e=this.Es.W();if(!e.priceLineVisible||!this.Es.yt())return;const i=this.Es.Zr(0===e.priceLineSource);i.Xr||(t.yt=!0,t.st=i.ki,t.V=this.Es.mh(i.V),t.et=e.priceLineWidth,t.Nt=e.priceLineStyle)}}class Pe extends dt{constructor(t){super(),this.jt=t}zi(t,e,i){t.yt=!1,e.yt=!1;const s=this.jt;if(!s.yt())return;const n=s.W(),r=n.lastValueVisible,o=""!==s.bh(),h=0===n.seriesLastValueMode,l=s.Zr(!1);if(l.Xr)return;r&&(t.Kt=this.wh(l,r,h),t.yt=0!==t.Kt.length),(o||h)&&(e.Kt=this.gh(l,r,o,h),e.yt=e.Kt.length>0);const a=s.mh(l.V),c=F(a);i.t=c.t,i.ki=l.ki,e.Ot=s.$t().Bt(l.ki/s.Dt().At()),t.Ot=a,t.V=c.i,e.V=c.i}gh(t,e,i,s){let n="";const r=this.jt.bh();return i&&0!==r.length&&(n+=`${r} `),e&&s&&(n+=this.jt.Dt().Mh()?t.xh:t.Sh),n.trim()}wh(t,e,i){return e?i?this.jt.Dt().Mh()?t.Sh:t.xh:t.Kt:""}}function Ve(t,e,i,s){const n=Number.isFinite(e),r=Number.isFinite(i);return n&&r?t(e,i):n||r?n?e:i:s}class De{constructor(t,e){this.kh=t,this.yh=e}Ch(t){return null!==t&&this.kh===t.kh&&this.yh===t.yh}Th(){return new De(this.kh,this.yh)}Ph(){return this.kh}Rh(){return this.yh}Dh(){return this.yh-this.kh}Ni(){return this.yh===this.kh||Number.isNaN(this.yh)||Number.isNaN(this.kh)}ts(t){return null===t?this:new De(Ve(Math.min,this.Ph(),t.Ph(),-1/0),Ve(Math.max,this.Rh(),t.Rh(),1/0))}Vh(t){if(!W(t))return;if(0===this.yh-this.kh)return;const e=.5*(this.yh+this.kh);let i=this.yh-e,s=this.kh-e;i*=t,s*=t,this.yh=e+i,this.kh=e+s}Oh(t){W(t)&&(this.yh+=t,this.kh+=t)}Bh(){return{minValue:this.kh,maxValue:this.yh}}static Ah(t){return null===t?null:new De(t.minValue,t.maxValue)}}class Be{constructor(t,e){this.Ih=t,this.zh=e||null}Lh(){return this.Ih}Eh(){return this.zh}Bh(){return null===this.Ih?null:{priceRange:this.Ih.Bh(),margins:this.zh||void 0}}static Ah(t){return null===t?null:new Be(De.Ah(t.priceRange),t.margins)}}class Fe extends pe{constructor(t,e){super(t),this.Nh=e}yr(){const t=this.Sr;t.yt=!1;const e=this.Nh.W();if(!this.Es.yt()||!e.lineVisible)return;const i=this.Nh.Fh();null!==i&&(t.yt=!0,t.st=i,t.V=e.color,t.et=e.lineWidth,t.Nt=e.lineStyle,t.gr=this.Nh.W().id)}}class Ae extends dt{constructor(t,e){super(),this.jr=t,this.Nh=e}zi(t,e,i){t.yt=!1,e.yt=!1;const s=this.Nh.W(),n=s.axisLabelVisible,r=""!==s.title,o=this.jr;if(!n||!o.yt())return;const h=this.Nh.Fh();if(null===h)return;r&&(e.Kt=s.title,e.yt=!0),e.Ot=o.$t().Bt(h/o.Dt().At()),t.Kt=this.Wh(s.price),t.yt=!0;const l=F(s.axisLabelColor||s.color);i.t=l.t;const a=s.axisLabelTextColor||l.i;t.V=a,e.V=a,i.ki=h}Wh(t){const e=this.jr.Ct();return null===e?"":this.jr.Dt().Fi(t,e.Vt)}}class Ie{constructor(t,e){this.jr=t,this.cn=e,this.jh=new Fe(t,this),this.ur=new Ae(t,this),this.Hh=new fe(this.ur,t,t.$t())}$h(t){I(this.cn,t),this.bt(),this.jr.$t().Uh()}W(){return this.cn}qh(){return this.jh}Yh(){return this.Hh}Zh(){return this.ur}bt(){this.jh.bt(),this.ur.bt()}Fh(){const t=this.jr,e=t.Dt();if(t.$t().St().Ni()||e.Ni())return null;const i=t.Ct();return null===i?null:e.Rt(this.cn.price,i.Vt)}}class We extends vt{constructor(t){super(),this.$i=t}$t(){return this.$i}}const je={Bar:(t,e,i,s)=>{var n;const r=e.upColor,o=e.downColor,h=k(t(i,s)),l=R(h.Vt[0])<=R(h.Vt[3]);return{ce:null!==(n=h.V)&&void 0!==n?n:l?r:o}},Candlestick:(t,e,i,s)=>{var n,r,o;const h=e.upColor,l=e.downColor,a=e.borderUpColor,c=e.borderDownColor,u=e.wickUpColor,d=e.wickDownColor,f=k(t(i,s)),m=R(f.Vt[0])<=R(f.Vt[3]);return{ce:null!==(n=f.V)&&void 0!==n?n:m?h:l,Ne:null!==(r=f.Ot)&&void 0!==r?r:m?a:c,Ee:null!==(o=f.Xh)&&void 0!==o?o:m?u:d}},Custom:(t,e,i,s)=>{var n;return{ce:null!==(n=k(t(i,s)).V)&&void 0!==n?n:e.color}},Area:(t,e,i,s)=>{var n,r,o,h;const l=k(t(i,s));return{ce:null!==(n=l.lt)&&void 0!==n?n:e.lineColor,lt:null!==(r=l.lt)&&void 0!==r?r:e.lineColor,Ps:null!==(o=l.Ps)&&void 0!==o?o:e.topColor,Rs:null!==(h=l.Rs)&&void 0!==h?h:e.bottomColor}},Baseline:(t,e,i,s)=>{var n,r,o,h,l,a;const c=k(t(i,s));return{ce:c.Vt[3]>=e.baseValue.price?e.topLineColor:e.bottomLineColor,Re:null!==(n=c.Re)&&void 0!==n?n:e.topLineColor,De:null!==(r=c.De)&&void 0!==r?r:e.bottomLineColor,ke:null!==(o=c.ke)&&void 0!==o?o:e.topFillColor1,ye:null!==(h=c.ye)&&void 0!==h?h:e.topFillColor2,Ce:null!==(l=c.Ce)&&void 0!==l?l:e.bottomFillColor1,Te:null!==(a=c.Te)&&void 0!==a?a:e.bottomFillColor2}},Line:(t,e,i,s)=>{var n,r;const o=k(t(i,s));return{ce:null!==(n=o.V)&&void 0!==n?n:e.color,lt:null!==(r=o.V)&&void 0!==r?r:e.color}},Histogram:(t,e,i,s)=>{var n;return{ce:null!==(n=k(t(i,s)).V)&&void 0!==n?n:e.color}}};class Ue{constructor(t){this.Kh=(t,e)=>void 0!==e?e.Vt:this.jr.In().Gh(t),this.jr=t,this.Jh=je[t.Qh()]}$s(t,e){return this.Jh(this.Kh,this.jr.W(),t,e)}}var He;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(He||(He={}));const Ke=30;class qe{constructor(){this.tl=[],this.il=new Map,this.nl=new Map}sl(){return this.Ks()>0?this.tl[this.tl.length-1]:null}el(){return this.Ks()>0?this.rl(0):null}An(){return this.Ks()>0?this.rl(this.tl.length-1):null}Ks(){return this.tl.length}Ni(){return 0===this.Ks()}Kr(t){return null!==this.hl(t,0)}Gh(t){return this.ll(t)}ll(t,e=0){const i=this.hl(t,e);return null===i?null:Object.assign(Object.assign({},this.al(i)),{ee:this.rl(i)})}ne(){return this.tl}ol(t,e,i){if(this.Ni())return null;let s=null;for(const n of i)s=Xe(s,this._l(t,e,n));return s}J(t){this.nl.clear(),this.il.clear(),this.tl=t}rl(t){return this.tl[t].ee}al(t){return this.tl[t]}hl(t,e){const i=this.ul(t);if(null===i&&0!==e)switch(e){case-1:return this.cl(t);case 1:return this.dl(t);default:throw new TypeError("Unknown search mode")}return i}cl(t){let e=this.fl(t);return e>0&&(e-=1),e!==this.tl.length&&this.rl(e)<t?e:null}dl(t){const e=this.vl(t);return e!==this.tl.length&&t<this.rl(e)?e:null}ul(t){const e=this.fl(t);return e===this.tl.length||t<this.tl[e].ee?null:e}fl(t){return Wt(this.tl,t,(t,e)=>t.ee<e)}vl(t){return jt(this.tl,t,(t,e)=>t.ee>e)}pl(t,e,i){let s=null;for(let n=t;n<e;n++){const t=this.tl[n].Vt[i];Number.isNaN(t)||(null===s?s={ml:t,bl:t}:(t<s.ml&&(s.ml=t),t>s.bl&&(s.bl=t)))}return s}_l(t,e,i){if(this.Ni())return null;let s=null;const n=k(this.el()),r=k(this.An()),o=Math.max(t,n),h=Math.min(e,r),l=Math.ceil(o/Ke)*Ke,a=Math.max(l,Math.floor(h/Ke)*Ke);{const t=this.fl(o),n=this.vl(Math.min(h,l,e));s=Xe(s,this.pl(t,n,i))}let c=this.il.get(i);void 0===c&&(c=new Map,this.il.set(i,c));for(let t=Math.max(l+1,o);t<a;t+=Ke){const e=Math.floor(t/Ke);let n=c.get(e);if(void 0===n){const t=this.fl(e*Ke),s=this.vl((e+1)*Ke-1);n=this.pl(t,s,i),c.set(e,n)}s=Xe(s,n)}{const t=this.fl(a),e=this.vl(h);s=Xe(s,this.pl(t,e,i))}return s}}function Xe(t,e){return null===t?e:null===e?t:{ml:Math.min(t.ml,e.ml),bl:Math.max(t.bl,e.bl)}}class Je{constructor(t){this.wl=t}X(t,e,i){this.wl.draw(t)}gl(t,e,i){var s,n;null===(n=(s=this.wl).drawBackground)||void 0===n||n.call(s,t)}}class Ge{constructor(t){this.tr=null,this.wn=t}gt(){var t;const e=this.wn.renderer();if(null===e)return null;if((null===(t=this.tr)||void 0===t?void 0:t.Ml)===e)return this.tr.xl;const i=new Je(e);return this.tr={Ml:e,xl:i},i}Sl(){var t,e,i;return null!==(i=null===(e=(t=this.wn).zOrder)||void 0===e?void 0:e.call(t))&&void 0!==i?i:"normal"}}function Qe(t){var e,i,s,n,r;return{Kt:t.text(),ki:t.coordinate(),Si:null===(e=t.fixedCoordinate)||void 0===e?void 0:e.call(t),V:t.textColor(),t:t.backColor(),yt:null===(s=null===(i=t.visible)||void 0===i?void 0:i.call(t))||void 0===s||s,hi:null===(r=null===(n=t.tickVisible)||void 0===n?void 0:n.call(t))||void 0===r||r}}class Ye{constructor(t,e){this.Wt=new pt,this.kl=t,this.yl=e}gt(){return this.Wt.J(Object.assign({Hi:this.yl.Hi()},Qe(this.kl))),this.Wt}}class Ze extends dt{constructor(t,e){super(),this.kl=t,this.Li=e}zi(t,e,i){const s=Qe(this.kl);i.t=s.t,t.V=s.V;const n=2/12*this.Li.P();i.wi=n,i.gi=n,i.ki=s.ki,i.Si=s.Si,t.Kt=s.Kt,t.yt=s.yt,t.hi=s.hi}}class ti{constructor(t,e){this.Cl=null,this.Tl=null,this.Pl=null,this.Rl=null,this.Dl=null,this.Vl=t,this.jr=e}Ol(){return this.Vl}Vn(){var t,e;null===(e=(t=this.Vl).updateAllViews)||void 0===e||e.call(t)}Pn(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).paneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Cl)||void 0===s?void 0:s.Ml)===n)return this.Cl.xl;const r=n.map(t=>new Ge(t));return this.Cl={Ml:n,xl:r},r}Qi(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).timeAxisViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Tl)||void 0===s?void 0:s.Ml)===n)return this.Tl.xl;const r=this.jr.$t().St(),o=n.map(t=>new Ye(t,r));return this.Tl={Ml:n,xl:o},o}Rn(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).priceAxisViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Pl)||void 0===s?void 0:s.Ml)===n)return this.Pl.xl;const r=this.jr.Dt(),o=n.map(t=>new Ze(t,r));return this.Pl={Ml:n,xl:o},o}Bl(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).priceAxisPaneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Rl)||void 0===s?void 0:s.Ml)===n)return this.Rl.xl;const r=n.map(t=>new Ge(t));return this.Rl={Ml:n,xl:r},r}Al(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).timeAxisPaneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Dl)||void 0===s?void 0:s.Ml)===n)return this.Dl.xl;const r=n.map(t=>new Ge(t));return this.Dl={Ml:n,xl:r},r}Il(t,e){var i,s,n;return null!==(n=null===(s=(i=this.Vl).autoscaleInfo)||void 0===s?void 0:s.call(i,t,e))&&void 0!==n?n:null}wr(t,e){var i,s,n;return null!==(n=null===(s=(i=this.Vl).hitTest)||void 0===s?void 0:s.call(i,t,e))&&void 0!==n?n:null}}function ei(t,e,i,s){t.forEach(t=>{e(t).forEach(t=>{t.Sl()===i&&s.push(t)})})}function ii(t){return t.Pn()}function si(t){return t.Bl()}function ni(t){return t.Al()}class ri extends We{constructor(t,e,i,s,n){super(t),this.zt=new qe,this.jh=new $e(this),this.zl=[],this.Ll=new ge(this),this.El=null,this.Nl=null,this.Fl=[],this.Wl=[],this.jl=null,this.Hl=[],this.cn=e,this.$l=i;const r=new Pe(this);this.rn=[r],this.Hh=new fe(r,this,t),"Area"!==i&&"Line"!==i&&"Baseline"!==i||(this.El=new Se(this)),this.Ul(),this.ql(n)}S(){null!==this.jl&&clearTimeout(this.jl)}mh(t){return this.cn.priceLineColor||t}Zr(t){const e={Xr:!0},i=this.Dt();if(this.$t().St().Ni()||i.Ni()||this.zt.Ni())return e;const s=this.$t().St().Xs(),n=this.Ct();if(null===s||null===n)return e;let r,o;if(t){const t=this.zt.sl();if(null===t)return e;r=t,o=t.ee}else{const t=this.zt.ll(s.ui(),-1);if(null===t)return e;if(r=this.zt.Gh(t.ee),null===r)return e;o=t.ee}const h=r.Vt[3],l=this.Us().$s(o,{Vt:r}),a=i.Rt(h,n.Vt);return{Xr:!1,_t:h,Kt:i.Fi(h,n.Vt),xh:i.Yl(h),Sh:i.Zl(h,n.Vt),V:l.ce,ki:a,ee:o}}Us(){return null!==this.Nl||(this.Nl=new Ue(this)),this.Nl}W(){return this.cn}$h(t){const e=t.priceScaleId;void 0!==e&&e!==this.cn.priceScaleId&&this.$t().Xl(this,e),I(this.cn,t),void 0!==t.priceFormat&&(this.Ul(),this.$t().Kl()),this.$t().Gl(this),this.$t().Jl(),this.wn.bt("options")}J(t,e){this.zt.J(t),this.Ql(),this.wn.bt("data"),this.dn.bt("data"),null!==this.El&&(e&&e.ta?this.El.$r():0===t.length&&this.El.Hr());const i=this.$t().dr(this);this.$t().ia(i),this.$t().Gl(this),this.$t().Jl(),this.$t().Uh()}na(t){this.Fl=t,this.Ql();const e=this.$t().dr(this);this.dn.bt("data"),this.$t().ia(e),this.$t().Gl(this),this.$t().Jl(),this.$t().Uh()}sa(){return this.Fl}dh(){return this.Wl}ea(t){const e=new Ie(this,t);return this.zl.push(e),this.$t().Gl(this),e}ra(t){const e=this.zl.indexOf(t);-1!==e&&this.zl.splice(e,1),this.$t().Gl(this)}Qh(){return this.$l}Ct(){const t=this.ha();return null===t?null:{Vt:t.Vt[3],la:t.ot}}ha(){const t=this.$t().St().Xs();if(null===t)return null;const e=t.Os();return this.zt.ll(e,1)}In(){return this.zt}ph(t){const e=this.zt.Gh(t);return null===e?null:"Bar"===this.$l||"Candlestick"===this.$l||"Custom"===this.$l?{ge:e.Vt[0],Me:e.Vt[1],xe:e.Vt[2],Se:e.Vt[3]}:e.Vt[3]}aa(t){const e=[];ei(this.Hl,ii,"top",e);const i=this.El;return null!==i&&i.yt()?(null===this.jl&&i.qr()&&(this.jl=setTimeout(()=>{this.jl=null,this.$t().oa()},0)),i.Ur(),e.unshift(i),e):e}Pn(){const t=[];this._a()||t.push(this.Ll),t.push(this.wn,this.jh,this.dn);const e=this.zl.map(t=>t.qh());return t.push(...e),ei(this.Hl,ii,"normal",t),t}ua(){return this.ca(ii,"bottom")}da(t){return this.ca(si,t)}fa(t){return this.ca(ni,t)}va(t,e){return this.Hl.map(i=>i.wr(t,e)).filter(t=>null!==t)}Ji(t){return[this.Hh,...this.zl.map(t=>t.Yh())]}Rn(t,e){if(e!==this.Yi&&!this._a())return[];const i=[...this.rn];for(const t of this.zl)i.push(t.Zh());return this.Hl.forEach(t=>{i.push(...t.Rn())}),i}Qi(){const t=[];return this.Hl.forEach(e=>{t.push(...e.Qi())}),t}Il(t,e){if(void 0!==this.cn.autoscaleInfoProvider){const i=this.cn.autoscaleInfoProvider(()=>{const i=this.pa(t,e);return null===i?null:i.Bh()});return Be.Ah(i)}return this.pa(t,e)}ma(){return this.cn.priceFormat.minMove}ba(){return this.wa}Vn(){var t;this.wn.bt(),this.dn.bt();for(const t of this.rn)t.bt();for(const t of this.zl)t.bt();this.jh.bt(),this.Ll.bt(),null===(t=this.El)||void 0===t||t.bt(),this.Hl.forEach(t=>t.Vn())}Dt(){return k(super.Dt())}kt(t){if("Line"!==this.$l&&"Area"!==this.$l&&"Baseline"!==this.$l||!this.cn.crosshairMarkerVisible)return null;const e=this.zt.Gh(t);return null===e?null:{_t:e.Vt[3],ht:this.ga(),Ot:this.Ma(),Pt:this.xa(),Tt:this.Sa(t)}}bh(){return this.cn.title}yt(){return this.cn.visible}ka(t){this.Hl.push(new ti(t,this))}ya(t){this.Hl=this.Hl.filter(e=>e.Ol()!==t)}Ca(){if(this.wn instanceof re!=0)return t=>this.wn.We(t)}Ta(){if(this.wn instanceof re!=0)return t=>this.wn.je(t)}_a(){return!yt(this.Dt().Pa())}pa(t,e){if(!j(t)||!j(e)||this.zt.Ni())return null;const i="Line"===this.$l||"Area"===this.$l||"Baseline"===this.$l||"Histogram"===this.$l?[3]:[2,1],s=this.zt.ol(t,e,i);let n=null!==s?new De(s.ml,s.bl):null;if("Histogram"===this.Qh()){const t=this.cn.base,e=new De(t,t);n=null!==n?n.ts(e):e}let r=this.dn.uh();return this.Hl.forEach(i=>{const s=i.Il(t,e);if(null==s?void 0:s.priceRange){const t=new De(s.priceRange.minValue,s.priceRange.maxValue);n=null!==n?n.ts(t):t}var o,h,l,a;(null==s?void 0:s.margins)&&(o=r,h=s.margins,r={above:Math.max(null!==(l=null==o?void 0:o.above)&&void 0!==l?l:0,h.above),below:Math.max(null!==(a=null==o?void 0:o.below)&&void 0!==a?a:0,h.below)})}),new Be(n,r)}ga(){switch(this.$l){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerRadius}return 0}Ma(){switch(this.$l){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}xa(){switch(this.$l){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerBorderWidth}return 0}Sa(t){switch(this.$l){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Us().$s(t).ce}Ul(){switch(this.cn.priceFormat.type){case"custom":this.wa={format:this.cn.priceFormat.formatter};break;case"volume":this.wa=new _t(this.cn.priceFormat.precision);break;case"percent":this.wa=new Mt(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.wa=new Ct(t,this.cn.priceFormat.minMove*t)}}null!==this.Yi&&this.Yi.Ra()}Ql(){const t=this.$t().St();if(!t.Da()||this.zt.Ni())return void(this.Wl=[]);const e=k(this.zt.el());this.Wl=this.Fl.map((i,s)=>{const n=k(t.Va(i.time,!0)),r=n<e?1:-1;return{time:k(this.zt.ll(n,r)).ee,position:i.position,shape:i.shape,color:i.color,id:i.id,th:s,text:i.text,size:i.size,originalTime:i.originalTime}})}ql(t){switch(this.dn=new Oe(this,this.$t()),this.$l){case"Bar":this.wn=new Yt(this,this.$t());break;case"Candlestick":this.wn=new se(this,this.$t());break;case"Line":this.wn=new ae(this,this.$t());break;case"Custom":this.wn=new re(this,this.$t(),z(t));break;case"Area":this.wn=new Jt(this,this.$t());break;case"Baseline":this.wn=new ee(this,this.$t());break;case"Histogram":this.wn=new le(this,this.$t());break;default:throw Error("Unknown chart style assigned: "+this.$l)}}ca(t,e){const i=[];return ei(this.Hl,t,e,i),i}}class oi{constructor(t){this.cn=t}Oa(t,e,i){let s=t;if(0===this.cn.mode)return s;const n=i.vn(),r=n.Ct();if(null===r)return s;const o=n.Rt(t,r),h=i.Ba().filter(t=>t instanceof ri).reduce((t,s)=>{if(i.vr(s)||!s.yt())return t;const n=s.Dt(),r=s.In();if(n.Ni()||!r.Kr(e))return t;const o=r.Gh(e);if(null===o)return t;const h=R(s.Ct());return t.concat([n.Rt(o.Vt[3],h.Vt)])},[]);if(0===h.length)return s;h.sort((t,e)=>Math.abs(t-o)-Math.abs(e-o));const l=h[0];return s=n.pn(l,r),s}}class hi extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;const n=Math.max(1,Math.floor(i));t.lineWidth=n,function(t,e){t.save(),t.lineWidth%2&&t.translate(.5,.5),e(),t.restore()}(t,()=>{const r=k(this.zt);if(r.Aa){t.strokeStyle=r.Ia,M(t,r.za),t.beginPath();for(const s of r.La){const r=Math.round(s.Ea*i);t.moveTo(r,-n),t.lineTo(r,e.height+n)}t.stroke()}if(r.Na){t.strokeStyle=r.Fa,M(t,r.Wa),t.beginPath();for(const i of r.ja){const r=Math.round(i.Ea*s);t.moveTo(-n,r),t.lineTo(e.width+n,r)}t.stroke()}})}}class li{constructor(t){this.Wt=new hi,this.ft=!0,this.tn=t}bt(){this.ft=!0}gt(){if(this.ft){const t=this.tn.$t().W().grid,e={Na:t.horzLines.visible,Aa:t.vertLines.visible,Fa:t.horzLines.color,Ia:t.vertLines.color,Wa:t.horzLines.style,za:t.vertLines.style,ja:this.tn.vn().Ha(),La:(this.tn.$t().St().Ha()||[]).map(t=>({Ea:t.coord}))};this.Wt.J(e),this.ft=!1}return this.Wt}}class ai{constructor(t){this.wn=new li(t)}qh(){return this.wn}}const ci={$a:4,Ua:1e-4};function ui(t,e){const i=100*(t-e)/e;return e<0?-i:i}function di(t,e){const i=ui(t.Ph(),e),s=ui(t.Rh(),e);return new De(i,s)}function fi(t,e){const i=100*(t-e)/e+100;return e<0?-i:i}function mi(t,e){const i=fi(t.Ph(),e),s=fi(t.Rh(),e);return new De(i,s)}function pi(t,e){const i=Math.abs(t);if(i<1e-15)return 0;const s=Math.log10(i+e.Ua)+e.$a;return t<0?-s:s}function gi(t,e){const i=Math.abs(t);if(i<1e-15)return 0;const s=Math.pow(10,i-e.$a)-e.Ua;return t<0?-s:s}function vi(t,e){if(null===t)return null;const i=pi(t.Ph(),e),s=pi(t.Rh(),e);return new De(i,s)}function bi(t,e){if(null===t)return null;const i=gi(t.Ph(),e),s=gi(t.Rh(),e);return new De(i,s)}function wi(t){if(null===t)return ci;const e=Math.abs(t.Rh()-t.Ph());if(e>=1||e<1e-15)return ci;const i=Math.ceil(Math.abs(Math.log10(e))),s=ci.$a+i;return{$a:s,Ua:1/Math.pow(10,s)}}class yi{constructor(t,e){if(this.qa=t,this.Ya=e,function(t){if(t<0)return!1;for(let e=t;e>1;e/=10)if(e%10!=0)return!1;return!0}(this.qa))this.Za=[2,2.5,2];else{this.Za=[];for(let t=this.qa;1!==t;){if(t%2==0)this.Za.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Za.push(2,2.5),t/=5}if(this.Za.length>100)throw new Error("something wrong with base")}}}Xa(t,e,i){const s=0===this.qa?0:1/this.qa;let n=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-e)))),r=0,o=this.Ya[0];for(;;){const t=$t(n,s,1e-14)&&n>s+1e-14,e=$t(n,i*o,1e-14),h=$t(n,1,1e-14);if(!(t&&e&&h))break;n/=o,o=this.Ya[++r%this.Ya.length]}if(n<=s+1e-14&&(n=s),n=Math.max(1,n),this.Za.length>0&&(h=n,Math.abs(h-1)<1e-14))for(r=0,o=this.Za[0];$t(n,i*o,1e-14)&&n>s+1e-14;)n/=o,o=this.Za[++r%this.Za.length];var h;return n}}class Si{constructor(t,e,i,s){this.Ka=[],this.Li=t,this.qa=e,this.Ga=i,this.Ja=s}Xa(t,e){if(t<e)throw new Error("high < low");const i=this.Li.At(),s=(t-e)*this.Qa()/i,n=new yi(this.qa,[2,2.5,2]),r=new yi(this.qa,[2,2,2.5]),o=new yi(this.qa,[2.5,2,2]),h=[];return h.push(n.Xa(t,e,s),r.Xa(t,e,s),o.Xa(t,e,s)),function(t){if(t.length<1)throw Error("array is empty");let e=t[0];for(let i=1;i<t.length;++i)t[i]<e&&(e=t[i]);return e}(h)}io(){const t=this.Li,e=t.Ct();if(null===e)return void(this.Ka=[]);const i=t.At(),s=this.Ga(i-1,e),n=this.Ga(0,e),r=this.Li.W().entireTextOnly?this.no()/2:0,o=r,h=i-1-r,l=Math.max(s,n),a=Math.min(s,n);if(l===a)return void(this.Ka=[]);let c=this.Xa(l,a),u=l%c;u+=u<0?c:0;const d=l>=a?1:-1;let f=null,m=0;for(let i=l-u;i>a;i-=c){const s=this.Ja(i,e,!0);null!==f&&Math.abs(s-f)<this.Qa()||s<o||s>h||(m<this.Ka.length?(this.Ka[m].Ea=s,this.Ka[m].so=t.eo(i)):this.Ka.push({Ea:s,so:t.eo(i)}),m++,f=s,t.ro()&&(c=this.Xa(i*d,a)))}this.Ka.length=m}Ha(){return this.Ka}no(){return this.Li.P()}Qa(){return Math.ceil(2.5*this.no())}}function xi(t){return t.slice().sort((t,e)=>k(t.Xi())-k(e.Xi()))}var Ci;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(Ci||(Ci={}));const Mi=new Mt,_i=new Ct(100,1);class Ei{constructor(t,e,i,s){this.ho=0,this.lo=null,this.Ih=null,this.ao=null,this.oo={_o:!1,uo:null},this.co=0,this.do=0,this.fo=new A,this.vo=new A,this.po=[],this.mo=null,this.bo=null,this.wo=null,this.Mo=null,this.wa=_i,this.xo=wi(null),this.So=t,this.cn=e,this.ko=i,this.yo=s,this.Co=new Si(this,100,this.To.bind(this),this.Po.bind(this))}Pa(){return this.So}W(){return this.cn}$h(t){if(I(this.cn,t),this.Ra(),void 0!==t.mode&&this.Ro({Cr:t.mode}),void 0!==t.scaleMargins){const e=z(t.scaleMargins.top),i=z(t.scaleMargins.bottom);if(e<0||e>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${e}`);if(i<0||i>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${i}`);if(e+i>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${e+i}`);this.Do(),this.bo=null}}Vo(){return this.cn.autoScale}ro(){return 1===this.cn.mode}Mh(){return 2===this.cn.mode}Oo(){return 3===this.cn.mode}Cr(){return{Wn:this.cn.autoScale,Bo:this.cn.invertScale,Cr:this.cn.mode}}Ro(t){const e=this.Cr();let i=null;void 0!==t.Wn&&(this.cn.autoScale=t.Wn),void 0!==t.Cr&&(this.cn.mode=t.Cr,2!==t.Cr&&3!==t.Cr||(this.cn.autoScale=!0),this.oo._o=!1),1===e.Cr&&t.Cr!==e.Cr&&(function(t,e){if(null===t)return!1;const i=gi(t.Ph(),e),s=gi(t.Rh(),e);return isFinite(i)&&isFinite(s)}(this.Ih,this.xo)?(i=bi(this.Ih,this.xo),null!==i&&this.Ao(i)):this.cn.autoScale=!0),1===t.Cr&&t.Cr!==e.Cr&&(i=vi(this.Ih,this.xo),null!==i&&this.Ao(i));const s=e.Cr!==this.cn.mode;s&&(2===e.Cr||this.Mh())&&this.Ra(),s&&(3===e.Cr||this.Oo())&&this.Ra(),void 0!==t.Bo&&e.Bo!==t.Bo&&(this.cn.invertScale=t.Bo,this.Io()),this.vo.m(e,this.Cr())}zo(){return this.vo}P(){return this.ko.fontSize}At(){return this.ho}Lo(t){this.ho!==t&&(this.ho=t,this.Do(),this.bo=null)}Eo(){if(this.lo)return this.lo;const t=this.At()-this.No()-this.Fo();return this.lo=t,t}Lh(){return this.Wo(),this.Ih}Ao(t,e){const i=this.Ih;(e||null===i&&null!==t||null!==i&&!i.Ch(t))&&(this.bo=null,this.Ih=t)}Ni(){return this.Wo(),0===this.ho||!this.Ih||this.Ih.Ni()}jo(t){return this.Bo()?t:this.At()-1-t}Rt(t,e){return this.Mh()?t=ui(t,e):this.Oo()&&(t=fi(t,e)),this.Po(t,e)}te(t,e,i){this.Wo();const s=this.Fo(),n=k(this.Lh()),r=n.Ph(),o=n.Rh(),h=this.Eo()-1,l=this.Bo(),a=h/(o-r),c=void 0===i?0:i.from,u=void 0===i?t.length:i.to,d=this.Ho();for(let i=c;i<u;i++){const n=t[i],o=n._t;if(isNaN(o))continue;let h=o;null!==d&&(h=d(n._t,e));const c=s+a*(h-r),u=l?c:this.ho-1-c;n.st=u}}be(t,e,i){this.Wo();const s=this.Fo(),n=k(this.Lh()),r=n.Ph(),o=n.Rh(),h=this.Eo()-1,l=this.Bo(),a=h/(o-r),c=void 0===i?0:i.from,u=void 0===i?t.length:i.to,d=this.Ho();for(let i=c;i<u;i++){const n=t[i];let o=n.ge,h=n.Me,c=n.xe,u=n.Se;null!==d&&(o=d(n.ge,e),h=d(n.Me,e),c=d(n.xe,e),u=d(n.Se,e));let f=s+a*(o-r),m=l?f:this.ho-1-f;n.pe=m,f=s+a*(h-r),m=l?f:this.ho-1-f,n.de=m,f=s+a*(c-r),m=l?f:this.ho-1-f,n.fe=m,f=s+a*(u-r),m=l?f:this.ho-1-f,n.me=m}}pn(t,e){const i=this.To(t,e);return this.$o(i,e)}$o(t,e){let i=t;return this.Mh()?i=function(t,e){return e<0&&(t=-t),t/100*e+e}(i,e):this.Oo()&&(i=function(t,e){return t-=100,e<0&&(t=-t),t/100*e+e}(i,e)),i}Ba(){return this.po}Uo(){if(this.mo)return this.mo;let t=[];for(let e=0;e<this.po.length;e++){const i=this.po[e];null===i.Xi()&&i.Ki(e+1),t.push(i)}return t=xi(t),this.mo=t,this.mo}qo(t){-1===this.po.indexOf(t)&&(this.po.push(t),this.Ra(),this.Yo())}Zo(t){const e=this.po.indexOf(t);if(-1===e)throw new Error("source is not attached to scale");this.po.splice(e,1),0===this.po.length&&(this.Ro({Wn:!0}),this.Ao(null)),this.Ra(),this.Yo()}Ct(){let t=null;for(const e of this.po){const i=e.Ct();null!==i&&(null===t||i.la<t.la)&&(t=i)}return null===t?null:t.Vt}Bo(){return this.cn.invertScale}Ha(){const t=null===this.Ct();if(null!==this.bo&&(t||this.bo.Xo===t))return this.bo.Ha;this.Co.io();const e=this.Co.Ha();return this.bo={Ha:e,Xo:t},this.fo.m(),e}Ko(){return this.fo}Go(t){this.Mh()||this.Oo()||null===this.wo&&null===this.ao&&(this.Ni()||(this.wo=this.ho-t,this.ao=k(this.Lh()).Th()))}Jo(t){if(this.Mh()||this.Oo())return;if(null===this.wo)return;this.Ro({Wn:!1}),(t=this.ho-t)<0&&(t=0);let e=(this.wo+.2*(this.ho-1))/(t+.2*(this.ho-1));const i=k(this.ao).Th();e=Math.max(e,.1),i.Vh(e),this.Ao(i)}Qo(){this.Mh()||this.Oo()||(this.wo=null,this.ao=null)}t_(t){this.Vo()||null===this.Mo&&null===this.ao&&(this.Ni()||(this.Mo=t,this.ao=k(this.Lh()).Th()))}i_(t){if(this.Vo())return;if(null===this.Mo)return;const e=k(this.Lh()).Dh()/(this.Eo()-1);let i=t-this.Mo;this.Bo()&&(i*=-1);const s=i*e,n=k(this.ao).Th();n.Oh(s),this.Ao(n,!0),this.bo=null}n_(){this.Vo()||null!==this.Mo&&(this.Mo=null,this.ao=null)}ba(){return this.wa||this.Ra(),this.wa}Fi(t,e){switch(this.cn.mode){case 2:return this.s_(ui(t,e));case 3:return this.ba().format(fi(t,e));default:return this.Wh(t)}}eo(t){switch(this.cn.mode){case 2:return this.s_(t);case 3:return this.ba().format(t);default:return this.Wh(t)}}Yl(t){return this.Wh(t,k(this.e_()).ba())}Zl(t,e){return t=ui(t,e),this.s_(t,Mi)}r_(){return this.po}h_(t){this.oo={uo:t,_o:!1}}Vn(){this.po.forEach(t=>t.Vn())}Ra(){this.bo=null;const t=this.e_();let e=100;null!==t&&(e=Math.round(1/t.ma())),this.wa=_i,this.Mh()?(this.wa=Mi,e=100):this.Oo()?(this.wa=new Ct(100,1),e=100):null!==t&&(this.wa=t.ba()),this.Co=new Si(this,e,this.To.bind(this),this.Po.bind(this)),this.Co.io()}Yo(){this.mo=null}e_(){return this.po[0]||null}No(){return this.Bo()?this.cn.scaleMargins.bottom*this.At()+this.do:this.cn.scaleMargins.top*this.At()+this.co}Fo(){return this.Bo()?this.cn.scaleMargins.top*this.At()+this.co:this.cn.scaleMargins.bottom*this.At()+this.do}Wo(){this.oo._o||(this.oo._o=!0,this.l_())}Do(){this.lo=null}Po(t,e){if(this.Wo(),this.Ni())return 0;t=this.ro()&&t?pi(t,this.xo):t;const i=k(this.Lh()),s=this.Fo()+(this.Eo()-1)*(t-i.Ph())/i.Dh();return this.jo(s)}To(t,e){if(this.Wo(),this.Ni())return 0;const i=this.jo(t),s=k(this.Lh()),n=s.Ph()+s.Dh()*((i-this.Fo())/(this.Eo()-1));return this.ro()?gi(n,this.xo):n}Io(){this.bo=null,this.Co.io()}l_(){const t=this.oo.uo;if(null===t)return;let e=null;const i=this.r_();let s=0,n=0;for(const r of i){if(!r.yt())continue;const i=r.Ct();if(null===i)continue;const o=r.Il(t.Os(),t.ui());let h=o&&o.Lh();if(null!==h){switch(this.cn.mode){case 1:h=vi(h,this.xo);break;case 2:h=di(h,i.Vt);break;case 3:h=mi(h,i.Vt)}if(e=null===e?h:e.ts(k(h)),null!==o){const t=o.Eh();null!==t&&(s=Math.max(s,t.above),n=Math.max(n,t.below))}}}if(s===this.co&&n===this.do||(this.co=s,this.do=n,this.bo=null,this.Do()),null!==e){if(e.Ph()===e.Rh()){const t=this.e_(),i=5*(null===t||this.Mh()||this.Oo()?1:t.ma());this.ro()&&(e=bi(e,this.xo)),e=new De(e.Ph()-i,e.Rh()+i),this.ro()&&(e=vi(e,this.xo))}if(this.ro()){const t=bi(e,this.xo),i=wi(t);if(r=i,o=this.xo,r.$a!==o.$a||r.Ua!==o.Ua){const s=null!==this.ao?bi(this.ao,this.xo):null;this.xo=i,e=vi(t,i),null!==s&&(this.ao=vi(s,i))}}this.Ao(e)}else null===this.Ih&&(this.Ao(new De(-.5,.5)),this.xo=wi(null));var r,o;this.oo._o=!0}Ho(){return this.Mh()?ui:this.Oo()?fi:this.ro()?t=>pi(t,this.xo):null}a_(t,e,i){return void 0===e?(void 0===i&&(i=this.ba()),i.format(t)):e(t)}Wh(t,e){return this.a_(t,this.yo.priceFormatter,e)}s_(t,e){return this.a_(t,this.yo.percentageFormatter,e)}}class zi{constructor(t,e){this.po=[],this.o_=new Map,this.ho=0,this.__=0,this.u_=1e3,this.mo=null,this.c_=new A,this.yl=t,this.$i=e,this.d_=new ai(this);const i=e.W();this.f_=this.v_("left",i.leftPriceScale),this.p_=this.v_("right",i.rightPriceScale),this.f_.zo().l(this.m_.bind(this,this.f_),this),this.p_.zo().l(this.m_.bind(this,this.p_),this),this.b_(i)}b_(t){if(t.leftPriceScale&&this.f_.$h(t.leftPriceScale),t.rightPriceScale&&this.p_.$h(t.rightPriceScale),t.localization&&(this.f_.Ra(),this.p_.Ra()),t.overlayPriceScales){const e=Array.from(this.o_.values());for(const i of e){const e=k(i[0].Dt());e.$h(t.overlayPriceScales),t.localization&&e.Ra()}}}w_(t){switch(t){case"left":return this.f_;case"right":return this.p_}return this.o_.has(t)?z(this.o_.get(t))[0].Dt():null}S(){this.$t().g_().p(this),this.f_.zo().p(this),this.p_.zo().p(this),this.po.forEach(t=>{t.S&&t.S()}),this.c_.m()}M_(){return this.u_}x_(t){this.u_=t}$t(){return this.$i}Hi(){return this.__}At(){return this.ho}S_(t){this.__=t,this.k_()}Lo(t){this.ho=t,this.f_.Lo(t),this.p_.Lo(t),this.po.forEach(e=>{if(this.vr(e)){const i=e.Dt();null!==i&&i.Lo(t)}}),this.k_()}Ba(){return this.po}vr(t){const e=t.Dt();return null===e||this.f_!==e&&this.p_!==e}qo(t,e,i){const s=void 0!==i?i:this.C_().y_+1;this.T_(t,e,s)}Zo(t){const e=this.po.indexOf(t);E(-1!==e,"removeDataSource: invalid data source"),this.po.splice(e,1);const i=k(t.Dt()).Pa();if(this.o_.has(i)){const e=z(this.o_.get(i)),s=e.indexOf(t);-1!==s&&(e.splice(s,1),0===e.length&&this.o_.delete(i))}const s=t.Dt();s&&s.Ba().indexOf(t)>=0&&s.Zo(t),null!==s&&(s.Yo(),this.P_(s)),this.mo=null}mr(t){return t===this.f_?"left":t===this.p_?"right":"overlay"}R_(){return this.f_}D_(){return this.p_}V_(t,e){t.Go(e)}O_(t,e){t.Jo(e),this.k_()}B_(t){t.Qo()}A_(t,e){t.t_(e)}I_(t,e){t.i_(e),this.k_()}z_(t){t.n_()}k_(){this.po.forEach(t=>{t.Vn()})}vn(){let t=null;return this.$i.W().rightPriceScale.visible&&0!==this.p_.Ba().length?t=this.p_:this.$i.W().leftPriceScale.visible&&0!==this.f_.Ba().length?t=this.f_:0!==this.po.length&&(t=this.po[0].Dt()),null===t&&(t=this.p_),t}pr(){let t=null;return this.$i.W().rightPriceScale.visible?t=this.p_:this.$i.W().leftPriceScale.visible&&(t=this.f_),t}P_(t){null!==t&&t.Vo()&&this.L_(t)}E_(t){const e=this.yl.Xs();t.Ro({Wn:!0}),null!==e&&t.h_(e),this.k_()}N_(){this.L_(this.f_),this.L_(this.p_)}F_(){this.P_(this.f_),this.P_(this.p_),this.po.forEach(t=>{this.vr(t)&&this.P_(t.Dt())}),this.k_(),this.$i.Uh()}Uo(){return null===this.mo&&(this.mo=xi(this.po)),this.mo}W_(){return this.c_}j_(){return this.d_}L_(t){const e=t.r_();if(e&&e.length>0&&!this.yl.Ni()){const e=this.yl.Xs();null!==e&&t.h_(e)}t.Vn()}C_(){const t=this.Uo();if(0===t.length)return{H_:0,y_:0};let e=0,i=0;for(let s=0;s<t.length;s++){const n=t[s].Xi();null!==n&&(n<e&&(e=n),n>i&&(i=n))}return{H_:e,y_:i}}T_(t,e,i){let s=this.w_(e);if(null===s&&(s=this.v_(e,this.$i.W().overlayPriceScales)),this.po.push(t),!yt(e)){const i=this.o_.get(e)||[];i.push(t),this.o_.set(e,i)}s.qo(t),t.Gi(s),t.Ki(i),this.P_(s),this.mo=null}m_(t,e,i){e.Cr!==i.Cr&&this.L_(t)}v_(t,e){const i=Object.assign({visible:!0,autoScale:!0},K(e)),s=new Ei(t,i,this.$i.W().layout,this.$i.W().localization);return s.Lo(this.At()),s}}class ki{constructor(t,e,i=50){this.Ke=0,this.Ge=1,this.Je=1,this.tr=new Map,this.Qe=new Map,this.U_=t,this.q_=e,this.ir=i}Y_(t){const e=t.time,i=this.q_.cacheKey(e),s=this.tr.get(i);if(void 0!==s)return s.Z_;if(this.Ke===this.ir){const t=this.Qe.get(this.Je);this.Qe.delete(this.Je),this.tr.delete(z(t)),this.Je++,this.Ke--}const n=this.U_(t);return this.tr.set(i,{Z_:n,rr:this.Ge}),this.Qe.set(this.Ge,i),this.Ke++,this.Ge++,n}}class Ri{constructor(t,e){E(t<=e,"right should be >= left"),this.X_=t,this.K_=e}Os(){return this.X_}ui(){return this.K_}G_(){return this.K_-this.X_+1}Kr(t){return this.X_<=t&&t<=this.K_}Ch(t){return this.X_===t.Os()&&this.K_===t.ui()}}function Li(t,e){return null===t||null===e?t===e:t.Ch(e)}class Ti{constructor(){this.J_=new Map,this.tr=null,this.Q_=!1}tu(t){this.Q_=t,this.tr=null}iu(t,e){this.nu(e),this.tr=null;for(let i=e;i<t.length;++i){const e=t[i];let s=this.J_.get(e.timeWeight);void 0===s&&(s=[],this.J_.set(e.timeWeight,s)),s.push({index:i,time:e.time,weight:e.timeWeight,originalTime:e.originalTime})}}su(t,e){const i=Math.ceil(e/t);return null!==this.tr&&this.tr.eu===i||(this.tr={Ha:this.ru(i),eu:i}),this.tr.Ha}nu(t){if(0===t)return void this.J_.clear();const e=[];this.J_.forEach((i,s)=>{t<=i[0].index?e.push(s):i.splice(Wt(i,t,e=>e.index<t),1/0)});for(const t of e)this.J_.delete(t)}ru(t){let e=[];for(const i of Array.from(this.J_.keys()).sort((t,e)=>e-t)){if(!this.J_.get(i))continue;const s=e;e=[];const n=s.length;let r=0;const o=z(this.J_.get(i)),h=o.length;let l=1/0,a=-1/0;for(let i=0;i<h;i++){const h=o[i],c=h.index;for(;r<n;){const t=s[r],i=t.index;if(!(i<c)){l=i;break}r++,e.push(t),a=i,l=1/0}if(l-c>=t&&c-a>=t)e.push(h),a=c;else if(this.Q_)return s}for(;r<n;r++)e.push(s[r])}return e}}class Ni{constructor(t){this.hu=t}lu(){return null===this.hu?null:new Ri(Math.floor(this.hu.Os()),Math.ceil(this.hu.ui()))}au(){return this.hu}static ou(){return new Ni(null)}}function Oi(t,e){return t.weight>e.weight?t:e}class $i{constructor(t,e,i,s){this.__=0,this._u=null,this.uu=[],this.Mo=null,this.wo=null,this.cu=new Ti,this.du=new Map,this.fu=Ni.ou(),this.vu=!0,this.pu=new A,this.mu=new A,this.bu=new A,this.wu=null,this.gu=null,this.Mu=[],this.cn=e,this.yo=i,this.xu=e.rightOffset,this.Su=e.barSpacing,this.$i=t,this.q_=s,this.ku(),this.cu.tu(e.uniformDistribution)}W(){return this.cn}yu(t){I(this.yo,t),this.Cu(),this.ku()}$h(t,e){var i;I(this.cn,t),this.cn.fixLeftEdge&&this.Tu(),this.cn.fixRightEdge&&this.Pu(),void 0!==t.barSpacing&&this.$i.Gn(t.barSpacing),void 0!==t.rightOffset&&this.$i.Jn(t.rightOffset),void 0!==t.minBarSpacing&&this.$i.Gn(null!==(i=t.barSpacing)&&void 0!==i?i:this.Su),this.Cu(),this.ku(),this.bu.m()}mn(t){var e,i;return null!==(i=null===(e=this.uu[t])||void 0===e?void 0:e.time)&&void 0!==i?i:null}Ui(t){var e;return null!==(e=this.uu[t])&&void 0!==e?e:null}Va(t,e){if(this.uu.length<1)return null;if(this.q_.key(t)>this.q_.key(this.uu[this.uu.length-1].time))return e?this.uu.length-1:null;const i=Wt(this.uu,this.q_.key(t),(t,e)=>this.q_.key(t.time)<e);return this.q_.key(t)<this.q_.key(this.uu[i].time)?e?i:null:i}Ni(){return 0===this.__||0===this.uu.length||null===this._u}Da(){return this.uu.length>0}Xs(){return this.Ru(),this.fu.lu()}Du(){return this.Ru(),this.fu.au()}Vu(){const t=this.Xs();if(null===t)return null;const e={from:t.Os(),to:t.ui()};return this.Ou(e)}Ou(t){const e=Math.round(t.from),i=Math.round(t.to),s=k(this.Bu()),n=k(this.Au());return{from:k(this.Ui(Math.max(s,e))),to:k(this.Ui(Math.min(n,i)))}}Iu(t){return{from:k(this.Va(t.from,!0)),to:k(this.Va(t.to,!0))}}Hi(){return this.__}S_(t){if(!isFinite(t)||t<=0)return;if(this.__===t)return;const e=this.Du(),i=this.__;if(this.__=t,this.vu=!0,this.cn.lockVisibleTimeRangeOnResize&&0!==i){const e=this.Su*t/i;this.Su=e}if(this.cn.fixLeftEdge&&null!==e&&e.Os()<=0){const e=i-t;this.xu-=Math.round(e/this.Su)+1,this.vu=!0}this.zu(),this.Lu()}It(t){if(this.Ni()||!j(t))return 0;const e=this.Eu()+this.xu-t;return this.__-(e+.5)*this.Su-1}Qs(t,e){const i=this.Eu(),s=void 0===e?0:e.from,n=void 0===e?t.length:e.to;for(let e=s;e<n;e++){const s=t[e].ot,n=i+this.xu-s,r=this.__-(n+.5)*this.Su-1;t[e].nt=r}}Nu(t){return Math.ceil(this.Fu(t))}Jn(t){this.vu=!0,this.xu=t,this.Lu(),this.$i.Wu(),this.$i.Uh()}le(){return this.Su}Gn(t){this.ju(t),this.Lu(),this.$i.Wu(),this.$i.Uh()}Hu(){return this.xu}Ha(){if(this.Ni())return null;if(null!==this.gu)return this.gu;const t=this.Su,e=5*(this.$i.W().layout.fontSize+4)/8*(this.cn.tickMarkMaxCharacterLength||8),i=Math.round(e/t),s=k(this.Xs()),n=Math.max(s.Os(),s.Os()-i),r=Math.max(s.ui(),s.ui()-i),o=this.cu.su(t,e),h=this.Bu()+i,l=this.Au()-i,a=this.$u(),c=this.cn.fixLeftEdge||a,u=this.cn.fixRightEdge||a;let d=0;for(const t of o){if(!(n<=t.index&&t.index<=r))continue;let i;d<this.Mu.length?(i=this.Mu[d],i.coord=this.It(t.index),i.label=this.Uu(t),i.weight=t.weight):(i={needAlignCoordinate:!1,coord:this.It(t.index),label:this.Uu(t),weight:t.weight},this.Mu.push(i)),this.Su>e/2&&!a?i.needAlignCoordinate=!1:i.needAlignCoordinate=c&&t.index<=h||u&&t.index>=l,d++}return this.Mu.length=d,this.gu=this.Mu,this.Mu}qu(){this.vu=!0,this.Gn(this.cn.barSpacing),this.Jn(this.cn.rightOffset)}Yu(t){this.vu=!0,this._u=t,this.Lu(),this.Tu()}Zu(t,e){const i=this.Fu(t),s=this.le(),n=s+e*(s/10);this.Gn(n),this.cn.rightBarStaysOnScroll||this.Jn(this.Hu()+(i-this.Fu(t)))}Go(t){this.Mo&&this.n_(),null===this.wo&&null===this.wu&&(this.Ni()||(this.wo=t,this.Xu()))}Jo(t){if(null===this.wu)return;const e=Ot(this.__-t,0,this.__),i=Ot(this.__-k(this.wo),0,this.__);0!==e&&0!==i&&this.Gn(this.wu.le*e/i)}Qo(){null!==this.wo&&(this.wo=null,this.Ku())}t_(t){null===this.Mo&&null===this.wu&&(this.Ni()||(this.Mo=t,this.Xu()))}i_(t){if(null===this.Mo)return;const e=(this.Mo-t)/this.le();this.xu=k(this.wu).Hu+e,this.vu=!0,this.Lu()}n_(){null!==this.Mo&&(this.Mo=null,this.Ku())}Gu(){this.Ju(this.cn.rightOffset)}Ju(t,e=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(e)||e<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const i=this.xu,s=performance.now();this.$i.Zn({Qu:t=>(t-s)/e>=1,tc:n=>{const r=(n-s)/e;return r>=1?t:i+(t-i)*r}})}bt(t,e){this.vu=!0,this.uu=t,this.cu.iu(t,e),this.Lu()}nc(){return this.pu}sc(){return this.mu}ec(){return this.bu}Eu(){return this._u||0}rc(t){const e=t.G_();this.ju(this.__/e),this.xu=t.ui()-this.Eu(),this.Lu(),this.vu=!0,this.$i.Wu(),this.$i.Uh()}hc(){const t=this.Bu(),e=this.Au();null!==t&&null!==e&&this.rc(new Ri(t,e+this.cn.rightOffset))}lc(t){const e=new Ri(t.from,t.to);this.rc(e)}qi(t){return void 0!==this.yo.timeFormatter?this.yo.timeFormatter(t.originalTime):this.q_.formatHorzItem(t.time)}$u(){const{handleScroll:t,handleScale:e}=this.$i.W();return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||e.axisDoubleClickReset.time||e.axisPressedMouseMove.time||e.mouseWheel||e.pinch)}Bu(){return 0===this.uu.length?null:0}Au(){return 0===this.uu.length?null:this.uu.length-1}ac(t){return(this.__-1-t)/this.Su}Fu(t){const e=this.ac(t),i=this.Eu()+this.xu-e;return Math.round(1e6*i)/1e6}ju(t){const e=this.Su;this.Su=t,this.zu(),e!==this.Su&&(this.vu=!0,this.oc())}Ru(){if(!this.vu)return;if(this.vu=!1,this.Ni())return void this._c(Ni.ou());const t=this.Eu(),e=this.__/this.Su,i=this.xu+t,s=new Ri(i-e+1,i);this._c(new Ni(s))}zu(){const t=this.uc();if(this.Su<t&&(this.Su=t,this.vu=!0),0!==this.__){const t=.5*this.__;this.Su>t&&(this.Su=t,this.vu=!0)}}uc(){return this.cn.fixLeftEdge&&this.cn.fixRightEdge&&0!==this.uu.length?this.__/this.uu.length:this.cn.minBarSpacing}Lu(){const t=this.cc();null!==t&&this.xu<t&&(this.xu=t,this.vu=!0);const e=this.dc();this.xu>e&&(this.xu=e,this.vu=!0)}cc(){const t=this.Bu(),e=this._u;return null===t||null===e?null:t-e-1+(this.cn.fixLeftEdge?this.__/this.Su:Math.min(2,this.uu.length))}dc(){return this.cn.fixRightEdge?0:this.__/this.Su-Math.min(2,this.uu.length)}Xu(){this.wu={le:this.le(),Hu:this.Hu()}}Ku(){this.wu=null}Uu(t){let e=this.du.get(t.weight);return void 0===e&&(e=new ki(t=>this.fc(t),this.q_),this.du.set(t.weight,e)),e.Y_(t)}fc(t){return this.q_.formatTickmark(t,this.yo)}_c(t){const e=this.fu;this.fu=t,Li(e.lu(),this.fu.lu())||this.pu.m(),Li(e.au(),this.fu.au())||this.mu.m(),this.oc()}oc(){this.gu=null}Cu(){this.oc(),this.du.clear()}ku(){this.q_.updateFormatter(this.yo)}Tu(){if(!this.cn.fixLeftEdge)return;const t=this.Bu();if(null===t)return;const e=this.Xs();if(null===e)return;const i=e.Os()-t;if(i<0){const t=this.xu-i-1;this.Jn(t)}this.zu()}Pu(){this.Lu(),this.zu()}}class Pi{X(t,e,i){t.useMediaCoordinateSpace(t=>this.K(t,e,i))}gl(t,e,i){t.useMediaCoordinateSpace(t=>this.vc(t,e,i))}vc(t,e,i){}}class Vi extends Pi{constructor(t){super(),this.mc=new Map,this.zt=t}K(t){}vc(t){if(!this.zt.yt)return;const{context:e,mediaSize:i}=t;let s=0;for(const t of this.zt.bc){if(0===t.Kt.length)continue;e.font=t.R;const n=this.wc(e,t.Kt);n>i.width?t.Zu=i.width/n:t.Zu=1,s+=t.gc*t.Zu}let n=0;switch(this.zt.Mc){case"top":n=0;break;case"center":n=Math.max((i.height-s)/2,0);break;case"bottom":n=Math.max(i.height-s,0)}e.fillStyle=this.zt.V;for(const t of this.zt.bc){e.save();let s=0;switch(this.zt.xc){case"left":e.textAlign="left",s=t.gc/2;break;case"center":e.textAlign="center",s=i.width/2;break;case"right":e.textAlign="right",s=i.width-1-t.gc/2}e.translate(s,n),e.textBaseline="top",e.font=t.R,e.scale(t.Zu,t.Zu),e.fillText(t.Kt,0,t.Sc),e.restore(),n+=t.gc*t.Zu}}wc(t,e){const i=this.kc(t.font);let s=i.get(e);return void 0===s&&(s=t.measureText(e).width,i.set(e,s)),s}kc(t){let e=this.mc.get(t);return void 0===e&&(e=new Map,this.mc.set(t,e)),e}}class Di{constructor(t){this.ft=!0,this.Ft={yt:!1,V:"",bc:[],Mc:"center",xc:"center"},this.Wt=new Vi(this.Ft),this.jt=t}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt}Mt(){const t=this.jt.W(),e=this.Ft;e.yt=t.visible,e.yt&&(e.V=t.color,e.xc=t.horzAlign,e.Mc=t.vertAlign,e.bc=[{Kt:t.text,R:G(t.fontSize,t.fontFamily,t.fontStyle),gc:1.2*t.fontSize,Sc:0,Zu:0}])}}class Bi extends vt{constructor(t,e){super(),this.cn=e,this.wn=new Di(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}Vn(){this.wn.bt()}}var Fi,Ai,Ii,Wi,ji;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Fi||(Fi={}));class Ui{constructor(t,e,i){this.yc=[],this.Cc=[],this.__=0,this.Tc=null,this.Pc=new A,this.Rc=new A,this.Dc=null,this.Vc=t,this.cn=e,this.q_=i,this.Oc=new Q(this),this.yl=new $i(this,e.timeScale,this.cn.localization,i),this.vt=new wt(this,e.crosshair),this.Bc=new oi(e.crosshair),this.Ac=new Bi(this,e.watermark),this.Ic(),this.yc[0].x_(2e3),this.zc=this.Lc(0),this.Ec=this.Lc(1)}Kl(){this.Nc(St.es())}Uh(){this.Nc(St.ss())}oa(){this.Nc(new St(1))}Gl(t){const e=this.Fc(t);this.Nc(e)}Wc(){return this.Tc}jc(t){const e=this.Tc;this.Tc=t,null!==e&&this.Gl(e.Hc),null!==t&&this.Gl(t.Hc)}W(){return this.cn}$h(t){I(this.cn,t),this.yc.forEach(e=>e.b_(t)),void 0!==t.timeScale&&this.yl.$h(t.timeScale),void 0!==t.localization&&this.yl.yu(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Pc.m(),this.zc=this.Lc(0),this.Ec=this.Lc(1),this.Kl()}$c(t,e){if("left"===t)return void this.$h({leftPriceScale:e});if("right"===t)return void this.$h({rightPriceScale:e});const i=this.Uc(t);null!==i&&(i.Dt.$h(e),this.Pc.m())}Uc(t){for(const e of this.yc){const i=e.w_(t);if(null!==i)return{Ht:e,Dt:i}}return null}St(){return this.yl}qc(){return this.yc}Yc(){return this.Ac}Zc(){return this.vt}Xc(){return this.Rc}Kc(t,e){t.Lo(e),this.Wu()}S_(t){this.__=t,this.yl.S_(this.__),this.yc.forEach(e=>e.S_(t)),this.Wu()}Ic(t){const e=new zi(this.yl,this);void 0!==t?this.yc.splice(t,0,e):this.yc.push(e);const i=void 0===t?this.yc.length-1:t,s=St.es();return s.Nn(i,{Fn:0,Wn:!0}),this.Nc(s),e}V_(t,e,i){t.V_(e,i)}O_(t,e,i){t.O_(e,i),this.Jl(),this.Nc(this.Gc(t,2))}B_(t,e){t.B_(e),this.Nc(this.Gc(t,2))}A_(t,e,i){e.Vo()||t.A_(e,i)}I_(t,e,i){e.Vo()||(t.I_(e,i),this.Jl(),this.Nc(this.Gc(t,2)))}z_(t,e){e.Vo()||(t.z_(e),this.Nc(this.Gc(t,2)))}E_(t,e){t.E_(e),this.Nc(this.Gc(t,2))}Jc(t){this.yl.Go(t)}Qc(t,e){const i=this.St();if(i.Ni()||0===e)return;const s=i.Hi();t=Math.max(1,Math.min(t,s)),i.Zu(t,e),this.Wu()}td(t){this.nd(0),this.sd(t),this.ed()}rd(t){this.yl.Jo(t),this.Wu()}hd(){this.yl.Qo(),this.Uh()}nd(t){this.yl.t_(t)}sd(t){this.yl.i_(t),this.Wu()}ed(){this.yl.n_(),this.Uh()}wt(){return this.Cc}ld(t,e,i,s,n){this.vt.gn(t,e);let r=NaN,o=this.yl.Nu(t);const h=this.yl.Xs();null!==h&&(o=Math.min(Math.max(h.Os(),o),h.ui()));const l=s.vn(),a=l.Ct();null!==a&&(r=l.pn(e,a)),r=this.Bc.Oa(r,o,s),this.vt.kn(o,r,s),this.oa(),n||this.Rc.m(this.vt.xt(),{x:t,y:e},i)}ad(t,e,i){const s=i.vn(),n=s.Ct(),r=s.Rt(t,k(n)),o=this.yl.Va(e,!0),h=this.yl.It(k(o));this.ld(h,r,null,i,!0)}od(t){this.Zc().Cn(),this.oa(),t||this.Rc.m(null,null,null)}Jl(){const t=this.vt.Ht();if(null!==t){const e=this.vt.xn(),i=this.vt.Sn();this.ld(e,i,null,t)}this.vt.Vn()}_d(t,e,i){const s=this.yl.mn(0);void 0!==e&&void 0!==i&&this.yl.bt(e,i);const n=this.yl.mn(0),r=this.yl.Eu(),o=this.yl.Xs();if(null!==o&&null!==s&&null!==n){const e=o.Kr(r),h=this.q_.key(s)>this.q_.key(n),l=null!==t&&t>r&&!h,a=this.yl.W().allowShiftVisibleRangeOnWhitespaceReplacement,c=e&&(!(void 0===i)||a)&&this.yl.W().shiftVisibleRangeOnNewBar;if(l&&!c){const e=t-r;this.yl.Jn(this.yl.Hu()-e)}}this.yl.Yu(t)}ia(t){null!==t&&t.F_()}dr(t){const e=this.yc.find(e=>e.Uo().includes(t));return void 0===e?null:e}Wu(){this.Ac.Vn(),this.yc.forEach(t=>t.F_()),this.Jl()}S(){this.yc.forEach(t=>t.S()),this.yc.length=0,this.cn.localization.priceFormatter=void 0,this.cn.localization.percentageFormatter=void 0,this.cn.localization.timeFormatter=void 0}ud(){return this.Oc}br(){return this.Oc.W()}g_(){return this.Pc}dd(t,e,i){const s=this.yc[0],n=this.fd(e,t,s,i);return this.Cc.push(n),1===this.Cc.length?this.Kl():this.Uh(),n}vd(t){const e=this.dr(t),i=this.Cc.indexOf(t);E(-1!==i,"Series not found"),this.Cc.splice(i,1),k(e).Zo(t),t.S&&t.S()}Xl(t,e){const i=k(this.dr(t));i.Zo(t);const s=this.Uc(e);if(null===s){const s=t.Xi();i.qo(t,e,s)}else{const n=s.Ht===i?t.Xi():void 0;s.Ht.qo(t,e,n)}}hc(){const t=St.ss();t.$n(),this.Nc(t)}pd(t){const e=St.ss();e.Yn(t),this.Nc(e)}Kn(){const t=St.ss();t.Kn(),this.Nc(t)}Gn(t){const e=St.ss();e.Gn(t),this.Nc(e)}Jn(t){const e=St.ss();e.Jn(t),this.Nc(e)}Zn(t){const e=St.ss();e.Zn(t),this.Nc(e)}Un(){const t=St.ss();t.Un(),this.Nc(t)}md(){return this.cn.rightPriceScale.visible?"right":"left"}bd(){return this.Ec}q(){return this.zc}Bt(t){const e=this.Ec,i=this.zc;if(e===i)return e;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Dc||this.Dc.Ps!==i||this.Dc.Rs!==e)this.Dc={Ps:i,Rs:e,wd:new Map};else{const e=this.Dc.wd.get(t);if(void 0!==e)return e}const s=function(t,e,i){const[s,n,r,o]=D(t),[h,l,a,c]=D(e),u=[T(s+i*(h-s)),T(n+i*(l-n)),T(r+i*(a-r)),N(o+i*(c-o))];return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}(i,e,t/100);return this.Dc.wd.set(t,s),s}Gc(t,e){const i=new St(e);if(null!==t){const s=this.yc.indexOf(t);i.Nn(s,{Fn:e})}return i}Fc(t,e){return void 0===e&&(e=2),this.Gc(this.dr(t),e)}Nc(t){this.Vc&&this.Vc(t),this.yc.forEach(t=>t.j_().qh().bt())}fd(t,e,i,s){const n=new ri(this,t,e,i,s),r=void 0!==t.priceScaleId?t.priceScaleId:this.md();return i.qo(n,r),yt(r)||n.$h(t),n}Lc(t){const e=this.cn.layout;return"gradient"===e.background.type?0===t?e.background.topColor:e.background.bottomColor:e.background.color}}function Hi(t){return!W(t)&&!U(t)}function Ki(t){return W(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Ai||(Ai={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ii||(Ii={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Wi||(Wi={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(ji||(ji={}));const qi=t=>t.getUTCFullYear();class Xi{constructor(t="yyyy-MM-dd",e="default"){this.gd=t,this.Md=e}Y_(t){return function(t,e,i){return e.replace(/yyyy/g,(t=>xt(qi(t),4))(t)).replace(/yy/g,(t=>xt(qi(t)%100,2))(t)).replace(/MMMM/g,((t,e)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(e,{month:"long"}))(t,i)).replace(/MMM/g,((t,e)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(e,{month:"short"}))(t,i)).replace(/MM/g,(t=>xt((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>xt((t=>t.getUTCDate())(t),2))(t))}(t,this.gd,this.Md)}}class Ji{constructor(t){this.xd=t||"%h:%m:%s"}Y_(t){return this.xd.replace("%h",xt(t.getUTCHours(),2)).replace("%m",xt(t.getUTCMinutes(),2)).replace("%s",xt(t.getUTCSeconds(),2))}}const Gi={Sd:"yyyy-MM-dd",kd:"%h:%m:%s",yd:" ",Cd:"default"};class Qi{constructor(t={}){const e=Object.assign(Object.assign({},Gi),t);this.Td=new Xi(e.Sd,e.Cd),this.Pd=new Ji(e.kd),this.Rd=e.yd}Y_(t){return`${this.Td.Y_(t)}${this.Rd}${this.Pd.Y_(t)}`}}function Yi(t){return 60*t*60*1e3}function Zi(t){return 60*t*1e3}const ts=[{Dd:1e3,Vd:10},{Dd:Zi(1),Vd:20},{Dd:Zi(5),Vd:21},{Dd:Zi(30),Vd:22},{Dd:Yi(1),Vd:30},{Dd:Yi(3),Vd:31},{Dd:Yi(6),Vd:32},{Dd:Yi(12),Vd:33}];function es(t,e){if(t.getUTCFullYear()!==e.getUTCFullYear())return 70;if(t.getUTCMonth()!==e.getUTCMonth())return 60;if(t.getUTCDate()!==e.getUTCDate())return 50;for(let i=ts.length-1;i>=0;--i)if(Math.floor(e.getTime()/ts[i].Dd)!==Math.floor(t.getTime()/ts[i].Dd))return ts[i].Vd;return 0}function is(t){let e=t;if(U(t)&&(e=ns(t)),!Hi(e))throw new Error("time must be of type BusinessDay");const i=new Date(Date.UTC(e.year,e.month-1,e.day,0,0,0,0));return{Od:Math.round(i.getTime()/1e3),Bd:e}}function ss(t){if(!Ki(t))throw new Error("time must be of type isUTCTimestamp");return{Od:t}}function ns(t){const e=new Date(t);if(isNaN(e.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:e.getUTCDate(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}}function rs(t){U(t.time)&&(t.time=ns(t.time))}class os{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(rs)}(t):rs(t)}createConverterToInternalObj(t){return k(function(t){return 0===t.length?null:Hi(t[0].time)||U(t[0].time)?is:ss}(t))}key(t){return"object"==typeof t&&"Od"in t?t.Od:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const e=t;return void 0===e.Bd?new Date(1e3*e.Od).getTime():new Date(Date.UTC(e.Bd.year,e.Bd.month-1,e.Bd.day)).getTime()}convertHorzItemToInternal(t){return Ki(e=t)?ss(e):Hi(e)?is(e):is(ns(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.Ad=new Qi({Sd:e,kd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",yd:" ",Cd:t.locale}):this.Ad=new Xi(e,t.locale)}formatHorzItem(t){const e=t;return this.Ad.Y_(new Date(1e3*e.Od))}formatTickmark(t,e){const i=function(t,e,i){switch(t){case 0:case 10:return e?i?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return e?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.cn.timeScale.timeVisible,this.cn.timeScale.secondsVisible),s=this.cn.timeScale;if(void 0!==s.tickMarkFormatter){const n=s.tickMarkFormatter(t.originalTime,i,e.locale);if(null!==n)return n}return function(t,e,i){const s={};switch(e){case 0:s.year="numeric";break;case 1:s.month="short";break;case 2:s.day="numeric";break;case 3:s.hour12=!1,s.hour="2-digit",s.minute="2-digit";break;case 4:s.hour12=!1,s.hour="2-digit",s.minute="2-digit",s.second="2-digit"}const n=void 0===t.Bd?new Date(1e3*t.Od):new Date(Date.UTC(t.Bd.year,t.Bd.month-1,t.Bd.day));return new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),n.getUTCMilliseconds()).toLocaleString(i,s)}(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(Oi,t[0]).weight;return e>30&&e<50&&(e=30),e}fillWeightsForPoints(t,e){!function(t,e=0){if(0===t.length)return;let i=0===e?null:t[e-1].time.Od,s=null!==i?new Date(1e3*i):null,n=0;for(let r=e;r<t.length;++r){const e=t[r],o=new Date(1e3*e.time.Od);null!==s&&(e.timeWeight=es(o,s)),n+=e.time.Od-(i||e.time.Od),i=e.time.Od,s=o}if(0===e&&t.length>1){const e=Math.ceil(n/(t.length-1)),i=new Date(1e3*(t[0].time.Od-e));t[0].timeWeight=es(new Date(1e3*t[0].time.Od),i)}}(t,e)}static Id(t){return I({localization:{dateFormat:"dd MMM 'yy"}},null!=t?t:{})}}const hs="undefined"!=typeof window;function ls(){return!!hs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function as(){return!!hs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function cs(t){return t+t%2}function us(t,e){return t.zd-e.zd}function ds(t,e,i){const s=(t.zd-e.zd)/(t.ot-e.ot);return Math.sign(s)*Math.min(Math.abs(s),i)}class fs{constructor(t,e,i,s){this.Ld=null,this.Ed=null,this.Nd=null,this.Fd=null,this.Wd=null,this.jd=0,this.Hd=0,this.$d=t,this.Ud=e,this.qd=i,this.rs=s}Yd(t,e){if(null!==this.Ld){if(this.Ld.ot===e)return void(this.Ld.zd=t);if(Math.abs(this.Ld.zd-t)<this.rs)return}this.Fd=this.Nd,this.Nd=this.Ed,this.Ed=this.Ld,this.Ld={ot:e,zd:t}}Vr(t,e){if(null===this.Ld||null===this.Ed)return;if(e-this.Ld.ot>50)return;let i=0;const s=ds(this.Ld,this.Ed,this.Ud),n=us(this.Ld,this.Ed),r=[s],o=[n];if(i+=n,null!==this.Nd){const t=ds(this.Ed,this.Nd,this.Ud);if(Math.sign(t)===Math.sign(s)){const e=us(this.Ed,this.Nd);if(r.push(t),o.push(e),i+=e,null!==this.Fd){const t=ds(this.Nd,this.Fd,this.Ud);if(Math.sign(t)===Math.sign(s)){const e=us(this.Nd,this.Fd);r.push(t),o.push(e),i+=e}}}}let h=0;for(let t=0;t<r.length;++t)h+=o[t]/i*r[t];Math.abs(h)<this.$d||(this.Wd={zd:t,ot:e},this.Hd=h,this.jd=function(t,e){const i=Math.log(e);return Math.log(1*i/-t)/i}(Math.abs(h),this.qd))}tc(t){const e=k(this.Wd),i=t-e.ot;return e.zd+this.Hd*(Math.pow(this.qd,i)-1)/Math.log(this.qd)}Qu(t){return null===this.Wd||this.Zd(t)===this.jd}Zd(t){const e=t-k(this.Wd).ot;return Math.min(e,this.jd)}}class ms{constructor(t,e){this.Xd=void 0,this.Kd=void 0,this.Gd=void 0,this.en=!1,this.Jd=t,this.Qd=e,this.tf()}bt(){this.tf()}if(){this.Xd&&this.Jd.removeChild(this.Xd),this.Kd&&this.Jd.removeChild(this.Kd),this.Xd=void 0,this.Kd=void 0}nf(){return this.en!==this.sf()||this.Gd!==this.ef()}ef(){return B(D(this.Qd.W().layout.textColor))>160?"dark":"light"}sf(){return this.Qd.W().layout.attributionLogo}rf(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}tf(){this.nf()&&(this.if(),this.en=this.sf(),this.en&&(this.Gd=this.ef(),this.Kd=document.createElement("style"),this.Kd.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.Xd=document.createElement("a"),this.Xd.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.rf()}`,this.Xd.title="Charting by TradingView",this.Xd.id="tv-attr-logo",this.Xd.target="_blank",this.Xd.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 19" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.Xd.toggleAttribute("data-dark","dark"===this.Gd),this.Jd.appendChild(this.Kd),this.Jd.appendChild(this.Xd)))}}function ps(t,e){const i=k(t.ownerDocument).createElement("canvas");t.appendChild(i);const s=(n={options:{allowResizeObserver:!1},transform:(t,e)=>({width:Math.max(t.width,e.width),height:Math.max(t.height,e.height)})},new a(i,n.transform,n.options));var n;return s.resizeCanvasElement(e),s}function gs(t){var e;t.width=1,t.height=1,null===(e=t.getContext("2d"))||void 0===e||e.clearRect(0,0,1,1)}function vs(t,e,i,s){t.gl&&t.gl(e,i,s)}function bs(t,e,i,s){t.X(e,i,s)}function ws(t,e,i,s){const n=t(i,s);for(const t of n){const i=t.gt();null!==i&&e(i)}}class ys{constructor(t,e,i){this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this.df=null,this.ff=!1,this.vf=null,this.pf=null,this.mf=!1,this.bf=!1,this.wf=!1,this.gf=null,this.Mf=null,this.xf=null,this.Sf=null,this.kf=null,this.yf=null,this.Cf=null,this.Tf=0,this.Pf=!1,this.Rf=!1,this.Df=!1,this.Vf=0,this.Of=null,this.Bf=!as(),this.Af=t=>{this.If(t)},this.zf=t=>{if(this.Lf(t)){const e=this.Ef(t);if(++this._f,this.uf&&this._f>1){const{Nf:i}=this.Ff(Cs(t),this.cf);i<30&&!this.wf&&this.Wf(e,this.Hf.jf),this.$f()}}else{const e=this.Ef(t);if(++this.hf,this.lf&&this.hf>1){const{Nf:i}=this.Ff(Cs(t),this.af);i<5&&!this.bf&&this.Uf(e,this.Hf.qf),this.Yf()}}},this.Zf=t,this.Hf=e,this.cn=i,this.Xf()}S(){null!==this.gf&&(this.gf(),this.gf=null),null!==this.Mf&&(this.Mf(),this.Mf=null),null!==this.Sf&&(this.Sf(),this.Sf=null),null!==this.kf&&(this.kf(),this.kf=null),null!==this.yf&&(this.yf(),this.yf=null),null!==this.xf&&(this.xf(),this.xf=null),this.Kf(),this.Yf()}Gf(t){this.Sf&&this.Sf();const e=this.Jf.bind(this);if(this.Sf=()=>{this.Zf.removeEventListener("mousemove",e)},this.Zf.addEventListener("mousemove",e),this.Lf(t))return;const i=this.Ef(t);this.Uf(i,this.Hf.Qf),this.Bf=!0}Yf(){null!==this.lf&&clearTimeout(this.lf),this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}$f(){null!==this.uf&&clearTimeout(this.uf),this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}Jf(t){if(this.Df||null!==this.pf)return;if(this.Lf(t))return;const e=this.Ef(t);this.Uf(e,this.Hf.tv),this.Bf=!0}iv(t){const e=_s(t.changedTouches,k(this.Of));if(null===e)return;if(this.Vf=Ms(t),null!==this.Cf)return;if(this.Rf)return;this.Pf=!0;const i=this.Ff(Cs(e),k(this.pf)),{nv:s,sv:n,Nf:r}=i;if(this.mf||!(r<5)){if(!this.mf){const t=.5*s,e=n>=t&&!this.cn.ev(),i=t>n&&!this.cn.rv();e||i||(this.Rf=!0),this.mf=!0,this.wf=!0,this.Kf(),this.$f()}if(!this.Rf){const i=this.Ef(t,e);this.Wf(i,this.Hf.hv),xs(t)}}}lv(t){if(0!==t.button)return;const e=this.Ff(Cs(t),k(this.vf)),{Nf:i}=e;if(i>=5&&(this.bf=!0,this.Yf()),this.bf){const e=this.Ef(t);this.Uf(e,this.Hf.av)}}Ff(t,e){const i=Math.abs(e.nt-t.nt),s=Math.abs(e.st-t.st);return{nv:i,sv:s,Nf:i+s}}ov(t){let e=_s(t.changedTouches,k(this.Of));if(null===e&&0===t.touches.length&&(e=t.changedTouches[0]),null===e)return;this.Of=null,this.Vf=Ms(t),this.Kf(),this.pf=null,this.yf&&(this.yf(),this.yf=null);const i=this.Ef(t,e);if(this.Wf(i,this.Hf._v),++this._f,this.uf&&this._f>1){const{Nf:t}=this.Ff(Cs(e),this.cf);t<30&&!this.wf&&this.Wf(i,this.Hf.jf),this.$f()}else this.wf||(this.Wf(i,this.Hf.uv),this.Hf.uv&&xs(t));0===this._f&&xs(t),0===t.touches.length&&this.ff&&(this.ff=!1,xs(t))}If(t){if(0!==t.button)return;const e=this.Ef(t);if(this.vf=null,this.Df=!1,this.kf&&(this.kf(),this.kf=null),ls()&&this.Zf.ownerDocument.documentElement.removeEventListener("mouseleave",this.Af),!this.Lf(t))if(this.Uf(e,this.Hf.cv),++this.hf,this.lf&&this.hf>1){const{Nf:i}=this.Ff(Cs(t),this.af);i<5&&!this.bf&&this.Uf(e,this.Hf.qf),this.Yf()}else this.bf||this.Uf(e,this.Hf.dv)}Kf(){null!==this.df&&(clearTimeout(this.df),this.df=null)}fv(t){if(null!==this.Of)return;const e=t.changedTouches[0];this.Of=e.identifier,this.Vf=Ms(t);const i=this.Zf.ownerDocument.documentElement;this.wf=!1,this.mf=!1,this.Rf=!1,this.pf=Cs(e),this.yf&&(this.yf(),this.yf=null);{const e=this.iv.bind(this),s=this.ov.bind(this);this.yf=()=>{i.removeEventListener("touchmove",e),i.removeEventListener("touchend",s)},i.addEventListener("touchmove",e,{passive:!1}),i.addEventListener("touchend",s,{passive:!1}),this.Kf(),this.df=setTimeout(this.vv.bind(this,t),240)}const s=this.Ef(t,e);this.Wf(s,this.Hf.pv),this.uf||(this._f=0,this.uf=setTimeout(this.$f.bind(this),500),this.cf=Cs(e))}mv(t){if(0!==t.button)return;const e=this.Zf.ownerDocument.documentElement;ls()&&e.addEventListener("mouseleave",this.Af),this.bf=!1,this.vf=Cs(t),this.kf&&(this.kf(),this.kf=null);{const t=this.lv.bind(this),i=this.If.bind(this);this.kf=()=>{e.removeEventListener("mousemove",t),e.removeEventListener("mouseup",i)},e.addEventListener("mousemove",t),e.addEventListener("mouseup",i)}if(this.Df=!0,this.Lf(t))return;const i=this.Ef(t);this.Uf(i,this.Hf.bv),this.lf||(this.hf=0,this.lf=setTimeout(this.Yf.bind(this),500),this.af=Cs(t))}Xf(){this.Zf.addEventListener("mouseenter",this.Gf.bind(this)),this.Zf.addEventListener("touchcancel",this.Kf.bind(this));{const t=this.Zf.ownerDocument,e=t=>{this.Hf.wv&&(t.composed&&this.Zf.contains(t.composedPath()[0])||t.target&&this.Zf.contains(t.target)||this.Hf.wv())};this.Mf=()=>{t.removeEventListener("touchstart",e)},this.gf=()=>{t.removeEventListener("mousedown",e)},t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0})}as()&&(this.xf=()=>{this.Zf.removeEventListener("dblclick",this.zf)},this.Zf.addEventListener("dblclick",this.zf)),this.Zf.addEventListener("mouseleave",this.gv.bind(this)),this.Zf.addEventListener("touchstart",this.fv.bind(this),{passive:!0}),function(t){hs&&void 0!==window.chrome&&t.addEventListener("mousedown",t=>{if(1===t.button)return t.preventDefault(),!1})}(this.Zf),this.Zf.addEventListener("mousedown",this.mv.bind(this)),this.Mv(),this.Zf.addEventListener("touchmove",()=>{},{passive:!1})}Mv(){void 0===this.Hf.xv&&void 0===this.Hf.Sv&&void 0===this.Hf.kv||(this.Zf.addEventListener("touchstart",t=>this.yv(t.touches),{passive:!0}),this.Zf.addEventListener("touchmove",t=>{if(2===t.touches.length&&null!==this.Cf&&void 0!==this.Hf.Sv){const e=Ss(t.touches[0],t.touches[1])/this.Tf;this.Hf.Sv(this.Cf,e),xs(t)}},{passive:!1}),this.Zf.addEventListener("touchend",t=>{this.yv(t.touches)}))}yv(t){1===t.length&&(this.Pf=!1),2!==t.length||this.Pf||this.ff?this.Cv():this.Tv(t)}Tv(t){const e=this.Zf.getBoundingClientRect()||{left:0,top:0};this.Cf={nt:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,st:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this.Tf=Ss(t[0],t[1]),void 0!==this.Hf.xv&&this.Hf.xv(),this.Kf()}Cv(){null!==this.Cf&&(this.Cf=null,void 0!==this.Hf.kv&&this.Hf.kv())}gv(t){if(this.Sf&&this.Sf(),this.Lf(t))return;if(!this.Bf)return;const e=this.Ef(t);this.Uf(e,this.Hf.Pv),this.Bf=!as()}vv(t){const e=_s(t.touches,k(this.Of));if(null===e)return;const i=this.Ef(t,e);this.Wf(i,this.Hf.Rv),this.wf=!0,this.ff=!0}Lf(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:Ms(t)<this.Vf+500}Wf(t,e){e&&e.call(this.Hf,t)}Uf(t,e){e&&e.call(this.Hf,t)}Ef(t,e){const i=e||t,s=this.Zf.getBoundingClientRect()||{left:0,top:0};return{clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,localX:i.clientX-s.left,localY:i.clientY-s.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Dv:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,Vv:t.type,Ov:i.target,Bv:t.view,Av:()=>{"touchstart"!==t.type&&xs(t)}}}}function Ss(t,e){const i=t.clientX-e.clientX,s=t.clientY-e.clientY;return Math.sqrt(i*i+s*s)}function xs(t){t.cancelable&&t.preventDefault()}function Cs(t){return{nt:t.pageX,st:t.pageY}}function Ms(t){return t.timeStamp||performance.now()}function _s(t,e){for(let i=0;i<t.length;++i)if(t[i].identifier===e)return t[i];return null}function Es(t){return{Hc:t.Hc,Iv:{gr:t.zv.externalId},Lv:t.zv.cursorStyle}}function zs(t,e,i){for(const s of t){const t=s.gt();if(null!==t&&t.wr){const n=t.wr(e,i);if(null!==n)return{Bv:s,Iv:n}}}return null}function ks(t,e){return i=>{var s,n,r,o;return(null!==(n=null===(s=i.Dt())||void 0===s?void 0:s.Pa())&&void 0!==n?n:"")!==e?[]:null!==(o=null===(r=i.da)||void 0===r?void 0:r.call(i,t))&&void 0!==o?o:[]}}function Rs(t,e,i,s){if(!t.length)return;let n=0;const r=i/2,o=t[0].At(s,!0);let h=1===e?r-(t[0].Vi()-o/2):t[0].Vi()-o/2-r;h=Math.max(0,h);for(let r=1;r<t.length;r++){const o=t[r],l=t[r-1],a=l.At(s,!1),c=o.Vi(),u=l.Vi();if(1===e?c>u-a:c<u+a){const s=u-a*e;o.Oi(s);const r=s-e*a/2;if((1===e?r<0:r>i)&&h>0){const s=1===e?-1-r:r-i,o=Math.min(s,h);for(let i=n;i<t.length;i++)t[i].Oi(t[i].Vi()+e*o);h-=o}}else n=r,h=1===e?u-a-c:c-(u+a)}}class Ls{constructor(t,e,i,s){this.Li=null,this.Ev=null,this.Nv=!1,this.Fv=new ue(200),this.Qr=null,this.Wv=0,this.jv=!1,this.Hv=()=>{this.jv||this.tn.$v().$t().Uh()},this.Uv=()=>{this.jv||this.tn.$v().$t().Uh()},this.tn=t,this.cn=e,this.ko=e.layout,this.Oc=i,this.qv="left"===s,this.Yv=ks("normal",s),this.Zv=ks("top",s),this.Xv=ks("bottom",s),this.Kv=document.createElement("div"),this.Kv.style.height="100%",this.Kv.style.overflow="hidden",this.Kv.style.width="25px",this.Kv.style.left="0",this.Kv.style.position="relative",this.Gv=ps(this.Kv,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const n=this.Gv.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Jv=ps(this.Kv,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const r=this.Jv.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={bv:this.Qv.bind(this),pv:this.Qv.bind(this),av:this.tp.bind(this),hv:this.tp.bind(this),wv:this.ip.bind(this),cv:this.np.bind(this),_v:this.np.bind(this),qf:this.sp.bind(this),jf:this.sp.bind(this),Qf:this.ep.bind(this),Pv:this.rp.bind(this)};this.hp=new ys(this.Jv.canvasElement,h,{ev:()=>!this.cn.handleScroll.vertTouchDrag,rv:()=>!0})}S(){this.hp.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose(),null!==this.Li&&this.Li.Ko().p(this),this.Li=null}lp(){return this.Kv}P(){return this.ko.fontSize}ap(){const t=this.Oc.W();return this.Qr!==t.R&&(this.Fv.nr(),this.Qr=t.R),t}op(){if(null===this.Li)return 0;let t=0;const e=this.ap(),i=k(this.Gv.canvasElement.getContext("2d"));i.save();const s=this.Li.Ha();i.font=this._p(),s.length>0&&(t=Math.max(this.Fv.xi(i,s[0].so),this.Fv.xi(i,s[s.length-1].so)));const n=this.up();for(let e=n.length;e--;){const s=this.Fv.xi(i,n[e].Kt());s>t&&(t=s)}const r=this.Li.Ct();if(null!==r&&null!==this.Ev&&2!==(o=this.cn.crosshair).mode&&o.horzLine.visible&&o.horzLine.labelVisible){const e=this.Li.pn(1,r),s=this.Li.pn(this.Ev.height-2,r);t=Math.max(t,this.Fv.xi(i,this.Li.Fi(Math.floor(Math.min(e,s))+.11111111111111,r)),this.Fv.xi(i,this.Li.Fi(Math.ceil(Math.max(e,s))-.11111111111111,r)))}var o;i.restore();const h=t||34;return cs(Math.ceil(e.C+e.T+e.A+e.I+5+h))}cp(t){null!==this.Ev&&h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`)}dp(){return k(this.Ev).width}Gi(t){this.Li!==t&&(null!==this.Li&&this.Li.Ko().p(this),this.Li=t,t.Ko().l(this.fo.bind(this),this))}Dt(){return this.Li}nr(){const t=this.tn.fp();this.tn.$v().$t().E_(t,k(this.Dt()))}vp(t){if(null===this.Ev)return;if(1!==t){this.pp(),this.Gv.applySuggestedBitmapSize();const t=d(this.Gv);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t)}),this.tn.bp(t,this.Xv),this.wp(t),this.tn.bp(t,this.Yv),this.gp(t))}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.Mp(e),this.tn.bp(e,this.Zv))}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}bt(){var t;null===(t=this.Li)||void 0===t||t.Ha()}Qv(t){if(null===this.Li||this.Li.Ni()||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp();this.Nv=!0,e.V_(i,this.Li,t.localY)}tp(t){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp(),s=this.Li;e.O_(i,s,t.localY)}ip(){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const t=this.tn.$v().$t(),e=this.tn.fp(),i=this.Li;this.Nv&&(this.Nv=!1,t.B_(e,i))}np(t){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp();this.Nv=!1,e.B_(i,this.Li)}sp(t){this.cn.handleScale.axisDoubleClickReset.price&&this.nr()}ep(t){null!==this.Li&&(!this.tn.$v().$t().W().handleScale.axisPressedMouseMove.price||this.Li.Mh()||this.Li.Oo()||this.kp(1))}rp(t){this.kp(0)}up(){const t=[],e=null===this.Li?void 0:this.Li;return(i=>{for(let s=0;s<i.length;++s){const n=i[s].Rn(this.tn.fp(),e);for(let e=0;e<n.length;e++)t.push(n[e])}})(this.tn.fp().Uo()),t}mp({context:t,bitmapSize:e}){const{width:i,height:s}=e,n=this.tn.fp().$t(),r=n.q(),o=n.bd();r===o?ht(t,0,0,i,s,r):ct(t,0,0,i,s,r,o)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i}){if(null===this.Ev||null===this.Li||!this.Li.W().borderVisible)return;t.fillStyle=this.Li.W().borderColor;const s=Math.max(1,Math.floor(this.ap().C*i));let n;n=this.qv?e.width-s:0,t.fillRect(n,0,s,e.height)}wp(t){if(null===this.Ev||null===this.Li)return;const e=this.Li.Ha(),i=this.Li.W(),s=this.ap(),n=this.qv?this.Ev.width-s.T:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:r,verticalPixelRatio:o})=>{t.fillStyle=i.borderColor;const h=Math.max(1,Math.floor(o)),l=Math.floor(.5*o),a=Math.round(s.T*r);t.beginPath();for(const i of e)t.rect(Math.floor(n*r),Math.round(i.Ea*o)-l,a,h);t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{var r;t.font=this._p(),t.fillStyle=null!==(r=i.textColor)&&void 0!==r?r:this.ko.textColor,t.textAlign=this.qv?"right":"left",t.textBaseline="middle";const o=this.qv?Math.round(n-s.A):Math.round(n+s.T+s.A),h=e.map(e=>this.Fv.Mi(t,e.so));for(let i=e.length;i--;){const s=e[i];t.fillText(s.so,o,s.Ea+h[i])}})}pp(){if(null===this.Ev||null===this.Li)return;const t=[],e=this.Li.Uo().slice(),i=this.tn.fp(),s=this.ap();this.Li===i.pr()&&this.tn.fp().Uo().forEach(t=>{i.vr(t)&&e.push(t)});const n=this.Li;e.forEach(e=>{e.Rn(i,n).forEach(e=>{e.Oi(null),e.Bi()&&t.push(e)})}),t.forEach(t=>t.Oi(t.ki())),this.Li.W().alignLabels&&this.yp(t,s)}yp(t,e){if(null===this.Ev)return;const i=this.Ev.height/2,s=t.filter(t=>t.ki()<=i),n=t.filter(t=>t.ki()>i);s.sort((t,e)=>e.ki()-t.ki()),n.sort((t,e)=>t.ki()-e.ki());for(const i of t){const t=Math.floor(i.At(e)/2),s=i.ki();s>-t&&s<t&&i.Oi(t),s>this.Ev.height-t&&s<this.Ev.height+t&&i.Oi(this.Ev.height-t)}Rs(s,1,this.Ev.height,e),Rs(n,-1,this.Ev.height,e)}gp(t){if(null===this.Ev)return;const e=this.up(),i=this.ap(),s=this.qv?"right":"left";e.forEach(e=>{e.Ai()&&e.gt(k(this.Li)).X(t,i,this.Fv,s)})}Mp(t){if(null===this.Ev||null===this.Li)return;const e=this.tn.$v().$t(),i=[],s=this.tn.fp(),n=e.Zc().Rn(s,this.Li);n.length&&i.push(n);const r=this.ap(),o=this.qv?"right":"left";i.forEach(e=>{e.forEach(e=>{e.gt(k(this.Li)).X(t,r,this.Fv,o)})})}kp(t){this.Kv.style.cursor=1===t?"ns-resize":"default"}fo(){const t=this.op();this.Wv<t&&this.tn.$v().$t().Kl(),this.Wv=t}_p(){return G(this.ko.fontSize,this.ko.fontFamily)}}function Ts(t,e){var i,s;return null!==(s=null===(i=t.ua)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function Ns(t,e){var i,s;return null!==(s=null===(i=t.Pn)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function Os(t,e){var i,s;return null!==(s=null===(i=t.Ji)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function $s(t,e){var i,s;return null!==(s=null===(i=t.aa)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}class Ps{constructor(t,e){this.Ev=o({width:0,height:0}),this.Cp=null,this.Tp=null,this.Pp=null,this.Rp=null,this.Dp=!1,this.Vp=new A,this.Op=new A,this.Bp=0,this.Ap=!1,this.Ip=null,this.zp=!1,this.Lp=null,this.Ep=null,this.jv=!1,this.Hv=()=>{this.jv||null===this.Np||this.$i().Uh()},this.Uv=()=>{this.jv||null===this.Np||this.$i().Uh()},this.Qd=t,this.Np=e,this.Np.W_().l(this.Fp.bind(this),this,!0),this.Wp=document.createElement("td"),this.Wp.style.padding="0",this.Wp.style.position="relative";const i=document.createElement("div");i.style.width="100%",i.style.height="100%",i.style.position="relative",i.style.overflow="hidden",this.jp=document.createElement("td"),this.jp.style.padding="0",this.Hp=document.createElement("td"),this.Hp.style.padding="0",this.Wp.appendChild(i),this.Gv=ps(i,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const s=this.Gv.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Jv=ps(i,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const n=this.Jv.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.$p=document.createElement("tr"),this.$p.appendChild(this.jp),this.$p.appendChild(this.Wp),this.$p.appendChild(this.Hp),this.Up(),this.hp=new ys(this.Jv.canvasElement,this,{ev:()=>null===this.Ip&&!this.Qd.W().handleScroll.vertTouchDrag,rv:()=>null===this.Ip&&!this.Qd.W().handleScroll.horzTouchDrag})}S(){null!==this.Cp&&this.Cp.S(),null!==this.Tp&&this.Tp.S(),this.Pp=null,this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose(),null!==this.Np&&this.Np.W_().p(this),this.hp.S()}fp(){return k(this.Np)}qp(t){var e,i;null!==this.Np&&this.Np.W_().p(this),this.Np=t,null!==this.Np&&this.Np.W_().l(Ps.prototype.Fp.bind(this),this,!0),this.Up(),this.Qd.Yp().indexOf(this)===this.Qd.Yp().length-1?(this.Pp=null!==(e=this.Pp)&&void 0!==e?e:new ms(this.Wp,this.Qd),this.Pp.bt()):(null===(i=this.Pp)||void 0===i||i.if(),this.Pp=null)}$v(){return this.Qd}lp(){return this.$p}Up(){if(null!==this.Np&&(this.Zp(),0!==this.$i().wt().length)){if(null!==this.Cp){const t=this.Np.R_();this.Cp.Gi(k(t))}if(null!==this.Tp){const t=this.Np.D_();this.Tp.Gi(k(t))}}}Xp(){null!==this.Cp&&this.Cp.bt(),null!==this.Tp&&this.Tp.bt()}M_(){return null!==this.Np?this.Np.M_():0}x_(t){this.Np&&this.Np.x_(t)}Qf(t){if(!this.Np)return;this.Kp();const e=t.localX,i=t.localY;this.Gp(e,i,t)}bv(t){this.Kp(),this.Jp(),this.Gp(t.localX,t.localY,t)}tv(t){var e;if(!this.Np)return;this.Kp();const i=t.localX,s=t.localY;this.Gp(i,s,t);const n=this.wr(i,s);this.Qd.Qp(null!==(e=null==n?void 0:n.Lv)&&void 0!==e?e:null),this.$i().jc(n&&{Hc:n.Hc,Iv:n.Iv})}dv(t){null!==this.Np&&(this.Kp(),this.tm(t))}qf(t){null!==this.Np&&this.im(this.Op,t)}jf(t){this.qf(t)}av(t){this.Kp(),this.nm(t),this.Gp(t.localX,t.localY,t)}cv(t){null!==this.Np&&(this.Kp(),this.Ap=!1,this.sm(t))}uv(t){null!==this.Np&&this.tm(t)}Rv(t){if(this.Ap=!0,null===this.Ip){const e={x:t.localX,y:t.localY};this.rm(e,e,t)}}Pv(t){null!==this.Np&&(this.Kp(),this.Np.$t().jc(null),this.hm())}lm(){return this.Vp}am(){return this.Op}xv(){this.Bp=1,this.$i().Un()}Sv(t,e){if(!this.Qd.W().handleScale.pinch)return;const i=5*(e-this.Bp);this.Bp=e,this.$i().Qc(t.nt,i)}pv(t){this.Ap=!1,this.zp=null!==this.Ip,this.Jp();const e=this.$i().Zc();null!==this.Ip&&e.yt()&&(this.Lp={x:e.Yt(),y:e.Zt()},this.Ip={x:t.localX,y:t.localY})}hv(t){if(null===this.Np)return;const e=t.localX,i=t.localY;if(null===this.Ip)this.nm(t);else{this.zp=!1;const s=k(this.Lp),n=s.x+(e-this.Ip.x),r=s.y+(i-this.Ip.y);this.Gp(n,r,t)}}_v(t){0===this.$v().W().trackingMode.exitMode&&(this.zp=!0),this.om(),this.sm(t)}wr(t,e){const i=this.Np;return null===i?null:function(t,e,i){const s=t.Uo(),n=function(t,e,i){var s,n;let r,o;for(const a of t){const t=null!==(n=null===(s=a.va)||void 0===s?void 0:s.call(a,e,i))&&void 0!==n?n:[];for(const e of t)h=e.zOrder,(!(l=null==r?void 0:r.zOrder)||"top"===h&&"top"!==l||"normal"===h&&"bottom"===l)&&(r=e,o=a)}var h,l;return r&&o?{zv:r,Hc:o}:null}(s,e,i);if("top"===(null==n?void 0:n.zv.zOrder))return Es(n);for(const r of s){if(n&&n.Hc===r&&"bottom"!==n.zv.zOrder&&!n.zv.isBackground)return Es(n);const s=zs(r.Pn(t),e,i);if(null!==s)return{Hc:r,Bv:s.Bv,Iv:s.Iv};if(n&&n.Hc===r&&"bottom"!==n.zv.zOrder&&n.zv.isBackground)return Es(n)}return(null==n?void 0:n.zv)?Es(n):null}(i,t,e)}_m(t,e){k("left"===e?this.Cp:this.Tp).cp(o({width:t,height:this.Ev.height}))}um(){return this.Ev}cp(t){h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Wp.style.width=t.width+"px",this.Wp.style.height=t.height+"px")}dm(){const t=k(this.Np);t.P_(t.R_()),t.P_(t.D_());for(const e of t.Ba())if(t.vr(e)){const i=e.Dt();null!==i&&t.P_(i),e.Vn()}}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(0===t)return;if(null===this.Np)return;if(t>1&&this.dm(),null!==this.Cp&&this.Cp.vp(t),null!==this.Tp&&this.Tp.vp(t),1!==t){this.Gv.applySuggestedBitmapSize();const t=d(this.Gv);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.mp(t)}),this.Np&&(this.fm(t,Ts),this.vm(t),this.pm(t),this.fm(t,Ns),this.fm(t,Os)))}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.bm(e),this.fm(e,$s))}wm(){return this.Cp}gm(){return this.Tp}bp(t,e){this.fm(t,e)}Fp(){null!==this.Np&&this.Np.W_().p(this),this.Np=null}tm(t){this.im(this.Vp,t)}im(t,e){const i=e.localX,s=e.localY;t.M()&&t.m(this.$i().St().Nu(i),{x:i,y:s},e)}mp({context:t,bitmapSize:e}){const{width:i,height:s}=e,n=this.$i(),r=n.q(),o=n.bd();r===o?ht(t,0,0,i,s,o):ct(t,0,0,i,s,r,o)}vm(t){const e=k(this.Np).j_().qh().gt();null!==e&&e.X(t,!1)}pm(t){const e=this.$i().Yc();this.Mm(t,Ns,vs,e),this.Mm(t,Ns,bs,e)}bm(t){this.Mm(t,Ns,bs,this.$i().Zc())}fm(t,e){const i=k(this.Np).Uo();for(const s of i)this.Mm(t,e,vs,s);for(const s of i)this.Mm(t,e,bs,s)}Mm(t,e,i,s){const n=k(this.Np),r=n.$t().Wc(),o=null!==r&&r.Hc===s,h=null!==r&&o&&void 0!==r.Iv?r.Iv.Mr:void 0;ws(e,e=>i(e,t,o,h),s,n)}Zp(){if(null===this.Np)return;const t=this.Qd,e=this.Np.R_().W().visible,i=this.Np.D_().W().visible;e||null===this.Cp||(this.jp.removeChild(this.Cp.lp()),this.Cp.S(),this.Cp=null),i||null===this.Tp||(this.Hp.removeChild(this.Tp.lp()),this.Tp.S(),this.Tp=null);const s=t.$t().ud();e&&null===this.Cp&&(this.Cp=new Ls(this,t.W(),s,"left"),this.jp.appendChild(this.Cp.lp())),i&&null===this.Tp&&(this.Tp=new Ls(this,t.W(),s,"right"),this.Hp.appendChild(this.Tp.lp()))}xm(t){return t.Dv&&this.Ap||null!==this.Ip}Sm(t){return Math.max(0,Math.min(t,this.Ev.width-1))}km(t){return Math.max(0,Math.min(t,this.Ev.height-1))}Gp(t,e,i){this.$i().ld(this.Sm(t),this.km(e),i,k(this.Np))}hm(){this.$i().od()}om(){this.zp&&(this.Ip=null,this.hm())}rm(t,e,i){this.Ip=t,this.zp=!1,this.Gp(e.x,e.y,i);const s=this.$i().Zc();this.Lp={x:s.Yt(),y:s.Zt()}}$i(){return this.Qd.$t()}sm(t){if(!this.Dp)return;const e=this.$i(),i=this.fp();if(e.z_(i,i.vn()),this.Rp=null,this.Dp=!1,e.ed(),null!==this.Ep){const t=performance.now(),i=e.St();this.Ep.Vr(i.Hu(),t),this.Ep.Qu(t)||e.Zn(this.Ep)}}Kp(){this.Ip=null}Jp(){if(this.Np){if(this.$i().Un(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)k(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Np.vn().Ni()&&this.$i().St().Ni()}}nm(t){if(null===this.Np)return;const e=this.$i(),i=e.St();if(i.Ni())return;const s=this.Qd.W(),n=s.handleScroll,r=s.kineticScroll;if((!n.pressedMouseMove||t.Dv)&&(!n.horzTouchDrag&&!n.vertTouchDrag||!t.Dv))return;const o=this.Np.vn(),h=performance.now();if(null!==this.Rp||this.xm(t)||(this.Rp={x:t.clientX,y:t.clientY,Od:h,ym:t.localX,Cm:t.localY}),null!==this.Rp&&!this.Dp&&(this.Rp.x!==t.clientX||this.Rp.y!==t.clientY)){if(t.Dv&&r.touch||!t.Dv&&r.mouse){const t=i.le();this.Ep=new fs(.2/t,7/t,.997,15/t),this.Ep.Yd(i.Hu(),this.Rp.Od)}else this.Ep=null;o.Ni()||e.A_(this.Np,o,t.localY),e.nd(t.localX),this.Dp=!0}this.Dp&&(o.Ni()||e.I_(this.Np,o,t.localY),e.sd(t.localX),null!==this.Ep&&this.Ep.Yd(i.Hu(),h))}}class Vs{constructor(t,e,i,s,n){this.ft=!0,this.Ev=o({width:0,height:0}),this.Hv=()=>this.vp(3),this.qv="left"===t,this.Oc=i.ud,this.cn=e,this.Tm=s,this.Pm=n,this.Kv=document.createElement("div"),this.Kv.style.width="25px",this.Kv.style.height="100%",this.Kv.style.overflow="hidden",this.Gv=ps(this.Kv,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv)}S(){this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Kv}um(){return this.Ev}cp(t){h(this.Ev,t)||(this.Ev=t,this.Gv.resizeCanvasElement(t),this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`,this.ft=!0)}vp(t){if(t<3&&!this.ft)return;if(0===this.Ev.width||0===this.Ev.height)return;this.ft=!1,this.Gv.applySuggestedBitmapSize();const e=d(this.Gv);null!==e&&e.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t)})}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(!this.Tm())return;t.fillStyle=this.cn.timeScale.borderColor;const n=Math.floor(this.Oc.W().C*i),r=Math.floor(this.Oc.W().C*s),o=this.qv?e.width-n:0;t.fillRect(o,0,n,r)}mp({context:t,bitmapSize:e}){ht(t,0,0,e.width,e.height,this.Pm())}}function Ds(t){return e=>{var i,s;return null!==(s=null===(i=e.fa)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:[]}}const Bs=Ds("normal"),Fs=Ds("top"),As=Ds("bottom");class Is{constructor(t,e){this.Rm=null,this.Dm=null,this.k=null,this.Vm=!1,this.Ev=o({width:0,height:0}),this.Om=new A,this.Fv=new ue(5),this.jv=!1,this.Hv=()=>{this.jv||this.Qd.$t().Uh()},this.Uv=()=>{this.jv||this.Qd.$t().Uh()},this.Qd=t,this.q_=e,this.cn=t.W().layout,this.Xd=document.createElement("tr"),this.Bm=document.createElement("td"),this.Bm.style.padding="0",this.Am=document.createElement("td"),this.Am.style.padding="0",this.Kv=document.createElement("td"),this.Kv.style.height="25px",this.Kv.style.padding="0",this.Im=document.createElement("div"),this.Im.style.width="100%",this.Im.style.height="100%",this.Im.style.position="relative",this.Im.style.overflow="hidden",this.Kv.appendChild(this.Im),this.Gv=ps(this.Im,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const i=this.Gv.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Jv=ps(this.Im,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const s=this.Jv.canvasElement;s.style.position="absolute",s.style.zIndex="2",s.style.left="0",s.style.top="0",this.Xd.appendChild(this.Bm),this.Xd.appendChild(this.Kv),this.Xd.appendChild(this.Am),this.zm(),this.Qd.$t().g_().l(this.zm.bind(this),this),this.hp=new ys(this.Jv.canvasElement,this,{ev:()=>!0,rv:()=>!this.Qd.W().handleScroll.horzTouchDrag})}S(){this.hp.S(),null!==this.Rm&&this.Rm.S(),null!==this.Dm&&this.Dm.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Xd}Lm(){return this.Rm}Em(){return this.Dm}bv(t){if(this.Vm)return;this.Vm=!0;const e=this.Qd.$t();!e.St().Ni()&&this.Qd.W().handleScale.axisPressedMouseMove.time&&e.Jc(t.localX)}pv(t){this.bv(t)}wv(){const t=this.Qd.$t();!t.St().Ni()&&this.Vm&&(this.Vm=!1,this.Qd.W().handleScale.axisPressedMouseMove.time&&t.hd())}av(t){const e=this.Qd.$t();!e.St().Ni()&&this.Qd.W().handleScale.axisPressedMouseMove.time&&e.rd(t.localX)}hv(t){this.av(t)}cv(){this.Vm=!1;const t=this.Qd.$t();t.St().Ni()&&!this.Qd.W().handleScale.axisPressedMouseMove.time||t.hd()}_v(){this.cv()}qf(){this.Qd.W().handleScale.axisDoubleClickReset.time&&this.Qd.$t().Kn()}jf(){this.qf()}Qf(){this.Qd.$t().W().handleScale.axisPressedMouseMove.time&&this.kp(1)}Pv(){this.kp(0)}um(){return this.Ev}Nm(){return this.Om}Fm(t,e,i){h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`,this.Om.m(t)),null!==this.Rm&&this.Rm.cp(o({width:e,height:t.height})),null!==this.Dm&&this.Dm.cp(o({width:i,height:t.height}))}Wm(){const t=this.jm();return Math.ceil(t.C+t.T+t.P+t.L+t.B+t.Hm)}bt(){this.Qd.$t().St().Ha()}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(0===t)return;if(1!==t){this.Gv.applySuggestedBitmapSize();const e=d(this.Gv);null!==e&&(e.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t),this.$m(e,As)}),this.wp(e),this.$m(e,Bs)),null!==this.Rm&&this.Rm.vp(t),null!==this.Dm&&this.Dm.vp(t)}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.Um([...this.Qd.$t().wt(),this.Qd.$t().Zc()],e),this.$m(e,Fs))}$m(t,e){const i=this.Qd.$t().wt();for(const s of i)ws(e,e=>vs(e,t,!1,void 0),s,void 0);for(const s of i)ws(e,e=>bs(e,t,!1,void 0),s,void 0)}mp({context:t,bitmapSize:e}){ht(t,0,0,e.width,e.height,this.Qd.$t().bd())}Ie({context:t,bitmapSize:e,verticalPixelRatio:i}){if(this.Qd.W().timeScale.borderVisible){t.fillStyle=this.qm();const s=Math.max(1,Math.floor(this.jm().C*i));t.fillRect(0,0,e.width,s)}}wp(t){const e=this.Qd.$t().St(),i=e.Ha();if(!i||0===i.length)return;const s=this.q_.maxTickMarkWeight(i),n=this.jm(),r=e.W();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:e,verticalPixelRatio:s})=>{t.strokeStyle=this.qm(),t.fillStyle=this.qm();const r=Math.max(1,Math.floor(e)),o=Math.floor(.5*e);t.beginPath();const h=Math.round(n.T*s);for(let s=i.length;s--;){const n=Math.round(i[s].coord*e);t.rect(n-o,0,r,h)}t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{const e=n.C+n.T+n.L+n.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.$(),t.font=this._p();for(const n of i)if(n.weight<s){const i=n.needAlignCoordinate?this.Ym(t,n.coord,n.label):n.coord;t.fillText(n.label,i,e)}this.Qd.W().timeScale.allowBoldLabels&&(t.font=this.Zm());for(const n of i)if(n.weight>=s){const i=n.needAlignCoordinate?this.Ym(t,n.coord,n.label):n.coord;t.fillText(n.label,i,e)}})}Ym(t,e,i){const s=this.Fv.xi(t,i),n=s/2,r=Math.floor(e-n)+.5;return r<0?e+=Math.abs(0-r):r+s>this.Ev.width&&(e-=Math.abs(this.Ev.width-(r+s))),e}Um(t,e){const i=this.jm();for(const s of t)for(const t of s.Qi())t.gt().X(e,i)}qm(){return this.Qd.W().timeScale.borderColor}$(){return this.cn.textColor}j(){return this.cn.fontSize}_p(){return G(this.j(),this.cn.fontFamily)}Zm(){return G(this.j(),this.cn.fontFamily,"bold")}jm(){null===this.k&&(this.k={C:1,N:NaN,L:NaN,B:NaN,ji:NaN,T:5,P:NaN,R:"",Wi:new ue,Hm:0});const t=this.k,e=this._p();if(t.R!==e){const i=this.j();t.P=i,t.R=e,t.L=3*i/12,t.B=3*i/12,t.ji=9*i/12,t.N=0,t.Hm=4*i/12,t.Wi.nr()}return this.k}kp(t){this.Kv.style.cursor=1===t?"ew-resize":"default"}zm(){const t=this.Qd.$t(),e=t.W();e.leftPriceScale.visible||null===this.Rm||(this.Bm.removeChild(this.Rm.lp()),this.Rm.S(),this.Rm=null),e.rightPriceScale.visible||null===this.Dm||(this.Am.removeChild(this.Dm.lp()),this.Dm.S(),this.Dm=null);const i={ud:this.Qd.$t().ud()},s=()=>e.leftPriceScale.borderVisible&&t.St().W().borderVisible,n=()=>t.bd();e.leftPriceScale.visible&&null===this.Rm&&(this.Rm=new Vs("left",e,i,s,n),this.Bm.appendChild(this.Rm.lp())),e.rightPriceScale.visible&&null===this.Dm&&(this.Dm=new Vs("right",e,i,s,n),this.Am.appendChild(this.Dm.lp()))}}const Ws=!!hs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(t=>t.brand.includes("Chromium"))&&!!hs&&((null===(js=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===js?void 0:js.platform)?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);var js;class Us{constructor(t,e,i){var s;this.Xm=[],this.Km=0,this.ho=0,this.__=0,this.Gm=0,this.Jm=0,this.Qm=null,this.tb=!1,this.Vp=new A,this.Op=new A,this.Rc=new A,this.ib=null,this.nb=null,this.Jd=t,this.cn=e,this.q_=i,this.Xd=document.createElement("div"),this.Xd.classList.add("tv-lightweight-charts"),this.Xd.style.overflow="hidden",this.Xd.style.direction="ltr",this.Xd.style.width="100%",this.Xd.style.height="100%",(s=this.Xd).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.sb=document.createElement("table"),this.sb.setAttribute("cellspacing","0"),this.Xd.appendChild(this.sb),this.eb=this.rb.bind(this),Hs(this.cn)&&this.hb(!0),this.$i=new Ui(this.Vc.bind(this),this.cn,i),this.$t().Xc().l(this.lb.bind(this),this),this.ab=new Is(this,this.q_),this.sb.appendChild(this.ab.lp());const n=e.autoSize&&this.ob();let r=this.cn.width,o=this.cn.height;if(n||0===r||0===o){const e=t.getBoundingClientRect();r=r||e.width,o=o||e.height}this._b(r,o),this.ub(),t.appendChild(this.Xd),this.cb(),this.$i.St().ec().l(this.$i.Kl.bind(this.$i),this),this.$i.g_().l(this.$i.Kl.bind(this.$i),this)}$t(){return this.$i}W(){return this.cn}Yp(){return this.Xm}fb(){return this.ab}S(){this.hb(!1),0!==this.Km&&window.cancelAnimationFrame(this.Km),this.$i.Xc().p(this),this.$i.St().ec().p(this),this.$i.g_().p(this),this.$i.S();for(const t of this.Xm)this.sb.removeChild(t.lp()),t.lm().p(this),t.am().p(this),t.S();this.Xm=[],k(this.ab).S(),null!==this.Xd.parentElement&&this.Xd.parentElement.removeChild(this.Xd),this.Rc.S(),this.Vp.S(),this.Op.S(),this.pb()}_b(t,e,i=!1){if(this.ho===e&&this.__===t)return;const s=function(t){const e=Math.floor(t.width),i=Math.floor(t.height);return o({width:e-e%2,height:i-i%2})}(o({width:t,height:e}));this.ho=s.height,this.__=s.width;const n=this.ho+"px",r=this.__+"px";k(this.Xd).style.height=n,k(this.Xd).style.width=r,this.sb.style.height=n,this.sb.style.width=r,i?this.mb(St.es(),performance.now()):this.$i.Kl()}vp(t){void 0===t&&(t=St.es());for(let e=0;e<this.Xm.length;e++)this.Xm[e].vp(t.Hn(e).Fn);this.cn.timeScale.visible&&this.ab.vp(t.jn())}$h(t){const e=Hs(this.cn);this.$i.$h(t);const i=Hs(this.cn);i!==e&&this.hb(i),this.cb(),this.bb(t)}lm(){return this.Vp}am(){return this.Op}Xc(){return this.Rc}wb(){null!==this.Qm&&(this.mb(this.Qm,performance.now()),this.Qm=null);const t=this.gb(null),e=document.createElement("canvas");e.width=t.width,e.height=t.height;const i=k(e.getContext("2d"));return this.gb(i),e}Mb(t){return("left"!==t||this.xb())&&("right"!==t||this.Sb())?0===this.Xm.length?0:k("left"===t?this.Xm[0].wm():this.Xm[0].gm()).dp():0}kb(){return this.cn.autoSize&&null!==this.ib}yb(){return this.Xd}Qp(t){this.nb=t,this.nb?this.yb().style.setProperty("cursor",t):this.yb().style.removeProperty("cursor")}Cb(){return this.nb}Tb(){return z(this.Xm[0]).um()}bb(t){(void 0!==t.autoSize||!this.ib||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.ib&&this.ob(),!1===t.autoSize&&null!==this.ib&&this.pb(),t.autoSize||void 0===t.width&&void 0===t.height||this._b(t.width||this.__,t.height||this.ho))}gb(t){let e=0,i=0;const s=this.Xm[0],n=(e,i)=>{let s=0;for(let n=0;n<this.Xm.length;n++){const r=this.Xm[n],o=k("left"===e?r.wm():r.gm()),h=o.xp();null!==t&&o.Sp(t,i,s),s+=h.height}};this.xb()&&(n("left",0),e+=k(s.wm()).xp().width);for(let s=0;s<this.Xm.length;s++){const n=this.Xm[s],r=n.xp();null!==t&&n.Sp(t,e,i),i+=r.height}e+=s.xp().width,this.Sb()&&(n("right",e),e+=k(s.gm()).xp().width);const r=(e,i,s)=>{k("left"===e?this.ab.Lm():this.ab.Em()).Sp(k(t),i,s)};if(this.cn.timeScale.visible){const e=this.ab.xp();if(null!==t){let n=0;this.xb()&&(r("left",n,i),n=k(s.wm()).xp().width),this.ab.Sp(t,n,i),n+=e.width,this.Sb()&&r("right",n,i)}i+=e.height}return o({width:e,height:i})}Pb(){let t=0,e=0,i=0;for(const s of this.Xm)this.xb()&&(e=Math.max(e,k(s.wm()).op(),this.cn.leftPriceScale.minimumWidth)),this.Sb()&&(i=Math.max(i,k(s.gm()).op(),this.cn.rightPriceScale.minimumWidth)),t+=s.M_();e=cs(e),i=cs(i);const s=this.__,n=this.ho,r=Math.max(s-e-i,0),h=this.cn.timeScale.visible;let l=h?Math.max(this.ab.Wm(),this.cn.timeScale.minimumHeight):0;var a;l=(a=l)+a%2;const c=0+l,u=n<c?0:n-c,d=u/t;let f=0;for(let t=0;t<this.Xm.length;++t){const s=this.Xm[t];s.qp(this.$i.qc()[t]);let n=0,h=0;h=t===this.Xm.length-1?u-f:Math.round(s.M_()*d),n=Math.max(h,2),f+=n,s.cp(o({width:r,height:n})),this.xb()&&s._m(e,"left"),this.Sb()&&s._m(i,"right"),s.fp()&&this.$i.Kc(s.fp(),n)}this.ab.Fm(o({width:h?r:0,height:l}),h?e:0,h?i:0),this.$i.S_(r),this.Gm!==e&&(this.Gm=e),this.Jm!==i&&(this.Jm=i)}hb(t){t?this.Xd.addEventListener("wheel",this.eb,{passive:!1}):this.Xd.removeEventListener("wheel",this.eb)}Rb(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Ws?1/window.devicePixelRatio:1}rb(t){if(!(0!==t.deltaX&&this.cn.handleScroll.mouseWheel||0!==t.deltaY&&this.cn.handleScale.mouseWheel))return;const e=this.Rb(t),i=e*t.deltaX/100,s=-e*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==s&&this.cn.handleScale.mouseWheel){const e=Math.sign(s)*Math.min(1,Math.abs(s)),i=t.clientX-this.Xd.getBoundingClientRect().left;this.$t().Qc(i,e)}0!==i&&this.cn.handleScroll.mouseWheel&&this.$t().td(-80*i)}mb(t,e){var i;const s=t.jn();3===s&&this.Db(),3!==s&&2!==s||(this.Vb(t),this.Ob(t,e),this.ab.bt(),this.Xm.forEach(t=>{t.Xp()}),3===(null===(i=this.Qm)||void 0===i?void 0:i.jn())&&(this.Qm.ts(t),this.Db(),this.Vb(this.Qm),this.Ob(this.Qm,e),t=this.Qm,this.Qm=null)),this.vp(t)}Ob(t,e){for(const i of t.Qn())this.ns(i,e)}Vb(t){const e=this.$i.qc();for(let i=0;i<e.length;i++)t.Hn(i).Wn&&e[i].N_()}ns(t,e){const i=this.$i.St();switch(t.qn){case 0:i.hc();break;case 1:i.lc(t.Vt);break;case 2:i.Gn(t.Vt);break;case 3:i.Jn(t.Vt);break;case 4:i.qu();break;case 5:t.Vt.Qu(e)||i.Jn(t.Vt.tc(e))}}Vc(t){null!==this.Qm?this.Qm.ts(t):this.Qm=t,this.tb||(this.tb=!0,this.Km=window.requestAnimationFrame(t=>{if(this.tb=!1,this.Km=0,null!==this.Qm){const e=this.Qm;this.Qm=null,this.mb(e,t);for(const i of e.Qn())if(5===i.qn&&!i.Vt.Qu(t)){this.$t().Zn(i.Vt);break}}}))}Db(){this.ub()}ub(){const t=this.$i.qc(),e=t.length,i=this.Xm.length;for(let t=e;t<i;t++){const t=z(this.Xm.pop());this.sb.removeChild(t.lp()),t.lm().p(this),t.am().p(this),t.S()}for(let s=i;s<e;s++){const e=new Ps(this,t[s]);e.lm().l(this.Bb.bind(this),this),e.am().l(this.Ab.bind(this),this),this.Xm.push(e),this.sb.insertBefore(e.lp(),this.ab.lp())}for(let i=0;i<e;i++){const e=t[i],s=this.Xm[i];s.fp()!==e?s.qp(e):s.Up()}this.cb(),this.Pb()}Ib(t,e,i){var s;const n=new Map;let r;if(null!==t&&this.$i.wt().forEach(e=>{const i=e.In().ll(t);null!==i&&n.set(e,i)}),null!==t){const e=null===(s=this.$i.St().Ui(t))||void 0===s?void 0:s.originalTime;void 0!==e&&(r=e)}const o=this.$t().Wc(),h=null!==o&&o.Hc instanceof ri?o.Hc:void 0,l=null!==o&&void 0!==o.Iv?o.Iv.gr:void 0;return{zb:r,ee:null!=t?t:void 0,Lb:null!=e?e:void 0,Eb:h,Nb:n,Fb:l,Wb:null!=i?i:void 0}}Bb(t,e,i){this.Vp.m(()=>this.Ib(t,e,i))}Ab(t,e,i){this.Op.m(()=>this.Ib(t,e,i))}lb(t,e,i){this.Rc.m(()=>this.Ib(t,e,i))}cb(){const t=this.cn.timeScale.visible?"":"none";this.ab.lp().style.display=t}xb(){return this.Xm[0].fp().R_().W().visible}Sb(){return this.Xm[0].fp().D_().W().visible}ob(){return"ResizeObserver"in window&&(this.ib=new ResizeObserver(t=>{const e=t.find(t=>t.target===this.Jd);e&&this._b(e.contentRect.width,e.contentRect.height)}),this.ib.observe(this.Jd,{box:"border-box"}),!0)}pb(){null!==this.ib&&this.ib.disconnect(),this.ib=null}}function Hs(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Ks(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}function qs(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.color&&(r.V=i.color),r}function Xs(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.lineColor&&(r.lt=i.lineColor),void 0!==i.topColor&&(r.Ps=i.topColor),void 0!==i.bottomColor&&(r.Rs=i.bottomColor),r}function Js(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.topLineColor&&(r.Re=i.topLineColor),void 0!==i.bottomLineColor&&(r.De=i.bottomLineColor),void 0!==i.topFillColor1&&(r.ke=i.topFillColor1),void 0!==i.topFillColor2&&(r.ye=i.topFillColor2),void 0!==i.bottomFillColor1&&(r.Ce=i.bottomFillColor1),void 0!==i.bottomFillColor2&&(r.Te=i.bottomFillColor2),r}function Gs(t,e,i,s){const n={ee:e,ot:t,Vt:[i.open,i.high,i.low,i.close],zb:s};return void 0!==i.color&&(n.V=i.color),n}function Qs(t,e,i,s){const n={ee:e,ot:t,Vt:[i.open,i.high,i.low,i.close],zb:s};return void 0!==i.color&&(n.V=i.color),void 0!==i.borderColor&&(n.Ot=i.borderColor),void 0!==i.wickColor&&(n.Xh=i.wickColor),n}function Ys(t,e,i,s,n){const r=z(n)(i),o=Math.max(...r),h=Math.min(...r),l=r[r.length-1],a=[l,o,h,l],c=i,{time:u,color:d}=c;return{ee:e,ot:t,Vt:a,zb:s,$e:Ks(c,["time","color"]),V:d}}function Zs(t){return void 0!==t.Vt}function tn(t,e){return void 0!==e.customValues&&(t.jb=e.customValues),t}function en(t){return(e,i,s,n,r,o)=>function(t,e){return e?e(t):void 0===(i=t).open&&void 0===i.value;var i}(s,o)?tn({ot:e,ee:i,zb:n},s):tn(t(e,i,s,n,r),s)}function sn(t){return{Candlestick:en(Qs),Bar:en(Gs),Area:en(Xs),Baseline:en(Js),Histogram:en(qs),Line:en(qs),Custom:en(Ys)}[t]}function nn(t){return{ee:0,Hb:new Map,la:t}}function rn(t,e){if(void 0!==t&&0!==t.length)return{$b:e.key(t[0].ot),Ub:e.key(t[t.length-1].ot)}}function on(t){let e;return t.forEach(t=>{void 0===e&&(e=t.zb)}),z(e)}class hn{constructor(t){this.qb=new Map,this.Yb=new Map,this.Zb=new Map,this.Xb=[],this.q_=t}S(){this.qb.clear(),this.Yb.clear(),this.Zb.clear(),this.Xb=[]}Kb(t,e){let i=0!==this.qb.size,s=!1;const n=this.Yb.get(t);if(void 0!==n)if(1===this.Yb.size)i=!1,s=!0,this.qb.clear();else for(const e of this.Xb)e.pointData.Hb.delete(t)&&(s=!0);let r=[];if(0!==e.length){const i=e.map(t=>t.time),n=this.q_.createConverterToInternalObj(e),o=sn(t.Qh()),h=t.Ca(),l=t.Ta();r=e.map((e,r)=>{const a=n(e.time),c=this.q_.key(a);let u=this.qb.get(c);void 0===u&&(u=nn(a),this.qb.set(c,u),s=!0);const d=o(a,u.ee,e,i[r],h,l);return u.Hb.set(t,d),d})}i&&this.Gb(),this.Jb(t,r);let o=-1;if(s){const t=[];this.qb.forEach(e=>{t.push({timeWeight:0,time:e.la,pointData:e,originalTime:on(e.Hb)})}),t.sort((t,e)=>this.q_.key(t.time)-this.q_.key(e.time)),o=this.Qb(t)}return this.tw(t,o,function(t,e,i){const s=rn(t,i),n=rn(e,i);if(void 0!==s&&void 0!==n)return{ta:s.Ub>=n.Ub&&s.$b>=n.$b}}(this.Yb.get(t),n,this.q_))}vd(t){return this.Kb(t,[])}iw(t,e){const i=e;!function(t){void 0===t.zb&&(t.zb=t.time)}(i),this.q_.preprocessData(e);const s=this.q_.createConverterToInternalObj([e])(e.time),n=this.Zb.get(t);if(void 0!==n&&this.q_.key(s)<this.q_.key(n))throw new Error(`Cannot update oldest data, last time=${n}, new time=${s}`);let r=this.qb.get(this.q_.key(s));const o=void 0===r;void 0===r&&(r=nn(s),this.qb.set(this.q_.key(s),r));const h=sn(t.Qh()),l=t.Ca(),a=t.Ta(),c=h(s,r.ee,e,i.zb,l,a);r.Hb.set(t,c),this.nw(t,c);const u={ta:Zs(c)};if(!o)return this.tw(t,-1,u);const d={timeWeight:0,time:r.la,pointData:r,originalTime:on(r.Hb)},f=Wt(this.Xb,this.q_.key(d.time),(t,e)=>this.q_.key(t.time)<e);this.Xb.splice(f,0,d);for(let t=f;t<this.Xb.length;++t)ln(this.Xb[t].pointData,t);return this.q_.fillWeightsForPoints(this.Xb,f),this.tw(t,f,u)}nw(t,e){let i=this.Yb.get(t);void 0===i&&(i=[],this.Yb.set(t,i));const s=0!==i.length?i[i.length-1]:null;null===s||this.q_.key(e.ot)>this.q_.key(s.ot)?Zs(e)&&i.push(e):Zs(e)?i[i.length-1]=e:i.splice(-1,1),this.Zb.set(t,e.ot)}Jb(t,e){0!==e.length?(this.Yb.set(t,e.filter(Zs)),this.Zb.set(t,e[e.length-1].ot)):(this.Yb.delete(t),this.Zb.delete(t))}Gb(){for(const t of this.Xb)0===t.pointData.Hb.size&&this.qb.delete(this.q_.key(t.time))}Qb(t){let e=-1;for(let i=0;i<this.Xb.length&&i<t.length;++i){const s=this.Xb[i],n=t[i];if(this.q_.key(s.time)!==this.q_.key(n.time)){e=i;break}n.timeWeight=s.timeWeight,ln(n.pointData,i)}if(-1===e&&this.Xb.length!==t.length&&(e=Math.min(this.Xb.length,t.length)),-1===e)return-1;for(let i=e;i<t.length;++i)ln(t[i].pointData,i);return this.q_.fillWeightsForPoints(t,e),this.Xb=t,e}sw(){if(0===this.Yb.size)return null;let t=0;return this.Yb.forEach(e=>{0!==e.length&&(t=Math.max(t,e[e.length-1].ee))}),t}tw(t,e,i){const s={ew:new Map,St:{Eu:this.sw()}};if(-1!==e)this.Yb.forEach((e,n)=>{s.ew.set(n,{$e:e,rw:n===t?i:void 0})}),this.Yb.has(t)||s.ew.set(t,{$e:[],rw:i}),s.St.hw=this.Xb,s.St.lw=e;else{const e=this.Yb.get(t);s.ew.set(t,{$e:e||[],rw:i})}return s}}function ln(t,e){t.ee=e,t.Hb.forEach(t=>{t.ee=e})}function an(t){const e={value:t.Vt[3],time:t.zb};return void 0!==t.jb&&(e.customValues=t.jb),e}function cn(t){const e=an(t);return void 0!==t.V&&(e.color=t.V),e}function un(t){const e=an(t);return void 0!==t.lt&&(e.lineColor=t.lt),void 0!==t.Ps&&(e.topColor=t.Ps),void 0!==t.Rs&&(e.bottomColor=t.Rs),e}function dn(t){const e=an(t);return void 0!==t.Re&&(e.topLineColor=t.Re),void 0!==t.De&&(e.bottomLineColor=t.De),void 0!==t.ke&&(e.topFillColor1=t.ke),void 0!==t.ye&&(e.topFillColor2=t.ye),void 0!==t.Ce&&(e.bottomFillColor1=t.Ce),void 0!==t.Te&&(e.bottomFillColor2=t.Te),e}function fn(t){const e={open:t.Vt[0],high:t.Vt[1],low:t.Vt[2],close:t.Vt[3],time:t.zb};return void 0!==t.jb&&(e.customValues=t.jb),e}function mn(t){const e=fn(t);return void 0!==t.V&&(e.color=t.V),e}function pn(t){const e=fn(t),{V:i,Ot:s,Xh:n}=t;return void 0!==i&&(e.color=i),void 0!==s&&(e.borderColor=s),void 0!==n&&(e.wickColor=n),e}function gn(t){return{Area:un,Line:cn,Baseline:dn,Histogram:cn,Bar:mn,Candlestick:pn,Custom:vn}[t]}function vn(t){const e=t.zb;return Object.assign(Object.assign({},t.$e),{time:e})}const bn={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},wn={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},yn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:J,attributionLogo:!0},Sn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},xn={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,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0},Cn={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:J,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function Mn(){return{width:0,height:0,autoSize:!1,layout:yn,crosshair:bn,grid:wn,overlayPriceScales:Object.assign({},Sn),leftPriceScale:Object.assign(Object.assign({},Sn),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Sn),{visible:!0}),timeScale:xn,watermark:Cn,localization:{locale:hs?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class _n{constructor(t,e){this.aw=t,this.ow=e}applyOptions(t){this.aw.$t().$c(this.ow,t)}options(){return this.Li().W()}width(){return yt(this.ow)?this.aw.Mb(this.ow):0}Li(){return k(this.aw.$t().Uc(this.ow)).Dt}}function En(t,e,i){const s=Ks(t,["time","originalTime"]),n=Object.assign({time:e},s);return void 0!==i&&(n.originalTime=i),n}const zn={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class kn{constructor(t){this.Nh=t}applyOptions(t){this.Nh.$h(t)}options(){return this.Nh.W()}_w(){return this.Nh}}class Rn{constructor(t,e,i,s,n){this.uw=new A,this.Es=t,this.cw=e,this.dw=i,this.q_=n,this.fw=s}S(){this.uw.S()}priceFormatter(){return this.Es.ba()}priceToCoordinate(t){const e=this.Es.Ct();return null===e?null:this.Es.Dt().Rt(t,e.Vt)}coordinateToPrice(t){const e=this.Es.Ct();return null===e?null:this.Es.Dt().pn(t,e.Vt)}barsInLogicalRange(t){if(null===t)return null;const e=new Ni(new Ri(t.from,t.to)).lu(),i=this.Es.In();if(i.Ni())return null;const s=i.ll(e.Os(),1),n=i.ll(e.ui(),-1),r=k(i.el()),o=k(i.An());if(null!==s&&null!==n&&s.ee>n.ee)return{barsBefore:t.from-r,barsAfter:o-t.to};const h={barsBefore:null===s||s.ee===r?t.from-r:s.ee-r,barsAfter:null===n||n.ee===o?o-t.to:o-n.ee};return null!==s&&null!==n&&(h.from=s.zb,h.to=n.zb),h}setData(t){this.q_,this.Es.Qh(),this.cw.pw(this.Es,t),this.mw("full")}update(t){this.Es.Qh(),this.cw.bw(this.Es,t),this.mw("update")}dataByIndex(t,e){const i=this.Es.In().ll(t,e);return null===i?null:gn(this.seriesType())(i)}data(){const t=gn(this.seriesType());return this.Es.In().ne().map(e=>t(e))}subscribeDataChanged(t){this.uw.l(t)}unsubscribeDataChanged(t){this.uw.v(t)}setMarkers(t){this.q_;const e=t.map(t=>En(t,this.q_.convertHorzItemToInternal(t.time),t.time));this.Es.na(e)}markers(){return this.Es.sa().map(t=>En(t,t.originalTime,void 0))}applyOptions(t){this.Es.$h(t)}options(){return K(this.Es.W())}priceScale(){return this.dw.priceScale(this.Es.Dt().Pa())}createPriceLine(t){const e=I(K(zn),t),i=this.Es.ea(e);return new kn(i)}removePriceLine(t){this.Es.ra(t._w())}seriesType(){return this.Es.Qh()}attachPrimitive(t){this.Es.ka(t),t.attached&&t.attached({chart:this.fw,series:this,requestUpdate:()=>this.Es.$t().Kl()})}detachPrimitive(t){this.Es.ya(t),t.detached&&t.detached()}mw(t){this.uw.M()&&this.uw.m(t)}}class Ln{constructor(t,e,i){this.ww=new A,this.mu=new A,this.Om=new A,this.$i=t,this.yl=t.St(),this.ab=e,this.yl.nc().l(this.gw.bind(this)),this.yl.sc().l(this.Mw.bind(this)),this.ab.Nm().l(this.xw.bind(this)),this.q_=i}S(){this.yl.nc().p(this),this.yl.sc().p(this),this.ab.Nm().p(this),this.ww.S(),this.mu.S(),this.Om.S()}scrollPosition(){return this.yl.Hu()}scrollToPosition(t,e){e?this.yl.Ju(t,1e3):this.$i.Jn(t)}scrollToRealTime(){this.yl.Gu()}getVisibleRange(){const t=this.yl.Vu();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const e={from:this.q_.convertHorzItemToInternal(t.from),to:this.q_.convertHorzItemToInternal(t.to)},i=this.yl.Iu(e);this.$i.pd(i)}getVisibleLogicalRange(){const t=this.yl.Du();return null===t?null:{from:t.Os(),to:t.ui()}}setVisibleLogicalRange(t){E(t.from<=t.to,"The from index cannot be after the to index."),this.$i.pd(t)}resetTimeScale(){this.$i.Kn()}fitContent(){this.$i.hc()}logicalToCoordinate(t){const e=this.$i.St();return e.Ni()?null:e.It(t)}coordinateToLogical(t){return this.yl.Ni()?null:this.yl.Nu(t)}timeToCoordinate(t){const e=this.q_.convertHorzItemToInternal(t),i=this.yl.Va(e,!1);return null===i?null:this.yl.It(i)}coordinateToTime(t){const e=this.$i.St(),i=e.Nu(t),s=e.Ui(i);return null===s?null:s.originalTime}width(){return this.ab.um().width}height(){return this.ab.um().height}subscribeVisibleTimeRangeChange(t){this.ww.l(t)}unsubscribeVisibleTimeRangeChange(t){this.ww.v(t)}subscribeVisibleLogicalRangeChange(t){this.mu.l(t)}unsubscribeVisibleLogicalRangeChange(t){this.mu.v(t)}subscribeSizeChange(t){this.Om.l(t)}unsubscribeSizeChange(t){this.Om.v(t)}applyOptions(t){this.yl.$h(t)}options(){return Object.assign(Object.assign({},K(this.yl.W())),{barSpacing:this.yl.le()})}gw(){this.ww.M()&&this.ww.m(this.getVisibleRange())}Mw(){this.mu.M()&&this.mu.m(this.getVisibleLogicalRange())}xw(t){this.Om.m(t.width,t.height)}}function Tn(t){return function(t){if(H(t.handleScale)){const e=t.handleScale;t.handleScale={axisDoubleClickReset:{time:e,price:e},axisPressedMouseMove:{time:e,price:e},mouseWheel:e,pinch:e}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:e,axisDoubleClickReset:i}=t.handleScale;H(e)&&(t.handleScale.axisPressedMouseMove={time:e,price:e}),H(i)&&(t.handleScale.axisDoubleClickReset={time:i,price:i})}const e=t.handleScroll;H(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})}(t),t}class Nn{constructor(t,e,i){this.Sw=new Map,this.kw=new Map,this.yw=new A,this.Cw=new A,this.Tw=new A,this.Pw=new hn(e);const s=void 0===i?K(Mn()):I(K(Mn()),Tn(i));this.q_=e,this.aw=new Us(t,s,e),this.aw.lm().l(t=>{this.yw.M()&&this.yw.m(this.Rw(t()))},this),this.aw.am().l(t=>{this.Cw.M()&&this.Cw.m(this.Rw(t()))},this),this.aw.Xc().l(t=>{this.Tw.M()&&this.Tw.m(this.Rw(t()))},this);const n=this.aw.$t();this.Dw=new Ln(n,this.aw.fb(),this.q_)}remove(){this.aw.lm().p(this),this.aw.am().p(this),this.aw.Xc().p(this),this.Dw.S(),this.aw.S(),this.Sw.clear(),this.kw.clear(),this.yw.S(),this.Cw.S(),this.Tw.S(),this.Pw.S()}resize(t,e,i){this.autoSizeActive()||this.aw._b(t,e,i)}addCustomSeries(t,e){const i=R(t),s=Object.assign(Object.assign({},w),i.defaultOptions());return this.Vw("Custom",s,e,i)}addAreaSeries(t){return this.Vw("Area",g,t)}addBaselineSeries(t){return this.Vw("Baseline",v,t)}addBarSeries(t){return this.Vw("Bar",m,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.Vw("Candlestick",f,t)}addHistogramSeries(t){return this.Vw("Histogram",b,t)}addLineSeries(t){return this.Vw("Line",p,t)}removeSeries(t){const e=z(this.Sw.get(t)),i=this.Pw.vd(e);this.aw.$t().vd(e),this.Ow(i),this.Sw.delete(t),this.kw.delete(e)}pw(t,e){this.Ow(this.Pw.Kb(t,e))}bw(t,e){this.Ow(this.Pw.iw(t,e))}subscribeClick(t){this.yw.l(t)}unsubscribeClick(t){this.yw.v(t)}subscribeCrosshairMove(t){this.Tw.l(t)}unsubscribeCrosshairMove(t){this.Tw.v(t)}subscribeDblClick(t){this.Cw.l(t)}unsubscribeDblClick(t){this.Cw.v(t)}priceScale(t){return new _n(this.aw,t)}timeScale(){return this.Dw}applyOptions(t){this.aw.$h(Tn(t))}options(){return this.aw.W()}takeScreenshot(){return this.aw.wb()}autoSizeActive(){return this.aw.kb()}chartElement(){return this.aw.yb()}paneSize(){const t=this.aw.Tb();return{height:t.height,width:t.width}}setCrosshairPosition(t,e,i){const s=this.Sw.get(i);if(void 0===s)return;const n=this.aw.$t().dr(s);null!==n&&this.aw.$t().ad(t,e,n)}clearCrosshairPosition(){this.aw.$t().od(!0)}Vw(t,e,i={},s){!function(t){if(void 0===t||"custom"===t.type)return;const e=t;void 0!==e.minMove&&void 0===e.precision&&(e.precision=function(t){if(t>=1)return 0;let e=0;for(;e<8;e++){const i=Math.round(t);if(Math.abs(i-t)<1e-8)return e;t*=10}return e}(e.minMove))}(i.priceFormat);const n=I(K(y),K(e),i),r=this.aw.$t().dd(t,n,s),o=new Rn(r,this,this,this,this.q_);return this.Sw.set(o,r),this.kw.set(r,o),o}Ow(t){const e=this.aw.$t();e._d(t.St.Eu,t.St.hw,t.St.lw),t.ew.forEach((t,e)=>e.J(t.$e,t.rw)),e.Wu()}Bw(t){return z(this.kw.get(t))}Rw(t){const e=new Map;t.Nb.forEach((t,i)=>{const s=i.Qh(),n=gn(s)(t);if("Custom"!==s)E(function(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}(n));else{const t=i.Ta();E(!t||!1===t(n))}e.set(this.Bw(i),n)});const i=void 0!==t.Eb&&this.kw.has(t.Eb)?this.Bw(t.Eb):void 0;return{time:t.zb,logical:t.ee,point:t.Lb,hoveredSeries:i,hoveredObjectId:t.Fb,seriesData:e,sourceEvent:t.Wb}}}function On(t,e){return function(t,e,i){let s;if(U(t)){const e=document.getElementById(t);E(null!==e,`Cannot find element in DOM with id=${t}`),s=e}else s=t;const n=new Nn(s,e,i);return e.setOptions(n.options()),n}(t,new os,os.Id(e))}Object.assign(Object.assign({},y),w);const $n=t=>{const[n]=e(t||null),[r,o]=e(!1),[h,l]=e(!1);i(()=>{if(!n)return o(!1),void l(!1);l(!0);const t=()=>{console.log("✅ [useSocket] Connected to Socket.IO server"),o(!0),l(!1)},e=()=>{console.log("🔌 [useSocket] Disconnected from Socket.IO server"),o(!1),l(!1)},i=t=>{console.error("❌ [useSocket] Connection error:",t),l(!1)};return n.connected&&(o(!0),l(!1)),n.on("connect",t),n.on("disconnect",e),n.on("connect_error",i),()=>{n.off("connect",t),n.off("disconnect",e),n.off("connect_error",i)}},[n]);const a=s(()=>{console.log("🔍 [useSocket] Connect called - connection managed by provider")},[]),c=s(()=>{console.log("🔍 [useSocket] Disconnect called - connection managed by provider")},[]),u=s((t,e=60,i,s,r)=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot subscribe"),!1;try{return n.emit("ohlcv:subscribe",{mint:t,timeFrame:e}),i&&n.on("ohlcv:initial",i),s&&n.on("ohlcv:update",s),r&&n.on("ohlcv:newCandle",r),console.log(`📊 [useSocket] Subscribed to OHLCV updates for ${t} (${e}s)`),!0}catch(t){return console.error("❌ [useSocket] Failed to subscribe to OHLCV:",t),!1}},[n]),d=s((t,e=60,i,s,r)=>{if(!n?.connected)return!1;try{return n.emit("ohlcv:unsubscribe",{mint:t,timeFrame:e}),i&&n.off("ohlcv:initial",i),s&&n.off("ohlcv:update",s),r&&n.off("ohlcv:newCandle",r),console.log(`📊 [useSocket] Unsubscribed from OHLCV updates for ${t} (${e}s)`),!0}catch(t){return console.error("❌ [useSocket] Failed to unsubscribe from OHLCV:",t),!1}},[n]),f=s((t,e)=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot subscribe"),!1;try{return n.emit("price:subscribe",{mint:t}),e&&n.on("price:update",e),console.log(`💰 [useSocket] Subscribed to price updates for ${t}`),!0}catch(t){return console.error("❌ [useSocket] Failed to subscribe to price:",t),!1}},[n]),m=s((t,e)=>{if(!n?.connected)return!1;try{return n.emit("price:unsubscribe",{mint:t}),e&&n.off("price:update",e),console.log(`💰 [useSocket] Unsubscribed from price updates for ${t}`),!0}catch(t){return console.error("❌ [useSocket] Failed to unsubscribe from price:",t),!1}},[n]),p=s(t=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot send test message"),!1;try{return n.emit("test-message",{message:t,timestamp:Date.now()}),n.once("test-response",t=>{console.log("🧪 [useSocket] Test response received:",t)}),!0}catch(t){return console.error("❌ [useSocket] Failed to send test message:",t),!1}},[n]);return{socket:n,isConnected:r,isConnecting:h,connect:a,disconnect:c,subscribeToOHLCV:u,unsubscribeFromOHLCV:d,subscribeToPrice:f,unsubscribeFromPrice:m,testConnection:p}};function Pn(t,r){const[o,h]=e(null),[l,a]=e(!1),[c,u]=e(null),[d,f]=e(null),[m,p]=e(!1);i(()=>{r&&(h(r),f(Date.now()),p(!0),a(!1))},[r]);const g=n(()=>{if(!o||!o.market)return{currentPrice:0,currentMarketCap:0,currentVolume:0,performance24h:{value:"0.00%",isPositive:!1,raw:0},performance7d:{value:"0.00%",isPositive:!1,raw:0},performance1m:{value:"0.00%",isPositive:!1,raw:0},performanceAllTime:{value:"0.00%",isPositive:!1,raw:0},high24h:0,low24h:0,volume24h:0,return24h:0};const t=parseFloat(o.market?.price||"0")||0,e=parseFloat(o.market?.marketCap||"0")||0;let i=parseFloat(o.volume?.current||"0")||0;i<=.01&&(i=parseFloat(o.blockchain?.currentRealSol||"0")||0);const s={value:o.performance?.["24H"]?.percentage||"0.00%",isPositive:o.performance?.["24H"]?.isPositive||!1,raw:o.performance?.["24H"]?.gain||0},n={value:o.performance?.["7D"]?.percentage||"0.00%",isPositive:o.performance?.["7D"]?.isPositive||!1,raw:o.performance?.["7D"]?.gain||0},r={value:o.performance?.["1M"]?.percentage||"0.00%",isPositive:o.performance?.["1M"]?.isPositive||!1,raw:o.performance?.["1M"]?.gain||0},h={value:o.performance?.["All Time"]?.percentage||"0.00%",isPositive:o.performance?.["All Time"]?.isPositive||!1,raw:o.performance?.["All Time"]?.gain||0},l=parseFloat(o["24H"]?.high||"0")||0,a=parseFloat(o["24H"]?.low||"0")||0;let c=parseFloat(o.volume?.["24h"]||"0")||0;c<=.01&&(c=parseFloat(o.blockchain?.currentRealSol||"0")||0);return{currentPrice:t,currentMarketCap:e,currentVolume:i,performance24h:s,performance7d:n,performance1m:r,performanceAllTime:h,high24h:l,low24h:a,volume24h:c,return24h:parseFloat(o["24H"]?.return||"0")||0}},[o]),v=s(t=>t>.01,[]);return{analytics:o,...g,isRealVolume:v,loading:l,error:c,connected:m,lastUpdate:d}}function Vn(t,e){return function(){return t.apply(e,arguments)}}const{toString:Dn}=Object.prototype,{getPrototypeOf:Bn}=Object,{iterator:Fn,toStringTag:An}=Symbol,In=(Wn=Object.create(null),t=>{const e=Dn.call(t);return Wn[e]||(Wn[e]=e.slice(8,-1).toLowerCase())});var Wn;const jn=t=>(t=t.toLowerCase(),e=>In(e)===t),Un=t=>e=>typeof e===t,{isArray:Hn}=Array,Kn=Un("undefined");function qn(t){return null!==t&&!Kn(t)&&null!==t.constructor&&!Kn(t.constructor)&&Gn(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Xn=jn("ArrayBuffer");const Jn=Un("string"),Gn=Un("function"),Qn=Un("number"),Yn=t=>null!==t&&"object"==typeof t,Zn=t=>{if("object"!==In(t))return!1;const e=Bn(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||An in t||Fn in t)},tr=jn("Date"),er=jn("File"),ir=jn("Blob"),sr=jn("FileList"),nr=jn("URLSearchParams"),[rr,or,hr,lr]=["ReadableStream","Request","Response","Headers"].map(jn);function ar(t,e,{allOwnKeys:i=!1}={}){if(null==t)return;let s,n;if("object"!=typeof t&&(t=[t]),Hn(t))for(s=0,n=t.length;s<n;s++)e.call(null,t[s],s,t);else{if(qn(t))return;const n=i?Object.getOwnPropertyNames(t):Object.keys(t),r=n.length;let o;for(s=0;s<r;s++)o=n[s],e.call(null,t[o],o,t)}}function cr(t,e){if(qn(t))return null;e=e.toLowerCase();const i=Object.keys(t);let s,n=i.length;for(;n-- >0;)if(s=i[n],e===s.toLowerCase())return s;return null}const ur="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,dr=t=>!Kn(t)&&t!==ur;const fr=(mr="undefined"!=typeof Uint8Array&&Bn(Uint8Array),t=>mr&&t instanceof mr);var mr;const pr=jn("HTMLFormElement"),gr=(({hasOwnProperty:t})=>(e,i)=>t.call(e,i))(Object.prototype),vr=jn("RegExp"),br=(t,e)=>{const i=Object.getOwnPropertyDescriptors(t),s={};ar(i,(i,n)=>{let r;!1!==(r=e(i,n,t))&&(s[n]=r||i)}),Object.defineProperties(t,s)};const wr=jn("AsyncFunction"),yr=(Sr="function"==typeof setImmediate,xr=Gn(ur.postMessage),Sr?setImmediate:xr?(Cr=`axios@${Math.random()}`,Mr=[],ur.addEventListener("message",({source:t,data:e})=>{t===ur&&e===Cr&&Mr.length&&Mr.shift()()},!1),t=>{Mr.push(t),ur.postMessage(Cr,"*")}):t=>setTimeout(t));var Sr,xr,Cr,Mr;const _r="undefined"!=typeof queueMicrotask?queueMicrotask.bind(ur):"undefined"!=typeof process&&process.nextTick||yr;var Er={isArray:Hn,isArrayBuffer:Xn,isBuffer:qn,isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||Gn(t.append)&&("formdata"===(e=In(t))||"object"===e&&Gn(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&Xn(t.buffer),e},isString:Jn,isNumber:Qn,isBoolean:t=>!0===t||!1===t,isObject:Yn,isPlainObject:Zn,isEmptyObject:t=>{if(!Yn(t)||qn(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:rr,isRequest:or,isResponse:hr,isHeaders:lr,isUndefined:Kn,isDate:tr,isFile:er,isBlob:ir,isRegExp:vr,isFunction:Gn,isStream:t=>Yn(t)&&Gn(t.pipe),isURLSearchParams:nr,isTypedArray:fr,isFileList:sr,forEach:ar,merge:function t(){const{caseless:e,skipUndefined:i}=dr(this)&&this||{},s={},n=(n,r)=>{const o=e&&cr(s,r)||r;Zn(s[o])&&Zn(n)?s[o]=t(s[o],n):Zn(n)?s[o]=t({},n):Hn(n)?s[o]=n.slice():i&&Kn(n)||(s[o]=n)};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&ar(arguments[t],n);return s},extend:(t,e,i,{allOwnKeys:s}={})=>(ar(e,(e,s)=>{i&&Gn(e)?t[s]=Vn(e,i):t[s]=e},{allOwnKeys:s}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,i,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),i&&Object.assign(t.prototype,i)},toFlatObject:(t,e,i,s)=>{let n,r,o;const h={};if(e=e||{},null==t)return e;do{for(n=Object.getOwnPropertyNames(t),r=n.length;r-- >0;)o=n[r],s&&!s(o,t,e)||h[o]||(e[o]=t[o],h[o]=!0);t=!1!==i&&Bn(t)}while(t&&(!i||i(t,e))&&t!==Object.prototype);return e},kindOf:In,kindOfTest:jn,endsWith:(t,e,i)=>{t=String(t),(void 0===i||i>t.length)&&(i=t.length),i-=e.length;const s=t.indexOf(e,i);return-1!==s&&s===i},toArray:t=>{if(!t)return null;if(Hn(t))return t;let e=t.length;if(!Qn(e))return null;const i=new Array(e);for(;e-- >0;)i[e]=t[e];return i},forEachEntry:(t,e)=>{const i=(t&&t[Fn]).call(t);let s;for(;(s=i.next())&&!s.done;){const i=s.value;e.call(t,i[0],i[1])}},matchAll:(t,e)=>{let i;const s=[];for(;null!==(i=t.exec(e));)s.push(i);return s},isHTMLForm:pr,hasOwnProperty:gr,hasOwnProp:gr,reduceDescriptors:br,freezeMethods:t=>{br(t,(e,i)=>{if(Gn(t)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const s=t[i];Gn(s)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))})},toObjectSet:(t,e)=>{const i={},s=t=>{t.forEach(t=>{i[t]=!0})};return Hn(t)?s(t):s(String(t).split(e)),i},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,i){return e.toUpperCase()+i}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:cr,global:ur,isContextDefined:dr,isSpecCompliantForm:function(t){return!!(t&&Gn(t.append)&&"FormData"===t[An]&&t[Fn])},toJSONObject:t=>{const e=new Array(10),i=(t,s)=>{if(Yn(t)){if(e.indexOf(t)>=0)return;if(qn(t))return t;if(!("toJSON"in t)){e[s]=t;const n=Hn(t)?[]:{};return ar(t,(t,e)=>{const r=i(t,s+1);!Kn(r)&&(n[e]=r)}),e[s]=void 0,n}}return t};return i(t,0)},isAsyncFn:wr,isThenable:t=>t&&(Yn(t)||Gn(t))&&Gn(t.then)&&Gn(t.catch),setImmediate:yr,asap:_r,isIterable:t=>null!=t&&Gn(t[Fn])};function zr(t,e,i,s,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),i&&(this.config=i),s&&(this.request=s),n&&(this.response=n,this.status=n.status?n.status:null)}Er.inherits(zr,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Er.toJSONObject(this.config),code:this.code,status:this.status}}});const kr=zr.prototype,Rr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Rr[t]={value:t}}),Object.defineProperties(zr,Rr),Object.defineProperty(kr,"isAxiosError",{value:!0}),zr.from=(t,e,i,s,n,r)=>{const o=Object.create(kr);Er.toFlatObject(t,o,function(t){return t!==Error.prototype},t=>"isAxiosError"!==t);const h=t&&t.message?t.message:"Error",l=null==e&&t?t.code:e;return zr.call(o,h,l,i,s,n),t&&null==o.cause&&Object.defineProperty(o,"cause",{value:t,configurable:!0}),o.name=t&&t.name||"Error",r&&Object.assign(o,r),o};function Lr(t){return Er.isPlainObject(t)||Er.isArray(t)}function Tr(t){return Er.endsWith(t,"[]")?t.slice(0,-2):t}function Nr(t,e,i){return t?t.concat(e).map(function(t,e){return t=Tr(t),!i&&e?"["+t+"]":t}).join(i?".":""):e}const Or=Er.toFlatObject(Er,{},null,function(t){return/^is[A-Z]/.test(t)});function $r(t,e,i){if(!Er.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const s=(i=Er.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!Er.isUndefined(e[t])})).metaTokens,n=i.visitor||a,r=i.dots,o=i.indexes,h=(i.Blob||"undefined"!=typeof Blob&&Blob)&&Er.isSpecCompliantForm(e);if(!Er.isFunction(n))throw new TypeError("visitor must be a function");function l(t){if(null===t)return"";if(Er.isDate(t))return t.toISOString();if(Er.isBoolean(t))return t.toString();if(!h&&Er.isBlob(t))throw new zr("Blob is not supported. Use a Buffer instead.");return Er.isArrayBuffer(t)||Er.isTypedArray(t)?h&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function a(t,i,n){let h=t;if(t&&!n&&"object"==typeof t)if(Er.endsWith(i,"{}"))i=s?i:i.slice(0,-2),t=JSON.stringify(t);else if(Er.isArray(t)&&function(t){return Er.isArray(t)&&!t.some(Lr)}(t)||(Er.isFileList(t)||Er.endsWith(i,"[]"))&&(h=Er.toArray(t)))return i=Tr(i),h.forEach(function(t,s){!Er.isUndefined(t)&&null!==t&&e.append(!0===o?Nr([i],s,r):null===o?i:i+"[]",l(t))}),!1;return!!Lr(t)||(e.append(Nr(n,i,r),l(t)),!1)}const c=[],u=Object.assign(Or,{defaultVisitor:a,convertValue:l,isVisitable:Lr});if(!Er.isObject(t))throw new TypeError("data must be an object");return function t(i,s){if(!Er.isUndefined(i)){if(-1!==c.indexOf(i))throw Error("Circular reference detected in "+s.join("."));c.push(i),Er.forEach(i,function(i,r){!0===(!(Er.isUndefined(i)||null===i)&&n.call(e,i,Er.isString(r)?r.trim():r,s,u))&&t(i,s?s.concat(r):[r])}),c.pop()}}(t),e}function Pr(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function Vr(t,e){this._pairs=[],t&&$r(t,this,e)}const Dr=Vr.prototype;function Br(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Fr(t,e,i){if(!e)return t;const s=i&&i.encode||Br;Er.isFunction(i)&&(i={serialize:i});const n=i&&i.serialize;let r;if(r=n?n(e,i):Er.isURLSearchParams(e)?e.toString():new Vr(e,i).toString(s),r){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t}Dr.append=function(t,e){this._pairs.push([t,e])},Dr.toString=function(t){const e=t?function(e){return t.call(this,e,Pr)}:Pr;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};class Ar{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Er.forEach(this.handlers,function(e){null!==e&&t(e)})}}var Ir={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wr={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Vr,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const jr="undefined"!=typeof window&&"undefined"!=typeof document,Ur="object"==typeof navigator&&navigator||void 0,Hr=jr&&(!Ur||["ReactNative","NativeScript","NS"].indexOf(Ur.product)<0),Kr="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,qr=jr&&window.location.href||"http://localhost";var Xr={...Object.freeze({__proto__:null,hasBrowserEnv:jr,hasStandardBrowserEnv:Hr,hasStandardBrowserWebWorkerEnv:Kr,navigator:Ur,origin:qr}),...Wr};function Jr(t){function e(t,i,s,n){let r=t[n++];if("__proto__"===r)return!0;const o=Number.isFinite(+r),h=n>=t.length;if(r=!r&&Er.isArray(s)?s.length:r,h)return Er.hasOwnProp(s,r)?s[r]=[s[r],i]:s[r]=i,!o;s[r]&&Er.isObject(s[r])||(s[r]=[]);return e(t,i,s[r],n)&&Er.isArray(s[r])&&(s[r]=function(t){const e={},i=Object.keys(t);let s;const n=i.length;let r;for(s=0;s<n;s++)r=i[s],e[r]=t[r];return e}(s[r])),!o}if(Er.isFormData(t)&&Er.isFunction(t.entries)){const i={};return Er.forEachEntry(t,(t,s)=>{e(function(t){return Er.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),s,i,0)}),i}return null}const Gr={transitional:Ir,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",s=i.indexOf("application/json")>-1,n=Er.isObject(t);n&&Er.isHTMLForm(t)&&(t=new FormData(t));if(Er.isFormData(t))return s?JSON.stringify(Jr(t)):t;if(Er.isArrayBuffer(t)||Er.isBuffer(t)||Er.isStream(t)||Er.isFile(t)||Er.isBlob(t)||Er.isReadableStream(t))return t;if(Er.isArrayBufferView(t))return t.buffer;if(Er.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let r;if(n){if(i.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return $r(t,new Xr.classes.URLSearchParams,{visitor:function(t,e,i,s){return Xr.isNode&&Er.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((r=Er.isFileList(t))||i.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return $r(r?{"files[]":t}:t,e&&new e,this.formSerializer)}}return n||s?(e.setContentType("application/json",!1),function(t,e,i){if(Er.isString(t))try{return(e||JSON.parse)(t),Er.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(i||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||Gr.transitional,i=e&&e.forcedJSONParsing,s="json"===this.responseType;if(Er.isResponse(t)||Er.isReadableStream(t))return t;if(t&&Er.isString(t)&&(i&&!this.responseType||s)){const i=!(e&&e.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(t){if(i){if("SyntaxError"===t.name)throw zr.from(t,zr.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Xr.classes.FormData,Blob:Xr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Er.forEach(["delete","get","head","post","put","patch"],t=>{Gr.headers[t]={}});const Qr=Er.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Yr=Symbol("internals");function Zr(t){return t&&String(t).trim().toLowerCase()}function to(t){return!1===t||null==t?t:Er.isArray(t)?t.map(to):String(t)}function eo(t,e,i,s,n){return Er.isFunction(s)?s.call(this,e,i):(n&&(e=i),Er.isString(e)?Er.isString(s)?-1!==e.indexOf(s):Er.isRegExp(s)?s.test(e):void 0:void 0)}let io=class{constructor(t){t&&this.set(t)}set(t,e,i){const s=this;function n(t,e,i){const n=Zr(e);if(!n)throw new Error("header name must be a non-empty string");const r=Er.findKey(s,n);(!r||void 0===s[r]||!0===i||void 0===i&&!1!==s[r])&&(s[r||e]=to(t))}const r=(t,e)=>Er.forEach(t,(t,i)=>n(t,i,e));if(Er.isPlainObject(t)||t instanceof this.constructor)r(t,e);else if(Er.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))r((t=>{const e={};let i,s,n;return t&&t.split("\n").forEach(function(t){n=t.indexOf(":"),i=t.substring(0,n).trim().toLowerCase(),s=t.substring(n+1).trim(),!i||e[i]&&Qr[i]||("set-cookie"===i?e[i]?e[i].push(s):e[i]=[s]:e[i]=e[i]?e[i]+", "+s:s)}),e})(t),e);else if(Er.isObject(t)&&Er.isIterable(t)){let i,s,n={};for(const e of t){if(!Er.isArray(e))throw TypeError("Object iterator must return a key-value pair");n[s=e[0]]=(i=n[s])?Er.isArray(i)?[...i,e[1]]:[i,e[1]]:e[1]}r(n,e)}else null!=t&&n(e,t,i);return this}get(t,e){if(t=Zr(t)){const i=Er.findKey(this,t);if(i){const t=this[i];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=i.exec(t);)e[s[1]]=s[2];return e}(t);if(Er.isFunction(e))return e.call(this,t,i);if(Er.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Zr(t)){const i=Er.findKey(this,t);return!(!i||void 0===this[i]||e&&!eo(0,this[i],i,e))}return!1}delete(t,e){const i=this;let s=!1;function n(t){if(t=Zr(t)){const n=Er.findKey(i,t);!n||e&&!eo(0,i[n],n,e)||(delete i[n],s=!0)}}return Er.isArray(t)?t.forEach(n):n(t),s}clear(t){const e=Object.keys(this);let i=e.length,s=!1;for(;i--;){const n=e[i];t&&!eo(0,this[n],n,t,!0)||(delete this[n],s=!0)}return s}normalize(t){const e=this,i={};return Er.forEach(this,(s,n)=>{const r=Er.findKey(i,n);if(r)return e[r]=to(s),void delete e[n];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}(n):String(n).trim();o!==n&&delete e[n],e[o]=to(s),i[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return Er.forEach(this,(i,s)=>{null!=i&&!1!==i&&(e[s]=t&&Er.isArray(i)?i.join(", "):i)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const i=new this(t);return e.forEach(t=>i.set(t)),i}static accessor(t){const e=(this[Yr]=this[Yr]={accessors:{}}).accessors,i=this.prototype;function s(t){const s=Zr(t);e[s]||(!function(t,e){const i=Er.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+i,{value:function(t,i,n){return this[s].call(this,e,t,i,n)},configurable:!0})})}(i,t),e[s]=!0)}return Er.isArray(t)?t.forEach(s):s(t),this}};function so(t,e){const i=this||Gr,s=e||i,n=io.from(s.headers);let r=s.data;return Er.forEach(t,function(t){r=t.call(i,r,n.normalize(),e?e.status:void 0)}),n.normalize(),r}function no(t){return!(!t||!t.__CANCEL__)}function ro(t,e,i){zr.call(this,null==t?"canceled":t,zr.ERR_CANCELED,e,i),this.name="CanceledError"}function oo(t,e,i){const s=i.config.validateStatus;i.status&&s&&!s(i.status)?e(new zr("Request failed with status code "+i.status,[zr.ERR_BAD_REQUEST,zr.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):t(i)}io.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Er.reduceDescriptors(io.prototype,({value:t},e)=>{let i=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[i]=t}}}),Er.freezeMethods(io),Er.inherits(ro,zr,{__CANCEL__:!0});const ho=(t,e,i=3)=>{let s=0;const n=function(t,e){t=t||10;const i=new Array(t),s=new Array(t);let n,r=0,o=0;return e=void 0!==e?e:1e3,function(h){const l=Date.now(),a=s[o];n||(n=l),i[r]=h,s[r]=l;let c=o,u=0;for(;c!==r;)u+=i[c++],c%=t;if(r=(r+1)%t,r===o&&(o=(o+1)%t),l-n<e)return;const d=a&&l-a;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(t,e){let i,s,n=0,r=1e3/e;const o=(e,r=Date.now())=>{n=r,i=null,s&&(clearTimeout(s),s=null),t(...e)};return[(...t)=>{const e=Date.now(),h=e-n;h>=r?o(t,e):(i=t,s||(s=setTimeout(()=>{s=null,o(i)},r-h)))},()=>i&&o(i)]}(i=>{const r=i.loaded,o=i.lengthComputable?i.total:void 0,h=r-s,l=n(h);s=r;t({loaded:r,total:o,progress:o?r/o:void 0,bytes:h,rate:l||void 0,estimated:l&&o&&r<=o?(o-r)/l:void 0,event:i,lengthComputable:null!=o,[e?"download":"upload"]:!0})},i)},lo=(t,e)=>{const i=null!=t;return[s=>e[0]({lengthComputable:i,total:t,loaded:s}),e[1]]},ao=t=>(...e)=>Er.asap(()=>t(...e));var co=Xr.hasStandardBrowserEnv?((t,e)=>i=>(i=new URL(i,Xr.origin),t.protocol===i.protocol&&t.host===i.host&&(e||t.port===i.port)))(new URL(Xr.origin),Xr.navigator&&/(msie|trident)/i.test(Xr.navigator.userAgent)):()=>!0,uo=Xr.hasStandardBrowserEnv?{write(t,e,i,s,n,r){const o=[t+"="+encodeURIComponent(e)];Er.isNumber(i)&&o.push("expires="+new Date(i).toGMTString()),Er.isString(s)&&o.push("path="+s),Er.isString(n)&&o.push("domain="+n),!0===r&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function fo(t,e,i){let s=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);return t&&(s||0==i)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const mo=t=>t instanceof io?{...t}:t;function po(t,e){e=e||{};const i={};function s(t,e,i,s){return Er.isPlainObject(t)&&Er.isPlainObject(e)?Er.merge.call({caseless:s},t,e):Er.isPlainObject(e)?Er.merge({},e):Er.isArray(e)?e.slice():e}function n(t,e,i,n){return Er.isUndefined(e)?Er.isUndefined(t)?void 0:s(void 0,t,0,n):s(t,e,0,n)}function r(t,e){if(!Er.isUndefined(e))return s(void 0,e)}function o(t,e){return Er.isUndefined(e)?Er.isUndefined(t)?void 0:s(void 0,t):s(void 0,e)}function h(i,n,r){return r in e?s(i,n):r in t?s(void 0,i):void 0}const l={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:h,headers:(t,e,i)=>n(mo(t),mo(e),0,!0)};return Er.forEach(Object.keys({...t,...e}),function(s){const r=l[s]||n,o=r(t[s],e[s],s);Er.isUndefined(o)&&r!==h||(i[s]=o)}),i}var go=t=>{const e=po({},t);let{data:i,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:h}=e;if(e.headers=o=io.from(o),e.url=Fr(fo(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),h&&o.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),Er.isFormData(i))if(Xr.hasStandardBrowserEnv||Xr.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Er.isFunction(i.getHeaders)){const t=i.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,i])=>{e.includes(t.toLowerCase())&&o.set(t,i)})}if(Xr.hasStandardBrowserEnv&&(s&&Er.isFunction(s)&&(s=s(e)),s||!1!==s&&co(e.url))){const t=n&&r&&uo.read(r);t&&o.set(n,t)}return e};var vo="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,i){const s=go(t);let n=s.data;const r=io.from(s.headers).normalize();let o,h,l,a,c,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=s;function m(){a&&a(),c&&c(),s.cancelToken&&s.cancelToken.unsubscribe(o),s.signal&&s.signal.removeEventListener("abort",o)}let p=new XMLHttpRequest;function g(){if(!p)return;const s=io.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders());oo(function(t){e(t),m()},function(t){i(t),m()},{data:u&&"text"!==u&&"json"!==u?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:s,config:t,request:p}),p=null}p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout,"onloadend"in p?p.onloadend=g:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(g)},p.onabort=function(){p&&(i(new zr("Request aborted",zr.ECONNABORTED,t,p)),p=null)},p.onerror=function(e){const s=new zr(e&&e.message?e.message:"Network Error",zr.ERR_NETWORK,t,p);s.event=e||null,i(s),p=null},p.ontimeout=function(){let e=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const n=s.transitional||Ir;s.timeoutErrorMessage&&(e=s.timeoutErrorMessage),i(new zr(e,n.clarifyTimeoutError?zr.ETIMEDOUT:zr.ECONNABORTED,t,p)),p=null},void 0===n&&r.setContentType(null),"setRequestHeader"in p&&Er.forEach(r.toJSON(),function(t,e){p.setRequestHeader(e,t)}),Er.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),u&&"json"!==u&&(p.responseType=s.responseType),f&&([l,c]=ho(f,!0),p.addEventListener("progress",l)),d&&p.upload&&([h,a]=ho(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",a)),(s.cancelToken||s.signal)&&(o=e=>{p&&(i(!e||e.type?new ro(null,t,p):e),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(o),s.signal&&(s.signal.aborted?o():s.signal.addEventListener("abort",o)));const v=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(s.url);v&&-1===Xr.protocols.indexOf(v)?i(new zr("Unsupported protocol "+v+":",zr.ERR_BAD_REQUEST,t)):p.send(n||null)})};const bo=(t,e)=>{const{length:i}=t=t?t.filter(Boolean):[];if(e||i){let i,s=new AbortController;const n=function(t){if(!i){i=!0,o();const e=t instanceof Error?t:this.reason;s.abort(e instanceof zr?e:new ro(e instanceof Error?e.message:e))}};let r=e&&setTimeout(()=>{r=null,n(new zr(`timeout ${e} of ms exceeded`,zr.ETIMEDOUT))},e);const o=()=>{t&&(r&&clearTimeout(r),r=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(n):t.removeEventListener("abort",n)}),t=null)};t.forEach(t=>t.addEventListener("abort",n));const{signal:h}=s;return h.unsubscribe=()=>Er.asap(o),h}},wo=function*(t,e){let i=t.byteLength;if(i<e)return void(yield t);let s,n=0;for(;n<i;)s=n+e,yield t.slice(n,s),n=s},yo=async function*(t){if(t[Symbol.asyncIterator])return void(yield*t);const e=t.getReader();try{for(;;){const{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},So=(t,e,i,s)=>{const n=async function*(t,e){for await(const i of yo(t))yield*wo(i,e)}(t,e);let r,o=0,h=t=>{r||(r=!0,s&&s(t))};return new ReadableStream({async pull(t){try{const{done:e,value:s}=await n.next();if(e)return h(),void t.close();let r=s.byteLength;if(i){let t=o+=r;i(t)}t.enqueue(new Uint8Array(s))}catch(t){throw h(t),t}},cancel:t=>(h(t),n.return())},{highWaterMark:2})},{isFunction:xo}=Er,Co=(({Request:t,Response:e})=>({Request:t,Response:e}))(Er.global),{ReadableStream:Mo,TextEncoder:_o}=Er.global,Eo=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},zo=t=>{t=Er.merge.call({skipUndefined:!0},Co,t);const{fetch:e,Request:i,Response:s}=t,n=e?xo(e):"function"==typeof fetch,r=xo(i),o=xo(s);if(!n)return!1;const h=n&&xo(Mo),l=n&&("function"==typeof _o?(a=new _o,t=>a.encode(t)):async t=>new Uint8Array(await new i(t).arrayBuffer()));var a;const c=r&&h&&Eo(()=>{let t=!1;const e=new i(Xr.origin,{body:new Mo,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),u=o&&h&&Eo(()=>Er.isReadableStream(new s("").body)),d={stream:u&&(t=>t.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!d[t]&&(d[t]=(e,i)=>{let s=e&&e[t];if(s)return s.call(e);throw new zr(`Response type '${t}' is not supported`,zr.ERR_NOT_SUPPORT,i)})});const f=async(t,e)=>{const s=Er.toFiniteNumber(t.getContentLength());return null==s?(async t=>{if(null==t)return 0;if(Er.isBlob(t))return t.size;if(Er.isSpecCompliantForm(t)){const e=new i(Xr.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return Er.isArrayBufferView(t)||Er.isArrayBuffer(t)?t.byteLength:(Er.isURLSearchParams(t)&&(t+=""),Er.isString(t)?(await l(t)).byteLength:void 0)})(e):s};return async t=>{let{url:n,method:o,data:h,signal:l,cancelToken:a,timeout:m,onDownloadProgress:p,onUploadProgress:g,responseType:v,headers:b,withCredentials:w="same-origin",fetchOptions:y}=go(t),S=e||fetch;v=v?(v+"").toLowerCase():"text";let x=bo([l,a&&a.toAbortSignal()],m),C=null;const M=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let _;try{if(g&&c&&"get"!==o&&"head"!==o&&0!==(_=await f(b,h))){let t,e=new i(n,{method:"POST",body:h,duplex:"half"});if(Er.isFormData(h)&&(t=e.headers.get("content-type"))&&b.setContentType(t),e.body){const[t,i]=lo(_,ho(ao(g)));h=So(e.body,65536,t,i)}}Er.isString(w)||(w=w?"include":"omit");const e=r&&"credentials"in i.prototype,l={...y,signal:x,method:o.toUpperCase(),headers:b.normalize().toJSON(),body:h,duplex:"half",credentials:e?w:void 0};C=r&&new i(n,l);let a=await(r?S(C,y):S(n,l));const m=u&&("stream"===v||"response"===v);if(u&&(p||m&&M)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=a[e]});const e=Er.toFiniteNumber(a.headers.get("content-length")),[i,n]=p&&lo(e,ho(ao(p),!0))||[];a=new s(So(a.body,65536,i,()=>{n&&n(),M&&M()}),t)}v=v||"text";let E=await d[Er.findKey(d,v)||"text"](a,t);return!m&&M&&M(),await new Promise((e,i)=>{oo(e,i,{data:E,headers:io.from(a.headers),status:a.status,statusText:a.statusText,config:t,request:C})})}catch(e){if(M&&M(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new zr("Network Error",zr.ERR_NETWORK,t,C),{cause:e.cause||e});throw zr.from(e,e&&e.code,t,C)}}},ko=new Map,Ro=t=>{let e=t?t.env:{};const{fetch:i,Request:s,Response:n}=e,r=[s,n,i];let o,h,l=r.length,a=ko;for(;l--;)o=r[l],h=a.get(o),void 0===h&&a.set(o,h=l?new Map:zo(e)),a=h;return h};Ro();const Lo={http:null,xhr:vo,fetch:{get:Ro}};Er.forEach(Lo,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const To=t=>`- ${t}`,No=t=>Er.isFunction(t)||null===t||!1===t;var Oo=(t,e)=>{t=Er.isArray(t)?t:[t];const{length:i}=t;let s,n;const r={};for(let o=0;o<i;o++){let i;if(s=t[o],n=s,!No(s)&&(n=Lo[(i=String(s)).toLowerCase()],void 0===n))throw new zr(`Unknown adapter '${i}'`);if(n&&(Er.isFunction(n)||(n=n.get(e))))break;r[i||"#"+o]=n}if(!n){const t=Object.entries(r).map(([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));throw new zr("There is no suitable adapter to dispatch the request "+(i?t.length>1?"since :\n"+t.map(To).join("\n"):" "+To(t[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function $o(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ro(null,t)}function Po(t){$o(t),t.headers=io.from(t.headers),t.data=so.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return Oo(t.adapter||Gr.adapter,t)(t).then(function(e){return $o(t),e.data=so.call(t,t.transformResponse,e),e.headers=io.from(e.headers),e},function(e){return no(e)||($o(t),e&&e.response&&(e.response.data=so.call(t,t.transformResponse,e.response),e.response.headers=io.from(e.response.headers))),Promise.reject(e)})}const Vo="1.12.2",Do={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Do[t]=function(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}});const Bo={};Do.transitional=function(t,e,i){function s(t,e){return"[Axios v"+Vo+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return(i,n,r)=>{if(!1===t)throw new zr(s(n," has been removed"+(e?" in "+e:"")),zr.ERR_DEPRECATED);return e&&!Bo[n]&&(Bo[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(i,n,r)}},Do.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};var Fo={assertOptions:function(t,e,i){if("object"!=typeof t)throw new zr("options must be an object",zr.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let n=s.length;for(;n-- >0;){const r=s[n],o=e[r];if(o){const e=t[r],i=void 0===e||o(e,r,t);if(!0!==i)throw new zr("option "+r+" must be "+i,zr.ERR_BAD_OPTION_VALUE);continue}if(!0!==i)throw new zr("Unknown option "+r,zr.ERR_BAD_OPTION)}},validators:Do};const Ao=Fo.validators;let Io=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ar,response:new Ar}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const i=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?i&&!String(t.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+i):t.stack=i}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=po(this.defaults,e);const{transitional:i,paramsSerializer:s,headers:n}=e;void 0!==i&&Fo.assertOptions(i,{silentJSONParsing:Ao.transitional(Ao.boolean),forcedJSONParsing:Ao.transitional(Ao.boolean),clarifyTimeoutError:Ao.transitional(Ao.boolean)},!1),null!=s&&(Er.isFunction(s)?e.paramsSerializer={serialize:s}:Fo.assertOptions(s,{encode:Ao.function,serialize:Ao.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Fo.assertOptions(e,{baseUrl:Ao.spelling("baseURL"),withXsrfToken:Ao.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&Er.merge(n.common,n[e.method]);n&&Er.forEach(["delete","get","head","post","put","patch","common"],t=>{delete n[t]}),e.headers=io.concat(r,n);const o=[];let h=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(h=h&&t.synchronous,o.unshift(t.fulfilled,t.rejected))});const l=[];let a;this.interceptors.response.forEach(function(t){l.push(t.fulfilled,t.rejected)});let c,u=0;if(!h){const t=[Po.bind(this),void 0];for(t.unshift(...o),t.push(...l),c=t.length,a=Promise.resolve(e);u<c;)a=a.then(t[u++],t[u++]);return a}c=o.length;let d=e;for(;u<c;){const t=o[u++],e=o[u++];try{d=t(d)}catch(t){e.call(this,t);break}}try{a=Po.call(this,d)}catch(t){return Promise.reject(t)}for(u=0,c=l.length;u<c;)a=a.then(l[u++],l[u++]);return a}getUri(t){return Fr(fo((t=po(this.defaults,t)).baseURL,t.url,t.allowAbsoluteUrls),t.params,t.paramsSerializer)}};Er.forEach(["delete","get","head","options"],function(t){Io.prototype[t]=function(e,i){return this.request(po(i||{},{method:t,url:e,data:(i||{}).data}))}}),Er.forEach(["post","put","patch"],function(t){function e(e){return function(i,s,n){return this.request(po(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Io.prototype[t]=e(),Io.prototype[t+"Form"]=e(!0)});const Wo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wo).forEach(([t,e])=>{Wo[e]=t});const jo=function t(e){const i=new Io(e),s=Vn(Io.prototype.request,i);return Er.extend(s,Io.prototype,i,{allOwnKeys:!0}),Er.extend(s,i,null,{allOwnKeys:!0}),s.create=function(i){return t(po(e,i))},s}(Gr);jo.Axios=Io,jo.CanceledError=ro,jo.CancelToken=class t{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const i=this;this.promise.then(t=>{if(!i._listeners)return;let e=i._listeners.length;for(;e-- >0;)i._listeners[e](t);i._listeners=null}),this.promise.then=t=>{let e;const s=new Promise(t=>{i.subscribe(t),e=t}).then(t);return s.cancel=function(){i.unsubscribe(e)},s},t(function(t,s,n){i.reason||(i.reason=new ro(t,s,n),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let e;const i=new t(function(t){e=t});return{token:i,cancel:e}}},jo.isCancel=no,jo.VERSION=Vo,jo.toFormData=$r,jo.AxiosError=zr,jo.Cancel=jo.CanceledError,jo.all=function(t){return Promise.all(t)},jo.spread=function(t){return function(e){return t.apply(null,e)}},jo.isAxiosError=function(t){return Er.isObject(t)&&!0===t.isAxiosError},jo.mergeConfig=po,jo.AxiosHeaders=io,jo.formToJSON=t=>Jr(Er.isHTMLForm(t)?new FormData(t):t),jo.getAdapter=Oo,jo.HttpStatusCode=Wo,jo.default=jo;const{Axios:Uo,AxiosError:Ho,CanceledError:Ko,isCancel:qo,CancelToken:Xo,VERSION:Jo,all:Go,Cancel:Qo,isAxiosError:Yo,spread:Zo,toFormData:th,AxiosHeaders:eh,HttpStatusCode:ih,formToJSON:sh,getAdapter:nh,mergeConfig:rh}=jo,oh={BASE_URL:"undefined"!=typeof window&&window.FUNHI_CHART_API_URL?window.FUNHI_CHART_API_URL:process.env.NEXT_PUBLIC_BACKEND_URL||"",TIMEOUT:1e4,MAX_RETRIES:3,RETRY_DELAY:1e3};const hh=new class{constructor(){this.baseURL=`${oh.BASE_URL}/api/ohlcv`,this.savingQueue=new Map,this.BATCH_DELAY=5e3,this.BATCH_SIZE=50}async saveCandles(t){try{const{mint:e,candles:i,timeFrame:s=60}=t;if(!e||!i||0===i.length)return console.warn("⚠️ [CandleStorage] Invalid save request:",t),!1;return!!(await jo.post(`${this.baseURL}/candles/save`,{mint:e,candles:i,timeFrame:s})).data.success&&(console.log(`💾 [CandleStorage] Saved ${i.length} candles for ${e}`),!0)}catch(t){return console.error("❌ [CandleStorage] Error saving candles:",t),!1}}async saveCandle(t){try{const{mint:e,candle:i,timeFrame:s=60}=t;if(!e||!i)return console.warn("⚠️ [CandleStorage] Invalid save request:",t),!1;const n=`${e}_${s}`,r=this.savingQueue.get(n);if(r)clearTimeout(r.timeout),r.candles.push(i),r.candles.length>=this.BATCH_SIZE?await this.flushQueue(n,e,s):r.timeout=setTimeout(()=>{this.flushQueue(n,e,s)},this.BATCH_DELAY);else{const t=setTimeout(()=>{this.flushQueue(n,e,s)},this.BATCH_DELAY);this.savingQueue.set(n,{candles:[i],timeout:t})}return!0}catch(t){return console.error("❌ [CandleStorage] Error queuing candle:",t),!1}}async flushQueue(t,e,i){const s=this.savingQueue.get(t);s&&0!==s.candles.length&&(this.savingQueue.delete(t),await this.saveCandles({mint:e,candles:s.candles,timeFrame:i}))}async getCandles(t){try{const{mint:e,timeFrame:i=60,limit:s=5e4}=t;if(!e)return console.warn("⚠️ [CandleStorage] Invalid get request:",t),[];const n=await jo.get(`${this.baseURL}/candles/${e}`,{params:{timeFrame:i,limit:s},timeout:8e3,validateStatus:t=>t>=200&&t<500});if(n.data.success&&n.data.data&&n.data.data.candles){const t=n.data.data.candles.length;return t>0?console.log(`✅ [CandleStorage] Retrieved ${t} candles for ${e}`):console.log(`ℹ️ [CandleStorage] No candles found for ${e} in database`),n.data.data.candles}return n.data.warning&&console.warn(`⚠️ [CandleStorage] ${n.data.warning}`),[]}catch(e){return"ECONNABORTED"===e.code?console.error("❌ [CandleStorage] Request timeout getting candles for",t.mint):e.response?console.error("❌ [CandleStorage] Server error getting candles:",e.response.status,e.response.data):e.request?console.error("❌ [CandleStorage] Network error getting candles - no response received"):console.error("❌ [CandleStorage] Error getting candles:",e.message),[]}}async flushAll(){const t=[];for(const[e,i]of this.savingQueue.entries()){clearTimeout(i.timeout);const[s,n]=e.split("_"),r=parseInt(n);t.push(this.flushQueue(e,s,r))}await Promise.all(t)}},lh=({mint:o,ticker:h,tokenName:l,socket:a,isConnected:c,currentMarketCap:u,analyticsConnected:d,analyticsLoading:f})=>{const m=r(null),p=r(null),g=r(null),v=r([]),b=r([]),w=r([]),y=r([]),S=r([]),x=r([]),C=r(null),M=r(null),_=r(null),E=r(null),z=r(null),k=r(null),R=r(0),L=r(0),T=r(0),N=r(0),O=r(0),$=r(0),P=r(null),[V,D]=e([]),[B,F]=e(null),[A,I]=e(0),[W,j]=e([]),[U,H]=e(null),[K,q]=e(0),[X,J]=e([]),[G,Q]=e(null),[Y,Z]=e(0),[tt,et]=e([]),[it,st]=e(null),[nt,rt]=e(0),[ot,ht]=e([]),[lt,at]=e(null),[ct,ut]=e(0),[dt,ft]=e([]),[mt,pt]=e(null),[gt,vt]=e(0),[wt,yt]=e(0),[St,xt]=e(!0),[Ct,Mt]=e(!1),[_t,Et]=e(null),[zt,kt]=e(null),Rt=r(0),Lt=r(0),Tt=$n(),Nt=a||Tt.socket,Ot=void 0!==c?c:Tt.isConnected,$t=Pn(),Pt=void 0!==u?u:$t.currentMarketCap,Vt=void 0!==d?d:$t.connected,Dt=void 0!==f?f:$t.loading,Bt=n(()=>[{label:"1m",value:"1m",seconds:60},{label:"5m",value:"5m",seconds:300},{label:"15m",value:"15m",seconds:900},{label:"1h",value:"1h",seconds:3600},{label:"4h",value:"4h",seconds:14400},{label:"1d",value:"1d",seconds:86400}],[]),[Ft,At]=e(Bt[0]),It=s(()=>{switch(Ft.seconds){case 60:default:return v.current;case 300:return b.current;case 900:return w.current;case 3600:return y.current;case 14400:return S.current;case 86400:return x.current}},[Ft.seconds]),Wt=s(t=>t>=1e9?`$${(t/1e9).toFixed(t>=1e10?2:3)}B`:t>=1e6?`$${(t/1e6).toFixed(t>=1e7?2:3)}M`:t>=1e4?`$${(t/1e3).toFixed(t>=1e5?1:2)}K`:t>=1e3?`$${(t/1e3).toFixed(2)}K`:t>=1?`$${t.toFixed(2)}`:`$${t.toFixed(4)}`,[]),jt=s(async(t,e=1e3)=>{const i=Bt.find(e=>e.seconds===t)?.label||`${t}s`;try{console.log(`📊 [Chart-${i}] Loading ${e} candles from database`);const s=(await hh.getCandles({mint:o,timeFrame:t,limit:e})).reduce((t,e)=>{const i=t.findIndex(t=>t.time===e.time);return i>=0?t[i]=e:t.push(e),t},[]),n=s.sort((t,e)=>t.time-e.time);return console.log(`✅ [Chart-${i}] Loaded ${n.length} candles`),n}catch(t){return console.error(`❌ [Chart-${i}] Error loading candles:`,t),[]}},[o,Bt]),Ut=s((t,e)=>{const i=Math.floor(e/1e3),s=60*Math.floor(i/60),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1m] Invalid price data: ${t}`),null;if(s!==R.current){if(C.current&&C.current.open>0&&C.current.high>0&&C.current.low>0&&C.current.close>0){const t={...C.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),D(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,v.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return v.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return C.current=e,R.current=s,F(e),I(s),D(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,v.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return v.current=n,n}),console.log(`🆕 [Chart-1m] New candle: $${t.toFixed(2)}`),e}if(C.current){const e=C.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-1m] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return C.current=i,F(i),D(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,v.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),C.current=i,F(i),D(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,v.current=s,s}return t}),i}return null},[]),Ht=s((t,e)=>{const i=Math.floor(e/1e3),s=300*Math.floor(i/300),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-5m] Invalid price data: ${t}`),null;if(s!==L.current){if(M.current&&M.current.open>0&&M.current.high>0&&M.current.low>0&&M.current.close>0){const t={...M.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),j(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,b.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return b.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return M.current=e,L.current=s,H(e),q(s),j(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,b.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return b.current=n,n}),console.log(`🆕 [Chart-5m] New candle: $${t.toFixed(2)}`),e}if(M.current){const e=M.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-5m] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return M.current=i,H(i),j(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,b.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),M.current=i,H(i),j(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,b.current=s,s}return t}),i}return null},[]),Kt=s((t,e)=>{const i=Math.floor(e/1e3),s=900*Math.floor(i/900),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-15m] Invalid price data: ${t}`),null;if(s!==T.current){if(_.current&&_.current.open>0&&_.current.high>0&&_.current.low>0&&_.current.close>0){const t={..._.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),J(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,w.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return w.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return _.current=e,T.current=s,Q(e),Z(s),J(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,w.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return w.current=n,n}),console.log(`🆕 [Chart-15m] New candle: $${t.toFixed(2)}`),e}if(_.current){const e=_.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-15m] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return _.current=i,Q(i),J(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,w.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),_.current=i,Q(i),J(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,w.current=s,s}return t}),i}return null},[]),qt=s((t,e)=>{const i=Math.floor(e/1e3),s=3600*Math.floor(i/3600),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1h] Invalid price data: ${t}`),null;if(s!==N.current){if(E.current&&E.current.open>0&&E.current.high>0&&E.current.low>0&&E.current.close>0){const t={...E.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),et(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,y.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return y.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return E.current=e,N.current=s,st(e),rt(s),et(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,y.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return y.current=n,n}),console.log(`🆕 [Chart-1h] New candle: $${t.toFixed(2)}`),e}if(E.current){const e=E.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-1h] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return E.current=i,st(i),et(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,y.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),E.current=i,st(i),et(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,y.current=s,s}return t}),i}return null},[]),Xt=s((t,e)=>{const i=Math.floor(e/1e3),s=14400*Math.floor(i/14400),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-4h] Invalid price data: ${t}`),null;if(s!==O.current){if(z.current&&z.current.open>0&&z.current.high>0&&z.current.low>0&&z.current.close>0){const t={...z.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),ht(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,S.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return S.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return z.current=e,O.current=s,at(e),ut(s),ht(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,S.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return S.current=n,n}),console.log(`🆕 [Chart-4h] New candle: $${t.toFixed(2)}`),e}if(z.current){const e=z.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-4h] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return z.current=i,at(i),ht(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,S.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),z.current=i,at(i),ht(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,S.current=s,s}return t}),i}return null},[]),Jt=s((t,e)=>{const i=Math.floor(e/1e3),s=86400*Math.floor(i/86400),n=Date.now();if(Lt.current&&n-Lt.current<50)return null;if(Lt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1d] Invalid price data: ${t}`),null;if(s!==$.current){if(k.current&&k.current.open>0&&k.current.high>0&&k.current.low>0&&k.current.close>0){const t={...k.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),ft(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,x.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return x.current=n,n})}const e={time:s,open:t,high:t,low:t,close:t,volume:0};return k.current=e,$.current=s,pt(e),vt(s),ft(t=>{const i=t.findIndex(t=>t.time===e.time);if(i>=0){const s=[...t];return s[i]=e,x.current=s,s}const s=[...t,e].sort((t,e)=>t.time-e.time),n=s.length>1e3?s.slice(-1e3):s;return x.current=n,n}),console.log(`🆕 [Chart-1d] New candle: $${t.toFixed(2)}`),e}if(k.current){const e=k.current;if(e.open<=0||e.high<=0||e.low<=0||e.close<=0){console.warn("⚠️ [Chart-1d] Invalid existing candle data, recreating");const i={time:e.time,open:t,high:t,low:t,close:t,volume:0};return k.current=i,pt(i),ft(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,x.current=s,s}return t}),i}const i={...e,high:Math.max(e.high,t),low:Math.min(e.low,t),close:t};return i.high=Math.max(i.open,i.high,i.close),i.low=Math.min(i.open,i.low,i.close),k.current=i,pt(i),ft(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,x.current=s,s}return t}),i}return null},[]);i(()=>{Rt.current=wt},[wt]),i(()=>{P.current=Ft},[Ft]),i(()=>{if(!m.current)return;const t=On(m.current,{layout:{background:{color:"#ffffff"},textColor:"#333333"},grid:{vertLines:{color:"#f0f0f0"},horzLines:{color:"#f0f0f0"}},crosshair:{mode:bt.Normal},rightPriceScale:{borderColor:"#cccccc"},timeScale:{borderColor:"#cccccc",timeVisible:!0,secondsVisible:!1,rightOffset:12,barSpacing:8,minBarSpacing:4},height:384,localization:{priceFormatter:t=>Wt(t)},watermark:{visible:!0,fontSize:64,horzAlign:"center",vertAlign:"center",color:"rgba(0, 0, 0, 0.03)",text:h?`${h}/SOL`:`${o.substring(0,4)}...${o.substring(o.length-4)}/SOL`}});p.current=t;const e=t.addCandlestickSeries({upColor:"#26a69a",downColor:"#ef5350",borderVisible:!0,borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350"});g.current=e,jt(Ft.seconds,1e3).then(t=>{if(t.length>0){let i=t[t.length-1],s=t;if(Pt>0){const e=Math.floor(Date.now()/1e3),n=Math.floor(e/Ft.seconds)*Ft.seconds;i.time===n&&(i={...i,high:Math.max(i.high,Pt),low:Math.min(i.low,Pt),close:Pt},s=[...t],s[s.length-1]=i,console.log(`🔄 [Chart-Init] Updated initial ${Ft.label} candle with current MC: $${Pt.toFixed(2)}`))}switch(Ft.seconds){case 60:D(s),I(i.time),F(i),v.current=s,R.current=i.time,C.current=i;break;case 300:j(s),q(i.time),H(i),b.current=s,L.current=i.time,M.current=i;break;case 900:J(s),Z(i.time),Q(i),w.current=s,T.current=i.time,_.current=i;break;case 3600:et(s),rt(i.time),st(i),y.current=s,N.current=i.time,E.current=i;break;case 14400:ht(s),ut(i.time),at(i),S.current=s,O.current=i.time,z.current=i;break;case 86400:ft(s),vt(i.time),pt(i),x.current=s,$.current=i.time,k.current=i}e.setData(s.map(t=>({...t,time:t.time}))),console.log(`✅ [Chart-${Ft.label}] Loaded and displayed ${s.length} candles`)}xt(!1)}).catch(t=>{console.error(`❌ [Chart-${Ft.label}] Load error:`,t),xt(!1)});const i=()=>{m.current&&t.applyOptions({width:m.current.clientWidth})};return window.addEventListener("resize",i),i(),()=>{window.removeEventListener("resize",i),t.remove()}},[o,jt,Wt,Ft,h]);const Gt=s(async t=>{const e=Bt.find(e=>e.value===t);if(e&&e.value!==Ft.value){if(Ct)return void console.log(`⚠️ [Chart] Timeframe switch already in progress, ignoring ${e.label}`);console.log(`🔄 [Chart] Switching to ${e.label}`),Mt(!0),Et(e.label),xt(!0);try{let t=[];switch(e.seconds){case 60:t=v.current;break;case 300:t=b.current;break;case 900:t=w.current;break;case 3600:t=y.current;break;case 14400:t=S.current;break;case 86400:t=x.current}if(t.length>0){console.log(`✅ [Chart] Using ${t.length} cached ${e.label} candles`);let i=t,s=t[t.length-1];if(Rt.current>0){const n=Math.floor(Date.now()/1e3),r=Math.floor(n/e.seconds)*e.seconds;if(s&&s.time===r){const n={...s,high:Math.max(s.high,Rt.current),low:Math.min(s.low,Rt.current),close:Rt.current};i=[...t],i[i.length-1]=n,s=n,console.log(`🔄 [Chart] Updated current ${e.label} candle with latest MC: $${Rt.current.toFixed(2)}`)}}switch(e.seconds){case 60:D(i),I(s.time),F(s),v.current=i,R.current=s.time,C.current=s;break;case 300:j(i),q(s.time),H(s),b.current=i,L.current=s.time,M.current=s;break;case 900:J(i),Z(s.time),Q(s),w.current=i,T.current=s.time,_.current=s;break;case 3600:et(i),rt(s.time),st(s),y.current=i,N.current=s.time,E.current=s;break;case 14400:ht(i),ut(s.time),at(s),S.current=i,O.current=s.time,z.current=s;break;case 86400:ft(i),vt(s.time),pt(s),x.current=i,$.current=s.time,k.current=s}g.current&&g.current.setData(i.map(t=>({...t,time:t.time}))),setTimeout(()=>{At(e),xt(!1),Mt(!1),Et(null),console.log(`✅ [Chart] Switched to ${e.label} with ${i.length} cached candles`)},0)}else{console.log(`📊 [Chart] Loading ${e.label} candles`);const t=await jt(e.seconds,1e3);if(t.length>0){let i=t[t.length-1],s=t;if(Rt.current>0){const n=Math.floor(Date.now()/1e3),r=Math.floor(n/e.seconds)*e.seconds;i.time===r&&(i={...i,high:Math.max(i.high,Rt.current),low:Math.min(i.low,Rt.current),close:Rt.current},s=[...t],s[s.length-1]=i,console.log(`🔄 [Chart] Updated loaded ${e.label} candle with current MC: $${Rt.current.toFixed(2)}`))}switch(e.seconds){case 60:D(s),I(i.time),F(i),v.current=s,R.current=i.time,C.current=i;break;case 300:j(s),q(i.time),H(i),b.current=s,L.current=i.time,M.current=i;break;case 900:J(s),Z(i.time),Q(i),w.current=s,T.current=i.time,_.current=i;break;case 3600:et(s),rt(i.time),st(i),y.current=s,N.current=i.time,E.current=i;break;case 14400:ht(s),ut(i.time),at(i),S.current=s,O.current=i.time,z.current=i;break;case 86400:ft(s),vt(i.time),pt(i),x.current=s,$.current=i.time,k.current=i}g.current&&g.current.setData(s.map(t=>({...t,time:t.time}))),setTimeout(()=>{At(e),xt(!1),Mt(!1),Et(null),console.log(`✅ [Chart] Switched to ${e.label} with ${s.length} loaded candles`)},0)}else setTimeout(()=>{At(e),xt(!1),Mt(!1),Et(null),console.log(`⚠️ [Chart] No candles loaded for ${e.label}`)},0)}}catch(t){console.error("❌ [Chart] Switch error:",t),setTimeout(()=>{At(e),xt(!1),Mt(!1),Et(null)},0)}}},[Bt,Ft,jt,Ct]);if(i(()=>{if(!o||!g.current||Pt<=0)return;if(!isFinite(Pt)||Pt<=0)return void console.warn(`⚠️ [Chart-Isolated] Invalid market cap data: ${Pt}`);console.log(`💰 [Chart-Isolated] Real-time update: $${Pt.toFixed(2)}`);const t=Date.now();requestAnimationFrame(()=>{Ut(Pt,t),Ht(Pt,t),Kt(Pt,t),qt(Pt,t),Xt(Pt,t),Jt(Pt,t),yt(Pt),xt(!1);const e=It();if(e.length>0){const t=e.filter(t=>t&&t.open>0&&t.high>0&&t.low>0&&t.close>0&&isFinite(t.open)&&isFinite(t.high)&&isFinite(t.low)&&isFinite(t.close));t.length>0&&g.current&&(g.current.setData(t.map(t=>({...t,time:t.time}))),requestAnimationFrame(()=>{p.current&&p.current.timeScale().scrollToRealTime()}))}})},[o,Pt,Ut,Ht,Kt,qt,Xt,Jt,It]),i(()=>{if(!Nt||!Ot||!o)return;const t=t=>{if(t.mint===o&&(console.log(`📡 [Chart-Isolated] Received multi-timeframe candles from backend for ${o}`,t.candles?Object.keys(t.candles):"no candles"),t.candles)){const e=t.candles,i=(t,e)=>{const i={time:e.time,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume||0};switch(t){case 60:C.current=i,R.current=i.time,F(i),I(i.time),D(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,v.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return v.current=s,s});break;case 300:M.current=i,L.current=i.time,H(i),q(i.time),j(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,b.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return b.current=s,s});break;case 900:_.current=i,T.current=i.time,Q(i),Z(i.time),J(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,w.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return w.current=s,s});break;case 3600:E.current=i,N.current=i.time,st(i),rt(i.time),et(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,y.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return y.current=s,s});break;case 14400:z.current=i,O.current=i.time,at(i),ut(i.time),ht(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,S.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return S.current=s,s});break;case 86400:k.current=i,$.current=i.time,pt(i),vt(i.time),ft(t=>{const e=t.findIndex(t=>t.time===i.time);if(e>=0){const s=[...t];return s[e]=i,x.current=s,s}const s=[...t,i].sort((t,e)=>t.time-e.time);return x.current=s,s})}};e["1m"]&&(i(60,e["1m"]),console.log("✅ [Chart-Isolated] Updated 1m from backend with full OHLC")),e["5m"]&&(i(300,e["5m"]),console.log("✅ [Chart-Isolated] Updated 5m from backend with full OHLC")),e["15m"]&&(i(900,e["15m"]),console.log("✅ [Chart-Isolated] Updated 15m from backend with full OHLC")),e["1h"]&&(i(3600,e["1h"]),console.log("✅ [Chart-Isolated] Updated 1h from backend with full OHLC")),e["4h"]&&(i(14400,e["4h"]),console.log("✅ [Chart-Isolated] Updated 4h from backend with full OHLC")),e["1d"]&&(i(86400,e["1d"]),console.log("✅ [Chart-Isolated] Updated 1d from backend with full OHLC"));const s=It();s.length>0&&g.current&&(g.current.setData(s.map(t=>({...t,time:t.time}))),requestAnimationFrame(()=>{p.current&&p.current.timeScale().scrollToRealTime()}))}};return Nt.on("multiTimeframeCandleUpdate",t),()=>{Nt.off("multiTimeframeCandleUpdate",t)}},[Nt,Ot,o,It]),i(()=>{const t=It();if((St||Dt)&&0===t.length){const t=setTimeout(()=>xt(!1),1e4);return()=>clearTimeout(t)}},[St,Dt,It]),zt)return t.createElement("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg"},t.createElement("div",{className:"text-red-800 font-medium"},"Chart Error"),t.createElement("div",{className:"text-red-600 text-sm"},zt),t.createElement("button",{onClick:()=>kt(null),className:"mt-2 px-3 py-1 bg-red-100 text-red-700 rounded text-sm hover:bg-red-200"},"Dismiss"));const Qt=It();return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"mb-4 flex flex-wrap gap-2 items-center"},t.createElement("div",{className:"flex flex-wrap gap-2"},Bt.map(e=>{const i=Ft.value===e.value,s=Ct&&_t===e.label,n=Ct;return t.createElement("button",{key:e.value,onClick:()=>Gt(e.value),disabled:n,className:`\n px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200 relative\n ${i?"bg-blue-600 text-white":n?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"}\n ${s?"animate-pulse":""}\n `},s&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center"},t.createElement("div",{className:"flex space-x-1"},t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse"}),t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse",style:{animationDelay:"0.1s"}}),t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse",style:{animationDelay:"0.2s"}}))),t.createElement("span",{className:s?"opacity-0":"opacity-100"},e.label))})),t.createElement("div",{className:"ml-auto flex items-center gap-2 text-sm"},t.createElement("div",{className:"w-2 h-2 rounded-full "+(Vt?"bg-green-500":"bg-red-500")}),t.createElement("span",{className:Vt?"text-green-600":"text-red-600"},Vt?"Connected":"Disconnected"),Ct&&_t&&t.createElement("span",{className:"text-blue-600"},"• Switching to ",_t,"..."),!Ct&&St&&!Dt&&t.createElement("span",{className:"text-blue-600"},"• Loading candles..."),Dt&&t.createElement("span",{className:"text-blue-600"},"• Connecting to analytics..."),!Ct&&!St&&!Dt&&Qt.length>0&&t.createElement("span",{className:"text-green-600"},"• ",Qt.length," ",Ft.label," candles • ",Wt(wt)))),t.createElement("div",{ref:m,className:"relative w-full h-96 transition-all duration-300 "+(Ct?"opacity-75 scale-[0.98]":"opacity-100 scale-100")},(Ct||St&&!Dt)&&t.createElement("div",{className:"absolute inset-0 bg-gradient-to-br from-white via-blue-50 to-white bg-opacity-90 flex items-center justify-center rounded-lg z-10 backdrop-blur-sm"},t.createElement("div",{className:"text-center"},t.createElement("div",{className:"flex justify-center items-center mb-4"},t.createElement("div",{className:"relative"},t.createElement("div",{className:"w-12 h-12 border-4 border-blue-200 rounded-full"}),t.createElement("div",{className:"absolute top-0 left-0 w-12 h-12 border-4 border-blue-600 rounded-full border-t-transparent animate-spin"}))),t.createElement("div",{className:"text-gray-700 font-medium text-lg"},Ct&&_t?`Switching to ${_t} timeframe...`:"Loading real-time data..."),t.createElement("div",{className:"mt-3 flex justify-center space-x-1"},t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce"}),t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})))),!Ct&&!St&&!Dt&&0===Qt.length&&t.createElement("div",{className:"absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center rounded-lg z-10"},t.createElement("div",{className:"text-center"},t.createElement("div",{className:"text-gray-600 mb-2"},"No ",Ft.label," market data available"),t.createElement("div",{className:"text-sm text-gray-500"},"Waiting for real-time data...")))))};const ah=new class{constructor(){this.timeframes={"1m":60,"5m":300,"15m":900,"30m":1800,"1h":3600,"4h":14400,"1d":86400}}aggregateCandles(t,e){try{if(60===e)return t;if(!Array.isArray(t)||0===t.length)return console.warn("⚠️ [CandleAggregation] No candles to aggregate"),[];const i=[...t].sort((t,e)=>t.time-e.time),s=[];let n=[],r=null;for(const t of i){const i=Math.floor(t.time/e)*e;if(null===r&&(r=i),i===r)n.push(t);else{if(n.length>0){const t=this.aggregateGroup(n,r);s.push(t)}n=[t],r=i}}if(n.length>0&&null!==r){const t=this.aggregateGroup(n,r);s.push(t)}return console.log(`📊 [CandleAggregation] Aggregated ${t.length} 1m candles into ${s.length} ${this.getTimeframeLabel(e)} candles`),s}catch(t){return console.error("❌ [CandleAggregation] Error aggregating candles:",t),[]}}aggregateGroup(t,e){const i=[...t].sort((t,e)=>t.time-e.time),s=i[0].open,n=i[i.length-1].close,r=Math.max(...i.map(t=>t.high)),o=Math.min(...i.map(t=>t.low)),h=i.reduce((t,e)=>t+(e.volume||0),0);return{time:e,open:s,high:r,low:o,close:n,volume:h}}getTimeframeLabel(t){for(const[e,i]of Object.entries(this.timeframes))if(i===t)return e;return`${t}s`}getTimeframeSeconds(t){return this.timeframes[t]||60}fillGaps(t,e){try{if(!Array.isArray(t)||t.length<2)return t;const i=[...t].sort((t,e)=>t.time-e.time),s=[];for(let t=0;t<i.length-1;t++){const n=i[t],r=i[t+1];s.push(n);let o=n.time+e;for(;o<r.time;)s.push({time:o,open:n.close,high:n.close,low:n.close,close:n.close,volume:0}),o+=e}return s.push(i[i.length-1]),s.length>i.length&&console.log(`🔧 [CandleAggregation] Filled ${s.length-i.length} gaps in ${this.getTimeframeLabel(e)} candles`),s}catch(e){return console.error("❌ [CandleAggregation] Error filling gaps:",e),t}}getCurrentCandle(t,e){try{if(!Array.isArray(t)||0===t.length)return null;const i=Math.floor(Date.now()/1e3),s=Math.floor(i/e)*e,n=t.filter(t=>Math.floor(t.time/e)*e===s);return 0===n.length?null:this.aggregateGroup(n,s)}catch(t){return console.error("❌ [CandleAggregation] Error getting current candle:",t),null}}updateRealtimeCandle(t,e,i){try{if(!e)return t;const s=Math.floor(e.time/i)*i,n=t.findIndex(t=>t.time===s);if(n>=0){const i=t[n],r={time:s,open:i.open,high:Math.max(i.high,e.high),low:Math.min(i.low,e.low),close:e.close,volume:i.volume+(e.volume||0)},o=[...t];return o[n]=r,o}{const i={time:s,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume||0};return[...t,i].sort((t,e)=>t.time-e.time)}}catch(e){return console.error("❌ [CandleAggregation] Error updating realtime candle:",e),t}}isValidCandle(t){return t&&"number"==typeof t.time&&"number"==typeof t.open&&"number"==typeof t.high&&"number"==typeof t.low&&"number"==typeof t.close&&t.high>=t.low&&t.high>=t.open&&t.high>=t.close&&t.low<=t.open&&t.low<=t.close}cleanCandles(t){if(!Array.isArray(t))return[];const e=t.filter(t=>this.isValidCandle(t));return e.length<t.length&&console.warn(`⚠️ [CandleAggregation] Removed ${t.length-e.length} invalid candles`),e}getRequiredOneMinuteCandles(t,e=200){const i=t/60;return Math.ceil(e*i)}};export{oh as API_CONFIG,lh as FunhiChart,ah as candleAggregation,hh as candleStorageService,Pn as useOptimizedTokenAnalytics,$n as useSocket};
7
+ */const f={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},m={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},p={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},g={topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},b={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,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},v={color:"#26a69a",base:0},w={color:"#2196f3"},y={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var M,x,S;function C(t,e){const i={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]}[e];t.setLineDash(i)}function E(t,e,i,s){t.beginPath();const n=t.lineWidth%2?.5:0;t.moveTo(i,e+n),t.lineTo(s,e+n),t.stroke()}function _(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:""))}function $(t){if(void 0===t)throw new Error("Value is undefined");return t}function z(t){if(null===t)throw new Error("Value is null");return t}function k(t){return z($(t))}(S=M||(M={}))[S.Simple=0]="Simple",S[S.WithSteps=1]="WithSteps",S[S.Curved=2]="Curved",function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(x||(x={}));const R={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 L(t){return t<0?0:t>255?255:Math.round(t)||0}function T(t){return t<=0||t>1?Math.min(Math.max(t,0),1):Math.round(1e4*t)/1e4}const N=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,O=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,P=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,F=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d*\.?\d+)\s*\)$/;function V(t){(t=t.toLowerCase())in R&&(t=R[t]);{const e=F.exec(t)||P.exec(t);if(e)return[L(parseInt(e[1],10)),L(parseInt(e[2],10)),L(parseInt(e[3],10)),T(e.length<5?1:parseFloat(e[4]))]}{const e=O.exec(t);if(e)return[L(parseInt(e[1],16)),L(parseInt(e[2],16)),L(parseInt(e[3],16)),1]}{const e=N.exec(t);if(e)return[L(17*parseInt(e[1],16)),L(17*parseInt(e[2],16)),L(17*parseInt(e[3],16)),1]}throw new Error(`Cannot parse color: ${t}`)}function D(t){return.199*t[0]+.687*t[1]+.114*t[2]}function I(t){const e=V(t);return{t:`rgb(${e[0]}, ${e[1]}, ${e[2]})`,i:D(e)>160?"black":"white"}}class B{constructor(){this.h=[]}l(t,e,i){const s={o:t,_:e,u:!0===i};this.h.push(s)}v(t){const e=this.h.findIndex(e=>t===e.o);e>-1&&this.h.splice(e,1)}p(t){this.h=this.h.filter(e=>e._!==t)}m(t,e,i){const s=[...this.h];this.h=this.h.filter(t=>!t.u),s.forEach(s=>s.o(t,e,i))}M(){return this.h.length>0}S(){this.h=[]}}function A(t,...e){for(const i of e)for(const e in i)void 0!==i[e]&&Object.prototype.hasOwnProperty.call(i,e)&&!["__proto__","constructor","prototype"].includes(e)&&("object"!=typeof i[e]||void 0===t[e]||Array.isArray(i[e])?t[e]=i[e]:A(t[e],i[e]));return t}function W(t){return"number"==typeof t&&isFinite(t)}function j(t){return"number"==typeof t&&t%1==0}function U(t){return"string"==typeof t}function H(t){return"boolean"==typeof t}function K(t){const e=t;if(!e||"object"!=typeof e)return e;let i,s,n;for(s in i=Array.isArray(e)?[]:{},e)e.hasOwnProperty(s)&&(n=e[s],i[s]=n&&"object"==typeof n?K(n):n);return i}function q(t){return null!==t}function X(t){return null===t?void 0:t}const J="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function G(t,e,i){return void 0===e&&(e=J),`${i=void 0!==i?`${i} `:""}${t}px ${e}`}class Q{constructor(t){this.k={C:1,T:5,P:NaN,R:"",D:"",V:"",O:"",B:0,A:0,I:0,L:0,N:0},this.F=t}W(){const t=this.k,e=this.j(),i=this.H();return t.P===e&&t.D===i||(t.P=e,t.D=i,t.R=G(e,i),t.L=2.5/12*e,t.B=t.L,t.A=e/12*t.T,t.I=e/12*t.T,t.N=0),t.V=this.$(),t.O=this.U(),this.k}$(){return this.F.W().layout.textColor}U(){return this.F.q()}j(){return this.F.W().layout.fontSize}H(){return this.F.W().layout.fontFamily}}class Y{constructor(){this.Y=[]}Z(t){this.Y=t}X(t,e,i){this.Y.forEach(s=>{s.X(t,e,i)})}}class Z{X(t,e,i){t.useBitmapCoordinateSpace(t=>this.K(t,e,i))}}class tt extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.G||null===this.G.tt)return;const s=this.G.tt,n=this.G,r=Math.max(1,Math.floor(e))%2/2,o=o=>{t.beginPath();for(let h=s.to-1;h>=s.from;--h){const s=n.it[h],l=Math.round(s.nt*e)+r,a=s.st*i,c=o*i+r;t.moveTo(l,a),t.arc(l,a,c,0,2*Math.PI)}t.fill()};n.et>0&&(t.fillStyle=n.rt,o(n.ht+n.et)),t.fillStyle=n.lt,o(n.ht)}}function et(){return{it:[{nt:0,st:0,ot:0,_t:0}],lt:"",rt:"",ht:0,et:0,tt:null}}const it={from:0,to:1};class st{constructor(t,e){this.ut=new Y,this.ct=[],this.dt=[],this.ft=!0,this.F=t,this.vt=e,this.ut.Z(this.ct)}bt(t){const e=this.F.wt();e.length!==this.ct.length&&(this.dt=e.map(et),this.ct=this.dt.map(t=>{const e=new tt;return e.J(t),e}),this.ut.Z(this.ct)),this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.ut}Mt(){const t=2===this.vt.W().mode,e=this.F.wt(),i=this.vt.xt(),s=this.F.St();e.forEach((e,n)=>{var r;const o=this.dt[n],h=e.kt(i);if(t||null===h||!e.yt())return void(o.tt=null);const l=z(e.Ct());o.lt=h.Tt,o.ht=h.ht,o.et=h.Pt,o.it[0]._t=h._t,o.it[0].st=e.Dt().Rt(h._t,l.Vt),o.rt=null!==(r=h.Ot)&&void 0!==r?r:this.F.Bt(o.it[0].st/e.Dt().At()),o.it[0].ot=i,o.it[0].nt=s.It(i),o.tt=it})}}class nt extends Z{constructor(t){super(),this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;const n=this.zt.Lt.yt,r=this.zt.Et.yt;if(!n&&!r)return;const o=Math.round(this.zt.nt*i),h=Math.round(this.zt.st*s);t.lineCap="butt",n&&o>=0&&(t.lineWidth=Math.floor(this.zt.Lt.et*i),t.strokeStyle=this.zt.Lt.V,t.fillStyle=this.zt.Lt.V,C(t,this.zt.Lt.Nt),function(t,e,i,s){t.beginPath();const n=t.lineWidth%2?.5:0;t.moveTo(e+n,0),t.lineTo(e+n,s),t.stroke()}(t,o,0,e.height)),r&&h>=0&&(t.lineWidth=Math.floor(this.zt.Et.et*s),t.strokeStyle=this.zt.Et.V,t.fillStyle=this.zt.Et.V,C(t,this.zt.Et.Nt),E(t,h,0,e.width))}}class rt{constructor(t){this.ft=!0,this.Ft={Lt:{et:1,Nt:0,V:"",yt:!1},Et:{et:1,Nt:0,V:"",yt:!1},nt:0,st:0},this.Wt=new nt(this.Ft),this.jt=t}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt}Mt(){const t=this.jt.yt(),e=z(this.jt.Ht()),i=e.$t().W().crosshair,s=this.Ft;if(2===i.mode)return s.Et.yt=!1,void(s.Lt.yt=!1);s.Et.yt=t&&this.jt.Ut(e),s.Lt.yt=t&&this.jt.qt(),s.Et.et=i.horzLine.width,s.Et.Nt=i.horzLine.style,s.Et.V=i.horzLine.color,s.Lt.et=i.vertLine.width,s.Lt.Nt=i.vertLine.style,s.Lt.V=i.vertLine.color,s.nt=this.jt.Yt(),s.st=this.jt.Zt()}}function ot(t,e,i,s,n,r){t.fillRect(e+r,i,s-2*r,r),t.fillRect(e+r,i+n-r,s-2*r,r),t.fillRect(e,i,r,n),t.fillRect(e+s-r,i,r,n)}function ht(t,e,i,s,n,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(e,i,s,n),t.restore()}function lt(t,e,i,s,n,r){t.beginPath(),t.roundRect?t.roundRect(e,i,s,n,r):(t.lineTo(e+s-r[1],i),0!==r[1]&&t.arcTo(e+s,i,e+s,i+r[1],r[1]),t.lineTo(e+s,i+n-r[2]),0!==r[2]&&t.arcTo(e+s,i+n,e+s-r[2],i+n,r[2]),t.lineTo(e+r[3],i+n),0!==r[3]&&t.arcTo(e,i+n,e,i+n-r[3],r[3]),t.lineTo(e,i+r[0]),0!==r[0]&&t.arcTo(e,i,e+r[0],i,r[0]))}function at(t,e,i,s,n,r,o=0,h=[0,0,0,0],l=""){if(t.save(),!o||!l||l===r)return lt(t,e,i,s,n,h),t.fillStyle=r,t.fill(),void t.restore();const a=o/2;var c;lt(t,e+a,i+a,s-o,n-o,(c=-a,h.map(t=>0===t?t:t+c))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=o,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function ct(t,e,i,s,n,r,o){t.save(),t.globalCompositeOperation="copy";const h=t.createLinearGradient(0,0,0,n);h.addColorStop(0,r),h.addColorStop(1,o),t.fillStyle=h,t.fillRect(e,i,s,n),t.restore()}class ut{constructor(t,e){this.J(t,e)}J(t,e){this.zt=t,this.Xt=e}At(t,e){return this.zt.yt?t.P+t.L+t.B:0}X(t,e,i,s){if(!this.zt.yt||0===this.zt.Kt.length)return;const n=this.zt.V,r=this.Xt.t,o=t.useBitmapCoordinateSpace(t=>{const o=t.context;o.font=e.R;const h=this.Gt(t,e,i,s),l=h.Jt;return h.Qt?at(o,l.ti,l.ii,l.ni,l.si,r,l.ei,[l.ht,0,0,l.ht],r):at(o,l.ri,l.ii,l.ni,l.si,r,l.ei,[0,l.ht,l.ht,0],r),this.zt.hi&&(o.fillStyle=n,o.fillRect(l.ri,l.li,l.ai-l.ri,l.oi)),this.zt._i&&(o.fillStyle=e.O,o.fillRect(h.Qt?l.ui-l.ei:0,l.ii,l.ei,l.ci-l.ii)),h});t.useMediaCoordinateSpace(({context:t})=>{const i=o.di;t.font=e.R,t.textAlign=o.Qt?"right":"left",t.textBaseline="middle",t.fillStyle=n,t.fillText(this.zt.Kt,i.fi,(i.ii+i.ci)/2+i.pi)})}Gt(t,e,i,s){var n;const{context:r,bitmapSize:o,mediaSize:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,c=this.zt.hi||!this.zt.mi?e.T:0,u=this.zt.bi?e.C:0,d=e.L+this.Xt.wi,f=e.B+this.Xt.gi,m=e.A,p=e.I,g=this.zt.Kt,b=e.P,v=i.Mi(r,g),w=Math.ceil(i.xi(r,g)),y=b+d+f,M=e.C+m+p+w+c,x=Math.max(1,Math.floor(a));let S=Math.round(y*a);S%2!=x%2&&(S+=1);const C=u>0?Math.max(1,Math.floor(u*l)):0,E=Math.round(M*l),_=Math.round(c*l),$=null!==(n=this.Xt.Si)&&void 0!==n?n:this.Xt.ki,z=Math.round($*a)-Math.floor(.5*a),k=Math.floor(z+x/2-S/2),R=k+S,L="right"===s,T=L?h.width-u:u,N=L?o.width-C:C;let O,P,F;return L?(O=N-E,P=N-_,F=T-c-m-u):(O=N+E,P=N+_,F=T+c+m),{Qt:L,Jt:{ii:k,li:z,ci:R,ni:E,si:S,ht:2*l,ei:C,ti:O,ri:N,ai:P,oi:x,ui:o.width},di:{ii:k/a,ci:R/a,fi:F,pi:v}}}}class dt{constructor(t){this.yi={ki:0,t:"#000",gi:0,wi:0},this.Ci={Kt:"",yt:!1,hi:!0,mi:!1,Ot:"",V:"#FFF",_i:!1,bi:!1},this.Ti={Kt:"",yt:!1,hi:!1,mi:!0,Ot:"",V:"#FFF",_i:!0,bi:!0},this.ft=!0,this.Pi=new(t||ut)(this.Ci,this.yi),this.Ri=new(t||ut)(this.Ti,this.yi)}Kt(){return this.Di(),this.Ci.Kt}ki(){return this.Di(),this.yi.ki}bt(){this.ft=!0}At(t,e=!1){return Math.max(this.Pi.At(t,e),this.Ri.At(t,e))}Vi(){return this.yi.Si||0}Oi(t){this.yi.Si=t}Bi(){return this.Di(),this.Ci.yt||this.Ti.yt}Ai(){return this.Di(),this.Ci.yt}gt(t){return this.Di(),this.Ci.hi=this.Ci.hi&&t.W().ticksVisible,this.Ti.hi=this.Ti.hi&&t.W().ticksVisible,this.Pi.J(this.Ci,this.yi),this.Ri.J(this.Ti,this.yi),this.Pi}Ii(){return this.Di(),this.Pi.J(this.Ci,this.yi),this.Ri.J(this.Ti,this.yi),this.Ri}Di(){this.ft&&(this.Ci.hi=!0,this.Ti.hi=!1,this.zi(this.Ci,this.Ti,this.yi))}}class ft extends dt{constructor(t,e,i){super(),this.jt=t,this.Li=e,this.Ei=i}zi(t,e,i){if(t.yt=!1,2===this.jt.W().mode)return;const s=this.jt.W().horzLine;if(!s.labelVisible)return;const n=this.Li.Ct();if(!this.jt.yt()||this.Li.Ni()||null===n)return;const r=I(s.labelBackgroundColor);i.t=r.t,t.V=r.i;const o=2/12*this.Li.P();i.wi=o,i.gi=o;const h=this.Ei(this.Li);i.ki=h.ki,t.Kt=this.Li.Fi(h._t,n),t.yt=!0}}const mt=/[1-9]/g;class pt{constructor(){this.zt=null}J(t){this.zt=t}X(t,e){if(null===this.zt||!1===this.zt.yt||0===this.zt.Kt.length)return;const i=t.useMediaCoordinateSpace(({context:t})=>(t.font=e.R,Math.round(e.Wi.xi(t,z(this.zt).Kt,mt))));if(i<=0)return;const s=e.ji,n=i+2*s,r=n/2,o=this.zt.Hi;let h=this.zt.ki,l=Math.floor(h-r)+.5;l<0?(h+=Math.abs(0-l),l=Math.floor(h-r)+.5):l+n>o&&(h-=Math.abs(o-(l+n)),l=Math.floor(h-r)+.5);const a=l+n,c=Math.ceil(0+e.C+e.T+e.L+e.P+e.B);t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:i,verticalPixelRatio:s})=>{const n=z(this.zt);t.fillStyle=n.t;const r=Math.round(l*i),o=Math.round(0*s),h=Math.round(a*i),u=Math.round(c*s),d=Math.round(2*i);if(t.beginPath(),t.moveTo(r,o),t.lineTo(r,u-d),t.arcTo(r,u,r+d,u,d),t.lineTo(h-d,u),t.arcTo(h,u,h,u-d,d),t.lineTo(h,o),t.fill(),n.hi){const r=Math.round(n.ki*i),h=o,l=Math.round((h+e.T)*s);t.fillStyle=n.V;const a=Math.max(1,Math.floor(i)),c=Math.floor(.5*i);t.fillRect(r-c,h,a,l-h)}}),t.useMediaCoordinateSpace(({context:t})=>{const i=z(this.zt),n=0+e.C+e.T+e.L+e.P/2;t.font=e.R,t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.V;const r=e.Wi.Mi(t,"Apr0");t.translate(l+s,n+r),t.fillText(i.Kt,0,0)})}}class gt{constructor(t,e,i){this.ft=!0,this.Wt=new pt,this.Ft={yt:!1,t:"#4c525e",V:"white",Kt:"",Hi:0,ki:NaN,hi:!0},this.vt=t,this.$i=e,this.Ei=i}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt.J(this.Ft),this.Wt}Mt(){const t=this.Ft;if(t.yt=!1,2===this.vt.W().mode)return;const e=this.vt.W().vertLine;if(!e.labelVisible)return;const i=this.$i.St();if(i.Ni())return;t.Hi=i.Hi();const s=this.Ei();if(null===s)return;t.ki=s.ki;const n=i.Ui(this.vt.xt());t.Kt=i.qi(z(n)),t.yt=!0;const r=I(e.labelBackgroundColor);t.t=r.t,t.V=r.i,t.hi=i.W().ticksVisible}}class bt{constructor(){this.Yi=null,this.Zi=0}Xi(){return this.Zi}Ki(t){this.Zi=t}Dt(){return this.Yi}Gi(t){this.Yi=t}Ji(t){return[]}Qi(){return[]}yt(){return!0}}var vt;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden"}(vt||(vt={}));class wt extends bt{constructor(t,e){super(),this.tn=null,this.nn=NaN,this.sn=0,this.en=!0,this.rn=new Map,this.hn=!1,this.ln=NaN,this.an=NaN,this._n=NaN,this.un=NaN,this.$i=t,this.cn=e,this.dn=new st(t,this),this.fn=((t,e)=>i=>{const s=e(),n=t();if(i===z(this.tn).vn())return{_t:n,ki:s};{const t=z(i.Ct());return{_t:i.pn(s,t),ki:s}}})(()=>this.nn,()=>this.an);const i=((t,e)=>()=>{const i=this.$i.St().mn(t()),s=e();return i&&Number.isFinite(s)?{ot:i,ki:s}:null})(()=>this.sn,()=>this.Yt());this.bn=new gt(this,t,i),this.wn=new rt(this)}W(){return this.cn}gn(t,e){this._n=t,this.un=e}Mn(){this._n=NaN,this.un=NaN}xn(){return this._n}Sn(){return this.un}kn(t,e,i){this.hn||(this.hn=!0),this.en=!0,this.yn(t,e,i)}xt(){return this.sn}Yt(){return this.ln}Zt(){return this.an}yt(){return this.en}Cn(){this.en=!1,this.Tn(),this.nn=NaN,this.ln=NaN,this.an=NaN,this.tn=null,this.Mn()}Pn(t){return null!==this.tn?[this.wn,this.dn]:[]}Ut(t){return t===this.tn&&this.cn.horzLine.visible}qt(){return this.cn.vertLine.visible}Rn(t,e){this.en&&this.tn===t||this.rn.clear();const i=[];return this.tn===t&&i.push(this.Dn(this.rn,e,this.fn)),i}Qi(){return this.en?[this.bn]:[]}Ht(){return this.tn}Vn(){this.wn.bt(),this.rn.forEach(t=>t.bt()),this.bn.bt(),this.dn.bt()}On(t){return t&&!t.vn().Ni()?t.vn():null}yn(t,e,i){this.Bn(t,e,i)&&this.Vn()}Bn(t,e,i){const s=this.ln,n=this.an,r=this.nn,o=this.sn,h=this.tn,l=this.On(i);this.sn=t,this.ln=isNaN(t)?NaN:this.$i.St().It(t),this.tn=i;const a=null!==l?l.Ct():null;return null!==l&&null!==a?(this.nn=e,this.an=l.Rt(e,a)):(this.nn=NaN,this.an=NaN),s!==this.ln||n!==this.an||o!==this.sn||r!==this.nn||h!==this.tn}Tn(){const t=this.$i.wt().map(t=>t.In().An()).filter(q),e=0===t.length?null:Math.max(...t);this.sn=null!==e?e:NaN}Dn(t,e,i){let s=t.get(e);return void 0===s&&(s=new ft(this,e,i),t.set(e,s)),s}}function yt(t){return"left"===t||"right"===t}class Mt{constructor(t){this.zn=new Map,this.Ln=[],this.En=t}Nn(t,e){const i=function(t,e){return void 0===t?e:{Fn:Math.max(t.Fn,e.Fn),Wn:t.Wn||e.Wn}}(this.zn.get(t),e);this.zn.set(t,i)}jn(){return this.En}Hn(t){const e=this.zn.get(t);return void 0===e?{Fn:this.En}:{Fn:Math.max(this.En,e.Fn),Wn:e.Wn}}$n(){this.Un(),this.Ln=[{qn:0}]}Yn(t){this.Un(),this.Ln=[{qn:1,Vt:t}]}Zn(t){this.Xn(),this.Ln.push({qn:5,Vt:t})}Un(){this.Xn(),this.Ln.push({qn:6})}Kn(){this.Un(),this.Ln=[{qn:4}]}Gn(t){this.Un(),this.Ln.push({qn:2,Vt:t})}Jn(t){this.Un(),this.Ln.push({qn:3,Vt:t})}Qn(){return this.Ln}ts(t){for(const e of t.Ln)this.ns(e);this.En=Math.max(this.En,t.En),t.zn.forEach((t,e)=>{this.Nn(e,t)})}static ss(){return new Mt(2)}static es(){return new Mt(3)}ns(t){switch(t.qn){case 0:this.$n();break;case 1:this.Yn(t.Vt);break;case 2:this.Gn(t.Vt);break;case 3:this.Jn(t.Vt);break;case 4:this.Kn();break;case 5:this.Zn(t.Vt);break;case 6:this.Xn()}}Xn(){const t=this.Ln.findIndex(t=>5===t.qn);-1!==t&&this.Ln.splice(t,1)}}function xt(t,e){if(!W(t))return"n/a";if(!j(e))throw new TypeError("invalid length");if(e<0||e>16)throw new TypeError("invalid length");return 0===e?t.toString():("0000000000000000"+t.toString()).slice(-e)}class St{constructor(t,e){if(e||(e=1),W(t)&&j(t)||(t=100),t<0)throw new TypeError("invalid base");this.Li=t,this.rs=e,this.hs()}format(t){const e=t<0?"−":"";return t=Math.abs(t),e+this.ls(t)}hs(){if(this._s=0,this.Li>0&&this.rs>0){let t=this.Li;for(;t>1;)t/=10,this._s++}}ls(t){const e=this.Li/this.rs;let i=Math.floor(t),s="";const n=void 0!==this._s?this._s:NaN;if(e>1){let r=+(Math.round(t*e)-i*e).toFixed(this._s);r>=e&&(r-=e,i+=1),s="."+xt(+r.toFixed(this._s)*this.rs,n)}else i=Math.round(i*e)/e,n>0&&(s="."+xt(0,n));return i.toFixed(0)+s}}class Ct extends St{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Et{constructor(t){this.us=t}format(t){let e="";return t<0&&(e="-",t=-t),t<995?e+this.cs(t):t<999995?e+this.cs(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),e+this.cs(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),e+this.cs(t/1e9)+"B")}cs(t){let e;const i=Math.pow(10,this.us);return e=(t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this.us).replace(/\.?0+$/,""):String(t),e.replace(/(\.[1-9]*)0+$/,(t,e)=>e)}}function _t(t,e,i,s,n,r,o){if(0===e.length||s.from>=e.length||s.to<=0)return;const{context:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,c=e[s.from];let u=r(t,c),d=c;if(s.to-s.from<2){const e=n/2;h.beginPath();const i={nt:c.nt-e,st:c.st},s={nt:c.nt+e,st:c.st};h.moveTo(i.nt*l,i.st*a),h.lineTo(s.nt*l,s.st*a),o(t,u,i,s)}else{const n=(e,i)=>{o(t,u,d,i),h.beginPath(),u=e,d=i};let f=d;h.beginPath(),h.moveTo(c.nt*l,c.st*a);for(let o=s.from+1;o<s.to;++o){f=e[o];const s=r(t,f);switch(i){case 0:h.lineTo(f.nt*l,f.st*a);break;case 1:h.lineTo(f.nt*l,e[o-1].st*a),s!==u&&(n(s,f),h.lineTo(f.nt*l,e[o-1].st*a)),h.lineTo(f.nt*l,f.st*a);break;case 2:{const[t,i]=Rt(e,o-1,o);h.bezierCurveTo(t.nt*l,t.st*a,i.nt*l,i.st*a,f.nt*l,f.st*a);break}}1!==i&&s!==u&&(n(s,f),h.moveTo(f.nt*l,f.st*a))}(d!==f||d===f&&1===i)&&o(t,u,d,f)}}const $t=6;function zt(t,e){return{nt:t.nt-e.nt,st:t.st-e.st}}function kt(t,e){return{nt:t.nt/e,st:t.st/e}}function Rt(t,e,i){const s=Math.max(0,e-1),n=Math.min(t.length-1,i+1);var r,o;return[(r=t[e],o=kt(zt(t[i],t[s]),$t),{nt:r.nt+o.nt,st:r.st+o.st}),zt(t[i],kt(zt(t[n],t[e]),$t))]}function Lt(t,e,i,s,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:h}=e;r.lineTo(n.nt*o,t*h),r.lineTo(s.nt*o,t*h),r.closePath(),r.fillStyle=i,r.fill()}class Tt extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){var e;if(null===this.G)return;const{it:i,tt:s,ds:n,et:r,Nt:o,fs:h}=this.G,l=null!==(e=this.G.vs)&&void 0!==e?e:this.G.ps?0:t.mediaSize.height;if(null===s)return;const a=t.context;a.lineCap="butt",a.lineJoin="round",a.lineWidth=r,C(a,o),a.lineWidth=1,_t(t,i,h,s,n,this.bs.bind(this),Lt.bind(null,l))}}function Nt(t,e,i){return Math.min(Math.max(t,e),i)}function Ot(t,e,i){return e-t<=i}function Pt(t){const e=Math.ceil(t);return e%2==0?e-1:e}class Ft{ws(t,e){const i=this.gs,{Ms:s,xs:n,Ss:r,ks:o,ys:h,vs:l}=e;if(void 0===this.Cs||void 0===i||i.Ms!==s||i.xs!==n||i.Ss!==r||i.ks!==o||i.vs!==l||i.ys!==h){const i=t.context.createLinearGradient(0,0,0,h);if(i.addColorStop(0,s),null!=l){const e=Nt(l*t.verticalPixelRatio/h,0,1);i.addColorStop(e,n),i.addColorStop(e,r)}i.addColorStop(1,o),this.Cs=i,this.gs=e}return this.Cs}}class Vt extends Tt{constructor(){super(...arguments),this.Ts=new Ft}bs(t,e){return this.Ts.ws(t,{Ms:e.Ps,xs:"",Ss:"",ks:e.Rs,ys:t.bitmapSize.height})}}function Dt(t,e){const i=t.context;i.strokeStyle=e,i.stroke()}class It extends Z{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){if(null===this.G)return;const{it:e,tt:i,ds:s,fs:n,et:r,Nt:o,Ds:h}=this.G;if(null===i)return;const l=t.context;l.lineCap="butt",l.lineWidth=r*t.verticalPixelRatio,C(l,o),l.lineJoin="round";const a=this.Vs.bind(this);void 0!==n&&_t(t,e,n,i,s,a,Dt),h&&function(t,e,i,s,n){const{horizontalPixelRatio:r,verticalPixelRatio:o,context:h}=t;let l=null;const a=Math.max(1,Math.floor(r))%2/2,c=i*o+a;for(let i=s.to-1;i>=s.from;--i){const s=e[i];if(s){const e=n(t,s);e!==l&&(h.beginPath(),null!==l&&h.fill(),h.fillStyle=e,l=e);const i=Math.round(s.nt*r)+a,u=s.st*o;h.moveTo(i,u),h.arc(i,u,c,0,2*Math.PI)}}h.fill()}(t,e,h,i,a)}}class Bt extends It{Vs(t,e){return e.lt}}function At(t,e,i,s,n=0,r=e.length){let o=r-n;for(;0<o;){const r=o>>1,h=n+r;s(e[h],i)===t?(n=h+1,o-=r+1):o=r}return n}const Wt=At.bind(null,!0),jt=At.bind(null,!1);function Ut(t,e){return t.ot<e}function Ht(t,e){return e<t.ot}function Kt(t,e,i){const s=e.Os(),n=e.ui(),r=Wt(t,s,Ut),o=jt(t,n,Ht);if(!i)return{from:r,to:o};let h=r,l=o;return r>0&&r<t.length&&t[r].ot>=s&&(h=r-1),o>0&&o<t.length&&t[o-1].ot<=n&&(l=o+1),{from:h,to:l}}class qt{constructor(t,e,i){this.Bs=!0,this.As=!0,this.Is=!0,this.zs=[],this.Ls=null,this.Es=t,this.Ns=e,this.Fs=i}bt(t){this.Bs=!0,"data"===t&&(this.As=!0),"options"===t&&(this.Is=!0)}gt(){return this.Es.yt()?(this.Ws(),null===this.Ls?null:this.js):null}Hs(){this.zs=this.zs.map(t=>Object.assign(Object.assign({},t),this.Es.Us().$s(t.ot)))}qs(){this.Ls=null}Ws(){this.As&&(this.Ys(),this.As=!1),this.Is&&(this.Hs(),this.Is=!1),this.Bs&&(this.Zs(),this.Bs=!1)}Zs(){const t=this.Es.Dt(),e=this.Ns.St();if(this.qs(),e.Ni()||t.Ni())return;const i=e.Xs();if(null===i)return;if(0===this.Es.In().Ks())return;const s=this.Es.Ct();null!==s&&(this.Ls=Kt(this.zs,i,this.Fs),this.Gs(t,e,s.Vt),this.Js())}}class Xt extends qt{constructor(t,e){super(t,e,!0)}Gs(t,e,i){e.Qs(this.zs,X(this.Ls)),t.te(this.zs,i,X(this.Ls))}ie(t,e){return{ot:t,_t:e,nt:NaN,st:NaN}}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>{const i=e.Vt[3];return this.se(e.ee,i,t)})}}class Jt extends Xt{constructor(t,e){super(t,e),this.js=new Y,this.re=new Vt,this.he=new Bt,this.js.Z([this.re,this.he])}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.W();this.re.J({fs:t.lineType,it:this.zs,Nt:t.lineStyle,et:t.lineWidth,vs:null,ps:t.invertFilledArea,tt:this.Ls,ds:this.Ns.St().le()}),this.he.J({fs:t.lineVisible?t.lineType:void 0,it:this.zs,Nt:t.lineStyle,et:t.lineWidth,tt:this.Ls,ds:this.Ns.St().le(),Ds:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}class Gt extends Z{constructor(){super(...arguments),this.zt=null,this.ae=0,this.oe=0}J(t){this.zt=t}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.zt||0===this.zt.In.length||null===this.zt.tt)return;this.ae=this._e(e),this.ae>=2&&Math.max(1,Math.floor(e))%2!=this.ae%2&&this.ae--,this.oe=this.zt.ue?Math.min(this.ae,Math.floor(e)):this.ae;let s=null;const n=this.oe<=this.ae&&this.zt.le>=Math.floor(1.5*e);for(let r=this.zt.tt.from;r<this.zt.tt.to;++r){const o=this.zt.In[r];s!==o.ce&&(t.fillStyle=o.ce,s=o.ce);const h=Math.floor(.5*this.oe),l=Math.round(o.nt*e),a=l-h,c=this.oe,u=a+c-1,d=Math.min(o.de,o.fe),f=Math.max(o.de,o.fe),m=Math.round(d*i)-h,p=Math.round(f*i)+h,g=Math.max(p-m,this.oe);t.fillRect(a,m,c,g);const b=Math.ceil(1.5*this.ae);if(n){if(this.zt.ve){const e=l-b;let s=Math.max(m,Math.round(o.pe*i)-h),n=s+c-1;n>m+g-1&&(n=m+g-1,s=n-c+1),t.fillRect(e,s,a-e,n-s+1)}const e=l+b;let s=Math.max(m,Math.round(o.me*i)-h),n=s+c-1;n>m+g-1&&(n=m+g-1,s=n-c+1),t.fillRect(u+1,s,e-u,n-s+1)}}}_e(t){const e=Math.floor(t);return Math.max(e,Math.floor(function(t,e){return Math.floor(.3*t*e)}(z(this.zt).le,t)))}}class Qt extends qt{constructor(t,e){super(t,e,!1)}Gs(t,e,i){e.Qs(this.zs,X(this.Ls)),t.be(this.zs,i,X(this.Ls))}we(t,e,i){return{ot:t,ge:e.Vt[0],Me:e.Vt[1],xe:e.Vt[2],Se:e.Vt[3],nt:NaN,pe:NaN,de:NaN,fe:NaN,me:NaN}}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>this.se(e.ee,e,t))}}class Yt extends Qt{constructor(){super(...arguments),this.js=new Gt}se(t,e,i){return Object.assign(Object.assign({},this.we(t,e,i)),i.$s(t))}Js(){const t=this.Es.W();this.js.J({In:this.zs,le:this.Ns.St().le(),ve:t.openVisible,ue:t.thinBars,tt:this.Ls})}}class Zt extends Tt{constructor(){super(...arguments),this.Ts=new Ft}bs(t,e){const i=this.G;return this.Ts.ws(t,{Ms:e.ke,xs:e.ye,Ss:e.Ce,ks:e.Te,ys:t.bitmapSize.height,vs:i.vs})}}class te extends It{constructor(){super(...arguments),this.Pe=new Ft}Vs(t,e){const i=this.G;return this.Pe.ws(t,{Ms:e.Re,xs:e.Re,Ss:e.De,ks:e.De,ys:t.bitmapSize.height,vs:i.vs})}}class ee extends Xt{constructor(t,e){super(t,e),this.js=new Y,this.Ve=new Zt,this.Oe=new te,this.js.Z([this.Ve,this.Oe])}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.Ct();if(null===t)return;const e=this.Es.W(),i=this.Es.Dt().Rt(e.baseValue.price,t.Vt),s=this.Ns.St().le();this.Ve.J({it:this.zs,et:e.lineWidth,Nt:e.lineStyle,fs:e.lineType,vs:i,ps:!1,tt:this.Ls,ds:s}),this.Oe.J({it:this.zs,et:e.lineWidth,Nt:e.lineStyle,fs:e.lineVisible?e.lineType:void 0,Ds:e.pointMarkersVisible?e.pointMarkersRadius||e.lineWidth/2+2:void 0,vs:i,tt:this.Ls,ds:s})}}class ie extends Z{constructor(){super(...arguments),this.zt=null,this.ae=0}J(t){this.zt=t}K(t){if(null===this.zt||0===this.zt.In.length||null===this.zt.tt)return;const{horizontalPixelRatio:e}=t;this.ae=function(t,e){if(t>=2.5&&t<=4)return Math.floor(3*e);const i=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),s=Math.floor(t*i*e),n=Math.floor(t*e),r=Math.min(s,n);return Math.max(Math.floor(e),r)}(this.zt.le,e),this.ae>=2&&Math.floor(e)%2!=this.ae%2&&this.ae--;const i=this.zt.In;this.zt.Be&&this.Ae(t,i,this.zt.tt),this.zt._i&&this.Ie(t,i,this.zt.tt);const s=this.ze(e);(!this.zt._i||this.ae>2*s)&&this.Le(t,i,this.zt.tt)}Ae(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="",h=Math.min(Math.floor(n),Math.floor(this.zt.le*n));h=Math.max(Math.floor(n),Math.min(h,this.ae));const l=Math.floor(.5*h);let a=null;for(let t=i.from;t<i.to;t++){const i=e[t];i.Ee!==o&&(s.fillStyle=i.Ee,o=i.Ee);const c=Math.round(Math.min(i.pe,i.me)*r),u=Math.round(Math.max(i.pe,i.me)*r),d=Math.round(i.de*r),f=Math.round(i.fe*r);let m=Math.round(n*i.nt)-l;const p=m+h-1;null!==a&&(m=Math.max(a+1,m),m=Math.min(m,p));const g=p-m+1;s.fillRect(m,d,g,c-d),s.fillRect(m,u+1,g,f-u),a=p}}ze(t){let e=Math.floor(1*t);this.ae<=2*e&&(e=Math.floor(.5*(this.ae-1)));const i=Math.max(Math.floor(t),e);return this.ae<=2*i?Math.max(Math.floor(t),Math.floor(1*t)):i}Ie(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="";const h=this.ze(n);let l=null;for(let t=i.from;t<i.to;t++){const i=e[t];i.Ne!==o&&(s.fillStyle=i.Ne,o=i.Ne);let a=Math.round(i.nt*n)-Math.floor(.5*this.ae);const c=a+this.ae-1,u=Math.round(Math.min(i.pe,i.me)*r),d=Math.round(Math.max(i.pe,i.me)*r);if(null!==l&&(a=Math.max(l+1,a),a=Math.min(a,c)),this.zt.le*n>2*h)ot(s,a,u,c-a+1,d-u+1,h);else{const t=c-a+1;s.fillRect(a,u,t,d-u+1)}l=c}}Le(t,e,i){if(null===this.zt)return;const{context:s,horizontalPixelRatio:n,verticalPixelRatio:r}=t;let o="";const h=this.ze(n);for(let t=i.from;t<i.to;t++){const i=e[t];let l=Math.round(Math.min(i.pe,i.me)*r),a=Math.round(Math.max(i.pe,i.me)*r),c=Math.round(i.nt*n)-Math.floor(.5*this.ae),u=c+this.ae-1;if(i.ce!==o){const t=i.ce;s.fillStyle=t,o=t}this.zt._i&&(c+=h,l+=h,u-=h,a-=h),l>a||s.fillRect(c,l,u-c+1,a-l+1)}}}class se extends Qt{constructor(){super(...arguments),this.js=new ie}se(t,e,i){return Object.assign(Object.assign({},this.we(t,e,i)),i.$s(t))}Js(){const t=this.Es.W();this.js.J({In:this.zs,le:this.Ns.St().le(),Be:t.wickVisible,_i:t.borderVisible,tt:this.Ls})}}class ne{constructor(t,e){this.Fe=t,this.Li=e}X(t,e,i){this.Fe.draw(t,this.Li,e,i)}}class re extends qt{constructor(t,e,i){super(t,e,!1),this.wn=i,this.js=new ne(this.wn.renderer(),e=>{const i=t.Ct();return null===i?null:t.Dt().Rt(e,i.Vt)})}We(t){return this.wn.priceValueBuilder(t)}je(t){return this.wn.isWhitespace(t)}Ys(){const t=this.Es.Us();this.zs=this.Es.In().ne().map(e=>Object.assign(Object.assign({ot:e.ee,nt:NaN},t.$s(e.ee)),{He:e.$e}))}Gs(t,e){e.Qs(this.zs,X(this.Ls))}Js(){this.wn.update({bars:this.zs.map(oe),barSpacing:this.Ns.St().le(),visibleRange:this.Ls},this.Es.W())}}function oe(t){return{x:t.nt,time:t.ot,originalData:t.He,barColor:t.ce}}class he extends Z{constructor(){super(...arguments),this.zt=null,this.Ue=[]}J(t){this.zt=t,this.Ue=[]}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(null===this.zt||0===this.zt.it.length||null===this.zt.tt)return;this.Ue.length||this.qe(e);const s=Math.max(1,Math.floor(i)),n=Math.round(this.zt.Ye*i)-Math.floor(s/2),r=n+s;for(let e=this.zt.tt.from;e<this.zt.tt.to;e++){const o=this.zt.it[e],h=this.Ue[e-this.zt.tt.from],l=Math.round(o.st*i);let a,c;t.fillStyle=o.ce,l<=n?(a=l,c=r):(a=n,c=l-Math.floor(s/2)+s),t.fillRect(h.Os,a,h.ui-h.Os+1,c-a)}}qe(t){if(null===this.zt||0===this.zt.it.length||null===this.zt.tt)return void(this.Ue=[]);const e=Math.ceil(this.zt.le*t)<=1?0:Math.max(1,Math.floor(t)),i=Math.round(this.zt.le*t)-e;this.Ue=new Array(this.zt.tt.to-this.zt.tt.from);for(let e=this.zt.tt.from;e<this.zt.tt.to;e++){const s=this.zt.it[e],n=Math.round(s.nt*t);let r,o;if(i%2){const t=(i-1)/2;r=n-t,o=n+t}else{const t=i/2;r=n-t,o=n+t-1}this.Ue[e-this.zt.tt.from]={Os:r,ui:o,Ze:n,Xe:s.nt*t,ot:s.ot}}for(let t=this.zt.tt.from+1;t<this.zt.tt.to;t++){const i=this.Ue[t-this.zt.tt.from],s=this.Ue[t-this.zt.tt.from-1];i.ot===s.ot+1&&i.Os-s.ui!==e+1&&(s.Ze>s.Xe?s.ui=i.Os-e-1:i.Os=s.ui+e+1)}let s=Math.ceil(this.zt.le*t);for(let t=this.zt.tt.from;t<this.zt.tt.to;t++){const e=this.Ue[t-this.zt.tt.from];e.ui<e.Os&&(e.ui=e.Os);const i=e.ui-e.Os+1;s=Math.min(i,s)}if(e>0&&s<4)for(let t=this.zt.tt.from;t<this.zt.tt.to;t++){const e=this.Ue[t-this.zt.tt.from];e.ui-e.Os+1>s&&(e.Ze>e.Xe?e.ui-=1:e.Os+=1)}}}class le extends Xt{constructor(){super(...arguments),this.js=new he}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t={it:this.zs,le:this.Ns.St().le(),tt:this.Ls,Ye:this.Es.Dt().Rt(this.Es.W().base,z(this.Es.Ct()).Vt)};this.js.J(t)}}class ae extends Xt{constructor(){super(...arguments),this.js=new Bt}se(t,e,i){return Object.assign(Object.assign({},this.ie(t,e)),i.$s(t))}Js(){const t=this.Es.W(),e={it:this.zs,Nt:t.lineStyle,fs:t.lineVisible?t.lineType:void 0,et:t.lineWidth,Ds:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,tt:this.Ls,ds:this.Ns.St().le()};this.js.J(e)}}const ce=/[2-9]/g;class ue{constructor(t=50){this.Ke=0,this.Ge=1,this.Je=1,this.Qe={},this.tr=new Map,this.ir=t}nr(){this.Ke=0,this.tr.clear(),this.Ge=1,this.Je=1,this.Qe={}}xi(t,e,i){return this.sr(t,e,i).width}Mi(t,e,i){const s=this.sr(t,e,i);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}sr(t,e,i){const s=i||ce,n=String(e).replace(s,"0");if(this.tr.has(n))return $(this.tr.get(n)).er;if(this.Ke===this.ir){const t=this.Qe[this.Je];delete this.Qe[this.Je],this.tr.delete(t),this.Je++,this.Ke--}t.save(),t.textBaseline="middle";const r=t.measureText(n);return t.restore(),0===r.width&&e.length||(this.tr.set(n,{er:r,rr:this.Ge}),this.Qe[this.Ge]=n,this.Ke++,this.Ge++),r}}class de{constructor(t){this.hr=null,this.k=null,this.lr="right",this.ar=t}_r(t,e,i){this.hr=t,this.k=e,this.lr=i}X(t){null!==this.k&&null!==this.hr&&this.hr.X(t,this.k,this.ar,this.lr)}}class fe{constructor(t,e,i){this.ur=t,this.ar=new ue(50),this.cr=e,this.F=i,this.j=-1,this.Wt=new de(this.ar)}gt(){const t=this.F.dr(this.cr);if(null===t)return null;const e=t.vr(this.cr)?t.pr():this.cr.Dt();if(null===e)return null;const i=t.mr(e);if("overlay"===i)return null;const s=this.F.br();return s.P!==this.j&&(this.j=s.P,this.ar.nr()),this.Wt._r(this.ur.Ii(),s,i),this.Wt}}class me extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}wr(t,e){var i;if(!(null===(i=this.zt)||void 0===i?void 0:i.yt))return null;const{st:s,et:n,gr:r}=this.zt;return e>=s-n-7&&e<=s+n+7?{Mr:this.zt,gr:r}:null}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;if(!1===this.zt.yt)return;const n=Math.round(this.zt.st*s);n<0||n>e.height||(t.lineCap="butt",t.strokeStyle=this.zt.V,t.lineWidth=Math.floor(this.zt.et*i),C(t,this.zt.Nt),E(t,n,0,e.width))}}class pe{constructor(t){this.Sr={st:0,V:"rgba(0, 0, 0, 0)",et:1,Nt:0,yt:!1},this.kr=new me,this.ft=!0,this.Es=t,this.Ns=t.$t(),this.kr.J(this.Sr)}bt(){this.ft=!0}gt(){return this.Es.yt()?(this.ft&&(this.yr(),this.ft=!1),this.kr):null}}class ge extends pe{constructor(t){super(t)}yr(){this.Sr.yt=!1;const t=this.Es.Dt(),e=t.Cr().Cr;if(2!==e&&3!==e)return;const i=this.Es.W();if(!i.baseLineVisible||!this.Es.yt())return;const s=this.Es.Ct();null!==s&&(this.Sr.yt=!0,this.Sr.st=t.Rt(s.Vt,s.Vt),this.Sr.V=i.baseLineColor,this.Sr.et=i.baseLineWidth,this.Sr.Nt=i.baseLineStyle)}}class be extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}$e(){return this.zt}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){const s=this.zt;if(null===s)return;const n=Math.max(1,Math.floor(e)),r=n%2/2,o=Math.round(s.Xe.x*e)+r,h=s.Xe.y*i;t.fillStyle=s.Tr,t.beginPath();const l=Math.max(2,1.5*s.Pr)*e;t.arc(o,h,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.Rr,t.beginPath(),t.arc(o,h,s.ht*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=n,t.strokeStyle=s.Dr,t.beginPath(),t.arc(o,h,s.ht*e+n/2,0,2*Math.PI,!1),t.stroke()}}const ve=[{Vr:0,Or:.25,Br:4,Ar:10,Ir:.25,zr:0,Lr:.4,Er:.8},{Vr:.25,Or:.525,Br:10,Ar:14,Ir:0,zr:0,Lr:.8,Er:0},{Vr:.525,Or:1,Br:14,Ar:14,Ir:0,zr:0,Lr:0,Er:0}];function we(t,e,i,s){return function(t,e){if("transparent"===t)return t;const i=V(t),s=i[3];return`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${e*s})`}(t,i+(s-i)*e)}function ye(t,e){const i=t%2600/2600;let s;for(const t of ve)if(i>=t.Vr&&i<=t.Or){s=t;break}_(void 0!==s,"Last price animation internal logic error");const n=(i-s.Vr)/(s.Or-s.Vr);return{Rr:we(e,n,s.Ir,s.zr),Dr:we(e,n,s.Lr,s.Er),ht:(r=n,o=s.Br,h=s.Ar,o+(h-o)*r)};var r,o,h}class Me{constructor(t){this.Wt=new be,this.ft=!0,this.Nr=!0,this.Fr=performance.now(),this.Wr=this.Fr-1,this.jr=t}Hr(){this.Wr=this.Fr-1,this.bt()}$r(){if(this.bt(),2===this.jr.W().lastPriceAnimation){const t=performance.now(),e=this.Wr-t;if(e>0)return void(e<650&&(this.Wr+=2600));this.Fr=t,this.Wr=t+2600}}bt(){this.ft=!0}Ur(){this.Nr=!0}yt(){return 0!==this.jr.W().lastPriceAnimation}qr(){switch(this.jr.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Wr}}gt(){return this.ft?(this.Mt(),this.ft=!1,this.Nr=!1):this.Nr&&(this.Yr(),this.Nr=!1),this.Wt}Mt(){this.Wt.J(null);const t=this.jr.$t().St(),e=t.Xs(),i=this.jr.Ct();if(null===e||null===i)return;const s=this.jr.Zr(!0);if(s.Xr||!e.Kr(s.ee))return;const n={x:t.It(s.ee),y:this.jr.Dt().Rt(s._t,i.Vt)},r=s.V,o=this.jr.W().lineWidth,h=ye(this.Gr(),r);this.Wt.J({Tr:r,Pr:o,Rr:h.Rr,Dr:h.Dr,ht:h.ht,Xe:n})}Yr(){const t=this.Wt.$e();if(null!==t){const e=ye(this.Gr(),t.Tr);t.Rr=e.Rr,t.Dr=e.Dr,t.ht=e.ht}}Gr(){return this.qr()?performance.now()-this.Fr:2599}}function xe(t,e){return Pt(Math.min(Math.max(t,12),30)*e)}function Se(t,e){switch(t){case"arrowDown":case"arrowUp":return xe(e,1);case"circle":return xe(e,.8);case"square":return xe(e,.7)}}function Ce(t){return function(t){const e=Math.ceil(t);return e%2!=0?e-1:e}(xe(t,1))}function Ee(t){return Math.max(xe(t,.1),3)}function _e(t,e,i){return e?t:i?Math.ceil(t/2):0}function $e(t,e,i,s,n){const r=Se("square",i),o=(r-1)/2,h=t-o,l=e-o;return s>=h&&s<=h+r&&n>=l&&n<=l+r}function ze(t,e,i,s){const n=(Se("arrowUp",s)-1)/2*i.Jr,r=(Pt(s/2)-1)/2*i.Jr;e.beginPath(),t?(e.moveTo(i.nt-n,i.st),e.lineTo(i.nt,i.st-n),e.lineTo(i.nt+n,i.st),e.lineTo(i.nt+r,i.st),e.lineTo(i.nt+r,i.st+n),e.lineTo(i.nt-r,i.st+n),e.lineTo(i.nt-r,i.st)):(e.moveTo(i.nt-n,i.st),e.lineTo(i.nt,i.st+n),e.lineTo(i.nt+n,i.st),e.lineTo(i.nt+r,i.st),e.lineTo(i.nt+r,i.st-n),e.lineTo(i.nt-r,i.st-n),e.lineTo(i.nt-r,i.st)),e.fill()}class ke extends Z{constructor(){super(...arguments),this.zt=null,this.ar=new ue,this.j=-1,this.H="",this.Qr=""}J(t){this.zt=t}_r(t,e){this.j===t&&this.H===e||(this.j=t,this.H=e,this.Qr=G(t,e),this.ar.nr())}wr(t,e){if(null===this.zt||null===this.zt.tt)return null;for(let i=this.zt.tt.from;i<this.zt.tt.to;i++){const s=this.zt.it[i];if(Le(s,t,e))return{Mr:s.th,gr:s.gr}}return null}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i},s,n){if(null!==this.zt&&null!==this.zt.tt){t.textBaseline="middle",t.font=this.Qr;for(let s=this.zt.tt.from;s<this.zt.tt.to;s++){const n=this.zt.it[s];void 0!==n.Kt&&(n.Kt.Hi=this.ar.xi(t,n.Kt.ih),n.Kt.At=this.j,n.Kt.nt=n.nt-n.Kt.Hi/2),Re(n,t,e,i)}}}}function Re(t,e,i,s){e.fillStyle=t.V,void 0!==t.Kt&&function(t,e,i,s,n,r){t.save(),t.scale(n,r),t.fillText(e,i,s),t.restore()}(e,t.Kt.ih,t.Kt.nt,t.Kt.st,i,s),function(t,e,i){if(0!==t.Ks){switch(t.nh){case"arrowDown":return void ze(!1,e,i,t.Ks);case"arrowUp":return void ze(!0,e,i,t.Ks);case"circle":return void function(t,e,i){const s=(Se("circle",i)-1)/2;t.beginPath(),t.arc(e.nt,e.st,s*e.Jr,0,2*Math.PI,!1),t.fill()}(e,i,t.Ks);case"square":return void function(t,e,i){const s=Se("square",i),n=(s-1)*e.Jr/2,r=e.nt-n,o=e.st-n;t.fillRect(r,o,s*e.Jr,s*e.Jr)}(e,i,t.Ks)}t.nh}}(t,e,function(t,e,i){const s=Math.max(1,Math.floor(e))%2/2;return{nt:Math.round(t.nt*e)+s,st:t.st*i,Jr:e}}(t,i,s))}function Le(t,e,i){return!(void 0===t.Kt||!function(t,e,i,s,n,r){const o=s/2;return n>=t&&n<=t+i&&r>=e-o&&r<=e+o}(t.Kt.nt,t.Kt.st,t.Kt.Hi,t.Kt.At,e,i))||function(t,e,i){if(0===t.Ks)return!1;switch(t.nh){case"arrowDown":case"arrowUp":return function(t,e,i,s,n,r){return $e(e,i,s,n,r)}(0,t.nt,t.st,t.Ks,e,i);case"circle":return function(t,e,i,s,n){const r=2+Se("circle",i)/2,o=t-s,h=e-n;return Math.sqrt(o*o+h*h)<=r}(t.nt,t.st,t.Ks,e,i);case"square":return $e(t.nt,t.st,t.Ks,e,i)}}(t,e,i)}function Te(t,e,i,s,n,r,o,h,l){const a=W(i)?i:i.Se,c=W(i)?i:i.Me,u=W(i)?i:i.xe,d=W(e.size)?Math.max(e.size,0):1,f=Ce(h.le())*d,m=f/2;switch(t.Ks=f,e.position){case"inBar":return t.st=o.Rt(a,l),void(void 0!==t.Kt&&(t.Kt.st=t.st+m+r+.6*n));case"aboveBar":return t.st=o.Rt(c,l)-m-s.sh,void 0!==t.Kt&&(t.Kt.st=t.st-m-.6*n,s.sh+=1.2*n),void(s.sh+=f+r);case"belowBar":return t.st=o.Rt(u,l)+m+s.eh,void 0!==t.Kt&&(t.Kt.st=t.st+m+r+.6*n,s.eh+=1.2*n),void(s.eh+=f+r)}e.position}class Ne{constructor(t,e){this.ft=!0,this.rh=!0,this.hh=!0,this.ah=null,this.oh=null,this.Wt=new ke,this.jr=t,this.$i=e,this.zt={it:[],tt:null}}bt(t){this.ft=!0,this.hh=!0,"data"===t&&(this.rh=!0,this.oh=null)}gt(t){if(!this.jr.yt())return null;this.ft&&this._h();const e=this.$i.W().layout;return this.Wt._r(e.fontSize,e.fontFamily),this.Wt.J(this.zt),this.Wt}uh(){if(this.hh){if(this.jr.dh().length>0){const t=this.$i.St().le(),e=Ee(t),i=1.5*Ce(t)+2*e,s=this.fh();this.ah={above:_e(i,s.aboveBar,s.inBar),below:_e(i,s.belowBar,s.inBar)}}else this.ah=null;this.hh=!1}return this.ah}fh(){return null===this.oh&&(this.oh=this.jr.dh().reduce((t,e)=>(t[e.position]||(t[e.position]=!0),t),{inBar:!1,aboveBar:!1,belowBar:!1})),this.oh}_h(){const t=this.jr.Dt(),e=this.$i.St(),i=this.jr.dh();this.rh&&(this.zt.it=i.map(t=>({ot:t.time,nt:0,st:0,Ks:0,nh:t.shape,V:t.color,th:t.th,gr:t.id,Kt:void 0})),this.rh=!1);const s=this.$i.W().layout;this.zt.tt=null;const n=e.Xs();if(null===n)return;const r=this.jr.Ct();if(null===r)return;if(0===this.zt.it.length)return;let o=NaN;const h=Ee(e.le()),l={sh:h,eh:h};this.zt.tt=Kt(this.zt.it,n,!0);for(let n=this.zt.tt.from;n<this.zt.tt.to;n++){const a=i[n];a.time!==o&&(l.sh=h,l.eh=h,o=a.time);const c=this.zt.it[n];c.nt=e.It(a.time),void 0!==a.text&&a.text.length>0&&(c.Kt={ih:a.text,nt:0,st:0,Hi:0,At:0});const u=this.jr.ph(a.time);null!==u&&Te(c,a,u,l,s.fontSize,h,t,e,r.Vt)}this.ft=!1}}class Oe extends pe{constructor(t){super(t)}yr(){const t=this.Sr;t.yt=!1;const e=this.Es.W();if(!e.priceLineVisible||!this.Es.yt())return;const i=this.Es.Zr(0===e.priceLineSource);i.Xr||(t.yt=!0,t.st=i.ki,t.V=this.Es.mh(i.V),t.et=e.priceLineWidth,t.Nt=e.priceLineStyle)}}class Pe extends dt{constructor(t){super(),this.jt=t}zi(t,e,i){t.yt=!1,e.yt=!1;const s=this.jt;if(!s.yt())return;const n=s.W(),r=n.lastValueVisible,o=""!==s.bh(),h=0===n.seriesLastValueMode,l=s.Zr(!1);if(l.Xr)return;r&&(t.Kt=this.wh(l,r,h),t.yt=0!==t.Kt.length),(o||h)&&(e.Kt=this.gh(l,r,o,h),e.yt=e.Kt.length>0);const a=s.mh(l.V),c=I(a);i.t=c.t,i.ki=l.ki,e.Ot=s.$t().Bt(l.ki/s.Dt().At()),t.Ot=a,t.V=c.i,e.V=c.i}gh(t,e,i,s){let n="";const r=this.jt.bh();return i&&0!==r.length&&(n+=`${r} `),e&&s&&(n+=this.jt.Dt().Mh()?t.xh:t.Sh),n.trim()}wh(t,e,i){return e?i?this.jt.Dt().Mh()?t.Sh:t.xh:t.Kt:""}}function Fe(t,e,i,s){const n=Number.isFinite(e),r=Number.isFinite(i);return n&&r?t(e,i):n||r?n?e:i:s}class Ve{constructor(t,e){this.kh=t,this.yh=e}Ch(t){return null!==t&&this.kh===t.kh&&this.yh===t.yh}Th(){return new Ve(this.kh,this.yh)}Ph(){return this.kh}Rh(){return this.yh}Dh(){return this.yh-this.kh}Ni(){return this.yh===this.kh||Number.isNaN(this.yh)||Number.isNaN(this.kh)}ts(t){return null===t?this:new Ve(Fe(Math.min,this.Ph(),t.Ph(),-1/0),Fe(Math.max,this.Rh(),t.Rh(),1/0))}Vh(t){if(!W(t))return;if(0===this.yh-this.kh)return;const e=.5*(this.yh+this.kh);let i=this.yh-e,s=this.kh-e;i*=t,s*=t,this.yh=e+i,this.kh=e+s}Oh(t){W(t)&&(this.yh+=t,this.kh+=t)}Bh(){return{minValue:this.kh,maxValue:this.yh}}static Ah(t){return null===t?null:new Ve(t.minValue,t.maxValue)}}class De{constructor(t,e){this.Ih=t,this.zh=e||null}Lh(){return this.Ih}Eh(){return this.zh}Bh(){return null===this.Ih?null:{priceRange:this.Ih.Bh(),margins:this.zh||void 0}}static Ah(t){return null===t?null:new De(Ve.Ah(t.priceRange),t.margins)}}class Ie extends pe{constructor(t,e){super(t),this.Nh=e}yr(){const t=this.Sr;t.yt=!1;const e=this.Nh.W();if(!this.Es.yt()||!e.lineVisible)return;const i=this.Nh.Fh();null!==i&&(t.yt=!0,t.st=i,t.V=e.color,t.et=e.lineWidth,t.Nt=e.lineStyle,t.gr=this.Nh.W().id)}}class Be extends dt{constructor(t,e){super(),this.jr=t,this.Nh=e}zi(t,e,i){t.yt=!1,e.yt=!1;const s=this.Nh.W(),n=s.axisLabelVisible,r=""!==s.title,o=this.jr;if(!n||!o.yt())return;const h=this.Nh.Fh();if(null===h)return;r&&(e.Kt=s.title,e.yt=!0),e.Ot=o.$t().Bt(h/o.Dt().At()),t.Kt=this.Wh(s.price),t.yt=!0;const l=I(s.axisLabelColor||s.color);i.t=l.t;const a=s.axisLabelTextColor||l.i;t.V=a,e.V=a,i.ki=h}Wh(t){const e=this.jr.Ct();return null===e?"":this.jr.Dt().Fi(t,e.Vt)}}class Ae{constructor(t,e){this.jr=t,this.cn=e,this.jh=new Ie(t,this),this.ur=new Be(t,this),this.Hh=new fe(this.ur,t,t.$t())}$h(t){A(this.cn,t),this.bt(),this.jr.$t().Uh()}W(){return this.cn}qh(){return this.jh}Yh(){return this.Hh}Zh(){return this.ur}bt(){this.jh.bt(),this.ur.bt()}Fh(){const t=this.jr,e=t.Dt();if(t.$t().St().Ni()||e.Ni())return null;const i=t.Ct();return null===i?null:e.Rt(this.cn.price,i.Vt)}}class We extends bt{constructor(t){super(),this.$i=t}$t(){return this.$i}}const je={Bar:(t,e,i,s)=>{var n;const r=e.upColor,o=e.downColor,h=z(t(i,s)),l=k(h.Vt[0])<=k(h.Vt[3]);return{ce:null!==(n=h.V)&&void 0!==n?n:l?r:o}},Candlestick:(t,e,i,s)=>{var n,r,o;const h=e.upColor,l=e.downColor,a=e.borderUpColor,c=e.borderDownColor,u=e.wickUpColor,d=e.wickDownColor,f=z(t(i,s)),m=k(f.Vt[0])<=k(f.Vt[3]);return{ce:null!==(n=f.V)&&void 0!==n?n:m?h:l,Ne:null!==(r=f.Ot)&&void 0!==r?r:m?a:c,Ee:null!==(o=f.Xh)&&void 0!==o?o:m?u:d}},Custom:(t,e,i,s)=>{var n;return{ce:null!==(n=z(t(i,s)).V)&&void 0!==n?n:e.color}},Area:(t,e,i,s)=>{var n,r,o,h;const l=z(t(i,s));return{ce:null!==(n=l.lt)&&void 0!==n?n:e.lineColor,lt:null!==(r=l.lt)&&void 0!==r?r:e.lineColor,Ps:null!==(o=l.Ps)&&void 0!==o?o:e.topColor,Rs:null!==(h=l.Rs)&&void 0!==h?h:e.bottomColor}},Baseline:(t,e,i,s)=>{var n,r,o,h,l,a;const c=z(t(i,s));return{ce:c.Vt[3]>=e.baseValue.price?e.topLineColor:e.bottomLineColor,Re:null!==(n=c.Re)&&void 0!==n?n:e.topLineColor,De:null!==(r=c.De)&&void 0!==r?r:e.bottomLineColor,ke:null!==(o=c.ke)&&void 0!==o?o:e.topFillColor1,ye:null!==(h=c.ye)&&void 0!==h?h:e.topFillColor2,Ce:null!==(l=c.Ce)&&void 0!==l?l:e.bottomFillColor1,Te:null!==(a=c.Te)&&void 0!==a?a:e.bottomFillColor2}},Line:(t,e,i,s)=>{var n,r;const o=z(t(i,s));return{ce:null!==(n=o.V)&&void 0!==n?n:e.color,lt:null!==(r=o.V)&&void 0!==r?r:e.color}},Histogram:(t,e,i,s)=>{var n;return{ce:null!==(n=z(t(i,s)).V)&&void 0!==n?n:e.color}}};class Ue{constructor(t){this.Kh=(t,e)=>void 0!==e?e.Vt:this.jr.In().Gh(t),this.jr=t,this.Jh=je[t.Qh()]}$s(t,e){return this.Jh(this.Kh,this.jr.W(),t,e)}}var He;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(He||(He={}));const Ke=30;class qe{constructor(){this.tl=[],this.il=new Map,this.nl=new Map}sl(){return this.Ks()>0?this.tl[this.tl.length-1]:null}el(){return this.Ks()>0?this.rl(0):null}An(){return this.Ks()>0?this.rl(this.tl.length-1):null}Ks(){return this.tl.length}Ni(){return 0===this.Ks()}Kr(t){return null!==this.hl(t,0)}Gh(t){return this.ll(t)}ll(t,e=0){const i=this.hl(t,e);return null===i?null:Object.assign(Object.assign({},this.al(i)),{ee:this.rl(i)})}ne(){return this.tl}ol(t,e,i){if(this.Ni())return null;let s=null;for(const n of i)s=Xe(s,this._l(t,e,n));return s}J(t){this.nl.clear(),this.il.clear(),this.tl=t}rl(t){return this.tl[t].ee}al(t){return this.tl[t]}hl(t,e){const i=this.ul(t);if(null===i&&0!==e)switch(e){case-1:return this.cl(t);case 1:return this.dl(t);default:throw new TypeError("Unknown search mode")}return i}cl(t){let e=this.fl(t);return e>0&&(e-=1),e!==this.tl.length&&this.rl(e)<t?e:null}dl(t){const e=this.vl(t);return e!==this.tl.length&&t<this.rl(e)?e:null}ul(t){const e=this.fl(t);return e===this.tl.length||t<this.tl[e].ee?null:e}fl(t){return Wt(this.tl,t,(t,e)=>t.ee<e)}vl(t){return jt(this.tl,t,(t,e)=>t.ee>e)}pl(t,e,i){let s=null;for(let n=t;n<e;n++){const t=this.tl[n].Vt[i];Number.isNaN(t)||(null===s?s={ml:t,bl:t}:(t<s.ml&&(s.ml=t),t>s.bl&&(s.bl=t)))}return s}_l(t,e,i){if(this.Ni())return null;let s=null;const n=z(this.el()),r=z(this.An()),o=Math.max(t,n),h=Math.min(e,r),l=Math.ceil(o/Ke)*Ke,a=Math.max(l,Math.floor(h/Ke)*Ke);{const t=this.fl(o),n=this.vl(Math.min(h,l,e));s=Xe(s,this.pl(t,n,i))}let c=this.il.get(i);void 0===c&&(c=new Map,this.il.set(i,c));for(let t=Math.max(l+1,o);t<a;t+=Ke){const e=Math.floor(t/Ke);let n=c.get(e);if(void 0===n){const t=this.fl(e*Ke),s=this.vl((e+1)*Ke-1);n=this.pl(t,s,i),c.set(e,n)}s=Xe(s,n)}{const t=this.fl(a),e=this.vl(h);s=Xe(s,this.pl(t,e,i))}return s}}function Xe(t,e){return null===t?e:null===e?t:{ml:Math.min(t.ml,e.ml),bl:Math.max(t.bl,e.bl)}}class Je{constructor(t){this.wl=t}X(t,e,i){this.wl.draw(t)}gl(t,e,i){var s,n;null===(n=(s=this.wl).drawBackground)||void 0===n||n.call(s,t)}}class Ge{constructor(t){this.tr=null,this.wn=t}gt(){var t;const e=this.wn.renderer();if(null===e)return null;if((null===(t=this.tr)||void 0===t?void 0:t.Ml)===e)return this.tr.xl;const i=new Je(e);return this.tr={Ml:e,xl:i},i}Sl(){var t,e,i;return null!==(i=null===(e=(t=this.wn).zOrder)||void 0===e?void 0:e.call(t))&&void 0!==i?i:"normal"}}function Qe(t){var e,i,s,n,r;return{Kt:t.text(),ki:t.coordinate(),Si:null===(e=t.fixedCoordinate)||void 0===e?void 0:e.call(t),V:t.textColor(),t:t.backColor(),yt:null===(s=null===(i=t.visible)||void 0===i?void 0:i.call(t))||void 0===s||s,hi:null===(r=null===(n=t.tickVisible)||void 0===n?void 0:n.call(t))||void 0===r||r}}class Ye{constructor(t,e){this.Wt=new pt,this.kl=t,this.yl=e}gt(){return this.Wt.J(Object.assign({Hi:this.yl.Hi()},Qe(this.kl))),this.Wt}}class Ze extends dt{constructor(t,e){super(),this.kl=t,this.Li=e}zi(t,e,i){const s=Qe(this.kl);i.t=s.t,t.V=s.V;const n=2/12*this.Li.P();i.wi=n,i.gi=n,i.ki=s.ki,i.Si=s.Si,t.Kt=s.Kt,t.yt=s.yt,t.hi=s.hi}}class ti{constructor(t,e){this.Cl=null,this.Tl=null,this.Pl=null,this.Rl=null,this.Dl=null,this.Vl=t,this.jr=e}Ol(){return this.Vl}Vn(){var t,e;null===(e=(t=this.Vl).updateAllViews)||void 0===e||e.call(t)}Pn(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).paneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Cl)||void 0===s?void 0:s.Ml)===n)return this.Cl.xl;const r=n.map(t=>new Ge(t));return this.Cl={Ml:n,xl:r},r}Qi(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).timeAxisViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Tl)||void 0===s?void 0:s.Ml)===n)return this.Tl.xl;const r=this.jr.$t().St(),o=n.map(t=>new Ye(t,r));return this.Tl={Ml:n,xl:o},o}Rn(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).priceAxisViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Pl)||void 0===s?void 0:s.Ml)===n)return this.Pl.xl;const r=this.jr.Dt(),o=n.map(t=>new Ze(t,r));return this.Pl={Ml:n,xl:o},o}Bl(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).priceAxisPaneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Rl)||void 0===s?void 0:s.Ml)===n)return this.Rl.xl;const r=n.map(t=>new Ge(t));return this.Rl={Ml:n,xl:r},r}Al(){var t,e,i,s;const n=null!==(i=null===(e=(t=this.Vl).timeAxisPaneViews)||void 0===e?void 0:e.call(t))&&void 0!==i?i:[];if((null===(s=this.Dl)||void 0===s?void 0:s.Ml)===n)return this.Dl.xl;const r=n.map(t=>new Ge(t));return this.Dl={Ml:n,xl:r},r}Il(t,e){var i,s,n;return null!==(n=null===(s=(i=this.Vl).autoscaleInfo)||void 0===s?void 0:s.call(i,t,e))&&void 0!==n?n:null}wr(t,e){var i,s,n;return null!==(n=null===(s=(i=this.Vl).hitTest)||void 0===s?void 0:s.call(i,t,e))&&void 0!==n?n:null}}function ei(t,e,i,s){t.forEach(t=>{e(t).forEach(t=>{t.Sl()===i&&s.push(t)})})}function ii(t){return t.Pn()}function si(t){return t.Bl()}function ni(t){return t.Al()}class ri extends We{constructor(t,e,i,s,n){super(t),this.zt=new qe,this.jh=new Oe(this),this.zl=[],this.Ll=new ge(this),this.El=null,this.Nl=null,this.Fl=[],this.Wl=[],this.jl=null,this.Hl=[],this.cn=e,this.$l=i;const r=new Pe(this);this.rn=[r],this.Hh=new fe(r,this,t),"Area"!==i&&"Line"!==i&&"Baseline"!==i||(this.El=new Me(this)),this.Ul(),this.ql(n)}S(){null!==this.jl&&clearTimeout(this.jl)}mh(t){return this.cn.priceLineColor||t}Zr(t){const e={Xr:!0},i=this.Dt();if(this.$t().St().Ni()||i.Ni()||this.zt.Ni())return e;const s=this.$t().St().Xs(),n=this.Ct();if(null===s||null===n)return e;let r,o;if(t){const t=this.zt.sl();if(null===t)return e;r=t,o=t.ee}else{const t=this.zt.ll(s.ui(),-1);if(null===t)return e;if(r=this.zt.Gh(t.ee),null===r)return e;o=t.ee}const h=r.Vt[3],l=this.Us().$s(o,{Vt:r}),a=i.Rt(h,n.Vt);return{Xr:!1,_t:h,Kt:i.Fi(h,n.Vt),xh:i.Yl(h),Sh:i.Zl(h,n.Vt),V:l.ce,ki:a,ee:o}}Us(){return null!==this.Nl||(this.Nl=new Ue(this)),this.Nl}W(){return this.cn}$h(t){const e=t.priceScaleId;void 0!==e&&e!==this.cn.priceScaleId&&this.$t().Xl(this,e),A(this.cn,t),void 0!==t.priceFormat&&(this.Ul(),this.$t().Kl()),this.$t().Gl(this),this.$t().Jl(),this.wn.bt("options")}J(t,e){this.zt.J(t),this.Ql(),this.wn.bt("data"),this.dn.bt("data"),null!==this.El&&(e&&e.ta?this.El.$r():0===t.length&&this.El.Hr());const i=this.$t().dr(this);this.$t().ia(i),this.$t().Gl(this),this.$t().Jl(),this.$t().Uh()}na(t){this.Fl=t,this.Ql();const e=this.$t().dr(this);this.dn.bt("data"),this.$t().ia(e),this.$t().Gl(this),this.$t().Jl(),this.$t().Uh()}sa(){return this.Fl}dh(){return this.Wl}ea(t){const e=new Ae(this,t);return this.zl.push(e),this.$t().Gl(this),e}ra(t){const e=this.zl.indexOf(t);-1!==e&&this.zl.splice(e,1),this.$t().Gl(this)}Qh(){return this.$l}Ct(){const t=this.ha();return null===t?null:{Vt:t.Vt[3],la:t.ot}}ha(){const t=this.$t().St().Xs();if(null===t)return null;const e=t.Os();return this.zt.ll(e,1)}In(){return this.zt}ph(t){const e=this.zt.Gh(t);return null===e?null:"Bar"===this.$l||"Candlestick"===this.$l||"Custom"===this.$l?{ge:e.Vt[0],Me:e.Vt[1],xe:e.Vt[2],Se:e.Vt[3]}:e.Vt[3]}aa(t){const e=[];ei(this.Hl,ii,"top",e);const i=this.El;return null!==i&&i.yt()?(null===this.jl&&i.qr()&&(this.jl=setTimeout(()=>{this.jl=null,this.$t().oa()},0)),i.Ur(),e.unshift(i),e):e}Pn(){const t=[];this._a()||t.push(this.Ll),t.push(this.wn,this.jh,this.dn);const e=this.zl.map(t=>t.qh());return t.push(...e),ei(this.Hl,ii,"normal",t),t}ua(){return this.ca(ii,"bottom")}da(t){return this.ca(si,t)}fa(t){return this.ca(ni,t)}va(t,e){return this.Hl.map(i=>i.wr(t,e)).filter(t=>null!==t)}Ji(t){return[this.Hh,...this.zl.map(t=>t.Yh())]}Rn(t,e){if(e!==this.Yi&&!this._a())return[];const i=[...this.rn];for(const t of this.zl)i.push(t.Zh());return this.Hl.forEach(t=>{i.push(...t.Rn())}),i}Qi(){const t=[];return this.Hl.forEach(e=>{t.push(...e.Qi())}),t}Il(t,e){if(void 0!==this.cn.autoscaleInfoProvider){const i=this.cn.autoscaleInfoProvider(()=>{const i=this.pa(t,e);return null===i?null:i.Bh()});return De.Ah(i)}return this.pa(t,e)}ma(){return this.cn.priceFormat.minMove}ba(){return this.wa}Vn(){var t;this.wn.bt(),this.dn.bt();for(const t of this.rn)t.bt();for(const t of this.zl)t.bt();this.jh.bt(),this.Ll.bt(),null===(t=this.El)||void 0===t||t.bt(),this.Hl.forEach(t=>t.Vn())}Dt(){return z(super.Dt())}kt(t){if("Line"!==this.$l&&"Area"!==this.$l&&"Baseline"!==this.$l||!this.cn.crosshairMarkerVisible)return null;const e=this.zt.Gh(t);return null===e?null:{_t:e.Vt[3],ht:this.ga(),Ot:this.Ma(),Pt:this.xa(),Tt:this.Sa(t)}}bh(){return this.cn.title}yt(){return this.cn.visible}ka(t){this.Hl.push(new ti(t,this))}ya(t){this.Hl=this.Hl.filter(e=>e.Ol()!==t)}Ca(){if(this.wn instanceof re!=0)return t=>this.wn.We(t)}Ta(){if(this.wn instanceof re!=0)return t=>this.wn.je(t)}_a(){return!yt(this.Dt().Pa())}pa(t,e){if(!j(t)||!j(e)||this.zt.Ni())return null;const i="Line"===this.$l||"Area"===this.$l||"Baseline"===this.$l||"Histogram"===this.$l?[3]:[2,1],s=this.zt.ol(t,e,i);let n=null!==s?new Ve(s.ml,s.bl):null;if("Histogram"===this.Qh()){const t=this.cn.base,e=new Ve(t,t);n=null!==n?n.ts(e):e}let r=this.dn.uh();return this.Hl.forEach(i=>{const s=i.Il(t,e);if(null==s?void 0:s.priceRange){const t=new Ve(s.priceRange.minValue,s.priceRange.maxValue);n=null!==n?n.ts(t):t}var o,h,l,a;(null==s?void 0:s.margins)&&(o=r,h=s.margins,r={above:Math.max(null!==(l=null==o?void 0:o.above)&&void 0!==l?l:0,h.above),below:Math.max(null!==(a=null==o?void 0:o.below)&&void 0!==a?a:0,h.below)})}),new De(n,r)}ga(){switch(this.$l){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerRadius}return 0}Ma(){switch(this.$l){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}xa(){switch(this.$l){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerBorderWidth}return 0}Sa(t){switch(this.$l){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Us().$s(t).ce}Ul(){switch(this.cn.priceFormat.type){case"custom":this.wa={format:this.cn.priceFormat.formatter};break;case"volume":this.wa=new Et(this.cn.priceFormat.precision);break;case"percent":this.wa=new Ct(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.wa=new St(t,this.cn.priceFormat.minMove*t)}}null!==this.Yi&&this.Yi.Ra()}Ql(){const t=this.$t().St();if(!t.Da()||this.zt.Ni())return void(this.Wl=[]);const e=z(this.zt.el());this.Wl=this.Fl.map((i,s)=>{const n=z(t.Va(i.time,!0)),r=n<e?1:-1;return{time:z(this.zt.ll(n,r)).ee,position:i.position,shape:i.shape,color:i.color,id:i.id,th:s,text:i.text,size:i.size,originalTime:i.originalTime}})}ql(t){switch(this.dn=new Ne(this,this.$t()),this.$l){case"Bar":this.wn=new Yt(this,this.$t());break;case"Candlestick":this.wn=new se(this,this.$t());break;case"Line":this.wn=new ae(this,this.$t());break;case"Custom":this.wn=new re(this,this.$t(),$(t));break;case"Area":this.wn=new Jt(this,this.$t());break;case"Baseline":this.wn=new ee(this,this.$t());break;case"Histogram":this.wn=new le(this,this.$t());break;default:throw Error("Unknown chart style assigned: "+this.$l)}}ca(t,e){const i=[];return ei(this.Hl,t,e,i),i}}class oi{constructor(t){this.cn=t}Oa(t,e,i){let s=t;if(0===this.cn.mode)return s;const n=i.vn(),r=n.Ct();if(null===r)return s;const o=n.Rt(t,r),h=i.Ba().filter(t=>t instanceof ri).reduce((t,s)=>{if(i.vr(s)||!s.yt())return t;const n=s.Dt(),r=s.In();if(n.Ni()||!r.Kr(e))return t;const o=r.Gh(e);if(null===o)return t;const h=k(s.Ct());return t.concat([n.Rt(o.Vt[3],h.Vt)])},[]);if(0===h.length)return s;h.sort((t,e)=>Math.abs(t-o)-Math.abs(e-o));const l=h[0];return s=n.pn(l,r),s}}class hi extends Z{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.zt)return;const n=Math.max(1,Math.floor(i));t.lineWidth=n,function(t,e){t.save(),t.lineWidth%2&&t.translate(.5,.5),e(),t.restore()}(t,()=>{const r=z(this.zt);if(r.Aa){t.strokeStyle=r.Ia,C(t,r.za),t.beginPath();for(const s of r.La){const r=Math.round(s.Ea*i);t.moveTo(r,-n),t.lineTo(r,e.height+n)}t.stroke()}if(r.Na){t.strokeStyle=r.Fa,C(t,r.Wa),t.beginPath();for(const i of r.ja){const r=Math.round(i.Ea*s);t.moveTo(-n,r),t.lineTo(e.width+n,r)}t.stroke()}})}}class li{constructor(t){this.Wt=new hi,this.ft=!0,this.tn=t}bt(){this.ft=!0}gt(){if(this.ft){const t=this.tn.$t().W().grid,e={Na:t.horzLines.visible,Aa:t.vertLines.visible,Fa:t.horzLines.color,Ia:t.vertLines.color,Wa:t.horzLines.style,za:t.vertLines.style,ja:this.tn.vn().Ha(),La:(this.tn.$t().St().Ha()||[]).map(t=>({Ea:t.coord}))};this.Wt.J(e),this.ft=!1}return this.Wt}}class ai{constructor(t){this.wn=new li(t)}qh(){return this.wn}}const ci={$a:4,Ua:1e-4};function ui(t,e){const i=100*(t-e)/e;return e<0?-i:i}function di(t,e){const i=ui(t.Ph(),e),s=ui(t.Rh(),e);return new Ve(i,s)}function fi(t,e){const i=100*(t-e)/e+100;return e<0?-i:i}function mi(t,e){const i=fi(t.Ph(),e),s=fi(t.Rh(),e);return new Ve(i,s)}function pi(t,e){const i=Math.abs(t);if(i<1e-15)return 0;const s=Math.log10(i+e.Ua)+e.$a;return t<0?-s:s}function gi(t,e){const i=Math.abs(t);if(i<1e-15)return 0;const s=Math.pow(10,i-e.$a)-e.Ua;return t<0?-s:s}function bi(t,e){if(null===t)return null;const i=pi(t.Ph(),e),s=pi(t.Rh(),e);return new Ve(i,s)}function vi(t,e){if(null===t)return null;const i=gi(t.Ph(),e),s=gi(t.Rh(),e);return new Ve(i,s)}function wi(t){if(null===t)return ci;const e=Math.abs(t.Rh()-t.Ph());if(e>=1||e<1e-15)return ci;const i=Math.ceil(Math.abs(Math.log10(e))),s=ci.$a+i;return{$a:s,Ua:1/Math.pow(10,s)}}class yi{constructor(t,e){if(this.qa=t,this.Ya=e,function(t){if(t<0)return!1;for(let e=t;e>1;e/=10)if(e%10!=0)return!1;return!0}(this.qa))this.Za=[2,2.5,2];else{this.Za=[];for(let t=this.qa;1!==t;){if(t%2==0)this.Za.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Za.push(2,2.5),t/=5}if(this.Za.length>100)throw new Error("something wrong with base")}}}Xa(t,e,i){const s=0===this.qa?0:1/this.qa;let n=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-e)))),r=0,o=this.Ya[0];for(;;){const t=Ot(n,s,1e-14)&&n>s+1e-14,e=Ot(n,i*o,1e-14),h=Ot(n,1,1e-14);if(!(t&&e&&h))break;n/=o,o=this.Ya[++r%this.Ya.length]}if(n<=s+1e-14&&(n=s),n=Math.max(1,n),this.Za.length>0&&(h=n,Math.abs(h-1)<1e-14))for(r=0,o=this.Za[0];Ot(n,i*o,1e-14)&&n>s+1e-14;)n/=o,o=this.Za[++r%this.Za.length];var h;return n}}class Mi{constructor(t,e,i,s){this.Ka=[],this.Li=t,this.qa=e,this.Ga=i,this.Ja=s}Xa(t,e){if(t<e)throw new Error("high < low");const i=this.Li.At(),s=(t-e)*this.Qa()/i,n=new yi(this.qa,[2,2.5,2]),r=new yi(this.qa,[2,2,2.5]),o=new yi(this.qa,[2.5,2,2]),h=[];return h.push(n.Xa(t,e,s),r.Xa(t,e,s),o.Xa(t,e,s)),function(t){if(t.length<1)throw Error("array is empty");let e=t[0];for(let i=1;i<t.length;++i)t[i]<e&&(e=t[i]);return e}(h)}io(){const t=this.Li,e=t.Ct();if(null===e)return void(this.Ka=[]);const i=t.At(),s=this.Ga(i-1,e),n=this.Ga(0,e),r=this.Li.W().entireTextOnly?this.no()/2:0,o=r,h=i-1-r,l=Math.max(s,n),a=Math.min(s,n);if(l===a)return void(this.Ka=[]);let c=this.Xa(l,a),u=l%c;u+=u<0?c:0;const d=l>=a?1:-1;let f=null,m=0;for(let i=l-u;i>a;i-=c){const s=this.Ja(i,e,!0);null!==f&&Math.abs(s-f)<this.Qa()||s<o||s>h||(m<this.Ka.length?(this.Ka[m].Ea=s,this.Ka[m].so=t.eo(i)):this.Ka.push({Ea:s,so:t.eo(i)}),m++,f=s,t.ro()&&(c=this.Xa(i*d,a)))}this.Ka.length=m}Ha(){return this.Ka}no(){return this.Li.P()}Qa(){return Math.ceil(2.5*this.no())}}function xi(t){return t.slice().sort((t,e)=>z(t.Xi())-z(e.Xi()))}var Si;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(Si||(Si={}));const Ci=new Ct,Ei=new St(100,1);class _i{constructor(t,e,i,s){this.ho=0,this.lo=null,this.Ih=null,this.ao=null,this.oo={_o:!1,uo:null},this.co=0,this.do=0,this.fo=new B,this.vo=new B,this.po=[],this.mo=null,this.bo=null,this.wo=null,this.Mo=null,this.wa=Ei,this.xo=wi(null),this.So=t,this.cn=e,this.ko=i,this.yo=s,this.Co=new Mi(this,100,this.To.bind(this),this.Po.bind(this))}Pa(){return this.So}W(){return this.cn}$h(t){if(A(this.cn,t),this.Ra(),void 0!==t.mode&&this.Ro({Cr:t.mode}),void 0!==t.scaleMargins){const e=$(t.scaleMargins.top),i=$(t.scaleMargins.bottom);if(e<0||e>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${e}`);if(i<0||i>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${i}`);if(e+i>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${e+i}`);this.Do(),this.bo=null}}Vo(){return this.cn.autoScale}ro(){return 1===this.cn.mode}Mh(){return 2===this.cn.mode}Oo(){return 3===this.cn.mode}Cr(){return{Wn:this.cn.autoScale,Bo:this.cn.invertScale,Cr:this.cn.mode}}Ro(t){const e=this.Cr();let i=null;void 0!==t.Wn&&(this.cn.autoScale=t.Wn),void 0!==t.Cr&&(this.cn.mode=t.Cr,2!==t.Cr&&3!==t.Cr||(this.cn.autoScale=!0),this.oo._o=!1),1===e.Cr&&t.Cr!==e.Cr&&(function(t,e){if(null===t)return!1;const i=gi(t.Ph(),e),s=gi(t.Rh(),e);return isFinite(i)&&isFinite(s)}(this.Ih,this.xo)?(i=vi(this.Ih,this.xo),null!==i&&this.Ao(i)):this.cn.autoScale=!0),1===t.Cr&&t.Cr!==e.Cr&&(i=bi(this.Ih,this.xo),null!==i&&this.Ao(i));const s=e.Cr!==this.cn.mode;s&&(2===e.Cr||this.Mh())&&this.Ra(),s&&(3===e.Cr||this.Oo())&&this.Ra(),void 0!==t.Bo&&e.Bo!==t.Bo&&(this.cn.invertScale=t.Bo,this.Io()),this.vo.m(e,this.Cr())}zo(){return this.vo}P(){return this.ko.fontSize}At(){return this.ho}Lo(t){this.ho!==t&&(this.ho=t,this.Do(),this.bo=null)}Eo(){if(this.lo)return this.lo;const t=this.At()-this.No()-this.Fo();return this.lo=t,t}Lh(){return this.Wo(),this.Ih}Ao(t,e){const i=this.Ih;(e||null===i&&null!==t||null!==i&&!i.Ch(t))&&(this.bo=null,this.Ih=t)}Ni(){return this.Wo(),0===this.ho||!this.Ih||this.Ih.Ni()}jo(t){return this.Bo()?t:this.At()-1-t}Rt(t,e){return this.Mh()?t=ui(t,e):this.Oo()&&(t=fi(t,e)),this.Po(t,e)}te(t,e,i){this.Wo();const s=this.Fo(),n=z(this.Lh()),r=n.Ph(),o=n.Rh(),h=this.Eo()-1,l=this.Bo(),a=h/(o-r),c=void 0===i?0:i.from,u=void 0===i?t.length:i.to,d=this.Ho();for(let i=c;i<u;i++){const n=t[i],o=n._t;if(isNaN(o))continue;let h=o;null!==d&&(h=d(n._t,e));const c=s+a*(h-r),u=l?c:this.ho-1-c;n.st=u}}be(t,e,i){this.Wo();const s=this.Fo(),n=z(this.Lh()),r=n.Ph(),o=n.Rh(),h=this.Eo()-1,l=this.Bo(),a=h/(o-r),c=void 0===i?0:i.from,u=void 0===i?t.length:i.to,d=this.Ho();for(let i=c;i<u;i++){const n=t[i];let o=n.ge,h=n.Me,c=n.xe,u=n.Se;null!==d&&(o=d(n.ge,e),h=d(n.Me,e),c=d(n.xe,e),u=d(n.Se,e));let f=s+a*(o-r),m=l?f:this.ho-1-f;n.pe=m,f=s+a*(h-r),m=l?f:this.ho-1-f,n.de=m,f=s+a*(c-r),m=l?f:this.ho-1-f,n.fe=m,f=s+a*(u-r),m=l?f:this.ho-1-f,n.me=m}}pn(t,e){const i=this.To(t,e);return this.$o(i,e)}$o(t,e){let i=t;return this.Mh()?i=function(t,e){return e<0&&(t=-t),t/100*e+e}(i,e):this.Oo()&&(i=function(t,e){return t-=100,e<0&&(t=-t),t/100*e+e}(i,e)),i}Ba(){return this.po}Uo(){if(this.mo)return this.mo;let t=[];for(let e=0;e<this.po.length;e++){const i=this.po[e];null===i.Xi()&&i.Ki(e+1),t.push(i)}return t=xi(t),this.mo=t,this.mo}qo(t){-1===this.po.indexOf(t)&&(this.po.push(t),this.Ra(),this.Yo())}Zo(t){const e=this.po.indexOf(t);if(-1===e)throw new Error("source is not attached to scale");this.po.splice(e,1),0===this.po.length&&(this.Ro({Wn:!0}),this.Ao(null)),this.Ra(),this.Yo()}Ct(){let t=null;for(const e of this.po){const i=e.Ct();null!==i&&(null===t||i.la<t.la)&&(t=i)}return null===t?null:t.Vt}Bo(){return this.cn.invertScale}Ha(){const t=null===this.Ct();if(null!==this.bo&&(t||this.bo.Xo===t))return this.bo.Ha;this.Co.io();const e=this.Co.Ha();return this.bo={Ha:e,Xo:t},this.fo.m(),e}Ko(){return this.fo}Go(t){this.Mh()||this.Oo()||null===this.wo&&null===this.ao&&(this.Ni()||(this.wo=this.ho-t,this.ao=z(this.Lh()).Th()))}Jo(t){if(this.Mh()||this.Oo())return;if(null===this.wo)return;this.Ro({Wn:!1}),(t=this.ho-t)<0&&(t=0);let e=(this.wo+.2*(this.ho-1))/(t+.2*(this.ho-1));const i=z(this.ao).Th();e=Math.max(e,.1),i.Vh(e),this.Ao(i)}Qo(){this.Mh()||this.Oo()||(this.wo=null,this.ao=null)}t_(t){this.Vo()||null===this.Mo&&null===this.ao&&(this.Ni()||(this.Mo=t,this.ao=z(this.Lh()).Th()))}i_(t){if(this.Vo())return;if(null===this.Mo)return;const e=z(this.Lh()).Dh()/(this.Eo()-1);let i=t-this.Mo;this.Bo()&&(i*=-1);const s=i*e,n=z(this.ao).Th();n.Oh(s),this.Ao(n,!0),this.bo=null}n_(){this.Vo()||null!==this.Mo&&(this.Mo=null,this.ao=null)}ba(){return this.wa||this.Ra(),this.wa}Fi(t,e){switch(this.cn.mode){case 2:return this.s_(ui(t,e));case 3:return this.ba().format(fi(t,e));default:return this.Wh(t)}}eo(t){switch(this.cn.mode){case 2:return this.s_(t);case 3:return this.ba().format(t);default:return this.Wh(t)}}Yl(t){return this.Wh(t,z(this.e_()).ba())}Zl(t,e){return t=ui(t,e),this.s_(t,Ci)}r_(){return this.po}h_(t){this.oo={uo:t,_o:!1}}Vn(){this.po.forEach(t=>t.Vn())}Ra(){this.bo=null;const t=this.e_();let e=100;null!==t&&(e=Math.round(1/t.ma())),this.wa=Ei,this.Mh()?(this.wa=Ci,e=100):this.Oo()?(this.wa=new St(100,1),e=100):null!==t&&(this.wa=t.ba()),this.Co=new Mi(this,e,this.To.bind(this),this.Po.bind(this)),this.Co.io()}Yo(){this.mo=null}e_(){return this.po[0]||null}No(){return this.Bo()?this.cn.scaleMargins.bottom*this.At()+this.do:this.cn.scaleMargins.top*this.At()+this.co}Fo(){return this.Bo()?this.cn.scaleMargins.top*this.At()+this.co:this.cn.scaleMargins.bottom*this.At()+this.do}Wo(){this.oo._o||(this.oo._o=!0,this.l_())}Do(){this.lo=null}Po(t,e){if(this.Wo(),this.Ni())return 0;t=this.ro()&&t?pi(t,this.xo):t;const i=z(this.Lh()),s=this.Fo()+(this.Eo()-1)*(t-i.Ph())/i.Dh();return this.jo(s)}To(t,e){if(this.Wo(),this.Ni())return 0;const i=this.jo(t),s=z(this.Lh()),n=s.Ph()+s.Dh()*((i-this.Fo())/(this.Eo()-1));return this.ro()?gi(n,this.xo):n}Io(){this.bo=null,this.Co.io()}l_(){const t=this.oo.uo;if(null===t)return;let e=null;const i=this.r_();let s=0,n=0;for(const r of i){if(!r.yt())continue;const i=r.Ct();if(null===i)continue;const o=r.Il(t.Os(),t.ui());let h=o&&o.Lh();if(null!==h){switch(this.cn.mode){case 1:h=bi(h,this.xo);break;case 2:h=di(h,i.Vt);break;case 3:h=mi(h,i.Vt)}if(e=null===e?h:e.ts(z(h)),null!==o){const t=o.Eh();null!==t&&(s=Math.max(s,t.above),n=Math.max(n,t.below))}}}if(s===this.co&&n===this.do||(this.co=s,this.do=n,this.bo=null,this.Do()),null!==e){if(e.Ph()===e.Rh()){const t=this.e_(),i=5*(null===t||this.Mh()||this.Oo()?1:t.ma());this.ro()&&(e=vi(e,this.xo)),e=new Ve(e.Ph()-i,e.Rh()+i),this.ro()&&(e=bi(e,this.xo))}if(this.ro()){const t=vi(e,this.xo),i=wi(t);if(r=i,o=this.xo,r.$a!==o.$a||r.Ua!==o.Ua){const s=null!==this.ao?vi(this.ao,this.xo):null;this.xo=i,e=bi(t,i),null!==s&&(this.ao=bi(s,i))}}this.Ao(e)}else null===this.Ih&&(this.Ao(new Ve(-.5,.5)),this.xo=wi(null));var r,o;this.oo._o=!0}Ho(){return this.Mh()?ui:this.Oo()?fi:this.ro()?t=>pi(t,this.xo):null}a_(t,e,i){return void 0===e?(void 0===i&&(i=this.ba()),i.format(t)):e(t)}Wh(t,e){return this.a_(t,this.yo.priceFormatter,e)}s_(t,e){return this.a_(t,this.yo.percentageFormatter,e)}}class $i{constructor(t,e){this.po=[],this.o_=new Map,this.ho=0,this.__=0,this.u_=1e3,this.mo=null,this.c_=new B,this.yl=t,this.$i=e,this.d_=new ai(this);const i=e.W();this.f_=this.v_("left",i.leftPriceScale),this.p_=this.v_("right",i.rightPriceScale),this.f_.zo().l(this.m_.bind(this,this.f_),this),this.p_.zo().l(this.m_.bind(this,this.p_),this),this.b_(i)}b_(t){if(t.leftPriceScale&&this.f_.$h(t.leftPriceScale),t.rightPriceScale&&this.p_.$h(t.rightPriceScale),t.localization&&(this.f_.Ra(),this.p_.Ra()),t.overlayPriceScales){const e=Array.from(this.o_.values());for(const i of e){const e=z(i[0].Dt());e.$h(t.overlayPriceScales),t.localization&&e.Ra()}}}w_(t){switch(t){case"left":return this.f_;case"right":return this.p_}return this.o_.has(t)?$(this.o_.get(t))[0].Dt():null}S(){this.$t().g_().p(this),this.f_.zo().p(this),this.p_.zo().p(this),this.po.forEach(t=>{t.S&&t.S()}),this.c_.m()}M_(){return this.u_}x_(t){this.u_=t}$t(){return this.$i}Hi(){return this.__}At(){return this.ho}S_(t){this.__=t,this.k_()}Lo(t){this.ho=t,this.f_.Lo(t),this.p_.Lo(t),this.po.forEach(e=>{if(this.vr(e)){const i=e.Dt();null!==i&&i.Lo(t)}}),this.k_()}Ba(){return this.po}vr(t){const e=t.Dt();return null===e||this.f_!==e&&this.p_!==e}qo(t,e,i){const s=void 0!==i?i:this.C_().y_+1;this.T_(t,e,s)}Zo(t){const e=this.po.indexOf(t);_(-1!==e,"removeDataSource: invalid data source"),this.po.splice(e,1);const i=z(t.Dt()).Pa();if(this.o_.has(i)){const e=$(this.o_.get(i)),s=e.indexOf(t);-1!==s&&(e.splice(s,1),0===e.length&&this.o_.delete(i))}const s=t.Dt();s&&s.Ba().indexOf(t)>=0&&s.Zo(t),null!==s&&(s.Yo(),this.P_(s)),this.mo=null}mr(t){return t===this.f_?"left":t===this.p_?"right":"overlay"}R_(){return this.f_}D_(){return this.p_}V_(t,e){t.Go(e)}O_(t,e){t.Jo(e),this.k_()}B_(t){t.Qo()}A_(t,e){t.t_(e)}I_(t,e){t.i_(e),this.k_()}z_(t){t.n_()}k_(){this.po.forEach(t=>{t.Vn()})}vn(){let t=null;return this.$i.W().rightPriceScale.visible&&0!==this.p_.Ba().length?t=this.p_:this.$i.W().leftPriceScale.visible&&0!==this.f_.Ba().length?t=this.f_:0!==this.po.length&&(t=this.po[0].Dt()),null===t&&(t=this.p_),t}pr(){let t=null;return this.$i.W().rightPriceScale.visible?t=this.p_:this.$i.W().leftPriceScale.visible&&(t=this.f_),t}P_(t){null!==t&&t.Vo()&&this.L_(t)}E_(t){const e=this.yl.Xs();t.Ro({Wn:!0}),null!==e&&t.h_(e),this.k_()}N_(){this.L_(this.f_),this.L_(this.p_)}F_(){this.P_(this.f_),this.P_(this.p_),this.po.forEach(t=>{this.vr(t)&&this.P_(t.Dt())}),this.k_(),this.$i.Uh()}Uo(){return null===this.mo&&(this.mo=xi(this.po)),this.mo}W_(){return this.c_}j_(){return this.d_}L_(t){const e=t.r_();if(e&&e.length>0&&!this.yl.Ni()){const e=this.yl.Xs();null!==e&&t.h_(e)}t.Vn()}C_(){const t=this.Uo();if(0===t.length)return{H_:0,y_:0};let e=0,i=0;for(let s=0;s<t.length;s++){const n=t[s].Xi();null!==n&&(n<e&&(e=n),n>i&&(i=n))}return{H_:e,y_:i}}T_(t,e,i){let s=this.w_(e);if(null===s&&(s=this.v_(e,this.$i.W().overlayPriceScales)),this.po.push(t),!yt(e)){const i=this.o_.get(e)||[];i.push(t),this.o_.set(e,i)}s.qo(t),t.Gi(s),t.Ki(i),this.P_(s),this.mo=null}m_(t,e,i){e.Cr!==i.Cr&&this.L_(t)}v_(t,e){const i=Object.assign({visible:!0,autoScale:!0},K(e)),s=new _i(t,i,this.$i.W().layout,this.$i.W().localization);return s.Lo(this.At()),s}}class zi{constructor(t,e,i=50){this.Ke=0,this.Ge=1,this.Je=1,this.tr=new Map,this.Qe=new Map,this.U_=t,this.q_=e,this.ir=i}Y_(t){const e=t.time,i=this.q_.cacheKey(e),s=this.tr.get(i);if(void 0!==s)return s.Z_;if(this.Ke===this.ir){const t=this.Qe.get(this.Je);this.Qe.delete(this.Je),this.tr.delete($(t)),this.Je++,this.Ke--}const n=this.U_(t);return this.tr.set(i,{Z_:n,rr:this.Ge}),this.Qe.set(this.Ge,i),this.Ke++,this.Ge++,n}}class ki{constructor(t,e){_(t<=e,"right should be >= left"),this.X_=t,this.K_=e}Os(){return this.X_}ui(){return this.K_}G_(){return this.K_-this.X_+1}Kr(t){return this.X_<=t&&t<=this.K_}Ch(t){return this.X_===t.Os()&&this.K_===t.ui()}}function Ri(t,e){return null===t||null===e?t===e:t.Ch(e)}class Li{constructor(){this.J_=new Map,this.tr=null,this.Q_=!1}tu(t){this.Q_=t,this.tr=null}iu(t,e){this.nu(e),this.tr=null;for(let i=e;i<t.length;++i){const e=t[i];let s=this.J_.get(e.timeWeight);void 0===s&&(s=[],this.J_.set(e.timeWeight,s)),s.push({index:i,time:e.time,weight:e.timeWeight,originalTime:e.originalTime})}}su(t,e){const i=Math.ceil(e/t);return null!==this.tr&&this.tr.eu===i||(this.tr={Ha:this.ru(i),eu:i}),this.tr.Ha}nu(t){if(0===t)return void this.J_.clear();const e=[];this.J_.forEach((i,s)=>{t<=i[0].index?e.push(s):i.splice(Wt(i,t,e=>e.index<t),1/0)});for(const t of e)this.J_.delete(t)}ru(t){let e=[];for(const i of Array.from(this.J_.keys()).sort((t,e)=>e-t)){if(!this.J_.get(i))continue;const s=e;e=[];const n=s.length;let r=0;const o=$(this.J_.get(i)),h=o.length;let l=1/0,a=-1/0;for(let i=0;i<h;i++){const h=o[i],c=h.index;for(;r<n;){const t=s[r],i=t.index;if(!(i<c)){l=i;break}r++,e.push(t),a=i,l=1/0}if(l-c>=t&&c-a>=t)e.push(h),a=c;else if(this.Q_)return s}for(;r<n;r++)e.push(s[r])}return e}}class Ti{constructor(t){this.hu=t}lu(){return null===this.hu?null:new ki(Math.floor(this.hu.Os()),Math.ceil(this.hu.ui()))}au(){return this.hu}static ou(){return new Ti(null)}}function Ni(t,e){return t.weight>e.weight?t:e}class Oi{constructor(t,e,i,s){this.__=0,this._u=null,this.uu=[],this.Mo=null,this.wo=null,this.cu=new Li,this.du=new Map,this.fu=Ti.ou(),this.vu=!0,this.pu=new B,this.mu=new B,this.bu=new B,this.wu=null,this.gu=null,this.Mu=[],this.cn=e,this.yo=i,this.xu=e.rightOffset,this.Su=e.barSpacing,this.$i=t,this.q_=s,this.ku(),this.cu.tu(e.uniformDistribution)}W(){return this.cn}yu(t){A(this.yo,t),this.Cu(),this.ku()}$h(t,e){var i;A(this.cn,t),this.cn.fixLeftEdge&&this.Tu(),this.cn.fixRightEdge&&this.Pu(),void 0!==t.barSpacing&&this.$i.Gn(t.barSpacing),void 0!==t.rightOffset&&this.$i.Jn(t.rightOffset),void 0!==t.minBarSpacing&&this.$i.Gn(null!==(i=t.barSpacing)&&void 0!==i?i:this.Su),this.Cu(),this.ku(),this.bu.m()}mn(t){var e,i;return null!==(i=null===(e=this.uu[t])||void 0===e?void 0:e.time)&&void 0!==i?i:null}Ui(t){var e;return null!==(e=this.uu[t])&&void 0!==e?e:null}Va(t,e){if(this.uu.length<1)return null;if(this.q_.key(t)>this.q_.key(this.uu[this.uu.length-1].time))return e?this.uu.length-1:null;const i=Wt(this.uu,this.q_.key(t),(t,e)=>this.q_.key(t.time)<e);return this.q_.key(t)<this.q_.key(this.uu[i].time)?e?i:null:i}Ni(){return 0===this.__||0===this.uu.length||null===this._u}Da(){return this.uu.length>0}Xs(){return this.Ru(),this.fu.lu()}Du(){return this.Ru(),this.fu.au()}Vu(){const t=this.Xs();if(null===t)return null;const e={from:t.Os(),to:t.ui()};return this.Ou(e)}Ou(t){const e=Math.round(t.from),i=Math.round(t.to),s=z(this.Bu()),n=z(this.Au());return{from:z(this.Ui(Math.max(s,e))),to:z(this.Ui(Math.min(n,i)))}}Iu(t){return{from:z(this.Va(t.from,!0)),to:z(this.Va(t.to,!0))}}Hi(){return this.__}S_(t){if(!isFinite(t)||t<=0)return;if(this.__===t)return;const e=this.Du(),i=this.__;if(this.__=t,this.vu=!0,this.cn.lockVisibleTimeRangeOnResize&&0!==i){const e=this.Su*t/i;this.Su=e}if(this.cn.fixLeftEdge&&null!==e&&e.Os()<=0){const e=i-t;this.xu-=Math.round(e/this.Su)+1,this.vu=!0}this.zu(),this.Lu()}It(t){if(this.Ni()||!j(t))return 0;const e=this.Eu()+this.xu-t;return this.__-(e+.5)*this.Su-1}Qs(t,e){const i=this.Eu(),s=void 0===e?0:e.from,n=void 0===e?t.length:e.to;for(let e=s;e<n;e++){const s=t[e].ot,n=i+this.xu-s,r=this.__-(n+.5)*this.Su-1;t[e].nt=r}}Nu(t){return Math.ceil(this.Fu(t))}Jn(t){this.vu=!0,this.xu=t,this.Lu(),this.$i.Wu(),this.$i.Uh()}le(){return this.Su}Gn(t){this.ju(t),this.Lu(),this.$i.Wu(),this.$i.Uh()}Hu(){return this.xu}Ha(){if(this.Ni())return null;if(null!==this.gu)return this.gu;const t=this.Su,e=5*(this.$i.W().layout.fontSize+4)/8*(this.cn.tickMarkMaxCharacterLength||8),i=Math.round(e/t),s=z(this.Xs()),n=Math.max(s.Os(),s.Os()-i),r=Math.max(s.ui(),s.ui()-i),o=this.cu.su(t,e),h=this.Bu()+i,l=this.Au()-i,a=this.$u(),c=this.cn.fixLeftEdge||a,u=this.cn.fixRightEdge||a;let d=0;for(const t of o){if(!(n<=t.index&&t.index<=r))continue;let i;d<this.Mu.length?(i=this.Mu[d],i.coord=this.It(t.index),i.label=this.Uu(t),i.weight=t.weight):(i={needAlignCoordinate:!1,coord:this.It(t.index),label:this.Uu(t),weight:t.weight},this.Mu.push(i)),this.Su>e/2&&!a?i.needAlignCoordinate=!1:i.needAlignCoordinate=c&&t.index<=h||u&&t.index>=l,d++}return this.Mu.length=d,this.gu=this.Mu,this.Mu}qu(){this.vu=!0,this.Gn(this.cn.barSpacing),this.Jn(this.cn.rightOffset)}Yu(t){this.vu=!0,this._u=t,this.Lu(),this.Tu()}Zu(t,e){const i=this.Fu(t),s=this.le(),n=s+e*(s/10);this.Gn(n),this.cn.rightBarStaysOnScroll||this.Jn(this.Hu()+(i-this.Fu(t)))}Go(t){this.Mo&&this.n_(),null===this.wo&&null===this.wu&&(this.Ni()||(this.wo=t,this.Xu()))}Jo(t){if(null===this.wu)return;const e=Nt(this.__-t,0,this.__),i=Nt(this.__-z(this.wo),0,this.__);0!==e&&0!==i&&this.Gn(this.wu.le*e/i)}Qo(){null!==this.wo&&(this.wo=null,this.Ku())}t_(t){null===this.Mo&&null===this.wu&&(this.Ni()||(this.Mo=t,this.Xu()))}i_(t){if(null===this.Mo)return;const e=(this.Mo-t)/this.le();this.xu=z(this.wu).Hu+e,this.vu=!0,this.Lu()}n_(){null!==this.Mo&&(this.Mo=null,this.Ku())}Gu(){this.Ju(this.cn.rightOffset)}Ju(t,e=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(e)||e<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const i=this.xu,s=performance.now();this.$i.Zn({Qu:t=>(t-s)/e>=1,tc:n=>{const r=(n-s)/e;return r>=1?t:i+(t-i)*r}})}bt(t,e){this.vu=!0,this.uu=t,this.cu.iu(t,e),this.Lu()}nc(){return this.pu}sc(){return this.mu}ec(){return this.bu}Eu(){return this._u||0}rc(t){const e=t.G_();this.ju(this.__/e),this.xu=t.ui()-this.Eu(),this.Lu(),this.vu=!0,this.$i.Wu(),this.$i.Uh()}hc(){const t=this.Bu(),e=this.Au();null!==t&&null!==e&&this.rc(new ki(t,e+this.cn.rightOffset))}lc(t){const e=new ki(t.from,t.to);this.rc(e)}qi(t){return void 0!==this.yo.timeFormatter?this.yo.timeFormatter(t.originalTime):this.q_.formatHorzItem(t.time)}$u(){const{handleScroll:t,handleScale:e}=this.$i.W();return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||e.axisDoubleClickReset.time||e.axisPressedMouseMove.time||e.mouseWheel||e.pinch)}Bu(){return 0===this.uu.length?null:0}Au(){return 0===this.uu.length?null:this.uu.length-1}ac(t){return(this.__-1-t)/this.Su}Fu(t){const e=this.ac(t),i=this.Eu()+this.xu-e;return Math.round(1e6*i)/1e6}ju(t){const e=this.Su;this.Su=t,this.zu(),e!==this.Su&&(this.vu=!0,this.oc())}Ru(){if(!this.vu)return;if(this.vu=!1,this.Ni())return void this._c(Ti.ou());const t=this.Eu(),e=this.__/this.Su,i=this.xu+t,s=new ki(i-e+1,i);this._c(new Ti(s))}zu(){const t=this.uc();if(this.Su<t&&(this.Su=t,this.vu=!0),0!==this.__){const t=.5*this.__;this.Su>t&&(this.Su=t,this.vu=!0)}}uc(){return this.cn.fixLeftEdge&&this.cn.fixRightEdge&&0!==this.uu.length?this.__/this.uu.length:this.cn.minBarSpacing}Lu(){const t=this.cc();null!==t&&this.xu<t&&(this.xu=t,this.vu=!0);const e=this.dc();this.xu>e&&(this.xu=e,this.vu=!0)}cc(){const t=this.Bu(),e=this._u;return null===t||null===e?null:t-e-1+(this.cn.fixLeftEdge?this.__/this.Su:Math.min(2,this.uu.length))}dc(){return this.cn.fixRightEdge?0:this.__/this.Su-Math.min(2,this.uu.length)}Xu(){this.wu={le:this.le(),Hu:this.Hu()}}Ku(){this.wu=null}Uu(t){let e=this.du.get(t.weight);return void 0===e&&(e=new zi(t=>this.fc(t),this.q_),this.du.set(t.weight,e)),e.Y_(t)}fc(t){return this.q_.formatTickmark(t,this.yo)}_c(t){const e=this.fu;this.fu=t,Ri(e.lu(),this.fu.lu())||this.pu.m(),Ri(e.au(),this.fu.au())||this.mu.m(),this.oc()}oc(){this.gu=null}Cu(){this.oc(),this.du.clear()}ku(){this.q_.updateFormatter(this.yo)}Tu(){if(!this.cn.fixLeftEdge)return;const t=this.Bu();if(null===t)return;const e=this.Xs();if(null===e)return;const i=e.Os()-t;if(i<0){const t=this.xu-i-1;this.Jn(t)}this.zu()}Pu(){this.Lu(),this.zu()}}class Pi{X(t,e,i){t.useMediaCoordinateSpace(t=>this.K(t,e,i))}gl(t,e,i){t.useMediaCoordinateSpace(t=>this.vc(t,e,i))}vc(t,e,i){}}class Fi extends Pi{constructor(t){super(),this.mc=new Map,this.zt=t}K(t){}vc(t){if(!this.zt.yt)return;const{context:e,mediaSize:i}=t;let s=0;for(const t of this.zt.bc){if(0===t.Kt.length)continue;e.font=t.R;const n=this.wc(e,t.Kt);n>i.width?t.Zu=i.width/n:t.Zu=1,s+=t.gc*t.Zu}let n=0;switch(this.zt.Mc){case"top":n=0;break;case"center":n=Math.max((i.height-s)/2,0);break;case"bottom":n=Math.max(i.height-s,0)}e.fillStyle=this.zt.V;for(const t of this.zt.bc){e.save();let s=0;switch(this.zt.xc){case"left":e.textAlign="left",s=t.gc/2;break;case"center":e.textAlign="center",s=i.width/2;break;case"right":e.textAlign="right",s=i.width-1-t.gc/2}e.translate(s,n),e.textBaseline="top",e.font=t.R,e.scale(t.Zu,t.Zu),e.fillText(t.Kt,0,t.Sc),e.restore(),n+=t.gc*t.Zu}}wc(t,e){const i=this.kc(t.font);let s=i.get(e);return void 0===s&&(s=t.measureText(e).width,i.set(e,s)),s}kc(t){let e=this.mc.get(t);return void 0===e&&(e=new Map,this.mc.set(t,e)),e}}class Vi{constructor(t){this.ft=!0,this.Ft={yt:!1,V:"",bc:[],Mc:"center",xc:"center"},this.Wt=new Fi(this.Ft),this.jt=t}bt(){this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.Wt}Mt(){const t=this.jt.W(),e=this.Ft;e.yt=t.visible,e.yt&&(e.V=t.color,e.xc=t.horzAlign,e.Mc=t.vertAlign,e.bc=[{Kt:t.text,R:G(t.fontSize,t.fontFamily,t.fontStyle),gc:1.2*t.fontSize,Sc:0,Zu:0}])}}class Di extends bt{constructor(t,e){super(),this.cn=e,this.wn=new Vi(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}Vn(){this.wn.bt()}}var Ii,Bi,Ai,Wi,ji;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ii||(Ii={}));class Ui{constructor(t,e,i){this.yc=[],this.Cc=[],this.__=0,this.Tc=null,this.Pc=new B,this.Rc=new B,this.Dc=null,this.Vc=t,this.cn=e,this.q_=i,this.Oc=new Q(this),this.yl=new Oi(this,e.timeScale,this.cn.localization,i),this.vt=new wt(this,e.crosshair),this.Bc=new oi(e.crosshair),this.Ac=new Di(this,e.watermark),this.Ic(),this.yc[0].x_(2e3),this.zc=this.Lc(0),this.Ec=this.Lc(1)}Kl(){this.Nc(Mt.es())}Uh(){this.Nc(Mt.ss())}oa(){this.Nc(new Mt(1))}Gl(t){const e=this.Fc(t);this.Nc(e)}Wc(){return this.Tc}jc(t){const e=this.Tc;this.Tc=t,null!==e&&this.Gl(e.Hc),null!==t&&this.Gl(t.Hc)}W(){return this.cn}$h(t){A(this.cn,t),this.yc.forEach(e=>e.b_(t)),void 0!==t.timeScale&&this.yl.$h(t.timeScale),void 0!==t.localization&&this.yl.yu(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Pc.m(),this.zc=this.Lc(0),this.Ec=this.Lc(1),this.Kl()}$c(t,e){if("left"===t)return void this.$h({leftPriceScale:e});if("right"===t)return void this.$h({rightPriceScale:e});const i=this.Uc(t);null!==i&&(i.Dt.$h(e),this.Pc.m())}Uc(t){for(const e of this.yc){const i=e.w_(t);if(null!==i)return{Ht:e,Dt:i}}return null}St(){return this.yl}qc(){return this.yc}Yc(){return this.Ac}Zc(){return this.vt}Xc(){return this.Rc}Kc(t,e){t.Lo(e),this.Wu()}S_(t){this.__=t,this.yl.S_(this.__),this.yc.forEach(e=>e.S_(t)),this.Wu()}Ic(t){const e=new $i(this.yl,this);void 0!==t?this.yc.splice(t,0,e):this.yc.push(e);const i=void 0===t?this.yc.length-1:t,s=Mt.es();return s.Nn(i,{Fn:0,Wn:!0}),this.Nc(s),e}V_(t,e,i){t.V_(e,i)}O_(t,e,i){t.O_(e,i),this.Jl(),this.Nc(this.Gc(t,2))}B_(t,e){t.B_(e),this.Nc(this.Gc(t,2))}A_(t,e,i){e.Vo()||t.A_(e,i)}I_(t,e,i){e.Vo()||(t.I_(e,i),this.Jl(),this.Nc(this.Gc(t,2)))}z_(t,e){e.Vo()||(t.z_(e),this.Nc(this.Gc(t,2)))}E_(t,e){t.E_(e),this.Nc(this.Gc(t,2))}Jc(t){this.yl.Go(t)}Qc(t,e){const i=this.St();if(i.Ni()||0===e)return;const s=i.Hi();t=Math.max(1,Math.min(t,s)),i.Zu(t,e),this.Wu()}td(t){this.nd(0),this.sd(t),this.ed()}rd(t){this.yl.Jo(t),this.Wu()}hd(){this.yl.Qo(),this.Uh()}nd(t){this.yl.t_(t)}sd(t){this.yl.i_(t),this.Wu()}ed(){this.yl.n_(),this.Uh()}wt(){return this.Cc}ld(t,e,i,s,n){this.vt.gn(t,e);let r=NaN,o=this.yl.Nu(t);const h=this.yl.Xs();null!==h&&(o=Math.min(Math.max(h.Os(),o),h.ui()));const l=s.vn(),a=l.Ct();null!==a&&(r=l.pn(e,a)),r=this.Bc.Oa(r,o,s),this.vt.kn(o,r,s),this.oa(),n||this.Rc.m(this.vt.xt(),{x:t,y:e},i)}ad(t,e,i){const s=i.vn(),n=s.Ct(),r=s.Rt(t,z(n)),o=this.yl.Va(e,!0),h=this.yl.It(z(o));this.ld(h,r,null,i,!0)}od(t){this.Zc().Cn(),this.oa(),t||this.Rc.m(null,null,null)}Jl(){const t=this.vt.Ht();if(null!==t){const e=this.vt.xn(),i=this.vt.Sn();this.ld(e,i,null,t)}this.vt.Vn()}_d(t,e,i){const s=this.yl.mn(0);void 0!==e&&void 0!==i&&this.yl.bt(e,i);const n=this.yl.mn(0),r=this.yl.Eu(),o=this.yl.Xs();if(null!==o&&null!==s&&null!==n){const e=o.Kr(r),h=this.q_.key(s)>this.q_.key(n),l=null!==t&&t>r&&!h,a=this.yl.W().allowShiftVisibleRangeOnWhitespaceReplacement,c=e&&(!(void 0===i)||a)&&this.yl.W().shiftVisibleRangeOnNewBar;if(l&&!c){const e=t-r;this.yl.Jn(this.yl.Hu()-e)}}this.yl.Yu(t)}ia(t){null!==t&&t.F_()}dr(t){const e=this.yc.find(e=>e.Uo().includes(t));return void 0===e?null:e}Wu(){this.Ac.Vn(),this.yc.forEach(t=>t.F_()),this.Jl()}S(){this.yc.forEach(t=>t.S()),this.yc.length=0,this.cn.localization.priceFormatter=void 0,this.cn.localization.percentageFormatter=void 0,this.cn.localization.timeFormatter=void 0}ud(){return this.Oc}br(){return this.Oc.W()}g_(){return this.Pc}dd(t,e,i){const s=this.yc[0],n=this.fd(e,t,s,i);return this.Cc.push(n),1===this.Cc.length?this.Kl():this.Uh(),n}vd(t){const e=this.dr(t),i=this.Cc.indexOf(t);_(-1!==i,"Series not found"),this.Cc.splice(i,1),z(e).Zo(t),t.S&&t.S()}Xl(t,e){const i=z(this.dr(t));i.Zo(t);const s=this.Uc(e);if(null===s){const s=t.Xi();i.qo(t,e,s)}else{const n=s.Ht===i?t.Xi():void 0;s.Ht.qo(t,e,n)}}hc(){const t=Mt.ss();t.$n(),this.Nc(t)}pd(t){const e=Mt.ss();e.Yn(t),this.Nc(e)}Kn(){const t=Mt.ss();t.Kn(),this.Nc(t)}Gn(t){const e=Mt.ss();e.Gn(t),this.Nc(e)}Jn(t){const e=Mt.ss();e.Jn(t),this.Nc(e)}Zn(t){const e=Mt.ss();e.Zn(t),this.Nc(e)}Un(){const t=Mt.ss();t.Un(),this.Nc(t)}md(){return this.cn.rightPriceScale.visible?"right":"left"}bd(){return this.Ec}q(){return this.zc}Bt(t){const e=this.Ec,i=this.zc;if(e===i)return e;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Dc||this.Dc.Ps!==i||this.Dc.Rs!==e)this.Dc={Ps:i,Rs:e,wd:new Map};else{const e=this.Dc.wd.get(t);if(void 0!==e)return e}const s=function(t,e,i){const[s,n,r,o]=V(t),[h,l,a,c]=V(e),u=[L(s+i*(h-s)),L(n+i*(l-n)),L(r+i*(a-r)),T(o+i*(c-o))];return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}(i,e,t/100);return this.Dc.wd.set(t,s),s}Gc(t,e){const i=new Mt(e);if(null!==t){const s=this.yc.indexOf(t);i.Nn(s,{Fn:e})}return i}Fc(t,e){return void 0===e&&(e=2),this.Gc(this.dr(t),e)}Nc(t){this.Vc&&this.Vc(t),this.yc.forEach(t=>t.j_().qh().bt())}fd(t,e,i,s){const n=new ri(this,t,e,i,s),r=void 0!==t.priceScaleId?t.priceScaleId:this.md();return i.qo(n,r),yt(r)||n.$h(t),n}Lc(t){const e=this.cn.layout;return"gradient"===e.background.type?0===t?e.background.topColor:e.background.bottomColor:e.background.color}}function Hi(t){return!W(t)&&!U(t)}function Ki(t){return W(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Bi||(Bi={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ai||(Ai={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Wi||(Wi={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(ji||(ji={}));const qi=t=>t.getUTCFullYear();class Xi{constructor(t="yyyy-MM-dd",e="default"){this.gd=t,this.Md=e}Y_(t){return function(t,e,i){return e.replace(/yyyy/g,(t=>xt(qi(t),4))(t)).replace(/yy/g,(t=>xt(qi(t)%100,2))(t)).replace(/MMMM/g,((t,e)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(e,{month:"long"}))(t,i)).replace(/MMM/g,((t,e)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(e,{month:"short"}))(t,i)).replace(/MM/g,(t=>xt((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>xt((t=>t.getUTCDate())(t),2))(t))}(t,this.gd,this.Md)}}class Ji{constructor(t){this.xd=t||"%h:%m:%s"}Y_(t){return this.xd.replace("%h",xt(t.getUTCHours(),2)).replace("%m",xt(t.getUTCMinutes(),2)).replace("%s",xt(t.getUTCSeconds(),2))}}const Gi={Sd:"yyyy-MM-dd",kd:"%h:%m:%s",yd:" ",Cd:"default"};class Qi{constructor(t={}){const e=Object.assign(Object.assign({},Gi),t);this.Td=new Xi(e.Sd,e.Cd),this.Pd=new Ji(e.kd),this.Rd=e.yd}Y_(t){return`${this.Td.Y_(t)}${this.Rd}${this.Pd.Y_(t)}`}}function Yi(t){return 60*t*60*1e3}function Zi(t){return 60*t*1e3}const ts=[{Dd:1e3,Vd:10},{Dd:Zi(1),Vd:20},{Dd:Zi(5),Vd:21},{Dd:Zi(30),Vd:22},{Dd:Yi(1),Vd:30},{Dd:Yi(3),Vd:31},{Dd:Yi(6),Vd:32},{Dd:Yi(12),Vd:33}];function es(t,e){if(t.getUTCFullYear()!==e.getUTCFullYear())return 70;if(t.getUTCMonth()!==e.getUTCMonth())return 60;if(t.getUTCDate()!==e.getUTCDate())return 50;for(let i=ts.length-1;i>=0;--i)if(Math.floor(e.getTime()/ts[i].Dd)!==Math.floor(t.getTime()/ts[i].Dd))return ts[i].Vd;return 0}function is(t){let e=t;if(U(t)&&(e=ns(t)),!Hi(e))throw new Error("time must be of type BusinessDay");const i=new Date(Date.UTC(e.year,e.month-1,e.day,0,0,0,0));return{Od:Math.round(i.getTime()/1e3),Bd:e}}function ss(t){if(!Ki(t))throw new Error("time must be of type isUTCTimestamp");return{Od:t}}function ns(t){const e=new Date(t);if(isNaN(e.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:e.getUTCDate(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}}function rs(t){U(t.time)&&(t.time=ns(t.time))}class os{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(rs)}(t):rs(t)}createConverterToInternalObj(t){return z(function(t){return 0===t.length?null:Hi(t[0].time)||U(t[0].time)?is:ss}(t))}key(t){return"object"==typeof t&&"Od"in t?t.Od:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const e=t;return void 0===e.Bd?new Date(1e3*e.Od).getTime():new Date(Date.UTC(e.Bd.year,e.Bd.month-1,e.Bd.day)).getTime()}convertHorzItemToInternal(t){return Ki(e=t)?ss(e):Hi(e)?is(e):is(ns(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.Ad=new Qi({Sd:e,kd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",yd:" ",Cd:t.locale}):this.Ad=new Xi(e,t.locale)}formatHorzItem(t){const e=t;return this.Ad.Y_(new Date(1e3*e.Od))}formatTickmark(t,e){const i=function(t,e,i){switch(t){case 0:case 10:return e?i?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return e?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.cn.timeScale.timeVisible,this.cn.timeScale.secondsVisible),s=this.cn.timeScale;if(void 0!==s.tickMarkFormatter){const n=s.tickMarkFormatter(t.originalTime,i,e.locale);if(null!==n)return n}return function(t,e,i){const s={};switch(e){case 0:s.year="numeric";break;case 1:s.month="short";break;case 2:s.day="numeric";break;case 3:s.hour12=!1,s.hour="2-digit",s.minute="2-digit";break;case 4:s.hour12=!1,s.hour="2-digit",s.minute="2-digit",s.second="2-digit"}const n=void 0===t.Bd?new Date(1e3*t.Od):new Date(Date.UTC(t.Bd.year,t.Bd.month-1,t.Bd.day));return new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),n.getUTCMilliseconds()).toLocaleString(i,s)}(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(Ni,t[0]).weight;return e>30&&e<50&&(e=30),e}fillWeightsForPoints(t,e){!function(t,e=0){if(0===t.length)return;let i=0===e?null:t[e-1].time.Od,s=null!==i?new Date(1e3*i):null,n=0;for(let r=e;r<t.length;++r){const e=t[r],o=new Date(1e3*e.time.Od);null!==s&&(e.timeWeight=es(o,s)),n+=e.time.Od-(i||e.time.Od),i=e.time.Od,s=o}if(0===e&&t.length>1){const e=Math.ceil(n/(t.length-1)),i=new Date(1e3*(t[0].time.Od-e));t[0].timeWeight=es(new Date(1e3*t[0].time.Od),i)}}(t,e)}static Id(t){return A({localization:{dateFormat:"dd MMM 'yy"}},null!=t?t:{})}}const hs="undefined"!=typeof window;function ls(){return!!hs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function as(){return!!hs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function cs(t){return t+t%2}function us(t,e){return t.zd-e.zd}function ds(t,e,i){const s=(t.zd-e.zd)/(t.ot-e.ot);return Math.sign(s)*Math.min(Math.abs(s),i)}class fs{constructor(t,e,i,s){this.Ld=null,this.Ed=null,this.Nd=null,this.Fd=null,this.Wd=null,this.jd=0,this.Hd=0,this.$d=t,this.Ud=e,this.qd=i,this.rs=s}Yd(t,e){if(null!==this.Ld){if(this.Ld.ot===e)return void(this.Ld.zd=t);if(Math.abs(this.Ld.zd-t)<this.rs)return}this.Fd=this.Nd,this.Nd=this.Ed,this.Ed=this.Ld,this.Ld={ot:e,zd:t}}Vr(t,e){if(null===this.Ld||null===this.Ed)return;if(e-this.Ld.ot>50)return;let i=0;const s=ds(this.Ld,this.Ed,this.Ud),n=us(this.Ld,this.Ed),r=[s],o=[n];if(i+=n,null!==this.Nd){const t=ds(this.Ed,this.Nd,this.Ud);if(Math.sign(t)===Math.sign(s)){const e=us(this.Ed,this.Nd);if(r.push(t),o.push(e),i+=e,null!==this.Fd){const t=ds(this.Nd,this.Fd,this.Ud);if(Math.sign(t)===Math.sign(s)){const e=us(this.Nd,this.Fd);r.push(t),o.push(e),i+=e}}}}let h=0;for(let t=0;t<r.length;++t)h+=o[t]/i*r[t];Math.abs(h)<this.$d||(this.Wd={zd:t,ot:e},this.Hd=h,this.jd=function(t,e){const i=Math.log(e);return Math.log(1*i/-t)/i}(Math.abs(h),this.qd))}tc(t){const e=z(this.Wd),i=t-e.ot;return e.zd+this.Hd*(Math.pow(this.qd,i)-1)/Math.log(this.qd)}Qu(t){return null===this.Wd||this.Zd(t)===this.jd}Zd(t){const e=t-z(this.Wd).ot;return Math.min(e,this.jd)}}class ms{constructor(t,e){this.Xd=void 0,this.Kd=void 0,this.Gd=void 0,this.en=!1,this.Jd=t,this.Qd=e,this.tf()}bt(){this.tf()}if(){this.Xd&&this.Jd.removeChild(this.Xd),this.Kd&&this.Jd.removeChild(this.Kd),this.Xd=void 0,this.Kd=void 0}nf(){return this.en!==this.sf()||this.Gd!==this.ef()}ef(){return D(V(this.Qd.W().layout.textColor))>160?"dark":"light"}sf(){return this.Qd.W().layout.attributionLogo}rf(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}tf(){this.nf()&&(this.if(),this.en=this.sf(),this.en&&(this.Gd=this.ef(),this.Kd=document.createElement("style"),this.Kd.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.Xd=document.createElement("a"),this.Xd.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.rf()}`,this.Xd.title="Charting by TradingView",this.Xd.id="tv-attr-logo",this.Xd.target="_blank",this.Xd.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 19" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.Xd.toggleAttribute("data-dark","dark"===this.Gd),this.Jd.appendChild(this.Kd),this.Jd.appendChild(this.Xd)))}}function ps(t,e){const i=z(t.ownerDocument).createElement("canvas");t.appendChild(i);const s=(n={options:{allowResizeObserver:!1},transform:(t,e)=>({width:Math.max(t.width,e.width),height:Math.max(t.height,e.height)})},new a(i,n.transform,n.options));var n;return s.resizeCanvasElement(e),s}function gs(t){var e;t.width=1,t.height=1,null===(e=t.getContext("2d"))||void 0===e||e.clearRect(0,0,1,1)}function bs(t,e,i,s){t.gl&&t.gl(e,i,s)}function vs(t,e,i,s){t.X(e,i,s)}function ws(t,e,i,s){const n=t(i,s);for(const t of n){const i=t.gt();null!==i&&e(i)}}class ys{constructor(t,e,i){this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this.df=null,this.ff=!1,this.vf=null,this.pf=null,this.mf=!1,this.bf=!1,this.wf=!1,this.gf=null,this.Mf=null,this.xf=null,this.Sf=null,this.kf=null,this.yf=null,this.Cf=null,this.Tf=0,this.Pf=!1,this.Rf=!1,this.Df=!1,this.Vf=0,this.Of=null,this.Bf=!as(),this.Af=t=>{this.If(t)},this.zf=t=>{if(this.Lf(t)){const e=this.Ef(t);if(++this._f,this.uf&&this._f>1){const{Nf:i}=this.Ff(Ss(t),this.cf);i<30&&!this.wf&&this.Wf(e,this.Hf.jf),this.$f()}}else{const e=this.Ef(t);if(++this.hf,this.lf&&this.hf>1){const{Nf:i}=this.Ff(Ss(t),this.af);i<5&&!this.bf&&this.Uf(e,this.Hf.qf),this.Yf()}}},this.Zf=t,this.Hf=e,this.cn=i,this.Xf()}S(){null!==this.gf&&(this.gf(),this.gf=null),null!==this.Mf&&(this.Mf(),this.Mf=null),null!==this.Sf&&(this.Sf(),this.Sf=null),null!==this.kf&&(this.kf(),this.kf=null),null!==this.yf&&(this.yf(),this.yf=null),null!==this.xf&&(this.xf(),this.xf=null),this.Kf(),this.Yf()}Gf(t){this.Sf&&this.Sf();const e=this.Jf.bind(this);if(this.Sf=()=>{this.Zf.removeEventListener("mousemove",e)},this.Zf.addEventListener("mousemove",e),this.Lf(t))return;const i=this.Ef(t);this.Uf(i,this.Hf.Qf),this.Bf=!0}Yf(){null!==this.lf&&clearTimeout(this.lf),this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}$f(){null!==this.uf&&clearTimeout(this.uf),this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}Jf(t){if(this.Df||null!==this.pf)return;if(this.Lf(t))return;const e=this.Ef(t);this.Uf(e,this.Hf.tv),this.Bf=!0}iv(t){const e=Es(t.changedTouches,z(this.Of));if(null===e)return;if(this.Vf=Cs(t),null!==this.Cf)return;if(this.Rf)return;this.Pf=!0;const i=this.Ff(Ss(e),z(this.pf)),{nv:s,sv:n,Nf:r}=i;if(this.mf||!(r<5)){if(!this.mf){const t=.5*s,e=n>=t&&!this.cn.ev(),i=t>n&&!this.cn.rv();e||i||(this.Rf=!0),this.mf=!0,this.wf=!0,this.Kf(),this.$f()}if(!this.Rf){const i=this.Ef(t,e);this.Wf(i,this.Hf.hv),xs(t)}}}lv(t){if(0!==t.button)return;const e=this.Ff(Ss(t),z(this.vf)),{Nf:i}=e;if(i>=5&&(this.bf=!0,this.Yf()),this.bf){const e=this.Ef(t);this.Uf(e,this.Hf.av)}}Ff(t,e){const i=Math.abs(e.nt-t.nt),s=Math.abs(e.st-t.st);return{nv:i,sv:s,Nf:i+s}}ov(t){let e=Es(t.changedTouches,z(this.Of));if(null===e&&0===t.touches.length&&(e=t.changedTouches[0]),null===e)return;this.Of=null,this.Vf=Cs(t),this.Kf(),this.pf=null,this.yf&&(this.yf(),this.yf=null);const i=this.Ef(t,e);if(this.Wf(i,this.Hf._v),++this._f,this.uf&&this._f>1){const{Nf:t}=this.Ff(Ss(e),this.cf);t<30&&!this.wf&&this.Wf(i,this.Hf.jf),this.$f()}else this.wf||(this.Wf(i,this.Hf.uv),this.Hf.uv&&xs(t));0===this._f&&xs(t),0===t.touches.length&&this.ff&&(this.ff=!1,xs(t))}If(t){if(0!==t.button)return;const e=this.Ef(t);if(this.vf=null,this.Df=!1,this.kf&&(this.kf(),this.kf=null),ls()&&this.Zf.ownerDocument.documentElement.removeEventListener("mouseleave",this.Af),!this.Lf(t))if(this.Uf(e,this.Hf.cv),++this.hf,this.lf&&this.hf>1){const{Nf:i}=this.Ff(Ss(t),this.af);i<5&&!this.bf&&this.Uf(e,this.Hf.qf),this.Yf()}else this.bf||this.Uf(e,this.Hf.dv)}Kf(){null!==this.df&&(clearTimeout(this.df),this.df=null)}fv(t){if(null!==this.Of)return;const e=t.changedTouches[0];this.Of=e.identifier,this.Vf=Cs(t);const i=this.Zf.ownerDocument.documentElement;this.wf=!1,this.mf=!1,this.Rf=!1,this.pf=Ss(e),this.yf&&(this.yf(),this.yf=null);{const e=this.iv.bind(this),s=this.ov.bind(this);this.yf=()=>{i.removeEventListener("touchmove",e),i.removeEventListener("touchend",s)},i.addEventListener("touchmove",e,{passive:!1}),i.addEventListener("touchend",s,{passive:!1}),this.Kf(),this.df=setTimeout(this.vv.bind(this,t),240)}const s=this.Ef(t,e);this.Wf(s,this.Hf.pv),this.uf||(this._f=0,this.uf=setTimeout(this.$f.bind(this),500),this.cf=Ss(e))}mv(t){if(0!==t.button)return;const e=this.Zf.ownerDocument.documentElement;ls()&&e.addEventListener("mouseleave",this.Af),this.bf=!1,this.vf=Ss(t),this.kf&&(this.kf(),this.kf=null);{const t=this.lv.bind(this),i=this.If.bind(this);this.kf=()=>{e.removeEventListener("mousemove",t),e.removeEventListener("mouseup",i)},e.addEventListener("mousemove",t),e.addEventListener("mouseup",i)}if(this.Df=!0,this.Lf(t))return;const i=this.Ef(t);this.Uf(i,this.Hf.bv),this.lf||(this.hf=0,this.lf=setTimeout(this.Yf.bind(this),500),this.af=Ss(t))}Xf(){this.Zf.addEventListener("mouseenter",this.Gf.bind(this)),this.Zf.addEventListener("touchcancel",this.Kf.bind(this));{const t=this.Zf.ownerDocument,e=t=>{this.Hf.wv&&(t.composed&&this.Zf.contains(t.composedPath()[0])||t.target&&this.Zf.contains(t.target)||this.Hf.wv())};this.Mf=()=>{t.removeEventListener("touchstart",e)},this.gf=()=>{t.removeEventListener("mousedown",e)},t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0})}as()&&(this.xf=()=>{this.Zf.removeEventListener("dblclick",this.zf)},this.Zf.addEventListener("dblclick",this.zf)),this.Zf.addEventListener("mouseleave",this.gv.bind(this)),this.Zf.addEventListener("touchstart",this.fv.bind(this),{passive:!0}),function(t){hs&&void 0!==window.chrome&&t.addEventListener("mousedown",t=>{if(1===t.button)return t.preventDefault(),!1})}(this.Zf),this.Zf.addEventListener("mousedown",this.mv.bind(this)),this.Mv(),this.Zf.addEventListener("touchmove",()=>{},{passive:!1})}Mv(){void 0===this.Hf.xv&&void 0===this.Hf.Sv&&void 0===this.Hf.kv||(this.Zf.addEventListener("touchstart",t=>this.yv(t.touches),{passive:!0}),this.Zf.addEventListener("touchmove",t=>{if(2===t.touches.length&&null!==this.Cf&&void 0!==this.Hf.Sv){const e=Ms(t.touches[0],t.touches[1])/this.Tf;this.Hf.Sv(this.Cf,e),xs(t)}},{passive:!1}),this.Zf.addEventListener("touchend",t=>{this.yv(t.touches)}))}yv(t){1===t.length&&(this.Pf=!1),2!==t.length||this.Pf||this.ff?this.Cv():this.Tv(t)}Tv(t){const e=this.Zf.getBoundingClientRect()||{left:0,top:0};this.Cf={nt:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,st:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this.Tf=Ms(t[0],t[1]),void 0!==this.Hf.xv&&this.Hf.xv(),this.Kf()}Cv(){null!==this.Cf&&(this.Cf=null,void 0!==this.Hf.kv&&this.Hf.kv())}gv(t){if(this.Sf&&this.Sf(),this.Lf(t))return;if(!this.Bf)return;const e=this.Ef(t);this.Uf(e,this.Hf.Pv),this.Bf=!as()}vv(t){const e=Es(t.touches,z(this.Of));if(null===e)return;const i=this.Ef(t,e);this.Wf(i,this.Hf.Rv),this.wf=!0,this.ff=!0}Lf(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:Cs(t)<this.Vf+500}Wf(t,e){e&&e.call(this.Hf,t)}Uf(t,e){e&&e.call(this.Hf,t)}Ef(t,e){const i=e||t,s=this.Zf.getBoundingClientRect()||{left:0,top:0};return{clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,localX:i.clientX-s.left,localY:i.clientY-s.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Dv:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,Vv:t.type,Ov:i.target,Bv:t.view,Av:()=>{"touchstart"!==t.type&&xs(t)}}}}function Ms(t,e){const i=t.clientX-e.clientX,s=t.clientY-e.clientY;return Math.sqrt(i*i+s*s)}function xs(t){t.cancelable&&t.preventDefault()}function Ss(t){return{nt:t.pageX,st:t.pageY}}function Cs(t){return t.timeStamp||performance.now()}function Es(t,e){for(let i=0;i<t.length;++i)if(t[i].identifier===e)return t[i];return null}function _s(t){return{Hc:t.Hc,Iv:{gr:t.zv.externalId},Lv:t.zv.cursorStyle}}function $s(t,e,i){for(const s of t){const t=s.gt();if(null!==t&&t.wr){const n=t.wr(e,i);if(null!==n)return{Bv:s,Iv:n}}}return null}function zs(t,e){return i=>{var s,n,r,o;return(null!==(n=null===(s=i.Dt())||void 0===s?void 0:s.Pa())&&void 0!==n?n:"")!==e?[]:null!==(o=null===(r=i.da)||void 0===r?void 0:r.call(i,t))&&void 0!==o?o:[]}}function ks(t,e,i,s){if(!t.length)return;let n=0;const r=i/2,o=t[0].At(s,!0);let h=1===e?r-(t[0].Vi()-o/2):t[0].Vi()-o/2-r;h=Math.max(0,h);for(let r=1;r<t.length;r++){const o=t[r],l=t[r-1],a=l.At(s,!1),c=o.Vi(),u=l.Vi();if(1===e?c>u-a:c<u+a){const s=u-a*e;o.Oi(s);const r=s-e*a/2;if((1===e?r<0:r>i)&&h>0){const s=1===e?-1-r:r-i,o=Math.min(s,h);for(let i=n;i<t.length;i++)t[i].Oi(t[i].Vi()+e*o);h-=o}}else n=r,h=1===e?u-a-c:c-(u+a)}}class Rs{constructor(t,e,i,s){this.Li=null,this.Ev=null,this.Nv=!1,this.Fv=new ue(200),this.Qr=null,this.Wv=0,this.jv=!1,this.Hv=()=>{this.jv||this.tn.$v().$t().Uh()},this.Uv=()=>{this.jv||this.tn.$v().$t().Uh()},this.tn=t,this.cn=e,this.ko=e.layout,this.Oc=i,this.qv="left"===s,this.Yv=zs("normal",s),this.Zv=zs("top",s),this.Xv=zs("bottom",s),this.Kv=document.createElement("div"),this.Kv.style.height="100%",this.Kv.style.overflow="hidden",this.Kv.style.width="25px",this.Kv.style.left="0",this.Kv.style.position="relative",this.Gv=ps(this.Kv,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const n=this.Gv.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Jv=ps(this.Kv,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const r=this.Jv.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={bv:this.Qv.bind(this),pv:this.Qv.bind(this),av:this.tp.bind(this),hv:this.tp.bind(this),wv:this.ip.bind(this),cv:this.np.bind(this),_v:this.np.bind(this),qf:this.sp.bind(this),jf:this.sp.bind(this),Qf:this.ep.bind(this),Pv:this.rp.bind(this)};this.hp=new ys(this.Jv.canvasElement,h,{ev:()=>!this.cn.handleScroll.vertTouchDrag,rv:()=>!0})}S(){this.hp.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose(),null!==this.Li&&this.Li.Ko().p(this),this.Li=null}lp(){return this.Kv}P(){return this.ko.fontSize}ap(){const t=this.Oc.W();return this.Qr!==t.R&&(this.Fv.nr(),this.Qr=t.R),t}op(){if(null===this.Li)return 0;let t=0;const e=this.ap(),i=z(this.Gv.canvasElement.getContext("2d"));i.save();const s=this.Li.Ha();i.font=this._p(),s.length>0&&(t=Math.max(this.Fv.xi(i,s[0].so),this.Fv.xi(i,s[s.length-1].so)));const n=this.up();for(let e=n.length;e--;){const s=this.Fv.xi(i,n[e].Kt());s>t&&(t=s)}const r=this.Li.Ct();if(null!==r&&null!==this.Ev&&2!==(o=this.cn.crosshair).mode&&o.horzLine.visible&&o.horzLine.labelVisible){const e=this.Li.pn(1,r),s=this.Li.pn(this.Ev.height-2,r);t=Math.max(t,this.Fv.xi(i,this.Li.Fi(Math.floor(Math.min(e,s))+.11111111111111,r)),this.Fv.xi(i,this.Li.Fi(Math.ceil(Math.max(e,s))-.11111111111111,r)))}var o;i.restore();const h=t||34;return cs(Math.ceil(e.C+e.T+e.A+e.I+5+h))}cp(t){null!==this.Ev&&h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`)}dp(){return z(this.Ev).width}Gi(t){this.Li!==t&&(null!==this.Li&&this.Li.Ko().p(this),this.Li=t,t.Ko().l(this.fo.bind(this),this))}Dt(){return this.Li}nr(){const t=this.tn.fp();this.tn.$v().$t().E_(t,z(this.Dt()))}vp(t){if(null===this.Ev)return;if(1!==t){this.pp(),this.Gv.applySuggestedBitmapSize();const t=d(this.Gv);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t)}),this.tn.bp(t,this.Xv),this.wp(t),this.tn.bp(t,this.Yv),this.gp(t))}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.Mp(e),this.tn.bp(e,this.Zv))}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}bt(){var t;null===(t=this.Li)||void 0===t||t.Ha()}Qv(t){if(null===this.Li||this.Li.Ni()||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp();this.Nv=!0,e.V_(i,this.Li,t.localY)}tp(t){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp(),s=this.Li;e.O_(i,s,t.localY)}ip(){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const t=this.tn.$v().$t(),e=this.tn.fp(),i=this.Li;this.Nv&&(this.Nv=!1,t.B_(e,i))}np(t){if(null===this.Li||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp();this.Nv=!1,e.B_(i,this.Li)}sp(t){this.cn.handleScale.axisDoubleClickReset.price&&this.nr()}ep(t){null!==this.Li&&(!this.tn.$v().$t().W().handleScale.axisPressedMouseMove.price||this.Li.Mh()||this.Li.Oo()||this.kp(1))}rp(t){this.kp(0)}up(){const t=[],e=null===this.Li?void 0:this.Li;return(i=>{for(let s=0;s<i.length;++s){const n=i[s].Rn(this.tn.fp(),e);for(let e=0;e<n.length;e++)t.push(n[e])}})(this.tn.fp().Uo()),t}mp({context:t,bitmapSize:e}){const{width:i,height:s}=e,n=this.tn.fp().$t(),r=n.q(),o=n.bd();r===o?ht(t,0,0,i,s,r):ct(t,0,0,i,s,r,o)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i}){if(null===this.Ev||null===this.Li||!this.Li.W().borderVisible)return;t.fillStyle=this.Li.W().borderColor;const s=Math.max(1,Math.floor(this.ap().C*i));let n;n=this.qv?e.width-s:0,t.fillRect(n,0,s,e.height)}wp(t){if(null===this.Ev||null===this.Li)return;const e=this.Li.Ha(),i=this.Li.W(),s=this.ap(),n=this.qv?this.Ev.width-s.T:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:r,verticalPixelRatio:o})=>{t.fillStyle=i.borderColor;const h=Math.max(1,Math.floor(o)),l=Math.floor(.5*o),a=Math.round(s.T*r);t.beginPath();for(const i of e)t.rect(Math.floor(n*r),Math.round(i.Ea*o)-l,a,h);t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{var r;t.font=this._p(),t.fillStyle=null!==(r=i.textColor)&&void 0!==r?r:this.ko.textColor,t.textAlign=this.qv?"right":"left",t.textBaseline="middle";const o=this.qv?Math.round(n-s.A):Math.round(n+s.T+s.A),h=e.map(e=>this.Fv.Mi(t,e.so));for(let i=e.length;i--;){const s=e[i];t.fillText(s.so,o,s.Ea+h[i])}})}pp(){if(null===this.Ev||null===this.Li)return;const t=[],e=this.Li.Uo().slice(),i=this.tn.fp(),s=this.ap();this.Li===i.pr()&&this.tn.fp().Uo().forEach(t=>{i.vr(t)&&e.push(t)});const n=this.Li;e.forEach(e=>{e.Rn(i,n).forEach(e=>{e.Oi(null),e.Bi()&&t.push(e)})}),t.forEach(t=>t.Oi(t.ki())),this.Li.W().alignLabels&&this.yp(t,s)}yp(t,e){if(null===this.Ev)return;const i=this.Ev.height/2,s=t.filter(t=>t.ki()<=i),n=t.filter(t=>t.ki()>i);s.sort((t,e)=>e.ki()-t.ki()),n.sort((t,e)=>t.ki()-e.ki());for(const i of t){const t=Math.floor(i.At(e)/2),s=i.ki();s>-t&&s<t&&i.Oi(t),s>this.Ev.height-t&&s<this.Ev.height+t&&i.Oi(this.Ev.height-t)}ks(s,1,this.Ev.height,e),ks(n,-1,this.Ev.height,e)}gp(t){if(null===this.Ev)return;const e=this.up(),i=this.ap(),s=this.qv?"right":"left";e.forEach(e=>{e.Ai()&&e.gt(z(this.Li)).X(t,i,this.Fv,s)})}Mp(t){if(null===this.Ev||null===this.Li)return;const e=this.tn.$v().$t(),i=[],s=this.tn.fp(),n=e.Zc().Rn(s,this.Li);n.length&&i.push(n);const r=this.ap(),o=this.qv?"right":"left";i.forEach(e=>{e.forEach(e=>{e.gt(z(this.Li)).X(t,r,this.Fv,o)})})}kp(t){this.Kv.style.cursor=1===t?"ns-resize":"default"}fo(){const t=this.op();this.Wv<t&&this.tn.$v().$t().Kl(),this.Wv=t}_p(){return G(this.ko.fontSize,this.ko.fontFamily)}}function Ls(t,e){var i,s;return null!==(s=null===(i=t.ua)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function Ts(t,e){var i,s;return null!==(s=null===(i=t.Pn)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function Ns(t,e){var i,s;return null!==(s=null===(i=t.Ji)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}function Os(t,e){var i,s;return null!==(s=null===(i=t.aa)||void 0===i?void 0:i.call(t,e))&&void 0!==s?s:[]}class Ps{constructor(t,e){this.Ev=o({width:0,height:0}),this.Cp=null,this.Tp=null,this.Pp=null,this.Rp=null,this.Dp=!1,this.Vp=new B,this.Op=new B,this.Bp=0,this.Ap=!1,this.Ip=null,this.zp=!1,this.Lp=null,this.Ep=null,this.jv=!1,this.Hv=()=>{this.jv||null===this.Np||this.$i().Uh()},this.Uv=()=>{this.jv||null===this.Np||this.$i().Uh()},this.Qd=t,this.Np=e,this.Np.W_().l(this.Fp.bind(this),this,!0),this.Wp=document.createElement("td"),this.Wp.style.padding="0",this.Wp.style.position="relative";const i=document.createElement("div");i.style.width="100%",i.style.height="100%",i.style.position="relative",i.style.overflow="hidden",this.jp=document.createElement("td"),this.jp.style.padding="0",this.Hp=document.createElement("td"),this.Hp.style.padding="0",this.Wp.appendChild(i),this.Gv=ps(i,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const s=this.Gv.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Jv=ps(i,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const n=this.Jv.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.$p=document.createElement("tr"),this.$p.appendChild(this.jp),this.$p.appendChild(this.Wp),this.$p.appendChild(this.Hp),this.Up(),this.hp=new ys(this.Jv.canvasElement,this,{ev:()=>null===this.Ip&&!this.Qd.W().handleScroll.vertTouchDrag,rv:()=>null===this.Ip&&!this.Qd.W().handleScroll.horzTouchDrag})}S(){null!==this.Cp&&this.Cp.S(),null!==this.Tp&&this.Tp.S(),this.Pp=null,this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose(),null!==this.Np&&this.Np.W_().p(this),this.hp.S()}fp(){return z(this.Np)}qp(t){var e,i;null!==this.Np&&this.Np.W_().p(this),this.Np=t,null!==this.Np&&this.Np.W_().l(Ps.prototype.Fp.bind(this),this,!0),this.Up(),this.Qd.Yp().indexOf(this)===this.Qd.Yp().length-1?(this.Pp=null!==(e=this.Pp)&&void 0!==e?e:new ms(this.Wp,this.Qd),this.Pp.bt()):(null===(i=this.Pp)||void 0===i||i.if(),this.Pp=null)}$v(){return this.Qd}lp(){return this.$p}Up(){if(null!==this.Np&&(this.Zp(),0!==this.$i().wt().length)){if(null!==this.Cp){const t=this.Np.R_();this.Cp.Gi(z(t))}if(null!==this.Tp){const t=this.Np.D_();this.Tp.Gi(z(t))}}}Xp(){null!==this.Cp&&this.Cp.bt(),null!==this.Tp&&this.Tp.bt()}M_(){return null!==this.Np?this.Np.M_():0}x_(t){this.Np&&this.Np.x_(t)}Qf(t){if(!this.Np)return;this.Kp();const e=t.localX,i=t.localY;this.Gp(e,i,t)}bv(t){this.Kp(),this.Jp(),this.Gp(t.localX,t.localY,t)}tv(t){var e;if(!this.Np)return;this.Kp();const i=t.localX,s=t.localY;this.Gp(i,s,t);const n=this.wr(i,s);this.Qd.Qp(null!==(e=null==n?void 0:n.Lv)&&void 0!==e?e:null),this.$i().jc(n&&{Hc:n.Hc,Iv:n.Iv})}dv(t){null!==this.Np&&(this.Kp(),this.tm(t))}qf(t){null!==this.Np&&this.im(this.Op,t)}jf(t){this.qf(t)}av(t){this.Kp(),this.nm(t),this.Gp(t.localX,t.localY,t)}cv(t){null!==this.Np&&(this.Kp(),this.Ap=!1,this.sm(t))}uv(t){null!==this.Np&&this.tm(t)}Rv(t){if(this.Ap=!0,null===this.Ip){const e={x:t.localX,y:t.localY};this.rm(e,e,t)}}Pv(t){null!==this.Np&&(this.Kp(),this.Np.$t().jc(null),this.hm())}lm(){return this.Vp}am(){return this.Op}xv(){this.Bp=1,this.$i().Un()}Sv(t,e){if(!this.Qd.W().handleScale.pinch)return;const i=5*(e-this.Bp);this.Bp=e,this.$i().Qc(t.nt,i)}pv(t){this.Ap=!1,this.zp=null!==this.Ip,this.Jp();const e=this.$i().Zc();null!==this.Ip&&e.yt()&&(this.Lp={x:e.Yt(),y:e.Zt()},this.Ip={x:t.localX,y:t.localY})}hv(t){if(null===this.Np)return;const e=t.localX,i=t.localY;if(null===this.Ip)this.nm(t);else{this.zp=!1;const s=z(this.Lp),n=s.x+(e-this.Ip.x),r=s.y+(i-this.Ip.y);this.Gp(n,r,t)}}_v(t){0===this.$v().W().trackingMode.exitMode&&(this.zp=!0),this.om(),this.sm(t)}wr(t,e){const i=this.Np;return null===i?null:function(t,e,i){const s=t.Uo(),n=function(t,e,i){var s,n;let r,o;for(const a of t){const t=null!==(n=null===(s=a.va)||void 0===s?void 0:s.call(a,e,i))&&void 0!==n?n:[];for(const e of t)h=e.zOrder,(!(l=null==r?void 0:r.zOrder)||"top"===h&&"top"!==l||"normal"===h&&"bottom"===l)&&(r=e,o=a)}var h,l;return r&&o?{zv:r,Hc:o}:null}(s,e,i);if("top"===(null==n?void 0:n.zv.zOrder))return _s(n);for(const r of s){if(n&&n.Hc===r&&"bottom"!==n.zv.zOrder&&!n.zv.isBackground)return _s(n);const s=$s(r.Pn(t),e,i);if(null!==s)return{Hc:r,Bv:s.Bv,Iv:s.Iv};if(n&&n.Hc===r&&"bottom"!==n.zv.zOrder&&n.zv.isBackground)return _s(n)}return(null==n?void 0:n.zv)?_s(n):null}(i,t,e)}_m(t,e){z("left"===e?this.Cp:this.Tp).cp(o({width:t,height:this.Ev.height}))}um(){return this.Ev}cp(t){h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Wp.style.width=t.width+"px",this.Wp.style.height=t.height+"px")}dm(){const t=z(this.Np);t.P_(t.R_()),t.P_(t.D_());for(const e of t.Ba())if(t.vr(e)){const i=e.Dt();null!==i&&t.P_(i),e.Vn()}}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(0===t)return;if(null===this.Np)return;if(t>1&&this.dm(),null!==this.Cp&&this.Cp.vp(t),null!==this.Tp&&this.Tp.vp(t),1!==t){this.Gv.applySuggestedBitmapSize();const t=d(this.Gv);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.mp(t)}),this.Np&&(this.fm(t,Ls),this.vm(t),this.pm(t),this.fm(t,Ts),this.fm(t,Ns)))}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.bm(e),this.fm(e,Os))}wm(){return this.Cp}gm(){return this.Tp}bp(t,e){this.fm(t,e)}Fp(){null!==this.Np&&this.Np.W_().p(this),this.Np=null}tm(t){this.im(this.Vp,t)}im(t,e){const i=e.localX,s=e.localY;t.M()&&t.m(this.$i().St().Nu(i),{x:i,y:s},e)}mp({context:t,bitmapSize:e}){const{width:i,height:s}=e,n=this.$i(),r=n.q(),o=n.bd();r===o?ht(t,0,0,i,s,o):ct(t,0,0,i,s,r,o)}vm(t){const e=z(this.Np).j_().qh().gt();null!==e&&e.X(t,!1)}pm(t){const e=this.$i().Yc();this.Mm(t,Ts,bs,e),this.Mm(t,Ts,vs,e)}bm(t){this.Mm(t,Ts,vs,this.$i().Zc())}fm(t,e){const i=z(this.Np).Uo();for(const s of i)this.Mm(t,e,bs,s);for(const s of i)this.Mm(t,e,vs,s)}Mm(t,e,i,s){const n=z(this.Np),r=n.$t().Wc(),o=null!==r&&r.Hc===s,h=null!==r&&o&&void 0!==r.Iv?r.Iv.Mr:void 0;ws(e,e=>i(e,t,o,h),s,n)}Zp(){if(null===this.Np)return;const t=this.Qd,e=this.Np.R_().W().visible,i=this.Np.D_().W().visible;e||null===this.Cp||(this.jp.removeChild(this.Cp.lp()),this.Cp.S(),this.Cp=null),i||null===this.Tp||(this.Hp.removeChild(this.Tp.lp()),this.Tp.S(),this.Tp=null);const s=t.$t().ud();e&&null===this.Cp&&(this.Cp=new Rs(this,t.W(),s,"left"),this.jp.appendChild(this.Cp.lp())),i&&null===this.Tp&&(this.Tp=new Rs(this,t.W(),s,"right"),this.Hp.appendChild(this.Tp.lp()))}xm(t){return t.Dv&&this.Ap||null!==this.Ip}Sm(t){return Math.max(0,Math.min(t,this.Ev.width-1))}km(t){return Math.max(0,Math.min(t,this.Ev.height-1))}Gp(t,e,i){this.$i().ld(this.Sm(t),this.km(e),i,z(this.Np))}hm(){this.$i().od()}om(){this.zp&&(this.Ip=null,this.hm())}rm(t,e,i){this.Ip=t,this.zp=!1,this.Gp(e.x,e.y,i);const s=this.$i().Zc();this.Lp={x:s.Yt(),y:s.Zt()}}$i(){return this.Qd.$t()}sm(t){if(!this.Dp)return;const e=this.$i(),i=this.fp();if(e.z_(i,i.vn()),this.Rp=null,this.Dp=!1,e.ed(),null!==this.Ep){const t=performance.now(),i=e.St();this.Ep.Vr(i.Hu(),t),this.Ep.Qu(t)||e.Zn(this.Ep)}}Kp(){this.Ip=null}Jp(){if(this.Np){if(this.$i().Un(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)z(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Np.vn().Ni()&&this.$i().St().Ni()}}nm(t){if(null===this.Np)return;const e=this.$i(),i=e.St();if(i.Ni())return;const s=this.Qd.W(),n=s.handleScroll,r=s.kineticScroll;if((!n.pressedMouseMove||t.Dv)&&(!n.horzTouchDrag&&!n.vertTouchDrag||!t.Dv))return;const o=this.Np.vn(),h=performance.now();if(null!==this.Rp||this.xm(t)||(this.Rp={x:t.clientX,y:t.clientY,Od:h,ym:t.localX,Cm:t.localY}),null!==this.Rp&&!this.Dp&&(this.Rp.x!==t.clientX||this.Rp.y!==t.clientY)){if(t.Dv&&r.touch||!t.Dv&&r.mouse){const t=i.le();this.Ep=new fs(.2/t,7/t,.997,15/t),this.Ep.Yd(i.Hu(),this.Rp.Od)}else this.Ep=null;o.Ni()||e.A_(this.Np,o,t.localY),e.nd(t.localX),this.Dp=!0}this.Dp&&(o.Ni()||e.I_(this.Np,o,t.localY),e.sd(t.localX),null!==this.Ep&&this.Ep.Yd(i.Hu(),h))}}class Fs{constructor(t,e,i,s,n){this.ft=!0,this.Ev=o({width:0,height:0}),this.Hv=()=>this.vp(3),this.qv="left"===t,this.Oc=i.ud,this.cn=e,this.Tm=s,this.Pm=n,this.Kv=document.createElement("div"),this.Kv.style.width="25px",this.Kv.style.height="100%",this.Kv.style.overflow="hidden",this.Gv=ps(this.Kv,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv)}S(){this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Kv}um(){return this.Ev}cp(t){h(this.Ev,t)||(this.Ev=t,this.Gv.resizeCanvasElement(t),this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`,this.ft=!0)}vp(t){if(t<3&&!this.ft)return;if(0===this.Ev.width||0===this.Ev.height)return;this.ft=!1,this.Gv.applySuggestedBitmapSize();const e=d(this.Gv);null!==e&&e.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t)})}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:s}){if(!this.Tm())return;t.fillStyle=this.cn.timeScale.borderColor;const n=Math.floor(this.Oc.W().C*i),r=Math.floor(this.Oc.W().C*s),o=this.qv?e.width-n:0;t.fillRect(o,0,n,r)}mp({context:t,bitmapSize:e}){ht(t,0,0,e.width,e.height,this.Pm())}}function Vs(t){return e=>{var i,s;return null!==(s=null===(i=e.fa)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:[]}}const Ds=Vs("normal"),Is=Vs("top"),Bs=Vs("bottom");class As{constructor(t,e){this.Rm=null,this.Dm=null,this.k=null,this.Vm=!1,this.Ev=o({width:0,height:0}),this.Om=new B,this.Fv=new ue(5),this.jv=!1,this.Hv=()=>{this.jv||this.Qd.$t().Uh()},this.Uv=()=>{this.jv||this.Qd.$t().Uh()},this.Qd=t,this.q_=e,this.cn=t.W().layout,this.Xd=document.createElement("tr"),this.Bm=document.createElement("td"),this.Bm.style.padding="0",this.Am=document.createElement("td"),this.Am.style.padding="0",this.Kv=document.createElement("td"),this.Kv.style.height="25px",this.Kv.style.padding="0",this.Im=document.createElement("div"),this.Im.style.width="100%",this.Im.style.height="100%",this.Im.style.position="relative",this.Im.style.overflow="hidden",this.Kv.appendChild(this.Im),this.Gv=ps(this.Im,o({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const i=this.Gv.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Jv=ps(this.Im,o({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const s=this.Jv.canvasElement;s.style.position="absolute",s.style.zIndex="2",s.style.left="0",s.style.top="0",this.Xd.appendChild(this.Bm),this.Xd.appendChild(this.Kv),this.Xd.appendChild(this.Am),this.zm(),this.Qd.$t().g_().l(this.zm.bind(this),this),this.hp=new ys(this.Jv.canvasElement,this,{ev:()=>!0,rv:()=>!this.Qd.W().handleScroll.horzTouchDrag})}S(){this.hp.S(),null!==this.Rm&&this.Rm.S(),null!==this.Dm&&this.Dm.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),gs(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),gs(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Xd}Lm(){return this.Rm}Em(){return this.Dm}bv(t){if(this.Vm)return;this.Vm=!0;const e=this.Qd.$t();!e.St().Ni()&&this.Qd.W().handleScale.axisPressedMouseMove.time&&e.Jc(t.localX)}pv(t){this.bv(t)}wv(){const t=this.Qd.$t();!t.St().Ni()&&this.Vm&&(this.Vm=!1,this.Qd.W().handleScale.axisPressedMouseMove.time&&t.hd())}av(t){const e=this.Qd.$t();!e.St().Ni()&&this.Qd.W().handleScale.axisPressedMouseMove.time&&e.rd(t.localX)}hv(t){this.av(t)}cv(){this.Vm=!1;const t=this.Qd.$t();t.St().Ni()&&!this.Qd.W().handleScale.axisPressedMouseMove.time||t.hd()}_v(){this.cv()}qf(){this.Qd.W().handleScale.axisDoubleClickReset.time&&this.Qd.$t().Kn()}jf(){this.qf()}Qf(){this.Qd.$t().W().handleScale.axisPressedMouseMove.time&&this.kp(1)}Pv(){this.kp(0)}um(){return this.Ev}Nm(){return this.Om}Fm(t,e,i){h(this.Ev,t)||(this.Ev=t,this.jv=!0,this.Gv.resizeCanvasElement(t),this.Jv.resizeCanvasElement(t),this.jv=!1,this.Kv.style.width=`${t.width}px`,this.Kv.style.height=`${t.height}px`,this.Om.m(t)),null!==this.Rm&&this.Rm.cp(o({width:e,height:t.height})),null!==this.Dm&&this.Dm.cp(o({width:i,height:t.height}))}Wm(){const t=this.jm();return Math.ceil(t.C+t.T+t.P+t.L+t.B+t.Hm)}bt(){this.Qd.$t().St().Ha()}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const s=this.xp();s.width>0&&s.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(0===t)return;if(1!==t){this.Gv.applySuggestedBitmapSize();const e=d(this.Gv);null!==e&&(e.useBitmapCoordinateSpace(t=>{this.mp(t),this.Ie(t),this.$m(e,Bs)}),this.wp(e),this.$m(e,Ds)),null!==this.Rm&&this.Rm.vp(t),null!==this.Dm&&this.Dm.vp(t)}this.Jv.applySuggestedBitmapSize();const e=d(this.Jv);null!==e&&(e.useBitmapCoordinateSpace(({context:t,bitmapSize:e})=>{t.clearRect(0,0,e.width,e.height)}),this.Um([...this.Qd.$t().wt(),this.Qd.$t().Zc()],e),this.$m(e,Is))}$m(t,e){const i=this.Qd.$t().wt();for(const s of i)ws(e,e=>bs(e,t,!1,void 0),s,void 0);for(const s of i)ws(e,e=>vs(e,t,!1,void 0),s,void 0)}mp({context:t,bitmapSize:e}){ht(t,0,0,e.width,e.height,this.Qd.$t().bd())}Ie({context:t,bitmapSize:e,verticalPixelRatio:i}){if(this.Qd.W().timeScale.borderVisible){t.fillStyle=this.qm();const s=Math.max(1,Math.floor(this.jm().C*i));t.fillRect(0,0,e.width,s)}}wp(t){const e=this.Qd.$t().St(),i=e.Ha();if(!i||0===i.length)return;const s=this.q_.maxTickMarkWeight(i),n=this.jm(),r=e.W();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:e,verticalPixelRatio:s})=>{t.strokeStyle=this.qm(),t.fillStyle=this.qm();const r=Math.max(1,Math.floor(e)),o=Math.floor(.5*e);t.beginPath();const h=Math.round(n.T*s);for(let s=i.length;s--;){const n=Math.round(i[s].coord*e);t.rect(n-o,0,r,h)}t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{const e=n.C+n.T+n.L+n.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.$(),t.font=this._p();for(const n of i)if(n.weight<s){const i=n.needAlignCoordinate?this.Ym(t,n.coord,n.label):n.coord;t.fillText(n.label,i,e)}this.Qd.W().timeScale.allowBoldLabels&&(t.font=this.Zm());for(const n of i)if(n.weight>=s){const i=n.needAlignCoordinate?this.Ym(t,n.coord,n.label):n.coord;t.fillText(n.label,i,e)}})}Ym(t,e,i){const s=this.Fv.xi(t,i),n=s/2,r=Math.floor(e-n)+.5;return r<0?e+=Math.abs(0-r):r+s>this.Ev.width&&(e-=Math.abs(this.Ev.width-(r+s))),e}Um(t,e){const i=this.jm();for(const s of t)for(const t of s.Qi())t.gt().X(e,i)}qm(){return this.Qd.W().timeScale.borderColor}$(){return this.cn.textColor}j(){return this.cn.fontSize}_p(){return G(this.j(),this.cn.fontFamily)}Zm(){return G(this.j(),this.cn.fontFamily,"bold")}jm(){null===this.k&&(this.k={C:1,N:NaN,L:NaN,B:NaN,ji:NaN,T:5,P:NaN,R:"",Wi:new ue,Hm:0});const t=this.k,e=this._p();if(t.R!==e){const i=this.j();t.P=i,t.R=e,t.L=3*i/12,t.B=3*i/12,t.ji=9*i/12,t.N=0,t.Hm=4*i/12,t.Wi.nr()}return this.k}kp(t){this.Kv.style.cursor=1===t?"ew-resize":"default"}zm(){const t=this.Qd.$t(),e=t.W();e.leftPriceScale.visible||null===this.Rm||(this.Bm.removeChild(this.Rm.lp()),this.Rm.S(),this.Rm=null),e.rightPriceScale.visible||null===this.Dm||(this.Am.removeChild(this.Dm.lp()),this.Dm.S(),this.Dm=null);const i={ud:this.Qd.$t().ud()},s=()=>e.leftPriceScale.borderVisible&&t.St().W().borderVisible,n=()=>t.bd();e.leftPriceScale.visible&&null===this.Rm&&(this.Rm=new Fs("left",e,i,s,n),this.Bm.appendChild(this.Rm.lp())),e.rightPriceScale.visible&&null===this.Dm&&(this.Dm=new Fs("right",e,i,s,n),this.Am.appendChild(this.Dm.lp()))}}const Ws=!!hs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(t=>t.brand.includes("Chromium"))&&!!hs&&((null===(js=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===js?void 0:js.platform)?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);var js;class Us{constructor(t,e,i){var s;this.Xm=[],this.Km=0,this.ho=0,this.__=0,this.Gm=0,this.Jm=0,this.Qm=null,this.tb=!1,this.Vp=new B,this.Op=new B,this.Rc=new B,this.ib=null,this.nb=null,this.Jd=t,this.cn=e,this.q_=i,this.Xd=document.createElement("div"),this.Xd.classList.add("tv-lightweight-charts"),this.Xd.style.overflow="hidden",this.Xd.style.direction="ltr",this.Xd.style.width="100%",this.Xd.style.height="100%",(s=this.Xd).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.sb=document.createElement("table"),this.sb.setAttribute("cellspacing","0"),this.Xd.appendChild(this.sb),this.eb=this.rb.bind(this),Hs(this.cn)&&this.hb(!0),this.$i=new Ui(this.Vc.bind(this),this.cn,i),this.$t().Xc().l(this.lb.bind(this),this),this.ab=new As(this,this.q_),this.sb.appendChild(this.ab.lp());const n=e.autoSize&&this.ob();let r=this.cn.width,o=this.cn.height;if(n||0===r||0===o){const e=t.getBoundingClientRect();r=r||e.width,o=o||e.height}this._b(r,o),this.ub(),t.appendChild(this.Xd),this.cb(),this.$i.St().ec().l(this.$i.Kl.bind(this.$i),this),this.$i.g_().l(this.$i.Kl.bind(this.$i),this)}$t(){return this.$i}W(){return this.cn}Yp(){return this.Xm}fb(){return this.ab}S(){this.hb(!1),0!==this.Km&&window.cancelAnimationFrame(this.Km),this.$i.Xc().p(this),this.$i.St().ec().p(this),this.$i.g_().p(this),this.$i.S();for(const t of this.Xm)this.sb.removeChild(t.lp()),t.lm().p(this),t.am().p(this),t.S();this.Xm=[],z(this.ab).S(),null!==this.Xd.parentElement&&this.Xd.parentElement.removeChild(this.Xd),this.Rc.S(),this.Vp.S(),this.Op.S(),this.pb()}_b(t,e,i=!1){if(this.ho===e&&this.__===t)return;const s=function(t){const e=Math.floor(t.width),i=Math.floor(t.height);return o({width:e-e%2,height:i-i%2})}(o({width:t,height:e}));this.ho=s.height,this.__=s.width;const n=this.ho+"px",r=this.__+"px";z(this.Xd).style.height=n,z(this.Xd).style.width=r,this.sb.style.height=n,this.sb.style.width=r,i?this.mb(Mt.es(),performance.now()):this.$i.Kl()}vp(t){void 0===t&&(t=Mt.es());for(let e=0;e<this.Xm.length;e++)this.Xm[e].vp(t.Hn(e).Fn);this.cn.timeScale.visible&&this.ab.vp(t.jn())}$h(t){const e=Hs(this.cn);this.$i.$h(t);const i=Hs(this.cn);i!==e&&this.hb(i),this.cb(),this.bb(t)}lm(){return this.Vp}am(){return this.Op}Xc(){return this.Rc}wb(){null!==this.Qm&&(this.mb(this.Qm,performance.now()),this.Qm=null);const t=this.gb(null),e=document.createElement("canvas");e.width=t.width,e.height=t.height;const i=z(e.getContext("2d"));return this.gb(i),e}Mb(t){return("left"!==t||this.xb())&&("right"!==t||this.Sb())?0===this.Xm.length?0:z("left"===t?this.Xm[0].wm():this.Xm[0].gm()).dp():0}kb(){return this.cn.autoSize&&null!==this.ib}yb(){return this.Xd}Qp(t){this.nb=t,this.nb?this.yb().style.setProperty("cursor",t):this.yb().style.removeProperty("cursor")}Cb(){return this.nb}Tb(){return $(this.Xm[0]).um()}bb(t){(void 0!==t.autoSize||!this.ib||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.ib&&this.ob(),!1===t.autoSize&&null!==this.ib&&this.pb(),t.autoSize||void 0===t.width&&void 0===t.height||this._b(t.width||this.__,t.height||this.ho))}gb(t){let e=0,i=0;const s=this.Xm[0],n=(e,i)=>{let s=0;for(let n=0;n<this.Xm.length;n++){const r=this.Xm[n],o=z("left"===e?r.wm():r.gm()),h=o.xp();null!==t&&o.Sp(t,i,s),s+=h.height}};this.xb()&&(n("left",0),e+=z(s.wm()).xp().width);for(let s=0;s<this.Xm.length;s++){const n=this.Xm[s],r=n.xp();null!==t&&n.Sp(t,e,i),i+=r.height}e+=s.xp().width,this.Sb()&&(n("right",e),e+=z(s.gm()).xp().width);const r=(e,i,s)=>{z("left"===e?this.ab.Lm():this.ab.Em()).Sp(z(t),i,s)};if(this.cn.timeScale.visible){const e=this.ab.xp();if(null!==t){let n=0;this.xb()&&(r("left",n,i),n=z(s.wm()).xp().width),this.ab.Sp(t,n,i),n+=e.width,this.Sb()&&r("right",n,i)}i+=e.height}return o({width:e,height:i})}Pb(){let t=0,e=0,i=0;for(const s of this.Xm)this.xb()&&(e=Math.max(e,z(s.wm()).op(),this.cn.leftPriceScale.minimumWidth)),this.Sb()&&(i=Math.max(i,z(s.gm()).op(),this.cn.rightPriceScale.minimumWidth)),t+=s.M_();e=cs(e),i=cs(i);const s=this.__,n=this.ho,r=Math.max(s-e-i,0),h=this.cn.timeScale.visible;let l=h?Math.max(this.ab.Wm(),this.cn.timeScale.minimumHeight):0;var a;l=(a=l)+a%2;const c=0+l,u=n<c?0:n-c,d=u/t;let f=0;for(let t=0;t<this.Xm.length;++t){const s=this.Xm[t];s.qp(this.$i.qc()[t]);let n=0,h=0;h=t===this.Xm.length-1?u-f:Math.round(s.M_()*d),n=Math.max(h,2),f+=n,s.cp(o({width:r,height:n})),this.xb()&&s._m(e,"left"),this.Sb()&&s._m(i,"right"),s.fp()&&this.$i.Kc(s.fp(),n)}this.ab.Fm(o({width:h?r:0,height:l}),h?e:0,h?i:0),this.$i.S_(r),this.Gm!==e&&(this.Gm=e),this.Jm!==i&&(this.Jm=i)}hb(t){t?this.Xd.addEventListener("wheel",this.eb,{passive:!1}):this.Xd.removeEventListener("wheel",this.eb)}Rb(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Ws?1/window.devicePixelRatio:1}rb(t){if(!(0!==t.deltaX&&this.cn.handleScroll.mouseWheel||0!==t.deltaY&&this.cn.handleScale.mouseWheel))return;const e=this.Rb(t),i=e*t.deltaX/100,s=-e*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==s&&this.cn.handleScale.mouseWheel){const e=Math.sign(s)*Math.min(1,Math.abs(s)),i=t.clientX-this.Xd.getBoundingClientRect().left;this.$t().Qc(i,e)}0!==i&&this.cn.handleScroll.mouseWheel&&this.$t().td(-80*i)}mb(t,e){var i;const s=t.jn();3===s&&this.Db(),3!==s&&2!==s||(this.Vb(t),this.Ob(t,e),this.ab.bt(),this.Xm.forEach(t=>{t.Xp()}),3===(null===(i=this.Qm)||void 0===i?void 0:i.jn())&&(this.Qm.ts(t),this.Db(),this.Vb(this.Qm),this.Ob(this.Qm,e),t=this.Qm,this.Qm=null)),this.vp(t)}Ob(t,e){for(const i of t.Qn())this.ns(i,e)}Vb(t){const e=this.$i.qc();for(let i=0;i<e.length;i++)t.Hn(i).Wn&&e[i].N_()}ns(t,e){const i=this.$i.St();switch(t.qn){case 0:i.hc();break;case 1:i.lc(t.Vt);break;case 2:i.Gn(t.Vt);break;case 3:i.Jn(t.Vt);break;case 4:i.qu();break;case 5:t.Vt.Qu(e)||i.Jn(t.Vt.tc(e))}}Vc(t){null!==this.Qm?this.Qm.ts(t):this.Qm=t,this.tb||(this.tb=!0,this.Km=window.requestAnimationFrame(t=>{if(this.tb=!1,this.Km=0,null!==this.Qm){const e=this.Qm;this.Qm=null,this.mb(e,t);for(const i of e.Qn())if(5===i.qn&&!i.Vt.Qu(t)){this.$t().Zn(i.Vt);break}}}))}Db(){this.ub()}ub(){const t=this.$i.qc(),e=t.length,i=this.Xm.length;for(let t=e;t<i;t++){const t=$(this.Xm.pop());this.sb.removeChild(t.lp()),t.lm().p(this),t.am().p(this),t.S()}for(let s=i;s<e;s++){const e=new Ps(this,t[s]);e.lm().l(this.Bb.bind(this),this),e.am().l(this.Ab.bind(this),this),this.Xm.push(e),this.sb.insertBefore(e.lp(),this.ab.lp())}for(let i=0;i<e;i++){const e=t[i],s=this.Xm[i];s.fp()!==e?s.qp(e):s.Up()}this.cb(),this.Pb()}Ib(t,e,i){var s;const n=new Map;let r;if(null!==t&&this.$i.wt().forEach(e=>{const i=e.In().ll(t);null!==i&&n.set(e,i)}),null!==t){const e=null===(s=this.$i.St().Ui(t))||void 0===s?void 0:s.originalTime;void 0!==e&&(r=e)}const o=this.$t().Wc(),h=null!==o&&o.Hc instanceof ri?o.Hc:void 0,l=null!==o&&void 0!==o.Iv?o.Iv.gr:void 0;return{zb:r,ee:null!=t?t:void 0,Lb:null!=e?e:void 0,Eb:h,Nb:n,Fb:l,Wb:null!=i?i:void 0}}Bb(t,e,i){this.Vp.m(()=>this.Ib(t,e,i))}Ab(t,e,i){this.Op.m(()=>this.Ib(t,e,i))}lb(t,e,i){this.Rc.m(()=>this.Ib(t,e,i))}cb(){const t=this.cn.timeScale.visible?"":"none";this.ab.lp().style.display=t}xb(){return this.Xm[0].fp().R_().W().visible}Sb(){return this.Xm[0].fp().D_().W().visible}ob(){return"ResizeObserver"in window&&(this.ib=new ResizeObserver(t=>{const e=t.find(t=>t.target===this.Jd);e&&this._b(e.contentRect.width,e.contentRect.height)}),this.ib.observe(this.Jd,{box:"border-box"}),!0)}pb(){null!==this.ib&&this.ib.disconnect(),this.ib=null}}function Hs(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Ks(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}function qs(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.color&&(r.V=i.color),r}function Xs(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.lineColor&&(r.lt=i.lineColor),void 0!==i.topColor&&(r.Ps=i.topColor),void 0!==i.bottomColor&&(r.Rs=i.bottomColor),r}function Js(t,e,i,s){const n=i.value,r={ee:e,ot:t,Vt:[n,n,n,n],zb:s};return void 0!==i.topLineColor&&(r.Re=i.topLineColor),void 0!==i.bottomLineColor&&(r.De=i.bottomLineColor),void 0!==i.topFillColor1&&(r.ke=i.topFillColor1),void 0!==i.topFillColor2&&(r.ye=i.topFillColor2),void 0!==i.bottomFillColor1&&(r.Ce=i.bottomFillColor1),void 0!==i.bottomFillColor2&&(r.Te=i.bottomFillColor2),r}function Gs(t,e,i,s){const n={ee:e,ot:t,Vt:[i.open,i.high,i.low,i.close],zb:s};return void 0!==i.color&&(n.V=i.color),n}function Qs(t,e,i,s){const n={ee:e,ot:t,Vt:[i.open,i.high,i.low,i.close],zb:s};return void 0!==i.color&&(n.V=i.color),void 0!==i.borderColor&&(n.Ot=i.borderColor),void 0!==i.wickColor&&(n.Xh=i.wickColor),n}function Ys(t,e,i,s,n){const r=$(n)(i),o=Math.max(...r),h=Math.min(...r),l=r[r.length-1],a=[l,o,h,l],c=i,{time:u,color:d}=c;return{ee:e,ot:t,Vt:a,zb:s,$e:Ks(c,["time","color"]),V:d}}function Zs(t){return void 0!==t.Vt}function tn(t,e){return void 0!==e.customValues&&(t.jb=e.customValues),t}function en(t){return(e,i,s,n,r,o)=>function(t,e){return e?e(t):void 0===(i=t).open&&void 0===i.value;var i}(s,o)?tn({ot:e,ee:i,zb:n},s):tn(t(e,i,s,n,r),s)}function sn(t){return{Candlestick:en(Qs),Bar:en(Gs),Area:en(Xs),Baseline:en(Js),Histogram:en(qs),Line:en(qs),Custom:en(Ys)}[t]}function nn(t){return{ee:0,Hb:new Map,la:t}}function rn(t,e){if(void 0!==t&&0!==t.length)return{$b:e.key(t[0].ot),Ub:e.key(t[t.length-1].ot)}}function on(t){let e;return t.forEach(t=>{void 0===e&&(e=t.zb)}),$(e)}class hn{constructor(t){this.qb=new Map,this.Yb=new Map,this.Zb=new Map,this.Xb=[],this.q_=t}S(){this.qb.clear(),this.Yb.clear(),this.Zb.clear(),this.Xb=[]}Kb(t,e){let i=0!==this.qb.size,s=!1;const n=this.Yb.get(t);if(void 0!==n)if(1===this.Yb.size)i=!1,s=!0,this.qb.clear();else for(const e of this.Xb)e.pointData.Hb.delete(t)&&(s=!0);let r=[];if(0!==e.length){const i=e.map(t=>t.time),n=this.q_.createConverterToInternalObj(e),o=sn(t.Qh()),h=t.Ca(),l=t.Ta();r=e.map((e,r)=>{const a=n(e.time),c=this.q_.key(a);let u=this.qb.get(c);void 0===u&&(u=nn(a),this.qb.set(c,u),s=!0);const d=o(a,u.ee,e,i[r],h,l);return u.Hb.set(t,d),d})}i&&this.Gb(),this.Jb(t,r);let o=-1;if(s){const t=[];this.qb.forEach(e=>{t.push({timeWeight:0,time:e.la,pointData:e,originalTime:on(e.Hb)})}),t.sort((t,e)=>this.q_.key(t.time)-this.q_.key(e.time)),o=this.Qb(t)}return this.tw(t,o,function(t,e,i){const s=rn(t,i),n=rn(e,i);if(void 0!==s&&void 0!==n)return{ta:s.Ub>=n.Ub&&s.$b>=n.$b}}(this.Yb.get(t),n,this.q_))}vd(t){return this.Kb(t,[])}iw(t,e){const i=e;!function(t){void 0===t.zb&&(t.zb=t.time)}(i),this.q_.preprocessData(e);const s=this.q_.createConverterToInternalObj([e])(e.time),n=this.Zb.get(t);if(void 0!==n&&this.q_.key(s)<this.q_.key(n))throw new Error(`Cannot update oldest data, last time=${n}, new time=${s}`);let r=this.qb.get(this.q_.key(s));const o=void 0===r;void 0===r&&(r=nn(s),this.qb.set(this.q_.key(s),r));const h=sn(t.Qh()),l=t.Ca(),a=t.Ta(),c=h(s,r.ee,e,i.zb,l,a);r.Hb.set(t,c),this.nw(t,c);const u={ta:Zs(c)};if(!o)return this.tw(t,-1,u);const d={timeWeight:0,time:r.la,pointData:r,originalTime:on(r.Hb)},f=Wt(this.Xb,this.q_.key(d.time),(t,e)=>this.q_.key(t.time)<e);this.Xb.splice(f,0,d);for(let t=f;t<this.Xb.length;++t)ln(this.Xb[t].pointData,t);return this.q_.fillWeightsForPoints(this.Xb,f),this.tw(t,f,u)}nw(t,e){let i=this.Yb.get(t);void 0===i&&(i=[],this.Yb.set(t,i));const s=0!==i.length?i[i.length-1]:null;null===s||this.q_.key(e.ot)>this.q_.key(s.ot)?Zs(e)&&i.push(e):Zs(e)?i[i.length-1]=e:i.splice(-1,1),this.Zb.set(t,e.ot)}Jb(t,e){0!==e.length?(this.Yb.set(t,e.filter(Zs)),this.Zb.set(t,e[e.length-1].ot)):(this.Yb.delete(t),this.Zb.delete(t))}Gb(){for(const t of this.Xb)0===t.pointData.Hb.size&&this.qb.delete(this.q_.key(t.time))}Qb(t){let e=-1;for(let i=0;i<this.Xb.length&&i<t.length;++i){const s=this.Xb[i],n=t[i];if(this.q_.key(s.time)!==this.q_.key(n.time)){e=i;break}n.timeWeight=s.timeWeight,ln(n.pointData,i)}if(-1===e&&this.Xb.length!==t.length&&(e=Math.min(this.Xb.length,t.length)),-1===e)return-1;for(let i=e;i<t.length;++i)ln(t[i].pointData,i);return this.q_.fillWeightsForPoints(t,e),this.Xb=t,e}sw(){if(0===this.Yb.size)return null;let t=0;return this.Yb.forEach(e=>{0!==e.length&&(t=Math.max(t,e[e.length-1].ee))}),t}tw(t,e,i){const s={ew:new Map,St:{Eu:this.sw()}};if(-1!==e)this.Yb.forEach((e,n)=>{s.ew.set(n,{$e:e,rw:n===t?i:void 0})}),this.Yb.has(t)||s.ew.set(t,{$e:[],rw:i}),s.St.hw=this.Xb,s.St.lw=e;else{const e=this.Yb.get(t);s.ew.set(t,{$e:e||[],rw:i})}return s}}function ln(t,e){t.ee=e,t.Hb.forEach(t=>{t.ee=e})}function an(t){const e={value:t.Vt[3],time:t.zb};return void 0!==t.jb&&(e.customValues=t.jb),e}function cn(t){const e=an(t);return void 0!==t.V&&(e.color=t.V),e}function un(t){const e=an(t);return void 0!==t.lt&&(e.lineColor=t.lt),void 0!==t.Ps&&(e.topColor=t.Ps),void 0!==t.Rs&&(e.bottomColor=t.Rs),e}function dn(t){const e=an(t);return void 0!==t.Re&&(e.topLineColor=t.Re),void 0!==t.De&&(e.bottomLineColor=t.De),void 0!==t.ke&&(e.topFillColor1=t.ke),void 0!==t.ye&&(e.topFillColor2=t.ye),void 0!==t.Ce&&(e.bottomFillColor1=t.Ce),void 0!==t.Te&&(e.bottomFillColor2=t.Te),e}function fn(t){const e={open:t.Vt[0],high:t.Vt[1],low:t.Vt[2],close:t.Vt[3],time:t.zb};return void 0!==t.jb&&(e.customValues=t.jb),e}function mn(t){const e=fn(t);return void 0!==t.V&&(e.color=t.V),e}function pn(t){const e=fn(t),{V:i,Ot:s,Xh:n}=t;return void 0!==i&&(e.color=i),void 0!==s&&(e.borderColor=s),void 0!==n&&(e.wickColor=n),e}function gn(t){return{Area:un,Line:cn,Baseline:dn,Histogram:cn,Bar:mn,Candlestick:pn,Custom:bn}[t]}function bn(t){const e=t.zb;return Object.assign(Object.assign({},t.$e),{time:e})}const vn={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},wn={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},yn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:J,attributionLogo:!0},Mn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},xn={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,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0},Sn={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:J,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function Cn(){return{width:0,height:0,autoSize:!1,layout:yn,crosshair:vn,grid:wn,overlayPriceScales:Object.assign({},Mn),leftPriceScale:Object.assign(Object.assign({},Mn),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Mn),{visible:!0}),timeScale:xn,watermark:Sn,localization:{locale:hs?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class En{constructor(t,e){this.aw=t,this.ow=e}applyOptions(t){this.aw.$t().$c(this.ow,t)}options(){return this.Li().W()}width(){return yt(this.ow)?this.aw.Mb(this.ow):0}Li(){return z(this.aw.$t().Uc(this.ow)).Dt}}function _n(t,e,i){const s=Ks(t,["time","originalTime"]),n=Object.assign({time:e},s);return void 0!==i&&(n.originalTime=i),n}const $n={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class zn{constructor(t){this.Nh=t}applyOptions(t){this.Nh.$h(t)}options(){return this.Nh.W()}_w(){return this.Nh}}class kn{constructor(t,e,i,s,n){this.uw=new B,this.Es=t,this.cw=e,this.dw=i,this.q_=n,this.fw=s}S(){this.uw.S()}priceFormatter(){return this.Es.ba()}priceToCoordinate(t){const e=this.Es.Ct();return null===e?null:this.Es.Dt().Rt(t,e.Vt)}coordinateToPrice(t){const e=this.Es.Ct();return null===e?null:this.Es.Dt().pn(t,e.Vt)}barsInLogicalRange(t){if(null===t)return null;const e=new Ti(new ki(t.from,t.to)).lu(),i=this.Es.In();if(i.Ni())return null;const s=i.ll(e.Os(),1),n=i.ll(e.ui(),-1),r=z(i.el()),o=z(i.An());if(null!==s&&null!==n&&s.ee>n.ee)return{barsBefore:t.from-r,barsAfter:o-t.to};const h={barsBefore:null===s||s.ee===r?t.from-r:s.ee-r,barsAfter:null===n||n.ee===o?o-t.to:o-n.ee};return null!==s&&null!==n&&(h.from=s.zb,h.to=n.zb),h}setData(t){this.q_,this.Es.Qh(),this.cw.pw(this.Es,t),this.mw("full")}update(t){this.Es.Qh(),this.cw.bw(this.Es,t),this.mw("update")}dataByIndex(t,e){const i=this.Es.In().ll(t,e);return null===i?null:gn(this.seriesType())(i)}data(){const t=gn(this.seriesType());return this.Es.In().ne().map(e=>t(e))}subscribeDataChanged(t){this.uw.l(t)}unsubscribeDataChanged(t){this.uw.v(t)}setMarkers(t){this.q_;const e=t.map(t=>_n(t,this.q_.convertHorzItemToInternal(t.time),t.time));this.Es.na(e)}markers(){return this.Es.sa().map(t=>_n(t,t.originalTime,void 0))}applyOptions(t){this.Es.$h(t)}options(){return K(this.Es.W())}priceScale(){return this.dw.priceScale(this.Es.Dt().Pa())}createPriceLine(t){const e=A(K($n),t),i=this.Es.ea(e);return new zn(i)}removePriceLine(t){this.Es.ra(t._w())}seriesType(){return this.Es.Qh()}attachPrimitive(t){this.Es.ka(t),t.attached&&t.attached({chart:this.fw,series:this,requestUpdate:()=>this.Es.$t().Kl()})}detachPrimitive(t){this.Es.ya(t),t.detached&&t.detached()}mw(t){this.uw.M()&&this.uw.m(t)}}class Rn{constructor(t,e,i){this.ww=new B,this.mu=new B,this.Om=new B,this.$i=t,this.yl=t.St(),this.ab=e,this.yl.nc().l(this.gw.bind(this)),this.yl.sc().l(this.Mw.bind(this)),this.ab.Nm().l(this.xw.bind(this)),this.q_=i}S(){this.yl.nc().p(this),this.yl.sc().p(this),this.ab.Nm().p(this),this.ww.S(),this.mu.S(),this.Om.S()}scrollPosition(){return this.yl.Hu()}scrollToPosition(t,e){e?this.yl.Ju(t,1e3):this.$i.Jn(t)}scrollToRealTime(){this.yl.Gu()}getVisibleRange(){const t=this.yl.Vu();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const e={from:this.q_.convertHorzItemToInternal(t.from),to:this.q_.convertHorzItemToInternal(t.to)},i=this.yl.Iu(e);this.$i.pd(i)}getVisibleLogicalRange(){const t=this.yl.Du();return null===t?null:{from:t.Os(),to:t.ui()}}setVisibleLogicalRange(t){_(t.from<=t.to,"The from index cannot be after the to index."),this.$i.pd(t)}resetTimeScale(){this.$i.Kn()}fitContent(){this.$i.hc()}logicalToCoordinate(t){const e=this.$i.St();return e.Ni()?null:e.It(t)}coordinateToLogical(t){return this.yl.Ni()?null:this.yl.Nu(t)}timeToCoordinate(t){const e=this.q_.convertHorzItemToInternal(t),i=this.yl.Va(e,!1);return null===i?null:this.yl.It(i)}coordinateToTime(t){const e=this.$i.St(),i=e.Nu(t),s=e.Ui(i);return null===s?null:s.originalTime}width(){return this.ab.um().width}height(){return this.ab.um().height}subscribeVisibleTimeRangeChange(t){this.ww.l(t)}unsubscribeVisibleTimeRangeChange(t){this.ww.v(t)}subscribeVisibleLogicalRangeChange(t){this.mu.l(t)}unsubscribeVisibleLogicalRangeChange(t){this.mu.v(t)}subscribeSizeChange(t){this.Om.l(t)}unsubscribeSizeChange(t){this.Om.v(t)}applyOptions(t){this.yl.$h(t)}options(){return Object.assign(Object.assign({},K(this.yl.W())),{barSpacing:this.yl.le()})}gw(){this.ww.M()&&this.ww.m(this.getVisibleRange())}Mw(){this.mu.M()&&this.mu.m(this.getVisibleLogicalRange())}xw(t){this.Om.m(t.width,t.height)}}function Ln(t){return function(t){if(H(t.handleScale)){const e=t.handleScale;t.handleScale={axisDoubleClickReset:{time:e,price:e},axisPressedMouseMove:{time:e,price:e},mouseWheel:e,pinch:e}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:e,axisDoubleClickReset:i}=t.handleScale;H(e)&&(t.handleScale.axisPressedMouseMove={time:e,price:e}),H(i)&&(t.handleScale.axisDoubleClickReset={time:i,price:i})}const e=t.handleScroll;H(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})}(t),t}class Tn{constructor(t,e,i){this.Sw=new Map,this.kw=new Map,this.yw=new B,this.Cw=new B,this.Tw=new B,this.Pw=new hn(e);const s=void 0===i?K(Cn()):A(K(Cn()),Ln(i));this.q_=e,this.aw=new Us(t,s,e),this.aw.lm().l(t=>{this.yw.M()&&this.yw.m(this.Rw(t()))},this),this.aw.am().l(t=>{this.Cw.M()&&this.Cw.m(this.Rw(t()))},this),this.aw.Xc().l(t=>{this.Tw.M()&&this.Tw.m(this.Rw(t()))},this);const n=this.aw.$t();this.Dw=new Rn(n,this.aw.fb(),this.q_)}remove(){this.aw.lm().p(this),this.aw.am().p(this),this.aw.Xc().p(this),this.Dw.S(),this.aw.S(),this.Sw.clear(),this.kw.clear(),this.yw.S(),this.Cw.S(),this.Tw.S(),this.Pw.S()}resize(t,e,i){this.autoSizeActive()||this.aw._b(t,e,i)}addCustomSeries(t,e){const i=k(t),s=Object.assign(Object.assign({},w),i.defaultOptions());return this.Vw("Custom",s,e,i)}addAreaSeries(t){return this.Vw("Area",g,t)}addBaselineSeries(t){return this.Vw("Baseline",b,t)}addBarSeries(t){return this.Vw("Bar",m,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.Vw("Candlestick",f,t)}addHistogramSeries(t){return this.Vw("Histogram",v,t)}addLineSeries(t){return this.Vw("Line",p,t)}removeSeries(t){const e=$(this.Sw.get(t)),i=this.Pw.vd(e);this.aw.$t().vd(e),this.Ow(i),this.Sw.delete(t),this.kw.delete(e)}pw(t,e){this.Ow(this.Pw.Kb(t,e))}bw(t,e){this.Ow(this.Pw.iw(t,e))}subscribeClick(t){this.yw.l(t)}unsubscribeClick(t){this.yw.v(t)}subscribeCrosshairMove(t){this.Tw.l(t)}unsubscribeCrosshairMove(t){this.Tw.v(t)}subscribeDblClick(t){this.Cw.l(t)}unsubscribeDblClick(t){this.Cw.v(t)}priceScale(t){return new En(this.aw,t)}timeScale(){return this.Dw}applyOptions(t){this.aw.$h(Ln(t))}options(){return this.aw.W()}takeScreenshot(){return this.aw.wb()}autoSizeActive(){return this.aw.kb()}chartElement(){return this.aw.yb()}paneSize(){const t=this.aw.Tb();return{height:t.height,width:t.width}}setCrosshairPosition(t,e,i){const s=this.Sw.get(i);if(void 0===s)return;const n=this.aw.$t().dr(s);null!==n&&this.aw.$t().ad(t,e,n)}clearCrosshairPosition(){this.aw.$t().od(!0)}Vw(t,e,i={},s){!function(t){if(void 0===t||"custom"===t.type)return;const e=t;void 0!==e.minMove&&void 0===e.precision&&(e.precision=function(t){if(t>=1)return 0;let e=0;for(;e<8;e++){const i=Math.round(t);if(Math.abs(i-t)<1e-8)return e;t*=10}return e}(e.minMove))}(i.priceFormat);const n=A(K(y),K(e),i),r=this.aw.$t().dd(t,n,s),o=new kn(r,this,this,this,this.q_);return this.Sw.set(o,r),this.kw.set(r,o),o}Ow(t){const e=this.aw.$t();e._d(t.St.Eu,t.St.hw,t.St.lw),t.ew.forEach((t,e)=>e.J(t.$e,t.rw)),e.Wu()}Bw(t){return $(this.kw.get(t))}Rw(t){const e=new Map;t.Nb.forEach((t,i)=>{const s=i.Qh(),n=gn(s)(t);if("Custom"!==s)_(function(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}(n));else{const t=i.Ta();_(!t||!1===t(n))}e.set(this.Bw(i),n)});const i=void 0!==t.Eb&&this.kw.has(t.Eb)?this.Bw(t.Eb):void 0;return{time:t.zb,logical:t.ee,point:t.Lb,hoveredSeries:i,hoveredObjectId:t.Fb,seriesData:e,sourceEvent:t.Wb}}}function Nn(t,e){return function(t,e,i){let s;if(U(t)){const e=document.getElementById(t);_(null!==e,`Cannot find element in DOM with id=${t}`),s=e}else s=t;const n=new Tn(s,e,i);return e.setOptions(n.options()),n}(t,new os,os.Id(e))}Object.assign(Object.assign({},y),w);const On=t=>{const[n]=e(t||null),[r,o]=e(!1),[h,l]=e(!1);i(()=>{if(!n)return o(!1),void l(!1);l(!0);const t=()=>{console.log("✅ [useSocket] Connected to Socket.IO server"),o(!0),l(!1)},e=()=>{console.log("🔌 [useSocket] Disconnected from Socket.IO server"),o(!1),l(!1)},i=t=>{console.error("❌ [useSocket] Connection error:",t),l(!1)};return n.connected&&(o(!0),l(!1)),n.on("connect",t),n.on("disconnect",e),n.on("connect_error",i),()=>{n.off("connect",t),n.off("disconnect",e),n.off("connect_error",i)}},[n]);const a=s(()=>{console.log("🔍 [useSocket] Connect called - connection managed by provider")},[]),c=s(()=>{console.log("🔍 [useSocket] Disconnect called - connection managed by provider")},[]),u=s((t,e=60,i,s,r)=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot subscribe"),!1;try{return n.emit("ohlcv:subscribe",{mint:t,timeFrame:e}),i&&n.on("ohlcv:initial",i),s&&n.on("ohlcv:update",s),r&&n.on("ohlcv:newCandle",r),console.log(`📊 [useSocket] Subscribed to OHLCV updates for ${t} (${e}s)`),!0}catch(t){return console.error("❌ [useSocket] Failed to subscribe to OHLCV:",t),!1}},[n]),d=s((t,e=60,i,s,r)=>{if(!n?.connected)return!1;try{return n.emit("ohlcv:unsubscribe",{mint:t,timeFrame:e}),i&&n.off("ohlcv:initial",i),s&&n.off("ohlcv:update",s),r&&n.off("ohlcv:newCandle",r),console.log(`📊 [useSocket] Unsubscribed from OHLCV updates for ${t} (${e}s)`),!0}catch(t){return console.error("❌ [useSocket] Failed to unsubscribe from OHLCV:",t),!1}},[n]),f=s((t,e)=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot subscribe"),!1;try{return n.emit("price:subscribe",{mint:t}),e&&n.on("price:update",e),console.log(`💰 [useSocket] Subscribed to price updates for ${t}`),!0}catch(t){return console.error("❌ [useSocket] Failed to subscribe to price:",t),!1}},[n]),m=s((t,e)=>{if(!n?.connected)return!1;try{return n.emit("price:unsubscribe",{mint:t}),e&&n.off("price:update",e),console.log(`💰 [useSocket] Unsubscribed from price updates for ${t}`),!0}catch(t){return console.error("❌ [useSocket] Failed to unsubscribe from price:",t),!1}},[n]),p=s(t=>{if(!n?.connected)return console.warn("⚠️ [useSocket] Socket not connected, cannot send test message"),!1;try{return n.emit("test-message",{message:t,timestamp:Date.now()}),n.once("test-response",t=>{console.log("🧪 [useSocket] Test response received:",t)}),!0}catch(t){return console.error("❌ [useSocket] Failed to send test message:",t),!1}},[n]);return{socket:n,isConnected:r,isConnecting:h,connect:a,disconnect:c,subscribeToOHLCV:u,unsubscribeFromOHLCV:d,subscribeToPrice:f,unsubscribeFromPrice:m,testConnection:p}};function Pn(t,r){const[o,h]=e(null),[l,a]=e(!1),[c,u]=e(null),[d,f]=e(null),[m,p]=e(!1);i(()=>{r&&(h(r),f(Date.now()),p(!0),a(!1))},[r]);const g=n(()=>{if(!o||!o.market)return{currentPrice:0,currentMarketCap:0,currentVolume:0,performance24h:{value:"0.00%",isPositive:!1,raw:0},performance7d:{value:"0.00%",isPositive:!1,raw:0},performance1m:{value:"0.00%",isPositive:!1,raw:0},performanceAllTime:{value:"0.00%",isPositive:!1,raw:0},high24h:0,low24h:0,volume24h:0,return24h:0};const t=parseFloat(o.market?.price||"0")||0,e=parseFloat(o.market?.marketCap||"0")||0;let i=parseFloat(o.volume?.current||"0")||0;i<=.01&&(i=parseFloat(o.blockchain?.currentRealSol||"0")||0);const s={value:o.performance?.["24H"]?.percentage||"0.00%",isPositive:o.performance?.["24H"]?.isPositive||!1,raw:o.performance?.["24H"]?.gain||0},n={value:o.performance?.["7D"]?.percentage||"0.00%",isPositive:o.performance?.["7D"]?.isPositive||!1,raw:o.performance?.["7D"]?.gain||0},r={value:o.performance?.["1M"]?.percentage||"0.00%",isPositive:o.performance?.["1M"]?.isPositive||!1,raw:o.performance?.["1M"]?.gain||0},h={value:o.performance?.["All Time"]?.percentage||"0.00%",isPositive:o.performance?.["All Time"]?.isPositive||!1,raw:o.performance?.["All Time"]?.gain||0},l=parseFloat(o["24H"]?.high||"0")||0,a=parseFloat(o["24H"]?.low||"0")||0;let c=parseFloat(o.volume?.["24h"]||"0")||0;c<=.01&&(c=parseFloat(o.blockchain?.currentRealSol||"0")||0);return{currentPrice:t,currentMarketCap:e,currentVolume:i,performance24h:s,performance7d:n,performance1m:r,performanceAllTime:h,high24h:l,low24h:a,volume24h:c,return24h:parseFloat(o["24H"]?.return||"0")||0}},[o]),b=s(t=>t>.01,[]);return{analytics:o,...g,isRealVolume:b,loading:l,error:c,connected:m,lastUpdate:d}}function Fn(t,e){return function(){return t.apply(e,arguments)}}const{toString:Vn}=Object.prototype,{getPrototypeOf:Dn}=Object,{iterator:In,toStringTag:Bn}=Symbol,An=(Wn=Object.create(null),t=>{const e=Vn.call(t);return Wn[e]||(Wn[e]=e.slice(8,-1).toLowerCase())});var Wn;const jn=t=>(t=t.toLowerCase(),e=>An(e)===t),Un=t=>e=>typeof e===t,{isArray:Hn}=Array,Kn=Un("undefined");function qn(t){return null!==t&&!Kn(t)&&null!==t.constructor&&!Kn(t.constructor)&&Gn(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Xn=jn("ArrayBuffer");const Jn=Un("string"),Gn=Un("function"),Qn=Un("number"),Yn=t=>null!==t&&"object"==typeof t,Zn=t=>{if("object"!==An(t))return!1;const e=Dn(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Bn in t||In in t)},tr=jn("Date"),er=jn("File"),ir=jn("Blob"),sr=jn("FileList"),nr=jn("URLSearchParams"),[rr,or,hr,lr]=["ReadableStream","Request","Response","Headers"].map(jn);function ar(t,e,{allOwnKeys:i=!1}={}){if(null==t)return;let s,n;if("object"!=typeof t&&(t=[t]),Hn(t))for(s=0,n=t.length;s<n;s++)e.call(null,t[s],s,t);else{if(qn(t))return;const n=i?Object.getOwnPropertyNames(t):Object.keys(t),r=n.length;let o;for(s=0;s<r;s++)o=n[s],e.call(null,t[o],o,t)}}function cr(t,e){if(qn(t))return null;e=e.toLowerCase();const i=Object.keys(t);let s,n=i.length;for(;n-- >0;)if(s=i[n],e===s.toLowerCase())return s;return null}const ur="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,dr=t=>!Kn(t)&&t!==ur;const fr=(mr="undefined"!=typeof Uint8Array&&Dn(Uint8Array),t=>mr&&t instanceof mr);var mr;const pr=jn("HTMLFormElement"),gr=(({hasOwnProperty:t})=>(e,i)=>t.call(e,i))(Object.prototype),br=jn("RegExp"),vr=(t,e)=>{const i=Object.getOwnPropertyDescriptors(t),s={};ar(i,(i,n)=>{let r;!1!==(r=e(i,n,t))&&(s[n]=r||i)}),Object.defineProperties(t,s)};const wr=jn("AsyncFunction"),yr=(Mr="function"==typeof setImmediate,xr=Gn(ur.postMessage),Mr?setImmediate:xr?(Sr=`axios@${Math.random()}`,Cr=[],ur.addEventListener("message",({source:t,data:e})=>{t===ur&&e===Sr&&Cr.length&&Cr.shift()()},!1),t=>{Cr.push(t),ur.postMessage(Sr,"*")}):t=>setTimeout(t));var Mr,xr,Sr,Cr;const Er="undefined"!=typeof queueMicrotask?queueMicrotask.bind(ur):"undefined"!=typeof process&&process.nextTick||yr;var _r={isArray:Hn,isArrayBuffer:Xn,isBuffer:qn,isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||Gn(t.append)&&("formdata"===(e=An(t))||"object"===e&&Gn(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&Xn(t.buffer),e},isString:Jn,isNumber:Qn,isBoolean:t=>!0===t||!1===t,isObject:Yn,isPlainObject:Zn,isEmptyObject:t=>{if(!Yn(t)||qn(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:rr,isRequest:or,isResponse:hr,isHeaders:lr,isUndefined:Kn,isDate:tr,isFile:er,isBlob:ir,isRegExp:br,isFunction:Gn,isStream:t=>Yn(t)&&Gn(t.pipe),isURLSearchParams:nr,isTypedArray:fr,isFileList:sr,forEach:ar,merge:function t(){const{caseless:e,skipUndefined:i}=dr(this)&&this||{},s={},n=(n,r)=>{const o=e&&cr(s,r)||r;Zn(s[o])&&Zn(n)?s[o]=t(s[o],n):Zn(n)?s[o]=t({},n):Hn(n)?s[o]=n.slice():i&&Kn(n)||(s[o]=n)};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&ar(arguments[t],n);return s},extend:(t,e,i,{allOwnKeys:s}={})=>(ar(e,(e,s)=>{i&&Gn(e)?t[s]=Fn(e,i):t[s]=e},{allOwnKeys:s}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,i,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),i&&Object.assign(t.prototype,i)},toFlatObject:(t,e,i,s)=>{let n,r,o;const h={};if(e=e||{},null==t)return e;do{for(n=Object.getOwnPropertyNames(t),r=n.length;r-- >0;)o=n[r],s&&!s(o,t,e)||h[o]||(e[o]=t[o],h[o]=!0);t=!1!==i&&Dn(t)}while(t&&(!i||i(t,e))&&t!==Object.prototype);return e},kindOf:An,kindOfTest:jn,endsWith:(t,e,i)=>{t=String(t),(void 0===i||i>t.length)&&(i=t.length),i-=e.length;const s=t.indexOf(e,i);return-1!==s&&s===i},toArray:t=>{if(!t)return null;if(Hn(t))return t;let e=t.length;if(!Qn(e))return null;const i=new Array(e);for(;e-- >0;)i[e]=t[e];return i},forEachEntry:(t,e)=>{const i=(t&&t[In]).call(t);let s;for(;(s=i.next())&&!s.done;){const i=s.value;e.call(t,i[0],i[1])}},matchAll:(t,e)=>{let i;const s=[];for(;null!==(i=t.exec(e));)s.push(i);return s},isHTMLForm:pr,hasOwnProperty:gr,hasOwnProp:gr,reduceDescriptors:vr,freezeMethods:t=>{vr(t,(e,i)=>{if(Gn(t)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const s=t[i];Gn(s)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))})},toObjectSet:(t,e)=>{const i={},s=t=>{t.forEach(t=>{i[t]=!0})};return Hn(t)?s(t):s(String(t).split(e)),i},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,i){return e.toUpperCase()+i}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:cr,global:ur,isContextDefined:dr,isSpecCompliantForm:function(t){return!!(t&&Gn(t.append)&&"FormData"===t[Bn]&&t[In])},toJSONObject:t=>{const e=new Array(10),i=(t,s)=>{if(Yn(t)){if(e.indexOf(t)>=0)return;if(qn(t))return t;if(!("toJSON"in t)){e[s]=t;const n=Hn(t)?[]:{};return ar(t,(t,e)=>{const r=i(t,s+1);!Kn(r)&&(n[e]=r)}),e[s]=void 0,n}}return t};return i(t,0)},isAsyncFn:wr,isThenable:t=>t&&(Yn(t)||Gn(t))&&Gn(t.then)&&Gn(t.catch),setImmediate:yr,asap:Er,isIterable:t=>null!=t&&Gn(t[In])};function $r(t,e,i,s,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),i&&(this.config=i),s&&(this.request=s),n&&(this.response=n,this.status=n.status?n.status:null)}_r.inherits($r,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_r.toJSONObject(this.config),code:this.code,status:this.status}}});const zr=$r.prototype,kr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{kr[t]={value:t}}),Object.defineProperties($r,kr),Object.defineProperty(zr,"isAxiosError",{value:!0}),$r.from=(t,e,i,s,n,r)=>{const o=Object.create(zr);_r.toFlatObject(t,o,function(t){return t!==Error.prototype},t=>"isAxiosError"!==t);const h=t&&t.message?t.message:"Error",l=null==e&&t?t.code:e;return $r.call(o,h,l,i,s,n),t&&null==o.cause&&Object.defineProperty(o,"cause",{value:t,configurable:!0}),o.name=t&&t.name||"Error",r&&Object.assign(o,r),o};function Rr(t){return _r.isPlainObject(t)||_r.isArray(t)}function Lr(t){return _r.endsWith(t,"[]")?t.slice(0,-2):t}function Tr(t,e,i){return t?t.concat(e).map(function(t,e){return t=Lr(t),!i&&e?"["+t+"]":t}).join(i?".":""):e}const Nr=_r.toFlatObject(_r,{},null,function(t){return/^is[A-Z]/.test(t)});function Or(t,e,i){if(!_r.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const s=(i=_r.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!_r.isUndefined(e[t])})).metaTokens,n=i.visitor||a,r=i.dots,o=i.indexes,h=(i.Blob||"undefined"!=typeof Blob&&Blob)&&_r.isSpecCompliantForm(e);if(!_r.isFunction(n))throw new TypeError("visitor must be a function");function l(t){if(null===t)return"";if(_r.isDate(t))return t.toISOString();if(_r.isBoolean(t))return t.toString();if(!h&&_r.isBlob(t))throw new $r("Blob is not supported. Use a Buffer instead.");return _r.isArrayBuffer(t)||_r.isTypedArray(t)?h&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function a(t,i,n){let h=t;if(t&&!n&&"object"==typeof t)if(_r.endsWith(i,"{}"))i=s?i:i.slice(0,-2),t=JSON.stringify(t);else if(_r.isArray(t)&&function(t){return _r.isArray(t)&&!t.some(Rr)}(t)||(_r.isFileList(t)||_r.endsWith(i,"[]"))&&(h=_r.toArray(t)))return i=Lr(i),h.forEach(function(t,s){!_r.isUndefined(t)&&null!==t&&e.append(!0===o?Tr([i],s,r):null===o?i:i+"[]",l(t))}),!1;return!!Rr(t)||(e.append(Tr(n,i,r),l(t)),!1)}const c=[],u=Object.assign(Nr,{defaultVisitor:a,convertValue:l,isVisitable:Rr});if(!_r.isObject(t))throw new TypeError("data must be an object");return function t(i,s){if(!_r.isUndefined(i)){if(-1!==c.indexOf(i))throw Error("Circular reference detected in "+s.join("."));c.push(i),_r.forEach(i,function(i,r){!0===(!(_r.isUndefined(i)||null===i)&&n.call(e,i,_r.isString(r)?r.trim():r,s,u))&&t(i,s?s.concat(r):[r])}),c.pop()}}(t),e}function Pr(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function Fr(t,e){this._pairs=[],t&&Or(t,this,e)}const Vr=Fr.prototype;function Dr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ir(t,e,i){if(!e)return t;const s=i&&i.encode||Dr;_r.isFunction(i)&&(i={serialize:i});const n=i&&i.serialize;let r;if(r=n?n(e,i):_r.isURLSearchParams(e)?e.toString():new Fr(e,i).toString(s),r){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t}Vr.append=function(t,e){this._pairs.push([t,e])},Vr.toString=function(t){const e=t?function(e){return t.call(this,e,Pr)}:Pr;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};class Br{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){_r.forEach(this.handlers,function(e){null!==e&&t(e)})}}var Ar={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wr={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Fr,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const jr="undefined"!=typeof window&&"undefined"!=typeof document,Ur="object"==typeof navigator&&navigator||void 0,Hr=jr&&(!Ur||["ReactNative","NativeScript","NS"].indexOf(Ur.product)<0),Kr="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,qr=jr&&window.location.href||"http://localhost";var Xr={...Object.freeze({__proto__:null,hasBrowserEnv:jr,hasStandardBrowserEnv:Hr,hasStandardBrowserWebWorkerEnv:Kr,navigator:Ur,origin:qr}),...Wr};function Jr(t){function e(t,i,s,n){let r=t[n++];if("__proto__"===r)return!0;const o=Number.isFinite(+r),h=n>=t.length;if(r=!r&&_r.isArray(s)?s.length:r,h)return _r.hasOwnProp(s,r)?s[r]=[s[r],i]:s[r]=i,!o;s[r]&&_r.isObject(s[r])||(s[r]=[]);return e(t,i,s[r],n)&&_r.isArray(s[r])&&(s[r]=function(t){const e={},i=Object.keys(t);let s;const n=i.length;let r;for(s=0;s<n;s++)r=i[s],e[r]=t[r];return e}(s[r])),!o}if(_r.isFormData(t)&&_r.isFunction(t.entries)){const i={};return _r.forEachEntry(t,(t,s)=>{e(function(t){return _r.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),s,i,0)}),i}return null}const Gr={transitional:Ar,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",s=i.indexOf("application/json")>-1,n=_r.isObject(t);n&&_r.isHTMLForm(t)&&(t=new FormData(t));if(_r.isFormData(t))return s?JSON.stringify(Jr(t)):t;if(_r.isArrayBuffer(t)||_r.isBuffer(t)||_r.isStream(t)||_r.isFile(t)||_r.isBlob(t)||_r.isReadableStream(t))return t;if(_r.isArrayBufferView(t))return t.buffer;if(_r.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let r;if(n){if(i.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Or(t,new Xr.classes.URLSearchParams,{visitor:function(t,e,i,s){return Xr.isNode&&_r.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((r=_r.isFileList(t))||i.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Or(r?{"files[]":t}:t,e&&new e,this.formSerializer)}}return n||s?(e.setContentType("application/json",!1),function(t,e,i){if(_r.isString(t))try{return(e||JSON.parse)(t),_r.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(i||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||Gr.transitional,i=e&&e.forcedJSONParsing,s="json"===this.responseType;if(_r.isResponse(t)||_r.isReadableStream(t))return t;if(t&&_r.isString(t)&&(i&&!this.responseType||s)){const i=!(e&&e.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(t){if(i){if("SyntaxError"===t.name)throw $r.from(t,$r.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Xr.classes.FormData,Blob:Xr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_r.forEach(["delete","get","head","post","put","patch"],t=>{Gr.headers[t]={}});const Qr=_r.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Yr=Symbol("internals");function Zr(t){return t&&String(t).trim().toLowerCase()}function to(t){return!1===t||null==t?t:_r.isArray(t)?t.map(to):String(t)}function eo(t,e,i,s,n){return _r.isFunction(s)?s.call(this,e,i):(n&&(e=i),_r.isString(e)?_r.isString(s)?-1!==e.indexOf(s):_r.isRegExp(s)?s.test(e):void 0:void 0)}let io=class{constructor(t){t&&this.set(t)}set(t,e,i){const s=this;function n(t,e,i){const n=Zr(e);if(!n)throw new Error("header name must be a non-empty string");const r=_r.findKey(s,n);(!r||void 0===s[r]||!0===i||void 0===i&&!1!==s[r])&&(s[r||e]=to(t))}const r=(t,e)=>_r.forEach(t,(t,i)=>n(t,i,e));if(_r.isPlainObject(t)||t instanceof this.constructor)r(t,e);else if(_r.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))r((t=>{const e={};let i,s,n;return t&&t.split("\n").forEach(function(t){n=t.indexOf(":"),i=t.substring(0,n).trim().toLowerCase(),s=t.substring(n+1).trim(),!i||e[i]&&Qr[i]||("set-cookie"===i?e[i]?e[i].push(s):e[i]=[s]:e[i]=e[i]?e[i]+", "+s:s)}),e})(t),e);else if(_r.isObject(t)&&_r.isIterable(t)){let i,s,n={};for(const e of t){if(!_r.isArray(e))throw TypeError("Object iterator must return a key-value pair");n[s=e[0]]=(i=n[s])?_r.isArray(i)?[...i,e[1]]:[i,e[1]]:e[1]}r(n,e)}else null!=t&&n(e,t,i);return this}get(t,e){if(t=Zr(t)){const i=_r.findKey(this,t);if(i){const t=this[i];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=i.exec(t);)e[s[1]]=s[2];return e}(t);if(_r.isFunction(e))return e.call(this,t,i);if(_r.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Zr(t)){const i=_r.findKey(this,t);return!(!i||void 0===this[i]||e&&!eo(0,this[i],i,e))}return!1}delete(t,e){const i=this;let s=!1;function n(t){if(t=Zr(t)){const n=_r.findKey(i,t);!n||e&&!eo(0,i[n],n,e)||(delete i[n],s=!0)}}return _r.isArray(t)?t.forEach(n):n(t),s}clear(t){const e=Object.keys(this);let i=e.length,s=!1;for(;i--;){const n=e[i];t&&!eo(0,this[n],n,t,!0)||(delete this[n],s=!0)}return s}normalize(t){const e=this,i={};return _r.forEach(this,(s,n)=>{const r=_r.findKey(i,n);if(r)return e[r]=to(s),void delete e[n];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}(n):String(n).trim();o!==n&&delete e[n],e[o]=to(s),i[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return _r.forEach(this,(i,s)=>{null!=i&&!1!==i&&(e[s]=t&&_r.isArray(i)?i.join(", "):i)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const i=new this(t);return e.forEach(t=>i.set(t)),i}static accessor(t){const e=(this[Yr]=this[Yr]={accessors:{}}).accessors,i=this.prototype;function s(t){const s=Zr(t);e[s]||(!function(t,e){const i=_r.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+i,{value:function(t,i,n){return this[s].call(this,e,t,i,n)},configurable:!0})})}(i,t),e[s]=!0)}return _r.isArray(t)?t.forEach(s):s(t),this}};function so(t,e){const i=this||Gr,s=e||i,n=io.from(s.headers);let r=s.data;return _r.forEach(t,function(t){r=t.call(i,r,n.normalize(),e?e.status:void 0)}),n.normalize(),r}function no(t){return!(!t||!t.__CANCEL__)}function ro(t,e,i){$r.call(this,null==t?"canceled":t,$r.ERR_CANCELED,e,i),this.name="CanceledError"}function oo(t,e,i){const s=i.config.validateStatus;i.status&&s&&!s(i.status)?e(new $r("Request failed with status code "+i.status,[$r.ERR_BAD_REQUEST,$r.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):t(i)}io.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_r.reduceDescriptors(io.prototype,({value:t},e)=>{let i=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[i]=t}}}),_r.freezeMethods(io),_r.inherits(ro,$r,{__CANCEL__:!0});const ho=(t,e,i=3)=>{let s=0;const n=function(t,e){t=t||10;const i=new Array(t),s=new Array(t);let n,r=0,o=0;return e=void 0!==e?e:1e3,function(h){const l=Date.now(),a=s[o];n||(n=l),i[r]=h,s[r]=l;let c=o,u=0;for(;c!==r;)u+=i[c++],c%=t;if(r=(r+1)%t,r===o&&(o=(o+1)%t),l-n<e)return;const d=a&&l-a;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(t,e){let i,s,n=0,r=1e3/e;const o=(e,r=Date.now())=>{n=r,i=null,s&&(clearTimeout(s),s=null),t(...e)};return[(...t)=>{const e=Date.now(),h=e-n;h>=r?o(t,e):(i=t,s||(s=setTimeout(()=>{s=null,o(i)},r-h)))},()=>i&&o(i)]}(i=>{const r=i.loaded,o=i.lengthComputable?i.total:void 0,h=r-s,l=n(h);s=r;t({loaded:r,total:o,progress:o?r/o:void 0,bytes:h,rate:l||void 0,estimated:l&&o&&r<=o?(o-r)/l:void 0,event:i,lengthComputable:null!=o,[e?"download":"upload"]:!0})},i)},lo=(t,e)=>{const i=null!=t;return[s=>e[0]({lengthComputable:i,total:t,loaded:s}),e[1]]},ao=t=>(...e)=>_r.asap(()=>t(...e));var co=Xr.hasStandardBrowserEnv?((t,e)=>i=>(i=new URL(i,Xr.origin),t.protocol===i.protocol&&t.host===i.host&&(e||t.port===i.port)))(new URL(Xr.origin),Xr.navigator&&/(msie|trident)/i.test(Xr.navigator.userAgent)):()=>!0,uo=Xr.hasStandardBrowserEnv?{write(t,e,i,s,n,r){const o=[t+"="+encodeURIComponent(e)];_r.isNumber(i)&&o.push("expires="+new Date(i).toGMTString()),_r.isString(s)&&o.push("path="+s),_r.isString(n)&&o.push("domain="+n),!0===r&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function fo(t,e,i){let s=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);return t&&(s||0==i)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const mo=t=>t instanceof io?{...t}:t;function po(t,e){e=e||{};const i={};function s(t,e,i,s){return _r.isPlainObject(t)&&_r.isPlainObject(e)?_r.merge.call({caseless:s},t,e):_r.isPlainObject(e)?_r.merge({},e):_r.isArray(e)?e.slice():e}function n(t,e,i,n){return _r.isUndefined(e)?_r.isUndefined(t)?void 0:s(void 0,t,0,n):s(t,e,0,n)}function r(t,e){if(!_r.isUndefined(e))return s(void 0,e)}function o(t,e){return _r.isUndefined(e)?_r.isUndefined(t)?void 0:s(void 0,t):s(void 0,e)}function h(i,n,r){return r in e?s(i,n):r in t?s(void 0,i):void 0}const l={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:h,headers:(t,e,i)=>n(mo(t),mo(e),0,!0)};return _r.forEach(Object.keys({...t,...e}),function(s){const r=l[s]||n,o=r(t[s],e[s],s);_r.isUndefined(o)&&r!==h||(i[s]=o)}),i}var go=t=>{const e=po({},t);let{data:i,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:h}=e;if(e.headers=o=io.from(o),e.url=Ir(fo(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),h&&o.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),_r.isFormData(i))if(Xr.hasStandardBrowserEnv||Xr.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(_r.isFunction(i.getHeaders)){const t=i.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,i])=>{e.includes(t.toLowerCase())&&o.set(t,i)})}if(Xr.hasStandardBrowserEnv&&(s&&_r.isFunction(s)&&(s=s(e)),s||!1!==s&&co(e.url))){const t=n&&r&&uo.read(r);t&&o.set(n,t)}return e};var bo="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,i){const s=go(t);let n=s.data;const r=io.from(s.headers).normalize();let o,h,l,a,c,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=s;function m(){a&&a(),c&&c(),s.cancelToken&&s.cancelToken.unsubscribe(o),s.signal&&s.signal.removeEventListener("abort",o)}let p=new XMLHttpRequest;function g(){if(!p)return;const s=io.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders());oo(function(t){e(t),m()},function(t){i(t),m()},{data:u&&"text"!==u&&"json"!==u?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:s,config:t,request:p}),p=null}p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout,"onloadend"in p?p.onloadend=g:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(g)},p.onabort=function(){p&&(i(new $r("Request aborted",$r.ECONNABORTED,t,p)),p=null)},p.onerror=function(e){const s=new $r(e&&e.message?e.message:"Network Error",$r.ERR_NETWORK,t,p);s.event=e||null,i(s),p=null},p.ontimeout=function(){let e=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const n=s.transitional||Ar;s.timeoutErrorMessage&&(e=s.timeoutErrorMessage),i(new $r(e,n.clarifyTimeoutError?$r.ETIMEDOUT:$r.ECONNABORTED,t,p)),p=null},void 0===n&&r.setContentType(null),"setRequestHeader"in p&&_r.forEach(r.toJSON(),function(t,e){p.setRequestHeader(e,t)}),_r.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),u&&"json"!==u&&(p.responseType=s.responseType),f&&([l,c]=ho(f,!0),p.addEventListener("progress",l)),d&&p.upload&&([h,a]=ho(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",a)),(s.cancelToken||s.signal)&&(o=e=>{p&&(i(!e||e.type?new ro(null,t,p):e),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(o),s.signal&&(s.signal.aborted?o():s.signal.addEventListener("abort",o)));const b=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(s.url);b&&-1===Xr.protocols.indexOf(b)?i(new $r("Unsupported protocol "+b+":",$r.ERR_BAD_REQUEST,t)):p.send(n||null)})};const vo=(t,e)=>{const{length:i}=t=t?t.filter(Boolean):[];if(e||i){let i,s=new AbortController;const n=function(t){if(!i){i=!0,o();const e=t instanceof Error?t:this.reason;s.abort(e instanceof $r?e:new ro(e instanceof Error?e.message:e))}};let r=e&&setTimeout(()=>{r=null,n(new $r(`timeout ${e} of ms exceeded`,$r.ETIMEDOUT))},e);const o=()=>{t&&(r&&clearTimeout(r),r=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(n):t.removeEventListener("abort",n)}),t=null)};t.forEach(t=>t.addEventListener("abort",n));const{signal:h}=s;return h.unsubscribe=()=>_r.asap(o),h}},wo=function*(t,e){let i=t.byteLength;if(i<e)return void(yield t);let s,n=0;for(;n<i;)s=n+e,yield t.slice(n,s),n=s},yo=async function*(t){if(t[Symbol.asyncIterator])return void(yield*t);const e=t.getReader();try{for(;;){const{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},Mo=(t,e,i,s)=>{const n=async function*(t,e){for await(const i of yo(t))yield*wo(i,e)}(t,e);let r,o=0,h=t=>{r||(r=!0,s&&s(t))};return new ReadableStream({async pull(t){try{const{done:e,value:s}=await n.next();if(e)return h(),void t.close();let r=s.byteLength;if(i){let t=o+=r;i(t)}t.enqueue(new Uint8Array(s))}catch(t){throw h(t),t}},cancel:t=>(h(t),n.return())},{highWaterMark:2})},{isFunction:xo}=_r,So=(({Request:t,Response:e})=>({Request:t,Response:e}))(_r.global),{ReadableStream:Co,TextEncoder:Eo}=_r.global,_o=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},$o=t=>{t=_r.merge.call({skipUndefined:!0},So,t);const{fetch:e,Request:i,Response:s}=t,n=e?xo(e):"function"==typeof fetch,r=xo(i),o=xo(s);if(!n)return!1;const h=n&&xo(Co),l=n&&("function"==typeof Eo?(a=new Eo,t=>a.encode(t)):async t=>new Uint8Array(await new i(t).arrayBuffer()));var a;const c=r&&h&&_o(()=>{let t=!1;const e=new i(Xr.origin,{body:new Co,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),u=o&&h&&_o(()=>_r.isReadableStream(new s("").body)),d={stream:u&&(t=>t.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!d[t]&&(d[t]=(e,i)=>{let s=e&&e[t];if(s)return s.call(e);throw new $r(`Response type '${t}' is not supported`,$r.ERR_NOT_SUPPORT,i)})});const f=async(t,e)=>{const s=_r.toFiniteNumber(t.getContentLength());return null==s?(async t=>{if(null==t)return 0;if(_r.isBlob(t))return t.size;if(_r.isSpecCompliantForm(t)){const e=new i(Xr.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return _r.isArrayBufferView(t)||_r.isArrayBuffer(t)?t.byteLength:(_r.isURLSearchParams(t)&&(t+=""),_r.isString(t)?(await l(t)).byteLength:void 0)})(e):s};return async t=>{let{url:n,method:o,data:h,signal:l,cancelToken:a,timeout:m,onDownloadProgress:p,onUploadProgress:g,responseType:b,headers:v,withCredentials:w="same-origin",fetchOptions:y}=go(t),M=e||fetch;b=b?(b+"").toLowerCase():"text";let x=vo([l,a&&a.toAbortSignal()],m),S=null;const C=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let E;try{if(g&&c&&"get"!==o&&"head"!==o&&0!==(E=await f(v,h))){let t,e=new i(n,{method:"POST",body:h,duplex:"half"});if(_r.isFormData(h)&&(t=e.headers.get("content-type"))&&v.setContentType(t),e.body){const[t,i]=lo(E,ho(ao(g)));h=Mo(e.body,65536,t,i)}}_r.isString(w)||(w=w?"include":"omit");const e=r&&"credentials"in i.prototype,l={...y,signal:x,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:h,duplex:"half",credentials:e?w:void 0};S=r&&new i(n,l);let a=await(r?M(S,y):M(n,l));const m=u&&("stream"===b||"response"===b);if(u&&(p||m&&C)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=a[e]});const e=_r.toFiniteNumber(a.headers.get("content-length")),[i,n]=p&&lo(e,ho(ao(p),!0))||[];a=new s(Mo(a.body,65536,i,()=>{n&&n(),C&&C()}),t)}b=b||"text";let _=await d[_r.findKey(d,b)||"text"](a,t);return!m&&C&&C(),await new Promise((e,i)=>{oo(e,i,{data:_,headers:io.from(a.headers),status:a.status,statusText:a.statusText,config:t,request:S})})}catch(e){if(C&&C(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new $r("Network Error",$r.ERR_NETWORK,t,S),{cause:e.cause||e});throw $r.from(e,e&&e.code,t,S)}}},zo=new Map,ko=t=>{let e=t?t.env:{};const{fetch:i,Request:s,Response:n}=e,r=[s,n,i];let o,h,l=r.length,a=zo;for(;l--;)o=r[l],h=a.get(o),void 0===h&&a.set(o,h=l?new Map:$o(e)),a=h;return h};ko();const Ro={http:null,xhr:bo,fetch:{get:ko}};_r.forEach(Ro,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const Lo=t=>`- ${t}`,To=t=>_r.isFunction(t)||null===t||!1===t;var No=(t,e)=>{t=_r.isArray(t)?t:[t];const{length:i}=t;let s,n;const r={};for(let o=0;o<i;o++){let i;if(s=t[o],n=s,!To(s)&&(n=Ro[(i=String(s)).toLowerCase()],void 0===n))throw new $r(`Unknown adapter '${i}'`);if(n&&(_r.isFunction(n)||(n=n.get(e))))break;r[i||"#"+o]=n}if(!n){const t=Object.entries(r).map(([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));throw new $r("There is no suitable adapter to dispatch the request "+(i?t.length>1?"since :\n"+t.map(Lo).join("\n"):" "+Lo(t[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Oo(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ro(null,t)}function Po(t){Oo(t),t.headers=io.from(t.headers),t.data=so.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return No(t.adapter||Gr.adapter,t)(t).then(function(e){return Oo(t),e.data=so.call(t,t.transformResponse,e),e.headers=io.from(e.headers),e},function(e){return no(e)||(Oo(t),e&&e.response&&(e.response.data=so.call(t,t.transformResponse,e.response),e.response.headers=io.from(e.response.headers))),Promise.reject(e)})}const Fo="1.12.2",Vo={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Vo[t]=function(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}});const Do={};Vo.transitional=function(t,e,i){function s(t,e){return"[Axios v"+Fo+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return(i,n,r)=>{if(!1===t)throw new $r(s(n," has been removed"+(e?" in "+e:"")),$r.ERR_DEPRECATED);return e&&!Do[n]&&(Do[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(i,n,r)}},Vo.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};var Io={assertOptions:function(t,e,i){if("object"!=typeof t)throw new $r("options must be an object",$r.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let n=s.length;for(;n-- >0;){const r=s[n],o=e[r];if(o){const e=t[r],i=void 0===e||o(e,r,t);if(!0!==i)throw new $r("option "+r+" must be "+i,$r.ERR_BAD_OPTION_VALUE);continue}if(!0!==i)throw new $r("Unknown option "+r,$r.ERR_BAD_OPTION)}},validators:Vo};const Bo=Io.validators;let Ao=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Br,response:new Br}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const i=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?i&&!String(t.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+i):t.stack=i}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=po(this.defaults,e);const{transitional:i,paramsSerializer:s,headers:n}=e;void 0!==i&&Io.assertOptions(i,{silentJSONParsing:Bo.transitional(Bo.boolean),forcedJSONParsing:Bo.transitional(Bo.boolean),clarifyTimeoutError:Bo.transitional(Bo.boolean)},!1),null!=s&&(_r.isFunction(s)?e.paramsSerializer={serialize:s}:Io.assertOptions(s,{encode:Bo.function,serialize:Bo.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Io.assertOptions(e,{baseUrl:Bo.spelling("baseURL"),withXsrfToken:Bo.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&_r.merge(n.common,n[e.method]);n&&_r.forEach(["delete","get","head","post","put","patch","common"],t=>{delete n[t]}),e.headers=io.concat(r,n);const o=[];let h=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(h=h&&t.synchronous,o.unshift(t.fulfilled,t.rejected))});const l=[];let a;this.interceptors.response.forEach(function(t){l.push(t.fulfilled,t.rejected)});let c,u=0;if(!h){const t=[Po.bind(this),void 0];for(t.unshift(...o),t.push(...l),c=t.length,a=Promise.resolve(e);u<c;)a=a.then(t[u++],t[u++]);return a}c=o.length;let d=e;for(;u<c;){const t=o[u++],e=o[u++];try{d=t(d)}catch(t){e.call(this,t);break}}try{a=Po.call(this,d)}catch(t){return Promise.reject(t)}for(u=0,c=l.length;u<c;)a=a.then(l[u++],l[u++]);return a}getUri(t){return Ir(fo((t=po(this.defaults,t)).baseURL,t.url,t.allowAbsoluteUrls),t.params,t.paramsSerializer)}};_r.forEach(["delete","get","head","options"],function(t){Ao.prototype[t]=function(e,i){return this.request(po(i||{},{method:t,url:e,data:(i||{}).data}))}}),_r.forEach(["post","put","patch"],function(t){function e(e){return function(i,s,n){return this.request(po(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Ao.prototype[t]=e(),Ao.prototype[t+"Form"]=e(!0)});const Wo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wo).forEach(([t,e])=>{Wo[e]=t});const jo=function t(e){const i=new Ao(e),s=Fn(Ao.prototype.request,i);return _r.extend(s,Ao.prototype,i,{allOwnKeys:!0}),_r.extend(s,i,null,{allOwnKeys:!0}),s.create=function(i){return t(po(e,i))},s}(Gr);jo.Axios=Ao,jo.CanceledError=ro,jo.CancelToken=class t{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const i=this;this.promise.then(t=>{if(!i._listeners)return;let e=i._listeners.length;for(;e-- >0;)i._listeners[e](t);i._listeners=null}),this.promise.then=t=>{let e;const s=new Promise(t=>{i.subscribe(t),e=t}).then(t);return s.cancel=function(){i.unsubscribe(e)},s},t(function(t,s,n){i.reason||(i.reason=new ro(t,s,n),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let e;const i=new t(function(t){e=t});return{token:i,cancel:e}}},jo.isCancel=no,jo.VERSION=Fo,jo.toFormData=Or,jo.AxiosError=$r,jo.Cancel=jo.CanceledError,jo.all=function(t){return Promise.all(t)},jo.spread=function(t){return function(e){return t.apply(null,e)}},jo.isAxiosError=function(t){return _r.isObject(t)&&!0===t.isAxiosError},jo.mergeConfig=po,jo.AxiosHeaders=io,jo.formToJSON=t=>Jr(_r.isHTMLForm(t)?new FormData(t):t),jo.getAdapter=No,jo.HttpStatusCode=Wo,jo.default=jo;const{Axios:Uo,AxiosError:Ho,CanceledError:Ko,isCancel:qo,CancelToken:Xo,VERSION:Jo,all:Go,Cancel:Qo,isAxiosError:Yo,spread:Zo,toFormData:th,AxiosHeaders:eh,HttpStatusCode:ih,formToJSON:sh,getAdapter:nh,mergeConfig:rh}=jo,oh={BASE_URL:"undefined"!=typeof window&&window.FUNHI_CHART_API_URL?window.FUNHI_CHART_API_URL:process.env.NEXT_PUBLIC_BACKEND_URL||"",TIMEOUT:1e4,MAX_RETRIES:3,RETRY_DELAY:1e3};const hh=new class{constructor(){this.baseURL=`${oh.BASE_URL}/api/ohlcv`,this.savingQueue=new Map,this.BATCH_DELAY=5e3,this.BATCH_SIZE=50}async saveCandles(t){try{const{mint:e,candles:i,timeFrame:s=60}=t;if(!e||!i||0===i.length)return console.warn("⚠️ [CandleStorage] Invalid save request:",t),!1;return!!(await jo.post(`${this.baseURL}/candles/save`,{mint:e,candles:i,timeFrame:s})).data.success&&(console.log(`💾 [CandleStorage] Saved ${i.length} candles for ${e}`),!0)}catch(t){return console.error("❌ [CandleStorage] Error saving candles:",t),!1}}async saveCandle(t){try{const{mint:e,candle:i,timeFrame:s=60}=t;if(!e||!i)return console.warn("⚠️ [CandleStorage] Invalid save request:",t),!1;const n=`${e}_${s}`,r=this.savingQueue.get(n);if(r)clearTimeout(r.timeout),r.candles.push(i),r.candles.length>=this.BATCH_SIZE?await this.flushQueue(n,e,s):r.timeout=setTimeout(()=>{this.flushQueue(n,e,s)},this.BATCH_DELAY);else{const t=setTimeout(()=>{this.flushQueue(n,e,s)},this.BATCH_DELAY);this.savingQueue.set(n,{candles:[i],timeout:t})}return!0}catch(t){return console.error("❌ [CandleStorage] Error queuing candle:",t),!1}}async flushQueue(t,e,i){const s=this.savingQueue.get(t);s&&0!==s.candles.length&&(this.savingQueue.delete(t),await this.saveCandles({mint:e,candles:s.candles,timeFrame:i}))}async getCandles(t){try{const{mint:e,timeFrame:i=60,limit:s=5e4}=t;if(!e)return console.warn("⚠️ [CandleStorage] Invalid get request:",t),[];const n=await jo.get(`${this.baseURL}/candles/${e}`,{params:{timeFrame:i,limit:s},timeout:8e3,validateStatus:t=>t>=200&&t<500});if(n.data.success&&n.data.data&&n.data.data.candles){const t=n.data.data.candles.length;return t>0?console.log(`✅ [CandleStorage] Retrieved ${t} candles for ${e}`):console.log(`ℹ️ [CandleStorage] No candles found for ${e} in database`),n.data.data.candles}return n.data.warning&&console.warn(`⚠️ [CandleStorage] ${n.data.warning}`),[]}catch(e){return"ECONNABORTED"===e.code?console.error("❌ [CandleStorage] Request timeout getting candles for",t.mint):e.response?console.error("❌ [CandleStorage] Server error getting candles:",e.response.status,e.response.data):e.request?console.error("❌ [CandleStorage] Network error getting candles - no response received"):console.error("❌ [CandleStorage] Error getting candles:",e.message),[]}}async flushAll(){const t=[];for(const[e,i]of this.savingQueue.entries()){clearTimeout(i.timeout);const[s,n]=e.split("_"),r=parseInt(n);t.push(this.flushQueue(e,s,r))}await Promise.all(t)}},lh=({mint:o,ticker:h,tokenName:l,socket:a,isConnected:c,currentMarketCap:u,analyticsConnected:d,analyticsLoading:f})=>{const m=r(null),p=r(null),g=r(null),b=r([]),v=r([]),w=r([]),y=r([]),M=r([]),x=r([]),S=r(null),C=r(null),E=r(null),_=r(null),$=r(null),z=r(null),k=r(0),R=r(0),L=r(0),T=r(0),N=r(0),O=r(0),P=r(null),[F,V]=e([]),[D,I]=e(null),[B,A]=e(0),[W,j]=e([]),[U,H]=e(null),[K,q]=e(0),[X,J]=e([]),[G,Q]=e(null),[Y,Z]=e(0),[tt,et]=e([]),[it,st]=e(null),[nt,rt]=e(0),[ot,ht]=e([]),[lt,at]=e(null),[ct,ut]=e(0),[dt,ft]=e([]),[mt,pt]=e(null),[gt,bt]=e(0),[wt,yt]=e(0),[Mt,xt]=e(!0),[St,Ct]=e(!1),[Et,_t]=e(null),[$t,zt]=e(null),kt=r(0),Rt=r(0),Lt=On(),Tt=a||Lt.socket,Nt=void 0!==c?c:Lt.isConnected,Ot=Pn(),Pt=void 0!==u?u:Ot.currentMarketCap,Ft=void 0!==d?d:Ot.connected,Vt=void 0!==f?f:Ot.loading,Dt=n(()=>[{label:"1m",value:"1m",seconds:60},{label:"5m",value:"5m",seconds:300},{label:"15m",value:"15m",seconds:900},{label:"1h",value:"1h",seconds:3600},{label:"4h",value:"4h",seconds:14400},{label:"1d",value:"1d",seconds:86400}],[]),[It,Bt]=e(Dt[0]),At=s(()=>{switch(It.seconds){case 60:default:return b.current;case 300:return v.current;case 900:return w.current;case 3600:return y.current;case 14400:return M.current;case 86400:return x.current}},[It.seconds]),Wt=s(t=>t>=1e9?`$${(t/1e9).toFixed(t>=1e10?2:3)}B`:t>=1e6?`$${(t/1e6).toFixed(t>=1e7?2:3)}M`:t>=1e4?`$${(t/1e3).toFixed(t>=1e5?1:2)}K`:t>=1e3?`$${(t/1e3).toFixed(2)}K`:t>=1?`$${t.toFixed(2)}`:`$${t.toFixed(4)}`,[]),jt=s(async(t,e)=>{const i=Dt.find(e=>e.seconds===t)?.label||`${t}s`;try{const s=e?`${e} candles`:"all available candles";console.log(`📊 [Chart-${i}] Loading ${s} from database`);const n=e??Number.MAX_SAFE_INTEGER,r=(await hh.getCandles({mint:o,timeFrame:t,limit:n})).reduce((t,e)=>{const i=Math.max(1e-4*e.open,.01),s=Math.abs(e.open-e.close);let n={...e};if(s<i&&e.open>0){const t=e.close>=e.open?1:-1;n.close=e.open+t*i,n.high=Math.max(e.high||e.open,n.close),n.low=Math.min(e.low||e.open,n.close)}const r=t.findIndex(t=>t.time===n.time);return r>=0?t[r]=n:t.push(n),t},[]),h=r.sort((t,e)=>t.time-e.time);return console.log(`✅ [Chart-${i}] Loaded ${h.length} candles`),h}catch(t){return console.error(`❌ [Chart-${i}] Error loading candles:`,t),[]}},[o,Dt]),Ut=s((t,e)=>{const i=Math.floor(e/1e3),s=60*Math.floor(i/60),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1m] Invalid price data: ${t}`),null;if(s!==k.current){let e=null,i=1;if(S.current&&S.current.close>0&&isFinite(S.current.close)&&(S.current.time<s?(e=S.current.close,S.current.open>0&&(i=S.current.close>=S.current.open?1:-1),console.log(`✅ [Chart-1m] Method 1: Using currentCandle ref close (${S.current.time}) as new candle open: $${e.toFixed(2)}`)):S.current.time===s&&console.warn(`⚠️ [Chart-1m] Current candle ref is already for new bucket ${s}, skipping`)),null===e){const t=b.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s&&t.close>0&&isFinite(t.close));r&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`✅ [Chart-1m] Method 2: Using last completed candle from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&S.current&&S.current.close>0&&isFinite(S.current.close)&&(e=S.current.close,S.current.open>0&&(i=S.current.close>=S.current.open?1:-1),console.log(`✅ [Chart-1m] Method 3 (PRIMARY): Using currentCandle ref close (${S.current.time}) as new candle open: $${e.toFixed(2)}`)),S.current&&S.current.open>0&&S.current.high>0&&S.current.low>0&&S.current.close>0){const t={...S.current};null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-1m] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`)),t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),V(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,b.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return b.current=s,s})}null===e&&(console.error("❌ [Chart-1m] CRITICAL: No previous candle close found after all attempts! This should not happen."),console.error(" - currentCandle1mRef.current:",S.current),console.error(" - candles1mRef.current length:",b.current?.length||0),console.error(" - bucketStart:",s,`(${new Date(1e3*s).toLocaleTimeString()})`),console.error(` - Using current price as last resort: $${t.toFixed(2)}`),e=t);const n=e;console.log(`🕯️ [Chart-1m] Creating new candle at ${new Date(1e3*s).toLocaleTimeString()}: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return S.current=l,k.current=s,I(l),A(s),V(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,b.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return b.current=i,i}),console.log(`🆕 [Chart-1m] New candle: $${t.toFixed(2)}`),l}if(S.current){const i=Math.floor(e/1e3),s=60*Math.floor(i/60);if(S.current.time!==s)return console.warn(`⚠️ [Chart-1m] Skipping update for historical candle (time: ${S.current.time}, current: ${s})`),null;const n=S.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-1m] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return S.current=e,I(e),V(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,b.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r,console.log(`🛡️ [Chart-1m] PRESERVING body: open=$${n.open.toFixed(2)}, close=$${l.toFixed(2)}, bodySize=$${r.toFixed(4)}, priceDiff=$${o.toFixed(4)}, direction=${e>0?"UP":"DOWN"}, price=$${t.toFixed(2)}`)}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1;const i=n.open+e*r;Math.abs(i-l)>1e-4&&(console.log(`🔒 [Chart-1m] ENFORCING minimum body: was $${l.toFixed(2)}, now $${i.toFixed(2)}, direction=${e>0?"UP":"DOWN"}, price=$${t.toFixed(2)}`),l=i)}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),S.current=a,I(a),a.time!==s?(console.warn(`⚠️ [Chart-1m] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(V(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,b.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return b.current=e,e}return t}),a)}return null},[]),Ht=s((t,e)=>{const i=Math.floor(e/1e3),s=300*Math.floor(i/300),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-5m] Invalid price data: ${t}`),null;if(s!==R.current){let e=null,i=1;if(C.current&&C.current.close>0&&isFinite(C.current.close)&&C.current.time<s&&(e=C.current.close,C.current.open>0&&(i=C.current.close>=C.current.open?1:-1),console.log(`✅ [Chart-5m] Using currentCandle ref close (${C.current.time}) as new candle open: $${e.toFixed(2)}`)),null===e){const t=v.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s);r&&r.close>0&&isFinite(r.close)&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`🔄 [Chart-5m] Using last completed candle close from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&C.current&&C.current.close>0&&isFinite(C.current.close)&&(e=C.current.close,C.current.open>0&&(i=C.current.close>=C.current.open?1:-1),console.log(`✅ [Chart-5m] Method 3 (PRIMARY): Using currentCandle ref close (${C.current.time}) as new candle open: $${e.toFixed(2)}`)),C.current&&C.current.open>0&&C.current.high>0&&C.current.low>0&&C.current.close>0){const t={...C.current};null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-5m] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`)),t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),j(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,v.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return v.current=s,s})}null===e&&(console.error("❌ [Chart-5m] CRITICAL: No previous candle close found after all attempts!"),e=t);const n=e;console.log(`🕯️ [Chart-5m] Creating new candle: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return C.current=l,R.current=s,H(l),q(s),j(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,v.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return v.current=i,i}),console.log(`🆕 [Chart-5m] New candle: $${t.toFixed(2)}`),l}if(C.current){const i=Math.floor(e/1e3),s=300*Math.floor(i/300);if(C.current.time!==s)return console.warn(`⚠️ [Chart-5m] Skipping update for historical candle (time: ${C.current.time}, current: ${s})`),null;const n=C.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-5m] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return C.current=e,H(e),j(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,v.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1,l=n.open+e*r}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),C.current=a,H(a),a.time!==s?(console.warn(`⚠️ [Chart-5m] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(j(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,v.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return v.current=e,e}return t}),a)}return null},[]),Kt=s((t,e)=>{const i=Math.floor(e/1e3),s=900*Math.floor(i/900),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-15m] Invalid price data: ${t}`),null;if(s!==L.current){let e=null,i=1;if(E.current&&E.current.close>0&&isFinite(E.current.close)&&E.current.time<s&&(e=E.current.close,E.current.open>0&&(i=E.current.close>=E.current.open?1:-1),console.log(`✅ [Chart-15m] Using currentCandle ref close (${E.current.time}) as new candle open: $${e.toFixed(2)}`)),null===e){const t=w.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s);r&&r.close>0&&isFinite(r.close)&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`🔄 [Chart-15m] Using last completed candle close from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&E.current&&E.current.close>0&&isFinite(E.current.close)&&(e=E.current.close,E.current.open>0&&(i=E.current.close>=E.current.open?1:-1),console.log(`✅ [Chart-15m] Method 3 (PRIMARY): Using currentCandle ref close (${E.current.time}) as new candle open: $${e.toFixed(2)}`)),E.current&&E.current.open>0&&E.current.high>0&&E.current.low>0&&E.current.close>0){const t={...E.current};t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),J(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,w.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return w.current=s,s}),null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-15m] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`))}null===e&&(console.error("❌ [Chart-15m] CRITICAL: No previous candle close found after all attempts!"),e=t);const n=e;console.log(`🕯️ [Chart-15m] Creating new candle: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return E.current=l,L.current=s,Q(l),Z(s),J(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,w.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return w.current=i,i}),console.log(`🆕 [Chart-15m] New candle: $${t.toFixed(2)}`),l}if(E.current){const i=Math.floor(e/1e3),s=900*Math.floor(i/900);if(E.current.time!==s)return console.warn(`⚠️ [Chart-15m] Skipping update for historical candle (time: ${E.current.time}, current: ${s})`),null;const n=E.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-15m] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return E.current=e,Q(e),J(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,w.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1,l=n.open+e*r}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),E.current=a,Q(a),a.time!==s?(console.warn(`⚠️ [Chart-15m] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(J(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,w.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return w.current=e,e}return t}),a)}return null},[]),qt=s((t,e)=>{const i=Math.floor(e/1e3),s=3600*Math.floor(i/3600),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1h] Invalid price data: ${t}`),null;if(s!==T.current){let e=null,i=1;if(_.current&&_.current.close>0&&isFinite(_.current.close)&&_.current.time<s&&(e=_.current.close,_.current.open>0&&(i=_.current.close>=_.current.open?1:-1),console.log(`✅ [Chart-1h] Using currentCandle ref close (${_.current.time}) as new candle open: $${e.toFixed(2)}`)),null===e){const t=y.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s);r&&r.close>0&&isFinite(r.close)&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`🔄 [Chart-1h] Using last completed candle close from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&_.current&&_.current.close>0&&isFinite(_.current.close)&&(e=_.current.close,_.current.open>0&&(i=_.current.close>=_.current.open?1:-1),console.log(`✅ [Chart-1h] Method 3 (PRIMARY): Using currentCandle ref close (${_.current.time}) as new candle open: $${e.toFixed(2)}`)),_.current&&_.current.open>0&&_.current.high>0&&_.current.low>0&&_.current.close>0){const t={..._.current};null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-1h] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`)),t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),et(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,y.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return y.current=s,s})}null===e&&(console.error("❌ [Chart-1h] CRITICAL: No previous candle close found after all attempts!"),e=t);const n=e;console.log(`🕯️ [Chart-1h] Creating new candle: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return _.current=l,T.current=s,st(l),rt(s),et(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,y.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return y.current=i,i}),console.log(`🆕 [Chart-1h] New candle: $${t.toFixed(2)}`),l}if(_.current){const i=Math.floor(e/1e3),s=3600*Math.floor(i/3600);if(_.current.time!==s)return console.warn(`⚠️ [Chart-1h] Skipping update for historical candle (time: ${_.current.time}, current: ${s})`),null;const n=_.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-1h] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return _.current=e,st(e),et(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,y.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1,l=n.open+e*r}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),_.current=a,st(a),a.time!==s?(console.warn(`⚠️ [Chart-1h] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(et(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,y.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return y.current=e,e}return t}),a)}return null},[]),Xt=s((t,e)=>{const i=Math.floor(e/1e3),s=14400*Math.floor(i/14400),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-4h] Invalid price data: ${t}`),null;if(s!==N.current){let e=null,i=1;if($.current&&$.current.close>0&&isFinite($.current.close)&&$.current.time<s&&(e=$.current.close,$.current.open>0&&(i=$.current.close>=$.current.open?1:-1),console.log(`✅ [Chart-4h] Using currentCandle ref close (${$.current.time}) as new candle open: $${e.toFixed(2)}`)),null===e){const t=M.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s);r&&r.close>0&&isFinite(r.close)&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`🔄 [Chart-4h] Using last completed candle close from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&$.current&&$.current.close>0&&isFinite($.current.close)&&(e=$.current.close,$.current.open>0&&(i=$.current.close>=$.current.open?1:-1),console.log(`✅ [Chart-4h] Method 3 (PRIMARY): Using currentCandle ref close (${$.current.time}) as new candle open: $${e.toFixed(2)}`)),$.current&&$.current.open>0&&$.current.high>0&&$.current.low>0&&$.current.close>0){const t={...$.current};null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-4h] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`)),t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),ht(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,M.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return M.current=s,s})}null===e&&(console.error("❌ [Chart-4h] CRITICAL: No previous candle close found after all attempts!"),e=t);const n=e;console.log(`🕯️ [Chart-4h] Creating new candle: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return $.current=l,N.current=s,at(l),ut(s),ht(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,M.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return M.current=i,i}),console.log(`🆕 [Chart-4h] New candle: $${t.toFixed(2)}`),l}if($.current){const i=Math.floor(e/1e3),s=14400*Math.floor(i/14400);if($.current.time!==s)return console.warn(`⚠️ [Chart-4h] Skipping update for historical candle (time: ${$.current.time}, current: ${s})`),null;const n=$.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-4h] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return $.current=e,at(e),ht(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,M.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1,l=n.open+e*r}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),$.current=a,at(a),a.time!==s?(console.warn(`⚠️ [Chart-4h] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(ht(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,M.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return M.current=e,e}return t}),a)}return null},[]),Jt=s((t,e)=>{const i=Math.floor(e/1e3),s=86400*Math.floor(i/86400),n=Date.now();if(Rt.current&&n-Rt.current<50)return null;if(Rt.current=n,!t||t<=0||!isFinite(t))return console.warn(`⚠️ [Chart-1d] Invalid price data: ${t}`),null;if(s!==O.current){let e=null,i=1;if(z.current&&z.current.close>0&&isFinite(z.current.close)&&z.current.time<s&&(e=z.current.close,z.current.open>0&&(i=z.current.close>=z.current.open?1:-1),console.log(`✅ [Chart-1d] Using currentCandle ref close (${z.current.time}) as new candle open: $${e.toFixed(2)}`)),null===e){const t=x.current||[];if(t.length>0){const n=[...t].sort((t,e)=>e.time-t.time),r=n.find(t=>t.time<s);r&&r.close>0&&isFinite(r.close)&&(e=r.close,r.open>0&&(i=r.close>=r.open?1:-1),console.log(`🔄 [Chart-1d] Using last completed candle close from array (${r.time}) as new candle open: $${e.toFixed(2)}`))}}if(null===e&&z.current&&z.current.close>0&&isFinite(z.current.close)&&(e=z.current.close,z.current.open>0&&(i=z.current.close>=z.current.open?1:-1),console.log(`✅ [Chart-1d] Method 3 (PRIMARY): Using currentCandle ref close (${z.current.time}) as new candle open: $${e.toFixed(2)}`)),z.current&&z.current.open>0&&z.current.high>0&&z.current.low>0&&z.current.close>0){const t={...z.current};null===e&&(e=t.close,t.open>0&&(i=t.close>=t.open?1:-1),console.log(`✅ [Chart-1d] Method 4: Using finalized candle close (${t.time}) as new candle open: $${e.toFixed(2)}`)),t.high=Math.max(t.open,t.high,t.close),t.low=Math.min(t.open,t.low,t.close),ft(e=>{const i=e.findIndex(e=>e.time===t.time);if(i>=0){const s=[...e];return s[i]=t,x.current=s,s}const s=[...e,t].sort((t,e)=>t.time-e.time);return x.current=s,s})}null===e&&(console.error("❌ [Chart-1d] CRITICAL: No previous candle close found after all attempts!"),e=t);const n=e;console.log(`🕯️ [Chart-1d] Creating new candle: open=$${n.toFixed(2)} (from previous close), current price=$${t.toFixed(2)}`);let r=t;const o=Math.abs(n-t),h=Math.max(1e-4*n,.01);if(o<h){let e;e=0===o||Math.abs(t-n)<1e-4?null!==i?i:1:t>=n?1:-1,r=n+e*h}if(Math.abs(r-n)<h&&n>0){r=n+(t>=n||null!==i&&1===i?1:-1)*h}const l={time:s,open:n,high:Math.max(n,r,t),low:Math.min(n,r,t),close:r,volume:0};return z.current=l,O.current=s,pt(l),bt(s),ft(t=>{const e=t.findIndex(t=>t.time===l.time);if(e>=0){const i=[...t];return i[e]=l,x.current=i,i}const i=[...t,l].sort((t,e)=>t.time-e.time);return x.current=i,i}),console.log(`🆕 [Chart-1d] New candle: $${t.toFixed(2)}`),l}if(z.current){const i=Math.floor(e/1e3),s=86400*Math.floor(i/86400);if(z.current.time!==s)return console.warn(`⚠️ [Chart-1d] Skipping update for historical candle (time: ${z.current.time}, current: ${s})`),null;const n=z.current;if(n.open<=0||n.high<=0||n.low<=0||n.close<=0){console.warn("⚠️ [Chart-1d] Invalid existing candle data, recreating");const e={time:n.time,open:t,high:t,low:t,close:t,volume:0};return z.current=e,pt(e),ft(t=>{const i=t.findIndex(t=>t.time===e.time&&t.time===s);if(i>=0){const s=[...t];return s[i]=e,x.current=s,s}return t}),e}const r=Math.max(1e-4*n.open,.01),o=Math.abs(n.open-t),h=Math.abs(n.close-n.open);let l=t;if(h>0&&h<=10*r&&n.open>0)if(o<100*r){const e=t>=n.open?1:-1;l=n.open+e*r}else{l=t;if(Math.abs(l-n.open)<r){const e=t>=n.open?1:-1;l=n.open+e*r}}else if(o<r&&n.open>0){const e=t>=n.open?1:-1;l=n.open+e*r}if(Math.abs(l-n.open)<r&&n.open>0){let e;e=t!==n.open&&Math.abs(t-n.open)>1e-4?t>=n.open?1:-1:n.close!==n.open&&Math.abs(n.close-n.open)>1e-4?n.close>=n.open?1:-1:1,l=n.open+e*r}const a={...n,high:Math.max(n.high,t,l),low:Math.min(n.low,t,l),close:l};return a.high=Math.max(a.open,a.high,a.close),a.low=Math.min(a.open,a.low,a.close),z.current=a,pt(a),a.time!==s?(console.warn(`⚠️ [Chart-1d] Prevented update of historical candle: time=${a.time}, currentBucket=${s}`),a):(ft(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,x.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return x.current=e,e}return t}),a)}return null},[]);i(()=>{kt.current=wt},[wt]),i(()=>{P.current=It},[It]),i(()=>{if(!m.current)return;const t=Nn(m.current,{layout:{background:{color:"#ffffff"},textColor:"#333333"},grid:{vertLines:{color:"#f0f0f0"},horzLines:{color:"#f0f0f0"}},crosshair:{mode:vt.Normal},rightPriceScale:{borderColor:"#cccccc"},timeScale:{borderColor:"#cccccc",timeVisible:!0,secondsVisible:!1,rightOffset:12,barSpacing:8,minBarSpacing:4},height:384,localization:{priceFormatter:t=>Wt(t)},watermark:{visible:!0,fontSize:64,horzAlign:"center",vertAlign:"center",color:"rgba(0, 0, 0, 0.03)",text:h?`${h}/SOL`:`${o.substring(0,4)}...${o.substring(o.length-4)}/SOL`}});p.current=t;const e=t.addCandlestickSeries({upColor:"#26a69a",downColor:"#ef5350",borderVisible:!0,borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350"});g.current=e,jt(It.seconds).then(t=>{if(t.length>0){let i=t[t.length-1],s=t;if(Pt>0){const e=Math.floor(Date.now()/1e3),n=Math.floor(e/It.seconds)*It.seconds;if(i.time===n){const e=Math.max(1e-4*i.open,.01),n=Math.abs(i.open-Pt);let r=Pt;if(n<e&&i.open>0){const t=Pt>=i.open?1:-1;r=i.open+t*e}i={...i,high:Math.max(i.high,Pt,r),low:Math.min(i.low,Pt,r),close:r},s=[...t],s[s.length-1]=i,console.log(`🔄 [Chart-Init] Updated initial ${It.label} candle with current MC: $${Pt.toFixed(2)}`)}}switch(It.seconds){case 60:V(s),A(i.time),I(i),b.current=s,k.current=i.time,S.current=i,console.log(`✅ [Chart-Init] 1m refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`);break;case 300:j(s),q(i.time),H(i),v.current=s,R.current=i.time,C.current=i,console.log(`✅ [Chart-Init] 5m refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`);break;case 900:J(s),Z(i.time),Q(i),w.current=s,L.current=i.time,E.current=i,console.log(`✅ [Chart-Init] 15m refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`);break;case 3600:et(s),rt(i.time),st(i),y.current=s,T.current=i.time,_.current=i,console.log(`✅ [Chart-Init] 1h refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`);break;case 14400:ht(s),ut(i.time),at(i),M.current=s,N.current=i.time,$.current=i,console.log(`✅ [Chart-Init] 4h refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`);break;case 86400:ft(s),bt(i.time),pt(i),x.current=s,O.current=i.time,z.current=i,console.log(`✅ [Chart-Init] 1d refs initialized: lastCandle.time=${i.time}, close=$${i.close.toFixed(2)}`)}e.setData(s.map(t=>({...t,time:t.time}))),console.log(`✅ [Chart-${It.label}] Loaded and displayed ${s.length} candles`),60!==It.seconds&&jt(60).then(t=>{if(t.length>0){b.current=t;const e=t[t.length-1];k.current=e.time,S.current=e,console.log(`✅ [Chart-Init] 1m refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{}),300!==It.seconds&&jt(300).then(t=>{if(t.length>0){v.current=t;const e=t[t.length-1];R.current=e.time,C.current=e,console.log(`✅ [Chart-Init] 5m refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{}),900!==It.seconds&&jt(900).then(t=>{if(t.length>0){w.current=t;const e=t[t.length-1];L.current=e.time,E.current=e,console.log(`✅ [Chart-Init] 15m refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{}),3600!==It.seconds&&jt(3600).then(t=>{if(t.length>0){y.current=t;const e=t[t.length-1];T.current=e.time,_.current=e,console.log(`✅ [Chart-Init] 1h refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{}),14400!==It.seconds&&jt(14400).then(t=>{if(t.length>0){M.current=t;const e=t[t.length-1];N.current=e.time,$.current=e,console.log(`✅ [Chart-Init] 4h refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{}),86400!==It.seconds&&jt(86400).then(t=>{if(t.length>0){x.current=t;const e=t[t.length-1];O.current=e.time,z.current=e,console.log(`✅ [Chart-Init] 1d refs initialized from DB: close=$${e.close.toFixed(2)}`)}}).catch(()=>{})}xt(!1)}).catch(t=>{console.error(`❌ [Chart-${It.label}] Load error:`,t),xt(!1)});const i=()=>{m.current&&t.applyOptions({width:m.current.clientWidth})};return window.addEventListener("resize",i),i(),()=>{window.removeEventListener("resize",i),t.remove()}},[o,jt,Wt,It,h]);const Gt=s(async t=>{const e=Dt.find(e=>e.value===t);if(e&&e.value!==It.value){if(St)return void console.log(`⚠️ [Chart] Timeframe switch already in progress, ignoring ${e.label}`);console.log(`🔄 [Chart] Switching to ${e.label}`),Ct(!0),_t(e.label),xt(!0);try{let t=[];switch(e.seconds){case 60:t=b.current;break;case 300:t=v.current;break;case 900:t=w.current;break;case 3600:t=y.current;break;case 14400:t=M.current;break;case 86400:t=x.current}if(t.length>0){console.log(`✅ [Chart] Using ${t.length} cached ${e.label} candles`);let i=t,s=t[t.length-1];if(kt.current>0){const n=Math.floor(Date.now()/1e3),r=Math.floor(n/e.seconds)*e.seconds;if(s&&s.time===r){const n=Math.max(1e-4*s.open,.01),r=Math.abs(s.open-kt.current);let o=kt.current;if(r<n&&s.open>0){const t=kt.current>=s.open?1:-1;o=s.open+t*n}const h={...s,high:Math.max(s.high,kt.current,o),low:Math.min(s.low,kt.current,o),close:o};i=[...t],i[i.length-1]=h,s=h,console.log(`🔄 [Chart] Updated current ${e.label} candle with latest MC: $${kt.current.toFixed(2)}`)}}switch(e.seconds){case 60:V(i),A(s.time),I(s),b.current=i,k.current=s.time,S.current=s;break;case 300:j(i),q(s.time),H(s),v.current=i,R.current=s.time,C.current=s;break;case 900:J(i),Z(s.time),Q(s),w.current=i,L.current=s.time,E.current=s;break;case 3600:et(i),rt(s.time),st(s),y.current=i,T.current=s.time,_.current=s;break;case 14400:ht(i),ut(s.time),at(s),M.current=i,N.current=s.time,$.current=s;break;case 86400:ft(i),bt(s.time),pt(s),x.current=i,O.current=s.time,z.current=s}g.current&&g.current.setData(i.map(t=>({...t,time:t.time}))),setTimeout(()=>{Bt(e),xt(!1),Ct(!1),_t(null),console.log(`✅ [Chart] Switched to ${e.label} with ${i.length} cached candles`)},0)}else{console.log(`📊 [Chart] Loading ${e.label} candles`);const t=await jt(e.seconds);if(t.length>0){let i=t[t.length-1],s=t;if(kt.current>0){const n=Math.floor(Date.now()/1e3),r=Math.floor(n/e.seconds)*e.seconds;if(i.time===r){const n=Math.max(1e-4*i.open,.01),r=Math.abs(i.open-kt.current);let o=kt.current;if(r<n&&i.open>0){const t=kt.current>=i.open?1:-1;o=i.open+t*n}i={...i,high:Math.max(i.high,kt.current,o),low:Math.min(i.low,kt.current,o),close:o},s=[...t],s[s.length-1]=i,console.log(`🔄 [Chart] Updated loaded ${e.label} candle with current MC: $${kt.current.toFixed(2)}`)}}switch(e.seconds){case 60:V(s),A(i.time),I(i),b.current=s,k.current=i.time,S.current=i;break;case 300:j(s),q(i.time),H(i),v.current=s,R.current=i.time,C.current=i;break;case 900:J(s),Z(i.time),Q(i),w.current=s,L.current=i.time,E.current=i;break;case 3600:et(s),rt(i.time),st(i),y.current=s,T.current=i.time,_.current=i;break;case 14400:ht(s),ut(i.time),at(i),M.current=s,N.current=i.time,$.current=i;break;case 86400:ft(s),bt(i.time),pt(i),x.current=s,O.current=i.time,z.current=i}g.current&&g.current.setData(s.map(t=>({...t,time:t.time}))),setTimeout(()=>{Bt(e),xt(!1),Ct(!1),_t(null),console.log(`✅ [Chart] Switched to ${e.label} with ${s.length} loaded candles`)},0)}else setTimeout(()=>{Bt(e),xt(!1),Ct(!1),_t(null),console.log(`⚠️ [Chart] No candles loaded for ${e.label}`)},0)}}catch(t){console.error("❌ [Chart] Switch error:",t),setTimeout(()=>{Bt(e),xt(!1),Ct(!1),_t(null)},0)}}},[Dt,It,jt,St]);if(i(()=>{if(!o||!g.current||Pt<=0)return;if(!isFinite(Pt)||Pt<=0)return void console.warn(`⚠️ [Chart-Isolated] Invalid market cap data: ${Pt}`);console.log(`💰 [Chart-Isolated] Real-time update: $${Pt.toFixed(2)}`);const t=Date.now();requestAnimationFrame(()=>{Ut(Pt,t),Ht(Pt,t),Kt(Pt,t),qt(Pt,t),Xt(Pt,t),Jt(Pt,t),yt(Pt),xt(!1);const e=At();if(e.length>0){const t=e.filter(t=>t&&t.open>0&&t.high>0&&t.low>0&&t.close>0&&isFinite(t.open)&&isFinite(t.high)&&isFinite(t.low)&&isFinite(t.close));t.length>0&&g.current&&(g.current.setData(t.map(t=>({...t,time:t.time}))),requestAnimationFrame(()=>{p.current&&p.current.timeScale().scrollToRealTime()}))}})},[o,Pt,Ut,Ht,Kt,qt,Xt,Jt,At]),i(()=>{if(!Tt||!Nt||!o)return;const t=t=>{if(t.mint===o&&(console.log(`📡 [Chart-Isolated] Received multi-timeframe candles from backend for ${o}`,t.candles?Object.keys(t.candles):"no candles"),t.candles)){const e=t.candles,i=(t,e)=>{const i=Math.floor(Date.now()/1e3),s=Math.floor(i/t)*t;if(e.time!==s)return void console.warn(`⚠️ [Chart-Socket] Skipping backend update for historical candle: time=${e.time}, currentBucket=${s}, timeframe=${t}s`);let n=e.open,r=e.close;const o=Math.max(1e-4*n,.01),h=Math.abs(n-r);let l=null;switch(t){case 60:l=S.current;break;case 300:l=C.current;break;case 900:l=E.current;break;case 3600:l=_.current;break;case 14400:l=$.current;break;case 86400:l=z.current}if(l&&l.time===e.time&&l.open>0&&l){const e=Math.abs(l.close-l.open);if(e>=.5*o&&e<=2*o){if(Math.abs(l.open-r)<2*o)r=l.close,n=l.open,console.log(`🛡️ [Chart] Preserving minimum body size for ${t}s candle from frontend`);else if(h<o){r=n+(r>=n?1:-1)*o}}else if(h<o&&n>0){r=n+(r>=n?1:-1)*o}}else if(h<o&&n>0){r=n+(r>=n?1:-1)*o}if(Math.abs(r-n)<o&&n>0){r=n+(r>=n||l&&l.close>=l.open?1:-1)*o}const a={time:e.time,open:n,high:Math.max(e.high||n,n,r),low:Math.min(e.low||n,n,r),close:r,volume:e.volume||0};if(a.time===s)switch(t){case 60:S.current=a,k.current=a.time,I(a),A(a.time),V(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,b.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return b.current=e,e}return t});break;case 300:C.current=a,R.current=a.time,H(a),q(a.time),j(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,v.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return v.current=e,e}return t});break;case 900:E.current=a,L.current=a.time,Q(a),Z(a.time),J(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,w.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return w.current=e,e}return t});break;case 3600:_.current=a,T.current=a.time,st(a),rt(a.time),et(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,y.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return y.current=e,e}return t});break;case 14400:$.current=a,N.current=a.time,at(a),ut(a.time),ht(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,M.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return M.current=e,e}return t});break;case 86400:z.current=a,O.current=a.time,pt(a),bt(a.time),ft(t=>{const e=t.findIndex(t=>t.time===s);if(e>=0&&t[e].time===s){const i=[...t];return i[e]=a,x.current=i,i}if(a.time===s){const e=[...t,a].sort((t,e)=>t.time-e.time);return x.current=e,e}return t})}else console.warn(`⚠️ [Chart-Socket] Prevented update: candle time ${a.time} doesn't match current bucket ${s}`)};e["1m"]&&(i(60,e["1m"]),console.log("✅ [Chart-Isolated] Updated 1m from backend with full OHLC")),e["5m"]&&(i(300,e["5m"]),console.log("✅ [Chart-Isolated] Updated 5m from backend with full OHLC")),e["15m"]&&(i(900,e["15m"]),console.log("✅ [Chart-Isolated] Updated 15m from backend with full OHLC")),e["1h"]&&(i(3600,e["1h"]),console.log("✅ [Chart-Isolated] Updated 1h from backend with full OHLC")),e["4h"]&&(i(14400,e["4h"]),console.log("✅ [Chart-Isolated] Updated 4h from backend with full OHLC")),e["1d"]&&(i(86400,e["1d"]),console.log("✅ [Chart-Isolated] Updated 1d from backend with full OHLC"));const s=At();s.length>0&&g.current&&(g.current.setData(s.map(t=>({...t,time:t.time}))),requestAnimationFrame(()=>{p.current&&p.current.timeScale().scrollToRealTime()}))}};return Tt.on("multiTimeframeCandleUpdate",t),()=>{Tt.off("multiTimeframeCandleUpdate",t)}},[Tt,Nt,o,At]),i(()=>{const t=At();if((Mt||Vt)&&0===t.length){const t=setTimeout(()=>xt(!1),1e4);return()=>clearTimeout(t)}},[Mt,Vt,At]),$t)return t.createElement("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg"},t.createElement("div",{className:"text-red-800 font-medium"},"Chart Error"),t.createElement("div",{className:"text-red-600 text-sm"},$t),t.createElement("button",{onClick:()=>zt(null),className:"mt-2 px-3 py-1 bg-red-100 text-red-700 rounded text-sm hover:bg-red-200"},"Dismiss"));const Qt=At();return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"mb-4 flex flex-wrap gap-2 items-center"},t.createElement("div",{className:"flex flex-wrap gap-2"},Dt.map(e=>{const i=It.value===e.value,s=St&&Et===e.label,n=St;return t.createElement("button",{key:e.value,onClick:()=>Gt(e.value),disabled:n,className:`\n px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200 relative\n ${i?"bg-blue-600 text-white":n?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"}\n ${s?"animate-pulse":""}\n `},s&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center"},t.createElement("div",{className:"flex space-x-1"},t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse"}),t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse",style:{animationDelay:"0.1s"}}),t.createElement("div",{className:"w-1 h-1 bg-white rounded-full animate-pulse",style:{animationDelay:"0.2s"}}))),t.createElement("span",{className:s?"opacity-0":"opacity-100"},e.label))})),t.createElement("div",{className:"ml-auto flex items-center gap-2 text-sm"},t.createElement("div",{className:"w-2 h-2 rounded-full "+(Ft?"bg-green-500":"bg-red-500")}),t.createElement("span",{className:Ft?"text-green-600":"text-red-600"},Ft?"Connected":"Disconnected"),St&&Et&&t.createElement("span",{className:"text-blue-600"},"• Switching to ",Et,"..."),!St&&Mt&&!Vt&&t.createElement("span",{className:"text-blue-600"},"• Loading candles..."),Vt&&t.createElement("span",{className:"text-blue-600"},"• Connecting to analytics..."),!St&&!Mt&&!Vt&&Qt.length>0&&t.createElement("span",{className:"text-green-600"},"• ",Qt.length," ",It.label," candles • ",Wt(wt)))),t.createElement("div",{ref:m,className:"relative w-full h-96 transition-all duration-300 "+(St?"opacity-75 scale-[0.98]":"opacity-100 scale-100")},(St||Mt&&!Vt)&&t.createElement("div",{className:"absolute inset-0 bg-gradient-to-br from-white via-blue-50 to-white bg-opacity-90 flex items-center justify-center rounded-lg z-10 backdrop-blur-sm"},t.createElement("div",{className:"text-center"},t.createElement("div",{className:"flex justify-center items-center mb-4"},t.createElement("div",{className:"relative"},t.createElement("div",{className:"w-12 h-12 border-4 border-blue-200 rounded-full"}),t.createElement("div",{className:"absolute top-0 left-0 w-12 h-12 border-4 border-blue-600 rounded-full border-t-transparent animate-spin"}))),t.createElement("div",{className:"text-gray-700 font-medium text-lg"},St&&Et?`Switching to ${Et} timeframe...`:"Loading real-time data..."),t.createElement("div",{className:"mt-3 flex justify-center space-x-1"},t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce"}),t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.createElement("div",{className:"w-2 h-2 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})))),!St&&!Mt&&!Vt&&0===Qt.length&&t.createElement("div",{className:"absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center rounded-lg z-10"},t.createElement("div",{className:"text-center"},t.createElement("div",{className:"text-gray-600 mb-2"},"No ",It.label," market data available"),t.createElement("div",{className:"text-sm text-gray-500"},"Waiting for real-time data...")))))};const ah=new class{constructor(){this.timeframes={"1m":60,"5m":300,"15m":900,"30m":1800,"1h":3600,"4h":14400,"1d":86400}}aggregateCandles(t,e){try{if(60===e)return t;if(!Array.isArray(t)||0===t.length)return console.warn("⚠️ [CandleAggregation] No candles to aggregate"),[];const i=[...t].sort((t,e)=>t.time-e.time),s=[];let n=[],r=null;for(const t of i){const i=Math.floor(t.time/e)*e;if(null===r&&(r=i),i===r)n.push(t);else{if(n.length>0){const t=this.aggregateGroup(n,r);s.push(t)}n=[t],r=i}}if(n.length>0&&null!==r){const t=this.aggregateGroup(n,r);s.push(t)}return console.log(`📊 [CandleAggregation] Aggregated ${t.length} 1m candles into ${s.length} ${this.getTimeframeLabel(e)} candles`),s}catch(t){return console.error("❌ [CandleAggregation] Error aggregating candles:",t),[]}}aggregateGroup(t,e){const i=[...t].sort((t,e)=>t.time-e.time),s=i[0].open,n=i[i.length-1].close,r=Math.max(...i.map(t=>t.high)),o=Math.min(...i.map(t=>t.low)),h=i.reduce((t,e)=>t+(e.volume||0),0);return{time:e,open:s,high:r,low:o,close:n,volume:h}}getTimeframeLabel(t){for(const[e,i]of Object.entries(this.timeframes))if(i===t)return e;return`${t}s`}getTimeframeSeconds(t){return this.timeframes[t]||60}fillGaps(t,e){try{if(!Array.isArray(t)||t.length<2)return t;const i=[...t].sort((t,e)=>t.time-e.time),s=[];for(let t=0;t<i.length-1;t++){const n=i[t],r=i[t+1];s.push(n);let o=n.time+e;for(;o<r.time;)s.push({time:o,open:n.close,high:n.close,low:n.close,close:n.close,volume:0}),o+=e}return s.push(i[i.length-1]),s.length>i.length&&console.log(`🔧 [CandleAggregation] Filled ${s.length-i.length} gaps in ${this.getTimeframeLabel(e)} candles`),s}catch(e){return console.error("❌ [CandleAggregation] Error filling gaps:",e),t}}getCurrentCandle(t,e){try{if(!Array.isArray(t)||0===t.length)return null;const i=Math.floor(Date.now()/1e3),s=Math.floor(i/e)*e,n=t.filter(t=>Math.floor(t.time/e)*e===s);return 0===n.length?null:this.aggregateGroup(n,s)}catch(t){return console.error("❌ [CandleAggregation] Error getting current candle:",t),null}}updateRealtimeCandle(t,e,i){try{if(!e)return t;const s=Math.floor(e.time/i)*i,n=t.findIndex(t=>t.time===s);if(n>=0){const i=t[n],r={time:s,open:i.open,high:Math.max(i.high,e.high),low:Math.min(i.low,e.low),close:e.close,volume:i.volume+(e.volume||0)},o=[...t];return o[n]=r,o}{const i={time:s,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume||0};return[...t,i].sort((t,e)=>t.time-e.time)}}catch(e){return console.error("❌ [CandleAggregation] Error updating realtime candle:",e),t}}isValidCandle(t){return t&&"number"==typeof t.time&&"number"==typeof t.open&&"number"==typeof t.high&&"number"==typeof t.low&&"number"==typeof t.close&&t.high>=t.low&&t.high>=t.open&&t.high>=t.close&&t.low<=t.open&&t.low<=t.close}cleanCandles(t){if(!Array.isArray(t))return[];const e=t.filter(t=>this.isValidCandle(t));return e.length<t.length&&console.warn(`⚠️ [CandleAggregation] Removed ${t.length-e.length} invalid candles`),e}getRequiredOneMinuteCandles(t,e=200){const i=t/60;return Math.ceil(e*i)}};export{oh as API_CONFIG,lh as FunhiChart,ah as candleAggregation,hh as candleStorageService,Pn as useOptimizedTokenAnalytics,On as useSocket};
8
8
  //# sourceMappingURL=index.esm.js.map