@nabeeltahirdeveloper/chart-sdk 1.2.1 → 1.2.2

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(G,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],w):(G=typeof globalThis<"u"?globalThis:G||self,w(G.ChartSDK={},G.jsxRuntime,G.React))})(this,(function(G,w,C){"use strict";var $i=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 we(s,t){return s.width===t.width&&s.height===t.height}var Zo=(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 Qo(s){return new Zo(s)}var tl=(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;we(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=we(this.bitmapSize,i)?null:i;e===null&&n===null||e!==null&&n!==null&&we(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}il().then(function(e){return e?t._initResizeObserver():t._initDevicePixelRatioObservable()})},s.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var e=cn(this._canvasElement);if(e===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=Qo(e),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},s.prototype._invalidateBitmapSize=function(){var t,e;if(this._canvasElement!==null){var i=cn(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?sl(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 el(s,t){return new tl(s,t.transform,t.options)}function cn(s){return s.ownerDocument.defaultView}function il(){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 sl(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 nl=(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 Se(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 nl(n,e,i)}const rl={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},ol={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},ll={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},hl={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},al={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},cl={color:"#26a69a",base:0},un={color:"#2196f3"},fn={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 dn,pn;function xe(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 mn(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 be(s,t){if(!s)throw new Error("Assertion failed"+(t?": "+t:""))}function Ut(s){if(s===void 0)throw new Error("Value is undefined");return s}function T(s){if(s===null)throw new Error("Value is null");return s}function ke(s){return T(Ut(s))}(function(s){s[s.Simple=0]="Simple",s[s.WithSteps=1]="WithSteps",s[s.Curved=2]="Curved"})(dn||(dn={})),(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"})(pn||(pn={}));const bn={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 jt(s){return s<0?0:s>255?255:Math.round(s)||0}function gn(s){return s<=0||s>0?s<0?0:s>1?1:Math.round(1e4*s)/1e4:0}const ul=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,fl=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,dl=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,pl=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/;function oi(s){(s=s.toLowerCase())in bn&&(s=bn[s]);{const t=pl.exec(s)||dl.exec(s);if(t)return[jt(parseInt(t[1],10)),jt(parseInt(t[2],10)),jt(parseInt(t[3],10)),gn(t.length<5?1:parseFloat(t[4]))]}{const t=fl.exec(s);if(t)return[jt(parseInt(t[1],16)),jt(parseInt(t[2],16)),jt(parseInt(t[3],16)),1]}{const t=ul.exec(s);if(t)return[jt(17*parseInt(t[1],16)),jt(17*parseInt(t[2],16)),jt(17*parseInt(t[3],16)),1]}throw new Error(`Cannot parse color: ${s}`)}function li(s){const t=oi(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 Ct{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&&(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 Ue(s){return typeof s=="number"&&s%1==0}function Ve(s){return typeof s=="string"}function hi(s){return typeof s=="boolean"}function de(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"?de(n):n);return e}function ml(s){return s!==null}function We(s){return s===null?void 0:s}const ji="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function Oe(s,t,e){return t===void 0&&(t=ji),`${e=e!==void 0?`${e} `:""}${s}px ${t}`}class bl{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=Oe(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 Ji{constructor(){this.Y=[]}X(t){this.Y=t}K(t,e,i){this.Y.forEach((n=>{n.K(t,e,i)}))}}class Ki{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 gl extends Ki{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 l=i.st[o];t.moveTo(l.et,l.rt),t.arc(l.et,l.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 vl(){return{st:[{et:0,rt:0,ut:0,ct:0}],_t:"",lt:"",ot:0,ht:0,nt:null}}const yl={from:0,to:1};class wl{constructor(t,e){this.dt=new Ji,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(vl),this.ft=this.vt.map((i=>{const n=new gl;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 l;const h=this.vt[o],a=r.Ct(i);if(t||a===null||!r.Tt())return void(h.nt=null);const c=T(r.Pt());h._t=a.Rt,h.ot=a.ot,h.ht=a.Dt,h.st[0].ct=a.ct,h.st[0].rt=r.At().Ot(a.ct,c.Vt),h.lt=(l=a.Bt)!==null&&l!==void 0?l:this.F.It(h.st[0].rt/r.At().zt()),h.st[0].ut=i,h.st[0].et=n.Et(i),h.nt=yl}))}}class pe{K(t,e,i){t.useBitmapCoordinateSpace((n=>this.Z(n,e,i)))}}class Sl extends pe{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 l=Math.round(this.Lt.et*i),h=Math.round(this.Lt.rt*n);t.lineCap="butt",r&&l>=0&&(t.lineWidth=Math.floor(this.Lt.Nt.ht*i),t.strokeStyle=this.Lt.Nt.O,t.fillStyle=this.Lt.Nt.O,xe(t,this.Lt.Nt.Wt),(function(a,c,u,p){a.beginPath();const b=a.lineWidth%2?.5:0;a.moveTo(c+b,u),a.lineTo(c+b,p),a.stroke()})(t,l,0,e.height)),o&&h>=0&&(t.lineWidth=Math.floor(this.Lt.Ft.ht*n),t.strokeStyle=this.Lt.Ft.O,t.fillStyle=this.Lt.Ft.O,xe(t,this.Lt.Ft.Wt),mn(t,h,0,e.width))}}class xl{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 Sl(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=T(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 _l(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 ai(s,t,e,i,n,r){s.save(),s.globalCompositeOperation="copy",s.fillStyle=r,s.fillRect(t,e,i,n),s.restore()}function vn(s,t){return s.map((e=>e===0?e:e+t))}function Xi(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 yn(s,t,e,i,n,r,o=0,l=[0,0,0,0],h=""){if(s.save(),!o||!h||h===r)return Xi(s,t,e,i,n,l),s.fillStyle=r,s.fill(),void s.restore();const a=o/2;r!=="transparent"&&(Xi(s,t+o,e+o,i-2*o,n-2*o,vn(l,-o)),s.fillStyle=r,s.fill()),h!=="transparent"&&(Xi(s,t+a,e+a,i-o,n-o,vn(l,-a)),s.lineWidth=o,s.strokeStyle=h,s.closePath(),s.stroke()),s.restore()}function wn(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 Sn{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,l=t.useBitmapCoordinateSpace((h=>{const a=h.context;a.font=e.R;const c=this.Qt(h,e,i,n),u=c.ti,p=(b,d)=>{c.ii?yn(a,u.ni,u.si,u.ei,u.ri,b,u.hi,[u.ot,0,0,u.ot],d):yn(a,u.li,u.si,u.ei,u.ri,b,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:h})=>{const a=l.vi;h.font=e.R,h.textAlign=l.ii?"right":"left",h.textBaseline="middle",h.fillStyle=r,h.fillText(this.Lt.Jt,a.pi,(a.si+a.fi)/2+a.mi)}))}Qt(t,e,i,n){var r;const{context:o,bitmapSize:l,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:c}=t,u=this.Lt.ai||!this.Lt.bi?e.T:0,p=this.Lt.wi?e.C:0,b=e.L+this.Gt.gi,d=e.V+this.Gt.Mi,f=e.B,m=e.I,S=this.Lt.Jt,g=e.P,x=i.xi(o,S),L=Math.ceil(i.Si(o,S)),A=g+b+d,J=e.C+f+m+L+u,F=Math.max(1,Math.floor(c));let Y=Math.round(A*c);Y%2!=F%2&&(Y+=1);const Q=p>0?Math.max(1,Math.floor(p*a)):0,Tt=Math.round(J*a),V=Math.round(u*a),at=(r=this.Gt.ki)!==null&&r!==void 0?r:this.Gt.yi,Bt=Math.round(at*c)-Math.floor(.5*c),vt=Math.floor(Bt+F/2-Y/2),lt=vt+Y,ct=n==="right",ut=ct?h.width-p:p,Dt=ct?l.width-Q:Q;let Et,St,xt;return ct?(Et=Dt-Tt,St=Dt-V,xt=ut-u-f-p):(Et=Dt+Tt,St=Dt+V,xt=ut+u+f),{ii:ct,ti:{si:vt,oi:Bt,fi:lt,ei:Tt,ri:Y,ot:2*a,hi:Q,ni:Et,li:Dt,_i:St,ui:F,di:l.width},vi:{si:vt/c,fi:lt/c,pi:xt,mi:x}}}}class ci{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||Sn)(this.Ti,this.Ci),this.Di=new(t||Sn)(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 Cl extends ci{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=li(n.labelBackgroundColor);i.t=o.t,t.O=o.i;const l=2/12*this.Li.P();i.gi=l,i.Mi=l;const h=this.Ni(this.Li);i.yi=h.yi,t.Jt=this.Li.Wi(h.ct,r),t.Tt=!0}}const Tl=/[1-9]/g;class xn{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,T(this.Lt).Jt,Tl)))));if(i<=0)return;const n=e.Hi,r=i+2*n,o=r/2,l=this.Lt.$i;let h=this.Lt.yi,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.V);t.useBitmapCoordinateSpace((({context:p,horizontalPixelRatio:b,verticalPixelRatio:d})=>{const f=T(this.Lt);p.fillStyle=f.t;const m=Math.round(a*b),S=Math.round(0*d),g=Math.round(c*b),x=Math.round(u*d),L=Math.round(2*b);if(p.beginPath(),p.moveTo(m,S),p.lineTo(m,x-L),p.arcTo(m,x,m+L,x,L),p.lineTo(g-L,x),p.arcTo(g,x,g,x-L,L),p.lineTo(g,S),p.fill(),f.ai){const A=Math.round(f.yi*b),J=S,F=Math.round((J+e.T)*d);p.fillStyle=f.O;const Y=Math.max(1,Math.floor(b)),Q=Math.floor(.5*b);p.fillRect(A-Q,J,Y,F-J)}})),t.useMediaCoordinateSpace((({context:p})=>{const b=T(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=b.O;const f=e.ji.xi(p,"Apr0");p.translate(a+n,d+f),p.fillText(b.Jt,0,0)}))}}class El{constructor(t,e,i){this.bt=!0,this.Ht=new xn,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(T(r)),t.Tt=!0;const o=li(e.labelBackgroundColor);t.t=o.t,t.O=o.i,t.ai=i.W().ticksVisible}}class Yi{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 _n;(function(s){s[s.Normal=0]="Normal",s[s.Magnet=1]="Magnet",s[s.Hidden=2]="Hidden"})(_n||(_n={}));class Ll extends Yi{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 wl(t,this),this.fn=((n,r)=>o=>{const l=r(),h=n();if(o===T(this.nn).vn())return{ct:h,yi:l};{const a=T(o.Pt());return{ct:o.pn(l,a),yi:l}}})((()=>this.sn),(()=>this.on));const i=((n,r)=>()=>{const o=this.Ui.yt().mn(n()),l=r();return o&&Number.isFinite(l)?{ut:o,yi:l}:null})((()=>this.en),(()=>this.Kt()));this.bn=new El(this,t,i),this.wn=new xl(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,l=this.en,h=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||l!==this.en||o!==this.sn||h!==this.nn}Tn(){const t=this.Ui.Mt().map((i=>i.In().Bn())).filter(ml),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 Cl(this,e,i),t.set(e,n)),n}}function ui(s){return s==="left"||s==="right"}class At{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 At(2)}static es(){return new At(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 Cn=".";function me(s,t){if(!te(s))return"n/a";if(!Ue(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 fi{constructor(t,e){if(e||(e=1),te(t)&&Ue(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=Cn+me(+o.toFixed(this.os)*this.rs,r)}else i=Math.round(i*e)/e,r>0&&(n=Cn+me(0,r));return i.toFixed(0)+n}}class Tn extends fi{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Ml{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 En(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 b=n/2;l.beginPath();const d={et:c.et-b,rt:c.rt},f={et:c.et+b,rt:c.rt};l.moveTo(d.et*h,d.rt*a),l.lineTo(f.et*h,f.rt*a),o(s,u,d,f)}else{const b=(f,m)=>{o(s,u,p,m),l.beginPath(),u=f,p=m};let d=p;l.beginPath(),l.moveTo(c.et*h,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:l.lineTo(d.et*h,d.rt*a);break;case 1:l.lineTo(d.et*h,t[f-1].rt*a),m!==u&&(b(m,d),l.lineTo(d.et*h,t[f-1].rt*a)),l.lineTo(d.et*h,d.rt*a);break;case 2:{const[S,g]=kl(t,f-1,f);l.bezierCurveTo(S.et*h,S.rt*a,g.et*h,g.rt*a,d.et*h,d.rt*a);break}}e!==1&&m!==u&&(b(m,d),l.moveTo(d.et*h,d.rt*a))}(p!==d||p===d&&e===1)&&o(s,u,p,d)}}const Ln=6;function Gi(s,t){return{et:s.et-t.et,rt:s.rt-t.rt}}function Mn(s,t){return{et:s.et/t,rt:s.rt/t}}function kl(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=Mn(Gi(s[e],s[i]),Ln),{et:r.et+o.et,rt:r.rt+o.rt}),Gi(s[e],Mn(Gi(s[n],s[t]),Ln))]}function Ol(s,t,e,i,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;r.lineTo(n.et*o,s*l),r.lineTo(i.et*o,s*l),r.closePath(),r.fillStyle=e,r.fill()}class kn extends pe{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:l,ds:h}=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,xe(c,l),c.lineWidth=1,En(t,i,h,n,r,this.ps.bind(this),Ol.bind(null,a))}}function Zi(s,t,e){return Math.min(Math.max(s,t),e)}function di(s,t,e){return t-s<=e}function On(s){const t=Math.ceil(s);return t%2==0?t-1:t}class Qi{bs(t,e){const i=this.ws,{gs:n,Ms:r,xs:o,Ss:l,ks:h,fs:a}=e;if(this.ys===void 0||i===void 0||i.gs!==n||i.Ms!==r||i.xs!==o||i.Ss!==l||i.fs!==a||i.ks!==h){const c=t.context.createLinearGradient(0,0,0,h);if(c.addColorStop(0,n),a!=null){const u=Zi(a*t.verticalPixelRatio/h,0,1);c.addColorStop(u,r),c.addColorStop(u,o)}c.addColorStop(1,l),this.ys=c,this.ws=e}return this.ys}}class Pl extends kn{constructor(){super(...arguments),this.Cs=new Qi}ps(t,e){return this.Cs.bs(t,{gs:e.Ts,Ms:"",xs:"",Ss:e.Ps,ks:t.bitmapSize.height})}}function Al(s,t){const e=s.context;e.strokeStyle=t,e.stroke()}class Pn extends pe{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:l,Rs:h}=this.tt;if(i===null)return;const a=t.context;a.lineCap="butt",a.lineWidth=o*t.verticalPixelRatio,xe(a,l),a.lineJoin="round";const c=this.Ds.bind(this);r!==void 0&&En(t,e,r,i,n,c,Al),h&&(function(u,p,b,d,f){const{horizontalPixelRatio:m,verticalPixelRatio:S,context:g}=u;let x=null;const L=Math.max(1,Math.floor(m))%2/2,A=b*S+L;for(let J=d.to-1;J>=d.from;--J){const F=p[J];if(F){const Y=f(u,F);Y!==x&&(g.beginPath(),x!==null&&g.fill(),g.fillStyle=Y,x=Y);const Q=Math.round(F.et*m)+L,Tt=F.rt*S;g.moveTo(Q,Tt),g.arc(Q,Tt,A,0,2*Math.PI)}}g.fill()})(t,e,h,i,c)}}class An extends Pn{Ds(t,e){return e._t}}function Bn(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 Ie=Bn.bind(null,!0),Dn=Bn.bind(null,!1);function Bl(s,t){return s.ut<t}function Dl(s,t){return t<s.ut}function Nn(s,t,e){const i=t.Os(),n=t.di(),r=Ie(s,i,Bl),o=Dn(s,n,Dl);if(!e)return{from:r,to:o};let l=r,h=o;return r>0&&r<s.length&&s[r].ut>=i&&(l=r-1),o>0&&o<s.length&&s[o-1].ut<=n&&(h=o+1),{from:l,to:h}}class ts{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=Nn(this.Is,i,this.Ns),this.Zs(t,e,n.Vt),this.Gs())}}class pi extends ts{constructor(t,e){super(t,e,!0)}Zs(t,e,i){e.Js(this.Is,We(this.zs)),t.Qs(this.Is,i,We(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 Nl extends pi{constructor(t,e){super(t,e),this.Ws=new Ji,this.ee=new Pl,this.re=new An,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 Rl extends pe{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 l=this.Lt.In[o];n!==l.ue&&(t.fillStyle=l.ue,n=l.ue);const h=Math.floor(.5*this.ae),a=Math.round(l.et*e),c=a-h,u=this.ae,p=c+u-1,b=Math.min(l.ce,l.de),d=Math.max(l.ce,l.de),f=Math.round(b*i)-h,m=Math.round(d*i)+h,S=Math.max(m-f,this.ae);t.fillRect(c,f,u,S);const g=Math.ceil(1.5*this.le);if(r){if(this.Lt.fe){const J=a-g;let F=Math.max(f,Math.round(l.ve*i)-h),Y=F+u-1;Y>f+S-1&&(Y=f+S-1,F=Y-u+1),t.fillRect(J,F,c-J,Y-F+1)}const x=a+g;let L=Math.max(f,Math.round(l.pe*i)-h),A=L+u-1;A>f+S-1&&(A=f+S-1,L=A-u+1),t.fillRect(p+1,L,x-p,A-L+1)}}}oe(t){const e=Math.floor(t);return Math.max(e,Math.floor((function(i,n){return Math.floor(.3*i*n)})(T(this.Lt).he,t)))}}class Rn extends ts{constructor(t,e){super(t,e,!1)}Zs(t,e,i){e.Js(this.Is,We(this.zs)),t.me(this.Is,i,We(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 Fl extends Rn{constructor(){super(...arguments),this.Ws=new Rl}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 zl extends kn{constructor(){super(...arguments),this.Cs=new Qi}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 Ul extends Pn{constructor(){super(...arguments),this.Te=new Qi}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 Vl extends pi{constructor(t,e){super(t,e),this.Ws=new Ji,this.De=new zl,this.Oe=new Ul,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 Wl extends pe{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 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.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 l="",h=Math.min(Math.floor(r),Math.floor(this.Lt.he*r));h=Math.max(Math.floor(r),Math.min(h,this.le));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 b=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 S=Math.round(r*p.et)-a;const g=S+h-1;c!==null&&(S=Math.max(c+1,S),S=Math.min(S,g));const x=g-S+1;n.fillRect(S,f,x,b-f),n.fillRect(S,d+1,x,m-d),c=g}}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 l="";const h=this.Ie(r);let a=null;for(let c=i.from;c<i.to;c++){const u=e[c];u.Le!==l&&(n.fillStyle=u.Le,l=u.Le);let p=Math.round(u.et*r)-Math.floor(.5*this.le);const b=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,b)),this.Lt.he*r>2*h)_l(n,p,d,b-p+1,f-d+1,h);else{const m=b-p+1;n.fillRect(p,d,m,f-d+1)}a=b}}ze(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const h=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),b=Math.round(c.et*r)-Math.floor(.5*this.le),d=b+this.le-1;if(c.ue!==l){const f=c.ue;n.fillStyle=f,l=f}this.Lt.ci&&(b+=h,u+=h,d-=h,p-=h),u>p||n.fillRect(b,u,d-b+1,p-u+1)}}}class Il extends Rn{constructor(){super(...arguments),this.Ws=new Wl}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 ql{constructor(t,e){this.Ne=t,this.Li=e}K(t,e,i){this.Ne.draw(t,this.Li,e,i)}}class es extends ts{constructor(t,e,i){super(t,e,!1),this.wn=i,this.Ws=new ql(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,We(this.zs))}Gs(){this.wn.update({bars:this.Is.map(Hl),barSpacing:this.Ls.yt().he(),visibleRange:this.zs},this.Es.W())}}function Hl(s){return{x:s.et,time:s.ut,originalData:s.je,barColor:s.ue}}class $l extends pe{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 l=this.Lt.nt.from;l<this.Lt.nt.to;l++){const h=this.Lt.st[l],a=this.$e[l-this.Lt.nt.from],c=Math.round(h.rt*i);let u,p;t.fillStyle=h.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],l=Math.round(o.et*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.$e[r-this.Lt.nt.from]={Os:h,di:a,Ye:l,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],l=this.$e[r-this.Lt.nt.from-1];o.ut===l.ut+1&&o.Os-l.di!==e+1&&(l.Ye>l.Xe?l.di=o.Os-e-1:o.Os=l.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 l=o.di-o.Os+1;n=Math.min(l,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 jl extends pi{constructor(){super(...arguments),this.Ws=new $l}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,T(this.Es.Pt()).Vt)};this.Ws.it(t)}}class Jl extends pi{constructor(){super(...arguments),this.Ws=new An}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 Kl=/[2-9]/g;class qe{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||Kl,r=String(e).replace(n,"0");if(this.Qe.has(r))return Ut(this.Qe.get(r)).sr;if(this.Ke===this.tr){const l=this.Je[this.Ge];delete this.Je[this.Ge],this.Qe.delete(l),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 Xl{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 Fn{constructor(t,e,i){this._r=t,this.lr=new qe(50),this.ur=e,this.F=i,this.j=-1,this.Ht=new Xl(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 Yl extends pe{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),xe(t,this.Lt.Wt),mn(t,r,0,e.width))}}class is{constructor(t){this.Mr={rt:0,O:"rgba(0, 0, 0, 0)",ht:1,Wt:0,Tt:!1},this.Sr=new Yl,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 Gl extends is{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 Zl extends pe{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,l=Math.round(n.Xe.x*e)+o,h=n.Xe.y*i;t.fillStyle=n.Cr,t.beginPath();const a=Math.max(2,1.5*n.Tr)*e;t.arc(l,h,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.Pr,t.beginPath(),t.arc(l,h,n.ot*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=n.Rr,t.beginPath(),t.arc(l,h,n.ot*e+r/2,0,2*Math.PI,!1),t.stroke()}}const Ql=[{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 zn(s,t,e,i){return(function(n,r){if(n==="transparent")return n;const o=oi(n),l=o[3];return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${r*l})`})(s,e+(i-e)*t)}function Un(s,t){const e=s%2600/2600;let i;for(const h of Ql)if(e>=h.Dr&&e<=h.Or){i=h;break}be(i!==void 0,"Last price animation internal logic error");const n=(e-i.Dr)/(i.Or-i.Dr);return{Pr:zn(t,n,i.Br,i.Ir),Rr:zn(t,n,i.zr,i.Er),ot:(r=n,o=i.Ar,l=i.Vr,o+(l-o)*r)};var r,o,l}class th{constructor(t){this.Ht=new Zl,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,l=this.Wr.W().lineWidth,h=Un(this.Zr(),o);this.Ht.it({Cr:o,Tr:l,Pr:h.Pr,Rr:h.Rr,ot:h.ot,Xe:r})}qr(){const t=this.Ht.He();if(t!==null){const e=Un(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 He(s,t){return On(Math.min(Math.max(s,12),30)*t)}function $e(s,t){switch(s){case"arrowDown":case"arrowUp":return He(t,1);case"circle":return He(t,.8);case"square":return He(t,.7)}}function Vn(s){return(function(t){const e=Math.ceil(t);return e%2!=0?e-1:e})(He(s,1))}function Wn(s){return Math.max(He(s,.1),3)}function In(s,t,e,i,n){const r=$e("square",e),o=(r-1)/2,l=s-o,h=t-o;return i>=l&&i<=l+r&&n>=h&&n<=h+r}function qn(s,t,e,i,n){const r=($e("arrowUp",n)-1)/2,o=(On(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 eh(s,t,e,i,n,r){return In(t,e,i,n,r)}class ih extends Ki{constructor(){super(...arguments),this.Lt=null,this.lr=new qe,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=Oe(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(nh(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),sh(r,t)}}}}function sh(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 qn(!1,i,e.et,e.rt,e.Ks);case"arrowUp":return void qn(!0,i,e.et,e.rt,e.Ks);case"circle":return void(function(n,r,o,l){const h=($e("circle",l)-1)/2;n.beginPath(),n.arc(r,o,h,0,2*Math.PI,!1),n.fill()})(i,e.et,e.rt,e.Ks);case"square":return void(function(n,r,o,l){const h=$e("square",l),a=(h-1)/2,c=r-a,u=o-a;n.fillRect(c,u,h,h)})(i,e.et,e.rt,e.Ks)}e.th}})(s,t)}function nh(s,t,e){return!(s.Jt===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.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 eh(0,i.et,i.rt,i.Ks,n,r);case"circle":return(function(o,l,h,a,c){const u=2+$e("circle",h)/2,p=o-a,b=l-c;return Math.sqrt(p*p+b*b)<=u})(i.et,i.rt,i.Ks,n,r);case"square":return In(i.et,i.rt,i.Ks,n,r)}})(s,t,e)}function rh(s,t,e,i,n,r,o,l,h){const a=te(e)?e:e.xe,c=te(e)?e:e.ge,u=te(e)?e:e.Me,p=te(t.size)?Math.max(t.size,0):1,b=Vn(l.he())*p,d=b/2;switch(s.Ks=b,t.position){case"inBar":return s.rt=o.Ot(a,h),void(s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n));case"aboveBar":return s.rt=o.Ot(c,h)-d-i.ih,s.Jt!==void 0&&(s.Jt.rt=s.rt-d-.6*n,i.ih+=1.2*n),void(i.ih+=b+r);case"belowBar":return s.rt=o.Ot(u,h)+d+i.nh,s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n,i.nh+=1.2*n),void(i.nh+=b+r)}t.position}class oh{constructor(t,e){this.bt=!0,this.sh=!0,this.eh=!0,this.rh=null,this.Ht=new ih,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=Wn(t),i=1.5*Vn(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 l=NaN;const h=Wn(e.he()),a={ih:h,nh:h};this.Lt.nt=Nn(this.Lt.st,r,!0);for(let c=this.Lt.nt.from;c<this.Lt.nt.to;c++){const u=i[c];u.time!==l&&(a.ih=h,a.nh=h,l=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 b=this.Wr.oh(u.time);b!==null&&rh(p,u,b,a,n.fontSize,h,t,e,o.Vt)}this.bt=!1}}class lh extends is{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 hh extends ci{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,l=n.uh()!=="",h=r.seriesLastValueMode===0,a=n.Yr(!1);if(a.Xr)return;o&&(t.Jt=this.dh(a,o,h),t.Tt=t.Jt.length!==0),(l||h)&&(e.Jt=this.fh(a,o,l,h),e.Tt=e.Jt.length>0);const c=n._h(a.O),u=li(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 Hn(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 Wt{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 Wt(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 Wt(Hn(Math.min,this.Sh(),t.Sh(),-1/0),Hn(Math.max,this.kh(),t.kh(),1/0))}Ch(t){if(!te(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){te(t)&&(this.gh+=t,this.wh+=t)}Ph(){return{minValue:this.wh,maxValue:this.gh}}static Rh(t){return t===null?null:new Wt(t.minValue,t.maxValue)}}class mi{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 mi(Wt.Rh(t.priceRange),t.margins)}}class ah extends is{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 ch extends ci{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!=="",l=this.Wr;if(!r||!l.Tt())return;const h=this.Bh.Ih();if(h===null)return;o&&(e.Jt=n.title,e.Tt=!0),e.Bt=l.qt().It(h/l.At().zt()),t.Jt=this.zh(n.price),t.Tt=!0;const a=li(n.axisLabelColor||n.color);i.t=a.t;const c=n.axisLabelTextColor||a.i;t.O=c,e.O=c,i.yi=h}zh(t){const e=this.Wr.Pt();return e===null?"":this.Wr.At().Wi(t,e.Vt)}}class uh{constructor(t,e){this.Wr=t,this.cn=e,this.Eh=new ah(t,this),this._r=new ch(t,this),this.Lh=new Fn(this._r,t,t.qt())}Nh(t){Gt(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 fh extends Yi{constructor(t){super(),this.Ui=t}qt(){return this.Ui}}const dh={Bar:(s,t,e,i)=>{var n;const r=t.upColor,o=t.downColor,l=T(s(e,i)),h=ke(l.Vt[0])<=ke(l.Vt[3]);return{ue:(n=l.O)!==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,b=T(s(e,i)),d=ke(b.Vt[0])<=ke(b.Vt[3]);return{ue:(n=b.O)!==null&&n!==void 0?n:d?l:h,Le:(r=b.Bt)!==null&&r!==void 0?r:d?a:c,Ee:(o=b.$h)!==null&&o!==void 0?o:d?u:p}},Custom:(s,t,e,i)=>{var n;return{ue:(n=T(s(e,i)).O)!==null&&n!==void 0?n:t.color}},Area:(s,t,e,i)=>{var n,r,o,l;const h=T(s(e,i));return{ue:(n=h._t)!==null&&n!==void 0?n:t.lineColor,_t:(r=h._t)!==null&&r!==void 0?r:t.lineColor,Ts:(o=h.Ts)!==null&&o!==void 0?o:t.topColor,Ps:(l=h.Ps)!==null&&l!==void 0?l:t.bottomColor}},Baseline:(s,t,e,i)=>{var n,r,o,l,h,a;const c=T(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:(l=c.ke)!==null&&l!==void 0?l:t.topFillColor2,ye:(h=c.ye)!==null&&h!==void 0?h:t.bottomFillColor1,Ce:(a=c.Ce)!==null&&a!==void 0?a:t.bottomFillColor2}},Line:(s,t,e,i)=>{var n,r;const o=T(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=T(s(e,i)).O)!==null&&n!==void 0?n:t.color}}};class ph{constructor(t){this.Uh=(e,i)=>i!==void 0?i.Vt:this.Wr.In().qh(e),this.Wr=t,this.Yh=dh[t.Xh()]}Hs(t,e){return this.Yh(this.Uh,this.Wr.W(),t,e)}}var $n;(function(s){s[s.NearestLeft=-1]="NearestLeft",s[s.None=0]="None",s[s.NearestRight=1]="NearestRight"})($n||($n={}));const ge=30;class mh{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=bi(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 Ie(this.Kh,t,((e,i)=>e.se<i))}_l(t){return Dn(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=T(this.Qh()),o=T(this.Bn()),l=Math.max(t,r),h=Math.min(e,o),a=Math.ceil(l/ge)*ge,c=Math.max(a,Math.floor(h/ge)*ge);{const p=this.ol(l),b=this._l(Math.min(h,a,e));n=bi(n,this.ul(p,b,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,l);p<c;p+=ge){const b=Math.floor(p/ge);let d=u.get(b);if(d===void 0){const f=this.ol(b*ge),m=this._l((b+1)*ge-1);d=this.ul(f,m,i),u.set(b,d)}n=bi(n,d)}{const p=this.ol(c),b=this._l(h);n=bi(n,this.ul(p,b,i))}return n}}function bi(s,t){return s===null?t:t===null?s:{cl:Math.min(s.cl,t.cl),dl:Math.max(s.dl,t.dl)}}class bh{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 ss{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 bh(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 jn(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 gh{constructor(t,e){this.Ht=new xn,this.bl=t,this.wl=e}xt(){return this.Ht.it(Object.assign({$i:this.wl.$i()},jn(this.bl))),this.Ht}}class vh extends ci{constructor(t,e){super(),this.bl=t,this.Li=e}Ei(t,e,i){const n=jn(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 yh{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((l=>new ss(l)));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(),l=r.map((h=>new gh(h,o)));return this.Ml={vl:r,pl:l},l}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(),l=r.map((h=>new vh(h,o)));return this.xl={vl:r,pl:l},l}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((l=>new ss(l)));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((l=>new ss(l)));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 ns(s,t,e,i){s.forEach((n=>{t(n).forEach((r=>{r.ml()===e&&i.push(r)}))}))}function rs(s){return s.Pn()}function wh(s){return s.Tl()}function Sh(s){return s.Pl()}class os extends fh{constructor(t,e,i,n,r){super(t),this.Lt=new mh,this.Eh=new lh(this),this.Dl=[],this.Ol=new Gl(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 hh(this);this.hn=[o],this.Lh=new Fn(o,this,t),i!=="Area"&&i!=="Line"&&i!=="Baseline"||(this.Al=new th(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,l;if(t){const u=this.Lt.Jh();if(u===null)return e;o=u,l=u.se}else{const u=this.Lt.nl(n.di(),-1);if(u===null||(o=this.Lt.qh(u.se),o===null))return e;l=u.se}const h=o.Vt[3],a=this.$s().Hs(l,{Vt:o}),c=i.Ot(h,r.Vt);return{Xr:!1,ct:h,Jt:i.Wi(h,r.Vt),mh:i.Wl(h),bh:i.jl(h,r.Vt),O:a.ue,yi:c,se:l}}$s(){return this.Vl!==null||(this.Vl=new ph(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),Gt(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 uh(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=[];ns(this.El,rs,"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),ns(this.El,rs,"normal",t),t}ra(){return this.ha(rs,"bottom")}la(t){return this.ha(wh,t)}aa(t){return this.ha(Sh,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 mi.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 T(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 yh(t,this))}wa(t){this.El=this.El.filter((e=>e.Cl()!==t))}ga(){if(this.wn instanceof es)return t=>this.wn.Fe(t)}Ma(){if(this.wn instanceof es)return t=>this.wn.We(t)}ea(){return!ui(this.At().xa())}_a(t,e){if(!Ue(t)||!Ue(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 Wt(n.cl,n.dl):null;if(this.Xh()==="Histogram"){const l=this.cn.base,h=new Wt(l,l);r=r!==null?r.ts(h):h}let o=this.dn.lh();return this.El.forEach((l=>{const h=l.Rl(t,e);if(h?.priceRange){const b=new Wt(h.priceRange.minValue,h.priceRange.maxValue);r=r!==null?r.ts(b):b}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 mi(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 Ml(this.cn.priceFormat.precision);break;case"percent":this.da=new Tn(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.da=new fi(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=T(this.Lt.Qh());this.Il=this.Bl.map(((i,n)=>{const r=T(t.ya(i.time,!0)),o=r<e?1:-1;return{time:T(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 oh(this,this.qt()),this.Ll){case"Bar":this.wn=new Fl(this,this.qt());break;case"Candlestick":this.wn=new Il(this,this.qt());break;case"Line":this.wn=new Jl(this,this.qt());break;case"Custom":this.wn=new es(this,this.qt(),Ut(t));break;case"Area":this.wn=new Nl(this,this.qt());break;case"Baseline":this.wn=new Vl(this,this.qt());break;case"Histogram":this.wn=new jl(this,this.qt());break;default:throw Error("Unknown chart style assigned: "+this.Ll)}}ha(t,e){const i=[];return ns(this.El,t,e,i),i}}class xh{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 l=r.Ot(t,o),h=i.Ta().filter((c=>c instanceof os)).reduce(((c,u)=>{if(i.dr(u)||!u.Tt())return c;const p=u.At(),b=u.In();if(p.Fi()||!b.Kr(e))return c;const d=b.qh(e);if(d===null)return c;const f=ke(u.Pt());return c.concat([p.Ot(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 _h extends pe{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,l){o.save(),o.lineWidth%2&&o.translate(.5,.5),l(),o.restore()})(t,(()=>{const o=T(this.Lt);if(o.Pa){t.strokeStyle=o.Ra,xe(t,o.Da),t.beginPath();for(const l of o.Oa){const h=Math.round(l.Aa*i);t.moveTo(h,-r),t.lineTo(h,e.height+r)}t.stroke()}if(o.Va){t.strokeStyle=o.Ba,xe(t,o.Ia),t.beginPath();for(const l of o.za){const h=Math.round(l.Aa*n);t.moveTo(-r,h),t.lineTo(e.width+r,h)}t.stroke()}}))}}class Ch{constructor(t){this.Ht=new _h,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 Th{constructor(t){this.wn=new Ch(t)}Wh(){return this.wn}}const ls={La:4,Na:1e-4};function Pe(s,t){const e=100*(s-t)/t;return t<0?-e:e}function Eh(s,t){const e=Pe(s.Sh(),t),i=Pe(s.kh(),t);return new Wt(e,i)}function je(s,t){const e=100*(s-t)/t+100;return t<0?-e:e}function Lh(s,t){const e=je(s.Sh(),t),i=je(s.kh(),t);return new Wt(e,i)}function gi(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 Je(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 Ke(s,t){if(s===null)return null;const e=gi(s.Sh(),t),i=gi(s.kh(),t);return new Wt(e,i)}function vi(s,t){if(s===null)return null;const e=Je(s.Sh(),t),i=Je(s.kh(),t);return new Wt(e,i)}function hs(s){if(s===null)return ls;const t=Math.abs(s.kh()-s.Sh());if(t>=1||t<1e-15)return ls;const e=Math.ceil(Math.abs(Math.log10(t))),i=ls.La+e;return{La:i,Na:1/Math.pow(10,i)}}class as{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,l=this.Wa[0];for(;;){const u=di(r,n,1e-14)&&r>n+1e-14,p=di(r,i*l,1e-14),b=di(r,1,1e-14);if(!(u&&p&&b))break;r/=l,l=this.Wa[++o%this.Wa.length]}if(r<=n+1e-14&&(r=n),r=Math.max(1,r),this.ja.length>0&&(h=r,a=1,c=1e-14,Math.abs(h-a)<c))for(o=0,l=this.ja[0];di(r,i*l,1e-14)&&r>n+1e-14;)r/=l,l=this.ja[++o%this.ja.length];var h,a,c;return r}}class Jn{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 as(this.Fa,[2,2.5,2]),o=new as(this.Fa,[2,2,2.5]),l=new as(this.Fa,[2.5,2,2]),h=[];return h.push(r.Ha(t,e,n),o.Ha(t,e,n),l.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})(h)}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,l=o,h=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 b=a>=c?1:-1;let d=null,f=0;for(let m=a-p;m>c;m-=u){const S=this.qa(m,e,!0);d!==null&&Math.abs(S-d)<this.Ya()||S<l||S>h||(f<this.$a.length?(this.$a[f].Aa=S,this.$a[f].Za=t.Ga(m)):this.$a.push({Aa:S,Za:t.Ga(m)}),f++,d=S,t.Ja()&&(u=this.Ha(m*b,c)))}this.$a.length=f}Ea(){return this.$a}Ka(){return this.Li.P()}Ya(){return Math.ceil(2.5*this.Ka())}}function Kn(s){return s.slice().sort(((t,e)=>T(t.Zi())-T(e.Zi())))}var Xn;(function(s){s[s.Normal=0]="Normal",s[s.Logarithmic=1]="Logarithmic",s[s.Percentage=2]="Percentage",s[s.IndexedTo100=3]="IndexedTo100"})(Xn||(Xn={}));const Yn=new Tn,Gn=new fi(100,1);class Mh{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 Ct,this.oo=new Ct,this._o=[],this.uo=null,this.co=null,this.do=null,this.fo=null,this.da=Gn,this.vo=hs(null),this.po=t,this.cn=e,this.mo=i,this.bo=n,this.wo=new Jn(this,100,this.Mo.bind(this),this.xo.bind(this))}xa(){return this.po}W(){return this.cn}Nh(t){if(Gt(this.cn,t),this.Sa(),t.mode!==void 0&&this.So({yr:t.mode}),t.scaleMargins!==void 0){const e=Ut(t.scaleMargins.top),i=Ut(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 l=Je(r.Sh(),o),h=Je(r.kh(),o);return isFinite(l)&&isFinite(h)})(this.Dh,this.vo)?(i=vi(this.Dh,this.vo),i!==null&&this.Po(i)):this.cn.autoScale=!0),t.yr===1&&t.yr!==e.yr&&(i=Ke(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=Pe(t,e):this.Co()&&(t=je(t,e)),this.xo(t,e)}Qs(t,e,i){this.Io();const n=this.Bo(),r=T(this.Ah()),o=r.Sh(),l=r.kh(),h=this.Ao()-1,a=this.To(),c=h/(l-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,b=this.Eo();for(let d=u;d<p;d++){const f=t[d],m=f.ct;if(isNaN(m))continue;let S=m;b!==null&&(S=b(f.ct,e));const g=n+c*(S-o),x=a?g:this.Qa-1-g;f.rt=x}}me(t,e,i){this.Io();const n=this.Bo(),r=T(this.Ah()),o=r.Sh(),l=r.kh(),h=this.Ao()-1,a=this.To(),c=h/(l-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,b=this.Eo();for(let d=u;d<p;d++){const f=t[d];let m=f.we,S=f.ge,g=f.Me,x=f.xe;b!==null&&(m=b(f.we,e),S=b(f.ge,e),g=b(f.Me,e),x=b(f.xe,e));let L=n+c*(m-o),A=a?L:this.Qa-1-L;f.ve=A,L=n+c*(S-o),A=a?L:this.Qa-1-L,f.ce=A,L=n+c*(g-o),A=a?L:this.Qa-1-L,f.de=A,L=n+c*(x-o),A=a?L:this.Qa-1-L,f.pe=A}}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=Kn(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=T(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=T(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=T(this.Ah()).xh()))}Ko(t){if(this.yo()||this.fo===null)return;const e=T(this.Ah()).yh()/(this.Ao()-1);let i=t-this.fo;this.To()&&(i*=-1);const n=i*e,r=T(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(Pe(t,e));case 3:return this.ca().format(je(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,T(this.Jo()).ca())}jl(t,e){return t=Pe(t,e),this.Go(t,Yn)}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=Gn,this.ph()?(this.da=Yn,e=100):this.Co()?(this.da=new fi(100,1),e=100):t!==null&&(this.da=t.ca()),this.wo=new Jn(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?gi(t,this.vo):t;const i=T(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=T(this.Ah()),r=n.Sh()+n.yh()*((i-this.Bo())/(this.Ao()-1));return this.Ja()?Je(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 h of i){if(!h.Tt())continue;const a=h.Pt();if(a===null)continue;const c=h.Rl(t.Os(),t.di());let u=c&&c.Ah();if(u!==null){switch(this.cn.mode){case 1:u=Ke(u,this.vo);break;case 2:u=Eh(u,a.Vt);break;case 3:u=Lh(u,a.Vt)}if(e=e===null?u:e.ts(T(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 h=this.Jo(),a=5*(h===null||this.ph()||this.Co()?1:h.ua());this.Ja()&&(e=vi(e,this.vo)),e=new Wt(e.Sh()-a,e.kh()+a),this.Ja()&&(e=Ke(e,this.vo))}if(this.Ja()){const h=vi(e,this.vo),a=hs(h);if(o=a,l=this.vo,o.La!==l.La||o.Na!==l.Na){const c=this.no!==null?vi(this.no,this.vo):null;this.vo=a,e=Ke(h,a),c!==null&&(this.no=Ke(c,a))}}this.Po(e)}else this.Dh===null&&(this.Po(new Wt(-.5,.5)),this.vo=hs(null));var o,l;this.so.eo=!0}Eo(){return this.ph()?Pe:this.Co()?je:this.Ja()?t=>gi(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 kh{constructor(t,e){this._o=[],this.s_=new Map,this.Qa=0,this.e_=0,this.r_=1e3,this.uo=null,this.h_=new Ct,this.wl=t,this.Ui=e,this.l_=new Th(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=T(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)?Ut(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);be(e!==-1,"removeDataSource: invalid data source"),this._o.splice(e,1);const i=T(t.At()).xa();if(this.s_.has(i)){const r=Ut(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=Kn(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),!ui(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},de(e)),n=new Mh(t,i,this.Ui.W().layout,this.Ui.W().localization);return n.Oo(this.zt()),n}}class Oh{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(Ut(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 Xe{constructor(t,e){be(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 Zn(s,t){return s===null||t===null?s===t:s.Mh(t)}class Ph{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(Ie(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 l=Ut(this.q_.get(i)),h=l.length;let a=1/0,c=-1/0;for(let u=0;u<h;u++){const p=l[u],b=p.index;for(;o<r;){const d=n[o],f=d.index;if(!(f<b)){a=f;break}o++,e.push(d),c=f,a=1/0}if(a-b>=t&&b-c>=t)e.push(p),c=b;else if(this.Y_)return n}for(;o<r;o++)e.push(n[o])}return e}}class Ae{constructor(t){this.tu=t}iu(){return this.tu===null?null:new Xe(Math.floor(this.tu.Os()),Math.ceil(this.tu.di()))}nu(){return this.tu}static su(){return new Ae(null)}}function Ah(s,t){return s.weight>t.weight?s:t}class Bh{constructor(t,e,i,n){this.e_=0,this.eu=null,this.ru=[],this.fo=null,this.do=null,this.hu=new Ph,this.lu=new Map,this.au=Ae.su(),this.ou=!0,this._u=new Ct,this.uu=new Ct,this.cu=new Ct,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){Gt(this.bo,t),this.gu(),this.bu()}Nh(t,e){var i;Gt(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=Ie(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=T(this.Tu()),r=T(this.Bn());return{from:T(this.qi(Math.max(n,e))),to:T(this.qi(Math.min(r,i)))}}Pu(t){return{from:T(this.ya(t.from,!0)),to:T(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()||!Ue(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 l=t[o].ut,h=i+this.pu-l,a=this.e_-(h+.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=T(this.Xs()),r=Math.max(n.Os(),n.Os()-i),o=Math.max(n.di(),n.di()-i),l=this.hu.G_(t,e),h=this.Tu()+i,a=this.Bn()-i,c=this.Eu(),u=this.cn.fixLeftEdge||c,p=this.cn.fixRightEdge||c;let b=0;for(const d of l){if(!(r<=d.index&&d.index<=o))continue;let f;b<this.vu.length?(f=this.vu[b],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<=h||p&&d.index>=a,b++}return this.vu.length=b,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=Zi(this.e_-t,0,this.e_),i=Zi(this.e_-T(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=T(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 Xe(t,e+this.cn.rightOffset))}Qu(t){const e=new Xe(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(Ae.su());const t=this.Ou(),e=this.e_/this.mu,i=this.pu+t,n=new Xe(i-e+1,i);this.nc(new Ae(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 Oh((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,Zn(e.iu(),this.au.iu())||this._u.m(),Zn(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 Dh extends Ki{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 l=this.oc(e,o.Jt);l>i.width?o.Wu=i.width/l: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 l=0;switch(this.Lt.cc){case"left":e.textAlign="left",l=o._c/2;break;case"center":e.textAlign="center",l=i.width/2;break;case"right":e.textAlign="right",l=i.width-1-o._c/2}e.translate(l,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 Nh{constructor(t){this.bt=!0,this.jt={Tt:!1,O:"",ac:[],uc:"center",cc:"center"},this.Ht=new Dh(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:Oe(t.fontSize,t.fontFamily,t.fontStyle),_c:1.2*t.fontSize,dc:0,Wu:0}])}}class Rh extends Yi{constructor(t,e){super(),this.cn=e,this.wn=new Nh(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}On(){this.wn.gt()}}var Qn,tr,er,ir,sr;(function(s){s[s.OnTouchEnd=0]="OnTouchEnd",s[s.OnNextTap=1]="OnNextTap"})(Qn||(Qn={}));class Fh{constructor(t,e,i){this.vc=[],this.mc=[],this.e_=0,this.bc=null,this.wc=new Ct,this.gc=new Ct,this.Mc=null,this.xc=t,this.cn=e,this.N_=i,this.Sc=new bl(this),this.wl=new Bh(this,e.timeScale,this.cn.localization,i),this.wt=new Ll(this,e.crosshair),this.kc=new xh(e.crosshair),this.yc=new Rh(this,e.watermark),this.Cc(),this.vc[0].p_(2e3),this.Tc=this.Pc(0),this.Rc=this.Pc(1)}$l(){this.Dc(At.es())}Fh(){this.Dc(At.ss())}sa(){this.Dc(new At(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){Gt(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 kh(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=At.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,l=this.wl.Au(t);const h=this.wl.Xs();h!==null&&(l=Math.min(Math.max(h.Os(),l),h.di()));const a=n.vn(),c=a.Pt();c!==null&&(o=a.pn(e,c)),o=this.kc.Ca(o,l,n),this.wt.kn(l,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,T(r)),l=this.wl.ya(e,!0),h=this.wl.Et(T(l));this.Gc(h,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),l=this.wl.Ou(),h=this.wl.Xs();if(h!==null&&n!==null&&o!==null){const a=h.Kr(l),c=this.N_.key(n)>this.N_.key(o),u=t!==null&&t>l&&!c,p=this.wl.Bn(),b=a&&p!==r&&this.wl.W().shiftVisibleRangeOnNewBar;if(u&&!b){const d=t-l;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);be(i!==-1,"Series not found"),this.mc.splice(i,1),T(e).jo(t),t.S&&t.S()}Hl(t,e){const i=T(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=At.ss();t.$n(),this.Dc(t)}hd(t){const e=At.ss();e.Yn(t),this.Dc(e)}Zn(){const t=At.ss();t.Zn(),this.Dc(t)}Gn(t){const e=At.ss();e.Gn(t),this.Dc(e)}Jn(t){const e=At.ss();e.Jn(t),this.Dc(e)}Xn(t){const e=At.ss();e.Xn(t),this.Dc(e)}Un(){const t=At.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,l){const[h,a,c,u]=oi(r),[p,b,d,f]=oi(o),m=[jt(h+l*(p-h)),jt(a+l*(b-a)),jt(c+l*(d-c)),gn(u+l*(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 At(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 os(this,t,e,i,n),o=t.priceScaleId!==void 0?t.priceScaleId:this.ld();return i.Fo(r,o),ui(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 cs(s){return!te(s)&&!Ve(s)}function nr(s){return te(s)}(function(s){s[s.Disabled=0]="Disabled",s[s.Continuous=1]="Continuous",s[s.OnDataUpdate=2]="OnDataUpdate"})(tr||(tr={})),(function(s){s[s.LastBar=0]="LastBar",s[s.LastVisible=1]="LastVisible"})(er||(er={})),(function(s){s.Solid="solid",s.VerticalGradient="gradient"})(ir||(ir={})),(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"})(sr||(sr={}));const rr=s=>s.getUTCFullYear();function zh(s,t,e){return t.replace(/yyyy/g,(i=>me(rr(i),4))(s)).replace(/yy/g,(i=>me(rr(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=>me((n=>n.getUTCMonth()+1)(i),2))(s)).replace(/dd/g,(i=>me((n=>n.getUTCDate())(i),2))(s))}class or{constructor(t="yyyy-MM-dd",e="default"){this._d=t,this.ud=e}F_(t){return zh(t,this._d,this.ud)}}class Uh{constructor(t){this.dd=t||"%h:%m:%s"}F_(t){return this.dd.replace("%h",me(t.getUTCHours(),2)).replace("%m",me(t.getUTCMinutes(),2)).replace("%s",me(t.getUTCSeconds(),2))}}const Vh={fd:"yyyy-MM-dd",vd:"%h:%m:%s",pd:" ",md:"default"};class Wh{constructor(t={}){const e=Object.assign(Object.assign({},Vh),t);this.bd=new or(e.fd,e.md),this.wd=new Uh(e.vd),this.gd=e.pd}F_(t){return`${this.bd.F_(t)}${this.gd}${this.wd.F_(t)}`}}function yi(s){return 60*s*60*1e3}function us(s){return 60*s*1e3}const wi=[{Md:(lr=1,1e3*lr),xd:10},{Md:us(1),xd:20},{Md:us(5),xd:21},{Md:us(30),xd:22},{Md:yi(1),xd:30},{Md:yi(3),xd:31},{Md:yi(6),xd:32},{Md:yi(12),xd:33}];var lr;function hr(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=wi.length-1;e>=0;--e)if(Math.floor(t.getTime()/wi[e].Md)!==Math.floor(s.getTime()/wi[e].Md))return wi[e].xd;return 0}function fs(s){let t=s;if(Ve(s)&&(t=ds(s)),!cs(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 ar(s){if(!nr(s))throw new Error("time must be of type isUTCTimestamp");return{Sd:s}}function ds(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 cr(s){Ve(s.time)&&(s.time=ds(s.time))}class ur{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?(function(e){e.forEach(cr)})(t):cr(t)}createConverterToInternalObj(t){return T((function(e){return e.length===0?null:cs(e[0].time)||Ve(e[0].time)?fs:ar})(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 nr(e=t)?ar(e):cs(e)?fs(e):fs(ds(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.yd=new Wh({fd:e,vd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",pd:" ",md:t.locale}):this.yd=new or(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,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.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(l,h)})(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(Ah,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,l=0;for(let h=n;h<i.length;++h){const a=i[h],c=new Date(1e3*a.time.Sd);o!==null&&(a.timeWeight=hr(c,o)),l+=a.time.Sd-(r||a.time.Sd),r=a.time.Sd,o=c}if(n===0&&i.length>1){const h=Math.ceil(l/(i.length-1)),a=new Date(1e3*(i[0].time.Sd-h));i[0].timeWeight=hr(new Date(1e3*i[0].time.Sd),a)}})(t,e)}static Cd(t){return Gt({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Be=typeof window<"u";function fr(){return!!Be&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function ps(){return!!Be&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ms(s){return s+s%2}function bs(s,t){return s.Td-t.Td}function gs(s,t,e){const i=(s.Td-t.Td)/(s.ut-t.ut);return Math.sign(i)*Math.min(Math.abs(i),e)}class Ih{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=gs(this.Pd,this.Rd,this.zd),r=bs(this.Pd,this.Rd),o=[n],l=[r];if(i+=r,this.Dd!==null){const a=gs(this.Rd,this.Dd,this.zd);if(Math.sign(a)===Math.sign(n)){const c=bs(this.Rd,this.Dd);if(o.push(a),l.push(c),i+=c,this.Od!==null){const u=gs(this.Dd,this.Od,this.zd);if(Math.sign(u)===Math.sign(n)){const p=bs(this.Dd,this.Od);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.Id||(this.Ad={Td:t,ut:e},this.Bd=h,this.Vd=(function(a,c){const u=Math.log(c);return Math.log(1*u/-a)/u})(Math.abs(h),this.Ed))}Yu(t){const e=T(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-T(this.Ad).ut;return Math.min(e,this.Vd)}}function _e(s,t){const e=T(s.ownerDocument).createElement("canvas");s.appendChild(e);const i=el(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 vs(s,t,e,i){s.G&&s.G(t,e,i)}function Si(s,t,e,i){s.K(t,e,i)}function ys(s,t,e,i){const n=s(e,i);for(const r of n){const o=r.xt();o!==null&&t(o)}}function qh(s){Be&&window.chrome!==void 0&&s.addEventListener("mousedown",(t=>{if(t.button===1)return t.preventDefault(),!1}))}class ws{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=!ps(),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(ee(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(ee(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=Ss(t.changedTouches,T(this.cf));if(e===null||(this.uf=xi(t),this.rf!==null)||this.af)return;this.lf=!0;const i=this.gf(ee(e),T(this.Kd)),{zf:n,Ef:r,wf:o}=i;if(this.Zd||!(o<5)){if(!this.Zd){const l=.5*n,h=r>=l&&!this.cn.Lf(),a=l>r&&!this.cn.Nf();h||a||(this.af=!0),this.Zd=!0,this.Jd=!0,this.Df(),this.kf()}if(!this.af){const l=this.bf(t,e);this.Mf(l,this.Sf.Ff),De(t)}}}Wf(t){if(t.button!==0)return;const e=this.gf(ee(t),T(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=Ss(t.changedTouches,T(this.cf));if(e===null&&t.touches.length===0&&(e=t.changedTouches[0]),e===null)return;this.cf=null,this.uf=xi(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(ee(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&&De(t));this.Hd===0&&De(t),t.touches.length===0&&this.Yd&&(this.Yd=!1,De(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),fr()&&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(ee(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=xi(t);const i=this.Pf.ownerDocument.documentElement;this.Jd=!1,this.Zd=!1,this.af=!1,this.Kd=ee(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=ee(e))}Gf(t){if(t.button!==0)return;const e=this.Pf.ownerDocument.documentElement;fr()&&e.addEventListener("mouseleave",this.ff),this.Gd=!1,this.Xd=ee(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=ee(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})}ps()&&(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}),qh(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=dr(t.touches[0],t.touches[1])/this.hf;this.Sf.sv(this.rf,e),De(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=dr(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=!ps()}Kf(t){const e=Ss(t.touches,T(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:xi(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"&&De(t)}}}}function dr(s,t){const e=s.clientX-t.clientX,i=s.clientY-t.clientY;return Math.sqrt(e*e+i*i)}function De(s){s.cancelable&&s.preventDefault()}function ee(s){return{et:s.pageX,rt:s.pageY}}function xi(s){return s.timeStamp||performance.now()}function Ss(s,t){for(let e=0;e<s.length;++e)if(s[e].identifier===t)return s[e];return null}function _i(s){return{Bc:s.Bc,vv:{wr:s.pv.externalId},mv:s.pv.cursorStyle}}function Hh(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 xs(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 pr{constructor(t,e,i,n){this.Li=null,this.bv=null,this.wv=!1,this.gv=new qe(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=xs("normal",n),this.Pv=xs("top",n),this.Rv=xs("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=_e(this.Dv,ft({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=_e(this.Dv,ft({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 l={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 ws(this.Av.canvasElement,l,{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=T(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 h=r.length;h--;){const a=this.gv.Si(i,r[h].Jt());a>t&&(t=a)}const o=this.Li.Pt();if(o!==null&&this.bv!==null){const h=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(h,a))+.11111111111111,o)),this.gv.Si(i,this.Li.Wi(Math.ceil(Math.max(h,a))-.11111111111111,o)))}i.restore();const l=t||34;return ms(Math.ceil(e.C+e.T+e.B+e.I+5+l))}qv(t){this.bv!==null&&we(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 T(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,T(this.At()))}Kv(t){if(this.bv===null)return;if(t!==1){this.Zv(),this.Ov.applySuggestedBitmapSize();const i=Se(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=Se(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(),l=r.ad();o===l?ai(t,0,0,i,n,o):wn(t,0,0,i,n,o,l)}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: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.Aa*h)-c,u,a);o.fill()})),t.useMediaCoordinateSpace((({context:o})=>{var l;o.font=this.$v(),o.fillStyle=(l=i.textColor)!==null&&l!==void 0?l:this.mo.textColor,o.textAlign=this.Cv?"right":"left",o.textBaseline="middle";const h=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,h,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((h=>{n.dr(h)&&i.push(h)}));const o=this.Li.Ta()[0],l=this.Li;i.forEach((h=>{const a=h.Rn(n,l);a.forEach((c=>{c.Vi(null),c.Bi()&&e.push(c)})),o===h&&a.length>0&&(t=a[0].yi())})),e.forEach((h=>h.Vi(h.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,l)=>l.yi()-o.yi())),n.length&&r.length&&r.push(n[0]),r.sort(((o,l)=>o.yi()-l.yi()));for(const o of t){const l=Math.floor(o.zt(e)/2),h=o.yi();h>-l&&h<l&&o.Vi(l),h>this.bv.height-l&&h<this.bv.height+l&&o.Vi(this.bv.height-l)}for(let o=1;o<n.length;o++){const l=n[o],h=n[o-1],a=h.zt(e,!1),c=l.yi(),u=h.Ai();c>u-a&&l.Vi(u-a)}for(let o=1;o<r.length;o++){const l=r[o],h=r[o-1],a=h.zt(e,!0),c=l.yi(),u=h.Ai();c<u+a&&l.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(T(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(),l=this.Cv?"right":"left";i.forEach((h=>{h.forEach((a=>{a.xt(T(this.Li)).K(t,o,this.gv,l)}))}))}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 Oe(this.mo.fontSize,this.mo.fontFamily)}}function $h(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 Ci(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 jh(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 Jh(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 _s{constructor(t,e){this.bv=ft({width:0,height:0}),this.hp=null,this.lp=null,this.ap=null,this.op=!1,this._p=new Ct,this.up=new Ct,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=_e(i,ft({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=_e(i,ft({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 ws(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 T(this.bp)}Cp(t){this.bp!==null&&this.bp.I_().p(this),this.bp=t,this.bp!==null&&this.bp.I_().l(_s.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(T(t))}if(this.lp!==null){const t=this.bp.k_();this.lp.Ji(T(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=T(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 l=n.No(),h=(function(a,c,u){var p,b;let d,f;for(const g of a){const x=(b=(p=g.oa)===null||p===void 0?void 0:p.call(g,c,u))!==null&&b!==void 0?b:[];for(const L of x)m=L.zOrder,(!(S=d?.zOrder)||m==="top"&&S!=="top"||m==="normal"&&S==="bottom")&&(d=L,f=g)}var m,S;return d&&f?{pv:d,Bc:f}:null})(l,r,o);if(h?.pv.zOrder==="top")return _i(h);for(const a of l){if(h&&h.Bc===a&&h.pv.zOrder!=="bottom"&&!h.pv.isBackground)return _i(h);const c=Hh(a.Pn(n),r,o);if(c!==null)return{Bc:a,dv:c.dv,vv:c.vv};if(h&&h.Bc===a&&h.pv.zOrder!=="bottom"&&h.pv.isBackground)return _i(h)}return h?.pv?_i(h):null})(i,t,e)}jp(t,e){T(e==="left"?this.hp:this.lp).qv(ft({width:t,height:this.bv.height}))}Hp(){return this.bv}qv(t){we(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=T(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=Se(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n)})),this.bp&&(this.Up(i,$h),this.qp(i),this.Yp(i),this.Up(i,Ci),this.Up(i,jh)))}this.Av.applySuggestedBitmapSize();const e=Se(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.Xp(e),this.Up(e,Jh))}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(),l=r.ad();o===l?ai(t,0,0,i,n,l):wn(t,0,0,i,n,o,l)}qp(t){const e=T(this.bp).z_().Wh().xt();e!==null&&e.K(t,!1)}Yp(t){const e=this.Ui().Lc();this.Gp(t,Ci,vs,e),this.Gp(t,Ci,Si,e)}Xp(t){this.Gp(t,Ci,Si,this.Ui().Nc())}Up(t,e){const i=T(this.bp).No();for(const n of i)this.Gp(t,e,vs,n);for(const n of i)this.Gp(t,e,Si,n)}Gp(t,e,i,n){const r=T(this.bp),o=r.qt().Ac(),l=o!==null&&o.Bc===n,h=o!==null&&l&&o.vv!==void 0?o.vv.gr:void 0;ys(e,(a=>i(a,t,l,h)),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 pr(this,t.W(),n,"left"),this.xp.appendChild(this.hp.Wv())),i&&this.lp===null&&(this.lp=new pr(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,T(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)T(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 l=this.bp.vn(),h=performance.now();if(this.ap!==null||this.Jp(t)||(this.ap={x:t.clientX,y:t.clientY,Sd:h,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 Ih(.2/a,7/a,.997,15/a),this.mp.Ld(i.zu(),this.ap.Sd)}else this.mp=null;l.Fi()||e.P_(this.bp,l,t.localY),e.qc(t.localX),this.op=!0}this.op&&(l.Fi()||e.R_(this.bp,l,t.localY),e.Yc(t.localX),this.mp!==null&&this.mp.Ld(i.zu(),h))}}class mr{constructor(t,e,i,n,r){this.bt=!0,this.bv=ft({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=_e(this.Dv,ft({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){we(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=Se(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),l=this.Cv?e.width-r:0;t.fillRect(l,0,r,o)}Gv({context:t,bitmapSize:e}){ai(t,0,0,e.width,e.height,this.rm())}}function Cs(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 Kh=Cs("normal"),Xh=Cs("top"),Yh=Cs("bottom");class Gh{constructor(t,e){this.hm=null,this.lm=null,this.k=null,this.am=!1,this.bv=ft({width:0,height:0}),this.om=new Ct,this.gv=new qe(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=_e(this.fm,ft({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=_e(this.fm,ft({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 ws(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){we(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(ft({width:e,height:t.height})),this.lm!==null&&this.lm.qv(ft({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=Se(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n),this.Be(n),this.km(i,Yh)})),this.Qv(i),this.km(i,Kh)),this.hm!==null&&this.hm.Kv(t),this.lm!==null&&this.lm.Kv(t)}this.Av.applySuggestedBitmapSize();const e=Se(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,Xh))}km(t,e){const i=this.wp.qt().Mt();for(const n of i)ys(e,(r=>vs(r,t,!1,void 0)),n,void 0);for(const n of i)ys(e,(r=>Si(r,t,!1,void 0)),n,void 0)}Gv({context:t,bitmapSize:e}){ai(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:l,horizontalPixelRatio:h,verticalPixelRatio:a})=>{l.strokeStyle=this.Cm(),l.fillStyle=this.Cm();const c=Math.max(1,Math.floor(h)),u=Math.floor(.5*h);l.beginPath();const p=Math.round(r.T*a);for(let b=i.length;b--;){const d=Math.round(i[b].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.$v();for(const a of i)if(a.weight<n){const c=a.needAlignCoordinate?this.Tm(l,a.coord,a.label):a.coord;l.fillText(a.label,c,h)}l.font=this.Pm();for(const a of i)if(a.weight>=n){const c=a.needAlignCoordinate?this.Tm(l,a.coord,a.label):a.coord;l.fillText(a.label,c,h)}}))}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 Oe(this.j(),this.cn.fontFamily)}Pm(){return Oe(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 qe,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 mr("left",e,i,n,r),this.um.appendChild(this.hm.Wv())),e.rightPriceScale.visible&&this.lm===null&&(this.lm=new mr("right",e,i,n,r),this.dm.appendChild(this.lm.Wv()))}}const Zh=!!Be&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((s=>s.brand.includes("Chromium")))&&!!Be&&(!((Ts=navigator?.userAgentData)===null||Ts===void 0)&&Ts.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);var Ts;class Qh{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 Ct,this.up=new Ct,this.gc=new Ct,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),Es(this.cn)&&this.Wm(!0),this.Ui=new Fh(this.xc.bind(this),this.cn,i),this.qt().Fc().l(this.jm.bind(this),this),this.Hm=new Gh(this,this.N_),this.Lm.appendChild(this.Hm.Wv());const r=e.autoSize&&this.$m();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.Um(o,l),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=[],T(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(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.Qa=n.height,this.e_=n.width;const r=this.Qa+"px",o=this.e_+"px";T(this._m).style.height=r,T(this._m).style.width=o,this.Lm.style.height=r,this.Lm.style.width=o,i?this.Gm(At.es(),performance.now()):this.Ui.$l()}Kv(t){t===void 0&&(t=At.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=Es(this.cn);this.Ui.Nh(t);const i=Es(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=T(e.getContext("2d"));return this.tb(i),e}ib(t){return t==="left"&&!this.nb()||t==="right"&&!this.sb()||this.Rm.length===0?0:T(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 Ut(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=(l,h)=>{let a=0;for(let c=0;c<this.Rm.length;c++){const u=this.Rm[c],p=T(l==="left"?u.Kp():u.Zp()),b=p.np();t!==null&&p.sp(t,h,a),a+=b.height}};this.nb()&&(r("left",0),e+=T(n.Kp()).np().width);for(let l=0;l<this.Rm.length;l++){const h=this.Rm[l],a=h.np();t!==null&&h.sp(t,e,i),i+=a.height}e+=n.np().width,this.sb()&&(r("right",e),e+=T(n.Zp()).np().width);const o=(l,h,a)=>{T(l==="left"?this.Hm.pm():this.Hm.bm()).sp(T(t),h,a)};if(this.cn.timeScale.visible){const l=this.Hm.np();if(t!==null){let h=0;this.nb()&&(o("left",h,i),h=T(n.Kp()).np().width),this.Hm.sp(t,h,i),h+=l.width,this.sb()&&o("right",h,i)}i+=l.height}return ft({width:e,height:i})}ab(){let t=0,e=0,i=0;for(const d of this.Rm)this.nb()&&(e=Math.max(e,T(d.Kp()).Hv(),this.cn.leftPriceScale.minimumWidth)),this.sb()&&(i=Math.max(i,T(d.Zp()).Hv(),this.cn.rightPriceScale.minimumWidth)),t+=d.v_();e=ms(e),i=ms(i);const n=this.e_,r=this.Qa,o=Math.max(n-e-i,0),l=this.cn.timeScale.visible;let h=l?Math.max(this.Hm.Mm(),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 b=0;for(let d=0;d<this.Rm.length;++d){const f=this.Rm[d];f.Cp(this.Ui.Ec()[d]);let m=0,S=0;S=d===this.Rm.length-1?u-b:Math.round(f.v_()*p),m=Math.max(S,2),b+=m,f.qv(ft({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(ft({width:l?o:0,height:h}),l?e:0,l?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 Zh?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=Ut(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 _s(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 l=this.qt().Ac(),h=l!==null&&l.Bc instanceof os?l.Bc:void 0,a=l!==null&&l.vv!==void 0?l.vv.wr:void 0;return{mb:o,se:t??void 0,bb:e??void 0,wb:h,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 Es(s){return!!(s.handleScroll.mouseWheel||s.handleScale.mouseWheel)}function br(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={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.color!==void 0&&(r.O=e.color),r}function ta(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 ea(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 ia(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 sa(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 na(s,t,e,i,n){const r=Ut(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{se:t,ut:s,Vt:a,mb:i,He:br(c,["time","color"]),O:p}}function Ti(s){return s.Vt!==void 0}function vr(s,t){return t.customValues!==void 0&&(s.Sb=t.customValues),s}function Ce(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)?vr({ut:t,se:e,mb:n},i):vr(s(t,e,i,n,r),i)}function yr(s){return{Candlestick:Ce(sa),Bar:Ce(ia),Area:Ce(ta),Baseline:Ce(ea),Histogram:Ce(gr),Line:Ce(gr),Custom:Ce(na)}[s]}function wr(s){return{se:0,kb:new Map,ia:s}}function Sr(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 xr(s){let t;return s.forEach((e=>{t===void 0&&(t=e.mb)})),Ut(t)}class ra{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 h of this.Db)h.pointData.kb.delete(t)&&(n=!0);let o=[];if(e.length!==0){const h=e.map((b=>b.time)),a=this.N_.createConverterToInternalObj(e),c=yr(t.Xh()),u=t.ga(),p=t.Ma();o=e.map(((b,d)=>{const f=a(b.time),m=this.N_.key(f);let S=this.Tb.get(m);S===void 0&&(S=wr(f),this.Tb.set(m,S),n=!0);const g=c(f,S.se,b,h[d],u,p);return S.kb.set(t,g),g}))}i&&this.Ab(),this.Vb(t,o);let l=-1;if(n){const h=[];this.Tb.forEach((a=>{h.push({timeWeight:0,time:a.ia,pointData:a,originalTime:xr(a.kb)})})),h.sort(((a,c)=>this.N_.key(a.time)-this.N_.key(c.time))),l=this.Bb(h)}return this.Ib(t,l,(function(h,a,c){const u=Sr(h,c),p=Sr(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 l=o===void 0;o===void 0&&(o=wr(n),this.Tb.set(this.N_.key(n),o));const h=yr(t.Xh()),a=t.ga(),c=t.Ma(),u=h(n,o.se,e,i.mb,a,c);o.kb.set(t,u),this.Eb(t,u);const p={Xl:Ti(u)};if(!l)return this.Ib(t,-1,p);const b={timeWeight:0,time:o.ia,pointData:o,originalTime:xr(o.kb)},d=Ie(this.Db,this.N_.key(b.time),((f,m)=>this.N_.key(f.time)<m));this.Db.splice(d,0,b);for(let f=d;f<this.Db.length;++f)Ls(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)?Ti(e)&&i.push(e):Ti(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(Ti)),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,Ls(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)Ls(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 Ls(s,t){s.se=t,s.kb.forEach((e=>{e.se=t}))}function Ms(s){const t={value:s.Vt[3],time:s.mb};return s.Sb!==void 0&&(t.customValues=s.Sb),t}function _r(s){const t=Ms(s);return s.O!==void 0&&(t.color=s.O),t}function oa(s){const t=Ms(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 la(s){const t=Ms(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 Cr(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 ha(s){const t=Cr(s);return s.O!==void 0&&(t.color=s.O),t}function aa(s){const t=Cr(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 ks(s){return{Area:oa,Line:_r,Baseline:la,Histogram:_r,Bar:ha,Candlestick:aa,Custom:ca}[s]}function ca(s){const t=s.mb;return Object.assign(Object.assign({},s.He),{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:ji},Os={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,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0},ma={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:ji,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function Tr(){return{width:0,height:0,autoSize:!1,layout:da,crosshair:ua,grid:fa,overlayPriceScales:Object.assign({},Os),leftPriceScale:Object.assign(Object.assign({},Os),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Os),{visible:!0}),timeScale:pa,watermark:ma,localization:{locale:Be?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 ba{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 ui(this.$b)?this.Hb.ib(this.$b):0}Li(){return T(this.Hb.qt().zc(this.$b)).At}}function Er(s,t,e){const i=br(s,["time","originalTime"]),n=Object.assign({time:t},i);return e!==void 0&&(n.originalTime=e),n}const ga={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class va{constructor(t){this.Bh=t}applyOptions(t){this.Bh.Nh(t)}options(){return this.Bh.W()}Ub(){return this.Bh}}class ya{constructor(t,e,i,n,r){this.qb=new Ct,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 Ae(new Xe(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=T(i.Qh()),l=T(i.Bn());if(n!==null&&r!==null&&n.se>r.se)return{barsBefore:t.from-o,barsAfter:l-t.to};const h={barsBefore:n===null||n.se===o?t.from-o:n.se-o,barsAfter:r===null||r.se===l?l-t.to:l-r.se};return n!==null&&r!==null&&(h.from=n.mb,h.to=r.mb),h}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:ks(this.seriesType())(i)}data(){const t=ks(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=>Er(i,this.N_.convertHorzItemToInternal(i.time),i.time)));this.Es.Zl(e)}markers(){return this.Es.Gl().map((t=>Er(t,t.originalTime,void 0)))}applyOptions(t){this.Es.Nh(t)}options(){return de(this.Es.W())}priceScale(){return this.Xb.priceScale(this.Es.At().xa())}createPriceLine(t){const e=Gt(de(ga),t),i=this.Es.Jl(e);return new va(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 wa{constructor(t,e,i){this.Qb=new Ct,this.uu=new Ct,this.om=new Ct,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){be(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({},de(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 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 Lr(s){return(function(t){if(hi(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;hi(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),hi(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const e=t.handleScroll;hi(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})})(s),s}class xa{constructor(t,e,i){this.sw=new Map,this.ew=new Map,this.rw=new Ct,this.hw=new Ct,this.lw=new Ct,this.aw=new ra(e);const n=i===void 0?de(Tr()):Gt(de(Tr()),Lr(i));this.N_=e,this.Hb=new Qh(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 wa(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=ke(t),n=Object.assign(Object.assign({},un),i.defaultOptions());return this.uw("Custom",n,e,i)}addAreaSeries(t){return this.uw("Area",hl,t)}addBaselineSeries(t){return this.uw("Baseline",al,t)}addBarSeries(t){return this.uw("Bar",ol,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",rl,t)}addHistogramSeries(t){return this.uw("Histogram",cl,t)}addLineSeries(t){return this.uw("Line",ll,t)}removeSeries(t){const e=Ut(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 ba(this.Hb,t)}timeScale(){return this._w}applyOptions(t){this.Hb.Nh(Lr(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){Sa(i.priceFormat);const r=Gt(de(fn),de(e),i),o=this.Hb.qt().sd(t,r,n),l=new ya(o,this,this,this,this.N_);return this.sw.set(l,o),this.ew.set(o,l),l}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 Ut(this.ew.get(t))}ow(t){const e=new Map;t.gb.forEach(((n,r)=>{const o=r.Xh(),l=ks(o)(n);if(o!=="Custom")be((function(h){return h.open!==void 0||h.value!==void 0})(l));else{const h=r.Ma();be(!h||h(l)===!1)}e.set(this.dw(r),l)}));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 _a(s,t,e){let i;if(Ve(s)){const r=document.getElementById(s);be(r!==null,`Cannot find element in DOM with id=${s}`),i=r}else i=s;const n=new xa(i,t,e);return t.setOptions(n.options()),n}function Ca(s,t){return _a(s,new ur,ur.Cd(t))}Object.assign(Object.assign({},fn),un);function Mr(s,t){return function(){return s.apply(t,arguments)}}const{toString:Ta}=Object.prototype,{getPrototypeOf:Ps}=Object,{iterator:Ei,toStringTag:kr}=Symbol,Li=(s=>t=>{const e=Ta.call(t);return s[e]||(s[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),Zt=s=>(s=s.toLowerCase(),t=>Li(t)===s),Mi=s=>t=>typeof t===s,{isArray:Ne}=Array,Re=Mi("undefined");function Ye(s){return s!==null&&!Re(s)&&s.constructor!==null&&!Re(s.constructor)&&It(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const Or=Zt("ArrayBuffer");function Ea(s){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(s):t=s&&s.buffer&&Or(s.buffer),t}const La=Mi("string"),It=Mi("function"),Pr=Mi("number"),Ge=s=>s!==null&&typeof s=="object",Ma=s=>s===!0||s===!1,ki=s=>{if(Li(s)!=="object")return!1;const t=Ps(s);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kr in s)&&!(Ei in s)},ka=s=>{if(!Ge(s)||Ye(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},Oa=Zt("Date"),Pa=Zt("File"),Aa=Zt("Blob"),Ba=Zt("FileList"),Da=s=>Ge(s)&&It(s.pipe),Na=s=>{let t;return s&&(typeof FormData=="function"&&s instanceof FormData||It(s.append)&&((t=Li(s))==="formdata"||t==="object"&&It(s.toString)&&s.toString()==="[object FormData]"))},Ra=Zt("URLSearchParams"),[Fa,za,Ua,Va]=["ReadableStream","Request","Response","Headers"].map(Zt),Wa=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ze(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(Ye(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 Ar(s,t){if(Ye(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 Te=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Br=s=>!Re(s)&&s!==Te;function As(){const{caseless:s,skipUndefined:t}=Br(this)&&this||{},e={},i=(n,r)=>{const o=s&&Ar(e,r)||r;ki(e[o])&&ki(n)?e[o]=As(e[o],n):ki(n)?e[o]=As({},n):Ne(n)?e[o]=n.slice():(!t||!Re(n))&&(e[o]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&Ze(arguments[n],i);return e}const Ia=(s,t,e,{allOwnKeys:i}={})=>(Ze(t,(n,r)=>{e&&It(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),qa=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),Ha=(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)},$a=(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&&Ps(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},Ja=s=>{if(!s)return null;if(Ne(s))return s;let t=s.length;if(!Pr(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=s[t];return e},Ka=(s=>t=>s&&t instanceof s)(typeof Uint8Array<"u"&&Ps(Uint8Array)),Xa=(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])}},Ya=(s,t)=>{let e;const i=[];for(;(e=s.exec(t))!==null;)i.push(e);return i},Ga=Zt("HTMLFormElement"),Za=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,n){return i.toUpperCase()+n}),Dr=(({hasOwnProperty:s})=>(t,e)=>s.call(t,e))(Object.prototype),Qa=Zt("RegExp"),Nr=(s,t)=>{const e=Object.getOwnPropertyDescriptors(s),i={};Ze(e,(n,r)=>{let o;(o=t(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},tc=s=>{Nr(s,(t,e)=>{if(It(s)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=s[e];if(It(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&&It(s.append)&&s[kr]==="FormData"&&s[Ei])}const rc=s=>{const t=new Array(10),e=(i,n)=>{if(Ge(i)){if(t.indexOf(i)>=0)return;if(Ye(i))return i;if(!("toJSON"in i)){t[n]=i;const r=Ne(i)?[]:{};return Ze(i,(o,l)=>{const h=e(o,n+1);!Re(h)&&(r[l]=h)}),t[n]=void 0,r}}return i};return e(s,0)},oc=Zt("AsyncFunction"),lc=s=>s&&(Ge(s)||It(s))&&It(s.then)&&It(s.catch),Rr=((s,t)=>s?setImmediate:t?((e,i)=>(Te.addEventListener("message",({source:n,data:r})=>{n===Te&&r===e&&i.length&&i.shift()()},!1),n=>{i.push(n),Te.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",It(Te.postMessage)),hc=typeof queueMicrotask<"u"?queueMicrotask.bind(Te):typeof process<"u"&&process.nextTick||Rr,y={isArray:Ne,isArrayBuffer:Or,isBuffer:Ye,isFormData:Na,isArrayBufferView:Ea,isString:La,isNumber:Pr,isBoolean:Ma,isObject:Ge,isPlainObject:ki,isEmptyObject:ka,isReadableStream:Fa,isRequest:za,isResponse:Ua,isHeaders:Va,isUndefined:Re,isDate:Oa,isFile:Pa,isBlob:Aa,isRegExp:Qa,isFunction:It,isStream:Da,isURLSearchParams:Ra,isTypedArray:Ka,isFileList:Ba,forEach:Ze,merge:As,extend:Ia,trim:Wa,stripBOM:qa,inherits:Ha,toFlatObject:$a,kindOf:Li,kindOfTest:Zt,endsWith:ja,toArray:Ja,forEachEntry:Xa,matchAll:Ya,isHTMLForm:Ga,hasOwnProperty:Dr,hasOwnProp:Dr,reduceDescriptors:Nr,freezeMethods:tc,toObjectSet:ec,toCamelCase:Za,noop:ic,toFiniteNumber:sc,findKey:Ar,global:Te,isContextDefined:Br,isSpecCompliantForm:nc,toJSONObject:rc,isAsyncFn:oc,isThenable:lc,setImmediate:Rr,asap:hc,isIterable:s=>s!=null&&It(s[Ei])};let z=class Yo extends Error{static from(t,e,i,n,r,o){const l=new Yo(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:y.toJSONObject(this.config),code:this.code,status:this.status}}};z.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",z.ERR_BAD_OPTION="ERR_BAD_OPTION",z.ECONNABORTED="ECONNABORTED",z.ETIMEDOUT="ETIMEDOUT",z.ERR_NETWORK="ERR_NETWORK",z.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",z.ERR_DEPRECATED="ERR_DEPRECATED",z.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",z.ERR_BAD_REQUEST="ERR_BAD_REQUEST",z.ERR_CANCELED="ERR_CANCELED",z.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",z.ERR_INVALID_URL="ERR_INVALID_URL";const ac=null;function Bs(s){return y.isPlainObject(s)||y.isArray(s)}function Fr(s){return y.endsWith(s,"[]")?s.slice(0,-2):s}function zr(s,t,e){return s?s.concat(t).map(function(n,r){return n=Fr(n),!e&&r?"["+n+"]":n}).join(e?".":""):t}function cc(s){return y.isArray(s)&&!s.some(Bs)}const uc=y.toFlatObject(y,{},null,function(t){return/^is[A-Z]/.test(t)});function Oi(s,t,e){if(!y.isObject(s))throw new TypeError("target must be an object");t=t||new FormData,e=y.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,m){return!y.isUndefined(m[f])});const i=e.metaTokens,n=e.visitor||c,r=e.dots,o=e.indexes,h=(e.Blob||typeof Blob<"u"&&Blob)&&y.isSpecCompliantForm(t);if(!y.isFunction(n))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(y.isDate(d))return d.toISOString();if(y.isBoolean(d))return d.toString();if(!h&&y.isBlob(d))throw new z("Blob is not supported. Use a Buffer instead.");return y.isArrayBuffer(d)||y.isTypedArray(d)?h&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,f,m){let S=d;if(d&&!m&&typeof d=="object"){if(y.endsWith(f,"{}"))f=i?f:f.slice(0,-2),d=JSON.stringify(d);else if(y.isArray(d)&&cc(d)||(y.isFileList(d)||y.endsWith(f,"[]"))&&(S=y.toArray(d)))return f=Fr(f),S.forEach(function(x,L){!(y.isUndefined(x)||x===null)&&t.append(o===!0?zr([f],L,r):o===null?f:f+"[]",a(x))}),!1}return Bs(d)?!0:(t.append(zr(m,f,r),a(d)),!1)}const u=[],p=Object.assign(uc,{defaultVisitor:c,convertValue:a,isVisitable:Bs});function b(d,f){if(!y.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(d),y.forEach(d,function(S,g){(!(y.isUndefined(S)||S===null)&&n.call(t,S,y.isString(g)?g.trim():g,f,p))===!0&&b(S,f?f.concat(g):[g])}),u.pop()}}if(!y.isObject(s))throw new TypeError("data must be an object");return b(s),t}function Ur(s){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Ds(s,t){this._pairs=[],s&&Oi(s,this,t)}const Vr=Ds.prototype;Vr.append=function(t,e){this._pairs.push([t,e])},Vr.toString=function(t){const e=t?function(i){return t.call(this,i,Ur)}:Ur;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 Wr(s,t,e){if(!t)return s;const i=e&&e.encode||fc,n=y.isFunction(e)?{serialize:e}:e,r=n&&n.serialize;let o;if(r?o=r(t,n):o=y.isURLSearchParams(t)?t.toString():new Ds(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){y.forEach(this.handlers,function(i){i!==null&&t(i)})}}const qr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dc={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ds,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ns=typeof window<"u"&&typeof document<"u",Rs=typeof navigator=="object"&&navigator||void 0,pc=Ns&&(!Rs||["ReactNative","NativeScript","NS"].indexOf(Rs.product)<0),mc=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bc=Ns&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ns,hasStandardBrowserEnv:pc,hasStandardBrowserWebWorkerEnv:mc,navigator:Rs,origin:bc},Symbol.toStringTag,{value:"Module"})),...dc};function gc(s,t){return Oi(s,new Nt.classes.URLSearchParams,{visitor:function(e,i,n,r){return Nt.isNode&&y.isBuffer(e)?(this.append(i,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}function vc(s){return y.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 Hr(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&&y.isArray(n)?n.length:o,h?(y.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!l):((!n[o]||!y.isObject(n[o]))&&(n[o]=[]),t(e,i,n[o],r)&&y.isArray(n[o])&&(n[o]=yc(n[o])),!l)}if(y.isFormData(s)&&y.isFunction(s.entries)){const e={};return y.forEachEntry(s,(i,n)=>{t(vc(i),n,e,0)}),e}return null}function wc(s,t,e){if(y.isString(s))try{return(t||JSON.parse)(s),y.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(s)}const Qe={transitional:qr,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",n=i.indexOf("application/json")>-1,r=y.isObject(t);if(r&&y.isHTMLForm(t)&&(t=new FormData(t)),y.isFormData(t))return n?JSON.stringify(Hr(t)):t;if(y.isArrayBuffer(t)||y.isBuffer(t)||y.isStream(t)||y.isFile(t)||y.isBlob(t)||y.isReadableStream(t))return t;if(y.isArrayBufferView(t))return t.buffer;if(y.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 gc(t,this.formSerializer).toString();if((l=y.isFileList(t))||i.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Oi(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||Qe.transitional,i=e&&e.forcedJSONParsing,n=this.responseType==="json";if(y.isResponse(t)||y.isReadableStream(t))return t;if(t&&y.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"?z.from(l,z.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}}};y.forEach(["delete","get","head","post","put","patch"],s=>{Qe.headers[s]={}});const Sc=y.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"]),xc=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},$r=Symbol("internals");function ti(s){return s&&String(s).trim().toLowerCase()}function Pi(s){return s===!1||s==null?s:y.isArray(s)?s.map(Pi):String(s)}function _c(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 Fs(s,t,e,i,n){if(y.isFunction(i))return i.call(this,t,e);if(n&&(t=e),!!y.isString(t)){if(y.isString(i))return t.indexOf(i)!==-1;if(y.isRegExp(i))return i.test(t)}}function Tc(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function Ec(s,t){const e=y.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 qt=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=y.findKey(n,c);(!u||n[u]===void 0||a===!0||a===void 0&&n[u]!==!1)&&(n[u||h]=Pi(l))}const o=(l,h)=>y.forEach(l,(a,c)=>r(a,c,h));if(y.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(y.isString(t)&&(t=t.trim())&&!Cc(t))o(xc(t),e);else if(y.isObject(t)&&y.isIterable(t)){let l={},h,a;for(const c of t){if(!y.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[a=c[0]]=(h=l[a])?y.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=y.findKey(this,t);if(i){const n=this[i];if(!e)return n;if(e===!0)return _c(n);if(y.isFunction(e))return e.call(this,n,i);if(y.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=y.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Fs(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=y.findKey(i,o);l&&(!e||Fs(i,i[l],l,e))&&(delete i[l],n=!0)}}return y.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||Fs(this,this[r],r,t,!0))&&(delete this[r],n=!0)}return n}normalize(t){const e=this,i={};return y.forEach(this,(n,r)=>{const o=y.findKey(i,r);if(o){e[o]=Pi(n),delete e[r];return}const l=t?Tc(r):String(r).trim();l!==r&&delete e[r],e[l]=Pi(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return y.forEach(this,(i,n)=>{i!=null&&i!==!1&&(e[n]=t&&y.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[$r]=this[$r]={accessors:{}}).accessors,n=this.prototype;function r(o){const l=ti(o);i[l]||(Ec(n,o),i[l]=!0)}return y.isArray(t)?t.forEach(r):r(t),this}};qt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),y.reduceDescriptors(qt.prototype,({value:s},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>s,set(i){this[e]=i}}}),y.freezeMethods(qt);function zs(s,t){const e=this||Qe,i=t||e,n=qt.from(i.headers);let r=i.data;return y.forEach(s,function(l){r=l.call(e,r,n.normalize(),t?t.status:void 0)}),n.normalize(),r}function jr(s){return!!(s&&s.__CANCEL__)}let ei=class extends z{constructor(t,e,i){super(t??"canceled",z.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function Jr(s,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?s(e):t(new z("Request failed with status code "+e.status,[z.ERR_BAD_REQUEST,z.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function Lc(s){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return t&&t[1]||""}function Mc(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 b=c&&a-c;return b?Math.round(p*1e3/b):void 0}}function kc(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 Ai=(s,t,e=3)=>{let i=0;const n=Mc(50,250);return kc(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)},Kr=(s,t)=>{const e=s!=null;return[i=>t[0]({lengthComputable:e,total:s,loaded:i}),t[1]]},Xr=s=>(...t)=>y.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,Pc=Nt.hasStandardBrowserEnv?{write(s,t,e,i,n,r,o){if(typeof document>"u")return;const l=[`${s}=${encodeURIComponent(t)}`];y.isNumber(e)&&l.push(`expires=${new Date(e).toUTCString()}`),y.isString(i)&&l.push(`path=${i}`),y.isString(n)&&l.push(`domain=${n}`),r===!0&&l.push("secure"),y.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 Ac(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Bc(s,t){return t?s.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):s}function Yr(s,t,e){let i=!Ac(t);return s&&(i||e==!1)?Bc(s,t):t}const Gr=s=>s instanceof qt?{...s}:s;function Ee(s,t){t=t||{};const e={};function i(a,c,u,p){return y.isPlainObject(a)&&y.isPlainObject(c)?y.merge.call({caseless:p},a,c):y.isPlainObject(c)?y.merge({},c):y.isArray(c)?c.slice():c}function n(a,c,u,p){if(y.isUndefined(c)){if(!y.isUndefined(a))return i(void 0,a,u,p)}else return i(a,c,u,p)}function r(a,c){if(!y.isUndefined(c))return i(void 0,c)}function o(a,c){if(y.isUndefined(c)){if(!y.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(Gr(a),Gr(c),u,!0)};return y.forEach(Object.keys({...s,...t}),function(c){const u=h[c]||n,p=u(s[c],t[c],c);y.isUndefined(p)&&u!==l||(e[c]=p)}),e}const Zr=s=>{const t=Ee({},s);let{data:e,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:l}=t;if(t.headers=o=qt.from(o),t.url=Wr(Yr(t.baseURL,t.url,t.allowAbsoluteUrls),s.params,s.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),y.isFormData(e)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(y.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&&y.isFunction(i)&&(i=i(t)),i||i!==!1&&Oc(t.url))){const h=n&&r&&Pc.read(r);h&&o.set(n,h)}return t},Dc=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(e,i){const n=Zr(s);let r=n.data;const o=qt.from(n.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:a}=n,c,u,p,b,d;function f(){b&&b(),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 S(){if(!m)return;const x=qt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),A={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:x,config:s,request:m};Jr(function(F){e(F),f()},function(F){i(F),f()},A),m=null}"onloadend"in m?m.onloadend=S:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(S)},m.onabort=function(){m&&(i(new z("Request aborted",z.ECONNABORTED,s,m)),m=null)},m.onerror=function(L){const A=L&&L.message?L.message:"Network Error",J=new z(A,z.ERR_NETWORK,s,m);J.event=L||null,i(J),m=null},m.ontimeout=function(){let L=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const A=n.transitional||qr;n.timeoutErrorMessage&&(L=n.timeoutErrorMessage),i(new z(L,A.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,s,m)),m=null},r===void 0&&o.setContentType(null),"setRequestHeader"in m&&y.forEach(o.toJSON(),function(L,A){m.setRequestHeader(A,L)}),y.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&l!=="json"&&(m.responseType=n.responseType),a&&([p,d]=Ai(a,!0),m.addEventListener("progress",p)),h&&m.upload&&([u,b]=Ai(h),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",b)),(n.cancelToken||n.signal)&&(c=x=>{m&&(i(!x||x.type?new ei(null,s,m):x),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const g=Lc(n.url);if(g&&Nt.protocols.indexOf(g)===-1){i(new z("Unsupported protocol "+g+":",z.ERR_BAD_REQUEST,s));return}m.send(r||null)})},Nc=(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 z?c:new ei(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new z(`timeout of ${t}ms exceeded`,z.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=()=>y.asap(l),h}},Rc=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},Fc=async function*(s,t){for await(const e of zc(s))yield*Rc(e,t)},zc=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=Fc(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})},to=64*1024,{isFunction:Bi}=y,Uc=(({Request:s,Response:t})=>({Request:s,Response:t}))(y.global),{ReadableStream:eo,TextEncoder:io}=y.global,so=(s,...t)=>{try{return!!s(...t)}catch{return!1}},Vc=s=>{s=y.merge.call({skipUndefined:!0},Uc,s);const{fetch:t,Request:e,Response:i}=s,n=t?Bi(t):typeof fetch=="function",r=Bi(e),o=Bi(i);if(!n)return!1;const l=n&&Bi(eo),h=n&&(typeof io=="function"?(d=>f=>d.encode(f))(new io):async d=>new Uint8Array(await new e(d).arrayBuffer())),a=r&&l&&so(()=>{let d=!1;const f=new e(Nt.origin,{body:new eo,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!f}),c=o&&l&&so(()=>y.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 S=f&&f[d];if(S)return S.call(f);throw new z(`Response type '${d}' is not supported`,z.ERR_NOT_SUPPORT,m)})});const p=async d=>{if(d==null)return 0;if(y.isBlob(d))return d.size;if(y.isSpecCompliantForm(d))return(await new e(Nt.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(y.isArrayBufferView(d)||y.isArrayBuffer(d))return d.byteLength;if(y.isURLSearchParams(d)&&(d=d+""),y.isString(d))return(await h(d)).byteLength},b=async(d,f)=>{const m=y.toFiniteNumber(d.getContentLength());return m??p(f)};return async d=>{let{url:f,method:m,data:S,signal:g,cancelToken:x,timeout:L,onDownloadProgress:A,onUploadProgress:J,responseType:F,headers:Y,withCredentials:Q="same-origin",fetchOptions:Tt}=Zr(d),V=t||fetch;F=F?(F+"").toLowerCase():"text";let at=Nc([g,x&&x.toAbortSignal()],L),Bt=null;const vt=at&&at.unsubscribe&&(()=>{at.unsubscribe()});let lt;try{if(J&&a&&m!=="get"&&m!=="head"&&(lt=await b(Y,S))!==0){let xt=new e(f,{method:"POST",body:S,duplex:"half"}),st;if(y.isFormData(S)&&(st=xt.headers.get("content-type"))&&Y.setContentType(st),xt.body){const[dt,Lt]=Kr(lt,Ai(Xr(J)));S=Qr(xt.body,to,dt,Lt)}}y.isString(Q)||(Q=Q?"include":"omit");const ct=r&&"credentials"in e.prototype,ut={...Tt,signal:at,method:m.toUpperCase(),headers:Y.normalize().toJSON(),body:S,duplex:"half",credentials:ct?Q:void 0};Bt=r&&new e(f,ut);let Dt=await(r?V(Bt,Tt):V(f,ut));const Et=c&&(F==="stream"||F==="response");if(c&&(A||Et&&vt)){const xt={};["status","statusText","headers"].forEach(_t=>{xt[_t]=Dt[_t]});const st=y.toFiniteNumber(Dt.headers.get("content-length")),[dt,Lt]=A&&Kr(st,Ai(Xr(A),!0))||[];Dt=new i(Qr(Dt.body,to,dt,()=>{Lt&&Lt(),vt&&vt()}),xt)}F=F||"text";let St=await u[y.findKey(u,F)||"text"](Dt,d);return!Et&&vt&&vt(),await new Promise((xt,st)=>{Jr(xt,st,{data:St,headers:qt.from(Dt.headers),status:Dt.status,statusText:Dt.statusText,config:d,request:Bt})})}catch(ct){throw vt&&vt(),ct&&ct.name==="TypeError"&&/Load failed|fetch/i.test(ct.message)?Object.assign(new z("Network Error",z.ERR_NETWORK,d,Bt),{cause:ct.cause||ct}):z.from(ct,ct&&ct.code,d,Bt)}}},Wc=new Map,no=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=Wc;for(;l--;)h=r[l],a=c.get(h),a===void 0&&c.set(h,a=l?new Map:Vc(t)),c=a;return a};no();const Us={http:ac,xhr:Dc,fetch:{get:no}};y.forEach(Us,(s,t)=>{if(s){try{Object.defineProperty(s,"name",{value:t})}catch{}Object.defineProperty(s,"adapterName",{value:t})}});const ro=s=>`- ${s}`,Ic=s=>y.isFunction(s)||s===null||s===!1;function qc(s,t){s=y.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,!Ic(i)&&(n=Us[(l=String(i)).toLowerCase()],n===void 0))throw new z(`Unknown adapter '${l}'`);if(n&&(y.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(ro).join(`
5
- `):" "+ro(o[0]):"as no adapter specified";throw new z("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return n}const oo={getAdapter:qc,adapters:Us};function Vs(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new ei(null,s)}function lo(s){return Vs(s),s.headers=qt.from(s.headers),s.data=zs.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),oo.getAdapter(s.adapter||Qe.adapter,s)(s).then(function(i){return Vs(s),i.data=zs.call(s,s.transformResponse,i),i.headers=qt.from(i.headers),i},function(i){return jr(i)||(Vs(s),i&&i.response&&(i.response.data=zs.call(s,s.transformResponse,i.response),i.response.headers=qt.from(i.response.headers))),Promise.reject(i)})}const ho="1.13.4",Di={};["object","boolean","number","function","string","symbol"].forEach((s,t)=>{Di[s]=function(i){return typeof i===s||"a"+(t<1?"n ":" ")+s}});const ao={};Di.transitional=function(t,e,i){function n(r,o){return"[Axios v"+ho+"] Transitional option '"+r+"'"+o+(i?". "+i:"")}return(r,o,l)=>{if(t===!1)throw new z(n(o," has been removed"+(e?" in "+e:"")),z.ERR_DEPRECATED);return e&&!ao[o]&&(ao[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}},Di.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Hc(s,t,e){if(typeof s!="object")throw new z("options must be an object",z.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 z("option "+r+" must be "+h,z.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new z("Unknown option "+r,z.ERR_BAD_OPTION)}}const Ni={assertOptions:Hc,validators:Di},ie=Ni.validators;let Le=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=Ee(this.defaults,e);const{transitional:i,paramsSerializer:n,headers:r}=e;i!==void 0&&Ni.assertOptions(i,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),n!=null&&(y.isFunction(n)?e.paramsSerializer={serialize:n}:Ni.assertOptions(n,{encode:ie.function,serialize:ie.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Ni.assertOptions(e,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=r&&y.merge(r.common,r[e.method]);r&&y.forEach(["delete","get","head","post","put","patch","common"],d=>{delete r[d]}),e.headers=qt.concat(o,r);const l=[];let h=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(h=h&&f.synchronous,l.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(!h){const d=[lo.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 b=e;for(;u<p;){const d=l[u++],f=l[u++];try{b=d(b)}catch(m){f.call(this,m);break}}try{c=lo.call(this,b)}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=Ee(this.defaults,t);const e=Yr(t.baseURL,t.url,t.allowAbsoluteUrls);return Wr(e,t.params,t.paramsSerializer)}};y.forEach(["delete","get","head","options"],function(t){Le.prototype[t]=function(e,i){return this.request(Ee(i||{},{method:t,url:e,data:(i||{}).data}))}}),y.forEach(["post","put","patch"],function(t){function e(i){return function(r,o,l){return this.request(Ee(l||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}Le.prototype[t]=e(),Le.prototype[t+"Form"]=e(!0)});let $c=class Go{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 Go(function(n){t=n}),cancel:t}}};function jc(s){return function(e){return s.apply(null,e)}}function Jc(s){return y.isObject(s)&&s.isAxiosError===!0}const Ws={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(Ws).forEach(([s,t])=>{Ws[t]=s});function co(s){const t=new Le(s),e=Mr(Le.prototype.request,t);return y.extend(e,Le.prototype,t,{allOwnKeys:!0}),y.extend(e,t,null,{allOwnKeys:!0}),e.create=function(n){return co(Ee(s,n))},e}const bt=co(Qe);bt.Axios=Le,bt.CanceledError=ei,bt.CancelToken=$c,bt.isCancel=jr,bt.VERSION=ho,bt.toFormData=Oi,bt.AxiosError=z,bt.Cancel=bt.CanceledError,bt.all=function(t){return Promise.all(t)},bt.spread=jc,bt.isAxiosError=Jc,bt.mergeConfig=Ee,bt.AxiosHeaders=qt,bt.formToJSON=s=>Hr(y.isHTMLForm(s)?new FormData(s):s),bt.getAdapter=oo.getAdapter,bt.HttpStatusCode=Ws,bt.default=bt;const{Axios:Sf,AxiosError:xf,CanceledError:_f,isCancel:Cf,CancelToken:Tf,VERSION:Ef,all:Lf,Cancel:Mf,isAxiosError:kf,spread:Of,toFormData:Pf,AxiosHeaders:Af,HttpStatusCode:Bf,formToJSON:Df,getAdapter:Nf,mergeConfig:Rf}=bt,se=Object.create(null);se.open="0",se.close="1",se.ping="2",se.pong="3",se.message="4",se.upgrade="5",se.noop="6";const Ri=Object.create(null);Object.keys(se).forEach(s=>{Ri[se[s]]=s});const Is={type:"error",data:"parser error"},uo=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",fo=typeof ArrayBuffer=="function",po=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,qs=({type:s,data:t},e,i)=>uo&&t instanceof Blob?e?i(t):mo(t,i):fo&&(t instanceof ArrayBuffer||po(t))?e?i(t):mo(new Blob([t]),i):i(se[s]+(t||"")),mo=(s,t)=>{const e=new FileReader;return e.onload=function(){const i=e.result.split(",")[1];t("b"+(i||""))},e.readAsDataURL(s)};function bo(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Hs;function Kc(s,t){if(uo&&s.data instanceof Blob)return s.data.arrayBuffer().then(bo).then(t);if(fo&&(s.data instanceof ArrayBuffer||po(s.data)))return t(bo(s.data));qs(s,!1,e=>{Hs||(Hs=new TextEncoder),t(Hs.encode(e))})}const go="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ii=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<go.length;s++)ii[go.charCodeAt(s)]=s;const Xc=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},Yc=typeof ArrayBuffer=="function",$s=(s,t)=>{if(typeof s!="string")return{type:"message",data:vo(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:Gc(s.substring(1),t)}:Ri[e]?s.length>1?{type:Ri[e],data:s.substring(1)}:{type:Ri[e]}:Is},Gc=(s,t)=>{if(Yc){const e=Xc(s);return vo(e,t)}else return{base64:!0,data:s}},vo=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,yo="",Zc=(s,t)=>{const e=s.length,i=new Array(e);let n=0;s.forEach((r,o)=>{qs(r,!1,l=>{i[o]=l,++n===e&&t(i.join(yo))})})},Qc=(s,t)=>{const e=s.split(yo),i=[];for(let n=0;n<e.length;n++){const r=$s(e[n],t);if(i.push(r),r.type==="error")break}return i};function tu(){return new TransformStream({transform(s,t){Kc(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 js;function Fi(s){return s.reduce((t,e)=>t+e.length,0)}function zi(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){js||(js=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(Fi(e)<1)break;const h=zi(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(Fi(e)<2)break;const h=zi(e,2);n=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),i=3}else if(i===2){if(Fi(e)<8)break;const h=zi(e,8),a=new DataView(h.buffer,h.byteOffset,h.length),c=a.getUint32(0);if(c>Math.pow(2,21)-1){l.enqueue(Is);break}n=c*Math.pow(2,32)+a.getUint32(4),i=3}else{if(Fi(e)<n)break;const h=zi(e,n);l.enqueue($s(r?h:js.decode(h),t)),i=0}if(n===0||n>s){l.enqueue(Is);break}}}})}const wo=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 Ui=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 Ff(){}function So(s,...t){return t.reduce((e,i)=>(s.hasOwnProperty(i)&&(e[i]=s[i]),e),{})}const nu=Jt.setTimeout,ru=Jt.clearTimeout;function Vi(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 xo(){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 Js extends Mt{constructor(t){super(),this.writable=!1,Vi(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=$s(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 Js{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)};Qc(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,Zc(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]=xo()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let _o=!1;try{_o=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const du=_o;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 ne extends Mt{constructor(t,e,i){super(),this.createRequest=t,Vi(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=So(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=ne.requestsCount++,ne.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 ne.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(ne.requestsCount=0,ne.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Co);else if(typeof addEventListener=="function"){const s="onpagehide"in Jt?"pagehide":"unload";addEventListener(s,Co,!1)}}function Co(){for(let s in ne.requests)ne.requests.hasOwnProperty(s)&&ne.requests[s].abort()}const bu=(function(){const s=To({xdomain:!1});return s&&s.responseType!==null})();class gu extends mu{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=bu&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new ne(To,this.uri(),t)}}function To(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 Eo=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class vu extends Js{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,i=Eo?{}:So(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;qs(i,this.supportsBinary,r=>{try{this.doWrite(i,r)}catch{}n&&Ui(()=>{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]=xo()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Ks=Jt.WebSocket||Jt.MozWebSocket;class yu extends vu{createSocket(t,e,i){return Eo?new Ks(t,e,i):e?new Ks(t,e):new Ks(t)}doWrite(t,e){this.ws.send(e)}}class wu extends Js{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&&Ui(()=>{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:gu},xu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,_u=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Xs(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=xu.exec(s||""),r={},o=14;for(;o--;)r[_u[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=Tu(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 Tu(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,n,r){n&&(e[n]=r)}),e}const Ys=typeof addEventListener=="function"&&typeof removeEventListener=="function",Wi=[];Ys&&addEventListener("offline",()=>{Wi.forEach(s=>s())},!1);class ve 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=Xs(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=Xs(e.host).host);Vi(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)),Ys&&(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"})},Wi.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=wo,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&&ve.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",ve.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,Ui(()=>{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(ve.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(),Ys&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=Wi.indexOf(this._offlineEventListener);i!==-1&&Wi.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}ve.protocol=wo;class Eu extends ve{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;ve.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;ve.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 Lu=class extends Eu{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 Mu(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=Xs(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 ku=typeof ArrayBuffer=="function",Ou=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Lo=Object.prototype.toString,Pu=typeof Blob=="function"||typeof Blob<"u"&&Lo.call(Blob)==="[object BlobConstructor]",Au=typeof File=="function"||typeof File<"u"&&Lo.call(File)==="[object FileConstructor]";function Gs(s){return ku&&(s instanceof ArrayBuffer||Ou(s))||Pu&&s instanceof Blob||Au&&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(Gs(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 Bu(s){const t=[],e=s.data,i=s;return i.data=Zs(e,t),i.attachments=t.length,{packet:i,buffers:t}}function Zs(s,t){if(!s)return s;if(Gs(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]=Zs(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]=Zs(s[i],t));return e}return s}function Du(s,t){return s.data=Qs(s.data,t),delete s.attachments,s}function Qs(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]=Qs(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Qs(s[e],t));return s}const Nu=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var et;(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"})(et||(et={}));class Ru{constructor(t){this.replacer=t}encode(t){return(t.type===et.EVENT||t.type===et.ACK)&&Ii(t)?this.encodeAsBinary({type:t.type===et.EVENT?et.BINARY_EVENT:et.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===et.BINARY_EVENT||t.type===et.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 tn 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===et.BINARY_EVENT;i||e.type===et.BINARY_ACK?(e.type=i?et.EVENT:et.ACK,this.reconstructor=new Fu(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Gs(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(et[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===et.BINARY_EVENT||i.type===et.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(tn.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 et.CONNECT:return Mo(e);case et.DISCONNECT:return e===void 0;case et.CONNECT_ERROR:return typeof e=="string"||Mo(e);case et.EVENT:case et.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Nu.indexOf(e[0])===-1);case et.ACK:case et.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Fu{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=Du(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Mo(s){return Object.prototype.toString.call(s)==="[object Object]"}const zu=Object.freeze(Object.defineProperty({__proto__:null,Decoder:tn,Encoder:Ru,get PacketType(){return et}},Symbol.toStringTag,{value:"Module"}));function Qt(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const Uu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ko 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=[Qt(t,"open",this.onopen.bind(this)),Qt(t,"packet",this.onpacket.bind(this)),Qt(t,"error",this.onerror.bind(this)),Qt(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(Uu.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:et.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:et.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 et.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 et.EVENT:case et.BINARY_EVENT:this.onevent(t);break;case et.ACK:case et.BINARY_ACK:this.onack(t);break;case et.DISCONNECT:this.ondisconnect();break;case et.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:et.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:et.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 Fe(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}Fe.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},Fe.prototype.reset=function(){this.attempts=0},Fe.prototype.setMin=function(s){this.ms=s},Fe.prototype.setMax=function(s){this.max=s},Fe.prototype.setJitter=function(s){this.jitter=s};class en 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,Vi(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 Fe({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||zu;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 Lu(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=Qt(e,"open",function(){i.onopen(),t&&t()}),r=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Qt(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(Qt(t,"ping",this.onping.bind(this)),Qt(t,"data",this.ondata.bind(this)),Qt(t,"error",this.onerror.bind(this)),Qt(t,"close",this.onclose.bind(this)),Qt(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){Ui(()=>{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 ko(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 qi(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=Mu(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 en(i,t):(si[n]||(si[n]=new en(i,t)),h=si[n]),e.query&&!t.query&&(t.query=e.queryKey),h.socket(e.path,t)}Object.assign(qi,{Manager:en,Socket:ko,io:qi,connect:qi});let sn="http://localhost:8000";function Oo(s){s&&s!==sn&&(sn=s,re&&(re.disconnect(),re=null))}let re=null;function Vu(){return qi(sn,{transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,reconnectionAttempts:1/0,timeout:1e4,forceNew:!1})}function nn(){return re||(re=Vu()),re}function Wu(s,t){const e=nn();return e.on(s,t),()=>e.off(s,t)}function Iu(s,t){re&&re.off(s,t)}function qu(s,t){nn().emit(s,t)}function Hu(){return re?re.connected?"connected":"connecting":"disconnected"}const Hi={getSocket:nn,on:Wu,off:Iu,emit:qu,getStatus:Hu,setBaseUrl:Oo},Po=C.createContext(),oe=()=>{const s=C.useContext(Po);if(!s)throw new Error("useTrading must be used within TradingProvider");return s},$u=({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:$i&&$i.tagName.toUpperCase()==="SCRIPT"&&$i.src||new URL("chart-sdk.umd.js",document.baseURI).href}<"u"&&"http://localhost:8000"||"http://localhost:8000";Wo(e),Hi.setBaseUrl(e),C.useEffect(()=>{Hi.setBaseUrl(e)},[e]);const[i,n]=C.useState("BTCUSDT"),[r,o]=C.useState("M1"),[l,h]=C.useState([]),[a,c]=C.useState(!0),[u,p]=C.useState([]),[b,d]=C.useState(!1),[f,m]=C.useState(1e5),[S,g]=C.useState(null),[x,L]=C.useState([]),[A,J]=C.useState(!0),[F,Y]=C.useState(!1),[Q,Tt]=C.useState(!0),[V,at]=C.useState("candles"),[Bt,vt]=C.useState(!1),lt=C.useRef(null),ct=C.useRef(new Map),ut=C.useRef(null),Dt=1e3,Et=C.useCallback(async()=>{try{const q=localStorage.getItem("token");if(!q){console.log("⚠️ No token, skipping orders fetch");return}d(!0);const nt=await bt.get(`${e}/api/trades`,{headers:{Authorization:`Bearer ${q}`}});if(nt.data&&nt.data.data){const wt=nt.data.data.map(tt=>({id:tt.id,ticket:tt.ticket,symbol:tt.symbol,type:tt.type,volume:tt.volume,price:tt.price,stopLoss:tt.stopLoss,takeProfit:tt.takeProfit,comment:tt.comment||"",status:tt.status,swap:tt.swap||0,profit:tt.profit||0,profitCurrency:"USD",time:new Date(tt.openAt).toLocaleTimeString(),openAt:tt.openAt,closeAt:tt.closeAt}));p(wt)}else p([])}catch(q){console.error("❌ Error fetching orders:",q.response?.data||q.message),p([])}finally{d(!1)}},[]),St=C.useCallback((q,nt)=>!nt||!q.price||isNaN(nt)||isNaN(q.price)?q.profit||0:(q.type==="BUY"?nt-q.price:q.price-nt)*q.volume,[]),xt=C.useCallback(async()=>{try{const q=localStorage.getItem("token");if(!q){console.log("⚠️ No token, skipping balance fetch");return}const nt=await bt.get(`${e}/api/user/account`,{headers:{Authorization:`Bearer ${q}`}});if(nt.data&&nt.data.data){const wt=parseFloat(nt.data.data.balance);isNaN(wt)||m(wt)}}catch(q){console.error("❌ Error fetching user balance:",q.response?.data||q.message)}},[]),st=C.useMemo(()=>{const q=f,nt=u.reduce((Ot,Pt)=>Ot+Pt.volume*Pt.price*.01,0),wt=u.reduce((Ot,Pt)=>{const Kt=l.find(Xt=>Xt.symbol===Pt.symbol);if(Kt){const Xt=Pt.type==="BUY"?parseFloat(Kt.bid||0):parseFloat(Kt.ask||0);if(Xt&&Xt>0&&!isNaN(Xt))return Ot+St(Pt,Xt)}return Ot+(Pt.profit||0)},0),tt=q+wt,it=tt-nt,rt=nt>0?tt/nt*100:0;return{balance:q,equity:tt,margin:nt,freeMargin:it,level:rt.toFixed(2)}},[u,l,f,St]);C.useEffect(()=>{localStorage.getItem("token")&&(Et(),xt())},[Et,xt]),C.useEffect(()=>{(async()=>{try{c(!0);const nt=await bt.get(`${e}/api/symbols`);if(nt.data&&nt.data.data){const wt=nt.data.data;h(wt),wt.length>0&&(wt.find(it=>it.symbol===i)||n(wt[0].symbol))}else h([])}catch(nt){console.error("❌ Error fetching symbols:",nt.response?.data||nt.message),h([])}finally{c(!1)}})()},[]);const dt=C.useCallback(()=>{const q=ct.current;if(q.size===0)return;const nt=new Map(q);q.clear(),h(wt=>wt.map(tt=>{const it=nt.get(tt.symbol);return it?{...tt,...it}:tt})),p(wt=>{let tt=!1;const it=wt.map(rt=>{const Ot=nt.get(rt.symbol);if(!Ot)return rt;const Pt=rt.type==="BUY"?parseFloat(Ot.bid||0):parseFloat(Ot.ask||0);if(!Pt||isNaN(Pt)||Pt<=0)return rt;const Kt=St(rt,Pt);return Kt===rt.profit?rt:(tt=!0,{...rt,profit:Kt})});return tt?it:wt})},[St]);C.useEffect(()=>{lt.current||(lt.current=Hi.getSocket());const q=lt.current,nt=()=>console.log("✅ TradingContext: Connected"),wt=()=>console.log("⚠️ TradingContext: Disconnected"),tt=rt=>{rt?.symbol&&(ct.current.set(rt.symbol,rt),ut.current||(ut.current=setTimeout(()=>{ut.current=null,dt()},Dt)))},it=async rt=>{if(console.log("🔔 Trade closed event received:",rt),!!rt){if(rt.newBalance!==void 0){const Ot=parseFloat(rt.newBalance);isNaN(Ot)||m(Ot)}if(window.notify){const Ot=rt.profitLoss||rt.profit||0,Pt=Ot>=0?`+${Ot.toFixed(2)}`:Ot.toFixed(2),Kt=rt.symbol||"Trade",Xt=rt.reason||"Closed";window.notify(`Trade Closed: ${Xt} | ${Kt} | P/L: ${Pt} USD`,Ot>=0?"success":"error")}rt.tradeId&&p(Ot=>Ot.filter(Pt=>Pt.id!==rt.tradeId)),await Et(),await xt()}};return q.on("connect",nt),q.on("disconnect",wt),q.on("priceUpdate",tt),q.on("tradeClosed",it),()=>{q.off("connect",nt),q.off("disconnect",wt),q.off("priceUpdate",tt),q.off("tradeClosed",it),ut.current&&(clearTimeout(ut.current),ut.current=null),ct.current.clear()}},[dt,Et,xt]);const Lt=C.useMemo(()=>l.find(q=>q.symbol===i)||{bid:"0.00000",ask:"0.00000",change:0},[l,i]),_t=C.useMemo(()=>({selectedSymbol:i,setSelectedSymbol:n,selectedTimeframe:r,setSelectedTimeframe:o,symbols:l,setSymbols:h,symbolsLoading:a,orders:u,setOrders:p,ordersLoading:b,fetchOrders:Et,fetchUserBalance:xt,userBalance:f,setUserBalance:m,accountSummary:st,currentSymbolData:Lt,activeTool:S,setActiveTool:g,chartObjects:x,setChartObjects:L,showGrid:A,setShowGrid:J,snapToGrid:F,setSnapToGrid:Y,drawingsVisible:Q,setDrawingsVisible:Tt,chartType:V,setChartType:at,chartLocked:Bt,setChartLocked:vt,baseUrl:e}),[i,r,l,a,u,b,Et,xt,f,st,Lt,S,x,A,F,Q,V,Bt,e]);return w.jsx(Po.Provider,{value:_t,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 Ju(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 Ao(s){return Array.isArray(s)?s.map(t=>({...t,time:kt(t.time)})).filter(t=>t.time!=null):[]}function Ku(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 ze(s,t){return!Number.isFinite(s)||!Number.isFinite(t)||t<=0?s:Math.floor(s/t)*t}const Rt="17:00-17:00",Ft="America/New_York",le="24x7",he="UTC",Bo={EURUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},GBPUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},USDJPY:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},USDCHF:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},AUDUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},USDCAD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},NZDUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},EURGBP:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},GBPJPY:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},CADJPY:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},XAUUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},XAGUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},OILUSD:{type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"},BTCUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},ETHUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},BNBUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},SOLUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},ADAUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},XRPUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},DOGEUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},DOTUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},MATICUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"},LINKUSDT:{type:"crypto",session:le,sessionTZ:he,priceMode:"last"}},Do={type:"forex",sessionTZ:Ft,session:Rt,priceMode:"mid"};function ni(s){return s&&Bo[s.toUpperCase()]||Do}function Xu(s){return ni(s).type==="forex"}function Yu(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 Ro(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 Fo(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 Zu(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,b=0;for(p=ze(p,t);p<a&&b<n;){const d=ze(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}),b++),p+=t}if(p<a&&b>=n){const d=ze(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((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 rn(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 zo(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=rn(e),l=Ao(s).map(m=>({...m,time:ze(m.time,n)})).filter(m=>No(m)).map(m=>Ro(m)),h=Fo(l);h.sort((m,S)=>m.time-S.time);const a=h.filter((m,S)=>S===0?!0:m.time>h[S-1].time),c=a.length>10?Zu(a,"percentile"):a,u=Fo(c);u.sort((m,S)=>m.time-S.time);const p=Qu(u,n),b=[];for(let m=1;m<p.length;m++){const S=p[m].time-p[m-1].time;S>n*2&&b.push({from:p[m-1].time,to:p[m].time,gapSeconds:S,gapMinutes:Math.round(S/60),fromDate:new Date(p[m-1].time*1e3).toISOString(),toDate:new Date(p[m].time*1e3).toISOString()})}const d=c.filter((m,S)=>S===0?!1:m.close===c[S-1].close&&m.open===c[S-1].close).length,f={original:s.length,processed:p.length,duplicates:s.length-h.length,outliers:d,gaps:b,filledGaps:p.length-u.length,symbolConfig:i};return{candles:p,stats:f}}function Uo(s,t,e="1m"){if(!s||!t||!No(s))return null;const i=kt(s.time);if(i==null)return null;const n=rn(e),r=ze(i,n);return Ro({...s,time:r})}let Vo="http://localhost:8000";function Wo(s){s&&(Vo=s)}const tf={M1:3,M5:7,M15:14,M30:30,H1:90,H4:180,D1:1095,W1:1825,MN:3650};function Io(s){if(!s)return 7;const t=String(s).toUpperCase();return tf[t]??7}function ef(s,t){const e=String(s||"").toUpperCase(),i=t||Io(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 zt=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 sf(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 on(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),b=c+u*(o-n.time);return[{time:r,price:p},{time:o,price:b}]}const nf=C.forwardRef(function({bidPrice:t="113.638",askPrice:e="113.649",showBuySellPanel:i=!0,onBuyClick:n,onSellClick:r},o){const l=C.useRef(null),h=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useRef([]),p=C.useRef(!1),b=C.useRef(null),d=C.useRef(null),f=C.useRef(null),m=C.useRef(null),S=C.useRef([]),[g,x]=C.useState(null),[L,A]=C.useState([]),J=C.useRef(null),F=C.useRef(null),Y=C.useRef(null),Q=C.useRef(!1);C.useEffect(()=>{Y.current=g},[g]);const Tt=C.useRef(new Map),V=C.useRef(null),at=(v,_)=>`${v}_${_}`,Bt=()=>{const v=at(st,dt);return Tt.current.get(v)||null},vt=v=>{if(!v)return;const _=at(st,dt);Tt.current.set(_,v)},{activeTool:lt,setActiveTool:ct,showGrid:ut,snapToGrid:Dt,chartObjects:Et,setChartObjects:St,orders:xt,selectedSymbol:st,selectedTimeframe:dt,drawingsVisible:Lt,chartType:_t,chartLocked:q,baseUrl:nt}=oe(),wt=nt||Vo,tt=C.useRef([]),[it,rt]=C.useState([]),[Ot,Pt]=C.useState(!0),Kt=C.useRef(null),Xt=C.useRef(new Map);C.useRef(null);const Xo=C.useRef(0);C.useImperativeHandle(o,()=>({zoomIn:()=>{const v=h.current?.timeScale();if(!v)return;const _=v.getVisibleRange();if(!_||!_.from||!_.to)return;const E=_.to-_.from,D=(_.from+_.to)/2,k=E*.8;try{v.setVisibleRange({from:D-k/2,to:D+k/2}),vt(v.getVisibleRange())}catch{}},zoomOut:()=>{const v=h.current?.timeScale();if(!v)return;const _=v.getVisibleRange();if(!_||!_.from||!_.to)return;const E=_.to-_.from,D=(_.from+_.to)/2,k=E*1.25;try{v.setVisibleRange({from:D-k/2,to:D+k/2}),vt(v.getVisibleRange())}catch{}}}));const an=C.useMemo(()=>it.length===0?[]:_t==="line"||_t==="area"?it.map(v=>({time:v.time,value:v.close})):it,[it,_t]);return C.useEffect(()=>{const v=l.current;if(!v)return;const _=v.getBoundingClientRect(),E=O=>{const W=Math.abs(Number(O));return Number.isFinite(W)?W>=1e3?W.toFixed(2):W>=1?W.toFixed(4):W.toFixed(5):"0"},D=Ca(v,{width:_.width||v.clientWidth,height:_.height||v.clientHeight,autoSize:!0,localization:{priceFormatter:E},layout:{background:{color:"#0F1720"},textColor:"#fff",fontSize:12},grid:{vertLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ut,color:ut?"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:lt===1?1:0,vertLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},vertLineVisible:lt===1,horzLineVisible:lt===1},handleScroll:{mouseWheel:!0,pressedMouseMove:lt===null||lt===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}}),k=D.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1});h.current=D,a.current=k;const H=D.timeScale(),X=()=>{if(Q.current&&it.length>0){const O=H.getVisibleRange();O&&vt(O)}};H.subscribeVisibleTimeRangeChange(X);const pt=new ResizeObserver(O=>{for(const W of O){const{width:ht,height:$}=W.contentRect;if(ht>0&&$>0&&D){const M=H.getVisibleRange();D.resize(ht,$),M&&setTimeout(()=>{try{H.setVisibleRange(M)}catch{}},0)}}});return pt.observe(v),()=>{H.unsubscribeVisibleTimeRangeChange(X),pt.disconnect(),D.remove(),h.current=null,a.current=null,c.current=null,u.current=[]}},[]),C.useEffect(()=>{h.current&&h.current.applyOptions({grid:{vertLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0}}})},[ut]),C.useEffect(()=>{if(!h.current)return;const _=!q&&!(lt!==null&&lt!==1&&lt!==0),E=!q;h.current.applyOptions({crosshair:{mode:lt===1?1:0,vertLine:{visible:lt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{visible:lt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"}},handleScroll:{mouseWheel:E,pressedMouseMove:_,horzTouchDrag:_,vertTouchDrag:_},handleScale:{axisPressedMouseMove:{time:_,price:_},axisDoubleClickReset:{time:E,price:E},axisTouch:{time:_,price:_},mouseWheel:E,pinch:E}})},[lt,q]),C.useEffect(()=>{(async()=>{if(!st||!dt){rt([]),Q.current=!1;return}try{if(Pt(!0),rt([]),Q.current=!1,a.current)try{a.current.setData([])}catch{}console.log(`📊 Fetching candles for ${st} @ ${dt}`);const _=Io(dt),E=ef(dt,_),D=await bt.get(`${wt}/api/chart/candles`,{params:{symbol:st,timeframe:dt,limit:E,daysBack:_},timeout:1e4});if(D.data&&D.data.data&&D.data.data.length>0){const k=D.data.data;console.log(`✅ Loaded ${k.length} raw candles from server`);const{candles:H,stats:X}=zo(k,st,dt);H.length>0?(rt(H),Xt.current=new Map,H.forEach(pt=>{Xt.current.set(pt.time,pt)})):(console.warn(`⚠️ No valid candles after processing for ${st}`),rt([]))}else console.warn(`⚠️ No candle data returned for ${st}`),rt([])}catch(_){console.error(`❌ Error fetching ${st}:`,_.message),rt([])}finally{Pt(!1)}})()},[st,dt,wt]),C.useEffect(()=>{Kt.current=Hi.getSocket();const v=Kt.current,_=()=>{console.log("✅ Chart WebSocket connected"),k()},E=()=>{console.log("⚠️ Chart WebSocket disconnected - will auto-reconnect")},D=X=>{console.error("❌ Chart WebSocket connection error:",X)};v.on("connect",_),v.on("disconnect",E),v.on("connect_error",D);const k=()=>{st&&dt&&v.connected&&(console.log(`Subscribing to real-time candles: ${st}@${dt}`),v.emit("subscribeCandles",{symbol:st,timeframe:dt}))},H=X=>{if(!X||!X.candle||!X.symbol||X.symbol.toUpperCase()!==st?.toUpperCase())return;const{candle:pt}=X,O=Uo(pt,st,dt);if(!O)return;const W=Date.now();if(W-Xo.current<200)return;Xo.current=W;const ht=h.current?.timeScale(),$=ht?.getVisibleRange(),M=a.current,I=h.current;if(!(!M||!I||!Q.current))try{_t==="line"||_t==="area"?M.update({time:O.time,value:O.close}):M.update({time:O.time,open:O.open,high:O.high,low:O.low,close:O.close}),Xt.current.set(O.time,O),ht&&$&&vt($)}catch(P){console.error("❌ Error updating candle:",P)}};return v.on("candleUpdate",H),v.connected&&k(),()=>{v.off("candleUpdate",H),v.off("connect",_),v.off("disconnect",E),v.off("connect_error",D),st&&dt&&v.connected&&v.emit("unsubscribeCandles",{symbol:st,timeframe:dt})}},[st,dt]),C.useEffect(()=>{const v=a.current,_=h.current;if(!(!v||!_)&&!(it.length===0&&Q.current)){if(it.length===0&&!Q.current){if(Ot)return;const E=_.timeScale();v.setData([]),E.fitContent();return}if(!Q.current){const E=_.timeScale(),D=at(st,dt);if(V.current,V.current=D,_t==="line"||_t==="area"){const H=[...it.map(X=>({time:X.time,value:X.close})).filter(X=>X.time!=null)].sort((X,pt)=>X.time-pt.time);H.length>0&&v.setData(H)}else{const k=[...it].sort((H,X)=>H.time-X.time);k.length>0&&v.setData(k)}E.fitContent();try{_.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}Q.current=!0,vt(E.getVisibleRange())}}},[it.length,_t,st,dt]),C.useEffect(()=>{const v=h.current;if(!v||!Q.current||it.length===0)return;const _=v.timeScale(),E=_.getVisibleRange()||Bt();if(a.current)try{v.removeSeries(a.current)}catch{}if(c.current)try{v.removeSeries(c.current),c.current=null}catch{}let D;if(_t==="bars"){D=v.addBarSeries({upColor:"#26A69A",downColor:"#EF5350",borderUpColor:"#26A69A",borderDownColor:"#EF5350",scaleMargins:{top:.1,bottom:.1}});const k=[...it].sort((H,X)=>H.time-X.time);k.length>0&&D.setData(k)}else if(_t==="line"){D=v.addLineSeries({color:"#38bdf8",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const k=zt(an);k.length>0&&D.setData(k)}else if(_t==="area"){D=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 k=zt(an);k.length>0&&D.setData(k)}else if(_t==="volume ticks"||_t==="volume"){D=v.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,priceScaleId:"right"});const k=[...it].sort((pt,O)=>pt.time-O.time);k.length>0&&D.setData(k);const H=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 X=k.map(pt=>({time:pt.time,value:pt.volume||0,color:pt.close>=pt.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));X.length>0&&H.setData(X),c.current=H}else{D=v.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,scaleMargins:{top:.1,bottom:.1}});const k=[...it].sort((H,X)=>H.time-X.time);k.length>0&&D.setData(k)}if(a.current=D,E&&Q.current)setTimeout(()=>{try{_.setVisibleRange(E),vt(E)}catch{if(it.length>0)try{const H=it[it.length-1].time,X=H-6e3;_.setVisibleRange({from:X,to:H}),vt(_.getVisibleRange())}catch{_.fitContent(),vt(_.getVisibleRange())}}try{v.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}},0);else if(!Q.current){_.fitContent();try{v.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}Q.current=!0,vt(_.getVisibleRange())}},[_t,it.length,an.length]),C.useEffect(()=>{const v=h.current,_=c.current;if(!v||!_||!Q.current||it.length===0||_t!=="volume"&&_t!=="volume ticks")return;const D=[...it].sort((k,H)=>k.time-H.time).map(k=>({time:k.time,value:k.volume||0,color:k.close>=k.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));D.length>0&&_.setData(D)},[it,_t]),C.useEffect(()=>{const v=h.current,_=a.current,E=l.current;if(!v||!_||!E)return;const k=lt!==null?[null,null,"trendline","parallellines","fibonacci","rectangle","pricelevel","text",null,null,null,null,null,null,null,null,null][lt]:null;if(!k){if(p.current=!1,b.current=null,d.current=null,m.current=null,f.current?.series)try{v.removeSeries(f.current.series)}catch{}f.current=null;return}if(k==="pricelevel"){const O=W=>{const ht=E.getBoundingClientRect(),$=W.clientX-ht.left,M=W.clientY-ht.top,I=v.timeScale().coordinateToTime($),P=_.coordinateToPrice(M);if(I==null||P==null)return;const N={type:"pricelevel",priceLine:_.createPriceLine({price:P,color:"#3b82f6",lineWidth:2,lineStyle:2,axisLabelVisible:!0,title:P.toFixed(5)}),price:P};St(j=>[...j,N]),u.current.push(N)};return E.addEventListener("click",O),()=>{E.removeEventListener("click",O)}}if(k==="trendline"){const O=M=>{M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const I=E.getBoundingClientRect(),P=M.clientX-I.left,R=M.clientY-I.top;let N=v.timeScale().coordinateToTime(P);const j=_.coordinateToPrice(R);if(!(N==null||j==null)&&(N=kt(N),N!=null))if(m.current===null){m.current={time:N,price:j};const B=v.addLineSeries({color:"#22c55e",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"trendline",series:B},B.setData([{time:N,value:j}])}else{const B=m.current,U={time:N,price:j},K=1,mt=1e-5,ot=Math.abs(U.time-B.time),yt=Math.abs(U.price-B.price);if(ot<K&&yt<mt){try{v.removeSeries(f.current.series)}catch{}m.current=null,f.current=null;return}const ue={time:B.time,price:B.price},fe={time:U.time,price:U.price},Yt=zt([{time:ue.time,value:ue.price},{time:fe.time,value:fe.price}]);if(Yt.length>0){f.current.series.setData(Yt);const ye={type:"trendline",series:f.current.series,point1:ue,point2:fe};St(Me=>[...Me,ye]),u.current.push(ye)}ct(null),m.current=null,f.current=null}},W=M=>{if(m.current===null||f.current?.type!=="trendline")return;M.preventDefault(),M.stopPropagation();const I=E.getBoundingClientRect(),P=M.clientX-I.left,R=M.clientY-I.top;let N=v.timeScale().coordinateToTime(P);const j=_.coordinateToPrice(R);if(N==null||j==null||(N=kt(N),N==null))return;const B=m.current,U=zt([{time:B.time,value:B.price},{time:N,value:j}]);U.length>0&&f.current.series.setData(U)},ht=M=>{M.stopPropagation()},$={capture:!0,passive:!1};return E.addEventListener("click",O,$),E.addEventListener("mousemove",W,$),E.addEventListener("mousemove",ht,$),()=>{if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{v.removeSeries(f.current.series)}catch{}f.current=null}E.removeEventListener("click",O,$),E.removeEventListener("mousemove",W,$),E.removeEventListener("mousemove",ht,$)}}if(k==="parallellines"){const O={capture:!0,passive:!1},W=P=>{P.preventDefault(),P.stopPropagation(),P.stopImmediatePropagation();const R=E.getBoundingClientRect(),N=P.clientX-R.left,j=P.clientY-R.top;let B=v.timeScale().coordinateToTime(N);const U=_.coordinateToPrice(j);if(B==null||U==null||(B=kt(B),B==null))return;const K={time:B,price:U},mt=S.current;if(mt.length===0){S.current=[K];const ot=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});ot.setData([{time:B,value:U}]),f.current={type:"parallellines",series:ot,previewLine:null}}else if(mt.length===1){S.current=[mt[0],K];const ot=zt([{time:mt[0].time,value:mt[0].price},{time:B,value:U}]);ot.length>0&&f.current.series.setData(ot),f.current.previewLine=v.addLineSeries({color:"#8b5cf6",lineWidth:2,lineStyle:2,priceLineVisible:!1,lastValueVisible:!1});const yt=on(v,_,mt[0],K,K);yt&&f.current.previewLine.setData(zt([{time:yt[0].time,value:yt[0].price},{time:yt[1].time,value:yt[1].price}]))}else{const[ot,yt]=mt,ue=K;if(f.current?.previewLine){try{v.removeSeries(f.current.previewLine)}catch{}f.current.previewLine=null}const fe=f.current?.series;if(!fe)return;const Yt=on(v,_,ot,yt,ue);if(!Yt)return;const ye=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});fe.setData(zt([{time:ot.time,value:ot.price},{time:yt.time,value:yt.price}])),ye.setData(zt([{time:Yt[0].time,value:Yt[0].price},{time:Yt[1].time,value:Yt[1].price}]));const Me={type:"parallellines",point1:ot,point2:yt,point3:ue,baseLine:fe,parallelLine:ye};St(ri=>[...ri,Me]),u.current.push(Me),ct(null),S.current=[],f.current=null}},ht=P=>{const R=S.current;if(R.length!==1||!f.current?.series)return;const N=E.getBoundingClientRect(),j=P.clientX-N.left,B=P.clientY-N.top;let U=v.timeScale().coordinateToTime(j);const K=_.coordinateToPrice(B);if(U==null||K==null||(U=kt(U),U==null))return;const mt=zt([{time:R[0].time,value:R[0].price},{time:U,value:K}]);mt.length>0&&f.current.series.setData(mt)},$=P=>{const R=S.current;if(R.length!==2||!f.current?.previewLine)return;const N=E.getBoundingClientRect(),j=P.clientX-N.left,B=P.clientY-N.top;let U=v.timeScale().coordinateToTime(j);const K=_.coordinateToPrice(B);if(U==null||K==null||(U=kt(U),U==null))return;const mt={time:U,price:K},ot=on(v,_,R[0],R[1],mt);ot&&f.current.previewLine.setData(zt([{time:ot[0].time,value:ot[0].price},{time:ot[1].time,value:ot[1].price}]))},M=P=>{ht(P),$(P)},I=P=>{P.stopPropagation()};return E.addEventListener("click",W,O),E.addEventListener("mousemove",M,O),E.addEventListener("mousemove",I,O),()=>{if(S.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",W,O),E.removeEventListener("mousemove",M,O),E.removeEventListener("mousemove",I,O)}}if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{v.removeSeries(f.current.series)}catch{}f.current=null}const H=O=>{if(O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation(),k==="trendline"||k==="parallellines"||k!=="rectangle"&&k!=="fibonacci")return;const W=E.getBoundingClientRect(),ht=O.clientX-W.left,$=O.clientY-W.top;let M=v.timeScale().coordinateToTime(ht);const I=_.coordinateToPrice($);if(!(M==null||I==null)&&(M=kt(M),M!=null)){if(p.current=!0,b.current={time:M,price:I},d.current=null,k==="rectangle"){const P=v.addBaselineSeries({baseValue:{type:"price",price:I},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:P}}if(k==="fibonacci"){const P=v.addLineSeries({color:"#f59e0b",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"fibonacci",series:P,priceLines:[]}}if(k==="parallellines"){const P=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"parallellines",series:P,firstLine:null,secondLine:null}}}},X=O=>{if(!p.current||!b.current||!f.current)return;O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation();const W=E.getBoundingClientRect(),ht=O.clientX-W.left,$=O.clientY-W.top;let M=v.timeScale().coordinateToTime(ht);const I=_.coordinateToPrice($);if(M==null||I==null||(M=kt(M),M==null))return;d.current={time:M,price:I};const P=b.current;if(f.current.type==="rectangle"){const R=Math.max(P.price,I),N=Math.min(P.price,I),j=kt(Math.min(P.time,M)),B=kt(Math.max(P.time,M));if(j==null||B==null||Math.abs(B-j)<1||Math.abs(R-N)<1e-5)return;const U=f.current.series;U.setData(zt([{time:j,value:R},{time:B,value:R}])),U.applyOptions({baseValue:{type:"price",price:N}})}if(f.current.type==="fibonacci"){const R=[{time:P.time,value:P.price},{time:M,value:I}],N=zt(R);N.length>0&&f.current.series.setData(N),d.current={time:M,price:I},f.current.priceLines&&(f.current.priceLines.forEach(j=>{try{_.removePriceLine(j)}catch{}}),f.current.priceLines=[])}if(f.current.type==="parallellines")if(f.current.firstLine){const R=f.current.firstLine;R.endTime-R.startTime;const N=R.endPrice-R.startPrice,j=I,B=j+N;if(f.current.secondLine)f.current.secondLine.setData([{time:P.time,value:j},{time:M,value:B}]);else{const U=v.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});U.setData([{time:P.time,value:j},{time:M,value:B}]),f.current.secondLine=U}}else f.current.series.setData([{time:P.time,value:P.price},{time:M,value:I}])},pt=O=>{if(O&&(O.preventDefault(),O.stopPropagation()),!p.current||!f.current||!b.current)return;const W=b.current,ht=d.current||W;if(f.current.type==="parallellines")if(f.current.firstLine){const $={type:"parallellines",firstLine:f.current.series,secondLine:f.current.secondLine,firstLineData:f.current.firstLine};St(M=>[...M,$]),u.current.push($),ct(null),f.current=null,p.current=!1,b.current=null,d.current=null;return}else{f.current.firstLine={startTime:W.time,startPrice:W.price,endTime:ht.time,endPrice:ht.price},p.current=!1,b.current=null,d.current=null;return}if(f.current.type==="fibonacci"){const M=(d.current||W).price;if(Math.abs(W.price-M)<1e-4){try{v.removeSeries(f.current.series)}catch{}p.current=!1,b.current=null,d.current=null,f.current=null;return}const I=Math.max(W.price,M),P=Math.min(W.price,M),R=I-P,N=[{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%"}],j=[],B=f.current.series;try{v.removeSeries(B)}catch{}N.forEach(({level:K,label:mt})=>{const ot=I-R*K,yt=_.createPriceLine({price:ot,color:K===0||K===1?"#f59e0b":"#fbbf24",lineWidth:K===0||K===1?2:1,lineStyle:K===0||K===1?0:2,axisLabelVisible:!0,title:`${mt} (${ot.toFixed(5)})`,textColor:K===0||K===1?"#f59e0b":"#fbbf24"});j.push(yt)});const U={type:"fibonacci",priceLines:j,startPrice:W.price,endPrice:M,high:I,low:P};St(K=>[...K,U]),u.current.push(U),ct(null)}if(f.current.type==="rectangle"){const $=b.current,M=d.current||$,I=Math.max($.price,M.price),P=Math.min($.price,M.price),R=kt(Math.min($.time,M.time)),N=kt(Math.max($.time,M.time));if(R!=null&&N!=null&&Math.abs(N-R)>=1&&Math.abs(I-P)>=1e-5){const j=f.current.series;j.setData(zt([{time:R,value:I},{time:N,value:I}])),j.applyOptions({baseValue:{type:"price",price:P}});const B={type:"rectangle",timeStart:R,timeEnd:N,priceTop:I,priceBottom:P,series:j};St(U=>[...U,B]),u.current.push(B),ct(null)}else try{v.removeSeries(f.current.series)}catch{}}p.current=!1,b.current=null,d.current=null,f.current=null};if(k==="rectangle"||k==="fibonacci"||k==="parallellines"){const O={capture:!0,passive:!1},W=ht=>{p.current||ht.stopPropagation()};return E.addEventListener("mousedown",H,O),E.addEventListener("mousemove",X,O),E.addEventListener("mousemove",W,O),E.addEventListener("mouseup",pt,O),()=>{E.removeEventListener("mousedown",H,O),E.removeEventListener("mousemove",X,O),E.removeEventListener("mousemove",W,O),E.removeEventListener("mouseup",pt,O)}}},[lt,St,ct]),C.useEffect(()=>{const v=h.current,_=a.current,E=l.current,D=lt===null||lt===1;if(!D||!v||!_||!E){D||(x(null),A([]));return}const k=10,H=8;function X($,M){const I=Et.filter(P=>P.type==="trendline"&&P.point1&&P.point2);for(let P=I.length-1;P>=0;P--){const R=I[P],N=v.timeScale().timeToCoordinate(R.point1.time),j=_.priceToCoordinate(R.point1.price),B=v.timeScale().timeToCoordinate(R.point2.time),U=_.priceToCoordinate(R.point2.price);if(N==null||j==null||B==null||U==null)continue;const K=Math.hypot($-N,M-j),mt=Math.hypot($-B,M-U);if(K<k)return{object:R,mode:"handle1"};if(mt<k)return{object:R,mode:"handle2"};if(sf($,M,N,j,B,U)<H)return{object:R,mode:"line"}}return null}const pt=$=>{$.preventDefault(),$.stopPropagation();const M=E.getBoundingClientRect(),I=$.clientX-M.left,P=$.clientY-M.top,R=X(I,P);R?(x(R.object),J.current=R.mode,R.mode==="line"&&(F.current={x:I,y:P,point1:{...R.object.point1},point2:{...R.object.point2}})):(x(null),J.current=null)},O=$=>{if(!J.current)return;const M=Y.current;if(!M||!M.point1||!M.point2)return;const I=E.getBoundingClientRect(),P=$.clientX-I.left,R=$.clientY-I.top;let N=v.timeScale().coordinateToTime(P);const j=_.coordinateToPrice(R);if(!(N==null||j==null)&&(N=kt(N),N!=null)){if(J.current==="handle1"){const B={time:N,price:j},U=zt([{time:B.time,value:B.price},{time:M.point2.time,value:M.point2.price}]);U.length>0&&M.series.setData(U);const K={...M,point1:B};St(mt=>{const ot=mt.map(yt=>yt===M?K:yt);return u.current=ot,ot}),x(K),Y.current=K}else if(J.current==="handle2"){const B={time:N,price:j},U=zt([{time:M.point1.time,value:M.point1.price},{time:B.time,value:B.price}]);U.length>0&&M.series.setData(U);const K={...M,point2:B};St(mt=>{const ot=mt.map(yt=>yt===M?K:yt);return u.current=ot,ot}),x(K),Y.current=K}else if(J.current==="line"){const B=F.current;if(!B)return;const U=v.timeScale().coordinateToTime(B.x),K=_.coordinateToPrice(B.y);if(U==null||K==null)return;const mt=N-U,ot=j-K,yt={time:kt(B.point1.time+mt),price:B.point1.price+ot},ue={time:kt(B.point2.time+mt),price:B.point2.price+ot},fe=zt([{time:yt.time,value:yt.price},{time:ue.time,value:ue.price}]);fe.length>0&&M.series.setData(fe);const Yt={...M,point1:yt,point2:ue};St(ye=>{const Me=ye.map(ri=>ri===M?Yt:ri);return u.current=Me,Me}),x(Yt),Y.current=Yt}}},W=()=>{J.current=null,F.current=null},ht={capture:!0,passive:!1};return E.addEventListener("mousedown",pt,ht),E.addEventListener("mousemove",O,ht),E.addEventListener("mouseup",W,ht),()=>{E.removeEventListener("mousedown",pt,ht),E.removeEventListener("mousemove",O,ht),E.removeEventListener("mouseup",W,ht)}},[lt,Et,St]),C.useEffect(()=>{const v=h.current,_=a.current;if(!v||!_)return;const E=()=>{const k=g;if(!k||k.type!=="trendline"||!k.point1||!k.point2){A([]);return}const H=v.timeScale(),X=H.timeToCoordinate(k.point1.time),pt=_.priceToCoordinate(k.point1.price),O=H.timeToCoordinate(k.point2.time),W=_.priceToCoordinate(k.point2.price);X!=null&&pt!=null&&O!=null&&W!=null?A([{x:X,y:pt},{x:O,y:W}]):A([])};E();const D=v.timeScale();return D.subscribeVisibleTimeRangeChange(E),()=>{D.unsubscribeVisibleTimeRangeChange(E)}},[g]),C.useEffect(()=>{!h.current||!a.current||u.current.forEach(v=>{v.series&&v.series.applyOptions({visible:Lt}),v.priceLine&&v.priceLine.applyOptions(Lt?{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(_=>{try{_.applyOptions({lineVisible:Lt,axisLabelVisible:Lt})}catch{}}),v.type==="rectangle"&&v.series&&v.series.applyOptions({visible:Lt}),v.type==="parallellines"&&(v.baseLine&&v.baseLine.applyOptions({visible:Lt}),v.parallelLine&&v.parallelLine.applyOptions({visible:Lt}),v.firstLine&&v.firstLine.applyOptions({visible:Lt}),v.secondLine&&v.secondLine.applyOptions({visible:Lt}))})},[Lt,Et]),C.useEffect(()=>{!Lt&&g&&(x(null),A([]))},[Lt,g]),C.useEffect(()=>{if(u.current.length>Et.length){const v=u.current.filter((_,E)=>!Et.includes(_));g&&v.some(_=>_===g)&&(x(null),A([])),v.forEach(_=>{if(_.series&&h.current?.removeSeries(_.series),_.priceLine&&a.current?.removePriceLine(_.priceLine),_.type==="fibonacci"&&_.priceLines&&_.priceLines.forEach(E=>{try{a.current?.removePriceLine(E)}catch{}}),_.type==="rectangle"&&_.series)try{h.current?.removeSeries(_.series)}catch{}if(_.type==="parallellines")try{_.baseLine&&h.current?.removeSeries(_.baseLine),_.parallelLine&&h.current?.removeSeries(_.parallelLine),_.firstLine&&h.current?.removeSeries(_.firstLine),_.secondLine&&h.current?.removeSeries(_.secondLine)}catch{}}),u.current=Et}},[Et,g]),C.useEffect(()=>{const v=a.current;return v?(tt.current.forEach(E=>{try{v.removePriceLine(E)}catch{}}),tt.current=[],xt.filter(E=>E.symbol===st).forEach(E=>{const D=parseFloat(E.price);if(isNaN(D))return;const H=E.type==="BUY"?"#26A69A":"#EF5350",X=v.createPriceLine({price:D,color:H,lineWidth:2,lineStyle:0,axisLabelVisible:!0,title:`${E.type} ${E.volume} @ ${E.price}`,textColor:H});tt.current.push(X)}),()=>{tt.current.forEach(E=>{try{v.removePriceLine(E)}catch{}}),tt.current=[]}):void 0},[xt,st]),w.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden",width:"100%",height:"100%"},children:w.jsx("div",{ref:l,style:{flex:1,width:"100%",height:"100%",position:"relative",cursor:lt===1||lt!==null?"crosshair":"default",minHeight:0,minWidth:0},onDoubleClick:v=>{h.current&&!p.current&&(v.preventDefault(),v.stopPropagation(),h.current.timeScale().fitContent(),vt(h.current.timeScale().getVisibleRange()))},children:Lt&&g?.type==="trendline"&&g?.point1&&g?.point2&&L.length===2&&w.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,pointerEvents:"none"},"aria-hidden":!0,children:L.map((v,_)=>w.jsx("div",{style:{position:"absolute",width:10,height:10,borderRadius:"50%",border:"2px solid white",backgroundColor:"#22c55e",boxShadow:"0 1px 3px rgba(0,0,0,0.3)",left:v.x-5,top:v.y-5}},_))})})})}),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 qo({style:s,className:t}){const{selectedSymbol:e,setSelectedSymbol:i,symbols:n,symbolsLoading:r}=oe(),[o,l]=C.useState(!1),[h,a]=C.useState(""),[c,u]=C.useState(-1),p=C.useRef(null),b=C.useRef(null);C.useEffect(()=>{const g=x=>{p.current&&!p.current.contains(x.target)&&(l(!1),a(""))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),C.useEffect(()=>{o&&b.current&&b.current.focus()},[o]);const d=n.filter(g=>g.symbol.toLowerCase().includes(h.toLowerCase())),f=d.filter(g=>!g.symbol.endsWith("USDT")),m=d.filter(g=>g.symbol.endsWith("USDT")),S=g=>{i(g),l(!1),a("")};return n.find(g=>g.symbol===e),w.jsxs("div",{ref:p,style:{...gt.container,...s},className:t,children:[w.jsxs("button",{style:gt.button,onClick:()=>l(!o),onMouseEnter:g=>Object.assign(g.currentTarget.style,gt.buttonHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:[w.jsx("span",{children:r?"Loading...":e||"Select Coin"}),w.jsx("span",{style:{...gt.arrow,...o?gt.arrowOpen:{}},children:"▼"})]}),o&&w.jsxs("div",{style:gt.dropdown,children:[w.jsx("div",{style:gt.searchContainer,children:w.jsx("input",{ref:b,style:gt.searchInput,type:"text",placeholder:"Search symbol...",value:h,onChange:g=>a(g.target.value)})}),w.jsx("div",{style:gt.list,children:d.length===0?w.jsx("div",{style:gt.empty,children:"No symbols found"}):w.jsxs(w.Fragment,{children:[f.length>0&&w.jsxs(w.Fragment,{children:[w.jsx("div",{style:gt.categoryLabel,children:"Forex & Metals"}),f.map(g=>w.jsxs("div",{style:{...gt.item,...g.symbol===e?gt.itemSelected:{}},onClick:()=>S(g.symbol),onMouseEnter:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="#334155")},onMouseLeave:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="transparent")},children:[w.jsx("span",{style:gt.symbolName,children:g.symbol}),g.bid&&w.jsx("span",{style:{...gt.symbolPrice,...parseFloat(g.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(g.bid).toFixed(5)})]},g.symbol))]}),m.length>0&&w.jsxs(w.Fragment,{children:[w.jsx("div",{style:gt.categoryLabel,children:"Crypto"}),m.map(g=>w.jsxs("div",{style:{...gt.item,...g.symbol===e?gt.itemSelected:{}},onClick:()=>S(g.symbol),onMouseEnter:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="#334155")},onMouseLeave:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="transparent")},children:[w.jsx("span",{style:gt.symbolName,children:g.symbol}),g.bid&&w.jsx("span",{style:{...gt.symbolPrice,...parseFloat(g.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(g.bid).toFixed(2)})]},g.symbol))]})]})})]})]})}const ae={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"}},rf=[.01,.05,.1,.5,1];function Ho({value:s,onChange:t,min:e=.01,max:i=100,step:n=.01,presets:r=rf,showPresets:o=!0,showLabel:l=!0,label:h="Vol",style:a,className:c}){const[u,p]=C.useState(.1),b=s!==void 0?s:u,d=C.useCallback(g=>{const x=Math.max(e,Math.min(i,parseFloat(g)||e)),L=Math.round(x/n)*n,A=parseFloat(L.toFixed(8));s!==void 0||p(A),t?.(A)},[e,i,n,s,t]),f=()=>d(b+n),m=()=>d(b-n),S=(b>=1,b.toFixed(2));return w.jsxs("div",{style:{...ae.container,...a},className:c,children:[l&&w.jsx("span",{style:ae.label,children:h}),w.jsx("button",{style:ae.btn,onClick:m,onMouseEnter:g=>Object.assign(g.currentTarget.style,ae.btnHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:"−"}),w.jsx("input",{style:ae.input,type:"text",value:S,onChange:g=>{const x=g.target.value;if(x===""||x==="."||x==="0.")return;const L=parseFloat(x);isNaN(L)||d(L)},onBlur:()=>d(b)}),w.jsx("button",{style:ae.btn,onClick:f,onMouseEnter:g=>Object.assign(g.currentTarget.style,ae.btnHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:"+"}),o&&r&&r.length>0&&w.jsx("div",{style:ae.presets,children:r.map(g=>w.jsx("button",{style:{...ae.preset,...Math.abs(b-g)<1e-4?ae.presetActive:{}},onClick:()=>d(g),onMouseEnter:x=>{Math.abs(b-g)>=1e-4&&Object.assign(x.currentTarget.style,{borderColor:"#3b82f6"})},onMouseLeave:x=>{Math.abs(b-g)>=1e-4&&(x.currentTarget.style.borderColor="#334155")},children:g},g))})]})}const Ht={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 $o({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}=oe(),[b,d]=C.useState(""),[f,m]=C.useState(!1),[S,g]=C.useState("price"),x=s!==void 0?s:b,L=e!==void 0?e:f,A=n!==void 0?n:S,J=C.useCallback(V=>{e!==void 0||m(V),i?.(V)},[e,i]),F=C.useCallback(V=>{n!==void 0||g(V),r?.(V)},[n,r]),Y=C.useCallback(V=>{s!==void 0||d(V),t?.(V)},[s,t]),Q=V=>{const at=V.target.value;if(at===""||at==="."||at==="0."){Y(at);return}const Bt=parseFloat(at);isNaN(Bt)||Y(at)},Tt=A==="price"?p?.bid?parseFloat(p.bid).toFixed(5):"0.00000":"50";return w.jsxs("div",{style:{...Ht.container,...c},className:u,children:[h&&w.jsx("span",{style:Ht.label,children:a}),o&&w.jsx("button",{style:{...Ht.toggle,...L?Ht.toggleOn:Ht.toggleOff},onClick:()=>J(!L),children:w.jsx("div",{style:{...Ht.toggleKnob,...L?Ht.knobOn:Ht.knobOff}})}),(L||!o)&&w.jsxs("div",{style:Ht.inputGroup,children:[w.jsx("input",{style:Ht.input,type:"text",value:x,onChange:Q,placeholder:Tt,onFocus:V=>V.currentTarget.style.borderColor="#EF5350",onBlur:V=>V.currentTarget.style.borderColor="#334155"}),l&&w.jsxs(w.Fragment,{children:[w.jsx("button",{style:{...Ht.modeBtn,...A==="price"?Ht.modeBtnActive:{}},onClick:()=>F("price"),children:"Price"}),w.jsx("button",{style:{...Ht.modeBtn,...A==="pips"?Ht.modeBtnActive:{}},onClick:()=>F("pips"),children:"Pips"})]})]})]})}const $t={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 jo({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}=oe(),[b,d]=C.useState(""),[f,m]=C.useState(!1),[S,g]=C.useState("price"),x=s!==void 0?s:b,L=e!==void 0?e:f,A=n!==void 0?n:S,J=C.useCallback(V=>{e!==void 0||m(V),i?.(V)},[e,i]),F=C.useCallback(V=>{n!==void 0||g(V),r?.(V)},[n,r]),Y=C.useCallback(V=>{s!==void 0||d(V),t?.(V)},[s,t]),Q=V=>{const at=V.target.value;if(at===""||at==="."||at==="0."){Y(at);return}const Bt=parseFloat(at);isNaN(Bt)||Y(at)},Tt=A==="price"?p?.ask?parseFloat(p.ask).toFixed(5):"0.00000":"50";return w.jsxs("div",{style:{...$t.container,...c},className:u,children:[h&&w.jsx("span",{style:$t.label,children:a}),o&&w.jsx("button",{style:{...$t.toggle,...L?$t.toggleOn:$t.toggleOff},onClick:()=>J(!L),children:w.jsx("div",{style:{...$t.toggleKnob,...L?$t.knobOn:$t.knobOff}})}),(L||!o)&&w.jsxs("div",{style:$t.inputGroup,children:[w.jsx("input",{style:$t.input,type:"text",value:x,onChange:Q,placeholder:Tt,onFocus:V=>V.currentTarget.style.borderColor="#26A69A",onBlur:V=>V.currentTarget.style.borderColor="#334155"}),l&&w.jsxs(w.Fragment,{children:[w.jsx("button",{style:{...$t.modeBtn,...A==="price"?$t.modeBtnActive:{}},onClick:()=>F("price"),children:"Price"}),w.jsx("button",{style:{...$t.modeBtn,...A==="pips"?$t.modeBtnActive:{}},onClick:()=>F("pips"),children:"Pips"})]})]})]})}const of=[{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:"─"}],ce={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 Jo({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}=oe(),[b,d]=C.useState(null),f=i||of,m=x=>{h(l===x?null:x)},S=()=>{p([]),h(null)},g=()=>{c(!a)};return w.jsxs("div",{style:{...ce.container,...r},className:o,children:[s&&w.jsx("span",{style:ce.label,children:n}),f.map(x=>w.jsxs("button",{style:{...ce.btn,...l===x.id?ce.btnActive:{}},onClick:()=>m(x.id),onMouseEnter:L=>{d(x.id),l!==x.id&&Object.assign(L.currentTarget.style,ce.btnHover)},onMouseLeave:L=>{d(null),l!==x.id&&(L.currentTarget.style.borderColor="#334155",L.currentTarget.style.backgroundColor="#1e293b",L.currentTarget.style.color="#94a3b8")},title:x.name,children:[x.icon,b===x.id&&w.jsx("div",{style:ce.tooltip,children:x.name})]},x.id)),(t||e)&&w.jsx("div",{style:ce.divider}),e&&w.jsx("button",{style:{...ce.visibilityBtn,...a?{}:{color:"#64748b",backgroundColor:"#0f172a"}},onClick:g,onMouseEnter:x=>{x.currentTarget.style.borderColor="#3b82f6"},onMouseLeave:x=>{x.currentTarget.style.borderColor="#334155"},title:a?"Hide Drawings":"Show Drawings",children:a?"👁":"○"}),t&&w.jsx("button",{style:ce.deleteBtn,onClick:S,onMouseEnter:x=>Object.assign(x.currentTarget.style,ce.deleteBtnHover),onMouseLeave:x=>{x.currentTarget.style.borderColor="#334155",x.currentTarget.style.backgroundColor="#1e293b",x.currentTarget.style.color="#94a3b8"},title:"Delete All Drawings",children:"🗑"})]})}const Ko={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 lf({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:b,takeProfitEnabled:d,onTakeProfitEnabledChange:f,coinSelectorProps:m={},volumeControlProps:S={},stopLossProps:g={},takeProfitProps:x={},drawingToolsProps:L={},style:A,className:J}){const F=[];s&&F.push(w.jsx(qo,{...m},"coin")),t&&F.push(w.jsx(Ho,{value:o,onChange:l,...S},"volume")),e&&F.push(w.jsx($o,{value:h,onChange:a,enabled:c,onEnabledChange:u,...g},"sl")),i&&F.push(w.jsx(jo,{value:p,onChange:b,enabled:d,onEnabledChange:f,...x},"tp")),n&&F.push(w.jsx(Jo,{...L},"draw"));const Y=[];return F.forEach((Q,Tt)=>{Y.push(Q),r&&Tt<F.length-1&&Y.push(w.jsx("div",{style:Ko.divider},`div-${Tt}`))}),w.jsx("div",{style:{...Ko.toolbar,...A},className:J,children:Y})}const hf=[{label:"M1",value:"M1"},{label:"M5",value:"M5"},{label:"M15",value:"M15"},{label:"M30",value:"M30"},{label:"H1",value:"H1"},{label:"H4",value:"H4"},{label:"D1",value:"D1"},{label:"W1",value:"W1"}],ln={container:{display:"inline-flex",alignItems:"center",gap:"2px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},btn:{padding:"4px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"},btnActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"}};function af({style:s,className:t}){const{selectedTimeframe:e,setSelectedTimeframe:i}=oe();return w.jsx("div",{style:{...ln.container,...s},className:t,children:hf.map(n=>w.jsx("button",{style:{...ln.btn,...e===n.value?ln.btnActive:{}},onClick:()=>i(n.value),onMouseEnter:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#3b82f6")},onMouseLeave:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#334155")},children:n.label},n.value))})}const cf=[{label:"Candles",value:"candles",icon:"📊"},{label:"Line",value:"line",icon:"📈"},{label:"Area",value:"area",icon:"▤"},{label:"Bars",value:"bars",icon:"▥"}],hn={container:{display:"inline-flex",alignItems:"center",gap:"2px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},btn:{padding:"4px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"3px"},btnActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"}};function uf({style:s,className:t}){const{chartType:e,setChartType:i}=oe();return w.jsx("div",{style:{...hn.container,...s},className:t,children:cf.map(n=>w.jsxs("button",{style:{...hn.btn,...e===n.value?hn.btnActive:{}},onClick:()=>i(n.value),onMouseEnter:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#3b82f6")},onMouseLeave:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#334155")},title:n.label,children:[w.jsx("span",{children:n.icon}),w.jsx("span",{children:n.label})]},n.value))})}const Vt={container:{display:"inline-flex",alignItems:"center",gap:"6px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},priceBox:{display:"flex",flexDirection:"column",alignItems:"center",padding:"4px 10px",backgroundColor:"#0f172a",borderRadius:"4px",minWidth:"80px"},priceLabel:{fontSize:"9px",color:"#64748b",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},priceValue:{fontSize:"13px",fontWeight:700,fontFamily:"monospace"},spread:{fontSize:"9px",color:"#64748b",padding:"0 4px",display:"flex",flexDirection:"column",alignItems:"center",gap:"1px"},spreadLabel:{fontSize:"8px",textTransform:"uppercase",letterSpacing:"0.05em"},spreadValue:{fontSize:"10px",fontWeight:700,color:"#94a3b8"},sellBtn:{padding:"6px 16px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"4px",color:"#fca5a5",fontSize:"12px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease",textTransform:"uppercase",letterSpacing:"0.03em",minWidth:"70px"},sellBtnHover:{backgroundColor:"#991b1b",borderColor:"#EF5350"},buyBtn:{padding:"6px 16px",backgroundColor:"#14532d",border:"1px solid #166534",borderRadius:"4px",color:"#86efac",fontSize:"12px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease",textTransform:"uppercase",letterSpacing:"0.03em",minWidth:"70px"},buyBtnHover:{backgroundColor:"#166534",borderColor:"#26A69A"},status:{fontSize:"10px",padding:"2px 8px",borderRadius:"3px",fontWeight:600,whiteSpace:"nowrap"}};function ff({volume:s=.1,stopLoss:t,takeProfit:e,onTradeExecuted:i,style:n,className:r}){const{selectedSymbol:o,currentSymbolData:l,setOrders:h,setUserBalance:a}=oe(),[c,u]=C.useState(null),p=parseFloat(l?.bid||0),b=parseFloat(l?.ask||0),d=b>0&&p>0?Math.abs(b-p):0,f=g=>!g||g===0?"-.-----":g>=1e3?g.toFixed(2):g>=1?g.toFixed(4):g.toFixed(5),m=g=>g===0?"-":g>=1?g.toFixed(1):g>=.01?g.toFixed(3):(g*1e4).toFixed(1)+"p",S=C.useCallback(g=>{if(!o)return;const x=g==="BUY"?b:p;if(!x||x<=0){u({type:"error",message:"No price available"});return}const L={id:Date.now().toString(),ticket:Math.floor(Math.random()*9e5)+1e5,symbol:o,type:g,volume:s,price:x,stopLoss:t?parseFloat(t):null,takeProfit:e?parseFloat(e):null,status:"OPEN",profit:0,swap:0,openAt:new Date().toISOString(),time:new Date().toLocaleTimeString()};h(J=>[...J,L]);const A=s*x*.01;a(J=>J-A),u({type:"success",message:`${g} executed`}),i?.(L),setTimeout(()=>u(null),3e3)},[o,b,p,s,t,e,h,a,i]);return w.jsxs("div",{style:{...Vt.container,...n},className:r,children:[w.jsx("button",{style:Vt.sellBtn,onClick:()=>S("SELL"),onMouseEnter:g=>{Object.assign(g.currentTarget.style,Vt.sellBtnHover)},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#7f1d1d",g.currentTarget.style.borderColor="#991b1b"},children:"Sell"}),w.jsxs("div",{style:Vt.priceBox,children:[w.jsx("span",{style:Vt.priceLabel,children:"Bid"}),w.jsx("span",{style:{...Vt.priceValue,color:"#EF5350"},children:f(p)})]}),w.jsxs("div",{style:Vt.spread,children:[w.jsx("span",{style:Vt.spreadLabel,children:"Spread"}),w.jsx("span",{style:Vt.spreadValue,children:m(d)})]}),w.jsxs("div",{style:Vt.priceBox,children:[w.jsx("span",{style:Vt.priceLabel,children:"Ask"}),w.jsx("span",{style:{...Vt.priceValue,color:"#26A69A"},children:f(b)})]}),w.jsx("button",{style:Vt.buyBtn,onClick:()=>S("BUY"),onMouseEnter:g=>{Object.assign(g.currentTarget.style,Vt.buyBtnHover)},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#14532d",g.currentTarget.style.borderColor="#166534"},children:"Buy"}),c&&w.jsx("span",{style:{...Vt.status,backgroundColor:c.type==="success"?"#14532d":"#7f1d1d",color:c.type==="success"?"#86efac":"#fca5a5",border:`1px solid ${c.type==="success"?"#166534":"#991b1b"}`},children:c.message})]})}const Z={container:{fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",backgroundColor:"#0f172a",borderTop:"1px solid #1e293b",fontSize:"11px",overflow:"hidden",display:"flex",flexDirection:"column"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",backgroundColor:"#0f172a",borderBottom:"1px solid #1e293b"},headerTitle:{color:"#94a3b8",fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em"},summary:{display:"flex",gap:"16px",fontSize:"11px"},summaryItem:{display:"flex",gap:"4px",alignItems:"center"},summaryLabel:{color:"#64748b",fontWeight:600},summaryValue:{fontWeight:700,fontFamily:"monospace"},table:{width:"100%",borderCollapse:"collapse"},th:{padding:"4px 8px",textAlign:"left",color:"#64748b",fontWeight:700,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em",borderBottom:"1px solid #1e293b",whiteSpace:"nowrap"},td:{padding:"4px 8px",color:"#cbd5e1",borderBottom:"1px solid #1e293b",whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"11px"},closeBtn:{padding:"2px 8px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"3px",color:"#fca5a5",fontSize:"10px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease"},emptyRow:{padding:"16px",textAlign:"center",color:"#475569",fontSize:"12px"},scrollArea:{overflowY:"auto",maxHeight:"200px"},typeBuy:{color:"#26A69A",fontWeight:700},typeSell:{color:"#EF5350",fontWeight:700}};function df({style:s,className:t,maxHeight:e=200}){const{orders:i,setOrders:n,symbols:r,accountSummary:o,setUserBalance:l}=oe(),[h,a]=C.useState(null),c=i.filter(f=>f.status==="OPEN"||!f.closeAt),u=C.useCallback((f,m)=>{const S=r.find(g=>g.symbol===f);return S?parseFloat(m==="BUY"?S.bid||0:S.ask||0):0},[r]),p=C.useCallback(f=>{if(h)return;a(f.id);const m=u(f.symbol,f.type),g=(f.type==="BUY"?m-f.price:f.price-m)*f.volume,x=f.volume*f.price*.01;n(L=>L.filter(A=>A.id!==f.id)),l(L=>L+x+g),a(null)},[h,u,n,l]),b=f=>{const m=parseFloat(f);return!m||isNaN(m)?"-":m>=1e3?m.toFixed(2):m>=1?m.toFixed(4):m.toFixed(5)},d=f=>{const m=parseFloat(f);return isNaN(m)?"-":(m>=0?"+":"")+m.toFixed(2)};return w.jsxs("div",{style:{...Z.container,...s},className:t,children:[w.jsxs("div",{style:Z.header,children:[w.jsxs("span",{style:Z.headerTitle,children:["Positions (",c.length,")"]}),w.jsxs("div",{style:Z.summary,children:[w.jsxs("div",{style:Z.summaryItem,children:[w.jsx("span",{style:Z.summaryLabel,children:"Balance:"}),w.jsxs("span",{style:{...Z.summaryValue,color:"#e2e8f0"},children:["$",o?.balance?.toFixed(2)||"0.00"]})]}),w.jsxs("div",{style:Z.summaryItem,children:[w.jsx("span",{style:Z.summaryLabel,children:"Equity:"}),w.jsxs("span",{style:{...Z.summaryValue,color:(o?.equity||0)>=(o?.balance||0)?"#26A69A":"#EF5350"},children:["$",o?.equity?.toFixed(2)||"0.00"]})]}),w.jsxs("div",{style:Z.summaryItem,children:[w.jsx("span",{style:Z.summaryLabel,children:"Free:"}),w.jsxs("span",{style:{...Z.summaryValue,color:"#94a3b8"},children:["$",o?.freeMargin?.toFixed(2)||"0.00"]})]})]})]}),w.jsx("div",{style:{...Z.scrollArea,maxHeight:e},children:w.jsxs("table",{style:Z.table,children:[w.jsx("thead",{children:w.jsxs("tr",{children:[w.jsx("th",{style:Z.th,children:"Symbol"}),w.jsx("th",{style:Z.th,children:"Type"}),w.jsx("th",{style:Z.th,children:"Volume"}),w.jsx("th",{style:Z.th,children:"Open Price"}),w.jsx("th",{style:Z.th,children:"Current"}),w.jsx("th",{style:Z.th,children:"SL"}),w.jsx("th",{style:Z.th,children:"TP"}),w.jsx("th",{style:Z.th,children:"Profit"}),w.jsx("th",{style:Z.th,children:"Action"})]})}),w.jsx("tbody",{children:c.length===0?w.jsx("tr",{children:w.jsx("td",{colSpan:9,style:Z.emptyRow,children:"No open positions"})}):c.map(f=>{const m=u(f.symbol,f.type),S=f.profit||0;return w.jsxs("tr",{children:[w.jsx("td",{style:{...Z.td,fontWeight:700,color:"#e2e8f0"},children:f.symbol}),w.jsx("td",{style:{...Z.td,...f.type==="BUY"?Z.typeBuy:Z.typeSell},children:f.type}),w.jsx("td",{style:Z.td,children:f.volume}),w.jsx("td",{style:Z.td,children:b(f.price)}),w.jsx("td",{style:Z.td,children:b(m)}),w.jsx("td",{style:Z.td,children:f.stopLoss?b(f.stopLoss):"-"}),w.jsx("td",{style:Z.td,children:f.takeProfit?b(f.takeProfit):"-"}),w.jsx("td",{style:{...Z.td,color:S>=0?"#26A69A":"#EF5350",fontWeight:700},children:d(S)}),w.jsx("td",{style:Z.td,children:w.jsx("button",{style:{...Z.closeBtn,...h===f.id?{opacity:.5,cursor:"not-allowed"}:{}},onClick:()=>p(f),disabled:h===f.id,onMouseEnter:g=>{h!==f.id&&(g.currentTarget.style.backgroundColor="#991b1b")},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#7f1d1d"},children:h===f.id?"...":"Close"})})]},f.id)})})]})})]})}const pf="1.2.1";G.Chart=nf,G.ChartTypeSelector=uf,G.CoinSelector=qo,G.DrawingTools=Jo,G.PositionsPanel=df,G.SYMBOL_CONFIG=Bo,G.StopLoss=$o,G.TakeProfit=jo,G.TimeframeSelector=af,G.TradePanel=ff,G.TradingProvider=$u,G.TradingToolbar=lf,G.VolumeControl=Ho,G.alignToTimeframe=ze,G.detectGaps=ju,G.getSymbolConfig=ni,G.is24x7Symbol=Gu,G.isCryptoSymbol=Yu,G.isForexSymbol=Xu,G.isWithinTradingSession=Ju,G.normalizeCandleTimes=Ao,G.normalizeTime=kt,G.processCandles=zo,G.processSingleCandle=Uo,G.setChartBaseUrl=Wo,G.setSocketBaseUrl=Oo,G.timeframeToSeconds=rn,G.useTrading=oe,G.validateTimeOrdering=Ku,G.version=pf,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(Y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],w):(Y=typeof globalThis<"u"?globalThis:Y||self,w(Y.ChartSDK={},Y.jsxRuntime,Y.React))})(this,(function(Y,w,C){"use strict";var ji=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 we(s,t){return s.width===t.width&&s.height===t.height}var tl=(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 el(s){return new tl(s)}var il=(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;we(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=we(this.bitmapSize,i)?null:i;e===null&&n===null||e!==null&&n!==null&&we(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}nl().then(function(e){return e?t._initResizeObserver():t._initDevicePixelRatioObservable()})},s.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var e=cn(this._canvasElement);if(e===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=el(e),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},s.prototype._invalidateBitmapSize=function(){var t,e;if(this._canvasElement!==null){var i=cn(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?rl(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 sl(s,t){return new il(s,t.transform,t.options)}function cn(s){return s.ownerDocument.defaultView}function nl(){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 rl(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 ol=(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 Se(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 ol(n,e,i)}const ll={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},hl={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},al={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},cl={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},ul={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},fl={color:"#26a69a",base:0},un={color:"#2196f3"},fn={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 dn,pn;function xe(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 mn(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 be(s,t){if(!s)throw new Error("Assertion failed"+(t?": "+t:""))}function Ft(s){if(s===void 0)throw new Error("Value is undefined");return s}function E(s){if(s===null)throw new Error("Value is null");return s}function Oe(s){return E(Ft(s))}(function(s){s[s.Simple=0]="Simple",s[s.WithSteps=1]="WithSteps",s[s.Curved=2]="Curved"})(dn||(dn={})),(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"})(pn||(pn={}));const bn={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 jt(s){return s<0?0:s>255?255:Math.round(s)||0}function gn(s){return s<=0||s>1?Math.min(Math.max(s,0),1):Math.round(1e4*s)/1e4}const dl=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,pl=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,ml=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,bl=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d*\.?\d+)\s*\)$/;function $e(s){(s=s.toLowerCase())in bn&&(s=bn[s]);{const t=bl.exec(s)||ml.exec(s);if(t)return[jt(parseInt(t[1],10)),jt(parseInt(t[2],10)),jt(parseInt(t[3],10)),gn(t.length<5?1:parseFloat(t[4]))]}{const t=pl.exec(s);if(t)return[jt(parseInt(t[1],16)),jt(parseInt(t[2],16)),jt(parseInt(t[3],16)),1]}{const t=dl.exec(s);if(t)return[jt(17*parseInt(t[1],16)),jt(17*parseInt(t[2],16)),jt(17*parseInt(t[3],16)),1]}throw new Error(`Cannot parse color: ${s}`)}function vn(s){return .199*s[0]+.687*s[1]+.114*s[2]}function hi(s){const t=$e(s);return{t:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,i:vn(t)>160?"black":"white"}}class Ct{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 Qt(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]:Qt(s[i],e[i]));return s}function ie(s){return typeof s=="number"&&isFinite(s)}function Ie(s){return typeof s=="number"&&s%1==0}function Ue(s){return typeof s=="string"}function ai(s){return typeof s=="boolean"}function pe(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"?pe(n):n);return e}function gl(s){return s!==null}function We(s){return s===null?void 0:s}const Ki="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function ze(s,t,e){return t===void 0&&(t=Ki),`${e=e!==void 0?`${e} `:""}${s}px ${t}`}class vl{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=ze(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 Xi{constructor(){this.Y=[]}Z(t){this.Y=t}X(t,e,i){this.Y.forEach((n=>{n.X(t,e,i)}))}}class Zt{X(t,e,i){t.useBitmapCoordinateSpace((n=>this.K(n,e,i)))}}class yl extends Zt{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,d=c.st*i,b=h*i+o;t.moveTo(u,d),t.arc(u,d,b,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 wl(){return{it:[{nt:0,st:0,ot:0,_t:0}],lt:"",rt:"",ht:0,et:0,tt:null}}const Sl={from:0,to:1};class xl{constructor(t,e){this.ut=new Xi,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(wl),this.ct=this.dt.map((i=>{const n=new yl;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=E(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=Sl}))}}class _l extends Zt{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,xe(t,this.zt.Lt.Nt),(function(a,c,u,d){a.beginPath();const b=a.lineWidth%2?.5:0;a.moveTo(c+b,u),a.lineTo(c+b,d),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,xe(t,this.zt.Et.Nt),mn(t,h,0,e.width))}}class Cl{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 _l(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=E(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 El(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 ci(s,t,e,i,n,r){s.save(),s.globalCompositeOperation="copy",s.fillStyle=r,s.fillRect(t,e,i,n),s.restore()}function yn(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 wn(s,t,e,i,n,r,o=0,l=[0,0,0,0],h=""){if(s.save(),!o||!h||h===r)return yn(s,t,e,i,n,l),s.fillStyle=r,s.fill(),void s.restore();const a=o/2;var c;yn(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 Sn(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 xn{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?wn(a,u.ti,u.ii,u.ni,u.si,o,u.ei,[u.ht,0,0,u.ht],o):wn(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,d=this.zt.bi?e.C:0,b=e.L+this.Xt.wi,p=e.B+this.Xt.gi,f=e.A,m=e.I,S=this.zt.Kt,g=e.P,x=i.Mi(o,S),M=Math.ceil(i.xi(o,S)),P=g+b+p,K=e.C+f+m+M+u,D=Math.max(1,Math.floor(c));let G=Math.round(P*c);G%2!=D%2&&(G+=1);const Z=d>0?Math.max(1,Math.floor(d*a)):0,Et=Math.round(K*a),$=Math.round(u*a),ct=(r=this.Xt.Si)!==null&&r!==void 0?r:this.Xt.ki,Nt=Math.round(ct*c)-Math.floor(.5*c),vt=Math.floor(Nt+D/2-G/2),lt=vt+G,ht=n==="right",ut=ht?h.width-d:d,Rt=ht?l.width-Z:Z;let Tt,St,xt;return ht?(Tt=Rt-Et,St=Rt-$,xt=ut-u-f-d):(Tt=Rt+Et,St=Rt+$,xt=ut+u+f),{Qt:ht,Jt:{ii:vt,li:Nt,ci:lt,ni:Et,si:G,ht:2*a,ei:Z,ti:Tt,ri:Rt,ai:St,oi:D,ui:l.width},di:{ii:vt/c,ci:lt/c,fi:xt,pi:x}}}}class ui{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||xn)(this.Ci,this.yi),this.Ri=new(t||xn)(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 Tl extends ui{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=hi(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 Ml=/[1-9]/g;class _n{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:d})=>(d.font=e.R,Math.round(e.Wi.xi(d,E(this.zt).Kt,Ml)))));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:d,horizontalPixelRatio:b,verticalPixelRatio:p})=>{const f=E(this.zt);d.fillStyle=f.t;const m=Math.round(a*b),S=Math.round(0*p),g=Math.round(c*b),x=Math.round(u*p),M=Math.round(2*b);if(d.beginPath(),d.moveTo(m,S),d.lineTo(m,x-M),d.arcTo(m,x,m+M,x,M),d.lineTo(g-M,x),d.arcTo(g,x,g,x-M,M),d.lineTo(g,S),d.fill(),f.hi){const P=Math.round(f.ki*b),K=S,D=Math.round((K+e.T)*p);d.fillStyle=f.V;const G=Math.max(1,Math.floor(b)),Z=Math.floor(.5*b);d.fillRect(P-Z,K,G,D-K)}})),t.useMediaCoordinateSpace((({context:d})=>{const b=E(this.zt),p=0+e.C+e.T+e.L+e.P/2;d.font=e.R,d.textAlign="left",d.textBaseline="middle",d.fillStyle=b.V;const f=e.Wi.Mi(d,"Apr0");d.translate(a+n,p+f),d.fillText(b.Kt,0,0)}))}}class kl{constructor(t,e,i){this.ft=!0,this.Wt=new _n,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(E(r)),t.yt=!0;const o=hi(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 Cn;(function(s){s[s.Normal=0]="Normal",s[s.Magnet=1]="Magnet",s[s.Hidden=2]="Hidden"})(Cn||(Cn={}));class Ll 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 xl(t,this),this.fn=((n,r)=>o=>{const l=r(),h=n();if(o===E(this.tn).vn())return{_t:h,ki:l};{const a=E(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 kl(this,t,i),this.wn=new Cl(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(gl),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 Tl(this,e,i),t.set(e,n)),n}}function fi(s){return s==="left"||s==="right"}class Pt{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 Pt(2)}static es(){return new Pt(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 En=".";function me(s,t){if(!ie(s))return"n/a";if(!Ie(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 di{constructor(t,e){if(e||(e=1),ie(t)&&Ie(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=En+me(+o.toFixed(this._s)*this.rs,r)}else i=Math.round(i*e)/e,r>0&&(n=En+me(0,r));return i.toFixed(0)+n}}class Tn extends di{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Ol{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 Mn(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),d=c;if(i.to-i.from<2){const b=n/2;l.beginPath();const p={nt:c.nt-b,st:c.st},f={nt:c.nt+b,st:c.st};l.moveTo(p.nt*h,p.st*a),l.lineTo(f.nt*h,f.st*a),o(s,u,p,f)}else{const b=(f,m)=>{o(s,u,d,m),l.beginPath(),u=f,d=m};let p=d;l.beginPath(),l.moveTo(c.nt*h,c.st*a);for(let f=i.from+1;f<i.to;++f){p=t[f];const m=r(s,p);switch(e){case 0:l.lineTo(p.nt*h,p.st*a);break;case 1:l.lineTo(p.nt*h,t[f-1].st*a),m!==u&&(b(m,p),l.lineTo(p.nt*h,t[f-1].st*a)),l.lineTo(p.nt*h,p.st*a);break;case 2:{const[S,g]=zl(t,f-1,f);l.bezierCurveTo(S.nt*h,S.st*a,g.nt*h,g.st*a,p.nt*h,p.st*a);break}}e!==1&&m!==u&&(b(m,p),l.moveTo(p.nt*h,p.st*a))}(d!==p||d===p&&e===1)&&o(s,u,d,p)}}const kn=6;function Gi(s,t){return{nt:s.nt-t.nt,st:s.st-t.st}}function Ln(s,t){return{nt:s.nt/t,st:s.st/t}}function zl(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=Ln(Gi(s[e],s[i]),kn),{nt:r.nt+o.nt,st:r.st+o.st}),Gi(s[e],Ln(Gi(s[n],s[t]),kn))]}function Pl(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 On extends Zt{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,xe(c,l),c.lineWidth=1,Mn(t,i,h,n,r,this.bs.bind(this),Pl.bind(null,a))}}function Yi(s,t,e){return Math.min(Math.max(s,t),e)}function pi(s,t,e){return t-s<=e}function zn(s){const t=Math.ceil(s);return t%2==0?t-1:t}class Qi{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=Yi(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 Nl extends On{constructor(){super(...arguments),this.Ts=new Qi}bs(t,e){return this.Ts.ws(t,{Ms:e.Ps,xs:"",Ss:"",ks:e.Rs,ys:t.bitmapSize.height})}}function Rl(s,t){const e=s.context;e.strokeStyle=t,e.stroke()}class Pn extends Zt{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,xe(a,l),a.lineJoin="round";const c=this.Vs.bind(this);r!==void 0&&Mn(t,e,r,i,n,c,Rl),h&&(function(u,d,b,p,f){const{horizontalPixelRatio:m,verticalPixelRatio:S,context:g}=u;let x=null;const M=Math.max(1,Math.floor(m))%2/2,P=b*S+M;for(let K=p.to-1;K>=p.from;--K){const D=d[K];if(D){const G=f(u,D);G!==x&&(g.beginPath(),x!==null&&g.fill(),g.fillStyle=G,x=G);const Z=Math.round(D.nt*m)+M,Et=D.st*S;g.moveTo(Z,Et),g.arc(Z,Et,P,0,2*Math.PI)}}g.fill()})(t,e,h,i,c)}}class Nn extends Pn{Vs(t,e){return e.lt}}function Rn(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 He=Rn.bind(null,!0),An=Rn.bind(null,!1);function Al(s,t){return s.ot<t}function Bl(s,t){return t<s.ot}function Bn(s,t,e){const i=t.Os(),n=t.ui(),r=He(s,i,Al),o=An(s,n,Bl);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 Zi{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=Bn(this.zs,i,this.Fs),this.Gs(t,e,n.Vt),this.Js())}}class mi extends Zi{constructor(t,e){super(t,e,!0)}Gs(t,e,i){e.Qs(this.zs,We(this.Ls)),t.te(this.zs,i,We(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 Dl extends mi{constructor(t,e){super(t,e),this.js=new Xi,this.re=new Nl,this.he=new Nn,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 Vl extends Zt{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,d=c+u-1,b=Math.min(l.de,l.fe),p=Math.max(l.de,l.fe),f=Math.round(b*i)-h,m=Math.round(p*i)+h,S=Math.max(m-f,this.oe);t.fillRect(c,f,u,S);const g=Math.ceil(1.5*this.ae);if(r){if(this.zt.ve){const K=a-g;let D=Math.max(f,Math.round(l.pe*i)-h),G=D+u-1;G>f+S-1&&(G=f+S-1,D=G-u+1),t.fillRect(K,D,c-K,G-D+1)}const x=a+g;let M=Math.max(f,Math.round(l.me*i)-h),P=M+u-1;P>f+S-1&&(P=f+S-1,M=P-u+1),t.fillRect(d+1,M,x-d,P-M+1)}}}_e(t){const e=Math.floor(t);return Math.max(e,Math.floor((function(i,n){return Math.floor(.3*i*n)})(E(this.zt).le,t)))}}class Dn extends Zi{constructor(t,e){super(t,e,!1)}Gs(t,e,i){e.Qs(this.zs,We(this.Ls)),t.be(this.zs,i,We(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 Fl extends Dn{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(),ve:t.openVisible,ue:t.thinBars,tt:this.Ls})}}class $l extends On{constructor(){super(...arguments),this.Ts=new Qi}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 Il extends Pn{constructor(){super(...arguments),this.Pe=new Qi}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 Ul extends mi{constructor(t,e){super(t,e),this.js=new Xi,this.Ve=new $l,this.Oe=new Il,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 Wl extends Zt{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 d=e[u];d.Ee!==l&&(n.fillStyle=d.Ee,l=d.Ee);const b=Math.round(Math.min(d.pe,d.me)*o),p=Math.round(Math.max(d.pe,d.me)*o),f=Math.round(d.de*o),m=Math.round(d.fe*o);let S=Math.round(r*d.nt)-a;const g=S+h-1;c!==null&&(S=Math.max(c+1,S),S=Math.min(S,g));const x=g-S+1;n.fillRect(S,f,x,b-f),n.fillRect(S,p+1,x,m-p),c=g}}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 d=Math.round(u.nt*r)-Math.floor(.5*this.ae);const b=d+this.ae-1,p=Math.round(Math.min(u.pe,u.me)*o),f=Math.round(Math.max(u.pe,u.me)*o);if(a!==null&&(d=Math.max(a+1,d),d=Math.min(d,b)),this.zt.le*r>2*h)El(n,d,p,b-d+1,f-p+1,h);else{const m=b-d+1;n.fillRect(d,p,m,f-p+1)}a=b}}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),d=Math.round(Math.max(c.pe,c.me)*o),b=Math.round(c.nt*r)-Math.floor(.5*this.ae),p=b+this.ae-1;if(c.ce!==l){const f=c.ce;n.fillStyle=f,l=f}this.zt._i&&(b+=h,u+=h,p-=h,d-=h),u>d||n.fillRect(b,u,p-b+1,d-u+1)}}}class Hl extends Dn{constructor(){super(...arguments),this.js=new Wl}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 ql{constructor(t,e){this.Fe=t,this.Li=e}X(t,e,i){this.Fe.draw(t,this.Li,e,i)}}class ts extends Zi{constructor(t,e,i){super(t,e,!1),this.wn=i,this.js=new ql(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,We(this.Ls))}Js(){this.wn.update({bars:this.zs.map(jl),barSpacing:this.Ns.St().le(),visibleRange:this.Ls},this.Es.W())}}function jl(s){return{x:s.nt,time:s.ot,originalData:s.He,barColor:s.ce}}class Kl extends Zt{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,d;t.fillStyle=h.ce,c<=r?(u=c,d=o):(u=r,d=c-Math.floor(n/2)+n),t.fillRect(a.Os,u,a.ui-a.Os+1,d-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 Xl extends mi{constructor(){super(...arguments),this.js=new Kl}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,E(this.Es.Ct()).Vt)};this.js.J(t)}}class Jl extends mi{constructor(){super(...arguments),this.js=new Nn}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 Gl=/[2-9]/g;class qe{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||Gl,r=String(e).replace(n,"0");if(this.tr.has(r))return Ft(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 Yl{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 Vn{constructor(t,e,i){this.ur=t,this.ar=new qe(50),this.cr=e,this.F=i,this.j=-1,this.Wt=new Yl(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 Ql extends Zt{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),xe(t,this.zt.Nt),mn(t,r,0,e.width))}}class es{constructor(t){this.Sr={st:0,V:"rgba(0, 0, 0, 0)",et:1,Nt:0,yt:!1},this.kr=new Ql,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 Zl extends es{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 th extends Zt{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 eh=[{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 Fn(s,t,e,i){return(function(n,r){if(n==="transparent")return n;const o=$e(n),l=o[3];return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${r*l})`})(s,e+(i-e)*t)}function $n(s,t){const e=s%2600/2600;let i;for(const h of eh)if(e>=h.Vr&&e<=h.Or){i=h;break}be(i!==void 0,"Last price animation internal logic error");const n=(e-i.Vr)/(i.Or-i.Vr);return{Rr:Fn(t,n,i.Ir,i.zr),Dr:Fn(t,n,i.Lr,i.Er),ht:(r=n,o=i.Br,l=i.Ar,o+(l-o)*r)};var r,o,l}class ih{constructor(t){this.Wt=new th,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=$n(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=$n(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 je(s,t){return zn(Math.min(Math.max(s,12),30)*t)}function Ke(s,t){switch(s){case"arrowDown":case"arrowUp":return je(t,1);case"circle":return je(t,.8);case"square":return je(t,.7)}}function In(s){return(function(t){const e=Math.ceil(t);return e%2!=0?e-1:e})(je(s,1))}function Un(s){return Math.max(je(s,.1),3)}function Wn(s,t,e){return t?s:e?Math.ceil(s/2):0}function Hn(s,t,e,i,n){const r=Ke("square",e),o=(r-1)/2,l=s-o,h=t-o;return i>=l&&i<=l+r&&n>=h&&n<=h+r}function qn(s,t,e,i){const n=(Ke("arrowUp",i)-1)/2*e.Jr,r=(zn(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 sh(s,t,e,i,n,r){return Hn(t,e,i,n,r)}class nh extends Zt{constructor(){super(...arguments),this.zt=null,this.ar=new qe,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=ze(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(oh(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),rh(l,t,e,i)}}}}function rh(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 qn(!1,r,o,n.Ks);case"arrowUp":return void qn(!0,r,o,n.Ks);case"circle":return void(function(l,h,a){const c=(Ke("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=Ke("square",a),u=(c-1)*h.Jr/2,d=h.nt-u,b=h.st-u;l.fillRect(d,b,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 oh(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 sh(0,i.nt,i.st,i.Ks,n,r);case"circle":return(function(o,l,h,a,c){const u=2+Ke("circle",h)/2,d=o-a,b=l-c;return Math.sqrt(d*d+b*b)<=u})(i.nt,i.st,i.Ks,n,r);case"square":return Hn(i.nt,i.st,i.Ks,n,r)}})(s,t,e)}function lh(s,t,e,i,n,r,o,l,h){const a=ie(e)?e:e.Se,c=ie(e)?e:e.Me,u=ie(e)?e:e.xe,d=ie(t.size)?Math.max(t.size,0):1,b=In(l.le())*d,p=b/2;switch(s.Ks=b,t.position){case"inBar":return s.st=o.Rt(a,h),void(s.Kt!==void 0&&(s.Kt.st=s.st+p+r+.6*n));case"aboveBar":return s.st=o.Rt(c,h)-p-i.sh,s.Kt!==void 0&&(s.Kt.st=s.st-p-.6*n,i.sh+=1.2*n),void(i.sh+=b+r);case"belowBar":return s.st=o.Rt(u,h)+p+i.eh,s.Kt!==void 0&&(s.Kt.st=s.st+p+r+.6*n,i.eh+=1.2*n),void(i.eh+=b+r)}t.position}class hh{constructor(t,e){this.ft=!0,this.rh=!0,this.hh=!0,this.ah=null,this.oh=null,this.Wt=new nh,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=Un(t),i=1.5*In(t)+2*e,n=this.fh();this.ah={above:Wn(i,n.aboveBar,n.inBar),below:Wn(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=Un(e.le()),a={sh:h,eh:h};this.zt.tt=Bn(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 d=this.zt.it[c];d.nt=e.It(u.time),u.text!==void 0&&u.text.length>0&&(d.Kt={ih:u.text,nt:0,st:0,Hi:0,At:0});const b=this.jr.ph(u.time);b!==null&&lh(d,u,b,a,n.fontSize,h,t,e,o.Vt)}this.ft=!1}}class ah extends es{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 ch extends ui{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=hi(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 jn(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 It{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 It(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 It(jn(Math.min,this.Ph(),t.Ph(),-1/0),jn(Math.max,this.Rh(),t.Rh(),1/0))}Vh(t){if(!ie(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){ie(t)&&(this.yh+=t,this.kh+=t)}Bh(){return{minValue:this.kh,maxValue:this.yh}}static Ah(t){return t===null?null:new It(t.minValue,t.maxValue)}}class bi{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 bi(It.Ah(t.priceRange),t.margins)}}class uh extends es{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 fh extends ui{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=hi(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 dh{constructor(t,e){this.jr=t,this.cn=e,this.jh=new uh(t,this),this.ur=new fh(t,this),this.Hh=new Vn(this.ur,t,t.$t())}$h(t){Qt(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 ph extends Ji{constructor(t){super(),this.$i=t}$t(){return this.$i}}const mh={Bar:(s,t,e,i)=>{var n;const r=t.upColor,o=t.downColor,l=E(s(e,i)),h=Oe(l.Vt[0])<=Oe(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,d=t.wickDownColor,b=E(s(e,i)),p=Oe(b.Vt[0])<=Oe(b.Vt[3]);return{ce:(n=b.V)!==null&&n!==void 0?n:p?l:h,Ne:(r=b.Ot)!==null&&r!==void 0?r:p?a:c,Ee:(o=b.Xh)!==null&&o!==void 0?o:p?u:d}},Custom:(s,t,e,i)=>{var n;return{ce:(n=E(s(e,i)).V)!==null&&n!==void 0?n:t.color}},Area:(s,t,e,i)=>{var n,r,o,l;const h=E(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=E(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=E(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=E(s(e,i)).V)!==null&&n!==void 0?n:t.color}}};class bh{constructor(t){this.Kh=(e,i)=>i!==void 0?i.Vt:this.jr.In().Gh(e),this.jr=t,this.Jh=mh[t.Qh()]}$s(t,e){return this.Jh(this.Kh,this.jr.W(),t,e)}}var Kn;(function(s){s[s.NearestLeft=-1]="NearestLeft",s[s.None=0]="None",s[s.NearestRight=1]="NearestRight"})(Kn||(Kn={}));const ge=30;class gh{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=gi(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 He(this.tl,t,((e,i)=>e.ee<i))}vl(t){return An(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=E(this.el()),o=E(this.An()),l=Math.max(t,r),h=Math.min(e,o),a=Math.ceil(l/ge)*ge,c=Math.max(a,Math.floor(h/ge)*ge);{const d=this.fl(l),b=this.vl(Math.min(h,a,e));n=gi(n,this.pl(d,b,i))}let u=this.il.get(i);u===void 0&&(u=new Map,this.il.set(i,u));for(let d=Math.max(a+1,l);d<c;d+=ge){const b=Math.floor(d/ge);let p=u.get(b);if(p===void 0){const f=this.fl(b*ge),m=this.vl((b+1)*ge-1);p=this.pl(f,m,i),u.set(b,p)}n=gi(n,p)}{const d=this.fl(c),b=this.vl(h);n=gi(n,this.pl(d,b,i))}return n}}function gi(s,t){return s===null?t:t===null?s:{ml:Math.min(s.ml,t.ml),bl:Math.max(s.bl,t.bl)}}class vh{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 is{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 vh(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 Xn(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 yh{constructor(t,e){this.Wt=new _n,this.kl=t,this.yl=e}gt(){return this.Wt.J(Object.assign({Hi:this.yl.Hi()},Xn(this.kl))),this.Wt}}class wh extends ui{constructor(t,e){super(),this.kl=t,this.Li=e}zi(t,e,i){const n=Xn(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 Sh{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 is(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 yh(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 wh(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 is(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 is(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 ss(s,t,e,i){s.forEach((n=>{t(n).forEach((r=>{r.Sl()===e&&i.push(r)}))}))}function ns(s){return s.Pn()}function xh(s){return s.Bl()}function _h(s){return s.Al()}class rs extends ph{constructor(t,e,i,n,r){super(t),this.zt=new gh,this.jh=new ah(this),this.zl=[],this.Ll=new Zl(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 ch(this);this.rn=[o],this.Hh=new Vn(o,this,t),i!=="Area"&&i!=="Line"&&i!=="Baseline"||(this.El=new ih(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 bh(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),Qt(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 dh(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=[];ss(this.Hl,ns,"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),ss(this.Hl,ns,"normal",t),t}ua(){return this.ca(ns,"bottom")}da(t){return this.ca(xh,t)}fa(t){return this.ca(_h,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 bi.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 E(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 Sh(t,this))}ya(t){this.Hl=this.Hl.filter((e=>e.Ol()!==t))}Ca(){if(this.wn instanceof ts)return t=>this.wn.We(t)}Ta(){if(this.wn instanceof ts)return t=>this.wn.je(t)}_a(){return!fi(this.Dt().Pa())}pa(t,e){if(!Ie(t)||!Ie(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 It(n.ml,n.bl):null;if(this.Qh()==="Histogram"){const l=this.cn.base,h=new It(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 b=new It(h.priceRange.minValue,h.priceRange.maxValue);r=r!==null?r.ts(b):b}var a,c,u,d;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((d=a?.below)!==null&&d!==void 0?d:0,c.below)})})),new bi(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 Ol(this.cn.priceFormat.precision);break;case"percent":this.wa=new Tn(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.wa=new di(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=E(this.zt.el());this.Wl=this.Fl.map(((i,n)=>{const r=E(t.Va(i.time,!0)),o=r<e?1:-1;return{time:E(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 hh(this,this.$t()),this.$l){case"Bar":this.wn=new Fl(this,this.$t());break;case"Candlestick":this.wn=new Hl(this,this.$t());break;case"Line":this.wn=new Jl(this,this.$t());break;case"Custom":this.wn=new ts(this,this.$t(),Ft(t));break;case"Area":this.wn=new Dl(this,this.$t());break;case"Baseline":this.wn=new Ul(this,this.$t());break;case"Histogram":this.wn=new Xl(this,this.$t());break;default:throw Error("Unknown chart style assigned: "+this.$l)}}ca(t,e){const i=[];return ss(this.Hl,t,e,i),i}}class Ch{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 rs)).reduce(((c,u)=>{if(i.vr(u)||!u.yt())return c;const d=u.Dt(),b=u.In();if(d.Ni()||!b.Kr(e))return c;const p=b.Gh(e);if(p===null)return c;const f=Oe(u.Ct());return c.concat([d.Rt(p.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 Eh extends Zt{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=E(this.zt);if(o.Aa){t.strokeStyle=o.Ia,xe(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,xe(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 Th{constructor(t){this.Wt=new Eh,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 Mh{constructor(t){this.wn=new Th(t)}qh(){return this.wn}}const os={$a:4,Ua:1e-4};function Pe(s,t){const e=100*(s-t)/t;return t<0?-e:e}function kh(s,t){const e=Pe(s.Ph(),t),i=Pe(s.Rh(),t);return new It(e,i)}function Xe(s,t){const e=100*(s-t)/t+100;return t<0?-e:e}function Lh(s,t){const e=Xe(s.Ph(),t),i=Xe(s.Rh(),t);return new It(e,i)}function vi(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 Je(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 Ge(s,t){if(s===null)return null;const e=vi(s.Ph(),t),i=vi(s.Rh(),t);return new It(e,i)}function yi(s,t){if(s===null)return null;const e=Je(s.Ph(),t),i=Je(s.Rh(),t);return new It(e,i)}function ls(s){if(s===null)return os;const t=Math.abs(s.Rh()-s.Ph());if(t>=1||t<1e-15)return os;const e=Math.ceil(Math.abs(Math.log10(t))),i=os.$a+e;return{$a:i,Ua:1/Math.pow(10,i)}}class hs{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=pi(r,n,1e-14)&&r>n+1e-14,d=pi(r,i*l,1e-14),b=pi(r,1,1e-14);if(!(u&&d&&b))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];pi(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 Jn{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 hs(this.qa,[2,2.5,2]),o=new hs(this.qa,[2,2,2.5]),l=new hs(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),d=a%u;d+=d<0?u:0;const b=a>=c?1:-1;let p=null,f=0;for(let m=a-d;m>c;m-=u){const S=this.Ja(m,e,!0);p!==null&&Math.abs(S-p)<this.Qa()||S<l||S>h||(f<this.Ka.length?(this.Ka[f].Ea=S,this.Ka[f].so=t.eo(m)):this.Ka.push({Ea:S,so:t.eo(m)}),f++,p=S,t.ro()&&(u=this.Xa(m*b,c)))}this.Ka.length=f}Ha(){return this.Ka}no(){return this.Li.P()}Qa(){return Math.ceil(2.5*this.no())}}function Gn(s){return s.slice().sort(((t,e)=>E(t.Xi())-E(e.Xi())))}var Yn;(function(s){s[s.Normal=0]="Normal",s[s.Logarithmic=1]="Logarithmic",s[s.Percentage=2]="Percentage",s[s.IndexedTo100=3]="IndexedTo100"})(Yn||(Yn={}));const Qn=new Tn,Zn=new di(100,1);class Oh{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 Ct,this.vo=new Ct,this.po=[],this.mo=null,this.bo=null,this.wo=null,this.Mo=null,this.wa=Zn,this.xo=ls(null),this.So=t,this.cn=e,this.ko=i,this.yo=n,this.Co=new Jn(this,100,this.To.bind(this),this.Po.bind(this))}Pa(){return this.So}W(){return this.cn}$h(t){if(Qt(this.cn,t),this.Ra(),t.mode!==void 0&&this.Ro({Cr:t.mode}),t.scaleMargins!==void 0){const e=Ft(t.scaleMargins.top),i=Ft(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=Je(r.Ph(),o),h=Je(r.Rh(),o);return isFinite(l)&&isFinite(h)})(this.Ih,this.xo)?(i=yi(this.Ih,this.xo),i!==null&&this.Ao(i)):this.cn.autoScale=!0),t.Cr===1&&t.Cr!==e.Cr&&(i=Ge(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=Pe(t,e):this.Oo()&&(t=Xe(t,e)),this.Po(t,e)}te(t,e,i){this.Wo();const n=this.Fo(),r=E(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,d=i===void 0?t.length:i.to,b=this.Ho();for(let p=u;p<d;p++){const f=t[p],m=f._t;if(isNaN(m))continue;let S=m;b!==null&&(S=b(f._t,e));const g=n+c*(S-o),x=a?g:this.ho-1-g;f.st=x}}be(t,e,i){this.Wo();const n=this.Fo(),r=E(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,d=i===void 0?t.length:i.to,b=this.Ho();for(let p=u;p<d;p++){const f=t[p];let m=f.ge,S=f.Me,g=f.xe,x=f.Se;b!==null&&(m=b(f.ge,e),S=b(f.Me,e),g=b(f.xe,e),x=b(f.Se,e));let M=n+c*(m-o),P=a?M:this.ho-1-M;f.pe=P,M=n+c*(S-o),P=a?M:this.ho-1-M,f.de=P,M=n+c*(g-o),P=a?M:this.ho-1-M,f.fe=P,M=n+c*(x-o),P=a?M:this.ho-1-M,f.me=P}}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=Gn(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=E(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=E(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=E(this.Lh()).Th()))}i_(t){if(this.Vo()||this.Mo===null)return;const e=E(this.Lh()).Dh()/(this.Eo()-1);let i=t-this.Mo;this.Bo()&&(i*=-1);const n=i*e,r=E(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_(Pe(t,e));case 3:return this.ba().format(Xe(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,E(this.e_()).ba())}Zl(t,e){return t=Pe(t,e),this.s_(t,Qn)}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=Zn,this.Mh()?(this.wa=Qn,e=100):this.Oo()?(this.wa=new di(100,1),e=100):t!==null&&(this.wa=t.ba()),this.Co=new Jn(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?vi(t,this.xo):t;const i=E(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=E(this.Lh()),r=n.Ph()+n.Dh()*((i-this.Fo())/(this.Eo()-1));return this.ro()?Je(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=Ge(u,this.xo);break;case 2:u=kh(u,a.Vt);break;case 3:u=Lh(u,a.Vt)}if(e=e===null?u:e.ts(E(u)),c!==null){const d=c.Eh();d!==null&&(n=Math.max(n,d.above),r=Math.max(r,d.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=yi(e,this.xo)),e=new It(e.Ph()-a,e.Rh()+a),this.ro()&&(e=Ge(e,this.xo))}if(this.ro()){const h=yi(e,this.xo),a=ls(h);if(o=a,l=this.xo,o.$a!==l.$a||o.Ua!==l.Ua){const c=this.ao!==null?yi(this.ao,this.xo):null;this.xo=a,e=Ge(h,a),c!==null&&(this.ao=Ge(c,a))}}this.Ao(e)}else this.Ih===null&&(this.Ao(new It(-.5,.5)),this.xo=ls(null));var o,l;this.oo._o=!0}Ho(){return this.Mh()?Pe:this.Oo()?Xe:this.ro()?t=>vi(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 zh{constructor(t,e){this.po=[],this.o_=new Map,this.ho=0,this.__=0,this.u_=1e3,this.mo=null,this.c_=new Ct,this.yl=t,this.$i=e,this.d_=new Mh(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=E(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)?Ft(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);be(e!==-1,"removeDataSource: invalid data source"),this.po.splice(e,1);const i=E(t.Dt()).Pa();if(this.o_.has(i)){const r=Ft(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=Gn(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),!fi(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},pe(e)),n=new Oh(t,i,this.$i.W().layout,this.$i.W().localization);return n.Lo(this.At()),n}}class Ph{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(Ft(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 Ye{constructor(t,e){be(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 tr(s,t){return s===null||t===null?s===t:s.Ch(t)}class Nh{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(He(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=Ft(this.J_.get(i)),h=l.length;let a=1/0,c=-1/0;for(let u=0;u<h;u++){const d=l[u],b=d.index;for(;o<r;){const p=n[o],f=p.index;if(!(f<b)){a=f;break}o++,e.push(p),c=f,a=1/0}if(a-b>=t&&b-c>=t)e.push(d),c=b;else if(this.Q_)return n}for(;o<r;o++)e.push(n[o])}return e}}class Ne{constructor(t){this.hu=t}lu(){return this.hu===null?null:new Ye(Math.floor(this.hu.Os()),Math.ceil(this.hu.ui()))}au(){return this.hu}static ou(){return new Ne(null)}}function Rh(s,t){return s.weight>t.weight?s:t}class Ah{constructor(t,e,i,n){this.__=0,this._u=null,this.uu=[],this.Mo=null,this.wo=null,this.cu=new Nh,this.du=new Map,this.fu=Ne.ou(),this.vu=!0,this.pu=new Ct,this.mu=new Ct,this.bu=new Ct,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){Qt(this.yo,t),this.Cu(),this.ku()}$h(t,e){var i;Qt(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=He(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=E(this.Bu()),r=E(this.Au());return{from:E(this.Ui(Math.max(n,e))),to:E(this.Ui(Math.min(r,i)))}}Iu(t){return{from:E(this.Va(t.from,!0)),to:E(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()||!Ie(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=E(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,d=this.cn.fixRightEdge||c;let b=0;for(const p of l){if(!(r<=p.index&&p.index<=o))continue;let f;b<this.Mu.length?(f=this.Mu[b],f.coord=this.It(p.index),f.label=this.Uu(p),f.weight=p.weight):(f={needAlignCoordinate:!1,coord:this.It(p.index),label:this.Uu(p),weight:p.weight},this.Mu.push(f)),this.Su>e/2&&!c?f.needAlignCoordinate=!1:f.needAlignCoordinate=u&&p.index<=h||d&&p.index>=a,b++}return this.Mu.length=b,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=Yi(this.__-t,0,this.__),i=Yi(this.__-E(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=E(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 Ye(t,e+this.cn.rightOffset))}lc(t){const e=new Ye(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(Ne.ou());const t=this.Eu(),e=this.__/this.Su,i=this.xu+t,n=new Ye(i-e+1,i);this._c(new Ne(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 Ph((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,tr(e.lu(),this.fu.lu())||this.pu.m(),tr(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 Bh{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 Dh extends Bh{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 Vh{constructor(t){this.ft=!0,this.Ft={yt:!1,V:"",bc:[],Mc:"center",xc:"center"},this.Wt=new Dh(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:ze(t.fontSize,t.fontFamily,t.fontStyle),gc:1.2*t.fontSize,Sc:0,Zu:0}])}}class Fh extends Ji{constructor(t,e){super(),this.cn=e,this.wn=new Vh(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}Vn(){this.wn.bt()}}var er,ir,sr,nr,rr;(function(s){s[s.OnTouchEnd=0]="OnTouchEnd",s[s.OnNextTap=1]="OnNextTap"})(er||(er={}));class $h{constructor(t,e,i){this.yc=[],this.Cc=[],this.__=0,this.Tc=null,this.Pc=new Ct,this.Rc=new Ct,this.Dc=null,this.Vc=t,this.cn=e,this.q_=i,this.Oc=new vl(this),this.yl=new Ah(this,e.timeScale,this.cn.localization,i),this.vt=new Ll(this,e.crosshair),this.Bc=new Ch(e.crosshair),this.Ac=new Fh(this,e.watermark),this.Ic(),this.yc[0].x_(2e3),this.zc=this.Lc(0),this.Ec=this.Lc(1)}Kl(){this.Nc(Pt.es())}Uh(){this.Nc(Pt.ss())}oa(){this.Nc(new Pt(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){Qt(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 zh(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=Pt.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,E(r)),l=this.yl.Va(e,!0),h=this.yl.It(E(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,d=h&&(i!==void 0||u)&&this.yl.W().shiftVisibleRangeOnNewBar;if(c&&!d){const b=t-o;this.yl.Jn(this.yl.Hu()-b)}}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);be(i!==-1,"Series not found"),this.Cc.splice(i,1),E(e).Zo(t),t.S&&t.S()}Xl(t,e){const i=E(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=Pt.ss();t.$n(),this.Nc(t)}pd(t){const e=Pt.ss();e.Yn(t),this.Nc(e)}Kn(){const t=Pt.ss();t.Kn(),this.Nc(t)}Gn(t){const e=Pt.ss();e.Gn(t),this.Nc(e)}Jn(t){const e=Pt.ss();e.Jn(t),this.Nc(e)}Zn(t){const e=Pt.ss();e.Zn(t),this.Nc(e)}Un(){const t=Pt.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]=$e(r),[d,b,p,f]=$e(o),m=[jt(h+l*(d-h)),jt(a+l*(b-a)),jt(c+l*(p-c)),gn(u+l*(f-u))];return`rgba(${m[0]}, ${m[1]}, ${m[2]}, ${m[3]})`})(i,e,t/100);return this.Dc.wd.set(t,n),n}Gc(t,e){const i=new Pt(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 rs(this,t,e,i,n),o=t.priceScaleId!==void 0?t.priceScaleId:this.md();return i.qo(r,o),fi(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 as(s){return!ie(s)&&!Ue(s)}function or(s){return ie(s)}(function(s){s[s.Disabled=0]="Disabled",s[s.Continuous=1]="Continuous",s[s.OnDataUpdate=2]="OnDataUpdate"})(ir||(ir={})),(function(s){s[s.LastBar=0]="LastBar",s[s.LastVisible=1]="LastVisible"})(sr||(sr={})),(function(s){s.Solid="solid",s.VerticalGradient="gradient"})(nr||(nr={})),(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"})(rr||(rr={}));const lr=s=>s.getUTCFullYear();function Ih(s,t,e){return t.replace(/yyyy/g,(i=>me(lr(i),4))(s)).replace(/yy/g,(i=>me(lr(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=>me((n=>n.getUTCMonth()+1)(i),2))(s)).replace(/dd/g,(i=>me((n=>n.getUTCDate())(i),2))(s))}class hr{constructor(t="yyyy-MM-dd",e="default"){this.gd=t,this.Md=e}Y_(t){return Ih(t,this.gd,this.Md)}}class Uh{constructor(t){this.xd=t||"%h:%m:%s"}Y_(t){return this.xd.replace("%h",me(t.getUTCHours(),2)).replace("%m",me(t.getUTCMinutes(),2)).replace("%s",me(t.getUTCSeconds(),2))}}const Wh={Sd:"yyyy-MM-dd",kd:"%h:%m:%s",yd:" ",Cd:"default"};class Hh{constructor(t={}){const e=Object.assign(Object.assign({},Wh),t);this.Td=new hr(e.Sd,e.Cd),this.Pd=new Uh(e.kd),this.Rd=e.yd}Y_(t){return`${this.Td.Y_(t)}${this.Rd}${this.Pd.Y_(t)}`}}function wi(s){return 60*s*60*1e3}function cs(s){return 60*s*1e3}const Si=[{Dd:(ar=1,1e3*ar),Vd:10},{Dd:cs(1),Vd:20},{Dd:cs(5),Vd:21},{Dd:cs(30),Vd:22},{Dd:wi(1),Vd:30},{Dd:wi(3),Vd:31},{Dd:wi(6),Vd:32},{Dd:wi(12),Vd:33}];var ar;function cr(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=Si.length-1;e>=0;--e)if(Math.floor(t.getTime()/Si[e].Dd)!==Math.floor(s.getTime()/Si[e].Dd))return Si[e].Vd;return 0}function us(s){let t=s;if(Ue(s)&&(t=fs(s)),!as(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 ur(s){if(!or(s))throw new Error("time must be of type isUTCTimestamp");return{Od:s}}function fs(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 fr(s){Ue(s.time)&&(s.time=fs(s.time))}class dr{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?(function(e){e.forEach(fr)})(t):fr(t)}createConverterToInternalObj(t){return E((function(e){return e.length===0?null:as(e[0].time)||Ue(e[0].time)?us:ur})(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 or(e=t)?ur(e):as(e)?us(e):us(fs(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.Ad=new Hh({Sd:e,kd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",yd:" ",Cd:t.locale}):this.Ad=new hr(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(Rh,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=cr(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=cr(new Date(1e3*i[0].time.Od),a)}})(t,e)}static Id(t){return Qt({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Re=typeof window<"u";function pr(){return!!Re&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function ds(){return!!Re&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ps(s){return s+s%2}function ms(s,t){return s.zd-t.zd}function bs(s,t,e){const i=(s.zd-t.zd)/(s.ot-t.ot);return Math.sign(i)*Math.min(Math.abs(i),e)}class qh{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=bs(this.Ld,this.Ed,this.Ud),r=ms(this.Ld,this.Ed),o=[n],l=[r];if(i+=r,this.Nd!==null){const a=bs(this.Ed,this.Nd,this.Ud);if(Math.sign(a)===Math.sign(n)){const c=ms(this.Ed,this.Nd);if(o.push(a),l.push(c),i+=c,this.Fd!==null){const u=bs(this.Nd,this.Fd,this.Ud);if(Math.sign(u)===Math.sign(n)){const d=ms(this.Nd,this.Fd);o.push(u),l.push(d),i+=d}}}}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=E(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-E(this.Wd).ot;return Math.min(e,this.jd)}}class jh{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 vn($e(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 _e(s,t){const e=E(s.ownerDocument).createElement("canvas");s.appendChild(e);const i=sl(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 Ce(s){var t;s.width=1,s.height=1,(t=s.getContext("2d"))===null||t===void 0||t.clearRect(0,0,1,1)}function gs(s,t,e,i){s.gl&&s.gl(t,e,i)}function xi(s,t,e,i){s.X(t,e,i)}function vs(s,t,e,i){const n=s(e,i);for(const r of n){const o=r.gt();o!==null&&t(o)}}function Kh(s){Re&&window.chrome!==void 0&&s.addEventListener("mousedown",(t=>{if(t.button===1)return t.preventDefault(),!1}))}class ys{constructor(t,e,i){this.hf=0,this.lf=null,this.af={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this._f=0,this.uf=null,this.cf={nt:Number.NEGATIVE_INFINITY,st:Number.POSITIVE_INFINITY},this.df=null,this.ff=!1,this.vf=null,this.pf=null,this.mf=!1,this.bf=!1,this.wf=!1,this.gf=null,this.Mf=null,this.xf=null,this.Sf=null,this.kf=null,this.yf=null,this.Cf=null,this.Tf=0,this.Pf=!1,this.Rf=!1,this.Df=!1,this.Vf=0,this.Of=null,this.Bf=!ds(),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(se(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(se(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=ws(t.changedTouches,E(this.Of));if(e===null||(this.Vf=_i(t),this.Cf!==null)||this.Rf)return;this.Pf=!0;const i=this.Ff(se(e),E(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),Ae(t)}}}lv(t){if(t.button!==0)return;const e=this.Ff(se(t),E(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=ws(t.changedTouches,E(this.Of));if(e===null&&t.touches.length===0&&(e=t.changedTouches[0]),e===null)return;this.Of=null,this.Vf=_i(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(se(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&&Ae(t));this._f===0&&Ae(t),t.touches.length===0&&this.ff&&(this.ff=!1,Ae(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),pr()&&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(se(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=_i(t);const i=this.Zf.ownerDocument.documentElement;this.wf=!1,this.mf=!1,this.Rf=!1,this.pf=se(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=se(e))}mv(t){if(t.button!==0)return;const e=this.Zf.ownerDocument.documentElement;pr()&&e.addEventListener("mouseleave",this.Af),this.bf=!1,this.vf=se(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=se(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})}ds()&&(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}),Kh(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=mr(t.touches[0],t.touches[1])/this.Tf;this.Hf.Sv(this.Cf,e),Ae(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=mr(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=!ds()}vv(t){const e=ws(t.touches,E(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:_i(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"&&Ae(t)}}}}function mr(s,t){const e=s.clientX-t.clientX,i=s.clientY-t.clientY;return Math.sqrt(e*e+i*i)}function Ae(s){s.cancelable&&s.preventDefault()}function se(s){return{nt:s.pageX,st:s.pageY}}function _i(s){return s.timeStamp||performance.now()}function ws(s,t){for(let e=0;e<s.length;++e)if(s[e].identifier===t)return s[e];return null}function Ci(s){return{Hc:s.Hc,Iv:{gr:s.zv.externalId},Lv:s.zv.cursorStyle}}function Xh(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 Ss(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 br(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),d=a.Vi(),b=c.Vi();if(t===1?d>b-u:d<b+u){const p=b-u*t;a.Oi(p);const f=p-t*u/2;if((t===1?f<0:f>e)&&l>0){const m=t===1?-1-f:f-e,S=Math.min(m,l);for(let g=n;g<s.length;g++)s[g].Oi(s[g].Vi()+t*S);l-=S}}else n=h,l=t===1?b-u-d:d-(b+u)}}class gr{constructor(t,e,i,n){this.Li=null,this.Ev=null,this.Nv=!1,this.Fv=new qe(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=Ss("normal",n),this.Zv=Ss("top",n),this.Xv=Ss("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=_e(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=_e(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 ys(this.Jv.canvasElement,l,{ev:()=>!this.cn.handleScroll.vertTouchDrag,rv:()=>!0})}S(){this.hp.S(),this.Jv.unsubscribeSuggestedBitmapSizeChanged(this.Uv),Ce(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Ce(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=E(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 ps(Math.ceil(e.C+e.T+e.A+e.I+5+h))}cp(t){this.Ev!==null&&we(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 E(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,E(this.Dt()))}vp(t){if(this.Ev===null)return;if(t!==1){this.pp(),this.Gv.applySuggestedBitmapSize();const i=Se(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=Se(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?ci(t,0,0,i,n,o):Sn(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 d of e)o.rect(Math.floor(r*l),Math.round(d.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)}br(n,1,this.Ev.height,e),br(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(E(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(E(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 ze(this.ko.fontSize,this.ko.fontFamily)}}function Jh(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 Ei(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 Gh(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 Yh(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 xs{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 Ct,this.Op=new Ct,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=_e(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=_e(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 ys(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),Ce(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Ce(this.Gv.canvasElement),this.Gv.dispose(),this.Np!==null&&this.Np.W_().p(this),this.hp.S()}fp(){return E(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(xs.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 jh(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(E(t))}if(this.Tp!==null){const t=this.Np.D_();this.Tp.Gi(E(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=E(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 d,b;let p,f;for(const g of a){const x=(b=(d=g.va)===null||d===void 0?void 0:d.call(g,c,u))!==null&&b!==void 0?b:[];for(const M of x)m=M.zOrder,(!(S=p?.zOrder)||m==="top"&&S!=="top"||m==="normal"&&S==="bottom")&&(p=M,f=g)}var m,S;return p&&f?{zv:p,Hc:f}:null})(l,r,o);if(h?.zv.zOrder==="top")return Ci(h);for(const a of l){if(h&&h.Hc===a&&h.zv.zOrder!=="bottom"&&!h.zv.isBackground)return Ci(h);const c=Xh(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 Ci(h)}return h?.zv?Ci(h):null})(i,t,e)}_m(t,e){E(e==="left"?this.Cp:this.Tp).cp(ft({width:t,height:this.Ev.height}))}um(){return this.Ev}cp(t){we(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=E(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=Se(this.Gv);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.mp(n)})),this.Np&&(this.fm(i,Jh),this.vm(i),this.pm(i),this.fm(i,Ei),this.fm(i,Gh)))}this.Jv.applySuggestedBitmapSize();const e=Se(this.Jv);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.bm(e),this.fm(e,Yh))}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?ci(t,0,0,i,n,l):Sn(t,0,0,i,n,o,l)}vm(t){const e=E(this.Np).j_().qh().gt();e!==null&&e.X(t,!1)}pm(t){const e=this.$i().Yc();this.Mm(t,Ei,gs,e),this.Mm(t,Ei,xi,e)}bm(t){this.Mm(t,Ei,xi,this.$i().Zc())}fm(t,e){const i=E(this.Np).Uo();for(const n of i)this.Mm(t,e,gs,n);for(const n of i)this.Mm(t,e,xi,n)}Mm(t,e,i,n){const r=E(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;vs(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 gr(this,t.W(),n,"left"),this.jp.appendChild(this.Cp.lp())),i&&this.Tp===null&&(this.Tp=new gr(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,E(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)E(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 qh(.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 vr{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=_e(this.Kv,ft({width:16,height:16})),this.Gv.subscribeSuggestedBitmapSizeChanged(this.Hv)}S(){this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Ce(this.Gv.canvasElement),this.Gv.dispose()}lp(){return this.Kv}um(){return this.Ev}cp(t){we(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=Se(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}){ci(t,0,0,e.width,e.height,this.Pm())}}function _s(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 Qh=_s("normal"),Zh=_s("top"),ta=_s("bottom");class ea{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 Ct,this.Fv=new qe(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=_e(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=_e(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 ys(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),Ce(this.Jv.canvasElement),this.Jv.dispose(),this.Gv.unsubscribeSuggestedBitmapSizeChanged(this.Hv),Ce(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){we(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=Se(this.Gv);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.mp(n),this.Ie(n),this.$m(i,ta)})),this.wp(i),this.$m(i,Qh)),this.Rm!==null&&this.Rm.vp(t),this.Dm!==null&&this.Dm.vp(t)}this.Jv.applySuggestedBitmapSize();const e=Se(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,Zh))}$m(t,e){const i=this.Qd.$t().wt();for(const n of i)vs(e,(r=>gs(r,t,!1,void 0)),n,void 0);for(const n of i)vs(e,(r=>xi(r,t,!1,void 0)),n,void 0)}mp({context:t,bitmapSize:e}){ci(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 d=Math.round(r.T*a);for(let b=i.length;b--;){const p=Math.round(i[b].coord*h);l.rect(p-u,0,c,d)}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 ze(this.j(),this.cn.fontFamily)}Zm(){return ze(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 qe,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 vr("left",e,i,n,r),this.Bm.appendChild(this.Rm.lp())),e.rightPriceScale.visible&&this.Dm===null&&(this.Dm=new vr("right",e,i,n,r),this.Am.appendChild(this.Dm.lp()))}}const ia=!!Re&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((s=>s.brand.includes("Chromium")))&&!!Re&&(!((Cs=navigator?.userAgentData)===null||Cs===void 0)&&Cs.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);var Cs;class sa{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 Ct,this.Op=new Ct,this.Rc=new Ct,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),Es(this.cn)&&this.hb(!0),this.$i=new $h(this.Vc.bind(this),this.cn,i),this.$t().Xc().l(this.lb.bind(this),this),this.ab=new ea(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=[],E(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";E(this.Xd).style.height=r,E(this.Xd).style.width=o,this.sb.style.height=r,this.sb.style.width=o,i?this.mb(Pt.es(),performance.now()):this.$i.Kl()}vp(t){t===void 0&&(t=Pt.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=Es(this.cn);this.$i.$h(t);const i=Es(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=E(e.getContext("2d"));return this.gb(i),e}Mb(t){return t==="left"&&!this.xb()||t==="right"&&!this.Sb()||this.Xm.length===0?0:E(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 Ft(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],d=E(l==="left"?u.wm():u.gm()),b=d.xp();t!==null&&d.Sp(t,h,a),a+=b.height}};this.xb()&&(r("left",0),e+=E(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+=E(n.gm()).xp().width);const o=(l,h,a)=>{E(l==="left"?this.ab.Lm():this.ab.Em()).Sp(E(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=E(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 p of this.Xm)this.xb()&&(e=Math.max(e,E(p.wm()).op(),this.cn.leftPriceScale.minimumWidth)),this.Sb()&&(i=Math.max(i,E(p.gm()).op(),this.cn.rightPriceScale.minimumWidth)),t+=p.M_();e=ps(e),i=ps(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,d=u/t;let b=0;for(let p=0;p<this.Xm.length;++p){const f=this.Xm[p];f.qp(this.$i.qc()[p]);let m=0,S=0;S=p===this.Xm.length-1?u-b:Math.round(f.M_()*d),m=Math.max(S,2),b+=m,f.cp(ft({width:o,height:m})),this.xb()&&f._m(e,"left"),this.Sb()&&f._m(i,"right"),f.fp()&&this.$i.Kc(f.fp(),m)}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 ia?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=Ft(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 xs(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 rs?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 Es(s){return!!(s.handleScroll.mouseWheel||s.handleScale.mouseWheel)}function na(s){return(function(t){return t.open!==void 0})(s)||(function(t){return t.value!==void 0})(s)}function yr(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 wr(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 ra(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 oa(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 la(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 ha(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 aa(s,t,e,i,n){const r=Ft(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:d}=c;return{ee:t,ot:s,Vt:a,zb:i,$e:yr(c,["time","color"]),V:d}}function Ti(s){return s.Vt!==void 0}function Sr(s,t){return t.customValues!==void 0&&(s.jb=t.customValues),s}function Ee(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)?Sr({ot:t,ee:e,zb:n},i):Sr(s(t,e,i,n,r),i)}function xr(s){return{Candlestick:Ee(ha),Bar:Ee(la),Area:Ee(ra),Baseline:Ee(oa),Histogram:Ee(wr),Line:Ee(wr),Custom:Ee(aa)}[s]}function _r(s){return{ee:0,Hb:new Map,la:s}}function Cr(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 Er(s){let t;return s.forEach((e=>{t===void 0&&(t=e.zb)})),Ft(t)}class ca{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((b=>b.time)),a=this.q_.createConverterToInternalObj(e),c=xr(t.Qh()),u=t.Ca(),d=t.Ta();o=e.map(((b,p)=>{const f=a(b.time),m=this.q_.key(f);let S=this.qb.get(m);S===void 0&&(S=_r(f),this.qb.set(m,S),n=!0);const g=c(f,S.ee,b,h[p],u,d);return S.Hb.set(t,g),g}))}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:Er(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=Cr(h,c),d=Cr(a,c);if(u!==void 0&&d!==void 0)return{ta:u.Ub>=d.Ub&&u.$b>=d.$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=_r(n),this.qb.set(this.q_.key(n),o));const h=xr(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 d={ta:Ti(u)};if(!l)return this.tw(t,-1,d);const b={timeWeight:0,time:o.la,pointData:o,originalTime:Er(o.Hb)},p=He(this.Xb,this.q_.key(b.time),((f,m)=>this.q_.key(f.time)<m));this.Xb.splice(p,0,b);for(let f=p;f<this.Xb.length;++f)Ts(this.Xb[f].pointData,f);return this.q_.fillWeightsForPoints(this.Xb,p),this.tw(t,p,d)}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)?Ti(e)&&i.push(e):Ti(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(Ti)),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,Ts(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)Ts(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 Ts(s,t){s.ee=t,s.Hb.forEach((e=>{e.ee=t}))}function Ms(s){const t={value:s.Vt[3],time:s.zb};return s.jb!==void 0&&(t.customValues=s.jb),t}function Tr(s){const t=Ms(s);return s.V!==void 0&&(t.color=s.V),t}function ua(s){const t=Ms(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 fa(s){const t=Ms(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 Mr(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 da(s){const t=Mr(s);return s.V!==void 0&&(t.color=s.V),t}function pa(s){const t=Mr(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 ks(s){return{Area:ua,Line:Tr,Baseline:fa,Histogram:Tr,Bar:da,Candlestick:pa,Custom:ma}[s]}function ma(s){const t=s.zb;return Object.assign(Object.assign({},s.$e),{time:t})}const ba={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},ga={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},va={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Ki,attributionLogo:!0},Ls={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},ya={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},wa={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:Ki,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function kr(){return{width:0,height:0,autoSize:!1,layout:va,crosshair:ba,grid:ga,overlayPriceScales:Object.assign({},Ls),leftPriceScale:Object.assign(Object.assign({},Ls),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Ls),{visible:!0}),timeScale:ya,watermark:wa,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 Sa{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 fi(this.ow)?this.aw.Mb(this.ow):0}Li(){return E(this.aw.$t().Uc(this.ow)).Dt}}function Lr(s,t,e){const i=yr(s,["time","originalTime"]),n=Object.assign({time:t},i);return e!==void 0&&(n.originalTime=e),n}const xa={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class _a{constructor(t){this.Nh=t}applyOptions(t){this.Nh.$h(t)}options(){return this.Nh.W()}_w(){return this.Nh}}class Ca{constructor(t,e,i,n,r){this.uw=new Ct,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 Ne(new Ye(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=E(i.el()),l=E(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:ks(this.seriesType())(i)}data(){const t=ks(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=>Lr(i,this.q_.convertHorzItemToInternal(i.time),i.time)));this.Es.na(e)}markers(){return this.Es.sa().map((t=>Lr(t,t.originalTime,void 0)))}applyOptions(t){this.Es.$h(t)}options(){return pe(this.Es.W())}priceScale(){return this.dw.priceScale(this.Es.Dt().Pa())}createPriceLine(t){const e=Qt(pe(xa),t),i=this.Es.ea(e);return new _a(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 Ea{constructor(t,e,i){this.ww=new Ct,this.mu=new Ct,this.Om=new Ct,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){be(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({},pe(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 Ta(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 Or(s){return(function(t){if(ai(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;ai(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),ai(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const e=t.handleScroll;ai(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})})(s),s}class Ma{constructor(t,e,i){this.Sw=new Map,this.kw=new Map,this.yw=new Ct,this.Cw=new Ct,this.Tw=new Ct,this.Pw=new ca(e);const n=i===void 0?pe(kr()):Qt(pe(kr()),Or(i));this.q_=e,this.aw=new sa(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 Ea(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=Oe(t),n=Object.assign(Object.assign({},un),i.defaultOptions());return this.Vw("Custom",n,e,i)}addAreaSeries(t){return this.Vw("Area",cl,t)}addBaselineSeries(t){return this.Vw("Baseline",ul,t)}addBarSeries(t){return this.Vw("Bar",hl,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",ll,t)}addHistogramSeries(t){return this.Vw("Histogram",fl,t)}addLineSeries(t){return this.Vw("Line",al,t)}removeSeries(t){const e=Ft(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 Sa(this.aw,t)}timeScale(){return this.Dw}applyOptions(t){this.aw.$h(Or(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){Ta(i.priceFormat);const r=Qt(pe(fn),pe(e),i),o=this.aw.$t().dd(t,r,n),l=new Ca(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 Ft(this.kw.get(t))}Rw(t){const e=new Map;t.Nb.forEach(((n,r)=>{const o=r.Qh(),l=ks(o)(n);if(o!=="Custom")be(na(l));else{const h=r.Ta();be(!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 ka(s,t,e){let i;if(Ue(s)){const r=document.getElementById(s);be(r!==null,`Cannot find element in DOM with id=${s}`),i=r}else i=s;const n=new Ma(i,t,e);return t.setOptions(n.options()),n}function La(s,t){return ka(s,new dr,dr.Id(t))}Object.assign(Object.assign({},fn),un);function zr(s,t){return function(){return s.apply(t,arguments)}}const{toString:Oa}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:Mi,toStringTag:Pr}=Symbol,ki=(s=>t=>{const e=Oa.call(t);return s[e]||(s[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),te=s=>(s=s.toLowerCase(),t=>ki(t)===s),Li=s=>t=>typeof t===s,{isArray:Be}=Array,De=Li("undefined");function Qe(s){return s!==null&&!De(s)&&s.constructor!==null&&!De(s.constructor)&&Ut(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const Nr=te("ArrayBuffer");function za(s){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(s):t=s&&s.buffer&&Nr(s.buffer),t}const Pa=Li("string"),Ut=Li("function"),Rr=Li("number"),Ze=s=>s!==null&&typeof s=="object",Na=s=>s===!0||s===!1,Oi=s=>{if(ki(s)!=="object")return!1;const t=Os(s);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Pr in s)&&!(Mi in s)},Ra=s=>{if(!Ze(s)||Qe(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},Aa=te("Date"),Ba=te("File"),Da=te("Blob"),Va=te("FileList"),Fa=s=>Ze(s)&&Ut(s.pipe),$a=s=>{let t;return s&&(typeof FormData=="function"&&s instanceof FormData||Ut(s.append)&&((t=ki(s))==="formdata"||t==="object"&&Ut(s.toString)&&s.toString()==="[object FormData]"))},Ia=te("URLSearchParams"),[Ua,Wa,Ha,qa]=["ReadableStream","Request","Response","Headers"].map(te),ja=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ti(s,t,{allOwnKeys:e=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),Be(s))for(i=0,n=s.length;i<n;i++)t.call(null,s[i],i,s);else{if(Qe(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 Ar(s,t){if(Qe(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 Te=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Br=s=>!De(s)&&s!==Te;function zs(){const{caseless:s,skipUndefined:t}=Br(this)&&this||{},e={},i=(n,r)=>{if(r==="__proto__"||r==="constructor"||r==="prototype")return;const o=s&&Ar(e,r)||r;Oi(e[o])&&Oi(n)?e[o]=zs(e[o],n):Oi(n)?e[o]=zs({},n):Be(n)?e[o]=n.slice():(!t||!De(n))&&(e[o]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&ti(arguments[n],i);return e}const Ka=(s,t,e,{allOwnKeys:i}={})=>(ti(t,(n,r)=>{e&&Ut(n)?Object.defineProperty(s,r,{value:zr(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),Ja=(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)},Ga=(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&&Os(s)}while(s&&(!e||e(s,t))&&s!==Object.prototype);return t},Ya=(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},Qa=s=>{if(!s)return null;if(Be(s))return s;let t=s.length;if(!Rr(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=s[t];return e},Za=(s=>t=>s&&t instanceof s)(typeof Uint8Array<"u"&&Os(Uint8Array)),tc=(s,t)=>{const i=(s&&s[Mi]).call(s);let n;for(;(n=i.next())&&!n.done;){const r=n.value;t.call(s,r[0],r[1])}},ec=(s,t)=>{let e;const i=[];for(;(e=s.exec(t))!==null;)i.push(e);return i},ic=te("HTMLFormElement"),sc=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,n){return i.toUpperCase()+n}),Dr=(({hasOwnProperty:s})=>(t,e)=>s.call(t,e))(Object.prototype),nc=te("RegExp"),Vr=(s,t)=>{const e=Object.getOwnPropertyDescriptors(s),i={};ti(e,(n,r)=>{let o;(o=t(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},rc=s=>{Vr(s,(t,e)=>{if(Ut(s)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=s[e];if(Ut(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+"'")})}})},oc=(s,t)=>{const e={},i=n=>{n.forEach(r=>{e[r]=!0})};return Be(s)?i(s):i(String(s).split(t)),e},lc=()=>{},hc=(s,t)=>s!=null&&Number.isFinite(s=+s)?s:t;function ac(s){return!!(s&&Ut(s.append)&&s[Pr]==="FormData"&&s[Mi])}const cc=s=>{const t=new Array(10),e=(i,n)=>{if(Ze(i)){if(t.indexOf(i)>=0)return;if(Qe(i))return i;if(!("toJSON"in i)){t[n]=i;const r=Be(i)?[]:{};return ti(i,(o,l)=>{const h=e(o,n+1);!De(h)&&(r[l]=h)}),t[n]=void 0,r}}return i};return e(s,0)},uc=te("AsyncFunction"),fc=s=>s&&(Ze(s)||Ut(s))&&Ut(s.then)&&Ut(s.catch),Fr=((s,t)=>s?setImmediate:t?((e,i)=>(Te.addEventListener("message",({source:n,data:r})=>{n===Te&&r===e&&i.length&&i.shift()()},!1),n=>{i.push(n),Te.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",Ut(Te.postMessage)),dc=typeof queueMicrotask<"u"?queueMicrotask.bind(Te):typeof process<"u"&&process.nextTick||Fr,v={isArray:Be,isArrayBuffer:Nr,isBuffer:Qe,isFormData:$a,isArrayBufferView:za,isString:Pa,isNumber:Rr,isBoolean:Na,isObject:Ze,isPlainObject:Oi,isEmptyObject:Ra,isReadableStream:Ua,isRequest:Wa,isResponse:Ha,isHeaders:qa,isUndefined:De,isDate:Aa,isFile:Ba,isBlob:Da,isRegExp:nc,isFunction:Ut,isStream:Fa,isURLSearchParams:Ia,isTypedArray:Za,isFileList:Va,forEach:ti,merge:zs,extend:Ka,trim:ja,stripBOM:Xa,inherits:Ja,toFlatObject:Ga,kindOf:ki,kindOfTest:te,endsWith:Ya,toArray:Qa,forEachEntry:tc,matchAll:ec,isHTMLForm:ic,hasOwnProperty:Dr,hasOwnProp:Dr,reduceDescriptors:Vr,freezeMethods:rc,toObjectSet:oc,toCamelCase:sc,noop:lc,toFiniteNumber:hc,findKey:Ar,global:Te,isContextDefined:Br,isSpecCompliantForm:ac,toJSONObject:cc,isAsyncFn:uc,isThenable:fc,setImmediate:Fr,asap:dc,isIterable:s=>s!=null&&Ut(s[Mi])};let V=class Qo extends Error{static from(t,e,i,n,r,o){const l=new Qo(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:v.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 pc=null;function Ps(s){return v.isPlainObject(s)||v.isArray(s)}function $r(s){return v.endsWith(s,"[]")?s.slice(0,-2):s}function Ir(s,t,e){return s?s.concat(t).map(function(n,r){return n=$r(n),!e&&r?"["+n+"]":n}).join(e?".":""):t}function mc(s){return v.isArray(s)&&!s.some(Ps)}const bc=v.toFlatObject(v,{},null,function(t){return/^is[A-Z]/.test(t)});function zi(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,h=(e.Blob||typeof Blob<"u"&&Blob)&&v.isSpecCompliantForm(t);if(!v.isFunction(n))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(v.isDate(p))return p.toISOString();if(v.isBoolean(p))return p.toString();if(!h&&v.isBlob(p))throw new V("Blob is not supported. Use a Buffer instead.");return v.isArrayBuffer(p)||v.isTypedArray(p)?h&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function c(p,f,m){let S=p;if(p&&!m&&typeof p=="object"){if(v.endsWith(f,"{}"))f=i?f:f.slice(0,-2),p=JSON.stringify(p);else if(v.isArray(p)&&mc(p)||(v.isFileList(p)||v.endsWith(f,"[]"))&&(S=v.toArray(p)))return f=$r(f),S.forEach(function(x,M){!(v.isUndefined(x)||x===null)&&t.append(o===!0?Ir([f],M,r):o===null?f:f+"[]",a(x))}),!1}return Ps(p)?!0:(t.append(Ir(m,f,r),a(p)),!1)}const u=[],d=Object.assign(bc,{defaultVisitor:c,convertValue:a,isVisitable:Ps});function b(p,f){if(!v.isUndefined(p)){if(u.indexOf(p)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(p),v.forEach(p,function(S,g){(!(v.isUndefined(S)||S===null)&&n.call(t,S,v.isString(g)?g.trim():g,f,d))===!0&&b(S,f?f.concat(g):[g])}),u.pop()}}if(!v.isObject(s))throw new TypeError("data must be an object");return b(s),t}function Ur(s){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Ns(s,t){this._pairs=[],s&&zi(s,this,t)}const Wr=Ns.prototype;Wr.append=function(t,e){this._pairs.push([t,e])},Wr.toString=function(t){const e=t?function(i){return t.call(this,i,Ur)}:Ur;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};function gc(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hr(s,t,e){if(!t)return s;const i=e&&e.encode||gc,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 Ns(t,n).toString(i),o){const l=s.indexOf("#");l!==-1&&(s=s.slice(0,l)),s+=(s.indexOf("?")===-1?"?":"&")+o}return s}class qr{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 Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},vc={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ns,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},As=typeof window<"u"&&typeof document<"u",Bs=typeof navigator=="object"&&navigator||void 0,yc=As&&(!Bs||["ReactNative","NativeScript","NS"].indexOf(Bs.product)<0),wc=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Sc=As&&window.location.href||"http://localhost",At={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:As,hasStandardBrowserEnv:yc,hasStandardBrowserWebWorkerEnv:wc,navigator:Bs,origin:Sc},Symbol.toStringTag,{value:"Module"})),...vc};function xc(s,t){return zi(s,new At.classes.URLSearchParams,{visitor:function(e,i,n,r){return At.isNode&&v.isBuffer(e)?(this.append(i,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}function _c(s){return v.matchAll(/\w+|\[(\w*)]/g,s).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cc(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 jr(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&&v.isArray(n)?n.length:o,h?(v.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!l):((!n[o]||!v.isObject(n[o]))&&(n[o]=[]),t(e,i,n[o],r)&&v.isArray(n[o])&&(n[o]=Cc(n[o])),!l)}if(v.isFormData(s)&&v.isFunction(s.entries)){const e={};return v.forEachEntry(s,(i,n)=>{t(_c(i),n,e,0)}),e}return null}function Ec(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 ei={transitional:Rs,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(jr(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 l;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return xc(t,this.formSerializer).toString();if((l=v.isFileList(t))||i.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return zi(l?{"files[]":t}:t,h&&new h,this.formSerializer)}}return r||n?(e.setContentType("application/json",!1),Ec(t)):t}],transformResponse:[function(t){const e=this.transitional||ei.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(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:At.classes.FormData,Blob:At.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=>{ei.headers[s]={}});const Tc=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"]),Mc=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]&&Tc[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},Kr=Symbol("internals");function ii(s){return s&&String(s).trim().toLowerCase()}function Pi(s){return s===!1||s==null?s:v.isArray(s)?s.map(Pi):String(s)}function kc(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 Ds(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 Oc(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function zc(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 Wt=class{constructor(t){t&&this.set(t)}set(t,e,i){const n=this;function r(l,h,a){const c=ii(h);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||h]=Pi(l))}const o=(l,h)=>v.forEach(l,(a,c)=>r(a,c,h));if(v.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(v.isString(t)&&(t=t.trim())&&!Lc(t))o(Mc(t),e);else if(v.isObject(t)&&v.isIterable(t)){let l={},h,a;for(const c of t){if(!v.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[a=c[0]]=(h=l[a])?v.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=ii(t),t){const i=v.findKey(this,t);if(i){const n=this[i];if(!e)return n;if(e===!0)return kc(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=ii(t),t){const i=v.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Ds(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let n=!1;function r(o){if(o=ii(o),o){const l=v.findKey(i,o);l&&(!e||Ds(i,i[l],l,e))&&(delete i[l],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||Ds(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]=Pi(n),delete e[r];return}const l=t?Oc(r):String(r).trim();l!==r&&delete e[r],e[l]=Pi(n),i[l]=!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[Kr]=this[Kr]={accessors:{}}).accessors,n=this.prototype;function r(o){const l=ii(o);i[l]||(zc(n,o),i[l]=!0)}return v.isArray(t)?t.forEach(r):r(t),this}};Wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),v.reduceDescriptors(Wt.prototype,({value:s},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>s,set(i){this[e]=i}}}),v.freezeMethods(Wt);function Vs(s,t){const e=this||ei,i=t||e,n=Wt.from(i.headers);let r=i.data;return v.forEach(s,function(l){r=l.call(e,r,n.normalize(),t?t.status:void 0)}),n.normalize(),r}function Xr(s){return!!(s&&s.__CANCEL__)}let si=class extends V{constructor(t,e,i){super(t??"canceled",V.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function Jr(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 Pc(s){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return t&&t[1]||""}function Nc(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,d=0;for(;u!==n;)d+=e[u++],u=u%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),a-o<t)return;const b=c&&a-c;return b?Math.round(d*1e3/b):void 0}}function Rc(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 Ni=(s,t,e=3)=>{let i=0;const n=Nc(50,250);return Rc(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)},Gr=(s,t)=>{const e=s!=null;return[i=>t[0]({lengthComputable:e,total:s,loaded:i}),t[1]]},Yr=s=>(...t)=>v.asap(()=>s(...t)),Ac=At.hasStandardBrowserEnv?((s,t)=>e=>(e=new URL(e,At.origin),s.protocol===e.protocol&&s.host===e.host&&(t||s.port===e.port)))(new URL(At.origin),At.navigator&&/(msie|trident)/i.test(At.navigator.userAgent)):()=>!0,Bc=At.hasStandardBrowserEnv?{write(s,t,e,i,n,r,o){if(typeof document>"u")return;const l=[`${s}=${encodeURIComponent(t)}`];v.isNumber(e)&&l.push(`expires=${new Date(e).toUTCString()}`),v.isString(i)&&l.push(`path=${i}`),v.isString(n)&&l.push(`domain=${n}`),r===!0&&l.push("secure"),v.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 Dc(s){return typeof s!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Vc(s,t){return t?s.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):s}function Qr(s,t,e){let i=!Dc(t);return s&&(i||e==!1)?Vc(s,t):t}const Zr=s=>s instanceof Wt?{...s}:s;function Me(s,t){t=t||{};const e={};function i(a,c,u,d){return v.isPlainObject(a)&&v.isPlainObject(c)?v.merge.call({caseless:d},a,c):v.isPlainObject(c)?v.merge({},c):v.isArray(c)?c.slice():c}function n(a,c,u,d){if(v.isUndefined(c)){if(!v.isUndefined(a))return i(void 0,a,u,d)}else return i(a,c,u,d)}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 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(Zr(a),Zr(c),u,!0)};return v.forEach(Object.keys({...s,...t}),function(c){if(c==="__proto__"||c==="constructor"||c==="prototype")return;const u=v.hasOwnProp(h,c)?h[c]:n,d=u(s[c],t[c],c);v.isUndefined(d)&&u!==l||(e[c]=d)}),e}const to=s=>{const t=Me({},s);let{data:e,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:l}=t;if(t.headers=o=Wt.from(o),t.url=Hr(Qr(t.baseURL,t.url,t.allowAbsoluteUrls),s.params,s.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),v.isFormData(e)){if(At.hasStandardBrowserEnv||At.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(v.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(At.hasStandardBrowserEnv&&(i&&v.isFunction(i)&&(i=i(t)),i||i!==!1&&Ac(t.url))){const h=n&&r&&Bc.read(r);h&&o.set(n,h)}return t},Fc=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(e,i){const n=to(s);let r=n.data;const o=Wt.from(n.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:a}=n,c,u,d,b,p;function f(){b&&b(),p&&p(),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 S(){if(!m)return;const x=Wt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),P={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:x,config:s,request:m};Jr(function(D){e(D),f()},function(D){i(D),f()},P),m=null}"onloadend"in m?m.onloadend=S:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(S)},m.onabort=function(){m&&(i(new V("Request aborted",V.ECONNABORTED,s,m)),m=null)},m.onerror=function(M){const P=M&&M.message?M.message:"Network Error",K=new V(P,V.ERR_NETWORK,s,m);K.event=M||null,i(K),m=null},m.ontimeout=function(){let M=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const P=n.transitional||Rs;n.timeoutErrorMessage&&(M=n.timeoutErrorMessage),i(new V(M,P.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,s,m)),m=null},r===void 0&&o.setContentType(null),"setRequestHeader"in m&&v.forEach(o.toJSON(),function(M,P){m.setRequestHeader(P,M)}),v.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&l!=="json"&&(m.responseType=n.responseType),a&&([d,p]=Ni(a,!0),m.addEventListener("progress",d)),h&&m.upload&&([u,b]=Ni(h),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",b)),(n.cancelToken||n.signal)&&(c=x=>{m&&(i(!x||x.type?new si(null,s,m):x),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const g=Pc(n.url);if(g&&At.protocols.indexOf(g)===-1){i(new V("Unsupported protocol "+g+":",V.ERR_BAD_REQUEST,s));return}m.send(r||null)})},$c=(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 si(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=()=>v.asap(l),h}},Ic=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},Uc=async function*(s,t){for await(const e of Wc(s))yield*Ic(e,t)},Wc=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()}},eo=(s,t,e,i)=>{const n=Uc(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 d=r+=u;e(d)}h.enqueue(new Uint8Array(c))}catch(a){throw l(a),a}},cancel(h){return l(h),n.return()}},{highWaterMark:2})},io=64*1024,{isFunction:Ri}=v,Hc=(({Request:s,Response:t})=>({Request:s,Response:t}))(v.global),{ReadableStream:so,TextEncoder:no}=v.global,ro=(s,...t)=>{try{return!!s(...t)}catch{return!1}},qc=s=>{s=v.merge.call({skipUndefined:!0},Hc,s);const{fetch:t,Request:e,Response:i}=s,n=t?Ri(t):typeof fetch=="function",r=Ri(e),o=Ri(i);if(!n)return!1;const l=n&&Ri(so),h=n&&(typeof no=="function"?(p=>f=>p.encode(f))(new no):async p=>new Uint8Array(await new e(p).arrayBuffer())),a=r&&l&&ro(()=>{let p=!1;const f=new e(At.origin,{body:new so,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!f}),c=o&&l&&ro(()=>v.isReadableStream(new i("").body)),u={stream:c&&(p=>p.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!u[p]&&(u[p]=(f,m)=>{let S=f&&f[p];if(S)return S.call(f);throw new V(`Response type '${p}' is not supported`,V.ERR_NOT_SUPPORT,m)})});const d=async p=>{if(p==null)return 0;if(v.isBlob(p))return p.size;if(v.isSpecCompliantForm(p))return(await new e(At.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(v.isArrayBufferView(p)||v.isArrayBuffer(p))return p.byteLength;if(v.isURLSearchParams(p)&&(p=p+""),v.isString(p))return(await h(p)).byteLength},b=async(p,f)=>{const m=v.toFiniteNumber(p.getContentLength());return m??d(f)};return async p=>{let{url:f,method:m,data:S,signal:g,cancelToken:x,timeout:M,onDownloadProgress:P,onUploadProgress:K,responseType:D,headers:G,withCredentials:Z="same-origin",fetchOptions:Et}=to(p),$=t||fetch;D=D?(D+"").toLowerCase():"text";let ct=$c([g,x&&x.toAbortSignal()],M),Nt=null;const vt=ct&&ct.unsubscribe&&(()=>{ct.unsubscribe()});let lt;try{if(K&&a&&m!=="get"&&m!=="head"&&(lt=await b(G,S))!==0){let xt=new e(f,{method:"POST",body:S,duplex:"half"}),st;if(v.isFormData(S)&&(st=xt.headers.get("content-type"))&&G.setContentType(st),xt.body){const[dt,Mt]=Gr(lt,Ni(Yr(K)));S=eo(xt.body,io,dt,Mt)}}v.isString(Z)||(Z=Z?"include":"omit");const ht=r&&"credentials"in e.prototype,ut={...Et,signal:ct,method:m.toUpperCase(),headers:G.normalize().toJSON(),body:S,duplex:"half",credentials:ht?Z:void 0};Nt=r&&new e(f,ut);let Rt=await(r?$(Nt,Et):$(f,ut));const Tt=c&&(D==="stream"||D==="response");if(c&&(P||Tt&&vt)){const xt={};["status","statusText","headers"].forEach(_t=>{xt[_t]=Rt[_t]});const st=v.toFiniteNumber(Rt.headers.get("content-length")),[dt,Mt]=P&&Gr(st,Ni(Yr(P),!0))||[];Rt=new i(eo(Rt.body,io,dt,()=>{Mt&&Mt(),vt&&vt()}),xt)}D=D||"text";let St=await u[v.findKey(u,D)||"text"](Rt,p);return!Tt&&vt&&vt(),await new Promise((xt,st)=>{Jr(xt,st,{data:St,headers:Wt.from(Rt.headers),status:Rt.status,statusText:Rt.statusText,config:p,request:Nt})})}catch(ht){throw vt&&vt(),ht&&ht.name==="TypeError"&&/Load failed|fetch/i.test(ht.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,p,Nt,ht&&ht.response),{cause:ht.cause||ht}):V.from(ht,ht&&ht.code,p,Nt,ht&&ht.response)}}},jc=new Map,oo=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=jc;for(;l--;)h=r[l],a=c.get(h),a===void 0&&c.set(h,a=l?new Map:qc(t)),c=a;return a};oo();const Fs={http:pc,xhr:Fc,fetch:{get:oo}};v.forEach(Fs,(s,t)=>{if(s){try{Object.defineProperty(s,"name",{value:t})}catch{}Object.defineProperty(s,"adapterName",{value:t})}});const lo=s=>`- ${s}`,Kc=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 l;if(n=i,!Kc(i)&&(n=Fs[(l=String(i)).toLowerCase()],n===void 0))throw new V(`Unknown adapter '${l}'`);if(n&&(v.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(lo).join(`
5
+ `):" "+lo(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 ho={getAdapter:Xc,adapters:Fs};function $s(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new si(null,s)}function ao(s){return $s(s),s.headers=Wt.from(s.headers),s.data=Vs.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),ho.getAdapter(s.adapter||ei.adapter,s)(s).then(function(i){return $s(s),i.data=Vs.call(s,s.transformResponse,i),i.headers=Wt.from(i.headers),i},function(i){return Xr(i)||($s(s),i&&i.response&&(i.response.data=Vs.call(s,s.transformResponse,i.response),i.response.headers=Wt.from(i.response.headers))),Promise.reject(i)})}const co="1.13.5",Ai={};["object","boolean","number","function","string","symbol"].forEach((s,t)=>{Ai[s]=function(i){return typeof i===s||"a"+(t<1?"n ":" ")+s}});const uo={};Ai.transitional=function(t,e,i){function n(r,o){return"[Axios v"+co+"] 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&&!uo[o]&&(uo[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}},Ai.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Jc(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 Bi={assertOptions:Jc,validators:Ai},Kt=Bi.validators;let ke=class{constructor(t){this.defaults=t||{},this.interceptors={request:new qr,response:new qr}}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=Me(this.defaults,e);const{transitional:i,paramsSerializer:n,headers:r}=e;i!==void 0&&Bi.assertOptions(i,{silentJSONParsing:Kt.transitional(Kt.boolean),forcedJSONParsing:Kt.transitional(Kt.boolean),clarifyTimeoutError:Kt.transitional(Kt.boolean),legacyInterceptorReqResOrdering:Kt.transitional(Kt.boolean)},!1),n!=null&&(v.isFunction(n)?e.paramsSerializer={serialize:n}:Bi.assertOptions(n,{encode:Kt.function,serialize:Kt.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Bi.assertOptions(e,{baseUrl:Kt.spelling("baseURL"),withXsrfToken:Kt.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"],p=>{delete r[p]}),e.headers=Wt.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 m=e.transitional||Rs;m&&m.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,d;if(!h){const p=[ao.bind(this),void 0];for(p.unshift(...l),p.push(...a),d=p.length,c=Promise.resolve(e);u<d;)c=c.then(p[u++],p[u++]);return c}d=l.length;let b=e;for(;u<d;){const p=l[u++],f=l[u++];try{b=p(b)}catch(m){f.call(this,m);break}}try{c=ao.call(this,b)}catch(p){return Promise.reject(p)}for(u=0,d=a.length;u<d;)c=c.then(a[u++],a[u++]);return c}getUri(t){t=Me(this.defaults,t);const e=Qr(t.baseURL,t.url,t.allowAbsoluteUrls);return Hr(e,t.params,t.paramsSerializer)}};v.forEach(["delete","get","head","options"],function(t){ke.prototype[t]=function(e,i){return this.request(Me(i||{},{method:t,url:e,data:(i||{}).data}))}}),v.forEach(["post","put","patch"],function(t){function e(i){return function(r,o,l){return this.request(Me(l||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}ke.prototype[t]=e(),ke.prototype[t+"Form"]=e(!0)});let Gc=class Zo{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 si(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 Zo(function(n){t=n}),cancel:t}}};function Yc(s){return function(e){return s.apply(null,e)}}function Qc(s){return v.isObject(s)&&s.isAxiosError===!0}const Is={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(Is).forEach(([s,t])=>{Is[t]=s});function fo(s){const t=new ke(s),e=zr(ke.prototype.request,t);return v.extend(e,ke.prototype,t,{allOwnKeys:!0}),v.extend(e,t,null,{allOwnKeys:!0}),e.create=function(n){return fo(Me(s,n))},e}const bt=fo(ei);bt.Axios=ke,bt.CanceledError=si,bt.CancelToken=Gc,bt.isCancel=Xr,bt.VERSION=co,bt.toFormData=zi,bt.AxiosError=V,bt.Cancel=bt.CanceledError,bt.all=function(t){return Promise.all(t)},bt.spread=Yc,bt.isAxiosError=Qc,bt.mergeConfig=Me,bt.AxiosHeaders=Wt,bt.formToJSON=s=>jr(v.isHTMLForm(s)?new FormData(s):s),bt.getAdapter=ho.getAdapter,bt.HttpStatusCode=Is,bt.default=bt;const{Axios:Tf,AxiosError:Mf,CanceledError:kf,isCancel:Lf,CancelToken:Of,VERSION:zf,all:Pf,Cancel:Nf,isAxiosError:Rf,spread:Af,toFormData:Bf,AxiosHeaders:Df,HttpStatusCode:Vf,formToJSON:Ff,getAdapter:$f,mergeConfig:If}=bt,ne=Object.create(null);ne.open="0",ne.close="1",ne.ping="2",ne.pong="3",ne.message="4",ne.upgrade="5",ne.noop="6";const Di=Object.create(null);Object.keys(ne).forEach(s=>{Di[ne[s]]=s});const Us={type:"error",data:"parser error"},po=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",mo=typeof ArrayBuffer=="function",bo=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Ws=({type:s,data:t},e,i)=>po&&t instanceof Blob?e?i(t):go(t,i):mo&&(t instanceof ArrayBuffer||bo(t))?e?i(t):go(new Blob([t]),i):i(ne[s]+(t||"")),go=(s,t)=>{const e=new FileReader;return e.onload=function(){const i=e.result.split(",")[1];t("b"+(i||""))},e.readAsDataURL(s)};function vo(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Hs;function Zc(s,t){if(po&&s.data instanceof Blob)return s.data.arrayBuffer().then(vo).then(t);if(mo&&(s.data instanceof ArrayBuffer||bo(s.data)))return t(vo(s.data));Ws(s,!1,e=>{Hs||(Hs=new TextEncoder),t(Hs.encode(e))})}const yo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ni=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<yo.length;s++)ni[yo.charCodeAt(s)]=s;const tu=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=ni[s.charCodeAt(i)],o=ni[s.charCodeAt(i+1)],l=ni[s.charCodeAt(i+2)],h=ni[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},eu=typeof ArrayBuffer=="function",qs=(s,t)=>{if(typeof s!="string")return{type:"message",data:wo(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:iu(s.substring(1),t)}:Di[e]?s.length>1?{type:Di[e],data:s.substring(1)}:{type:Di[e]}:Us},iu=(s,t)=>{if(eu){const e=tu(s);return wo(e,t)}else return{base64:!0,data:s}},wo=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,So="",su=(s,t)=>{const e=s.length,i=new Array(e);let n=0;s.forEach((r,o)=>{Ws(r,!1,l=>{i[o]=l,++n===e&&t(i.join(So))})})},nu=(s,t)=>{const e=s.split(So),i=[];for(let n=0;n<e.length;n++){const r=qs(e[n],t);if(i.push(r),r.type==="error")break}return i};function ru(){return new TransformStream({transform(s,t){Zc(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 js;function Vi(s){return s.reduce((t,e)=>t+e.length,0)}function Fi(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 ou(s,t){js||(js=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(Vi(e)<1)break;const h=Fi(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(Vi(e)<2)break;const h=Fi(e,2);n=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),i=3}else if(i===2){if(Vi(e)<8)break;const h=Fi(e,8),a=new DataView(h.buffer,h.byteOffset,h.length),c=a.getUint32(0);if(c>Math.pow(2,21)-1){l.enqueue(Us);break}n=c*Math.pow(2,32)+a.getUint32(4),i=3}else{if(Vi(e)<n)break;const h=Fi(e,n);l.enqueue(qs(r?h:js.decode(h),t)),i=0}if(n===0||n>s){l.enqueue(Us);break}}}})}const xo=4;function kt(s){if(s)return lu(s)}function lu(s){for(var t in kt.prototype)s[t]=kt.prototype[t];return s}kt.prototype.on=kt.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},kt.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},kt.prototype.off=kt.prototype.removeListener=kt.prototype.removeAllListeners=kt.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},kt.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},kt.prototype.emitReserved=kt.prototype.emit,kt.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},kt.prototype.hasListeners=function(s){return!!this.listeners(s).length};const $i=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Xt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),hu="arraybuffer";function Uf(){}function _o(s,...t){return t.reduce((e,i)=>(s.hasOwnProperty(i)&&(e[i]=s[i]),e),{})}const au=Xt.setTimeout,cu=Xt.clearTimeout;function Ii(s,t){t.useNativeTimers?(s.setTimeoutFn=au.bind(Xt),s.clearTimeoutFn=cu.bind(Xt)):(s.setTimeoutFn=Xt.setTimeout.bind(Xt),s.clearTimeoutFn=Xt.clearTimeout.bind(Xt))}const uu=1.33;function fu(s){return typeof s=="string"?du(s):Math.ceil((s.byteLength||s.size)*uu)}function du(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 Co(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function pu(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function mu(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 bu extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class Ks extends kt{constructor(t){super(),this.writable=!1,Ii(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 bu(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=qs(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=pu(t);return e.length?"?"+e:""}}class gu extends Ks{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)};nu(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,su(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]=Co()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let Eo=!1;try{Eo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const vu=Eo;function yu(){}class wu extends gu{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 re extends kt{constructor(t,e,i){super(),this.createRequest=t,Ii(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=_o(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=re.requestsCount++,re.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=yu,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete re.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(re.requestsCount=0,re.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",To);else if(typeof addEventListener=="function"){const s="onpagehide"in Xt?"pagehide":"unload";addEventListener(s,To,!1)}}function To(){for(let s in re.requests)re.requests.hasOwnProperty(s)&&re.requests[s].abort()}const Su=(function(){const s=Mo({xdomain:!1});return s&&s.responseType!==null})();class xu extends wu{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=Su&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new re(Mo,this.uri(),t)}}function Mo(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||vu))return new XMLHttpRequest}catch{}if(!t)try{return new Xt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ko=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class _u extends Ks{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,i=ko?{}:_o(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;Ws(i,this.supportsBinary,r=>{try{this.doWrite(i,r)}catch{}n&&$i(()=>{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]=Co()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Xs=Xt.WebSocket||Xt.MozWebSocket;class Cu extends _u{createSocket(t,e,i){return ko?new Xs(t,e,i):e?new Xs(t,e):new Xs(t)}doWrite(t,e){this.ws.send(e)}}class Eu extends Ks{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=ou(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),n=ru();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&&$i(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Tu={websocket:Cu,webtransport:Eu,polling:xu},Mu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ku=["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=Mu.exec(s||""),r={},o=14;for(;o--;)r[ku[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=Ou(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 Ou(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,n,r){n&&(e[n]=r)}),e}const Gs=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ui=[];Gs&&addEventListener("offline",()=>{Ui.forEach(s=>s())},!1);class ve extends kt{constructor(t,e){if(super(),this.binaryType=hu,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);Ii(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=mu(this.opts.query)),Gs&&(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"})},Ui.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=xo,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&&ve.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",ve.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+=fu(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,$i(()=>{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(ve.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(),Gs&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=Ui.indexOf(this._offlineEventListener);i!==-1&&Ui.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}ve.protocol=xo;class zu extends ve{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;ve.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;ve.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 d=new Error("probe error");d.transport=e.name,this.emitReserved("upgradeError",d)}}))};function r(){i||(i=!0,c(),e.close(),e=null)}const o=u=>{const d=new Error("probe error: "+u);d.transport=e.name,r(),this.emitReserved("upgradeError",d)};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 Pu=class extends zu{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=>Tu[n]).filter(n=>!!n)),super(t,i)}};function Nu(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 Ru=typeof ArrayBuffer=="function",Au=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Lo=Object.prototype.toString,Bu=typeof Blob=="function"||typeof Blob<"u"&&Lo.call(Blob)==="[object BlobConstructor]",Du=typeof File=="function"||typeof File<"u"&&Lo.call(File)==="[object FileConstructor]";function Ys(s){return Ru&&(s instanceof ArrayBuffer||Au(s))||Bu&&s instanceof Blob||Du&&s instanceof File}function Wi(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,i=s.length;e<i;e++)if(Wi(s[e]))return!0;return!1}if(Ys(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Wi(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&Wi(s[e]))return!0;return!1}function Vu(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(Ys(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 Fu(s,t){return s.data=Zs(s.data,t),delete s.attachments,s}function Zs(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]=Zs(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Zs(s[e],t));return s}const $u=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var et;(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"})(et||(et={}));class Iu{constructor(t){this.replacer=t}encode(t){return(t.type===et.EVENT||t.type===et.ACK)&&Wi(t)?this.encodeAsBinary({type:t.type===et.EVENT?et.BINARY_EVENT:et.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===et.BINARY_EVENT||t.type===et.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=Vu(t),i=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(i),n}}class tn extends kt{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===et.BINARY_EVENT;i||e.type===et.BINARY_ACK?(e.type=i?et.EVENT:et.ACK,this.reconstructor=new Uu(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Ys(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(et[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===et.BINARY_EVENT||i.type===et.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(tn.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 et.CONNECT:return Oo(e);case et.DISCONNECT:return e===void 0;case et.CONNECT_ERROR:return typeof e=="string"||Oo(e);case et.EVENT:case et.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&$u.indexOf(e[0])===-1);case et.ACK:case et.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Uu{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=Fu(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Oo(s){return Object.prototype.toString.call(s)==="[object Object]"}const Wu=Object.freeze(Object.defineProperty({__proto__:null,Decoder:tn,Encoder:Iu,get PacketType(){return et}},Symbol.toStringTag,{value:"Module"}));function ee(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const Hu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class zo extends kt{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=[ee(t,"open",this.onopen.bind(this)),ee(t,"packet",this.onpacket.bind(this)),ee(t,"error",this.onerror.bind(this)),ee(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(Hu.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:et.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:et.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 et.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 et.EVENT:case et.BINARY_EVENT:this.onevent(t);break;case et.ACK:case et.BINARY_ACK:this.onack(t);break;case et.DISCONNECT:this.ondisconnect();break;case et.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:et.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:et.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 Ve(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}Ve.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},Ve.prototype.reset=function(){this.attempts=0},Ve.prototype.setMin=function(s){this.ms=s},Ve.prototype.setMax=function(s){this.max=s},Ve.prototype.setJitter=function(s){this.jitter=s};class en extends kt{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,Ii(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 Ve({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||Wu;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 Pu(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=ee(e,"open",function(){i.onopen(),t&&t()}),r=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=ee(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(ee(t,"ping",this.onping.bind(this)),ee(t,"data",this.ondata.bind(this)),ee(t,"error",this.onerror.bind(this)),ee(t,"close",this.onclose.bind(this)),ee(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){$i(()=>{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 zo(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 ri={};function Hi(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=Nu(s,t.path||"/socket.io"),i=e.source,n=e.id,r=e.path,o=ri[n]&&r in ri[n].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let h;return l?h=new en(i,t):(ri[n]||(ri[n]=new en(i,t)),h=ri[n]),e.query&&!t.query&&(t.query=e.queryKey),h.socket(e.path,t)}Object.assign(Hi,{Manager:en,Socket:zo,io:Hi,connect:Hi});let sn="http://localhost:8000";function Po(s){s&&s!==sn&&(sn=s,oe&&(oe.disconnect(),oe=null))}let oe=null;function qu(){return Hi(sn,{transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,reconnectionAttempts:1/0,timeout:1e4,forceNew:!1,withCredentials:!1,autoConnect:!0,upgrade:!0})}function nn(){return oe||(oe=qu()),oe}function ju(s,t){const e=nn();return e.on(s,t),()=>e.off(s,t)}function Ku(s,t){oe&&oe.off(s,t)}function Xu(s,t){nn().emit(s,t)}function Ju(){return oe?oe.connected?"connected":"connecting":"disconnected"}const qi={getSocket:nn,on:ju,off:Ku,emit:Xu,getStatus:Ju,setBaseUrl:Po},No=C.createContext(),le=()=>{const s=C.useContext(No);if(!s)throw new Error("useTrading must be used within TradingProvider");return s},Gu=({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:ji&&ji.tagName.toUpperCase()==="SCRIPT"&&ji.src||new URL("chart-sdk.umd.js",document.baseURI).href}<"u"&&"http://localhost:8000"||"http://localhost:8000";Wo(e),qi.setBaseUrl(e),C.useEffect(()=>{qi.setBaseUrl(e)},[e]);const[i,n]=C.useState("BTCUSDT"),[r,o]=C.useState("M1"),[l,h]=C.useState([]),[a,c]=C.useState(!0),[u,d]=C.useState([]),[b,p]=C.useState(!1),[f,m]=C.useState(1e5),[S,g]=C.useState(null),[x,M]=C.useState([]),[P,K]=C.useState(!0),[D,G]=C.useState(!1),[Z,Et]=C.useState(!0),[$,ct]=C.useState("candles"),[Nt,vt]=C.useState(!1),lt=C.useRef(null),ht=C.useRef(new Map),ut=C.useRef(null),Rt=1e3,Tt=C.useCallback(async()=>{try{const W=localStorage.getItem("token");if(!W){console.log("⚠️ No token, skipping orders fetch");return}p(!0);const nt=await bt.get(`${e}/api/trades`,{headers:{Authorization:`Bearer ${W}`}});if(nt.data&&nt.data.data){const wt=nt.data.data.map(tt=>({id:tt.id,ticket:tt.ticket,symbol:tt.symbol,type:tt.type,volume:tt.volume,price:tt.price,stopLoss:tt.stopLoss,takeProfit:tt.takeProfit,comment:tt.comment||"",status:tt.status,swap:tt.swap||0,profit:tt.profit||0,profitCurrency:"USD",time:new Date(tt.openAt).toLocaleTimeString(),openAt:tt.openAt,closeAt:tt.closeAt}));d(wt)}else d([])}catch(W){console.error("❌ Error fetching orders:",W.response?.data||W.message),d([])}finally{p(!1)}},[]),St=C.useCallback((W,nt)=>!nt||!W.price||isNaN(nt)||isNaN(W.price)?W.profit||0:(W.type==="BUY"?nt-W.price:W.price-nt)*W.volume,[]),xt=C.useCallback(async()=>{try{const W=localStorage.getItem("token");if(!W){console.log("⚠️ No token, skipping balance fetch");return}const nt=await bt.get(`${e}/api/user/account`,{headers:{Authorization:`Bearer ${W}`}});if(nt.data&&nt.data.data){const wt=parseFloat(nt.data.data.balance);isNaN(wt)||m(wt)}}catch(W){console.error("❌ Error fetching user balance:",W.response?.data||W.message)}},[]),st=C.useMemo(()=>{const W=f,nt=u.reduce((Ot,zt)=>Ot+zt.volume*zt.price*.01,0),wt=u.reduce((Ot,zt)=>{const Jt=l.find(Gt=>Gt.symbol===zt.symbol);if(Jt){const Gt=zt.type==="BUY"?parseFloat(Jt.bid||0):parseFloat(Jt.ask||0);if(Gt&&Gt>0&&!isNaN(Gt))return Ot+St(zt,Gt)}return Ot+(zt.profit||0)},0),tt=W+wt,it=tt-nt,rt=nt>0?tt/nt*100:0;return{balance:W,equity:tt,margin:nt,freeMargin:it,level:rt.toFixed(2)}},[u,l,f,St]);C.useEffect(()=>{localStorage.getItem("token")&&(Tt(),xt())},[Tt,xt]),C.useEffect(()=>{(async()=>{try{c(!0);const nt=await bt.get(`${e}/api/symbols`);if(nt.data&&nt.data.data){const wt=nt.data.data;h(wt),wt.length>0&&(wt.find(it=>it.symbol===i)||n(wt[0].symbol))}else h([])}catch(nt){console.error("❌ Error fetching symbols:",nt.response?.data||nt.message),h([])}finally{c(!1)}})()},[]);const dt=C.useCallback(()=>{const W=ht.current;if(W.size===0)return;const nt=new Map(W);W.clear(),h(wt=>wt.map(tt=>{const it=nt.get(tt.symbol);return it?{...tt,...it}:tt})),d(wt=>{let tt=!1;const it=wt.map(rt=>{const Ot=nt.get(rt.symbol);if(!Ot)return rt;const zt=rt.type==="BUY"?parseFloat(Ot.bid||0):parseFloat(Ot.ask||0);if(!zt||isNaN(zt)||zt<=0)return rt;const Jt=St(rt,zt);return Jt===rt.profit?rt:(tt=!0,{...rt,profit:Jt})});return tt?it:wt})},[St]);C.useEffect(()=>{lt.current||(lt.current=qi.getSocket());const W=lt.current,nt=()=>console.log("✅ TradingContext: Connected"),wt=()=>console.log("⚠️ TradingContext: Disconnected"),tt=rt=>{rt?.symbol&&(ht.current.set(rt.symbol,rt),ut.current||(ut.current=setTimeout(()=>{ut.current=null,dt()},Rt)))},it=async rt=>{if(console.log("🔔 Trade closed event received:",rt),!!rt){if(rt.newBalance!==void 0){const Ot=parseFloat(rt.newBalance);isNaN(Ot)||m(Ot)}if(window.notify){const Ot=rt.profitLoss||rt.profit||0,zt=Ot>=0?`+${Ot.toFixed(2)}`:Ot.toFixed(2),Jt=rt.symbol||"Trade",Gt=rt.reason||"Closed";window.notify(`Trade Closed: ${Gt} | ${Jt} | P/L: ${zt} USD`,Ot>=0?"success":"error")}rt.tradeId&&d(Ot=>Ot.filter(zt=>zt.id!==rt.tradeId)),await Tt(),await xt()}};return W.on("connect",nt),W.on("disconnect",wt),W.on("priceUpdate",tt),W.on("tradeClosed",it),()=>{W.off("connect",nt),W.off("disconnect",wt),W.off("priceUpdate",tt),W.off("tradeClosed",it),ut.current&&(clearTimeout(ut.current),ut.current=null),ht.current.clear()}},[dt,Tt,xt]);const Mt=C.useMemo(()=>l.find(W=>W.symbol===i)||{bid:"0.00000",ask:"0.00000",change:0},[l,i]),_t=C.useMemo(()=>({selectedSymbol:i,setSelectedSymbol:n,selectedTimeframe:r,setSelectedTimeframe:o,symbols:l,setSymbols:h,symbolsLoading:a,orders:u,setOrders:d,ordersLoading:b,fetchOrders:Tt,fetchUserBalance:xt,userBalance:f,setUserBalance:m,accountSummary:st,currentSymbolData:Mt,activeTool:S,setActiveTool:g,chartObjects:x,setChartObjects:M,showGrid:P,setShowGrid:K,snapToGrid:D,setSnapToGrid:G,drawingsVisible:Z,setDrawingsVisible:Et,chartType:$,setChartType:ct,chartLocked:Nt,setChartLocked:vt,baseUrl:e}),[i,r,l,a,u,b,Tt,xt,f,st,Mt,S,x,P,D,Z,$,Nt,e]);return w.jsx(No.Provider,{value:_t,children:s})};function Lt(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 Yu(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 Qu(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 Ro(s){return Array.isArray(s)?s.map(t=>({...t,time:Lt(t.time)})).filter(t=>t.time!=null):[]}function Zu(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 Fe(s,t){return!Number.isFinite(s)||!Number.isFinite(t)||t<=0?s:Math.floor(s/t)*t}const Bt="17:00-17:00",Dt="America/New_York",he="24x7",ae="UTC",Ao={EURUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},GBPUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},USDJPY:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},USDCHF:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},AUDUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},USDCAD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},NZDUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},EURGBP:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},GBPJPY:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},CADJPY:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},XAUUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},XAGUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},OILUSD:{type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"},BTCUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},ETHUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},BNBUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},SOLUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},ADAUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},XRPUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},DOGEUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},DOTUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},MATICUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"},LINKUSDT:{type:"crypto",session:he,sessionTZ:ae,priceMode:"last"}},Bo={type:"forex",sessionTZ:Dt,session:Bt,priceMode:"mid"};function oi(s){return s&&Ao[s.toUpperCase()]||Bo}function tf(s){return oi(s).type==="forex"}function ef(s){return oi(s).type==="crypto"}function sf(s){return oi(s).session==="24x7"}function Do(s){if(!s||typeof s!="object")return!1;const{time:t,open:e,high:i,low:n,close:r,volume:o}=s;return!(Lt(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 Vo(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 Fo(s){if(!Array.isArray(s)||s.length===0)return[];const t=new Map;return s.forEach(e=>{const i=Lt(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 nf(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 rf(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 d=h+t,b=0;for(d=Fe(d,t);d<a&&b<n;){const p=Fe(d,t);e.some(m=>m.time===p)||(e.push({time:p,open:u.close,high:u.close,low:u.close,close:u.close,volume:0}),b++),d+=t}if(d<a&&b>=n){const p=Fe(a-t,t);e.some(m=>m.time===p)||e.push({time:p,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 rn(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 $o(s,t,e){if(!Array.isArray(s)||s.length===0)return{candles:[],stats:{original:0,processed:0,duplicates:0,outliers:0,gaps:[]}};const i=oi(t),n=rn(e),l=Ro(s).map(m=>({...m,time:Fe(m.time,n)})).filter(m=>Do(m)).map(m=>Vo(m)),h=Fo(l);h.sort((m,S)=>m.time-S.time);const a=h.filter((m,S)=>S===0?!0:m.time>h[S-1].time),c=a.length>10?nf(a,"percentile"):a,u=Fo(c);u.sort((m,S)=>m.time-S.time);const d=rf(u,n),b=[];for(let m=1;m<d.length;m++){const S=d[m].time-d[m-1].time;S>n*2&&b.push({from:d[m-1].time,to:d[m].time,gapSeconds:S,gapMinutes:Math.round(S/60),fromDate:new Date(d[m-1].time*1e3).toISOString(),toDate:new Date(d[m].time*1e3).toISOString()})}const p=c.filter((m,S)=>S===0?!1:m.close===c[S-1].close&&m.open===c[S-1].close).length,f={original:s.length,processed:d.length,duplicates:s.length-h.length,outliers:p,gaps:b,filledGaps:d.length-u.length,symbolConfig:i};return{candles:d,stats:f}}function Io(s,t,e="1m"){if(!s||!t||!Do(s))return null;const i=Lt(s.time);if(i==null)return null;const n=rn(e),r=Fe(i,n);return Vo({...s,time:r})}let Uo="http://localhost:8000";function Wo(s){s&&(Uo=s)}const of={M1:3,M5:7,M15:14,M30:30,H1:90,H4:180,D1:1095,W1:1825,MN:3650};function Ho(s){if(!s)return 7;const t=String(s).toUpperCase();return of[t]??7}function lf(s,t){const e=String(s||"").toUpperCase(),i=t||Ho(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 Vt=s=>{if(!Array.isArray(s)||s.length===0)return[];const t=s.map(i=>({...i,time:Lt(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 hf(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 on(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 p=c-h;return[{time:r,price:h+p},{time:o+1,price:a+p}]}const u=(a-h)/l,d=c+u*(r-n.time),b=c+u*(o-n.time);return[{time:r,price:d},{time:o,price:b}]}const af=C.forwardRef(function({bidPrice:t="113.638",askPrice:e="113.649",showBuySellPanel:i=!0,onBuyClick:n,onSellClick:r},o){const l=C.useRef(null),h=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useRef([]),d=C.useRef(!1),b=C.useRef(null),p=C.useRef(null),f=C.useRef(null),m=C.useRef(null),S=C.useRef([]),[g,x]=C.useState(null),[M,P]=C.useState([]),K=C.useRef(null),D=C.useRef(null),G=C.useRef(null),Z=C.useRef(!1);C.useEffect(()=>{G.current=g},[g]);const Et=C.useRef(new Map),$=C.useRef(null),ct=(y,_)=>`${y}_${_}`,Nt=()=>{const y=ct(st,dt);return Et.current.get(y)||null},vt=y=>{if(!y)return;const _=ct(st,dt);Et.current.set(_,y)},{activeTool:lt,setActiveTool:ht,showGrid:ut,snapToGrid:Rt,chartObjects:Tt,setChartObjects:St,orders:xt,selectedSymbol:st,selectedTimeframe:dt,drawingsVisible:Mt,chartType:_t,chartLocked:W,baseUrl:nt}=le(),wt=nt||Uo,tt=C.useRef([]),[it,rt]=C.useState([]),[Ot,zt]=C.useState(!0),Jt=C.useRef(null),Gt=C.useRef(new Map);C.useRef(null);const Yo=C.useRef(0);C.useImperativeHandle(o,()=>({zoomIn:()=>{const y=h.current?.timeScale();if(!y)return;const _=y.getVisibleRange();if(!_||!_.from||!_.to)return;const T=_.to-_.from,R=(_.from+_.to)/2,L=T*.8;try{y.setVisibleRange({from:R-L/2,to:R+L/2}),vt(y.getVisibleRange())}catch{}},zoomOut:()=>{const y=h.current?.timeScale();if(!y)return;const _=y.getVisibleRange();if(!_||!_.from||!_.to)return;const T=_.to-_.from,R=(_.from+_.to)/2,L=T*1.25;try{y.setVisibleRange({from:R-L/2,to:R+L/2}),vt(y.getVisibleRange())}catch{}}}));const an=C.useMemo(()=>it.length===0?[]:_t==="line"||_t==="area"?it.map(y=>({time:y.time,value:y.close})):it,[it,_t]);return C.useEffect(()=>{const y=l.current;if(!y)return;const _=y.getBoundingClientRect(),T=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"},R=La(y,{width:_.width||y.clientWidth,height:_.height||y.clientHeight,autoSize:!0,localization:{priceFormatter:T},layout:{background:{color:"#0F1720"},textColor:"#fff",fontSize:12},grid:{vertLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ut,color:ut?"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:lt===1?1:0,vertLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},vertLineVisible:lt===1,horzLineVisible:lt===1},handleScroll:{mouseWheel:!0,pressedMouseMove:lt===null||lt===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}}),L=R.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1});h.current=R,a.current=L;const H=R.timeScale(),J=()=>{if(Z.current&&it.length>0){const O=H.getVisibleRange();O&&vt(O)}};H.subscribeVisibleTimeRangeChange(J);const pt=new ResizeObserver(O=>{for(const I of O){const{width:at,height:q}=I.contentRect;if(at>0&&q>0&&R){const k=H.getVisibleRange();R.resize(at,q),k&&setTimeout(()=>{try{H.setVisibleRange(k)}catch{}},0)}}});return pt.observe(y),()=>{H.unsubscribeVisibleTimeRangeChange(J),pt.disconnect(),R.remove(),h.current=null,a.current=null,c.current=null,u.current=[]}},[]),C.useEffect(()=>{h.current&&h.current.applyOptions({grid:{vertLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ut,color:ut?"rgba(148, 163, 184, 0.2)":"transparent",style:0}}})},[ut]),C.useEffect(()=>{if(!h.current)return;const _=!W&&!(lt!==null&&lt!==1&&lt!==0),T=!W;h.current.applyOptions({crosshair:{mode:lt===1?1:0,vertLine:{visible:lt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{visible:lt===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"}},handleScroll:{mouseWheel:T,pressedMouseMove:_,horzTouchDrag:_,vertTouchDrag:_},handleScale:{axisPressedMouseMove:{time:_,price:_},axisDoubleClickReset:{time:T,price:T},axisTouch:{time:_,price:_},mouseWheel:T,pinch:T}})},[lt,W]),C.useEffect(()=>{(async()=>{if(!st||!dt){rt([]),Z.current=!1;return}try{if(zt(!0),rt([]),Z.current=!1,a.current)try{a.current.setData([])}catch{}console.log(`📊 Fetching candles for ${st} @ ${dt}`);const _=Ho(dt),T=lf(dt,_),R=await bt.get(`${wt}/api/chart/candles`,{params:{symbol:st,timeframe:dt,limit:T,daysBack:_},timeout:1e4});if(R.data&&R.data.data&&R.data.data.length>0){const L=R.data.data;console.log(`✅ Loaded ${L.length} raw candles from server`);const{candles:H,stats:J}=$o(L,st,dt);H.length>0?(rt(H),Gt.current=new Map,H.forEach(pt=>{Gt.current.set(pt.time,pt)})):(console.warn(`⚠️ No valid candles after processing for ${st}`),rt([]))}else console.warn(`⚠️ No candle data returned for ${st}`),rt([])}catch(_){console.error(`❌ Error fetching ${st}:`,_.message),rt([])}finally{zt(!1)}})()},[st,dt,wt]),C.useEffect(()=>{Jt.current=qi.getSocket();const y=Jt.current,_=()=>{console.log("✅ Chart WebSocket connected"),L()},T=()=>{console.log("⚠️ Chart WebSocket disconnected - will auto-reconnect")},R=J=>{console.error("❌ Chart WebSocket connection error:",J)};y.on("connect",_),y.on("disconnect",T),y.on("connect_error",R);const L=()=>{st&&dt&&y.connected&&(console.log(`Subscribing to real-time candles: ${st}@${dt}`),y.emit("subscribeCandles",{symbol:st,timeframe:dt}))},H=J=>{if(!J||!J.candle||!J.symbol||J.symbol.toUpperCase()!==st?.toUpperCase())return;const{candle:pt}=J,O=Io(pt,st,dt);if(!O)return;const I=Date.now();if(I-Yo.current<200)return;Yo.current=I;const at=h.current?.timeScale(),q=at?.getVisibleRange(),k=a.current,U=h.current;if(!(!k||!U||!Z.current))try{_t==="line"||_t==="area"?k.update({time:O.time,value:O.close}):k.update({time:O.time,open:O.open,high:O.high,low:O.low,close:O.close}),Gt.current.set(O.time,O),at&&q&&vt(q)}catch(z){console.error("❌ Error updating candle:",z)}};return y.on("candleUpdate",H),y.connected&&L(),()=>{y.off("candleUpdate",H),y.off("connect",_),y.off("disconnect",T),y.off("connect_error",R),st&&dt&&y.connected&&y.emit("unsubscribeCandles",{symbol:st,timeframe:dt})}},[st,dt]),C.useEffect(()=>{const y=a.current,_=h.current;if(!(!y||!_)&&!(it.length===0&&Z.current)){if(it.length===0&&!Z.current){if(Ot)return;const T=_.timeScale();y.setData([]),T.fitContent();return}if(!Z.current){const T=_.timeScale(),R=ct(st,dt);if($.current,$.current=R,_t==="line"||_t==="area"){const H=[...it.map(J=>({time:J.time,value:J.close})).filter(J=>J.time!=null)].sort((J,pt)=>J.time-pt.time);H.length>0&&y.setData(H)}else{const L=[...it].sort((H,J)=>H.time-J.time);L.length>0&&y.setData(L)}T.fitContent();try{_.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}Z.current=!0,vt(T.getVisibleRange())}}},[it.length,_t,st,dt]),C.useEffect(()=>{const y=h.current;if(!y||!Z.current||it.length===0)return;const _=y.timeScale(),T=_.getVisibleRange()||Nt();if(a.current)try{y.removeSeries(a.current)}catch{}if(c.current)try{y.removeSeries(c.current),c.current=null}catch{}let R;if(_t==="bars"){R=y.addBarSeries({upColor:"#26A69A",downColor:"#EF5350",borderUpColor:"#26A69A",borderDownColor:"#EF5350",scaleMargins:{top:.1,bottom:.1}});const L=[...it].sort((H,J)=>H.time-J.time);L.length>0&&R.setData(L)}else if(_t==="line"){R=y.addLineSeries({color:"#38bdf8",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const L=Vt(an);L.length>0&&R.setData(L)}else if(_t==="area"){R=y.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 L=Vt(an);L.length>0&&R.setData(L)}else if(_t==="volume ticks"||_t==="volume"){R=y.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,priceScaleId:"right"});const L=[...it].sort((pt,O)=>pt.time-O.time);L.length>0&&R.setData(L);const H=y.addHistogramSeries({priceFormat:{type:"volume"},priceScaleId:"vol",base:0,priceLineVisible:!1,lastValueVisible:!1,color:"rgba(38,166,154,0.15)"});y.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.3}}),y.priceScale("vol").applyOptions({scaleMargins:{top:.75,bottom:0},visible:!1});const J=L.map(pt=>({time:pt.time,value:pt.volume||0,color:pt.close>=pt.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));J.length>0&&H.setData(J),c.current=H}else{R=y.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,scaleMargins:{top:.1,bottom:.1}});const L=[...it].sort((H,J)=>H.time-J.time);L.length>0&&R.setData(L)}if(a.current=R,T&&Z.current)setTimeout(()=>{try{_.setVisibleRange(T),vt(T)}catch{if(it.length>0)try{const H=it[it.length-1].time,J=H-6e3;_.setVisibleRange({from:J,to:H}),vt(_.getVisibleRange())}catch{_.fitContent(),vt(_.getVisibleRange())}}try{y.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}},0);else if(!Z.current){_.fitContent();try{y.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}Z.current=!0,vt(_.getVisibleRange())}},[_t,it.length,an.length]),C.useEffect(()=>{const y=h.current,_=c.current;if(!y||!_||!Z.current||it.length===0||_t!=="volume"&&_t!=="volume ticks")return;const R=[...it].sort((L,H)=>L.time-H.time).map(L=>({time:L.time,value:L.volume||0,color:L.close>=L.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));R.length>0&&_.setData(R)},[it,_t]),C.useEffect(()=>{const y=h.current,_=a.current,T=l.current;if(!y||!_||!T)return;const L=lt!==null?[null,null,"trendline","parallellines","fibonacci","rectangle","pricelevel","text",null,null,null,null,null,null,null,null,null][lt]:null;if(!L){if(d.current=!1,b.current=null,p.current=null,m.current=null,f.current?.series)try{y.removeSeries(f.current.series)}catch{}f.current=null;return}if(L==="pricelevel"){const O=I=>{const at=T.getBoundingClientRect(),q=I.clientX-at.left,k=I.clientY-at.top,U=y.timeScale().coordinateToTime(q),z=_.coordinateToPrice(k);if(U==null||z==null)return;const A={type:"pricelevel",priceLine:_.createPriceLine({price:z,color:"#3b82f6",lineWidth:2,lineStyle:2,axisLabelVisible:!0,title:z.toFixed(5)}),price:z};St(j=>[...j,A]),u.current.push(A)};return T.addEventListener("click",O),()=>{T.removeEventListener("click",O)}}if(L==="trendline"){const O=k=>{k.preventDefault(),k.stopPropagation(),k.stopImmediatePropagation();const U=T.getBoundingClientRect(),z=k.clientX-U.left,B=k.clientY-U.top;let A=y.timeScale().coordinateToTime(z);const j=_.coordinateToPrice(B);if(!(A==null||j==null)&&(A=Lt(A),A!=null))if(m.current===null){m.current={time:A,price:j};const N=y.addLineSeries({color:"#22c55e",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"trendline",series:N},N.setData([{time:A,value:j}])}else{const N=m.current,F={time:A,price:j},X=1,mt=1e-5,ot=Math.abs(F.time-N.time),yt=Math.abs(F.price-N.price);if(ot<X&&yt<mt){try{y.removeSeries(f.current.series)}catch{}m.current=null,f.current=null;return}const fe={time:N.time,price:N.price},de={time:F.time,price:F.price},Yt=Vt([{time:fe.time,value:fe.price},{time:de.time,value:de.price}]);if(Yt.length>0){f.current.series.setData(Yt);const ye={type:"trendline",series:f.current.series,point1:fe,point2:de};St(Le=>[...Le,ye]),u.current.push(ye)}ht(null),m.current=null,f.current=null}},I=k=>{if(m.current===null||f.current?.type!=="trendline")return;k.preventDefault(),k.stopPropagation();const U=T.getBoundingClientRect(),z=k.clientX-U.left,B=k.clientY-U.top;let A=y.timeScale().coordinateToTime(z);const j=_.coordinateToPrice(B);if(A==null||j==null||(A=Lt(A),A==null))return;const N=m.current,F=Vt([{time:N.time,value:N.price},{time:A,value:j}]);F.length>0&&f.current.series.setData(F)},at=k=>{k.stopPropagation()},q={capture:!0,passive:!1};return T.addEventListener("click",O,q),T.addEventListener("mousemove",I,q),T.addEventListener("mousemove",at,q),()=>{if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{y.removeSeries(f.current.series)}catch{}f.current=null}T.removeEventListener("click",O,q),T.removeEventListener("mousemove",I,q),T.removeEventListener("mousemove",at,q)}}if(L==="parallellines"){const O={capture:!0,passive:!1},I=z=>{z.preventDefault(),z.stopPropagation(),z.stopImmediatePropagation();const B=T.getBoundingClientRect(),A=z.clientX-B.left,j=z.clientY-B.top;let N=y.timeScale().coordinateToTime(A);const F=_.coordinateToPrice(j);if(N==null||F==null||(N=Lt(N),N==null))return;const X={time:N,price:F},mt=S.current;if(mt.length===0){S.current=[X];const ot=y.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});ot.setData([{time:N,value:F}]),f.current={type:"parallellines",series:ot,previewLine:null}}else if(mt.length===1){S.current=[mt[0],X];const ot=Vt([{time:mt[0].time,value:mt[0].price},{time:N,value:F}]);ot.length>0&&f.current.series.setData(ot),f.current.previewLine=y.addLineSeries({color:"#8b5cf6",lineWidth:2,lineStyle:2,priceLineVisible:!1,lastValueVisible:!1});const yt=on(y,_,mt[0],X,X);yt&&f.current.previewLine.setData(Vt([{time:yt[0].time,value:yt[0].price},{time:yt[1].time,value:yt[1].price}]))}else{const[ot,yt]=mt,fe=X;if(f.current?.previewLine){try{y.removeSeries(f.current.previewLine)}catch{}f.current.previewLine=null}const de=f.current?.series;if(!de)return;const Yt=on(y,_,ot,yt,fe);if(!Yt)return;const ye=y.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});de.setData(Vt([{time:ot.time,value:ot.price},{time:yt.time,value:yt.price}])),ye.setData(Vt([{time:Yt[0].time,value:Yt[0].price},{time:Yt[1].time,value:Yt[1].price}]));const Le={type:"parallellines",point1:ot,point2:yt,point3:fe,baseLine:de,parallelLine:ye};St(li=>[...li,Le]),u.current.push(Le),ht(null),S.current=[],f.current=null}},at=z=>{const B=S.current;if(B.length!==1||!f.current?.series)return;const A=T.getBoundingClientRect(),j=z.clientX-A.left,N=z.clientY-A.top;let F=y.timeScale().coordinateToTime(j);const X=_.coordinateToPrice(N);if(F==null||X==null||(F=Lt(F),F==null))return;const mt=Vt([{time:B[0].time,value:B[0].price},{time:F,value:X}]);mt.length>0&&f.current.series.setData(mt)},q=z=>{const B=S.current;if(B.length!==2||!f.current?.previewLine)return;const A=T.getBoundingClientRect(),j=z.clientX-A.left,N=z.clientY-A.top;let F=y.timeScale().coordinateToTime(j);const X=_.coordinateToPrice(N);if(F==null||X==null||(F=Lt(F),F==null))return;const mt={time:F,price:X},ot=on(y,_,B[0],B[1],mt);ot&&f.current.previewLine.setData(Vt([{time:ot[0].time,value:ot[0].price},{time:ot[1].time,value:ot[1].price}]))},k=z=>{at(z),q(z)},U=z=>{z.stopPropagation()};return T.addEventListener("click",I,O),T.addEventListener("mousemove",k,O),T.addEventListener("mousemove",U,O),()=>{if(S.current=[],f.current?.type==="parallellines"){try{f.current.series&&y.removeSeries(f.current.series),f.current.previewLine&&y.removeSeries(f.current.previewLine)}catch{}f.current=null}T.removeEventListener("click",I,O),T.removeEventListener("mousemove",k,O),T.removeEventListener("mousemove",U,O)}}if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{y.removeSeries(f.current.series)}catch{}f.current=null}const H=O=>{if(O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation(),L==="trendline"||L==="parallellines"||L!=="rectangle"&&L!=="fibonacci")return;const I=T.getBoundingClientRect(),at=O.clientX-I.left,q=O.clientY-I.top;let k=y.timeScale().coordinateToTime(at);const U=_.coordinateToPrice(q);if(!(k==null||U==null)&&(k=Lt(k),k!=null)){if(d.current=!0,b.current={time:k,price:U},p.current=null,L==="rectangle"){const z=y.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:z}}if(L==="fibonacci"){const z=y.addLineSeries({color:"#f59e0b",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"fibonacci",series:z,priceLines:[]}}if(L==="parallellines"){const z=y.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"parallellines",series:z,firstLine:null,secondLine:null}}}},J=O=>{if(!d.current||!b.current||!f.current)return;O.preventDefault(),O.stopPropagation(),O.stopImmediatePropagation();const I=T.getBoundingClientRect(),at=O.clientX-I.left,q=O.clientY-I.top;let k=y.timeScale().coordinateToTime(at);const U=_.coordinateToPrice(q);if(k==null||U==null||(k=Lt(k),k==null))return;p.current={time:k,price:U};const z=b.current;if(f.current.type==="rectangle"){const B=Math.max(z.price,U),A=Math.min(z.price,U),j=Lt(Math.min(z.time,k)),N=Lt(Math.max(z.time,k));if(j==null||N==null||Math.abs(N-j)<1||Math.abs(B-A)<1e-5)return;const F=f.current.series;F.setData(Vt([{time:j,value:B},{time:N,value:B}])),F.applyOptions({baseValue:{type:"price",price:A}})}if(f.current.type==="fibonacci"){const B=[{time:z.time,value:z.price},{time:k,value:U}],A=Vt(B);A.length>0&&f.current.series.setData(A),p.current={time:k,price:U},f.current.priceLines&&(f.current.priceLines.forEach(j=>{try{_.removePriceLine(j)}catch{}}),f.current.priceLines=[])}if(f.current.type==="parallellines")if(f.current.firstLine){const B=f.current.firstLine;B.endTime-B.startTime;const A=B.endPrice-B.startPrice,j=U,N=j+A;if(f.current.secondLine)f.current.secondLine.setData([{time:z.time,value:j},{time:k,value:N}]);else{const F=y.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});F.setData([{time:z.time,value:j},{time:k,value:N}]),f.current.secondLine=F}}else f.current.series.setData([{time:z.time,value:z.price},{time:k,value:U}])},pt=O=>{if(O&&(O.preventDefault(),O.stopPropagation()),!d.current||!f.current||!b.current)return;const I=b.current,at=p.current||I;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};St(k=>[...k,q]),u.current.push(q),ht(null),f.current=null,d.current=!1,b.current=null,p.current=null;return}else{f.current.firstLine={startTime:I.time,startPrice:I.price,endTime:at.time,endPrice:at.price},d.current=!1,b.current=null,p.current=null;return}if(f.current.type==="fibonacci"){const k=(p.current||I).price;if(Math.abs(I.price-k)<1e-4){try{y.removeSeries(f.current.series)}catch{}d.current=!1,b.current=null,p.current=null,f.current=null;return}const U=Math.max(I.price,k),z=Math.min(I.price,k),B=U-z,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%"}],j=[],N=f.current.series;try{y.removeSeries(N)}catch{}A.forEach(({level:X,label:mt})=>{const ot=U-B*X,yt=_.createPriceLine({price:ot,color:X===0||X===1?"#f59e0b":"#fbbf24",lineWidth:X===0||X===1?2:1,lineStyle:X===0||X===1?0:2,axisLabelVisible:!0,title:`${mt} (${ot.toFixed(5)})`,textColor:X===0||X===1?"#f59e0b":"#fbbf24"});j.push(yt)});const F={type:"fibonacci",priceLines:j,startPrice:I.price,endPrice:k,high:U,low:z};St(X=>[...X,F]),u.current.push(F),ht(null)}if(f.current.type==="rectangle"){const q=b.current,k=p.current||q,U=Math.max(q.price,k.price),z=Math.min(q.price,k.price),B=Lt(Math.min(q.time,k.time)),A=Lt(Math.max(q.time,k.time));if(B!=null&&A!=null&&Math.abs(A-B)>=1&&Math.abs(U-z)>=1e-5){const j=f.current.series;j.setData(Vt([{time:B,value:U},{time:A,value:U}])),j.applyOptions({baseValue:{type:"price",price:z}});const N={type:"rectangle",timeStart:B,timeEnd:A,priceTop:U,priceBottom:z,series:j};St(F=>[...F,N]),u.current.push(N),ht(null)}else try{y.removeSeries(f.current.series)}catch{}}d.current=!1,b.current=null,p.current=null,f.current=null};if(L==="rectangle"||L==="fibonacci"||L==="parallellines"){const O={capture:!0,passive:!1},I=at=>{d.current||at.stopPropagation()};return T.addEventListener("mousedown",H,O),T.addEventListener("mousemove",J,O),T.addEventListener("mousemove",I,O),T.addEventListener("mouseup",pt,O),()=>{T.removeEventListener("mousedown",H,O),T.removeEventListener("mousemove",J,O),T.removeEventListener("mousemove",I,O),T.removeEventListener("mouseup",pt,O)}}},[lt,St,ht]),C.useEffect(()=>{const y=h.current,_=a.current,T=l.current,R=lt===null||lt===1;if(!R||!y||!_||!T){R||(x(null),P([]));return}const L=10,H=8;function J(q,k){const U=Tt.filter(z=>z.type==="trendline"&&z.point1&&z.point2);for(let z=U.length-1;z>=0;z--){const B=U[z],A=y.timeScale().timeToCoordinate(B.point1.time),j=_.priceToCoordinate(B.point1.price),N=y.timeScale().timeToCoordinate(B.point2.time),F=_.priceToCoordinate(B.point2.price);if(A==null||j==null||N==null||F==null)continue;const X=Math.hypot(q-A,k-j),mt=Math.hypot(q-N,k-F);if(X<L)return{object:B,mode:"handle1"};if(mt<L)return{object:B,mode:"handle2"};if(hf(q,k,A,j,N,F)<H)return{object:B,mode:"line"}}return null}const pt=q=>{q.preventDefault(),q.stopPropagation();const k=T.getBoundingClientRect(),U=q.clientX-k.left,z=q.clientY-k.top,B=J(U,z);B?(x(B.object),K.current=B.mode,B.mode==="line"&&(D.current={x:U,y:z,point1:{...B.object.point1},point2:{...B.object.point2}})):(x(null),K.current=null)},O=q=>{if(!K.current)return;const k=G.current;if(!k||!k.point1||!k.point2)return;const U=T.getBoundingClientRect(),z=q.clientX-U.left,B=q.clientY-U.top;let A=y.timeScale().coordinateToTime(z);const j=_.coordinateToPrice(B);if(!(A==null||j==null)&&(A=Lt(A),A!=null)){if(K.current==="handle1"){const N={time:A,price:j},F=Vt([{time:N.time,value:N.price},{time:k.point2.time,value:k.point2.price}]);F.length>0&&k.series.setData(F);const X={...k,point1:N};St(mt=>{const ot=mt.map(yt=>yt===k?X:yt);return u.current=ot,ot}),x(X),G.current=X}else if(K.current==="handle2"){const N={time:A,price:j},F=Vt([{time:k.point1.time,value:k.point1.price},{time:N.time,value:N.price}]);F.length>0&&k.series.setData(F);const X={...k,point2:N};St(mt=>{const ot=mt.map(yt=>yt===k?X:yt);return u.current=ot,ot}),x(X),G.current=X}else if(K.current==="line"){const N=D.current;if(!N)return;const F=y.timeScale().coordinateToTime(N.x),X=_.coordinateToPrice(N.y);if(F==null||X==null)return;const mt=A-F,ot=j-X,yt={time:Lt(N.point1.time+mt),price:N.point1.price+ot},fe={time:Lt(N.point2.time+mt),price:N.point2.price+ot},de=Vt([{time:yt.time,value:yt.price},{time:fe.time,value:fe.price}]);de.length>0&&k.series.setData(de);const Yt={...k,point1:yt,point2:fe};St(ye=>{const Le=ye.map(li=>li===k?Yt:li);return u.current=Le,Le}),x(Yt),G.current=Yt}}},I=()=>{K.current=null,D.current=null},at={capture:!0,passive:!1};return T.addEventListener("mousedown",pt,at),T.addEventListener("mousemove",O,at),T.addEventListener("mouseup",I,at),()=>{T.removeEventListener("mousedown",pt,at),T.removeEventListener("mousemove",O,at),T.removeEventListener("mouseup",I,at)}},[lt,Tt,St]),C.useEffect(()=>{const y=h.current,_=a.current;if(!y||!_)return;const T=()=>{const L=g;if(!L||L.type!=="trendline"||!L.point1||!L.point2){P([]);return}const H=y.timeScale(),J=H.timeToCoordinate(L.point1.time),pt=_.priceToCoordinate(L.point1.price),O=H.timeToCoordinate(L.point2.time),I=_.priceToCoordinate(L.point2.price);J!=null&&pt!=null&&O!=null&&I!=null?P([{x:J,y:pt},{x:O,y:I}]):P([])};T();const R=y.timeScale();return R.subscribeVisibleTimeRangeChange(T),()=>{R.unsubscribeVisibleTimeRangeChange(T)}},[g]),C.useEffect(()=>{!h.current||!a.current||u.current.forEach(y=>{y.series&&y.series.applyOptions({visible:Mt}),y.priceLine&&y.priceLine.applyOptions(Mt?{color:"#3b82f6",axisLabelVisible:!0,title:typeof y.price=="number"?y.price.toFixed(5):""}:{color:"rgba(0,0,0,0)",axisLabelVisible:!1,title:""}),y.type==="fibonacci"&&y.priceLines&&y.priceLines.forEach(_=>{try{_.applyOptions({lineVisible:Mt,axisLabelVisible:Mt})}catch{}}),y.type==="rectangle"&&y.series&&y.series.applyOptions({visible:Mt}),y.type==="parallellines"&&(y.baseLine&&y.baseLine.applyOptions({visible:Mt}),y.parallelLine&&y.parallelLine.applyOptions({visible:Mt}),y.firstLine&&y.firstLine.applyOptions({visible:Mt}),y.secondLine&&y.secondLine.applyOptions({visible:Mt}))})},[Mt,Tt]),C.useEffect(()=>{!Mt&&g&&(x(null),P([]))},[Mt,g]),C.useEffect(()=>{if(u.current.length>Tt.length){const y=u.current.filter((_,T)=>!Tt.includes(_));g&&y.some(_=>_===g)&&(x(null),P([])),y.forEach(_=>{if(_.series&&h.current?.removeSeries(_.series),_.priceLine&&a.current?.removePriceLine(_.priceLine),_.type==="fibonacci"&&_.priceLines&&_.priceLines.forEach(T=>{try{a.current?.removePriceLine(T)}catch{}}),_.type==="rectangle"&&_.series)try{h.current?.removeSeries(_.series)}catch{}if(_.type==="parallellines")try{_.baseLine&&h.current?.removeSeries(_.baseLine),_.parallelLine&&h.current?.removeSeries(_.parallelLine),_.firstLine&&h.current?.removeSeries(_.firstLine),_.secondLine&&h.current?.removeSeries(_.secondLine)}catch{}}),u.current=Tt}},[Tt,g]),C.useEffect(()=>{const y=a.current;return y?(tt.current.forEach(T=>{try{y.removePriceLine(T)}catch{}}),tt.current=[],xt.filter(T=>T.symbol===st).forEach(T=>{const R=parseFloat(T.price);if(isNaN(R))return;const H=T.type==="BUY"?"#26A69A":"#EF5350",J=y.createPriceLine({price:R,color:H,lineWidth:2,lineStyle:0,axisLabelVisible:!0,title:`${T.type} ${T.volume} @ ${T.price}`,textColor:H});tt.current.push(J)}),()=>{tt.current.forEach(T=>{try{y.removePriceLine(T)}catch{}}),tt.current=[]}):void 0},[xt,st]),w.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden",width:"100%",height:"100%"},children:w.jsx("div",{ref:l,style:{flex:1,width:"100%",height:"100%",position:"relative",cursor:lt===1||lt!==null?"crosshair":"default",minHeight:0,minWidth:0},onDoubleClick:y=>{h.current&&!d.current&&(y.preventDefault(),y.stopPropagation(),h.current.timeScale().fitContent(),vt(h.current.timeScale().getVisibleRange()))},children:Mt&&g?.type==="trendline"&&g?.point1&&g?.point2&&M.length===2&&w.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,pointerEvents:"none"},"aria-hidden":!0,children:M.map((y,_)=>w.jsx("div",{style:{position:"absolute",width:10,height:10,borderRadius:"50%",border:"2px solid white",backgroundColor:"#22c55e",boxShadow:"0 1px 3px rgba(0,0,0,0.3)",left:y.x-5,top:y.y-5}},_))})})})}),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 qo({style:s,className:t}){const{selectedSymbol:e,setSelectedSymbol:i,symbols:n,symbolsLoading:r}=le(),[o,l]=C.useState(!1),[h,a]=C.useState(""),[c,u]=C.useState(-1),d=C.useRef(null),b=C.useRef(null);C.useEffect(()=>{const g=x=>{d.current&&!d.current.contains(x.target)&&(l(!1),a(""))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),C.useEffect(()=>{o&&b.current&&b.current.focus()},[o]);const p=n.filter(g=>g.symbol.toLowerCase().includes(h.toLowerCase())),f=p.filter(g=>!g.symbol.endsWith("USDT")),m=p.filter(g=>g.symbol.endsWith("USDT")),S=g=>{i(g),l(!1),a("")};return n.find(g=>g.symbol===e),w.jsxs("div",{ref:d,style:{...gt.container,...s},className:t,children:[w.jsxs("button",{style:gt.button,onClick:()=>l(!o),onMouseEnter:g=>Object.assign(g.currentTarget.style,gt.buttonHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:[w.jsx("span",{children:r?"Loading...":e||"Select Coin"}),w.jsx("span",{style:{...gt.arrow,...o?gt.arrowOpen:{}},children:"▼"})]}),o&&w.jsxs("div",{style:gt.dropdown,children:[w.jsx("div",{style:gt.searchContainer,children:w.jsx("input",{ref:b,style:gt.searchInput,type:"text",placeholder:"Search symbol...",value:h,onChange:g=>a(g.target.value)})}),w.jsx("div",{style:gt.list,children:p.length===0?w.jsx("div",{style:gt.empty,children:"No symbols found"}):w.jsxs(w.Fragment,{children:[f.length>0&&w.jsxs(w.Fragment,{children:[w.jsx("div",{style:gt.categoryLabel,children:"Forex & Metals"}),f.map(g=>w.jsxs("div",{style:{...gt.item,...g.symbol===e?gt.itemSelected:{}},onClick:()=>S(g.symbol),onMouseEnter:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="#334155")},onMouseLeave:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="transparent")},children:[w.jsx("span",{style:gt.symbolName,children:g.symbol}),g.bid&&w.jsx("span",{style:{...gt.symbolPrice,...parseFloat(g.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(g.bid).toFixed(5)})]},g.symbol))]}),m.length>0&&w.jsxs(w.Fragment,{children:[w.jsx("div",{style:gt.categoryLabel,children:"Crypto"}),m.map(g=>w.jsxs("div",{style:{...gt.item,...g.symbol===e?gt.itemSelected:{}},onClick:()=>S(g.symbol),onMouseEnter:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="#334155")},onMouseLeave:x=>{g.symbol!==e&&(x.currentTarget.style.backgroundColor="transparent")},children:[w.jsx("span",{style:gt.symbolName,children:g.symbol}),g.bid&&w.jsx("span",{style:{...gt.symbolPrice,...parseFloat(g.change)>=0?gt.priceUp:gt.priceDown},children:parseFloat(g.bid).toFixed(2)})]},g.symbol))]})]})})]})]})}const ce={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"}},cf=[.01,.05,.1,.5,1];function jo({value:s,onChange:t,min:e=.01,max:i=100,step:n=.01,presets:r=cf,showPresets:o=!0,showLabel:l=!0,label:h="Vol",style:a,className:c}){const[u,d]=C.useState(.1),b=s!==void 0?s:u,p=C.useCallback(g=>{const x=Math.max(e,Math.min(i,parseFloat(g)||e)),M=Math.round(x/n)*n,P=parseFloat(M.toFixed(8));s!==void 0||d(P),t?.(P)},[e,i,n,s,t]),f=()=>p(b+n),m=()=>p(b-n),S=(b>=1,b.toFixed(2));return w.jsxs("div",{style:{...ce.container,...a},className:c,children:[l&&w.jsx("span",{style:ce.label,children:h}),w.jsx("button",{style:ce.btn,onClick:m,onMouseEnter:g=>Object.assign(g.currentTarget.style,ce.btnHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:"−"}),w.jsx("input",{style:ce.input,type:"text",value:S,onChange:g=>{const x=g.target.value;if(x===""||x==="."||x==="0.")return;const M=parseFloat(x);isNaN(M)||p(M)},onBlur:()=>p(b)}),w.jsx("button",{style:ce.btn,onClick:f,onMouseEnter:g=>Object.assign(g.currentTarget.style,ce.btnHover),onMouseLeave:g=>{g.currentTarget.style.borderColor="#334155",g.currentTarget.style.backgroundColor="#1e293b"},children:"+"}),o&&r&&r.length>0&&w.jsx("div",{style:ce.presets,children:r.map(g=>w.jsx("button",{style:{...ce.preset,...Math.abs(b-g)<1e-4?ce.presetActive:{}},onClick:()=>p(g),onMouseEnter:x=>{Math.abs(b-g)>=1e-4&&Object.assign(x.currentTarget.style,{borderColor:"#3b82f6"})},onMouseLeave:x=>{Math.abs(b-g)>=1e-4&&(x.currentTarget.style.borderColor="#334155")},children:g},g))})]})}const Ht={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 Ko({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:d}=le(),[b,p]=C.useState(""),[f,m]=C.useState(!1),[S,g]=C.useState("price"),x=s!==void 0?s:b,M=e!==void 0?e:f,P=n!==void 0?n:S,K=C.useCallback($=>{e!==void 0||m($),i?.($)},[e,i]),D=C.useCallback($=>{n!==void 0||g($),r?.($)},[n,r]),G=C.useCallback($=>{s!==void 0||p($),t?.($)},[s,t]),Z=$=>{const ct=$.target.value;if(ct===""||ct==="."||ct==="0."){G(ct);return}const Nt=parseFloat(ct);isNaN(Nt)||G(ct)},Et=P==="price"?d?.bid?parseFloat(d.bid).toFixed(5):"0.00000":"50";return w.jsxs("div",{style:{...Ht.container,...c},className:u,children:[h&&w.jsx("span",{style:Ht.label,children:a}),o&&w.jsx("button",{style:{...Ht.toggle,...M?Ht.toggleOn:Ht.toggleOff},onClick:()=>K(!M),children:w.jsx("div",{style:{...Ht.toggleKnob,...M?Ht.knobOn:Ht.knobOff}})}),(M||!o)&&w.jsxs("div",{style:Ht.inputGroup,children:[w.jsx("input",{style:Ht.input,type:"text",value:x,onChange:Z,placeholder:Et,onFocus:$=>$.currentTarget.style.borderColor="#EF5350",onBlur:$=>$.currentTarget.style.borderColor="#334155"}),l&&w.jsxs(w.Fragment,{children:[w.jsx("button",{style:{...Ht.modeBtn,...P==="price"?Ht.modeBtnActive:{}},onClick:()=>D("price"),children:"Price"}),w.jsx("button",{style:{...Ht.modeBtn,...P==="pips"?Ht.modeBtnActive:{}},onClick:()=>D("pips"),children:"Pips"})]})]})]})}const qt={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 Xo({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:d}=le(),[b,p]=C.useState(""),[f,m]=C.useState(!1),[S,g]=C.useState("price"),x=s!==void 0?s:b,M=e!==void 0?e:f,P=n!==void 0?n:S,K=C.useCallback($=>{e!==void 0||m($),i?.($)},[e,i]),D=C.useCallback($=>{n!==void 0||g($),r?.($)},[n,r]),G=C.useCallback($=>{s!==void 0||p($),t?.($)},[s,t]),Z=$=>{const ct=$.target.value;if(ct===""||ct==="."||ct==="0."){G(ct);return}const Nt=parseFloat(ct);isNaN(Nt)||G(ct)},Et=P==="price"?d?.ask?parseFloat(d.ask).toFixed(5):"0.00000":"50";return w.jsxs("div",{style:{...qt.container,...c},className:u,children:[h&&w.jsx("span",{style:qt.label,children:a}),o&&w.jsx("button",{style:{...qt.toggle,...M?qt.toggleOn:qt.toggleOff},onClick:()=>K(!M),children:w.jsx("div",{style:{...qt.toggleKnob,...M?qt.knobOn:qt.knobOff}})}),(M||!o)&&w.jsxs("div",{style:qt.inputGroup,children:[w.jsx("input",{style:qt.input,type:"text",value:x,onChange:Z,placeholder:Et,onFocus:$=>$.currentTarget.style.borderColor="#26A69A",onBlur:$=>$.currentTarget.style.borderColor="#334155"}),l&&w.jsxs(w.Fragment,{children:[w.jsx("button",{style:{...qt.modeBtn,...P==="price"?qt.modeBtnActive:{}},onClick:()=>D("price"),children:"Price"}),w.jsx("button",{style:{...qt.modeBtn,...P==="pips"?qt.modeBtnActive:{}},onClick:()=>D("pips"),children:"Pips"})]})]})]})}const uf=[{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:"─"}],ue={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 Jo({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:d}=le(),[b,p]=C.useState(null),f=i||uf,m=x=>{h(l===x?null:x)},S=()=>{d([]),h(null)},g=()=>{c(!a)};return w.jsxs("div",{style:{...ue.container,...r},className:o,children:[s&&w.jsx("span",{style:ue.label,children:n}),f.map(x=>w.jsxs("button",{style:{...ue.btn,...l===x.id?ue.btnActive:{}},onClick:()=>m(x.id),onMouseEnter:M=>{p(x.id),l!==x.id&&Object.assign(M.currentTarget.style,ue.btnHover)},onMouseLeave:M=>{p(null),l!==x.id&&(M.currentTarget.style.borderColor="#334155",M.currentTarget.style.backgroundColor="#1e293b",M.currentTarget.style.color="#94a3b8")},title:x.name,children:[x.icon,b===x.id&&w.jsx("div",{style:ue.tooltip,children:x.name})]},x.id)),(t||e)&&w.jsx("div",{style:ue.divider}),e&&w.jsx("button",{style:{...ue.visibilityBtn,...a?{}:{color:"#64748b",backgroundColor:"#0f172a"}},onClick:g,onMouseEnter:x=>{x.currentTarget.style.borderColor="#3b82f6"},onMouseLeave:x=>{x.currentTarget.style.borderColor="#334155"},title:a?"Hide Drawings":"Show Drawings",children:a?"👁":"○"}),t&&w.jsx("button",{style:ue.deleteBtn,onClick:S,onMouseEnter:x=>Object.assign(x.currentTarget.style,ue.deleteBtnHover),onMouseLeave:x=>{x.currentTarget.style.borderColor="#334155",x.currentTarget.style.backgroundColor="#1e293b",x.currentTarget.style.color="#94a3b8"},title:"Delete All Drawings",children:"🗑"})]})}const Go={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 ff({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:d,onTakeProfitChange:b,takeProfitEnabled:p,onTakeProfitEnabledChange:f,coinSelectorProps:m={},volumeControlProps:S={},stopLossProps:g={},takeProfitProps:x={},drawingToolsProps:M={},style:P,className:K}){const D=[];s&&D.push(w.jsx(qo,{...m},"coin")),t&&D.push(w.jsx(jo,{value:o,onChange:l,...S},"volume")),e&&D.push(w.jsx(Ko,{value:h,onChange:a,enabled:c,onEnabledChange:u,...g},"sl")),i&&D.push(w.jsx(Xo,{value:d,onChange:b,enabled:p,onEnabledChange:f,...x},"tp")),n&&D.push(w.jsx(Jo,{...M},"draw"));const G=[];return D.forEach((Z,Et)=>{G.push(Z),r&&Et<D.length-1&&G.push(w.jsx("div",{style:Go.divider},`div-${Et}`))}),w.jsx("div",{style:{...Go.toolbar,...P},className:K,children:G})}const df=[{label:"M1",value:"M1"},{label:"M5",value:"M5"},{label:"M15",value:"M15"},{label:"M30",value:"M30"},{label:"H1",value:"H1"},{label:"H4",value:"H4"},{label:"D1",value:"D1"},{label:"W1",value:"W1"}],ln={container:{display:"inline-flex",alignItems:"center",gap:"2px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},btn:{padding:"4px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"},btnActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"}};function pf({style:s,className:t}){const{selectedTimeframe:e,setSelectedTimeframe:i}=le();return w.jsx("div",{style:{...ln.container,...s},className:t,children:df.map(n=>w.jsx("button",{style:{...ln.btn,...e===n.value?ln.btnActive:{}},onClick:()=>i(n.value),onMouseEnter:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#3b82f6")},onMouseLeave:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#334155")},children:n.label},n.value))})}const mf=[{label:"Candles",value:"candles",icon:"📊"},{label:"Line",value:"line",icon:"📈"},{label:"Area",value:"area",icon:"▤"},{label:"Bars",value:"bars",icon:"▥"}],hn={container:{display:"inline-flex",alignItems:"center",gap:"2px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},btn:{padding:"4px 8px",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"4px",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:"3px"},btnActive:{backgroundColor:"#1e3a5f",borderColor:"#3b82f6",color:"#60a5fa"}};function bf({style:s,className:t}){const{chartType:e,setChartType:i}=le();return w.jsx("div",{style:{...hn.container,...s},className:t,children:mf.map(n=>w.jsxs("button",{style:{...hn.btn,...e===n.value?hn.btnActive:{}},onClick:()=>i(n.value),onMouseEnter:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#3b82f6")},onMouseLeave:r=>{e!==n.value&&(r.currentTarget.style.borderColor="#334155")},title:n.label,children:[w.jsx("span",{children:n.icon}),w.jsx("span",{children:n.label})]},n.value))})}const $t={container:{display:"inline-flex",alignItems:"center",gap:"6px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},priceBox:{display:"flex",flexDirection:"column",alignItems:"center",padding:"4px 10px",backgroundColor:"#0f172a",borderRadius:"4px",minWidth:"80px"},priceLabel:{fontSize:"9px",color:"#64748b",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},priceValue:{fontSize:"13px",fontWeight:700,fontFamily:"monospace"},spread:{fontSize:"9px",color:"#64748b",padding:"0 4px",display:"flex",flexDirection:"column",alignItems:"center",gap:"1px"},spreadLabel:{fontSize:"8px",textTransform:"uppercase",letterSpacing:"0.05em"},spreadValue:{fontSize:"10px",fontWeight:700,color:"#94a3b8"},sellBtn:{padding:"6px 16px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"4px",color:"#fca5a5",fontSize:"12px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease",textTransform:"uppercase",letterSpacing:"0.03em",minWidth:"70px"},sellBtnHover:{backgroundColor:"#991b1b",borderColor:"#EF5350"},buyBtn:{padding:"6px 16px",backgroundColor:"#14532d",border:"1px solid #166534",borderRadius:"4px",color:"#86efac",fontSize:"12px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease",textTransform:"uppercase",letterSpacing:"0.03em",minWidth:"70px"},buyBtnHover:{backgroundColor:"#166534",borderColor:"#26A69A"},status:{fontSize:"10px",padding:"2px 8px",borderRadius:"3px",fontWeight:600,whiteSpace:"nowrap"}};function gf({volume:s=.1,stopLoss:t,takeProfit:e,onTradeExecuted:i,style:n,className:r}){const{selectedSymbol:o,currentSymbolData:l,setOrders:h,setUserBalance:a}=le(),[c,u]=C.useState(null),d=parseFloat(l?.bid||0),b=parseFloat(l?.ask||0),p=b>0&&d>0?Math.abs(b-d):0,f=g=>!g||g===0?"-.-----":g>=1e3?g.toFixed(2):g>=1?g.toFixed(4):g.toFixed(5),m=g=>g===0?"-":g>=1?g.toFixed(1):g>=.01?g.toFixed(3):(g*1e4).toFixed(1)+"p",S=C.useCallback(g=>{if(!o)return;const x=g==="BUY"?b:d;if(!x||x<=0){u({type:"error",message:"No price available"});return}const M={id:Date.now().toString(),ticket:Math.floor(Math.random()*9e5)+1e5,symbol:o,type:g,volume:s,price:x,stopLoss:t?parseFloat(t):null,takeProfit:e?parseFloat(e):null,status:"OPEN",profit:0,swap:0,openAt:new Date().toISOString(),time:new Date().toLocaleTimeString()};h(K=>[...K,M]);const P=s*x*.01;a(K=>K-P),u({type:"success",message:`${g} executed`}),i?.(M),setTimeout(()=>u(null),3e3)},[o,b,d,s,t,e,h,a,i]);return w.jsxs("div",{style:{...$t.container,...n},className:r,children:[w.jsx("button",{style:$t.sellBtn,onClick:()=>S("SELL"),onMouseEnter:g=>{Object.assign(g.currentTarget.style,$t.sellBtnHover)},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#7f1d1d",g.currentTarget.style.borderColor="#991b1b"},children:"Sell"}),w.jsxs("div",{style:$t.priceBox,children:[w.jsx("span",{style:$t.priceLabel,children:"Bid"}),w.jsx("span",{style:{...$t.priceValue,color:"#EF5350"},children:f(d)})]}),w.jsxs("div",{style:$t.spread,children:[w.jsx("span",{style:$t.spreadLabel,children:"Spread"}),w.jsx("span",{style:$t.spreadValue,children:m(p)})]}),w.jsxs("div",{style:$t.priceBox,children:[w.jsx("span",{style:$t.priceLabel,children:"Ask"}),w.jsx("span",{style:{...$t.priceValue,color:"#26A69A"},children:f(b)})]}),w.jsx("button",{style:$t.buyBtn,onClick:()=>S("BUY"),onMouseEnter:g=>{Object.assign(g.currentTarget.style,$t.buyBtnHover)},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#14532d",g.currentTarget.style.borderColor="#166534"},children:"Buy"}),c&&w.jsx("span",{style:{...$t.status,backgroundColor:c.type==="success"?"#14532d":"#7f1d1d",color:c.type==="success"?"#86efac":"#fca5a5",border:`1px solid ${c.type==="success"?"#166534":"#991b1b"}`},children:c.message})]})}const Q={container:{fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",backgroundColor:"#0f172a",borderTop:"1px solid #1e293b",fontSize:"11px",overflow:"hidden",display:"flex",flexDirection:"column"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",backgroundColor:"#0f172a",borderBottom:"1px solid #1e293b"},headerTitle:{color:"#94a3b8",fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em"},summary:{display:"flex",gap:"16px",fontSize:"11px"},summaryItem:{display:"flex",gap:"4px",alignItems:"center"},summaryLabel:{color:"#64748b",fontWeight:600},summaryValue:{fontWeight:700,fontFamily:"monospace"},table:{width:"100%",borderCollapse:"collapse"},th:{padding:"4px 8px",textAlign:"left",color:"#64748b",fontWeight:700,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em",borderBottom:"1px solid #1e293b",whiteSpace:"nowrap"},td:{padding:"4px 8px",color:"#cbd5e1",borderBottom:"1px solid #1e293b",whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"11px"},closeBtn:{padding:"2px 8px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"3px",color:"#fca5a5",fontSize:"10px",fontWeight:700,cursor:"pointer",transition:"all 0.15s ease"},emptyRow:{padding:"16px",textAlign:"center",color:"#475569",fontSize:"12px"},scrollArea:{overflowY:"auto",maxHeight:"200px"},typeBuy:{color:"#26A69A",fontWeight:700},typeSell:{color:"#EF5350",fontWeight:700}};function vf({style:s,className:t,maxHeight:e=200}){const{orders:i,setOrders:n,symbols:r,accountSummary:o,setUserBalance:l}=le(),[h,a]=C.useState(null),c=i.filter(f=>f.status==="OPEN"||!f.closeAt),u=C.useCallback((f,m)=>{const S=r.find(g=>g.symbol===f);return S?parseFloat(m==="BUY"?S.bid||0:S.ask||0):0},[r]),d=C.useCallback(f=>{if(h)return;a(f.id);const m=u(f.symbol,f.type),g=(f.type==="BUY"?m-f.price:f.price-m)*f.volume,x=f.volume*f.price*.01;n(M=>M.filter(P=>P.id!==f.id)),l(M=>M+x+g),a(null)},[h,u,n,l]),b=f=>{const m=parseFloat(f);return!m||isNaN(m)?"-":m>=1e3?m.toFixed(2):m>=1?m.toFixed(4):m.toFixed(5)},p=f=>{const m=parseFloat(f);return isNaN(m)?"-":(m>=0?"+":"")+m.toFixed(2)};return w.jsxs("div",{style:{...Q.container,...s},className:t,children:[w.jsxs("div",{style:Q.header,children:[w.jsxs("span",{style:Q.headerTitle,children:["Positions (",c.length,")"]}),w.jsxs("div",{style:Q.summary,children:[w.jsxs("div",{style:Q.summaryItem,children:[w.jsx("span",{style:Q.summaryLabel,children:"Balance:"}),w.jsxs("span",{style:{...Q.summaryValue,color:"#e2e8f0"},children:["$",o?.balance?.toFixed(2)||"0.00"]})]}),w.jsxs("div",{style:Q.summaryItem,children:[w.jsx("span",{style:Q.summaryLabel,children:"Equity:"}),w.jsxs("span",{style:{...Q.summaryValue,color:(o?.equity||0)>=(o?.balance||0)?"#26A69A":"#EF5350"},children:["$",o?.equity?.toFixed(2)||"0.00"]})]}),w.jsxs("div",{style:Q.summaryItem,children:[w.jsx("span",{style:Q.summaryLabel,children:"Free:"}),w.jsxs("span",{style:{...Q.summaryValue,color:"#94a3b8"},children:["$",o?.freeMargin?.toFixed(2)||"0.00"]})]})]})]}),w.jsx("div",{style:{...Q.scrollArea,maxHeight:e},children:w.jsxs("table",{style:Q.table,children:[w.jsx("thead",{children:w.jsxs("tr",{children:[w.jsx("th",{style:Q.th,children:"Symbol"}),w.jsx("th",{style:Q.th,children:"Type"}),w.jsx("th",{style:Q.th,children:"Volume"}),w.jsx("th",{style:Q.th,children:"Open Price"}),w.jsx("th",{style:Q.th,children:"Current"}),w.jsx("th",{style:Q.th,children:"SL"}),w.jsx("th",{style:Q.th,children:"TP"}),w.jsx("th",{style:Q.th,children:"Profit"}),w.jsx("th",{style:Q.th,children:"Action"})]})}),w.jsx("tbody",{children:c.length===0?w.jsx("tr",{children:w.jsx("td",{colSpan:9,style:Q.emptyRow,children:"No open positions"})}):c.map(f=>{const m=u(f.symbol,f.type),S=f.profit||0;return w.jsxs("tr",{children:[w.jsx("td",{style:{...Q.td,fontWeight:700,color:"#e2e8f0"},children:f.symbol}),w.jsx("td",{style:{...Q.td,...f.type==="BUY"?Q.typeBuy:Q.typeSell},children:f.type}),w.jsx("td",{style:Q.td,children:f.volume}),w.jsx("td",{style:Q.td,children:b(f.price)}),w.jsx("td",{style:Q.td,children:b(m)}),w.jsx("td",{style:Q.td,children:f.stopLoss?b(f.stopLoss):"-"}),w.jsx("td",{style:Q.td,children:f.takeProfit?b(f.takeProfit):"-"}),w.jsx("td",{style:{...Q.td,color:S>=0?"#26A69A":"#EF5350",fontWeight:700},children:p(S)}),w.jsx("td",{style:Q.td,children:w.jsx("button",{style:{...Q.closeBtn,...h===f.id?{opacity:.5,cursor:"not-allowed"}:{}},onClick:()=>d(f),disabled:h===f.id,onMouseEnter:g=>{h!==f.id&&(g.currentTarget.style.backgroundColor="#991b1b")},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="#7f1d1d"},children:h===f.id?"...":"Close"})})]},f.id)})})]})})]})}const yf="1.2.1";Y.Chart=af,Y.ChartTypeSelector=bf,Y.CoinSelector=qo,Y.DrawingTools=Jo,Y.PositionsPanel=vf,Y.SYMBOL_CONFIG=Ao,Y.StopLoss=Ko,Y.TakeProfit=Xo,Y.TimeframeSelector=pf,Y.TradePanel=gf,Y.TradingProvider=Gu,Y.TradingToolbar=ff,Y.VolumeControl=jo,Y.alignToTimeframe=Fe,Y.detectGaps=Yu,Y.getSymbolConfig=oi,Y.is24x7Symbol=sf,Y.isCryptoSymbol=ef,Y.isForexSymbol=tf,Y.isWithinTradingSession=Qu,Y.normalizeCandleTimes=Ro,Y.normalizeTime=Lt,Y.processCandles=$o,Y.processSingleCandle=Io,Y.setChartBaseUrl=Wo,Y.setSocketBaseUrl=Po,Y.timeframeToSeconds=rn,Y.useTrading=le,Y.validateTimeOrdering=Zu,Y.version=yf,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));