@nabeeltahirdeveloper/chart-sdk 1.0.0 → 1.1.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.
@@ -1,6 +1,6 @@
1
- (function(rt,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],ne):(rt=typeof globalThis<"u"?globalThis:rt||self,ne(rt.ChartSDK={},rt.jsxRuntime,rt.React))})(this,(function(rt,ne,E){"use strict";var Bi=typeof document<"u"?document.currentScript:null;function at(s){var t=s.width,e=s.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(e<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:e}}function fe(s,t){return s.width===t.width&&s.height===t.height}var Bo=(function(){function s(t){var e=this;this._resolutionListener=function(){return e._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return s.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(s.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),s.prototype.subscribe=function(t){var e=this,i={next:t};return this._observers.push(i),{unsubscribe:function(){e._observers=e._observers.filter(function(n){return n!==i})}}},s.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},s.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},s.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},s.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(e){return e.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},s})();function Fo(s){return new Bo(s)}var zo=(function(){function s(t,e,i){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=at({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=e??(function(r){return r}),this._allowResizeObserver=(n=i?.allowResizeObserver)!==null&&n!==void 0?n:!0,this._chooseAndInitObserver()}return s.prototype.dispose=function(){var t,e;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(e=this._devicePixelRatioObservable)===null||e===void 0||e.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(s.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"bitmapSize",{get:function(){return at({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),s.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=at(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},s.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(e){return e!==t})},Object.defineProperty(s.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),s.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(e){return e!==t})},s.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},s.prototype._resizeBitmap=function(t){var e=this.bitmapSize;fe(e,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(e,t))},s.prototype._emitBitmapSizeChanged=function(t,e){var i=this;this._bitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._suggestNewBitmapSize=function(t){var e=this._suggestedBitmapSize,i=at(this._transformBitmapSize(t,this._canvasElementClientSize)),n=fe(this.bitmapSize,i)?null:i;e===null&&n===null||e!==null&&n!==null&&fe(e,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(e,n))},s.prototype._emitSuggestedBitmapSizeChanged=function(t,e){var i=this;this._suggestedBitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}Vo().then(function(e){return e?t._initResizeObserver():t._initDevicePixelRatioObservable()})},s.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var e=Qs(this._canvasElement);if(e===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=Fo(e),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},s.prototype._invalidateBitmapSize=function(){var t,e;if(this._canvasElement!==null){var i=Qs(this._canvasElement);if(i!==null){var n=(e=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&e!==void 0?e:i.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?Wo(r[0],n):at({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(o)}}},s.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(e){var i=e.find(function(o){return o.target===t._canvasElement});if(!(!i||!i.devicePixelContentBoxSize||!i.devicePixelContentBoxSize[0])){var n=i.devicePixelContentBoxSize[0],r=at({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},s})();function Uo(s,t){return new zo(s,t.transform,t.options)}function Qs(s){return s.ownerDocument.defaultView}function Vo(){return new Promise(function(s){var t=new ResizeObserver(function(e){s(e.every(function(i){return"devicePixelContentBoxSize"in i})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function Wo(s,t){return at({width:Math.round(s.left*t+s.width*t)-Math.round(s.left*t),height:Math.round(s.top*t+s.height*t)-Math.round(s.top*t)})}var Io=(function(){function s(t,e,i){if(e.width===0||e.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=e,i.width===0||i.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=i,this._context=t}return s.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},s.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(s.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),s})();function de(s,t){var e=s.canvasElementClientSize;if(e.width===0||e.height===0)return null;var i=s.bitmapSize;if(i.width===0||i.height===0)return null;var n=s.canvasElement.getContext("2d",t);return n===null?null:new Io(n,e,i)}const qo={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},Ho={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},$o={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jo={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},Jo={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},Ko={color:"#26a69a",base:0},tn={color:"#2196f3"},en={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 sn,nn;function pe(s,t){const e={0:[],1:[s.lineWidth,s.lineWidth],2:[2*s.lineWidth,2*s.lineWidth],3:[6*s.lineWidth,6*s.lineWidth],4:[s.lineWidth,4*s.lineWidth]}[t];s.setLineDash(e)}function rn(s,t,e,i){s.beginPath();const n=s.lineWidth%2?.5:0;s.moveTo(e,t+n),s.lineTo(i,t+n),s.stroke()}function le(s,t){if(!s)throw new Error("Assertion failed"+(t?": "+t:""))}function kt(s){if(s===void 0)throw new Error("Value is undefined");return s}function S(s){if(s===null)throw new Error("Value is null");return s}function Se(s){return S(kt(s))}(function(s){s[s.Simple=0]="Simple",s[s.WithSteps=1]="WithSteps",s[s.Curved=2]="Curved"})(sn||(sn={})),(function(s){s[s.Solid=0]="Solid",s[s.Dotted=1]="Dotted",s[s.Dashed=2]="Dashed",s[s.LargeDashed=3]="LargeDashed",s[s.SparseDotted=4]="SparseDotted"})(nn||(nn={}));const on={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 zt(s){return s<0?0:s>255?255:Math.round(s)||0}function hn(s){return s<=0||s>0?s<0?0:s>1?1:Math.round(1e4*s)/1e4:0}const Xo=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,Yo=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,Go=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,Zo=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/;function Ze(s){(s=s.toLowerCase())in on&&(s=on[s]);{const t=Zo.exec(s)||Go.exec(s);if(t)return[zt(parseInt(t[1],10)),zt(parseInt(t[2],10)),zt(parseInt(t[3],10)),hn(t.length<5?1:parseFloat(t[4]))]}{const t=Yo.exec(s);if(t)return[zt(parseInt(t[1],16)),zt(parseInt(t[2],16)),zt(parseInt(t[3],16)),1]}{const t=Xo.exec(s);if(t)return[zt(17*parseInt(t[1],16)),zt(17*parseInt(t[2],16)),zt(17*parseInt(t[3],16)),1]}throw new Error(`Cannot parse color: ${s}`)}function Qe(s){const t=Ze(s);return{t:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,i:(e=t,.199*e[0]+.687*e[1]+.114*e[2]>160?"black":"white")};var e}class yt{constructor(){this.h=[]}l(t,e,i){const n={o:t,_:e,u:i===!0};this.h.push(n)}v(t){const e=this.h.findIndex((i=>t===i.o));e>-1&&this.h.splice(e,1)}p(t){this.h=this.h.filter((e=>e._!==t))}m(t,e,i){const n=[...this.h];this.h=this.h.filter((r=>!r.u)),n.forEach((r=>r.o(t,e,i)))}M(){return this.h.length>0}S(){this.h=[]}}function Ht(s,...t){for(const e of t)for(const i in e)e[i]!==void 0&&(typeof e[i]!="object"||s[i]===void 0||Array.isArray(e[i])?s[i]=e[i]:Ht(s[i],e[i]));return s}function Kt(s){return typeof s=="number"&&isFinite(s)}function ke(s){return typeof s=="number"&&s%1==0}function Pe(s){return typeof s=="string"}function ti(s){return typeof s=="boolean"}function re(s){const t=s;if(!t||typeof t!="object")return t;let e,i,n;for(i in e=Array.isArray(t)?[]:{},t)t.hasOwnProperty(i)&&(n=t[i],e[i]=n&&typeof n=="object"?re(n):n);return e}function Qo(s){return s!==null}function Ae(s){return s===null?void 0:s}const Fi="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function _e(s,t,e){return t===void 0&&(t=Fi),`${e=e!==void 0?`${e} `:""}${s}px ${t}`}class th{constructor(t){this.k={C:1,T:5,P:NaN,R:"",D:"",O:"",A:"",V:0,B: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=_e(e,i),t.L=2.5/12*e,t.V=t.L,t.B=e/12*t.T,t.I=e/12*t.T,t.N=0),t.O=this.$(),t.A=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 zi{constructor(){this.Y=[]}X(t){this.Y=t}K(t,e,i){this.Y.forEach((n=>{n.K(t,e,i)}))}}class Ui{K(t,e,i){t.useMediaCoordinateSpace((n=>this.Z(n,e,i)))}G(t,e,i){t.useMediaCoordinateSpace((n=>this.J(n,e,i)))}J(t,e,i){}}class eh extends Ui{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z({context:t}){if(this.tt===null||this.tt.nt===null)return;const e=this.tt.nt,i=this.tt,n=r=>{t.beginPath();for(let o=e.to-1;o>=e.from;--o){const h=i.st[o];t.moveTo(h.et,h.rt),t.arc(h.et,h.rt,r,0,2*Math.PI)}t.fill()};i.ht>0&&(t.fillStyle=i.lt,n(i.ot+i.ht)),t.fillStyle=i._t,n(i.ot)}}function ih(){return{st:[{et:0,rt:0,ut:0,ct:0}],_t:"",lt:"",ot:0,ht:0,nt:null}}const sh={from:0,to:1};class nh{constructor(t,e){this.dt=new zi,this.ft=[],this.vt=[],this.bt=!0,this.F=t,this.wt=e,this.dt.X(this.ft)}gt(t){const e=this.F.Mt();e.length!==this.ft.length&&(this.vt=e.map(ih),this.ft=this.vt.map((i=>{const n=new eh;return n.it(i),n})),this.dt.X(this.ft)),this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.dt}St(){const t=this.wt.W().mode===2,e=this.F.Mt(),i=this.wt.kt(),n=this.F.yt();e.forEach(((r,o)=>{var h;const l=this.vt[o],a=r.Ct(i);if(t||a===null||!r.Tt())return void(l.nt=null);const c=S(r.Pt());l._t=a.Rt,l.ot=a.ot,l.ht=a.Dt,l.st[0].ct=a.ct,l.st[0].rt=r.At().Ot(a.ct,c.Vt),l.lt=(h=a.Bt)!==null&&h!==void 0?h:this.F.It(l.st[0].rt/r.At().zt()),l.st[0].ut=i,l.st[0].et=n.Et(i),l.nt=sh}))}}class oe{K(t,e,i){t.useBitmapCoordinateSpace((n=>this.Z(n,e,i)))}}class rh extends oe{constructor(t){super(),this.Lt=t}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null)return;const r=this.Lt.Nt.Tt,o=this.Lt.Ft.Tt;if(!r&&!o)return;const h=Math.round(this.Lt.et*i),l=Math.round(this.Lt.rt*n);t.lineCap="butt",r&&h>=0&&(t.lineWidth=Math.floor(this.Lt.Nt.ht*i),t.strokeStyle=this.Lt.Nt.O,t.fillStyle=this.Lt.Nt.O,pe(t,this.Lt.Nt.Wt),(function(a,c,u,p){a.beginPath();const g=a.lineWidth%2?.5:0;a.moveTo(c+g,u),a.lineTo(c+g,p),a.stroke()})(t,h,0,e.height)),o&&l>=0&&(t.lineWidth=Math.floor(this.Lt.Ft.ht*n),t.strokeStyle=this.Lt.Ft.O,t.fillStyle=this.Lt.Ft.O,pe(t,this.Lt.Ft.Wt),rn(t,l,0,e.width))}}class oh{constructor(t){this.bt=!0,this.jt={Nt:{ht:1,Wt:0,O:"",Tt:!1},Ft:{ht:1,Wt:0,O:"",Tt:!1},et:0,rt:0},this.Ht=new rh(this.jt),this.$t=t}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht}St(){const t=this.$t.Tt(),e=S(this.$t.Ut()),i=e.qt().W().crosshair,n=this.jt;if(i.mode===2)return n.Ft.Tt=!1,void(n.Nt.Tt=!1);n.Ft.Tt=t&&this.$t.Yt(e),n.Nt.Tt=t&&this.$t.Xt(),n.Ft.ht=i.horzLine.width,n.Ft.Wt=i.horzLine.style,n.Ft.O=i.horzLine.color,n.Nt.ht=i.vertLine.width,n.Nt.Wt=i.vertLine.style,n.Nt.O=i.vertLine.color,n.et=this.$t.Kt(),n.rt=this.$t.Zt()}}function hh(s,t,e,i,n,r){s.fillRect(t+r,e,i-2*r,r),s.fillRect(t+r,e+n-r,i-2*r,r),s.fillRect(t,e,r,n),s.fillRect(t+i-r,e,r,n)}function ei(s,t,e,i,n,r){s.save(),s.globalCompositeOperation="copy",s.fillStyle=r,s.fillRect(t,e,i,n),s.restore()}function ln(s,t){return s.map((e=>e===0?e:e+t))}function Vi(s,t,e,i,n,r){s.beginPath(),s.lineTo(t+i-r[1],e),r[1]!==0&&s.arcTo(t+i,e,t+i,e+r[1],r[1]),s.lineTo(t+i,e+n-r[2]),r[2]!==0&&s.arcTo(t+i,e+n,t+i-r[2],e+n,r[2]),s.lineTo(t+r[3],e+n),r[3]!==0&&s.arcTo(t,e+n,t,e+n-r[3],r[3]),s.lineTo(t,e+r[0]),r[0]!==0&&s.arcTo(t,e,t+r[0],e,r[0])}function an(s,t,e,i,n,r,o=0,h=[0,0,0,0],l=""){if(s.save(),!o||!l||l===r)return Vi(s,t,e,i,n,h),s.fillStyle=r,s.fill(),void s.restore();const a=o/2;r!=="transparent"&&(Vi(s,t+o,e+o,i-2*o,n-2*o,ln(h,-o)),s.fillStyle=r,s.fill()),l!=="transparent"&&(Vi(s,t+a,e+a,i-o,n-o,ln(h,-a)),s.lineWidth=o,s.strokeStyle=l,s.closePath(),s.stroke()),s.restore()}function cn(s,t,e,i,n,r,o){s.save(),s.globalCompositeOperation="copy";const h=s.createLinearGradient(0,0,0,n);h.addColorStop(0,r),h.addColorStop(1,o),s.fillStyle=h,s.fillRect(t,e,i,n),s.restore()}class un{constructor(t,e){this.it(t,e)}it(t,e){this.Lt=t,this.Gt=e}zt(t,e){return this.Lt.Tt?t.P+t.L+t.V:0}K(t,e,i,n){if(!this.Lt.Tt||this.Lt.Jt.length===0)return;const r=this.Lt.O,o=this.Gt.t,h=t.useBitmapCoordinateSpace((l=>{const a=l.context;a.font=e.R;const c=this.Qt(l,e,i,n),u=c.ti,p=(g,d)=>{c.ii?an(a,u.ni,u.si,u.ei,u.ri,g,u.hi,[u.ot,0,0,u.ot],d):an(a,u.li,u.si,u.ei,u.ri,g,u.hi,[0,u.ot,u.ot,0],d)};return p(o,"transparent"),this.Lt.ai&&(a.fillStyle=r,a.fillRect(u.li,u.oi,u._i-u.li,u.ui)),p("transparent",o),this.Lt.ci&&(a.fillStyle=e.A,a.fillRect(c.ii?u.di-u.hi:0,u.si,u.hi,u.fi-u.si)),c}));t.useMediaCoordinateSpace((({context:l})=>{const a=h.vi;l.font=e.R,l.textAlign=h.ii?"right":"left",l.textBaseline="middle",l.fillStyle=r,l.fillText(this.Lt.Jt,a.pi,(a.si+a.fi)/2+a.mi)}))}Qt(t,e,i,n){var r;const{context:o,bitmapSize:h,mediaSize:l,horizontalPixelRatio:a,verticalPixelRatio:c}=t,u=this.Lt.ai||!this.Lt.bi?e.T:0,p=this.Lt.wi?e.C:0,g=e.L+this.Gt.gi,d=e.V+this.Gt.Mi,f=e.B,m=e.I,w=this.Lt.Jt,M=e.P,R=i.xi(o,w),k=Math.ceil(i.Si(o,w)),$=M+g+d,Q=e.C+f+m+k+u,G=Math.max(1,Math.floor(c));let st=Math.round($*c);st%2!=G%2&&(st+=1);const tt=p>0?Math.max(1,Math.floor(p*a)):0,Nt=Math.round(Q*a),Jt=Math.round(u*a),Vt=(r=this.Gt.ki)!==null&&r!==void 0?r:this.Gt.yi,Bt=Math.round(Vt*c)-Math.floor(.5*c),dt=Math.floor(Bt+G/2-st/2),et=dt+st,ot=n==="right",ht=ot?l.width-p:p,Lt=ot?h.width-tt:tt;let wt,mt,gt;return ot?(wt=Lt-Nt,mt=Lt-Jt,gt=ht-u-f-p):(wt=Lt+Nt,mt=Lt+Jt,gt=ht+u+f),{ii:ot,ti:{si:dt,oi:Bt,fi:et,ei:Nt,ri:st,ot:2*a,hi:tt,ni:wt,li:Lt,_i:mt,ui:G,di:h.width},vi:{si:dt/c,fi:et/c,pi:gt,mi:R}}}}class ii{constructor(t){this.Ci={yi:0,t:"#000",Mi:0,gi:0},this.Ti={Jt:"",Tt:!1,ai:!0,bi:!1,Bt:"",O:"#FFF",ci:!1,wi:!1},this.Pi={Jt:"",Tt:!1,ai:!1,bi:!0,Bt:"",O:"#FFF",ci:!0,wi:!0},this.bt=!0,this.Ri=new(t||un)(this.Ti,this.Ci),this.Di=new(t||un)(this.Pi,this.Ci)}Jt(){return this.Oi(),this.Ti.Jt}yi(){return this.Oi(),this.Ci.yi}gt(){this.bt=!0}zt(t,e=!1){return Math.max(this.Ri.zt(t,e),this.Di.zt(t,e))}Ai(){return this.Ci.ki||0}Vi(t){this.Ci.ki=t}Bi(){return this.Oi(),this.Ti.Tt||this.Pi.Tt}Ii(){return this.Oi(),this.Ti.Tt}xt(t){return this.Oi(),this.Ti.ai=this.Ti.ai&&t.W().ticksVisible,this.Pi.ai=this.Pi.ai&&t.W().ticksVisible,this.Ri.it(this.Ti,this.Ci),this.Di.it(this.Pi,this.Ci),this.Ri}zi(){return this.Oi(),this.Ri.it(this.Ti,this.Ci),this.Di.it(this.Pi,this.Ci),this.Di}Oi(){this.bt&&(this.Ti.ai=!0,this.Pi.ai=!1,this.Ei(this.Ti,this.Pi,this.Ci))}}class lh extends ii{constructor(t,e,i){super(),this.$t=t,this.Li=e,this.Ni=i}Ei(t,e,i){if(t.Tt=!1,this.$t.W().mode===2)return;const n=this.$t.W().horzLine;if(!n.labelVisible)return;const r=this.Li.Pt();if(!this.$t.Tt()||this.Li.Fi()||r===null)return;const o=Qe(n.labelBackgroundColor);i.t=o.t,t.O=o.i;const h=2/12*this.Li.P();i.gi=h,i.Mi=h;const l=this.Ni(this.Li);i.yi=l.yi,t.Jt=this.Li.Wi(l.ct,r),t.Tt=!0}}const ah=/[1-9]/g;class fn{constructor(){this.Lt=null}it(t){this.Lt=t}K(t,e){if(this.Lt===null||this.Lt.Tt===!1||this.Lt.Jt.length===0)return;const i=t.useMediaCoordinateSpace((({context:p})=>(p.font=e.R,Math.round(e.ji.Si(p,S(this.Lt).Jt,ah)))));if(i<=0)return;const n=e.Hi,r=i+2*n,o=r/2,h=this.Lt.$i;let l=this.Lt.yi,a=Math.floor(l-o)+.5;a<0?(l+=Math.abs(0-a),a=Math.floor(l-o)+.5):a+r>h&&(l-=Math.abs(h-(a+r)),a=Math.floor(l-o)+.5);const c=a+r,u=Math.ceil(0+e.C+e.T+e.L+e.P+e.V);t.useBitmapCoordinateSpace((({context:p,horizontalPixelRatio:g,verticalPixelRatio:d})=>{const f=S(this.Lt);p.fillStyle=f.t;const m=Math.round(a*g),w=Math.round(0*d),M=Math.round(c*g),R=Math.round(u*d),k=Math.round(2*g);if(p.beginPath(),p.moveTo(m,w),p.lineTo(m,R-k),p.arcTo(m,R,m+k,R,k),p.lineTo(M-k,R),p.arcTo(M,R,M,R-k,k),p.lineTo(M,w),p.fill(),f.ai){const $=Math.round(f.yi*g),Q=w,G=Math.round((Q+e.T)*d);p.fillStyle=f.O;const st=Math.max(1,Math.floor(g)),tt=Math.floor(.5*g);p.fillRect($-tt,Q,st,G-Q)}})),t.useMediaCoordinateSpace((({context:p})=>{const g=S(this.Lt),d=0+e.C+e.T+e.L+e.P/2;p.font=e.R,p.textAlign="left",p.textBaseline="middle",p.fillStyle=g.O;const f=e.ji.xi(p,"Apr0");p.translate(a+n,d+f),p.fillText(g.Jt,0,0)}))}}class ch{constructor(t,e,i){this.bt=!0,this.Ht=new fn,this.jt={Tt:!1,t:"#4c525e",O:"white",Jt:"",$i:0,yi:NaN,ai:!0},this.wt=t,this.Ui=e,this.Ni=i}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht.it(this.jt),this.Ht}St(){const t=this.jt;if(t.Tt=!1,this.wt.W().mode===2)return;const e=this.wt.W().vertLine;if(!e.labelVisible)return;const i=this.Ui.yt();if(i.Fi())return;t.$i=i.$i();const n=this.Ni();if(n===null)return;t.yi=n.yi;const r=i.qi(this.wt.kt());t.Jt=i.Yi(S(r)),t.Tt=!0;const o=Qe(e.labelBackgroundColor);t.t=o.t,t.O=o.i,t.ai=i.W().ticksVisible}}class Wi{constructor(){this.Xi=null,this.Ki=0}Zi(){return this.Ki}Gi(t){this.Ki=t}At(){return this.Xi}Ji(t){this.Xi=t}Qi(t){return[]}tn(){return[]}Tt(){return!0}}var dn;(function(s){s[s.Normal=0]="Normal",s[s.Magnet=1]="Magnet",s[s.Hidden=2]="Hidden"})(dn||(dn={}));class uh extends Wi{constructor(t,e){super(),this.nn=null,this.sn=NaN,this.en=0,this.rn=!0,this.hn=new Map,this.ln=!1,this.an=NaN,this.on=NaN,this._n=NaN,this.un=NaN,this.Ui=t,this.cn=e,this.dn=new nh(t,this),this.fn=((n,r)=>o=>{const h=r(),l=n();if(o===S(this.nn).vn())return{ct:l,yi:h};{const a=S(o.Pt());return{ct:o.pn(h,a),yi:h}}})((()=>this.sn),(()=>this.on));const i=((n,r)=>()=>{const o=this.Ui.yt().mn(n()),h=r();return o&&Number.isFinite(h)?{ut:o,yi:h}:null})((()=>this.en),(()=>this.Kt()));this.bn=new ch(this,t,i),this.wn=new oh(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.ln||(this.ln=!0),this.rn=!0,this.yn(t,e,i)}kt(){return this.en}Kt(){return this.an}Zt(){return this.on}Tt(){return this.rn}Cn(){this.rn=!1,this.Tn(),this.sn=NaN,this.an=NaN,this.on=NaN,this.nn=null,this.Mn()}Pn(t){return this.nn!==null?[this.wn,this.dn]:[]}Yt(t){return t===this.nn&&this.cn.horzLine.visible}Xt(){return this.cn.vertLine.visible}Rn(t,e){this.rn&&this.nn===t||this.hn.clear();const i=[];return this.nn===t&&i.push(this.Dn(this.hn,e,this.fn)),i}tn(){return this.rn?[this.bn]:[]}Ut(){return this.nn}On(){this.wn.gt(),this.hn.forEach((t=>t.gt())),this.bn.gt(),this.dn.gt()}An(t){return t&&!t.vn().Fi()?t.vn():null}yn(t,e,i){this.Vn(t,e,i)&&this.On()}Vn(t,e,i){const n=this.an,r=this.on,o=this.sn,h=this.en,l=this.nn,a=this.An(i);this.en=t,this.an=isNaN(t)?NaN:this.Ui.yt().Et(t),this.nn=i;const c=a!==null?a.Pt():null;return a!==null&&c!==null?(this.sn=e,this.on=a.Ot(e,c)):(this.sn=NaN,this.on=NaN),n!==this.an||r!==this.on||h!==this.en||o!==this.sn||l!==this.nn}Tn(){const t=this.Ui.Mt().map((i=>i.In().Bn())).filter(Qo),e=t.length===0?null:Math.max(...t);this.en=e!==null?e:NaN}Dn(t,e,i){let n=t.get(e);return n===void 0&&(n=new lh(this,e,i),t.set(e,n)),n}}function si(s){return s==="left"||s==="right"}class Ct{constructor(t){this.zn=new Map,this.En=[],this.Ln=t}Nn(t,e){const i=(function(n,r){return n===void 0?r:{Fn:Math.max(n.Fn,r.Fn),Wn:n.Wn||r.Wn}})(this.zn.get(t),e);this.zn.set(t,i)}jn(){return this.Ln}Hn(t){const e=this.zn.get(t);return e===void 0?{Fn:this.Ln}:{Fn:Math.max(this.Ln,e.Fn),Wn:e.Wn}}$n(){this.Un(),this.En=[{qn:0}]}Yn(t){this.Un(),this.En=[{qn:1,Vt:t}]}Xn(t){this.Kn(),this.En.push({qn:5,Vt:t})}Un(){this.Kn(),this.En.push({qn:6})}Zn(){this.Un(),this.En=[{qn:4}]}Gn(t){this.Un(),this.En.push({qn:2,Vt:t})}Jn(t){this.Un(),this.En.push({qn:3,Vt:t})}Qn(){return this.En}ts(t){for(const e of t.En)this.ns(e);this.Ln=Math.max(this.Ln,t.Ln),t.zn.forEach(((e,i)=>{this.Nn(i,e)}))}static ss(){return new Ct(2)}static es(){return new Ct(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.Zn();break;case 5:this.Xn(t.Vt);break;case 6:this.Kn()}}Kn(){const t=this.En.findIndex((e=>e.qn===5));t!==-1&&this.En.splice(t,1)}}const pn=".";function he(s,t){if(!Kt(s))return"n/a";if(!ke(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?s.toString():("0000000000000000"+s.toString()).slice(-t)}class ni{constructor(t,e){if(e||(e=1),Kt(t)&&ke(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.os=0,this.Li>0&&this.rs>0){let t=this.Li;for(;t>1;)t/=10,this.os++}}ls(t){const e=this.Li/this.rs;let i=Math.floor(t),n="";const r=this.os!==void 0?this.os:NaN;if(e>1){let o=+(Math.round(t*e)-i*e).toFixed(this.os);o>=e&&(o-=e,i+=1),n=pn+he(+o.toFixed(this.os)*this.rs,r)}else i=Math.round(i*e)/e,r>0&&(n=pn+he(0,r));return i.toFixed(0)+n}}class mn extends ni{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class fh{constructor(t){this._s=t}format(t){let e="";return t<0&&(e="-",t=-t),t<995?e+this.us(t):t<999995?e+this.us(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),e+this.us(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),e+this.us(t/1e9)+"B")}us(t){let e;const i=Math.pow(10,this._s);return e=(t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this._s).replace(/\.?0+$/,""):String(t),e.replace(/(\.[1-9]*)0+$/,((n,r)=>r))}}function gn(s,t,e,i,n,r,o){if(t.length===0||i.from>=t.length||i.to<=0)return;const{context:h,horizontalPixelRatio:l,verticalPixelRatio:a}=s,c=t[i.from];let u=r(s,c),p=c;if(i.to-i.from<2){const g=n/2;h.beginPath();const d={et:c.et-g,rt:c.rt},f={et:c.et+g,rt:c.rt};h.moveTo(d.et*l,d.rt*a),h.lineTo(f.et*l,f.rt*a),o(s,u,d,f)}else{const g=(f,m)=>{o(s,u,p,m),h.beginPath(),u=f,p=m};let d=p;h.beginPath(),h.moveTo(c.et*l,c.rt*a);for(let f=i.from+1;f<i.to;++f){d=t[f];const m=r(s,d);switch(e){case 0:h.lineTo(d.et*l,d.rt*a);break;case 1:h.lineTo(d.et*l,t[f-1].rt*a),m!==u&&(g(m,d),h.lineTo(d.et*l,t[f-1].rt*a)),h.lineTo(d.et*l,d.rt*a);break;case 2:{const[w,M]=dh(t,f-1,f);h.bezierCurveTo(w.et*l,w.rt*a,M.et*l,M.rt*a,d.et*l,d.rt*a);break}}e!==1&&m!==u&&(g(m,d),h.moveTo(d.et*l,d.rt*a))}(p!==d||p===d&&e===1)&&o(s,u,p,d)}}const bn=6;function Ii(s,t){return{et:s.et-t.et,rt:s.rt-t.rt}}function vn(s,t){return{et:s.et/t,rt:s.rt/t}}function dh(s,t,e){const i=Math.max(0,t-1),n=Math.min(s.length-1,e+1);var r,o;return[(r=s[t],o=vn(Ii(s[e],s[i]),bn),{et:r.et+o.et,rt:r.rt+o.rt}),Ii(s[e],vn(Ii(s[n],s[t]),bn))]}function ph(s,t,e,i,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:h}=t;r.lineTo(n.et*o,s*h),r.lineTo(i.et*o,s*h),r.closePath(),r.fillStyle=e,r.fill()}class yn extends oe{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z(t){var e;if(this.tt===null)return;const{st:i,nt:n,cs:r,ht:o,Wt:h,ds:l}=this.tt,a=(e=this.tt.fs)!==null&&e!==void 0?e:this.tt.vs?0:t.mediaSize.height;if(n===null)return;const c=t.context;c.lineCap="butt",c.lineJoin="round",c.lineWidth=o,pe(c,h),c.lineWidth=1,gn(t,i,l,n,r,this.ps.bind(this),ph.bind(null,a))}}function qi(s,t,e){return Math.min(Math.max(s,t),e)}function ri(s,t,e){return t-s<=e}function wn(s){const t=Math.ceil(s);return t%2==0?t-1:t}class Hi{bs(t,e){const i=this.ws,{gs:n,Ms:r,xs:o,Ss:h,ks:l,fs:a}=e;if(this.ys===void 0||i===void 0||i.gs!==n||i.Ms!==r||i.xs!==o||i.Ss!==h||i.fs!==a||i.ks!==l){const c=t.context.createLinearGradient(0,0,0,l);if(c.addColorStop(0,n),a!=null){const u=qi(a*t.verticalPixelRatio/l,0,1);c.addColorStop(u,r),c.addColorStop(u,o)}c.addColorStop(1,h),this.ys=c,this.ws=e}return this.ys}}class mh extends yn{constructor(){super(...arguments),this.Cs=new Hi}ps(t,e){return this.Cs.bs(t,{gs:e.Ts,Ms:"",xs:"",Ss:e.Ps,ks:t.bitmapSize.height})}}function gh(s,t){const e=s.context;e.strokeStyle=t,e.stroke()}class Sn extends oe{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z(t){if(this.tt===null)return;const{st:e,nt:i,cs:n,ds:r,ht:o,Wt:h,Rs:l}=this.tt;if(i===null)return;const a=t.context;a.lineCap="butt",a.lineWidth=o*t.verticalPixelRatio,pe(a,h),a.lineJoin="round";const c=this.Ds.bind(this);r!==void 0&&gn(t,e,r,i,n,c,gh),l&&(function(u,p,g,d,f){const{horizontalPixelRatio:m,verticalPixelRatio:w,context:M}=u;let R=null;const k=Math.max(1,Math.floor(m))%2/2,$=g*w+k;for(let Q=d.to-1;Q>=d.from;--Q){const G=p[Q];if(G){const st=f(u,G);st!==R&&(M.beginPath(),R!==null&&M.fill(),M.fillStyle=st,R=st);const tt=Math.round(G.et*m)+k,Nt=G.rt*w;M.moveTo(tt,Nt),M.arc(tt,Nt,$,0,2*Math.PI)}}M.fill()})(t,e,l,i,c)}}class _n extends Sn{Ds(t,e){return e._t}}function Tn(s,t,e,i,n=0,r=t.length){let o=r-n;for(;0<o;){const h=o>>1,l=n+h;i(t[l],e)===s?(n=l+1,o-=h+1):o=h}return n}const De=Tn.bind(null,!0),En=Tn.bind(null,!1);function bh(s,t){return s.ut<t}function vh(s,t){return t<s.ut}function Cn(s,t,e){const i=t.Os(),n=t.di(),r=De(s,i,bh),o=En(s,n,vh);if(!e)return{from:r,to:o};let h=r,l=o;return r>0&&r<s.length&&s[r].ut>=i&&(h=r-1),o>0&&o<s.length&&s[o-1].ut<=n&&(l=o+1),{from:h,to:l}}class $i{constructor(t,e,i){this.As=!0,this.Vs=!0,this.Bs=!0,this.Is=[],this.zs=null,this.Es=t,this.Ls=e,this.Ns=i}gt(t){this.As=!0,t==="data"&&(this.Vs=!0),t==="options"&&(this.Bs=!0)}xt(){return this.Es.Tt()?(this.Fs(),this.zs===null?null:this.Ws):null}js(){this.Is=this.Is.map((t=>Object.assign(Object.assign({},t),this.Es.$s().Hs(t.ut))))}Us(){this.zs=null}Fs(){this.Vs&&(this.qs(),this.Vs=!1),this.Bs&&(this.js(),this.Bs=!1),this.As&&(this.Ys(),this.As=!1)}Ys(){const t=this.Es.At(),e=this.Ls.yt();if(this.Us(),e.Fi()||t.Fi())return;const i=e.Xs();if(i===null||this.Es.In().Ks()===0)return;const n=this.Es.Pt();n!==null&&(this.zs=Cn(this.Is,i,this.Ns),this.Zs(t,e,n.Vt),this.Gs())}}class oi extends $i{constructor(t,e){super(t,e,!0)}Zs(t,e,i){e.Js(this.Is,Ae(this.zs)),t.Qs(this.Is,i,Ae(this.zs))}te(t,e){return{ut:t,ct:e,et:NaN,rt:NaN}}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>{const i=e.Vt[3];return this.ne(e.se,i,t)}))}}class yh extends oi{constructor(t,e){super(t,e),this.Ws=new zi,this.ee=new mh,this.re=new _n,this.Ws.X([this.ee,this.re])}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.W();this.ee.it({ds:t.lineType,st:this.Is,Wt:t.lineStyle,ht:t.lineWidth,fs:null,vs:t.invertFilledArea,nt:this.zs,cs:this.Ls.yt().he()}),this.re.it({ds:t.lineVisible?t.lineType:void 0,st:this.Is,Wt:t.lineStyle,ht:t.lineWidth,nt:this.zs,cs:this.Ls.yt().he(),Rs:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}class wh extends oe{constructor(){super(...arguments),this.Lt=null,this.le=0,this.ae=0}it(t){this.Lt=t}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.Lt===null||this.Lt.In.length===0||this.Lt.nt===null)return;this.le=this.oe(e),this.le>=2&&Math.max(1,Math.floor(e))%2!=this.le%2&&this.le--,this.ae=this.Lt._e?Math.min(this.le,Math.floor(e)):this.le;let n=null;const r=this.ae<=this.le&&this.Lt.he>=Math.floor(1.5*e);for(let o=this.Lt.nt.from;o<this.Lt.nt.to;++o){const h=this.Lt.In[o];n!==h.ue&&(t.fillStyle=h.ue,n=h.ue);const l=Math.floor(.5*this.ae),a=Math.round(h.et*e),c=a-l,u=this.ae,p=c+u-1,g=Math.min(h.ce,h.de),d=Math.max(h.ce,h.de),f=Math.round(g*i)-l,m=Math.round(d*i)+l,w=Math.max(m-f,this.ae);t.fillRect(c,f,u,w);const M=Math.ceil(1.5*this.le);if(r){if(this.Lt.fe){const Q=a-M;let G=Math.max(f,Math.round(h.ve*i)-l),st=G+u-1;st>f+w-1&&(st=f+w-1,G=st-u+1),t.fillRect(Q,G,c-Q,st-G+1)}const R=a+M;let k=Math.max(f,Math.round(h.pe*i)-l),$=k+u-1;$>f+w-1&&($=f+w-1,k=$-u+1),t.fillRect(p+1,k,R-p,$-k+1)}}}oe(t){const e=Math.floor(t);return Math.max(e,Math.floor((function(i,n){return Math.floor(.3*i*n)})(S(this.Lt).he,t)))}}class Ln extends $i{constructor(t,e){super(t,e,!1)}Zs(t,e,i){e.Js(this.Is,Ae(this.zs)),t.me(this.Is,i,Ae(this.zs))}be(t,e,i){return{ut:t,we:e.Vt[0],ge:e.Vt[1],Me:e.Vt[2],xe:e.Vt[3],et:NaN,ve:NaN,ce:NaN,de:NaN,pe:NaN}}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>this.ne(e.se,e,t)))}}class Sh extends Ln{constructor(){super(...arguments),this.Ws=new wh}ne(t,e,i){return Object.assign(Object.assign({},this.be(t,e,i)),i.Hs(t))}Gs(){const t=this.Es.W();this.Ws.it({In:this.Is,he:this.Ls.yt().he(),fe:t.openVisible,_e:t.thinBars,nt:this.zs})}}class _h extends yn{constructor(){super(...arguments),this.Cs=new Hi}ps(t,e){const i=this.tt;return this.Cs.bs(t,{gs:e.Se,Ms:e.ke,xs:e.ye,Ss:e.Ce,ks:t.bitmapSize.height,fs:i.fs})}}class Th extends Sn{constructor(){super(...arguments),this.Te=new Hi}Ds(t,e){const i=this.tt;return this.Te.bs(t,{gs:e.Pe,Ms:e.Pe,xs:e.Re,Ss:e.Re,ks:t.bitmapSize.height,fs:i.fs})}}class Eh extends oi{constructor(t,e){super(t,e),this.Ws=new zi,this.De=new _h,this.Oe=new Th,this.Ws.X([this.De,this.Oe])}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.Pt();if(t===null)return;const e=this.Es.W(),i=this.Es.At().Ot(e.baseValue.price,t.Vt),n=this.Ls.yt().he();this.De.it({st:this.Is,ht:e.lineWidth,Wt:e.lineStyle,ds:e.lineType,fs:i,vs:!1,nt:this.zs,cs:n}),this.Oe.it({st:this.Is,ht:e.lineWidth,Wt:e.lineStyle,ds:e.lineVisible?e.lineType:void 0,Rs:e.pointMarkersVisible?e.pointMarkersRadius||e.lineWidth/2+2:void 0,fs:i,nt:this.zs,cs:n})}}class Ch extends oe{constructor(){super(...arguments),this.Lt=null,this.le=0}it(t){this.Lt=t}Z(t){if(this.Lt===null||this.Lt.In.length===0||this.Lt.nt===null)return;const{horizontalPixelRatio:e}=t;this.le=(function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const h=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),l=Math.floor(r*h*o),a=Math.floor(r*o),c=Math.min(l,a);return Math.max(Math.floor(o),c)})(this.Lt.he,e),this.le>=2&&Math.floor(e)%2!=this.le%2&&this.le--;const i=this.Lt.In;this.Lt.Ae&&this.Ve(t,i,this.Lt.nt),this.Lt.ci&&this.Be(t,i,this.Lt.nt);const n=this.Ie(e);(!this.Lt.ci||this.le>2*n)&&this.ze(t,i,this.Lt.nt)}Ve(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="",l=Math.min(Math.floor(r),Math.floor(this.Lt.he*r));l=Math.max(Math.floor(r),Math.min(l,this.le));const a=Math.floor(.5*l);let c=null;for(let u=i.from;u<i.to;u++){const p=e[u];p.Ee!==h&&(n.fillStyle=p.Ee,h=p.Ee);const g=Math.round(Math.min(p.ve,p.pe)*o),d=Math.round(Math.max(p.ve,p.pe)*o),f=Math.round(p.ce*o),m=Math.round(p.de*o);let w=Math.round(r*p.et)-a;const M=w+l-1;c!==null&&(w=Math.max(c+1,w),w=Math.min(w,M));const R=M-w+1;n.fillRect(w,f,R,g-f),n.fillRect(w,d+1,R,m-d),c=M}}Ie(t){let e=Math.floor(1*t);this.le<=2*e&&(e=Math.floor(.5*(this.le-1)));const i=Math.max(Math.floor(t),e);return this.le<=2*i?Math.max(Math.floor(t),Math.floor(1*t)):i}Be(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="";const l=this.Ie(r);let a=null;for(let c=i.from;c<i.to;c++){const u=e[c];u.Le!==h&&(n.fillStyle=u.Le,h=u.Le);let p=Math.round(u.et*r)-Math.floor(.5*this.le);const g=p+this.le-1,d=Math.round(Math.min(u.ve,u.pe)*o),f=Math.round(Math.max(u.ve,u.pe)*o);if(a!==null&&(p=Math.max(a+1,p),p=Math.min(p,g)),this.Lt.he*r>2*l)hh(n,p,d,g-p+1,f-d+1,l);else{const m=g-p+1;n.fillRect(p,d,m,f-d+1)}a=g}}ze(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="";const l=this.Ie(r);for(let a=i.from;a<i.to;a++){const c=e[a];let u=Math.round(Math.min(c.ve,c.pe)*o),p=Math.round(Math.max(c.ve,c.pe)*o),g=Math.round(c.et*r)-Math.floor(.5*this.le),d=g+this.le-1;if(c.ue!==h){const f=c.ue;n.fillStyle=f,h=f}this.Lt.ci&&(g+=l,u+=l,d-=l,p-=l),u>p||n.fillRect(g,u,d-g+1,p-u+1)}}}class Lh extends Ln{constructor(){super(...arguments),this.Ws=new Ch}ne(t,e,i){return Object.assign(Object.assign({},this.be(t,e,i)),i.Hs(t))}Gs(){const t=this.Es.W();this.Ws.it({In:this.Is,he:this.Ls.yt().he(),Ae:t.wickVisible,ci:t.borderVisible,nt:this.zs})}}class xh{constructor(t,e){this.Ne=t,this.Li=e}K(t,e,i){this.Ne.draw(t,this.Li,e,i)}}class ji extends $i{constructor(t,e,i){super(t,e,!1),this.wn=i,this.Ws=new xh(this.wn.renderer(),(n=>{const r=t.Pt();return r===null?null:t.At().Ot(n,r.Vt)}))}Fe(t){return this.wn.priceValueBuilder(t)}We(t){return this.wn.isWhitespace(t)}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>Object.assign(Object.assign({ut:e.se,et:NaN},t.Hs(e.se)),{je:e.He})))}Zs(t,e){e.Js(this.Is,Ae(this.zs))}Gs(){this.wn.update({bars:this.Is.map(Mh),barSpacing:this.Ls.yt().he(),visibleRange:this.zs},this.Es.W())}}function Mh(s){return{x:s.et,time:s.ut,originalData:s.je,barColor:s.ue}}class Rh extends oe{constructor(){super(...arguments),this.Lt=null,this.$e=[]}it(t){this.Lt=t,this.$e=[]}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.Lt===null||this.Lt.st.length===0||this.Lt.nt===null)return;this.$e.length||this.Ue(e);const n=Math.max(1,Math.floor(i)),r=Math.round(this.Lt.qe*i)-Math.floor(n/2),o=r+n;for(let h=this.Lt.nt.from;h<this.Lt.nt.to;h++){const l=this.Lt.st[h],a=this.$e[h-this.Lt.nt.from],c=Math.round(l.rt*i);let u,p;t.fillStyle=l.ue,c<=r?(u=c,p=o):(u=r,p=c-Math.floor(n/2)+n),t.fillRect(a.Os,u,a.di-a.Os+1,p-u)}}Ue(t){if(this.Lt===null||this.Lt.st.length===0||this.Lt.nt===null)return void(this.$e=[]);const e=Math.ceil(this.Lt.he*t)<=1?0:Math.max(1,Math.floor(t)),i=Math.round(this.Lt.he*t)-e;this.$e=new Array(this.Lt.nt.to-this.Lt.nt.from);for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.Lt.st[r],h=Math.round(o.et*t);let l,a;if(i%2){const c=(i-1)/2;l=h-c,a=h+c}else{const c=i/2;l=h-c,a=h+c-1}this.$e[r-this.Lt.nt.from]={Os:l,di:a,Ye:h,Xe:o.et*t,ut:o.ut}}for(let r=this.Lt.nt.from+1;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from],h=this.$e[r-this.Lt.nt.from-1];o.ut===h.ut+1&&o.Os-h.di!==e+1&&(h.Ye>h.Xe?h.di=o.Os-e-1:o.Os=h.di+e+1)}let n=Math.ceil(this.Lt.he*t);for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from];o.di<o.Os&&(o.di=o.Os);const h=o.di-o.Os+1;n=Math.min(h,n)}if(e>0&&n<4)for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from];o.di-o.Os+1>n&&(o.Ye>o.Xe?o.di-=1:o.Os+=1)}}}class Oh extends oi{constructor(){super(...arguments),this.Ws=new Rh}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t={st:this.Is,he:this.Ls.yt().he(),nt:this.zs,qe:this.Es.At().Ot(this.Es.W().base,S(this.Es.Pt()).Vt)};this.Ws.it(t)}}class kh extends oi{constructor(){super(...arguments),this.Ws=new _n}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.W(),e={st:this.Is,Wt:t.lineStyle,ds:t.lineVisible?t.lineType:void 0,ht:t.lineWidth,Rs:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,nt:this.zs,cs:this.Ls.yt().he()};this.Ws.it(e)}}const Ph=/[2-9]/g;class Ne{constructor(t=50){this.Ke=0,this.Ze=1,this.Ge=1,this.Je={},this.Qe=new Map,this.tr=t}ir(){this.Ke=0,this.Qe.clear(),this.Ze=1,this.Ge=1,this.Je={}}Si(t,e,i){return this.nr(t,e,i).width}xi(t,e,i){const n=this.nr(t,e,i);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}nr(t,e,i){const n=i||Ph,r=String(e).replace(n,"0");if(this.Qe.has(r))return kt(this.Qe.get(r)).sr;if(this.Ke===this.tr){const h=this.Je[this.Ge];delete this.Je[this.Ge],this.Qe.delete(h),this.Ge++,this.Ke--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&e.length||(this.Qe.set(r,{sr:o,er:this.Ze}),this.Je[this.Ze]=r,this.Ke++,this.Ze++),o}}class Ah{constructor(t){this.rr=null,this.k=null,this.hr="right",this.lr=t}ar(t,e,i){this.rr=t,this.k=e,this.hr=i}K(t){this.k!==null&&this.rr!==null&&this.rr.K(t,this.k,this.lr,this.hr)}}class xn{constructor(t,e,i){this._r=t,this.lr=new Ne(50),this.ur=e,this.F=i,this.j=-1,this.Ht=new Ah(this.lr)}xt(){const t=this.F.cr(this.ur);if(t===null)return null;const e=t.dr(this.ur)?t.vr():this.ur.At();if(e===null)return null;const i=t.pr(e);if(i==="overlay")return null;const n=this.F.mr();return n.P!==this.j&&(this.j=n.P,this.lr.ir()),this.Ht.ar(this._r.zi(),n,i),this.Ht}}class Dh extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}br(t,e){var i;if(!(!((i=this.Lt)===null||i===void 0)&&i.Tt))return null;const{rt:n,ht:r,wr:o}=this.Lt;return e>=n-r-7&&e<=n+r+7?{gr:this.Lt,wr:o}:null}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null||this.Lt.Tt===!1)return;const r=Math.round(this.Lt.rt*n);r<0||r>e.height||(t.lineCap="butt",t.strokeStyle=this.Lt.O,t.lineWidth=Math.floor(this.Lt.ht*i),pe(t,this.Lt.Wt),rn(t,r,0,e.width))}}class Ji{constructor(t){this.Mr={rt:0,O:"rgba(0, 0, 0, 0)",ht:1,Wt:0,Tt:!1},this.Sr=new Dh,this.bt=!0,this.Es=t,this.Ls=t.qt(),this.Sr.it(this.Mr)}gt(){this.bt=!0}xt(){return this.Es.Tt()?(this.bt&&(this.kr(),this.bt=!1),this.Sr):null}}class Nh extends Ji{constructor(t){super(t)}kr(){this.Mr.Tt=!1;const t=this.Es.At(),e=t.yr().yr;if(e!==2&&e!==3)return;const i=this.Es.W();if(!i.baseLineVisible||!this.Es.Tt())return;const n=this.Es.Pt();n!==null&&(this.Mr.Tt=!0,this.Mr.rt=t.Ot(n.Vt,n.Vt),this.Mr.O=i.baseLineColor,this.Mr.ht=i.baseLineWidth,this.Mr.Wt=i.baseLineStyle)}}class Bh extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}He(){return this.Lt}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){const n=this.Lt;if(n===null)return;const r=Math.max(1,Math.floor(e)),o=r%2/2,h=Math.round(n.Xe.x*e)+o,l=n.Xe.y*i;t.fillStyle=n.Cr,t.beginPath();const a=Math.max(2,1.5*n.Tr)*e;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.Pr,t.beginPath(),t.arc(h,l,n.ot*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=n.Rr,t.beginPath(),t.arc(h,l,n.ot*e+r/2,0,2*Math.PI,!1),t.stroke()}}const Fh=[{Dr:0,Or:.25,Ar:4,Vr:10,Br:.25,Ir:0,zr:.4,Er:.8},{Dr:.25,Or:.525,Ar:10,Vr:14,Br:0,Ir:0,zr:.8,Er:0},{Dr:.525,Or:1,Ar:14,Vr:14,Br:0,Ir:0,zr:0,Er:0}];function Mn(s,t,e,i){return(function(n,r){if(n==="transparent")return n;const o=Ze(n),h=o[3];return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${r*h})`})(s,e+(i-e)*t)}function Rn(s,t){const e=s%2600/2600;let i;for(const l of Fh)if(e>=l.Dr&&e<=l.Or){i=l;break}le(i!==void 0,"Last price animation internal logic error");const n=(e-i.Dr)/(i.Or-i.Dr);return{Pr:Mn(t,n,i.Br,i.Ir),Rr:Mn(t,n,i.zr,i.Er),ot:(r=n,o=i.Ar,h=i.Vr,o+(h-o)*r)};var r,o,h}class zh{constructor(t){this.Ht=new Bh,this.bt=!0,this.Lr=!0,this.Nr=performance.now(),this.Fr=this.Nr-1,this.Wr=t}jr(){this.Fr=this.Nr-1,this.gt()}Hr(){if(this.gt(),this.Wr.W().lastPriceAnimation===2){const t=performance.now(),e=this.Fr-t;if(e>0)return void(e<650&&(this.Fr+=2600));this.Nr=t,this.Fr=t+2600}}gt(){this.bt=!0}$r(){this.Lr=!0}Tt(){return this.Wr.W().lastPriceAnimation!==0}Ur(){switch(this.Wr.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Fr}}xt(){return this.bt?(this.St(),this.bt=!1,this.Lr=!1):this.Lr&&(this.qr(),this.Lr=!1),this.Ht}St(){this.Ht.it(null);const t=this.Wr.qt().yt(),e=t.Xs(),i=this.Wr.Pt();if(e===null||i===null)return;const n=this.Wr.Yr(!0);if(n.Xr||!e.Kr(n.se))return;const r={x:t.Et(n.se),y:this.Wr.At().Ot(n.ct,i.Vt)},o=n.O,h=this.Wr.W().lineWidth,l=Rn(this.Zr(),o);this.Ht.it({Cr:o,Tr:h,Pr:l.Pr,Rr:l.Rr,ot:l.ot,Xe:r})}qr(){const t=this.Ht.He();if(t!==null){const e=Rn(this.Zr(),t.Cr);t.Pr=e.Pr,t.Rr=e.Rr,t.ot=e.ot}}Zr(){return this.Ur()?performance.now()-this.Nr:2599}}function Be(s,t){return wn(Math.min(Math.max(s,12),30)*t)}function Fe(s,t){switch(s){case"arrowDown":case"arrowUp":return Be(t,1);case"circle":return Be(t,.8);case"square":return Be(t,.7)}}function On(s){return(function(t){const e=Math.ceil(t);return e%2!=0?e-1:e})(Be(s,1))}function kn(s){return Math.max(Be(s,.1),3)}function Pn(s,t,e,i,n){const r=Fe("square",e),o=(r-1)/2,h=s-o,l=t-o;return i>=h&&i<=h+r&&n>=l&&n<=l+r}function An(s,t,e,i,n){const r=(Fe("arrowUp",n)-1)/2,o=(wn(n/2)-1)/2;t.beginPath(),s?(t.moveTo(e-r,i),t.lineTo(e,i-r),t.lineTo(e+r,i),t.lineTo(e+o,i),t.lineTo(e+o,i+r),t.lineTo(e-o,i+r),t.lineTo(e-o,i)):(t.moveTo(e-r,i),t.lineTo(e,i+r),t.lineTo(e+r,i),t.lineTo(e+o,i),t.lineTo(e+o,i-r),t.lineTo(e-o,i-r),t.lineTo(e-o,i)),t.fill()}function Uh(s,t,e,i,n,r){return Pn(t,e,i,n,r)}class Vh extends Ui{constructor(){super(...arguments),this.Lt=null,this.lr=new Ne,this.j=-1,this.H="",this.Gr=""}it(t){this.Lt=t}ar(t,e){this.j===t&&this.H===e||(this.j=t,this.H=e,this.Gr=_e(t,e),this.lr.ir())}br(t,e){if(this.Lt===null||this.Lt.nt===null)return null;for(let i=this.Lt.nt.from;i<this.Lt.nt.to;i++){const n=this.Lt.st[i];if(Ih(n,t,e))return{gr:n.Jr,wr:n.wr}}return null}Z({context:t},e,i){if(this.Lt!==null&&this.Lt.nt!==null){t.textBaseline="middle",t.font=this.Gr;for(let n=this.Lt.nt.from;n<this.Lt.nt.to;n++){const r=this.Lt.st[n];r.Jt!==void 0&&(r.Jt.$i=this.lr.Si(t,r.Jt.Qr),r.Jt.zt=this.j,r.Jt.et=r.et-r.Jt.$i/2),Wh(r,t)}}}}function Wh(s,t){t.fillStyle=s.O,s.Jt!==void 0&&(function(e,i,n,r){e.fillText(i,n,r)})(t,s.Jt.Qr,s.Jt.et,s.Jt.rt),(function(e,i){if(e.Ks!==0){switch(e.th){case"arrowDown":return void An(!1,i,e.et,e.rt,e.Ks);case"arrowUp":return void An(!0,i,e.et,e.rt,e.Ks);case"circle":return void(function(n,r,o,h){const l=(Fe("circle",h)-1)/2;n.beginPath(),n.arc(r,o,l,0,2*Math.PI,!1),n.fill()})(i,e.et,e.rt,e.Ks);case"square":return void(function(n,r,o,h){const l=Fe("square",h),a=(l-1)/2,c=r-a,u=o-a;n.fillRect(c,u,l,l)})(i,e.et,e.rt,e.Ks)}e.th}})(s,t)}function Ih(s,t,e){return!(s.Jt===void 0||!(function(i,n,r,o,h,l){const a=o/2;return h>=i&&h<=i+r&&l>=n-a&&l<=n+a})(s.Jt.et,s.Jt.rt,s.Jt.$i,s.Jt.zt,t,e))||(function(i,n,r){if(i.Ks===0)return!1;switch(i.th){case"arrowDown":case"arrowUp":return Uh(0,i.et,i.rt,i.Ks,n,r);case"circle":return(function(o,h,l,a,c){const u=2+Fe("circle",l)/2,p=o-a,g=h-c;return Math.sqrt(p*p+g*g)<=u})(i.et,i.rt,i.Ks,n,r);case"square":return Pn(i.et,i.rt,i.Ks,n,r)}})(s,t,e)}function qh(s,t,e,i,n,r,o,h,l){const a=Kt(e)?e:e.xe,c=Kt(e)?e:e.ge,u=Kt(e)?e:e.Me,p=Kt(t.size)?Math.max(t.size,0):1,g=On(h.he())*p,d=g/2;switch(s.Ks=g,t.position){case"inBar":return s.rt=o.Ot(a,l),void(s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n));case"aboveBar":return s.rt=o.Ot(c,l)-d-i.ih,s.Jt!==void 0&&(s.Jt.rt=s.rt-d-.6*n,i.ih+=1.2*n),void(i.ih+=g+r);case"belowBar":return s.rt=o.Ot(u,l)+d+i.nh,s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n,i.nh+=1.2*n),void(i.nh+=g+r)}t.position}class Hh{constructor(t,e){this.bt=!0,this.sh=!0,this.eh=!0,this.rh=null,this.Ht=new Vh,this.Wr=t,this.Ui=e,this.Lt={st:[],nt:null}}gt(t){this.bt=!0,this.eh=!0,t==="data"&&(this.sh=!0)}xt(t){if(!this.Wr.Tt())return null;this.bt&&this.hh();const e=this.Ui.W().layout;return this.Ht.ar(e.fontSize,e.fontFamily),this.Ht.it(this.Lt),this.Ht}lh(){if(this.eh){if(this.Wr.ah().length>0){const t=this.Ui.yt().he(),e=kn(t),i=1.5*On(t)+2*e;this.rh={above:i,below:i}}else this.rh=null;this.eh=!1}return this.rh}hh(){const t=this.Wr.At(),e=this.Ui.yt(),i=this.Wr.ah();this.sh&&(this.Lt.st=i.map((c=>({ut:c.time,et:0,rt:0,Ks:0,th:c.shape,O:c.color,Jr:c.Jr,wr:c.id,Jt:void 0}))),this.sh=!1);const n=this.Ui.W().layout;this.Lt.nt=null;const r=e.Xs();if(r===null)return;const o=this.Wr.Pt();if(o===null||this.Lt.st.length===0)return;let h=NaN;const l=kn(e.he()),a={ih:l,nh:l};this.Lt.nt=Cn(this.Lt.st,r,!0);for(let c=this.Lt.nt.from;c<this.Lt.nt.to;c++){const u=i[c];u.time!==h&&(a.ih=l,a.nh=l,h=u.time);const p=this.Lt.st[c];p.et=e.Et(u.time),u.text!==void 0&&u.text.length>0&&(p.Jt={Qr:u.text,et:0,rt:0,$i:0,zt:0});const g=this.Wr.oh(u.time);g!==null&&qh(p,u,g,a,n.fontSize,l,t,e,o.Vt)}this.bt=!1}}class $h extends Ji{constructor(t){super(t)}kr(){const t=this.Mr;t.Tt=!1;const e=this.Es.W();if(!e.priceLineVisible||!this.Es.Tt())return;const i=this.Es.Yr(e.priceLineSource===0);i.Xr||(t.Tt=!0,t.rt=i.yi,t.O=this.Es._h(i.O),t.ht=e.priceLineWidth,t.Wt=e.priceLineStyle)}}class jh extends ii{constructor(t){super(),this.$t=t}Ei(t,e,i){t.Tt=!1,e.Tt=!1;const n=this.$t;if(!n.Tt())return;const r=n.W(),o=r.lastValueVisible,h=n.uh()!=="",l=r.seriesLastValueMode===0,a=n.Yr(!1);if(a.Xr)return;o&&(t.Jt=this.dh(a,o,l),t.Tt=t.Jt.length!==0),(h||l)&&(e.Jt=this.fh(a,o,h,l),e.Tt=e.Jt.length>0);const c=n._h(a.O),u=Qe(c);i.t=u.t,i.yi=a.yi,e.Bt=n.qt().It(a.yi/n.At().zt()),t.Bt=c,t.O=u.i,e.O=u.i}fh(t,e,i,n){let r="";const o=this.$t.uh();return i&&o.length!==0&&(r+=`${o} `),e&&n&&(r+=this.$t.At().ph()?t.mh:t.bh),r.trim()}dh(t,e,i){return e?i?this.$t.At().ph()?t.bh:t.mh:t.Jt:""}}function Dn(s,t,e,i){const n=Number.isFinite(t),r=Number.isFinite(e);return n&&r?s(t,e):n||r?n?t:e:i}class Pt{constructor(t,e){this.wh=t,this.gh=e}Mh(t){return t!==null&&this.wh===t.wh&&this.gh===t.gh}xh(){return new Pt(this.wh,this.gh)}Sh(){return this.wh}kh(){return this.gh}yh(){return this.gh-this.wh}Fi(){return this.gh===this.wh||Number.isNaN(this.gh)||Number.isNaN(this.wh)}ts(t){return t===null?this:new Pt(Dn(Math.min,this.Sh(),t.Sh(),-1/0),Dn(Math.max,this.kh(),t.kh(),1/0))}Ch(t){if(!Kt(t)||this.gh-this.wh===0)return;const e=.5*(this.gh+this.wh);let i=this.gh-e,n=this.wh-e;i*=t,n*=t,this.gh=e+i,this.wh=e+n}Th(t){Kt(t)&&(this.gh+=t,this.wh+=t)}Ph(){return{minValue:this.wh,maxValue:this.gh}}static Rh(t){return t===null?null:new Pt(t.minValue,t.maxValue)}}class hi{constructor(t,e){this.Dh=t,this.Oh=e||null}Ah(){return this.Dh}Vh(){return this.Oh}Ph(){return this.Dh===null?null:{priceRange:this.Dh.Ph(),margins:this.Oh||void 0}}static Rh(t){return t===null?null:new hi(Pt.Rh(t.priceRange),t.margins)}}class Jh extends Ji{constructor(t,e){super(t),this.Bh=e}kr(){const t=this.Mr;t.Tt=!1;const e=this.Bh.W();if(!this.Es.Tt()||!e.lineVisible)return;const i=this.Bh.Ih();i!==null&&(t.Tt=!0,t.rt=i,t.O=e.color,t.ht=e.lineWidth,t.Wt=e.lineStyle,t.wr=this.Bh.W().id)}}class Kh extends ii{constructor(t,e){super(),this.Wr=t,this.Bh=e}Ei(t,e,i){t.Tt=!1,e.Tt=!1;const n=this.Bh.W(),r=n.axisLabelVisible,o=n.title!=="",h=this.Wr;if(!r||!h.Tt())return;const l=this.Bh.Ih();if(l===null)return;o&&(e.Jt=n.title,e.Tt=!0),e.Bt=h.qt().It(l/h.At().zt()),t.Jt=this.zh(n.price),t.Tt=!0;const a=Qe(n.axisLabelColor||n.color);i.t=a.t;const c=n.axisLabelTextColor||a.i;t.O=c,e.O=c,i.yi=l}zh(t){const e=this.Wr.Pt();return e===null?"":this.Wr.At().Wi(t,e.Vt)}}class Xh{constructor(t,e){this.Wr=t,this.cn=e,this.Eh=new Jh(t,this),this._r=new Kh(t,this),this.Lh=new xn(this._r,t,t.qt())}Nh(t){Ht(this.cn,t),this.gt(),this.Wr.qt().Fh()}W(){return this.cn}Wh(){return this.Eh}jh(){return this.Lh}Hh(){return this._r}gt(){this.Eh.gt(),this._r.gt()}Ih(){const t=this.Wr,e=t.At();if(t.qt().yt().Fi()||e.Fi())return null;const i=t.Pt();return i===null?null:e.Ot(this.cn.price,i.Vt)}}class Yh extends Wi{constructor(t){super(),this.Ui=t}qt(){return this.Ui}}const Gh={Bar:(s,t,e,i)=>{var n;const r=t.upColor,o=t.downColor,h=S(s(e,i)),l=Se(h.Vt[0])<=Se(h.Vt[3]);return{ue:(n=h.O)!==null&&n!==void 0?n:l?r:o}},Candlestick:(s,t,e,i)=>{var n,r,o;const h=t.upColor,l=t.downColor,a=t.borderUpColor,c=t.borderDownColor,u=t.wickUpColor,p=t.wickDownColor,g=S(s(e,i)),d=Se(g.Vt[0])<=Se(g.Vt[3]);return{ue:(n=g.O)!==null&&n!==void 0?n:d?h:l,Le:(r=g.Bt)!==null&&r!==void 0?r:d?a:c,Ee:(o=g.$h)!==null&&o!==void 0?o:d?u:p}},Custom:(s,t,e,i)=>{var n;return{ue:(n=S(s(e,i)).O)!==null&&n!==void 0?n:t.color}},Area:(s,t,e,i)=>{var n,r,o,h;const l=S(s(e,i));return{ue:(n=l._t)!==null&&n!==void 0?n:t.lineColor,_t:(r=l._t)!==null&&r!==void 0?r:t.lineColor,Ts:(o=l.Ts)!==null&&o!==void 0?o:t.topColor,Ps:(h=l.Ps)!==null&&h!==void 0?h:t.bottomColor}},Baseline:(s,t,e,i)=>{var n,r,o,h,l,a;const c=S(s(e,i));return{ue:c.Vt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,Pe:(n=c.Pe)!==null&&n!==void 0?n:t.topLineColor,Re:(r=c.Re)!==null&&r!==void 0?r:t.bottomLineColor,Se:(o=c.Se)!==null&&o!==void 0?o:t.topFillColor1,ke:(h=c.ke)!==null&&h!==void 0?h:t.topFillColor2,ye:(l=c.ye)!==null&&l!==void 0?l:t.bottomFillColor1,Ce:(a=c.Ce)!==null&&a!==void 0?a:t.bottomFillColor2}},Line:(s,t,e,i)=>{var n,r;const o=S(s(e,i));return{ue:(n=o.O)!==null&&n!==void 0?n:t.color,_t:(r=o.O)!==null&&r!==void 0?r:t.color}},Histogram:(s,t,e,i)=>{var n;return{ue:(n=S(s(e,i)).O)!==null&&n!==void 0?n:t.color}}};class Zh{constructor(t){this.Uh=(e,i)=>i!==void 0?i.Vt:this.Wr.In().qh(e),this.Wr=t,this.Yh=Gh[t.Xh()]}Hs(t,e){return this.Yh(this.Uh,this.Wr.W(),t,e)}}var Nn;(function(s){s[s.NearestLeft=-1]="NearestLeft",s[s.None=0]="None",s[s.NearestRight=1]="NearestRight"})(Nn||(Nn={}));const ae=30;class Qh{constructor(){this.Kh=[],this.Zh=new Map,this.Gh=new Map}Jh(){return this.Ks()>0?this.Kh[this.Kh.length-1]:null}Qh(){return this.Ks()>0?this.tl(0):null}Bn(){return this.Ks()>0?this.tl(this.Kh.length-1):null}Ks(){return this.Kh.length}Fi(){return this.Ks()===0}Kr(t){return this.il(t,0)!==null}qh(t){return this.nl(t)}nl(t,e=0){const i=this.il(t,e);return i===null?null:Object.assign(Object.assign({},this.sl(i)),{se:this.tl(i)})}ie(){return this.Kh}el(t,e,i){if(this.Fi())return null;let n=null;for(const r of i)n=li(n,this.rl(t,e,r));return n}it(t){this.Gh.clear(),this.Zh.clear(),this.Kh=t}tl(t){return this.Kh[t].se}sl(t){return this.Kh[t]}il(t,e){const i=this.hl(t);if(i===null&&e!==0)switch(e){case-1:return this.ll(t);case 1:return this.al(t);default:throw new TypeError("Unknown search mode")}return i}ll(t){let e=this.ol(t);return e>0&&(e-=1),e!==this.Kh.length&&this.tl(e)<t?e:null}al(t){const e=this._l(t);return e!==this.Kh.length&&t<this.tl(e)?e:null}hl(t){const e=this.ol(t);return e===this.Kh.length||t<this.Kh[e].se?null:e}ol(t){return De(this.Kh,t,((e,i)=>e.se<i))}_l(t){return En(this.Kh,t,((e,i)=>e.se>i))}ul(t,e,i){let n=null;for(let r=t;r<e;r++){const o=this.Kh[r].Vt[i];Number.isNaN(o)||(n===null?n={cl:o,dl:o}:(o<n.cl&&(n.cl=o),o>n.dl&&(n.dl=o)))}return n}rl(t,e,i){if(this.Fi())return null;let n=null;const r=S(this.Qh()),o=S(this.Bn()),h=Math.max(t,r),l=Math.min(e,o),a=Math.ceil(h/ae)*ae,c=Math.max(a,Math.floor(l/ae)*ae);{const p=this.ol(h),g=this._l(Math.min(l,a,e));n=li(n,this.ul(p,g,i))}let u=this.Zh.get(i);u===void 0&&(u=new Map,this.Zh.set(i,u));for(let p=Math.max(a+1,h);p<c;p+=ae){const g=Math.floor(p/ae);let d=u.get(g);if(d===void 0){const f=this.ol(g*ae),m=this._l((g+1)*ae-1);d=this.ul(f,m,i),u.set(g,d)}n=li(n,d)}{const p=this.ol(c),g=this._l(l);n=li(n,this.ul(p,g,i))}return n}}function li(s,t){return s===null?t:t===null?s:{cl:Math.min(s.cl,t.cl),dl:Math.max(s.dl,t.dl)}}class tl{constructor(t){this.fl=t}K(t,e,i){this.fl.draw(t)}G(t,e,i){var n,r;(r=(n=this.fl).drawBackground)===null||r===void 0||r.call(n,t)}}class Ki{constructor(t){this.Qe=null,this.wn=t}xt(){var t;const e=this.wn.renderer();if(e===null)return null;if(((t=this.Qe)===null||t===void 0?void 0:t.vl)===e)return this.Qe.pl;const i=new tl(e);return this.Qe={vl:e,pl:i},i}ml(){var t,e,i;return(i=(e=(t=this.wn).zOrder)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:"normal"}}function Bn(s){var t,e,i,n,r;return{Jt:s.text(),yi:s.coordinate(),ki:(t=s.fixedCoordinate)===null||t===void 0?void 0:t.call(s),O:s.textColor(),t:s.backColor(),Tt:(i=(e=s.visible)===null||e===void 0?void 0:e.call(s))===null||i===void 0||i,ai:(r=(n=s.tickVisible)===null||n===void 0?void 0:n.call(s))===null||r===void 0||r}}class el{constructor(t,e){this.Ht=new fn,this.bl=t,this.wl=e}xt(){return this.Ht.it(Object.assign({$i:this.wl.$i()},Bn(this.bl))),this.Ht}}class il extends ii{constructor(t,e){super(),this.bl=t,this.Li=e}Ei(t,e,i){const n=Bn(this.bl);i.t=n.t,t.O=n.O;const r=2/12*this.Li.P();i.gi=r,i.Mi=r,i.yi=n.yi,i.ki=n.ki,t.Jt=n.Jt,t.Tt=n.Tt,t.ai=n.ai}}class sl{constructor(t,e){this.gl=null,this.Ml=null,this.xl=null,this.Sl=null,this.kl=null,this.yl=t,this.Wr=e}Cl(){return this.yl}On(){var t,e;(e=(t=this.yl).updateAllViews)===null||e===void 0||e.call(t)}Pn(){var t,e,i,n;const r=(i=(e=(t=this.yl).paneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.gl)===null||n===void 0?void 0:n.vl)===r)return this.gl.pl;const o=r.map((h=>new Ki(h)));return this.gl={vl:r,pl:o},o}tn(){var t,e,i,n;const r=(i=(e=(t=this.yl).timeAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Ml)===null||n===void 0?void 0:n.vl)===r)return this.Ml.pl;const o=this.Wr.qt().yt(),h=r.map((l=>new el(l,o)));return this.Ml={vl:r,pl:h},h}Rn(){var t,e,i,n;const r=(i=(e=(t=this.yl).priceAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.xl)===null||n===void 0?void 0:n.vl)===r)return this.xl.pl;const o=this.Wr.At(),h=r.map((l=>new il(l,o)));return this.xl={vl:r,pl:h},h}Tl(){var t,e,i,n;const r=(i=(e=(t=this.yl).priceAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Sl)===null||n===void 0?void 0:n.vl)===r)return this.Sl.pl;const o=r.map((h=>new Ki(h)));return this.Sl={vl:r,pl:o},o}Pl(){var t,e,i,n;const r=(i=(e=(t=this.yl).timeAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.kl)===null||n===void 0?void 0:n.vl)===r)return this.kl.pl;const o=r.map((h=>new Ki(h)));return this.kl={vl:r,pl:o},o}Rl(t,e){var i,n,r;return(r=(n=(i=this.yl).autoscaleInfo)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}br(t,e){var i,n,r;return(r=(n=(i=this.yl).hitTest)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}}function Xi(s,t,e,i){s.forEach((n=>{t(n).forEach((r=>{r.ml()===e&&i.push(r)}))}))}function Yi(s){return s.Pn()}function nl(s){return s.Tl()}function rl(s){return s.Pl()}class Gi extends Yh{constructor(t,e,i,n,r){super(t),this.Lt=new Qh,this.Eh=new $h(this),this.Dl=[],this.Ol=new Nh(this),this.Al=null,this.Vl=null,this.Bl=[],this.Il=[],this.zl=null,this.El=[],this.cn=e,this.Ll=i;const o=new jh(this);this.hn=[o],this.Lh=new xn(o,this,t),i!=="Area"&&i!=="Line"&&i!=="Baseline"||(this.Al=new zh(this)),this.Nl(),this.Fl(r)}S(){this.zl!==null&&clearTimeout(this.zl)}_h(t){return this.cn.priceLineColor||t}Yr(t){const e={Xr:!0},i=this.At();if(this.qt().yt().Fi()||i.Fi()||this.Lt.Fi())return e;const n=this.qt().yt().Xs(),r=this.Pt();if(n===null||r===null)return e;let o,h;if(t){const u=this.Lt.Jh();if(u===null)return e;o=u,h=u.se}else{const u=this.Lt.nl(n.di(),-1);if(u===null||(o=this.Lt.qh(u.se),o===null))return e;h=u.se}const l=o.Vt[3],a=this.$s().Hs(h,{Vt:o}),c=i.Ot(l,r.Vt);return{Xr:!1,ct:l,Jt:i.Wi(l,r.Vt),mh:i.Wl(l),bh:i.jl(l,r.Vt),O:a.ue,yi:c,se:h}}$s(){return this.Vl!==null||(this.Vl=new Zh(this)),this.Vl}W(){return this.cn}Nh(t){const e=t.priceScaleId;e!==void 0&&e!==this.cn.priceScaleId&&this.qt().Hl(this,e),Ht(this.cn,t),t.priceFormat!==void 0&&(this.Nl(),this.qt().$l()),this.qt().Ul(this),this.qt().ql(),this.wn.gt("options")}it(t,e){this.Lt.it(t),this.Yl(),this.wn.gt("data"),this.dn.gt("data"),this.Al!==null&&(e&&e.Xl?this.Al.Hr():t.length===0&&this.Al.jr());const i=this.qt().cr(this);this.qt().Kl(i),this.qt().Ul(this),this.qt().ql(),this.qt().Fh()}Zl(t){this.Bl=t,this.Yl();const e=this.qt().cr(this);this.dn.gt("data"),this.qt().Kl(e),this.qt().Ul(this),this.qt().ql(),this.qt().Fh()}Gl(){return this.Bl}ah(){return this.Il}Jl(t){const e=new Xh(this,t);return this.Dl.push(e),this.qt().Ul(this),e}Ql(t){const e=this.Dl.indexOf(t);e!==-1&&this.Dl.splice(e,1),this.qt().Ul(this)}Xh(){return this.Ll}Pt(){const t=this.ta();return t===null?null:{Vt:t.Vt[3],ia:t.ut}}ta(){const t=this.qt().yt().Xs();if(t===null)return null;const e=t.Os();return this.Lt.nl(e,1)}In(){return this.Lt}oh(t){const e=this.Lt.qh(t);return e===null?null:this.Ll==="Bar"||this.Ll==="Candlestick"||this.Ll==="Custom"?{we:e.Vt[0],ge:e.Vt[1],Me:e.Vt[2],xe:e.Vt[3]}:e.Vt[3]}na(t){const e=[];Xi(this.El,Yi,"top",e);const i=this.Al;return i!==null&&i.Tt()&&(this.zl===null&&i.Ur()&&(this.zl=setTimeout((()=>{this.zl=null,this.qt().sa()}),0)),i.$r(),e.push(i)),e}Pn(){const t=[];this.ea()||t.push(this.Ol),t.push(this.wn,this.Eh,this.dn);const e=this.Dl.map((i=>i.Wh()));return t.push(...e),Xi(this.El,Yi,"normal",t),t}ra(){return this.ha(Yi,"bottom")}la(t){return this.ha(nl,t)}aa(t){return this.ha(rl,t)}oa(t,e){return this.El.map((i=>i.br(t,e))).filter((i=>i!==null))}Qi(t){return[this.Lh,...this.Dl.map((e=>e.jh()))]}Rn(t,e){if(e!==this.Xi&&!this.ea())return[];const i=[...this.hn];for(const n of this.Dl)i.push(n.Hh());return this.El.forEach((n=>{i.push(...n.Rn())})),i}tn(){const t=[];return this.El.forEach((e=>{t.push(...e.tn())})),t}Rl(t,e){if(this.cn.autoscaleInfoProvider!==void 0){const i=this.cn.autoscaleInfoProvider((()=>{const n=this._a(t,e);return n===null?null:n.Ph()}));return hi.Rh(i)}return this._a(t,e)}ua(){return this.cn.priceFormat.minMove}ca(){return this.da}On(){var t;this.wn.gt(),this.dn.gt();for(const e of this.hn)e.gt();for(const e of this.Dl)e.gt();this.Eh.gt(),this.Ol.gt(),(t=this.Al)===null||t===void 0||t.gt(),this.El.forEach((e=>e.On()))}At(){return S(super.At())}Ct(t){if(!((this.Ll==="Line"||this.Ll==="Area"||this.Ll==="Baseline")&&this.cn.crosshairMarkerVisible))return null;const e=this.Lt.qh(t);return e===null?null:{ct:e.Vt[3],ot:this.fa(),Bt:this.va(),Dt:this.pa(),Rt:this.ma(t)}}uh(){return this.cn.title}Tt(){return this.cn.visible}ba(t){this.El.push(new sl(t,this))}wa(t){this.El=this.El.filter((e=>e.Cl()!==t))}ga(){if(this.wn instanceof ji)return t=>this.wn.Fe(t)}Ma(){if(this.wn instanceof ji)return t=>this.wn.We(t)}ea(){return!si(this.At().xa())}_a(t,e){if(!ke(t)||!ke(e)||this.Lt.Fi())return null;const i=this.Ll==="Line"||this.Ll==="Area"||this.Ll==="Baseline"||this.Ll==="Histogram"?[3]:[2,1],n=this.Lt.el(t,e,i);let r=n!==null?new Pt(n.cl,n.dl):null;if(this.Xh()==="Histogram"){const h=this.cn.base,l=new Pt(h,h);r=r!==null?r.ts(l):l}let o=this.dn.lh();return this.El.forEach((h=>{const l=h.Rl(t,e);if(l?.priceRange){const g=new Pt(l.priceRange.minValue,l.priceRange.maxValue);r=r!==null?r.ts(g):g}var a,c,u,p;l?.margins&&(a=o,c=l.margins,o={above:Math.max((u=a?.above)!==null&&u!==void 0?u:0,c.above),below:Math.max((p=a?.below)!==null&&p!==void 0?p:0,c.below)})})),new hi(r,o)}fa(){switch(this.Ll){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerRadius}return 0}va(){switch(this.Ll){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}pa(){switch(this.Ll){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerBorderWidth}return 0}ma(t){switch(this.Ll){case"Line":case"Area":case"Baseline":{const e=this.cn.crosshairMarkerBackgroundColor;if(e.length!==0)return e}}return this.$s().Hs(t).ue}Nl(){switch(this.cn.priceFormat.type){case"custom":this.da={format:this.cn.priceFormat.formatter};break;case"volume":this.da=new fh(this.cn.priceFormat.precision);break;case"percent":this.da=new mn(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.da=new ni(t,this.cn.priceFormat.minMove*t)}}this.Xi!==null&&this.Xi.Sa()}Yl(){const t=this.qt().yt();if(!t.ka()||this.Lt.Fi())return void(this.Il=[]);const e=S(this.Lt.Qh());this.Il=this.Bl.map(((i,n)=>{const r=S(t.ya(i.time,!0)),o=r<e?1:-1;return{time:S(this.Lt.nl(r,o)).se,position:i.position,shape:i.shape,color:i.color,id:i.id,Jr:n,text:i.text,size:i.size,originalTime:i.originalTime}}))}Fl(t){switch(this.dn=new Hh(this,this.qt()),this.Ll){case"Bar":this.wn=new Sh(this,this.qt());break;case"Candlestick":this.wn=new Lh(this,this.qt());break;case"Line":this.wn=new kh(this,this.qt());break;case"Custom":this.wn=new ji(this,this.qt(),kt(t));break;case"Area":this.wn=new yh(this,this.qt());break;case"Baseline":this.wn=new Eh(this,this.qt());break;case"Histogram":this.wn=new Oh(this,this.qt());break;default:throw Error("Unknown chart style assigned: "+this.Ll)}}ha(t,e){const i=[];return Xi(this.El,t,e,i),i}}class ol{constructor(t){this.cn=t}Ca(t,e,i){let n=t;if(this.cn.mode===0)return n;const r=i.vn(),o=r.Pt();if(o===null)return n;const h=r.Ot(t,o),l=i.Ta().filter((c=>c instanceof Gi)).reduce(((c,u)=>{if(i.dr(u)||!u.Tt())return c;const p=u.At(),g=u.In();if(p.Fi()||!g.Kr(e))return c;const d=g.qh(e);if(d===null)return c;const f=Se(u.Pt());return c.concat([p.Ot(d.Vt[3],f.Vt)])}),[]);if(l.length===0)return n;l.sort(((c,u)=>Math.abs(c-h)-Math.abs(u-h)));const a=l[0];return n=r.pn(a,o),n}}class hl extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null)return;const r=Math.max(1,Math.floor(i));t.lineWidth=r,(function(o,h){o.save(),o.lineWidth%2&&o.translate(.5,.5),h(),o.restore()})(t,(()=>{const o=S(this.Lt);if(o.Pa){t.strokeStyle=o.Ra,pe(t,o.Da),t.beginPath();for(const h of o.Oa){const l=Math.round(h.Aa*i);t.moveTo(l,-r),t.lineTo(l,e.height+r)}t.stroke()}if(o.Va){t.strokeStyle=o.Ba,pe(t,o.Ia),t.beginPath();for(const h of o.za){const l=Math.round(h.Aa*n);t.moveTo(-r,l),t.lineTo(e.width+r,l)}t.stroke()}}))}}class ll{constructor(t){this.Ht=new hl,this.bt=!0,this.nn=t}gt(){this.bt=!0}xt(){if(this.bt){const t=this.nn.qt().W().grid,e={Va:t.horzLines.visible,Pa:t.vertLines.visible,Ba:t.horzLines.color,Ra:t.vertLines.color,Ia:t.horzLines.style,Da:t.vertLines.style,za:this.nn.vn().Ea(),Oa:(this.nn.qt().yt().Ea()||[]).map((i=>({Aa:i.coord})))};this.Ht.it(e),this.bt=!1}return this.Ht}}class al{constructor(t){this.wn=new ll(t)}Wh(){return this.wn}}const Zi={La:4,Na:1e-4};function Te(s,t){const e=100*(s-t)/t;return t<0?-e:e}function cl(s,t){const e=Te(s.Sh(),t),i=Te(s.kh(),t);return new Pt(e,i)}function ze(s,t){const e=100*(s-t)/t+100;return t<0?-e:e}function ul(s,t){const e=ze(s.Sh(),t),i=ze(s.kh(),t);return new Pt(e,i)}function ai(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.log10(e+t.Na)+t.La;return s<0?-i:i}function Ue(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.pow(10,e-t.La)-t.Na;return s<0?-i:i}function Ve(s,t){if(s===null)return null;const e=ai(s.Sh(),t),i=ai(s.kh(),t);return new Pt(e,i)}function ci(s,t){if(s===null)return null;const e=Ue(s.Sh(),t),i=Ue(s.kh(),t);return new Pt(e,i)}function Qi(s){if(s===null)return Zi;const t=Math.abs(s.kh()-s.Sh());if(t>=1||t<1e-15)return Zi;const e=Math.ceil(Math.abs(Math.log10(t))),i=Zi.La+e;return{La:i,Na:1/Math.pow(10,i)}}class ts{constructor(t,e){if(this.Fa=t,this.Wa=e,(function(i){if(i<0)return!1;for(let n=i;n>1;n/=10)if(n%10!=0)return!1;return!0})(this.Fa))this.ja=[2,2.5,2];else{this.ja=[];for(let i=this.Fa;i!==1;){if(i%2==0)this.ja.push(2),i/=2;else{if(i%5!=0)throw new Error("unexpected base");this.ja.push(2,2.5),i/=5}if(this.ja.length>100)throw new Error("something wrong with base")}}}Ha(t,e,i){const n=this.Fa===0?0:1/this.Fa;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-e)))),o=0,h=this.Wa[0];for(;;){const u=ri(r,n,1e-14)&&r>n+1e-14,p=ri(r,i*h,1e-14),g=ri(r,1,1e-14);if(!(u&&p&&g))break;r/=h,h=this.Wa[++o%this.Wa.length]}if(r<=n+1e-14&&(r=n),r=Math.max(1,r),this.ja.length>0&&(l=r,a=1,c=1e-14,Math.abs(l-a)<c))for(o=0,h=this.ja[0];ri(r,i*h,1e-14)&&r>n+1e-14;)r/=h,h=this.ja[++o%this.ja.length];var l,a,c;return r}}class Fn{constructor(t,e,i,n){this.$a=[],this.Li=t,this.Fa=e,this.Ua=i,this.qa=n}Ha(t,e){if(t<e)throw new Error("high < low");const i=this.Li.zt(),n=(t-e)*this.Ya()/i,r=new ts(this.Fa,[2,2.5,2]),o=new ts(this.Fa,[2,2,2.5]),h=new ts(this.Fa,[2.5,2,2]),l=[];return l.push(r.Ha(t,e,n),o.Ha(t,e,n),h.Ha(t,e,n)),(function(a){if(a.length<1)throw Error("array is empty");let c=a[0];for(let u=1;u<a.length;++u)a[u]<c&&(c=a[u]);return c})(l)}Xa(){const t=this.Li,e=t.Pt();if(e===null)return void(this.$a=[]);const i=t.zt(),n=this.Ua(i-1,e),r=this.Ua(0,e),o=this.Li.W().entireTextOnly?this.Ka()/2:0,h=o,l=i-1-o,a=Math.max(n,r),c=Math.min(n,r);if(a===c)return void(this.$a=[]);let u=this.Ha(a,c),p=a%u;p+=p<0?u:0;const g=a>=c?1:-1;let d=null,f=0;for(let m=a-p;m>c;m-=u){const w=this.qa(m,e,!0);d!==null&&Math.abs(w-d)<this.Ya()||w<h||w>l||(f<this.$a.length?(this.$a[f].Aa=w,this.$a[f].Za=t.Ga(m)):this.$a.push({Aa:w,Za:t.Ga(m)}),f++,d=w,t.Ja()&&(u=this.Ha(m*g,c)))}this.$a.length=f}Ea(){return this.$a}Ka(){return this.Li.P()}Ya(){return Math.ceil(2.5*this.Ka())}}function zn(s){return s.slice().sort(((t,e)=>S(t.Zi())-S(e.Zi())))}var Un;(function(s){s[s.Normal=0]="Normal",s[s.Logarithmic=1]="Logarithmic",s[s.Percentage=2]="Percentage",s[s.IndexedTo100=3]="IndexedTo100"})(Un||(Un={}));const Vn=new mn,Wn=new ni(100,1);class fl{constructor(t,e,i,n){this.Qa=0,this.io=null,this.Dh=null,this.no=null,this.so={eo:!1,ro:null},this.ho=0,this.lo=0,this.ao=new yt,this.oo=new yt,this._o=[],this.uo=null,this.co=null,this.do=null,this.fo=null,this.da=Wn,this.vo=Qi(null),this.po=t,this.cn=e,this.mo=i,this.bo=n,this.wo=new Fn(this,100,this.Mo.bind(this),this.xo.bind(this))}xa(){return this.po}W(){return this.cn}Nh(t){if(Ht(this.cn,t),this.Sa(),t.mode!==void 0&&this.So({yr:t.mode}),t.scaleMargins!==void 0){const e=kt(t.scaleMargins.top),i=kt(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||e+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.ko(),this.co=null}}yo(){return this.cn.autoScale}Ja(){return this.cn.mode===1}ph(){return this.cn.mode===2}Co(){return this.cn.mode===3}yr(){return{Wn:this.cn.autoScale,To:this.cn.invertScale,yr:this.cn.mode}}So(t){const e=this.yr();let i=null;t.Wn!==void 0&&(this.cn.autoScale=t.Wn),t.yr!==void 0&&(this.cn.mode=t.yr,t.yr!==2&&t.yr!==3||(this.cn.autoScale=!0),this.so.eo=!1),e.yr===1&&t.yr!==e.yr&&((function(r,o){if(r===null)return!1;const h=Ue(r.Sh(),o),l=Ue(r.kh(),o);return isFinite(h)&&isFinite(l)})(this.Dh,this.vo)?(i=ci(this.Dh,this.vo),i!==null&&this.Po(i)):this.cn.autoScale=!0),t.yr===1&&t.yr!==e.yr&&(i=Ve(this.Dh,this.vo),i!==null&&this.Po(i));const n=e.yr!==this.cn.mode;n&&(e.yr===2||this.ph())&&this.Sa(),n&&(e.yr===3||this.Co())&&this.Sa(),t.To!==void 0&&e.To!==t.To&&(this.cn.invertScale=t.To,this.Ro()),this.oo.m(e,this.yr())}Do(){return this.oo}P(){return this.mo.fontSize}zt(){return this.Qa}Oo(t){this.Qa!==t&&(this.Qa=t,this.ko(),this.co=null)}Ao(){if(this.io)return this.io;const t=this.zt()-this.Vo()-this.Bo();return this.io=t,t}Ah(){return this.Io(),this.Dh}Po(t,e){const i=this.Dh;(e||i===null&&t!==null||i!==null&&!i.Mh(t))&&(this.co=null,this.Dh=t)}Fi(){return this.Io(),this.Qa===0||!this.Dh||this.Dh.Fi()}zo(t){return this.To()?t:this.zt()-1-t}Ot(t,e){return this.ph()?t=Te(t,e):this.Co()&&(t=ze(t,e)),this.xo(t,e)}Qs(t,e,i){this.Io();const n=this.Bo(),r=S(this.Ah()),o=r.Sh(),h=r.kh(),l=this.Ao()-1,a=this.To(),c=l/(h-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,g=this.Eo();for(let d=u;d<p;d++){const f=t[d],m=f.ct;if(isNaN(m))continue;let w=m;g!==null&&(w=g(f.ct,e));const M=n+c*(w-o),R=a?M:this.Qa-1-M;f.rt=R}}me(t,e,i){this.Io();const n=this.Bo(),r=S(this.Ah()),o=r.Sh(),h=r.kh(),l=this.Ao()-1,a=this.To(),c=l/(h-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,g=this.Eo();for(let d=u;d<p;d++){const f=t[d];let m=f.we,w=f.ge,M=f.Me,R=f.xe;g!==null&&(m=g(f.we,e),w=g(f.ge,e),M=g(f.Me,e),R=g(f.xe,e));let k=n+c*(m-o),$=a?k:this.Qa-1-k;f.ve=$,k=n+c*(w-o),$=a?k:this.Qa-1-k,f.ce=$,k=n+c*(M-o),$=a?k:this.Qa-1-k,f.de=$,k=n+c*(R-o),$=a?k:this.Qa-1-k,f.pe=$}}pn(t,e){const i=this.Mo(t,e);return this.Lo(i,e)}Lo(t,e){let i=t;return this.ph()?i=(function(n,r){return r<0&&(n=-n),n/100*r+r})(i,e):this.Co()&&(i=(function(n,r){return n-=100,r<0&&(n=-n),n/100*r+r})(i,e)),i}Ta(){return this._o}No(){if(this.uo)return this.uo;let t=[];for(let e=0;e<this._o.length;e++){const i=this._o[e];i.Zi()===null&&i.Gi(e+1),t.push(i)}return t=zn(t),this.uo=t,this.uo}Fo(t){this._o.indexOf(t)===-1&&(this._o.push(t),this.Sa(),this.Wo())}jo(t){const e=this._o.indexOf(t);if(e===-1)throw new Error("source is not attached to scale");this._o.splice(e,1),this._o.length===0&&(this.So({Wn:!0}),this.Po(null)),this.Sa(),this.Wo()}Pt(){let t=null;for(const e of this._o){const i=e.Pt();i!==null&&(t===null||i.ia<t.ia)&&(t=i)}return t===null?null:t.Vt}To(){return this.cn.invertScale}Ea(){const t=this.Pt()===null;if(this.co!==null&&(t||this.co.Ho===t))return this.co.Ea;this.wo.Xa();const e=this.wo.Ea();return this.co={Ea:e,Ho:t},this.ao.m(),e}$o(){return this.ao}Uo(t){this.ph()||this.Co()||this.do===null&&this.no===null&&(this.Fi()||(this.do=this.Qa-t,this.no=S(this.Ah()).xh()))}qo(t){if(this.ph()||this.Co()||this.do===null)return;this.So({Wn:!1}),(t=this.Qa-t)<0&&(t=0);let e=(this.do+.2*(this.Qa-1))/(t+.2*(this.Qa-1));const i=S(this.no).xh();e=Math.max(e,.1),i.Ch(e),this.Po(i)}Yo(){this.ph()||this.Co()||(this.do=null,this.no=null)}Xo(t){this.yo()||this.fo===null&&this.no===null&&(this.Fi()||(this.fo=t,this.no=S(this.Ah()).xh()))}Ko(t){if(this.yo()||this.fo===null)return;const e=S(this.Ah()).yh()/(this.Ao()-1);let i=t-this.fo;this.To()&&(i*=-1);const n=i*e,r=S(this.no).xh();r.Th(n),this.Po(r,!0),this.co=null}Zo(){this.yo()||this.fo!==null&&(this.fo=null,this.no=null)}ca(){return this.da||this.Sa(),this.da}Wi(t,e){switch(this.cn.mode){case 2:return this.Go(Te(t,e));case 3:return this.ca().format(ze(t,e));default:return this.zh(t)}}Ga(t){switch(this.cn.mode){case 2:return this.Go(t);case 3:return this.ca().format(t);default:return this.zh(t)}}Wl(t){return this.zh(t,S(this.Jo()).ca())}jl(t,e){return t=Te(t,e),this.Go(t,Vn)}Qo(){return this._o}t_(t){this.so={ro:t,eo:!1}}On(){this._o.forEach((t=>t.On()))}Sa(){this.co=null;const t=this.Jo();let e=100;t!==null&&(e=Math.round(1/t.ua())),this.da=Wn,this.ph()?(this.da=Vn,e=100):this.Co()?(this.da=new ni(100,1),e=100):t!==null&&(this.da=t.ca()),this.wo=new Fn(this,e,this.Mo.bind(this),this.xo.bind(this)),this.wo.Xa()}Wo(){this.uo=null}Jo(){return this._o[0]||null}Vo(){return this.To()?this.cn.scaleMargins.bottom*this.zt()+this.lo:this.cn.scaleMargins.top*this.zt()+this.ho}Bo(){return this.To()?this.cn.scaleMargins.top*this.zt()+this.ho:this.cn.scaleMargins.bottom*this.zt()+this.lo}Io(){this.so.eo||(this.so.eo=!0,this.i_())}ko(){this.io=null}xo(t,e){if(this.Io(),this.Fi())return 0;t=this.Ja()&&t?ai(t,this.vo):t;const i=S(this.Ah()),n=this.Bo()+(this.Ao()-1)*(t-i.Sh())/i.yh();return this.zo(n)}Mo(t,e){if(this.Io(),this.Fi())return 0;const i=this.zo(t),n=S(this.Ah()),r=n.Sh()+n.yh()*((i-this.Bo())/(this.Ao()-1));return this.Ja()?Ue(r,this.vo):r}Ro(){this.co=null,this.wo.Xa()}i_(){const t=this.so.ro;if(t===null)return;let e=null;const i=this.Qo();let n=0,r=0;for(const l of i){if(!l.Tt())continue;const a=l.Pt();if(a===null)continue;const c=l.Rl(t.Os(),t.di());let u=c&&c.Ah();if(u!==null){switch(this.cn.mode){case 1:u=Ve(u,this.vo);break;case 2:u=cl(u,a.Vt);break;case 3:u=ul(u,a.Vt)}if(e=e===null?u:e.ts(S(u)),c!==null){const p=c.Vh();p!==null&&(n=Math.max(n,p.above),r=Math.max(n,p.below))}}}if(n===this.ho&&r===this.lo||(this.ho=n,this.lo=r,this.co=null,this.ko()),e!==null){if(e.Sh()===e.kh()){const l=this.Jo(),a=5*(l===null||this.ph()||this.Co()?1:l.ua());this.Ja()&&(e=ci(e,this.vo)),e=new Pt(e.Sh()-a,e.kh()+a),this.Ja()&&(e=Ve(e,this.vo))}if(this.Ja()){const l=ci(e,this.vo),a=Qi(l);if(o=a,h=this.vo,o.La!==h.La||o.Na!==h.Na){const c=this.no!==null?ci(this.no,this.vo):null;this.vo=a,e=Ve(l,a),c!==null&&(this.no=Ve(c,a))}}this.Po(e)}else this.Dh===null&&(this.Po(new Pt(-.5,.5)),this.vo=Qi(null));var o,h;this.so.eo=!0}Eo(){return this.ph()?Te:this.Co()?ze:this.Ja()?t=>ai(t,this.vo):null}n_(t,e,i){return e===void 0?(i===void 0&&(i=this.ca()),i.format(t)):e(t)}zh(t,e){return this.n_(t,this.bo.priceFormatter,e)}Go(t,e){return this.n_(t,this.bo.percentageFormatter,e)}}class dl{constructor(t,e){this._o=[],this.s_=new Map,this.Qa=0,this.e_=0,this.r_=1e3,this.uo=null,this.h_=new yt,this.wl=t,this.Ui=e,this.l_=new al(this);const i=e.W();this.a_=this.o_("left",i.leftPriceScale),this.__=this.o_("right",i.rightPriceScale),this.a_.Do().l(this.u_.bind(this,this.a_),this),this.__.Do().l(this.u_.bind(this,this.__),this),this.c_(i)}c_(t){if(t.leftPriceScale&&this.a_.Nh(t.leftPriceScale),t.rightPriceScale&&this.__.Nh(t.rightPriceScale),t.localization&&(this.a_.Sa(),this.__.Sa()),t.overlayPriceScales){const e=Array.from(this.s_.values());for(const i of e){const n=S(i[0].At());n.Nh(t.overlayPriceScales),t.localization&&n.Sa()}}}d_(t){switch(t){case"left":return this.a_;case"right":return this.__}return this.s_.has(t)?kt(this.s_.get(t))[0].At():null}S(){this.qt().f_().p(this),this.a_.Do().p(this),this.__.Do().p(this),this._o.forEach((t=>{t.S&&t.S()})),this.h_.m()}v_(){return this.r_}p_(t){this.r_=t}qt(){return this.Ui}$i(){return this.e_}zt(){return this.Qa}m_(t){this.e_=t,this.b_()}Oo(t){this.Qa=t,this.a_.Oo(t),this.__.Oo(t),this._o.forEach((e=>{if(this.dr(e)){const i=e.At();i!==null&&i.Oo(t)}})),this.b_()}Ta(){return this._o}dr(t){const e=t.At();return e===null||this.a_!==e&&this.__!==e}Fo(t,e,i){const n=i!==void 0?i:this.g_().w_+1;this.M_(t,e,n)}jo(t){const e=this._o.indexOf(t);le(e!==-1,"removeDataSource: invalid data source"),this._o.splice(e,1);const i=S(t.At()).xa();if(this.s_.has(i)){const r=kt(this.s_.get(i)),o=r.indexOf(t);o!==-1&&(r.splice(o,1),r.length===0&&this.s_.delete(i))}const n=t.At();n&&n.Ta().indexOf(t)>=0&&n.jo(t),n!==null&&(n.Wo(),this.x_(n)),this.uo=null}pr(t){return t===this.a_?"left":t===this.__?"right":"overlay"}S_(){return this.a_}k_(){return this.__}y_(t,e){t.Uo(e)}C_(t,e){t.qo(e),this.b_()}T_(t){t.Yo()}P_(t,e){t.Xo(e)}R_(t,e){t.Ko(e),this.b_()}D_(t){t.Zo()}b_(){this._o.forEach((t=>{t.On()}))}vn(){let t=null;return this.Ui.W().rightPriceScale.visible&&this.__.Ta().length!==0?t=this.__:this.Ui.W().leftPriceScale.visible&&this.a_.Ta().length!==0?t=this.a_:this._o.length!==0&&(t=this._o[0].At()),t===null&&(t=this.__),t}vr(){let t=null;return this.Ui.W().rightPriceScale.visible?t=this.__:this.Ui.W().leftPriceScale.visible&&(t=this.a_),t}x_(t){t!==null&&t.yo()&&this.O_(t)}A_(t){const e=this.wl.Xs();t.So({Wn:!0}),e!==null&&t.t_(e),this.b_()}V_(){this.O_(this.a_),this.O_(this.__)}B_(){this.x_(this.a_),this.x_(this.__),this._o.forEach((t=>{this.dr(t)&&this.x_(t.At())})),this.b_(),this.Ui.Fh()}No(){return this.uo===null&&(this.uo=zn(this._o)),this.uo}I_(){return this.h_}z_(){return this.l_}O_(t){const e=t.Qo();if(e&&e.length>0&&!this.wl.Fi()){const i=this.wl.Xs();i!==null&&t.t_(i)}t.On()}g_(){const t=this.No();if(t.length===0)return{E_:0,w_:0};let e=0,i=0;for(let n=0;n<t.length;n++){const r=t[n].Zi();r!==null&&(r<e&&(e=r),r>i&&(i=r))}return{E_:e,w_:i}}M_(t,e,i){let n=this.d_(e);if(n===null&&(n=this.o_(e,this.Ui.W().overlayPriceScales)),this._o.push(t),!si(e)){const r=this.s_.get(e)||[];r.push(t),this.s_.set(e,r)}n.Fo(t),t.Ji(n),t.Gi(i),this.x_(n),this.uo=null}u_(t,e,i){e.yr!==i.yr&&this.O_(t)}o_(t,e){const i=Object.assign({visible:!0,autoScale:!0},re(e)),n=new fl(t,i,this.Ui.W().layout,this.Ui.W().localization);return n.Oo(this.zt()),n}}class pl{constructor(t,e,i=50){this.Ke=0,this.Ze=1,this.Ge=1,this.Qe=new Map,this.Je=new Map,this.L_=t,this.N_=e,this.tr=i}F_(t){const e=t.time,i=this.N_.cacheKey(e),n=this.Qe.get(i);if(n!==void 0)return n.W_;if(this.Ke===this.tr){const o=this.Je.get(this.Ge);this.Je.delete(this.Ge),this.Qe.delete(kt(o)),this.Ge++,this.Ke--}const r=this.L_(t);return this.Qe.set(i,{W_:r,er:this.Ze}),this.Je.set(this.Ze,i),this.Ke++,this.Ze++,r}}class We{constructor(t,e){le(t<=e,"right should be >= left"),this.j_=t,this.H_=e}Os(){return this.j_}di(){return this.H_}U_(){return this.H_-this.j_+1}Kr(t){return this.j_<=t&&t<=this.H_}Mh(t){return this.j_===t.Os()&&this.H_===t.di()}}function In(s,t){return s===null||t===null?s===t:s.Mh(t)}class ml{constructor(){this.q_=new Map,this.Qe=null,this.Y_=!1}X_(t){this.Y_=t,this.Qe=null}K_(t,e){this.Z_(e),this.Qe=null;for(let i=e;i<t.length;++i){const n=t[i];let r=this.q_.get(n.timeWeight);r===void 0&&(r=[],this.q_.set(n.timeWeight,r)),r.push({index:i,time:n.time,weight:n.timeWeight,originalTime:n.originalTime})}}G_(t,e){const i=Math.ceil(e/t);return this.Qe!==null&&this.Qe.J_===i||(this.Qe={Ea:this.Q_(i),J_:i}),this.Qe.Ea}Z_(t){if(t===0)return void this.q_.clear();const e=[];this.q_.forEach(((i,n)=>{t<=i[0].index?e.push(n):i.splice(De(i,t,(r=>r.index<t)),1/0)}));for(const i of e)this.q_.delete(i)}Q_(t){let e=[];for(const i of Array.from(this.q_.keys()).sort(((n,r)=>r-n))){if(!this.q_.get(i))continue;const n=e;e=[];const r=n.length;let o=0;const h=kt(this.q_.get(i)),l=h.length;let a=1/0,c=-1/0;for(let u=0;u<l;u++){const p=h[u],g=p.index;for(;o<r;){const d=n[o],f=d.index;if(!(f<g)){a=f;break}o++,e.push(d),c=f,a=1/0}if(a-g>=t&&g-c>=t)e.push(p),c=g;else if(this.Y_)return n}for(;o<r;o++)e.push(n[o])}return e}}class Ee{constructor(t){this.tu=t}iu(){return this.tu===null?null:new We(Math.floor(this.tu.Os()),Math.ceil(this.tu.di()))}nu(){return this.tu}static su(){return new Ee(null)}}function gl(s,t){return s.weight>t.weight?s:t}class bl{constructor(t,e,i,n){this.e_=0,this.eu=null,this.ru=[],this.fo=null,this.do=null,this.hu=new ml,this.lu=new Map,this.au=Ee.su(),this.ou=!0,this._u=new yt,this.uu=new yt,this.cu=new yt,this.du=null,this.fu=null,this.vu=[],this.cn=e,this.bo=i,this.pu=e.rightOffset,this.mu=e.barSpacing,this.Ui=t,this.N_=n,this.bu(),this.hu.X_(e.uniformDistribution)}W(){return this.cn}wu(t){Ht(this.bo,t),this.gu(),this.bu()}Nh(t,e){var i;Ht(this.cn,t),this.cn.fixLeftEdge&&this.Mu(),this.cn.fixRightEdge&&this.xu(),t.barSpacing!==void 0&&this.Ui.Gn(t.barSpacing),t.rightOffset!==void 0&&this.Ui.Jn(t.rightOffset),t.minBarSpacing!==void 0&&this.Ui.Gn((i=t.barSpacing)!==null&&i!==void 0?i:this.mu),this.gu(),this.bu(),this.cu.m()}mn(t){var e,i;return(i=(e=this.ru[t])===null||e===void 0?void 0:e.time)!==null&&i!==void 0?i:null}qi(t){var e;return(e=this.ru[t])!==null&&e!==void 0?e:null}ya(t,e){if(this.ru.length<1)return null;if(this.N_.key(t)>this.N_.key(this.ru[this.ru.length-1].time))return e?this.ru.length-1:null;const i=De(this.ru,this.N_.key(t),((n,r)=>this.N_.key(n.time)<r));return this.N_.key(t)<this.N_.key(this.ru[i].time)?e?i:null:i}Fi(){return this.e_===0||this.ru.length===0||this.eu===null}ka(){return this.ru.length>0}Xs(){return this.Su(),this.au.iu()}ku(){return this.Su(),this.au.nu()}yu(){const t=this.Xs();if(t===null)return null;const e={from:t.Os(),to:t.di()};return this.Cu(e)}Cu(t){const e=Math.round(t.from),i=Math.round(t.to),n=S(this.Tu()),r=S(this.Bn());return{from:S(this.qi(Math.max(n,e))),to:S(this.qi(Math.min(r,i)))}}Pu(t){return{from:S(this.ya(t.from,!0)),to:S(this.ya(t.to,!0))}}$i(){return this.e_}m_(t){if(!isFinite(t)||t<=0||this.e_===t)return;const e=this.ku(),i=this.e_;if(this.e_=t,this.ou=!0,this.cn.lockVisibleTimeRangeOnResize&&i!==0){const n=this.mu*t/i;this.mu=n}if(this.cn.fixLeftEdge&&e!==null&&e.Os()<=0){const n=i-t;this.pu-=Math.round(n/this.mu)+1,this.ou=!0}this.Ru(),this.Du()}Et(t){if(this.Fi()||!ke(t))return 0;const e=this.Ou()+this.pu-t;return this.e_-(e+.5)*this.mu-1}Js(t,e){const i=this.Ou(),n=e===void 0?0:e.from,r=e===void 0?t.length:e.to;for(let o=n;o<r;o++){const h=t[o].ut,l=i+this.pu-h,a=this.e_-(l+.5)*this.mu-1;t[o].et=a}}Au(t){return Math.ceil(this.Vu(t))}Jn(t){this.ou=!0,this.pu=t,this.Du(),this.Ui.Bu(),this.Ui.Fh()}he(){return this.mu}Gn(t){this.Iu(t),this.Du(),this.Ui.Bu(),this.Ui.Fh()}zu(){return this.pu}Ea(){if(this.Fi())return null;if(this.fu!==null)return this.fu;const t=this.mu,e=5*(this.Ui.W().layout.fontSize+4)/8*(this.cn.tickMarkMaxCharacterLength||8),i=Math.round(e/t),n=S(this.Xs()),r=Math.max(n.Os(),n.Os()-i),o=Math.max(n.di(),n.di()-i),h=this.hu.G_(t,e),l=this.Tu()+i,a=this.Bn()-i,c=this.Eu(),u=this.cn.fixLeftEdge||c,p=this.cn.fixRightEdge||c;let g=0;for(const d of h){if(!(r<=d.index&&d.index<=o))continue;let f;g<this.vu.length?(f=this.vu[g],f.coord=this.Et(d.index),f.label=this.Lu(d),f.weight=d.weight):(f={needAlignCoordinate:!1,coord:this.Et(d.index),label:this.Lu(d),weight:d.weight},this.vu.push(f)),this.mu>e/2&&!c?f.needAlignCoordinate=!1:f.needAlignCoordinate=u&&d.index<=l||p&&d.index>=a,g++}return this.vu.length=g,this.fu=this.vu,this.vu}Nu(){this.ou=!0,this.Gn(this.cn.barSpacing),this.Jn(this.cn.rightOffset)}Fu(t){this.ou=!0,this.eu=t,this.Du(),this.Mu()}Wu(t,e){const i=this.Vu(t),n=this.he(),r=n+e*(n/10);this.Gn(r),this.cn.rightBarStaysOnScroll||this.Jn(this.zu()+(i-this.Vu(t)))}Uo(t){this.fo&&this.Zo(),this.do===null&&this.du===null&&(this.Fi()||(this.do=t,this.ju()))}qo(t){if(this.du===null)return;const e=qi(this.e_-t,0,this.e_),i=qi(this.e_-S(this.do),0,this.e_);e!==0&&i!==0&&this.Gn(this.du.he*e/i)}Yo(){this.do!==null&&(this.do=null,this.Hu())}Xo(t){this.fo===null&&this.du===null&&(this.Fi()||(this.fo=t,this.ju()))}Ko(t){if(this.fo===null)return;const e=(this.fo-t)/this.he();this.pu=S(this.du).zu+e,this.ou=!0,this.Du()}Zo(){this.fo!==null&&(this.fo=null,this.Hu())}$u(){this.Uu(this.cn.rightOffset)}Uu(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.pu,n=performance.now();this.Ui.Xn({qu:r=>(r-n)/e>=1,Yu:r=>{const o=(r-n)/e;return o>=1?t:i+(t-i)*o}})}gt(t,e){this.ou=!0,this.ru=t,this.hu.K_(t,e),this.Du()}Xu(){return this._u}Ku(){return this.uu}Zu(){return this.cu}Ou(){return this.eu||0}Gu(t){const e=t.U_();this.Iu(this.e_/e),this.pu=t.di()-this.Ou(),this.Du(),this.ou=!0,this.Ui.Bu(),this.Ui.Fh()}Ju(){const t=this.Tu(),e=this.Bn();t!==null&&e!==null&&this.Gu(new We(t,e+this.cn.rightOffset))}Qu(t){const e=new We(t.from,t.to);this.Gu(e)}Yi(t){return this.bo.timeFormatter!==void 0?this.bo.timeFormatter(t.originalTime):this.N_.formatHorzItem(t.time)}Bn(){return this.ru.length===0?null:this.ru.length-1}Eu(){const{handleScroll:t,handleScale:e}=this.Ui.W();return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||e.axisDoubleClickReset.time||e.axisPressedMouseMove.time||e.mouseWheel||e.pinch)}Tu(){return this.ru.length===0?null:0}tc(t){return(this.e_-1-t)/this.mu}Vu(t){const e=this.tc(t),i=this.Ou()+this.pu-e;return Math.round(1e6*i)/1e6}Iu(t){const e=this.mu;this.mu=t,this.Ru(),e!==this.mu&&(this.ou=!0,this.ic())}Su(){if(!this.ou)return;if(this.ou=!1,this.Fi())return void this.nc(Ee.su());const t=this.Ou(),e=this.e_/this.mu,i=this.pu+t,n=new We(i-e+1,i);this.nc(new Ee(n))}Ru(){const t=this.sc();if(this.mu<t&&(this.mu=t,this.ou=!0),this.e_!==0){const e=.5*this.e_;this.mu>e&&(this.mu=e,this.ou=!0)}}sc(){return this.cn.fixLeftEdge&&this.cn.fixRightEdge&&this.ru.length!==0?this.e_/this.ru.length:this.cn.minBarSpacing}Du(){const t=this.ec();this.pu>t&&(this.pu=t,this.ou=!0);const e=this.rc();e!==null&&this.pu<e&&(this.pu=e,this.ou=!0)}rc(){const t=this.Tu(),e=this.eu;return t===null||e===null?null:t-e-1+(this.cn.fixLeftEdge?this.e_/this.mu:Math.min(2,this.ru.length))}ec(){return this.cn.fixRightEdge?0:this.e_/this.mu-Math.min(2,this.ru.length)}ju(){this.du={he:this.he(),zu:this.zu()}}Hu(){this.du=null}Lu(t){let e=this.lu.get(t.weight);return e===void 0&&(e=new pl((i=>this.hc(i)),this.N_),this.lu.set(t.weight,e)),e.F_(t)}hc(t){return this.N_.formatTickmark(t,this.bo)}nc(t){const e=this.au;this.au=t,In(e.iu(),this.au.iu())||this._u.m(),In(e.nu(),this.au.nu())||this.uu.m(),this.ic()}ic(){this.fu=null}gu(){this.ic(),this.lu.clear()}bu(){this.N_.updateFormatter(this.bo)}Mu(){if(!this.cn.fixLeftEdge)return;const t=this.Tu();if(t===null)return;const e=this.Xs();if(e===null)return;const i=e.Os()-t;if(i<0){const n=this.pu-i-1;this.Jn(n)}this.Ru()}xu(){this.Du(),this.Ru()}}class vl extends Ui{constructor(t){super(),this.lc=new Map,this.Lt=t}Z(t){}J(t){if(!this.Lt.Tt)return;const{context:e,mediaSize:i}=t;let n=0;for(const o of this.Lt.ac){if(o.Jt.length===0)continue;e.font=o.R;const h=this.oc(e,o.Jt);h>i.width?o.Wu=i.width/h:o.Wu=1,n+=o._c*o.Wu}let r=0;switch(this.Lt.uc){case"top":r=0;break;case"center":r=Math.max((i.height-n)/2,0);break;case"bottom":r=Math.max(i.height-n,0)}e.fillStyle=this.Lt.O;for(const o of this.Lt.ac){e.save();let h=0;switch(this.Lt.cc){case"left":e.textAlign="left",h=o._c/2;break;case"center":e.textAlign="center",h=i.width/2;break;case"right":e.textAlign="right",h=i.width-1-o._c/2}e.translate(h,r),e.textBaseline="top",e.font=o.R,e.scale(o.Wu,o.Wu),e.fillText(o.Jt,0,o.dc),e.restore(),r+=o._c*o.Wu}}oc(t,e){const i=this.fc(t.font);let n=i.get(e);return n===void 0&&(n=t.measureText(e).width,i.set(e,n)),n}fc(t){let e=this.lc.get(t);return e===void 0&&(e=new Map,this.lc.set(t,e)),e}}class yl{constructor(t){this.bt=!0,this.jt={Tt:!1,O:"",ac:[],uc:"center",cc:"center"},this.Ht=new vl(this.jt),this.$t=t}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht}St(){const t=this.$t.W(),e=this.jt;e.Tt=t.visible,e.Tt&&(e.O=t.color,e.cc=t.horzAlign,e.uc=t.vertAlign,e.ac=[{Jt:t.text,R:_e(t.fontSize,t.fontFamily,t.fontStyle),_c:1.2*t.fontSize,dc:0,Wu:0}])}}class wl extends Wi{constructor(t,e){super(),this.cn=e,this.wn=new yl(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}On(){this.wn.gt()}}var qn,Hn,$n,jn,Jn;(function(s){s[s.OnTouchEnd=0]="OnTouchEnd",s[s.OnNextTap=1]="OnNextTap"})(qn||(qn={}));class Sl{constructor(t,e,i){this.vc=[],this.mc=[],this.e_=0,this.bc=null,this.wc=new yt,this.gc=new yt,this.Mc=null,this.xc=t,this.cn=e,this.N_=i,this.Sc=new th(this),this.wl=new bl(this,e.timeScale,this.cn.localization,i),this.wt=new uh(this,e.crosshair),this.kc=new ol(e.crosshair),this.yc=new wl(this,e.watermark),this.Cc(),this.vc[0].p_(2e3),this.Tc=this.Pc(0),this.Rc=this.Pc(1)}$l(){this.Dc(Ct.es())}Fh(){this.Dc(Ct.ss())}sa(){this.Dc(new Ct(1))}Ul(t){const e=this.Oc(t);this.Dc(e)}Ac(){return this.bc}Vc(t){const e=this.bc;this.bc=t,e!==null&&this.Ul(e.Bc),t!==null&&this.Ul(t.Bc)}W(){return this.cn}Nh(t){Ht(this.cn,t),this.vc.forEach((e=>e.c_(t))),t.timeScale!==void 0&&this.wl.Nh(t.timeScale),t.localization!==void 0&&this.wl.wu(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.wc.m(),this.Tc=this.Pc(0),this.Rc=this.Pc(1),this.$l()}Ic(t,e){if(t==="left")return void this.Nh({leftPriceScale:e});if(t==="right")return void this.Nh({rightPriceScale:e});const i=this.zc(t);i!==null&&(i.At.Nh(e),this.wc.m())}zc(t){for(const e of this.vc){const i=e.d_(t);if(i!==null)return{Ut:e,At:i}}return null}yt(){return this.wl}Ec(){return this.vc}Lc(){return this.yc}Nc(){return this.wt}Fc(){return this.gc}Wc(t,e){t.Oo(e),this.Bu()}m_(t){this.e_=t,this.wl.m_(this.e_),this.vc.forEach((e=>e.m_(t))),this.Bu()}Cc(t){const e=new dl(this.wl,this);t!==void 0?this.vc.splice(t,0,e):this.vc.push(e);const i=t===void 0?this.vc.length-1:t,n=Ct.es();return n.Nn(i,{Fn:0,Wn:!0}),this.Dc(n),e}y_(t,e,i){t.y_(e,i)}C_(t,e,i){t.C_(e,i),this.ql(),this.Dc(this.jc(t,2))}T_(t,e){t.T_(e),this.Dc(this.jc(t,2))}P_(t,e,i){e.yo()||t.P_(e,i)}R_(t,e,i){e.yo()||(t.R_(e,i),this.ql(),this.Dc(this.jc(t,2)))}D_(t,e){e.yo()||(t.D_(e),this.Dc(this.jc(t,2)))}A_(t,e){t.A_(e),this.Dc(this.jc(t,2))}Hc(t){this.wl.Uo(t)}$c(t,e){const i=this.yt();if(i.Fi()||e===0)return;const n=i.$i();t=Math.max(1,Math.min(t,n)),i.Wu(t,e),this.Bu()}Uc(t){this.qc(0),this.Yc(t),this.Xc()}Kc(t){this.wl.qo(t),this.Bu()}Zc(){this.wl.Yo(),this.Fh()}qc(t){this.wl.Xo(t)}Yc(t){this.wl.Ko(t),this.Bu()}Xc(){this.wl.Zo(),this.Fh()}Mt(){return this.mc}Gc(t,e,i,n,r){this.wt.gn(t,e);let o=NaN,h=this.wl.Au(t);const l=this.wl.Xs();l!==null&&(h=Math.min(Math.max(l.Os(),h),l.di()));const a=n.vn(),c=a.Pt();c!==null&&(o=a.pn(e,c)),o=this.kc.Ca(o,h,n),this.wt.kn(h,o,n),this.sa(),r||this.gc.m(this.wt.kt(),{x:t,y:e},i)}Jc(t,e,i){const n=i.vn(),r=n.Pt(),o=n.Ot(t,S(r)),h=this.wl.ya(e,!0),l=this.wl.Et(S(h));this.Gc(l,o,null,i,!0)}Qc(t){this.Nc().Cn(),this.sa(),t||this.gc.m(null,null,null)}ql(){const t=this.wt.Ut();if(t!==null){const e=this.wt.xn(),i=this.wt.Sn();this.Gc(e,i,null,t)}this.wt.On()}td(t,e,i){const n=this.wl.mn(0),r=this.wl.Bn();e!==void 0&&i!==void 0&&this.wl.gt(e,i);const o=this.wl.mn(0),h=this.wl.Ou(),l=this.wl.Xs();if(l!==null&&n!==null&&o!==null){const a=l.Kr(h),c=this.N_.key(n)>this.N_.key(o),u=t!==null&&t>h&&!c,p=this.wl.Bn(),g=a&&p!==r&&this.wl.W().shiftVisibleRangeOnNewBar;if(u&&!g){const d=t-h;this.wl.Jn(this.wl.zu()-d)}}this.wl.Fu(t)}Kl(t){t!==null&&t.B_()}cr(t){const e=this.vc.find((i=>i.No().includes(t)));return e===void 0?null:e}Bu(){this.yc.On(),this.vc.forEach((t=>t.B_())),this.ql()}S(){this.vc.forEach((t=>t.S())),this.vc.length=0,this.cn.localization.priceFormatter=void 0,this.cn.localization.percentageFormatter=void 0,this.cn.localization.timeFormatter=void 0}nd(){return this.Sc}mr(){return this.Sc.W()}f_(){return this.wc}sd(t,e,i){const n=this.vc[0],r=this.ed(e,t,n,i);return this.mc.push(r),this.mc.length===1?this.$l():this.Fh(),r}rd(t){const e=this.cr(t),i=this.mc.indexOf(t);le(i!==-1,"Series not found"),this.mc.splice(i,1),S(e).jo(t),t.S&&t.S()}Hl(t,e){const i=S(this.cr(t));i.jo(t);const n=this.zc(e);if(n===null){const r=t.Zi();i.Fo(t,e,r)}else{const r=n.Ut===i?t.Zi():void 0;n.Ut.Fo(t,e,r)}}Ju(){const t=Ct.ss();t.$n(),this.Dc(t)}hd(t){const e=Ct.ss();e.Yn(t),this.Dc(e)}Zn(){const t=Ct.ss();t.Zn(),this.Dc(t)}Gn(t){const e=Ct.ss();e.Gn(t),this.Dc(e)}Jn(t){const e=Ct.ss();e.Jn(t),this.Dc(e)}Xn(t){const e=Ct.ss();e.Xn(t),this.Dc(e)}Un(){const t=Ct.ss();t.Un(),this.Dc(t)}ld(){return this.cn.rightPriceScale.visible?"right":"left"}ad(){return this.Rc}q(){return this.Tc}It(t){const e=this.Rc,i=this.Tc;if(e===i)return e;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Mc===null||this.Mc.Ts!==i||this.Mc.Ps!==e)this.Mc={Ts:i,Ps:e,od:new Map};else{const r=this.Mc.od.get(t);if(r!==void 0)return r}const n=(function(r,o,h){const[l,a,c,u]=Ze(r),[p,g,d,f]=Ze(o),m=[zt(l+h*(p-l)),zt(a+h*(g-a)),zt(c+h*(d-c)),hn(u+h*(f-u))];return`rgba(${m[0]}, ${m[1]}, ${m[2]}, ${m[3]})`})(i,e,t/100);return this.Mc.od.set(t,n),n}jc(t,e){const i=new Ct(e);if(t!==null){const n=this.vc.indexOf(t);i.Nn(n,{Fn:e})}return i}Oc(t,e){return e===void 0&&(e=2),this.jc(this.cr(t),e)}Dc(t){this.xc&&this.xc(t),this.vc.forEach((e=>e.z_().Wh().gt()))}ed(t,e,i,n){const r=new Gi(this,t,e,i,n),o=t.priceScaleId!==void 0?t.priceScaleId:this.ld();return i.Fo(r,o),si(o)||r.Nh(t),r}Pc(t){const e=this.cn.layout;return e.background.type==="gradient"?t===0?e.background.topColor:e.background.bottomColor:e.background.color}}function es(s){return!Kt(s)&&!Pe(s)}function Kn(s){return Kt(s)}(function(s){s[s.Disabled=0]="Disabled",s[s.Continuous=1]="Continuous",s[s.OnDataUpdate=2]="OnDataUpdate"})(Hn||(Hn={})),(function(s){s[s.LastBar=0]="LastBar",s[s.LastVisible=1]="LastVisible"})($n||($n={})),(function(s){s.Solid="solid",s.VerticalGradient="gradient"})(jn||(jn={})),(function(s){s[s.Year=0]="Year",s[s.Month=1]="Month",s[s.DayOfMonth=2]="DayOfMonth",s[s.Time=3]="Time",s[s.TimeWithSeconds=4]="TimeWithSeconds"})(Jn||(Jn={}));const Xn=s=>s.getUTCFullYear();function _l(s,t,e){return t.replace(/yyyy/g,(i=>he(Xn(i),4))(s)).replace(/yy/g,(i=>he(Xn(i)%100,2))(s)).replace(/MMMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"long"}))(s,e)).replace(/MMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"short"}))(s,e)).replace(/MM/g,(i=>he((n=>n.getUTCMonth()+1)(i),2))(s)).replace(/dd/g,(i=>he((n=>n.getUTCDate())(i),2))(s))}class Yn{constructor(t="yyyy-MM-dd",e="default"){this._d=t,this.ud=e}F_(t){return _l(t,this._d,this.ud)}}class Tl{constructor(t){this.dd=t||"%h:%m:%s"}F_(t){return this.dd.replace("%h",he(t.getUTCHours(),2)).replace("%m",he(t.getUTCMinutes(),2)).replace("%s",he(t.getUTCSeconds(),2))}}const El={fd:"yyyy-MM-dd",vd:"%h:%m:%s",pd:" ",md:"default"};class Cl{constructor(t={}){const e=Object.assign(Object.assign({},El),t);this.bd=new Yn(e.fd,e.md),this.wd=new Tl(e.vd),this.gd=e.pd}F_(t){return`${this.bd.F_(t)}${this.gd}${this.wd.F_(t)}`}}function ui(s){return 60*s*60*1e3}function is(s){return 60*s*1e3}const fi=[{Md:(Gn=1,1e3*Gn),xd:10},{Md:is(1),xd:20},{Md:is(5),xd:21},{Md:is(30),xd:22},{Md:ui(1),xd:30},{Md:ui(3),xd:31},{Md:ui(6),xd:32},{Md:ui(12),xd:33}];var Gn;function Zn(s,t){if(s.getUTCFullYear()!==t.getUTCFullYear())return 70;if(s.getUTCMonth()!==t.getUTCMonth())return 60;if(s.getUTCDate()!==t.getUTCDate())return 50;for(let e=fi.length-1;e>=0;--e)if(Math.floor(t.getTime()/fi[e].Md)!==Math.floor(s.getTime()/fi[e].Md))return fi[e].xd;return 0}function ss(s){let t=s;if(Pe(s)&&(t=ns(s)),!es(t))throw new Error("time must be of type BusinessDay");const e=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{Sd:Math.round(e.getTime()/1e3),kd:t}}function Qn(s){if(!Kn(s))throw new Error("time must be of type isUTCTimestamp");return{Sd:s}}function ns(s){const t=new Date(s);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${s}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function tr(s){Pe(s.time)&&(s.time=ns(s.time))}class er{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?(function(e){e.forEach(tr)})(t):tr(t)}createConverterToInternalObj(t){return S((function(e){return e.length===0?null:es(e[0].time)||Pe(e[0].time)?ss:Qn})(t))}key(t){return typeof t=="object"&&"Sd"in t?t.Sd:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const e=t;return e.kd===void 0?new Date(1e3*e.Sd).getTime():new Date(Date.UTC(e.kd.year,e.kd.month-1,e.kd.day)).getTime()}convertHorzItemToInternal(t){return Kn(e=t)?Qn(e):es(e)?ss(e):ss(ns(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.yd=new Cl({fd:e,vd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",pd:" ",md:t.locale}):this.yd=new Yn(e,t.locale)}formatHorzItem(t){const e=t;return this.yd.F_(new Date(1e3*e.Sd))}formatTickmark(t,e){const i=(function(r,o,h){switch(r){case 0:case 10:return o?h?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}})(t.weight,this.cn.timeScale.timeVisible,this.cn.timeScale.secondsVisible),n=this.cn.timeScale;if(n.tickMarkFormatter!==void 0){const r=n.tickMarkFormatter(t.originalTime,i,e.locale);if(r!==null)return r}return(function(r,o,h){const l={};switch(o){case 0:l.year="numeric";break;case 1:l.month="short";break;case 2:l.day="numeric";break;case 3:l.hour12=!1,l.hour="2-digit",l.minute="2-digit";break;case 4:l.hour12=!1,l.hour="2-digit",l.minute="2-digit",l.second="2-digit"}const a=r.kd===void 0?new Date(1e3*r.Sd):new Date(Date.UTC(r.kd.year,r.kd.month-1,r.kd.day));return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()).toLocaleString(h,l)})(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(gl,t[0]).weight;return e>30&&e<50&&(e=30),e}fillWeightsForPoints(t,e){(function(i,n=0){if(i.length===0)return;let r=n===0?null:i[n-1].time.Sd,o=r!==null?new Date(1e3*r):null,h=0;for(let l=n;l<i.length;++l){const a=i[l],c=new Date(1e3*a.time.Sd);o!==null&&(a.timeWeight=Zn(c,o)),h+=a.time.Sd-(r||a.time.Sd),r=a.time.Sd,o=c}if(n===0&&i.length>1){const l=Math.ceil(h/(i.length-1)),a=new Date(1e3*(i[0].time.Sd-l));i[0].timeWeight=Zn(new Date(1e3*i[0].time.Sd),a)}})(t,e)}static Cd(t){return Ht({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Ce=typeof window<"u";function ir(){return!!Ce&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function rs(){return!!Ce&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function os(s){return s+s%2}function hs(s,t){return s.Td-t.Td}function ls(s,t,e){const i=(s.Td-t.Td)/(s.ut-t.ut);return Math.sign(i)*Math.min(Math.abs(i),e)}class Ll{constructor(t,e,i,n){this.Pd=null,this.Rd=null,this.Dd=null,this.Od=null,this.Ad=null,this.Vd=0,this.Bd=0,this.Id=t,this.zd=e,this.Ed=i,this.rs=n}Ld(t,e){if(this.Pd!==null){if(this.Pd.ut===e)return void(this.Pd.Td=t);if(Math.abs(this.Pd.Td-t)<this.rs)return}this.Od=this.Dd,this.Dd=this.Rd,this.Rd=this.Pd,this.Pd={ut:e,Td:t}}Dr(t,e){if(this.Pd===null||this.Rd===null||e-this.Pd.ut>50)return;let i=0;const n=ls(this.Pd,this.Rd,this.zd),r=hs(this.Pd,this.Rd),o=[n],h=[r];if(i+=r,this.Dd!==null){const a=ls(this.Rd,this.Dd,this.zd);if(Math.sign(a)===Math.sign(n)){const c=hs(this.Rd,this.Dd);if(o.push(a),h.push(c),i+=c,this.Od!==null){const u=ls(this.Dd,this.Od,this.zd);if(Math.sign(u)===Math.sign(n)){const p=hs(this.Dd,this.Od);o.push(u),h.push(p),i+=p}}}}let l=0;for(let a=0;a<o.length;++a)l+=h[a]/i*o[a];Math.abs(l)<this.Id||(this.Ad={Td:t,ut:e},this.Bd=l,this.Vd=(function(a,c){const u=Math.log(c);return Math.log(1*u/-a)/u})(Math.abs(l),this.Ed))}Yu(t){const e=S(this.Ad),i=t-e.ut;return e.Td+this.Bd*(Math.pow(this.Ed,i)-1)/Math.log(this.Ed)}qu(t){return this.Ad===null||this.Nd(t)===this.Vd}Nd(t){const e=t-S(this.Ad).ut;return Math.min(e,this.Vd)}}function me(s,t){const e=S(s.ownerDocument).createElement("canvas");s.appendChild(e);const i=Uo(e,{options:{allowResizeObserver:!1},transform:(n,r)=>({width:Math.max(n.width,r.width),height:Math.max(n.height,r.height)})});return i.resizeCanvasElement(t),i}function as(s,t,e,i){s.G&&s.G(t,e,i)}function di(s,t,e,i){s.K(t,e,i)}function cs(s,t,e,i){const n=s(e,i);for(const r of n){const o=r.xt();o!==null&&t(o)}}function xl(s){Ce&&window.chrome!==void 0&&s.addEventListener("mousedown",(t=>{if(t.button===1)return t.preventDefault(),!1}))}class us{constructor(t,e,i){this.Fd=0,this.Wd=null,this.jd={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY},this.Hd=0,this.$d=null,this.Ud={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY},this.qd=null,this.Yd=!1,this.Xd=null,this.Kd=null,this.Zd=!1,this.Gd=!1,this.Jd=!1,this.Qd=null,this.tf=null,this.if=null,this.nf=null,this.sf=null,this.ef=null,this.rf=null,this.hf=0,this.lf=!1,this.af=!1,this._f=!1,this.uf=0,this.cf=null,this.df=!rs(),this.ff=n=>{this.vf(n)},this.pf=n=>{if(this.mf(n)){const r=this.bf(n);if(++this.Hd,this.$d&&this.Hd>1){const{wf:o}=this.gf(Xt(n),this.Ud);o<30&&!this.Jd&&this.Mf(r,this.Sf.xf),this.kf()}}else{const r=this.bf(n);if(++this.Fd,this.Wd&&this.Fd>1){const{wf:o}=this.gf(Xt(n),this.jd);o<5&&!this.Gd&&this.yf(r,this.Sf.Cf),this.Tf()}}},this.Pf=t,this.Sf=e,this.cn=i,this.Rf()}S(){this.Qd!==null&&(this.Qd(),this.Qd=null),this.tf!==null&&(this.tf(),this.tf=null),this.nf!==null&&(this.nf(),this.nf=null),this.sf!==null&&(this.sf(),this.sf=null),this.ef!==null&&(this.ef(),this.ef=null),this.if!==null&&(this.if(),this.if=null),this.Df(),this.Tf()}Of(t){this.nf&&this.nf();const e=this.Af.bind(this);if(this.nf=()=>{this.Pf.removeEventListener("mousemove",e)},this.Pf.addEventListener("mousemove",e),this.mf(t))return;const i=this.bf(t);this.yf(i,this.Sf.Vf),this.df=!0}Tf(){this.Wd!==null&&clearTimeout(this.Wd),this.Fd=0,this.Wd=null,this.jd={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY}}kf(){this.$d!==null&&clearTimeout(this.$d),this.Hd=0,this.$d=null,this.Ud={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY}}Af(t){if(this._f||this.Kd!==null||this.mf(t))return;const e=this.bf(t);this.yf(e,this.Sf.Bf),this.df=!0}If(t){const e=fs(t.changedTouches,S(this.cf));if(e===null||(this.uf=pi(t),this.rf!==null)||this.af)return;this.lf=!0;const i=this.gf(Xt(e),S(this.Kd)),{zf:n,Ef:r,wf:o}=i;if(this.Zd||!(o<5)){if(!this.Zd){const h=.5*n,l=r>=h&&!this.cn.Lf(),a=h>r&&!this.cn.Nf();l||a||(this.af=!0),this.Zd=!0,this.Jd=!0,this.Df(),this.kf()}if(!this.af){const h=this.bf(t,e);this.Mf(h,this.Sf.Ff),Le(t)}}}Wf(t){if(t.button!==0)return;const e=this.gf(Xt(t),S(this.Xd)),{wf:i}=e;if(i>=5&&(this.Gd=!0,this.Tf()),this.Gd){const n=this.bf(t);this.yf(n,this.Sf.jf)}}gf(t,e){const i=Math.abs(e.et-t.et),n=Math.abs(e.rt-t.rt);return{zf:i,Ef:n,wf:i+n}}Hf(t){let e=fs(t.changedTouches,S(this.cf));if(e===null&&t.touches.length===0&&(e=t.changedTouches[0]),e===null)return;this.cf=null,this.uf=pi(t),this.Df(),this.Kd=null,this.ef&&(this.ef(),this.ef=null);const i=this.bf(t,e);if(this.Mf(i,this.Sf.$f),++this.Hd,this.$d&&this.Hd>1){const{wf:n}=this.gf(Xt(e),this.Ud);n<30&&!this.Jd&&this.Mf(i,this.Sf.xf),this.kf()}else this.Jd||(this.Mf(i,this.Sf.Uf),this.Sf.Uf&&Le(t));this.Hd===0&&Le(t),t.touches.length===0&&this.Yd&&(this.Yd=!1,Le(t))}vf(t){if(t.button!==0)return;const e=this.bf(t);if(this.Xd=null,this._f=!1,this.sf&&(this.sf(),this.sf=null),ir()&&this.Pf.ownerDocument.documentElement.removeEventListener("mouseleave",this.ff),!this.mf(t))if(this.yf(e,this.Sf.qf),++this.Fd,this.Wd&&this.Fd>1){const{wf:i}=this.gf(Xt(t),this.jd);i<5&&!this.Gd&&this.yf(e,this.Sf.Cf),this.Tf()}else this.Gd||this.yf(e,this.Sf.Yf)}Df(){this.qd!==null&&(clearTimeout(this.qd),this.qd=null)}Xf(t){if(this.cf!==null)return;const e=t.changedTouches[0];this.cf=e.identifier,this.uf=pi(t);const i=this.Pf.ownerDocument.documentElement;this.Jd=!1,this.Zd=!1,this.af=!1,this.Kd=Xt(e),this.ef&&(this.ef(),this.ef=null);{const r=this.If.bind(this),o=this.Hf.bind(this);this.ef=()=>{i.removeEventListener("touchmove",r),i.removeEventListener("touchend",o)},i.addEventListener("touchmove",r,{passive:!1}),i.addEventListener("touchend",o,{passive:!1}),this.Df(),this.qd=setTimeout(this.Kf.bind(this,t),240)}const n=this.bf(t,e);this.Mf(n,this.Sf.Zf),this.$d||(this.Hd=0,this.$d=setTimeout(this.kf.bind(this),500),this.Ud=Xt(e))}Gf(t){if(t.button!==0)return;const e=this.Pf.ownerDocument.documentElement;ir()&&e.addEventListener("mouseleave",this.ff),this.Gd=!1,this.Xd=Xt(t),this.sf&&(this.sf(),this.sf=null);{const n=this.Wf.bind(this),r=this.vf.bind(this);this.sf=()=>{e.removeEventListener("mousemove",n),e.removeEventListener("mouseup",r)},e.addEventListener("mousemove",n),e.addEventListener("mouseup",r)}if(this._f=!0,this.mf(t))return;const i=this.bf(t);this.yf(i,this.Sf.Jf),this.Wd||(this.Fd=0,this.Wd=setTimeout(this.Tf.bind(this),500),this.jd=Xt(t))}Rf(){this.Pf.addEventListener("mouseenter",this.Of.bind(this)),this.Pf.addEventListener("touchcancel",this.Df.bind(this));{const t=this.Pf.ownerDocument,e=i=>{this.Sf.Qf&&(i.composed&&this.Pf.contains(i.composedPath()[0])||i.target&&this.Pf.contains(i.target)||this.Sf.Qf())};this.tf=()=>{t.removeEventListener("touchstart",e)},this.Qd=()=>{t.removeEventListener("mousedown",e)},t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0})}rs()&&(this.if=()=>{this.Pf.removeEventListener("dblclick",this.pf)},this.Pf.addEventListener("dblclick",this.pf)),this.Pf.addEventListener("mouseleave",this.tv.bind(this)),this.Pf.addEventListener("touchstart",this.Xf.bind(this),{passive:!0}),xl(this.Pf),this.Pf.addEventListener("mousedown",this.Gf.bind(this)),this.iv(),this.Pf.addEventListener("touchmove",(()=>{}),{passive:!1})}iv(){this.Sf.nv===void 0&&this.Sf.sv===void 0&&this.Sf.ev===void 0||(this.Pf.addEventListener("touchstart",(t=>this.rv(t.touches)),{passive:!0}),this.Pf.addEventListener("touchmove",(t=>{if(t.touches.length===2&&this.rf!==null&&this.Sf.sv!==void 0){const e=sr(t.touches[0],t.touches[1])/this.hf;this.Sf.sv(this.rf,e),Le(t)}}),{passive:!1}),this.Pf.addEventListener("touchend",(t=>{this.rv(t.touches)})))}rv(t){t.length===1&&(this.lf=!1),t.length!==2||this.lf||this.Yd?this.hv():this.lv(t)}lv(t){const e=this.Pf.getBoundingClientRect()||{left:0,top:0};this.rf={et:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,rt:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this.hf=sr(t[0],t[1]),this.Sf.nv!==void 0&&this.Sf.nv(),this.Df()}hv(){this.rf!==null&&(this.rf=null,this.Sf.ev!==void 0&&this.Sf.ev())}tv(t){if(this.nf&&this.nf(),this.mf(t)||!this.df)return;const e=this.bf(t);this.yf(e,this.Sf.av),this.df=!rs()}Kf(t){const e=fs(t.touches,S(this.cf));if(e===null)return;const i=this.bf(t,e);this.Mf(i,this.Sf.ov),this.Jd=!0,this.Yd=!0}mf(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:pi(t)<this.uf+500}Mf(t,e){e&&e.call(this.Sf,t)}yf(t,e){e&&e.call(this.Sf,t)}bf(t,e){const i=e||t,n=this.Pf.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-n.left,localY:i.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,_v:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",uv:t.type,cv:i.target,dv:t.view,fv:()=>{t.type!=="touchstart"&&Le(t)}}}}function sr(s,t){const e=s.clientX-t.clientX,i=s.clientY-t.clientY;return Math.sqrt(e*e+i*i)}function Le(s){s.cancelable&&s.preventDefault()}function Xt(s){return{et:s.pageX,rt:s.pageY}}function pi(s){return s.timeStamp||performance.now()}function fs(s,t){for(let e=0;e<s.length;++e)if(s[e].identifier===t)return s[e];return null}function mi(s){return{Bc:s.Bc,vv:{wr:s.pv.externalId},mv:s.pv.cursorStyle}}function Ml(s,t,e){for(const i of s){const n=i.xt();if(n!==null&&n.br){const r=n.br(t,e);if(r!==null)return{dv:i,vv:r}}}return null}function ds(s,t){return e=>{var i,n,r,o;return((n=(i=e.At())===null||i===void 0?void 0:i.xa())!==null&&n!==void 0?n:"")!==t?[]:(o=(r=e.la)===null||r===void 0?void 0:r.call(e,s))!==null&&o!==void 0?o:[]}}class nr{constructor(t,e,i,n){this.Li=null,this.bv=null,this.wv=!1,this.gv=new Ne(200),this.Gr=null,this.Mv=0,this.xv=!1,this.Sv=()=>{this.xv||this.nn.kv().qt().Fh()},this.yv=()=>{this.xv||this.nn.kv().qt().Fh()},this.nn=t,this.cn=e,this.mo=e.layout,this.Sc=i,this.Cv=n==="left",this.Tv=ds("normal",n),this.Pv=ds("top",n),this.Rv=ds("bottom",n),this.Dv=document.createElement("div"),this.Dv.style.height="100%",this.Dv.style.overflow="hidden",this.Dv.style.width="25px",this.Dv.style.left="0",this.Dv.style.position="relative",this.Ov=me(this.Dv,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const r=this.Ov.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Av=me(this.Dv,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const o=this.Av.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const h={Jf:this.Vv.bind(this),Zf:this.Vv.bind(this),jf:this.Bv.bind(this),Ff:this.Bv.bind(this),Qf:this.Iv.bind(this),qf:this.zv.bind(this),$f:this.zv.bind(this),Cf:this.Ev.bind(this),xf:this.Ev.bind(this),Vf:this.Lv.bind(this),av:this.Nv.bind(this)};this.Fv=new us(this.Av.canvasElement,h,{Lf:()=>!1,Nf:()=>!0})}S(){this.Fv.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose(),this.Li!==null&&this.Li.$o().p(this),this.Li=null}Wv(){return this.Dv}P(){return this.mo.fontSize}jv(){const t=this.Sc.W();return this.Gr!==t.R&&(this.gv.ir(),this.Gr=t.R),t}Hv(){if(this.Li===null)return 0;let t=0;const e=this.jv(),i=S(this.Ov.canvasElement.getContext("2d"));i.save();const n=this.Li.Ea();i.font=this.$v(),n.length>0&&(t=Math.max(this.gv.Si(i,n[0].Za),this.gv.Si(i,n[n.length-1].Za)));const r=this.Uv();for(let l=r.length;l--;){const a=this.gv.Si(i,r[l].Jt());a>t&&(t=a)}const o=this.Li.Pt();if(o!==null&&this.bv!==null){const l=this.Li.pn(1,o),a=this.Li.pn(this.bv.height-2,o);t=Math.max(t,this.gv.Si(i,this.Li.Wi(Math.floor(Math.min(l,a))+.11111111111111,o)),this.gv.Si(i,this.Li.Wi(Math.ceil(Math.max(l,a))-.11111111111111,o)))}i.restore();const h=t||34;return os(Math.ceil(e.C+e.T+e.B+e.I+5+h))}qv(t){this.bv!==null&&fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`)}Yv(){return S(this.bv).width}Ji(t){this.Li!==t&&(this.Li!==null&&this.Li.$o().p(this),this.Li=t,t.$o().l(this.ao.bind(this),this))}At(){return this.Li}ir(){const t=this.nn.Xv();this.nn.kv().qt().A_(t,S(this.At()))}Kv(t){if(this.bv===null)return;if(t!==1){this.Zv(),this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n),this.Be(n)})),this.nn.Jv(i,this.Rv),this.Qv(i),this.nn.Jv(i,this.Tv),this.tp(i))}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.ip(e),this.nn.Jv(e,this.Pv))}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}gt(){var t;(t=this.Li)===null||t===void 0||t.Ea()}Vv(t){if(this.Li===null||this.Li.Fi()||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv();this.wv=!0,e.y_(i,this.Li,t.localY)}Bv(t){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv(),n=this.Li;e.C_(i,n,t.localY)}Iv(){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const t=this.nn.kv().qt(),e=this.nn.Xv(),i=this.Li;this.wv&&(this.wv=!1,t.T_(e,i))}zv(t){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv();this.wv=!1,e.T_(i,this.Li)}Ev(t){this.cn.handleScale.axisDoubleClickReset.price&&this.ir()}Lv(t){this.Li!==null&&(!this.nn.kv().qt().W().handleScale.axisPressedMouseMove.price||this.Li.ph()||this.Li.Co()||this.ep(1))}Nv(t){this.ep(0)}Uv(){const t=[],e=this.Li===null?void 0:this.Li;return(i=>{for(let n=0;n<i.length;++n){const r=i[n].Rn(this.nn.Xv(),e);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.nn.Xv().No()),t}Gv({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.nn.Xv().qt(),o=r.q(),h=r.ad();o===h?ei(t,0,0,i,n,o):cn(t,0,0,i,n,o,h)}Be({context:t,bitmapSize:e,horizontalPixelRatio:i}){if(this.bv===null||this.Li===null||!this.Li.W().borderVisible)return;t.fillStyle=this.Li.W().borderColor;const n=Math.max(1,Math.floor(this.jv().C*i));let r;r=this.Cv?e.width-n:0,t.fillRect(r,0,n,e.height)}Qv(t){if(this.bv===null||this.Li===null)return;const e=this.Li.Ea(),i=this.Li.W(),n=this.jv(),r=this.Cv?this.bv.width-n.T:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace((({context:o,horizontalPixelRatio:h,verticalPixelRatio:l})=>{o.fillStyle=i.borderColor;const a=Math.max(1,Math.floor(l)),c=Math.floor(.5*l),u=Math.round(n.T*h);o.beginPath();for(const p of e)o.rect(Math.floor(r*h),Math.round(p.Aa*l)-c,u,a);o.fill()})),t.useMediaCoordinateSpace((({context:o})=>{var h;o.font=this.$v(),o.fillStyle=(h=i.textColor)!==null&&h!==void 0?h:this.mo.textColor,o.textAlign=this.Cv?"right":"left",o.textBaseline="middle";const l=this.Cv?Math.round(r-n.B):Math.round(r+n.T+n.B),a=e.map((c=>this.gv.xi(o,c.Za)));for(let c=e.length;c--;){const u=e[c];o.fillText(u.Za,l,u.Aa+a[c])}}))}Zv(){if(this.bv===null||this.Li===null)return;let t=this.bv.height/2;const e=[],i=this.Li.No().slice(),n=this.nn.Xv(),r=this.jv();this.Li===n.vr()&&this.nn.Xv().No().forEach((l=>{n.dr(l)&&i.push(l)}));const o=this.Li.Ta()[0],h=this.Li;i.forEach((l=>{const a=l.Rn(n,h);a.forEach((c=>{c.Vi(null),c.Bi()&&e.push(c)})),o===l&&a.length>0&&(t=a[0].yi())})),e.forEach((l=>l.Vi(l.yi()))),this.Li.W().alignLabels&&this.rp(e,r,t)}rp(t,e,i){if(this.bv===null)return;const n=t.filter((o=>o.yi()<=i)),r=t.filter((o=>o.yi()>i));n.sort(((o,h)=>h.yi()-o.yi())),n.length&&r.length&&r.push(n[0]),r.sort(((o,h)=>o.yi()-h.yi()));for(const o of t){const h=Math.floor(o.zt(e)/2),l=o.yi();l>-h&&l<h&&o.Vi(h),l>this.bv.height-h&&l<this.bv.height+h&&o.Vi(this.bv.height-h)}for(let o=1;o<n.length;o++){const h=n[o],l=n[o-1],a=l.zt(e,!1),c=h.yi(),u=l.Ai();c>u-a&&h.Vi(u-a)}for(let o=1;o<r.length;o++){const h=r[o],l=r[o-1],a=l.zt(e,!0),c=h.yi(),u=l.Ai();c<u+a&&h.Vi(u+a)}}tp(t){if(this.bv===null)return;const e=this.Uv(),i=this.jv(),n=this.Cv?"right":"left";e.forEach((r=>{r.Ii()&&r.xt(S(this.Li)).K(t,i,this.gv,n)}))}ip(t){if(this.bv===null||this.Li===null)return;const e=this.nn.kv().qt(),i=[],n=this.nn.Xv(),r=e.Nc().Rn(n,this.Li);r.length&&i.push(r);const o=this.jv(),h=this.Cv?"right":"left";i.forEach((l=>{l.forEach((a=>{a.xt(S(this.Li)).K(t,o,this.gv,h)}))}))}ep(t){this.Dv.style.cursor=t===1?"ns-resize":"default"}ao(){const t=this.Hv();this.Mv<t&&this.nn.kv().qt().$l(),this.Mv=t}$v(){return _e(this.mo.fontSize,this.mo.fontFamily)}}function Rl(s,t){var e,i;return(i=(e=s.ra)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function gi(s,t){var e,i;return(i=(e=s.Pn)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function Ol(s,t){var e,i;return(i=(e=s.Qi)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function kl(s,t){var e,i;return(i=(e=s.na)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}class ps{constructor(t,e){this.bv=at({width:0,height:0}),this.hp=null,this.lp=null,this.ap=null,this.op=!1,this._p=new yt,this.up=new yt,this.cp=0,this.dp=!1,this.fp=null,this.vp=!1,this.pp=null,this.mp=null,this.xv=!1,this.Sv=()=>{this.xv||this.bp===null||this.Ui().Fh()},this.yv=()=>{this.xv||this.bp===null||this.Ui().Fh()},this.wp=t,this.bp=e,this.bp.I_().l(this.gp.bind(this),this,!0),this.Mp=document.createElement("td"),this.Mp.style.padding="0",this.Mp.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.xp=document.createElement("td"),this.xp.style.padding="0",this.Sp=document.createElement("td"),this.Sp.style.padding="0",this.Mp.appendChild(i),this.Ov=me(i,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const n=this.Ov.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Av=me(i,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const r=this.Av.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this.kp=document.createElement("tr"),this.kp.appendChild(this.xp),this.kp.appendChild(this.Mp),this.kp.appendChild(this.Sp),this.yp(),this.Fv=new us(this.Av.canvasElement,this,{Lf:()=>this.fp===null&&!this.wp.W().handleScroll.vertTouchDrag,Nf:()=>this.fp===null&&!this.wp.W().handleScroll.horzTouchDrag})}S(){this.hp!==null&&this.hp.S(),this.lp!==null&&this.lp.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose(),this.bp!==null&&this.bp.I_().p(this),this.Fv.S()}Xv(){return S(this.bp)}Cp(t){this.bp!==null&&this.bp.I_().p(this),this.bp=t,this.bp!==null&&this.bp.I_().l(ps.prototype.gp.bind(this),this,!0),this.yp()}kv(){return this.wp}Wv(){return this.kp}yp(){if(this.bp!==null&&(this.Tp(),this.Ui().Mt().length!==0)){if(this.hp!==null){const t=this.bp.S_();this.hp.Ji(S(t))}if(this.lp!==null){const t=this.bp.k_();this.lp.Ji(S(t))}}}Pp(){this.hp!==null&&this.hp.gt(),this.lp!==null&&this.lp.gt()}v_(){return this.bp!==null?this.bp.v_():0}p_(t){this.bp&&this.bp.p_(t)}Vf(t){if(!this.bp)return;this.Rp();const e=t.localX,i=t.localY;this.Dp(e,i,t)}Jf(t){this.Rp(),this.Op(),this.Dp(t.localX,t.localY,t)}Bf(t){var e;if(!this.bp)return;this.Rp();const i=t.localX,n=t.localY;this.Dp(i,n,t);const r=this.br(i,n);this.wp.Ap((e=r?.mv)!==null&&e!==void 0?e:null),this.Ui().Vc(r&&{Bc:r.Bc,vv:r.vv})}Yf(t){this.bp!==null&&(this.Rp(),this.Vp(t))}Cf(t){this.bp!==null&&this.Bp(this.up,t)}xf(t){this.Cf(t)}jf(t){this.Rp(),this.Ip(t),this.Dp(t.localX,t.localY,t)}qf(t){this.bp!==null&&(this.Rp(),this.dp=!1,this.zp(t))}Uf(t){this.bp!==null&&this.Vp(t)}ov(t){if(this.dp=!0,this.fp===null){const e={x:t.localX,y:t.localY};this.Ep(e,e,t)}}av(t){this.bp!==null&&(this.Rp(),this.bp.qt().Vc(null),this.Lp())}Np(){return this._p}Fp(){return this.up}nv(){this.cp=1,this.Ui().Un()}sv(t,e){if(!this.wp.W().handleScale.pinch)return;const i=5*(e-this.cp);this.cp=e,this.Ui().$c(t.et,i)}Zf(t){this.dp=!1,this.vp=this.fp!==null,this.Op();const e=this.Ui().Nc();this.fp!==null&&e.Tt()&&(this.pp={x:e.Kt(),y:e.Zt()},this.fp={x:t.localX,y:t.localY})}Ff(t){if(this.bp===null)return;const e=t.localX,i=t.localY;if(this.fp===null)this.Ip(t);else{this.vp=!1;const n=S(this.pp),r=n.x+(e-this.fp.x),o=n.y+(i-this.fp.y);this.Dp(r,o,t)}}$f(t){this.kv().W().trackingMode.exitMode===0&&(this.vp=!0),this.Wp(),this.zp(t)}br(t,e){const i=this.bp;return i===null?null:(function(n,r,o){const h=n.No(),l=(function(a,c,u){var p,g;let d,f;for(const M of a){const R=(g=(p=M.oa)===null||p===void 0?void 0:p.call(M,c,u))!==null&&g!==void 0?g:[];for(const k of R)m=k.zOrder,(!(w=d?.zOrder)||m==="top"&&w!=="top"||m==="normal"&&w==="bottom")&&(d=k,f=M)}var m,w;return d&&f?{pv:d,Bc:f}:null})(h,r,o);if(l?.pv.zOrder==="top")return mi(l);for(const a of h){if(l&&l.Bc===a&&l.pv.zOrder!=="bottom"&&!l.pv.isBackground)return mi(l);const c=Ml(a.Pn(n),r,o);if(c!==null)return{Bc:a,dv:c.dv,vv:c.vv};if(l&&l.Bc===a&&l.pv.zOrder!=="bottom"&&l.pv.isBackground)return mi(l)}return l?.pv?mi(l):null})(i,t,e)}jp(t,e){S(e==="left"?this.hp:this.lp).qv(at({width:t,height:this.bv.height}))}Hp(){return this.bv}qv(t){fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Mp.style.width=t.width+"px",this.Mp.style.height=t.height+"px")}$p(){const t=S(this.bp);t.x_(t.S_()),t.x_(t.k_());for(const e of t.Ta())if(t.dr(e)){const i=e.At();i!==null&&t.x_(i),e.On()}}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Kv(t){if(t===0||this.bp===null)return;if(t>1&&this.$p(),this.hp!==null&&this.hp.Kv(t),this.lp!==null&&this.lp.Kv(t),t!==1){this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n)})),this.bp&&(this.Up(i,Rl),this.qp(i),this.Yp(i),this.Up(i,gi),this.Up(i,Ol)))}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.Xp(e),this.Up(e,kl))}Kp(){return this.hp}Zp(){return this.lp}Jv(t,e){this.Up(t,e)}gp(){this.bp!==null&&this.bp.I_().p(this),this.bp=null}Vp(t){this.Bp(this._p,t)}Bp(t,e){const i=e.localX,n=e.localY;t.M()&&t.m(this.Ui().yt().Au(i),{x:i,y:n},e)}Gv({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.Ui(),o=r.q(),h=r.ad();o===h?ei(t,0,0,i,n,h):cn(t,0,0,i,n,o,h)}qp(t){const e=S(this.bp).z_().Wh().xt();e!==null&&e.K(t,!1)}Yp(t){const e=this.Ui().Lc();this.Gp(t,gi,as,e),this.Gp(t,gi,di,e)}Xp(t){this.Gp(t,gi,di,this.Ui().Nc())}Up(t,e){const i=S(this.bp).No();for(const n of i)this.Gp(t,e,as,n);for(const n of i)this.Gp(t,e,di,n)}Gp(t,e,i,n){const r=S(this.bp),o=r.qt().Ac(),h=o!==null&&o.Bc===n,l=o!==null&&h&&o.vv!==void 0?o.vv.gr:void 0;cs(e,(a=>i(a,t,h,l)),n,r)}Tp(){if(this.bp===null)return;const t=this.wp,e=this.bp.S_().W().visible,i=this.bp.k_().W().visible;e||this.hp===null||(this.xp.removeChild(this.hp.Wv()),this.hp.S(),this.hp=null),i||this.lp===null||(this.Sp.removeChild(this.lp.Wv()),this.lp.S(),this.lp=null);const n=t.qt().nd();e&&this.hp===null&&(this.hp=new nr(this,t.W(),n,"left"),this.xp.appendChild(this.hp.Wv())),i&&this.lp===null&&(this.lp=new nr(this,t.W(),n,"right"),this.Sp.appendChild(this.lp.Wv()))}Jp(t){return t._v&&this.dp||this.fp!==null}Qp(t){return Math.max(0,Math.min(t,this.bv.width-1))}tm(t){return Math.max(0,Math.min(t,this.bv.height-1))}Dp(t,e,i){this.Ui().Gc(this.Qp(t),this.tm(e),i,S(this.bp))}Lp(){this.Ui().Qc()}Wp(){this.vp&&(this.fp=null,this.Lp())}Ep(t,e,i){this.fp=t,this.vp=!1,this.Dp(e.x,e.y,i);const n=this.Ui().Nc();this.pp={x:n.Kt(),y:n.Zt()}}Ui(){return this.wp.qt()}zp(t){if(!this.op)return;const e=this.Ui(),i=this.Xv();if(e.D_(i,i.vn()),this.ap=null,this.op=!1,e.Xc(),this.mp!==null){const n=performance.now(),r=e.yt();this.mp.Dr(r.zu(),n),this.mp.qu(n)||e.Xn(this.mp)}}Rp(){this.fp=null}Op(){if(this.bp){if(this.Ui().Un(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)S(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.bp.vn().Fi()&&this.Ui().yt().Fi()}}Ip(t){if(this.bp===null)return;const e=this.Ui(),i=e.yt();if(i.Fi())return;const n=this.wp.W(),r=n.handleScroll,o=n.kineticScroll;if((!r.pressedMouseMove||t._v)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t._v))return;const h=this.bp.vn(),l=performance.now();if(this.ap!==null||this.Jp(t)||(this.ap={x:t.clientX,y:t.clientY,Sd:l,im:t.localX,nm:t.localY}),this.ap!==null&&!this.op&&(this.ap.x!==t.clientX||this.ap.y!==t.clientY)){if(t._v&&o.touch||!t._v&&o.mouse){const a=i.he();this.mp=new Ll(.2/a,7/a,.997,15/a),this.mp.Ld(i.zu(),this.ap.Sd)}else this.mp=null;h.Fi()||e.P_(this.bp,h,t.localY),e.qc(t.localX),this.op=!0}this.op&&(h.Fi()||e.R_(this.bp,h,t.localY),e.Yc(t.localX),this.mp!==null&&this.mp.Ld(i.zu(),l))}}class rr{constructor(t,e,i,n,r){this.bt=!0,this.bv=at({width:0,height:0}),this.Sv=()=>this.Kv(3),this.Cv=t==="left",this.Sc=i.nd,this.cn=e,this.sm=n,this.rm=r,this.Dv=document.createElement("div"),this.Dv.style.width="25px",this.Dv.style.height="100%",this.Dv.style.overflow="hidden",this.Ov=me(this.Dv,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv)}S(){this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose()}Wv(){return this.Dv}Hp(){return this.bv}qv(t){fe(this.bv,t)||(this.bv=t,this.Ov.resizeCanvasElement(t),this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`,this.bt=!0)}Kv(t){if(t<3&&!this.bt||this.bv.width===0||this.bv.height===0)return;this.bt=!1,this.Ov.applySuggestedBitmapSize();const e=de(this.Ov);e!==null&&e.useBitmapCoordinateSpace((i=>{this.Gv(i),this.Be(i)}))}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Be({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(!this.sm())return;t.fillStyle=this.cn.timeScale.borderColor;const r=Math.floor(this.Sc.W().C*i),o=Math.floor(this.Sc.W().C*n),h=this.Cv?e.width-r:0;t.fillRect(h,0,r,o)}Gv({context:t,bitmapSize:e}){ei(t,0,0,e.width,e.height,this.rm())}}function ms(s){return t=>{var e,i;return(i=(e=t.aa)===null||e===void 0?void 0:e.call(t,s))!==null&&i!==void 0?i:[]}}const Pl=ms("normal"),Al=ms("top"),Dl=ms("bottom");class Nl{constructor(t,e){this.hm=null,this.lm=null,this.k=null,this.am=!1,this.bv=at({width:0,height:0}),this.om=new yt,this.gv=new Ne(5),this.xv=!1,this.Sv=()=>{this.xv||this.wp.qt().Fh()},this.yv=()=>{this.xv||this.wp.qt().Fh()},this.wp=t,this.N_=e,this.cn=t.W().layout,this._m=document.createElement("tr"),this.um=document.createElement("td"),this.um.style.padding="0",this.dm=document.createElement("td"),this.dm.style.padding="0",this.Dv=document.createElement("td"),this.Dv.style.height="25px",this.Dv.style.padding="0",this.fm=document.createElement("div"),this.fm.style.width="100%",this.fm.style.height="100%",this.fm.style.position="relative",this.fm.style.overflow="hidden",this.Dv.appendChild(this.fm),this.Ov=me(this.fm,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const i=this.Ov.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Av=me(this.fm,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const n=this.Av.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this._m.appendChild(this.um),this._m.appendChild(this.Dv),this._m.appendChild(this.dm),this.vm(),this.wp.qt().f_().l(this.vm.bind(this),this),this.Fv=new us(this.Av.canvasElement,this,{Lf:()=>!0,Nf:()=>!1})}S(){this.Fv.S(),this.hm!==null&&this.hm.S(),this.lm!==null&&this.lm.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose()}Wv(){return this._m}pm(){return this.hm}bm(){return this.lm}Jf(t){if(this.am)return;this.am=!0;const e=this.wp.qt();!e.yt().Fi()&&this.wp.W().handleScale.axisPressedMouseMove.time&&e.Hc(t.localX)}Zf(t){this.Jf(t)}Qf(){const t=this.wp.qt();!t.yt().Fi()&&this.am&&(this.am=!1,this.wp.W().handleScale.axisPressedMouseMove.time&&t.Zc())}jf(t){const e=this.wp.qt();!e.yt().Fi()&&this.wp.W().handleScale.axisPressedMouseMove.time&&e.Kc(t.localX)}Ff(t){this.jf(t)}qf(){this.am=!1;const t=this.wp.qt();t.yt().Fi()&&!this.wp.W().handleScale.axisPressedMouseMove.time||t.Zc()}$f(){this.qf()}Cf(){this.wp.W().handleScale.axisDoubleClickReset.time&&this.wp.qt().Zn()}xf(){this.Cf()}Vf(){this.wp.qt().W().handleScale.axisPressedMouseMove.time&&this.ep(1)}av(){this.ep(0)}Hp(){return this.bv}wm(){return this.om}gm(t,e,i){fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`,this.om.m(t)),this.hm!==null&&this.hm.qv(at({width:e,height:t.height})),this.lm!==null&&this.lm.qv(at({width:i,height:t.height}))}Mm(){const t=this.xm();return Math.ceil(t.C+t.T+t.P+t.L+t.V+t.Sm)}gt(){this.wp.qt().yt().Ea()}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Kv(t){if(t===0)return;if(t!==1){this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n),this.Be(n),this.km(i,Dl)})),this.Qv(i),this.km(i,Pl)),this.hm!==null&&this.hm.Kv(t),this.lm!==null&&this.lm.Kv(t)}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.ym([...this.wp.qt().Mt(),this.wp.qt().Nc()],e),this.km(e,Al))}km(t,e){const i=this.wp.qt().Mt();for(const n of i)cs(e,(r=>as(r,t,!1,void 0)),n,void 0);for(const n of i)cs(e,(r=>di(r,t,!1,void 0)),n,void 0)}Gv({context:t,bitmapSize:e}){ei(t,0,0,e.width,e.height,this.wp.qt().ad())}Be({context:t,bitmapSize:e,verticalPixelRatio:i}){if(this.wp.W().timeScale.borderVisible){t.fillStyle=this.Cm();const n=Math.max(1,Math.floor(this.xm().C*i));t.fillRect(0,0,e.width,n)}}Qv(t){const e=this.wp.qt().yt(),i=e.Ea();if(!i||i.length===0)return;const n=this.N_.maxTickMarkWeight(i),r=this.xm(),o=e.W();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace((({context:h,horizontalPixelRatio:l,verticalPixelRatio:a})=>{h.strokeStyle=this.Cm(),h.fillStyle=this.Cm();const c=Math.max(1,Math.floor(l)),u=Math.floor(.5*l);h.beginPath();const p=Math.round(r.T*a);for(let g=i.length;g--;){const d=Math.round(i[g].coord*l);h.rect(d-u,0,c,p)}h.fill()})),t.useMediaCoordinateSpace((({context:h})=>{const l=r.C+r.T+r.L+r.P/2;h.textAlign="center",h.textBaseline="middle",h.fillStyle=this.$(),h.font=this.$v();for(const a of i)if(a.weight<n){const c=a.needAlignCoordinate?this.Tm(h,a.coord,a.label):a.coord;h.fillText(a.label,c,l)}h.font=this.Pm();for(const a of i)if(a.weight>=n){const c=a.needAlignCoordinate?this.Tm(h,a.coord,a.label):a.coord;h.fillText(a.label,c,l)}}))}Tm(t,e,i){const n=this.gv.Si(t,i),r=n/2,o=Math.floor(e-r)+.5;return o<0?e+=Math.abs(0-o):o+n>this.bv.width&&(e-=Math.abs(this.bv.width-(o+n))),e}ym(t,e){const i=this.xm();for(const n of t)for(const r of n.tn())r.xt().K(e,i)}Cm(){return this.wp.W().timeScale.borderColor}$(){return this.cn.textColor}j(){return this.cn.fontSize}$v(){return _e(this.j(),this.cn.fontFamily)}Pm(){return _e(this.j(),this.cn.fontFamily,"bold")}xm(){this.k===null&&(this.k={C:1,N:NaN,L:NaN,V:NaN,Hi:NaN,T:5,P:NaN,R:"",ji:new Ne,Sm:0});const t=this.k,e=this.$v();if(t.R!==e){const i=this.j();t.P=i,t.R=e,t.L=3*i/12,t.V=3*i/12,t.Hi=9*i/12,t.N=0,t.Sm=4*i/12,t.ji.ir()}return this.k}ep(t){this.Dv.style.cursor=t===1?"ew-resize":"default"}vm(){const t=this.wp.qt(),e=t.W();e.leftPriceScale.visible||this.hm===null||(this.um.removeChild(this.hm.Wv()),this.hm.S(),this.hm=null),e.rightPriceScale.visible||this.lm===null||(this.dm.removeChild(this.lm.Wv()),this.lm.S(),this.lm=null);const i={nd:this.wp.qt().nd()},n=()=>e.leftPriceScale.borderVisible&&t.yt().W().borderVisible,r=()=>t.ad();e.leftPriceScale.visible&&this.hm===null&&(this.hm=new rr("left",e,i,n,r),this.um.appendChild(this.hm.Wv())),e.rightPriceScale.visible&&this.lm===null&&(this.lm=new rr("right",e,i,n,r),this.dm.appendChild(this.lm.Wv()))}}const Bl=!!Ce&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((s=>s.brand.includes("Chromium")))&&!!Ce&&(!((gs=navigator?.userAgentData)===null||gs===void 0)&&gs.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);var gs;class Fl{constructor(t,e,i){var n;this.Rm=[],this.Dm=0,this.Qa=0,this.e_=0,this.Om=0,this.Am=0,this.Vm=null,this.Bm=!1,this._p=new yt,this.up=new yt,this.gc=new yt,this.Im=null,this.zm=null,this.Em=t,this.cn=e,this.N_=i,this._m=document.createElement("div"),this._m.classList.add("tv-lightweight-charts"),this._m.style.overflow="hidden",this._m.style.direction="ltr",this._m.style.width="100%",this._m.style.height="100%",(n=this._m).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.Lm=document.createElement("table"),this.Lm.setAttribute("cellspacing","0"),this._m.appendChild(this.Lm),this.Nm=this.Fm.bind(this),bs(this.cn)&&this.Wm(!0),this.Ui=new Sl(this.xc.bind(this),this.cn,i),this.qt().Fc().l(this.jm.bind(this),this),this.Hm=new Nl(this,this.N_),this.Lm.appendChild(this.Hm.Wv());const r=e.autoSize&&this.$m();let o=this.cn.width,h=this.cn.height;if(r||o===0||h===0){const l=t.getBoundingClientRect();o=o||l.width,h=h||l.height}this.Um(o,h),this.qm(),t.appendChild(this._m),this.Ym(),this.Ui.yt().Zu().l(this.Ui.$l.bind(this.Ui),this),this.Ui.f_().l(this.Ui.$l.bind(this.Ui),this)}qt(){return this.Ui}W(){return this.cn}Xm(){return this.Rm}Km(){return this.Hm}S(){this.Wm(!1),this.Dm!==0&&window.cancelAnimationFrame(this.Dm),this.Ui.Fc().p(this),this.Ui.yt().Zu().p(this),this.Ui.f_().p(this),this.Ui.S();for(const t of this.Rm)this.Lm.removeChild(t.Wv()),t.Np().p(this),t.Fp().p(this),t.S();this.Rm=[],S(this.Hm).S(),this._m.parentElement!==null&&this._m.parentElement.removeChild(this._m),this.gc.S(),this._p.S(),this.up.S(),this.Zm()}Um(t,e,i=!1){if(this.Qa===e&&this.e_===t)return;const n=(function(h){const l=Math.floor(h.width),a=Math.floor(h.height);return at({width:l-l%2,height:a-a%2})})(at({width:t,height:e}));this.Qa=n.height,this.e_=n.width;const r=this.Qa+"px",o=this.e_+"px";S(this._m).style.height=r,S(this._m).style.width=o,this.Lm.style.height=r,this.Lm.style.width=o,i?this.Gm(Ct.es(),performance.now()):this.Ui.$l()}Kv(t){t===void 0&&(t=Ct.es());for(let e=0;e<this.Rm.length;e++)this.Rm[e].Kv(t.Hn(e).Fn);this.cn.timeScale.visible&&this.Hm.Kv(t.jn())}Nh(t){const e=bs(this.cn);this.Ui.Nh(t);const i=bs(this.cn);i!==e&&this.Wm(i),this.Ym(),this.Jm(t)}Np(){return this._p}Fp(){return this.up}Fc(){return this.gc}Qm(){this.Vm!==null&&(this.Gm(this.Vm,performance.now()),this.Vm=null);const t=this.tb(null),e=document.createElement("canvas");e.width=t.width,e.height=t.height;const i=S(e.getContext("2d"));return this.tb(i),e}ib(t){return t==="left"&&!this.nb()||t==="right"&&!this.sb()||this.Rm.length===0?0:S(t==="left"?this.Rm[0].Kp():this.Rm[0].Zp()).Yv()}eb(){return this.cn.autoSize&&this.Im!==null}rb(){return this._m}Ap(t){this.zm=t,this.zm?this.rb().style.setProperty("cursor",t):this.rb().style.removeProperty("cursor")}hb(){return this.zm}lb(){return kt(this.Rm[0]).Hp()}Jm(t){(t.autoSize!==void 0||!this.Im||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.Im&&this.$m(),t.autoSize===!1&&this.Im!==null&&this.Zm(),t.autoSize||t.width===void 0&&t.height===void 0||this.Um(t.width||this.e_,t.height||this.Qa))}tb(t){let e=0,i=0;const n=this.Rm[0],r=(h,l)=>{let a=0;for(let c=0;c<this.Rm.length;c++){const u=this.Rm[c],p=S(h==="left"?u.Kp():u.Zp()),g=p.np();t!==null&&p.sp(t,l,a),a+=g.height}};this.nb()&&(r("left",0),e+=S(n.Kp()).np().width);for(let h=0;h<this.Rm.length;h++){const l=this.Rm[h],a=l.np();t!==null&&l.sp(t,e,i),i+=a.height}e+=n.np().width,this.sb()&&(r("right",e),e+=S(n.Zp()).np().width);const o=(h,l,a)=>{S(h==="left"?this.Hm.pm():this.Hm.bm()).sp(S(t),l,a)};if(this.cn.timeScale.visible){const h=this.Hm.np();if(t!==null){let l=0;this.nb()&&(o("left",l,i),l=S(n.Kp()).np().width),this.Hm.sp(t,l,i),l+=h.width,this.sb()&&o("right",l,i)}i+=h.height}return at({width:e,height:i})}ab(){let t=0,e=0,i=0;for(const d of this.Rm)this.nb()&&(e=Math.max(e,S(d.Kp()).Hv(),this.cn.leftPriceScale.minimumWidth)),this.sb()&&(i=Math.max(i,S(d.Zp()).Hv(),this.cn.rightPriceScale.minimumWidth)),t+=d.v_();e=os(e),i=os(i);const n=this.e_,r=this.Qa,o=Math.max(n-e-i,0),h=this.cn.timeScale.visible;let l=h?Math.max(this.Hm.Mm(),this.cn.timeScale.minimumHeight):0;var a;l=(a=l)+a%2;const c=0+l,u=r<c?0:r-c,p=u/t;let g=0;for(let d=0;d<this.Rm.length;++d){const f=this.Rm[d];f.Cp(this.Ui.Ec()[d]);let m=0,w=0;w=d===this.Rm.length-1?u-g:Math.round(f.v_()*p),m=Math.max(w,2),g+=m,f.qv(at({width:o,height:m})),this.nb()&&f.jp(e,"left"),this.sb()&&f.jp(i,"right"),f.Xv()&&this.Ui.Wc(f.Xv(),m)}this.Hm.gm(at({width:h?o:0,height:l}),h?e:0,h?i:0),this.Ui.m_(o),this.Om!==e&&(this.Om=e),this.Am!==i&&(this.Am=i)}Wm(t){t?this._m.addEventListener("wheel",this.Nm,{passive:!1}):this._m.removeEventListener("wheel",this.Nm)}ob(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Bl?1/window.devicePixelRatio:1}Fm(t){if(!(t.deltaX!==0&&this.cn.handleScroll.mouseWheel||t.deltaY!==0&&this.cn.handleScale.mouseWheel))return;const e=this.ob(t),i=e*t.deltaX/100,n=-e*t.deltaY/100;if(t.cancelable&&t.preventDefault(),n!==0&&this.cn.handleScale.mouseWheel){const r=Math.sign(n)*Math.min(1,Math.abs(n)),o=t.clientX-this._m.getBoundingClientRect().left;this.qt().$c(o,r)}i!==0&&this.cn.handleScroll.mouseWheel&&this.qt().Uc(-80*i)}Gm(t,e){var i;const n=t.jn();n===3&&this._b(),n!==3&&n!==2||(this.ub(t),this.cb(t,e),this.Hm.gt(),this.Rm.forEach((r=>{r.Pp()})),((i=this.Vm)===null||i===void 0?void 0:i.jn())===3&&(this.Vm.ts(t),this._b(),this.ub(this.Vm),this.cb(this.Vm,e),t=this.Vm,this.Vm=null)),this.Kv(t)}cb(t,e){for(const i of t.Qn())this.ns(i,e)}ub(t){const e=this.Ui.Ec();for(let i=0;i<e.length;i++)t.Hn(i).Wn&&e[i].V_()}ns(t,e){const i=this.Ui.yt();switch(t.qn){case 0:i.Ju();break;case 1:i.Qu(t.Vt);break;case 2:i.Gn(t.Vt);break;case 3:i.Jn(t.Vt);break;case 4:i.Nu();break;case 5:t.Vt.qu(e)||i.Jn(t.Vt.Yu(e))}}xc(t){this.Vm!==null?this.Vm.ts(t):this.Vm=t,this.Bm||(this.Bm=!0,this.Dm=window.requestAnimationFrame((e=>{if(this.Bm=!1,this.Dm=0,this.Vm!==null){const i=this.Vm;this.Vm=null,this.Gm(i,e);for(const n of i.Qn())if(n.qn===5&&!n.Vt.qu(e)){this.qt().Xn(n.Vt);break}}})))}_b(){this.qm()}qm(){const t=this.Ui.Ec(),e=t.length,i=this.Rm.length;for(let n=e;n<i;n++){const r=kt(this.Rm.pop());this.Lm.removeChild(r.Wv()),r.Np().p(this),r.Fp().p(this),r.S()}for(let n=i;n<e;n++){const r=new ps(this,t[n]);r.Np().l(this.fb.bind(this),this),r.Fp().l(this.vb.bind(this),this),this.Rm.push(r),this.Lm.insertBefore(r.Wv(),this.Hm.Wv())}for(let n=0;n<e;n++){const r=t[n],o=this.Rm[n];o.Xv()!==r?o.Cp(r):o.yp()}this.Ym(),this.ab()}pb(t,e,i){var n;const r=new Map;t!==null&&this.Ui.Mt().forEach((c=>{const u=c.In().nl(t);u!==null&&r.set(c,u)}));let o;if(t!==null){const c=(n=this.Ui.yt().qi(t))===null||n===void 0?void 0:n.originalTime;c!==void 0&&(o=c)}const h=this.qt().Ac(),l=h!==null&&h.Bc instanceof Gi?h.Bc:void 0,a=h!==null&&h.vv!==void 0?h.vv.wr:void 0;return{mb:o,se:t??void 0,bb:e??void 0,wb:l,gb:r,Mb:a,xb:i??void 0}}fb(t,e,i){this._p.m((()=>this.pb(t,e,i)))}vb(t,e,i){this.up.m((()=>this.pb(t,e,i)))}jm(t,e,i){this.gc.m((()=>this.pb(t,e,i)))}Ym(){const t=this.cn.timeScale.visible?"":"none";this.Hm.Wv().style.display=t}nb(){return this.Rm[0].Xv().S_().W().visible}sb(){return this.Rm[0].Xv().k_().W().visible}$m(){return"ResizeObserver"in window&&(this.Im=new ResizeObserver((t=>{const e=t.find((i=>i.target===this.Em));e&&this.Um(e.contentRect.width,e.contentRect.height)})),this.Im.observe(this.Em,{box:"border-box"}),!0)}Zm(){this.Im!==null&&this.Im.disconnect(),this.Im=null}}function bs(s){return!!(s.handleScroll.mouseWheel||s.handleScale.mouseWheel)}function or(s,t){var e={};for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&t.indexOf(i)<0&&(e[i]=s[i]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function"){var n=0;for(i=Object.getOwnPropertySymbols(s);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(s,i[n])&&(e[i[n]]=s[i[n]])}return e}function hr(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.color!==void 0&&(r.O=e.color),r}function zl(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.lineColor!==void 0&&(r._t=e.lineColor),e.topColor!==void 0&&(r.Ts=e.topColor),e.bottomColor!==void 0&&(r.Ps=e.bottomColor),r}function Ul(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.topLineColor!==void 0&&(r.Pe=e.topLineColor),e.bottomLineColor!==void 0&&(r.Re=e.bottomLineColor),e.topFillColor1!==void 0&&(r.Se=e.topFillColor1),e.topFillColor2!==void 0&&(r.ke=e.topFillColor2),e.bottomFillColor1!==void 0&&(r.ye=e.bottomFillColor1),e.bottomFillColor2!==void 0&&(r.Ce=e.bottomFillColor2),r}function Vl(s,t,e,i){const n={se:t,ut:s,Vt:[e.open,e.high,e.low,e.close],mb:i};return e.color!==void 0&&(n.O=e.color),n}function Wl(s,t,e,i){const n={se:t,ut:s,Vt:[e.open,e.high,e.low,e.close],mb:i};return e.color!==void 0&&(n.O=e.color),e.borderColor!==void 0&&(n.Bt=e.borderColor),e.wickColor!==void 0&&(n.$h=e.wickColor),n}function Il(s,t,e,i,n){const r=kt(n)(e),o=Math.max(...r),h=Math.min(...r),l=r[r.length-1],a=[l,o,h,l],c=e,{time:u,color:p}=c;return{se:t,ut:s,Vt:a,mb:i,He:or(c,["time","color"]),O:p}}function bi(s){return s.Vt!==void 0}function lr(s,t){return t.customValues!==void 0&&(s.Sb=t.customValues),s}function ge(s){return(t,e,i,n,r,o)=>(function(h,l){return l?l(h):(a=h).open===void 0&&a.value===void 0;var a})(i,o)?lr({ut:t,se:e,mb:n},i):lr(s(t,e,i,n,r),i)}function ar(s){return{Candlestick:ge(Wl),Bar:ge(Vl),Area:ge(zl),Baseline:ge(Ul),Histogram:ge(hr),Line:ge(hr),Custom:ge(Il)}[s]}function cr(s){return{se:0,kb:new Map,ia:s}}function ur(s,t){if(s!==void 0&&s.length!==0)return{yb:t.key(s[0].ut),Cb:t.key(s[s.length-1].ut)}}function fr(s){let t;return s.forEach((e=>{t===void 0&&(t=e.mb)})),kt(t)}class ql{constructor(t){this.Tb=new Map,this.Pb=new Map,this.Rb=new Map,this.Db=[],this.N_=t}S(){this.Tb.clear(),this.Pb.clear(),this.Rb.clear(),this.Db=[]}Ob(t,e){let i=this.Tb.size!==0,n=!1;const r=this.Pb.get(t);if(r!==void 0)if(this.Pb.size===1)i=!1,n=!0,this.Tb.clear();else for(const l of this.Db)l.pointData.kb.delete(t)&&(n=!0);let o=[];if(e.length!==0){const l=e.map((g=>g.time)),a=this.N_.createConverterToInternalObj(e),c=ar(t.Xh()),u=t.ga(),p=t.Ma();o=e.map(((g,d)=>{const f=a(g.time),m=this.N_.key(f);let w=this.Tb.get(m);w===void 0&&(w=cr(f),this.Tb.set(m,w),n=!0);const M=c(f,w.se,g,l[d],u,p);return w.kb.set(t,M),M}))}i&&this.Ab(),this.Vb(t,o);let h=-1;if(n){const l=[];this.Tb.forEach((a=>{l.push({timeWeight:0,time:a.ia,pointData:a,originalTime:fr(a.kb)})})),l.sort(((a,c)=>this.N_.key(a.time)-this.N_.key(c.time))),h=this.Bb(l)}return this.Ib(t,h,(function(l,a,c){const u=ur(l,c),p=ur(a,c);if(u!==void 0&&p!==void 0)return{Xl:u.Cb>=p.Cb&&u.yb>=p.yb}})(this.Pb.get(t),r,this.N_))}rd(t){return this.Ob(t,[])}zb(t,e){const i=e;(function(f){f.mb===void 0&&(f.mb=f.time)})(i),this.N_.preprocessData(e);const n=this.N_.createConverterToInternalObj([e])(e.time),r=this.Rb.get(t);if(r!==void 0&&this.N_.key(n)<this.N_.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${n}`);let o=this.Tb.get(this.N_.key(n));const h=o===void 0;o===void 0&&(o=cr(n),this.Tb.set(this.N_.key(n),o));const l=ar(t.Xh()),a=t.ga(),c=t.Ma(),u=l(n,o.se,e,i.mb,a,c);o.kb.set(t,u),this.Eb(t,u);const p={Xl:bi(u)};if(!h)return this.Ib(t,-1,p);const g={timeWeight:0,time:o.ia,pointData:o,originalTime:fr(o.kb)},d=De(this.Db,this.N_.key(g.time),((f,m)=>this.N_.key(f.time)<m));this.Db.splice(d,0,g);for(let f=d;f<this.Db.length;++f)vs(this.Db[f].pointData,f);return this.N_.fillWeightsForPoints(this.Db,d),this.Ib(t,d,p)}Eb(t,e){let i=this.Pb.get(t);i===void 0&&(i=[],this.Pb.set(t,i));const n=i.length!==0?i[i.length-1]:null;n===null||this.N_.key(e.ut)>this.N_.key(n.ut)?bi(e)&&i.push(e):bi(e)?i[i.length-1]=e:i.splice(-1,1),this.Rb.set(t,e.ut)}Vb(t,e){e.length!==0?(this.Pb.set(t,e.filter(bi)),this.Rb.set(t,e[e.length-1].ut)):(this.Pb.delete(t),this.Rb.delete(t))}Ab(){for(const t of this.Db)t.pointData.kb.size===0&&this.Tb.delete(this.N_.key(t.time))}Bb(t){let e=-1;for(let i=0;i<this.Db.length&&i<t.length;++i){const n=this.Db[i],r=t[i];if(this.N_.key(n.time)!==this.N_.key(r.time)){e=i;break}r.timeWeight=n.timeWeight,vs(r.pointData,i)}if(e===-1&&this.Db.length!==t.length&&(e=Math.min(this.Db.length,t.length)),e===-1)return-1;for(let i=e;i<t.length;++i)vs(t[i].pointData,i);return this.N_.fillWeightsForPoints(t,e),this.Db=t,e}Lb(){if(this.Pb.size===0)return null;let t=0;return this.Pb.forEach((e=>{e.length!==0&&(t=Math.max(t,e[e.length-1].se))})),t}Ib(t,e,i){const n={Nb:new Map,yt:{Ou:this.Lb()}};if(e!==-1)this.Pb.forEach(((r,o)=>{n.Nb.set(o,{He:r,Fb:o===t?i:void 0})})),this.Pb.has(t)||n.Nb.set(t,{He:[],Fb:i}),n.yt.Wb=this.Db,n.yt.jb=e;else{const r=this.Pb.get(t);n.Nb.set(t,{He:r||[],Fb:i})}return n}}function vs(s,t){s.se=t,s.kb.forEach((e=>{e.se=t}))}function ys(s){const t={value:s.Vt[3],time:s.mb};return s.Sb!==void 0&&(t.customValues=s.Sb),t}function dr(s){const t=ys(s);return s.O!==void 0&&(t.color=s.O),t}function Hl(s){const t=ys(s);return s._t!==void 0&&(t.lineColor=s._t),s.Ts!==void 0&&(t.topColor=s.Ts),s.Ps!==void 0&&(t.bottomColor=s.Ps),t}function $l(s){const t=ys(s);return s.Pe!==void 0&&(t.topLineColor=s.Pe),s.Re!==void 0&&(t.bottomLineColor=s.Re),s.Se!==void 0&&(t.topFillColor1=s.Se),s.ke!==void 0&&(t.topFillColor2=s.ke),s.ye!==void 0&&(t.bottomFillColor1=s.ye),s.Ce!==void 0&&(t.bottomFillColor2=s.Ce),t}function pr(s){const t={open:s.Vt[0],high:s.Vt[1],low:s.Vt[2],close:s.Vt[3],time:s.mb};return s.Sb!==void 0&&(t.customValues=s.Sb),t}function jl(s){const t=pr(s);return s.O!==void 0&&(t.color=s.O),t}function Jl(s){const t=pr(s),{O:e,Bt:i,$h:n}=s;return e!==void 0&&(t.color=e),i!==void 0&&(t.borderColor=i),n!==void 0&&(t.wickColor=n),t}function ws(s){return{Area:Hl,Line:dr,Baseline:$l,Histogram:dr,Bar:jl,Candlestick:Jl,Custom:Kl}[s]}function Kl(s){const t=s.mb;return Object.assign(Object.assign({},s.He),{time:t})}const Xl={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},Yl={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Gl={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Fi},Ss={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},Zl={rightOffset:0,barSpacing:6,minBarSpacing:.5,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0},Ql={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:Fi,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function mr(){return{width:0,height:0,autoSize:!1,layout:Gl,crosshair:Xl,grid:Yl,overlayPriceScales:Object.assign({},Ss),leftPriceScale:Object.assign(Object.assign({},Ss),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Ss),{visible:!0}),timeScale:Zl,watermark:Ql,localization:{locale:Ce?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 ta{constructor(t,e){this.Hb=t,this.$b=e}applyOptions(t){this.Hb.qt().Ic(this.$b,t)}options(){return this.Li().W()}width(){return si(this.$b)?this.Hb.ib(this.$b):0}Li(){return S(this.Hb.qt().zc(this.$b)).At}}function gr(s,t,e){const i=or(s,["time","originalTime"]),n=Object.assign({time:t},i);return e!==void 0&&(n.originalTime=e),n}const ea={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class ia{constructor(t){this.Bh=t}applyOptions(t){this.Bh.Nh(t)}options(){return this.Bh.W()}Ub(){return this.Bh}}class sa{constructor(t,e,i,n,r){this.qb=new yt,this.Es=t,this.Yb=e,this.Xb=i,this.N_=r,this.Kb=n}S(){this.qb.S()}priceFormatter(){return this.Es.ca()}priceToCoordinate(t){const e=this.Es.Pt();return e===null?null:this.Es.At().Ot(t,e.Vt)}coordinateToPrice(t){const e=this.Es.Pt();return e===null?null:this.Es.At().pn(t,e.Vt)}barsInLogicalRange(t){if(t===null)return null;const e=new Ee(new We(t.from,t.to)).iu(),i=this.Es.In();if(i.Fi())return null;const n=i.nl(e.Os(),1),r=i.nl(e.di(),-1),o=S(i.Qh()),h=S(i.Bn());if(n!==null&&r!==null&&n.se>r.se)return{barsBefore:t.from-o,barsAfter:h-t.to};const l={barsBefore:n===null||n.se===o?t.from-o:n.se-o,barsAfter:r===null||r.se===h?h-t.to:h-r.se};return n!==null&&r!==null&&(l.from=n.mb,l.to=r.mb),l}setData(t){this.N_,this.Es.Xh(),this.Yb.Zb(this.Es,t),this.Gb("full")}update(t){this.Es.Xh(),this.Yb.Jb(this.Es,t),this.Gb("update")}dataByIndex(t,e){const i=this.Es.In().nl(t,e);return i===null?null:ws(this.seriesType())(i)}data(){const t=ws(this.seriesType());return this.Es.In().ie().map((e=>t(e)))}subscribeDataChanged(t){this.qb.l(t)}unsubscribeDataChanged(t){this.qb.v(t)}setMarkers(t){this.N_;const e=t.map((i=>gr(i,this.N_.convertHorzItemToInternal(i.time),i.time)));this.Es.Zl(e)}markers(){return this.Es.Gl().map((t=>gr(t,t.originalTime,void 0)))}applyOptions(t){this.Es.Nh(t)}options(){return re(this.Es.W())}priceScale(){return this.Xb.priceScale(this.Es.At().xa())}createPriceLine(t){const e=Ht(re(ea),t),i=this.Es.Jl(e);return new ia(i)}removePriceLine(t){this.Es.Ql(t.Ub())}seriesType(){return this.Es.Xh()}attachPrimitive(t){this.Es.ba(t),t.attached&&t.attached({chart:this.Kb,series:this,requestUpdate:()=>this.Es.qt().$l()})}detachPrimitive(t){this.Es.wa(t),t.detached&&t.detached()}Gb(t){this.qb.M()&&this.qb.m(t)}}class na{constructor(t,e,i){this.Qb=new yt,this.uu=new yt,this.om=new yt,this.Ui=t,this.wl=t.yt(),this.Hm=e,this.wl.Xu().l(this.tw.bind(this)),this.wl.Ku().l(this.iw.bind(this)),this.Hm.wm().l(this.nw.bind(this)),this.N_=i}S(){this.wl.Xu().p(this),this.wl.Ku().p(this),this.Hm.wm().p(this),this.Qb.S(),this.uu.S(),this.om.S()}scrollPosition(){return this.wl.zu()}scrollToPosition(t,e){e?this.wl.Uu(t,1e3):this.Ui.Jn(t)}scrollToRealTime(){this.wl.$u()}getVisibleRange(){const t=this.wl.yu();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const e={from:this.N_.convertHorzItemToInternal(t.from),to:this.N_.convertHorzItemToInternal(t.to)},i=this.wl.Pu(e);this.Ui.hd(i)}getVisibleLogicalRange(){const t=this.wl.ku();return t===null?null:{from:t.Os(),to:t.di()}}setVisibleLogicalRange(t){le(t.from<=t.to,"The from index cannot be after the to index."),this.Ui.hd(t)}resetTimeScale(){this.Ui.Zn()}fitContent(){this.Ui.Ju()}logicalToCoordinate(t){const e=this.Ui.yt();return e.Fi()?null:e.Et(t)}coordinateToLogical(t){return this.wl.Fi()?null:this.wl.Au(t)}timeToCoordinate(t){const e=this.N_.convertHorzItemToInternal(t),i=this.wl.ya(e,!1);return i===null?null:this.wl.Et(i)}coordinateToTime(t){const e=this.Ui.yt(),i=e.Au(t),n=e.qi(i);return n===null?null:n.originalTime}width(){return this.Hm.Hp().width}height(){return this.Hm.Hp().height}subscribeVisibleTimeRangeChange(t){this.Qb.l(t)}unsubscribeVisibleTimeRangeChange(t){this.Qb.v(t)}subscribeVisibleLogicalRangeChange(t){this.uu.l(t)}unsubscribeVisibleLogicalRangeChange(t){this.uu.v(t)}subscribeSizeChange(t){this.om.l(t)}unsubscribeSizeChange(t){this.om.v(t)}applyOptions(t){this.wl.Nh(t)}options(){return Object.assign(Object.assign({},re(this.wl.W())),{barSpacing:this.wl.he()})}tw(){this.Qb.M()&&this.Qb.m(this.getVisibleRange())}iw(){this.uu.M()&&this.uu.m(this.getVisibleLogicalRange())}nw(t){this.om.m(t.width,t.height)}}function ra(s){if(s===void 0||s.type==="custom")return;const t=s;t.minMove!==void 0&&t.precision===void 0&&(t.precision=(function(e){if(e>=1)return 0;let i=0;for(;i<8;i++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return i;e*=10}return i})(t.minMove))}function br(s){return(function(t){if(ti(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:i,axisDoubleClickReset:n}=t.handleScale;ti(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),ti(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const e=t.handleScroll;ti(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})})(s),s}class oa{constructor(t,e,i){this.sw=new Map,this.ew=new Map,this.rw=new yt,this.hw=new yt,this.lw=new yt,this.aw=new ql(e);const n=i===void 0?re(mr()):Ht(re(mr()),br(i));this.N_=e,this.Hb=new Fl(t,n,e),this.Hb.Np().l((o=>{this.rw.M()&&this.rw.m(this.ow(o()))}),this),this.Hb.Fp().l((o=>{this.hw.M()&&this.hw.m(this.ow(o()))}),this),this.Hb.Fc().l((o=>{this.lw.M()&&this.lw.m(this.ow(o()))}),this);const r=this.Hb.qt();this._w=new na(r,this.Hb.Km(),this.N_)}remove(){this.Hb.Np().p(this),this.Hb.Fp().p(this),this.Hb.Fc().p(this),this._w.S(),this.Hb.S(),this.sw.clear(),this.ew.clear(),this.rw.S(),this.hw.S(),this.lw.S(),this.aw.S()}resize(t,e,i){this.autoSizeActive()||this.Hb.Um(t,e,i)}addCustomSeries(t,e){const i=Se(t),n=Object.assign(Object.assign({},tn),i.defaultOptions());return this.uw("Custom",n,e,i)}addAreaSeries(t){return this.uw("Area",jo,t)}addBaselineSeries(t){return this.uw("Baseline",Jo,t)}addBarSeries(t){return this.uw("Bar",Ho,t)}addCandlestickSeries(t={}){return(function(e){e.borderColor!==void 0&&(e.borderUpColor=e.borderColor,e.borderDownColor=e.borderColor),e.wickColor!==void 0&&(e.wickUpColor=e.wickColor,e.wickDownColor=e.wickColor)})(t),this.uw("Candlestick",qo,t)}addHistogramSeries(t){return this.uw("Histogram",Ko,t)}addLineSeries(t){return this.uw("Line",$o,t)}removeSeries(t){const e=kt(this.sw.get(t)),i=this.aw.rd(e);this.Hb.qt().rd(e),this.cw(i),this.sw.delete(t),this.ew.delete(e)}Zb(t,e){this.cw(this.aw.Ob(t,e))}Jb(t,e){this.cw(this.aw.zb(t,e))}subscribeClick(t){this.rw.l(t)}unsubscribeClick(t){this.rw.v(t)}subscribeCrosshairMove(t){this.lw.l(t)}unsubscribeCrosshairMove(t){this.lw.v(t)}subscribeDblClick(t){this.hw.l(t)}unsubscribeDblClick(t){this.hw.v(t)}priceScale(t){return new ta(this.Hb,t)}timeScale(){return this._w}applyOptions(t){this.Hb.Nh(br(t))}options(){return this.Hb.W()}takeScreenshot(){return this.Hb.Qm()}autoSizeActive(){return this.Hb.eb()}chartElement(){return this.Hb.rb()}paneSize(){const t=this.Hb.lb();return{height:t.height,width:t.width}}setCrosshairPosition(t,e,i){const n=this.sw.get(i);if(n===void 0)return;const r=this.Hb.qt().cr(n);r!==null&&this.Hb.qt().Jc(t,e,r)}clearCrosshairPosition(){this.Hb.qt().Qc(!0)}uw(t,e,i={},n){ra(i.priceFormat);const r=Ht(re(en),re(e),i),o=this.Hb.qt().sd(t,r,n),h=new sa(o,this,this,this,this.N_);return this.sw.set(h,o),this.ew.set(o,h),h}cw(t){const e=this.Hb.qt();e.td(t.yt.Ou,t.yt.Wb,t.yt.jb),t.Nb.forEach(((i,n)=>n.it(i.He,i.Fb))),e.Bu()}dw(t){return kt(this.ew.get(t))}ow(t){const e=new Map;t.gb.forEach(((n,r)=>{const o=r.Xh(),h=ws(o)(n);if(o!=="Custom")le((function(l){return l.open!==void 0||l.value!==void 0})(h));else{const l=r.Ma();le(!l||l(h)===!1)}e.set(this.dw(r),h)}));const i=t.wb===void 0?void 0:this.dw(t.wb);return{time:t.mb,logical:t.se,point:t.bb,hoveredSeries:i,hoveredObjectId:t.Mb,seriesData:e,sourceEvent:t.xb}}}function ha(s,t,e){let i;if(Pe(s)){const r=document.getElementById(s);le(r!==null,`Cannot find element in DOM with id=${s}`),i=r}else i=s;const n=new oa(i,t,e);return t.setOptions(n.options()),n}function la(s,t){return ha(s,new er,er.Cd(t))}Object.assign(Object.assign({},en),tn);function vr(s,t){return function(){return s.apply(t,arguments)}}const{toString:aa}=Object.prototype,{getPrototypeOf:_s}=Object,{iterator:vi,toStringTag:yr}=Symbol,yi=(s=>t=>{const e=aa.call(t);return s[e]||(s[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),$t=s=>(s=s.toLowerCase(),t=>yi(t)===s),wi=s=>t=>typeof t===s,{isArray:xe}=Array,Me=wi("undefined");function Ie(s){return s!==null&&!Me(s)&&s.constructor!==null&&!Me(s.constructor)&&At(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const wr=$t("ArrayBuffer");function ca(s){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(s):t=s&&s.buffer&&wr(s.buffer),t}const ua=wi("string"),At=wi("function"),Sr=wi("number"),qe=s=>s!==null&&typeof s=="object",fa=s=>s===!0||s===!1,Si=s=>{if(yi(s)!=="object")return!1;const t=_s(s);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(yr in s)&&!(vi in s)},da=s=>{if(!qe(s)||Ie(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},pa=$t("Date"),ma=$t("File"),ga=$t("Blob"),ba=$t("FileList"),va=s=>qe(s)&&At(s.pipe),ya=s=>{let t;return s&&(typeof FormData=="function"&&s instanceof FormData||At(s.append)&&((t=yi(s))==="formdata"||t==="object"&&At(s.toString)&&s.toString()==="[object FormData]"))},wa=$t("URLSearchParams"),[Sa,_a,Ta,Ea]=["ReadableStream","Request","Response","Headers"].map($t),Ca=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function He(s,t,{allOwnKeys:e=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),xe(s))for(i=0,n=s.length;i<n;i++)t.call(null,s[i],i,s);else{if(Ie(s))return;const r=e?Object.getOwnPropertyNames(s):Object.keys(s),o=r.length;let h;for(i=0;i<o;i++)h=r[i],t.call(null,s[h],h,s)}}function _r(s,t){if(Ie(s))return null;t=t.toLowerCase();const e=Object.keys(s);let i=e.length,n;for(;i-- >0;)if(n=e[i],t===n.toLowerCase())return n;return null}const be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Tr=s=>!Me(s)&&s!==be;function Ts(){const{caseless:s,skipUndefined:t}=Tr(this)&&this||{},e={},i=(n,r)=>{const o=s&&_r(e,r)||r;Si(e[o])&&Si(n)?e[o]=Ts(e[o],n):Si(n)?e[o]=Ts({},n):xe(n)?e[o]=n.slice():(!t||!Me(n))&&(e[o]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&He(arguments[n],i);return e}const La=(s,t,e,{allOwnKeys:i}={})=>(He(t,(n,r)=>{e&&At(n)?Object.defineProperty(s,r,{value:vr(n,e),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,r,{value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),s),xa=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),Ma=(s,t,e,i)=>{s.prototype=Object.create(t.prototype,i),Object.defineProperty(s.prototype,"constructor",{value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{value:t.prototype}),e&&Object.assign(s.prototype,e)},Ra=(s,t,e,i)=>{let n,r,o;const h={};if(t=t||{},s==null)return t;do{for(n=Object.getOwnPropertyNames(s),r=n.length;r-- >0;)o=n[r],(!i||i(o,s,t))&&!h[o]&&(t[o]=s[o],h[o]=!0);s=e!==!1&&_s(s)}while(s&&(!e||e(s,t))&&s!==Object.prototype);return t},Oa=(s,t,e)=>{s=String(s),(e===void 0||e>s.length)&&(e=s.length),e-=t.length;const i=s.indexOf(t,e);return i!==-1&&i===e},ka=s=>{if(!s)return null;if(xe(s))return s;let t=s.length;if(!Sr(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=s[t];return e},Pa=(s=>t=>s&&t instanceof s)(typeof Uint8Array<"u"&&_s(Uint8Array)),Aa=(s,t)=>{const i=(s&&s[vi]).call(s);let n;for(;(n=i.next())&&!n.done;){const r=n.value;t.call(s,r[0],r[1])}},Da=(s,t)=>{let e;const i=[];for(;(e=s.exec(t))!==null;)i.push(e);return i},Na=$t("HTMLFormElement"),Ba=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,n){return i.toUpperCase()+n}),Er=(({hasOwnProperty:s})=>(t,e)=>s.call(t,e))(Object.prototype),Fa=$t("RegExp"),Cr=(s,t)=>{const e=Object.getOwnPropertyDescriptors(s),i={};He(e,(n,r)=>{let o;(o=t(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},za=s=>{Cr(s,(t,e)=>{if(At(s)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=s[e];if(At(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},Ua=(s,t)=>{const e={},i=n=>{n.forEach(r=>{e[r]=!0})};return xe(s)?i(s):i(String(s).split(t)),e},Va=()=>{},Wa=(s,t)=>s!=null&&Number.isFinite(s=+s)?s:t;function Ia(s){return!!(s&&At(s.append)&&s[yr]==="FormData"&&s[vi])}const qa=s=>{const t=new Array(10),e=(i,n)=>{if(qe(i)){if(t.indexOf(i)>=0)return;if(Ie(i))return i;if(!("toJSON"in i)){t[n]=i;const r=xe(i)?[]:{};return He(i,(o,h)=>{const l=e(o,n+1);!Me(l)&&(r[h]=l)}),t[n]=void 0,r}}return i};return e(s,0)},Ha=$t("AsyncFunction"),$a=s=>s&&(qe(s)||At(s))&&At(s.then)&&At(s.catch),Lr=((s,t)=>s?setImmediate:t?((e,i)=>(be.addEventListener("message",({source:n,data:r})=>{n===be&&r===e&&i.length&&i.shift()()},!1),n=>{i.push(n),be.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",At(be.postMessage)),ja=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Lr,v={isArray:xe,isArrayBuffer:wr,isBuffer:Ie,isFormData:ya,isArrayBufferView:ca,isString:ua,isNumber:Sr,isBoolean:fa,isObject:qe,isPlainObject:Si,isEmptyObject:da,isReadableStream:Sa,isRequest:_a,isResponse:Ta,isHeaders:Ea,isUndefined:Me,isDate:pa,isFile:ma,isBlob:ga,isRegExp:Fa,isFunction:At,isStream:va,isURLSearchParams:wa,isTypedArray:Pa,isFileList:ba,forEach:He,merge:Ts,extend:La,trim:Ca,stripBOM:xa,inherits:Ma,toFlatObject:Ra,kindOf:yi,kindOfTest:$t,endsWith:Oa,toArray:ka,forEachEntry:Aa,matchAll:Da,isHTMLForm:Na,hasOwnProperty:Er,hasOwnProp:Er,reduceDescriptors:Cr,freezeMethods:za,toObjectSet:Ua,toCamelCase:Ba,noop:Va,toFiniteNumber:Wa,findKey:_r,global:be,isContextDefined:Tr,isSpecCompliantForm:Ia,toJSONObject:qa,isAsyncFn:Ha,isThenable:$a,setImmediate:Lr,asap:ja,isIterable:s=>s!=null&&At(s[vi])};let N=class Do extends Error{static from(t,e,i,n,r,o){const h=new Do(t.message,e||t.code,i,n,r);return h.cause=t,h.name=t.name,o&&Object.assign(h,o),h}constructor(t,e,i,n,r){super(t),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r,this.status=r.status)}toJSON(){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:v.toJSONObject(this.config),code:this.code,status:this.status}}};N.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",N.ERR_BAD_OPTION="ERR_BAD_OPTION",N.ECONNABORTED="ECONNABORTED",N.ETIMEDOUT="ETIMEDOUT",N.ERR_NETWORK="ERR_NETWORK",N.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",N.ERR_DEPRECATED="ERR_DEPRECATED",N.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",N.ERR_BAD_REQUEST="ERR_BAD_REQUEST",N.ERR_CANCELED="ERR_CANCELED",N.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",N.ERR_INVALID_URL="ERR_INVALID_URL";const Ja=null;function Es(s){return v.isPlainObject(s)||v.isArray(s)}function xr(s){return v.endsWith(s,"[]")?s.slice(0,-2):s}function Mr(s,t,e){return s?s.concat(t).map(function(n,r){return n=xr(n),!e&&r?"["+n+"]":n}).join(e?".":""):t}function Ka(s){return v.isArray(s)&&!s.some(Es)}const Xa=v.toFlatObject(v,{},null,function(t){return/^is[A-Z]/.test(t)});function _i(s,t,e){if(!v.isObject(s))throw new TypeError("target must be an object");t=t||new FormData,e=v.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,m){return!v.isUndefined(m[f])});const i=e.metaTokens,n=e.visitor||c,r=e.dots,o=e.indexes,l=(e.Blob||typeof Blob<"u"&&Blob)&&v.isSpecCompliantForm(t);if(!v.isFunction(n))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(v.isDate(d))return d.toISOString();if(v.isBoolean(d))return d.toString();if(!l&&v.isBlob(d))throw new N("Blob is not supported. Use a Buffer instead.");return v.isArrayBuffer(d)||v.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,f,m){let w=d;if(d&&!m&&typeof d=="object"){if(v.endsWith(f,"{}"))f=i?f:f.slice(0,-2),d=JSON.stringify(d);else if(v.isArray(d)&&Ka(d)||(v.isFileList(d)||v.endsWith(f,"[]"))&&(w=v.toArray(d)))return f=xr(f),w.forEach(function(R,k){!(v.isUndefined(R)||R===null)&&t.append(o===!0?Mr([f],k,r):o===null?f:f+"[]",a(R))}),!1}return Es(d)?!0:(t.append(Mr(m,f,r),a(d)),!1)}const u=[],p=Object.assign(Xa,{defaultVisitor:c,convertValue:a,isVisitable:Es});function g(d,f){if(!v.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(d),v.forEach(d,function(w,M){(!(v.isUndefined(w)||w===null)&&n.call(t,w,v.isString(M)?M.trim():M,f,p))===!0&&g(w,f?f.concat(M):[M])}),u.pop()}}if(!v.isObject(s))throw new TypeError("data must be an object");return g(s),t}function Rr(s){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Cs(s,t){this._pairs=[],s&&_i(s,this,t)}const Or=Cs.prototype;Or.append=function(t,e){this._pairs.push([t,e])},Or.toString=function(t){const e=t?function(i){return t.call(this,i,Rr)}:Rr;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};function Ya(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kr(s,t,e){if(!t)return s;const i=e&&e.encode||Ya,n=v.isFunction(e)?{serialize:e}:e,r=n&&n.serialize;let o;if(r?o=r(t,n):o=v.isURLSearchParams(t)?t.toString():new Cs(t,n).toString(i),o){const h=s.indexOf("#");h!==-1&&(s=s.slice(0,h)),s+=(s.indexOf("?")===-1?"?":"&")+o}return s}class Pr{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:i?i.synchronous:!1,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){v.forEach(this.handlers,function(i){i!==null&&t(i)})}}const Ar={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ga={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Cs,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",xs=typeof navigator=="object"&&navigator||void 0,Za=Ls&&(!xs||["ReactNative","NativeScript","NS"].indexOf(xs.product)<0),Qa=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tc=Ls&&window.location.href||"http://localhost",xt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:Za,hasStandardBrowserWebWorkerEnv:Qa,navigator:xs,origin:tc},Symbol.toStringTag,{value:"Module"})),...Ga};function ec(s,t){return _i(s,new xt.classes.URLSearchParams,{visitor:function(e,i,n,r){return xt.isNode&&v.isBuffer(e)?(this.append(i,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}function ic(s){return v.matchAll(/\w+|\[(\w*)]/g,s).map(t=>t[0]==="[]"?"":t[1]||t[0])}function sc(s){const t={},e=Object.keys(s);let i;const n=e.length;let r;for(i=0;i<n;i++)r=e[i],t[r]=s[r];return t}function Dr(s){function t(e,i,n,r){let o=e[r++];if(o==="__proto__")return!0;const h=Number.isFinite(+o),l=r>=e.length;return o=!o&&v.isArray(n)?n.length:o,l?(v.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!h):((!n[o]||!v.isObject(n[o]))&&(n[o]=[]),t(e,i,n[o],r)&&v.isArray(n[o])&&(n[o]=sc(n[o])),!h)}if(v.isFormData(s)&&v.isFunction(s.entries)){const e={};return v.forEachEntry(s,(i,n)=>{t(ic(i),n,e,0)}),e}return null}function nc(s,t,e){if(v.isString(s))try{return(t||JSON.parse)(s),v.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(s)}const $e={transitional:Ar,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",n=i.indexOf("application/json")>-1,r=v.isObject(t);if(r&&v.isHTMLForm(t)&&(t=new FormData(t)),v.isFormData(t))return n?JSON.stringify(Dr(t)):t;if(v.isArrayBuffer(t)||v.isBuffer(t)||v.isStream(t)||v.isFile(t)||v.isBlob(t)||v.isReadableStream(t))return t;if(v.isArrayBufferView(t))return t.buffer;if(v.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let h;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ec(t,this.formSerializer).toString();if((h=v.isFileList(t))||i.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return _i(h?{"files[]":t}:t,l&&new l,this.formSerializer)}}return r||n?(e.setContentType("application/json",!1),nc(t)):t}],transformResponse:[function(t){const e=this.transitional||$e.transitional,i=e&&e.forcedJSONParsing,n=this.responseType==="json";if(v.isResponse(t)||v.isReadableStream(t))return t;if(t&&v.isString(t)&&(i&&!this.responseType||n)){const o=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(h){if(o)throw h.name==="SyntaxError"?N.from(h,N.ERR_BAD_RESPONSE,this,null,this.response):h}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};v.forEach(["delete","get","head","post","put","patch"],s=>{$e.headers[s]={}});const rc=v.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"]),oc=s=>{const t={};let e,i,n;return s&&s.split(`
2
- `).forEach(function(o){n=o.indexOf(":"),e=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!e||t[e]&&rc[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},Nr=Symbol("internals");function je(s){return s&&String(s).trim().toLowerCase()}function Ti(s){return s===!1||s==null?s:v.isArray(s)?s.map(Ti):String(s)}function hc(s){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=e.exec(s);)t[i[1]]=i[2];return t}const lc=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Ms(s,t,e,i,n){if(v.isFunction(i))return i.call(this,t,e);if(n&&(t=e),!!v.isString(t)){if(v.isString(i))return t.indexOf(i)!==-1;if(v.isRegExp(i))return i.test(t)}}function ac(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function cc(s,t){const e=v.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+e,{value:function(n,r,o){return this[i].call(this,t,n,r,o)},configurable:!0})})}let Dt=class{constructor(t){t&&this.set(t)}set(t,e,i){const n=this;function r(h,l,a){const c=je(l);if(!c)throw new Error("header name must be a non-empty string");const u=v.findKey(n,c);(!u||n[u]===void 0||a===!0||a===void 0&&n[u]!==!1)&&(n[u||l]=Ti(h))}const o=(h,l)=>v.forEach(h,(a,c)=>r(a,c,l));if(v.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(v.isString(t)&&(t=t.trim())&&!lc(t))o(oc(t),e);else if(v.isObject(t)&&v.isIterable(t)){let h={},l,a;for(const c of t){if(!v.isArray(c))throw TypeError("Object iterator must return a key-value pair");h[a=c[0]]=(l=h[a])?v.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}o(h,e)}else t!=null&&r(e,t,i);return this}get(t,e){if(t=je(t),t){const i=v.findKey(this,t);if(i){const n=this[i];if(!e)return n;if(e===!0)return hc(n);if(v.isFunction(e))return e.call(this,n,i);if(v.isRegExp(e))return e.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=je(t),t){const i=v.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Ms(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let n=!1;function r(o){if(o=je(o),o){const h=v.findKey(i,o);h&&(!e||Ms(i,i[h],h,e))&&(delete i[h],n=!0)}}return v.isArray(t)?t.forEach(r):r(t),n}clear(t){const e=Object.keys(this);let i=e.length,n=!1;for(;i--;){const r=e[i];(!t||Ms(this,this[r],r,t,!0))&&(delete this[r],n=!0)}return n}normalize(t){const e=this,i={};return v.forEach(this,(n,r)=>{const o=v.findKey(i,r);if(o){e[o]=Ti(n),delete e[r];return}const h=t?ac(r):String(r).trim();h!==r&&delete e[r],e[h]=Ti(n),i[h]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return v.forEach(this,(i,n)=>{i!=null&&i!==!1&&(e[n]=t&&v.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(`
3
- `)}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(n=>i.set(n)),i}static accessor(t){const i=(this[Nr]=this[Nr]={accessors:{}}).accessors,n=this.prototype;function r(o){const h=je(o);i[h]||(cc(n,o),i[h]=!0)}return v.isArray(t)?t.forEach(r):r(t),this}};Dt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),v.reduceDescriptors(Dt.prototype,({value:s},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>s,set(i){this[e]=i}}}),v.freezeMethods(Dt);function Rs(s,t){const e=this||$e,i=t||e,n=Dt.from(i.headers);let r=i.data;return v.forEach(s,function(h){r=h.call(e,r,n.normalize(),t?t.status:void 0)}),n.normalize(),r}function Br(s){return!!(s&&s.__CANCEL__)}let Je=class extends N{constructor(t,e,i){super(t??"canceled",N.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function Fr(s,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?s(e):t(new N("Request failed with status code "+e.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function uc(s){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return t&&t[1]||""}function fc(s,t){s=s||10;const e=new Array(s),i=new Array(s);let n=0,r=0,o;return t=t!==void 0?t:1e3,function(l){const a=Date.now(),c=i[r];o||(o=a),e[n]=l,i[n]=a;let u=r,p=0;for(;u!==n;)p+=e[u++],u=u%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),a-o<t)return;const g=c&&a-c;return g?Math.round(p*1e3/g):void 0}}function dc(s,t){let e=0,i=1e3/t,n,r;const o=(a,c=Date.now())=>{e=c,n=null,r&&(clearTimeout(r),r=null),s(...a)};return[(...a)=>{const c=Date.now(),u=c-e;u>=i?o(a,c):(n=a,r||(r=setTimeout(()=>{r=null,o(n)},i-u)))},()=>n&&o(n)]}const Ei=(s,t,e=3)=>{let i=0;const n=fc(50,250);return dc(r=>{const o=r.loaded,h=r.lengthComputable?r.total:void 0,l=o-i,a=n(l),c=o<=h;i=o;const u={loaded:o,total:h,progress:h?o/h:void 0,bytes:l,rate:a||void 0,estimated:a&&h&&c?(h-o)/a:void 0,event:r,lengthComputable:h!=null,[t?"download":"upload"]:!0};s(u)},e)},zr=(s,t)=>{const e=s!=null;return[i=>t[0]({lengthComputable:e,total:s,loaded:i}),t[1]]},Ur=s=>(...t)=>v.asap(()=>s(...t)),pc=xt.hasStandardBrowserEnv?((s,t)=>e=>(e=new URL(e,xt.origin),s.protocol===e.protocol&&s.host===e.host&&(t||s.port===e.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,mc=xt.hasStandardBrowserEnv?{write(s,t,e,i,n,r,o){if(typeof document>"u")return;const h=[`${s}=${encodeURIComponent(t)}`];v.isNumber(e)&&h.push(`expires=${new Date(e).toUTCString()}`),v.isString(i)&&h.push(`path=${i}`),v.isString(n)&&h.push(`domain=${n}`),r===!0&&h.push("secure"),v.isString(o)&&h.push(`SameSite=${o}`),document.cookie=h.join("; ")},read(s){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function gc(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function bc(s,t){return t?s.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):s}function Vr(s,t,e){let i=!gc(t);return s&&(i||e==!1)?bc(s,t):t}const Wr=s=>s instanceof Dt?{...s}:s;function ve(s,t){t=t||{};const e={};function i(a,c,u,p){return v.isPlainObject(a)&&v.isPlainObject(c)?v.merge.call({caseless:p},a,c):v.isPlainObject(c)?v.merge({},c):v.isArray(c)?c.slice():c}function n(a,c,u,p){if(v.isUndefined(c)){if(!v.isUndefined(a))return i(void 0,a,u,p)}else return i(a,c,u,p)}function r(a,c){if(!v.isUndefined(c))return i(void 0,c)}function o(a,c){if(v.isUndefined(c)){if(!v.isUndefined(a))return i(void 0,a)}else return i(void 0,c)}function h(a,c,u){if(u in t)return i(a,c);if(u in s)return i(void 0,a)}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:(a,c,u)=>n(Wr(a),Wr(c),u,!0)};return v.forEach(Object.keys({...s,...t}),function(c){const u=l[c]||n,p=u(s[c],t[c],c);v.isUndefined(p)&&u!==h||(e[c]=p)}),e}const Ir=s=>{const t=ve({},s);let{data:e,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:h}=t;if(t.headers=o=Dt.from(o),t.url=kr(Vr(t.baseURL,t.url,t.allowAbsoluteUrls),s.params,s.paramsSerializer),h&&o.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),v.isFormData(e)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(v.isFunction(e.getHeaders)){const l=e.getHeaders(),a=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{a.includes(c.toLowerCase())&&o.set(c,u)})}}if(xt.hasStandardBrowserEnv&&(i&&v.isFunction(i)&&(i=i(t)),i||i!==!1&&pc(t.url))){const l=n&&r&&mc.read(r);l&&o.set(n,l)}return t},vc=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(e,i){const n=Ir(s);let r=n.data;const o=Dt.from(n.headers).normalize();let{responseType:h,onUploadProgress:l,onDownloadProgress:a}=n,c,u,p,g,d;function f(){g&&g(),d&&d(),n.cancelToken&&n.cancelToken.unsubscribe(c),n.signal&&n.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout;function w(){if(!m)return;const R=Dt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),$={data:!h||h==="text"||h==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:R,config:s,request:m};Fr(function(G){e(G),f()},function(G){i(G),f()},$),m=null}"onloadend"in m?m.onloadend=w:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(w)},m.onabort=function(){m&&(i(new N("Request aborted",N.ECONNABORTED,s,m)),m=null)},m.onerror=function(k){const $=k&&k.message?k.message:"Network Error",Q=new N($,N.ERR_NETWORK,s,m);Q.event=k||null,i(Q),m=null},m.ontimeout=function(){let k=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const $=n.transitional||Ar;n.timeoutErrorMessage&&(k=n.timeoutErrorMessage),i(new N(k,$.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,s,m)),m=null},r===void 0&&o.setContentType(null),"setRequestHeader"in m&&v.forEach(o.toJSON(),function(k,$){m.setRequestHeader($,k)}),v.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),h&&h!=="json"&&(m.responseType=n.responseType),a&&([p,d]=Ei(a,!0),m.addEventListener("progress",p)),l&&m.upload&&([u,g]=Ei(l),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(c=R=>{m&&(i(!R||R.type?new Je(null,s,m):R),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const M=uc(n.url);if(M&&xt.protocols.indexOf(M)===-1){i(new N("Unsupported protocol "+M+":",N.ERR_BAD_REQUEST,s));return}m.send(r||null)})},yc=(s,t)=>{const{length:e}=s=s?s.filter(Boolean):[];if(t||e){let i=new AbortController,n;const r=function(a){if(!n){n=!0,h();const c=a instanceof Error?a:this.reason;i.abort(c instanceof N?c:new Je(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new N(`timeout of ${t}ms exceeded`,N.ETIMEDOUT))},t);const h=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),s=null)};s.forEach(a=>a.addEventListener("abort",r));const{signal:l}=i;return l.unsubscribe=()=>v.asap(h),l}},wc=function*(s,t){let e=s.byteLength;if(e<t){yield s;return}let i=0,n;for(;i<e;)n=i+t,yield s.slice(i,n),i=n},Sc=async function*(s,t){for await(const e of _c(s))yield*wc(e,t)},_c=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const t=s.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},qr=(s,t,e,i)=>{const n=Sc(s,t);let r=0,o,h=l=>{o||(o=!0,i&&i(l))};return new ReadableStream({async pull(l){try{const{done:a,value:c}=await n.next();if(a){h(),l.close();return}let u=c.byteLength;if(e){let p=r+=u;e(p)}l.enqueue(new Uint8Array(c))}catch(a){throw h(a),a}},cancel(l){return h(l),n.return()}},{highWaterMark:2})},Hr=64*1024,{isFunction:Ci}=v,Tc=(({Request:s,Response:t})=>({Request:s,Response:t}))(v.global),{ReadableStream:$r,TextEncoder:jr}=v.global,Jr=(s,...t)=>{try{return!!s(...t)}catch{return!1}},Ec=s=>{s=v.merge.call({skipUndefined:!0},Tc,s);const{fetch:t,Request:e,Response:i}=s,n=t?Ci(t):typeof fetch=="function",r=Ci(e),o=Ci(i);if(!n)return!1;const h=n&&Ci($r),l=n&&(typeof jr=="function"?(d=>f=>d.encode(f))(new jr):async d=>new Uint8Array(await new e(d).arrayBuffer())),a=r&&h&&Jr(()=>{let d=!1;const f=new e(xt.origin,{body:new $r,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!f}),c=o&&h&&Jr(()=>v.isReadableStream(new i("").body)),u={stream:c&&(d=>d.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(f,m)=>{let w=f&&f[d];if(w)return w.call(f);throw new N(`Response type '${d}' is not supported`,N.ERR_NOT_SUPPORT,m)})});const p=async d=>{if(d==null)return 0;if(v.isBlob(d))return d.size;if(v.isSpecCompliantForm(d))return(await new e(xt.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(v.isArrayBufferView(d)||v.isArrayBuffer(d))return d.byteLength;if(v.isURLSearchParams(d)&&(d=d+""),v.isString(d))return(await l(d)).byteLength},g=async(d,f)=>{const m=v.toFiniteNumber(d.getContentLength());return m??p(f)};return async d=>{let{url:f,method:m,data:w,signal:M,cancelToken:R,timeout:k,onDownloadProgress:$,onUploadProgress:Q,responseType:G,headers:st,withCredentials:tt="same-origin",fetchOptions:Nt}=Ir(d),Jt=t||fetch;G=G?(G+"").toLowerCase():"text";let Vt=yc([M,R&&R.toAbortSignal()],k),Bt=null;const dt=Vt&&Vt.unsubscribe&&(()=>{Vt.unsubscribe()});let et;try{if(Q&&a&&m!=="get"&&m!=="head"&&(et=await g(st,w))!==0){let gt=new e(f,{method:"POST",body:w,duplex:"half"}),J;if(v.isFormData(w)&&(J=gt.headers.get("content-type"))&&st.setContentType(J),gt.body){const[lt,St]=zr(et,Ei(Ur(Q)));w=qr(gt.body,Hr,lt,St)}}v.isString(tt)||(tt=tt?"include":"omit");const ot=r&&"credentials"in e.prototype,ht={...Nt,signal:Vt,method:m.toUpperCase(),headers:st.normalize().toJSON(),body:w,duplex:"half",credentials:ot?tt:void 0};Bt=r&&new e(f,ht);let Lt=await(r?Jt(Bt,Nt):Jt(f,ht));const wt=c&&(G==="stream"||G==="response");if(c&&($||wt&&dt)){const gt={};["status","statusText","headers"].forEach(bt=>{gt[bt]=Lt[bt]});const J=v.toFiniteNumber(Lt.headers.get("content-length")),[lt,St]=$&&zr(J,Ei(Ur($),!0))||[];Lt=new i(qr(Lt.body,Hr,lt,()=>{St&&St(),dt&&dt()}),gt)}G=G||"text";let mt=await u[v.findKey(u,G)||"text"](Lt,d);return!wt&&dt&&dt(),await new Promise((gt,J)=>{Fr(gt,J,{data:mt,headers:Dt.from(Lt.headers),status:Lt.status,statusText:Lt.statusText,config:d,request:Bt})})}catch(ot){throw dt&&dt(),ot&&ot.name==="TypeError"&&/Load failed|fetch/i.test(ot.message)?Object.assign(new N("Network Error",N.ERR_NETWORK,d,Bt),{cause:ot.cause||ot}):N.from(ot,ot&&ot.code,d,Bt)}}},Cc=new Map,Kr=s=>{let t=s&&s.env||{};const{fetch:e,Request:i,Response:n}=t,r=[i,n,e];let o=r.length,h=o,l,a,c=Cc;for(;h--;)l=r[h],a=c.get(l),a===void 0&&c.set(l,a=h?new Map:Ec(t)),c=a;return a};Kr();const Os={http:Ja,xhr:vc,fetch:{get:Kr}};v.forEach(Os,(s,t)=>{if(s){try{Object.defineProperty(s,"name",{value:t})}catch{}Object.defineProperty(s,"adapterName",{value:t})}});const Xr=s=>`- ${s}`,Lc=s=>v.isFunction(s)||s===null||s===!1;function xc(s,t){s=v.isArray(s)?s:[s];const{length:e}=s;let i,n;const r={};for(let o=0;o<e;o++){i=s[o];let h;if(n=i,!Lc(i)&&(n=Os[(h=String(i)).toLowerCase()],n===void 0))throw new N(`Unknown adapter '${h}'`);if(n&&(v.isFunction(n)||(n=n.get(t))))break;r[h||"#"+o]=n}if(!n){const o=Object.entries(r).map(([l,a])=>`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let h=e?o.length>1?`since :
4
- `+o.map(Xr).join(`
5
- `):" "+Xr(o[0]):"as no adapter specified";throw new N("There is no suitable adapter to dispatch the request "+h,"ERR_NOT_SUPPORT")}return n}const Yr={getAdapter:xc,adapters:Os};function ks(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Je(null,s)}function Gr(s){return ks(s),s.headers=Dt.from(s.headers),s.data=Rs.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Yr.getAdapter(s.adapter||$e.adapter,s)(s).then(function(i){return ks(s),i.data=Rs.call(s,s.transformResponse,i),i.headers=Dt.from(i.headers),i},function(i){return Br(i)||(ks(s),i&&i.response&&(i.response.data=Rs.call(s,s.transformResponse,i.response),i.response.headers=Dt.from(i.response.headers))),Promise.reject(i)})}const Zr="1.13.4",Li={};["object","boolean","number","function","string","symbol"].forEach((s,t)=>{Li[s]=function(i){return typeof i===s||"a"+(t<1?"n ":" ")+s}});const Qr={};Li.transitional=function(t,e,i){function n(r,o){return"[Axios v"+Zr+"] Transitional option '"+r+"'"+o+(i?". "+i:"")}return(r,o,h)=>{if(t===!1)throw new N(n(o," has been removed"+(e?" in "+e:"")),N.ERR_DEPRECATED);return e&&!Qr[o]&&(Qr[o]=!0,console.warn(n(o," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(r,o,h):!0}},Li.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Mc(s,t,e){if(typeof s!="object")throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const i=Object.keys(s);let n=i.length;for(;n-- >0;){const r=i[n],o=t[r];if(o){const h=s[r],l=h===void 0||o(h,r,s);if(l!==!0)throw new N("option "+r+" must be "+l,N.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new N("Unknown option "+r,N.ERR_BAD_OPTION)}}const xi={assertOptions:Mc,validators:Li},Yt=xi.validators;let ye=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Pr,response:new Pr}}async request(t,e){try{return await this._request(t,e)}catch(i){if(i instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const r=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?r&&!String(i.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(i.stack+=`
6
- `+r):i.stack=r}catch{}}throw i}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=ve(this.defaults,e);const{transitional:i,paramsSerializer:n,headers:r}=e;i!==void 0&&xi.assertOptions(i,{silentJSONParsing:Yt.transitional(Yt.boolean),forcedJSONParsing:Yt.transitional(Yt.boolean),clarifyTimeoutError:Yt.transitional(Yt.boolean)},!1),n!=null&&(v.isFunction(n)?e.paramsSerializer={serialize:n}:xi.assertOptions(n,{encode:Yt.function,serialize:Yt.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),xi.assertOptions(e,{baseUrl:Yt.spelling("baseURL"),withXsrfToken:Yt.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=r&&v.merge(r.common,r[e.method]);r&&v.forEach(["delete","get","head","post","put","patch","common"],d=>{delete r[d]}),e.headers=Dt.concat(o,r);const h=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(l=l&&f.synchronous,h.unshift(f.fulfilled,f.rejected))});const a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});let c,u=0,p;if(!l){const d=[Gr.bind(this),void 0];for(d.unshift(...h),d.push(...a),p=d.length,c=Promise.resolve(e);u<p;)c=c.then(d[u++],d[u++]);return c}p=h.length;let g=e;for(;u<p;){const d=h[u++],f=h[u++];try{g=d(g)}catch(m){f.call(this,m);break}}try{c=Gr.call(this,g)}catch(d){return Promise.reject(d)}for(u=0,p=a.length;u<p;)c=c.then(a[u++],a[u++]);return c}getUri(t){t=ve(this.defaults,t);const e=Vr(t.baseURL,t.url,t.allowAbsoluteUrls);return kr(e,t.params,t.paramsSerializer)}};v.forEach(["delete","get","head","options"],function(t){ye.prototype[t]=function(e,i){return this.request(ve(i||{},{method:t,url:e,data:(i||{}).data}))}}),v.forEach(["post","put","patch"],function(t){function e(i){return function(r,o,h){return this.request(ve(h||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}ye.prototype[t]=e(),ye.prototype[t+"Form"]=e(!0)});let Rc=class No{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(r){e=r});const i=this;this.promise.then(n=>{if(!i._listeners)return;let r=i._listeners.length;for(;r-- >0;)i._listeners[r](n);i._listeners=null}),this.promise.then=n=>{let r;const o=new Promise(h=>{i.subscribe(h),r=h}).then(n);return o.cancel=function(){i.unsubscribe(r)},o},t(function(r,o,h){i.reason||(i.reason=new Je(r,o,h),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=i=>{t.abort(i)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new No(function(n){t=n}),cancel:t}}};function Oc(s){return function(e){return s.apply(null,e)}}function kc(s){return v.isObject(s)&&s.isAxiosError===!0}const Ps={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ps).forEach(([s,t])=>{Ps[t]=s});function to(s){const t=new ye(s),e=vr(ye.prototype.request,t);return v.extend(e,ye.prototype,t,{allOwnKeys:!0}),v.extend(e,t,null,{allOwnKeys:!0}),e.create=function(n){return to(ve(s,n))},e}const ft=to($e);ft.Axios=ye,ft.CanceledError=Je,ft.CancelToken=Rc,ft.isCancel=Br,ft.VERSION=Zr,ft.toFormData=_i,ft.AxiosError=N,ft.Cancel=ft.CanceledError,ft.all=function(t){return Promise.all(t)},ft.spread=Oc,ft.isAxiosError=kc,ft.mergeConfig=ve,ft.AxiosHeaders=Dt,ft.formToJSON=s=>Dr(v.isHTMLForm(s)?new FormData(s):s),ft.getAdapter=Yr.getAdapter,ft.HttpStatusCode=Ps,ft.default=ft;const{Axios:Ku,AxiosError:Xu,CanceledError:Yu,isCancel:Gu,CancelToken:Zu,VERSION:Qu,all:tf,Cancel:ef,isAxiosError:sf,spread:nf,toFormData:rf,AxiosHeaders:of,HttpStatusCode:hf,formToJSON:lf,getAdapter:af,mergeConfig:cf}=ft,Gt=Object.create(null);Gt.open="0",Gt.close="1",Gt.ping="2",Gt.pong="3",Gt.message="4",Gt.upgrade="5",Gt.noop="6";const Mi=Object.create(null);Object.keys(Gt).forEach(s=>{Mi[Gt[s]]=s});const As={type:"error",data:"parser error"},eo=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",io=typeof ArrayBuffer=="function",so=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Ds=({type:s,data:t},e,i)=>eo&&t instanceof Blob?e?i(t):no(t,i):io&&(t instanceof ArrayBuffer||so(t))?e?i(t):no(new Blob([t]),i):i(Gt[s]+(t||"")),no=(s,t)=>{const e=new FileReader;return e.onload=function(){const i=e.result.split(",")[1];t("b"+(i||""))},e.readAsDataURL(s)};function ro(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Ns;function Pc(s,t){if(eo&&s.data instanceof Blob)return s.data.arrayBuffer().then(ro).then(t);if(io&&(s.data instanceof ArrayBuffer||so(s.data)))return t(ro(s.data));Ds(s,!1,e=>{Ns||(Ns=new TextEncoder),t(Ns.encode(e))})}const oo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ke=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<oo.length;s++)Ke[oo.charCodeAt(s)]=s;const Ac=s=>{let t=s.length*.75,e=s.length,i,n=0,r,o,h,l;s[s.length-1]==="="&&(t--,s[s.length-2]==="="&&t--);const a=new ArrayBuffer(t),c=new Uint8Array(a);for(i=0;i<e;i+=4)r=Ke[s.charCodeAt(i)],o=Ke[s.charCodeAt(i+1)],h=Ke[s.charCodeAt(i+2)],l=Ke[s.charCodeAt(i+3)],c[n++]=r<<2|o>>4,c[n++]=(o&15)<<4|h>>2,c[n++]=(h&3)<<6|l&63;return a},Dc=typeof ArrayBuffer=="function",Bs=(s,t)=>{if(typeof s!="string")return{type:"message",data:ho(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:Nc(s.substring(1),t)}:Mi[e]?s.length>1?{type:Mi[e],data:s.substring(1)}:{type:Mi[e]}:As},Nc=(s,t)=>{if(Dc){const e=Ac(s);return ho(e,t)}else return{base64:!0,data:s}},ho=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,lo="",Bc=(s,t)=>{const e=s.length,i=new Array(e);let n=0;s.forEach((r,o)=>{Ds(r,!1,h=>{i[o]=h,++n===e&&t(i.join(lo))})})},Fc=(s,t)=>{const e=s.split(lo),i=[];for(let n=0;n<e.length;n++){const r=Bs(e[n],t);if(i.push(r),r.type==="error")break}return i};function zc(){return new TransformStream({transform(s,t){Pc(s,e=>{const i=e.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const r=new DataView(n.buffer);r.setUint8(0,126),r.setUint16(1,i)}else{n=new Uint8Array(9);const r=new DataView(n.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(i))}s.data&&typeof s.data!="string"&&(n[0]|=128),t.enqueue(n),t.enqueue(e)})}})}let Fs;function Ri(s){return s.reduce((t,e)=>t+e.length,0)}function Oi(s,t){if(s[0].length===t)return s.shift();const e=new Uint8Array(t);let i=0;for(let n=0;n<t;n++)e[n]=s[0][i++],i===s[0].length&&(s.shift(),i=0);return s.length&&i<s[0].length&&(s[0]=s[0].slice(i)),e}function Uc(s,t){Fs||(Fs=new TextDecoder);const e=[];let i=0,n=-1,r=!1;return new TransformStream({transform(o,h){for(e.push(o);;){if(i===0){if(Ri(e)<1)break;const l=Oi(e,1);r=(l[0]&128)===128,n=l[0]&127,n<126?i=3:n===126?i=1:i=2}else if(i===1){if(Ri(e)<2)break;const l=Oi(e,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),i=3}else if(i===2){if(Ri(e)<8)break;const l=Oi(e,8),a=new DataView(l.buffer,l.byteOffset,l.length),c=a.getUint32(0);if(c>Math.pow(2,21)-1){h.enqueue(As);break}n=c*Math.pow(2,32)+a.getUint32(4),i=3}else{if(Ri(e)<n)break;const l=Oi(e,n);h.enqueue(Bs(r?l:Fs.decode(l),t)),i=0}if(n===0||n>s){h.enqueue(As);break}}}})}const ao=4;function _t(s){if(s)return Vc(s)}function Vc(s){for(var t in _t.prototype)s[t]=_t.prototype[t];return s}_t.prototype.on=_t.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},_t.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},_t.prototype.off=_t.prototype.removeListener=_t.prototype.removeAllListeners=_t.prototype.removeEventListener=function(s,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+s];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var i,n=0;n<e.length;n++)if(i=e[n],i===t||i.fn===t){e.splice(n,1);break}return e.length===0&&delete this._callbacks["$"+s],this},_t.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+s],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(e){e=e.slice(0);for(var i=0,n=e.length;i<n;++i)e[i].apply(this,t)}return this},_t.prototype.emitReserved=_t.prototype.emit,_t.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},_t.prototype.hasListeners=function(s){return!!this.listeners(s).length};const ki=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Ut=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Wc="arraybuffer";function uf(){}function co(s,...t){return t.reduce((e,i)=>(s.hasOwnProperty(i)&&(e[i]=s[i]),e),{})}const Ic=Ut.setTimeout,qc=Ut.clearTimeout;function Pi(s,t){t.useNativeTimers?(s.setTimeoutFn=Ic.bind(Ut),s.clearTimeoutFn=qc.bind(Ut)):(s.setTimeoutFn=Ut.setTimeout.bind(Ut),s.clearTimeoutFn=Ut.clearTimeout.bind(Ut))}const Hc=1.33;function $c(s){return typeof s=="string"?jc(s):Math.ceil((s.byteLength||s.size)*Hc)}function jc(s){let t=0,e=0;for(let i=0,n=s.length;i<n;i++)t=s.charCodeAt(i),t<128?e+=1:t<2048?e+=2:t<55296||t>=57344?e+=3:(i++,e+=4);return e}function uo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Jc(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function Kc(s){let t={},e=s.split("&");for(let i=0,n=e.length;i<n;i++){let r=e[i].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}class Xc extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class zs extends _t{constructor(t){super(),this.writable=!1,Pi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,i){return super.emitReserved("error",new Xc(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Bs(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=Jc(t);return e.length?"?"+e:""}}class Yc extends zs{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||e()})),this.writable||(i++,this.once("drain",function(){--i||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Fc(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Bc(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=uo()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let fo=!1;try{fo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Gc=fo;function Zc(){}class Qc extends Yc{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let i=location.port;i||(i=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",(n,r)=>{this.onError("xhr post error",n,r)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,i)=>{this.onError("xhr poll error",e,i)}),this.pollXhr=t}}class Zt extends _t{constructor(t,e,i){super(),this.createRequest=t,Pi(this,i),this._opts=i,this._method=i.method||"GET",this._uri=e,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;const e=co(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(e);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&i.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var n;i.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=Zt.requestsCount++,Zt.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Zc,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Zt.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(Zt.requestsCount=0,Zt.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",po);else if(typeof addEventListener=="function"){const s="onpagehide"in Ut?"pagehide":"unload";addEventListener(s,po,!1)}}function po(){for(let s in Zt.requests)Zt.requests.hasOwnProperty(s)&&Zt.requests[s].abort()}const tu=(function(){const s=mo({xdomain:!1});return s&&s.responseType!==null})();class eu extends Qc{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=tu&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Zt(mo,this.uri(),t)}}function mo(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Gc))return new XMLHttpRequest}catch{}if(!t)try{return new Ut[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const go=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class iu extends zs{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,i=go?{}:co(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,i)}catch(n){return this.emitReserved("error",n)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;Ds(i,this.supportsBinary,r=>{try{this.doWrite(i,r)}catch{}n&&ki(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=uo()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Us=Ut.WebSocket||Ut.MozWebSocket;class su extends iu{createSocket(t,e,i){return go?new Us(t,e,i):e?new Us(t,e):new Us(t)}doWrite(t,e){this.ws.send(e)}}class nu extends zs{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=Uc(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),n=zc();n.readable.pipeTo(t.writable),this._writer=n.writable.getWriter();const r=()=>{i.read().then(({done:h,value:l})=>{h||(this.onPacket(l),r())}).catch(h=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;this._writer.write(i).then(()=>{n&&ki(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ru={websocket:su,webtransport:nu,polling:eu},ou=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,hu=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Vs(s){if(s.length>8e3)throw"URI too long";const t=s,e=s.indexOf("["),i=s.indexOf("]");e!=-1&&i!=-1&&(s=s.substring(0,e)+s.substring(e,i).replace(/:/g,";")+s.substring(i,s.length));let n=ou.exec(s||""),r={},o=14;for(;o--;)r[hu[o]]=n[o]||"";return e!=-1&&i!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=lu(r,r.path),r.queryKey=au(r,r.query),r}function lu(s,t){const e=/\/{2,9}/g,i=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function au(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,n,r){n&&(e[n]=r)}),e}const Ws=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ai=[];Ws&&addEventListener("offline",()=>{Ai.forEach(s=>s())},!1);class ce extends _t{constructor(t,e){if(super(),this.binaryType=Wc,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const i=Vs(t);e.hostname=i.host,e.secure=i.protocol==="https"||i.protocol==="wss",e.port=i.port,i.query&&(e.query=i.query)}else e.host&&(e.hostname=Vs(e.host).host);Pi(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(i=>{const n=i.prototype.name;this.transports.push(n),this._transportsByName[n]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Kc(this.opts.query)),Ws&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ai.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=ao,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&ce.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",ce.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let i=0;i<this.writeBuffer.length;i++){const n=this.writeBuffer[i].data;if(n&&(e+=$c(n)),i>0&&e>this._maxPayload)return this.writeBuffer.slice(0,i);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ki(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,i){return this._sendPacket("message",t,e,i),this}send(t,e,i){return this._sendPacket("message",t,e,i),this}_sendPacket(t,e,i,n){if(typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const r={type:t,data:e,options:i};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():t()}):this.upgrading?i():t()),this}_onError(t){if(ce.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ws&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=Ai.indexOf(this._offlineEventListener);i!==-1&&Ai.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}ce.protocol=ao;class cu extends ce{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),i=!1;ce.priorWebsocketSuccess=!1;const n=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",u=>{if(!i)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;ce.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(c(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=e.name,this.emitReserved("upgradeError",p)}}))};function r(){i||(i=!0,c(),e.close(),e=null)}const o=u=>{const p=new Error("probe error: "+u);p.transport=e.name,r(),this.emitReserved("upgradeError",p)};function h(){o("transport closed")}function l(){o("socket closed")}function a(u){e&&u.name!==e.name&&r()}const c=()=>{e.removeListener("open",n),e.removeListener("error",o),e.removeListener("close",h),this.off("close",l),this.off("upgrading",a)};e.once("open",n),e.once("error",o),e.once("close",h),this.once("close",l),this.once("upgrading",a),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&e.push(t[i]);return e}}let uu=class extends cu{constructor(t,e={}){const i=typeof t=="object"?t:e;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(n=>ru[n]).filter(n=>!!n)),super(t,i)}};function fu(s,t="",e){let i=s;e=e||typeof location<"u"&&location,s==null&&(s=e.protocol+"//"+e.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=e.protocol+s:s=e.host+s),/^(https?|wss?):\/\//.test(s)||(typeof e<"u"?s=e.protocol+"//"+s:s="https://"+s),i=Vs(s)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const r=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+r+":"+i.port+t,i.href=i.protocol+"://"+r+(e&&e.port===i.port?"":":"+i.port),i}const du=typeof ArrayBuffer=="function",pu=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,bo=Object.prototype.toString,mu=typeof Blob=="function"||typeof Blob<"u"&&bo.call(Blob)==="[object BlobConstructor]",gu=typeof File=="function"||typeof File<"u"&&bo.call(File)==="[object FileConstructor]";function Is(s){return du&&(s instanceof ArrayBuffer||pu(s))||mu&&s instanceof Blob||gu&&s instanceof File}function Di(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,i=s.length;e<i;e++)if(Di(s[e]))return!0;return!1}if(Is(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Di(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&Di(s[e]))return!0;return!1}function bu(s){const t=[],e=s.data,i=s;return i.data=qs(e,t),i.attachments=t.length,{packet:i,buffers:t}}function qs(s,t){if(!s)return s;if(Is(s)){const e={_placeholder:!0,num:t.length};return t.push(s),e}else if(Array.isArray(s)){const e=new Array(s.length);for(let i=0;i<s.length;i++)e[i]=qs(s[i],t);return e}else if(typeof s=="object"&&!(s instanceof Date)){const e={};for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=qs(s[i],t));return e}return s}function vu(s,t){return s.data=Hs(s.data,t),delete s.attachments,s}function Hs(s,t){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<t.length)return t[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let e=0;e<s.length;e++)s[e]=Hs(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Hs(s[e],t));return s}const yu=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Y;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(Y||(Y={}));class wu{constructor(t){this.replacer=t}encode(t){return(t.type===Y.EVENT||t.type===Y.ACK)&&Di(t)?this.encodeAsBinary({type:t.type===Y.EVENT?Y.BINARY_EVENT:Y.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===Y.BINARY_EVENT||t.type===Y.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=bu(t),i=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(i),n}}class $s extends _t{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const i=e.type===Y.BINARY_EVENT;i||e.type===Y.BINARY_ACK?(e.type=i?Y.EVENT:Y.ACK,this.reconstructor=new Su(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Is(t)||t.base64)if(this.reconstructor)e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let e=0;const i={type:Number(t.charAt(0))};if(Y[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Y.BINARY_EVENT||i.type===Y.BINARY_ACK){const r=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(r,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(t.charAt(e+1)==="/"){const r=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););i.nsp=t.substring(r,e)}else i.nsp="/";const n=t.charAt(e+1);if(n!==""&&Number(n)==n){const r=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}i.id=Number(t.substring(r,e+1))}if(t.charAt(++e)){const r=this.tryParse(t.substr(e));if($s.isPayloadValid(i.type,r))i.data=r;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case Y.CONNECT:return vo(e);case Y.DISCONNECT:return e===void 0;case Y.CONNECT_ERROR:return typeof e=="string"||vo(e);case Y.EVENT:case Y.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&yu.indexOf(e[0])===-1);case Y.ACK:case Y.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Su{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=vu(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function vo(s){return Object.prototype.toString.call(s)==="[object Object]"}const _u=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$s,Encoder:wu,get PacketType(){return Y}},Symbol.toStringTag,{value:"Module"}));function jt(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const Tu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yo extends _t{constructor(t,e,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[jt(t,"open",this.onopen.bind(this)),jt(t,"packet",this.onpacket.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var i,n,r;if(Tu.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const o={type:Y.EVENT,data:e};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const c=this.ids++,u=e.pop();this._registerAckCallback(c,u),o.id=c}const h=(n=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||n===void 0?void 0:n.writable,l=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!h||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,e){var i;const n=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(n===void 0){this.acks[t]=e;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===t&&this.sendBuffer.splice(h,1);e.call(this,new Error("operation has timed out"))},n),o=(...h)=>{this.io.clearTimeoutFn(r),e.apply(this,h)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((i,n)=>{const r=(o,h)=>o?n(o):i(h);r.withError=!0,e.push(r),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((n,...r)=>(this._queue[0],n!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(n)):(this._queue.shift(),e&&e(null,...r)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Y.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Y.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Y.EVENT:case Y.BINARY_EVENT:this.onevent(t);break;case Y.ACK:case Y.BINARY_ACK:this.onack(t);break;case Y.DISCONNECT:this.ondisconnect();break;case Y.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...n){i||(i=!0,e.packet({type:Y.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Y.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const i of e)i.apply(this,t.data)}}}function Re(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}Re.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*s);s=(Math.floor(t*10)&1)==0?s-e:s+e}return Math.min(s,this.max)|0},Re.prototype.reset=function(){this.attempts=0},Re.prototype.setMin=function(s){this.ms=s},Re.prototype.setMax=function(s){this.max=s},Re.prototype.setJitter=function(s){this.jitter=s};class js extends _t{constructor(t,e){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,Pi(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((i=e.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new Re({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||_u;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new uu(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=jt(e,"open",function(){i.onopen(),t&&t()}),r=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),t?t(h):this.maybeReconnectOnOpen()},o=jt(e,"error",r);if(this._timeout!==!1){const h=this._timeout,l=this.setTimeoutFn(()=>{n(),r(new Error("timeout")),e.close()},h);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(jt(t,"ping",this.onping.bind(this)),jt(t,"data",this.ondata.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this)),jt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){ki(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new yo(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const i of e)if(this.nsps[i].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;i<e.length;i++)this.engine.write(e[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(n=>{n?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",n)):t.onreconnect()}))},e);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Xe={};function Ni(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=fu(s,t.path||"/socket.io"),i=e.source,n=e.id,r=e.path,o=Xe[n]&&r in Xe[n].nsps,h=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return h?l=new js(i,t):(Xe[n]||(Xe[n]=new js(i,t)),l=Xe[n]),e.query&&!t.query&&(t.query=e.queryKey),l.socket(e.path,t)}Object.assign(Ni,{Manager:js,Socket:yo,io:Ni,connect:Ni});let Js="http://localhost:8000";function wo(s){s&&s!==Js&&(Js=s,Qt&&(Qt.disconnect(),Qt=null))}let Qt=null;function Eu(){return Ni(Js,{transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,reconnectionAttempts:1/0,timeout:1e4,forceNew:!1})}function Ks(){return Qt||(Qt=Eu()),Qt}function Cu(s,t){const e=Ks();return e.on(s,t),()=>e.off(s,t)}function Lu(s,t){Qt&&Qt.off(s,t)}function xu(s,t){Ks().emit(s,t)}function Mu(){return Qt?Qt.connected?"connected":"connecting":"disconnected"}const Xs={getSocket:Ks,on:Cu,off:Lu,emit:xu,getStatus:Mu,setBaseUrl:wo},So=E.createContext(),_o=()=>{const s=E.useContext(So);if(!s)throw new Error("useTrading must be used within TradingProvider");return s},Ru=({children:s,baseUrl:t})=>{const e=t||typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Bi&&Bi.tagName.toUpperCase()==="SCRIPT"&&Bi.src||new URL("chart-sdk.umd.js",document.baseURI).href}<"u"&&"http://localhost:8000"||"http://localhost:8000";E.useEffect(()=>{Xs.setBaseUrl(e),Po(e)},[e]);const[i,n]=E.useState("CADJPY"),[r,o]=E.useState("M1"),[h,l]=E.useState([]),[a,c]=E.useState(!0),[u,p]=E.useState([]),[g,d]=E.useState(!1),[f,m]=E.useState(1e5),[w,M]=E.useState(null),[R,k]=E.useState([]),[$,Q]=E.useState(!0),[G,st]=E.useState(!1),[tt,Nt]=E.useState(!0),[Jt,Vt]=E.useState("candles"),[Bt,dt]=E.useState(!1),et=E.useRef(null),ot=E.useRef(new Map),ht=E.useRef(null),Lt=1e3,wt=E.useCallback(async()=>{try{const U=localStorage.getItem("token");if(!U){console.log("⚠️ No token, skipping orders fetch");return}d(!0);const X=await ft.get(`${e}/api/trades`,{headers:{Authorization:`Bearer ${U}`}});if(X.data&&X.data.data){const I=X.data.data.map(K=>({id:K.id,ticket:K.ticket,symbol:K.symbol,type:K.type,volume:K.volume,price:K.price,stopLoss:K.stopLoss,takeProfit:K.takeProfit,comment:K.comment||"",status:K.status,swap:K.swap||0,profit:K.profit||0,profitCurrency:"USD",time:new Date(K.openAt).toLocaleTimeString(),openAt:K.openAt,closeAt:K.closeAt}));p(I)}else p([])}catch(U){console.error("❌ Error fetching orders:",U.response?.data||U.message),p([])}finally{d(!1)}},[]),mt=E.useCallback((U,X)=>!X||!U.price||isNaN(X)||isNaN(U.price)?U.profit||0:(U.type==="BUY"?X-U.price:U.price-X)*U.volume,[]),gt=E.useCallback(async()=>{try{const U=localStorage.getItem("token");if(!U){console.log("⚠️ No token, skipping balance fetch");return}const X=await ft.get(`${e}/api/user/account`,{headers:{Authorization:`Bearer ${U}`}});if(X.data&&X.data.data){const I=parseFloat(X.data.data.balance);isNaN(I)||m(I)}}catch(U){console.error("❌ Error fetching user balance:",U.response?.data||U.message)}},[]),J=E.useMemo(()=>{const U=f,X=u.reduce((vt,Et)=>vt+Et.volume*Et.price*.01,0),I=u.reduce((vt,Et)=>{const Wt=h.find(It=>It.symbol===Et.symbol);if(Wt){const It=Et.type==="BUY"?parseFloat(Wt.bid||0):parseFloat(Wt.ask||0);if(It&&It>0&&!isNaN(It))return vt+mt(Et,It)}return vt+(Et.profit||0)},0),K=U+I,Ft=K-X,nt=X>0?K/X*100:0;return{balance:U,equity:K,margin:X,freeMargin:Ft,level:nt.toFixed(2)}},[u,h,f,mt]);E.useEffect(()=>{localStorage.getItem("token")&&(wt(),gt())},[wt,gt]),E.useEffect(()=>{(async()=>{try{c(!0);const X=await ft.get(`${e}/api/symbols`);if(X.data&&X.data.data){const I=X.data.data;l(I),I.length>0&&(I.find(Ft=>Ft.symbol===i)||n(I[0].symbol))}else l([])}catch(X){console.error("❌ Error fetching symbols:",X.response?.data||X.message),l([])}finally{c(!1)}})()},[]);const lt=E.useCallback(()=>{const U=ot.current;if(U.size===0)return;const X=new Map(U);U.clear(),l(I=>I.map(K=>{const Ft=X.get(K.symbol);return Ft?{...K,...Ft}:K})),p(I=>{let K=!1;const Ft=I.map(nt=>{const vt=X.get(nt.symbol);if(!vt)return nt;const Et=nt.type==="BUY"?parseFloat(vt.bid||0):parseFloat(vt.ask||0);if(!Et||isNaN(Et)||Et<=0)return nt;const Wt=mt(nt,Et);return Wt===nt.profit?nt:(K=!0,{...nt,profit:Wt})});return K?Ft:I})},[mt]);E.useEffect(()=>{et.current||(et.current=Xs.getSocket());const U=et.current,X=()=>console.log("✅ TradingContext: Connected"),I=()=>console.log("⚠️ TradingContext: Disconnected"),K=nt=>{nt?.symbol&&(ot.current.set(nt.symbol,nt),ht.current||(ht.current=setTimeout(()=>{ht.current=null,lt()},Lt)))},Ft=async nt=>{if(console.log("🔔 Trade closed event received:",nt),!!nt){if(nt.newBalance!==void 0){const vt=parseFloat(nt.newBalance);isNaN(vt)||m(vt)}if(window.notify){const vt=nt.profitLoss||nt.profit||0,Et=vt>=0?`+${vt.toFixed(2)}`:vt.toFixed(2),Wt=nt.symbol||"Trade",It=nt.reason||"Closed";window.notify(`Trade Closed: ${It} | ${Wt} | P/L: ${Et} USD`,vt>=0?"success":"error")}nt.tradeId&&p(vt=>vt.filter(Et=>Et.id!==nt.tradeId)),await wt(),await gt()}};return U.on("connect",X),U.on("disconnect",I),U.on("priceUpdate",K),U.on("tradeClosed",Ft),()=>{U.off("connect",X),U.off("disconnect",I),U.off("priceUpdate",K),U.off("tradeClosed",Ft),ht.current&&(clearTimeout(ht.current),ht.current=null),ot.current.clear()}},[lt,wt,gt]);const St=E.useMemo(()=>h.find(U=>U.symbol===i)||{bid:"0.00000",ask:"0.00000",change:0},[h,i]),bt=E.useMemo(()=>({selectedSymbol:i,setSelectedSymbol:n,selectedTimeframe:r,setSelectedTimeframe:o,symbols:h,setSymbols:l,symbolsLoading:a,orders:u,setOrders:p,ordersLoading:g,fetchOrders:wt,fetchUserBalance:gt,userBalance:f,setUserBalance:m,accountSummary:J,currentSymbolData:St,activeTool:w,setActiveTool:M,chartObjects:R,setChartObjects:k,showGrid:$,setShowGrid:Q,snapToGrid:G,setSnapToGrid:st,drawingsVisible:tt,setDrawingsVisible:Nt,chartType:Jt,setChartType:Vt,chartLocked:Bt,setChartLocked:dt}),[i,r,h,a,u,g,wt,gt,f,J,St,w,R,$,G,tt,Jt,Bt]);return ne.jsx(So.Provider,{value:bt,children:s})};function Tt(s){if(s==null)return null;if(typeof s=="number"){if(Number.isNaN(s)||!Number.isFinite(s))return null;let t;s>1e10?t=s/1e3:(s<1e9,t=s);const e=Math.floor(t);return e<946684800||e>4102444800?null:e}if(typeof s=="string"){const t=Date.parse(s);return Number.isNaN(t)?null:Math.floor(t/1e3)}if(typeof s=="object"&&"year"in s&&"month"in s&&"day"in s){const e=new Date(Date.UTC(s.year,s.month-1,s.day)).getTime();return Number.isNaN(e)?null:Math.floor(e/1e3)}return null}function Ou(s,t){if(!s||s.length<2)return[];const e=[],i=2;for(let n=1;n<s.length;n++){const r=s[n-1].time,o=s[n].time,h=o-r;h>t*i&&e.push({from:r,to:o,gapSeconds:h,gapHours:(h/3600).toFixed(1),fromDate:new Date(r*1e3).toISOString(),toDate:new Date(o*1e3).toISOString()})}return e}function ku(s,t="America/New_York"){const e=new Date(s*1e3),i=new Date(e.toLocaleString("en-US",{timeZone:t})),n=i.getDay();return!(n===0||n===6||n===5&&i.getHours()>=17)}function To(s){return Array.isArray(s)?s.map(t=>({...t,time:Tt(t.time)})).filter(t=>t.time!=null):[]}function Pu(s){if(!s||s.length<2)return!0;for(let t=1;t<s.length;t++)if(s[t].time<=s[t-1].time)return!1;return!0}function Oe(s,t){return!Number.isFinite(s)||!Number.isFinite(t)||t<=0?s:Math.floor(s/t)*t}const Mt="17:00-17:00",Rt="America/New_York",te="24x7",ee="UTC",Eo={EURUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},GBPUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDCHF:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},AUDUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDCAD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},NZDUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURGBP:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},GBPJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},CADJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},XAUUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},XAGUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},OILUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},BTCUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},ETHUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},BNBUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},SOLUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},ADAUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},XRPUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},DOGEUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},DOTUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},MATICUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},LINKUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"}},Co={type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"};function Ye(s){return s&&Eo[s.toUpperCase()]||Co}function Au(s){return Ye(s).type==="forex"}function Ys(s){return Ye(s).type==="crypto"}function Du(s){return Ye(s).session==="24x7"}function Lo(s){if(!s||typeof s!="object")return!1;const{time:t,open:e,high:i,low:n,close:r,volume:o}=s;return!(Tt(t)==null||typeof e!="number"||!Number.isFinite(e)||typeof i!="number"||!Number.isFinite(i)||typeof n!="number"||!Number.isFinite(n)||typeof r!="number"||!Number.isFinite(r)||o!=null&&(typeof o!="number"||o<0||!Number.isFinite(o))||i<e||i<r||i<n||n>e||n>r||n>i||e<=0||i<=0||n<=0||r<=0)}function xo(s){const t=o=>Math.round(o*1e5)/1e5;let e=t(s.open),i=t(s.high),n=t(s.low),r=t(s.close);return i=Math.max(i,e,r,n),n=Math.min(n,e,r,i),{...s,open:e,high:i,low:n,close:r,volume:s.volume!=null?Math.round(s.volume):s.volume}}function Mo(s){if(!Array.isArray(s)||s.length===0)return[];const t=new Map;return s.forEach(e=>{const i=Tt(e.time);if(i!=null)if(t.has(i)){const n=t.get(i);t.set(i,{...e,time:i,open:e.open,high:Math.max(n.high,e.high),low:Math.min(n.low,e.low),close:e.close,volume:(n.volume||0)+(e.volume||0)})}else t.set(i,{...e,time:i})}),Array.from(t.values())}function Nu(s,t="percentile"){if(!Array.isArray(s)||s.length<3)return s;const e=s.map(o=>o.close).filter(o=>Number.isFinite(o));if(e.length<3)return s;const i=[...e].sort((o,h)=>o-h);let n,r;if(t==="percentile"){const o=Math.floor(i.length*.25),h=Math.floor(i.length*.75),l=i[o],a=i[h],c=a-l;n=l-1.5*c,r=a+1.5*c}else{const o=e.reduce((a,c)=>a+c,0)/e.length,h=e.reduce((a,c)=>a+Math.pow(c-o,2),0)/e.length,l=Math.sqrt(h);if(l===0)return s;n=o-3*l,r=o+3*l}return s.map((o,h)=>{const l=o.close;if(l<n||l>r){if(h===0)return o;const a=s[h-1].close;return{...o,open:a,high:Math.max(a,o.high),low:Math.min(a,o.low),close:a}}return o})}function Bu(s,t){if(!Array.isArray(s)||s.length===0)return s;const e=[],i=Math.max(t*10080,604800),n=1e4;for(let h=0;h<s.length;h++)if(e.push(s[h]),h<s.length-1){const l=s[h].time,a=s[h+1].time,c=a-l;if(c>i&&((c/3600).toFixed(1),(i/3600).toFixed(1)),c>t&&c<=i){const u=s[h];let p=l+t,g=0;for(p=Oe(p,t);p<a&&g<n;){const d=Oe(p,t);e.some(m=>m.time===d)||(e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0}),g++),p+=t}if(p<a&&g>=n){const d=Oe(a-t,t);e.some(m=>m.time===d)||e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0})}}}e.sort((h,l)=>h.time-l.time);const r=[],o=new Set;for(const h of e)o.has(h.time)||(o.add(h.time),r.push(h));return r}function Gs(s){if(!s||typeof s!="string")return 60;const t=s.toUpperCase();if(t==="MN")return 2592e3;let e=t.match(/^([MHDW])(\d+)$/);if(e){const i=e[1];return parseInt(e[2],10)*({M:60,H:3600,D:86400,W:604800}[i]||60)}if(e=s.match(/^(\d+)([mhdwy])$/i),e){const i=parseInt(e[1],10),n=e[2].toLowerCase();return i*({m:60,h:3600,d:86400,w:604800,y:31536e3}[n]||60)}return 60}function Ro(s,t,e){if(!Array.isArray(s)||s.length===0)return{candles:[],stats:{original:0,processed:0,duplicates:0,outliers:0,gaps:[]}};const i=Ye(t),n=Gs(e),h=To(s).map(m=>({...m,time:Oe(m.time,n)})).filter(m=>Lo(m)).map(m=>xo(m)),l=Mo(h);l.sort((m,w)=>m.time-w.time);const a=l.filter((m,w)=>w===0?!0:m.time>l[w-1].time),c=a.length>10?Nu(a,"percentile"):a,u=Mo(c);u.sort((m,w)=>m.time-w.time);const p=Bu(u,n),g=[];for(let m=1;m<p.length;m++){const w=p[m].time-p[m-1].time;w>n*2&&g.push({from:p[m-1].time,to:p[m].time,gapSeconds:w,gapMinutes:Math.round(w/60),fromDate:new Date(p[m-1].time*1e3).toISOString(),toDate:new Date(p[m].time*1e3).toISOString()})}const d=c.filter((m,w)=>w===0?!1:m.close===c[w-1].close&&m.open===c[w-1].close).length,f={original:s.length,processed:p.length,duplicates:s.length-l.length,outliers:d,gaps:g,filledGaps:p.length-u.length,symbolConfig:i};return{candles:p,stats:f}}function Oo(s,t,e="1m"){if(!s||!t||!Lo(s))return null;const i=Tt(s.time);if(i==null)return null;const n=Gs(e),r=Oe(i,n);return xo({...s,time:r})}let ko="http://localhost:8000";function Po(s){s&&(ko=s)}const Fu={M1:3,M5:7,M15:14,M30:30,H1:90,H4:180,D1:1095,W1:1825,MN:3650};function Ao(s){if(!s)return 7;const t=String(s).toUpperCase();return Fu[t]??7}function zu(s,t){const e=String(s||"").toUpperCase(),i=t||Ao(s),n={M1:1440,M5:288,M15:96,M30:48,H1:24,H4:6,D1:1,W1:1/7,MN:1/30}[e]||96,r=Math.ceil(i*(typeof n=="number"?n:96));return Math.min(Math.max(r,500),5e3)}const Ot=s=>{if(!Array.isArray(s)||s.length===0)return[];const t=s.map(i=>({...i,time:Tt(i.time)})).filter(i=>i.time!=null);t.sort((i,n)=>i.time-n.time);const e=new Map;for(const i of t)e.set(i.time,i);return Array.from(e.values()).sort((i,n)=>i.time-n.time)};function Uu(s,t,e,i,n,r){const o=n-e,h=r-i,l=Math.sqrt(o*o+h*h);if(l===0)return Math.hypot(s-e,t-i);let a=((s-e)*o+(t-i)*h)/(l*l);a=Math.max(0,Math.min(1,a));const c=e+a*o,u=i+a*h;return Math.hypot(s-c,t-u)}function Zs(s,t,e,i,n){if(!e||!i||!n)return null;const r=e.time,o=i.time,h=o-r,l=e.price,a=i.price,c=n.price;if(Math.abs(h)<1e-9){const d=c-l;return[{time:r,price:l+d},{time:o+1,price:a+d}]}const u=(a-l)/h,p=c+u*(r-n.time),g=c+u*(o-n.time);return[{time:r,price:p},{time:o,price:g}]}const Vu=E.forwardRef(function({bidPrice:t="113.638",askPrice:e="113.649",showBuySellPanel:i=!0,onBuyClick:n,onSellClick:r},o){const h=E.useRef(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(null),u=E.useRef([]),p=E.useRef(!1),g=E.useRef(null),d=E.useRef(null),f=E.useRef(null),m=E.useRef(null),w=E.useRef([]),[M,R]=E.useState(null),[k,$]=E.useState([]),Q=E.useRef(null),G=E.useRef(null),st=E.useRef(null),tt=E.useRef(!1);E.useEffect(()=>{st.current=M},[M]);const Nt=E.useRef(new Map),Jt=E.useRef(null),Vt=(b,y)=>`${b}_${y}`,Bt=()=>{const b=Vt(J,lt);return Nt.current.get(b)||null},dt=b=>{if(!b)return;const y=Vt(J,lt);Nt.current.set(y,b)},{activeTool:et,setActiveTool:ot,showGrid:ht,snapToGrid:Lt,chartObjects:wt,setChartObjects:mt,orders:gt,selectedSymbol:J,selectedTimeframe:lt,drawingsVisible:St,chartType:bt,chartLocked:U}=_o(),X=E.useRef([]),[I,K]=E.useState([]),[Ft,nt]=E.useState(!0),vt=E.useRef(null),Et=E.useRef(new Map);E.useRef(null);const Wt=E.useRef(0);E.useImperativeHandle(o,()=>({zoomIn:()=>{const b=l.current?.timeScale();if(!b)return;const y=b.getVisibleRange();if(!y||!y.from||!y.to)return;const _=y.to-y.from,P=(y.from+y.to)/2,C=_*.8;try{b.setVisibleRange({from:P-C/2,to:P+C/2}),dt(b.getVisibleRange())}catch{}},zoomOut:()=>{const b=l.current?.timeScale();if(!b)return;const y=b.getVisibleRange();if(!y||!y.from||!y.to)return;const _=y.to-y.from,P=(y.from+y.to)/2,C=_*1.25;try{b.setVisibleRange({from:P-C/2,to:P+C/2}),dt(b.getVisibleRange())}catch{}}}));const It=E.useMemo(()=>I.length===0?[]:bt==="line"||bt==="area"?I.map(b=>({time:b.time,value:b.close})):I,[I,bt]);return E.useEffect(()=>{const b=h.current;if(!b)return;const y=b.getBoundingClientRect(),_=L=>{const F=Math.abs(Number(L));return Number.isFinite(F)?F>=1e3?F.toFixed(2):F>=1?F.toFixed(4):F.toFixed(5):"0"},P=la(b,{width:y.width||b.clientWidth,height:y.height||b.clientHeight,autoSize:!0,localization:{priceFormatter:_},layout:{background:{color:"#0F1720"},textColor:"#fff",fontSize:12},grid:{vertLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0}},rightPriceScale:{borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0},leftPriceScale:{visible:!1},timeScale:{borderColor:"#1e293b",timeVisible:!0,secondsVisible:!1,rightOffset:10,barSpacing:3,minBarSpacing:2,shiftVisibleRangeOnNewBar:!1,fixLeftEdge:!1,fixRightEdge:!1},crosshair:{mode:et===1?1:0,vertLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},vertLineVisible:et===1,horzLineVisible:et===1},handleScroll:{mouseWheel:!0,pressedMouseMove:et===null||et===1,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},axisTouch:{time:!0,price:!0},mouseWheel:!0,pinch:!0}}),C=P.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1});l.current=P,a.current=C;const V=P.timeScale(),W=()=>{if(tt.current&&I.length>0){const L=V.getVisibleRange();L&&dt(L)}};V.subscribeVisibleTimeRangeChange(W);const ct=new ResizeObserver(L=>{for(const F of L){const{width:it,height:q}=F.contentRect;if(it>0&&q>0&&P){const T=V.getVisibleRange();P.resize(it,q),T&&setTimeout(()=>{try{V.setVisibleRange(T)}catch{}},0)}}});return ct.observe(b),()=>{V.unsubscribeVisibleTimeRangeChange(W),ct.disconnect(),P.remove(),l.current=null,a.current=null,c.current=null,u.current=[]}},[]),E.useEffect(()=>{l.current&&l.current.applyOptions({grid:{vertLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0}}})},[ht]),E.useEffect(()=>{if(!l.current)return;const y=!U&&!(et!==null&&et!==1&&et!==0),_=!U;l.current.applyOptions({crosshair:{mode:et===1?1:0,vertLine:{visible:et===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{visible:et===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"}},handleScroll:{mouseWheel:_,pressedMouseMove:y,horzTouchDrag:y,vertTouchDrag:y},handleScale:{axisPressedMouseMove:{time:y,price:y},axisDoubleClickReset:{time:_,price:_},axisTouch:{time:y,price:y},mouseWheel:_,pinch:_}})},[et,U]),E.useEffect(()=>{(async()=>{if(!J||!lt){K([]),tt.current=!1;return}try{if(nt(!0),K([]),tt.current=!1,a.current)try{a.current.setData([])}catch{}console.log(`📊 Fetching candles for ${J} @ ${lt}`);const y=Ao(lt),_=zu(lt,y),P=await ft.get(`${ko}/api/chart/candles`,{params:{symbol:J,timeframe:lt,limit:_,daysBack:y},timeout:1e4});if(P.data&&P.data.data&&P.data.data.length>0){const C=P.data.data;console.log(`✅ Loaded ${C.length} raw candles from server`);const{candles:V,stats:W}=Ro(C,J,lt);V.length>0?(K(V),Et.current=new Map,V.forEach(ct=>{Et.current.set(ct.time,ct)})):(console.warn(`⚠️ No valid candles after processing for ${J}`),K([]))}else console.warn(`⚠️ No candle data returned for ${J}`),K([])}catch(y){console.error(`❌ Error fetching ${J}:`,y.message),K([])}finally{nt(!1)}})()},[J,lt]),E.useEffect(()=>{vt.current||(vt.current=Xs.getSocket());const b=vt.current,y=()=>{console.log("✅ Chart WebSocket connected"),C()},_=()=>{console.log("⚠️ Chart WebSocket disconnected - will auto-reconnect")},P=W=>{console.error("❌ Chart WebSocket connection error:",W)};b.on("connect",y),b.on("disconnect",_),b.on("connect_error",P);const C=()=>{const W=Ys(J);W&&J&&lt&&b.connected?(console.log(`Subscribing to real-time candles: ${J}@${lt}`),b.emit("subscribeCandles",{symbol:J,timeframe:lt})):!W&&J&&console.log(`⚠️ Symbol ${J} is not a crypto symbol, skipping candle subscription`)},V=W=>{if(!W||!W.candle||!W.symbol||W.symbol.toUpperCase()!==J?.toUpperCase())return;const{candle:ct}=W,L=Oo(ct,J,lt);if(!L)return;const F=Date.now();if(F-Wt.current<200)return;Wt.current=F;const it=l.current?.timeScale(),q=it?.getVisibleRange(),T=a.current,z=l.current;if(!(!T||!z||!tt.current))try{bt==="line"||bt==="area"?T.update({time:L.time,value:L.close}):T.update({time:L.time,open:L.open,high:L.high,low:L.low,close:L.close}),Et.current.set(L.time,L),it&&q&&dt(q)}catch(x){console.error("❌ Error updating candle:",x)}};return b.on("candleUpdate",V),b.connected&&C(),()=>{b.off("candleUpdate",V),b.off("connect",y),b.off("disconnect",_),b.off("connect_error",P),J&&lt&&b.connected&&Ys(J)&&(console.log(`🔌 Unsubscribing from: ${J}@${lt}`),b.emit("unsubscribeCandles",{symbol:J,timeframe:lt}))}},[J,lt]),E.useEffect(()=>{const b=a.current,y=l.current;if(!(!b||!y)&&!(I.length===0&&tt.current)){if(I.length===0&&!tt.current){if(Ft)return;const _=y.timeScale();b.setData([]),_.fitContent();return}if(!tt.current){const _=y.timeScale(),P=Vt(J,lt);if(Jt.current,Jt.current=P,bt==="line"||bt==="area"){const V=[...I.map(W=>({time:W.time,value:W.close})).filter(W=>W.time!=null)].sort((W,ct)=>W.time-ct.time);V.length>0&&b.setData(V)}else{const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&b.setData(C)}_.fitContent();try{y.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,dt(_.getVisibleRange())}}},[I.length,bt,J,lt]),E.useEffect(()=>{const b=l.current;if(!b||!tt.current||I.length===0)return;const y=b.timeScale(),_=y.getVisibleRange()||Bt();if(a.current)try{b.removeSeries(a.current)}catch{}if(c.current)try{b.removeSeries(c.current),c.current=null}catch{}let P;if(bt==="bars"){P=b.addBarSeries({upColor:"#26A69A",downColor:"#EF5350",borderUpColor:"#26A69A",borderDownColor:"#EF5350",scaleMargins:{top:.1,bottom:.1}});const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&P.setData(C)}else if(bt==="line"){P=b.addLineSeries({color:"#38bdf8",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const C=Ot(It);C.length>0&&P.setData(C)}else if(bt==="area"){P=b.addAreaSeries({lineColor:"#38bdf8",topColor:"rgba(56,189,248,0.4)",bottomColor:"rgba(56,189,248,0.0)",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const C=Ot(It);C.length>0&&P.setData(C)}else if(bt==="volume ticks"||bt==="volume"){P=b.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,priceScaleId:"right"});const C=[...I].sort((ct,L)=>ct.time-L.time);C.length>0&&P.setData(C);const V=b.addHistogramSeries({priceFormat:{type:"volume"},priceScaleId:"vol",base:0,priceLineVisible:!1,lastValueVisible:!1,color:"rgba(38,166,154,0.15)"});b.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.3}}),b.priceScale("vol").applyOptions({scaleMargins:{top:.75,bottom:0},visible:!1});const W=C.map(ct=>({time:ct.time,value:ct.volume||0,color:ct.close>=ct.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));W.length>0&&V.setData(W),c.current=V}else{P=b.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,scaleMargins:{top:.1,bottom:.1}});const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&P.setData(C)}if(a.current=P,_&&tt.current)setTimeout(()=>{try{y.setVisibleRange(_),dt(_)}catch{if(I.length>0)try{const V=I[I.length-1].time,W=V-6e3;y.setVisibleRange({from:W,to:V}),dt(y.getVisibleRange())}catch{y.fitContent(),dt(y.getVisibleRange())}}try{b.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}},0);else if(!tt.current){y.fitContent();try{b.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,dt(y.getVisibleRange())}},[bt,I.length,It.length]),E.useEffect(()=>{const b=l.current,y=c.current;if(!b||!y||!tt.current||I.length===0||bt!=="volume"&&bt!=="volume ticks")return;const P=[...I].sort((C,V)=>C.time-V.time).map(C=>({time:C.time,value:C.volume||0,color:C.close>=C.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));P.length>0&&y.setData(P)},[I,bt]),E.useEffect(()=>{const b=l.current,y=a.current,_=h.current;if(!b||!y||!_)return;const C=et!==null?[null,null,"trendline","parallellines","fibonacci","rectangle","pricelevel","text",null,null,null,null,null,null,null,null,null][et]:null;if(!C){if(p.current=!1,g.current=null,d.current=null,m.current=null,f.current?.series)try{b.removeSeries(f.current.series)}catch{}f.current=null;return}if(C==="pricelevel"){const L=F=>{const it=_.getBoundingClientRect(),q=F.clientX-it.left,T=F.clientY-it.top,z=b.timeScale().coordinateToTime(q),x=y.coordinateToPrice(T);if(z==null||x==null)return;const A={type:"pricelevel",priceLine:y.createPriceLine({price:x,color:"#3b82f6",lineWidth:2,lineStyle:2,axisLabelVisible:!0,title:x.toFixed(5)}),price:x};mt(H=>[...H,A]),u.current.push(A)};return _.addEventListener("click",L),()=>{_.removeEventListener("click",L)}}if(C==="trendline"){const L=T=>{T.preventDefault(),T.stopPropagation(),T.stopImmediatePropagation();const z=_.getBoundingClientRect(),x=T.clientX-z.left,D=T.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(!(A==null||H==null)&&(A=Tt(A),A!=null))if(m.current===null){m.current={time:A,price:H};const O=b.addLineSeries({color:"#22c55e",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"trendline",series:O},O.setData([{time:A,value:H}])}else{const O=m.current,B={time:A,price:H},j=1,ut=1e-5,Z=Math.abs(B.time-O.time),pt=Math.abs(B.price-O.price);if(Z<j&&pt<ut){try{b.removeSeries(f.current.series)}catch{}m.current=null,f.current=null;return}const ie={time:O.time,price:O.price},se={time:B.time,price:B.price},qt=Ot([{time:ie.time,value:ie.price},{time:se.time,value:se.price}]);if(qt.length>0){f.current.series.setData(qt);const ue={type:"trendline",series:f.current.series,point1:ie,point2:se};mt(we=>[...we,ue]),u.current.push(ue)}ot(null),m.current=null,f.current=null}},F=T=>{if(m.current===null||f.current?.type!=="trendline")return;T.preventDefault(),T.stopPropagation();const z=_.getBoundingClientRect(),x=T.clientX-z.left,D=T.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(A==null||H==null||(A=Tt(A),A==null))return;const O=m.current,B=Ot([{time:O.time,value:O.price},{time:A,value:H}]);B.length>0&&f.current.series.setData(B)},it=T=>{T.stopPropagation()},q={capture:!0,passive:!1};return _.addEventListener("click",L,q),_.addEventListener("mousemove",F,q),_.addEventListener("mousemove",it,q),()=>{if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{b.removeSeries(f.current.series)}catch{}f.current=null}_.removeEventListener("click",L,q),_.removeEventListener("mousemove",F,q),_.removeEventListener("mousemove",it,q)}}if(C==="parallellines"){const L={capture:!0,passive:!1},F=x=>{x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation();const D=_.getBoundingClientRect(),A=x.clientX-D.left,H=x.clientY-D.top;let O=b.timeScale().coordinateToTime(A);const B=y.coordinateToPrice(H);if(O==null||B==null||(O=Tt(O),O==null))return;const j={time:O,price:B},ut=w.current;if(ut.length===0){w.current=[j];const Z=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});Z.setData([{time:O,value:B}]),f.current={type:"parallellines",series:Z,previewLine:null}}else if(ut.length===1){w.current=[ut[0],j];const Z=Ot([{time:ut[0].time,value:ut[0].price},{time:O,value:B}]);Z.length>0&&f.current.series.setData(Z),f.current.previewLine=b.addLineSeries({color:"#8b5cf6",lineWidth:2,lineStyle:2,priceLineVisible:!1,lastValueVisible:!1});const pt=Zs(b,y,ut[0],j,j);pt&&f.current.previewLine.setData(Ot([{time:pt[0].time,value:pt[0].price},{time:pt[1].time,value:pt[1].price}]))}else{const[Z,pt]=ut,ie=j;if(f.current?.previewLine){try{b.removeSeries(f.current.previewLine)}catch{}f.current.previewLine=null}const se=f.current?.series;if(!se)return;const qt=Zs(b,y,Z,pt,ie);if(!qt)return;const ue=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});se.setData(Ot([{time:Z.time,value:Z.price},{time:pt.time,value:pt.price}])),ue.setData(Ot([{time:qt[0].time,value:qt[0].price},{time:qt[1].time,value:qt[1].price}]));const we={type:"parallellines",point1:Z,point2:pt,point3:ie,baseLine:se,parallelLine:ue};mt(Ge=>[...Ge,we]),u.current.push(we),ot(null),w.current=[],f.current=null}},it=x=>{const D=w.current;if(D.length!==1||!f.current?.series)return;const A=_.getBoundingClientRect(),H=x.clientX-A.left,O=x.clientY-A.top;let B=b.timeScale().coordinateToTime(H);const j=y.coordinateToPrice(O);if(B==null||j==null||(B=Tt(B),B==null))return;const ut=Ot([{time:D[0].time,value:D[0].price},{time:B,value:j}]);ut.length>0&&f.current.series.setData(ut)},q=x=>{const D=w.current;if(D.length!==2||!f.current?.previewLine)return;const A=_.getBoundingClientRect(),H=x.clientX-A.left,O=x.clientY-A.top;let B=b.timeScale().coordinateToTime(H);const j=y.coordinateToPrice(O);if(B==null||j==null||(B=Tt(B),B==null))return;const ut={time:B,price:j},Z=Zs(b,y,D[0],D[1],ut);Z&&f.current.previewLine.setData(Ot([{time:Z[0].time,value:Z[0].price},{time:Z[1].time,value:Z[1].price}]))},T=x=>{it(x),q(x)},z=x=>{x.stopPropagation()};return _.addEventListener("click",F,L),_.addEventListener("mousemove",T,L),_.addEventListener("mousemove",z,L),()=>{if(w.current=[],f.current?.type==="parallellines"){try{f.current.series&&b.removeSeries(f.current.series),f.current.previewLine&&b.removeSeries(f.current.previewLine)}catch{}f.current=null}_.removeEventListener("click",F,L),_.removeEventListener("mousemove",T,L),_.removeEventListener("mousemove",z,L)}}if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{b.removeSeries(f.current.series)}catch{}f.current=null}const V=L=>{if(L.preventDefault(),L.stopPropagation(),L.stopImmediatePropagation(),C==="trendline"||C==="parallellines"||C!=="rectangle"&&C!=="fibonacci")return;const F=_.getBoundingClientRect(),it=L.clientX-F.left,q=L.clientY-F.top;let T=b.timeScale().coordinateToTime(it);const z=y.coordinateToPrice(q);if(!(T==null||z==null)&&(T=Tt(T),T!=null)){if(p.current=!0,g.current={time:T,price:z},d.current=null,C==="rectangle"){const x=b.addBaselineSeries({baseValue:{type:"price",price:z},topLineColor:"#2563eb",bottomLineColor:"#2563eb",topFillColor1:"rgba(59, 130, 246, 0.38)",topFillColor2:"rgba(59, 130, 246, 0.22)",bottomFillColor1:"rgba(59, 130, 246, 0.22)",bottomFillColor2:"rgba(59, 130, 246, 0.38)",priceLineVisible:!1,lastValueVisible:!1,lineWidth:2,lineStyle:0});f.current={type:"rectangle",series:x}}if(C==="fibonacci"){const x=b.addLineSeries({color:"#f59e0b",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"fibonacci",series:x,priceLines:[]}}if(C==="parallellines"){const x=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"parallellines",series:x,firstLine:null,secondLine:null}}}},W=L=>{if(!p.current||!g.current||!f.current)return;L.preventDefault(),L.stopPropagation(),L.stopImmediatePropagation();const F=_.getBoundingClientRect(),it=L.clientX-F.left,q=L.clientY-F.top;let T=b.timeScale().coordinateToTime(it);const z=y.coordinateToPrice(q);if(T==null||z==null||(T=Tt(T),T==null))return;d.current={time:T,price:z};const x=g.current;if(f.current.type==="rectangle"){const D=Math.max(x.price,z),A=Math.min(x.price,z),H=Tt(Math.min(x.time,T)),O=Tt(Math.max(x.time,T));if(H==null||O==null||Math.abs(O-H)<1||Math.abs(D-A)<1e-5)return;const B=f.current.series;B.setData(Ot([{time:H,value:D},{time:O,value:D}])),B.applyOptions({baseValue:{type:"price",price:A}})}if(f.current.type==="fibonacci"){const D=[{time:x.time,value:x.price},{time:T,value:z}],A=Ot(D);A.length>0&&f.current.series.setData(A),d.current={time:T,price:z},f.current.priceLines&&(f.current.priceLines.forEach(H=>{try{y.removePriceLine(H)}catch{}}),f.current.priceLines=[])}if(f.current.type==="parallellines")if(f.current.firstLine){const D=f.current.firstLine;D.endTime-D.startTime;const A=D.endPrice-D.startPrice,H=z,O=H+A;if(f.current.secondLine)f.current.secondLine.setData([{time:x.time,value:H},{time:T,value:O}]);else{const B=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});B.setData([{time:x.time,value:H},{time:T,value:O}]),f.current.secondLine=B}}else f.current.series.setData([{time:x.time,value:x.price},{time:T,value:z}])},ct=L=>{if(L&&(L.preventDefault(),L.stopPropagation()),!p.current||!f.current||!g.current)return;const F=g.current,it=d.current||F;if(f.current.type==="parallellines")if(f.current.firstLine){const q={type:"parallellines",firstLine:f.current.series,secondLine:f.current.secondLine,firstLineData:f.current.firstLine};mt(T=>[...T,q]),u.current.push(q),ot(null),f.current=null,p.current=!1,g.current=null,d.current=null;return}else{f.current.firstLine={startTime:F.time,startPrice:F.price,endTime:it.time,endPrice:it.price},p.current=!1,g.current=null,d.current=null;return}if(f.current.type==="fibonacci"){const T=(d.current||F).price;if(Math.abs(F.price-T)<1e-4){try{b.removeSeries(f.current.series)}catch{}p.current=!1,g.current=null,d.current=null,f.current=null;return}const z=Math.max(F.price,T),x=Math.min(F.price,T),D=z-x,A=[{level:0,label:"0.0%"},{level:.236,label:"23.6%"},{level:.382,label:"38.2%"},{level:.5,label:"50.0%"},{level:.618,label:"61.8%"},{level:.786,label:"78.6%"},{level:1,label:"100.0%"}],H=[],O=f.current.series;try{b.removeSeries(O)}catch{}A.forEach(({level:j,label:ut})=>{const Z=z-D*j,pt=y.createPriceLine({price:Z,color:j===0||j===1?"#f59e0b":"#fbbf24",lineWidth:j===0||j===1?2:1,lineStyle:j===0||j===1?0:2,axisLabelVisible:!0,title:`${ut} (${Z.toFixed(5)})`,textColor:j===0||j===1?"#f59e0b":"#fbbf24"});H.push(pt)});const B={type:"fibonacci",priceLines:H,startPrice:F.price,endPrice:T,high:z,low:x};mt(j=>[...j,B]),u.current.push(B),ot(null)}if(f.current.type==="rectangle"){const q=g.current,T=d.current||q,z=Math.max(q.price,T.price),x=Math.min(q.price,T.price),D=Tt(Math.min(q.time,T.time)),A=Tt(Math.max(q.time,T.time));if(D!=null&&A!=null&&Math.abs(A-D)>=1&&Math.abs(z-x)>=1e-5){const H=f.current.series;H.setData(Ot([{time:D,value:z},{time:A,value:z}])),H.applyOptions({baseValue:{type:"price",price:x}});const O={type:"rectangle",timeStart:D,timeEnd:A,priceTop:z,priceBottom:x,series:H};mt(B=>[...B,O]),u.current.push(O),ot(null)}else try{b.removeSeries(f.current.series)}catch{}}p.current=!1,g.current=null,d.current=null,f.current=null};if(C==="rectangle"||C==="fibonacci"||C==="parallellines"){const L={capture:!0,passive:!1},F=it=>{p.current||it.stopPropagation()};return _.addEventListener("mousedown",V,L),_.addEventListener("mousemove",W,L),_.addEventListener("mousemove",F,L),_.addEventListener("mouseup",ct,L),()=>{_.removeEventListener("mousedown",V,L),_.removeEventListener("mousemove",W,L),_.removeEventListener("mousemove",F,L),_.removeEventListener("mouseup",ct,L)}}},[et,mt,ot]),E.useEffect(()=>{const b=l.current,y=a.current,_=h.current,P=et===null||et===1;if(!P||!b||!y||!_){P||(R(null),$([]));return}const C=10,V=8;function W(q,T){const z=wt.filter(x=>x.type==="trendline"&&x.point1&&x.point2);for(let x=z.length-1;x>=0;x--){const D=z[x],A=b.timeScale().timeToCoordinate(D.point1.time),H=y.priceToCoordinate(D.point1.price),O=b.timeScale().timeToCoordinate(D.point2.time),B=y.priceToCoordinate(D.point2.price);if(A==null||H==null||O==null||B==null)continue;const j=Math.hypot(q-A,T-H),ut=Math.hypot(q-O,T-B);if(j<C)return{object:D,mode:"handle1"};if(ut<C)return{object:D,mode:"handle2"};if(Uu(q,T,A,H,O,B)<V)return{object:D,mode:"line"}}return null}const ct=q=>{q.preventDefault(),q.stopPropagation();const T=_.getBoundingClientRect(),z=q.clientX-T.left,x=q.clientY-T.top,D=W(z,x);D?(R(D.object),Q.current=D.mode,D.mode==="line"&&(G.current={x:z,y:x,point1:{...D.object.point1},point2:{...D.object.point2}})):(R(null),Q.current=null)},L=q=>{if(!Q.current)return;const T=st.current;if(!T||!T.point1||!T.point2)return;const z=_.getBoundingClientRect(),x=q.clientX-z.left,D=q.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(!(A==null||H==null)&&(A=Tt(A),A!=null)){if(Q.current==="handle1"){const O={time:A,price:H},B=Ot([{time:O.time,value:O.price},{time:T.point2.time,value:T.point2.price}]);B.length>0&&T.series.setData(B);const j={...T,point1:O};mt(ut=>{const Z=ut.map(pt=>pt===T?j:pt);return u.current=Z,Z}),R(j),st.current=j}else if(Q.current==="handle2"){const O={time:A,price:H},B=Ot([{time:T.point1.time,value:T.point1.price},{time:O.time,value:O.price}]);B.length>0&&T.series.setData(B);const j={...T,point2:O};mt(ut=>{const Z=ut.map(pt=>pt===T?j:pt);return u.current=Z,Z}),R(j),st.current=j}else if(Q.current==="line"){const O=G.current;if(!O)return;const B=b.timeScale().coordinateToTime(O.x),j=y.coordinateToPrice(O.y);if(B==null||j==null)return;const ut=A-B,Z=H-j,pt={time:Tt(O.point1.time+ut),price:O.point1.price+Z},ie={time:Tt(O.point2.time+ut),price:O.point2.price+Z},se=Ot([{time:pt.time,value:pt.price},{time:ie.time,value:ie.price}]);se.length>0&&T.series.setData(se);const qt={...T,point1:pt,point2:ie};mt(ue=>{const we=ue.map(Ge=>Ge===T?qt:Ge);return u.current=we,we}),R(qt),st.current=qt}}},F=()=>{Q.current=null,G.current=null},it={capture:!0,passive:!1};return _.addEventListener("mousedown",ct,it),_.addEventListener("mousemove",L,it),_.addEventListener("mouseup",F,it),()=>{_.removeEventListener("mousedown",ct,it),_.removeEventListener("mousemove",L,it),_.removeEventListener("mouseup",F,it)}},[et,wt,mt]),E.useEffect(()=>{const b=l.current,y=a.current;if(!b||!y)return;const _=()=>{const C=M;if(!C||C.type!=="trendline"||!C.point1||!C.point2){$([]);return}const V=b.timeScale(),W=V.timeToCoordinate(C.point1.time),ct=y.priceToCoordinate(C.point1.price),L=V.timeToCoordinate(C.point2.time),F=y.priceToCoordinate(C.point2.price);W!=null&&ct!=null&&L!=null&&F!=null?$([{x:W,y:ct},{x:L,y:F}]):$([])};_();const P=b.timeScale();return P.subscribeVisibleTimeRangeChange(_),()=>{P.unsubscribeVisibleTimeRangeChange(_)}},[M]),E.useEffect(()=>{!l.current||!a.current||u.current.forEach(b=>{b.series&&b.series.applyOptions({visible:St}),b.priceLine&&b.priceLine.applyOptions(St?{color:"#3b82f6",axisLabelVisible:!0,title:typeof b.price=="number"?b.price.toFixed(5):""}:{color:"rgba(0,0,0,0)",axisLabelVisible:!1,title:""}),b.type==="fibonacci"&&b.priceLines&&b.priceLines.forEach(y=>{try{y.applyOptions({lineVisible:St,axisLabelVisible:St})}catch{}}),b.type==="rectangle"&&b.series&&b.series.applyOptions({visible:St}),b.type==="parallellines"&&(b.baseLine&&b.baseLine.applyOptions({visible:St}),b.parallelLine&&b.parallelLine.applyOptions({visible:St}),b.firstLine&&b.firstLine.applyOptions({visible:St}),b.secondLine&&b.secondLine.applyOptions({visible:St}))})},[St,wt]),E.useEffect(()=>{!St&&M&&(R(null),$([]))},[St,M]),E.useEffect(()=>{if(u.current.length>wt.length){const b=u.current.filter((y,_)=>!wt.includes(y));M&&b.some(y=>y===M)&&(R(null),$([])),b.forEach(y=>{if(y.series&&l.current?.removeSeries(y.series),y.priceLine&&a.current?.removePriceLine(y.priceLine),y.type==="fibonacci"&&y.priceLines&&y.priceLines.forEach(_=>{try{a.current?.removePriceLine(_)}catch{}}),y.type==="rectangle"&&y.series)try{l.current?.removeSeries(y.series)}catch{}if(y.type==="parallellines")try{y.baseLine&&l.current?.removeSeries(y.baseLine),y.parallelLine&&l.current?.removeSeries(y.parallelLine),y.firstLine&&l.current?.removeSeries(y.firstLine),y.secondLine&&l.current?.removeSeries(y.secondLine)}catch{}}),u.current=wt}},[wt,M]),E.useEffect(()=>{const b=a.current;return b?(X.current.forEach(_=>{try{b.removePriceLine(_)}catch{}}),X.current=[],gt.filter(_=>_.symbol===J).forEach(_=>{const P=parseFloat(_.price);if(isNaN(P))return;const V=_.type==="BUY"?"#26A69A":"#EF5350",W=b.createPriceLine({price:P,color:V,lineWidth:2,lineStyle:0,axisLabelVisible:!0,title:`${_.type} ${_.volume} @ ${_.price}`,textColor:V});X.current.push(W)}),()=>{X.current.forEach(_=>{try{b.removePriceLine(_)}catch{}}),X.current=[]}):void 0},[gt,J]),ne.jsx("div",{className:"flex-1 flex flex-col bg-primary min-w-0 overflow-hidden",children:ne.jsx("div",{ref:h,className:"flex-1 w-full h-full relative",style:{cursor:et===1||et!==null?"crosshair":"default",minHeight:0,minWidth:0},onDoubleClick:b=>{l.current&&!p.current&&(b.preventDefault(),b.stopPropagation(),l.current.timeScale().fitContent(),dt(l.current.timeScale().getVisibleRange()))},children:St&&M?.type==="trendline"&&M?.point1&&M?.point2&&k.length===2&&ne.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none","aria-hidden":!0,children:k.map((b,y)=>ne.jsx("div",{className:"absolute w-[10px] h-[10px] rounded-full border-2 border-white bg-[#22c55e] shadow",style:{left:b.x-5,top:b.y-5}},y))})})})}),Wu="1.0.0";rt.Chart=Vu,rt.SYMBOL_CONFIG=Eo,rt.TradingProvider=Ru,rt.alignToTimeframe=Oe,rt.detectGaps=Ou,rt.getSymbolConfig=Ye,rt.is24x7Symbol=Du,rt.isCryptoSymbol=Ys,rt.isForexSymbol=Au,rt.isWithinTradingSession=ku,rt.normalizeCandleTimes=To,rt.normalizeTime=Tt,rt.processCandles=Ro,rt.processSingleCandle=Oo,rt.setChartBaseUrl=Po,rt.setSocketBaseUrl=wo,rt.timeframeToSeconds=Gs,rt.useTrading=_o,rt.validateTimeOrdering=Pu,rt.version=Wu,Object.defineProperty(rt,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(st,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],L):(st=typeof globalThis<"u"?globalThis:st||self,L(st.ChartSDK={},st.jsxRuntime,st.React))})(this,(function(st,L,x){"use strict";var Wi=typeof document<"u"?document.currentScript:null;function ft(s){var t=s.width,e=s.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(e<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:e}}function be(s,t){return s.width===t.width&&s.height===t.height}var Jo=(function(){function s(t){var e=this;this._resolutionListener=function(){return e._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return s.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(s.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),s.prototype.subscribe=function(t){var e=this,i={next:t};return this._observers.push(i),{unsubscribe:function(){e._observers=e._observers.filter(function(n){return n!==i})}}},s.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},s.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},s.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},s.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(e){return e.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},s})();function Go(s){return new Jo(s)}var Yo=(function(){function s(t,e,i){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=ft({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=e??(function(r){return r}),this._allowResizeObserver=(n=i?.allowResizeObserver)!==null&&n!==void 0?n:!0,this._chooseAndInitObserver()}return s.prototype.dispose=function(){var t,e;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(e=this._devicePixelRatioObservable)===null||e===void 0||e.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(s.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"bitmapSize",{get:function(){return ft({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),s.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=ft(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},s.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(e){return e!==t})},Object.defineProperty(s.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),s.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(e){return e!==t})},s.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},s.prototype._resizeBitmap=function(t){var e=this.bitmapSize;be(e,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(e,t))},s.prototype._emitBitmapSizeChanged=function(t,e){var i=this;this._bitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._suggestNewBitmapSize=function(t){var e=this._suggestedBitmapSize,i=ft(this._transformBitmapSize(t,this._canvasElementClientSize)),n=be(this.bitmapSize,i)?null:i;e===null&&n===null||e!==null&&n!==null&&be(e,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(e,n))},s.prototype._emitSuggestedBitmapSizeChanged=function(t,e){var i=this;this._suggestedBitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}Zo().then(function(e){return e?t._initResizeObserver():t._initDevicePixelRatioObservable()})},s.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var e=on(this._canvasElement);if(e===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=Go(e),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},s.prototype._invalidateBitmapSize=function(){var t,e;if(this._canvasElement!==null){var i=on(this._canvasElement);if(i!==null){var n=(e=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&e!==void 0?e:i.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?tl(r[0],n):ft({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(o)}}},s.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(e){var i=e.find(function(o){return o.target===t._canvasElement});if(!(!i||!i.devicePixelContentBoxSize||!i.devicePixelContentBoxSize[0])){var n=i.devicePixelContentBoxSize[0],r=ft({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},s})();function Qo(s,t){return new Yo(s,t.transform,t.options)}function on(s){return s.ownerDocument.defaultView}function Zo(){return new Promise(function(s){var t=new ResizeObserver(function(e){s(e.every(function(i){return"devicePixelContentBoxSize"in i})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function tl(s,t){return ft({width:Math.round(s.left*t+s.width*t)-Math.round(s.left*t),height:Math.round(s.top*t+s.height*t)-Math.round(s.top*t)})}var el=(function(){function s(t,e,i){if(e.width===0||e.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=e,i.width===0||i.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=i,this._context=t}return s.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},s.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(s.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),s})();function ve(s,t){var e=s.canvasElementClientSize;if(e.width===0||e.height===0)return null;var i=s.bitmapSize;if(i.width===0||i.height===0)return null;var n=s.canvasElement.getContext("2d",t);return n===null?null:new el(n,e,i)}const il={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},sl={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},nl={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},rl={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},ol={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},ll={color:"#26a69a",base:0},ln={color:"#2196f3"},hn={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 an,cn;function ye(s,t){const e={0:[],1:[s.lineWidth,s.lineWidth],2:[2*s.lineWidth,2*s.lineWidth],3:[6*s.lineWidth,6*s.lineWidth],4:[s.lineWidth,4*s.lineWidth]}[t];s.setLineDash(e)}function un(s,t,e,i){s.beginPath();const n=s.lineWidth%2?.5:0;s.moveTo(e,t+n),s.lineTo(i,t+n),s.stroke()}function de(s,t){if(!s)throw new Error("Assertion failed"+(t?": "+t:""))}function Bt(s){if(s===void 0)throw new Error("Value is undefined");return s}function C(s){if(s===null)throw new Error("Value is null");return s}function Me(s){return C(Bt(s))}(function(s){s[s.Simple=0]="Simple",s[s.WithSteps=1]="WithSteps",s[s.Curved=2]="Curved"})(an||(an={})),(function(s){s[s.Solid=0]="Solid",s[s.Dotted=1]="Dotted",s[s.Dashed=2]="Dashed",s[s.LargeDashed=3]="LargeDashed",s[s.SparseDotted=4]="SparseDotted"})(cn||(cn={}));const fn={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 qt(s){return s<0?0:s>255?255:Math.round(s)||0}function dn(s){return s<=0||s>1?Math.min(Math.max(s,0),1):Math.round(1e4*s)/1e4}const hl=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,al=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,cl=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,ul=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d*\.?\d+)\s*\)$/;function Ve(s){(s=s.toLowerCase())in fn&&(s=fn[s]);{const t=ul.exec(s)||cl.exec(s);if(t)return[qt(parseInt(t[1],10)),qt(parseInt(t[2],10)),qt(parseInt(t[3],10)),dn(t.length<5?1:parseFloat(t[4]))]}{const t=al.exec(s);if(t)return[qt(parseInt(t[1],16)),qt(parseInt(t[2],16)),qt(parseInt(t[3],16)),1]}{const t=hl.exec(s);if(t)return[qt(17*parseInt(t[1],16)),qt(17*parseInt(t[2],16)),qt(17*parseInt(t[3],16)),1]}throw new Error(`Cannot parse color: ${s}`)}function pn(s){return .199*s[0]+.687*s[1]+.114*s[2]}function oi(s){const t=Ve(s);return{t:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,i:pn(t)>160?"black":"white"}}class xt{constructor(){this.h=[]}l(t,e,i){const n={o:t,_:e,u:i===!0};this.h.push(n)}v(t){const e=this.h.findIndex((i=>t===i.o));e>-1&&this.h.splice(e,1)}p(t){this.h=this.h.filter((e=>e._!==t))}m(t,e,i){const n=[...this.h];this.h=this.h.filter((r=>!r.u)),n.forEach((r=>r.o(t,e,i)))}M(){return this.h.length>0}S(){this.h=[]}}function Gt(s,...t){for(const e of t)for(const i in e)e[i]!==void 0&&Object.prototype.hasOwnProperty.call(e,i)&&!["__proto__","constructor","prototype"].includes(i)&&(typeof e[i]!="object"||s[i]===void 0||Array.isArray(e[i])?s[i]=e[i]:Gt(s[i],e[i]));return s}function te(s){return typeof s=="number"&&isFinite(s)}function Fe(s){return typeof s=="number"&&s%1==0}function $e(s){return typeof s=="string"}function li(s){return typeof s=="boolean"}function ue(s){const t=s;if(!t||typeof t!="object")return t;let e,i,n;for(i in e=Array.isArray(t)?[]:{},t)t.hasOwnProperty(i)&&(n=t[i],e[i]=n&&typeof n=="object"?ue(n):n);return e}function fl(s){return s!==null}function Ie(s){return s===null?void 0:s}const qi="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function ke(s,t,e){return t===void 0&&(t=qi),`${e=e!==void 0?`${e} `:""}${s}px ${t}`}class dl{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=ke(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 Hi{constructor(){this.Y=[]}Z(t){this.Y=t}X(t,e,i){this.Y.forEach((n=>{n.X(t,e,i)}))}}class Yt{X(t,e,i){t.useBitmapCoordinateSpace((n=>this.K(n,e,i)))}}class pl extends Yt{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.G===null||this.G.tt===null)return;const n=this.G.tt,r=this.G,o=Math.max(1,Math.floor(e))%2/2,l=h=>{t.beginPath();for(let a=n.to-1;a>=n.from;--a){const c=r.it[a],u=Math.round(c.nt*e)+o,p=c.st*i,m=h*i+o;t.moveTo(u,p),t.arc(u,p,m,0,2*Math.PI)}t.fill()};r.et>0&&(t.fillStyle=r.rt,l(r.ht+r.et)),t.fillStyle=r.lt,l(r.ht)}}function ml(){return{it:[{nt:0,st:0,ot:0,_t:0}],lt:"",rt:"",ht:0,et:0,tt:null}}const gl={from:0,to:1};class bl{constructor(t,e){this.ut=new Hi,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(ml),this.ct=this.dt.map((i=>{const n=new pl;return n.J(i),n})),this.ut.Z(this.ct)),this.ft=!0}gt(){return this.ft&&(this.Mt(),this.ft=!1),this.ut}Mt(){const t=this.vt.W().mode===2,e=this.F.wt(),i=this.vt.xt(),n=this.F.St();e.forEach(((r,o)=>{var l;const h=this.dt[o],a=r.kt(i);if(t||a===null||!r.yt())return void(h.tt=null);const c=C(r.Ct());h.lt=a.Tt,h.ht=a.ht,h.et=a.Pt,h.it[0]._t=a._t,h.it[0].st=r.Dt().Rt(a._t,c.Vt),h.rt=(l=a.Ot)!==null&&l!==void 0?l:this.F.Bt(h.it[0].st/r.Dt().At()),h.it[0].ot=i,h.it[0].nt=n.It(i),h.tt=gl}))}}class vl extends Yt{constructor(t){super(),this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.zt===null)return;const r=this.zt.Lt.yt,o=this.zt.Et.yt;if(!r&&!o)return;const l=Math.round(this.zt.nt*i),h=Math.round(this.zt.st*n);t.lineCap="butt",r&&l>=0&&(t.lineWidth=Math.floor(this.zt.Lt.et*i),t.strokeStyle=this.zt.Lt.V,t.fillStyle=this.zt.Lt.V,ye(t,this.zt.Lt.Nt),(function(a,c,u,p){a.beginPath();const m=a.lineWidth%2?.5:0;a.moveTo(c+m,u),a.lineTo(c+m,p),a.stroke()})(t,l,0,e.height)),o&&h>=0&&(t.lineWidth=Math.floor(this.zt.Et.et*n),t.strokeStyle=this.zt.Et.V,t.fillStyle=this.zt.Et.V,ye(t,this.zt.Et.Nt),un(t,h,0,e.width))}}class yl{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 vl(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=C(this.jt.Ht()),i=e.$t().W().crosshair,n=this.Ft;if(i.mode===2)return n.Et.yt=!1,void(n.Lt.yt=!1);n.Et.yt=t&&this.jt.Ut(e),n.Lt.yt=t&&this.jt.qt(),n.Et.et=i.horzLine.width,n.Et.Nt=i.horzLine.style,n.Et.V=i.horzLine.color,n.Lt.et=i.vertLine.width,n.Lt.Nt=i.vertLine.style,n.Lt.V=i.vertLine.color,n.nt=this.jt.Yt(),n.st=this.jt.Zt()}}function wl(s,t,e,i,n,r){s.fillRect(t+r,e,i-2*r,r),s.fillRect(t+r,e+n-r,i-2*r,r),s.fillRect(t,e,r,n),s.fillRect(t+i-r,e,r,n)}function hi(s,t,e,i,n,r){s.save(),s.globalCompositeOperation="copy",s.fillStyle=r,s.fillRect(t,e,i,n),s.restore()}function mn(s,t,e,i,n,r){s.beginPath(),s.roundRect?s.roundRect(t,e,i,n,r):(s.lineTo(t+i-r[1],e),r[1]!==0&&s.arcTo(t+i,e,t+i,e+r[1],r[1]),s.lineTo(t+i,e+n-r[2]),r[2]!==0&&s.arcTo(t+i,e+n,t+i-r[2],e+n,r[2]),s.lineTo(t+r[3],e+n),r[3]!==0&&s.arcTo(t,e+n,t,e+n-r[3],r[3]),s.lineTo(t,e+r[0]),r[0]!==0&&s.arcTo(t,e,t+r[0],e,r[0]))}function gn(s,t,e,i,n,r,o=0,l=[0,0,0,0],h=""){if(s.save(),!o||!h||h===r)return mn(s,t,e,i,n,l),s.fillStyle=r,s.fill(),void s.restore();const a=o/2;var c;mn(s,t+a,e+a,i-o,n-o,(c=-a,l.map((u=>u===0?u:u+c)))),r!=="transparent"&&(s.fillStyle=r,s.fill()),h!=="transparent"&&(s.lineWidth=o,s.strokeStyle=h,s.closePath(),s.stroke()),s.restore()}function bn(s,t,e,i,n,r,o){s.save(),s.globalCompositeOperation="copy";const l=s.createLinearGradient(0,0,0,n);l.addColorStop(0,r),l.addColorStop(1,o),s.fillStyle=l,s.fillRect(t,e,i,n),s.restore()}class vn{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,n){if(!this.zt.yt||this.zt.Kt.length===0)return;const r=this.zt.V,o=this.Xt.t,l=t.useBitmapCoordinateSpace((h=>{const a=h.context;a.font=e.R;const c=this.Gt(h,e,i,n),u=c.Jt;return c.Qt?gn(a,u.ti,u.ii,u.ni,u.si,o,u.ei,[u.ht,0,0,u.ht],o):gn(a,u.ri,u.ii,u.ni,u.si,o,u.ei,[0,u.ht,u.ht,0],o),this.zt.hi&&(a.fillStyle=r,a.fillRect(u.ri,u.li,u.ai-u.ri,u.oi)),this.zt._i&&(a.fillStyle=e.O,a.fillRect(c.Qt?u.ui-u.ei:0,u.ii,u.ei,u.ci-u.ii)),c}));t.useMediaCoordinateSpace((({context:h})=>{const a=l.di;h.font=e.R,h.textAlign=l.Qt?"right":"left",h.textBaseline="middle",h.fillStyle=r,h.fillText(this.zt.Kt,a.fi,(a.ii+a.ci)/2+a.pi)}))}Gt(t,e,i,n){var r;const{context:o,bitmapSize:l,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:c}=t,u=this.zt.hi||!this.zt.mi?e.T:0,p=this.zt.bi?e.C:0,m=e.L+this.Xt.wi,d=e.B+this.Xt.gi,f=e.A,g=e.I,w=this.zt.Kt,y=e.P,_=i.Mi(o,w),k=Math.ceil(i.xi(o,w)),N=y+m+d,Z=e.C+f+g+k+u,B=Math.max(1,Math.floor(c));let G=Math.round(N*c);G%2!=B%2&&(G+=1);const tt=p>0?Math.max(1,Math.floor(p*a)):0,Ct=Math.round(Z*a),$=Math.round(u*a),at=(r=this.Xt.Si)!==null&&r!==void 0?r:this.Xt.ki,Rt=Math.round(at*c)-Math.floor(.5*c),bt=Math.floor(Rt+B/2-G/2),rt=bt+G,ot=n==="right",ct=ot?h.width-p:p,zt=ot?l.width-tt:tt;let Et,yt,wt;return ot?(Et=zt-Ct,yt=zt-$,wt=ct-u-f-p):(Et=zt+Ct,yt=zt+$,wt=ct+u+f),{Qt:ot,Jt:{ii:bt,li:Rt,ci:rt,ni:Ct,si:G,ht:2*a,ei:tt,ti:Et,ri:zt,ai:yt,oi:B,ui:l.width},di:{ii:bt/c,ci:rt/c,fi:wt,pi:_}}}}class ai{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||vn)(this.Ci,this.yi),this.Ri=new(t||vn)(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 Sl extends ai{constructor(t,e,i){super(),this.jt=t,this.Li=e,this.Ei=i}zi(t,e,i){if(t.yt=!1,this.jt.W().mode===2)return;const n=this.jt.W().horzLine;if(!n.labelVisible)return;const r=this.Li.Ct();if(!this.jt.yt()||this.Li.Ni()||r===null)return;const o=oi(n.labelBackgroundColor);i.t=o.t,t.V=o.i;const l=2/12*this.Li.P();i.wi=l,i.gi=l;const h=this.Ei(this.Li);i.ki=h.ki,t.Kt=this.Li.Fi(h._t,r),t.yt=!0}}const _l=/[1-9]/g;class yn{constructor(){this.zt=null}J(t){this.zt=t}X(t,e){if(this.zt===null||this.zt.yt===!1||this.zt.Kt.length===0)return;const i=t.useMediaCoordinateSpace((({context:p})=>(p.font=e.R,Math.round(e.Wi.xi(p,C(this.zt).Kt,_l)))));if(i<=0)return;const n=e.ji,r=i+2*n,o=r/2,l=this.zt.Hi;let h=this.zt.ki,a=Math.floor(h-o)+.5;a<0?(h+=Math.abs(0-a),a=Math.floor(h-o)+.5):a+r>l&&(h-=Math.abs(l-(a+r)),a=Math.floor(h-o)+.5);const c=a+r,u=Math.ceil(0+e.C+e.T+e.L+e.P+e.B);t.useBitmapCoordinateSpace((({context:p,horizontalPixelRatio:m,verticalPixelRatio:d})=>{const f=C(this.zt);p.fillStyle=f.t;const g=Math.round(a*m),w=Math.round(0*d),y=Math.round(c*m),_=Math.round(u*d),k=Math.round(2*m);if(p.beginPath(),p.moveTo(g,w),p.lineTo(g,_-k),p.arcTo(g,_,g+k,_,k),p.lineTo(y-k,_),p.arcTo(y,_,y,_-k,k),p.lineTo(y,w),p.fill(),f.hi){const N=Math.round(f.ki*m),Z=w,B=Math.round((Z+e.T)*d);p.fillStyle=f.V;const G=Math.max(1,Math.floor(m)),tt=Math.floor(.5*m);p.fillRect(N-tt,Z,G,B-Z)}})),t.useMediaCoordinateSpace((({context:p})=>{const m=C(this.zt),d=0+e.C+e.T+e.L+e.P/2;p.font=e.R,p.textAlign="left",p.textBaseline="middle",p.fillStyle=m.V;const f=e.Wi.Mi(p,"Apr0");p.translate(a+n,d+f),p.fillText(m.Kt,0,0)}))}}class xl{constructor(t,e,i){this.ft=!0,this.Wt=new yn,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,this.vt.W().mode===2)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 n=this.Ei();if(n===null)return;t.ki=n.ki;const r=i.Ui(this.vt.xt());t.Kt=i.qi(C(r)),t.yt=!0;const o=oi(e.labelBackgroundColor);t.t=o.t,t.V=o.i,t.hi=i.W().ticksVisible}}class ji{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 wn;(function(s){s[s.Normal=0]="Normal",s[s.Magnet=1]="Magnet",s[s.Hidden=2]="Hidden"})(wn||(wn={}));class Cl extends ji{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 bl(t,this),this.fn=((n,r)=>o=>{const l=r(),h=n();if(o===C(this.tn).vn())return{_t:h,ki:l};{const a=C(o.Ct());return{_t:o.pn(l,a),ki:l}}})((()=>this.nn),(()=>this.an));const i=((n,r)=>()=>{const o=this.$i.St().mn(n()),l=r();return o&&Number.isFinite(l)?{ot:o,ki:l}:null})((()=>this.sn),(()=>this.Yt()));this.bn=new xl(this,t,i),this.wn=new yl(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 this.tn!==null?[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 n=this.ln,r=this.an,o=this.nn,l=this.sn,h=this.tn,a=this.On(i);this.sn=t,this.ln=isNaN(t)?NaN:this.$i.St().It(t),this.tn=i;const c=a!==null?a.Ct():null;return a!==null&&c!==null?(this.nn=e,this.an=a.Rt(e,c)):(this.nn=NaN,this.an=NaN),n!==this.ln||r!==this.an||l!==this.sn||o!==this.nn||h!==this.tn}Tn(){const t=this.$i.wt().map((i=>i.In().An())).filter(fl),e=t.length===0?null:Math.max(...t);this.sn=e!==null?e:NaN}Dn(t,e,i){let n=t.get(e);return n===void 0&&(n=new Sl(this,e,i),t.set(e,n)),n}}function ci(s){return s==="left"||s==="right"}class Ot{constructor(t){this.zn=new Map,this.Ln=[],this.En=t}Nn(t,e){const i=(function(n,r){return n===void 0?r:{Fn:Math.max(n.Fn,r.Fn),Wn:n.Wn||r.Wn}})(this.zn.get(t),e);this.zn.set(t,i)}jn(){return this.En}Hn(t){const e=this.zn.get(t);return e===void 0?{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(((e,i)=>{this.Nn(i,e)}))}static ss(){return new Ot(2)}static es(){return new Ot(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((e=>e.qn===5));t!==-1&&this.Ln.splice(t,1)}}const Sn=".";function fe(s,t){if(!te(s))return"n/a";if(!Fe(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?s.toString():("0000000000000000"+s.toString()).slice(-t)}class ui{constructor(t,e){if(e||(e=1),te(t)&&Fe(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),n="";const r=this._s!==void 0?this._s:NaN;if(e>1){let o=+(Math.round(t*e)-i*e).toFixed(this._s);o>=e&&(o-=e,i+=1),n=Sn+fe(+o.toFixed(this._s)*this.rs,r)}else i=Math.round(i*e)/e,r>0&&(n=Sn+fe(0,r));return i.toFixed(0)+n}}class _n extends ui{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class El{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+$/,((n,r)=>r))}}function xn(s,t,e,i,n,r,o){if(t.length===0||i.from>=t.length||i.to<=0)return;const{context:l,horizontalPixelRatio:h,verticalPixelRatio:a}=s,c=t[i.from];let u=r(s,c),p=c;if(i.to-i.from<2){const m=n/2;l.beginPath();const d={nt:c.nt-m,st:c.st},f={nt:c.nt+m,st:c.st};l.moveTo(d.nt*h,d.st*a),l.lineTo(f.nt*h,f.st*a),o(s,u,d,f)}else{const m=(f,g)=>{o(s,u,p,g),l.beginPath(),u=f,p=g};let d=p;l.beginPath(),l.moveTo(c.nt*h,c.st*a);for(let f=i.from+1;f<i.to;++f){d=t[f];const g=r(s,d);switch(e){case 0:l.lineTo(d.nt*h,d.st*a);break;case 1:l.lineTo(d.nt*h,t[f-1].st*a),g!==u&&(m(g,d),l.lineTo(d.nt*h,t[f-1].st*a)),l.lineTo(d.nt*h,d.st*a);break;case 2:{const[w,y]=Tl(t,f-1,f);l.bezierCurveTo(w.nt*h,w.st*a,y.nt*h,y.st*a,d.nt*h,d.st*a);break}}e!==1&&g!==u&&(m(g,d),l.moveTo(d.nt*h,d.st*a))}(p!==d||p===d&&e===1)&&o(s,u,p,d)}}const Cn=6;function Ki(s,t){return{nt:s.nt-t.nt,st:s.st-t.st}}function En(s,t){return{nt:s.nt/t,st:s.st/t}}function Tl(s,t,e){const i=Math.max(0,t-1),n=Math.min(s.length-1,e+1);var r,o;return[(r=s[t],o=En(Ki(s[e],s[i]),Cn),{nt:r.nt+o.nt,st:r.st+o.st}),Ki(s[e],En(Ki(s[n],s[t]),Cn))]}function Ml(s,t,e,i,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;r.lineTo(n.nt*o,s*l),r.lineTo(i.nt*o,s*l),r.closePath(),r.fillStyle=e,r.fill()}class Tn extends Yt{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){var e;if(this.G===null)return;const{it:i,tt:n,ds:r,et:o,Nt:l,fs:h}=this.G,a=(e=this.G.vs)!==null&&e!==void 0?e:this.G.ps?0:t.mediaSize.height;if(n===null)return;const c=t.context;c.lineCap="butt",c.lineJoin="round",c.lineWidth=o,ye(c,l),c.lineWidth=1,xn(t,i,h,n,r,this.bs.bind(this),Ml.bind(null,a))}}function Xi(s,t,e){return Math.min(Math.max(s,t),e)}function fi(s,t,e){return t-s<=e}function Mn(s){const t=Math.ceil(s);return t%2==0?t-1:t}class Ji{ws(t,e){const i=this.gs,{Ms:n,xs:r,Ss:o,ks:l,ys:h,vs:a}=e;if(this.Cs===void 0||i===void 0||i.Ms!==n||i.xs!==r||i.Ss!==o||i.ks!==l||i.vs!==a||i.ys!==h){const c=t.context.createLinearGradient(0,0,0,h);if(c.addColorStop(0,n),a!=null){const u=Xi(a*t.verticalPixelRatio/h,0,1);c.addColorStop(u,r),c.addColorStop(u,o)}c.addColorStop(1,l),this.Cs=c,this.gs=e}return this.Cs}}class kl extends Tn{constructor(){super(...arguments),this.Ts=new Ji}bs(t,e){return this.Ts.ws(t,{Ms:e.Ps,xs:"",Ss:"",ks:e.Rs,ys:t.bitmapSize.height})}}function Ll(s,t){const e=s.context;e.strokeStyle=t,e.stroke()}class kn extends Yt{constructor(){super(...arguments),this.G=null}J(t){this.G=t}K(t){if(this.G===null)return;const{it:e,tt:i,ds:n,fs:r,et:o,Nt:l,Ds:h}=this.G;if(i===null)return;const a=t.context;a.lineCap="butt",a.lineWidth=o*t.verticalPixelRatio,ye(a,l),a.lineJoin="round";const c=this.Vs.bind(this);r!==void 0&&xn(t,e,r,i,n,c,Ll),h&&(function(u,p,m,d,f){const{horizontalPixelRatio:g,verticalPixelRatio:w,context:y}=u;let _=null;const k=Math.max(1,Math.floor(g))%2/2,N=m*w+k;for(let Z=d.to-1;Z>=d.from;--Z){const B=p[Z];if(B){const G=f(u,B);G!==_&&(y.beginPath(),_!==null&&y.fill(),y.fillStyle=G,_=G);const tt=Math.round(B.nt*g)+k,Ct=B.st*w;y.moveTo(tt,Ct),y.arc(tt,Ct,N,0,2*Math.PI)}}y.fill()})(t,e,h,i,c)}}class Ln extends kn{Vs(t,e){return e.lt}}function On(s,t,e,i,n=0,r=t.length){let o=r-n;for(;0<o;){const l=o>>1,h=n+l;i(t[h],e)===s?(n=h+1,o-=l+1):o=l}return n}const Ue=On.bind(null,!0),Rn=On.bind(null,!1);function Ol(s,t){return s.ot<t}function Rl(s,t){return t<s.ot}function zn(s,t,e){const i=t.Os(),n=t.ui(),r=Ue(s,i,Ol),o=Rn(s,n,Rl);if(!e)return{from:r,to:o};let l=r,h=o;return r>0&&r<s.length&&s[r].ot>=i&&(l=r-1),o>0&&o<s.length&&s[o-1].ot<=n&&(h=o+1),{from:l,to:h}}class Gi{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,t==="data"&&(this.As=!0),t==="options"&&(this.Is=!0)}gt(){return this.Es.yt()?(this.Ws(),this.Ls===null?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(i===null||this.Es.In().Ks()===0)return;const n=this.Es.Ct();n!==null&&(this.Ls=zn(this.zs,i,this.Fs),this.Gs(t,e,n.Vt),this.Js())}}class di extends Gi{constructor(t,e){super(t,e,!0)}Gs(t,e,i){e.Qs(this.zs,Ie(this.Ls)),t.te(this.zs,i,Ie(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 zl extends di{constructor(t,e){super(t,e),this.js=new Hi,this.re=new kl,this.he=new Ln,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 Nl extends Yt{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(this.zt===null||this.zt.In.length===0||this.zt.tt===null)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 n=null;const r=this.oe<=this.ae&&this.zt.le>=Math.floor(1.5*e);for(let o=this.zt.tt.from;o<this.zt.tt.to;++o){const l=this.zt.In[o];n!==l.ce&&(t.fillStyle=l.ce,n=l.ce);const h=Math.floor(.5*this.oe),a=Math.round(l.nt*e),c=a-h,u=this.oe,p=c+u-1,m=Math.min(l.de,l.fe),d=Math.max(l.de,l.fe),f=Math.round(m*i)-h,g=Math.round(d*i)+h,w=Math.max(g-f,this.oe);t.fillRect(c,f,u,w);const y=Math.ceil(1.5*this.ae);if(r){if(this.zt.ve){const Z=a-y;let B=Math.max(f,Math.round(l.pe*i)-h),G=B+u-1;G>f+w-1&&(G=f+w-1,B=G-u+1),t.fillRect(Z,B,c-Z,G-B+1)}const _=a+y;let k=Math.max(f,Math.round(l.me*i)-h),N=k+u-1;N>f+w-1&&(N=f+w-1,k=N-u+1),t.fillRect(p+1,k,_-p,N-k+1)}}}_e(t){const e=Math.floor(t);return Math.max(e,Math.floor((function(i,n){return Math.floor(.3*i*n)})(C(this.zt).le,t)))}}class Nn extends Gi{constructor(t,e){super(t,e,!1)}Gs(t,e,i){e.Qs(this.zs,Ie(this.Ls)),t.be(this.zs,i,Ie(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 Pl extends Nn{constructor(){super(...arguments),this.js=new Nl}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 Dl extends Tn{constructor(){super(...arguments),this.Ts=new Ji}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 Al extends kn{constructor(){super(...arguments),this.Pe=new Ji}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 Bl extends di{constructor(t,e){super(t,e),this.js=new Hi,this.Ve=new Dl,this.Oe=new Al,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(t===null)return;const e=this.Es.W(),i=this.Es.Dt().Rt(e.baseValue.price,t.Vt),n=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:n}),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:n})}}class Vl extends Yt{constructor(){super(...arguments),this.zt=null,this.ae=0}J(t){this.zt=t}K(t){if(this.zt===null||this.zt.In.length===0||this.zt.tt===null)return;const{horizontalPixelRatio:e}=t;this.ae=(function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const l=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),h=Math.floor(r*l*o),a=Math.floor(r*o),c=Math.min(h,a);return Math.max(Math.floor(o),c)})(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 n=this.ze(e);(!this.zt._i||this.ae>2*n)&&this.Le(t,i,this.zt.tt)}Ae(t,e,i){if(this.zt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="",h=Math.min(Math.floor(r),Math.floor(this.zt.le*r));h=Math.max(Math.floor(r),Math.min(h,this.ae));const a=Math.floor(.5*h);let c=null;for(let u=i.from;u<i.to;u++){const p=e[u];p.Ee!==l&&(n.fillStyle=p.Ee,l=p.Ee);const m=Math.round(Math.min(p.pe,p.me)*o),d=Math.round(Math.max(p.pe,p.me)*o),f=Math.round(p.de*o),g=Math.round(p.fe*o);let w=Math.round(r*p.nt)-a;const y=w+h-1;c!==null&&(w=Math.max(c+1,w),w=Math.min(w,y));const _=y-w+1;n.fillRect(w,f,_,m-f),n.fillRect(w,d+1,_,g-d),c=y}}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(this.zt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const h=this.ze(r);let a=null;for(let c=i.from;c<i.to;c++){const u=e[c];u.Ne!==l&&(n.fillStyle=u.Ne,l=u.Ne);let p=Math.round(u.nt*r)-Math.floor(.5*this.ae);const m=p+this.ae-1,d=Math.round(Math.min(u.pe,u.me)*o),f=Math.round(Math.max(u.pe,u.me)*o);if(a!==null&&(p=Math.max(a+1,p),p=Math.min(p,m)),this.zt.le*r>2*h)wl(n,p,d,m-p+1,f-d+1,h);else{const g=m-p+1;n.fillRect(p,d,g,f-d+1)}a=m}}Le(t,e,i){if(this.zt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const h=this.ze(r);for(let a=i.from;a<i.to;a++){const c=e[a];let u=Math.round(Math.min(c.pe,c.me)*o),p=Math.round(Math.max(c.pe,c.me)*o),m=Math.round(c.nt*r)-Math.floor(.5*this.ae),d=m+this.ae-1;if(c.ce!==l){const f=c.ce;n.fillStyle=f,l=f}this.zt._i&&(m+=h,u+=h,d-=h,p-=h),u>p||n.fillRect(m,u,d-m+1,p-u+1)}}}class Fl extends Nn{constructor(){super(...arguments),this.js=new Vl}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 $l{constructor(t,e){this.Fe=t,this.Li=e}X(t,e,i){this.Fe.draw(t,this.Li,e,i)}}class Yi extends Gi{constructor(t,e,i){super(t,e,!1),this.wn=i,this.js=new $l(this.wn.renderer(),(n=>{const r=t.Ct();return r===null?null:t.Dt().Rt(n,r.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,Ie(this.Ls))}Js(){this.wn.update({bars:this.zs.map(Il),barSpacing:this.Ns.St().le(),visibleRange:this.Ls},this.Es.W())}}function Il(s){return{x:s.nt,time:s.ot,originalData:s.He,barColor:s.ce}}class Ul extends Yt{constructor(){super(...arguments),this.zt=null,this.Ue=[]}J(t){this.zt=t,this.Ue=[]}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.zt===null||this.zt.it.length===0||this.zt.tt===null)return;this.Ue.length||this.qe(e);const n=Math.max(1,Math.floor(i)),r=Math.round(this.zt.Ye*i)-Math.floor(n/2),o=r+n;for(let l=this.zt.tt.from;l<this.zt.tt.to;l++){const h=this.zt.it[l],a=this.Ue[l-this.zt.tt.from],c=Math.round(h.st*i);let u,p;t.fillStyle=h.ce,c<=r?(u=c,p=o):(u=r,p=c-Math.floor(n/2)+n),t.fillRect(a.Os,u,a.ui-a.Os+1,p-u)}}qe(t){if(this.zt===null||this.zt.it.length===0||this.zt.tt===null)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 r=this.zt.tt.from;r<this.zt.tt.to;r++){const o=this.zt.it[r],l=Math.round(o.nt*t);let h,a;if(i%2){const c=(i-1)/2;h=l-c,a=l+c}else{const c=i/2;h=l-c,a=l+c-1}this.Ue[r-this.zt.tt.from]={Os:h,ui:a,Ze:l,Xe:o.nt*t,ot:o.ot}}for(let r=this.zt.tt.from+1;r<this.zt.tt.to;r++){const o=this.Ue[r-this.zt.tt.from],l=this.Ue[r-this.zt.tt.from-1];o.ot===l.ot+1&&o.Os-l.ui!==e+1&&(l.Ze>l.Xe?l.ui=o.Os-e-1:o.Os=l.ui+e+1)}let n=Math.ceil(this.zt.le*t);for(let r=this.zt.tt.from;r<this.zt.tt.to;r++){const o=this.Ue[r-this.zt.tt.from];o.ui<o.Os&&(o.ui=o.Os);const l=o.ui-o.Os+1;n=Math.min(l,n)}if(e>0&&n<4)for(let r=this.zt.tt.from;r<this.zt.tt.to;r++){const o=this.Ue[r-this.zt.tt.from];o.ui-o.Os+1>n&&(o.Ze>o.Xe?o.ui-=1:o.Os+=1)}}}class Wl extends di{constructor(){super(...arguments),this.js=new Ul}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,C(this.Es.Ct()).Vt)};this.js.J(t)}}class ql extends di{constructor(){super(...arguments),this.js=new Ln}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 Hl=/[2-9]/g;class We{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 n=this.sr(t,e,i);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}sr(t,e,i){const n=i||Hl,r=String(e).replace(n,"0");if(this.tr.has(r))return Bt(this.tr.get(r)).er;if(this.Ke===this.ir){const l=this.Qe[this.Je];delete this.Qe[this.Je],this.tr.delete(l),this.Je++,this.Ke--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&e.length||(this.tr.set(r,{er:o,rr:this.Ge}),this.Qe[this.Ge]=r,this.Ke++,this.Ge++),o}}class jl{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){this.k!==null&&this.hr!==null&&this.hr.X(t,this.k,this.ar,this.lr)}}class Pn{constructor(t,e,i){this.ur=t,this.ar=new We(50),this.cr=e,this.F=i,this.j=-1,this.Wt=new jl(this.ar)}gt(){const t=this.F.dr(this.cr);if(t===null)return null;const e=t.vr(this.cr)?t.pr():this.cr.Dt();if(e===null)return null;const i=t.mr(e);if(i==="overlay")return null;const n=this.F.br();return n.P!==this.j&&(this.j=n.P,this.ar.nr()),this.Wt._r(this.ur.Ii(),n,i),this.Wt}}class Kl extends Yt{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}wr(t,e){var i;if(!(!((i=this.zt)===null||i===void 0)&&i.yt))return null;const{st:n,et:r,gr:o}=this.zt;return e>=n-r-7&&e<=n+r+7?{Mr:this.zt,gr:o}:null}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.zt===null||this.zt.yt===!1)return;const r=Math.round(this.zt.st*n);r<0||r>e.height||(t.lineCap="butt",t.strokeStyle=this.zt.V,t.lineWidth=Math.floor(this.zt.et*i),ye(t,this.zt.Nt),un(t,r,0,e.width))}}class Qi{constructor(t){this.Sr={st:0,V:"rgba(0, 0, 0, 0)",et:1,Nt:0,yt:!1},this.kr=new Kl,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 Xl extends Qi{constructor(t){super(t)}yr(){this.Sr.yt=!1;const t=this.Es.Dt(),e=t.Cr().Cr;if(e!==2&&e!==3)return;const i=this.Es.W();if(!i.baseLineVisible||!this.Es.yt())return;const n=this.Es.Ct();n!==null&&(this.Sr.yt=!0,this.Sr.st=t.Rt(n.Vt,n.Vt),this.Sr.V=i.baseLineColor,this.Sr.et=i.baseLineWidth,this.Sr.Nt=i.baseLineStyle)}}class Jl extends Yt{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}$e(){return this.zt}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){const n=this.zt;if(n===null)return;const r=Math.max(1,Math.floor(e)),o=r%2/2,l=Math.round(n.Xe.x*e)+o,h=n.Xe.y*i;t.fillStyle=n.Tr,t.beginPath();const a=Math.max(2,1.5*n.Pr)*e;t.arc(l,h,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.Rr,t.beginPath(),t.arc(l,h,n.ht*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=n.Dr,t.beginPath(),t.arc(l,h,n.ht*e+r/2,0,2*Math.PI,!1),t.stroke()}}const Gl=[{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 Dn(s,t,e,i){return(function(n,r){if(n==="transparent")return n;const o=Ve(n),l=o[3];return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${r*l})`})(s,e+(i-e)*t)}function An(s,t){const e=s%2600/2600;let i;for(const h of Gl)if(e>=h.Vr&&e<=h.Or){i=h;break}de(i!==void 0,"Last price animation internal logic error");const n=(e-i.Vr)/(i.Or-i.Vr);return{Rr:Dn(t,n,i.Ir,i.zr),Dr:Dn(t,n,i.Lr,i.Er),ht:(r=n,o=i.Br,l=i.Ar,o+(l-o)*r)};var r,o,l}class Yl{constructor(t){this.Wt=new Jl,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(),this.jr.W().lastPriceAnimation===2){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 this.jr.W().lastPriceAnimation!==0}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(e===null||i===null)return;const n=this.jr.Zr(!0);if(n.Xr||!e.Kr(n.ee))return;const r={x:t.It(n.ee),y:this.jr.Dt().Rt(n._t,i.Vt)},o=n.V,l=this.jr.W().lineWidth,h=An(this.Gr(),o);this.Wt.J({Tr:o,Pr:l,Rr:h.Rr,Dr:h.Dr,ht:h.ht,Xe:r})}Yr(){const t=this.Wt.$e();if(t!==null){const e=An(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 qe(s,t){return Mn(Math.min(Math.max(s,12),30)*t)}function He(s,t){switch(s){case"arrowDown":case"arrowUp":return qe(t,1);case"circle":return qe(t,.8);case"square":return qe(t,.7)}}function Bn(s){return(function(t){const e=Math.ceil(t);return e%2!=0?e-1:e})(qe(s,1))}function Vn(s){return Math.max(qe(s,.1),3)}function Fn(s,t,e){return t?s:e?Math.ceil(s/2):0}function $n(s,t,e,i,n){const r=He("square",e),o=(r-1)/2,l=s-o,h=t-o;return i>=l&&i<=l+r&&n>=h&&n<=h+r}function In(s,t,e,i){const n=(He("arrowUp",i)-1)/2*e.Jr,r=(Mn(i/2)-1)/2*e.Jr;t.beginPath(),s?(t.moveTo(e.nt-n,e.st),t.lineTo(e.nt,e.st-n),t.lineTo(e.nt+n,e.st),t.lineTo(e.nt+r,e.st),t.lineTo(e.nt+r,e.st+n),t.lineTo(e.nt-r,e.st+n),t.lineTo(e.nt-r,e.st)):(t.moveTo(e.nt-n,e.st),t.lineTo(e.nt,e.st+n),t.lineTo(e.nt+n,e.st),t.lineTo(e.nt+r,e.st),t.lineTo(e.nt+r,e.st-n),t.lineTo(e.nt-r,e.st-n),t.lineTo(e.nt-r,e.st)),t.fill()}function Ql(s,t,e,i,n,r){return $n(t,e,i,n,r)}class Zl extends Yt{constructor(){super(...arguments),this.zt=null,this.ar=new We,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=ke(t,e),this.ar.nr())}wr(t,e){if(this.zt===null||this.zt.tt===null)return null;for(let i=this.zt.tt.from;i<this.zt.tt.to;i++){const n=this.zt.it[i];if(eh(n,t,e))return{Mr:n.th,gr:n.gr}}return null}K({context:t,horizontalPixelRatio:e,verticalPixelRatio:i},n,r){if(this.zt!==null&&this.zt.tt!==null){t.textBaseline="middle",t.font=this.Qr;for(let o=this.zt.tt.from;o<this.zt.tt.to;o++){const l=this.zt.it[o];l.Kt!==void 0&&(l.Kt.Hi=this.ar.xi(t,l.Kt.ih),l.Kt.At=this.j,l.Kt.nt=l.nt-l.Kt.Hi/2),th(l,t,e,i)}}}}function th(s,t,e,i){t.fillStyle=s.V,s.Kt!==void 0&&(function(n,r,o,l,h,a){n.save(),n.scale(h,a),n.fillText(r,o,l),n.restore()})(t,s.Kt.ih,s.Kt.nt,s.Kt.st,e,i),(function(n,r,o){if(n.Ks!==0){switch(n.nh){case"arrowDown":return void In(!1,r,o,n.Ks);case"arrowUp":return void In(!0,r,o,n.Ks);case"circle":return void(function(l,h,a){const c=(He("circle",a)-1)/2;l.beginPath(),l.arc(h.nt,h.st,c*h.Jr,0,2*Math.PI,!1),l.fill()})(r,o,n.Ks);case"square":return void(function(l,h,a){const c=He("square",a),u=(c-1)*h.Jr/2,p=h.nt-u,m=h.st-u;l.fillRect(p,m,c*h.Jr,c*h.Jr)})(r,o,n.Ks)}n.nh}})(s,t,(function(n,r,o){const l=Math.max(1,Math.floor(r))%2/2;return{nt:Math.round(n.nt*r)+l,st:n.st*o,Jr:r}})(s,e,i))}function eh(s,t,e){return!(s.Kt===void 0||!(function(i,n,r,o,l,h){const a=o/2;return l>=i&&l<=i+r&&h>=n-a&&h<=n+a})(s.Kt.nt,s.Kt.st,s.Kt.Hi,s.Kt.At,t,e))||(function(i,n,r){if(i.Ks===0)return!1;switch(i.nh){case"arrowDown":case"arrowUp":return Ql(0,i.nt,i.st,i.Ks,n,r);case"circle":return(function(o,l,h,a,c){const u=2+He("circle",h)/2,p=o-a,m=l-c;return Math.sqrt(p*p+m*m)<=u})(i.nt,i.st,i.Ks,n,r);case"square":return $n(i.nt,i.st,i.Ks,n,r)}})(s,t,e)}function ih(s,t,e,i,n,r,o,l,h){const a=te(e)?e:e.Se,c=te(e)?e:e.Me,u=te(e)?e:e.xe,p=te(t.size)?Math.max(t.size,0):1,m=Bn(l.le())*p,d=m/2;switch(s.Ks=m,t.position){case"inBar":return s.st=o.Rt(a,h),void(s.Kt!==void 0&&(s.Kt.st=s.st+d+r+.6*n));case"aboveBar":return s.st=o.Rt(c,h)-d-i.sh,s.Kt!==void 0&&(s.Kt.st=s.st-d-.6*n,i.sh+=1.2*n),void(i.sh+=m+r);case"belowBar":return s.st=o.Rt(u,h)+d+i.eh,s.Kt!==void 0&&(s.Kt.st=s.st+d+r+.6*n,i.eh+=1.2*n),void(i.eh+=m+r)}t.position}class sh{constructor(t,e){this.ft=!0,this.rh=!0,this.hh=!0,this.ah=null,this.oh=null,this.Wt=new Zl,this.jr=t,this.$i=e,this.zt={it:[],tt:null}}bt(t){this.ft=!0,this.hh=!0,t==="data"&&(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=Vn(t),i=1.5*Bn(t)+2*e,n=this.fh();this.ah={above:Fn(i,n.aboveBar,n.inBar),below:Fn(i,n.belowBar,n.inBar)}}else this.ah=null;this.hh=!1}return this.ah}fh(){return this.oh===null&&(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((c=>({ot:c.time,nt:0,st:0,Ks:0,nh:c.shape,V:c.color,th:c.th,gr:c.id,Kt:void 0}))),this.rh=!1);const n=this.$i.W().layout;this.zt.tt=null;const r=e.Xs();if(r===null)return;const o=this.jr.Ct();if(o===null||this.zt.it.length===0)return;let l=NaN;const h=Vn(e.le()),a={sh:h,eh:h};this.zt.tt=zn(this.zt.it,r,!0);for(let c=this.zt.tt.from;c<this.zt.tt.to;c++){const u=i[c];u.time!==l&&(a.sh=h,a.eh=h,l=u.time);const p=this.zt.it[c];p.nt=e.It(u.time),u.text!==void 0&&u.text.length>0&&(p.Kt={ih:u.text,nt:0,st:0,Hi:0,At:0});const m=this.jr.ph(u.time);m!==null&&ih(p,u,m,a,n.fontSize,h,t,e,o.Vt)}this.ft=!1}}class nh extends Qi{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(e.priceLineSource===0);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 rh extends ai{constructor(t){super(),this.jt=t}zi(t,e,i){t.yt=!1,e.yt=!1;const n=this.jt;if(!n.yt())return;const r=n.W(),o=r.lastValueVisible,l=n.bh()!=="",h=r.seriesLastValueMode===0,a=n.Zr(!1);if(a.Xr)return;o&&(t.Kt=this.wh(a,o,h),t.yt=t.Kt.length!==0),(l||h)&&(e.Kt=this.gh(a,o,l,h),e.yt=e.Kt.length>0);const c=n.mh(a.V),u=oi(c);i.t=u.t,i.ki=a.ki,e.Ot=n.$t().Bt(a.ki/n.Dt().At()),t.Ot=c,t.V=u.i,e.V=u.i}gh(t,e,i,n){let r="";const o=this.jt.bh();return i&&o.length!==0&&(r+=`${o} `),e&&n&&(r+=this.jt.Dt().Mh()?t.xh:t.Sh),r.trim()}wh(t,e,i){return e?i?this.jt.Dt().Mh()?t.Sh:t.xh:t.Kt:""}}function Un(s,t,e,i){const n=Number.isFinite(t),r=Number.isFinite(e);return n&&r?s(t,e):n||r?n?t:e:i}class Vt{constructor(t,e){this.kh=t,this.yh=e}Ch(t){return t!==null&&this.kh===t.kh&&this.yh===t.yh}Th(){return new Vt(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 t===null?this:new Vt(Un(Math.min,this.Ph(),t.Ph(),-1/0),Un(Math.max,this.Rh(),t.Rh(),1/0))}Vh(t){if(!te(t)||this.yh-this.kh===0)return;const e=.5*(this.yh+this.kh);let i=this.yh-e,n=this.kh-e;i*=t,n*=t,this.yh=e+i,this.kh=e+n}Oh(t){te(t)&&(this.yh+=t,this.kh+=t)}Bh(){return{minValue:this.kh,maxValue:this.yh}}static Ah(t){return t===null?null:new Vt(t.minValue,t.maxValue)}}class pi{constructor(t,e){this.Ih=t,this.zh=e||null}Lh(){return this.Ih}Eh(){return this.zh}Bh(){return this.Ih===null?null:{priceRange:this.Ih.Bh(),margins:this.zh||void 0}}static Ah(t){return t===null?null:new pi(Vt.Ah(t.priceRange),t.margins)}}class oh extends Qi{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();i!==null&&(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 lh extends ai{constructor(t,e){super(),this.jr=t,this.Nh=e}zi(t,e,i){t.yt=!1,e.yt=!1;const n=this.Nh.W(),r=n.axisLabelVisible,o=n.title!=="",l=this.jr;if(!r||!l.yt())return;const h=this.Nh.Fh();if(h===null)return;o&&(e.Kt=n.title,e.yt=!0),e.Ot=l.$t().Bt(h/l.Dt().At()),t.Kt=this.Wh(n.price),t.yt=!0;const a=oi(n.axisLabelColor||n.color);i.t=a.t;const c=n.axisLabelTextColor||a.i;t.V=c,e.V=c,i.ki=h}Wh(t){const e=this.jr.Ct();return e===null?"":this.jr.Dt().Fi(t,e.Vt)}}class hh{constructor(t,e){this.jr=t,this.cn=e,this.jh=new oh(t,this),this.ur=new lh(t,this),this.Hh=new Pn(this.ur,t,t.$t())}$h(t){Gt(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 i===null?null:e.Rt(this.cn.price,i.Vt)}}class ah extends ji{constructor(t){super(),this.$i=t}$t(){return this.$i}}const ch={Bar:(s,t,e,i)=>{var n;const r=t.upColor,o=t.downColor,l=C(s(e,i)),h=Me(l.Vt[0])<=Me(l.Vt[3]);return{ce:(n=l.V)!==null&&n!==void 0?n:h?r:o}},Candlestick:(s,t,e,i)=>{var n,r,o;const l=t.upColor,h=t.downColor,a=t.borderUpColor,c=t.borderDownColor,u=t.wickUpColor,p=t.wickDownColor,m=C(s(e,i)),d=Me(m.Vt[0])<=Me(m.Vt[3]);return{ce:(n=m.V)!==null&&n!==void 0?n:d?l:h,Ne:(r=m.Ot)!==null&&r!==void 0?r:d?a:c,Ee:(o=m.Xh)!==null&&o!==void 0?o:d?u:p}},Custom:(s,t,e,i)=>{var n;return{ce:(n=C(s(e,i)).V)!==null&&n!==void 0?n:t.color}},Area:(s,t,e,i)=>{var n,r,o,l;const h=C(s(e,i));return{ce:(n=h.lt)!==null&&n!==void 0?n:t.lineColor,lt:(r=h.lt)!==null&&r!==void 0?r:t.lineColor,Ps:(o=h.Ps)!==null&&o!==void 0?o:t.topColor,Rs:(l=h.Rs)!==null&&l!==void 0?l:t.bottomColor}},Baseline:(s,t,e,i)=>{var n,r,o,l,h,a;const c=C(s(e,i));return{ce:c.Vt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,Re:(n=c.Re)!==null&&n!==void 0?n:t.topLineColor,De:(r=c.De)!==null&&r!==void 0?r:t.bottomLineColor,ke:(o=c.ke)!==null&&o!==void 0?o:t.topFillColor1,ye:(l=c.ye)!==null&&l!==void 0?l:t.topFillColor2,Ce:(h=c.Ce)!==null&&h!==void 0?h:t.bottomFillColor1,Te:(a=c.Te)!==null&&a!==void 0?a:t.bottomFillColor2}},Line:(s,t,e,i)=>{var n,r;const o=C(s(e,i));return{ce:(n=o.V)!==null&&n!==void 0?n:t.color,lt:(r=o.V)!==null&&r!==void 0?r:t.color}},Histogram:(s,t,e,i)=>{var n;return{ce:(n=C(s(e,i)).V)!==null&&n!==void 0?n:t.color}}};class uh{constructor(t){this.Kh=(e,i)=>i!==void 0?i.Vt:this.jr.In().Gh(e),this.jr=t,this.Jh=ch[t.Qh()]}$s(t,e){return this.Jh(this.Kh,this.jr.W(),t,e)}}var Wn;(function(s){s[s.NearestLeft=-1]="NearestLeft",s[s.None=0]="None",s[s.NearestRight=1]="NearestRight"})(Wn||(Wn={}));const pe=30;class fh{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 this.Ks()===0}Kr(t){return this.hl(t,0)!==null}Gh(t){return this.ll(t)}ll(t,e=0){const i=this.hl(t,e);return i===null?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 n=null;for(const r of i)n=mi(n,this._l(t,e,r));return n}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(i===null&&e!==0)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 Ue(this.tl,t,((e,i)=>e.ee<i))}vl(t){return Rn(this.tl,t,((e,i)=>e.ee>i))}pl(t,e,i){let n=null;for(let r=t;r<e;r++){const o=this.tl[r].Vt[i];Number.isNaN(o)||(n===null?n={ml:o,bl:o}:(o<n.ml&&(n.ml=o),o>n.bl&&(n.bl=o)))}return n}_l(t,e,i){if(this.Ni())return null;let n=null;const r=C(this.el()),o=C(this.An()),l=Math.max(t,r),h=Math.min(e,o),a=Math.ceil(l/pe)*pe,c=Math.max(a,Math.floor(h/pe)*pe);{const p=this.fl(l),m=this.vl(Math.min(h,a,e));n=mi(n,this.pl(p,m,i))}let u=this.il.get(i);u===void 0&&(u=new Map,this.il.set(i,u));for(let p=Math.max(a+1,l);p<c;p+=pe){const m=Math.floor(p/pe);let d=u.get(m);if(d===void 0){const f=this.fl(m*pe),g=this.vl((m+1)*pe-1);d=this.pl(f,g,i),u.set(m,d)}n=mi(n,d)}{const p=this.fl(c),m=this.vl(h);n=mi(n,this.pl(p,m,i))}return n}}function mi(s,t){return s===null?t:t===null?s:{ml:Math.min(s.ml,t.ml),bl:Math.max(s.bl,t.bl)}}class dh{constructor(t){this.wl=t}X(t,e,i){this.wl.draw(t)}gl(t,e,i){var n,r;(r=(n=this.wl).drawBackground)===null||r===void 0||r.call(n,t)}}class Zi{constructor(t){this.tr=null,this.wn=t}gt(){var t;const e=this.wn.renderer();if(e===null)return null;if(((t=this.tr)===null||t===void 0?void 0:t.Ml)===e)return this.tr.xl;const i=new dh(e);return this.tr={Ml:e,xl:i},i}Sl(){var t,e,i;return(i=(e=(t=this.wn).zOrder)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:"normal"}}function qn(s){var t,e,i,n,r;return{Kt:s.text(),ki:s.coordinate(),Si:(t=s.fixedCoordinate)===null||t===void 0?void 0:t.call(s),V:s.textColor(),t:s.backColor(),yt:(i=(e=s.visible)===null||e===void 0?void 0:e.call(s))===null||i===void 0||i,hi:(r=(n=s.tickVisible)===null||n===void 0?void 0:n.call(s))===null||r===void 0||r}}class ph{constructor(t,e){this.Wt=new yn,this.kl=t,this.yl=e}gt(){return this.Wt.J(Object.assign({Hi:this.yl.Hi()},qn(this.kl))),this.Wt}}class mh extends ai{constructor(t,e){super(),this.kl=t,this.Li=e}zi(t,e,i){const n=qn(this.kl);i.t=n.t,t.V=n.V;const r=2/12*this.Li.P();i.wi=r,i.gi=r,i.ki=n.ki,i.Si=n.Si,t.Kt=n.Kt,t.yt=n.yt,t.hi=n.hi}}class gh{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;(e=(t=this.Vl).updateAllViews)===null||e===void 0||e.call(t)}Pn(){var t,e,i,n;const r=(i=(e=(t=this.Vl).paneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Cl)===null||n===void 0?void 0:n.Ml)===r)return this.Cl.xl;const o=r.map((l=>new Zi(l)));return this.Cl={Ml:r,xl:o},o}Qi(){var t,e,i,n;const r=(i=(e=(t=this.Vl).timeAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Tl)===null||n===void 0?void 0:n.Ml)===r)return this.Tl.xl;const o=this.jr.$t().St(),l=r.map((h=>new ph(h,o)));return this.Tl={Ml:r,xl:l},l}Rn(){var t,e,i,n;const r=(i=(e=(t=this.Vl).priceAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Pl)===null||n===void 0?void 0:n.Ml)===r)return this.Pl.xl;const o=this.jr.Dt(),l=r.map((h=>new mh(h,o)));return this.Pl={Ml:r,xl:l},l}Bl(){var t,e,i,n;const r=(i=(e=(t=this.Vl).priceAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Rl)===null||n===void 0?void 0:n.Ml)===r)return this.Rl.xl;const o=r.map((l=>new Zi(l)));return this.Rl={Ml:r,xl:o},o}Al(){var t,e,i,n;const r=(i=(e=(t=this.Vl).timeAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Dl)===null||n===void 0?void 0:n.Ml)===r)return this.Dl.xl;const o=r.map((l=>new Zi(l)));return this.Dl={Ml:r,xl:o},o}Il(t,e){var i,n,r;return(r=(n=(i=this.Vl).autoscaleInfo)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}wr(t,e){var i,n,r;return(r=(n=(i=this.Vl).hitTest)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}}function ts(s,t,e,i){s.forEach((n=>{t(n).forEach((r=>{r.Sl()===e&&i.push(r)}))}))}function es(s){return s.Pn()}function bh(s){return s.Bl()}function vh(s){return s.Al()}class is extends ah{constructor(t,e,i,n,r){super(t),this.zt=new fh,this.jh=new nh(this),this.zl=[],this.Ll=new Xl(this),this.El=null,this.Nl=null,this.Fl=[],this.Wl=[],this.jl=null,this.Hl=[],this.cn=e,this.$l=i;const o=new rh(this);this.rn=[o],this.Hh=new Pn(o,this,t),i!=="Area"&&i!=="Line"&&i!=="Baseline"||(this.El=new Yl(this)),this.Ul(),this.ql(r)}S(){this.jl!==null&&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 n=this.$t().St().Xs(),r=this.Ct();if(n===null||r===null)return e;let o,l;if(t){const u=this.zt.sl();if(u===null)return e;o=u,l=u.ee}else{const u=this.zt.ll(n.ui(),-1);if(u===null||(o=this.zt.Gh(u.ee),o===null))return e;l=u.ee}const h=o.Vt[3],a=this.Us().$s(l,{Vt:o}),c=i.Rt(h,r.Vt);return{Xr:!1,_t:h,Kt:i.Fi(h,r.Vt),xh:i.Yl(h),Sh:i.Zl(h,r.Vt),V:a.ce,ki:c,ee:l}}Us(){return this.Nl!==null||(this.Nl=new uh(this)),this.Nl}W(){return this.cn}$h(t){const e=t.priceScaleId;e!==void 0&&e!==this.cn.priceScaleId&&this.$t().Xl(this,e),Gt(this.cn,t),t.priceFormat!==void 0&&(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"),this.El!==null&&(e&&e.ta?this.El.$r():t.length===0&&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 hh(this,t);return this.zl.push(e),this.$t().Gl(this),e}ra(t){const e=this.zl.indexOf(t);e!==-1&&this.zl.splice(e,1),this.$t().Gl(this)}Qh(){return this.$l}Ct(){const t=this.ha();return t===null?null:{Vt:t.Vt[3],la:t.ot}}ha(){const t=this.$t().St().Xs();if(t===null)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 e===null?null:this.$l==="Bar"||this.$l==="Candlestick"||this.$l==="Custom"?{ge:e.Vt[0],Me:e.Vt[1],xe:e.Vt[2],Se:e.Vt[3]}:e.Vt[3]}aa(t){const e=[];ts(this.Hl,es,"top",e);const i=this.El;return i!==null&&i.yt()&&(this.jl===null&&i.qr()&&(this.jl=setTimeout((()=>{this.jl=null,this.$t().oa()}),0)),i.Ur(),e.unshift(i)),e}Pn(){const t=[];this._a()||t.push(this.Ll),t.push(this.wn,this.jh,this.dn);const e=this.zl.map((i=>i.qh()));return t.push(...e),ts(this.Hl,es,"normal",t),t}ua(){return this.ca(es,"bottom")}da(t){return this.ca(bh,t)}fa(t){return this.ca(vh,t)}va(t,e){return this.Hl.map((i=>i.wr(t,e))).filter((i=>i!==null))}Ji(t){return[this.Hh,...this.zl.map((e=>e.Yh()))]}Rn(t,e){if(e!==this.Yi&&!this._a())return[];const i=[...this.rn];for(const n of this.zl)i.push(n.Zh());return this.Hl.forEach((n=>{i.push(...n.Rn())})),i}Qi(){const t=[];return this.Hl.forEach((e=>{t.push(...e.Qi())})),t}Il(t,e){if(this.cn.autoscaleInfoProvider!==void 0){const i=this.cn.autoscaleInfoProvider((()=>{const n=this.pa(t,e);return n===null?null:n.Bh()}));return pi.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 e of this.rn)e.bt();for(const e of this.zl)e.bt();this.jh.bt(),this.Ll.bt(),(t=this.El)===null||t===void 0||t.bt(),this.Hl.forEach((e=>e.Vn()))}Dt(){return C(super.Dt())}kt(t){if(!((this.$l==="Line"||this.$l==="Area"||this.$l==="Baseline")&&this.cn.crosshairMarkerVisible))return null;const e=this.zt.Gh(t);return e===null?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 gh(t,this))}ya(t){this.Hl=this.Hl.filter((e=>e.Ol()!==t))}Ca(){if(this.wn instanceof Yi)return t=>this.wn.We(t)}Ta(){if(this.wn instanceof Yi)return t=>this.wn.je(t)}_a(){return!ci(this.Dt().Pa())}pa(t,e){if(!Fe(t)||!Fe(e)||this.zt.Ni())return null;const i=this.$l==="Line"||this.$l==="Area"||this.$l==="Baseline"||this.$l==="Histogram"?[3]:[2,1],n=this.zt.ol(t,e,i);let r=n!==null?new Vt(n.ml,n.bl):null;if(this.Qh()==="Histogram"){const l=this.cn.base,h=new Vt(l,l);r=r!==null?r.ts(h):h}let o=this.dn.uh();return this.Hl.forEach((l=>{const h=l.Il(t,e);if(h?.priceRange){const m=new Vt(h.priceRange.minValue,h.priceRange.maxValue);r=r!==null?r.ts(m):m}var a,c,u,p;h?.margins&&(a=o,c=h.margins,o={above:Math.max((u=a?.above)!==null&&u!==void 0?u:0,c.above),below:Math.max((p=a?.below)!==null&&p!==void 0?p:0,c.below)})})),new pi(r,o)}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(t.length!==0)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 e=this.cn.crosshairMarkerBackgroundColor;if(e.length!==0)return e}}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 El(this.cn.priceFormat.precision);break;case"percent":this.wa=new _n(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.wa=new ui(t,this.cn.priceFormat.minMove*t)}}this.Yi!==null&&this.Yi.Ra()}Ql(){const t=this.$t().St();if(!t.Da()||this.zt.Ni())return void(this.Wl=[]);const e=C(this.zt.el());this.Wl=this.Fl.map(((i,n)=>{const r=C(t.Va(i.time,!0)),o=r<e?1:-1;return{time:C(this.zt.ll(r,o)).ee,position:i.position,shape:i.shape,color:i.color,id:i.id,th:n,text:i.text,size:i.size,originalTime:i.originalTime}}))}ql(t){switch(this.dn=new sh(this,this.$t()),this.$l){case"Bar":this.wn=new Pl(this,this.$t());break;case"Candlestick":this.wn=new Fl(this,this.$t());break;case"Line":this.wn=new ql(this,this.$t());break;case"Custom":this.wn=new Yi(this,this.$t(),Bt(t));break;case"Area":this.wn=new zl(this,this.$t());break;case"Baseline":this.wn=new Bl(this,this.$t());break;case"Histogram":this.wn=new Wl(this,this.$t());break;default:throw Error("Unknown chart style assigned: "+this.$l)}}ca(t,e){const i=[];return ts(this.Hl,t,e,i),i}}class yh{constructor(t){this.cn=t}Oa(t,e,i){let n=t;if(this.cn.mode===0)return n;const r=i.vn(),o=r.Ct();if(o===null)return n;const l=r.Rt(t,o),h=i.Ba().filter((c=>c instanceof is)).reduce(((c,u)=>{if(i.vr(u)||!u.yt())return c;const p=u.Dt(),m=u.In();if(p.Ni()||!m.Kr(e))return c;const d=m.Gh(e);if(d===null)return c;const f=Me(u.Ct());return c.concat([p.Rt(d.Vt[3],f.Vt)])}),[]);if(h.length===0)return n;h.sort(((c,u)=>Math.abs(c-l)-Math.abs(u-l)));const a=h[0];return n=r.pn(a,o),n}}class wh extends Yt{constructor(){super(...arguments),this.zt=null}J(t){this.zt=t}K({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.zt===null)return;const r=Math.max(1,Math.floor(i));t.lineWidth=r,(function(o,l){o.save(),o.lineWidth%2&&o.translate(.5,.5),l(),o.restore()})(t,(()=>{const o=C(this.zt);if(o.Aa){t.strokeStyle=o.Ia,ye(t,o.za),t.beginPath();for(const l of o.La){const h=Math.round(l.Ea*i);t.moveTo(h,-r),t.lineTo(h,e.height+r)}t.stroke()}if(o.Na){t.strokeStyle=o.Fa,ye(t,o.Wa),t.beginPath();for(const l of o.ja){const h=Math.round(l.Ea*n);t.moveTo(-r,h),t.lineTo(e.width+r,h)}t.stroke()}}))}}class Sh{constructor(t){this.Wt=new wh,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((i=>({Ea:i.coord})))};this.Wt.J(e),this.ft=!1}return this.Wt}}class _h{constructor(t){this.wn=new Sh(t)}qh(){return this.wn}}const ss={$a:4,Ua:1e-4};function Le(s,t){const e=100*(s-t)/t;return t<0?-e:e}function xh(s,t){const e=Le(s.Ph(),t),i=Le(s.Rh(),t);return new Vt(e,i)}function je(s,t){const e=100*(s-t)/t+100;return t<0?-e:e}function Ch(s,t){const e=je(s.Ph(),t),i=je(s.Rh(),t);return new Vt(e,i)}function gi(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.log10(e+t.Ua)+t.$a;return s<0?-i:i}function Ke(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.pow(10,e-t.$a)-t.Ua;return s<0?-i:i}function Xe(s,t){if(s===null)return null;const e=gi(s.Ph(),t),i=gi(s.Rh(),t);return new Vt(e,i)}function bi(s,t){if(s===null)return null;const e=Ke(s.Ph(),t),i=Ke(s.Rh(),t);return new Vt(e,i)}function ns(s){if(s===null)return ss;const t=Math.abs(s.Rh()-s.Ph());if(t>=1||t<1e-15)return ss;const e=Math.ceil(Math.abs(Math.log10(t))),i=ss.$a+e;return{$a:i,Ua:1/Math.pow(10,i)}}class rs{constructor(t,e){if(this.qa=t,this.Ya=e,(function(i){if(i<0)return!1;for(let n=i;n>1;n/=10)if(n%10!=0)return!1;return!0})(this.qa))this.Za=[2,2.5,2];else{this.Za=[];for(let i=this.qa;i!==1;){if(i%2==0)this.Za.push(2),i/=2;else{if(i%5!=0)throw new Error("unexpected base");this.Za.push(2,2.5),i/=5}if(this.Za.length>100)throw new Error("something wrong with base")}}}Xa(t,e,i){const n=this.qa===0?0:1/this.qa;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-e)))),o=0,l=this.Ya[0];for(;;){const u=fi(r,n,1e-14)&&r>n+1e-14,p=fi(r,i*l,1e-14),m=fi(r,1,1e-14);if(!(u&&p&&m))break;r/=l,l=this.Ya[++o%this.Ya.length]}if(r<=n+1e-14&&(r=n),r=Math.max(1,r),this.Za.length>0&&(h=r,a=1,c=1e-14,Math.abs(h-a)<c))for(o=0,l=this.Za[0];fi(r,i*l,1e-14)&&r>n+1e-14;)r/=l,l=this.Za[++o%this.Za.length];var h,a,c;return r}}class Hn{constructor(t,e,i,n){this.Ka=[],this.Li=t,this.qa=e,this.Ga=i,this.Ja=n}Xa(t,e){if(t<e)throw new Error("high < low");const i=this.Li.At(),n=(t-e)*this.Qa()/i,r=new rs(this.qa,[2,2.5,2]),o=new rs(this.qa,[2,2,2.5]),l=new rs(this.qa,[2.5,2,2]),h=[];return h.push(r.Xa(t,e,n),o.Xa(t,e,n),l.Xa(t,e,n)),(function(a){if(a.length<1)throw Error("array is empty");let c=a[0];for(let u=1;u<a.length;++u)a[u]<c&&(c=a[u]);return c})(h)}io(){const t=this.Li,e=t.Ct();if(e===null)return void(this.Ka=[]);const i=t.At(),n=this.Ga(i-1,e),r=this.Ga(0,e),o=this.Li.W().entireTextOnly?this.no()/2:0,l=o,h=i-1-o,a=Math.max(n,r),c=Math.min(n,r);if(a===c)return void(this.Ka=[]);let u=this.Xa(a,c),p=a%u;p+=p<0?u:0;const m=a>=c?1:-1;let d=null,f=0;for(let g=a-p;g>c;g-=u){const w=this.Ja(g,e,!0);d!==null&&Math.abs(w-d)<this.Qa()||w<l||w>h||(f<this.Ka.length?(this.Ka[f].Ea=w,this.Ka[f].so=t.eo(g)):this.Ka.push({Ea:w,so:t.eo(g)}),f++,d=w,t.ro()&&(u=this.Xa(g*m,c)))}this.Ka.length=f}Ha(){return this.Ka}no(){return this.Li.P()}Qa(){return Math.ceil(2.5*this.no())}}function jn(s){return s.slice().sort(((t,e)=>C(t.Xi())-C(e.Xi())))}var Kn;(function(s){s[s.Normal=0]="Normal",s[s.Logarithmic=1]="Logarithmic",s[s.Percentage=2]="Percentage",s[s.IndexedTo100=3]="IndexedTo100"})(Kn||(Kn={}));const Xn=new _n,Jn=new ui(100,1);class Eh{constructor(t,e,i,n){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 xt,this.vo=new xt,this.po=[],this.mo=null,this.bo=null,this.wo=null,this.Mo=null,this.wa=Jn,this.xo=ns(null),this.So=t,this.cn=e,this.ko=i,this.yo=n,this.Co=new Hn(this,100,this.To.bind(this),this.Po.bind(this))}Pa(){return this.So}W(){return this.cn}$h(t){if(Gt(this.cn,t),this.Ra(),t.mode!==void 0&&this.Ro({Cr:t.mode}),t.scaleMargins!==void 0){const e=Bt(t.scaleMargins.top),i=Bt(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 this.cn.mode===1}Mh(){return this.cn.mode===2}Oo(){return this.cn.mode===3}Cr(){return{Wn:this.cn.autoScale,Bo:this.cn.invertScale,Cr:this.cn.mode}}Ro(t){const e=this.Cr();let i=null;t.Wn!==void 0&&(this.cn.autoScale=t.Wn),t.Cr!==void 0&&(this.cn.mode=t.Cr,t.Cr!==2&&t.Cr!==3||(this.cn.autoScale=!0),this.oo._o=!1),e.Cr===1&&t.Cr!==e.Cr&&((function(r,o){if(r===null)return!1;const l=Ke(r.Ph(),o),h=Ke(r.Rh(),o);return isFinite(l)&&isFinite(h)})(this.Ih,this.xo)?(i=bi(this.Ih,this.xo),i!==null&&this.Ao(i)):this.cn.autoScale=!0),t.Cr===1&&t.Cr!==e.Cr&&(i=Xe(this.Ih,this.xo),i!==null&&this.Ao(i));const n=e.Cr!==this.cn.mode;n&&(e.Cr===2||this.Mh())&&this.Ra(),n&&(e.Cr===3||this.Oo())&&this.Ra(),t.Bo!==void 0&&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||i===null&&t!==null||i!==null&&!i.Ch(t))&&(this.bo=null,this.Ih=t)}Ni(){return this.Wo(),this.ho===0||!this.Ih||this.Ih.Ni()}jo(t){return this.Bo()?t:this.At()-1-t}Rt(t,e){return this.Mh()?t=Le(t,e):this.Oo()&&(t=je(t,e)),this.Po(t,e)}te(t,e,i){this.Wo();const n=this.Fo(),r=C(this.Lh()),o=r.Ph(),l=r.Rh(),h=this.Eo()-1,a=this.Bo(),c=h/(l-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,m=this.Ho();for(let d=u;d<p;d++){const f=t[d],g=f._t;if(isNaN(g))continue;let w=g;m!==null&&(w=m(f._t,e));const y=n+c*(w-o),_=a?y:this.ho-1-y;f.st=_}}be(t,e,i){this.Wo();const n=this.Fo(),r=C(this.Lh()),o=r.Ph(),l=r.Rh(),h=this.Eo()-1,a=this.Bo(),c=h/(l-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,m=this.Ho();for(let d=u;d<p;d++){const f=t[d];let g=f.ge,w=f.Me,y=f.xe,_=f.Se;m!==null&&(g=m(f.ge,e),w=m(f.Me,e),y=m(f.xe,e),_=m(f.Se,e));let k=n+c*(g-o),N=a?k:this.ho-1-k;f.pe=N,k=n+c*(w-o),N=a?k:this.ho-1-k,f.de=N,k=n+c*(y-o),N=a?k:this.ho-1-k,f.fe=N,k=n+c*(_-o),N=a?k:this.ho-1-k,f.me=N}}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(n,r){return r<0&&(n=-n),n/100*r+r})(i,e):this.Oo()&&(i=(function(n,r){return n-=100,r<0&&(n=-n),n/100*r+r})(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];i.Xi()===null&&i.Ki(e+1),t.push(i)}return t=jn(t),this.mo=t,this.mo}qo(t){this.po.indexOf(t)===-1&&(this.po.push(t),this.Ra(),this.Yo())}Zo(t){const e=this.po.indexOf(t);if(e===-1)throw new Error("source is not attached to scale");this.po.splice(e,1),this.po.length===0&&(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();i!==null&&(t===null||i.la<t.la)&&(t=i)}return t===null?null:t.Vt}Bo(){return this.cn.invertScale}Ha(){const t=this.Ct()===null;if(this.bo!==null&&(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()||this.wo===null&&this.ao===null&&(this.Ni()||(this.wo=this.ho-t,this.ao=C(this.Lh()).Th()))}Jo(t){if(this.Mh()||this.Oo()||this.wo===null)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=C(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()||this.Mo===null&&this.ao===null&&(this.Ni()||(this.Mo=t,this.ao=C(this.Lh()).Th()))}i_(t){if(this.Vo()||this.Mo===null)return;const e=C(this.Lh()).Dh()/(this.Eo()-1);let i=t-this.Mo;this.Bo()&&(i*=-1);const n=i*e,r=C(this.ao).Th();r.Oh(n),this.Ao(r,!0),this.bo=null}n_(){this.Vo()||this.Mo!==null&&(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_(Le(t,e));case 3:return this.ba().format(je(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,C(this.e_()).ba())}Zl(t,e){return t=Le(t,e),this.s_(t,Xn)}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;t!==null&&(e=Math.round(1/t.ma())),this.wa=Jn,this.Mh()?(this.wa=Xn,e=100):this.Oo()?(this.wa=new ui(100,1),e=100):t!==null&&(this.wa=t.ba()),this.Co=new Hn(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?gi(t,this.xo):t;const i=C(this.Lh()),n=this.Fo()+(this.Eo()-1)*(t-i.Ph())/i.Dh();return this.jo(n)}To(t,e){if(this.Wo(),this.Ni())return 0;const i=this.jo(t),n=C(this.Lh()),r=n.Ph()+n.Dh()*((i-this.Fo())/(this.Eo()-1));return this.ro()?Ke(r,this.xo):r}Io(){this.bo=null,this.Co.io()}l_(){const t=this.oo.uo;if(t===null)return;let e=null;const i=this.r_();let n=0,r=0;for(const h of i){if(!h.yt())continue;const a=h.Ct();if(a===null)continue;const c=h.Il(t.Os(),t.ui());let u=c&&c.Lh();if(u!==null){switch(this.cn.mode){case 1:u=Xe(u,this.xo);break;case 2:u=xh(u,a.Vt);break;case 3:u=Ch(u,a.Vt)}if(e=e===null?u:e.ts(C(u)),c!==null){const p=c.Eh();p!==null&&(n=Math.max(n,p.above),r=Math.max(r,p.below))}}}if(n===this.co&&r===this.do||(this.co=n,this.do=r,this.bo=null,this.Do()),e!==null){if(e.Ph()===e.Rh()){const h=this.e_(),a=5*(h===null||this.Mh()||this.Oo()?1:h.ma());this.ro()&&(e=bi(e,this.xo)),e=new Vt(e.Ph()-a,e.Rh()+a),this.ro()&&(e=Xe(e,this.xo))}if(this.ro()){const h=bi(e,this.xo),a=ns(h);if(o=a,l=this.xo,o.$a!==l.$a||o.Ua!==l.Ua){const c=this.ao!==null?bi(this.ao,this.xo):null;this.xo=a,e=Xe(h,a),c!==null&&(this.ao=Xe(c,a))}}this.Ao(e)}else this.Ih===null&&(this.Ao(new Vt(-.5,.5)),this.xo=ns(null));var o,l;this.oo._o=!0}Ho(){return this.Mh()?Le:this.Oo()?je:this.ro()?t=>gi(t,this.xo):null}a_(t,e,i){return e===void 0?(i===void 0&&(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 Th{constructor(t,e){this.po=[],this.o_=new Map,this.ho=0,this.__=0,this.u_=1e3,this.mo=null,this.c_=new xt,this.yl=t,this.$i=e,this.d_=new _h(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 n=C(i[0].Dt());n.$h(t.overlayPriceScales),t.localization&&n.Ra()}}}w_(t){switch(t){case"left":return this.f_;case"right":return this.p_}return this.o_.has(t)?Bt(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();i!==null&&i.Lo(t)}})),this.k_()}Ba(){return this.po}vr(t){const e=t.Dt();return e===null||this.f_!==e&&this.p_!==e}qo(t,e,i){const n=i!==void 0?i:this.C_().y_+1;this.T_(t,e,n)}Zo(t){const e=this.po.indexOf(t);de(e!==-1,"removeDataSource: invalid data source"),this.po.splice(e,1);const i=C(t.Dt()).Pa();if(this.o_.has(i)){const r=Bt(this.o_.get(i)),o=r.indexOf(t);o!==-1&&(r.splice(o,1),r.length===0&&this.o_.delete(i))}const n=t.Dt();n&&n.Ba().indexOf(t)>=0&&n.Zo(t),n!==null&&(n.Yo(),this.P_(n)),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&&this.p_.Ba().length!==0?t=this.p_:this.$i.W().leftPriceScale.visible&&this.f_.Ba().length!==0?t=this.f_:this.po.length!==0&&(t=this.po[0].Dt()),t===null&&(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){t!==null&&t.Vo()&&this.L_(t)}E_(t){const e=this.yl.Xs();t.Ro({Wn:!0}),e!==null&&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 this.mo===null&&(this.mo=jn(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 i=this.yl.Xs();i!==null&&t.h_(i)}t.Vn()}C_(){const t=this.Uo();if(t.length===0)return{H_:0,y_:0};let e=0,i=0;for(let n=0;n<t.length;n++){const r=t[n].Xi();r!==null&&(r<e&&(e=r),r>i&&(i=r))}return{H_:e,y_:i}}T_(t,e,i){let n=this.w_(e);if(n===null&&(n=this.v_(e,this.$i.W().overlayPriceScales)),this.po.push(t),!ci(e)){const r=this.o_.get(e)||[];r.push(t),this.o_.set(e,r)}n.qo(t),t.Gi(n),t.Ki(i),this.P_(n),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},ue(e)),n=new Eh(t,i,this.$i.W().layout,this.$i.W().localization);return n.Lo(this.At()),n}}class Mh{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),n=this.tr.get(i);if(n!==void 0)return n.Z_;if(this.Ke===this.ir){const o=this.Qe.get(this.Je);this.Qe.delete(this.Je),this.tr.delete(Bt(o)),this.Je++,this.Ke--}const r=this.U_(t);return this.tr.set(i,{Z_:r,rr:this.Ge}),this.Qe.set(this.Ge,i),this.Ke++,this.Ge++,r}}class Je{constructor(t,e){de(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 Gn(s,t){return s===null||t===null?s===t:s.Ch(t)}class kh{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 n=t[i];let r=this.J_.get(n.timeWeight);r===void 0&&(r=[],this.J_.set(n.timeWeight,r)),r.push({index:i,time:n.time,weight:n.timeWeight,originalTime:n.originalTime})}}su(t,e){const i=Math.ceil(e/t);return this.tr!==null&&this.tr.eu===i||(this.tr={Ha:this.ru(i),eu:i}),this.tr.Ha}nu(t){if(t===0)return void this.J_.clear();const e=[];this.J_.forEach(((i,n)=>{t<=i[0].index?e.push(n):i.splice(Ue(i,t,(r=>r.index<t)),1/0)}));for(const i of e)this.J_.delete(i)}ru(t){let e=[];for(const i of Array.from(this.J_.keys()).sort(((n,r)=>r-n))){if(!this.J_.get(i))continue;const n=e;e=[];const r=n.length;let o=0;const l=Bt(this.J_.get(i)),h=l.length;let a=1/0,c=-1/0;for(let u=0;u<h;u++){const p=l[u],m=p.index;for(;o<r;){const d=n[o],f=d.index;if(!(f<m)){a=f;break}o++,e.push(d),c=f,a=1/0}if(a-m>=t&&m-c>=t)e.push(p),c=m;else if(this.Q_)return n}for(;o<r;o++)e.push(n[o])}return e}}class Oe{constructor(t){this.hu=t}lu(){return this.hu===null?null:new Je(Math.floor(this.hu.Os()),Math.ceil(this.hu.ui()))}au(){return this.hu}static ou(){return new Oe(null)}}function Lh(s,t){return s.weight>t.weight?s:t}class Oh{constructor(t,e,i,n){this.__=0,this._u=null,this.uu=[],this.Mo=null,this.wo=null,this.cu=new kh,this.du=new Map,this.fu=Oe.ou(),this.vu=!0,this.pu=new xt,this.mu=new xt,this.bu=new xt,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_=n,this.ku(),this.cu.tu(e.uniformDistribution)}W(){return this.cn}yu(t){Gt(this.yo,t),this.Cu(),this.ku()}$h(t,e){var i;Gt(this.cn,t),this.cn.fixLeftEdge&&this.Tu(),this.cn.fixRightEdge&&this.Pu(),t.barSpacing!==void 0&&this.$i.Gn(t.barSpacing),t.rightOffset!==void 0&&this.$i.Jn(t.rightOffset),t.minBarSpacing!==void 0&&this.$i.Gn((i=t.barSpacing)!==null&&i!==void 0?i:this.Su),this.Cu(),this.ku(),this.bu.m()}mn(t){var e,i;return(i=(e=this.uu[t])===null||e===void 0?void 0:e.time)!==null&&i!==void 0?i:null}Ui(t){var e;return(e=this.uu[t])!==null&&e!==void 0?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=Ue(this.uu,this.q_.key(t),((n,r)=>this.q_.key(n.time)<r));return this.q_.key(t)<this.q_.key(this.uu[i].time)?e?i:null:i}Ni(){return this.__===0||this.uu.length===0||this._u===null}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(t===null)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),n=C(this.Bu()),r=C(this.Au());return{from:C(this.Ui(Math.max(n,e))),to:C(this.Ui(Math.min(r,i)))}}Iu(t){return{from:C(this.Va(t.from,!0)),to:C(this.Va(t.to,!0))}}Hi(){return this.__}S_(t){if(!isFinite(t)||t<=0||this.__===t)return;const e=this.Du(),i=this.__;if(this.__=t,this.vu=!0,this.cn.lockVisibleTimeRangeOnResize&&i!==0){const n=this.Su*t/i;this.Su=n}if(this.cn.fixLeftEdge&&e!==null&&e.Os()<=0){const n=i-t;this.xu-=Math.round(n/this.Su)+1,this.vu=!0}this.zu(),this.Lu()}It(t){if(this.Ni()||!Fe(t))return 0;const e=this.Eu()+this.xu-t;return this.__-(e+.5)*this.Su-1}Qs(t,e){const i=this.Eu(),n=e===void 0?0:e.from,r=e===void 0?t.length:e.to;for(let o=n;o<r;o++){const l=t[o].ot,h=i+this.xu-l,a=this.__-(h+.5)*this.Su-1;t[o].nt=a}}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(this.gu!==null)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),n=C(this.Xs()),r=Math.max(n.Os(),n.Os()-i),o=Math.max(n.ui(),n.ui()-i),l=this.cu.su(t,e),h=this.Bu()+i,a=this.Au()-i,c=this.$u(),u=this.cn.fixLeftEdge||c,p=this.cn.fixRightEdge||c;let m=0;for(const d of l){if(!(r<=d.index&&d.index<=o))continue;let f;m<this.Mu.length?(f=this.Mu[m],f.coord=this.It(d.index),f.label=this.Uu(d),f.weight=d.weight):(f={needAlignCoordinate:!1,coord:this.It(d.index),label:this.Uu(d),weight:d.weight},this.Mu.push(f)),this.Su>e/2&&!c?f.needAlignCoordinate=!1:f.needAlignCoordinate=u&&d.index<=h||p&&d.index>=a,m++}return this.Mu.length=m,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),n=this.le(),r=n+e*(n/10);this.Gn(r),this.cn.rightBarStaysOnScroll||this.Jn(this.Hu()+(i-this.Fu(t)))}Go(t){this.Mo&&this.n_(),this.wo===null&&this.wu===null&&(this.Ni()||(this.wo=t,this.Xu()))}Jo(t){if(this.wu===null)return;const e=Xi(this.__-t,0,this.__),i=Xi(this.__-C(this.wo),0,this.__);e!==0&&i!==0&&this.Gn(this.wu.le*e/i)}Qo(){this.wo!==null&&(this.wo=null,this.Ku())}t_(t){this.Mo===null&&this.wu===null&&(this.Ni()||(this.Mo=t,this.Xu()))}i_(t){if(this.Mo===null)return;const e=(this.Mo-t)/this.le();this.xu=C(this.wu).Hu+e,this.vu=!0,this.Lu()}n_(){this.Mo!==null&&(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,n=performance.now();this.$i.Zn({Qu:r=>(r-n)/e>=1,tc:r=>{const o=(r-n)/e;return o>=1?t:i+(t-i)*o}})}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();t!==null&&e!==null&&this.rc(new Je(t,e+this.cn.rightOffset))}lc(t){const e=new Je(t.from,t.to);this.rc(e)}qi(t){return this.yo.timeFormatter!==void 0?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 this.uu.length===0?null:0}Au(){return this.uu.length===0?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(Oe.ou());const t=this.Eu(),e=this.__/this.Su,i=this.xu+t,n=new Je(i-e+1,i);this._c(new Oe(n))}zu(){const t=this.uc();if(this.Su<t&&(this.Su=t,this.vu=!0),this.__!==0){const e=.5*this.__;this.Su>e&&(this.Su=e,this.vu=!0)}}uc(){return this.cn.fixLeftEdge&&this.cn.fixRightEdge&&this.uu.length!==0?this.__/this.uu.length:this.cn.minBarSpacing}Lu(){const t=this.cc();t!==null&&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 t===null||e===null?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 e===void 0&&(e=new Mh((i=>this.fc(i)),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,Gn(e.lu(),this.fu.lu())||this.pu.m(),Gn(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(t===null)return;const e=this.Xs();if(e===null)return;const i=e.Os()-t;if(i<0){const n=this.xu-i-1;this.Jn(n)}this.zu()}Pu(){this.Lu(),this.zu()}}class Rh{X(t,e,i){t.useMediaCoordinateSpace((n=>this.K(n,e,i)))}gl(t,e,i){t.useMediaCoordinateSpace((n=>this.vc(n,e,i)))}vc(t,e,i){}}class zh extends Rh{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 n=0;for(const o of this.zt.bc){if(o.Kt.length===0)continue;e.font=o.R;const l=this.wc(e,o.Kt);l>i.width?o.Zu=i.width/l:o.Zu=1,n+=o.gc*o.Zu}let r=0;switch(this.zt.Mc){case"top":r=0;break;case"center":r=Math.max((i.height-n)/2,0);break;case"bottom":r=Math.max(i.height-n,0)}e.fillStyle=this.zt.V;for(const o of this.zt.bc){e.save();let l=0;switch(this.zt.xc){case"left":e.textAlign="left",l=o.gc/2;break;case"center":e.textAlign="center",l=i.width/2;break;case"right":e.textAlign="right",l=i.width-1-o.gc/2}e.translate(l,r),e.textBaseline="top",e.font=o.R,e.scale(o.Zu,o.Zu),e.fillText(o.Kt,0,o.Sc),e.restore(),r+=o.gc*o.Zu}}wc(t,e){const i=this.kc(t.font);let n=i.get(e);return n===void 0&&(n=t.measureText(e).width,i.set(e,n)),n}kc(t){let e=this.mc.get(t);return e===void 0&&(e=new Map,this.mc.set(t,e)),e}}class Nh{constructor(t){this.ft=!0,this.Ft={yt:!1,V:"",bc:[],Mc:"center",xc:"center"},this.Wt=new zh(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:ke(t.fontSize,t.fontFamily,t.fontStyle),gc:1.2*t.fontSize,Sc:0,Zu:0}])}}class Ph extends ji{constructor(t,e){super(),this.cn=e,this.wn=new Nh(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}Vn(){this.wn.bt()}}var Yn,Qn,Zn,tr,er;(function(s){s[s.OnTouchEnd=0]="OnTouchEnd",s[s.OnNextTap=1]="OnNextTap"})(Yn||(Yn={}));class Dh{constructor(t,e,i){this.yc=[],this.Cc=[],this.__=0,this.Tc=null,this.Pc=new xt,this.Rc=new xt,this.Dc=null,this.Vc=t,this.cn=e,this.q_=i,this.Oc=new dl(this),this.yl=new Oh(this,e.timeScale,this.cn.localization,i),this.vt=new Cl(this,e.crosshair),this.Bc=new yh(e.crosshair),this.Ac=new Ph(this,e.watermark),this.Ic(),this.yc[0].x_(2e3),this.zc=this.Lc(0),this.Ec=this.Lc(1)}Kl(){this.Nc(Ot.es())}Uh(){this.Nc(Ot.ss())}oa(){this.Nc(new Ot(1))}Gl(t){const e=this.Fc(t);this.Nc(e)}Wc(){return this.Tc}jc(t){const e=this.Tc;this.Tc=t,e!==null&&this.Gl(e.Hc),t!==null&&this.Gl(t.Hc)}W(){return this.cn}$h(t){Gt(this.cn,t),this.yc.forEach((e=>e.b_(t))),t.timeScale!==void 0&&this.yl.$h(t.timeScale),t.localization!==void 0&&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(t==="left")return void this.$h({leftPriceScale:e});if(t==="right")return void this.$h({rightPriceScale:e});const i=this.Uc(t);i!==null&&(i.Dt.$h(e),this.Pc.m())}Uc(t){for(const e of this.yc){const i=e.w_(t);if(i!==null)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 Th(this.yl,this);t!==void 0?this.yc.splice(t,0,e):this.yc.push(e);const i=t===void 0?this.yc.length-1:t,n=Ot.es();return n.Nn(i,{Fn:0,Wn:!0}),this.Nc(n),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()||e===0)return;const n=i.Hi();t=Math.max(1,Math.min(t,n)),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,n,r){this.vt.gn(t,e);let o=NaN,l=this.yl.Nu(t);const h=this.yl.Xs();h!==null&&(l=Math.min(Math.max(h.Os(),l),h.ui()));const a=n.vn(),c=a.Ct();c!==null&&(o=a.pn(e,c)),o=this.Bc.Oa(o,l,n),this.vt.kn(l,o,n),this.oa(),r||this.Rc.m(this.vt.xt(),{x:t,y:e},i)}ad(t,e,i){const n=i.vn(),r=n.Ct(),o=n.Rt(t,C(r)),l=this.yl.Va(e,!0),h=this.yl.It(C(l));this.ld(h,o,null,i,!0)}od(t){this.Zc().Cn(),this.oa(),t||this.Rc.m(null,null,null)}Jl(){const t=this.vt.Ht();if(t!==null){const e=this.vt.xn(),i=this.vt.Sn();this.ld(e,i,null,t)}this.vt.Vn()}_d(t,e,i){const n=this.yl.mn(0);e!==void 0&&i!==void 0&&this.yl.bt(e,i);const r=this.yl.mn(0),o=this.yl.Eu(),l=this.yl.Xs();if(l!==null&&n!==null&&r!==null){const h=l.Kr(o),a=this.q_.key(n)>this.q_.key(r),c=t!==null&&t>o&&!a,u=this.yl.W().allowShiftVisibleRangeOnWhitespaceReplacement,p=h&&(i!==void 0||u)&&this.yl.W().shiftVisibleRangeOnNewBar;if(c&&!p){const m=t-o;this.yl.Jn(this.yl.Hu()-m)}}this.yl.Yu(t)}ia(t){t!==null&&t.F_()}dr(t){const e=this.yc.find((i=>i.Uo().includes(t)));return e===void 0?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 n=this.yc[0],r=this.fd(e,t,n,i);return this.Cc.push(r),this.Cc.length===1?this.Kl():this.Uh(),r}vd(t){const e=this.dr(t),i=this.Cc.indexOf(t);de(i!==-1,"Series not found"),this.Cc.splice(i,1),C(e).Zo(t),t.S&&t.S()}Xl(t,e){const i=C(this.dr(t));i.Zo(t);const n=this.Uc(e);if(n===null){const r=t.Xi();i.qo(t,e,r)}else{const r=n.Ht===i?t.Xi():void 0;n.Ht.qo(t,e,r)}}hc(){const t=Ot.ss();t.$n(),this.Nc(t)}pd(t){const e=Ot.ss();e.Yn(t),this.Nc(e)}Kn(){const t=Ot.ss();t.Kn(),this.Nc(t)}Gn(t){const e=Ot.ss();e.Gn(t),this.Nc(e)}Jn(t){const e=Ot.ss();e.Jn(t),this.Nc(e)}Zn(t){const e=Ot.ss();e.Zn(t),this.Nc(e)}Un(){const t=Ot.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))),this.Dc===null||this.Dc.Ps!==i||this.Dc.Rs!==e)this.Dc={Ps:i,Rs:e,wd:new Map};else{const r=this.Dc.wd.get(t);if(r!==void 0)return r}const n=(function(r,o,l){const[h,a,c,u]=Ve(r),[p,m,d,f]=Ve(o),g=[qt(h+l*(p-h)),qt(a+l*(m-a)),qt(c+l*(d-c)),dn(u+l*(f-u))];return`rgba(${g[0]}, ${g[1]}, ${g[2]}, ${g[3]})`})(i,e,t/100);return this.Dc.wd.set(t,n),n}Gc(t,e){const i=new Ot(e);if(t!==null){const n=this.yc.indexOf(t);i.Nn(n,{Fn:e})}return i}Fc(t,e){return e===void 0&&(e=2),this.Gc(this.dr(t),e)}Nc(t){this.Vc&&this.Vc(t),this.yc.forEach((e=>e.j_().qh().bt()))}fd(t,e,i,n){const r=new is(this,t,e,i,n),o=t.priceScaleId!==void 0?t.priceScaleId:this.md();return i.qo(r,o),ci(o)||r.$h(t),r}Lc(t){const e=this.cn.layout;return e.background.type==="gradient"?t===0?e.background.topColor:e.background.bottomColor:e.background.color}}function os(s){return!te(s)&&!$e(s)}function ir(s){return te(s)}(function(s){s[s.Disabled=0]="Disabled",s[s.Continuous=1]="Continuous",s[s.OnDataUpdate=2]="OnDataUpdate"})(Qn||(Qn={})),(function(s){s[s.LastBar=0]="LastBar",s[s.LastVisible=1]="LastVisible"})(Zn||(Zn={})),(function(s){s.Solid="solid",s.VerticalGradient="gradient"})(tr||(tr={})),(function(s){s[s.Year=0]="Year",s[s.Month=1]="Month",s[s.DayOfMonth=2]="DayOfMonth",s[s.Time=3]="Time",s[s.TimeWithSeconds=4]="TimeWithSeconds"})(er||(er={}));const sr=s=>s.getUTCFullYear();function Ah(s,t,e){return t.replace(/yyyy/g,(i=>fe(sr(i),4))(s)).replace(/yy/g,(i=>fe(sr(i)%100,2))(s)).replace(/MMMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"long"}))(s,e)).replace(/MMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"short"}))(s,e)).replace(/MM/g,(i=>fe((n=>n.getUTCMonth()+1)(i),2))(s)).replace(/dd/g,(i=>fe((n=>n.getUTCDate())(i),2))(s))}class nr{constructor(t="yyyy-MM-dd",e="default"){this.gd=t,this.Md=e}Y_(t){return Ah(t,this.gd,this.Md)}}class Bh{constructor(t){this.xd=t||"%h:%m:%s"}Y_(t){return this.xd.replace("%h",fe(t.getUTCHours(),2)).replace("%m",fe(t.getUTCMinutes(),2)).replace("%s",fe(t.getUTCSeconds(),2))}}const Vh={Sd:"yyyy-MM-dd",kd:"%h:%m:%s",yd:" ",Cd:"default"};class Fh{constructor(t={}){const e=Object.assign(Object.assign({},Vh),t);this.Td=new nr(e.Sd,e.Cd),this.Pd=new Bh(e.kd),this.Rd=e.yd}Y_(t){return`${this.Td.Y_(t)}${this.Rd}${this.Pd.Y_(t)}`}}function vi(s){return 60*s*60*1e3}function ls(s){return 60*s*1e3}const yi=[{Dd:(rr=1,1e3*rr),Vd:10},{Dd:ls(1),Vd:20},{Dd:ls(5),Vd:21},{Dd:ls(30),Vd:22},{Dd:vi(1),Vd:30},{Dd:vi(3),Vd:31},{Dd:vi(6),Vd:32},{Dd:vi(12),Vd:33}];var rr;function or(s,t){if(s.getUTCFullYear()!==t.getUTCFullYear())return 70;if(s.getUTCMonth()!==t.getUTCMonth())return 60;if(s.getUTCDate()!==t.getUTCDate())return 50;for(let e=yi.length-1;e>=0;--e)if(Math.floor(t.getTime()/yi[e].Dd)!==Math.floor(s.getTime()/yi[e].Dd))return yi[e].Vd;return 0}function hs(s){let t=s;if($e(s)&&(t=as(s)),!os(t))throw new Error("time must be of type BusinessDay");const e=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{Od:Math.round(e.getTime()/1e3),Bd:t}}function lr(s){if(!ir(s))throw new Error("time must be of type isUTCTimestamp");return{Od:s}}function as(s){const t=new Date(s);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${s}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function hr(s){$e(s.time)&&(s.time=as(s.time))}class ar{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?(function(e){e.forEach(hr)})(t):hr(t)}createConverterToInternalObj(t){return C((function(e){return e.length===0?null:os(e[0].time)||$e(e[0].time)?hs:lr})(t))}key(t){return typeof t=="object"&&"Od"in t?t.Od:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const e=t;return e.Bd===void 0?new Date(1e3*e.Od).getTime():new Date(Date.UTC(e.Bd.year,e.Bd.month-1,e.Bd.day)).getTime()}convertHorzItemToInternal(t){return ir(e=t)?lr(e):os(e)?hs(e):hs(as(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.Ad=new Fh({Sd:e,kd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",yd:" ",Cd:t.locale}):this.Ad=new nr(e,t.locale)}formatHorzItem(t){const e=t;return this.Ad.Y_(new Date(1e3*e.Od))}formatTickmark(t,e){const i=(function(r,o,l){switch(r){case 0:case 10:return o?l?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}})(t.weight,this.cn.timeScale.timeVisible,this.cn.timeScale.secondsVisible),n=this.cn.timeScale;if(n.tickMarkFormatter!==void 0){const r=n.tickMarkFormatter(t.originalTime,i,e.locale);if(r!==null)return r}return(function(r,o,l){const h={};switch(o){case 0:h.year="numeric";break;case 1:h.month="short";break;case 2:h.day="numeric";break;case 3:h.hour12=!1,h.hour="2-digit",h.minute="2-digit";break;case 4:h.hour12=!1,h.hour="2-digit",h.minute="2-digit",h.second="2-digit"}const a=r.Bd===void 0?new Date(1e3*r.Od):new Date(Date.UTC(r.Bd.year,r.Bd.month-1,r.Bd.day));return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()).toLocaleString(l,h)})(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(Lh,t[0]).weight;return e>30&&e<50&&(e=30),e}fillWeightsForPoints(t,e){(function(i,n=0){if(i.length===0)return;let r=n===0?null:i[n-1].time.Od,o=r!==null?new Date(1e3*r):null,l=0;for(let h=n;h<i.length;++h){const a=i[h],c=new Date(1e3*a.time.Od);o!==null&&(a.timeWeight=or(c,o)),l+=a.time.Od-(r||a.time.Od),r=a.time.Od,o=c}if(n===0&&i.length>1){const h=Math.ceil(l/(i.length-1)),a=new Date(1e3*(i[0].time.Od-h));i[0].timeWeight=or(new Date(1e3*i[0].time.Od),a)}})(t,e)}static Id(t){return Gt({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Re=typeof window<"u";function cr(){return!!Re&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function cs(){return!!Re&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function us(s){return s+s%2}function fs(s,t){return s.zd-t.zd}function ds(s,t,e){const i=(s.zd-t.zd)/(s.ot-t.ot);return Math.sign(i)*Math.min(Math.abs(i),e)}class $h{constructor(t,e,i,n){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=n}Yd(t,e){if(this.Ld!==null){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(this.Ld===null||this.Ed===null||e-this.Ld.ot>50)return;let i=0;const n=ds(this.Ld,this.Ed,this.Ud),r=fs(this.Ld,this.Ed),o=[n],l=[r];if(i+=r,this.Nd!==null){const a=ds(this.Ed,this.Nd,this.Ud);if(Math.sign(a)===Math.sign(n)){const c=fs(this.Ed,this.Nd);if(o.push(a),l.push(c),i+=c,this.Fd!==null){const u=ds(this.Nd,this.Fd,this.Ud);if(Math.sign(u)===Math.sign(n)){const p=fs(this.Nd,this.Fd);o.push(u),l.push(p),i+=p}}}}let h=0;for(let a=0;a<o.length;++a)h+=l[a]/i*o[a];Math.abs(h)<this.$d||(this.Wd={zd:t,ot:e},this.Hd=h,this.jd=(function(a,c){const u=Math.log(c);return Math.log(1*u/-a)/u})(Math.abs(h),this.qd))}tc(t){const e=C(this.Wd),i=t-e.ot;return e.zd+this.Hd*(Math.pow(this.qd,i)-1)/Math.log(this.qd)}Qu(t){return this.Wd===null||this.Zd(t)===this.jd}Zd(t){const e=t-C(this.Wd).ot;return Math.min(e,this.jd)}}class Ih{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 pn(Ve(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",this.Gd==="dark"),this.Jd.appendChild(this.Kd),this.Jd.appendChild(this.Xd)))}}function we(s,t){const e=C(s.ownerDocument).createElement("canvas");s.appendChild(e);const i=Qo(e,{options:{allowResizeObserver:!1},transform:(n,r)=>({width:Math.max(n.width,r.width),height:Math.max(n.height,r.height)})});return i.resizeCanvasElement(t),i}function Se(s){var t;s.width=1,s.height=1,(t=s.getContext("2d"))===null||t===void 0||t.clearRect(0,0,1,1)}function ps(s,t,e,i){s.gl&&s.gl(t,e,i)}function wi(s,t,e,i){s.X(t,e,i)}function ms(s,t,e,i){const n=s(e,i);for(const r of n){const o=r.gt();o!==null&&t(o)}}function Uh(s){Re&&window.chrome!==void 0&&s.addEventListener("mousedown",(t=>{if(t.button===1)return t.preventDefault(),!1}))}class gs{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=!cs(),this.Af=n=>{this.If(n)},this.zf=n=>{if(this.Lf(n)){const r=this.Ef(n);if(++this._f,this.uf&&this._f>1){const{Nf:o}=this.Ff(ee(n),this.cf);o<30&&!this.wf&&this.Wf(r,this.Hf.jf),this.$f()}}else{const r=this.Ef(n);if(++this.hf,this.lf&&this.hf>1){const{Nf:o}=this.Ff(ee(n),this.af);o<5&&!this.bf&&this.Uf(r,this.Hf.qf),this.Yf()}}},this.Zf=t,this.Hf=e,this.cn=i,this.Xf()}S(){this.gf!==null&&(this.gf(),this.gf=null),this.Mf!==null&&(this.Mf(),this.Mf=null),this.Sf!==null&&(this.Sf(),this.Sf=null),this.kf!==null&&(this.kf(),this.kf=null),this.yf!==null&&(this.yf(),this.yf=null),this.xf!==null&&(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(){this.lf!==null&&clearTimeout(this.lf),this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}$f(){this.uf!==null&&clearTimeout(this.uf),this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY}}Jf(t){if(this.Df||this.pf!==null||this.Lf(t))return;const e=this.Ef(t);this.Uf(e,this.Hf.tv),this.Bf=!0}iv(t){const e=bs(t.changedTouches,C(this.Of));if(e===null||(this.Vf=Si(t),this.Cf!==null)||this.Rf)return;this.Pf=!0;const i=this.Ff(ee(e),C(this.pf)),{nv:n,sv:r,Nf:o}=i;if(this.mf||!(o<5)){if(!this.mf){const l=.5*n,h=r>=l&&!this.cn.ev(),a=l>r&&!this.cn.rv();h||a||(this.Rf=!0),this.mf=!0,this.wf=!0,this.Kf(),this.$f()}if(!this.Rf){const l=this.Ef(t,e);this.Wf(l,this.Hf.hv),ze(t)}}}lv(t){if(t.button!==0)return;const e=this.Ff(ee(t),C(this.vf)),{Nf:i}=e;if(i>=5&&(this.bf=!0,this.Yf()),this.bf){const n=this.Ef(t);this.Uf(n,this.Hf.av)}}Ff(t,e){const i=Math.abs(e.nt-t.nt),n=Math.abs(e.st-t.st);return{nv:i,sv:n,Nf:i+n}}ov(t){let e=bs(t.changedTouches,C(this.Of));if(e===null&&t.touches.length===0&&(e=t.changedTouches[0]),e===null)return;this.Of=null,this.Vf=Si(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:n}=this.Ff(ee(e),this.cf);n<30&&!this.wf&&this.Wf(i,this.Hf.jf),this.$f()}else this.wf||(this.Wf(i,this.Hf.uv),this.Hf.uv&&ze(t));this._f===0&&ze(t),t.touches.length===0&&this.ff&&(this.ff=!1,ze(t))}If(t){if(t.button!==0)return;const e=this.Ef(t);if(this.vf=null,this.Df=!1,this.kf&&(this.kf(),this.kf=null),cr()&&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(ee(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(){this.df!==null&&(clearTimeout(this.df),this.df=null)}fv(t){if(this.Of!==null)return;const e=t.changedTouches[0];this.Of=e.identifier,this.Vf=Si(t);const i=this.Zf.ownerDocument.documentElement;this.wf=!1,this.mf=!1,this.Rf=!1,this.pf=ee(e),this.yf&&(this.yf(),this.yf=null);{const r=this.iv.bind(this),o=this.ov.bind(this);this.yf=()=>{i.removeEventListener("touchmove",r),i.removeEventListener("touchend",o)},i.addEventListener("touchmove",r,{passive:!1}),i.addEventListener("touchend",o,{passive:!1}),this.Kf(),this.df=setTimeout(this.vv.bind(this,t),240)}const n=this.Ef(t,e);this.Wf(n,this.Hf.pv),this.uf||(this._f=0,this.uf=setTimeout(this.$f.bind(this),500),this.cf=ee(e))}mv(t){if(t.button!==0)return;const e=this.Zf.ownerDocument.documentElement;cr()&&e.addEventListener("mouseleave",this.Af),this.bf=!1,this.vf=ee(t),this.kf&&(this.kf(),this.kf=null);{const n=this.lv.bind(this),r=this.If.bind(this);this.kf=()=>{e.removeEventListener("mousemove",n),e.removeEventListener("mouseup",r)},e.addEventListener("mousemove",n),e.addEventListener("mouseup",r)}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=ee(t))}Xf(){this.Zf.addEventListener("mouseenter",this.Gf.bind(this)),this.Zf.addEventListener("touchcancel",this.Kf.bind(this));{const t=this.Zf.ownerDocument,e=i=>{this.Hf.wv&&(i.composed&&this.Zf.contains(i.composedPath()[0])||i.target&&this.Zf.contains(i.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})}cs()&&(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}),Uh(this.Zf),this.Zf.addEventListener("mousedown",this.mv.bind(this)),this.Mv(),this.Zf.addEventListener("touchmove",(()=>{}),{passive:!1})}Mv(){this.Hf.xv===void 0&&this.Hf.Sv===void 0&&this.Hf.kv===void 0||(this.Zf.addEventListener("touchstart",(t=>this.yv(t.touches)),{passive:!0}),this.Zf.addEventListener("touchmove",(t=>{if(t.touches.length===2&&this.Cf!==null&&this.Hf.Sv!==void 0){const e=ur(t.touches[0],t.touches[1])/this.Tf;this.Hf.Sv(this.Cf,e),ze(t)}}),{passive:!1}),this.Zf.addEventListener("touchend",(t=>{this.yv(t.touches)})))}yv(t){t.length===1&&(this.Pf=!1),t.length!==2||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=ur(t[0],t[1]),this.Hf.xv!==void 0&&this.Hf.xv(),this.Kf()}Cv(){this.Cf!==null&&(this.Cf=null,this.Hf.kv!==void 0&&this.Hf.kv())}gv(t){if(this.Sf&&this.Sf(),this.Lf(t)||!this.Bf)return;const e=this.Ef(t);this.Uf(e,this.Hf.Pv),this.Bf=!cs()}vv(t){const e=bs(t.touches,C(this.Of));if(e===null)return;const i=this.Ef(t,e);this.Wf(i,this.Hf.Rv),this.wf=!0,this.ff=!0}Lf(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:Si(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,n=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-n.left,localY:i.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Dv:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",Vv:t.type,Ov:i.target,Bv:t.view,Av:()=>{t.type!=="touchstart"&&ze(t)}}}}function ur(s,t){const e=s.clientX-t.clientX,i=s.clientY-t.clientY;return Math.sqrt(e*e+i*i)}function ze(s){s.cancelable&&s.preventDefault()}function ee(s){return{nt:s.pageX,st:s.pageY}}function Si(s){return s.timeStamp||performance.now()}function bs(s,t){for(let e=0;e<s.length;++e)if(s[e].identifier===t)return s[e];return null}function _i(s){return{Hc:s.Hc,Iv:{gr:s.zv.externalId},Lv:s.zv.cursorStyle}}function Wh(s,t,e){for(const i of s){const n=i.gt();if(n!==null&&n.wr){const r=n.wr(t,e);if(r!==null)return{Bv:i,Iv:r}}}return null}function vs(s,t){return e=>{var i,n,r,o;return((n=(i=e.Dt())===null||i===void 0?void 0:i.Pa())!==null&&n!==void 0?n:"")!==t?[]:(o=(r=e.da)===null||r===void 0?void 0:r.call(e,s))!==null&&o!==void 0?o:[]}}function fr(s,t,e,i){if(!s.length)return;let n=0;const r=e/2,o=s[0].At(i,!0);let l=t===1?r-(s[0].Vi()-o/2):s[0].Vi()-o/2-r;l=Math.max(0,l);for(let h=1;h<s.length;h++){const a=s[h],c=s[h-1],u=c.At(i,!1),p=a.Vi(),m=c.Vi();if(t===1?p>m-u:p<m+u){const d=m-u*t;a.Oi(d);const f=d-t*u/2;if((t===1?f<0:f>e)&&l>0){const g=t===1?-1-f:f-e,w=Math.min(g,l);for(let y=n;y<s.length;y++)s[y].Oi(s[y].Vi()+t*w);l-=w}}else n=h,l=t===1?m-u-p:p-(m+u)}}class dr{constructor(t,e,i,n){this.Li=null,this.Ev=null,this.Nv=!1,this.Fv=new We(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=n==="left",this.Yv=vs("normal",n),this.Zv=vs("top",n),this.Xv=vs("bottom",n),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=we(this.Kv,ft({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv);const r=this.Gv.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Jv=we(this.Kv,ft({width:16,height:16})),this.Jv.subscribeSuggestedBitmapSizeChanged(this.Uv);const o=this.Jv.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const l={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 gs(this.Jv.canvasElement,l,{ev:()=>!this.cn.handleScroll.vertTouchDrag,rv:()=>!0})}S(){this.hp.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),Se(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Se(this.Gv.canvasElement),this.Gv.dispose(),this.Li!==null&&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(this.Li===null)return 0;let t=0;const e=this.ap(),i=C(this.Gv.canvasElement.getContext("2d"));i.save();const n=this.Li.Ha();i.font=this._p(),n.length>0&&(t=Math.max(this.Fv.xi(i,n[0].so),this.Fv.xi(i,n[n.length-1].so)));const r=this.up();for(let a=r.length;a--;){const c=this.Fv.xi(i,r[a].Kt());c>t&&(t=c)}const o=this.Li.Ct();if(o!==null&&this.Ev!==null&&(l=this.cn.crosshair).mode!==2&&l.horzLine.visible&&l.horzLine.labelVisible){const a=this.Li.pn(1,o),c=this.Li.pn(this.Ev.height-2,o);t=Math.max(t,this.Fv.xi(i,this.Li.Fi(Math.floor(Math.min(a,c))+.11111111111111,o)),this.Fv.xi(i,this.Li.Fi(Math.ceil(Math.max(a,c))-.11111111111111,o)))}var l;i.restore();const h=t||34;return us(Math.ceil(e.C+e.T+e.A+e.I+5+h))}cp(t){this.Ev!==null&&be(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 C(this.Ev).width}Gi(t){this.Li!==t&&(this.Li!==null&&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,C(this.Dt()))}vp(t){if(this.Ev===null)return;if(t!==1){this.pp(),this.Gv.applySuggestedBitmapSize();const i=ve(this.Gv);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.mp(n),this.Ie(n)})),this.tn.bp(i,this.Xv),this.wp(i),this.tn.bp(i,this.Yv),this.gp(i))}this.Jv.applySuggestedBitmapSize();const e=ve(this.Jv);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.Mp(e),this.tn.bp(e,this.Zv))}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const n=this.xp();n.width>0&&n.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}bt(){var t;(t=this.Li)===null||t===void 0||t.Ha()}Qv(t){if(this.Li===null||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(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.tn.$v().$t(),i=this.tn.fp(),n=this.Li;e.O_(i,n,t.localY)}ip(){if(this.Li===null||!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(this.Li===null||!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){this.Li!==null&&(!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=this.Li===null?void 0:this.Li;return(i=>{for(let n=0;n<i.length;++n){const r=i[n].Rn(this.tn.fp(),e);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.tn.fp().Uo()),t}mp({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.tn.fp().$t(),o=r.q(),l=r.bd();o===l?hi(t,0,0,i,n,o):bn(t,0,0,i,n,o,l)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i}){if(this.Ev===null||this.Li===null||!this.Li.W().borderVisible)return;t.fillStyle=this.Li.W().borderColor;const n=Math.max(1,Math.floor(this.ap().C*i));let r;r=this.qv?e.width-n:0,t.fillRect(r,0,n,e.height)}wp(t){if(this.Ev===null||this.Li===null)return;const e=this.Li.Ha(),i=this.Li.W(),n=this.ap(),r=this.qv?this.Ev.width-n.T:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace((({context:o,horizontalPixelRatio:l,verticalPixelRatio:h})=>{o.fillStyle=i.borderColor;const a=Math.max(1,Math.floor(h)),c=Math.floor(.5*h),u=Math.round(n.T*l);o.beginPath();for(const p of e)o.rect(Math.floor(r*l),Math.round(p.Ea*h)-c,u,a);o.fill()})),t.useMediaCoordinateSpace((({context:o})=>{var l;o.font=this._p(),o.fillStyle=(l=i.textColor)!==null&&l!==void 0?l:this.ko.textColor,o.textAlign=this.qv?"right":"left",o.textBaseline="middle";const h=this.qv?Math.round(r-n.A):Math.round(r+n.T+n.A),a=e.map((c=>this.Fv.Mi(o,c.so)));for(let c=e.length;c--;){const u=e[c];o.fillText(u.so,h,u.Ea+a[c])}}))}pp(){if(this.Ev===null||this.Li===null)return;const t=[],e=this.Li.Uo().slice(),i=this.tn.fp(),n=this.ap();this.Li===i.pr()&&this.tn.fp().Uo().forEach((o=>{i.vr(o)&&e.push(o)}));const r=this.Li;e.forEach((o=>{o.Rn(i,r).forEach((l=>{l.Oi(null),l.Bi()&&t.push(l)}))})),t.forEach((o=>o.Oi(o.ki()))),this.Li.W().alignLabels&&this.yp(t,n)}yp(t,e){if(this.Ev===null)return;const i=this.Ev.height/2,n=t.filter((o=>o.ki()<=i)),r=t.filter((o=>o.ki()>i));n.sort(((o,l)=>l.ki()-o.ki())),r.sort(((o,l)=>o.ki()-l.ki()));for(const o of t){const l=Math.floor(o.At(e)/2),h=o.ki();h>-l&&h<l&&o.Oi(l),h>this.Ev.height-l&&h<this.Ev.height+l&&o.Oi(this.Ev.height-l)}fr(n,1,this.Ev.height,e),fr(r,-1,this.Ev.height,e)}gp(t){if(this.Ev===null)return;const e=this.up(),i=this.ap(),n=this.qv?"right":"left";e.forEach((r=>{r.Ai()&&r.gt(C(this.Li)).X(t,i,this.Fv,n)}))}Mp(t){if(this.Ev===null||this.Li===null)return;const e=this.tn.$v().$t(),i=[],n=this.tn.fp(),r=e.Zc().Rn(n,this.Li);r.length&&i.push(r);const o=this.ap(),l=this.qv?"right":"left";i.forEach((h=>{h.forEach((a=>{a.gt(C(this.Li)).X(t,o,this.Fv,l)}))}))}kp(t){this.Kv.style.cursor=t===1?"ns-resize":"default"}fo(){const t=this.op();this.Wv<t&&this.tn.$v().$t().Kl(),this.Wv=t}_p(){return ke(this.ko.fontSize,this.ko.fontFamily)}}function qh(s,t){var e,i;return(i=(e=s.ua)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function xi(s,t){var e,i;return(i=(e=s.Pn)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function Hh(s,t){var e,i;return(i=(e=s.Ji)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function jh(s,t){var e,i;return(i=(e=s.aa)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}class ys{constructor(t,e){this.Ev=ft({width:0,height:0}),this.Cp=null,this.Tp=null,this.Pp=null,this.Rp=null,this.Dp=!1,this.Vp=new xt,this.Op=new xt,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||this.Np===null||this.$i().Uh()},this.Uv=()=>{this.jv||this.Np===null||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=we(i,ft({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=we(i,ft({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",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 gs(this.Jv.canvasElement,this,{ev:()=>this.Ip===null&&!this.Qd.W().handleScroll.vertTouchDrag,rv:()=>this.Ip===null&&!this.Qd.W().handleScroll.horzTouchDrag})}S(){this.Cp!==null&&this.Cp.S(),this.Tp!==null&&this.Tp.S(),this.Pp=null,this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),Se(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Se(this.Gv.canvasElement),this.Gv.dispose(),this.Np!==null&&this.Np.W_().p(this),this.hp.S()}fp(){return C(this.Np)}qp(t){var e,i;this.Np!==null&&this.Np.W_().p(this),this.Np=t,this.Np!==null&&this.Np.W_().l(ys.prototype.Fp.bind(this),this,!0),this.Up(),this.Qd.Yp().indexOf(this)===this.Qd.Yp().length-1?(this.Pp=(e=this.Pp)!==null&&e!==void 0?e:new Ih(this.Wp,this.Qd),this.Pp.bt()):((i=this.Pp)===null||i===void 0||i.if(),this.Pp=null)}$v(){return this.Qd}lp(){return this.$p}Up(){if(this.Np!==null&&(this.Zp(),this.$i().wt().length!==0)){if(this.Cp!==null){const t=this.Np.R_();this.Cp.Gi(C(t))}if(this.Tp!==null){const t=this.Np.D_();this.Tp.Gi(C(t))}}}Xp(){this.Cp!==null&&this.Cp.bt(),this.Tp!==null&&this.Tp.bt()}M_(){return this.Np!==null?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,n=t.localY;this.Gp(i,n,t);const r=this.wr(i,n);this.Qd.Qp((e=r?.Lv)!==null&&e!==void 0?e:null),this.$i().jc(r&&{Hc:r.Hc,Iv:r.Iv})}dv(t){this.Np!==null&&(this.Kp(),this.tm(t))}qf(t){this.Np!==null&&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){this.Np!==null&&(this.Kp(),this.Ap=!1,this.sm(t))}uv(t){this.Np!==null&&this.tm(t)}Rv(t){if(this.Ap=!0,this.Ip===null){const e={x:t.localX,y:t.localY};this.rm(e,e,t)}}Pv(t){this.Np!==null&&(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=this.Ip!==null,this.Jp();const e=this.$i().Zc();this.Ip!==null&&e.yt()&&(this.Lp={x:e.Yt(),y:e.Zt()},this.Ip={x:t.localX,y:t.localY})}hv(t){if(this.Np===null)return;const e=t.localX,i=t.localY;if(this.Ip===null)this.nm(t);else{this.zp=!1;const n=C(this.Lp),r=n.x+(e-this.Ip.x),o=n.y+(i-this.Ip.y);this.Gp(r,o,t)}}_v(t){this.$v().W().trackingMode.exitMode===0&&(this.zp=!0),this.om(),this.sm(t)}wr(t,e){const i=this.Np;return i===null?null:(function(n,r,o){const l=n.Uo(),h=(function(a,c,u){var p,m;let d,f;for(const y of a){const _=(m=(p=y.va)===null||p===void 0?void 0:p.call(y,c,u))!==null&&m!==void 0?m:[];for(const k of _)g=k.zOrder,(!(w=d?.zOrder)||g==="top"&&w!=="top"||g==="normal"&&w==="bottom")&&(d=k,f=y)}var g,w;return d&&f?{zv:d,Hc:f}:null})(l,r,o);if(h?.zv.zOrder==="top")return _i(h);for(const a of l){if(h&&h.Hc===a&&h.zv.zOrder!=="bottom"&&!h.zv.isBackground)return _i(h);const c=Wh(a.Pn(n),r,o);if(c!==null)return{Hc:a,Bv:c.Bv,Iv:c.Iv};if(h&&h.Hc===a&&h.zv.zOrder!=="bottom"&&h.zv.isBackground)return _i(h)}return h?.zv?_i(h):null})(i,t,e)}_m(t,e){C(e==="left"?this.Cp:this.Tp).cp(ft({width:t,height:this.Ev.height}))}um(){return this.Ev}cp(t){be(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=C(this.Np);t.P_(t.R_()),t.P_(t.D_());for(const e of t.Ba())if(t.vr(e)){const i=e.Dt();i!==null&&t.P_(i),e.Vn()}}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const n=this.xp();n.width>0&&n.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(t===0||this.Np===null)return;if(t>1&&this.dm(),this.Cp!==null&&this.Cp.vp(t),this.Tp!==null&&this.Tp.vp(t),t!==1){this.Gv.applySuggestedBitmapSize();const i=ve(this.Gv);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.mp(n)})),this.Np&&(this.fm(i,qh),this.vm(i),this.pm(i),this.fm(i,xi),this.fm(i,Hh)))}this.Jv.applySuggestedBitmapSize();const e=ve(this.Jv);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.bm(e),this.fm(e,jh))}wm(){return this.Cp}gm(){return this.Tp}bp(t,e){this.fm(t,e)}Fp(){this.Np!==null&&this.Np.W_().p(this),this.Np=null}tm(t){this.im(this.Vp,t)}im(t,e){const i=e.localX,n=e.localY;t.M()&&t.m(this.$i().St().Nu(i),{x:i,y:n},e)}mp({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.$i(),o=r.q(),l=r.bd();o===l?hi(t,0,0,i,n,l):bn(t,0,0,i,n,o,l)}vm(t){const e=C(this.Np).j_().qh().gt();e!==null&&e.X(t,!1)}pm(t){const e=this.$i().Yc();this.Mm(t,xi,ps,e),this.Mm(t,xi,wi,e)}bm(t){this.Mm(t,xi,wi,this.$i().Zc())}fm(t,e){const i=C(this.Np).Uo();for(const n of i)this.Mm(t,e,ps,n);for(const n of i)this.Mm(t,e,wi,n)}Mm(t,e,i,n){const r=C(this.Np),o=r.$t().Wc(),l=o!==null&&o.Hc===n,h=o!==null&&l&&o.Iv!==void 0?o.Iv.Mr:void 0;ms(e,(a=>i(a,t,l,h)),n,r)}Zp(){if(this.Np===null)return;const t=this.Qd,e=this.Np.R_().W().visible,i=this.Np.D_().W().visible;e||this.Cp===null||(this.jp.removeChild(this.Cp.lp()),this.Cp.S(),this.Cp=null),i||this.Tp===null||(this.Hp.removeChild(this.Tp.lp()),this.Tp.S(),this.Tp=null);const n=t.$t().ud();e&&this.Cp===null&&(this.Cp=new dr(this,t.W(),n,"left"),this.jp.appendChild(this.Cp.lp())),i&&this.Tp===null&&(this.Tp=new dr(this,t.W(),n,"right"),this.Hp.appendChild(this.Tp.lp()))}xm(t){return t.Dv&&this.Ap||this.Ip!==null}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,C(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 n=this.$i().Zc();this.Lp={x:n.Yt(),y:n.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(),this.Ep!==null){const n=performance.now(),r=e.St();this.Ep.Vr(r.Hu(),n),this.Ep.Qu(n)||e.Zn(this.Ep)}}Kp(){this.Ip=null}Jp(){if(this.Np){if(this.$i().Un(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)C(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.Np.vn().Ni()&&this.$i().St().Ni()}}nm(t){if(this.Np===null)return;const e=this.$i(),i=e.St();if(i.Ni())return;const n=this.Qd.W(),r=n.handleScroll,o=n.kineticScroll;if((!r.pressedMouseMove||t.Dv)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t.Dv))return;const l=this.Np.vn(),h=performance.now();if(this.Rp!==null||this.xm(t)||(this.Rp={x:t.clientX,y:t.clientY,Od:h,ym:t.localX,Cm:t.localY}),this.Rp!==null&&!this.Dp&&(this.Rp.x!==t.clientX||this.Rp.y!==t.clientY)){if(t.Dv&&o.touch||!t.Dv&&o.mouse){const a=i.le();this.Ep=new $h(.2/a,7/a,.997,15/a),this.Ep.Yd(i.Hu(),this.Rp.Od)}else this.Ep=null;l.Ni()||e.A_(this.Np,l,t.localY),e.nd(t.localX),this.Dp=!0}this.Dp&&(l.Ni()||e.I_(this.Np,l,t.localY),e.sd(t.localX),this.Ep!==null&&this.Ep.Yd(i.Hu(),h))}}class pr{constructor(t,e,i,n,r){this.ft=!0,this.Ev=ft({width:0,height:0}),this.Hv=()=>this.vp(3),this.qv=t==="left",this.Oc=i.ud,this.cn=e,this.Tm=n,this.Pm=r,this.Kv=document.createElement("div"),this.Kv.style.width="25px",this.Kv.style.height="100%",this.Kv.style.overflow="hidden",this.Gv=we(this.Kv,ft({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv)}S(){this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Se(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Kv}um(){return this.Ev}cp(t){be(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||this.Ev.width===0||this.Ev.height===0)return;this.ft=!1,this.Gv.applySuggestedBitmapSize();const e=ve(this.Gv);e!==null&&e.useBitmapCoordinateSpace((i=>{this.mp(i),this.Ie(i)}))}xp(){return this.Gv.bitmapSize}Sp(t,e,i){const n=this.xp();n.width>0&&n.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}Ie({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(!this.Tm())return;t.fillStyle=this.cn.timeScale.borderColor;const r=Math.floor(this.Oc.W().C*i),o=Math.floor(this.Oc.W().C*n),l=this.qv?e.width-r:0;t.fillRect(l,0,r,o)}mp({context:t,bitmapSize:e}){hi(t,0,0,e.width,e.height,this.Pm())}}function ws(s){return t=>{var e,i;return(i=(e=t.fa)===null||e===void 0?void 0:e.call(t,s))!==null&&i!==void 0?i:[]}}const Kh=ws("normal"),Xh=ws("top"),Jh=ws("bottom");class Gh{constructor(t,e){this.Rm=null,this.Dm=null,this.k=null,this.Vm=!1,this.Ev=ft({width:0,height:0}),this.Om=new xt,this.Fv=new We(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=we(this.Im,ft({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=we(this.Im,ft({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.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 gs(this.Jv.canvasElement,this,{ev:()=>!0,rv:()=>!this.Qd.W().handleScroll.horzTouchDrag})}S(){this.hp.S(),this.Rm!==null&&this.Rm.S(),this.Dm!==null&&this.Dm.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),Se(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Se(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){be(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)),this.Rm!==null&&this.Rm.cp(ft({width:e,height:t.height})),this.Dm!==null&&this.Dm.cp(ft({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 n=this.xp();n.width>0&&n.height>0&&t.drawImage(this.Gv.canvasElement,e,i)}vp(t){if(t===0)return;if(t!==1){this.Gv.applySuggestedBitmapSize();const i=ve(this.Gv);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.mp(n),this.Ie(n),this.$m(i,Jh)})),this.wp(i),this.$m(i,Kh)),this.Rm!==null&&this.Rm.vp(t),this.Dm!==null&&this.Dm.vp(t)}this.Jv.applySuggestedBitmapSize();const e=ve(this.Jv);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.Um([...this.Qd.$t().wt(),this.Qd.$t().Zc()],e),this.$m(e,Xh))}$m(t,e){const i=this.Qd.$t().wt();for(const n of i)ms(e,(r=>ps(r,t,!1,void 0)),n,void 0);for(const n of i)ms(e,(r=>wi(r,t,!1,void 0)),n,void 0)}mp({context:t,bitmapSize:e}){hi(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 n=Math.max(1,Math.floor(this.jm().C*i));t.fillRect(0,0,e.width,n)}}wp(t){const e=this.Qd.$t().St(),i=e.Ha();if(!i||i.length===0)return;const n=this.q_.maxTickMarkWeight(i),r=this.jm(),o=e.W();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace((({context:l,horizontalPixelRatio:h,verticalPixelRatio:a})=>{l.strokeStyle=this.qm(),l.fillStyle=this.qm();const c=Math.max(1,Math.floor(h)),u=Math.floor(.5*h);l.beginPath();const p=Math.round(r.T*a);for(let m=i.length;m--;){const d=Math.round(i[m].coord*h);l.rect(d-u,0,c,p)}l.fill()})),t.useMediaCoordinateSpace((({context:l})=>{const h=r.C+r.T+r.L+r.P/2;l.textAlign="center",l.textBaseline="middle",l.fillStyle=this.$(),l.font=this._p();for(const a of i)if(a.weight<n){const c=a.needAlignCoordinate?this.Ym(l,a.coord,a.label):a.coord;l.fillText(a.label,c,h)}this.Qd.W().timeScale.allowBoldLabels&&(l.font=this.Zm());for(const a of i)if(a.weight>=n){const c=a.needAlignCoordinate?this.Ym(l,a.coord,a.label):a.coord;l.fillText(a.label,c,h)}}))}Ym(t,e,i){const n=this.Fv.xi(t,i),r=n/2,o=Math.floor(e-r)+.5;return o<0?e+=Math.abs(0-o):o+n>this.Ev.width&&(e-=Math.abs(this.Ev.width-(o+n))),e}Um(t,e){const i=this.jm();for(const n of t)for(const r of n.Qi())r.gt().X(e,i)}qm(){return this.Qd.W().timeScale.borderColor}$(){return this.cn.textColor}j(){return this.cn.fontSize}_p(){return ke(this.j(),this.cn.fontFamily)}Zm(){return ke(this.j(),this.cn.fontFamily,"bold")}jm(){this.k===null&&(this.k={C:1,N:NaN,L:NaN,B:NaN,ji:NaN,T:5,P:NaN,R:"",Wi:new We,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=t===1?"ew-resize":"default"}zm(){const t=this.Qd.$t(),e=t.W();e.leftPriceScale.visible||this.Rm===null||(this.Bm.removeChild(this.Rm.lp()),this.Rm.S(),this.Rm=null),e.rightPriceScale.visible||this.Dm===null||(this.Am.removeChild(this.Dm.lp()),this.Dm.S(),this.Dm=null);const i={ud:this.Qd.$t().ud()},n=()=>e.leftPriceScale.borderVisible&&t.St().W().borderVisible,r=()=>t.bd();e.leftPriceScale.visible&&this.Rm===null&&(this.Rm=new pr("left",e,i,n,r),this.Bm.appendChild(this.Rm.lp())),e.rightPriceScale.visible&&this.Dm===null&&(this.Dm=new pr("right",e,i,n,r),this.Am.appendChild(this.Dm.lp()))}}const Yh=!!Re&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((s=>s.brand.includes("Chromium")))&&!!Re&&(!((Ss=navigator?.userAgentData)===null||Ss===void 0)&&Ss.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);var Ss;class Qh{constructor(t,e,i){var n;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 xt,this.Op=new xt,this.Rc=new xt,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%",(n=this.Xd).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.sb=document.createElement("table"),this.sb.setAttribute("cellspacing","0"),this.Xd.appendChild(this.sb),this.eb=this.rb.bind(this),_s(this.cn)&&this.hb(!0),this.$i=new Dh(this.Vc.bind(this),this.cn,i),this.$t().Xc().l(this.lb.bind(this),this),this.ab=new Gh(this,this.q_),this.sb.appendChild(this.ab.lp());const r=e.autoSize&&this.ob();let o=this.cn.width,l=this.cn.height;if(r||o===0||l===0){const h=t.getBoundingClientRect();o=o||h.width,l=l||h.height}this._b(o,l),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),this.Km!==0&&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=[],C(this.ab).S(),this.Xd.parentElement!==null&&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 n=(function(l){const h=Math.floor(l.width),a=Math.floor(l.height);return ft({width:h-h%2,height:a-a%2})})(ft({width:t,height:e}));this.ho=n.height,this.__=n.width;const r=this.ho+"px",o=this.__+"px";C(this.Xd).style.height=r,C(this.Xd).style.width=o,this.sb.style.height=r,this.sb.style.width=o,i?this.mb(Ot.es(),performance.now()):this.$i.Kl()}vp(t){t===void 0&&(t=Ot.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=_s(this.cn);this.$i.$h(t);const i=_s(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(){this.Qm!==null&&(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=C(e.getContext("2d"));return this.gb(i),e}Mb(t){return t==="left"&&!this.xb()||t==="right"&&!this.Sb()||this.Xm.length===0?0:C(t==="left"?this.Xm[0].wm():this.Xm[0].gm()).dp()}kb(){return this.cn.autoSize&&this.ib!==null}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 Bt(this.Xm[0]).um()}bb(t){(t.autoSize!==void 0||!this.ib||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.ib&&this.ob(),t.autoSize===!1&&this.ib!==null&&this.pb(),t.autoSize||t.width===void 0&&t.height===void 0||this._b(t.width||this.__,t.height||this.ho))}gb(t){let e=0,i=0;const n=this.Xm[0],r=(l,h)=>{let a=0;for(let c=0;c<this.Xm.length;c++){const u=this.Xm[c],p=C(l==="left"?u.wm():u.gm()),m=p.xp();t!==null&&p.Sp(t,h,a),a+=m.height}};this.xb()&&(r("left",0),e+=C(n.wm()).xp().width);for(let l=0;l<this.Xm.length;l++){const h=this.Xm[l],a=h.xp();t!==null&&h.Sp(t,e,i),i+=a.height}e+=n.xp().width,this.Sb()&&(r("right",e),e+=C(n.gm()).xp().width);const o=(l,h,a)=>{C(l==="left"?this.ab.Lm():this.ab.Em()).Sp(C(t),h,a)};if(this.cn.timeScale.visible){const l=this.ab.xp();if(t!==null){let h=0;this.xb()&&(o("left",h,i),h=C(n.wm()).xp().width),this.ab.Sp(t,h,i),h+=l.width,this.Sb()&&o("right",h,i)}i+=l.height}return ft({width:e,height:i})}Pb(){let t=0,e=0,i=0;for(const d of this.Xm)this.xb()&&(e=Math.max(e,C(d.wm()).op(),this.cn.leftPriceScale.minimumWidth)),this.Sb()&&(i=Math.max(i,C(d.gm()).op(),this.cn.rightPriceScale.minimumWidth)),t+=d.M_();e=us(e),i=us(i);const n=this.__,r=this.ho,o=Math.max(n-e-i,0),l=this.cn.timeScale.visible;let h=l?Math.max(this.ab.Wm(),this.cn.timeScale.minimumHeight):0;var a;h=(a=h)+a%2;const c=0+h,u=r<c?0:r-c,p=u/t;let m=0;for(let d=0;d<this.Xm.length;++d){const f=this.Xm[d];f.qp(this.$i.qc()[d]);let g=0,w=0;w=d===this.Xm.length-1?u-m:Math.round(f.M_()*p),g=Math.max(w,2),m+=g,f.cp(ft({width:o,height:g})),this.xb()&&f._m(e,"left"),this.Sb()&&f._m(i,"right"),f.fp()&&this.$i.Kc(f.fp(),g)}this.ab.Fm(ft({width:l?o:0,height:h}),l?e:0,l?i:0),this.$i.S_(o),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 Yh?1/window.devicePixelRatio:1}rb(t){if(!(t.deltaX!==0&&this.cn.handleScroll.mouseWheel||t.deltaY!==0&&this.cn.handleScale.mouseWheel))return;const e=this.Rb(t),i=e*t.deltaX/100,n=-e*t.deltaY/100;if(t.cancelable&&t.preventDefault(),n!==0&&this.cn.handleScale.mouseWheel){const r=Math.sign(n)*Math.min(1,Math.abs(n)),o=t.clientX-this.Xd.getBoundingClientRect().left;this.$t().Qc(o,r)}i!==0&&this.cn.handleScroll.mouseWheel&&this.$t().td(-80*i)}mb(t,e){var i;const n=t.jn();n===3&&this.Db(),n!==3&&n!==2||(this.Vb(t),this.Ob(t,e),this.ab.bt(),this.Xm.forEach((r=>{r.Xp()})),((i=this.Qm)===null||i===void 0?void 0:i.jn())===3&&(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){this.Qm!==null?this.Qm.ts(t):this.Qm=t,this.tb||(this.tb=!0,this.Km=window.requestAnimationFrame((e=>{if(this.tb=!1,this.Km=0,this.Qm!==null){const i=this.Qm;this.Qm=null,this.mb(i,e);for(const n of i.Qn())if(n.qn===5&&!n.Vt.Qu(e)){this.$t().Zn(n.Vt);break}}})))}Db(){this.ub()}ub(){const t=this.$i.qc(),e=t.length,i=this.Xm.length;for(let n=e;n<i;n++){const r=Bt(this.Xm.pop());this.sb.removeChild(r.lp()),r.lm().p(this),r.am().p(this),r.S()}for(let n=i;n<e;n++){const r=new ys(this,t[n]);r.lm().l(this.Bb.bind(this),this),r.am().l(this.Ab.bind(this),this),this.Xm.push(r),this.sb.insertBefore(r.lp(),this.ab.lp())}for(let n=0;n<e;n++){const r=t[n],o=this.Xm[n];o.fp()!==r?o.qp(r):o.Up()}this.cb(),this.Pb()}Ib(t,e,i){var n;const r=new Map;t!==null&&this.$i.wt().forEach((c=>{const u=c.In().ll(t);u!==null&&r.set(c,u)}));let o;if(t!==null){const c=(n=this.$i.St().Ui(t))===null||n===void 0?void 0:n.originalTime;c!==void 0&&(o=c)}const l=this.$t().Wc(),h=l!==null&&l.Hc instanceof is?l.Hc:void 0,a=l!==null&&l.Iv!==void 0?l.Iv.gr:void 0;return{zb:o,ee:t??void 0,Lb:e??void 0,Eb:h,Nb:r,Fb:a,Wb: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((i=>i.target===this.Jd));e&&this._b(e.contentRect.width,e.contentRect.height)})),this.ib.observe(this.Jd,{box:"border-box"}),!0)}pb(){this.ib!==null&&this.ib.disconnect(),this.ib=null}}function _s(s){return!!(s.handleScroll.mouseWheel||s.handleScale.mouseWheel)}function Zh(s){return(function(t){return t.open!==void 0})(s)||(function(t){return t.value!==void 0})(s)}function mr(s,t){var e={};for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&t.indexOf(i)<0&&(e[i]=s[i]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function"){var n=0;for(i=Object.getOwnPropertySymbols(s);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(s,i[n])&&(e[i[n]]=s[i[n]])}return e}function gr(s,t,e,i){const n=e.value,r={ee:t,ot:s,Vt:[n,n,n,n],zb:i};return e.color!==void 0&&(r.V=e.color),r}function ta(s,t,e,i){const n=e.value,r={ee:t,ot:s,Vt:[n,n,n,n],zb:i};return e.lineColor!==void 0&&(r.lt=e.lineColor),e.topColor!==void 0&&(r.Ps=e.topColor),e.bottomColor!==void 0&&(r.Rs=e.bottomColor),r}function ea(s,t,e,i){const n=e.value,r={ee:t,ot:s,Vt:[n,n,n,n],zb:i};return e.topLineColor!==void 0&&(r.Re=e.topLineColor),e.bottomLineColor!==void 0&&(r.De=e.bottomLineColor),e.topFillColor1!==void 0&&(r.ke=e.topFillColor1),e.topFillColor2!==void 0&&(r.ye=e.topFillColor2),e.bottomFillColor1!==void 0&&(r.Ce=e.bottomFillColor1),e.bottomFillColor2!==void 0&&(r.Te=e.bottomFillColor2),r}function ia(s,t,e,i){const n={ee:t,ot:s,Vt:[e.open,e.high,e.low,e.close],zb:i};return e.color!==void 0&&(n.V=e.color),n}function sa(s,t,e,i){const n={ee:t,ot:s,Vt:[e.open,e.high,e.low,e.close],zb:i};return e.color!==void 0&&(n.V=e.color),e.borderColor!==void 0&&(n.Ot=e.borderColor),e.wickColor!==void 0&&(n.Xh=e.wickColor),n}function na(s,t,e,i,n){const r=Bt(n)(e),o=Math.max(...r),l=Math.min(...r),h=r[r.length-1],a=[h,o,l,h],c=e,{time:u,color:p}=c;return{ee:t,ot:s,Vt:a,zb:i,$e:mr(c,["time","color"]),V:p}}function Ci(s){return s.Vt!==void 0}function br(s,t){return t.customValues!==void 0&&(s.jb=t.customValues),s}function _e(s){return(t,e,i,n,r,o)=>(function(l,h){return h?h(l):(a=l).open===void 0&&a.value===void 0;var a})(i,o)?br({ot:t,ee:e,zb:n},i):br(s(t,e,i,n,r),i)}function vr(s){return{Candlestick:_e(sa),Bar:_e(ia),Area:_e(ta),Baseline:_e(ea),Histogram:_e(gr),Line:_e(gr),Custom:_e(na)}[s]}function yr(s){return{ee:0,Hb:new Map,la:s}}function wr(s,t){if(s!==void 0&&s.length!==0)return{$b:t.key(s[0].ot),Ub:t.key(s[s.length-1].ot)}}function Sr(s){let t;return s.forEach((e=>{t===void 0&&(t=e.zb)})),Bt(t)}class ra{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=this.qb.size!==0,n=!1;const r=this.Yb.get(t);if(r!==void 0)if(this.Yb.size===1)i=!1,n=!0,this.qb.clear();else for(const h of this.Xb)h.pointData.Hb.delete(t)&&(n=!0);let o=[];if(e.length!==0){const h=e.map((m=>m.time)),a=this.q_.createConverterToInternalObj(e),c=vr(t.Qh()),u=t.Ca(),p=t.Ta();o=e.map(((m,d)=>{const f=a(m.time),g=this.q_.key(f);let w=this.qb.get(g);w===void 0&&(w=yr(f),this.qb.set(g,w),n=!0);const y=c(f,w.ee,m,h[d],u,p);return w.Hb.set(t,y),y}))}i&&this.Gb(),this.Jb(t,o);let l=-1;if(n){const h=[];this.qb.forEach((a=>{h.push({timeWeight:0,time:a.la,pointData:a,originalTime:Sr(a.Hb)})})),h.sort(((a,c)=>this.q_.key(a.time)-this.q_.key(c.time))),l=this.Qb(h)}return this.tw(t,l,(function(h,a,c){const u=wr(h,c),p=wr(a,c);if(u!==void 0&&p!==void 0)return{ta:u.Ub>=p.Ub&&u.$b>=p.$b}})(this.Yb.get(t),r,this.q_))}vd(t){return this.Kb(t,[])}iw(t,e){const i=e;(function(f){f.zb===void 0&&(f.zb=f.time)})(i),this.q_.preprocessData(e);const n=this.q_.createConverterToInternalObj([e])(e.time),r=this.Zb.get(t);if(r!==void 0&&this.q_.key(n)<this.q_.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${n}`);let o=this.qb.get(this.q_.key(n));const l=o===void 0;o===void 0&&(o=yr(n),this.qb.set(this.q_.key(n),o));const h=vr(t.Qh()),a=t.Ca(),c=t.Ta(),u=h(n,o.ee,e,i.zb,a,c);o.Hb.set(t,u),this.nw(t,u);const p={ta:Ci(u)};if(!l)return this.tw(t,-1,p);const m={timeWeight:0,time:o.la,pointData:o,originalTime:Sr(o.Hb)},d=Ue(this.Xb,this.q_.key(m.time),((f,g)=>this.q_.key(f.time)<g));this.Xb.splice(d,0,m);for(let f=d;f<this.Xb.length;++f)xs(this.Xb[f].pointData,f);return this.q_.fillWeightsForPoints(this.Xb,d),this.tw(t,d,p)}nw(t,e){let i=this.Yb.get(t);i===void 0&&(i=[],this.Yb.set(t,i));const n=i.length!==0?i[i.length-1]:null;n===null||this.q_.key(e.ot)>this.q_.key(n.ot)?Ci(e)&&i.push(e):Ci(e)?i[i.length-1]=e:i.splice(-1,1),this.Zb.set(t,e.ot)}Jb(t,e){e.length!==0?(this.Yb.set(t,e.filter(Ci)),this.Zb.set(t,e[e.length-1].ot)):(this.Yb.delete(t),this.Zb.delete(t))}Gb(){for(const t of this.Xb)t.pointData.Hb.size===0&&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 n=this.Xb[i],r=t[i];if(this.q_.key(n.time)!==this.q_.key(r.time)){e=i;break}r.timeWeight=n.timeWeight,xs(r.pointData,i)}if(e===-1&&this.Xb.length!==t.length&&(e=Math.min(this.Xb.length,t.length)),e===-1)return-1;for(let i=e;i<t.length;++i)xs(t[i].pointData,i);return this.q_.fillWeightsForPoints(t,e),this.Xb=t,e}sw(){if(this.Yb.size===0)return null;let t=0;return this.Yb.forEach((e=>{e.length!==0&&(t=Math.max(t,e[e.length-1].ee))})),t}tw(t,e,i){const n={ew:new Map,St:{Eu:this.sw()}};if(e!==-1)this.Yb.forEach(((r,o)=>{n.ew.set(o,{$e:r,rw:o===t?i:void 0})})),this.Yb.has(t)||n.ew.set(t,{$e:[],rw:i}),n.St.hw=this.Xb,n.St.lw=e;else{const r=this.Yb.get(t);n.ew.set(t,{$e:r||[],rw:i})}return n}}function xs(s,t){s.ee=t,s.Hb.forEach((e=>{e.ee=t}))}function Cs(s){const t={value:s.Vt[3],time:s.zb};return s.jb!==void 0&&(t.customValues=s.jb),t}function _r(s){const t=Cs(s);return s.V!==void 0&&(t.color=s.V),t}function oa(s){const t=Cs(s);return s.lt!==void 0&&(t.lineColor=s.lt),s.Ps!==void 0&&(t.topColor=s.Ps),s.Rs!==void 0&&(t.bottomColor=s.Rs),t}function la(s){const t=Cs(s);return s.Re!==void 0&&(t.topLineColor=s.Re),s.De!==void 0&&(t.bottomLineColor=s.De),s.ke!==void 0&&(t.topFillColor1=s.ke),s.ye!==void 0&&(t.topFillColor2=s.ye),s.Ce!==void 0&&(t.bottomFillColor1=s.Ce),s.Te!==void 0&&(t.bottomFillColor2=s.Te),t}function xr(s){const t={open:s.Vt[0],high:s.Vt[1],low:s.Vt[2],close:s.Vt[3],time:s.zb};return s.jb!==void 0&&(t.customValues=s.jb),t}function ha(s){const t=xr(s);return s.V!==void 0&&(t.color=s.V),t}function aa(s){const t=xr(s),{V:e,Ot:i,Xh:n}=s;return e!==void 0&&(t.color=e),i!==void 0&&(t.borderColor=i),n!==void 0&&(t.wickColor=n),t}function Es(s){return{Area:oa,Line:_r,Baseline:la,Histogram:_r,Bar:ha,Candlestick:aa,Custom:ca}[s]}function ca(s){const t=s.zb;return Object.assign(Object.assign({},s.$e),{time:t})}const ua={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},fa={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},da={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:qi,attributionLogo:!0},Ts={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},pa={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},ma={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:qi,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function Cr(){return{width:0,height:0,autoSize:!1,layout:da,crosshair:ua,grid:fa,overlayPriceScales:Object.assign({},Ts),leftPriceScale:Object.assign(Object.assign({},Ts),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Ts),{visible:!0}),timeScale:pa,watermark:ma,localization:{locale:Re?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 ga{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 ci(this.ow)?this.aw.Mb(this.ow):0}Li(){return C(this.aw.$t().Uc(this.ow)).Dt}}function Er(s,t,e){const i=mr(s,["time","originalTime"]),n=Object.assign({time:t},i);return e!==void 0&&(n.originalTime=e),n}const ba={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class va{constructor(t){this.Nh=t}applyOptions(t){this.Nh.$h(t)}options(){return this.Nh.W()}_w(){return this.Nh}}class ya{constructor(t,e,i,n,r){this.uw=new xt,this.Es=t,this.cw=e,this.dw=i,this.q_=r,this.fw=n}S(){this.uw.S()}priceFormatter(){return this.Es.ba()}priceToCoordinate(t){const e=this.Es.Ct();return e===null?null:this.Es.Dt().Rt(t,e.Vt)}coordinateToPrice(t){const e=this.Es.Ct();return e===null?null:this.Es.Dt().pn(t,e.Vt)}barsInLogicalRange(t){if(t===null)return null;const e=new Oe(new Je(t.from,t.to)).lu(),i=this.Es.In();if(i.Ni())return null;const n=i.ll(e.Os(),1),r=i.ll(e.ui(),-1),o=C(i.el()),l=C(i.An());if(n!==null&&r!==null&&n.ee>r.ee)return{barsBefore:t.from-o,barsAfter:l-t.to};const h={barsBefore:n===null||n.ee===o?t.from-o:n.ee-o,barsAfter:r===null||r.ee===l?l-t.to:l-r.ee};return n!==null&&r!==null&&(h.from=n.zb,h.to=r.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 i===null?null:Es(this.seriesType())(i)}data(){const t=Es(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((i=>Er(i,this.q_.convertHorzItemToInternal(i.time),i.time)));this.Es.na(e)}markers(){return this.Es.sa().map((t=>Er(t,t.originalTime,void 0)))}applyOptions(t){this.Es.$h(t)}options(){return ue(this.Es.W())}priceScale(){return this.dw.priceScale(this.Es.Dt().Pa())}createPriceLine(t){const e=Gt(ue(ba),t),i=this.Es.ea(e);return new va(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 wa{constructor(t,e,i){this.ww=new xt,this.mu=new xt,this.Om=new xt,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 t===null?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 t===null?null:{from:t.Os(),to:t.ui()}}setVisibleLogicalRange(t){de(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 i===null?null:this.yl.It(i)}coordinateToTime(t){const e=this.$i.St(),i=e.Nu(t),n=e.Ui(i);return n===null?null:n.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({},ue(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 Sa(s){if(s===void 0||s.type==="custom")return;const t=s;t.minMove!==void 0&&t.precision===void 0&&(t.precision=(function(e){if(e>=1)return 0;let i=0;for(;i<8;i++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return i;e*=10}return i})(t.minMove))}function Tr(s){return(function(t){if(li(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:i,axisDoubleClickReset:n}=t.handleScale;li(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),li(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const e=t.handleScroll;li(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})})(s),s}class _a{constructor(t,e,i){this.Sw=new Map,this.kw=new Map,this.yw=new xt,this.Cw=new xt,this.Tw=new xt,this.Pw=new ra(e);const n=i===void 0?ue(Cr()):Gt(ue(Cr()),Tr(i));this.q_=e,this.aw=new Qh(t,n,e),this.aw.lm().l((o=>{this.yw.M()&&this.yw.m(this.Rw(o()))}),this),this.aw.am().l((o=>{this.Cw.M()&&this.Cw.m(this.Rw(o()))}),this),this.aw.Xc().l((o=>{this.Tw.M()&&this.Tw.m(this.Rw(o()))}),this);const r=this.aw.$t();this.Dw=new wa(r,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=Me(t),n=Object.assign(Object.assign({},ln),i.defaultOptions());return this.Vw("Custom",n,e,i)}addAreaSeries(t){return this.Vw("Area",rl,t)}addBaselineSeries(t){return this.Vw("Baseline",ol,t)}addBarSeries(t){return this.Vw("Bar",sl,t)}addCandlestickSeries(t={}){return(function(e){e.borderColor!==void 0&&(e.borderUpColor=e.borderColor,e.borderDownColor=e.borderColor),e.wickColor!==void 0&&(e.wickUpColor=e.wickColor,e.wickDownColor=e.wickColor)})(t),this.Vw("Candlestick",il,t)}addHistogramSeries(t){return this.Vw("Histogram",ll,t)}addLineSeries(t){return this.Vw("Line",nl,t)}removeSeries(t){const e=Bt(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 ga(this.aw,t)}timeScale(){return this.Dw}applyOptions(t){this.aw.$h(Tr(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 n=this.Sw.get(i);if(n===void 0)return;const r=this.aw.$t().dr(n);r!==null&&this.aw.$t().ad(t,e,r)}clearCrosshairPosition(){this.aw.$t().od(!0)}Vw(t,e,i={},n){Sa(i.priceFormat);const r=Gt(ue(hn),ue(e),i),o=this.aw.$t().dd(t,r,n),l=new ya(o,this,this,this,this.q_);return this.Sw.set(l,o),this.kw.set(o,l),l}Ow(t){const e=this.aw.$t();e._d(t.St.Eu,t.St.hw,t.St.lw),t.ew.forEach(((i,n)=>n.J(i.$e,i.rw))),e.Wu()}Bw(t){return Bt(this.kw.get(t))}Rw(t){const e=new Map;t.Nb.forEach(((n,r)=>{const o=r.Qh(),l=Es(o)(n);if(o!=="Custom")de(Zh(l));else{const h=r.Ta();de(!h||h(l)===!1)}e.set(this.Bw(r),l)}));const i=t.Eb!==void 0&&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 xa(s,t,e){let i;if($e(s)){const r=document.getElementById(s);de(r!==null,`Cannot find element in DOM with id=${s}`),i=r}else i=s;const n=new _a(i,t,e);return t.setOptions(n.options()),n}function Ca(s,t){return xa(s,new ar,ar.Id(t))}Object.assign(Object.assign({},hn),ln);function Mr(s,t){return function(){return s.apply(t,arguments)}}const{toString:Ea}=Object.prototype,{getPrototypeOf:Ms}=Object,{iterator:Ei,toStringTag:kr}=Symbol,Ti=(s=>t=>{const e=Ea.call(t);return s[e]||(s[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),Qt=s=>(s=s.toLowerCase(),t=>Ti(t)===s),Mi=s=>t=>typeof t===s,{isArray:Ne}=Array,Pe=Mi("undefined");function Ge(s){return s!==null&&!Pe(s)&&s.constructor!==null&&!Pe(s.constructor)&&Ft(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const Lr=Qt("ArrayBuffer");function Ta(s){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(s):t=s&&s.buffer&&Lr(s.buffer),t}const Ma=Mi("string"),Ft=Mi("function"),Or=Mi("number"),Ye=s=>s!==null&&typeof s=="object",ka=s=>s===!0||s===!1,ki=s=>{if(Ti(s)!=="object")return!1;const t=Ms(s);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kr in s)&&!(Ei in s)},La=s=>{if(!Ye(s)||Ge(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},Oa=Qt("Date"),Ra=Qt("File"),za=Qt("Blob"),Na=Qt("FileList"),Pa=s=>Ye(s)&&Ft(s.pipe),Da=s=>{let t;return s&&(typeof FormData=="function"&&s instanceof FormData||Ft(s.append)&&((t=Ti(s))==="formdata"||t==="object"&&Ft(s.toString)&&s.toString()==="[object FormData]"))},Aa=Qt("URLSearchParams"),[Ba,Va,Fa,$a]=["ReadableStream","Request","Response","Headers"].map(Qt),Ia=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Qe(s,t,{allOwnKeys:e=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),Ne(s))for(i=0,n=s.length;i<n;i++)t.call(null,s[i],i,s);else{if(Ge(s))return;const r=e?Object.getOwnPropertyNames(s):Object.keys(s),o=r.length;let l;for(i=0;i<o;i++)l=r[i],t.call(null,s[l],l,s)}}function Rr(s,t){if(Ge(s))return null;t=t.toLowerCase();const e=Object.keys(s);let i=e.length,n;for(;i-- >0;)if(n=e[i],t===n.toLowerCase())return n;return null}const xe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zr=s=>!Pe(s)&&s!==xe;function ks(){const{caseless:s,skipUndefined:t}=zr(this)&&this||{},e={},i=(n,r)=>{if(r==="__proto__"||r==="constructor"||r==="prototype")return;const o=s&&Rr(e,r)||r;ki(e[o])&&ki(n)?e[o]=ks(e[o],n):ki(n)?e[o]=ks({},n):Ne(n)?e[o]=n.slice():(!t||!Pe(n))&&(e[o]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&Qe(arguments[n],i);return e}const Ua=(s,t,e,{allOwnKeys:i}={})=>(Qe(t,(n,r)=>{e&&Ft(n)?Object.defineProperty(s,r,{value:Mr(n,e),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,r,{value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),s),Wa=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),qa=(s,t,e,i)=>{s.prototype=Object.create(t.prototype,i),Object.defineProperty(s.prototype,"constructor",{value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{value:t.prototype}),e&&Object.assign(s.prototype,e)},Ha=(s,t,e,i)=>{let n,r,o;const l={};if(t=t||{},s==null)return t;do{for(n=Object.getOwnPropertyNames(s),r=n.length;r-- >0;)o=n[r],(!i||i(o,s,t))&&!l[o]&&(t[o]=s[o],l[o]=!0);s=e!==!1&&Ms(s)}while(s&&(!e||e(s,t))&&s!==Object.prototype);return t},ja=(s,t,e)=>{s=String(s),(e===void 0||e>s.length)&&(e=s.length),e-=t.length;const i=s.indexOf(t,e);return i!==-1&&i===e},Ka=s=>{if(!s)return null;if(Ne(s))return s;let t=s.length;if(!Or(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=s[t];return e},Xa=(s=>t=>s&&t instanceof s)(typeof Uint8Array<"u"&&Ms(Uint8Array)),Ja=(s,t)=>{const i=(s&&s[Ei]).call(s);let n;for(;(n=i.next())&&!n.done;){const r=n.value;t.call(s,r[0],r[1])}},Ga=(s,t)=>{let e;const i=[];for(;(e=s.exec(t))!==null;)i.push(e);return i},Ya=Qt("HTMLFormElement"),Qa=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,n){return i.toUpperCase()+n}),Nr=(({hasOwnProperty:s})=>(t,e)=>s.call(t,e))(Object.prototype),Za=Qt("RegExp"),Pr=(s,t)=>{const e=Object.getOwnPropertyDescriptors(s),i={};Qe(e,(n,r)=>{let o;(o=t(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},tc=s=>{Pr(s,(t,e)=>{if(Ft(s)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=s[e];if(Ft(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},ec=(s,t)=>{const e={},i=n=>{n.forEach(r=>{e[r]=!0})};return Ne(s)?i(s):i(String(s).split(t)),e},ic=()=>{},sc=(s,t)=>s!=null&&Number.isFinite(s=+s)?s:t;function nc(s){return!!(s&&Ft(s.append)&&s[kr]==="FormData"&&s[Ei])}const rc=s=>{const t=new Array(10),e=(i,n)=>{if(Ye(i)){if(t.indexOf(i)>=0)return;if(Ge(i))return i;if(!("toJSON"in i)){t[n]=i;const r=Ne(i)?[]:{};return Qe(i,(o,l)=>{const h=e(o,n+1);!Pe(h)&&(r[l]=h)}),t[n]=void 0,r}}return i};return e(s,0)},oc=Qt("AsyncFunction"),lc=s=>s&&(Ye(s)||Ft(s))&&Ft(s.then)&&Ft(s.catch),Dr=((s,t)=>s?setImmediate:t?((e,i)=>(xe.addEventListener("message",({source:n,data:r})=>{n===xe&&r===e&&i.length&&i.shift()()},!1),n=>{i.push(n),xe.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",Ft(xe.postMessage)),hc=typeof queueMicrotask<"u"?queueMicrotask.bind(xe):typeof process<"u"&&process.nextTick||Dr,b={isArray:Ne,isArrayBuffer:Lr,isBuffer:Ge,isFormData:Da,isArrayBufferView:Ta,isString:Ma,isNumber:Or,isBoolean:ka,isObject:Ye,isPlainObject:ki,isEmptyObject:La,isReadableStream:Ba,isRequest:Va,isResponse:Fa,isHeaders:$a,isUndefined:Pe,isDate:Oa,isFile:Ra,isBlob:za,isRegExp:Za,isFunction:Ft,isStream:Pa,isURLSearchParams:Aa,isTypedArray:Xa,isFileList:Na,forEach:Qe,merge:ks,extend:Ua,trim:Ia,stripBOM:Wa,inherits:qa,toFlatObject:Ha,kindOf:Ti,kindOfTest:Qt,endsWith:ja,toArray:Ka,forEachEntry:Ja,matchAll:Ga,isHTMLForm:Ya,hasOwnProperty:Nr,hasOwnProp:Nr,reduceDescriptors:Pr,freezeMethods:tc,toObjectSet:ec,toCamelCase:Qa,noop:ic,toFiniteNumber:sc,findKey:Rr,global:xe,isContextDefined:zr,isSpecCompliantForm:nc,toJSONObject:rc,isAsyncFn:oc,isThenable:lc,setImmediate:Dr,asap:hc,isIterable:s=>s!=null&&Ft(s[Ei])};let V=class Ko extends Error{static from(t,e,i,n,r,o){const l=new Ko(t.message,e||t.code,i,n,r);return l.cause=t,l.name=t.name,o&&Object.assign(l,o),l}constructor(t,e,i,n,r){super(t),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r,this.status=r.status)}toJSON(){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:b.toJSONObject(this.config),code:this.code,status:this.status}}};V.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",V.ERR_BAD_OPTION="ERR_BAD_OPTION",V.ECONNABORTED="ECONNABORTED",V.ETIMEDOUT="ETIMEDOUT",V.ERR_NETWORK="ERR_NETWORK",V.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",V.ERR_DEPRECATED="ERR_DEPRECATED",V.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",V.ERR_BAD_REQUEST="ERR_BAD_REQUEST",V.ERR_CANCELED="ERR_CANCELED",V.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",V.ERR_INVALID_URL="ERR_INVALID_URL";const ac=null;function Ls(s){return b.isPlainObject(s)||b.isArray(s)}function Ar(s){return b.endsWith(s,"[]")?s.slice(0,-2):s}function Br(s,t,e){return s?s.concat(t).map(function(n,r){return n=Ar(n),!e&&r?"["+n+"]":n}).join(e?".":""):t}function cc(s){return b.isArray(s)&&!s.some(Ls)}const uc=b.toFlatObject(b,{},null,function(t){return/^is[A-Z]/.test(t)});function Li(s,t,e){if(!b.isObject(s))throw new TypeError("target must be an object");t=t||new FormData,e=b.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,g){return!b.isUndefined(g[f])});const i=e.metaTokens,n=e.visitor||c,r=e.dots,o=e.indexes,h=(e.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(t);if(!b.isFunction(n))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(b.isDate(d))return d.toISOString();if(b.isBoolean(d))return d.toString();if(!h&&b.isBlob(d))throw new V("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(d)||b.isTypedArray(d)?h&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,f,g){let w=d;if(d&&!g&&typeof d=="object"){if(b.endsWith(f,"{}"))f=i?f:f.slice(0,-2),d=JSON.stringify(d);else if(b.isArray(d)&&cc(d)||(b.isFileList(d)||b.endsWith(f,"[]"))&&(w=b.toArray(d)))return f=Ar(f),w.forEach(function(_,k){!(b.isUndefined(_)||_===null)&&t.append(o===!0?Br([f],k,r):o===null?f:f+"[]",a(_))}),!1}return Ls(d)?!0:(t.append(Br(g,f,r),a(d)),!1)}const u=[],p=Object.assign(uc,{defaultVisitor:c,convertValue:a,isVisitable:Ls});function m(d,f){if(!b.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(d),b.forEach(d,function(w,y){(!(b.isUndefined(w)||w===null)&&n.call(t,w,b.isString(y)?y.trim():y,f,p))===!0&&m(w,f?f.concat(y):[y])}),u.pop()}}if(!b.isObject(s))throw new TypeError("data must be an object");return m(s),t}function Vr(s){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Os(s,t){this._pairs=[],s&&Li(s,this,t)}const Fr=Os.prototype;Fr.append=function(t,e){this._pairs.push([t,e])},Fr.toString=function(t){const e=t?function(i){return t.call(this,i,Vr)}:Vr;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};function fc(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $r(s,t,e){if(!t)return s;const i=e&&e.encode||fc,n=b.isFunction(e)?{serialize:e}:e,r=n&&n.serialize;let o;if(r?o=r(t,n):o=b.isURLSearchParams(t)?t.toString():new Os(t,n).toString(i),o){const l=s.indexOf("#");l!==-1&&(s=s.slice(0,l)),s+=(s.indexOf("?")===-1?"?":"&")+o}return s}class Ir{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:i?i.synchronous:!1,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){b.forEach(this.handlers,function(i){i!==null&&t(i)})}}const Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},dc={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Os,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},zs=typeof window<"u"&&typeof document<"u",Ns=typeof navigator=="object"&&navigator||void 0,pc=zs&&(!Ns||["ReactNative","NativeScript","NS"].indexOf(Ns.product)<0),mc=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gc=zs&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:zs,hasStandardBrowserEnv:pc,hasStandardBrowserWebWorkerEnv:mc,navigator:Ns,origin:gc},Symbol.toStringTag,{value:"Module"})),...dc};function bc(s,t){return Li(s,new Nt.classes.URLSearchParams,{visitor:function(e,i,n,r){return Nt.isNode&&b.isBuffer(e)?(this.append(i,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}function vc(s){return b.matchAll(/\w+|\[(\w*)]/g,s).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yc(s){const t={},e=Object.keys(s);let i;const n=e.length;let r;for(i=0;i<n;i++)r=e[i],t[r]=s[r];return t}function Ur(s){function t(e,i,n,r){let o=e[r++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),h=r>=e.length;return o=!o&&b.isArray(n)?n.length:o,h?(b.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!l):((!n[o]||!b.isObject(n[o]))&&(n[o]=[]),t(e,i,n[o],r)&&b.isArray(n[o])&&(n[o]=yc(n[o])),!l)}if(b.isFormData(s)&&b.isFunction(s.entries)){const e={};return b.forEachEntry(s,(i,n)=>{t(vc(i),n,e,0)}),e}return null}function wc(s,t,e){if(b.isString(s))try{return(t||JSON.parse)(s),b.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(s)}const Ze={transitional:Rs,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",n=i.indexOf("application/json")>-1,r=b.isObject(t);if(r&&b.isHTMLForm(t)&&(t=new FormData(t)),b.isFormData(t))return n?JSON.stringify(Ur(t)):t;if(b.isArrayBuffer(t)||b.isBuffer(t)||b.isStream(t)||b.isFile(t)||b.isBlob(t)||b.isReadableStream(t))return t;if(b.isArrayBufferView(t))return t.buffer;if(b.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return bc(t,this.formSerializer).toString();if((l=b.isFileList(t))||i.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Li(l?{"files[]":t}:t,h&&new h,this.formSerializer)}}return r||n?(e.setContentType("application/json",!1),wc(t)):t}],transformResponse:[function(t){const e=this.transitional||Ze.transitional,i=e&&e.forcedJSONParsing,n=this.responseType==="json";if(b.isResponse(t)||b.isReadableStream(t))return t;if(t&&b.isString(t)&&(i&&!this.responseType||n)){const o=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(l){if(o)throw l.name==="SyntaxError"?V.from(l,V.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],s=>{Ze.headers[s]={}});const Sc=b.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"]),_c=s=>{const t={};let e,i,n;return s&&s.split(`
2
+ `).forEach(function(o){n=o.indexOf(":"),e=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!e||t[e]&&Sc[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},Wr=Symbol("internals");function ti(s){return s&&String(s).trim().toLowerCase()}function Oi(s){return s===!1||s==null?s:b.isArray(s)?s.map(Oi):String(s)}function xc(s){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=e.exec(s);)t[i[1]]=i[2];return t}const Cc=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Ps(s,t,e,i,n){if(b.isFunction(i))return i.call(this,t,e);if(n&&(t=e),!!b.isString(t)){if(b.isString(i))return t.indexOf(i)!==-1;if(b.isRegExp(i))return i.test(t)}}function Ec(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function Tc(s,t){const e=b.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+e,{value:function(n,r,o){return this[i].call(this,t,n,r,o)},configurable:!0})})}let $t=class{constructor(t){t&&this.set(t)}set(t,e,i){const n=this;function r(l,h,a){const c=ti(h);if(!c)throw new Error("header name must be a non-empty string");const u=b.findKey(n,c);(!u||n[u]===void 0||a===!0||a===void 0&&n[u]!==!1)&&(n[u||h]=Oi(l))}const o=(l,h)=>b.forEach(l,(a,c)=>r(a,c,h));if(b.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(b.isString(t)&&(t=t.trim())&&!Cc(t))o(_c(t),e);else if(b.isObject(t)&&b.isIterable(t)){let l={},h,a;for(const c of t){if(!b.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[a=c[0]]=(h=l[a])?b.isArray(h)?[...h,c[1]]:[h,c[1]]:c[1]}o(l,e)}else t!=null&&r(e,t,i);return this}get(t,e){if(t=ti(t),t){const i=b.findKey(this,t);if(i){const n=this[i];if(!e)return n;if(e===!0)return xc(n);if(b.isFunction(e))return e.call(this,n,i);if(b.isRegExp(e))return e.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=ti(t),t){const i=b.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Ps(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let n=!1;function r(o){if(o=ti(o),o){const l=b.findKey(i,o);l&&(!e||Ps(i,i[l],l,e))&&(delete i[l],n=!0)}}return b.isArray(t)?t.forEach(r):r(t),n}clear(t){const e=Object.keys(this);let i=e.length,n=!1;for(;i--;){const r=e[i];(!t||Ps(this,this[r],r,t,!0))&&(delete this[r],n=!0)}return n}normalize(t){const e=this,i={};return b.forEach(this,(n,r)=>{const o=b.findKey(i,r);if(o){e[o]=Oi(n),delete e[r];return}const l=t?Ec(r):String(r).trim();l!==r&&delete e[r],e[l]=Oi(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return b.forEach(this,(i,n)=>{i!=null&&i!==!1&&(e[n]=t&&b.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(`
3
+ `)}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(n=>i.set(n)),i}static accessor(t){const i=(this[Wr]=this[Wr]={accessors:{}}).accessors,n=this.prototype;function r(o){const l=ti(o);i[l]||(Tc(n,o),i[l]=!0)}return b.isArray(t)?t.forEach(r):r(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors($t.prototype,({value:s},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>s,set(i){this[e]=i}}}),b.freezeMethods($t);function Ds(s,t){const e=this||Ze,i=t||e,n=$t.from(i.headers);let r=i.data;return b.forEach(s,function(l){r=l.call(e,r,n.normalize(),t?t.status:void 0)}),n.normalize(),r}function qr(s){return!!(s&&s.__CANCEL__)}let ei=class extends V{constructor(t,e,i){super(t??"canceled",V.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function Hr(s,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?s(e):t(new V("Request failed with status code "+e.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function Mc(s){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return t&&t[1]||""}function kc(s,t){s=s||10;const e=new Array(s),i=new Array(s);let n=0,r=0,o;return t=t!==void 0?t:1e3,function(h){const a=Date.now(),c=i[r];o||(o=a),e[n]=h,i[n]=a;let u=r,p=0;for(;u!==n;)p+=e[u++],u=u%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),a-o<t)return;const m=c&&a-c;return m?Math.round(p*1e3/m):void 0}}function Lc(s,t){let e=0,i=1e3/t,n,r;const o=(a,c=Date.now())=>{e=c,n=null,r&&(clearTimeout(r),r=null),s(...a)};return[(...a)=>{const c=Date.now(),u=c-e;u>=i?o(a,c):(n=a,r||(r=setTimeout(()=>{r=null,o(n)},i-u)))},()=>n&&o(n)]}const Ri=(s,t,e=3)=>{let i=0;const n=kc(50,250);return Lc(r=>{const o=r.loaded,l=r.lengthComputable?r.total:void 0,h=o-i,a=n(h),c=o<=l;i=o;const u={loaded:o,total:l,progress:l?o/l:void 0,bytes:h,rate:a||void 0,estimated:a&&l&&c?(l-o)/a:void 0,event:r,lengthComputable:l!=null,[t?"download":"upload"]:!0};s(u)},e)},jr=(s,t)=>{const e=s!=null;return[i=>t[0]({lengthComputable:e,total:s,loaded:i}),t[1]]},Kr=s=>(...t)=>b.asap(()=>s(...t)),Oc=Nt.hasStandardBrowserEnv?((s,t)=>e=>(e=new URL(e,Nt.origin),s.protocol===e.protocol&&s.host===e.host&&(t||s.port===e.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Rc=Nt.hasStandardBrowserEnv?{write(s,t,e,i,n,r,o){if(typeof document>"u")return;const l=[`${s}=${encodeURIComponent(t)}`];b.isNumber(e)&&l.push(`expires=${new Date(e).toUTCString()}`),b.isString(i)&&l.push(`path=${i}`),b.isString(n)&&l.push(`domain=${n}`),r===!0&&l.push("secure"),b.isString(o)&&l.push(`SameSite=${o}`),document.cookie=l.join("; ")},read(s){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function zc(s){return typeof s!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Nc(s,t){return t?s.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):s}function Xr(s,t,e){let i=!zc(t);return s&&(i||e==!1)?Nc(s,t):t}const Jr=s=>s instanceof $t?{...s}:s;function Ce(s,t){t=t||{};const e={};function i(a,c,u,p){return b.isPlainObject(a)&&b.isPlainObject(c)?b.merge.call({caseless:p},a,c):b.isPlainObject(c)?b.merge({},c):b.isArray(c)?c.slice():c}function n(a,c,u,p){if(b.isUndefined(c)){if(!b.isUndefined(a))return i(void 0,a,u,p)}else return i(a,c,u,p)}function r(a,c){if(!b.isUndefined(c))return i(void 0,c)}function o(a,c){if(b.isUndefined(c)){if(!b.isUndefined(a))return i(void 0,a)}else return i(void 0,c)}function l(a,c,u){if(u in t)return i(a,c);if(u in s)return i(void 0,a)}const h={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:l,headers:(a,c,u)=>n(Jr(a),Jr(c),u,!0)};return b.forEach(Object.keys({...s,...t}),function(c){if(c==="__proto__"||c==="constructor"||c==="prototype")return;const u=b.hasOwnProp(h,c)?h[c]:n,p=u(s[c],t[c],c);b.isUndefined(p)&&u!==l||(e[c]=p)}),e}const Gr=s=>{const t=Ce({},s);let{data:e,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:l}=t;if(t.headers=o=$t.from(o),t.url=$r(Xr(t.baseURL,t.url,t.allowAbsoluteUrls),s.params,s.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),b.isFormData(e)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(b.isFunction(e.getHeaders)){const h=e.getHeaders(),a=["content-type","content-length"];Object.entries(h).forEach(([c,u])=>{a.includes(c.toLowerCase())&&o.set(c,u)})}}if(Nt.hasStandardBrowserEnv&&(i&&b.isFunction(i)&&(i=i(t)),i||i!==!1&&Oc(t.url))){const h=n&&r&&Rc.read(r);h&&o.set(n,h)}return t},Pc=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(e,i){const n=Gr(s);let r=n.data;const o=$t.from(n.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:a}=n,c,u,p,m,d;function f(){m&&m(),d&&d(),n.cancelToken&&n.cancelToken.unsubscribe(c),n.signal&&n.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout;function w(){if(!g)return;const _=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),N={data:!l||l==="text"||l==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:_,config:s,request:g};Hr(function(B){e(B),f()},function(B){i(B),f()},N),g=null}"onloadend"in g?g.onloadend=w:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(w)},g.onabort=function(){g&&(i(new V("Request aborted",V.ECONNABORTED,s,g)),g=null)},g.onerror=function(k){const N=k&&k.message?k.message:"Network Error",Z=new V(N,V.ERR_NETWORK,s,g);Z.event=k||null,i(Z),g=null},g.ontimeout=function(){let k=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const N=n.transitional||Rs;n.timeoutErrorMessage&&(k=n.timeoutErrorMessage),i(new V(k,N.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,s,g)),g=null},r===void 0&&o.setContentType(null),"setRequestHeader"in g&&b.forEach(o.toJSON(),function(k,N){g.setRequestHeader(N,k)}),b.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),l&&l!=="json"&&(g.responseType=n.responseType),a&&([p,d]=Ri(a,!0),g.addEventListener("progress",p)),h&&g.upload&&([u,m]=Ri(h),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",m)),(n.cancelToken||n.signal)&&(c=_=>{g&&(i(!_||_.type?new ei(null,s,g):_),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const y=Mc(n.url);if(y&&Nt.protocols.indexOf(y)===-1){i(new V("Unsupported protocol "+y+":",V.ERR_BAD_REQUEST,s));return}g.send(r||null)})},Dc=(s,t)=>{const{length:e}=s=s?s.filter(Boolean):[];if(t||e){let i=new AbortController,n;const r=function(a){if(!n){n=!0,l();const c=a instanceof Error?a:this.reason;i.abort(c instanceof V?c:new ei(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new V(`timeout of ${t}ms exceeded`,V.ETIMEDOUT))},t);const l=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),s=null)};s.forEach(a=>a.addEventListener("abort",r));const{signal:h}=i;return h.unsubscribe=()=>b.asap(l),h}},Ac=function*(s,t){let e=s.byteLength;if(e<t){yield s;return}let i=0,n;for(;i<e;)n=i+t,yield s.slice(i,n),i=n},Bc=async function*(s,t){for await(const e of Vc(s))yield*Ac(e,t)},Vc=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const t=s.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},Yr=(s,t,e,i)=>{const n=Bc(s,t);let r=0,o,l=h=>{o||(o=!0,i&&i(h))};return new ReadableStream({async pull(h){try{const{done:a,value:c}=await n.next();if(a){l(),h.close();return}let u=c.byteLength;if(e){let p=r+=u;e(p)}h.enqueue(new Uint8Array(c))}catch(a){throw l(a),a}},cancel(h){return l(h),n.return()}},{highWaterMark:2})},Qr=64*1024,{isFunction:zi}=b,Fc=(({Request:s,Response:t})=>({Request:s,Response:t}))(b.global),{ReadableStream:Zr,TextEncoder:to}=b.global,eo=(s,...t)=>{try{return!!s(...t)}catch{return!1}},$c=s=>{s=b.merge.call({skipUndefined:!0},Fc,s);const{fetch:t,Request:e,Response:i}=s,n=t?zi(t):typeof fetch=="function",r=zi(e),o=zi(i);if(!n)return!1;const l=n&&zi(Zr),h=n&&(typeof to=="function"?(d=>f=>d.encode(f))(new to):async d=>new Uint8Array(await new e(d).arrayBuffer())),a=r&&l&&eo(()=>{let d=!1;const f=new e(Nt.origin,{body:new Zr,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!f}),c=o&&l&&eo(()=>b.isReadableStream(new i("").body)),u={stream:c&&(d=>d.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(f,g)=>{let w=f&&f[d];if(w)return w.call(f);throw new V(`Response type '${d}' is not supported`,V.ERR_NOT_SUPPORT,g)})});const p=async d=>{if(d==null)return 0;if(b.isBlob(d))return d.size;if(b.isSpecCompliantForm(d))return(await new e(Nt.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(b.isArrayBufferView(d)||b.isArrayBuffer(d))return d.byteLength;if(b.isURLSearchParams(d)&&(d=d+""),b.isString(d))return(await h(d)).byteLength},m=async(d,f)=>{const g=b.toFiniteNumber(d.getContentLength());return g??p(f)};return async d=>{let{url:f,method:g,data:w,signal:y,cancelToken:_,timeout:k,onDownloadProgress:N,onUploadProgress:Z,responseType:B,headers:G,withCredentials:tt="same-origin",fetchOptions:Ct}=Gr(d),$=t||fetch;B=B?(B+"").toLowerCase():"text";let at=Dc([y,_&&_.toAbortSignal()],k),Rt=null;const bt=at&&at.unsubscribe&&(()=>{at.unsubscribe()});let rt;try{if(Z&&a&&g!=="get"&&g!=="head"&&(rt=await m(G,w))!==0){let wt=new e(f,{method:"POST",body:w,duplex:"half"}),Y;if(b.isFormData(w)&&(Y=wt.headers.get("content-type"))&&G.setContentType(Y),wt.body){const[ut,Tt]=jr(rt,Ri(Kr(Z)));w=Yr(wt.body,Qr,ut,Tt)}}b.isString(tt)||(tt=tt?"include":"omit");const ot=r&&"credentials"in e.prototype,ct={...Ct,signal:at,method:g.toUpperCase(),headers:G.normalize().toJSON(),body:w,duplex:"half",credentials:ot?tt:void 0};Rt=r&&new e(f,ct);let zt=await(r?$(Rt,Ct):$(f,ct));const Et=c&&(B==="stream"||B==="response");if(c&&(N||Et&&bt)){const wt={};["status","statusText","headers"].forEach(St=>{wt[St]=zt[St]});const Y=b.toFiniteNumber(zt.headers.get("content-length")),[ut,Tt]=N&&jr(Y,Ri(Kr(N),!0))||[];zt=new i(Yr(zt.body,Qr,ut,()=>{Tt&&Tt(),bt&&bt()}),wt)}B=B||"text";let yt=await u[b.findKey(u,B)||"text"](zt,d);return!Et&&bt&&bt(),await new Promise((wt,Y)=>{Hr(wt,Y,{data:yt,headers:$t.from(zt.headers),status:zt.status,statusText:zt.statusText,config:d,request:Rt})})}catch(ot){throw bt&&bt(),ot&&ot.name==="TypeError"&&/Load failed|fetch/i.test(ot.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,d,Rt,ot&&ot.response),{cause:ot.cause||ot}):V.from(ot,ot&&ot.code,d,Rt,ot&&ot.response)}}},Ic=new Map,io=s=>{let t=s&&s.env||{};const{fetch:e,Request:i,Response:n}=t,r=[i,n,e];let o=r.length,l=o,h,a,c=Ic;for(;l--;)h=r[l],a=c.get(h),a===void 0&&c.set(h,a=l?new Map:$c(t)),c=a;return a};io();const As={http:ac,xhr:Pc,fetch:{get:io}};b.forEach(As,(s,t)=>{if(s){try{Object.defineProperty(s,"name",{value:t})}catch{}Object.defineProperty(s,"adapterName",{value:t})}});const so=s=>`- ${s}`,Uc=s=>b.isFunction(s)||s===null||s===!1;function Wc(s,t){s=b.isArray(s)?s:[s];const{length:e}=s;let i,n;const r={};for(let o=0;o<e;o++){i=s[o];let l;if(n=i,!Uc(i)&&(n=As[(l=String(i)).toLowerCase()],n===void 0))throw new V(`Unknown adapter '${l}'`);if(n&&(b.isFunction(n)||(n=n.get(t))))break;r[l||"#"+o]=n}if(!n){const o=Object.entries(r).map(([h,a])=>`adapter ${h} `+(a===!1?"is not supported by the environment":"is not available in the build"));let l=e?o.length>1?`since :
4
+ `+o.map(so).join(`
5
+ `):" "+so(o[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return n}const no={getAdapter:Wc,adapters:As};function Bs(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new ei(null,s)}function ro(s){return Bs(s),s.headers=$t.from(s.headers),s.data=Ds.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),no.getAdapter(s.adapter||Ze.adapter,s)(s).then(function(i){return Bs(s),i.data=Ds.call(s,s.transformResponse,i),i.headers=$t.from(i.headers),i},function(i){return qr(i)||(Bs(s),i&&i.response&&(i.response.data=Ds.call(s,s.transformResponse,i.response),i.response.headers=$t.from(i.response.headers))),Promise.reject(i)})}const oo="1.13.5",Ni={};["object","boolean","number","function","string","symbol"].forEach((s,t)=>{Ni[s]=function(i){return typeof i===s||"a"+(t<1?"n ":" ")+s}});const lo={};Ni.transitional=function(t,e,i){function n(r,o){return"[Axios v"+oo+"] Transitional option '"+r+"'"+o+(i?". "+i:"")}return(r,o,l)=>{if(t===!1)throw new V(n(o," has been removed"+(e?" in "+e:"")),V.ERR_DEPRECATED);return e&&!lo[o]&&(lo[o]=!0,console.warn(n(o," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(r,o,l):!0}},Ni.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function qc(s,t,e){if(typeof s!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const i=Object.keys(s);let n=i.length;for(;n-- >0;){const r=i[n],o=t[r];if(o){const l=s[r],h=l===void 0||o(l,r,s);if(h!==!0)throw new V("option "+r+" must be "+h,V.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new V("Unknown option "+r,V.ERR_BAD_OPTION)}}const Pi={assertOptions:qc,validators:Ni},Ht=Pi.validators;let Ee=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ir,response:new Ir}}async request(t,e){try{return await this._request(t,e)}catch(i){if(i instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const r=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?r&&!String(i.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(i.stack+=`
6
+ `+r):i.stack=r}catch{}}throw i}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Ce(this.defaults,e);const{transitional:i,paramsSerializer:n,headers:r}=e;i!==void 0&&Pi.assertOptions(i,{silentJSONParsing:Ht.transitional(Ht.boolean),forcedJSONParsing:Ht.transitional(Ht.boolean),clarifyTimeoutError:Ht.transitional(Ht.boolean),legacyInterceptorReqResOrdering:Ht.transitional(Ht.boolean)},!1),n!=null&&(b.isFunction(n)?e.paramsSerializer={serialize:n}:Pi.assertOptions(n,{encode:Ht.function,serialize:Ht.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Pi.assertOptions(e,{baseUrl:Ht.spelling("baseURL"),withXsrfToken:Ht.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=r&&b.merge(r.common,r[e.method]);r&&b.forEach(["delete","get","head","post","put","patch","common"],d=>{delete r[d]}),e.headers=$t.concat(o,r);const l=[];let h=!0;this.interceptors.request.forEach(function(f){if(typeof f.runWhen=="function"&&f.runWhen(e)===!1)return;h=h&&f.synchronous;const g=e.transitional||Rs;g&&g.legacyInterceptorReqResOrdering?l.unshift(f.fulfilled,f.rejected):l.push(f.fulfilled,f.rejected)});const a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});let c,u=0,p;if(!h){const d=[ro.bind(this),void 0];for(d.unshift(...l),d.push(...a),p=d.length,c=Promise.resolve(e);u<p;)c=c.then(d[u++],d[u++]);return c}p=l.length;let m=e;for(;u<p;){const d=l[u++],f=l[u++];try{m=d(m)}catch(g){f.call(this,g);break}}try{c=ro.call(this,m)}catch(d){return Promise.reject(d)}for(u=0,p=a.length;u<p;)c=c.then(a[u++],a[u++]);return c}getUri(t){t=Ce(this.defaults,t);const e=Xr(t.baseURL,t.url,t.allowAbsoluteUrls);return $r(e,t.params,t.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(t){Ee.prototype[t]=function(e,i){return this.request(Ce(i||{},{method:t,url:e,data:(i||{}).data}))}}),b.forEach(["post","put","patch"],function(t){function e(i){return function(r,o,l){return this.request(Ce(l||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}Ee.prototype[t]=e(),Ee.prototype[t+"Form"]=e(!0)});let Hc=class Xo{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(r){e=r});const i=this;this.promise.then(n=>{if(!i._listeners)return;let r=i._listeners.length;for(;r-- >0;)i._listeners[r](n);i._listeners=null}),this.promise.then=n=>{let r;const o=new Promise(l=>{i.subscribe(l),r=l}).then(n);return o.cancel=function(){i.unsubscribe(r)},o},t(function(r,o,l){i.reason||(i.reason=new ei(r,o,l),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=i=>{t.abort(i)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new Xo(function(n){t=n}),cancel:t}}};function jc(s){return function(e){return s.apply(null,e)}}function Kc(s){return b.isObject(s)&&s.isAxiosError===!0}const Vs={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Vs).forEach(([s,t])=>{Vs[t]=s});function ho(s){const t=new Ee(s),e=Mr(Ee.prototype.request,t);return b.extend(e,Ee.prototype,t,{allOwnKeys:!0}),b.extend(e,t,null,{allOwnKeys:!0}),e.create=function(n){return ho(Ce(s,n))},e}const mt=ho(Ze);mt.Axios=Ee,mt.CanceledError=ei,mt.CancelToken=Hc,mt.isCancel=qr,mt.VERSION=oo,mt.toFormData=Li,mt.AxiosError=V,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=jc,mt.isAxiosError=Kc,mt.mergeConfig=Ce,mt.AxiosHeaders=$t,mt.formToJSON=s=>Ur(b.isHTMLForm(s)?new FormData(s):s),mt.getAdapter=no.getAdapter,mt.HttpStatusCode=Vs,mt.default=mt;const{Axios:pf,AxiosError:mf,CanceledError:gf,isCancel:bf,CancelToken:vf,VERSION:yf,all:wf,Cancel:Sf,isAxiosError:_f,spread:xf,toFormData:Cf,AxiosHeaders:Ef,HttpStatusCode:Tf,formToJSON:Mf,getAdapter:kf,mergeConfig:Lf}=mt,ie=Object.create(null);ie.open="0",ie.close="1",ie.ping="2",ie.pong="3",ie.message="4",ie.upgrade="5",ie.noop="6";const Di=Object.create(null);Object.keys(ie).forEach(s=>{Di[ie[s]]=s});const Fs={type:"error",data:"parser error"},ao=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",co=typeof ArrayBuffer=="function",uo=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,$s=({type:s,data:t},e,i)=>ao&&t instanceof Blob?e?i(t):fo(t,i):co&&(t instanceof ArrayBuffer||uo(t))?e?i(t):fo(new Blob([t]),i):i(ie[s]+(t||"")),fo=(s,t)=>{const e=new FileReader;return e.onload=function(){const i=e.result.split(",")[1];t("b"+(i||""))},e.readAsDataURL(s)};function po(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Is;function Xc(s,t){if(ao&&s.data instanceof Blob)return s.data.arrayBuffer().then(po).then(t);if(co&&(s.data instanceof ArrayBuffer||uo(s.data)))return t(po(s.data));$s(s,!1,e=>{Is||(Is=new TextEncoder),t(Is.encode(e))})}const mo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ii=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<mo.length;s++)ii[mo.charCodeAt(s)]=s;const Jc=s=>{let t=s.length*.75,e=s.length,i,n=0,r,o,l,h;s[s.length-1]==="="&&(t--,s[s.length-2]==="="&&t--);const a=new ArrayBuffer(t),c=new Uint8Array(a);for(i=0;i<e;i+=4)r=ii[s.charCodeAt(i)],o=ii[s.charCodeAt(i+1)],l=ii[s.charCodeAt(i+2)],h=ii[s.charCodeAt(i+3)],c[n++]=r<<2|o>>4,c[n++]=(o&15)<<4|l>>2,c[n++]=(l&3)<<6|h&63;return a},Gc=typeof ArrayBuffer=="function",Us=(s,t)=>{if(typeof s!="string")return{type:"message",data:go(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:Yc(s.substring(1),t)}:Di[e]?s.length>1?{type:Di[e],data:s.substring(1)}:{type:Di[e]}:Fs},Yc=(s,t)=>{if(Gc){const e=Jc(s);return go(e,t)}else return{base64:!0,data:s}},go=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,bo="",Qc=(s,t)=>{const e=s.length,i=new Array(e);let n=0;s.forEach((r,o)=>{$s(r,!1,l=>{i[o]=l,++n===e&&t(i.join(bo))})})},Zc=(s,t)=>{const e=s.split(bo),i=[];for(let n=0;n<e.length;n++){const r=Us(e[n],t);if(i.push(r),r.type==="error")break}return i};function tu(){return new TransformStream({transform(s,t){Xc(s,e=>{const i=e.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const r=new DataView(n.buffer);r.setUint8(0,126),r.setUint16(1,i)}else{n=new Uint8Array(9);const r=new DataView(n.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(i))}s.data&&typeof s.data!="string"&&(n[0]|=128),t.enqueue(n),t.enqueue(e)})}})}let Ws;function Ai(s){return s.reduce((t,e)=>t+e.length,0)}function Bi(s,t){if(s[0].length===t)return s.shift();const e=new Uint8Array(t);let i=0;for(let n=0;n<t;n++)e[n]=s[0][i++],i===s[0].length&&(s.shift(),i=0);return s.length&&i<s[0].length&&(s[0]=s[0].slice(i)),e}function eu(s,t){Ws||(Ws=new TextDecoder);const e=[];let i=0,n=-1,r=!1;return new TransformStream({transform(o,l){for(e.push(o);;){if(i===0){if(Ai(e)<1)break;const h=Bi(e,1);r=(h[0]&128)===128,n=h[0]&127,n<126?i=3:n===126?i=1:i=2}else if(i===1){if(Ai(e)<2)break;const h=Bi(e,2);n=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),i=3}else if(i===2){if(Ai(e)<8)break;const h=Bi(e,8),a=new DataView(h.buffer,h.byteOffset,h.length),c=a.getUint32(0);if(c>Math.pow(2,21)-1){l.enqueue(Fs);break}n=c*Math.pow(2,32)+a.getUint32(4),i=3}else{if(Ai(e)<n)break;const h=Bi(e,n);l.enqueue(Us(r?h:Ws.decode(h),t)),i=0}if(n===0||n>s){l.enqueue(Fs);break}}}})}const vo=4;function Mt(s){if(s)return iu(s)}function iu(s){for(var t in Mt.prototype)s[t]=Mt.prototype[t];return s}Mt.prototype.on=Mt.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},Mt.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},Mt.prototype.off=Mt.prototype.removeListener=Mt.prototype.removeAllListeners=Mt.prototype.removeEventListener=function(s,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+s];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var i,n=0;n<e.length;n++)if(i=e[n],i===t||i.fn===t){e.splice(n,1);break}return e.length===0&&delete this._callbacks["$"+s],this},Mt.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+s],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(e){e=e.slice(0);for(var i=0,n=e.length;i<n;++i)e[i].apply(this,t)}return this},Mt.prototype.emitReserved=Mt.prototype.emit,Mt.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},Mt.prototype.hasListeners=function(s){return!!this.listeners(s).length};const Vi=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),jt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),su="arraybuffer";function Of(){}function yo(s,...t){return t.reduce((e,i)=>(s.hasOwnProperty(i)&&(e[i]=s[i]),e),{})}const nu=jt.setTimeout,ru=jt.clearTimeout;function Fi(s,t){t.useNativeTimers?(s.setTimeoutFn=nu.bind(jt),s.clearTimeoutFn=ru.bind(jt)):(s.setTimeoutFn=jt.setTimeout.bind(jt),s.clearTimeoutFn=jt.clearTimeout.bind(jt))}const ou=1.33;function lu(s){return typeof s=="string"?hu(s):Math.ceil((s.byteLength||s.size)*ou)}function hu(s){let t=0,e=0;for(let i=0,n=s.length;i<n;i++)t=s.charCodeAt(i),t<128?e+=1:t<2048?e+=2:t<55296||t>=57344?e+=3:(i++,e+=4);return e}function wo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function au(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function cu(s){let t={},e=s.split("&");for(let i=0,n=e.length;i<n;i++){let r=e[i].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}class uu extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class qs extends Mt{constructor(t){super(),this.writable=!1,Fi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,i){return super.emitReserved("error",new uu(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Us(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=au(t);return e.length?"?"+e:""}}class fu extends qs{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||e()})),this.writable||(i++,this.once("drain",function(){--i||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Zc(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Qc(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=wo()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let So=!1;try{So=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const du=So;function pu(){}class mu extends fu{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let i=location.port;i||(i=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",(n,r)=>{this.onError("xhr post error",n,r)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,i)=>{this.onError("xhr poll error",e,i)}),this.pollXhr=t}}class se extends Mt{constructor(t,e,i){super(),this.createRequest=t,Fi(this,i),this._opts=i,this._method=i.method||"GET",this._uri=e,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;const e=yo(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(e);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&i.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var n;i.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=se.requestsCount++,se.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pu,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete se.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(se.requestsCount=0,se.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",_o);else if(typeof addEventListener=="function"){const s="onpagehide"in jt?"pagehide":"unload";addEventListener(s,_o,!1)}}function _o(){for(let s in se.requests)se.requests.hasOwnProperty(s)&&se.requests[s].abort()}const gu=(function(){const s=xo({xdomain:!1});return s&&s.responseType!==null})();class bu extends mu{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=gu&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new se(xo,this.uri(),t)}}function xo(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||du))return new XMLHttpRequest}catch{}if(!t)try{return new jt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Co=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class vu extends qs{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,i=Co?{}:yo(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,i)}catch(n){return this.emitReserved("error",n)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;$s(i,this.supportsBinary,r=>{try{this.doWrite(i,r)}catch{}n&&Vi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=wo()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Hs=jt.WebSocket||jt.MozWebSocket;class yu extends vu{createSocket(t,e,i){return Co?new Hs(t,e,i):e?new Hs(t,e):new Hs(t)}doWrite(t,e){this.ws.send(e)}}class wu extends qs{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=eu(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),n=tu();n.readable.pipeTo(t.writable),this._writer=n.writable.getWriter();const r=()=>{i.read().then(({done:l,value:h})=>{l||(this.onPacket(h),r())}).catch(l=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;this._writer.write(i).then(()=>{n&&Vi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Su={websocket:yu,webtransport:wu,polling:bu},_u=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,xu=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function js(s){if(s.length>8e3)throw"URI too long";const t=s,e=s.indexOf("["),i=s.indexOf("]");e!=-1&&i!=-1&&(s=s.substring(0,e)+s.substring(e,i).replace(/:/g,";")+s.substring(i,s.length));let n=_u.exec(s||""),r={},o=14;for(;o--;)r[xu[o]]=n[o]||"";return e!=-1&&i!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Cu(r,r.path),r.queryKey=Eu(r,r.query),r}function Cu(s,t){const e=/\/{2,9}/g,i=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function Eu(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,n,r){n&&(e[n]=r)}),e}const Ks=typeof addEventListener=="function"&&typeof removeEventListener=="function",$i=[];Ks&&addEventListener("offline",()=>{$i.forEach(s=>s())},!1);class me extends Mt{constructor(t,e){if(super(),this.binaryType=su,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const i=js(t);e.hostname=i.host,e.secure=i.protocol==="https"||i.protocol==="wss",e.port=i.port,i.query&&(e.query=i.query)}else e.host&&(e.hostname=js(e.host).host);Fi(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(i=>{const n=i.prototype.name;this.transports.push(n),this._transportsByName[n]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=cu(this.opts.query)),Ks&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},$i.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=vo,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&me.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",me.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let i=0;i<this.writeBuffer.length;i++){const n=this.writeBuffer[i].data;if(n&&(e+=lu(n)),i>0&&e>this._maxPayload)return this.writeBuffer.slice(0,i);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Vi(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,i){return this._sendPacket("message",t,e,i),this}send(t,e,i){return this._sendPacket("message",t,e,i),this}_sendPacket(t,e,i,n){if(typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const r={type:t,data:e,options:i};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():t()}):this.upgrading?i():t()),this}_onError(t){if(me.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ks&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=$i.indexOf(this._offlineEventListener);i!==-1&&$i.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}me.protocol=vo;class Tu extends me{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),i=!1;me.priorWebsocketSuccess=!1;const n=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",u=>{if(!i)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;me.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(c(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=e.name,this.emitReserved("upgradeError",p)}}))};function r(){i||(i=!0,c(),e.close(),e=null)}const o=u=>{const p=new Error("probe error: "+u);p.transport=e.name,r(),this.emitReserved("upgradeError",p)};function l(){o("transport closed")}function h(){o("socket closed")}function a(u){e&&u.name!==e.name&&r()}const c=()=>{e.removeListener("open",n),e.removeListener("error",o),e.removeListener("close",l),this.off("close",h),this.off("upgrading",a)};e.once("open",n),e.once("error",o),e.once("close",l),this.once("close",h),this.once("upgrading",a),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&e.push(t[i]);return e}}let Mu=class extends Tu{constructor(t,e={}){const i=typeof t=="object"?t:e;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(n=>Su[n]).filter(n=>!!n)),super(t,i)}};function ku(s,t="",e){let i=s;e=e||typeof location<"u"&&location,s==null&&(s=e.protocol+"//"+e.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=e.protocol+s:s=e.host+s),/^(https?|wss?):\/\//.test(s)||(typeof e<"u"?s=e.protocol+"//"+s:s="https://"+s),i=js(s)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const r=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+r+":"+i.port+t,i.href=i.protocol+"://"+r+(e&&e.port===i.port?"":":"+i.port),i}const Lu=typeof ArrayBuffer=="function",Ou=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Eo=Object.prototype.toString,Ru=typeof Blob=="function"||typeof Blob<"u"&&Eo.call(Blob)==="[object BlobConstructor]",zu=typeof File=="function"||typeof File<"u"&&Eo.call(File)==="[object FileConstructor]";function Xs(s){return Lu&&(s instanceof ArrayBuffer||Ou(s))||Ru&&s instanceof Blob||zu&&s instanceof File}function Ii(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,i=s.length;e<i;e++)if(Ii(s[e]))return!0;return!1}if(Xs(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Ii(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&Ii(s[e]))return!0;return!1}function Nu(s){const t=[],e=s.data,i=s;return i.data=Js(e,t),i.attachments=t.length,{packet:i,buffers:t}}function Js(s,t){if(!s)return s;if(Xs(s)){const e={_placeholder:!0,num:t.length};return t.push(s),e}else if(Array.isArray(s)){const e=new Array(s.length);for(let i=0;i<s.length;i++)e[i]=Js(s[i],t);return e}else if(typeof s=="object"&&!(s instanceof Date)){const e={};for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=Js(s[i],t));return e}return s}function Pu(s,t){return s.data=Gs(s.data,t),delete s.attachments,s}function Gs(s,t){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<t.length)return t[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let e=0;e<s.length;e++)s[e]=Gs(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Gs(s[e],t));return s}const Du=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var it;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(it||(it={}));class Au{constructor(t){this.replacer=t}encode(t){return(t.type===it.EVENT||t.type===it.ACK)&&Ii(t)?this.encodeAsBinary({type:t.type===it.EVENT?it.BINARY_EVENT:it.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===it.BINARY_EVENT||t.type===it.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=Nu(t),i=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(i),n}}class Ys extends Mt{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const i=e.type===it.BINARY_EVENT;i||e.type===it.BINARY_ACK?(e.type=i?it.EVENT:it.ACK,this.reconstructor=new Bu(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Xs(t)||t.base64)if(this.reconstructor)e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let e=0;const i={type:Number(t.charAt(0))};if(it[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===it.BINARY_EVENT||i.type===it.BINARY_ACK){const r=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(r,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(t.charAt(e+1)==="/"){const r=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););i.nsp=t.substring(r,e)}else i.nsp="/";const n=t.charAt(e+1);if(n!==""&&Number(n)==n){const r=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}i.id=Number(t.substring(r,e+1))}if(t.charAt(++e)){const r=this.tryParse(t.substr(e));if(Ys.isPayloadValid(i.type,r))i.data=r;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case it.CONNECT:return To(e);case it.DISCONNECT:return e===void 0;case it.CONNECT_ERROR:return typeof e=="string"||To(e);case it.EVENT:case it.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Du.indexOf(e[0])===-1);case it.ACK:case it.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Bu{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=Pu(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function To(s){return Object.prototype.toString.call(s)==="[object Object]"}const Vu=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ys,Encoder:Au,get PacketType(){return it}},Symbol.toStringTag,{value:"Module"}));function Zt(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const Fu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Mo extends Mt{constructor(t,e,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Zt(t,"open",this.onopen.bind(this)),Zt(t,"packet",this.onpacket.bind(this)),Zt(t,"error",this.onerror.bind(this)),Zt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var i,n,r;if(Fu.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const o={type:it.EVENT,data:e};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const c=this.ids++,u=e.pop();this._registerAckCallback(c,u),o.id=c}const l=(n=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||n===void 0?void 0:n.writable,h=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!l||(h?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,e){var i;const n=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(n===void 0){this.acks[t]=e;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);e.call(this,new Error("operation has timed out"))},n),o=(...l)=>{this.io.clearTimeoutFn(r),e.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((i,n)=>{const r=(o,l)=>o?n(o):i(l);r.withError=!0,e.push(r),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((n,...r)=>(this._queue[0],n!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(n)):(this._queue.shift(),e&&e(null,...r)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:it.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case it.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case it.EVENT:case it.BINARY_EVENT:this.onevent(t);break;case it.ACK:case it.BINARY_ACK:this.onack(t);break;case it.DISCONNECT:this.ondisconnect();break;case it.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...n){i||(i=!0,e.packet({type:it.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:it.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const i of e)i.apply(this,t.data)}}}function De(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}De.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*s);s=(Math.floor(t*10)&1)==0?s-e:s+e}return Math.min(s,this.max)|0},De.prototype.reset=function(){this.attempts=0},De.prototype.setMin=function(s){this.ms=s},De.prototype.setMax=function(s){this.max=s},De.prototype.setJitter=function(s){this.jitter=s};class Qs extends Mt{constructor(t,e){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,Fi(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((i=e.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new De({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||Vu;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Mu(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=Zt(e,"open",function(){i.onopen(),t&&t()}),r=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Zt(e,"error",r);if(this._timeout!==!1){const l=this._timeout,h=this.setTimeoutFn(()=>{n(),r(new Error("timeout")),e.close()},l);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(n),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Zt(t,"ping",this.onping.bind(this)),Zt(t,"data",this.ondata.bind(this)),Zt(t,"error",this.onerror.bind(this)),Zt(t,"close",this.onclose.bind(this)),Zt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){Vi(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new Mo(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const i of e)if(this.nsps[i].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;i<e.length;i++)this.engine.write(e[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(n=>{n?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",n)):t.onreconnect()}))},e);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const si={};function Ui(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=ku(s,t.path||"/socket.io"),i=e.source,n=e.id,r=e.path,o=si[n]&&r in si[n].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let h;return l?h=new Qs(i,t):(si[n]||(si[n]=new Qs(i,t)),h=si[n]),e.query&&!t.query&&(t.query=e.queryKey),h.socket(e.path,t)}Object.assign(Ui,{Manager:Qs,Socket:Mo,io:Ui,connect:Ui});let Zs="http://localhost:8000";function ko(s){s&&s!==Zs&&(Zs=s,ne&&(ne.disconnect(),ne=null))}let ne=null;function $u(){return Ui(Zs,{transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,reconnectionAttempts:1/0,timeout:1e4,forceNew:!1})}function tn(){return ne||(ne=$u()),ne}function Iu(s,t){const e=tn();return e.on(s,t),()=>e.off(s,t)}function Uu(s,t){ne&&ne.off(s,t)}function Wu(s,t){tn().emit(s,t)}function qu(){return ne?ne.connected?"connected":"connecting":"disconnected"}const en={getSocket:tn,on:Iu,off:Uu,emit:Wu,getStatus:qu,setBaseUrl:ko},Lo=x.createContext(),Ae=()=>{const s=x.useContext(Lo);if(!s)throw new Error("useTrading must be used within TradingProvider");return s},Hu=({children:s,baseUrl:t})=>{const e=t||typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Wi&&Wi.tagName.toUpperCase()==="SCRIPT"&&Wi.src||new URL("chart-sdk.umd.js",document.baseURI).href}<"u"&&"http://localhost:8000"||"http://localhost:8000";x.useEffect(()=>{en.setBaseUrl(e),Fo(e)},[e]);const[i,n]=x.useState("CADJPY"),[r,o]=x.useState("M1"),[l,h]=x.useState([]),[a,c]=x.useState(!0),[u,p]=x.useState([]),[m,d]=x.useState(!1),[f,g]=x.useState(1e5),[w,y]=x.useState(null),[_,k]=x.useState([]),[N,Z]=x.useState(!0),[B,G]=x.useState(!1),[tt,Ct]=x.useState(!0),[$,at]=x.useState("candles"),[Rt,bt]=x.useState(!1),rt=x.useRef(null),ot=x.useRef(new Map),ct=x.useRef(null),zt=1e3,Et=x.useCallback(async()=>{try{const W=localStorage.getItem("token");if(!W){console.log("⚠️ No token, skipping orders fetch");return}d(!0);const et=await mt.get(`${e}/api/trades`,{headers:{Authorization:`Bearer ${W}`}});if(et.data&&et.data.data){const j=et.data.data.map(Q=>({id:Q.id,ticket:Q.ticket,symbol:Q.symbol,type:Q.type,volume:Q.volume,price:Q.price,stopLoss:Q.stopLoss,takeProfit:Q.takeProfit,comment:Q.comment||"",status:Q.status,swap:Q.swap||0,profit:Q.profit||0,profitCurrency:"USD",time:new Date(Q.openAt).toLocaleTimeString(),openAt:Q.openAt,closeAt:Q.closeAt}));p(j)}else p([])}catch(W){console.error("❌ Error fetching orders:",W.response?.data||W.message),p([])}finally{d(!1)}},[]),yt=x.useCallback((W,et)=>!et||!W.price||isNaN(et)||isNaN(W.price)?W.profit||0:(W.type==="BUY"?et-W.price:W.price-et)*W.volume,[]),wt=x.useCallback(async()=>{try{const W=localStorage.getItem("token");if(!W){console.log("⚠️ No token, skipping balance fetch");return}const et=await mt.get(`${e}/api/user/account`,{headers:{Authorization:`Bearer ${W}`}});if(et.data&&et.data.data){const j=parseFloat(et.data.data.balance);isNaN(j)||g(j)}}catch(W){console.error("❌ Error fetching user balance:",W.response?.data||W.message)}},[]),Y=x.useMemo(()=>{const W=f,et=u.reduce((_t,Lt)=>_t+Lt.volume*Lt.price*.01,0),j=u.reduce((_t,Lt)=>{const Kt=l.find(Xt=>Xt.symbol===Lt.symbol);if(Kt){const Xt=Lt.type==="BUY"?parseFloat(Kt.bid||0):parseFloat(Kt.ask||0);if(Xt&&Xt>0&&!isNaN(Xt))return _t+yt(Lt,Xt)}return _t+(Lt.profit||0)},0),Q=W+j,Wt=Q-et,ht=et>0?Q/et*100:0;return{balance:W,equity:Q,margin:et,freeMargin:Wt,level:ht.toFixed(2)}},[u,l,f,yt]);x.useEffect(()=>{localStorage.getItem("token")&&(Et(),wt())},[Et,wt]),x.useEffect(()=>{(async()=>{try{c(!0);const et=await mt.get(`${e}/api/symbols`);if(et.data&&et.data.data){const j=et.data.data;h(j),j.length>0&&(j.find(Wt=>Wt.symbol===i)||n(j[0].symbol))}else h([])}catch(et){console.error("❌ Error fetching symbols:",et.response?.data||et.message),h([])}finally{c(!1)}})()},[]);const ut=x.useCallback(()=>{const W=ot.current;if(W.size===0)return;const et=new Map(W);W.clear(),h(j=>j.map(Q=>{const Wt=et.get(Q.symbol);return Wt?{...Q,...Wt}:Q})),p(j=>{let Q=!1;const Wt=j.map(ht=>{const _t=et.get(ht.symbol);if(!_t)return ht;const Lt=ht.type==="BUY"?parseFloat(_t.bid||0):parseFloat(_t.ask||0);if(!Lt||isNaN(Lt)||Lt<=0)return ht;const Kt=yt(ht,Lt);return Kt===ht.profit?ht:(Q=!0,{...ht,profit:Kt})});return Q?Wt:j})},[yt]);x.useEffect(()=>{rt.current||(rt.current=en.getSocket());const W=rt.current,et=()=>console.log("✅ TradingContext: Connected"),j=()=>console.log("⚠️ TradingContext: Disconnected"),Q=ht=>{ht?.symbol&&(ot.current.set(ht.symbol,ht),ct.current||(ct.current=setTimeout(()=>{ct.current=null,ut()},zt)))},Wt=async ht=>{if(console.log("🔔 Trade closed event received:",ht),!!ht){if(ht.newBalance!==void 0){const _t=parseFloat(ht.newBalance);isNaN(_t)||g(_t)}if(window.notify){const _t=ht.profitLoss||ht.profit||0,Lt=_t>=0?`+${_t.toFixed(2)}`:_t.toFixed(2),Kt=ht.symbol||"Trade",Xt=ht.reason||"Closed";window.notify(`Trade Closed: ${Xt} | ${Kt} | P/L: ${Lt} USD`,_t>=0?"success":"error")}ht.tradeId&&p(_t=>_t.filter(Lt=>Lt.id!==ht.tradeId)),await Et(),await wt()}};return W.on("connect",et),W.on("disconnect",j),W.on("priceUpdate",Q),W.on("tradeClosed",Wt),()=>{W.off("connect",et),W.off("disconnect",j),W.off("priceUpdate",Q),W.off("tradeClosed",Wt),ct.current&&(clearTimeout(ct.current),ct.current=null),ot.current.clear()}},[ut,Et,wt]);const Tt=x.useMemo(()=>l.find(W=>W.symbol===i)||{bid:"0.00000",ask:"0.00000",change:0},[l,i]),St=x.useMemo(()=>({selectedSymbol:i,setSelectedSymbol:n,selectedTimeframe:r,setSelectedTimeframe:o,symbols:l,setSymbols:h,symbolsLoading:a,orders:u,setOrders:p,ordersLoading:m,fetchOrders:Et,fetchUserBalance:wt,userBalance:f,setUserBalance:g,accountSummary:Y,currentSymbolData:Tt,activeTool:w,setActiveTool:y,chartObjects:_,setChartObjects:k,showGrid:N,setShowGrid:Z,snapToGrid:B,setSnapToGrid:G,drawingsVisible:tt,setDrawingsVisible:Ct,chartType:$,setChartType:at,chartLocked:Rt,setChartLocked:bt}),[i,r,l,a,u,m,Et,wt,f,Y,Tt,w,_,N,B,tt,$,Rt]);return L.jsx(Lo.Provider,{value:St,children:s})};function kt(s){if(s==null)return null;if(typeof s=="number"){if(Number.isNaN(s)||!Number.isFinite(s))return null;let t;s>1e10?t=s/1e3:(s<1e9,t=s);const e=Math.floor(t);return e<946684800||e>4102444800?null:e}if(typeof s=="string"){const t=Date.parse(s);return Number.isNaN(t)?null:Math.floor(t/1e3)}if(typeof s=="object"&&"year"in s&&"month"in s&&"day"in s){const e=new Date(Date.UTC(s.year,s.month-1,s.day)).getTime();return Number.isNaN(e)?null:Math.floor(e/1e3)}return null}function ju(s,t){if(!s||s.length<2)return[];const e=[],i=2;for(let n=1;n<s.length;n++){const r=s[n-1].time,o=s[n].time,l=o-r;l>t*i&&e.push({from:r,to:o,gapSeconds:l,gapHours:(l/3600).toFixed(1),fromDate:new Date(r*1e3).toISOString(),toDate:new Date(o*1e3).toISOString()})}return e}function Ku(s,t="America/New_York"){const e=new Date(s*1e3),i=new Date(e.toLocaleString("en-US",{timeZone:t})),n=i.getDay();return!(n===0||n===6||n===5&&i.getHours()>=17)}function Oo(s){return Array.isArray(s)?s.map(t=>({...t,time:kt(t.time)})).filter(t=>t.time!=null):[]}function Xu(s){if(!s||s.length<2)return!0;for(let t=1;t<s.length;t++)if(s[t].time<=s[t-1].time)return!1;return!0}function Be(s,t){return!Number.isFinite(s)||!Number.isFinite(t)||t<=0?s:Math.floor(s/t)*t}const Pt="17:00-17:00",Dt="America/New_York",re="24x7",oe="UTC",Ro={EURUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},GBPUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},USDJPY:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},USDCHF:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},AUDUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},USDCAD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},NZDUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},EURGBP:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},GBPJPY:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},CADJPY:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},XAUUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},XAGUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},OILUSD:{type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"},BTCUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},ETHUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},BNBUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},SOLUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},ADAUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},XRPUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},DOGEUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},DOTUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},MATICUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"},LINKUSDT:{type:"crypto",session:re,sessionTZ:oe,priceMode:"last"}},zo={type:"forex",sessionTZ:Dt,session:Pt,priceMode:"mid"};function ni(s){return s&&Ro[s.toUpperCase()]||zo}function Ju(s){return ni(s).type==="forex"}function sn(s){return ni(s).type==="crypto"}function Gu(s){return ni(s).session==="24x7"}function No(s){if(!s||typeof s!="object")return!1;const{time:t,open:e,high:i,low:n,close:r,volume:o}=s;return!(kt(t)==null||typeof e!="number"||!Number.isFinite(e)||typeof i!="number"||!Number.isFinite(i)||typeof n!="number"||!Number.isFinite(n)||typeof r!="number"||!Number.isFinite(r)||o!=null&&(typeof o!="number"||o<0||!Number.isFinite(o))||i<e||i<r||i<n||n>e||n>r||n>i||e<=0||i<=0||n<=0||r<=0)}function Po(s){const t=o=>Math.round(o*1e5)/1e5;let e=t(s.open),i=t(s.high),n=t(s.low),r=t(s.close);return i=Math.max(i,e,r,n),n=Math.min(n,e,r,i),{...s,open:e,high:i,low:n,close:r,volume:s.volume!=null?Math.round(s.volume):s.volume}}function Do(s){if(!Array.isArray(s)||s.length===0)return[];const t=new Map;return s.forEach(e=>{const i=kt(e.time);if(i!=null)if(t.has(i)){const n=t.get(i);t.set(i,{...e,time:i,open:e.open,high:Math.max(n.high,e.high),low:Math.min(n.low,e.low),close:e.close,volume:(n.volume||0)+(e.volume||0)})}else t.set(i,{...e,time:i})}),Array.from(t.values())}function Yu(s,t="percentile"){if(!Array.isArray(s)||s.length<3)return s;const e=s.map(o=>o.close).filter(o=>Number.isFinite(o));if(e.length<3)return s;const i=[...e].sort((o,l)=>o-l);let n,r;if(t==="percentile"){const o=Math.floor(i.length*.25),l=Math.floor(i.length*.75),h=i[o],a=i[l],c=a-h;n=h-1.5*c,r=a+1.5*c}else{const o=e.reduce((a,c)=>a+c,0)/e.length,l=e.reduce((a,c)=>a+Math.pow(c-o,2),0)/e.length,h=Math.sqrt(l);if(h===0)return s;n=o-3*h,r=o+3*h}return s.map((o,l)=>{const h=o.close;if(h<n||h>r){if(l===0)return o;const a=s[l-1].close;return{...o,open:a,high:Math.max(a,o.high),low:Math.min(a,o.low),close:a}}return o})}function Qu(s,t){if(!Array.isArray(s)||s.length===0)return s;const e=[],i=Math.max(t*10080,604800),n=1e4;for(let l=0;l<s.length;l++)if(e.push(s[l]),l<s.length-1){const h=s[l].time,a=s[l+1].time,c=a-h;if(c>i&&((c/3600).toFixed(1),(i/3600).toFixed(1)),c>t&&c<=i){const u=s[l];let p=h+t,m=0;for(p=Be(p,t);p<a&&m<n;){const d=Be(p,t);e.some(g=>g.time===d)||(e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0}),m++),p+=t}if(p<a&&m>=n){const d=Be(a-t,t);e.some(g=>g.time===d)||e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0})}}}e.sort((l,h)=>l.time-h.time);const r=[],o=new Set;for(const l of e)o.has(l.time)||(o.add(l.time),r.push(l));return r}function nn(s){if(!s||typeof s!="string")return 60;const t=s.toUpperCase();if(t==="MN")return 2592e3;let e=t.match(/^([MHDW])(\d+)$/);if(e){const i=e[1];return parseInt(e[2],10)*({M:60,H:3600,D:86400,W:604800}[i]||60)}if(e=s.match(/^(\d+)([mhdwy])$/i),e){const i=parseInt(e[1],10),n=e[2].toLowerCase();return i*({m:60,h:3600,d:86400,w:604800,y:31536e3}[n]||60)}return 60}function Ao(s,t,e){if(!Array.isArray(s)||s.length===0)return{candles:[],stats:{original:0,processed:0,duplicates:0,outliers:0,gaps:[]}};const i=ni(t),n=nn(e),l=Oo(s).map(g=>({...g,time:Be(g.time,n)})).filter(g=>No(g)).map(g=>Po(g)),h=Do(l);h.sort((g,w)=>g.time-w.time);const a=h.filter((g,w)=>w===0?!0:g.time>h[w-1].time),c=a.length>10?Yu(a,"percentile"):a,u=Do(c);u.sort((g,w)=>g.time-w.time);const p=Qu(u,n),m=[];for(let g=1;g<p.length;g++){const w=p[g].time-p[g-1].time;w>n*2&&m.push({from:p[g-1].time,to:p[g].time,gapSeconds:w,gapMinutes:Math.round(w/60),fromDate:new Date(p[g-1].time*1e3).toISOString(),toDate:new Date(p[g].time*1e3).toISOString()})}const d=c.filter((g,w)=>w===0?!1:g.close===c[w-1].close&&g.open===c[w-1].close).length,f={original:s.length,processed:p.length,duplicates:s.length-h.length,outliers:d,gaps:m,filledGaps:p.length-u.length,symbolConfig:i};return{candles:p,stats:f}}function Bo(s,t,e="1m"){if(!s||!t||!No(s))return null;const i=kt(s.time);if(i==null)return null;const n=nn(e),r=Be(i,n);return Po({...s,time:r})}let Vo="http://localhost:8000";function Fo(s){s&&(Vo=s)}const Zu={M1:3,M5:7,M15:14,M30:30,H1:90,H4:180,D1:1095,W1:1825,MN:3650};function $o(s){if(!s)return 7;const t=String(s).toUpperCase();return Zu[t]??7}function tf(s,t){const e=String(s||"").toUpperCase(),i=t||$o(s),n={M1:1440,M5:288,M15:96,M30:48,H1:24,H4:6,D1:1,W1:1/7,MN:1/30}[e]||96,r=Math.ceil(i*(typeof n=="number"?n:96));return Math.min(Math.max(r,500),5e3)}const At=s=>{if(!Array.isArray(s)||s.length===0)return[];const t=s.map(i=>({...i,time:kt(i.time)})).filter(i=>i.time!=null);t.sort((i,n)=>i.time-n.time);const e=new Map;for(const i of t)e.set(i.time,i);return Array.from(e.values()).sort((i,n)=>i.time-n.time)};function ef(s,t,e,i,n,r){const o=n-e,l=r-i,h=Math.sqrt(o*o+l*l);if(h===0)return Math.hypot(s-e,t-i);let a=((s-e)*o+(t-i)*l)/(h*h);a=Math.max(0,Math.min(1,a));const c=e+a*o,u=i+a*l;return Math.hypot(s-c,t-u)}function rn(s,t,e,i,n){if(!e||!i||!n)return null;const r=e.time,o=i.time,l=o-r,h=e.price,a=i.price,c=n.price;if(Math.abs(l)<1e-9){const d=c-h;return[{time:r,price:h+d},{time:o+1,price:a+d}]}const u=(a-h)/l,p=c+u*(r-n.time),m=c+u*(o-n.time);return[{time:r,price:p},{time:o,price:m}]}const sf=x.forwardRef(function({bidPrice:t="113.638",askPrice:e="113.649",showBuySellPanel:i=!0,onBuyClick:n,onSellClick:r},o){const l=x.useRef(null),h=x.useRef(null),a=x.useRef(null),c=x.useRef(null),u=x.useRef([]),p=x.useRef(!1),m=x.useRef(null),d=x.useRef(null),f=x.useRef(null),g=x.useRef(null),w=x.useRef([]),[y,_]=x.useState(null),[k,N]=x.useState([]),Z=x.useRef(null),B=x.useRef(null),G=x.useRef(null),tt=x.useRef(!1);x.useEffect(()=>{G.current=y},[y]);const Ct=x.useRef(new Map),$=x.useRef(null),at=(v,S)=>`${v}_${S}`,Rt=()=>{const v=at(Y,ut);return Ct.current.get(v)||null},bt=v=>{if(!v)return;const S=at(Y,ut);Ct.current.set(S,v)},{activeTool:rt,setActiveTool:ot,showGrid:ct,snapToGrid:zt,chartObjects:Et,setChartObjects:yt,orders:wt,selectedSymbol:Y,selectedTimeframe:ut,drawingsVisible:Tt,chartType:St,chartLocked:W}=Ae(),et=x.useRef([]),[j,Q]=x.useState([]),[Wt,ht]=x.useState(!0),_t=x.useRef(null),Lt=x.useRef(new Map);x.useRef(null);const Kt=x.useRef(0);x.useImperativeHandle(o,()=>({zoomIn:()=>{const v=h.current?.timeScale();if(!v)return;const S=v.getVisibleRange();if(!S||!S.from||!S.to)return;const E=S.to-S.from,P=(S.from+S.to)/2,M=E*.8;try{v.setVisibleRange({from:P-M/2,to:P+M/2}),bt(v.getVisibleRange())}catch{}},zoomOut:()=>{const v=h.current?.timeScale();if(!v)return;const S=v.getVisibleRange();if(!S||!S.from||!S.to)return;const E=S.to-S.from,P=(S.from+S.to)/2,M=E*1.25;try{v.setVisibleRange({from:P-M/2,to:P+M/2}),bt(v.getVisibleRange())}catch{}}}));const Xt=x.useMemo(()=>j.length===0?[]:St==="line"||St==="area"?j.map(v=>({time:v.time,value:v.close})):j,[j,St]);return x.useEffect(()=>{const v=l.current;if(!v)return;const S=v.getBoundingClientRect(),E=O=>{const I=Math.abs(Number(O));return Number.isFinite(I)?I>=1e3?I.toFixed(2):I>=1?I.toFixed(4):I.toFixed(5):"0"},P=Ca(v,{width:S.width||v.clientWidth,height:S.height||v.clientHeight,autoSize:!0,localization:{priceFormatter:E},layout:{background:{color:"#0F1720"},textColor:"#fff",fontSize:12},grid:{vertLines:{visible:ct,color:ct?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ct,color:ct?"rgba(148, 163, 184, 0.2)":"transparent",style:0}},rightPriceScale:{borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0},leftPriceScale:{visible:!1},timeScale:{borderColor:"#1e293b",timeVisible:!0,secondsVisible:!1,rightOffset:10,barSpacing:3,minBarSpacing:2,shiftVisibleRangeOnNewBar:!1,fixLeftEdge:!1,fixRightEdge:!1},crosshair:{mode:rt===1?1:0,vertLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},vertLineVisible:rt===1,horzLineVisible:rt===1},handleScroll:{mouseWheel:!0,pressedMouseMove:rt===null||rt===1,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},axisTouch:{time:!0,price:!0},mouseWheel:!0,pinch:!0}}),M=P.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1});h.current=P,a.current=M;const q=P.timeScale(),H=()=>{if(tt.current&&j.length>0){const O=q.getVisibleRange();O&&bt(O)}};q.subscribeVisibleTimeRangeChange(H);const dt=new ResizeObserver(O=>{for(const I of O){const{width:lt,height:K}=I.contentRect;if(lt>0&&K>0&&P){const T=q.getVisibleRange();P.resize(lt,K),T&&setTimeout(()=>{try{q.setVisibleRange(T)}catch{}},0)}}});return dt.observe(v),()=>{q.unsubscribeVisibleTimeRangeChange(H),dt.disconnect(),P.remove(),h.current=null,a.current=null,c.current=null,u.current=[]}},[]),x.useEffect(()=>{h.current&&h.current.applyOptions({grid:{vertLines:{visible:ct,color:ct?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ct,color:ct?"rgba(148, 163, 184, 0.2)":"transparent",style:0}}})},[ct]),x.useEffect(()=>{if(!h.current)return;const S=!W&&!(rt!==null&&rt!==1&&rt!==0),E=!W;h.current.applyOptions({crosshair:{mode:rt===1?1:0,vertLine:{visible:rt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{visible:rt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"}},handleScroll:{mouseWheel:E,pressedMouseMove:S,horzTouchDrag:S,vertTouchDrag:S},handleScale:{axisPressedMouseMove:{time:S,price:S},axisDoubleClickReset:{time:E,price:E},axisTouch:{time:S,price:S},mouseWheel:E,pinch:E}})},[rt,W]),x.useEffect(()=>{(async()=>{if(!Y||!ut){Q([]),tt.current=!1;return}try{if(ht(!0),Q([]),tt.current=!1,a.current)try{a.current.setData([])}catch{}console.log(`📊 Fetching candles for ${Y} @ ${ut}`);const S=$o(ut),E=tf(ut,S),P=await mt.get(`${Vo}/api/chart/candles`,{params:{symbol:Y,timeframe:ut,limit:E,daysBack:S},timeout:1e4});if(P.data&&P.data.data&&P.data.data.length>0){const M=P.data.data;console.log(`✅ Loaded ${M.length} raw candles from server`);const{candles:q,stats:H}=Ao(M,Y,ut);q.length>0?(Q(q),Lt.current=new Map,q.forEach(dt=>{Lt.current.set(dt.time,dt)})):(console.warn(`⚠️ No valid candles after processing for ${Y}`),Q([]))}else console.warn(`⚠️ No candle data returned for ${Y}`),Q([])}catch(S){console.error(`❌ Error fetching ${Y}:`,S.message),Q([])}finally{ht(!1)}})()},[Y,ut]),x.useEffect(()=>{_t.current||(_t.current=en.getSocket());const v=_t.current,S=()=>{console.log("✅ Chart WebSocket connected"),M()},E=()=>{console.log("⚠️ Chart WebSocket disconnected - will auto-reconnect")},P=H=>{console.error("❌ Chart WebSocket connection error:",H)};v.on("connect",S),v.on("disconnect",E),v.on("connect_error",P);const M=()=>{const H=sn(Y);H&&Y&&ut&&v.connected?(console.log(`Subscribing to real-time candles: ${Y}@${ut}`),v.emit("subscribeCandles",{symbol:Y,timeframe:ut})):!H&&Y&&console.log(`⚠️ Symbol ${Y} is not a crypto symbol, skipping candle subscription`)},q=H=>{if(!H||!H.candle||!H.symbol||H.symbol.toUpperCase()!==Y?.toUpperCase())return;const{candle:dt}=H,O=Bo(dt,Y,ut);if(!O)return;const I=Date.now();if(I-Kt.current<200)return;Kt.current=I;const lt=h.current?.timeScale(),K=lt?.getVisibleRange(),T=a.current,U=h.current;if(!(!T||!U||!tt.current))try{St==="line"||St==="area"?T.update({time:O.time,value:O.close}):T.update({time:O.time,open:O.open,high:O.high,low:O.low,close:O.close}),Lt.current.set(O.time,O),lt&&K&&bt(K)}catch(R){console.error("❌ Error updating candle:",R)}};return v.on("candleUpdate",q),v.connected&&M(),()=>{v.off("candleUpdate",q),v.off("connect",S),v.off("disconnect",E),v.off("connect_error",P),Y&&ut&&v.connected&&sn(Y)&&(console.log(`🔌 Unsubscribing from: ${Y}@${ut}`),v.emit("unsubscribeCandles",{symbol:Y,timeframe:ut}))}},[Y,ut]),x.useEffect(()=>{const v=a.current,S=h.current;if(!(!v||!S)&&!(j.length===0&&tt.current)){if(j.length===0&&!tt.current){if(Wt)return;const E=S.timeScale();v.setData([]),E.fitContent();return}if(!tt.current){const E=S.timeScale(),P=at(Y,ut);if($.current,$.current=P,St==="line"||St==="area"){const q=[...j.map(H=>({time:H.time,value:H.close})).filter(H=>H.time!=null)].sort((H,dt)=>H.time-dt.time);q.length>0&&v.setData(q)}else{const M=[...j].sort((q,H)=>q.time-H.time);M.length>0&&v.setData(M)}E.fitContent();try{S.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,bt(E.getVisibleRange())}}},[j.length,St,Y,ut]),x.useEffect(()=>{const v=h.current;if(!v||!tt.current||j.length===0)return;const S=v.timeScale(),E=S.getVisibleRange()||Rt();if(a.current)try{v.removeSeries(a.current)}catch{}if(c.current)try{v.removeSeries(c.current),c.current=null}catch{}let P;if(St==="bars"){P=v.addBarSeries({upColor:"#26A69A",downColor:"#EF5350",borderUpColor:"#26A69A",borderDownColor:"#EF5350",scaleMargins:{top:.1,bottom:.1}});const M=[...j].sort((q,H)=>q.time-H.time);M.length>0&&P.setData(M)}else if(St==="line"){P=v.addLineSeries({color:"#38bdf8",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const M=At(Xt);M.length>0&&P.setData(M)}else if(St==="area"){P=v.addAreaSeries({lineColor:"#38bdf8",topColor:"rgba(56,189,248,0.4)",bottomColor:"rgba(56,189,248,0.0)",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const M=At(Xt);M.length>0&&P.setData(M)}else if(St==="volume ticks"||St==="volume"){P=v.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,priceScaleId:"right"});const M=[...j].sort((dt,O)=>dt.time-O.time);M.length>0&&P.setData(M);const q=v.addHistogramSeries({priceFormat:{type:"volume"},priceScaleId:"vol",base:0,priceLineVisible:!1,lastValueVisible:!1,color:"rgba(38,166,154,0.15)"});v.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.3}}),v.priceScale("vol").applyOptions({scaleMargins:{top:.75,bottom:0},visible:!1});const H=M.map(dt=>({time:dt.time,value:dt.volume||0,color:dt.close>=dt.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));H.length>0&&q.setData(H),c.current=q}else{P=v.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,scaleMargins:{top:.1,bottom:.1}});const M=[...j].sort((q,H)=>q.time-H.time);M.length>0&&P.setData(M)}if(a.current=P,E&&tt.current)setTimeout(()=>{try{S.setVisibleRange(E),bt(E)}catch{if(j.length>0)try{const q=j[j.length-1].time,H=q-6e3;S.setVisibleRange({from:H,to:q}),bt(S.getVisibleRange())}catch{S.fitContent(),bt(S.getVisibleRange())}}try{v.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}},0);else if(!tt.current){S.fitContent();try{v.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,bt(S.getVisibleRange())}},[St,j.length,Xt.length]),x.useEffect(()=>{const v=h.current,S=c.current;if(!v||!S||!tt.current||j.length===0||St!=="volume"&&St!=="volume ticks")return;const P=[...j].sort((M,q)=>M.time-q.time).map(M=>({time:M.time,value:M.volume||0,color:M.close>=M.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));P.length>0&&S.setData(P)},[j,St]),x.useEffect(()=>{const v=h.current,S=a.current,E=l.current;if(!v||!S||!E)return;const M=rt!==null?[null,null,"trendline","parallellines","fibonacci","rectangle","pricelevel","text",null,null,null,null,null,null,null,null,null][rt]:null;if(!M){if(p.current=!1,m.current=null,d.current=null,g.current=null,f.current?.series)try{v.removeSeries(f.current.series)}catch{}f.current=null;return}if(M==="pricelevel"){const O=I=>{const lt=E.getBoundingClientRect(),K=I.clientX-lt.left,T=I.clientY-lt.top,U=v.timeScale().coordinateToTime(K),R=S.coordinateToPrice(T);if(U==null||R==null)return;const D={type:"pricelevel",priceLine:S.createPriceLine({price:R,color:"#3b82f6",lineWidth:2,lineStyle:2,axisLabelVisible:!0,title:R.toFixed(5)}),price:R};yt(X=>[...X,D]),u.current.push(D)};return E.addEventListener("click",O),()=>{E.removeEventListener("click",O)}}if(M==="trendline"){const O=T=>{T.preventDefault(),T.stopPropagation(),T.stopImmediatePropagation();const U=E.getBoundingClientRect(),R=T.clientX-U.left,A=T.clientY-U.top;let D=v.timeScale().coordinateToTime(R);const X=S.coordinateToPrice(A);if(!(D==null||X==null)&&(D=kt(D),D!=null))if(g.current===null){g.current={time:D,price:X};const z=v.addLineSeries({color:"#22c55e",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"trendline",series:z},z.setData([{time:D,value:X}])}else{const z=g.current,F={time:D,price:X},J=1,pt=1e-5,nt=Math.abs(F.time-z.time),vt=Math.abs(F.price-z.price);if(nt<J&&vt<pt){try{v.removeSeries(f.current.series)}catch{}g.current=null,f.current=null;return}const ae={time:z.time,price:z.price},ce={time:F.time,price:F.price},Jt=At([{time:ae.time,value:ae.price},{time:ce.time,value:ce.price}]);if(Jt.length>0){f.current.series.setData(Jt);const ge={type:"trendline",series:f.current.series,point1:ae,point2:ce};yt(Te=>[...Te,ge]),u.current.push(ge)}ot(null),g.current=null,f.current=null}},I=T=>{if(g.current===null||f.current?.type!=="trendline")return;T.preventDefault(),T.stopPropagation();const U=E.getBoundingClientRect(),R=T.clientX-U.left,A=T.clientY-U.top;let D=v.timeScale().coordinateToTime(R);const X=S.coordinateToPrice(A);if(D==null||X==null||(D=kt(D),D==null))return;const z=g.current,F=At([{time:z.time,value:z.price},{time:D,value:X}]);F.length>0&&f.current.series.setData(F)},lt=T=>{T.stopPropagation()},K={capture:!0,passive:!1};return E.addEventListener("click",O,K),E.addEventListener("mousemove",I,K),E.addEventListener("mousemove",lt,K),()=>{if(g.current=null,f.current?.type==="trendline"&&f.current?.series){try{v.removeSeries(f.current.series)}catch{}f.current=null}E.removeEventListener("click",O,K),E.removeEventListener("mousemove",I,K),E.removeEventListener("mousemove",lt,K)}}if(M==="parallellines"){const O={capture:!0,passive:!1},I=R=>{R.preventDefault(),R.stopPropagation(),R.stopImmediatePropagation();const A=E.getBoundingClientRect(),D=R.clientX-A.left,X=R.clientY-A.top;let z=v.timeScale().coordinateToTime(D);const F=S.coordinateToPrice(X);if(z==null||F==null||(z=kt(z),z==null))return;const J={time:z,price:F},pt=w.current;if(pt.length===0){w.current=[J];const nt=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});nt.setData([{time:z,value:F}]),f.current={type:"parallellines",series:nt,previewLine:null}}else if(pt.length===1){w.current=[pt[0],J];const nt=At([{time:pt[0].time,value:pt[0].price},{time:z,value:F}]);nt.length>0&&f.current.series.setData(nt),f.current.previewLine=v.addLineSeries({color:"#8b5cf6",lineWidth:2,lineStyle:2,priceLineVisible:!1,lastValueVisible:!1});const vt=rn(v,S,pt[0],J,J);vt&&f.current.previewLine.setData(At([{time:vt[0].time,value:vt[0].price},{time:vt[1].time,value:vt[1].price}]))}else{const[nt,vt]=pt,ae=J;if(f.current?.previewLine){try{v.removeSeries(f.current.previewLine)}catch{}f.current.previewLine=null}const ce=f.current?.series;if(!ce)return;const Jt=rn(v,S,nt,vt,ae);if(!Jt)return;const ge=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});ce.setData(At([{time:nt.time,value:nt.price},{time:vt.time,value:vt.price}])),ge.setData(At([{time:Jt[0].time,value:Jt[0].price},{time:Jt[1].time,value:Jt[1].price}]));const Te={type:"parallellines",point1:nt,point2:vt,point3:ae,baseLine:ce,parallelLine:ge};yt(ri=>[...ri,Te]),u.current.push(Te),ot(null),w.current=[],f.current=null}},lt=R=>{const A=w.current;if(A.length!==1||!f.current?.series)return;const D=E.getBoundingClientRect(),X=R.clientX-D.left,z=R.clientY-D.top;let F=v.timeScale().coordinateToTime(X);const J=S.coordinateToPrice(z);if(F==null||J==null||(F=kt(F),F==null))return;const pt=At([{time:A[0].time,value:A[0].price},{time:F,value:J}]);pt.length>0&&f.current.series.setData(pt)},K=R=>{const A=w.current;if(A.length!==2||!f.current?.previewLine)return;const D=E.getBoundingClientRect(),X=R.clientX-D.left,z=R.clientY-D.top;let F=v.timeScale().coordinateToTime(X);const J=S.coordinateToPrice(z);if(F==null||J==null||(F=kt(F),F==null))return;const pt={time:F,price:J},nt=rn(v,S,A[0],A[1],pt);nt&&f.current.previewLine.setData(At([{time:nt[0].time,value:nt[0].price},{time:nt[1].time,value:nt[1].price}]))},T=R=>{lt(R),K(R)},U=R=>{R.stopPropagation()};return E.addEventListener("click",I,O),E.addEventListener("mousemove",T,O),E.addEventListener("mousemove",U,O),()=>{if(w.current=[],f.current?.type==="parallellines"){try{f.current.series&&v.removeSeries(f.current.series),f.current.previewLine&&v.removeSeries(f.current.previewLine)}catch{}f.current=null}E.removeEventListener("click",I,O),E.removeEventListener("mousemove",T,O),E.removeEventListener("mousemove",U,O)}}if(g.current=null,f.current?.type==="trendline"&&f.current?.series){try{v.removeSeries(f.current.series)}catch{}f.current=null}const q=O=>{if(O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation(),M==="trendline"||M==="parallellines"||M!=="rectangle"&&M!=="fibonacci")return;const I=E.getBoundingClientRect(),lt=O.clientX-I.left,K=O.clientY-I.top;let T=v.timeScale().coordinateToTime(lt);const U=S.coordinateToPrice(K);if(!(T==null||U==null)&&(T=kt(T),T!=null)){if(p.current=!0,m.current={time:T,price:U},d.current=null,M==="rectangle"){const R=v.addBaselineSeries({baseValue:{type:"price",price:U},topLineColor:"#2563eb",bottomLineColor:"#2563eb",topFillColor1:"rgba(59, 130, 246, 0.38)",topFillColor2:"rgba(59, 130, 246, 0.22)",bottomFillColor1:"rgba(59, 130, 246, 0.22)",bottomFillColor2:"rgba(59, 130, 246, 0.38)",priceLineVisible:!1,lastValueVisible:!1,lineWidth:2,lineStyle:0});f.current={type:"rectangle",series:R}}if(M==="fibonacci"){const R=v.addLineSeries({color:"#f59e0b",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"fibonacci",series:R,priceLines:[]}}if(M==="parallellines"){const R=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"parallellines",series:R,firstLine:null,secondLine:null}}}},H=O=>{if(!p.current||!m.current||!f.current)return;O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation();const I=E.getBoundingClientRect(),lt=O.clientX-I.left,K=O.clientY-I.top;let T=v.timeScale().coordinateToTime(lt);const U=S.coordinateToPrice(K);if(T==null||U==null||(T=kt(T),T==null))return;d.current={time:T,price:U};const R=m.current;if(f.current.type==="rectangle"){const A=Math.max(R.price,U),D=Math.min(R.price,U),X=kt(Math.min(R.time,T)),z=kt(Math.max(R.time,T));if(X==null||z==null||Math.abs(z-X)<1||Math.abs(A-D)<1e-5)return;const F=f.current.series;F.setData(At([{time:X,value:A},{time:z,value:A}])),F.applyOptions({baseValue:{type:"price",price:D}})}if(f.current.type==="fibonacci"){const A=[{time:R.time,value:R.price},{time:T,value:U}],D=At(A);D.length>0&&f.current.series.setData(D),d.current={time:T,price:U},f.current.priceLines&&(f.current.priceLines.forEach(X=>{try{S.removePriceLine(X)}catch{}}),f.current.priceLines=[])}if(f.current.type==="parallellines")if(f.current.firstLine){const A=f.current.firstLine;A.endTime-A.startTime;const D=A.endPrice-A.startPrice,X=U,z=X+D;if(f.current.secondLine)f.current.secondLine.setData([{time:R.time,value:X},{time:T,value:z}]);else{const F=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});F.setData([{time:R.time,value:X},{time:T,value:z}]),f.current.secondLine=F}}else f.current.series.setData([{time:R.time,value:R.price},{time:T,value:U}])},dt=O=>{if(O&&(O.preventDefault(),O.stopPropagation()),!p.current||!f.current||!m.current)return;const I=m.current,lt=d.current||I;if(f.current.type==="parallellines")if(f.current.firstLine){const K={type:"parallellines",firstLine:f.current.series,secondLine:f.current.secondLine,firstLineData:f.current.firstLine};yt(T=>[...T,K]),u.current.push(K),ot(null),f.current=null,p.current=!1,m.current=null,d.current=null;return}else{f.current.firstLine={startTime:I.time,startPrice:I.price,endTime:lt.time,endPrice:lt.price},p.current=!1,m.current=null,d.current=null;return}if(f.current.type==="fibonacci"){const T=(d.current||I).price;if(Math.abs(I.price-T)<1e-4){try{v.removeSeries(f.current.series)}catch{}p.current=!1,m.current=null,d.current=null,f.current=null;return}const U=Math.max(I.price,T),R=Math.min(I.price,T),A=U-R,D=[{level:0,label:"0.0%"},{level:.236,label:"23.6%"},{level:.382,label:"38.2%"},{level:.5,label:"50.0%"},{level:.618,label:"61.8%"},{level:.786,label:"78.6%"},{level:1,label:"100.0%"}],X=[],z=f.current.series;try{v.removeSeries(z)}catch{}D.forEach(({level:J,label:pt})=>{const nt=U-A*J,vt=S.createPriceLine({price:nt,color:J===0||J===1?"#f59e0b":"#fbbf24",lineWidth:J===0||J===1?2:1,lineStyle:J===0||J===1?0:2,axisLabelVisible:!0,title:`${pt} (${nt.toFixed(5)})`,textColor:J===0||J===1?"#f59e0b":"#fbbf24"});X.push(vt)});const F={type:"fibonacci",priceLines:X,startPrice:I.price,endPrice:T,high:U,low:R};yt(J=>[...J,F]),u.current.push(F),ot(null)}if(f.current.type==="rectangle"){const K=m.current,T=d.current||K,U=Math.max(K.price,T.price),R=Math.min(K.price,T.price),A=kt(Math.min(K.time,T.time)),D=kt(Math.max(K.time,T.time));if(A!=null&&D!=null&&Math.abs(D-A)>=1&&Math.abs(U-R)>=1e-5){const X=f.current.series;X.setData(At([{time:A,value:U},{time:D,value:U}])),X.applyOptions({baseValue:{type:"price",price:R}});const z={type:"rectangle",timeStart:A,timeEnd:D,priceTop:U,priceBottom:R,series:X};yt(F=>[...F,z]),u.current.push(z),ot(null)}else try{v.removeSeries(f.current.series)}catch{}}p.current=!1,m.current=null,d.current=null,f.current=null};if(M==="rectangle"||M==="fibonacci"||M==="parallellines"){const O={capture:!0,passive:!1},I=lt=>{p.current||lt.stopPropagation()};return E.addEventListener("mousedown",q,O),E.addEventListener("mousemove",H,O),E.addEventListener("mousemove",I,O),E.addEventListener("mouseup",dt,O),()=>{E.removeEventListener("mousedown",q,O),E.removeEventListener("mousemove",H,O),E.removeEventListener("mousemove",I,O),E.removeEventListener("mouseup",dt,O)}}},[rt,yt,ot]),x.useEffect(()=>{const v=h.current,S=a.current,E=l.current,P=rt===null||rt===1;if(!P||!v||!S||!E){P||(_(null),N([]));return}const M=10,q=8;function H(K,T){const U=Et.filter(R=>R.type==="trendline"&&R.point1&&R.point2);for(let R=U.length-1;R>=0;R--){const A=U[R],D=v.timeScale().timeToCoordinate(A.point1.time),X=S.priceToCoordinate(A.point1.price),z=v.timeScale().timeToCoordinate(A.point2.time),F=S.priceToCoordinate(A.point2.price);if(D==null||X==null||z==null||F==null)continue;const J=Math.hypot(K-D,T-X),pt=Math.hypot(K-z,T-F);if(J<M)return{object:A,mode:"handle1"};if(pt<M)return{object:A,mode:"handle2"};if(ef(K,T,D,X,z,F)<q)return{object:A,mode:"line"}}return null}const dt=K=>{K.preventDefault(),K.stopPropagation();const T=E.getBoundingClientRect(),U=K.clientX-T.left,R=K.clientY-T.top,A=H(U,R);A?(_(A.object),Z.current=A.mode,A.mode==="line"&&(B.current={x:U,y:R,point1:{...A.object.point1},point2:{...A.object.point2}})):(_(null),Z.current=null)},O=K=>{if(!Z.current)return;const T=G.current;if(!T||!T.point1||!T.point2)return;const U=E.getBoundingClientRect(),R=K.clientX-U.left,A=K.clientY-U.top;let D=v.timeScale().coordinateToTime(R);const X=S.coordinateToPrice(A);if(!(D==null||X==null)&&(D=kt(D),D!=null)){if(Z.current==="handle1"){const z={time:D,price:X},F=At([{time:z.time,value:z.price},{time:T.point2.time,value:T.point2.price}]);F.length>0&&T.series.setData(F);const J={...T,point1:z};yt(pt=>{const nt=pt.map(vt=>vt===T?J:vt);return u.current=nt,nt}),_(J),G.current=J}else if(Z.current==="handle2"){const z={time:D,price:X},F=At([{time:T.point1.time,value:T.point1.price},{time:z.time,value:z.price}]);F.length>0&&T.series.setData(F);const J={...T,point2:z};yt(pt=>{const nt=pt.map(vt=>vt===T?J:vt);return u.current=nt,nt}),_(J),G.current=J}else if(Z.current==="line"){const z=B.current;if(!z)return;const F=v.timeScale().coordinateToTime(z.x),J=S.coordinateToPrice(z.y);if(F==null||J==null)return;const pt=D-F,nt=X-J,vt={time:kt(z.point1.time+pt),price:z.point1.price+nt},ae={time:kt(z.point2.time+pt),price:z.point2.price+nt},ce=At([{time:vt.time,value:vt.price},{time:ae.time,value:ae.price}]);ce.length>0&&T.series.setData(ce);const Jt={...T,point1:vt,point2:ae};yt(ge=>{const Te=ge.map(ri=>ri===T?Jt:ri);return u.current=Te,Te}),_(Jt),G.current=Jt}}},I=()=>{Z.current=null,B.current=null},lt={capture:!0,passive:!1};return E.addEventListener("mousedown",dt,lt),E.addEventListener("mousemove",O,lt),E.addEventListener("mouseup",I,lt),()=>{E.removeEventListener("mousedown",dt,lt),E.removeEventListener("mousemove",O,lt),E.removeEventListener("mouseup",I,lt)}},[rt,Et,yt]),x.useEffect(()=>{const v=h.current,S=a.current;if(!v||!S)return;const E=()=>{const M=y;if(!M||M.type!=="trendline"||!M.point1||!M.point2){N([]);return}const q=v.timeScale(),H=q.timeToCoordinate(M.point1.time),dt=S.priceToCoordinate(M.point1.price),O=q.timeToCoordinate(M.point2.time),I=S.priceToCoordinate(M.point2.price);H!=null&&dt!=null&&O!=null&&I!=null?N([{x:H,y:dt},{x:O,y:I}]):N([])};E();const P=v.timeScale();return P.subscribeVisibleTimeRangeChange(E),()=>{P.unsubscribeVisibleTimeRangeChange(E)}},[y]),x.useEffect(()=>{!h.current||!a.current||u.current.forEach(v=>{v.series&&v.series.applyOptions({visible:Tt}),v.priceLine&&v.priceLine.applyOptions(Tt?{color:"#3b82f6",axisLabelVisible:!0,title:typeof v.price=="number"?v.price.toFixed(5):""}:{color:"rgba(0,0,0,0)",axisLabelVisible:!1,title:""}),v.type==="fibonacci"&&v.priceLines&&v.priceLines.forEach(S=>{try{S.applyOptions({lineVisible:Tt,axisLabelVisible:Tt})}catch{}}),v.type==="rectangle"&&v.series&&v.series.applyOptions({visible:Tt}),v.type==="parallellines"&&(v.baseLine&&v.baseLine.applyOptions({visible:Tt}),v.parallelLine&&v.parallelLine.applyOptions({visible:Tt}),v.firstLine&&v.firstLine.applyOptions({visible:Tt}),v.secondLine&&v.secondLine.applyOptions({visible:Tt}))})},[Tt,Et]),x.useEffect(()=>{!Tt&&y&&(_(null),N([]))},[Tt,y]),x.useEffect(()=>{if(u.current.length>Et.length){const v=u.current.filter((S,E)=>!Et.includes(S));y&&v.some(S=>S===y)&&(_(null),N([])),v.forEach(S=>{if(S.series&&h.current?.removeSeries(S.series),S.priceLine&&a.current?.removePriceLine(S.priceLine),S.type==="fibonacci"&&S.priceLines&&S.priceLines.forEach(E=>{try{a.current?.removePriceLine(E)}catch{}}),S.type==="rectangle"&&S.series)try{h.current?.removeSeries(S.series)}catch{}if(S.type==="parallellines")try{S.baseLine&&h.current?.removeSeries(S.baseLine),S.parallelLine&&h.current?.removeSeries(S.parallelLine),S.firstLine&&h.current?.removeSeries(S.firstLine),S.secondLine&&h.current?.removeSeries(S.secondLine)}catch{}}),u.current=Et}},[Et,y]),x.useEffect(()=>{const v=a.current;return v?(et.current.forEach(E=>{try{v.removePriceLine(E)}catch{}}),et.current=[],wt.filter(E=>E.symbol===Y).forEach(E=>{const P=parseFloat(E.price);if(isNaN(P))return;const q=E.type==="BUY"?"#26A69A":"#EF5350",H=v.createPriceLine({price:P,color:q,lineWidth:2,lineStyle:0,axisLabelVisible:!0,title:`${E.type} ${E.volume} @ ${E.price}`,textColor:q});et.current.push(H)}),()=>{et.current.forEach(E=>{try{v.removePriceLine(E)}catch{}}),et.current=[]}):void 0},[wt,Y]),L.jsx("div",{className:"flex-1 flex flex-col bg-primary min-w-0 overflow-hidden",children:L.jsx("div",{ref:l,className:"flex-1 w-full h-full relative",style:{cursor:rt===1||rt!==null?"crosshair":"default",minHeight:0,minWidth:0},onDoubleClick:v=>{h.current&&!p.current&&(v.preventDefault(),v.stopPropagation(),h.current.timeScale().fitContent(),bt(h.current.timeScale().getVisibleRange()))},children:Tt&&y?.type==="trendline"&&y?.point1&&y?.point2&&k.length===2&&L.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none","aria-hidden":!0,children:k.map((v,S)=>L.jsx("div",{className:"absolute w-[10px] h-[10px] rounded-full border-2 border-white bg-[#22c55e] shadow",style:{left:v.x-5,top:v.y-5}},S))})})})}),gt={container:{position:"relative",display:"inline-block",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},button:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"6px",color:"#e2e8f0",fontSize:"13px",fontWeight:600,cursor:"pointer",minWidth:"120px",justifyContent:"space-between",transition:"all 0.15s ease"},buttonHover:{borderColor:"#3b82f6",backgroundColor:"#1e3a5f"},arrow:{fontSize:"10px",color:"#94a3b8",transition:"transform 0.2s ease"},arrowOpen:{transform:"rotate(180deg)"},dropdown:{position:"absolute",top:"100%",left:0,marginTop:"4px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",zIndex:1e3,minWidth:"220px",maxHeight:"320px",overflow:"hidden",display:"flex",flexDirection:"column"},searchContainer:{padding:"8px",borderBottom:"1px solid #334155"},searchInput:{width:"100%",padding:"6px 10px",backgroundColor:"#0f172a",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"12px",outline:"none",boxSizing:"border-box"},list:{overflowY:"auto",maxHeight:"260px",padding:"4px 0"},item:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#cbd5e1",transition:"background-color 0.1s ease"},itemSelected:{backgroundColor:"#1e3a5f",color:"#60a5fa"},symbolName:{fontWeight:600},symbolPrice:{fontSize:"11px",color:"#94a3b8"},priceUp:{color:"#26A69A"},priceDown:{color:"#EF5350"},categoryLabel:{padding:"6px 12px 4px",fontSize:"10px",fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em"},empty:{padding:"16px",textAlign:"center",color:"#64748b",fontSize:"12px"}};function Io({style:s,className:t}){const{selectedSymbol:e,setSelectedSymbol:i,symbols:n,symbolsLoading:r}=Ae(),[o,l]=x.useState(!1),[h,a]=x.useState(""),[c,u]=x.useState(-1),p=x.useRef(null),m=x.useRef(null);x.useEffect(()=>{const y=_=>{p.current&&!p.current.contains(_.target)&&(l(!1),a(""))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),x.useEffect(()=>{o&&m.current&&m.current.focus()},[o]);const d=n.filter(y=>y.symbol.toLowerCase().includes(h.toLowerCase())),f=d.filter(y=>!y.symbol.endsWith("USDT")),g=d.filter(y=>y.symbol.endsWith("USDT")),w=y=>{i(y),l(!1),a("")};return n.find(y=>y.symbol===e),L.jsxs("div",{ref:p,style:{...gt.container,...s},className:t,children:[L.jsxs("button",{style:gt.button,onClick:()=>l(!o),onMouseEnter:y=>Object.assign(y.currentTarget.style,gt.buttonHover),onMouseLeave:y=>{y.currentTarget.style.borderColor="#334155",y.currentTarget.style.backgroundColor="#1e293b"},children:[L.jsx("span",{children:r?"Loading...":e||"Select Coin"}),L.jsx("span",{style:{...gt.arrow,...o?gt.arrowOpen:{}},children:"▼"})]}),o&&L.jsxs("div",{style:gt.dropdown,children:[L.jsx("div",{style:gt.searchContainer,children:L.jsx("input",{ref:m,style:gt.searchInput,type:"text",placeholder:"Search symbol...",value:h,onChange:y=>a(y.target.value)})}),L.jsx("div",{style:gt.list,children:d.length===0?L.jsx("div",{style:gt.empty,children:"No symbols found"}):L.jsxs(L.Fragment,{children:[f.length>0&&L.jsxs(L.Fragment,{children:[L.jsx("div",{style:gt.categoryLabel,children:"Forex & Metals"}),f.map(y=>L.jsxs("div",{style:{...gt.item,...y.symbol===e?gt.itemSelected:{}},onClick:()=>w(y.symbol),onMouseEnter:_=>{y.symbol!==e&&(_.currentTarget.style.backgroundColor="#334155")},onMouseLeave:_=>{y.symbol!==e&&(_.currentTarget.style.backgroundColor="transparent")},children:[L.jsx("span",{style:gt.symbolName,children:y.symbol}),y.bid&&L.jsx("span",{style:{...gt.symbolPrice,...parseFloat(y.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(y.bid).toFixed(5)})]},y.symbol))]}),g.length>0&&L.jsxs(L.Fragment,{children:[L.jsx("div",{style:gt.categoryLabel,children:"Crypto"}),g.map(y=>L.jsxs("div",{style:{...gt.item,...y.symbol===e?gt.itemSelected:{}},onClick:()=>w(y.symbol),onMouseEnter:_=>{y.symbol!==e&&(_.currentTarget.style.backgroundColor="#334155")},onMouseLeave:_=>{y.symbol!==e&&(_.currentTarget.style.backgroundColor="transparent")},children:[L.jsx("span",{style:gt.symbolName,children:y.symbol}),y.bid&&L.jsx("span",{style:{...gt.symbolPrice,...parseFloat(y.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(y.bid).toFixed(2)})]},y.symbol))]})]})})]})]})}const le={container:{display:"inline-flex",alignItems:"center",gap:"4px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},label:{fontSize:"11px",color:"#94a3b8",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.03em",marginRight:"4px",whiteSpace:"nowrap"},btn:{display:"flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"14px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease",padding:0,lineHeight:1,userSelect:"none"},btnHover:{borderColor:"#3b82f6",backgroundColor:"#1e3a5f"},input:{width:"70px",padding:"4px 6px",backgroundColor:"#0f172a",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"13px",fontWeight:600,textAlign:"center",outline:"none",boxSizing:"border-box"},presets:{display:"inline-flex",gap:"2px",marginLeft:"4px"},preset:{padding:"3px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"11px",cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"},presetActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"}},nf=[.01,.05,.1,.5,1];function Uo({value:s,onChange:t,min:e=.01,max:i=100,step:n=.01,presets:r=nf,showPresets:o=!0,showLabel:l=!0,label:h="Vol",style:a,className:c}){const[u,p]=x.useState(.1),m=s!==void 0?s:u,d=x.useCallback(y=>{const _=Math.max(e,Math.min(i,parseFloat(y)||e)),k=Math.round(_/n)*n,N=parseFloat(k.toFixed(8));s!==void 0||p(N),t?.(N)},[e,i,n,s,t]),f=()=>d(m+n),g=()=>d(m-n),w=(m>=1,m.toFixed(2));return L.jsxs("div",{style:{...le.container,...a},className:c,children:[l&&L.jsx("span",{style:le.label,children:h}),L.jsx("button",{style:le.btn,onClick:g,onMouseEnter:y=>Object.assign(y.currentTarget.style,le.btnHover),onMouseLeave:y=>{y.currentTarget.style.borderColor="#334155",y.currentTarget.style.backgroundColor="#1e293b"},children:"−"}),L.jsx("input",{style:le.input,type:"text",value:w,onChange:y=>{const _=y.target.value;if(_===""||_==="."||_==="0.")return;const k=parseFloat(_);isNaN(k)||d(k)},onBlur:()=>d(m)}),L.jsx("button",{style:le.btn,onClick:f,onMouseEnter:y=>Object.assign(y.currentTarget.style,le.btnHover),onMouseLeave:y=>{y.currentTarget.style.borderColor="#334155",y.currentTarget.style.backgroundColor="#1e293b"},children:"+"}),o&&r&&r.length>0&&L.jsx("div",{style:le.presets,children:r.map(y=>L.jsx("button",{style:{...le.preset,...Math.abs(m-y)<1e-4?le.presetActive:{}},onClick:()=>d(y),onMouseEnter:_=>{Math.abs(m-y)>=1e-4&&Object.assign(_.currentTarget.style,{borderColor:"#3b82f6"})},onMouseLeave:_=>{Math.abs(m-y)>=1e-4&&(_.currentTarget.style.borderColor="#334155")},children:y},y))})]})}const It={container:{display:"inline-flex",alignItems:"center",gap:"6px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},label:{fontSize:"11px",fontWeight:700,color:"#EF5350",textTransform:"uppercase",letterSpacing:"0.03em",whiteSpace:"nowrap"},toggle:{position:"relative",width:"32px",height:"18px",borderRadius:"9px",cursor:"pointer",transition:"background-color 0.2s ease",border:"none",padding:0},toggleOff:{backgroundColor:"#334155"},toggleOn:{backgroundColor:"#EF5350"},toggleKnob:{position:"absolute",top:"2px",width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s ease"},knobOff:{left:"2px"},knobOn:{left:"16px"},inputGroup:{display:"inline-flex",alignItems:"center",gap:"4px"},input:{width:"90px",padding:"4px 8px",backgroundColor:"#0f172a",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"13px",fontWeight:600,textAlign:"right",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s ease"},modeBtn:{padding:"3px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"10px",cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"},modeBtnActive:{backgroundColor:"#3b1515",borderColor:"#EF5350",color:"#EF5350"}};function Wo({value:s,onChange:t,enabled:e,onEnabledChange:i,mode:n,onModeChange:r,showToggle:o=!0,showModeSwitch:l=!0,showLabel:h=!0,label:a="SL",style:c,className:u}){const{currentSymbolData:p}=Ae(),[m,d]=x.useState(""),[f,g]=x.useState(!1),[w,y]=x.useState("price"),_=s!==void 0?s:m,k=e!==void 0?e:f,N=n!==void 0?n:w,Z=x.useCallback($=>{e!==void 0||g($),i?.($)},[e,i]),B=x.useCallback($=>{n!==void 0||y($),r?.($)},[n,r]),G=x.useCallback($=>{s!==void 0||d($),t?.($)},[s,t]),tt=$=>{const at=$.target.value;if(at===""||at==="."||at==="0."){G(at);return}const Rt=parseFloat(at);isNaN(Rt)||G(at)},Ct=N==="price"?p?.bid?parseFloat(p.bid).toFixed(5):"0.00000":"50";return L.jsxs("div",{style:{...It.container,...c},className:u,children:[h&&L.jsx("span",{style:It.label,children:a}),o&&L.jsx("button",{style:{...It.toggle,...k?It.toggleOn:It.toggleOff},onClick:()=>Z(!k),children:L.jsx("div",{style:{...It.toggleKnob,...k?It.knobOn:It.knobOff}})}),(k||!o)&&L.jsxs("div",{style:It.inputGroup,children:[L.jsx("input",{style:It.input,type:"text",value:_,onChange:tt,placeholder:Ct,onFocus:$=>$.currentTarget.style.borderColor="#EF5350",onBlur:$=>$.currentTarget.style.borderColor="#334155"}),l&&L.jsxs(L.Fragment,{children:[L.jsx("button",{style:{...It.modeBtn,...N==="price"?It.modeBtnActive:{}},onClick:()=>B("price"),children:"Price"}),L.jsx("button",{style:{...It.modeBtn,...N==="pips"?It.modeBtnActive:{}},onClick:()=>B("pips"),children:"Pips"})]})]})]})}const Ut={container:{display:"inline-flex",alignItems:"center",gap:"6px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},label:{fontSize:"11px",fontWeight:700,color:"#26A69A",textTransform:"uppercase",letterSpacing:"0.03em",whiteSpace:"nowrap"},toggle:{position:"relative",width:"32px",height:"18px",borderRadius:"9px",cursor:"pointer",transition:"background-color 0.2s ease",border:"none",padding:0},toggleOff:{backgroundColor:"#334155"},toggleOn:{backgroundColor:"#26A69A"},toggleKnob:{position:"absolute",top:"2px",width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s ease"},knobOff:{left:"2px"},knobOn:{left:"16px"},inputGroup:{display:"inline-flex",alignItems:"center",gap:"4px"},input:{width:"90px",padding:"4px 8px",backgroundColor:"#0f172a",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"13px",fontWeight:600,textAlign:"right",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s ease"},modeBtn:{padding:"3px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"10px",cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"},modeBtnActive:{backgroundColor:"#0d2e2a",borderColor:"#26A69A",color:"#26A69A"}};function qo({value:s,onChange:t,enabled:e,onEnabledChange:i,mode:n,onModeChange:r,showToggle:o=!0,showModeSwitch:l=!0,showLabel:h=!0,label:a="TP",style:c,className:u}){const{currentSymbolData:p}=Ae(),[m,d]=x.useState(""),[f,g]=x.useState(!1),[w,y]=x.useState("price"),_=s!==void 0?s:m,k=e!==void 0?e:f,N=n!==void 0?n:w,Z=x.useCallback($=>{e!==void 0||g($),i?.($)},[e,i]),B=x.useCallback($=>{n!==void 0||y($),r?.($)},[n,r]),G=x.useCallback($=>{s!==void 0||d($),t?.($)},[s,t]),tt=$=>{const at=$.target.value;if(at===""||at==="."||at==="0."){G(at);return}const Rt=parseFloat(at);isNaN(Rt)||G(at)},Ct=N==="price"?p?.ask?parseFloat(p.ask).toFixed(5):"0.00000":"50";return L.jsxs("div",{style:{...Ut.container,...c},className:u,children:[h&&L.jsx("span",{style:Ut.label,children:a}),o&&L.jsx("button",{style:{...Ut.toggle,...k?Ut.toggleOn:Ut.toggleOff},onClick:()=>Z(!k),children:L.jsx("div",{style:{...Ut.toggleKnob,...k?Ut.knobOn:Ut.knobOff}})}),(k||!o)&&L.jsxs("div",{style:Ut.inputGroup,children:[L.jsx("input",{style:Ut.input,type:"text",value:_,onChange:tt,placeholder:Ct,onFocus:$=>$.currentTarget.style.borderColor="#26A69A",onBlur:$=>$.currentTarget.style.borderColor="#334155"}),l&&L.jsxs(L.Fragment,{children:[L.jsx("button",{style:{...Ut.modeBtn,...N==="price"?Ut.modeBtnActive:{}},onClick:()=>B("price"),children:"Price"}),L.jsx("button",{style:{...Ut.modeBtn,...N==="pips"?Ut.modeBtnActive:{}},onClick:()=>B("pips"),children:"Pips"})]})]})]})}const rf=[{id:1,name:"Crosshair",icon:"+"},{id:2,name:"Trend Line",icon:"╱"},{id:3,name:"Parallel Channel",icon:"═"},{id:4,name:"Fibonacci",icon:"≡"},{id:5,name:"Rectangle",icon:"▭"},{id:6,name:"Price Level",icon:"─"}],he={container:{display:"inline-flex",alignItems:"center",gap:"2px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},label:{fontSize:"11px",color:"#94a3b8",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.03em",marginRight:"4px",whiteSpace:"nowrap"},btn:{display:"flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"14px",cursor:"pointer",transition:"all 0.15s ease",padding:0,position:"relative"},btnActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"},btnHover:{borderColor:"#3b82f6",backgroundColor:"#1e3a5f"},tooltip:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",padding:"4px 8px",backgroundColor:"#0f172a",border:"1px solid #334155",borderRadius:"4px",color:"#e2e8f0",fontSize:"11px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},divider:{width:"1px",height:"20px",backgroundColor:"#334155",margin:"0 4px"},deleteBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"13px",cursor:"pointer",transition:"all 0.15s ease",padding:0},deleteBtnHover:{borderColor:"#EF5350",backgroundColor:"#3b1515",color:"#EF5350"},visibilityBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"13px",cursor:"pointer",transition:"all 0.15s ease",padding:0}};function Ho({showLabel:s=!0,showDelete:t=!0,showVisibility:e=!0,tools:i,label:n="Draw",style:r,className:o}){const{activeTool:l,setActiveTool:h,drawingsVisible:a,setDrawingsVisible:c,chartObjects:u,setChartObjects:p}=Ae(),[m,d]=x.useState(null),f=i||rf,g=_=>{h(l===_?null:_)},w=()=>{p([]),h(null)},y=()=>{c(!a)};return L.jsxs("div",{style:{...he.container,...r},className:o,children:[s&&L.jsx("span",{style:he.label,children:n}),f.map(_=>L.jsxs("button",{style:{...he.btn,...l===_.id?he.btnActive:{}},onClick:()=>g(_.id),onMouseEnter:k=>{d(_.id),l!==_.id&&Object.assign(k.currentTarget.style,he.btnHover)},onMouseLeave:k=>{d(null),l!==_.id&&(k.currentTarget.style.borderColor="#334155",k.currentTarget.style.backgroundColor="#1e293b",k.currentTarget.style.color="#94a3b8")},title:_.name,children:[_.icon,m===_.id&&L.jsx("div",{style:he.tooltip,children:_.name})]},_.id)),(t||e)&&L.jsx("div",{style:he.divider}),e&&L.jsx("button",{style:{...he.visibilityBtn,...a?{}:{color:"#64748b",backgroundColor:"#0f172a"}},onClick:y,onMouseEnter:_=>{_.currentTarget.style.borderColor="#3b82f6"},onMouseLeave:_=>{_.currentTarget.style.borderColor="#334155"},title:a?"Hide Drawings":"Show Drawings",children:a?"👁":"○"}),t&&L.jsx("button",{style:he.deleteBtn,onClick:w,onMouseEnter:_=>Object.assign(_.currentTarget.style,he.deleteBtnHover),onMouseLeave:_=>{_.currentTarget.style.borderColor="#334155",_.currentTarget.style.backgroundColor="#1e293b",_.currentTarget.style.color="#94a3b8"},title:"Delete All Drawings",children:"🗑"})]})}const jo={toolbar:{display:"flex",alignItems:"center",gap:"12px",padding:"6px 12px",backgroundColor:"#0f172a",borderBottom:"1px solid #1e293b",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",flexWrap:"wrap",minHeight:"42px"},divider:{width:"1px",height:"24px",backgroundColor:"#1e293b",flexShrink:0}};function of({showCoinSelector:s=!0,showVolumeControl:t=!0,showStopLoss:e=!0,showTakeProfit:i=!0,showDrawingTools:n=!0,showDividers:r=!0,volume:o,onVolumeChange:l,stopLoss:h,onStopLossChange:a,stopLossEnabled:c,onStopLossEnabledChange:u,takeProfit:p,onTakeProfitChange:m,takeProfitEnabled:d,onTakeProfitEnabledChange:f,coinSelectorProps:g={},volumeControlProps:w={},stopLossProps:y={},takeProfitProps:_={},drawingToolsProps:k={},style:N,className:Z}){const B=[];s&&B.push(L.jsx(Io,{...g},"coin")),t&&B.push(L.jsx(Uo,{value:o,onChange:l,...w},"volume")),e&&B.push(L.jsx(Wo,{value:h,onChange:a,enabled:c,onEnabledChange:u,...y},"sl")),i&&B.push(L.jsx(qo,{value:p,onChange:m,enabled:d,onEnabledChange:f,..._},"tp")),n&&B.push(L.jsx(Ho,{...k},"draw"));const G=[];return B.forEach((tt,Ct)=>{G.push(tt),r&&Ct<B.length-1&&G.push(L.jsx("div",{style:jo.divider},`div-${Ct}`))}),L.jsx("div",{style:{...jo.toolbar,...N},className:Z,children:G})}const lf="1.1.0";st.Chart=sf,st.CoinSelector=Io,st.DrawingTools=Ho,st.SYMBOL_CONFIG=Ro,st.StopLoss=Wo,st.TakeProfit=qo,st.TradingProvider=Hu,st.TradingToolbar=of,st.VolumeControl=Uo,st.alignToTimeframe=Be,st.detectGaps=ju,st.getSymbolConfig=ni,st.is24x7Symbol=Gu,st.isCryptoSymbol=sn,st.isForexSymbol=Ju,st.isWithinTradingSession=Ku,st.normalizeCandleTimes=Oo,st.normalizeTime=kt,st.processCandles=Ao,st.processSingleCandle=Bo,st.setChartBaseUrl=Fo,st.setSocketBaseUrl=ko,st.timeframeToSeconds=nn,st.useTrading=Ae,st.validateTimeOrdering=Xu,st.version=lf,Object.defineProperty(st,Symbol.toStringTag,{value:"Module"})}));