@nabeeltahirdeveloper/chart-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart-sdk.es.js +12103 -0
- package/dist/chart-sdk.umd.js +6 -0
- package/package.json +40 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(rt,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],ne):(rt=typeof globalThis<"u"?globalThis:rt||self,ne(rt.ChartSDK={},rt.jsxRuntime,rt.React))})(this,(function(rt,ne,E){"use strict";var Bi=typeof document<"u"?document.currentScript:null;function at(s){var t=s.width,e=s.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(e<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:e}}function fe(s,t){return s.width===t.width&&s.height===t.height}var Bo=(function(){function s(t){var e=this;this._resolutionListener=function(){return e._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return s.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(s.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),s.prototype.subscribe=function(t){var e=this,i={next:t};return this._observers.push(i),{unsubscribe:function(){e._observers=e._observers.filter(function(n){return n!==i})}}},s.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},s.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},s.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},s.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(e){return e.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},s})();function Fo(s){return new Bo(s)}var zo=(function(){function s(t,e,i){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=at({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=e??(function(r){return r}),this._allowResizeObserver=(n=i?.allowResizeObserver)!==null&&n!==void 0?n:!0,this._chooseAndInitObserver()}return s.prototype.dispose=function(){var t,e;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(e=this._devicePixelRatioObservable)===null||e===void 0||e.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(s.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"bitmapSize",{get:function(){return at({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),s.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=at(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},s.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(e){return e!==t})},Object.defineProperty(s.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),s.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},s.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(e){return e!==t})},s.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},s.prototype._resizeBitmap=function(t){var e=this.bitmapSize;fe(e,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(e,t))},s.prototype._emitBitmapSizeChanged=function(t,e){var i=this;this._bitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._suggestNewBitmapSize=function(t){var e=this._suggestedBitmapSize,i=at(this._transformBitmapSize(t,this._canvasElementClientSize)),n=fe(this.bitmapSize,i)?null:i;e===null&&n===null||e!==null&&n!==null&&fe(e,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(e,n))},s.prototype._emitSuggestedBitmapSizeChanged=function(t,e){var i=this;this._suggestedBitmapSizeChangedListeners.forEach(function(n){return n.call(i,t,e)})},s.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}Vo().then(function(e){return e?t._initResizeObserver():t._initDevicePixelRatioObservable()})},s.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var e=Qs(this._canvasElement);if(e===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=Fo(e),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},s.prototype._invalidateBitmapSize=function(){var t,e;if(this._canvasElement!==null){var i=Qs(this._canvasElement);if(i!==null){var n=(e=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&e!==void 0?e:i.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?Wo(r[0],n):at({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(o)}}},s.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(e){var i=e.find(function(o){return o.target===t._canvasElement});if(!(!i||!i.devicePixelContentBoxSize||!i.devicePixelContentBoxSize[0])){var n=i.devicePixelContentBoxSize[0],r=at({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},s})();function Uo(s,t){return new zo(s,t.transform,t.options)}function Qs(s){return s.ownerDocument.defaultView}function Vo(){return new Promise(function(s){var t=new ResizeObserver(function(e){s(e.every(function(i){return"devicePixelContentBoxSize"in i})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function Wo(s,t){return at({width:Math.round(s.left*t+s.width*t)-Math.round(s.left*t),height:Math.round(s.top*t+s.height*t)-Math.round(s.top*t)})}var Io=(function(){function s(t,e,i){if(e.width===0||e.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=e,i.width===0||i.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=i,this._context=t}return s.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},s.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(s.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),s})();function de(s,t){var e=s.canvasElementClientSize;if(e.width===0||e.height===0)return null;var i=s.bitmapSize;if(i.width===0||i.height===0)return null;var n=s.canvasElement.getContext("2d",t);return n===null?null:new Io(n,e,i)}const qo={upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},Ho={upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},$o={color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jo={topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},Jo={baseValue:{type:"price",price:0},topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},Ko={color:"#26a69a",base:0},tn={color:"#2196f3"},en={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var sn,nn;function pe(s,t){const e={0:[],1:[s.lineWidth,s.lineWidth],2:[2*s.lineWidth,2*s.lineWidth],3:[6*s.lineWidth,6*s.lineWidth],4:[s.lineWidth,4*s.lineWidth]}[t];s.setLineDash(e)}function rn(s,t,e,i){s.beginPath();const n=s.lineWidth%2?.5:0;s.moveTo(e,t+n),s.lineTo(i,t+n),s.stroke()}function le(s,t){if(!s)throw new Error("Assertion failed"+(t?": "+t:""))}function kt(s){if(s===void 0)throw new Error("Value is undefined");return s}function S(s){if(s===null)throw new Error("Value is null");return s}function Se(s){return S(kt(s))}(function(s){s[s.Simple=0]="Simple",s[s.WithSteps=1]="WithSteps",s[s.Curved=2]="Curved"})(sn||(sn={})),(function(s){s[s.Solid=0]="Solid",s[s.Dotted=1]="Dotted",s[s.Dashed=2]="Dashed",s[s.LargeDashed=3]="LargeDashed",s[s.SparseDotted=4]="SparseDotted"})(nn||(nn={}));const on={khaki:"#f0e68c",azure:"#f0ffff",aliceblue:"#f0f8ff",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",gray:"#808080",green:"#008000",honeydew:"#f0fff0",floralwhite:"#fffaf0",lightblue:"#add8e6",lightcoral:"#f08080",lemonchiffon:"#fffacd",hotpink:"#ff69b4",lightyellow:"#ffffe0",greenyellow:"#adff2f",lightgoldenrodyellow:"#fafad2",limegreen:"#32cd32",linen:"#faf0e6",lightcyan:"#e0ffff",magenta:"#f0f",maroon:"#800000",olive:"#808000",orange:"#ffa500",oldlace:"#fdf5e6",mediumblue:"#0000cd",transparent:"#0000",lime:"#0f0",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",midnightblue:"#191970",orchid:"#da70d6",mediumorchid:"#ba55d3",mediumturquoise:"#48d1cc",orangered:"#ff4500",royalblue:"#4169e1",powderblue:"#b0e0e6",red:"#f00",coral:"#ff7f50",turquoise:"#40e0d0",white:"#fff",whitesmoke:"#f5f5f5",wheat:"#f5deb3",teal:"#008080",steelblue:"#4682b4",bisque:"#ffe4c4",aquamarine:"#7fffd4",aqua:"#0ff",sienna:"#a0522d",silver:"#c0c0c0",springgreen:"#00ff7f",antiquewhite:"#faebd7",burlywood:"#deb887",brown:"#a52a2a",beige:"#f5f5dc",chocolate:"#d2691e",chartreuse:"#7fff00",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cadetblue:"#5f9ea0",tomato:"#ff6347",fuchsia:"#f0f",blue:"#00f",salmon:"#fa8072",blanchedalmond:"#ffebcd",slateblue:"#6a5acd",slategray:"#708090",thistle:"#d8bfd8",tan:"#d2b48c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",blueviolet:"#8a2be2",black:"#000",darkmagenta:"#8b008b",darkslateblue:"#483d8b",darkkhaki:"#bdb76b",darkorchid:"#9932cc",darkorange:"#ff8c00",darkgreen:"#006400",darkred:"#8b0000",dodgerblue:"#1e90ff",darkslategray:"#2f4f4f",dimgray:"#696969",deepskyblue:"#00bfff",firebrick:"#b22222",forestgreen:"#228b22",indigo:"#4b0082",ivory:"#fffff0",lavenderblush:"#fff0f5",feldspar:"#d19275",indianred:"#cd5c5c",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightskyblue:"#87cefa",lightslategray:"#789",lightslateblue:"#8470ff",snow:"#fffafa",lightseagreen:"#20b2aa",lightsalmon:"#ffa07a",darksalmon:"#e9967a",darkviolet:"#9400d3",mediumpurple:"#9370d8",mediumaquamarine:"#66cdaa",skyblue:"#87ceeb",lavender:"#e6e6fa",lightsteelblue:"#b0c4de",mediumvioletred:"#c71585",mintcream:"#f5fffa",navajowhite:"#ffdead",navy:"#000080",olivedrab:"#6b8e23",palevioletred:"#d87093",violetred:"#d02090",yellow:"#ff0",yellowgreen:"#9acd32",lawngreen:"#7cfc00",pink:"#ffc0cb",paleturquoise:"#afeeee",palegoldenrod:"#eee8aa",darkolivegreen:"#556b2f",darkseagreen:"#8fbc8f",darkturquoise:"#00ced1",peachpuff:"#ffdab9",deeppink:"#ff1493",violet:"#ee82ee",palegreen:"#98fb98",mediumseagreen:"#3cb371",peru:"#cd853f",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",purple:"#800080",seagreen:"#2e8b57",seashell:"#fff5ee",papayawhip:"#ffefd5",mediumslateblue:"#7b68ee",plum:"#dda0dd",mediumspringgreen:"#00fa9a"};function zt(s){return s<0?0:s>255?255:Math.round(s)||0}function hn(s){return s<=0||s>0?s<0?0:s>1?1:Math.round(1e4*s)/1e4:0}const Xo=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,Yo=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,Go=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,Zo=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/;function Ze(s){(s=s.toLowerCase())in on&&(s=on[s]);{const t=Zo.exec(s)||Go.exec(s);if(t)return[zt(parseInt(t[1],10)),zt(parseInt(t[2],10)),zt(parseInt(t[3],10)),hn(t.length<5?1:parseFloat(t[4]))]}{const t=Yo.exec(s);if(t)return[zt(parseInt(t[1],16)),zt(parseInt(t[2],16)),zt(parseInt(t[3],16)),1]}{const t=Xo.exec(s);if(t)return[zt(17*parseInt(t[1],16)),zt(17*parseInt(t[2],16)),zt(17*parseInt(t[3],16)),1]}throw new Error(`Cannot parse color: ${s}`)}function Qe(s){const t=Ze(s);return{t:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,i:(e=t,.199*e[0]+.687*e[1]+.114*e[2]>160?"black":"white")};var e}class yt{constructor(){this.h=[]}l(t,e,i){const n={o:t,_:e,u:i===!0};this.h.push(n)}v(t){const e=this.h.findIndex((i=>t===i.o));e>-1&&this.h.splice(e,1)}p(t){this.h=this.h.filter((e=>e._!==t))}m(t,e,i){const n=[...this.h];this.h=this.h.filter((r=>!r.u)),n.forEach((r=>r.o(t,e,i)))}M(){return this.h.length>0}S(){this.h=[]}}function Ht(s,...t){for(const e of t)for(const i in e)e[i]!==void 0&&(typeof e[i]!="object"||s[i]===void 0||Array.isArray(e[i])?s[i]=e[i]:Ht(s[i],e[i]));return s}function Kt(s){return typeof s=="number"&&isFinite(s)}function ke(s){return typeof s=="number"&&s%1==0}function Pe(s){return typeof s=="string"}function ti(s){return typeof s=="boolean"}function re(s){const t=s;if(!t||typeof t!="object")return t;let e,i,n;for(i in e=Array.isArray(t)?[]:{},t)t.hasOwnProperty(i)&&(n=t[i],e[i]=n&&typeof n=="object"?re(n):n);return e}function Qo(s){return s!==null}function Ae(s){return s===null?void 0:s}const Fi="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function _e(s,t,e){return t===void 0&&(t=Fi),`${e=e!==void 0?`${e} `:""}${s}px ${t}`}class th{constructor(t){this.k={C:1,T:5,P:NaN,R:"",D:"",O:"",A:"",V:0,B:0,I:0,L:0,N:0},this.F=t}W(){const t=this.k,e=this.j(),i=this.H();return t.P===e&&t.D===i||(t.P=e,t.D=i,t.R=_e(e,i),t.L=2.5/12*e,t.V=t.L,t.B=e/12*t.T,t.I=e/12*t.T,t.N=0),t.O=this.$(),t.A=this.U(),this.k}$(){return this.F.W().layout.textColor}U(){return this.F.q()}j(){return this.F.W().layout.fontSize}H(){return this.F.W().layout.fontFamily}}class zi{constructor(){this.Y=[]}X(t){this.Y=t}K(t,e,i){this.Y.forEach((n=>{n.K(t,e,i)}))}}class Ui{K(t,e,i){t.useMediaCoordinateSpace((n=>this.Z(n,e,i)))}G(t,e,i){t.useMediaCoordinateSpace((n=>this.J(n,e,i)))}J(t,e,i){}}class eh extends Ui{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z({context:t}){if(this.tt===null||this.tt.nt===null)return;const e=this.tt.nt,i=this.tt,n=r=>{t.beginPath();for(let o=e.to-1;o>=e.from;--o){const h=i.st[o];t.moveTo(h.et,h.rt),t.arc(h.et,h.rt,r,0,2*Math.PI)}t.fill()};i.ht>0&&(t.fillStyle=i.lt,n(i.ot+i.ht)),t.fillStyle=i._t,n(i.ot)}}function ih(){return{st:[{et:0,rt:0,ut:0,ct:0}],_t:"",lt:"",ot:0,ht:0,nt:null}}const sh={from:0,to:1};class nh{constructor(t,e){this.dt=new zi,this.ft=[],this.vt=[],this.bt=!0,this.F=t,this.wt=e,this.dt.X(this.ft)}gt(t){const e=this.F.Mt();e.length!==this.ft.length&&(this.vt=e.map(ih),this.ft=this.vt.map((i=>{const n=new eh;return n.it(i),n})),this.dt.X(this.ft)),this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.dt}St(){const t=this.wt.W().mode===2,e=this.F.Mt(),i=this.wt.kt(),n=this.F.yt();e.forEach(((r,o)=>{var h;const l=this.vt[o],a=r.Ct(i);if(t||a===null||!r.Tt())return void(l.nt=null);const c=S(r.Pt());l._t=a.Rt,l.ot=a.ot,l.ht=a.Dt,l.st[0].ct=a.ct,l.st[0].rt=r.At().Ot(a.ct,c.Vt),l.lt=(h=a.Bt)!==null&&h!==void 0?h:this.F.It(l.st[0].rt/r.At().zt()),l.st[0].ut=i,l.st[0].et=n.Et(i),l.nt=sh}))}}class oe{K(t,e,i){t.useBitmapCoordinateSpace((n=>this.Z(n,e,i)))}}class rh extends oe{constructor(t){super(),this.Lt=t}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null)return;const r=this.Lt.Nt.Tt,o=this.Lt.Ft.Tt;if(!r&&!o)return;const h=Math.round(this.Lt.et*i),l=Math.round(this.Lt.rt*n);t.lineCap="butt",r&&h>=0&&(t.lineWidth=Math.floor(this.Lt.Nt.ht*i),t.strokeStyle=this.Lt.Nt.O,t.fillStyle=this.Lt.Nt.O,pe(t,this.Lt.Nt.Wt),(function(a,c,u,p){a.beginPath();const g=a.lineWidth%2?.5:0;a.moveTo(c+g,u),a.lineTo(c+g,p),a.stroke()})(t,h,0,e.height)),o&&l>=0&&(t.lineWidth=Math.floor(this.Lt.Ft.ht*n),t.strokeStyle=this.Lt.Ft.O,t.fillStyle=this.Lt.Ft.O,pe(t,this.Lt.Ft.Wt),rn(t,l,0,e.width))}}class oh{constructor(t){this.bt=!0,this.jt={Nt:{ht:1,Wt:0,O:"",Tt:!1},Ft:{ht:1,Wt:0,O:"",Tt:!1},et:0,rt:0},this.Ht=new rh(this.jt),this.$t=t}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht}St(){const t=this.$t.Tt(),e=S(this.$t.Ut()),i=e.qt().W().crosshair,n=this.jt;if(i.mode===2)return n.Ft.Tt=!1,void(n.Nt.Tt=!1);n.Ft.Tt=t&&this.$t.Yt(e),n.Nt.Tt=t&&this.$t.Xt(),n.Ft.ht=i.horzLine.width,n.Ft.Wt=i.horzLine.style,n.Ft.O=i.horzLine.color,n.Nt.ht=i.vertLine.width,n.Nt.Wt=i.vertLine.style,n.Nt.O=i.vertLine.color,n.et=this.$t.Kt(),n.rt=this.$t.Zt()}}function hh(s,t,e,i,n,r){s.fillRect(t+r,e,i-2*r,r),s.fillRect(t+r,e+n-r,i-2*r,r),s.fillRect(t,e,r,n),s.fillRect(t+i-r,e,r,n)}function ei(s,t,e,i,n,r){s.save(),s.globalCompositeOperation="copy",s.fillStyle=r,s.fillRect(t,e,i,n),s.restore()}function ln(s,t){return s.map((e=>e===0?e:e+t))}function Vi(s,t,e,i,n,r){s.beginPath(),s.lineTo(t+i-r[1],e),r[1]!==0&&s.arcTo(t+i,e,t+i,e+r[1],r[1]),s.lineTo(t+i,e+n-r[2]),r[2]!==0&&s.arcTo(t+i,e+n,t+i-r[2],e+n,r[2]),s.lineTo(t+r[3],e+n),r[3]!==0&&s.arcTo(t,e+n,t,e+n-r[3],r[3]),s.lineTo(t,e+r[0]),r[0]!==0&&s.arcTo(t,e,t+r[0],e,r[0])}function an(s,t,e,i,n,r,o=0,h=[0,0,0,0],l=""){if(s.save(),!o||!l||l===r)return Vi(s,t,e,i,n,h),s.fillStyle=r,s.fill(),void s.restore();const a=o/2;r!=="transparent"&&(Vi(s,t+o,e+o,i-2*o,n-2*o,ln(h,-o)),s.fillStyle=r,s.fill()),l!=="transparent"&&(Vi(s,t+a,e+a,i-o,n-o,ln(h,-a)),s.lineWidth=o,s.strokeStyle=l,s.closePath(),s.stroke()),s.restore()}function cn(s,t,e,i,n,r,o){s.save(),s.globalCompositeOperation="copy";const h=s.createLinearGradient(0,0,0,n);h.addColorStop(0,r),h.addColorStop(1,o),s.fillStyle=h,s.fillRect(t,e,i,n),s.restore()}class un{constructor(t,e){this.it(t,e)}it(t,e){this.Lt=t,this.Gt=e}zt(t,e){return this.Lt.Tt?t.P+t.L+t.V:0}K(t,e,i,n){if(!this.Lt.Tt||this.Lt.Jt.length===0)return;const r=this.Lt.O,o=this.Gt.t,h=t.useBitmapCoordinateSpace((l=>{const a=l.context;a.font=e.R;const c=this.Qt(l,e,i,n),u=c.ti,p=(g,d)=>{c.ii?an(a,u.ni,u.si,u.ei,u.ri,g,u.hi,[u.ot,0,0,u.ot],d):an(a,u.li,u.si,u.ei,u.ri,g,u.hi,[0,u.ot,u.ot,0],d)};return p(o,"transparent"),this.Lt.ai&&(a.fillStyle=r,a.fillRect(u.li,u.oi,u._i-u.li,u.ui)),p("transparent",o),this.Lt.ci&&(a.fillStyle=e.A,a.fillRect(c.ii?u.di-u.hi:0,u.si,u.hi,u.fi-u.si)),c}));t.useMediaCoordinateSpace((({context:l})=>{const a=h.vi;l.font=e.R,l.textAlign=h.ii?"right":"left",l.textBaseline="middle",l.fillStyle=r,l.fillText(this.Lt.Jt,a.pi,(a.si+a.fi)/2+a.mi)}))}Qt(t,e,i,n){var r;const{context:o,bitmapSize:h,mediaSize:l,horizontalPixelRatio:a,verticalPixelRatio:c}=t,u=this.Lt.ai||!this.Lt.bi?e.T:0,p=this.Lt.wi?e.C:0,g=e.L+this.Gt.gi,d=e.V+this.Gt.Mi,f=e.B,m=e.I,w=this.Lt.Jt,M=e.P,R=i.xi(o,w),k=Math.ceil(i.Si(o,w)),$=M+g+d,Q=e.C+f+m+k+u,G=Math.max(1,Math.floor(c));let st=Math.round($*c);st%2!=G%2&&(st+=1);const tt=p>0?Math.max(1,Math.floor(p*a)):0,Nt=Math.round(Q*a),Jt=Math.round(u*a),Vt=(r=this.Gt.ki)!==null&&r!==void 0?r:this.Gt.yi,Bt=Math.round(Vt*c)-Math.floor(.5*c),dt=Math.floor(Bt+G/2-st/2),et=dt+st,ot=n==="right",ht=ot?l.width-p:p,Lt=ot?h.width-tt:tt;let wt,mt,gt;return ot?(wt=Lt-Nt,mt=Lt-Jt,gt=ht-u-f-p):(wt=Lt+Nt,mt=Lt+Jt,gt=ht+u+f),{ii:ot,ti:{si:dt,oi:Bt,fi:et,ei:Nt,ri:st,ot:2*a,hi:tt,ni:wt,li:Lt,_i:mt,ui:G,di:h.width},vi:{si:dt/c,fi:et/c,pi:gt,mi:R}}}}class ii{constructor(t){this.Ci={yi:0,t:"#000",Mi:0,gi:0},this.Ti={Jt:"",Tt:!1,ai:!0,bi:!1,Bt:"",O:"#FFF",ci:!1,wi:!1},this.Pi={Jt:"",Tt:!1,ai:!1,bi:!0,Bt:"",O:"#FFF",ci:!0,wi:!0},this.bt=!0,this.Ri=new(t||un)(this.Ti,this.Ci),this.Di=new(t||un)(this.Pi,this.Ci)}Jt(){return this.Oi(),this.Ti.Jt}yi(){return this.Oi(),this.Ci.yi}gt(){this.bt=!0}zt(t,e=!1){return Math.max(this.Ri.zt(t,e),this.Di.zt(t,e))}Ai(){return this.Ci.ki||0}Vi(t){this.Ci.ki=t}Bi(){return this.Oi(),this.Ti.Tt||this.Pi.Tt}Ii(){return this.Oi(),this.Ti.Tt}xt(t){return this.Oi(),this.Ti.ai=this.Ti.ai&&t.W().ticksVisible,this.Pi.ai=this.Pi.ai&&t.W().ticksVisible,this.Ri.it(this.Ti,this.Ci),this.Di.it(this.Pi,this.Ci),this.Ri}zi(){return this.Oi(),this.Ri.it(this.Ti,this.Ci),this.Di.it(this.Pi,this.Ci),this.Di}Oi(){this.bt&&(this.Ti.ai=!0,this.Pi.ai=!1,this.Ei(this.Ti,this.Pi,this.Ci))}}class lh extends ii{constructor(t,e,i){super(),this.$t=t,this.Li=e,this.Ni=i}Ei(t,e,i){if(t.Tt=!1,this.$t.W().mode===2)return;const n=this.$t.W().horzLine;if(!n.labelVisible)return;const r=this.Li.Pt();if(!this.$t.Tt()||this.Li.Fi()||r===null)return;const o=Qe(n.labelBackgroundColor);i.t=o.t,t.O=o.i;const h=2/12*this.Li.P();i.gi=h,i.Mi=h;const l=this.Ni(this.Li);i.yi=l.yi,t.Jt=this.Li.Wi(l.ct,r),t.Tt=!0}}const ah=/[1-9]/g;class fn{constructor(){this.Lt=null}it(t){this.Lt=t}K(t,e){if(this.Lt===null||this.Lt.Tt===!1||this.Lt.Jt.length===0)return;const i=t.useMediaCoordinateSpace((({context:p})=>(p.font=e.R,Math.round(e.ji.Si(p,S(this.Lt).Jt,ah)))));if(i<=0)return;const n=e.Hi,r=i+2*n,o=r/2,h=this.Lt.$i;let l=this.Lt.yi,a=Math.floor(l-o)+.5;a<0?(l+=Math.abs(0-a),a=Math.floor(l-o)+.5):a+r>h&&(l-=Math.abs(h-(a+r)),a=Math.floor(l-o)+.5);const c=a+r,u=Math.ceil(0+e.C+e.T+e.L+e.P+e.V);t.useBitmapCoordinateSpace((({context:p,horizontalPixelRatio:g,verticalPixelRatio:d})=>{const f=S(this.Lt);p.fillStyle=f.t;const m=Math.round(a*g),w=Math.round(0*d),M=Math.round(c*g),R=Math.round(u*d),k=Math.round(2*g);if(p.beginPath(),p.moveTo(m,w),p.lineTo(m,R-k),p.arcTo(m,R,m+k,R,k),p.lineTo(M-k,R),p.arcTo(M,R,M,R-k,k),p.lineTo(M,w),p.fill(),f.ai){const $=Math.round(f.yi*g),Q=w,G=Math.round((Q+e.T)*d);p.fillStyle=f.O;const st=Math.max(1,Math.floor(g)),tt=Math.floor(.5*g);p.fillRect($-tt,Q,st,G-Q)}})),t.useMediaCoordinateSpace((({context:p})=>{const g=S(this.Lt),d=0+e.C+e.T+e.L+e.P/2;p.font=e.R,p.textAlign="left",p.textBaseline="middle",p.fillStyle=g.O;const f=e.ji.xi(p,"Apr0");p.translate(a+n,d+f),p.fillText(g.Jt,0,0)}))}}class ch{constructor(t,e,i){this.bt=!0,this.Ht=new fn,this.jt={Tt:!1,t:"#4c525e",O:"white",Jt:"",$i:0,yi:NaN,ai:!0},this.wt=t,this.Ui=e,this.Ni=i}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht.it(this.jt),this.Ht}St(){const t=this.jt;if(t.Tt=!1,this.wt.W().mode===2)return;const e=this.wt.W().vertLine;if(!e.labelVisible)return;const i=this.Ui.yt();if(i.Fi())return;t.$i=i.$i();const n=this.Ni();if(n===null)return;t.yi=n.yi;const r=i.qi(this.wt.kt());t.Jt=i.Yi(S(r)),t.Tt=!0;const o=Qe(e.labelBackgroundColor);t.t=o.t,t.O=o.i,t.ai=i.W().ticksVisible}}class Wi{constructor(){this.Xi=null,this.Ki=0}Zi(){return this.Ki}Gi(t){this.Ki=t}At(){return this.Xi}Ji(t){this.Xi=t}Qi(t){return[]}tn(){return[]}Tt(){return!0}}var dn;(function(s){s[s.Normal=0]="Normal",s[s.Magnet=1]="Magnet",s[s.Hidden=2]="Hidden"})(dn||(dn={}));class uh extends Wi{constructor(t,e){super(),this.nn=null,this.sn=NaN,this.en=0,this.rn=!0,this.hn=new Map,this.ln=!1,this.an=NaN,this.on=NaN,this._n=NaN,this.un=NaN,this.Ui=t,this.cn=e,this.dn=new nh(t,this),this.fn=((n,r)=>o=>{const h=r(),l=n();if(o===S(this.nn).vn())return{ct:l,yi:h};{const a=S(o.Pt());return{ct:o.pn(h,a),yi:h}}})((()=>this.sn),(()=>this.on));const i=((n,r)=>()=>{const o=this.Ui.yt().mn(n()),h=r();return o&&Number.isFinite(h)?{ut:o,yi:h}:null})((()=>this.en),(()=>this.Kt()));this.bn=new ch(this,t,i),this.wn=new oh(this)}W(){return this.cn}gn(t,e){this._n=t,this.un=e}Mn(){this._n=NaN,this.un=NaN}xn(){return this._n}Sn(){return this.un}kn(t,e,i){this.ln||(this.ln=!0),this.rn=!0,this.yn(t,e,i)}kt(){return this.en}Kt(){return this.an}Zt(){return this.on}Tt(){return this.rn}Cn(){this.rn=!1,this.Tn(),this.sn=NaN,this.an=NaN,this.on=NaN,this.nn=null,this.Mn()}Pn(t){return this.nn!==null?[this.wn,this.dn]:[]}Yt(t){return t===this.nn&&this.cn.horzLine.visible}Xt(){return this.cn.vertLine.visible}Rn(t,e){this.rn&&this.nn===t||this.hn.clear();const i=[];return this.nn===t&&i.push(this.Dn(this.hn,e,this.fn)),i}tn(){return this.rn?[this.bn]:[]}Ut(){return this.nn}On(){this.wn.gt(),this.hn.forEach((t=>t.gt())),this.bn.gt(),this.dn.gt()}An(t){return t&&!t.vn().Fi()?t.vn():null}yn(t,e,i){this.Vn(t,e,i)&&this.On()}Vn(t,e,i){const n=this.an,r=this.on,o=this.sn,h=this.en,l=this.nn,a=this.An(i);this.en=t,this.an=isNaN(t)?NaN:this.Ui.yt().Et(t),this.nn=i;const c=a!==null?a.Pt():null;return a!==null&&c!==null?(this.sn=e,this.on=a.Ot(e,c)):(this.sn=NaN,this.on=NaN),n!==this.an||r!==this.on||h!==this.en||o!==this.sn||l!==this.nn}Tn(){const t=this.Ui.Mt().map((i=>i.In().Bn())).filter(Qo),e=t.length===0?null:Math.max(...t);this.en=e!==null?e:NaN}Dn(t,e,i){let n=t.get(e);return n===void 0&&(n=new lh(this,e,i),t.set(e,n)),n}}function si(s){return s==="left"||s==="right"}class Ct{constructor(t){this.zn=new Map,this.En=[],this.Ln=t}Nn(t,e){const i=(function(n,r){return n===void 0?r:{Fn:Math.max(n.Fn,r.Fn),Wn:n.Wn||r.Wn}})(this.zn.get(t),e);this.zn.set(t,i)}jn(){return this.Ln}Hn(t){const e=this.zn.get(t);return e===void 0?{Fn:this.Ln}:{Fn:Math.max(this.Ln,e.Fn),Wn:e.Wn}}$n(){this.Un(),this.En=[{qn:0}]}Yn(t){this.Un(),this.En=[{qn:1,Vt:t}]}Xn(t){this.Kn(),this.En.push({qn:5,Vt:t})}Un(){this.Kn(),this.En.push({qn:6})}Zn(){this.Un(),this.En=[{qn:4}]}Gn(t){this.Un(),this.En.push({qn:2,Vt:t})}Jn(t){this.Un(),this.En.push({qn:3,Vt:t})}Qn(){return this.En}ts(t){for(const e of t.En)this.ns(e);this.Ln=Math.max(this.Ln,t.Ln),t.zn.forEach(((e,i)=>{this.Nn(i,e)}))}static ss(){return new Ct(2)}static es(){return new Ct(3)}ns(t){switch(t.qn){case 0:this.$n();break;case 1:this.Yn(t.Vt);break;case 2:this.Gn(t.Vt);break;case 3:this.Jn(t.Vt);break;case 4:this.Zn();break;case 5:this.Xn(t.Vt);break;case 6:this.Kn()}}Kn(){const t=this.En.findIndex((e=>e.qn===5));t!==-1&&this.En.splice(t,1)}}const pn=".";function he(s,t){if(!Kt(s))return"n/a";if(!ke(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?s.toString():("0000000000000000"+s.toString()).slice(-t)}class ni{constructor(t,e){if(e||(e=1),Kt(t)&&ke(t)||(t=100),t<0)throw new TypeError("invalid base");this.Li=t,this.rs=e,this.hs()}format(t){const e=t<0?"−":"";return t=Math.abs(t),e+this.ls(t)}hs(){if(this.os=0,this.Li>0&&this.rs>0){let t=this.Li;for(;t>1;)t/=10,this.os++}}ls(t){const e=this.Li/this.rs;let i=Math.floor(t),n="";const r=this.os!==void 0?this.os:NaN;if(e>1){let o=+(Math.round(t*e)-i*e).toFixed(this.os);o>=e&&(o-=e,i+=1),n=pn+he(+o.toFixed(this.os)*this.rs,r)}else i=Math.round(i*e)/e,r>0&&(n=pn+he(0,r));return i.toFixed(0)+n}}class mn extends ni{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class fh{constructor(t){this._s=t}format(t){let e="";return t<0&&(e="-",t=-t),t<995?e+this.us(t):t<999995?e+this.us(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),e+this.us(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),e+this.us(t/1e9)+"B")}us(t){let e;const i=Math.pow(10,this._s);return e=(t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this._s).replace(/\.?0+$/,""):String(t),e.replace(/(\.[1-9]*)0+$/,((n,r)=>r))}}function gn(s,t,e,i,n,r,o){if(t.length===0||i.from>=t.length||i.to<=0)return;const{context:h,horizontalPixelRatio:l,verticalPixelRatio:a}=s,c=t[i.from];let u=r(s,c),p=c;if(i.to-i.from<2){const g=n/2;h.beginPath();const d={et:c.et-g,rt:c.rt},f={et:c.et+g,rt:c.rt};h.moveTo(d.et*l,d.rt*a),h.lineTo(f.et*l,f.rt*a),o(s,u,d,f)}else{const g=(f,m)=>{o(s,u,p,m),h.beginPath(),u=f,p=m};let d=p;h.beginPath(),h.moveTo(c.et*l,c.rt*a);for(let f=i.from+1;f<i.to;++f){d=t[f];const m=r(s,d);switch(e){case 0:h.lineTo(d.et*l,d.rt*a);break;case 1:h.lineTo(d.et*l,t[f-1].rt*a),m!==u&&(g(m,d),h.lineTo(d.et*l,t[f-1].rt*a)),h.lineTo(d.et*l,d.rt*a);break;case 2:{const[w,M]=dh(t,f-1,f);h.bezierCurveTo(w.et*l,w.rt*a,M.et*l,M.rt*a,d.et*l,d.rt*a);break}}e!==1&&m!==u&&(g(m,d),h.moveTo(d.et*l,d.rt*a))}(p!==d||p===d&&e===1)&&o(s,u,p,d)}}const bn=6;function Ii(s,t){return{et:s.et-t.et,rt:s.rt-t.rt}}function vn(s,t){return{et:s.et/t,rt:s.rt/t}}function dh(s,t,e){const i=Math.max(0,t-1),n=Math.min(s.length-1,e+1);var r,o;return[(r=s[t],o=vn(Ii(s[e],s[i]),bn),{et:r.et+o.et,rt:r.rt+o.rt}),Ii(s[e],vn(Ii(s[n],s[t]),bn))]}function ph(s,t,e,i,n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:h}=t;r.lineTo(n.et*o,s*h),r.lineTo(i.et*o,s*h),r.closePath(),r.fillStyle=e,r.fill()}class yn extends oe{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z(t){var e;if(this.tt===null)return;const{st:i,nt:n,cs:r,ht:o,Wt:h,ds:l}=this.tt,a=(e=this.tt.fs)!==null&&e!==void 0?e:this.tt.vs?0:t.mediaSize.height;if(n===null)return;const c=t.context;c.lineCap="butt",c.lineJoin="round",c.lineWidth=o,pe(c,h),c.lineWidth=1,gn(t,i,l,n,r,this.ps.bind(this),ph.bind(null,a))}}function qi(s,t,e){return Math.min(Math.max(s,t),e)}function ri(s,t,e){return t-s<=e}function wn(s){const t=Math.ceil(s);return t%2==0?t-1:t}class Hi{bs(t,e){const i=this.ws,{gs:n,Ms:r,xs:o,Ss:h,ks:l,fs:a}=e;if(this.ys===void 0||i===void 0||i.gs!==n||i.Ms!==r||i.xs!==o||i.Ss!==h||i.fs!==a||i.ks!==l){const c=t.context.createLinearGradient(0,0,0,l);if(c.addColorStop(0,n),a!=null){const u=qi(a*t.verticalPixelRatio/l,0,1);c.addColorStop(u,r),c.addColorStop(u,o)}c.addColorStop(1,h),this.ys=c,this.ws=e}return this.ys}}class mh extends yn{constructor(){super(...arguments),this.Cs=new Hi}ps(t,e){return this.Cs.bs(t,{gs:e.Ts,Ms:"",xs:"",Ss:e.Ps,ks:t.bitmapSize.height})}}function gh(s,t){const e=s.context;e.strokeStyle=t,e.stroke()}class Sn extends oe{constructor(){super(...arguments),this.tt=null}it(t){this.tt=t}Z(t){if(this.tt===null)return;const{st:e,nt:i,cs:n,ds:r,ht:o,Wt:h,Rs:l}=this.tt;if(i===null)return;const a=t.context;a.lineCap="butt",a.lineWidth=o*t.verticalPixelRatio,pe(a,h),a.lineJoin="round";const c=this.Ds.bind(this);r!==void 0&&gn(t,e,r,i,n,c,gh),l&&(function(u,p,g,d,f){const{horizontalPixelRatio:m,verticalPixelRatio:w,context:M}=u;let R=null;const k=Math.max(1,Math.floor(m))%2/2,$=g*w+k;for(let Q=d.to-1;Q>=d.from;--Q){const G=p[Q];if(G){const st=f(u,G);st!==R&&(M.beginPath(),R!==null&&M.fill(),M.fillStyle=st,R=st);const tt=Math.round(G.et*m)+k,Nt=G.rt*w;M.moveTo(tt,Nt),M.arc(tt,Nt,$,0,2*Math.PI)}}M.fill()})(t,e,l,i,c)}}class _n extends Sn{Ds(t,e){return e._t}}function Tn(s,t,e,i,n=0,r=t.length){let o=r-n;for(;0<o;){const h=o>>1,l=n+h;i(t[l],e)===s?(n=l+1,o-=h+1):o=h}return n}const De=Tn.bind(null,!0),En=Tn.bind(null,!1);function bh(s,t){return s.ut<t}function vh(s,t){return t<s.ut}function Cn(s,t,e){const i=t.Os(),n=t.di(),r=De(s,i,bh),o=En(s,n,vh);if(!e)return{from:r,to:o};let h=r,l=o;return r>0&&r<s.length&&s[r].ut>=i&&(h=r-1),o>0&&o<s.length&&s[o-1].ut<=n&&(l=o+1),{from:h,to:l}}class $i{constructor(t,e,i){this.As=!0,this.Vs=!0,this.Bs=!0,this.Is=[],this.zs=null,this.Es=t,this.Ls=e,this.Ns=i}gt(t){this.As=!0,t==="data"&&(this.Vs=!0),t==="options"&&(this.Bs=!0)}xt(){return this.Es.Tt()?(this.Fs(),this.zs===null?null:this.Ws):null}js(){this.Is=this.Is.map((t=>Object.assign(Object.assign({},t),this.Es.$s().Hs(t.ut))))}Us(){this.zs=null}Fs(){this.Vs&&(this.qs(),this.Vs=!1),this.Bs&&(this.js(),this.Bs=!1),this.As&&(this.Ys(),this.As=!1)}Ys(){const t=this.Es.At(),e=this.Ls.yt();if(this.Us(),e.Fi()||t.Fi())return;const i=e.Xs();if(i===null||this.Es.In().Ks()===0)return;const n=this.Es.Pt();n!==null&&(this.zs=Cn(this.Is,i,this.Ns),this.Zs(t,e,n.Vt),this.Gs())}}class oi extends $i{constructor(t,e){super(t,e,!0)}Zs(t,e,i){e.Js(this.Is,Ae(this.zs)),t.Qs(this.Is,i,Ae(this.zs))}te(t,e){return{ut:t,ct:e,et:NaN,rt:NaN}}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>{const i=e.Vt[3];return this.ne(e.se,i,t)}))}}class yh extends oi{constructor(t,e){super(t,e),this.Ws=new zi,this.ee=new mh,this.re=new _n,this.Ws.X([this.ee,this.re])}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.W();this.ee.it({ds:t.lineType,st:this.Is,Wt:t.lineStyle,ht:t.lineWidth,fs:null,vs:t.invertFilledArea,nt:this.zs,cs:this.Ls.yt().he()}),this.re.it({ds:t.lineVisible?t.lineType:void 0,st:this.Is,Wt:t.lineStyle,ht:t.lineWidth,nt:this.zs,cs:this.Ls.yt().he(),Rs:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}class wh extends oe{constructor(){super(...arguments),this.Lt=null,this.le=0,this.ae=0}it(t){this.Lt=t}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.Lt===null||this.Lt.In.length===0||this.Lt.nt===null)return;this.le=this.oe(e),this.le>=2&&Math.max(1,Math.floor(e))%2!=this.le%2&&this.le--,this.ae=this.Lt._e?Math.min(this.le,Math.floor(e)):this.le;let n=null;const r=this.ae<=this.le&&this.Lt.he>=Math.floor(1.5*e);for(let o=this.Lt.nt.from;o<this.Lt.nt.to;++o){const h=this.Lt.In[o];n!==h.ue&&(t.fillStyle=h.ue,n=h.ue);const l=Math.floor(.5*this.ae),a=Math.round(h.et*e),c=a-l,u=this.ae,p=c+u-1,g=Math.min(h.ce,h.de),d=Math.max(h.ce,h.de),f=Math.round(g*i)-l,m=Math.round(d*i)+l,w=Math.max(m-f,this.ae);t.fillRect(c,f,u,w);const M=Math.ceil(1.5*this.le);if(r){if(this.Lt.fe){const Q=a-M;let G=Math.max(f,Math.round(h.ve*i)-l),st=G+u-1;st>f+w-1&&(st=f+w-1,G=st-u+1),t.fillRect(Q,G,c-Q,st-G+1)}const R=a+M;let k=Math.max(f,Math.round(h.pe*i)-l),$=k+u-1;$>f+w-1&&($=f+w-1,k=$-u+1),t.fillRect(p+1,k,R-p,$-k+1)}}}oe(t){const e=Math.floor(t);return Math.max(e,Math.floor((function(i,n){return Math.floor(.3*i*n)})(S(this.Lt).he,t)))}}class Ln extends $i{constructor(t,e){super(t,e,!1)}Zs(t,e,i){e.Js(this.Is,Ae(this.zs)),t.me(this.Is,i,Ae(this.zs))}be(t,e,i){return{ut:t,we:e.Vt[0],ge:e.Vt[1],Me:e.Vt[2],xe:e.Vt[3],et:NaN,ve:NaN,ce:NaN,de:NaN,pe:NaN}}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>this.ne(e.se,e,t)))}}class Sh extends Ln{constructor(){super(...arguments),this.Ws=new wh}ne(t,e,i){return Object.assign(Object.assign({},this.be(t,e,i)),i.Hs(t))}Gs(){const t=this.Es.W();this.Ws.it({In:this.Is,he:this.Ls.yt().he(),fe:t.openVisible,_e:t.thinBars,nt:this.zs})}}class _h extends yn{constructor(){super(...arguments),this.Cs=new Hi}ps(t,e){const i=this.tt;return this.Cs.bs(t,{gs:e.Se,Ms:e.ke,xs:e.ye,Ss:e.Ce,ks:t.bitmapSize.height,fs:i.fs})}}class Th extends Sn{constructor(){super(...arguments),this.Te=new Hi}Ds(t,e){const i=this.tt;return this.Te.bs(t,{gs:e.Pe,Ms:e.Pe,xs:e.Re,Ss:e.Re,ks:t.bitmapSize.height,fs:i.fs})}}class Eh extends oi{constructor(t,e){super(t,e),this.Ws=new zi,this.De=new _h,this.Oe=new Th,this.Ws.X([this.De,this.Oe])}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.Pt();if(t===null)return;const e=this.Es.W(),i=this.Es.At().Ot(e.baseValue.price,t.Vt),n=this.Ls.yt().he();this.De.it({st:this.Is,ht:e.lineWidth,Wt:e.lineStyle,ds:e.lineType,fs:i,vs:!1,nt:this.zs,cs:n}),this.Oe.it({st:this.Is,ht:e.lineWidth,Wt:e.lineStyle,ds:e.lineVisible?e.lineType:void 0,Rs:e.pointMarkersVisible?e.pointMarkersRadius||e.lineWidth/2+2:void 0,fs:i,nt:this.zs,cs:n})}}class Ch extends oe{constructor(){super(...arguments),this.Lt=null,this.le=0}it(t){this.Lt=t}Z(t){if(this.Lt===null||this.Lt.In.length===0||this.Lt.nt===null)return;const{horizontalPixelRatio:e}=t;this.le=(function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const h=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),l=Math.floor(r*h*o),a=Math.floor(r*o),c=Math.min(l,a);return Math.max(Math.floor(o),c)})(this.Lt.he,e),this.le>=2&&Math.floor(e)%2!=this.le%2&&this.le--;const i=this.Lt.In;this.Lt.Ae&&this.Ve(t,i,this.Lt.nt),this.Lt.ci&&this.Be(t,i,this.Lt.nt);const n=this.Ie(e);(!this.Lt.ci||this.le>2*n)&&this.ze(t,i,this.Lt.nt)}Ve(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="",l=Math.min(Math.floor(r),Math.floor(this.Lt.he*r));l=Math.max(Math.floor(r),Math.min(l,this.le));const a=Math.floor(.5*l);let c=null;for(let u=i.from;u<i.to;u++){const p=e[u];p.Ee!==h&&(n.fillStyle=p.Ee,h=p.Ee);const g=Math.round(Math.min(p.ve,p.pe)*o),d=Math.round(Math.max(p.ve,p.pe)*o),f=Math.round(p.ce*o),m=Math.round(p.de*o);let w=Math.round(r*p.et)-a;const M=w+l-1;c!==null&&(w=Math.max(c+1,w),w=Math.min(w,M));const R=M-w+1;n.fillRect(w,f,R,g-f),n.fillRect(w,d+1,R,m-d),c=M}}Ie(t){let e=Math.floor(1*t);this.le<=2*e&&(e=Math.floor(.5*(this.le-1)));const i=Math.max(Math.floor(t),e);return this.le<=2*i?Math.max(Math.floor(t),Math.floor(1*t)):i}Be(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="";const l=this.Ie(r);let a=null;for(let c=i.from;c<i.to;c++){const u=e[c];u.Le!==h&&(n.fillStyle=u.Le,h=u.Le);let p=Math.round(u.et*r)-Math.floor(.5*this.le);const g=p+this.le-1,d=Math.round(Math.min(u.ve,u.pe)*o),f=Math.round(Math.max(u.ve,u.pe)*o);if(a!==null&&(p=Math.max(a+1,p),p=Math.min(p,g)),this.Lt.he*r>2*l)hh(n,p,d,g-p+1,f-d+1,l);else{const m=g-p+1;n.fillRect(p,d,m,f-d+1)}a=g}}ze(t,e,i){if(this.Lt===null)return;const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let h="";const l=this.Ie(r);for(let a=i.from;a<i.to;a++){const c=e[a];let u=Math.round(Math.min(c.ve,c.pe)*o),p=Math.round(Math.max(c.ve,c.pe)*o),g=Math.round(c.et*r)-Math.floor(.5*this.le),d=g+this.le-1;if(c.ue!==h){const f=c.ue;n.fillStyle=f,h=f}this.Lt.ci&&(g+=l,u+=l,d-=l,p-=l),u>p||n.fillRect(g,u,d-g+1,p-u+1)}}}class Lh extends Ln{constructor(){super(...arguments),this.Ws=new Ch}ne(t,e,i){return Object.assign(Object.assign({},this.be(t,e,i)),i.Hs(t))}Gs(){const t=this.Es.W();this.Ws.it({In:this.Is,he:this.Ls.yt().he(),Ae:t.wickVisible,ci:t.borderVisible,nt:this.zs})}}class xh{constructor(t,e){this.Ne=t,this.Li=e}K(t,e,i){this.Ne.draw(t,this.Li,e,i)}}class ji extends $i{constructor(t,e,i){super(t,e,!1),this.wn=i,this.Ws=new xh(this.wn.renderer(),(n=>{const r=t.Pt();return r===null?null:t.At().Ot(n,r.Vt)}))}Fe(t){return this.wn.priceValueBuilder(t)}We(t){return this.wn.isWhitespace(t)}qs(){const t=this.Es.$s();this.Is=this.Es.In().ie().map((e=>Object.assign(Object.assign({ut:e.se,et:NaN},t.Hs(e.se)),{je:e.He})))}Zs(t,e){e.Js(this.Is,Ae(this.zs))}Gs(){this.wn.update({bars:this.Is.map(Mh),barSpacing:this.Ls.yt().he(),visibleRange:this.zs},this.Es.W())}}function Mh(s){return{x:s.et,time:s.ut,originalData:s.je,barColor:s.ue}}class Rh extends oe{constructor(){super(...arguments),this.Lt=null,this.$e=[]}it(t){this.Lt=t,this.$e=[]}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){if(this.Lt===null||this.Lt.st.length===0||this.Lt.nt===null)return;this.$e.length||this.Ue(e);const n=Math.max(1,Math.floor(i)),r=Math.round(this.Lt.qe*i)-Math.floor(n/2),o=r+n;for(let h=this.Lt.nt.from;h<this.Lt.nt.to;h++){const l=this.Lt.st[h],a=this.$e[h-this.Lt.nt.from],c=Math.round(l.rt*i);let u,p;t.fillStyle=l.ue,c<=r?(u=c,p=o):(u=r,p=c-Math.floor(n/2)+n),t.fillRect(a.Os,u,a.di-a.Os+1,p-u)}}Ue(t){if(this.Lt===null||this.Lt.st.length===0||this.Lt.nt===null)return void(this.$e=[]);const e=Math.ceil(this.Lt.he*t)<=1?0:Math.max(1,Math.floor(t)),i=Math.round(this.Lt.he*t)-e;this.$e=new Array(this.Lt.nt.to-this.Lt.nt.from);for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.Lt.st[r],h=Math.round(o.et*t);let l,a;if(i%2){const c=(i-1)/2;l=h-c,a=h+c}else{const c=i/2;l=h-c,a=h+c-1}this.$e[r-this.Lt.nt.from]={Os:l,di:a,Ye:h,Xe:o.et*t,ut:o.ut}}for(let r=this.Lt.nt.from+1;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from],h=this.$e[r-this.Lt.nt.from-1];o.ut===h.ut+1&&o.Os-h.di!==e+1&&(h.Ye>h.Xe?h.di=o.Os-e-1:o.Os=h.di+e+1)}let n=Math.ceil(this.Lt.he*t);for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from];o.di<o.Os&&(o.di=o.Os);const h=o.di-o.Os+1;n=Math.min(h,n)}if(e>0&&n<4)for(let r=this.Lt.nt.from;r<this.Lt.nt.to;r++){const o=this.$e[r-this.Lt.nt.from];o.di-o.Os+1>n&&(o.Ye>o.Xe?o.di-=1:o.Os+=1)}}}class Oh extends oi{constructor(){super(...arguments),this.Ws=new Rh}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t={st:this.Is,he:this.Ls.yt().he(),nt:this.zs,qe:this.Es.At().Ot(this.Es.W().base,S(this.Es.Pt()).Vt)};this.Ws.it(t)}}class kh extends oi{constructor(){super(...arguments),this.Ws=new _n}ne(t,e,i){return Object.assign(Object.assign({},this.te(t,e)),i.Hs(t))}Gs(){const t=this.Es.W(),e={st:this.Is,Wt:t.lineStyle,ds:t.lineVisible?t.lineType:void 0,ht:t.lineWidth,Rs:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,nt:this.zs,cs:this.Ls.yt().he()};this.Ws.it(e)}}const Ph=/[2-9]/g;class Ne{constructor(t=50){this.Ke=0,this.Ze=1,this.Ge=1,this.Je={},this.Qe=new Map,this.tr=t}ir(){this.Ke=0,this.Qe.clear(),this.Ze=1,this.Ge=1,this.Je={}}Si(t,e,i){return this.nr(t,e,i).width}xi(t,e,i){const n=this.nr(t,e,i);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}nr(t,e,i){const n=i||Ph,r=String(e).replace(n,"0");if(this.Qe.has(r))return kt(this.Qe.get(r)).sr;if(this.Ke===this.tr){const h=this.Je[this.Ge];delete this.Je[this.Ge],this.Qe.delete(h),this.Ge++,this.Ke--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&e.length||(this.Qe.set(r,{sr:o,er:this.Ze}),this.Je[this.Ze]=r,this.Ke++,this.Ze++),o}}class Ah{constructor(t){this.rr=null,this.k=null,this.hr="right",this.lr=t}ar(t,e,i){this.rr=t,this.k=e,this.hr=i}K(t){this.k!==null&&this.rr!==null&&this.rr.K(t,this.k,this.lr,this.hr)}}class xn{constructor(t,e,i){this._r=t,this.lr=new Ne(50),this.ur=e,this.F=i,this.j=-1,this.Ht=new Ah(this.lr)}xt(){const t=this.F.cr(this.ur);if(t===null)return null;const e=t.dr(this.ur)?t.vr():this.ur.At();if(e===null)return null;const i=t.pr(e);if(i==="overlay")return null;const n=this.F.mr();return n.P!==this.j&&(this.j=n.P,this.lr.ir()),this.Ht.ar(this._r.zi(),n,i),this.Ht}}class Dh extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}br(t,e){var i;if(!(!((i=this.Lt)===null||i===void 0)&&i.Tt))return null;const{rt:n,ht:r,wr:o}=this.Lt;return e>=n-r-7&&e<=n+r+7?{gr:this.Lt,wr:o}:null}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null||this.Lt.Tt===!1)return;const r=Math.round(this.Lt.rt*n);r<0||r>e.height||(t.lineCap="butt",t.strokeStyle=this.Lt.O,t.lineWidth=Math.floor(this.Lt.ht*i),pe(t,this.Lt.Wt),rn(t,r,0,e.width))}}class Ji{constructor(t){this.Mr={rt:0,O:"rgba(0, 0, 0, 0)",ht:1,Wt:0,Tt:!1},this.Sr=new Dh,this.bt=!0,this.Es=t,this.Ls=t.qt(),this.Sr.it(this.Mr)}gt(){this.bt=!0}xt(){return this.Es.Tt()?(this.bt&&(this.kr(),this.bt=!1),this.Sr):null}}class Nh extends Ji{constructor(t){super(t)}kr(){this.Mr.Tt=!1;const t=this.Es.At(),e=t.yr().yr;if(e!==2&&e!==3)return;const i=this.Es.W();if(!i.baseLineVisible||!this.Es.Tt())return;const n=this.Es.Pt();n!==null&&(this.Mr.Tt=!0,this.Mr.rt=t.Ot(n.Vt,n.Vt),this.Mr.O=i.baseLineColor,this.Mr.ht=i.baseLineWidth,this.Mr.Wt=i.baseLineStyle)}}class Bh extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}He(){return this.Lt}Z({context:t,horizontalPixelRatio:e,verticalPixelRatio:i}){const n=this.Lt;if(n===null)return;const r=Math.max(1,Math.floor(e)),o=r%2/2,h=Math.round(n.Xe.x*e)+o,l=n.Xe.y*i;t.fillStyle=n.Cr,t.beginPath();const a=Math.max(2,1.5*n.Tr)*e;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.Pr,t.beginPath(),t.arc(h,l,n.ot*e,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=n.Rr,t.beginPath(),t.arc(h,l,n.ot*e+r/2,0,2*Math.PI,!1),t.stroke()}}const Fh=[{Dr:0,Or:.25,Ar:4,Vr:10,Br:.25,Ir:0,zr:.4,Er:.8},{Dr:.25,Or:.525,Ar:10,Vr:14,Br:0,Ir:0,zr:.8,Er:0},{Dr:.525,Or:1,Ar:14,Vr:14,Br:0,Ir:0,zr:0,Er:0}];function Mn(s,t,e,i){return(function(n,r){if(n==="transparent")return n;const o=Ze(n),h=o[3];return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${r*h})`})(s,e+(i-e)*t)}function Rn(s,t){const e=s%2600/2600;let i;for(const l of Fh)if(e>=l.Dr&&e<=l.Or){i=l;break}le(i!==void 0,"Last price animation internal logic error");const n=(e-i.Dr)/(i.Or-i.Dr);return{Pr:Mn(t,n,i.Br,i.Ir),Rr:Mn(t,n,i.zr,i.Er),ot:(r=n,o=i.Ar,h=i.Vr,o+(h-o)*r)};var r,o,h}class zh{constructor(t){this.Ht=new Bh,this.bt=!0,this.Lr=!0,this.Nr=performance.now(),this.Fr=this.Nr-1,this.Wr=t}jr(){this.Fr=this.Nr-1,this.gt()}Hr(){if(this.gt(),this.Wr.W().lastPriceAnimation===2){const t=performance.now(),e=this.Fr-t;if(e>0)return void(e<650&&(this.Fr+=2600));this.Nr=t,this.Fr=t+2600}}gt(){this.bt=!0}$r(){this.Lr=!0}Tt(){return this.Wr.W().lastPriceAnimation!==0}Ur(){switch(this.Wr.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Fr}}xt(){return this.bt?(this.St(),this.bt=!1,this.Lr=!1):this.Lr&&(this.qr(),this.Lr=!1),this.Ht}St(){this.Ht.it(null);const t=this.Wr.qt().yt(),e=t.Xs(),i=this.Wr.Pt();if(e===null||i===null)return;const n=this.Wr.Yr(!0);if(n.Xr||!e.Kr(n.se))return;const r={x:t.Et(n.se),y:this.Wr.At().Ot(n.ct,i.Vt)},o=n.O,h=this.Wr.W().lineWidth,l=Rn(this.Zr(),o);this.Ht.it({Cr:o,Tr:h,Pr:l.Pr,Rr:l.Rr,ot:l.ot,Xe:r})}qr(){const t=this.Ht.He();if(t!==null){const e=Rn(this.Zr(),t.Cr);t.Pr=e.Pr,t.Rr=e.Rr,t.ot=e.ot}}Zr(){return this.Ur()?performance.now()-this.Nr:2599}}function Be(s,t){return wn(Math.min(Math.max(s,12),30)*t)}function Fe(s,t){switch(s){case"arrowDown":case"arrowUp":return Be(t,1);case"circle":return Be(t,.8);case"square":return Be(t,.7)}}function On(s){return(function(t){const e=Math.ceil(t);return e%2!=0?e-1:e})(Be(s,1))}function kn(s){return Math.max(Be(s,.1),3)}function Pn(s,t,e,i,n){const r=Fe("square",e),o=(r-1)/2,h=s-o,l=t-o;return i>=h&&i<=h+r&&n>=l&&n<=l+r}function An(s,t,e,i,n){const r=(Fe("arrowUp",n)-1)/2,o=(wn(n/2)-1)/2;t.beginPath(),s?(t.moveTo(e-r,i),t.lineTo(e,i-r),t.lineTo(e+r,i),t.lineTo(e+o,i),t.lineTo(e+o,i+r),t.lineTo(e-o,i+r),t.lineTo(e-o,i)):(t.moveTo(e-r,i),t.lineTo(e,i+r),t.lineTo(e+r,i),t.lineTo(e+o,i),t.lineTo(e+o,i-r),t.lineTo(e-o,i-r),t.lineTo(e-o,i)),t.fill()}function Uh(s,t,e,i,n,r){return Pn(t,e,i,n,r)}class Vh extends Ui{constructor(){super(...arguments),this.Lt=null,this.lr=new Ne,this.j=-1,this.H="",this.Gr=""}it(t){this.Lt=t}ar(t,e){this.j===t&&this.H===e||(this.j=t,this.H=e,this.Gr=_e(t,e),this.lr.ir())}br(t,e){if(this.Lt===null||this.Lt.nt===null)return null;for(let i=this.Lt.nt.from;i<this.Lt.nt.to;i++){const n=this.Lt.st[i];if(Ih(n,t,e))return{gr:n.Jr,wr:n.wr}}return null}Z({context:t},e,i){if(this.Lt!==null&&this.Lt.nt!==null){t.textBaseline="middle",t.font=this.Gr;for(let n=this.Lt.nt.from;n<this.Lt.nt.to;n++){const r=this.Lt.st[n];r.Jt!==void 0&&(r.Jt.$i=this.lr.Si(t,r.Jt.Qr),r.Jt.zt=this.j,r.Jt.et=r.et-r.Jt.$i/2),Wh(r,t)}}}}function Wh(s,t){t.fillStyle=s.O,s.Jt!==void 0&&(function(e,i,n,r){e.fillText(i,n,r)})(t,s.Jt.Qr,s.Jt.et,s.Jt.rt),(function(e,i){if(e.Ks!==0){switch(e.th){case"arrowDown":return void An(!1,i,e.et,e.rt,e.Ks);case"arrowUp":return void An(!0,i,e.et,e.rt,e.Ks);case"circle":return void(function(n,r,o,h){const l=(Fe("circle",h)-1)/2;n.beginPath(),n.arc(r,o,l,0,2*Math.PI,!1),n.fill()})(i,e.et,e.rt,e.Ks);case"square":return void(function(n,r,o,h){const l=Fe("square",h),a=(l-1)/2,c=r-a,u=o-a;n.fillRect(c,u,l,l)})(i,e.et,e.rt,e.Ks)}e.th}})(s,t)}function Ih(s,t,e){return!(s.Jt===void 0||!(function(i,n,r,o,h,l){const a=o/2;return h>=i&&h<=i+r&&l>=n-a&&l<=n+a})(s.Jt.et,s.Jt.rt,s.Jt.$i,s.Jt.zt,t,e))||(function(i,n,r){if(i.Ks===0)return!1;switch(i.th){case"arrowDown":case"arrowUp":return Uh(0,i.et,i.rt,i.Ks,n,r);case"circle":return(function(o,h,l,a,c){const u=2+Fe("circle",l)/2,p=o-a,g=h-c;return Math.sqrt(p*p+g*g)<=u})(i.et,i.rt,i.Ks,n,r);case"square":return Pn(i.et,i.rt,i.Ks,n,r)}})(s,t,e)}function qh(s,t,e,i,n,r,o,h,l){const a=Kt(e)?e:e.xe,c=Kt(e)?e:e.ge,u=Kt(e)?e:e.Me,p=Kt(t.size)?Math.max(t.size,0):1,g=On(h.he())*p,d=g/2;switch(s.Ks=g,t.position){case"inBar":return s.rt=o.Ot(a,l),void(s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n));case"aboveBar":return s.rt=o.Ot(c,l)-d-i.ih,s.Jt!==void 0&&(s.Jt.rt=s.rt-d-.6*n,i.ih+=1.2*n),void(i.ih+=g+r);case"belowBar":return s.rt=o.Ot(u,l)+d+i.nh,s.Jt!==void 0&&(s.Jt.rt=s.rt+d+r+.6*n,i.nh+=1.2*n),void(i.nh+=g+r)}t.position}class Hh{constructor(t,e){this.bt=!0,this.sh=!0,this.eh=!0,this.rh=null,this.Ht=new Vh,this.Wr=t,this.Ui=e,this.Lt={st:[],nt:null}}gt(t){this.bt=!0,this.eh=!0,t==="data"&&(this.sh=!0)}xt(t){if(!this.Wr.Tt())return null;this.bt&&this.hh();const e=this.Ui.W().layout;return this.Ht.ar(e.fontSize,e.fontFamily),this.Ht.it(this.Lt),this.Ht}lh(){if(this.eh){if(this.Wr.ah().length>0){const t=this.Ui.yt().he(),e=kn(t),i=1.5*On(t)+2*e;this.rh={above:i,below:i}}else this.rh=null;this.eh=!1}return this.rh}hh(){const t=this.Wr.At(),e=this.Ui.yt(),i=this.Wr.ah();this.sh&&(this.Lt.st=i.map((c=>({ut:c.time,et:0,rt:0,Ks:0,th:c.shape,O:c.color,Jr:c.Jr,wr:c.id,Jt:void 0}))),this.sh=!1);const n=this.Ui.W().layout;this.Lt.nt=null;const r=e.Xs();if(r===null)return;const o=this.Wr.Pt();if(o===null||this.Lt.st.length===0)return;let h=NaN;const l=kn(e.he()),a={ih:l,nh:l};this.Lt.nt=Cn(this.Lt.st,r,!0);for(let c=this.Lt.nt.from;c<this.Lt.nt.to;c++){const u=i[c];u.time!==h&&(a.ih=l,a.nh=l,h=u.time);const p=this.Lt.st[c];p.et=e.Et(u.time),u.text!==void 0&&u.text.length>0&&(p.Jt={Qr:u.text,et:0,rt:0,$i:0,zt:0});const g=this.Wr.oh(u.time);g!==null&&qh(p,u,g,a,n.fontSize,l,t,e,o.Vt)}this.bt=!1}}class $h extends Ji{constructor(t){super(t)}kr(){const t=this.Mr;t.Tt=!1;const e=this.Es.W();if(!e.priceLineVisible||!this.Es.Tt())return;const i=this.Es.Yr(e.priceLineSource===0);i.Xr||(t.Tt=!0,t.rt=i.yi,t.O=this.Es._h(i.O),t.ht=e.priceLineWidth,t.Wt=e.priceLineStyle)}}class jh extends ii{constructor(t){super(),this.$t=t}Ei(t,e,i){t.Tt=!1,e.Tt=!1;const n=this.$t;if(!n.Tt())return;const r=n.W(),o=r.lastValueVisible,h=n.uh()!=="",l=r.seriesLastValueMode===0,a=n.Yr(!1);if(a.Xr)return;o&&(t.Jt=this.dh(a,o,l),t.Tt=t.Jt.length!==0),(h||l)&&(e.Jt=this.fh(a,o,h,l),e.Tt=e.Jt.length>0);const c=n._h(a.O),u=Qe(c);i.t=u.t,i.yi=a.yi,e.Bt=n.qt().It(a.yi/n.At().zt()),t.Bt=c,t.O=u.i,e.O=u.i}fh(t,e,i,n){let r="";const o=this.$t.uh();return i&&o.length!==0&&(r+=`${o} `),e&&n&&(r+=this.$t.At().ph()?t.mh:t.bh),r.trim()}dh(t,e,i){return e?i?this.$t.At().ph()?t.bh:t.mh:t.Jt:""}}function Dn(s,t,e,i){const n=Number.isFinite(t),r=Number.isFinite(e);return n&&r?s(t,e):n||r?n?t:e:i}class Pt{constructor(t,e){this.wh=t,this.gh=e}Mh(t){return t!==null&&this.wh===t.wh&&this.gh===t.gh}xh(){return new Pt(this.wh,this.gh)}Sh(){return this.wh}kh(){return this.gh}yh(){return this.gh-this.wh}Fi(){return this.gh===this.wh||Number.isNaN(this.gh)||Number.isNaN(this.wh)}ts(t){return t===null?this:new Pt(Dn(Math.min,this.Sh(),t.Sh(),-1/0),Dn(Math.max,this.kh(),t.kh(),1/0))}Ch(t){if(!Kt(t)||this.gh-this.wh===0)return;const e=.5*(this.gh+this.wh);let i=this.gh-e,n=this.wh-e;i*=t,n*=t,this.gh=e+i,this.wh=e+n}Th(t){Kt(t)&&(this.gh+=t,this.wh+=t)}Ph(){return{minValue:this.wh,maxValue:this.gh}}static Rh(t){return t===null?null:new Pt(t.minValue,t.maxValue)}}class hi{constructor(t,e){this.Dh=t,this.Oh=e||null}Ah(){return this.Dh}Vh(){return this.Oh}Ph(){return this.Dh===null?null:{priceRange:this.Dh.Ph(),margins:this.Oh||void 0}}static Rh(t){return t===null?null:new hi(Pt.Rh(t.priceRange),t.margins)}}class Jh extends Ji{constructor(t,e){super(t),this.Bh=e}kr(){const t=this.Mr;t.Tt=!1;const e=this.Bh.W();if(!this.Es.Tt()||!e.lineVisible)return;const i=this.Bh.Ih();i!==null&&(t.Tt=!0,t.rt=i,t.O=e.color,t.ht=e.lineWidth,t.Wt=e.lineStyle,t.wr=this.Bh.W().id)}}class Kh extends ii{constructor(t,e){super(),this.Wr=t,this.Bh=e}Ei(t,e,i){t.Tt=!1,e.Tt=!1;const n=this.Bh.W(),r=n.axisLabelVisible,o=n.title!=="",h=this.Wr;if(!r||!h.Tt())return;const l=this.Bh.Ih();if(l===null)return;o&&(e.Jt=n.title,e.Tt=!0),e.Bt=h.qt().It(l/h.At().zt()),t.Jt=this.zh(n.price),t.Tt=!0;const a=Qe(n.axisLabelColor||n.color);i.t=a.t;const c=n.axisLabelTextColor||a.i;t.O=c,e.O=c,i.yi=l}zh(t){const e=this.Wr.Pt();return e===null?"":this.Wr.At().Wi(t,e.Vt)}}class Xh{constructor(t,e){this.Wr=t,this.cn=e,this.Eh=new Jh(t,this),this._r=new Kh(t,this),this.Lh=new xn(this._r,t,t.qt())}Nh(t){Ht(this.cn,t),this.gt(),this.Wr.qt().Fh()}W(){return this.cn}Wh(){return this.Eh}jh(){return this.Lh}Hh(){return this._r}gt(){this.Eh.gt(),this._r.gt()}Ih(){const t=this.Wr,e=t.At();if(t.qt().yt().Fi()||e.Fi())return null;const i=t.Pt();return i===null?null:e.Ot(this.cn.price,i.Vt)}}class Yh extends Wi{constructor(t){super(),this.Ui=t}qt(){return this.Ui}}const Gh={Bar:(s,t,e,i)=>{var n;const r=t.upColor,o=t.downColor,h=S(s(e,i)),l=Se(h.Vt[0])<=Se(h.Vt[3]);return{ue:(n=h.O)!==null&&n!==void 0?n:l?r:o}},Candlestick:(s,t,e,i)=>{var n,r,o;const h=t.upColor,l=t.downColor,a=t.borderUpColor,c=t.borderDownColor,u=t.wickUpColor,p=t.wickDownColor,g=S(s(e,i)),d=Se(g.Vt[0])<=Se(g.Vt[3]);return{ue:(n=g.O)!==null&&n!==void 0?n:d?h:l,Le:(r=g.Bt)!==null&&r!==void 0?r:d?a:c,Ee:(o=g.$h)!==null&&o!==void 0?o:d?u:p}},Custom:(s,t,e,i)=>{var n;return{ue:(n=S(s(e,i)).O)!==null&&n!==void 0?n:t.color}},Area:(s,t,e,i)=>{var n,r,o,h;const l=S(s(e,i));return{ue:(n=l._t)!==null&&n!==void 0?n:t.lineColor,_t:(r=l._t)!==null&&r!==void 0?r:t.lineColor,Ts:(o=l.Ts)!==null&&o!==void 0?o:t.topColor,Ps:(h=l.Ps)!==null&&h!==void 0?h:t.bottomColor}},Baseline:(s,t,e,i)=>{var n,r,o,h,l,a;const c=S(s(e,i));return{ue:c.Vt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,Pe:(n=c.Pe)!==null&&n!==void 0?n:t.topLineColor,Re:(r=c.Re)!==null&&r!==void 0?r:t.bottomLineColor,Se:(o=c.Se)!==null&&o!==void 0?o:t.topFillColor1,ke:(h=c.ke)!==null&&h!==void 0?h:t.topFillColor2,ye:(l=c.ye)!==null&&l!==void 0?l:t.bottomFillColor1,Ce:(a=c.Ce)!==null&&a!==void 0?a:t.bottomFillColor2}},Line:(s,t,e,i)=>{var n,r;const o=S(s(e,i));return{ue:(n=o.O)!==null&&n!==void 0?n:t.color,_t:(r=o.O)!==null&&r!==void 0?r:t.color}},Histogram:(s,t,e,i)=>{var n;return{ue:(n=S(s(e,i)).O)!==null&&n!==void 0?n:t.color}}};class Zh{constructor(t){this.Uh=(e,i)=>i!==void 0?i.Vt:this.Wr.In().qh(e),this.Wr=t,this.Yh=Gh[t.Xh()]}Hs(t,e){return this.Yh(this.Uh,this.Wr.W(),t,e)}}var Nn;(function(s){s[s.NearestLeft=-1]="NearestLeft",s[s.None=0]="None",s[s.NearestRight=1]="NearestRight"})(Nn||(Nn={}));const ae=30;class Qh{constructor(){this.Kh=[],this.Zh=new Map,this.Gh=new Map}Jh(){return this.Ks()>0?this.Kh[this.Kh.length-1]:null}Qh(){return this.Ks()>0?this.tl(0):null}Bn(){return this.Ks()>0?this.tl(this.Kh.length-1):null}Ks(){return this.Kh.length}Fi(){return this.Ks()===0}Kr(t){return this.il(t,0)!==null}qh(t){return this.nl(t)}nl(t,e=0){const i=this.il(t,e);return i===null?null:Object.assign(Object.assign({},this.sl(i)),{se:this.tl(i)})}ie(){return this.Kh}el(t,e,i){if(this.Fi())return null;let n=null;for(const r of i)n=li(n,this.rl(t,e,r));return n}it(t){this.Gh.clear(),this.Zh.clear(),this.Kh=t}tl(t){return this.Kh[t].se}sl(t){return this.Kh[t]}il(t,e){const i=this.hl(t);if(i===null&&e!==0)switch(e){case-1:return this.ll(t);case 1:return this.al(t);default:throw new TypeError("Unknown search mode")}return i}ll(t){let e=this.ol(t);return e>0&&(e-=1),e!==this.Kh.length&&this.tl(e)<t?e:null}al(t){const e=this._l(t);return e!==this.Kh.length&&t<this.tl(e)?e:null}hl(t){const e=this.ol(t);return e===this.Kh.length||t<this.Kh[e].se?null:e}ol(t){return De(this.Kh,t,((e,i)=>e.se<i))}_l(t){return En(this.Kh,t,((e,i)=>e.se>i))}ul(t,e,i){let n=null;for(let r=t;r<e;r++){const o=this.Kh[r].Vt[i];Number.isNaN(o)||(n===null?n={cl:o,dl:o}:(o<n.cl&&(n.cl=o),o>n.dl&&(n.dl=o)))}return n}rl(t,e,i){if(this.Fi())return null;let n=null;const r=S(this.Qh()),o=S(this.Bn()),h=Math.max(t,r),l=Math.min(e,o),a=Math.ceil(h/ae)*ae,c=Math.max(a,Math.floor(l/ae)*ae);{const p=this.ol(h),g=this._l(Math.min(l,a,e));n=li(n,this.ul(p,g,i))}let u=this.Zh.get(i);u===void 0&&(u=new Map,this.Zh.set(i,u));for(let p=Math.max(a+1,h);p<c;p+=ae){const g=Math.floor(p/ae);let d=u.get(g);if(d===void 0){const f=this.ol(g*ae),m=this._l((g+1)*ae-1);d=this.ul(f,m,i),u.set(g,d)}n=li(n,d)}{const p=this.ol(c),g=this._l(l);n=li(n,this.ul(p,g,i))}return n}}function li(s,t){return s===null?t:t===null?s:{cl:Math.min(s.cl,t.cl),dl:Math.max(s.dl,t.dl)}}class tl{constructor(t){this.fl=t}K(t,e,i){this.fl.draw(t)}G(t,e,i){var n,r;(r=(n=this.fl).drawBackground)===null||r===void 0||r.call(n,t)}}class Ki{constructor(t){this.Qe=null,this.wn=t}xt(){var t;const e=this.wn.renderer();if(e===null)return null;if(((t=this.Qe)===null||t===void 0?void 0:t.vl)===e)return this.Qe.pl;const i=new tl(e);return this.Qe={vl:e,pl:i},i}ml(){var t,e,i;return(i=(e=(t=this.wn).zOrder)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:"normal"}}function Bn(s){var t,e,i,n,r;return{Jt:s.text(),yi:s.coordinate(),ki:(t=s.fixedCoordinate)===null||t===void 0?void 0:t.call(s),O:s.textColor(),t:s.backColor(),Tt:(i=(e=s.visible)===null||e===void 0?void 0:e.call(s))===null||i===void 0||i,ai:(r=(n=s.tickVisible)===null||n===void 0?void 0:n.call(s))===null||r===void 0||r}}class el{constructor(t,e){this.Ht=new fn,this.bl=t,this.wl=e}xt(){return this.Ht.it(Object.assign({$i:this.wl.$i()},Bn(this.bl))),this.Ht}}class il extends ii{constructor(t,e){super(),this.bl=t,this.Li=e}Ei(t,e,i){const n=Bn(this.bl);i.t=n.t,t.O=n.O;const r=2/12*this.Li.P();i.gi=r,i.Mi=r,i.yi=n.yi,i.ki=n.ki,t.Jt=n.Jt,t.Tt=n.Tt,t.ai=n.ai}}class sl{constructor(t,e){this.gl=null,this.Ml=null,this.xl=null,this.Sl=null,this.kl=null,this.yl=t,this.Wr=e}Cl(){return this.yl}On(){var t,e;(e=(t=this.yl).updateAllViews)===null||e===void 0||e.call(t)}Pn(){var t,e,i,n;const r=(i=(e=(t=this.yl).paneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.gl)===null||n===void 0?void 0:n.vl)===r)return this.gl.pl;const o=r.map((h=>new Ki(h)));return this.gl={vl:r,pl:o},o}tn(){var t,e,i,n;const r=(i=(e=(t=this.yl).timeAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Ml)===null||n===void 0?void 0:n.vl)===r)return this.Ml.pl;const o=this.Wr.qt().yt(),h=r.map((l=>new el(l,o)));return this.Ml={vl:r,pl:h},h}Rn(){var t,e,i,n;const r=(i=(e=(t=this.yl).priceAxisViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.xl)===null||n===void 0?void 0:n.vl)===r)return this.xl.pl;const o=this.Wr.At(),h=r.map((l=>new il(l,o)));return this.xl={vl:r,pl:h},h}Tl(){var t,e,i,n;const r=(i=(e=(t=this.yl).priceAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.Sl)===null||n===void 0?void 0:n.vl)===r)return this.Sl.pl;const o=r.map((h=>new Ki(h)));return this.Sl={vl:r,pl:o},o}Pl(){var t,e,i,n;const r=(i=(e=(t=this.yl).timeAxisPaneViews)===null||e===void 0?void 0:e.call(t))!==null&&i!==void 0?i:[];if(((n=this.kl)===null||n===void 0?void 0:n.vl)===r)return this.kl.pl;const o=r.map((h=>new Ki(h)));return this.kl={vl:r,pl:o},o}Rl(t,e){var i,n,r;return(r=(n=(i=this.yl).autoscaleInfo)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}br(t,e){var i,n,r;return(r=(n=(i=this.yl).hitTest)===null||n===void 0?void 0:n.call(i,t,e))!==null&&r!==void 0?r:null}}function Xi(s,t,e,i){s.forEach((n=>{t(n).forEach((r=>{r.ml()===e&&i.push(r)}))}))}function Yi(s){return s.Pn()}function nl(s){return s.Tl()}function rl(s){return s.Pl()}class Gi extends Yh{constructor(t,e,i,n,r){super(t),this.Lt=new Qh,this.Eh=new $h(this),this.Dl=[],this.Ol=new Nh(this),this.Al=null,this.Vl=null,this.Bl=[],this.Il=[],this.zl=null,this.El=[],this.cn=e,this.Ll=i;const o=new jh(this);this.hn=[o],this.Lh=new xn(o,this,t),i!=="Area"&&i!=="Line"&&i!=="Baseline"||(this.Al=new zh(this)),this.Nl(),this.Fl(r)}S(){this.zl!==null&&clearTimeout(this.zl)}_h(t){return this.cn.priceLineColor||t}Yr(t){const e={Xr:!0},i=this.At();if(this.qt().yt().Fi()||i.Fi()||this.Lt.Fi())return e;const n=this.qt().yt().Xs(),r=this.Pt();if(n===null||r===null)return e;let o,h;if(t){const u=this.Lt.Jh();if(u===null)return e;o=u,h=u.se}else{const u=this.Lt.nl(n.di(),-1);if(u===null||(o=this.Lt.qh(u.se),o===null))return e;h=u.se}const l=o.Vt[3],a=this.$s().Hs(h,{Vt:o}),c=i.Ot(l,r.Vt);return{Xr:!1,ct:l,Jt:i.Wi(l,r.Vt),mh:i.Wl(l),bh:i.jl(l,r.Vt),O:a.ue,yi:c,se:h}}$s(){return this.Vl!==null||(this.Vl=new Zh(this)),this.Vl}W(){return this.cn}Nh(t){const e=t.priceScaleId;e!==void 0&&e!==this.cn.priceScaleId&&this.qt().Hl(this,e),Ht(this.cn,t),t.priceFormat!==void 0&&(this.Nl(),this.qt().$l()),this.qt().Ul(this),this.qt().ql(),this.wn.gt("options")}it(t,e){this.Lt.it(t),this.Yl(),this.wn.gt("data"),this.dn.gt("data"),this.Al!==null&&(e&&e.Xl?this.Al.Hr():t.length===0&&this.Al.jr());const i=this.qt().cr(this);this.qt().Kl(i),this.qt().Ul(this),this.qt().ql(),this.qt().Fh()}Zl(t){this.Bl=t,this.Yl();const e=this.qt().cr(this);this.dn.gt("data"),this.qt().Kl(e),this.qt().Ul(this),this.qt().ql(),this.qt().Fh()}Gl(){return this.Bl}ah(){return this.Il}Jl(t){const e=new Xh(this,t);return this.Dl.push(e),this.qt().Ul(this),e}Ql(t){const e=this.Dl.indexOf(t);e!==-1&&this.Dl.splice(e,1),this.qt().Ul(this)}Xh(){return this.Ll}Pt(){const t=this.ta();return t===null?null:{Vt:t.Vt[3],ia:t.ut}}ta(){const t=this.qt().yt().Xs();if(t===null)return null;const e=t.Os();return this.Lt.nl(e,1)}In(){return this.Lt}oh(t){const e=this.Lt.qh(t);return e===null?null:this.Ll==="Bar"||this.Ll==="Candlestick"||this.Ll==="Custom"?{we:e.Vt[0],ge:e.Vt[1],Me:e.Vt[2],xe:e.Vt[3]}:e.Vt[3]}na(t){const e=[];Xi(this.El,Yi,"top",e);const i=this.Al;return i!==null&&i.Tt()&&(this.zl===null&&i.Ur()&&(this.zl=setTimeout((()=>{this.zl=null,this.qt().sa()}),0)),i.$r(),e.push(i)),e}Pn(){const t=[];this.ea()||t.push(this.Ol),t.push(this.wn,this.Eh,this.dn);const e=this.Dl.map((i=>i.Wh()));return t.push(...e),Xi(this.El,Yi,"normal",t),t}ra(){return this.ha(Yi,"bottom")}la(t){return this.ha(nl,t)}aa(t){return this.ha(rl,t)}oa(t,e){return this.El.map((i=>i.br(t,e))).filter((i=>i!==null))}Qi(t){return[this.Lh,...this.Dl.map((e=>e.jh()))]}Rn(t,e){if(e!==this.Xi&&!this.ea())return[];const i=[...this.hn];for(const n of this.Dl)i.push(n.Hh());return this.El.forEach((n=>{i.push(...n.Rn())})),i}tn(){const t=[];return this.El.forEach((e=>{t.push(...e.tn())})),t}Rl(t,e){if(this.cn.autoscaleInfoProvider!==void 0){const i=this.cn.autoscaleInfoProvider((()=>{const n=this._a(t,e);return n===null?null:n.Ph()}));return hi.Rh(i)}return this._a(t,e)}ua(){return this.cn.priceFormat.minMove}ca(){return this.da}On(){var t;this.wn.gt(),this.dn.gt();for(const e of this.hn)e.gt();for(const e of this.Dl)e.gt();this.Eh.gt(),this.Ol.gt(),(t=this.Al)===null||t===void 0||t.gt(),this.El.forEach((e=>e.On()))}At(){return S(super.At())}Ct(t){if(!((this.Ll==="Line"||this.Ll==="Area"||this.Ll==="Baseline")&&this.cn.crosshairMarkerVisible))return null;const e=this.Lt.qh(t);return e===null?null:{ct:e.Vt[3],ot:this.fa(),Bt:this.va(),Dt:this.pa(),Rt:this.ma(t)}}uh(){return this.cn.title}Tt(){return this.cn.visible}ba(t){this.El.push(new sl(t,this))}wa(t){this.El=this.El.filter((e=>e.Cl()!==t))}ga(){if(this.wn instanceof ji)return t=>this.wn.Fe(t)}Ma(){if(this.wn instanceof ji)return t=>this.wn.We(t)}ea(){return!si(this.At().xa())}_a(t,e){if(!ke(t)||!ke(e)||this.Lt.Fi())return null;const i=this.Ll==="Line"||this.Ll==="Area"||this.Ll==="Baseline"||this.Ll==="Histogram"?[3]:[2,1],n=this.Lt.el(t,e,i);let r=n!==null?new Pt(n.cl,n.dl):null;if(this.Xh()==="Histogram"){const h=this.cn.base,l=new Pt(h,h);r=r!==null?r.ts(l):l}let o=this.dn.lh();return this.El.forEach((h=>{const l=h.Rl(t,e);if(l?.priceRange){const g=new Pt(l.priceRange.minValue,l.priceRange.maxValue);r=r!==null?r.ts(g):g}var a,c,u,p;l?.margins&&(a=o,c=l.margins,o={above:Math.max((u=a?.above)!==null&&u!==void 0?u:0,c.above),below:Math.max((p=a?.below)!==null&&p!==void 0?p:0,c.below)})})),new hi(r,o)}fa(){switch(this.Ll){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerRadius}return 0}va(){switch(this.Ll){case"Line":case"Area":case"Baseline":{const t=this.cn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}pa(){switch(this.Ll){case"Line":case"Area":case"Baseline":return this.cn.crosshairMarkerBorderWidth}return 0}ma(t){switch(this.Ll){case"Line":case"Area":case"Baseline":{const e=this.cn.crosshairMarkerBackgroundColor;if(e.length!==0)return e}}return this.$s().Hs(t).ue}Nl(){switch(this.cn.priceFormat.type){case"custom":this.da={format:this.cn.priceFormat.formatter};break;case"volume":this.da=new fh(this.cn.priceFormat.precision);break;case"percent":this.da=new mn(this.cn.priceFormat.precision);break;default:{const t=Math.pow(10,this.cn.priceFormat.precision);this.da=new ni(t,this.cn.priceFormat.minMove*t)}}this.Xi!==null&&this.Xi.Sa()}Yl(){const t=this.qt().yt();if(!t.ka()||this.Lt.Fi())return void(this.Il=[]);const e=S(this.Lt.Qh());this.Il=this.Bl.map(((i,n)=>{const r=S(t.ya(i.time,!0)),o=r<e?1:-1;return{time:S(this.Lt.nl(r,o)).se,position:i.position,shape:i.shape,color:i.color,id:i.id,Jr:n,text:i.text,size:i.size,originalTime:i.originalTime}}))}Fl(t){switch(this.dn=new Hh(this,this.qt()),this.Ll){case"Bar":this.wn=new Sh(this,this.qt());break;case"Candlestick":this.wn=new Lh(this,this.qt());break;case"Line":this.wn=new kh(this,this.qt());break;case"Custom":this.wn=new ji(this,this.qt(),kt(t));break;case"Area":this.wn=new yh(this,this.qt());break;case"Baseline":this.wn=new Eh(this,this.qt());break;case"Histogram":this.wn=new Oh(this,this.qt());break;default:throw Error("Unknown chart style assigned: "+this.Ll)}}ha(t,e){const i=[];return Xi(this.El,t,e,i),i}}class ol{constructor(t){this.cn=t}Ca(t,e,i){let n=t;if(this.cn.mode===0)return n;const r=i.vn(),o=r.Pt();if(o===null)return n;const h=r.Ot(t,o),l=i.Ta().filter((c=>c instanceof Gi)).reduce(((c,u)=>{if(i.dr(u)||!u.Tt())return c;const p=u.At(),g=u.In();if(p.Fi()||!g.Kr(e))return c;const d=g.qh(e);if(d===null)return c;const f=Se(u.Pt());return c.concat([p.Ot(d.Vt[3],f.Vt)])}),[]);if(l.length===0)return n;l.sort(((c,u)=>Math.abs(c-h)-Math.abs(u-h)));const a=l[0];return n=r.pn(a,o),n}}class hl extends oe{constructor(){super(...arguments),this.Lt=null}it(t){this.Lt=t}Z({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(this.Lt===null)return;const r=Math.max(1,Math.floor(i));t.lineWidth=r,(function(o,h){o.save(),o.lineWidth%2&&o.translate(.5,.5),h(),o.restore()})(t,(()=>{const o=S(this.Lt);if(o.Pa){t.strokeStyle=o.Ra,pe(t,o.Da),t.beginPath();for(const h of o.Oa){const l=Math.round(h.Aa*i);t.moveTo(l,-r),t.lineTo(l,e.height+r)}t.stroke()}if(o.Va){t.strokeStyle=o.Ba,pe(t,o.Ia),t.beginPath();for(const h of o.za){const l=Math.round(h.Aa*n);t.moveTo(-r,l),t.lineTo(e.width+r,l)}t.stroke()}}))}}class ll{constructor(t){this.Ht=new hl,this.bt=!0,this.nn=t}gt(){this.bt=!0}xt(){if(this.bt){const t=this.nn.qt().W().grid,e={Va:t.horzLines.visible,Pa:t.vertLines.visible,Ba:t.horzLines.color,Ra:t.vertLines.color,Ia:t.horzLines.style,Da:t.vertLines.style,za:this.nn.vn().Ea(),Oa:(this.nn.qt().yt().Ea()||[]).map((i=>({Aa:i.coord})))};this.Ht.it(e),this.bt=!1}return this.Ht}}class al{constructor(t){this.wn=new ll(t)}Wh(){return this.wn}}const Zi={La:4,Na:1e-4};function Te(s,t){const e=100*(s-t)/t;return t<0?-e:e}function cl(s,t){const e=Te(s.Sh(),t),i=Te(s.kh(),t);return new Pt(e,i)}function ze(s,t){const e=100*(s-t)/t+100;return t<0?-e:e}function ul(s,t){const e=ze(s.Sh(),t),i=ze(s.kh(),t);return new Pt(e,i)}function ai(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.log10(e+t.Na)+t.La;return s<0?-i:i}function Ue(s,t){const e=Math.abs(s);if(e<1e-15)return 0;const i=Math.pow(10,e-t.La)-t.Na;return s<0?-i:i}function Ve(s,t){if(s===null)return null;const e=ai(s.Sh(),t),i=ai(s.kh(),t);return new Pt(e,i)}function ci(s,t){if(s===null)return null;const e=Ue(s.Sh(),t),i=Ue(s.kh(),t);return new Pt(e,i)}function Qi(s){if(s===null)return Zi;const t=Math.abs(s.kh()-s.Sh());if(t>=1||t<1e-15)return Zi;const e=Math.ceil(Math.abs(Math.log10(t))),i=Zi.La+e;return{La:i,Na:1/Math.pow(10,i)}}class ts{constructor(t,e){if(this.Fa=t,this.Wa=e,(function(i){if(i<0)return!1;for(let n=i;n>1;n/=10)if(n%10!=0)return!1;return!0})(this.Fa))this.ja=[2,2.5,2];else{this.ja=[];for(let i=this.Fa;i!==1;){if(i%2==0)this.ja.push(2),i/=2;else{if(i%5!=0)throw new Error("unexpected base");this.ja.push(2,2.5),i/=5}if(this.ja.length>100)throw new Error("something wrong with base")}}}Ha(t,e,i){const n=this.Fa===0?0:1/this.Fa;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-e)))),o=0,h=this.Wa[0];for(;;){const u=ri(r,n,1e-14)&&r>n+1e-14,p=ri(r,i*h,1e-14),g=ri(r,1,1e-14);if(!(u&&p&&g))break;r/=h,h=this.Wa[++o%this.Wa.length]}if(r<=n+1e-14&&(r=n),r=Math.max(1,r),this.ja.length>0&&(l=r,a=1,c=1e-14,Math.abs(l-a)<c))for(o=0,h=this.ja[0];ri(r,i*h,1e-14)&&r>n+1e-14;)r/=h,h=this.ja[++o%this.ja.length];var l,a,c;return r}}class Fn{constructor(t,e,i,n){this.$a=[],this.Li=t,this.Fa=e,this.Ua=i,this.qa=n}Ha(t,e){if(t<e)throw new Error("high < low");const i=this.Li.zt(),n=(t-e)*this.Ya()/i,r=new ts(this.Fa,[2,2.5,2]),o=new ts(this.Fa,[2,2,2.5]),h=new ts(this.Fa,[2.5,2,2]),l=[];return l.push(r.Ha(t,e,n),o.Ha(t,e,n),h.Ha(t,e,n)),(function(a){if(a.length<1)throw Error("array is empty");let c=a[0];for(let u=1;u<a.length;++u)a[u]<c&&(c=a[u]);return c})(l)}Xa(){const t=this.Li,e=t.Pt();if(e===null)return void(this.$a=[]);const i=t.zt(),n=this.Ua(i-1,e),r=this.Ua(0,e),o=this.Li.W().entireTextOnly?this.Ka()/2:0,h=o,l=i-1-o,a=Math.max(n,r),c=Math.min(n,r);if(a===c)return void(this.$a=[]);let u=this.Ha(a,c),p=a%u;p+=p<0?u:0;const g=a>=c?1:-1;let d=null,f=0;for(let m=a-p;m>c;m-=u){const w=this.qa(m,e,!0);d!==null&&Math.abs(w-d)<this.Ya()||w<h||w>l||(f<this.$a.length?(this.$a[f].Aa=w,this.$a[f].Za=t.Ga(m)):this.$a.push({Aa:w,Za:t.Ga(m)}),f++,d=w,t.Ja()&&(u=this.Ha(m*g,c)))}this.$a.length=f}Ea(){return this.$a}Ka(){return this.Li.P()}Ya(){return Math.ceil(2.5*this.Ka())}}function zn(s){return s.slice().sort(((t,e)=>S(t.Zi())-S(e.Zi())))}var Un;(function(s){s[s.Normal=0]="Normal",s[s.Logarithmic=1]="Logarithmic",s[s.Percentage=2]="Percentage",s[s.IndexedTo100=3]="IndexedTo100"})(Un||(Un={}));const Vn=new mn,Wn=new ni(100,1);class fl{constructor(t,e,i,n){this.Qa=0,this.io=null,this.Dh=null,this.no=null,this.so={eo:!1,ro:null},this.ho=0,this.lo=0,this.ao=new yt,this.oo=new yt,this._o=[],this.uo=null,this.co=null,this.do=null,this.fo=null,this.da=Wn,this.vo=Qi(null),this.po=t,this.cn=e,this.mo=i,this.bo=n,this.wo=new Fn(this,100,this.Mo.bind(this),this.xo.bind(this))}xa(){return this.po}W(){return this.cn}Nh(t){if(Ht(this.cn,t),this.Sa(),t.mode!==void 0&&this.So({yr:t.mode}),t.scaleMargins!==void 0){const e=kt(t.scaleMargins.top),i=kt(t.scaleMargins.bottom);if(e<0||e>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${e}`);if(i<0||i>1||e+i>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${i}`);if(e+i>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${e+i}`);this.ko(),this.co=null}}yo(){return this.cn.autoScale}Ja(){return this.cn.mode===1}ph(){return this.cn.mode===2}Co(){return this.cn.mode===3}yr(){return{Wn:this.cn.autoScale,To:this.cn.invertScale,yr:this.cn.mode}}So(t){const e=this.yr();let i=null;t.Wn!==void 0&&(this.cn.autoScale=t.Wn),t.yr!==void 0&&(this.cn.mode=t.yr,t.yr!==2&&t.yr!==3||(this.cn.autoScale=!0),this.so.eo=!1),e.yr===1&&t.yr!==e.yr&&((function(r,o){if(r===null)return!1;const h=Ue(r.Sh(),o),l=Ue(r.kh(),o);return isFinite(h)&&isFinite(l)})(this.Dh,this.vo)?(i=ci(this.Dh,this.vo),i!==null&&this.Po(i)):this.cn.autoScale=!0),t.yr===1&&t.yr!==e.yr&&(i=Ve(this.Dh,this.vo),i!==null&&this.Po(i));const n=e.yr!==this.cn.mode;n&&(e.yr===2||this.ph())&&this.Sa(),n&&(e.yr===3||this.Co())&&this.Sa(),t.To!==void 0&&e.To!==t.To&&(this.cn.invertScale=t.To,this.Ro()),this.oo.m(e,this.yr())}Do(){return this.oo}P(){return this.mo.fontSize}zt(){return this.Qa}Oo(t){this.Qa!==t&&(this.Qa=t,this.ko(),this.co=null)}Ao(){if(this.io)return this.io;const t=this.zt()-this.Vo()-this.Bo();return this.io=t,t}Ah(){return this.Io(),this.Dh}Po(t,e){const i=this.Dh;(e||i===null&&t!==null||i!==null&&!i.Mh(t))&&(this.co=null,this.Dh=t)}Fi(){return this.Io(),this.Qa===0||!this.Dh||this.Dh.Fi()}zo(t){return this.To()?t:this.zt()-1-t}Ot(t,e){return this.ph()?t=Te(t,e):this.Co()&&(t=ze(t,e)),this.xo(t,e)}Qs(t,e,i){this.Io();const n=this.Bo(),r=S(this.Ah()),o=r.Sh(),h=r.kh(),l=this.Ao()-1,a=this.To(),c=l/(h-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,g=this.Eo();for(let d=u;d<p;d++){const f=t[d],m=f.ct;if(isNaN(m))continue;let w=m;g!==null&&(w=g(f.ct,e));const M=n+c*(w-o),R=a?M:this.Qa-1-M;f.rt=R}}me(t,e,i){this.Io();const n=this.Bo(),r=S(this.Ah()),o=r.Sh(),h=r.kh(),l=this.Ao()-1,a=this.To(),c=l/(h-o),u=i===void 0?0:i.from,p=i===void 0?t.length:i.to,g=this.Eo();for(let d=u;d<p;d++){const f=t[d];let m=f.we,w=f.ge,M=f.Me,R=f.xe;g!==null&&(m=g(f.we,e),w=g(f.ge,e),M=g(f.Me,e),R=g(f.xe,e));let k=n+c*(m-o),$=a?k:this.Qa-1-k;f.ve=$,k=n+c*(w-o),$=a?k:this.Qa-1-k,f.ce=$,k=n+c*(M-o),$=a?k:this.Qa-1-k,f.de=$,k=n+c*(R-o),$=a?k:this.Qa-1-k,f.pe=$}}pn(t,e){const i=this.Mo(t,e);return this.Lo(i,e)}Lo(t,e){let i=t;return this.ph()?i=(function(n,r){return r<0&&(n=-n),n/100*r+r})(i,e):this.Co()&&(i=(function(n,r){return n-=100,r<0&&(n=-n),n/100*r+r})(i,e)),i}Ta(){return this._o}No(){if(this.uo)return this.uo;let t=[];for(let e=0;e<this._o.length;e++){const i=this._o[e];i.Zi()===null&&i.Gi(e+1),t.push(i)}return t=zn(t),this.uo=t,this.uo}Fo(t){this._o.indexOf(t)===-1&&(this._o.push(t),this.Sa(),this.Wo())}jo(t){const e=this._o.indexOf(t);if(e===-1)throw new Error("source is not attached to scale");this._o.splice(e,1),this._o.length===0&&(this.So({Wn:!0}),this.Po(null)),this.Sa(),this.Wo()}Pt(){let t=null;for(const e of this._o){const i=e.Pt();i!==null&&(t===null||i.ia<t.ia)&&(t=i)}return t===null?null:t.Vt}To(){return this.cn.invertScale}Ea(){const t=this.Pt()===null;if(this.co!==null&&(t||this.co.Ho===t))return this.co.Ea;this.wo.Xa();const e=this.wo.Ea();return this.co={Ea:e,Ho:t},this.ao.m(),e}$o(){return this.ao}Uo(t){this.ph()||this.Co()||this.do===null&&this.no===null&&(this.Fi()||(this.do=this.Qa-t,this.no=S(this.Ah()).xh()))}qo(t){if(this.ph()||this.Co()||this.do===null)return;this.So({Wn:!1}),(t=this.Qa-t)<0&&(t=0);let e=(this.do+.2*(this.Qa-1))/(t+.2*(this.Qa-1));const i=S(this.no).xh();e=Math.max(e,.1),i.Ch(e),this.Po(i)}Yo(){this.ph()||this.Co()||(this.do=null,this.no=null)}Xo(t){this.yo()||this.fo===null&&this.no===null&&(this.Fi()||(this.fo=t,this.no=S(this.Ah()).xh()))}Ko(t){if(this.yo()||this.fo===null)return;const e=S(this.Ah()).yh()/(this.Ao()-1);let i=t-this.fo;this.To()&&(i*=-1);const n=i*e,r=S(this.no).xh();r.Th(n),this.Po(r,!0),this.co=null}Zo(){this.yo()||this.fo!==null&&(this.fo=null,this.no=null)}ca(){return this.da||this.Sa(),this.da}Wi(t,e){switch(this.cn.mode){case 2:return this.Go(Te(t,e));case 3:return this.ca().format(ze(t,e));default:return this.zh(t)}}Ga(t){switch(this.cn.mode){case 2:return this.Go(t);case 3:return this.ca().format(t);default:return this.zh(t)}}Wl(t){return this.zh(t,S(this.Jo()).ca())}jl(t,e){return t=Te(t,e),this.Go(t,Vn)}Qo(){return this._o}t_(t){this.so={ro:t,eo:!1}}On(){this._o.forEach((t=>t.On()))}Sa(){this.co=null;const t=this.Jo();let e=100;t!==null&&(e=Math.round(1/t.ua())),this.da=Wn,this.ph()?(this.da=Vn,e=100):this.Co()?(this.da=new ni(100,1),e=100):t!==null&&(this.da=t.ca()),this.wo=new Fn(this,e,this.Mo.bind(this),this.xo.bind(this)),this.wo.Xa()}Wo(){this.uo=null}Jo(){return this._o[0]||null}Vo(){return this.To()?this.cn.scaleMargins.bottom*this.zt()+this.lo:this.cn.scaleMargins.top*this.zt()+this.ho}Bo(){return this.To()?this.cn.scaleMargins.top*this.zt()+this.ho:this.cn.scaleMargins.bottom*this.zt()+this.lo}Io(){this.so.eo||(this.so.eo=!0,this.i_())}ko(){this.io=null}xo(t,e){if(this.Io(),this.Fi())return 0;t=this.Ja()&&t?ai(t,this.vo):t;const i=S(this.Ah()),n=this.Bo()+(this.Ao()-1)*(t-i.Sh())/i.yh();return this.zo(n)}Mo(t,e){if(this.Io(),this.Fi())return 0;const i=this.zo(t),n=S(this.Ah()),r=n.Sh()+n.yh()*((i-this.Bo())/(this.Ao()-1));return this.Ja()?Ue(r,this.vo):r}Ro(){this.co=null,this.wo.Xa()}i_(){const t=this.so.ro;if(t===null)return;let e=null;const i=this.Qo();let n=0,r=0;for(const l of i){if(!l.Tt())continue;const a=l.Pt();if(a===null)continue;const c=l.Rl(t.Os(),t.di());let u=c&&c.Ah();if(u!==null){switch(this.cn.mode){case 1:u=Ve(u,this.vo);break;case 2:u=cl(u,a.Vt);break;case 3:u=ul(u,a.Vt)}if(e=e===null?u:e.ts(S(u)),c!==null){const p=c.Vh();p!==null&&(n=Math.max(n,p.above),r=Math.max(n,p.below))}}}if(n===this.ho&&r===this.lo||(this.ho=n,this.lo=r,this.co=null,this.ko()),e!==null){if(e.Sh()===e.kh()){const l=this.Jo(),a=5*(l===null||this.ph()||this.Co()?1:l.ua());this.Ja()&&(e=ci(e,this.vo)),e=new Pt(e.Sh()-a,e.kh()+a),this.Ja()&&(e=Ve(e,this.vo))}if(this.Ja()){const l=ci(e,this.vo),a=Qi(l);if(o=a,h=this.vo,o.La!==h.La||o.Na!==h.Na){const c=this.no!==null?ci(this.no,this.vo):null;this.vo=a,e=Ve(l,a),c!==null&&(this.no=Ve(c,a))}}this.Po(e)}else this.Dh===null&&(this.Po(new Pt(-.5,.5)),this.vo=Qi(null));var o,h;this.so.eo=!0}Eo(){return this.ph()?Te:this.Co()?ze:this.Ja()?t=>ai(t,this.vo):null}n_(t,e,i){return e===void 0?(i===void 0&&(i=this.ca()),i.format(t)):e(t)}zh(t,e){return this.n_(t,this.bo.priceFormatter,e)}Go(t,e){return this.n_(t,this.bo.percentageFormatter,e)}}class dl{constructor(t,e){this._o=[],this.s_=new Map,this.Qa=0,this.e_=0,this.r_=1e3,this.uo=null,this.h_=new yt,this.wl=t,this.Ui=e,this.l_=new al(this);const i=e.W();this.a_=this.o_("left",i.leftPriceScale),this.__=this.o_("right",i.rightPriceScale),this.a_.Do().l(this.u_.bind(this,this.a_),this),this.__.Do().l(this.u_.bind(this,this.__),this),this.c_(i)}c_(t){if(t.leftPriceScale&&this.a_.Nh(t.leftPriceScale),t.rightPriceScale&&this.__.Nh(t.rightPriceScale),t.localization&&(this.a_.Sa(),this.__.Sa()),t.overlayPriceScales){const e=Array.from(this.s_.values());for(const i of e){const n=S(i[0].At());n.Nh(t.overlayPriceScales),t.localization&&n.Sa()}}}d_(t){switch(t){case"left":return this.a_;case"right":return this.__}return this.s_.has(t)?kt(this.s_.get(t))[0].At():null}S(){this.qt().f_().p(this),this.a_.Do().p(this),this.__.Do().p(this),this._o.forEach((t=>{t.S&&t.S()})),this.h_.m()}v_(){return this.r_}p_(t){this.r_=t}qt(){return this.Ui}$i(){return this.e_}zt(){return this.Qa}m_(t){this.e_=t,this.b_()}Oo(t){this.Qa=t,this.a_.Oo(t),this.__.Oo(t),this._o.forEach((e=>{if(this.dr(e)){const i=e.At();i!==null&&i.Oo(t)}})),this.b_()}Ta(){return this._o}dr(t){const e=t.At();return e===null||this.a_!==e&&this.__!==e}Fo(t,e,i){const n=i!==void 0?i:this.g_().w_+1;this.M_(t,e,n)}jo(t){const e=this._o.indexOf(t);le(e!==-1,"removeDataSource: invalid data source"),this._o.splice(e,1);const i=S(t.At()).xa();if(this.s_.has(i)){const r=kt(this.s_.get(i)),o=r.indexOf(t);o!==-1&&(r.splice(o,1),r.length===0&&this.s_.delete(i))}const n=t.At();n&&n.Ta().indexOf(t)>=0&&n.jo(t),n!==null&&(n.Wo(),this.x_(n)),this.uo=null}pr(t){return t===this.a_?"left":t===this.__?"right":"overlay"}S_(){return this.a_}k_(){return this.__}y_(t,e){t.Uo(e)}C_(t,e){t.qo(e),this.b_()}T_(t){t.Yo()}P_(t,e){t.Xo(e)}R_(t,e){t.Ko(e),this.b_()}D_(t){t.Zo()}b_(){this._o.forEach((t=>{t.On()}))}vn(){let t=null;return this.Ui.W().rightPriceScale.visible&&this.__.Ta().length!==0?t=this.__:this.Ui.W().leftPriceScale.visible&&this.a_.Ta().length!==0?t=this.a_:this._o.length!==0&&(t=this._o[0].At()),t===null&&(t=this.__),t}vr(){let t=null;return this.Ui.W().rightPriceScale.visible?t=this.__:this.Ui.W().leftPriceScale.visible&&(t=this.a_),t}x_(t){t!==null&&t.yo()&&this.O_(t)}A_(t){const e=this.wl.Xs();t.So({Wn:!0}),e!==null&&t.t_(e),this.b_()}V_(){this.O_(this.a_),this.O_(this.__)}B_(){this.x_(this.a_),this.x_(this.__),this._o.forEach((t=>{this.dr(t)&&this.x_(t.At())})),this.b_(),this.Ui.Fh()}No(){return this.uo===null&&(this.uo=zn(this._o)),this.uo}I_(){return this.h_}z_(){return this.l_}O_(t){const e=t.Qo();if(e&&e.length>0&&!this.wl.Fi()){const i=this.wl.Xs();i!==null&&t.t_(i)}t.On()}g_(){const t=this.No();if(t.length===0)return{E_:0,w_:0};let e=0,i=0;for(let n=0;n<t.length;n++){const r=t[n].Zi();r!==null&&(r<e&&(e=r),r>i&&(i=r))}return{E_:e,w_:i}}M_(t,e,i){let n=this.d_(e);if(n===null&&(n=this.o_(e,this.Ui.W().overlayPriceScales)),this._o.push(t),!si(e)){const r=this.s_.get(e)||[];r.push(t),this.s_.set(e,r)}n.Fo(t),t.Ji(n),t.Gi(i),this.x_(n),this.uo=null}u_(t,e,i){e.yr!==i.yr&&this.O_(t)}o_(t,e){const i=Object.assign({visible:!0,autoScale:!0},re(e)),n=new fl(t,i,this.Ui.W().layout,this.Ui.W().localization);return n.Oo(this.zt()),n}}class pl{constructor(t,e,i=50){this.Ke=0,this.Ze=1,this.Ge=1,this.Qe=new Map,this.Je=new Map,this.L_=t,this.N_=e,this.tr=i}F_(t){const e=t.time,i=this.N_.cacheKey(e),n=this.Qe.get(i);if(n!==void 0)return n.W_;if(this.Ke===this.tr){const o=this.Je.get(this.Ge);this.Je.delete(this.Ge),this.Qe.delete(kt(o)),this.Ge++,this.Ke--}const r=this.L_(t);return this.Qe.set(i,{W_:r,er:this.Ze}),this.Je.set(this.Ze,i),this.Ke++,this.Ze++,r}}class We{constructor(t,e){le(t<=e,"right should be >= left"),this.j_=t,this.H_=e}Os(){return this.j_}di(){return this.H_}U_(){return this.H_-this.j_+1}Kr(t){return this.j_<=t&&t<=this.H_}Mh(t){return this.j_===t.Os()&&this.H_===t.di()}}function In(s,t){return s===null||t===null?s===t:s.Mh(t)}class ml{constructor(){this.q_=new Map,this.Qe=null,this.Y_=!1}X_(t){this.Y_=t,this.Qe=null}K_(t,e){this.Z_(e),this.Qe=null;for(let i=e;i<t.length;++i){const n=t[i];let r=this.q_.get(n.timeWeight);r===void 0&&(r=[],this.q_.set(n.timeWeight,r)),r.push({index:i,time:n.time,weight:n.timeWeight,originalTime:n.originalTime})}}G_(t,e){const i=Math.ceil(e/t);return this.Qe!==null&&this.Qe.J_===i||(this.Qe={Ea:this.Q_(i),J_:i}),this.Qe.Ea}Z_(t){if(t===0)return void this.q_.clear();const e=[];this.q_.forEach(((i,n)=>{t<=i[0].index?e.push(n):i.splice(De(i,t,(r=>r.index<t)),1/0)}));for(const i of e)this.q_.delete(i)}Q_(t){let e=[];for(const i of Array.from(this.q_.keys()).sort(((n,r)=>r-n))){if(!this.q_.get(i))continue;const n=e;e=[];const r=n.length;let o=0;const h=kt(this.q_.get(i)),l=h.length;let a=1/0,c=-1/0;for(let u=0;u<l;u++){const p=h[u],g=p.index;for(;o<r;){const d=n[o],f=d.index;if(!(f<g)){a=f;break}o++,e.push(d),c=f,a=1/0}if(a-g>=t&&g-c>=t)e.push(p),c=g;else if(this.Y_)return n}for(;o<r;o++)e.push(n[o])}return e}}class Ee{constructor(t){this.tu=t}iu(){return this.tu===null?null:new We(Math.floor(this.tu.Os()),Math.ceil(this.tu.di()))}nu(){return this.tu}static su(){return new Ee(null)}}function gl(s,t){return s.weight>t.weight?s:t}class bl{constructor(t,e,i,n){this.e_=0,this.eu=null,this.ru=[],this.fo=null,this.do=null,this.hu=new ml,this.lu=new Map,this.au=Ee.su(),this.ou=!0,this._u=new yt,this.uu=new yt,this.cu=new yt,this.du=null,this.fu=null,this.vu=[],this.cn=e,this.bo=i,this.pu=e.rightOffset,this.mu=e.barSpacing,this.Ui=t,this.N_=n,this.bu(),this.hu.X_(e.uniformDistribution)}W(){return this.cn}wu(t){Ht(this.bo,t),this.gu(),this.bu()}Nh(t,e){var i;Ht(this.cn,t),this.cn.fixLeftEdge&&this.Mu(),this.cn.fixRightEdge&&this.xu(),t.barSpacing!==void 0&&this.Ui.Gn(t.barSpacing),t.rightOffset!==void 0&&this.Ui.Jn(t.rightOffset),t.minBarSpacing!==void 0&&this.Ui.Gn((i=t.barSpacing)!==null&&i!==void 0?i:this.mu),this.gu(),this.bu(),this.cu.m()}mn(t){var e,i;return(i=(e=this.ru[t])===null||e===void 0?void 0:e.time)!==null&&i!==void 0?i:null}qi(t){var e;return(e=this.ru[t])!==null&&e!==void 0?e:null}ya(t,e){if(this.ru.length<1)return null;if(this.N_.key(t)>this.N_.key(this.ru[this.ru.length-1].time))return e?this.ru.length-1:null;const i=De(this.ru,this.N_.key(t),((n,r)=>this.N_.key(n.time)<r));return this.N_.key(t)<this.N_.key(this.ru[i].time)?e?i:null:i}Fi(){return this.e_===0||this.ru.length===0||this.eu===null}ka(){return this.ru.length>0}Xs(){return this.Su(),this.au.iu()}ku(){return this.Su(),this.au.nu()}yu(){const t=this.Xs();if(t===null)return null;const e={from:t.Os(),to:t.di()};return this.Cu(e)}Cu(t){const e=Math.round(t.from),i=Math.round(t.to),n=S(this.Tu()),r=S(this.Bn());return{from:S(this.qi(Math.max(n,e))),to:S(this.qi(Math.min(r,i)))}}Pu(t){return{from:S(this.ya(t.from,!0)),to:S(this.ya(t.to,!0))}}$i(){return this.e_}m_(t){if(!isFinite(t)||t<=0||this.e_===t)return;const e=this.ku(),i=this.e_;if(this.e_=t,this.ou=!0,this.cn.lockVisibleTimeRangeOnResize&&i!==0){const n=this.mu*t/i;this.mu=n}if(this.cn.fixLeftEdge&&e!==null&&e.Os()<=0){const n=i-t;this.pu-=Math.round(n/this.mu)+1,this.ou=!0}this.Ru(),this.Du()}Et(t){if(this.Fi()||!ke(t))return 0;const e=this.Ou()+this.pu-t;return this.e_-(e+.5)*this.mu-1}Js(t,e){const i=this.Ou(),n=e===void 0?0:e.from,r=e===void 0?t.length:e.to;for(let o=n;o<r;o++){const h=t[o].ut,l=i+this.pu-h,a=this.e_-(l+.5)*this.mu-1;t[o].et=a}}Au(t){return Math.ceil(this.Vu(t))}Jn(t){this.ou=!0,this.pu=t,this.Du(),this.Ui.Bu(),this.Ui.Fh()}he(){return this.mu}Gn(t){this.Iu(t),this.Du(),this.Ui.Bu(),this.Ui.Fh()}zu(){return this.pu}Ea(){if(this.Fi())return null;if(this.fu!==null)return this.fu;const t=this.mu,e=5*(this.Ui.W().layout.fontSize+4)/8*(this.cn.tickMarkMaxCharacterLength||8),i=Math.round(e/t),n=S(this.Xs()),r=Math.max(n.Os(),n.Os()-i),o=Math.max(n.di(),n.di()-i),h=this.hu.G_(t,e),l=this.Tu()+i,a=this.Bn()-i,c=this.Eu(),u=this.cn.fixLeftEdge||c,p=this.cn.fixRightEdge||c;let g=0;for(const d of h){if(!(r<=d.index&&d.index<=o))continue;let f;g<this.vu.length?(f=this.vu[g],f.coord=this.Et(d.index),f.label=this.Lu(d),f.weight=d.weight):(f={needAlignCoordinate:!1,coord:this.Et(d.index),label:this.Lu(d),weight:d.weight},this.vu.push(f)),this.mu>e/2&&!c?f.needAlignCoordinate=!1:f.needAlignCoordinate=u&&d.index<=l||p&&d.index>=a,g++}return this.vu.length=g,this.fu=this.vu,this.vu}Nu(){this.ou=!0,this.Gn(this.cn.barSpacing),this.Jn(this.cn.rightOffset)}Fu(t){this.ou=!0,this.eu=t,this.Du(),this.Mu()}Wu(t,e){const i=this.Vu(t),n=this.he(),r=n+e*(n/10);this.Gn(r),this.cn.rightBarStaysOnScroll||this.Jn(this.zu()+(i-this.Vu(t)))}Uo(t){this.fo&&this.Zo(),this.do===null&&this.du===null&&(this.Fi()||(this.do=t,this.ju()))}qo(t){if(this.du===null)return;const e=qi(this.e_-t,0,this.e_),i=qi(this.e_-S(this.do),0,this.e_);e!==0&&i!==0&&this.Gn(this.du.he*e/i)}Yo(){this.do!==null&&(this.do=null,this.Hu())}Xo(t){this.fo===null&&this.du===null&&(this.Fi()||(this.fo=t,this.ju()))}Ko(t){if(this.fo===null)return;const e=(this.fo-t)/this.he();this.pu=S(this.du).zu+e,this.ou=!0,this.Du()}Zo(){this.fo!==null&&(this.fo=null,this.Hu())}$u(){this.Uu(this.cn.rightOffset)}Uu(t,e=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(e)||e<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const i=this.pu,n=performance.now();this.Ui.Xn({qu:r=>(r-n)/e>=1,Yu:r=>{const o=(r-n)/e;return o>=1?t:i+(t-i)*o}})}gt(t,e){this.ou=!0,this.ru=t,this.hu.K_(t,e),this.Du()}Xu(){return this._u}Ku(){return this.uu}Zu(){return this.cu}Ou(){return this.eu||0}Gu(t){const e=t.U_();this.Iu(this.e_/e),this.pu=t.di()-this.Ou(),this.Du(),this.ou=!0,this.Ui.Bu(),this.Ui.Fh()}Ju(){const t=this.Tu(),e=this.Bn();t!==null&&e!==null&&this.Gu(new We(t,e+this.cn.rightOffset))}Qu(t){const e=new We(t.from,t.to);this.Gu(e)}Yi(t){return this.bo.timeFormatter!==void 0?this.bo.timeFormatter(t.originalTime):this.N_.formatHorzItem(t.time)}Bn(){return this.ru.length===0?null:this.ru.length-1}Eu(){const{handleScroll:t,handleScale:e}=this.Ui.W();return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||e.axisDoubleClickReset.time||e.axisPressedMouseMove.time||e.mouseWheel||e.pinch)}Tu(){return this.ru.length===0?null:0}tc(t){return(this.e_-1-t)/this.mu}Vu(t){const e=this.tc(t),i=this.Ou()+this.pu-e;return Math.round(1e6*i)/1e6}Iu(t){const e=this.mu;this.mu=t,this.Ru(),e!==this.mu&&(this.ou=!0,this.ic())}Su(){if(!this.ou)return;if(this.ou=!1,this.Fi())return void this.nc(Ee.su());const t=this.Ou(),e=this.e_/this.mu,i=this.pu+t,n=new We(i-e+1,i);this.nc(new Ee(n))}Ru(){const t=this.sc();if(this.mu<t&&(this.mu=t,this.ou=!0),this.e_!==0){const e=.5*this.e_;this.mu>e&&(this.mu=e,this.ou=!0)}}sc(){return this.cn.fixLeftEdge&&this.cn.fixRightEdge&&this.ru.length!==0?this.e_/this.ru.length:this.cn.minBarSpacing}Du(){const t=this.ec();this.pu>t&&(this.pu=t,this.ou=!0);const e=this.rc();e!==null&&this.pu<e&&(this.pu=e,this.ou=!0)}rc(){const t=this.Tu(),e=this.eu;return t===null||e===null?null:t-e-1+(this.cn.fixLeftEdge?this.e_/this.mu:Math.min(2,this.ru.length))}ec(){return this.cn.fixRightEdge?0:this.e_/this.mu-Math.min(2,this.ru.length)}ju(){this.du={he:this.he(),zu:this.zu()}}Hu(){this.du=null}Lu(t){let e=this.lu.get(t.weight);return e===void 0&&(e=new pl((i=>this.hc(i)),this.N_),this.lu.set(t.weight,e)),e.F_(t)}hc(t){return this.N_.formatTickmark(t,this.bo)}nc(t){const e=this.au;this.au=t,In(e.iu(),this.au.iu())||this._u.m(),In(e.nu(),this.au.nu())||this.uu.m(),this.ic()}ic(){this.fu=null}gu(){this.ic(),this.lu.clear()}bu(){this.N_.updateFormatter(this.bo)}Mu(){if(!this.cn.fixLeftEdge)return;const t=this.Tu();if(t===null)return;const e=this.Xs();if(e===null)return;const i=e.Os()-t;if(i<0){const n=this.pu-i-1;this.Jn(n)}this.Ru()}xu(){this.Du(),this.Ru()}}class vl extends Ui{constructor(t){super(),this.lc=new Map,this.Lt=t}Z(t){}J(t){if(!this.Lt.Tt)return;const{context:e,mediaSize:i}=t;let n=0;for(const o of this.Lt.ac){if(o.Jt.length===0)continue;e.font=o.R;const h=this.oc(e,o.Jt);h>i.width?o.Wu=i.width/h:o.Wu=1,n+=o._c*o.Wu}let r=0;switch(this.Lt.uc){case"top":r=0;break;case"center":r=Math.max((i.height-n)/2,0);break;case"bottom":r=Math.max(i.height-n,0)}e.fillStyle=this.Lt.O;for(const o of this.Lt.ac){e.save();let h=0;switch(this.Lt.cc){case"left":e.textAlign="left",h=o._c/2;break;case"center":e.textAlign="center",h=i.width/2;break;case"right":e.textAlign="right",h=i.width-1-o._c/2}e.translate(h,r),e.textBaseline="top",e.font=o.R,e.scale(o.Wu,o.Wu),e.fillText(o.Jt,0,o.dc),e.restore(),r+=o._c*o.Wu}}oc(t,e){const i=this.fc(t.font);let n=i.get(e);return n===void 0&&(n=t.measureText(e).width,i.set(e,n)),n}fc(t){let e=this.lc.get(t);return e===void 0&&(e=new Map,this.lc.set(t,e)),e}}class yl{constructor(t){this.bt=!0,this.jt={Tt:!1,O:"",ac:[],uc:"center",cc:"center"},this.Ht=new vl(this.jt),this.$t=t}gt(){this.bt=!0}xt(){return this.bt&&(this.St(),this.bt=!1),this.Ht}St(){const t=this.$t.W(),e=this.jt;e.Tt=t.visible,e.Tt&&(e.O=t.color,e.cc=t.horzAlign,e.uc=t.vertAlign,e.ac=[{Jt:t.text,R:_e(t.fontSize,t.fontFamily,t.fontStyle),_c:1.2*t.fontSize,dc:0,Wu:0}])}}class wl extends Wi{constructor(t,e){super(),this.cn=e,this.wn=new yl(this)}Rn(){return[]}Pn(){return[this.wn]}W(){return this.cn}On(){this.wn.gt()}}var qn,Hn,$n,jn,Jn;(function(s){s[s.OnTouchEnd=0]="OnTouchEnd",s[s.OnNextTap=1]="OnNextTap"})(qn||(qn={}));class Sl{constructor(t,e,i){this.vc=[],this.mc=[],this.e_=0,this.bc=null,this.wc=new yt,this.gc=new yt,this.Mc=null,this.xc=t,this.cn=e,this.N_=i,this.Sc=new th(this),this.wl=new bl(this,e.timeScale,this.cn.localization,i),this.wt=new uh(this,e.crosshair),this.kc=new ol(e.crosshair),this.yc=new wl(this,e.watermark),this.Cc(),this.vc[0].p_(2e3),this.Tc=this.Pc(0),this.Rc=this.Pc(1)}$l(){this.Dc(Ct.es())}Fh(){this.Dc(Ct.ss())}sa(){this.Dc(new Ct(1))}Ul(t){const e=this.Oc(t);this.Dc(e)}Ac(){return this.bc}Vc(t){const e=this.bc;this.bc=t,e!==null&&this.Ul(e.Bc),t!==null&&this.Ul(t.Bc)}W(){return this.cn}Nh(t){Ht(this.cn,t),this.vc.forEach((e=>e.c_(t))),t.timeScale!==void 0&&this.wl.Nh(t.timeScale),t.localization!==void 0&&this.wl.wu(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.wc.m(),this.Tc=this.Pc(0),this.Rc=this.Pc(1),this.$l()}Ic(t,e){if(t==="left")return void this.Nh({leftPriceScale:e});if(t==="right")return void this.Nh({rightPriceScale:e});const i=this.zc(t);i!==null&&(i.At.Nh(e),this.wc.m())}zc(t){for(const e of this.vc){const i=e.d_(t);if(i!==null)return{Ut:e,At:i}}return null}yt(){return this.wl}Ec(){return this.vc}Lc(){return this.yc}Nc(){return this.wt}Fc(){return this.gc}Wc(t,e){t.Oo(e),this.Bu()}m_(t){this.e_=t,this.wl.m_(this.e_),this.vc.forEach((e=>e.m_(t))),this.Bu()}Cc(t){const e=new dl(this.wl,this);t!==void 0?this.vc.splice(t,0,e):this.vc.push(e);const i=t===void 0?this.vc.length-1:t,n=Ct.es();return n.Nn(i,{Fn:0,Wn:!0}),this.Dc(n),e}y_(t,e,i){t.y_(e,i)}C_(t,e,i){t.C_(e,i),this.ql(),this.Dc(this.jc(t,2))}T_(t,e){t.T_(e),this.Dc(this.jc(t,2))}P_(t,e,i){e.yo()||t.P_(e,i)}R_(t,e,i){e.yo()||(t.R_(e,i),this.ql(),this.Dc(this.jc(t,2)))}D_(t,e){e.yo()||(t.D_(e),this.Dc(this.jc(t,2)))}A_(t,e){t.A_(e),this.Dc(this.jc(t,2))}Hc(t){this.wl.Uo(t)}$c(t,e){const i=this.yt();if(i.Fi()||e===0)return;const n=i.$i();t=Math.max(1,Math.min(t,n)),i.Wu(t,e),this.Bu()}Uc(t){this.qc(0),this.Yc(t),this.Xc()}Kc(t){this.wl.qo(t),this.Bu()}Zc(){this.wl.Yo(),this.Fh()}qc(t){this.wl.Xo(t)}Yc(t){this.wl.Ko(t),this.Bu()}Xc(){this.wl.Zo(),this.Fh()}Mt(){return this.mc}Gc(t,e,i,n,r){this.wt.gn(t,e);let o=NaN,h=this.wl.Au(t);const l=this.wl.Xs();l!==null&&(h=Math.min(Math.max(l.Os(),h),l.di()));const a=n.vn(),c=a.Pt();c!==null&&(o=a.pn(e,c)),o=this.kc.Ca(o,h,n),this.wt.kn(h,o,n),this.sa(),r||this.gc.m(this.wt.kt(),{x:t,y:e},i)}Jc(t,e,i){const n=i.vn(),r=n.Pt(),o=n.Ot(t,S(r)),h=this.wl.ya(e,!0),l=this.wl.Et(S(h));this.Gc(l,o,null,i,!0)}Qc(t){this.Nc().Cn(),this.sa(),t||this.gc.m(null,null,null)}ql(){const t=this.wt.Ut();if(t!==null){const e=this.wt.xn(),i=this.wt.Sn();this.Gc(e,i,null,t)}this.wt.On()}td(t,e,i){const n=this.wl.mn(0),r=this.wl.Bn();e!==void 0&&i!==void 0&&this.wl.gt(e,i);const o=this.wl.mn(0),h=this.wl.Ou(),l=this.wl.Xs();if(l!==null&&n!==null&&o!==null){const a=l.Kr(h),c=this.N_.key(n)>this.N_.key(o),u=t!==null&&t>h&&!c,p=this.wl.Bn(),g=a&&p!==r&&this.wl.W().shiftVisibleRangeOnNewBar;if(u&&!g){const d=t-h;this.wl.Jn(this.wl.zu()-d)}}this.wl.Fu(t)}Kl(t){t!==null&&t.B_()}cr(t){const e=this.vc.find((i=>i.No().includes(t)));return e===void 0?null:e}Bu(){this.yc.On(),this.vc.forEach((t=>t.B_())),this.ql()}S(){this.vc.forEach((t=>t.S())),this.vc.length=0,this.cn.localization.priceFormatter=void 0,this.cn.localization.percentageFormatter=void 0,this.cn.localization.timeFormatter=void 0}nd(){return this.Sc}mr(){return this.Sc.W()}f_(){return this.wc}sd(t,e,i){const n=this.vc[0],r=this.ed(e,t,n,i);return this.mc.push(r),this.mc.length===1?this.$l():this.Fh(),r}rd(t){const e=this.cr(t),i=this.mc.indexOf(t);le(i!==-1,"Series not found"),this.mc.splice(i,1),S(e).jo(t),t.S&&t.S()}Hl(t,e){const i=S(this.cr(t));i.jo(t);const n=this.zc(e);if(n===null){const r=t.Zi();i.Fo(t,e,r)}else{const r=n.Ut===i?t.Zi():void 0;n.Ut.Fo(t,e,r)}}Ju(){const t=Ct.ss();t.$n(),this.Dc(t)}hd(t){const e=Ct.ss();e.Yn(t),this.Dc(e)}Zn(){const t=Ct.ss();t.Zn(),this.Dc(t)}Gn(t){const e=Ct.ss();e.Gn(t),this.Dc(e)}Jn(t){const e=Ct.ss();e.Jn(t),this.Dc(e)}Xn(t){const e=Ct.ss();e.Xn(t),this.Dc(e)}Un(){const t=Ct.ss();t.Un(),this.Dc(t)}ld(){return this.cn.rightPriceScale.visible?"right":"left"}ad(){return this.Rc}q(){return this.Tc}It(t){const e=this.Rc,i=this.Tc;if(e===i)return e;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Mc===null||this.Mc.Ts!==i||this.Mc.Ps!==e)this.Mc={Ts:i,Ps:e,od:new Map};else{const r=this.Mc.od.get(t);if(r!==void 0)return r}const n=(function(r,o,h){const[l,a,c,u]=Ze(r),[p,g,d,f]=Ze(o),m=[zt(l+h*(p-l)),zt(a+h*(g-a)),zt(c+h*(d-c)),hn(u+h*(f-u))];return`rgba(${m[0]}, ${m[1]}, ${m[2]}, ${m[3]})`})(i,e,t/100);return this.Mc.od.set(t,n),n}jc(t,e){const i=new Ct(e);if(t!==null){const n=this.vc.indexOf(t);i.Nn(n,{Fn:e})}return i}Oc(t,e){return e===void 0&&(e=2),this.jc(this.cr(t),e)}Dc(t){this.xc&&this.xc(t),this.vc.forEach((e=>e.z_().Wh().gt()))}ed(t,e,i,n){const r=new Gi(this,t,e,i,n),o=t.priceScaleId!==void 0?t.priceScaleId:this.ld();return i.Fo(r,o),si(o)||r.Nh(t),r}Pc(t){const e=this.cn.layout;return e.background.type==="gradient"?t===0?e.background.topColor:e.background.bottomColor:e.background.color}}function es(s){return!Kt(s)&&!Pe(s)}function Kn(s){return Kt(s)}(function(s){s[s.Disabled=0]="Disabled",s[s.Continuous=1]="Continuous",s[s.OnDataUpdate=2]="OnDataUpdate"})(Hn||(Hn={})),(function(s){s[s.LastBar=0]="LastBar",s[s.LastVisible=1]="LastVisible"})($n||($n={})),(function(s){s.Solid="solid",s.VerticalGradient="gradient"})(jn||(jn={})),(function(s){s[s.Year=0]="Year",s[s.Month=1]="Month",s[s.DayOfMonth=2]="DayOfMonth",s[s.Time=3]="Time",s[s.TimeWithSeconds=4]="TimeWithSeconds"})(Jn||(Jn={}));const Xn=s=>s.getUTCFullYear();function _l(s,t,e){return t.replace(/yyyy/g,(i=>he(Xn(i),4))(s)).replace(/yy/g,(i=>he(Xn(i)%100,2))(s)).replace(/MMMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"long"}))(s,e)).replace(/MMM/g,((i,n)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(n,{month:"short"}))(s,e)).replace(/MM/g,(i=>he((n=>n.getUTCMonth()+1)(i),2))(s)).replace(/dd/g,(i=>he((n=>n.getUTCDate())(i),2))(s))}class Yn{constructor(t="yyyy-MM-dd",e="default"){this._d=t,this.ud=e}F_(t){return _l(t,this._d,this.ud)}}class Tl{constructor(t){this.dd=t||"%h:%m:%s"}F_(t){return this.dd.replace("%h",he(t.getUTCHours(),2)).replace("%m",he(t.getUTCMinutes(),2)).replace("%s",he(t.getUTCSeconds(),2))}}const El={fd:"yyyy-MM-dd",vd:"%h:%m:%s",pd:" ",md:"default"};class Cl{constructor(t={}){const e=Object.assign(Object.assign({},El),t);this.bd=new Yn(e.fd,e.md),this.wd=new Tl(e.vd),this.gd=e.pd}F_(t){return`${this.bd.F_(t)}${this.gd}${this.wd.F_(t)}`}}function ui(s){return 60*s*60*1e3}function is(s){return 60*s*1e3}const fi=[{Md:(Gn=1,1e3*Gn),xd:10},{Md:is(1),xd:20},{Md:is(5),xd:21},{Md:is(30),xd:22},{Md:ui(1),xd:30},{Md:ui(3),xd:31},{Md:ui(6),xd:32},{Md:ui(12),xd:33}];var Gn;function Zn(s,t){if(s.getUTCFullYear()!==t.getUTCFullYear())return 70;if(s.getUTCMonth()!==t.getUTCMonth())return 60;if(s.getUTCDate()!==t.getUTCDate())return 50;for(let e=fi.length-1;e>=0;--e)if(Math.floor(t.getTime()/fi[e].Md)!==Math.floor(s.getTime()/fi[e].Md))return fi[e].xd;return 0}function ss(s){let t=s;if(Pe(s)&&(t=ns(s)),!es(t))throw new Error("time must be of type BusinessDay");const e=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{Sd:Math.round(e.getTime()/1e3),kd:t}}function Qn(s){if(!Kn(s))throw new Error("time must be of type isUTCTimestamp");return{Sd:s}}function ns(s){const t=new Date(s);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${s}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function tr(s){Pe(s.time)&&(s.time=ns(s.time))}class er{options(){return this.cn}setOptions(t){this.cn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?(function(e){e.forEach(tr)})(t):tr(t)}createConverterToInternalObj(t){return S((function(e){return e.length===0?null:es(e[0].time)||Pe(e[0].time)?ss:Qn})(t))}key(t){return typeof t=="object"&&"Sd"in t?t.Sd:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const e=t;return e.kd===void 0?new Date(1e3*e.Sd).getTime():new Date(Date.UTC(e.kd.year,e.kd.month-1,e.kd.day)).getTime()}convertHorzItemToInternal(t){return Kn(e=t)?Qn(e):es(e)?ss(e):ss(ns(e));var e}updateFormatter(t){if(!this.cn)return;const e=t.dateFormat;this.cn.timeScale.timeVisible?this.yd=new Cl({fd:e,vd:this.cn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",pd:" ",md:t.locale}):this.yd=new Yn(e,t.locale)}formatHorzItem(t){const e=t;return this.yd.F_(new Date(1e3*e.Sd))}formatTickmark(t,e){const i=(function(r,o,h){switch(r){case 0:case 10:return o?h?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}})(t.weight,this.cn.timeScale.timeVisible,this.cn.timeScale.secondsVisible),n=this.cn.timeScale;if(n.tickMarkFormatter!==void 0){const r=n.tickMarkFormatter(t.originalTime,i,e.locale);if(r!==null)return r}return(function(r,o,h){const l={};switch(o){case 0:l.year="numeric";break;case 1:l.month="short";break;case 2:l.day="numeric";break;case 3:l.hour12=!1,l.hour="2-digit",l.minute="2-digit";break;case 4:l.hour12=!1,l.hour="2-digit",l.minute="2-digit",l.second="2-digit"}const a=r.kd===void 0?new Date(1e3*r.Sd):new Date(Date.UTC(r.kd.year,r.kd.month-1,r.kd.day));return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()).toLocaleString(h,l)})(t.time,i,e.locale)}maxTickMarkWeight(t){let e=t.reduce(gl,t[0]).weight;return e>30&&e<50&&(e=30),e}fillWeightsForPoints(t,e){(function(i,n=0){if(i.length===0)return;let r=n===0?null:i[n-1].time.Sd,o=r!==null?new Date(1e3*r):null,h=0;for(let l=n;l<i.length;++l){const a=i[l],c=new Date(1e3*a.time.Sd);o!==null&&(a.timeWeight=Zn(c,o)),h+=a.time.Sd-(r||a.time.Sd),r=a.time.Sd,o=c}if(n===0&&i.length>1){const l=Math.ceil(h/(i.length-1)),a=new Date(1e3*(i[0].time.Sd-l));i[0].timeWeight=Zn(new Date(1e3*i[0].time.Sd),a)}})(t,e)}static Cd(t){return Ht({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Ce=typeof window<"u";function ir(){return!!Ce&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function rs(){return!!Ce&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function os(s){return s+s%2}function hs(s,t){return s.Td-t.Td}function ls(s,t,e){const i=(s.Td-t.Td)/(s.ut-t.ut);return Math.sign(i)*Math.min(Math.abs(i),e)}class Ll{constructor(t,e,i,n){this.Pd=null,this.Rd=null,this.Dd=null,this.Od=null,this.Ad=null,this.Vd=0,this.Bd=0,this.Id=t,this.zd=e,this.Ed=i,this.rs=n}Ld(t,e){if(this.Pd!==null){if(this.Pd.ut===e)return void(this.Pd.Td=t);if(Math.abs(this.Pd.Td-t)<this.rs)return}this.Od=this.Dd,this.Dd=this.Rd,this.Rd=this.Pd,this.Pd={ut:e,Td:t}}Dr(t,e){if(this.Pd===null||this.Rd===null||e-this.Pd.ut>50)return;let i=0;const n=ls(this.Pd,this.Rd,this.zd),r=hs(this.Pd,this.Rd),o=[n],h=[r];if(i+=r,this.Dd!==null){const a=ls(this.Rd,this.Dd,this.zd);if(Math.sign(a)===Math.sign(n)){const c=hs(this.Rd,this.Dd);if(o.push(a),h.push(c),i+=c,this.Od!==null){const u=ls(this.Dd,this.Od,this.zd);if(Math.sign(u)===Math.sign(n)){const p=hs(this.Dd,this.Od);o.push(u),h.push(p),i+=p}}}}let l=0;for(let a=0;a<o.length;++a)l+=h[a]/i*o[a];Math.abs(l)<this.Id||(this.Ad={Td:t,ut:e},this.Bd=l,this.Vd=(function(a,c){const u=Math.log(c);return Math.log(1*u/-a)/u})(Math.abs(l),this.Ed))}Yu(t){const e=S(this.Ad),i=t-e.ut;return e.Td+this.Bd*(Math.pow(this.Ed,i)-1)/Math.log(this.Ed)}qu(t){return this.Ad===null||this.Nd(t)===this.Vd}Nd(t){const e=t-S(this.Ad).ut;return Math.min(e,this.Vd)}}function me(s,t){const e=S(s.ownerDocument).createElement("canvas");s.appendChild(e);const i=Uo(e,{options:{allowResizeObserver:!1},transform:(n,r)=>({width:Math.max(n.width,r.width),height:Math.max(n.height,r.height)})});return i.resizeCanvasElement(t),i}function as(s,t,e,i){s.G&&s.G(t,e,i)}function di(s,t,e,i){s.K(t,e,i)}function cs(s,t,e,i){const n=s(e,i);for(const r of n){const o=r.xt();o!==null&&t(o)}}function xl(s){Ce&&window.chrome!==void 0&&s.addEventListener("mousedown",(t=>{if(t.button===1)return t.preventDefault(),!1}))}class us{constructor(t,e,i){this.Fd=0,this.Wd=null,this.jd={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY},this.Hd=0,this.$d=null,this.Ud={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY},this.qd=null,this.Yd=!1,this.Xd=null,this.Kd=null,this.Zd=!1,this.Gd=!1,this.Jd=!1,this.Qd=null,this.tf=null,this.if=null,this.nf=null,this.sf=null,this.ef=null,this.rf=null,this.hf=0,this.lf=!1,this.af=!1,this._f=!1,this.uf=0,this.cf=null,this.df=!rs(),this.ff=n=>{this.vf(n)},this.pf=n=>{if(this.mf(n)){const r=this.bf(n);if(++this.Hd,this.$d&&this.Hd>1){const{wf:o}=this.gf(Xt(n),this.Ud);o<30&&!this.Jd&&this.Mf(r,this.Sf.xf),this.kf()}}else{const r=this.bf(n);if(++this.Fd,this.Wd&&this.Fd>1){const{wf:o}=this.gf(Xt(n),this.jd);o<5&&!this.Gd&&this.yf(r,this.Sf.Cf),this.Tf()}}},this.Pf=t,this.Sf=e,this.cn=i,this.Rf()}S(){this.Qd!==null&&(this.Qd(),this.Qd=null),this.tf!==null&&(this.tf(),this.tf=null),this.nf!==null&&(this.nf(),this.nf=null),this.sf!==null&&(this.sf(),this.sf=null),this.ef!==null&&(this.ef(),this.ef=null),this.if!==null&&(this.if(),this.if=null),this.Df(),this.Tf()}Of(t){this.nf&&this.nf();const e=this.Af.bind(this);if(this.nf=()=>{this.Pf.removeEventListener("mousemove",e)},this.Pf.addEventListener("mousemove",e),this.mf(t))return;const i=this.bf(t);this.yf(i,this.Sf.Vf),this.df=!0}Tf(){this.Wd!==null&&clearTimeout(this.Wd),this.Fd=0,this.Wd=null,this.jd={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY}}kf(){this.$d!==null&&clearTimeout(this.$d),this.Hd=0,this.$d=null,this.Ud={et:Number.NEGATIVE_INFINITY,rt:Number.POSITIVE_INFINITY}}Af(t){if(this._f||this.Kd!==null||this.mf(t))return;const e=this.bf(t);this.yf(e,this.Sf.Bf),this.df=!0}If(t){const e=fs(t.changedTouches,S(this.cf));if(e===null||(this.uf=pi(t),this.rf!==null)||this.af)return;this.lf=!0;const i=this.gf(Xt(e),S(this.Kd)),{zf:n,Ef:r,wf:o}=i;if(this.Zd||!(o<5)){if(!this.Zd){const h=.5*n,l=r>=h&&!this.cn.Lf(),a=h>r&&!this.cn.Nf();l||a||(this.af=!0),this.Zd=!0,this.Jd=!0,this.Df(),this.kf()}if(!this.af){const h=this.bf(t,e);this.Mf(h,this.Sf.Ff),Le(t)}}}Wf(t){if(t.button!==0)return;const e=this.gf(Xt(t),S(this.Xd)),{wf:i}=e;if(i>=5&&(this.Gd=!0,this.Tf()),this.Gd){const n=this.bf(t);this.yf(n,this.Sf.jf)}}gf(t,e){const i=Math.abs(e.et-t.et),n=Math.abs(e.rt-t.rt);return{zf:i,Ef:n,wf:i+n}}Hf(t){let e=fs(t.changedTouches,S(this.cf));if(e===null&&t.touches.length===0&&(e=t.changedTouches[0]),e===null)return;this.cf=null,this.uf=pi(t),this.Df(),this.Kd=null,this.ef&&(this.ef(),this.ef=null);const i=this.bf(t,e);if(this.Mf(i,this.Sf.$f),++this.Hd,this.$d&&this.Hd>1){const{wf:n}=this.gf(Xt(e),this.Ud);n<30&&!this.Jd&&this.Mf(i,this.Sf.xf),this.kf()}else this.Jd||(this.Mf(i,this.Sf.Uf),this.Sf.Uf&&Le(t));this.Hd===0&&Le(t),t.touches.length===0&&this.Yd&&(this.Yd=!1,Le(t))}vf(t){if(t.button!==0)return;const e=this.bf(t);if(this.Xd=null,this._f=!1,this.sf&&(this.sf(),this.sf=null),ir()&&this.Pf.ownerDocument.documentElement.removeEventListener("mouseleave",this.ff),!this.mf(t))if(this.yf(e,this.Sf.qf),++this.Fd,this.Wd&&this.Fd>1){const{wf:i}=this.gf(Xt(t),this.jd);i<5&&!this.Gd&&this.yf(e,this.Sf.Cf),this.Tf()}else this.Gd||this.yf(e,this.Sf.Yf)}Df(){this.qd!==null&&(clearTimeout(this.qd),this.qd=null)}Xf(t){if(this.cf!==null)return;const e=t.changedTouches[0];this.cf=e.identifier,this.uf=pi(t);const i=this.Pf.ownerDocument.documentElement;this.Jd=!1,this.Zd=!1,this.af=!1,this.Kd=Xt(e),this.ef&&(this.ef(),this.ef=null);{const r=this.If.bind(this),o=this.Hf.bind(this);this.ef=()=>{i.removeEventListener("touchmove",r),i.removeEventListener("touchend",o)},i.addEventListener("touchmove",r,{passive:!1}),i.addEventListener("touchend",o,{passive:!1}),this.Df(),this.qd=setTimeout(this.Kf.bind(this,t),240)}const n=this.bf(t,e);this.Mf(n,this.Sf.Zf),this.$d||(this.Hd=0,this.$d=setTimeout(this.kf.bind(this),500),this.Ud=Xt(e))}Gf(t){if(t.button!==0)return;const e=this.Pf.ownerDocument.documentElement;ir()&&e.addEventListener("mouseleave",this.ff),this.Gd=!1,this.Xd=Xt(t),this.sf&&(this.sf(),this.sf=null);{const n=this.Wf.bind(this),r=this.vf.bind(this);this.sf=()=>{e.removeEventListener("mousemove",n),e.removeEventListener("mouseup",r)},e.addEventListener("mousemove",n),e.addEventListener("mouseup",r)}if(this._f=!0,this.mf(t))return;const i=this.bf(t);this.yf(i,this.Sf.Jf),this.Wd||(this.Fd=0,this.Wd=setTimeout(this.Tf.bind(this),500),this.jd=Xt(t))}Rf(){this.Pf.addEventListener("mouseenter",this.Of.bind(this)),this.Pf.addEventListener("touchcancel",this.Df.bind(this));{const t=this.Pf.ownerDocument,e=i=>{this.Sf.Qf&&(i.composed&&this.Pf.contains(i.composedPath()[0])||i.target&&this.Pf.contains(i.target)||this.Sf.Qf())};this.tf=()=>{t.removeEventListener("touchstart",e)},this.Qd=()=>{t.removeEventListener("mousedown",e)},t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0})}rs()&&(this.if=()=>{this.Pf.removeEventListener("dblclick",this.pf)},this.Pf.addEventListener("dblclick",this.pf)),this.Pf.addEventListener("mouseleave",this.tv.bind(this)),this.Pf.addEventListener("touchstart",this.Xf.bind(this),{passive:!0}),xl(this.Pf),this.Pf.addEventListener("mousedown",this.Gf.bind(this)),this.iv(),this.Pf.addEventListener("touchmove",(()=>{}),{passive:!1})}iv(){this.Sf.nv===void 0&&this.Sf.sv===void 0&&this.Sf.ev===void 0||(this.Pf.addEventListener("touchstart",(t=>this.rv(t.touches)),{passive:!0}),this.Pf.addEventListener("touchmove",(t=>{if(t.touches.length===2&&this.rf!==null&&this.Sf.sv!==void 0){const e=sr(t.touches[0],t.touches[1])/this.hf;this.Sf.sv(this.rf,e),Le(t)}}),{passive:!1}),this.Pf.addEventListener("touchend",(t=>{this.rv(t.touches)})))}rv(t){t.length===1&&(this.lf=!1),t.length!==2||this.lf||this.Yd?this.hv():this.lv(t)}lv(t){const e=this.Pf.getBoundingClientRect()||{left:0,top:0};this.rf={et:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,rt:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this.hf=sr(t[0],t[1]),this.Sf.nv!==void 0&&this.Sf.nv(),this.Df()}hv(){this.rf!==null&&(this.rf=null,this.Sf.ev!==void 0&&this.Sf.ev())}tv(t){if(this.nf&&this.nf(),this.mf(t)||!this.df)return;const e=this.bf(t);this.yf(e,this.Sf.av),this.df=!rs()}Kf(t){const e=fs(t.touches,S(this.cf));if(e===null)return;const i=this.bf(t,e);this.Mf(i,this.Sf.ov),this.Jd=!0,this.Yd=!0}mf(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:pi(t)<this.uf+500}Mf(t,e){e&&e.call(this.Sf,t)}yf(t,e){e&&e.call(this.Sf,t)}bf(t,e){const i=e||t,n=this.Pf.getBoundingClientRect()||{left:0,top:0};return{clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,localX:i.clientX-n.left,localY:i.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,_v:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",uv:t.type,cv:i.target,dv:t.view,fv:()=>{t.type!=="touchstart"&&Le(t)}}}}function sr(s,t){const e=s.clientX-t.clientX,i=s.clientY-t.clientY;return Math.sqrt(e*e+i*i)}function Le(s){s.cancelable&&s.preventDefault()}function Xt(s){return{et:s.pageX,rt:s.pageY}}function pi(s){return s.timeStamp||performance.now()}function fs(s,t){for(let e=0;e<s.length;++e)if(s[e].identifier===t)return s[e];return null}function mi(s){return{Bc:s.Bc,vv:{wr:s.pv.externalId},mv:s.pv.cursorStyle}}function Ml(s,t,e){for(const i of s){const n=i.xt();if(n!==null&&n.br){const r=n.br(t,e);if(r!==null)return{dv:i,vv:r}}}return null}function ds(s,t){return e=>{var i,n,r,o;return((n=(i=e.At())===null||i===void 0?void 0:i.xa())!==null&&n!==void 0?n:"")!==t?[]:(o=(r=e.la)===null||r===void 0?void 0:r.call(e,s))!==null&&o!==void 0?o:[]}}class nr{constructor(t,e,i,n){this.Li=null,this.bv=null,this.wv=!1,this.gv=new Ne(200),this.Gr=null,this.Mv=0,this.xv=!1,this.Sv=()=>{this.xv||this.nn.kv().qt().Fh()},this.yv=()=>{this.xv||this.nn.kv().qt().Fh()},this.nn=t,this.cn=e,this.mo=e.layout,this.Sc=i,this.Cv=n==="left",this.Tv=ds("normal",n),this.Pv=ds("top",n),this.Rv=ds("bottom",n),this.Dv=document.createElement("div"),this.Dv.style.height="100%",this.Dv.style.overflow="hidden",this.Dv.style.width="25px",this.Dv.style.left="0",this.Dv.style.position="relative",this.Ov=me(this.Dv,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const r=this.Ov.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Av=me(this.Dv,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const o=this.Av.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const h={Jf:this.Vv.bind(this),Zf:this.Vv.bind(this),jf:this.Bv.bind(this),Ff:this.Bv.bind(this),Qf:this.Iv.bind(this),qf:this.zv.bind(this),$f:this.zv.bind(this),Cf:this.Ev.bind(this),xf:this.Ev.bind(this),Vf:this.Lv.bind(this),av:this.Nv.bind(this)};this.Fv=new us(this.Av.canvasElement,h,{Lf:()=>!1,Nf:()=>!0})}S(){this.Fv.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose(),this.Li!==null&&this.Li.$o().p(this),this.Li=null}Wv(){return this.Dv}P(){return this.mo.fontSize}jv(){const t=this.Sc.W();return this.Gr!==t.R&&(this.gv.ir(),this.Gr=t.R),t}Hv(){if(this.Li===null)return 0;let t=0;const e=this.jv(),i=S(this.Ov.canvasElement.getContext("2d"));i.save();const n=this.Li.Ea();i.font=this.$v(),n.length>0&&(t=Math.max(this.gv.Si(i,n[0].Za),this.gv.Si(i,n[n.length-1].Za)));const r=this.Uv();for(let l=r.length;l--;){const a=this.gv.Si(i,r[l].Jt());a>t&&(t=a)}const o=this.Li.Pt();if(o!==null&&this.bv!==null){const l=this.Li.pn(1,o),a=this.Li.pn(this.bv.height-2,o);t=Math.max(t,this.gv.Si(i,this.Li.Wi(Math.floor(Math.min(l,a))+.11111111111111,o)),this.gv.Si(i,this.Li.Wi(Math.ceil(Math.max(l,a))-.11111111111111,o)))}i.restore();const h=t||34;return os(Math.ceil(e.C+e.T+e.B+e.I+5+h))}qv(t){this.bv!==null&&fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`)}Yv(){return S(this.bv).width}Ji(t){this.Li!==t&&(this.Li!==null&&this.Li.$o().p(this),this.Li=t,t.$o().l(this.ao.bind(this),this))}At(){return this.Li}ir(){const t=this.nn.Xv();this.nn.kv().qt().A_(t,S(this.At()))}Kv(t){if(this.bv===null)return;if(t!==1){this.Zv(),this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n),this.Be(n)})),this.nn.Jv(i,this.Rv),this.Qv(i),this.nn.Jv(i,this.Tv),this.tp(i))}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.ip(e),this.nn.Jv(e,this.Pv))}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}gt(){var t;(t=this.Li)===null||t===void 0||t.Ea()}Vv(t){if(this.Li===null||this.Li.Fi()||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv();this.wv=!0,e.y_(i,this.Li,t.localY)}Bv(t){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv(),n=this.Li;e.C_(i,n,t.localY)}Iv(){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const t=this.nn.kv().qt(),e=this.nn.Xv(),i=this.Li;this.wv&&(this.wv=!1,t.T_(e,i))}zv(t){if(this.Li===null||!this.cn.handleScale.axisPressedMouseMove.price)return;const e=this.nn.kv().qt(),i=this.nn.Xv();this.wv=!1,e.T_(i,this.Li)}Ev(t){this.cn.handleScale.axisDoubleClickReset.price&&this.ir()}Lv(t){this.Li!==null&&(!this.nn.kv().qt().W().handleScale.axisPressedMouseMove.price||this.Li.ph()||this.Li.Co()||this.ep(1))}Nv(t){this.ep(0)}Uv(){const t=[],e=this.Li===null?void 0:this.Li;return(i=>{for(let n=0;n<i.length;++n){const r=i[n].Rn(this.nn.Xv(),e);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.nn.Xv().No()),t}Gv({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.nn.Xv().qt(),o=r.q(),h=r.ad();o===h?ei(t,0,0,i,n,o):cn(t,0,0,i,n,o,h)}Be({context:t,bitmapSize:e,horizontalPixelRatio:i}){if(this.bv===null||this.Li===null||!this.Li.W().borderVisible)return;t.fillStyle=this.Li.W().borderColor;const n=Math.max(1,Math.floor(this.jv().C*i));let r;r=this.Cv?e.width-n:0,t.fillRect(r,0,n,e.height)}Qv(t){if(this.bv===null||this.Li===null)return;const e=this.Li.Ea(),i=this.Li.W(),n=this.jv(),r=this.Cv?this.bv.width-n.T:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace((({context:o,horizontalPixelRatio:h,verticalPixelRatio:l})=>{o.fillStyle=i.borderColor;const a=Math.max(1,Math.floor(l)),c=Math.floor(.5*l),u=Math.round(n.T*h);o.beginPath();for(const p of e)o.rect(Math.floor(r*h),Math.round(p.Aa*l)-c,u,a);o.fill()})),t.useMediaCoordinateSpace((({context:o})=>{var h;o.font=this.$v(),o.fillStyle=(h=i.textColor)!==null&&h!==void 0?h:this.mo.textColor,o.textAlign=this.Cv?"right":"left",o.textBaseline="middle";const l=this.Cv?Math.round(r-n.B):Math.round(r+n.T+n.B),a=e.map((c=>this.gv.xi(o,c.Za)));for(let c=e.length;c--;){const u=e[c];o.fillText(u.Za,l,u.Aa+a[c])}}))}Zv(){if(this.bv===null||this.Li===null)return;let t=this.bv.height/2;const e=[],i=this.Li.No().slice(),n=this.nn.Xv(),r=this.jv();this.Li===n.vr()&&this.nn.Xv().No().forEach((l=>{n.dr(l)&&i.push(l)}));const o=this.Li.Ta()[0],h=this.Li;i.forEach((l=>{const a=l.Rn(n,h);a.forEach((c=>{c.Vi(null),c.Bi()&&e.push(c)})),o===l&&a.length>0&&(t=a[0].yi())})),e.forEach((l=>l.Vi(l.yi()))),this.Li.W().alignLabels&&this.rp(e,r,t)}rp(t,e,i){if(this.bv===null)return;const n=t.filter((o=>o.yi()<=i)),r=t.filter((o=>o.yi()>i));n.sort(((o,h)=>h.yi()-o.yi())),n.length&&r.length&&r.push(n[0]),r.sort(((o,h)=>o.yi()-h.yi()));for(const o of t){const h=Math.floor(o.zt(e)/2),l=o.yi();l>-h&&l<h&&o.Vi(h),l>this.bv.height-h&&l<this.bv.height+h&&o.Vi(this.bv.height-h)}for(let o=1;o<n.length;o++){const h=n[o],l=n[o-1],a=l.zt(e,!1),c=h.yi(),u=l.Ai();c>u-a&&h.Vi(u-a)}for(let o=1;o<r.length;o++){const h=r[o],l=r[o-1],a=l.zt(e,!0),c=h.yi(),u=l.Ai();c<u+a&&h.Vi(u+a)}}tp(t){if(this.bv===null)return;const e=this.Uv(),i=this.jv(),n=this.Cv?"right":"left";e.forEach((r=>{r.Ii()&&r.xt(S(this.Li)).K(t,i,this.gv,n)}))}ip(t){if(this.bv===null||this.Li===null)return;const e=this.nn.kv().qt(),i=[],n=this.nn.Xv(),r=e.Nc().Rn(n,this.Li);r.length&&i.push(r);const o=this.jv(),h=this.Cv?"right":"left";i.forEach((l=>{l.forEach((a=>{a.xt(S(this.Li)).K(t,o,this.gv,h)}))}))}ep(t){this.Dv.style.cursor=t===1?"ns-resize":"default"}ao(){const t=this.Hv();this.Mv<t&&this.nn.kv().qt().$l(),this.Mv=t}$v(){return _e(this.mo.fontSize,this.mo.fontFamily)}}function Rl(s,t){var e,i;return(i=(e=s.ra)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function gi(s,t){var e,i;return(i=(e=s.Pn)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function Ol(s,t){var e,i;return(i=(e=s.Qi)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}function kl(s,t){var e,i;return(i=(e=s.na)===null||e===void 0?void 0:e.call(s,t))!==null&&i!==void 0?i:[]}class ps{constructor(t,e){this.bv=at({width:0,height:0}),this.hp=null,this.lp=null,this.ap=null,this.op=!1,this._p=new yt,this.up=new yt,this.cp=0,this.dp=!1,this.fp=null,this.vp=!1,this.pp=null,this.mp=null,this.xv=!1,this.Sv=()=>{this.xv||this.bp===null||this.Ui().Fh()},this.yv=()=>{this.xv||this.bp===null||this.Ui().Fh()},this.wp=t,this.bp=e,this.bp.I_().l(this.gp.bind(this),this,!0),this.Mp=document.createElement("td"),this.Mp.style.padding="0",this.Mp.style.position="relative";const i=document.createElement("div");i.style.width="100%",i.style.height="100%",i.style.position="relative",i.style.overflow="hidden",this.xp=document.createElement("td"),this.xp.style.padding="0",this.Sp=document.createElement("td"),this.Sp.style.padding="0",this.Mp.appendChild(i),this.Ov=me(i,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const n=this.Ov.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Av=me(i,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const r=this.Av.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this.kp=document.createElement("tr"),this.kp.appendChild(this.xp),this.kp.appendChild(this.Mp),this.kp.appendChild(this.Sp),this.yp(),this.Fv=new us(this.Av.canvasElement,this,{Lf:()=>this.fp===null&&!this.wp.W().handleScroll.vertTouchDrag,Nf:()=>this.fp===null&&!this.wp.W().handleScroll.horzTouchDrag})}S(){this.hp!==null&&this.hp.S(),this.lp!==null&&this.lp.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose(),this.bp!==null&&this.bp.I_().p(this),this.Fv.S()}Xv(){return S(this.bp)}Cp(t){this.bp!==null&&this.bp.I_().p(this),this.bp=t,this.bp!==null&&this.bp.I_().l(ps.prototype.gp.bind(this),this,!0),this.yp()}kv(){return this.wp}Wv(){return this.kp}yp(){if(this.bp!==null&&(this.Tp(),this.Ui().Mt().length!==0)){if(this.hp!==null){const t=this.bp.S_();this.hp.Ji(S(t))}if(this.lp!==null){const t=this.bp.k_();this.lp.Ji(S(t))}}}Pp(){this.hp!==null&&this.hp.gt(),this.lp!==null&&this.lp.gt()}v_(){return this.bp!==null?this.bp.v_():0}p_(t){this.bp&&this.bp.p_(t)}Vf(t){if(!this.bp)return;this.Rp();const e=t.localX,i=t.localY;this.Dp(e,i,t)}Jf(t){this.Rp(),this.Op(),this.Dp(t.localX,t.localY,t)}Bf(t){var e;if(!this.bp)return;this.Rp();const i=t.localX,n=t.localY;this.Dp(i,n,t);const r=this.br(i,n);this.wp.Ap((e=r?.mv)!==null&&e!==void 0?e:null),this.Ui().Vc(r&&{Bc:r.Bc,vv:r.vv})}Yf(t){this.bp!==null&&(this.Rp(),this.Vp(t))}Cf(t){this.bp!==null&&this.Bp(this.up,t)}xf(t){this.Cf(t)}jf(t){this.Rp(),this.Ip(t),this.Dp(t.localX,t.localY,t)}qf(t){this.bp!==null&&(this.Rp(),this.dp=!1,this.zp(t))}Uf(t){this.bp!==null&&this.Vp(t)}ov(t){if(this.dp=!0,this.fp===null){const e={x:t.localX,y:t.localY};this.Ep(e,e,t)}}av(t){this.bp!==null&&(this.Rp(),this.bp.qt().Vc(null),this.Lp())}Np(){return this._p}Fp(){return this.up}nv(){this.cp=1,this.Ui().Un()}sv(t,e){if(!this.wp.W().handleScale.pinch)return;const i=5*(e-this.cp);this.cp=e,this.Ui().$c(t.et,i)}Zf(t){this.dp=!1,this.vp=this.fp!==null,this.Op();const e=this.Ui().Nc();this.fp!==null&&e.Tt()&&(this.pp={x:e.Kt(),y:e.Zt()},this.fp={x:t.localX,y:t.localY})}Ff(t){if(this.bp===null)return;const e=t.localX,i=t.localY;if(this.fp===null)this.Ip(t);else{this.vp=!1;const n=S(this.pp),r=n.x+(e-this.fp.x),o=n.y+(i-this.fp.y);this.Dp(r,o,t)}}$f(t){this.kv().W().trackingMode.exitMode===0&&(this.vp=!0),this.Wp(),this.zp(t)}br(t,e){const i=this.bp;return i===null?null:(function(n,r,o){const h=n.No(),l=(function(a,c,u){var p,g;let d,f;for(const M of a){const R=(g=(p=M.oa)===null||p===void 0?void 0:p.call(M,c,u))!==null&&g!==void 0?g:[];for(const k of R)m=k.zOrder,(!(w=d?.zOrder)||m==="top"&&w!=="top"||m==="normal"&&w==="bottom")&&(d=k,f=M)}var m,w;return d&&f?{pv:d,Bc:f}:null})(h,r,o);if(l?.pv.zOrder==="top")return mi(l);for(const a of h){if(l&&l.Bc===a&&l.pv.zOrder!=="bottom"&&!l.pv.isBackground)return mi(l);const c=Ml(a.Pn(n),r,o);if(c!==null)return{Bc:a,dv:c.dv,vv:c.vv};if(l&&l.Bc===a&&l.pv.zOrder!=="bottom"&&l.pv.isBackground)return mi(l)}return l?.pv?mi(l):null})(i,t,e)}jp(t,e){S(e==="left"?this.hp:this.lp).qv(at({width:t,height:this.bv.height}))}Hp(){return this.bv}qv(t){fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Mp.style.width=t.width+"px",this.Mp.style.height=t.height+"px")}$p(){const t=S(this.bp);t.x_(t.S_()),t.x_(t.k_());for(const e of t.Ta())if(t.dr(e)){const i=e.At();i!==null&&t.x_(i),e.On()}}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Kv(t){if(t===0||this.bp===null)return;if(t>1&&this.$p(),this.hp!==null&&this.hp.Kv(t),this.lp!==null&&this.lp.Kv(t),t!==1){this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n)})),this.bp&&(this.Up(i,Rl),this.qp(i),this.Yp(i),this.Up(i,gi),this.Up(i,Ol)))}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.Xp(e),this.Up(e,kl))}Kp(){return this.hp}Zp(){return this.lp}Jv(t,e){this.Up(t,e)}gp(){this.bp!==null&&this.bp.I_().p(this),this.bp=null}Vp(t){this.Bp(this._p,t)}Bp(t,e){const i=e.localX,n=e.localY;t.M()&&t.m(this.Ui().yt().Au(i),{x:i,y:n},e)}Gv({context:t,bitmapSize:e}){const{width:i,height:n}=e,r=this.Ui(),o=r.q(),h=r.ad();o===h?ei(t,0,0,i,n,h):cn(t,0,0,i,n,o,h)}qp(t){const e=S(this.bp).z_().Wh().xt();e!==null&&e.K(t,!1)}Yp(t){const e=this.Ui().Lc();this.Gp(t,gi,as,e),this.Gp(t,gi,di,e)}Xp(t){this.Gp(t,gi,di,this.Ui().Nc())}Up(t,e){const i=S(this.bp).No();for(const n of i)this.Gp(t,e,as,n);for(const n of i)this.Gp(t,e,di,n)}Gp(t,e,i,n){const r=S(this.bp),o=r.qt().Ac(),h=o!==null&&o.Bc===n,l=o!==null&&h&&o.vv!==void 0?o.vv.gr:void 0;cs(e,(a=>i(a,t,h,l)),n,r)}Tp(){if(this.bp===null)return;const t=this.wp,e=this.bp.S_().W().visible,i=this.bp.k_().W().visible;e||this.hp===null||(this.xp.removeChild(this.hp.Wv()),this.hp.S(),this.hp=null),i||this.lp===null||(this.Sp.removeChild(this.lp.Wv()),this.lp.S(),this.lp=null);const n=t.qt().nd();e&&this.hp===null&&(this.hp=new nr(this,t.W(),n,"left"),this.xp.appendChild(this.hp.Wv())),i&&this.lp===null&&(this.lp=new nr(this,t.W(),n,"right"),this.Sp.appendChild(this.lp.Wv()))}Jp(t){return t._v&&this.dp||this.fp!==null}Qp(t){return Math.max(0,Math.min(t,this.bv.width-1))}tm(t){return Math.max(0,Math.min(t,this.bv.height-1))}Dp(t,e,i){this.Ui().Gc(this.Qp(t),this.tm(e),i,S(this.bp))}Lp(){this.Ui().Qc()}Wp(){this.vp&&(this.fp=null,this.Lp())}Ep(t,e,i){this.fp=t,this.vp=!1,this.Dp(e.x,e.y,i);const n=this.Ui().Nc();this.pp={x:n.Kt(),y:n.Zt()}}Ui(){return this.wp.qt()}zp(t){if(!this.op)return;const e=this.Ui(),i=this.Xv();if(e.D_(i,i.vn()),this.ap=null,this.op=!1,e.Xc(),this.mp!==null){const n=performance.now(),r=e.yt();this.mp.Dr(r.zu(),n),this.mp.qu(n)||e.Xn(this.mp)}}Rp(){this.fp=null}Op(){if(this.bp){if(this.Ui().Un(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)S(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.bp.vn().Fi()&&this.Ui().yt().Fi()}}Ip(t){if(this.bp===null)return;const e=this.Ui(),i=e.yt();if(i.Fi())return;const n=this.wp.W(),r=n.handleScroll,o=n.kineticScroll;if((!r.pressedMouseMove||t._v)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t._v))return;const h=this.bp.vn(),l=performance.now();if(this.ap!==null||this.Jp(t)||(this.ap={x:t.clientX,y:t.clientY,Sd:l,im:t.localX,nm:t.localY}),this.ap!==null&&!this.op&&(this.ap.x!==t.clientX||this.ap.y!==t.clientY)){if(t._v&&o.touch||!t._v&&o.mouse){const a=i.he();this.mp=new Ll(.2/a,7/a,.997,15/a),this.mp.Ld(i.zu(),this.ap.Sd)}else this.mp=null;h.Fi()||e.P_(this.bp,h,t.localY),e.qc(t.localX),this.op=!0}this.op&&(h.Fi()||e.R_(this.bp,h,t.localY),e.Yc(t.localX),this.mp!==null&&this.mp.Ld(i.zu(),l))}}class rr{constructor(t,e,i,n,r){this.bt=!0,this.bv=at({width:0,height:0}),this.Sv=()=>this.Kv(3),this.Cv=t==="left",this.Sc=i.nd,this.cn=e,this.sm=n,this.rm=r,this.Dv=document.createElement("div"),this.Dv.style.width="25px",this.Dv.style.height="100%",this.Dv.style.overflow="hidden",this.Ov=me(this.Dv,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv)}S(){this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose()}Wv(){return this.Dv}Hp(){return this.bv}qv(t){fe(this.bv,t)||(this.bv=t,this.Ov.resizeCanvasElement(t),this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`,this.bt=!0)}Kv(t){if(t<3&&!this.bt||this.bv.width===0||this.bv.height===0)return;this.bt=!1,this.Ov.applySuggestedBitmapSize();const e=de(this.Ov);e!==null&&e.useBitmapCoordinateSpace((i=>{this.Gv(i),this.Be(i)}))}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Be({context:t,bitmapSize:e,horizontalPixelRatio:i,verticalPixelRatio:n}){if(!this.sm())return;t.fillStyle=this.cn.timeScale.borderColor;const r=Math.floor(this.Sc.W().C*i),o=Math.floor(this.Sc.W().C*n),h=this.Cv?e.width-r:0;t.fillRect(h,0,r,o)}Gv({context:t,bitmapSize:e}){ei(t,0,0,e.width,e.height,this.rm())}}function ms(s){return t=>{var e,i;return(i=(e=t.aa)===null||e===void 0?void 0:e.call(t,s))!==null&&i!==void 0?i:[]}}const Pl=ms("normal"),Al=ms("top"),Dl=ms("bottom");class Nl{constructor(t,e){this.hm=null,this.lm=null,this.k=null,this.am=!1,this.bv=at({width:0,height:0}),this.om=new yt,this.gv=new Ne(5),this.xv=!1,this.Sv=()=>{this.xv||this.wp.qt().Fh()},this.yv=()=>{this.xv||this.wp.qt().Fh()},this.wp=t,this.N_=e,this.cn=t.W().layout,this._m=document.createElement("tr"),this.um=document.createElement("td"),this.um.style.padding="0",this.dm=document.createElement("td"),this.dm.style.padding="0",this.Dv=document.createElement("td"),this.Dv.style.height="25px",this.Dv.style.padding="0",this.fm=document.createElement("div"),this.fm.style.width="100%",this.fm.style.height="100%",this.fm.style.position="relative",this.fm.style.overflow="hidden",this.Dv.appendChild(this.fm),this.Ov=me(this.fm,at({width:16,height:16})),this.Ov.subscribeSuggestedBitmapSizeChanged(this.Sv);const i=this.Ov.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Av=me(this.fm,at({width:16,height:16})),this.Av.subscribeSuggestedBitmapSizeChanged(this.yv);const n=this.Av.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this._m.appendChild(this.um),this._m.appendChild(this.Dv),this._m.appendChild(this.dm),this.vm(),this.wp.qt().f_().l(this.vm.bind(this),this),this.Fv=new us(this.Av.canvasElement,this,{Lf:()=>!0,Nf:()=>!1})}S(){this.Fv.S(),this.hm!==null&&this.hm.S(),this.lm!==null&&this.lm.S(),this.Av.unsubscribeSuggestedBitmapSizeChanged(this.yv),this.Av.dispose(),this.Ov.unsubscribeSuggestedBitmapSizeChanged(this.Sv),this.Ov.dispose()}Wv(){return this._m}pm(){return this.hm}bm(){return this.lm}Jf(t){if(this.am)return;this.am=!0;const e=this.wp.qt();!e.yt().Fi()&&this.wp.W().handleScale.axisPressedMouseMove.time&&e.Hc(t.localX)}Zf(t){this.Jf(t)}Qf(){const t=this.wp.qt();!t.yt().Fi()&&this.am&&(this.am=!1,this.wp.W().handleScale.axisPressedMouseMove.time&&t.Zc())}jf(t){const e=this.wp.qt();!e.yt().Fi()&&this.wp.W().handleScale.axisPressedMouseMove.time&&e.Kc(t.localX)}Ff(t){this.jf(t)}qf(){this.am=!1;const t=this.wp.qt();t.yt().Fi()&&!this.wp.W().handleScale.axisPressedMouseMove.time||t.Zc()}$f(){this.qf()}Cf(){this.wp.W().handleScale.axisDoubleClickReset.time&&this.wp.qt().Zn()}xf(){this.Cf()}Vf(){this.wp.qt().W().handleScale.axisPressedMouseMove.time&&this.ep(1)}av(){this.ep(0)}Hp(){return this.bv}wm(){return this.om}gm(t,e,i){fe(this.bv,t)||(this.bv=t,this.xv=!0,this.Ov.resizeCanvasElement(t),this.Av.resizeCanvasElement(t),this.xv=!1,this.Dv.style.width=`${t.width}px`,this.Dv.style.height=`${t.height}px`,this.om.m(t)),this.hm!==null&&this.hm.qv(at({width:e,height:t.height})),this.lm!==null&&this.lm.qv(at({width:i,height:t.height}))}Mm(){const t=this.xm();return Math.ceil(t.C+t.T+t.P+t.L+t.V+t.Sm)}gt(){this.wp.qt().yt().Ea()}np(){return this.Ov.bitmapSize}sp(t,e,i){const n=this.np();n.width>0&&n.height>0&&t.drawImage(this.Ov.canvasElement,e,i)}Kv(t){if(t===0)return;if(t!==1){this.Ov.applySuggestedBitmapSize();const i=de(this.Ov);i!==null&&(i.useBitmapCoordinateSpace((n=>{this.Gv(n),this.Be(n),this.km(i,Dl)})),this.Qv(i),this.km(i,Pl)),this.hm!==null&&this.hm.Kv(t),this.lm!==null&&this.lm.Kv(t)}this.Av.applySuggestedBitmapSize();const e=de(this.Av);e!==null&&(e.useBitmapCoordinateSpace((({context:i,bitmapSize:n})=>{i.clearRect(0,0,n.width,n.height)})),this.ym([...this.wp.qt().Mt(),this.wp.qt().Nc()],e),this.km(e,Al))}km(t,e){const i=this.wp.qt().Mt();for(const n of i)cs(e,(r=>as(r,t,!1,void 0)),n,void 0);for(const n of i)cs(e,(r=>di(r,t,!1,void 0)),n,void 0)}Gv({context:t,bitmapSize:e}){ei(t,0,0,e.width,e.height,this.wp.qt().ad())}Be({context:t,bitmapSize:e,verticalPixelRatio:i}){if(this.wp.W().timeScale.borderVisible){t.fillStyle=this.Cm();const n=Math.max(1,Math.floor(this.xm().C*i));t.fillRect(0,0,e.width,n)}}Qv(t){const e=this.wp.qt().yt(),i=e.Ea();if(!i||i.length===0)return;const n=this.N_.maxTickMarkWeight(i),r=this.xm(),o=e.W();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace((({context:h,horizontalPixelRatio:l,verticalPixelRatio:a})=>{h.strokeStyle=this.Cm(),h.fillStyle=this.Cm();const c=Math.max(1,Math.floor(l)),u=Math.floor(.5*l);h.beginPath();const p=Math.round(r.T*a);for(let g=i.length;g--;){const d=Math.round(i[g].coord*l);h.rect(d-u,0,c,p)}h.fill()})),t.useMediaCoordinateSpace((({context:h})=>{const l=r.C+r.T+r.L+r.P/2;h.textAlign="center",h.textBaseline="middle",h.fillStyle=this.$(),h.font=this.$v();for(const a of i)if(a.weight<n){const c=a.needAlignCoordinate?this.Tm(h,a.coord,a.label):a.coord;h.fillText(a.label,c,l)}h.font=this.Pm();for(const a of i)if(a.weight>=n){const c=a.needAlignCoordinate?this.Tm(h,a.coord,a.label):a.coord;h.fillText(a.label,c,l)}}))}Tm(t,e,i){const n=this.gv.Si(t,i),r=n/2,o=Math.floor(e-r)+.5;return o<0?e+=Math.abs(0-o):o+n>this.bv.width&&(e-=Math.abs(this.bv.width-(o+n))),e}ym(t,e){const i=this.xm();for(const n of t)for(const r of n.tn())r.xt().K(e,i)}Cm(){return this.wp.W().timeScale.borderColor}$(){return this.cn.textColor}j(){return this.cn.fontSize}$v(){return _e(this.j(),this.cn.fontFamily)}Pm(){return _e(this.j(),this.cn.fontFamily,"bold")}xm(){this.k===null&&(this.k={C:1,N:NaN,L:NaN,V:NaN,Hi:NaN,T:5,P:NaN,R:"",ji:new Ne,Sm:0});const t=this.k,e=this.$v();if(t.R!==e){const i=this.j();t.P=i,t.R=e,t.L=3*i/12,t.V=3*i/12,t.Hi=9*i/12,t.N=0,t.Sm=4*i/12,t.ji.ir()}return this.k}ep(t){this.Dv.style.cursor=t===1?"ew-resize":"default"}vm(){const t=this.wp.qt(),e=t.W();e.leftPriceScale.visible||this.hm===null||(this.um.removeChild(this.hm.Wv()),this.hm.S(),this.hm=null),e.rightPriceScale.visible||this.lm===null||(this.dm.removeChild(this.lm.Wv()),this.lm.S(),this.lm=null);const i={nd:this.wp.qt().nd()},n=()=>e.leftPriceScale.borderVisible&&t.yt().W().borderVisible,r=()=>t.ad();e.leftPriceScale.visible&&this.hm===null&&(this.hm=new rr("left",e,i,n,r),this.um.appendChild(this.hm.Wv())),e.rightPriceScale.visible&&this.lm===null&&(this.lm=new rr("right",e,i,n,r),this.dm.appendChild(this.lm.Wv()))}}const Bl=!!Ce&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((s=>s.brand.includes("Chromium")))&&!!Ce&&(!((gs=navigator?.userAgentData)===null||gs===void 0)&&gs.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);var gs;class Fl{constructor(t,e,i){var n;this.Rm=[],this.Dm=0,this.Qa=0,this.e_=0,this.Om=0,this.Am=0,this.Vm=null,this.Bm=!1,this._p=new yt,this.up=new yt,this.gc=new yt,this.Im=null,this.zm=null,this.Em=t,this.cn=e,this.N_=i,this._m=document.createElement("div"),this._m.classList.add("tv-lightweight-charts"),this._m.style.overflow="hidden",this._m.style.direction="ltr",this._m.style.width="100%",this._m.style.height="100%",(n=this._m).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.Lm=document.createElement("table"),this.Lm.setAttribute("cellspacing","0"),this._m.appendChild(this.Lm),this.Nm=this.Fm.bind(this),bs(this.cn)&&this.Wm(!0),this.Ui=new Sl(this.xc.bind(this),this.cn,i),this.qt().Fc().l(this.jm.bind(this),this),this.Hm=new Nl(this,this.N_),this.Lm.appendChild(this.Hm.Wv());const r=e.autoSize&&this.$m();let o=this.cn.width,h=this.cn.height;if(r||o===0||h===0){const l=t.getBoundingClientRect();o=o||l.width,h=h||l.height}this.Um(o,h),this.qm(),t.appendChild(this._m),this.Ym(),this.Ui.yt().Zu().l(this.Ui.$l.bind(this.Ui),this),this.Ui.f_().l(this.Ui.$l.bind(this.Ui),this)}qt(){return this.Ui}W(){return this.cn}Xm(){return this.Rm}Km(){return this.Hm}S(){this.Wm(!1),this.Dm!==0&&window.cancelAnimationFrame(this.Dm),this.Ui.Fc().p(this),this.Ui.yt().Zu().p(this),this.Ui.f_().p(this),this.Ui.S();for(const t of this.Rm)this.Lm.removeChild(t.Wv()),t.Np().p(this),t.Fp().p(this),t.S();this.Rm=[],S(this.Hm).S(),this._m.parentElement!==null&&this._m.parentElement.removeChild(this._m),this.gc.S(),this._p.S(),this.up.S(),this.Zm()}Um(t,e,i=!1){if(this.Qa===e&&this.e_===t)return;const n=(function(h){const l=Math.floor(h.width),a=Math.floor(h.height);return at({width:l-l%2,height:a-a%2})})(at({width:t,height:e}));this.Qa=n.height,this.e_=n.width;const r=this.Qa+"px",o=this.e_+"px";S(this._m).style.height=r,S(this._m).style.width=o,this.Lm.style.height=r,this.Lm.style.width=o,i?this.Gm(Ct.es(),performance.now()):this.Ui.$l()}Kv(t){t===void 0&&(t=Ct.es());for(let e=0;e<this.Rm.length;e++)this.Rm[e].Kv(t.Hn(e).Fn);this.cn.timeScale.visible&&this.Hm.Kv(t.jn())}Nh(t){const e=bs(this.cn);this.Ui.Nh(t);const i=bs(this.cn);i!==e&&this.Wm(i),this.Ym(),this.Jm(t)}Np(){return this._p}Fp(){return this.up}Fc(){return this.gc}Qm(){this.Vm!==null&&(this.Gm(this.Vm,performance.now()),this.Vm=null);const t=this.tb(null),e=document.createElement("canvas");e.width=t.width,e.height=t.height;const i=S(e.getContext("2d"));return this.tb(i),e}ib(t){return t==="left"&&!this.nb()||t==="right"&&!this.sb()||this.Rm.length===0?0:S(t==="left"?this.Rm[0].Kp():this.Rm[0].Zp()).Yv()}eb(){return this.cn.autoSize&&this.Im!==null}rb(){return this._m}Ap(t){this.zm=t,this.zm?this.rb().style.setProperty("cursor",t):this.rb().style.removeProperty("cursor")}hb(){return this.zm}lb(){return kt(this.Rm[0]).Hp()}Jm(t){(t.autoSize!==void 0||!this.Im||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.Im&&this.$m(),t.autoSize===!1&&this.Im!==null&&this.Zm(),t.autoSize||t.width===void 0&&t.height===void 0||this.Um(t.width||this.e_,t.height||this.Qa))}tb(t){let e=0,i=0;const n=this.Rm[0],r=(h,l)=>{let a=0;for(let c=0;c<this.Rm.length;c++){const u=this.Rm[c],p=S(h==="left"?u.Kp():u.Zp()),g=p.np();t!==null&&p.sp(t,l,a),a+=g.height}};this.nb()&&(r("left",0),e+=S(n.Kp()).np().width);for(let h=0;h<this.Rm.length;h++){const l=this.Rm[h],a=l.np();t!==null&&l.sp(t,e,i),i+=a.height}e+=n.np().width,this.sb()&&(r("right",e),e+=S(n.Zp()).np().width);const o=(h,l,a)=>{S(h==="left"?this.Hm.pm():this.Hm.bm()).sp(S(t),l,a)};if(this.cn.timeScale.visible){const h=this.Hm.np();if(t!==null){let l=0;this.nb()&&(o("left",l,i),l=S(n.Kp()).np().width),this.Hm.sp(t,l,i),l+=h.width,this.sb()&&o("right",l,i)}i+=h.height}return at({width:e,height:i})}ab(){let t=0,e=0,i=0;for(const d of this.Rm)this.nb()&&(e=Math.max(e,S(d.Kp()).Hv(),this.cn.leftPriceScale.minimumWidth)),this.sb()&&(i=Math.max(i,S(d.Zp()).Hv(),this.cn.rightPriceScale.minimumWidth)),t+=d.v_();e=os(e),i=os(i);const n=this.e_,r=this.Qa,o=Math.max(n-e-i,0),h=this.cn.timeScale.visible;let l=h?Math.max(this.Hm.Mm(),this.cn.timeScale.minimumHeight):0;var a;l=(a=l)+a%2;const c=0+l,u=r<c?0:r-c,p=u/t;let g=0;for(let d=0;d<this.Rm.length;++d){const f=this.Rm[d];f.Cp(this.Ui.Ec()[d]);let m=0,w=0;w=d===this.Rm.length-1?u-g:Math.round(f.v_()*p),m=Math.max(w,2),g+=m,f.qv(at({width:o,height:m})),this.nb()&&f.jp(e,"left"),this.sb()&&f.jp(i,"right"),f.Xv()&&this.Ui.Wc(f.Xv(),m)}this.Hm.gm(at({width:h?o:0,height:l}),h?e:0,h?i:0),this.Ui.m_(o),this.Om!==e&&(this.Om=e),this.Am!==i&&(this.Am=i)}Wm(t){t?this._m.addEventListener("wheel",this.Nm,{passive:!1}):this._m.removeEventListener("wheel",this.Nm)}ob(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Bl?1/window.devicePixelRatio:1}Fm(t){if(!(t.deltaX!==0&&this.cn.handleScroll.mouseWheel||t.deltaY!==0&&this.cn.handleScale.mouseWheel))return;const e=this.ob(t),i=e*t.deltaX/100,n=-e*t.deltaY/100;if(t.cancelable&&t.preventDefault(),n!==0&&this.cn.handleScale.mouseWheel){const r=Math.sign(n)*Math.min(1,Math.abs(n)),o=t.clientX-this._m.getBoundingClientRect().left;this.qt().$c(o,r)}i!==0&&this.cn.handleScroll.mouseWheel&&this.qt().Uc(-80*i)}Gm(t,e){var i;const n=t.jn();n===3&&this._b(),n!==3&&n!==2||(this.ub(t),this.cb(t,e),this.Hm.gt(),this.Rm.forEach((r=>{r.Pp()})),((i=this.Vm)===null||i===void 0?void 0:i.jn())===3&&(this.Vm.ts(t),this._b(),this.ub(this.Vm),this.cb(this.Vm,e),t=this.Vm,this.Vm=null)),this.Kv(t)}cb(t,e){for(const i of t.Qn())this.ns(i,e)}ub(t){const e=this.Ui.Ec();for(let i=0;i<e.length;i++)t.Hn(i).Wn&&e[i].V_()}ns(t,e){const i=this.Ui.yt();switch(t.qn){case 0:i.Ju();break;case 1:i.Qu(t.Vt);break;case 2:i.Gn(t.Vt);break;case 3:i.Jn(t.Vt);break;case 4:i.Nu();break;case 5:t.Vt.qu(e)||i.Jn(t.Vt.Yu(e))}}xc(t){this.Vm!==null?this.Vm.ts(t):this.Vm=t,this.Bm||(this.Bm=!0,this.Dm=window.requestAnimationFrame((e=>{if(this.Bm=!1,this.Dm=0,this.Vm!==null){const i=this.Vm;this.Vm=null,this.Gm(i,e);for(const n of i.Qn())if(n.qn===5&&!n.Vt.qu(e)){this.qt().Xn(n.Vt);break}}})))}_b(){this.qm()}qm(){const t=this.Ui.Ec(),e=t.length,i=this.Rm.length;for(let n=e;n<i;n++){const r=kt(this.Rm.pop());this.Lm.removeChild(r.Wv()),r.Np().p(this),r.Fp().p(this),r.S()}for(let n=i;n<e;n++){const r=new ps(this,t[n]);r.Np().l(this.fb.bind(this),this),r.Fp().l(this.vb.bind(this),this),this.Rm.push(r),this.Lm.insertBefore(r.Wv(),this.Hm.Wv())}for(let n=0;n<e;n++){const r=t[n],o=this.Rm[n];o.Xv()!==r?o.Cp(r):o.yp()}this.Ym(),this.ab()}pb(t,e,i){var n;const r=new Map;t!==null&&this.Ui.Mt().forEach((c=>{const u=c.In().nl(t);u!==null&&r.set(c,u)}));let o;if(t!==null){const c=(n=this.Ui.yt().qi(t))===null||n===void 0?void 0:n.originalTime;c!==void 0&&(o=c)}const h=this.qt().Ac(),l=h!==null&&h.Bc instanceof Gi?h.Bc:void 0,a=h!==null&&h.vv!==void 0?h.vv.wr:void 0;return{mb:o,se:t??void 0,bb:e??void 0,wb:l,gb:r,Mb:a,xb:i??void 0}}fb(t,e,i){this._p.m((()=>this.pb(t,e,i)))}vb(t,e,i){this.up.m((()=>this.pb(t,e,i)))}jm(t,e,i){this.gc.m((()=>this.pb(t,e,i)))}Ym(){const t=this.cn.timeScale.visible?"":"none";this.Hm.Wv().style.display=t}nb(){return this.Rm[0].Xv().S_().W().visible}sb(){return this.Rm[0].Xv().k_().W().visible}$m(){return"ResizeObserver"in window&&(this.Im=new ResizeObserver((t=>{const e=t.find((i=>i.target===this.Em));e&&this.Um(e.contentRect.width,e.contentRect.height)})),this.Im.observe(this.Em,{box:"border-box"}),!0)}Zm(){this.Im!==null&&this.Im.disconnect(),this.Im=null}}function bs(s){return!!(s.handleScroll.mouseWheel||s.handleScale.mouseWheel)}function or(s,t){var e={};for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&t.indexOf(i)<0&&(e[i]=s[i]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function"){var n=0;for(i=Object.getOwnPropertySymbols(s);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(s,i[n])&&(e[i[n]]=s[i[n]])}return e}function hr(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.color!==void 0&&(r.O=e.color),r}function zl(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.lineColor!==void 0&&(r._t=e.lineColor),e.topColor!==void 0&&(r.Ts=e.topColor),e.bottomColor!==void 0&&(r.Ps=e.bottomColor),r}function Ul(s,t,e,i){const n=e.value,r={se:t,ut:s,Vt:[n,n,n,n],mb:i};return e.topLineColor!==void 0&&(r.Pe=e.topLineColor),e.bottomLineColor!==void 0&&(r.Re=e.bottomLineColor),e.topFillColor1!==void 0&&(r.Se=e.topFillColor1),e.topFillColor2!==void 0&&(r.ke=e.topFillColor2),e.bottomFillColor1!==void 0&&(r.ye=e.bottomFillColor1),e.bottomFillColor2!==void 0&&(r.Ce=e.bottomFillColor2),r}function Vl(s,t,e,i){const n={se:t,ut:s,Vt:[e.open,e.high,e.low,e.close],mb:i};return e.color!==void 0&&(n.O=e.color),n}function Wl(s,t,e,i){const n={se:t,ut:s,Vt:[e.open,e.high,e.low,e.close],mb:i};return e.color!==void 0&&(n.O=e.color),e.borderColor!==void 0&&(n.Bt=e.borderColor),e.wickColor!==void 0&&(n.$h=e.wickColor),n}function Il(s,t,e,i,n){const r=kt(n)(e),o=Math.max(...r),h=Math.min(...r),l=r[r.length-1],a=[l,o,h,l],c=e,{time:u,color:p}=c;return{se:t,ut:s,Vt:a,mb:i,He:or(c,["time","color"]),O:p}}function bi(s){return s.Vt!==void 0}function lr(s,t){return t.customValues!==void 0&&(s.Sb=t.customValues),s}function ge(s){return(t,e,i,n,r,o)=>(function(h,l){return l?l(h):(a=h).open===void 0&&a.value===void 0;var a})(i,o)?lr({ut:t,se:e,mb:n},i):lr(s(t,e,i,n,r),i)}function ar(s){return{Candlestick:ge(Wl),Bar:ge(Vl),Area:ge(zl),Baseline:ge(Ul),Histogram:ge(hr),Line:ge(hr),Custom:ge(Il)}[s]}function cr(s){return{se:0,kb:new Map,ia:s}}function ur(s,t){if(s!==void 0&&s.length!==0)return{yb:t.key(s[0].ut),Cb:t.key(s[s.length-1].ut)}}function fr(s){let t;return s.forEach((e=>{t===void 0&&(t=e.mb)})),kt(t)}class ql{constructor(t){this.Tb=new Map,this.Pb=new Map,this.Rb=new Map,this.Db=[],this.N_=t}S(){this.Tb.clear(),this.Pb.clear(),this.Rb.clear(),this.Db=[]}Ob(t,e){let i=this.Tb.size!==0,n=!1;const r=this.Pb.get(t);if(r!==void 0)if(this.Pb.size===1)i=!1,n=!0,this.Tb.clear();else for(const l of this.Db)l.pointData.kb.delete(t)&&(n=!0);let o=[];if(e.length!==0){const l=e.map((g=>g.time)),a=this.N_.createConverterToInternalObj(e),c=ar(t.Xh()),u=t.ga(),p=t.Ma();o=e.map(((g,d)=>{const f=a(g.time),m=this.N_.key(f);let w=this.Tb.get(m);w===void 0&&(w=cr(f),this.Tb.set(m,w),n=!0);const M=c(f,w.se,g,l[d],u,p);return w.kb.set(t,M),M}))}i&&this.Ab(),this.Vb(t,o);let h=-1;if(n){const l=[];this.Tb.forEach((a=>{l.push({timeWeight:0,time:a.ia,pointData:a,originalTime:fr(a.kb)})})),l.sort(((a,c)=>this.N_.key(a.time)-this.N_.key(c.time))),h=this.Bb(l)}return this.Ib(t,h,(function(l,a,c){const u=ur(l,c),p=ur(a,c);if(u!==void 0&&p!==void 0)return{Xl:u.Cb>=p.Cb&&u.yb>=p.yb}})(this.Pb.get(t),r,this.N_))}rd(t){return this.Ob(t,[])}zb(t,e){const i=e;(function(f){f.mb===void 0&&(f.mb=f.time)})(i),this.N_.preprocessData(e);const n=this.N_.createConverterToInternalObj([e])(e.time),r=this.Rb.get(t);if(r!==void 0&&this.N_.key(n)<this.N_.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${n}`);let o=this.Tb.get(this.N_.key(n));const h=o===void 0;o===void 0&&(o=cr(n),this.Tb.set(this.N_.key(n),o));const l=ar(t.Xh()),a=t.ga(),c=t.Ma(),u=l(n,o.se,e,i.mb,a,c);o.kb.set(t,u),this.Eb(t,u);const p={Xl:bi(u)};if(!h)return this.Ib(t,-1,p);const g={timeWeight:0,time:o.ia,pointData:o,originalTime:fr(o.kb)},d=De(this.Db,this.N_.key(g.time),((f,m)=>this.N_.key(f.time)<m));this.Db.splice(d,0,g);for(let f=d;f<this.Db.length;++f)vs(this.Db[f].pointData,f);return this.N_.fillWeightsForPoints(this.Db,d),this.Ib(t,d,p)}Eb(t,e){let i=this.Pb.get(t);i===void 0&&(i=[],this.Pb.set(t,i));const n=i.length!==0?i[i.length-1]:null;n===null||this.N_.key(e.ut)>this.N_.key(n.ut)?bi(e)&&i.push(e):bi(e)?i[i.length-1]=e:i.splice(-1,1),this.Rb.set(t,e.ut)}Vb(t,e){e.length!==0?(this.Pb.set(t,e.filter(bi)),this.Rb.set(t,e[e.length-1].ut)):(this.Pb.delete(t),this.Rb.delete(t))}Ab(){for(const t of this.Db)t.pointData.kb.size===0&&this.Tb.delete(this.N_.key(t.time))}Bb(t){let e=-1;for(let i=0;i<this.Db.length&&i<t.length;++i){const n=this.Db[i],r=t[i];if(this.N_.key(n.time)!==this.N_.key(r.time)){e=i;break}r.timeWeight=n.timeWeight,vs(r.pointData,i)}if(e===-1&&this.Db.length!==t.length&&(e=Math.min(this.Db.length,t.length)),e===-1)return-1;for(let i=e;i<t.length;++i)vs(t[i].pointData,i);return this.N_.fillWeightsForPoints(t,e),this.Db=t,e}Lb(){if(this.Pb.size===0)return null;let t=0;return this.Pb.forEach((e=>{e.length!==0&&(t=Math.max(t,e[e.length-1].se))})),t}Ib(t,e,i){const n={Nb:new Map,yt:{Ou:this.Lb()}};if(e!==-1)this.Pb.forEach(((r,o)=>{n.Nb.set(o,{He:r,Fb:o===t?i:void 0})})),this.Pb.has(t)||n.Nb.set(t,{He:[],Fb:i}),n.yt.Wb=this.Db,n.yt.jb=e;else{const r=this.Pb.get(t);n.Nb.set(t,{He:r||[],Fb:i})}return n}}function vs(s,t){s.se=t,s.kb.forEach((e=>{e.se=t}))}function ys(s){const t={value:s.Vt[3],time:s.mb};return s.Sb!==void 0&&(t.customValues=s.Sb),t}function dr(s){const t=ys(s);return s.O!==void 0&&(t.color=s.O),t}function Hl(s){const t=ys(s);return s._t!==void 0&&(t.lineColor=s._t),s.Ts!==void 0&&(t.topColor=s.Ts),s.Ps!==void 0&&(t.bottomColor=s.Ps),t}function $l(s){const t=ys(s);return s.Pe!==void 0&&(t.topLineColor=s.Pe),s.Re!==void 0&&(t.bottomLineColor=s.Re),s.Se!==void 0&&(t.topFillColor1=s.Se),s.ke!==void 0&&(t.topFillColor2=s.ke),s.ye!==void 0&&(t.bottomFillColor1=s.ye),s.Ce!==void 0&&(t.bottomFillColor2=s.Ce),t}function pr(s){const t={open:s.Vt[0],high:s.Vt[1],low:s.Vt[2],close:s.Vt[3],time:s.mb};return s.Sb!==void 0&&(t.customValues=s.Sb),t}function jl(s){const t=pr(s);return s.O!==void 0&&(t.color=s.O),t}function Jl(s){const t=pr(s),{O:e,Bt:i,$h:n}=s;return e!==void 0&&(t.color=e),i!==void 0&&(t.borderColor=i),n!==void 0&&(t.wickColor=n),t}function ws(s){return{Area:Hl,Line:dr,Baseline:$l,Histogram:dr,Bar:jl,Candlestick:Jl,Custom:Kl}[s]}function Kl(s){const t=s.mb;return Object.assign(Object.assign({},s.He),{time:t})}const Xl={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},Yl={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Gl={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Fi},Ss={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},Zl={rightOffset:0,barSpacing:6,minBarSpacing:.5,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0},Ql={color:"rgba(0, 0, 0, 0)",visible:!1,fontSize:48,fontFamily:Fi,fontStyle:"",text:"",horzAlign:"center",vertAlign:"center"};function mr(){return{width:0,height:0,autoSize:!1,layout:Gl,crosshair:Xl,grid:Yl,overlayPriceScales:Object.assign({},Ss),leftPriceScale:Object.assign(Object.assign({},Ss),{visible:!1}),rightPriceScale:Object.assign(Object.assign({},Ss),{visible:!0}),timeScale:Zl,watermark:Ql,localization:{locale:Ce?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class ta{constructor(t,e){this.Hb=t,this.$b=e}applyOptions(t){this.Hb.qt().Ic(this.$b,t)}options(){return this.Li().W()}width(){return si(this.$b)?this.Hb.ib(this.$b):0}Li(){return S(this.Hb.qt().zc(this.$b)).At}}function gr(s,t,e){const i=or(s,["time","originalTime"]),n=Object.assign({time:t},i);return e!==void 0&&(n.originalTime=e),n}const ea={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class ia{constructor(t){this.Bh=t}applyOptions(t){this.Bh.Nh(t)}options(){return this.Bh.W()}Ub(){return this.Bh}}class sa{constructor(t,e,i,n,r){this.qb=new yt,this.Es=t,this.Yb=e,this.Xb=i,this.N_=r,this.Kb=n}S(){this.qb.S()}priceFormatter(){return this.Es.ca()}priceToCoordinate(t){const e=this.Es.Pt();return e===null?null:this.Es.At().Ot(t,e.Vt)}coordinateToPrice(t){const e=this.Es.Pt();return e===null?null:this.Es.At().pn(t,e.Vt)}barsInLogicalRange(t){if(t===null)return null;const e=new Ee(new We(t.from,t.to)).iu(),i=this.Es.In();if(i.Fi())return null;const n=i.nl(e.Os(),1),r=i.nl(e.di(),-1),o=S(i.Qh()),h=S(i.Bn());if(n!==null&&r!==null&&n.se>r.se)return{barsBefore:t.from-o,barsAfter:h-t.to};const l={barsBefore:n===null||n.se===o?t.from-o:n.se-o,barsAfter:r===null||r.se===h?h-t.to:h-r.se};return n!==null&&r!==null&&(l.from=n.mb,l.to=r.mb),l}setData(t){this.N_,this.Es.Xh(),this.Yb.Zb(this.Es,t),this.Gb("full")}update(t){this.Es.Xh(),this.Yb.Jb(this.Es,t),this.Gb("update")}dataByIndex(t,e){const i=this.Es.In().nl(t,e);return i===null?null:ws(this.seriesType())(i)}data(){const t=ws(this.seriesType());return this.Es.In().ie().map((e=>t(e)))}subscribeDataChanged(t){this.qb.l(t)}unsubscribeDataChanged(t){this.qb.v(t)}setMarkers(t){this.N_;const e=t.map((i=>gr(i,this.N_.convertHorzItemToInternal(i.time),i.time)));this.Es.Zl(e)}markers(){return this.Es.Gl().map((t=>gr(t,t.originalTime,void 0)))}applyOptions(t){this.Es.Nh(t)}options(){return re(this.Es.W())}priceScale(){return this.Xb.priceScale(this.Es.At().xa())}createPriceLine(t){const e=Ht(re(ea),t),i=this.Es.Jl(e);return new ia(i)}removePriceLine(t){this.Es.Ql(t.Ub())}seriesType(){return this.Es.Xh()}attachPrimitive(t){this.Es.ba(t),t.attached&&t.attached({chart:this.Kb,series:this,requestUpdate:()=>this.Es.qt().$l()})}detachPrimitive(t){this.Es.wa(t),t.detached&&t.detached()}Gb(t){this.qb.M()&&this.qb.m(t)}}class na{constructor(t,e,i){this.Qb=new yt,this.uu=new yt,this.om=new yt,this.Ui=t,this.wl=t.yt(),this.Hm=e,this.wl.Xu().l(this.tw.bind(this)),this.wl.Ku().l(this.iw.bind(this)),this.Hm.wm().l(this.nw.bind(this)),this.N_=i}S(){this.wl.Xu().p(this),this.wl.Ku().p(this),this.Hm.wm().p(this),this.Qb.S(),this.uu.S(),this.om.S()}scrollPosition(){return this.wl.zu()}scrollToPosition(t,e){e?this.wl.Uu(t,1e3):this.Ui.Jn(t)}scrollToRealTime(){this.wl.$u()}getVisibleRange(){const t=this.wl.yu();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const e={from:this.N_.convertHorzItemToInternal(t.from),to:this.N_.convertHorzItemToInternal(t.to)},i=this.wl.Pu(e);this.Ui.hd(i)}getVisibleLogicalRange(){const t=this.wl.ku();return t===null?null:{from:t.Os(),to:t.di()}}setVisibleLogicalRange(t){le(t.from<=t.to,"The from index cannot be after the to index."),this.Ui.hd(t)}resetTimeScale(){this.Ui.Zn()}fitContent(){this.Ui.Ju()}logicalToCoordinate(t){const e=this.Ui.yt();return e.Fi()?null:e.Et(t)}coordinateToLogical(t){return this.wl.Fi()?null:this.wl.Au(t)}timeToCoordinate(t){const e=this.N_.convertHorzItemToInternal(t),i=this.wl.ya(e,!1);return i===null?null:this.wl.Et(i)}coordinateToTime(t){const e=this.Ui.yt(),i=e.Au(t),n=e.qi(i);return n===null?null:n.originalTime}width(){return this.Hm.Hp().width}height(){return this.Hm.Hp().height}subscribeVisibleTimeRangeChange(t){this.Qb.l(t)}unsubscribeVisibleTimeRangeChange(t){this.Qb.v(t)}subscribeVisibleLogicalRangeChange(t){this.uu.l(t)}unsubscribeVisibleLogicalRangeChange(t){this.uu.v(t)}subscribeSizeChange(t){this.om.l(t)}unsubscribeSizeChange(t){this.om.v(t)}applyOptions(t){this.wl.Nh(t)}options(){return Object.assign(Object.assign({},re(this.wl.W())),{barSpacing:this.wl.he()})}tw(){this.Qb.M()&&this.Qb.m(this.getVisibleRange())}iw(){this.uu.M()&&this.uu.m(this.getVisibleLogicalRange())}nw(t){this.om.m(t.width,t.height)}}function ra(s){if(s===void 0||s.type==="custom")return;const t=s;t.minMove!==void 0&&t.precision===void 0&&(t.precision=(function(e){if(e>=1)return 0;let i=0;for(;i<8;i++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return i;e*=10}return i})(t.minMove))}function br(s){return(function(t){if(ti(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:i,axisDoubleClickReset:n}=t.handleScale;ti(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),ti(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const e=t.handleScroll;ti(e)&&(t.handleScroll={horzTouchDrag:e,vertTouchDrag:e,mouseWheel:e,pressedMouseMove:e})})(s),s}class oa{constructor(t,e,i){this.sw=new Map,this.ew=new Map,this.rw=new yt,this.hw=new yt,this.lw=new yt,this.aw=new ql(e);const n=i===void 0?re(mr()):Ht(re(mr()),br(i));this.N_=e,this.Hb=new Fl(t,n,e),this.Hb.Np().l((o=>{this.rw.M()&&this.rw.m(this.ow(o()))}),this),this.Hb.Fp().l((o=>{this.hw.M()&&this.hw.m(this.ow(o()))}),this),this.Hb.Fc().l((o=>{this.lw.M()&&this.lw.m(this.ow(o()))}),this);const r=this.Hb.qt();this._w=new na(r,this.Hb.Km(),this.N_)}remove(){this.Hb.Np().p(this),this.Hb.Fp().p(this),this.Hb.Fc().p(this),this._w.S(),this.Hb.S(),this.sw.clear(),this.ew.clear(),this.rw.S(),this.hw.S(),this.lw.S(),this.aw.S()}resize(t,e,i){this.autoSizeActive()||this.Hb.Um(t,e,i)}addCustomSeries(t,e){const i=Se(t),n=Object.assign(Object.assign({},tn),i.defaultOptions());return this.uw("Custom",n,e,i)}addAreaSeries(t){return this.uw("Area",jo,t)}addBaselineSeries(t){return this.uw("Baseline",Jo,t)}addBarSeries(t){return this.uw("Bar",Ho,t)}addCandlestickSeries(t={}){return(function(e){e.borderColor!==void 0&&(e.borderUpColor=e.borderColor,e.borderDownColor=e.borderColor),e.wickColor!==void 0&&(e.wickUpColor=e.wickColor,e.wickDownColor=e.wickColor)})(t),this.uw("Candlestick",qo,t)}addHistogramSeries(t){return this.uw("Histogram",Ko,t)}addLineSeries(t){return this.uw("Line",$o,t)}removeSeries(t){const e=kt(this.sw.get(t)),i=this.aw.rd(e);this.Hb.qt().rd(e),this.cw(i),this.sw.delete(t),this.ew.delete(e)}Zb(t,e){this.cw(this.aw.Ob(t,e))}Jb(t,e){this.cw(this.aw.zb(t,e))}subscribeClick(t){this.rw.l(t)}unsubscribeClick(t){this.rw.v(t)}subscribeCrosshairMove(t){this.lw.l(t)}unsubscribeCrosshairMove(t){this.lw.v(t)}subscribeDblClick(t){this.hw.l(t)}unsubscribeDblClick(t){this.hw.v(t)}priceScale(t){return new ta(this.Hb,t)}timeScale(){return this._w}applyOptions(t){this.Hb.Nh(br(t))}options(){return this.Hb.W()}takeScreenshot(){return this.Hb.Qm()}autoSizeActive(){return this.Hb.eb()}chartElement(){return this.Hb.rb()}paneSize(){const t=this.Hb.lb();return{height:t.height,width:t.width}}setCrosshairPosition(t,e,i){const n=this.sw.get(i);if(n===void 0)return;const r=this.Hb.qt().cr(n);r!==null&&this.Hb.qt().Jc(t,e,r)}clearCrosshairPosition(){this.Hb.qt().Qc(!0)}uw(t,e,i={},n){ra(i.priceFormat);const r=Ht(re(en),re(e),i),o=this.Hb.qt().sd(t,r,n),h=new sa(o,this,this,this,this.N_);return this.sw.set(h,o),this.ew.set(o,h),h}cw(t){const e=this.Hb.qt();e.td(t.yt.Ou,t.yt.Wb,t.yt.jb),t.Nb.forEach(((i,n)=>n.it(i.He,i.Fb))),e.Bu()}dw(t){return kt(this.ew.get(t))}ow(t){const e=new Map;t.gb.forEach(((n,r)=>{const o=r.Xh(),h=ws(o)(n);if(o!=="Custom")le((function(l){return l.open!==void 0||l.value!==void 0})(h));else{const l=r.Ma();le(!l||l(h)===!1)}e.set(this.dw(r),h)}));const i=t.wb===void 0?void 0:this.dw(t.wb);return{time:t.mb,logical:t.se,point:t.bb,hoveredSeries:i,hoveredObjectId:t.Mb,seriesData:e,sourceEvent:t.xb}}}function ha(s,t,e){let i;if(Pe(s)){const r=document.getElementById(s);le(r!==null,`Cannot find element in DOM with id=${s}`),i=r}else i=s;const n=new oa(i,t,e);return t.setOptions(n.options()),n}function la(s,t){return ha(s,new er,er.Cd(t))}Object.assign(Object.assign({},en),tn);function vr(s,t){return function(){return s.apply(t,arguments)}}const{toString:aa}=Object.prototype,{getPrototypeOf:_s}=Object,{iterator:vi,toStringTag:yr}=Symbol,yi=(s=>t=>{const e=aa.call(t);return s[e]||(s[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),$t=s=>(s=s.toLowerCase(),t=>yi(t)===s),wi=s=>t=>typeof t===s,{isArray:xe}=Array,Me=wi("undefined");function Ie(s){return s!==null&&!Me(s)&&s.constructor!==null&&!Me(s.constructor)&&At(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const wr=$t("ArrayBuffer");function ca(s){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(s):t=s&&s.buffer&&wr(s.buffer),t}const ua=wi("string"),At=wi("function"),Sr=wi("number"),qe=s=>s!==null&&typeof s=="object",fa=s=>s===!0||s===!1,Si=s=>{if(yi(s)!=="object")return!1;const t=_s(s);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(yr in s)&&!(vi in s)},da=s=>{if(!qe(s)||Ie(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},pa=$t("Date"),ma=$t("File"),ga=$t("Blob"),ba=$t("FileList"),va=s=>qe(s)&&At(s.pipe),ya=s=>{let t;return s&&(typeof FormData=="function"&&s instanceof FormData||At(s.append)&&((t=yi(s))==="formdata"||t==="object"&&At(s.toString)&&s.toString()==="[object FormData]"))},wa=$t("URLSearchParams"),[Sa,_a,Ta,Ea]=["ReadableStream","Request","Response","Headers"].map($t),Ca=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function He(s,t,{allOwnKeys:e=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),xe(s))for(i=0,n=s.length;i<n;i++)t.call(null,s[i],i,s);else{if(Ie(s))return;const r=e?Object.getOwnPropertyNames(s):Object.keys(s),o=r.length;let h;for(i=0;i<o;i++)h=r[i],t.call(null,s[h],h,s)}}function _r(s,t){if(Ie(s))return null;t=t.toLowerCase();const e=Object.keys(s);let i=e.length,n;for(;i-- >0;)if(n=e[i],t===n.toLowerCase())return n;return null}const be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Tr=s=>!Me(s)&&s!==be;function Ts(){const{caseless:s,skipUndefined:t}=Tr(this)&&this||{},e={},i=(n,r)=>{const o=s&&_r(e,r)||r;Si(e[o])&&Si(n)?e[o]=Ts(e[o],n):Si(n)?e[o]=Ts({},n):xe(n)?e[o]=n.slice():(!t||!Me(n))&&(e[o]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&He(arguments[n],i);return e}const La=(s,t,e,{allOwnKeys:i}={})=>(He(t,(n,r)=>{e&&At(n)?Object.defineProperty(s,r,{value:vr(n,e),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,r,{value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),s),xa=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),Ma=(s,t,e,i)=>{s.prototype=Object.create(t.prototype,i),Object.defineProperty(s.prototype,"constructor",{value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{value:t.prototype}),e&&Object.assign(s.prototype,e)},Ra=(s,t,e,i)=>{let n,r,o;const h={};if(t=t||{},s==null)return t;do{for(n=Object.getOwnPropertyNames(s),r=n.length;r-- >0;)o=n[r],(!i||i(o,s,t))&&!h[o]&&(t[o]=s[o],h[o]=!0);s=e!==!1&&_s(s)}while(s&&(!e||e(s,t))&&s!==Object.prototype);return t},Oa=(s,t,e)=>{s=String(s),(e===void 0||e>s.length)&&(e=s.length),e-=t.length;const i=s.indexOf(t,e);return i!==-1&&i===e},ka=s=>{if(!s)return null;if(xe(s))return s;let t=s.length;if(!Sr(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=s[t];return e},Pa=(s=>t=>s&&t instanceof s)(typeof Uint8Array<"u"&&_s(Uint8Array)),Aa=(s,t)=>{const i=(s&&s[vi]).call(s);let n;for(;(n=i.next())&&!n.done;){const r=n.value;t.call(s,r[0],r[1])}},Da=(s,t)=>{let e;const i=[];for(;(e=s.exec(t))!==null;)i.push(e);return i},Na=$t("HTMLFormElement"),Ba=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,n){return i.toUpperCase()+n}),Er=(({hasOwnProperty:s})=>(t,e)=>s.call(t,e))(Object.prototype),Fa=$t("RegExp"),Cr=(s,t)=>{const e=Object.getOwnPropertyDescriptors(s),i={};He(e,(n,r)=>{let o;(o=t(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},za=s=>{Cr(s,(t,e)=>{if(At(s)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=s[e];if(At(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},Ua=(s,t)=>{const e={},i=n=>{n.forEach(r=>{e[r]=!0})};return xe(s)?i(s):i(String(s).split(t)),e},Va=()=>{},Wa=(s,t)=>s!=null&&Number.isFinite(s=+s)?s:t;function Ia(s){return!!(s&&At(s.append)&&s[yr]==="FormData"&&s[vi])}const qa=s=>{const t=new Array(10),e=(i,n)=>{if(qe(i)){if(t.indexOf(i)>=0)return;if(Ie(i))return i;if(!("toJSON"in i)){t[n]=i;const r=xe(i)?[]:{};return He(i,(o,h)=>{const l=e(o,n+1);!Me(l)&&(r[h]=l)}),t[n]=void 0,r}}return i};return e(s,0)},Ha=$t("AsyncFunction"),$a=s=>s&&(qe(s)||At(s))&&At(s.then)&&At(s.catch),Lr=((s,t)=>s?setImmediate:t?((e,i)=>(be.addEventListener("message",({source:n,data:r})=>{n===be&&r===e&&i.length&&i.shift()()},!1),n=>{i.push(n),be.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",At(be.postMessage)),ja=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Lr,v={isArray:xe,isArrayBuffer:wr,isBuffer:Ie,isFormData:ya,isArrayBufferView:ca,isString:ua,isNumber:Sr,isBoolean:fa,isObject:qe,isPlainObject:Si,isEmptyObject:da,isReadableStream:Sa,isRequest:_a,isResponse:Ta,isHeaders:Ea,isUndefined:Me,isDate:pa,isFile:ma,isBlob:ga,isRegExp:Fa,isFunction:At,isStream:va,isURLSearchParams:wa,isTypedArray:Pa,isFileList:ba,forEach:He,merge:Ts,extend:La,trim:Ca,stripBOM:xa,inherits:Ma,toFlatObject:Ra,kindOf:yi,kindOfTest:$t,endsWith:Oa,toArray:ka,forEachEntry:Aa,matchAll:Da,isHTMLForm:Na,hasOwnProperty:Er,hasOwnProp:Er,reduceDescriptors:Cr,freezeMethods:za,toObjectSet:Ua,toCamelCase:Ba,noop:Va,toFiniteNumber:Wa,findKey:_r,global:be,isContextDefined:Tr,isSpecCompliantForm:Ia,toJSONObject:qa,isAsyncFn:Ha,isThenable:$a,setImmediate:Lr,asap:ja,isIterable:s=>s!=null&&At(s[vi])};let N=class Do extends Error{static from(t,e,i,n,r,o){const h=new Do(t.message,e||t.code,i,n,r);return h.cause=t,h.name=t.name,o&&Object.assign(h,o),h}constructor(t,e,i,n,r){super(t),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r,this.status=r.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:v.toJSONObject(this.config),code:this.code,status:this.status}}};N.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",N.ERR_BAD_OPTION="ERR_BAD_OPTION",N.ECONNABORTED="ECONNABORTED",N.ETIMEDOUT="ETIMEDOUT",N.ERR_NETWORK="ERR_NETWORK",N.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",N.ERR_DEPRECATED="ERR_DEPRECATED",N.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",N.ERR_BAD_REQUEST="ERR_BAD_REQUEST",N.ERR_CANCELED="ERR_CANCELED",N.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",N.ERR_INVALID_URL="ERR_INVALID_URL";const Ja=null;function Es(s){return v.isPlainObject(s)||v.isArray(s)}function xr(s){return v.endsWith(s,"[]")?s.slice(0,-2):s}function Mr(s,t,e){return s?s.concat(t).map(function(n,r){return n=xr(n),!e&&r?"["+n+"]":n}).join(e?".":""):t}function Ka(s){return v.isArray(s)&&!s.some(Es)}const Xa=v.toFlatObject(v,{},null,function(t){return/^is[A-Z]/.test(t)});function _i(s,t,e){if(!v.isObject(s))throw new TypeError("target must be an object");t=t||new FormData,e=v.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,m){return!v.isUndefined(m[f])});const i=e.metaTokens,n=e.visitor||c,r=e.dots,o=e.indexes,l=(e.Blob||typeof Blob<"u"&&Blob)&&v.isSpecCompliantForm(t);if(!v.isFunction(n))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(v.isDate(d))return d.toISOString();if(v.isBoolean(d))return d.toString();if(!l&&v.isBlob(d))throw new N("Blob is not supported. Use a Buffer instead.");return v.isArrayBuffer(d)||v.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,f,m){let w=d;if(d&&!m&&typeof d=="object"){if(v.endsWith(f,"{}"))f=i?f:f.slice(0,-2),d=JSON.stringify(d);else if(v.isArray(d)&&Ka(d)||(v.isFileList(d)||v.endsWith(f,"[]"))&&(w=v.toArray(d)))return f=xr(f),w.forEach(function(R,k){!(v.isUndefined(R)||R===null)&&t.append(o===!0?Mr([f],k,r):o===null?f:f+"[]",a(R))}),!1}return Es(d)?!0:(t.append(Mr(m,f,r),a(d)),!1)}const u=[],p=Object.assign(Xa,{defaultVisitor:c,convertValue:a,isVisitable:Es});function g(d,f){if(!v.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(d),v.forEach(d,function(w,M){(!(v.isUndefined(w)||w===null)&&n.call(t,w,v.isString(M)?M.trim():M,f,p))===!0&&g(w,f?f.concat(M):[M])}),u.pop()}}if(!v.isObject(s))throw new TypeError("data must be an object");return g(s),t}function Rr(s){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Cs(s,t){this._pairs=[],s&&_i(s,this,t)}const Or=Cs.prototype;Or.append=function(t,e){this._pairs.push([t,e])},Or.toString=function(t){const e=t?function(i){return t.call(this,i,Rr)}:Rr;return this._pairs.map(function(n){return e(n[0])+"="+e(n[1])},"").join("&")};function Ya(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kr(s,t,e){if(!t)return s;const i=e&&e.encode||Ya,n=v.isFunction(e)?{serialize:e}:e,r=n&&n.serialize;let o;if(r?o=r(t,n):o=v.isURLSearchParams(t)?t.toString():new Cs(t,n).toString(i),o){const h=s.indexOf("#");h!==-1&&(s=s.slice(0,h)),s+=(s.indexOf("?")===-1?"?":"&")+o}return s}class Pr{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){v.forEach(this.handlers,function(i){i!==null&&t(i)})}}const Ar={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ga={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Cs,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",xs=typeof navigator=="object"&&navigator||void 0,Za=Ls&&(!xs||["ReactNative","NativeScript","NS"].indexOf(xs.product)<0),Qa=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tc=Ls&&window.location.href||"http://localhost",xt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:Za,hasStandardBrowserWebWorkerEnv:Qa,navigator:xs,origin:tc},Symbol.toStringTag,{value:"Module"})),...Ga};function ec(s,t){return _i(s,new xt.classes.URLSearchParams,{visitor:function(e,i,n,r){return xt.isNode&&v.isBuffer(e)?(this.append(i,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}function ic(s){return v.matchAll(/\w+|\[(\w*)]/g,s).map(t=>t[0]==="[]"?"":t[1]||t[0])}function sc(s){const t={},e=Object.keys(s);let i;const n=e.length;let r;for(i=0;i<n;i++)r=e[i],t[r]=s[r];return t}function Dr(s){function t(e,i,n,r){let o=e[r++];if(o==="__proto__")return!0;const h=Number.isFinite(+o),l=r>=e.length;return o=!o&&v.isArray(n)?n.length:o,l?(v.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!h):((!n[o]||!v.isObject(n[o]))&&(n[o]=[]),t(e,i,n[o],r)&&v.isArray(n[o])&&(n[o]=sc(n[o])),!h)}if(v.isFormData(s)&&v.isFunction(s.entries)){const e={};return v.forEachEntry(s,(i,n)=>{t(ic(i),n,e,0)}),e}return null}function nc(s,t,e){if(v.isString(s))try{return(t||JSON.parse)(s),v.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(s)}const $e={transitional:Ar,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",n=i.indexOf("application/json")>-1,r=v.isObject(t);if(r&&v.isHTMLForm(t)&&(t=new FormData(t)),v.isFormData(t))return n?JSON.stringify(Dr(t)):t;if(v.isArrayBuffer(t)||v.isBuffer(t)||v.isStream(t)||v.isFile(t)||v.isBlob(t)||v.isReadableStream(t))return t;if(v.isArrayBufferView(t))return t.buffer;if(v.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let h;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ec(t,this.formSerializer).toString();if((h=v.isFileList(t))||i.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return _i(h?{"files[]":t}:t,l&&new l,this.formSerializer)}}return r||n?(e.setContentType("application/json",!1),nc(t)):t}],transformResponse:[function(t){const e=this.transitional||$e.transitional,i=e&&e.forcedJSONParsing,n=this.responseType==="json";if(v.isResponse(t)||v.isReadableStream(t))return t;if(t&&v.isString(t)&&(i&&!this.responseType||n)){const o=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(h){if(o)throw h.name==="SyntaxError"?N.from(h,N.ERR_BAD_RESPONSE,this,null,this.response):h}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};v.forEach(["delete","get","head","post","put","patch"],s=>{$e.headers[s]={}});const rc=v.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),oc=s=>{const t={};let e,i,n;return s&&s.split(`
|
|
2
|
+
`).forEach(function(o){n=o.indexOf(":"),e=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!e||t[e]&&rc[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},Nr=Symbol("internals");function je(s){return s&&String(s).trim().toLowerCase()}function Ti(s){return s===!1||s==null?s:v.isArray(s)?s.map(Ti):String(s)}function hc(s){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=e.exec(s);)t[i[1]]=i[2];return t}const lc=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Ms(s,t,e,i,n){if(v.isFunction(i))return i.call(this,t,e);if(n&&(t=e),!!v.isString(t)){if(v.isString(i))return t.indexOf(i)!==-1;if(v.isRegExp(i))return i.test(t)}}function ac(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function cc(s,t){const e=v.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+e,{value:function(n,r,o){return this[i].call(this,t,n,r,o)},configurable:!0})})}let Dt=class{constructor(t){t&&this.set(t)}set(t,e,i){const n=this;function r(h,l,a){const c=je(l);if(!c)throw new Error("header name must be a non-empty string");const u=v.findKey(n,c);(!u||n[u]===void 0||a===!0||a===void 0&&n[u]!==!1)&&(n[u||l]=Ti(h))}const o=(h,l)=>v.forEach(h,(a,c)=>r(a,c,l));if(v.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(v.isString(t)&&(t=t.trim())&&!lc(t))o(oc(t),e);else if(v.isObject(t)&&v.isIterable(t)){let h={},l,a;for(const c of t){if(!v.isArray(c))throw TypeError("Object iterator must return a key-value pair");h[a=c[0]]=(l=h[a])?v.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}o(h,e)}else t!=null&&r(e,t,i);return this}get(t,e){if(t=je(t),t){const i=v.findKey(this,t);if(i){const n=this[i];if(!e)return n;if(e===!0)return hc(n);if(v.isFunction(e))return e.call(this,n,i);if(v.isRegExp(e))return e.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=je(t),t){const i=v.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Ms(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let n=!1;function r(o){if(o=je(o),o){const h=v.findKey(i,o);h&&(!e||Ms(i,i[h],h,e))&&(delete i[h],n=!0)}}return v.isArray(t)?t.forEach(r):r(t),n}clear(t){const e=Object.keys(this);let i=e.length,n=!1;for(;i--;){const r=e[i];(!t||Ms(this,this[r],r,t,!0))&&(delete this[r],n=!0)}return n}normalize(t){const e=this,i={};return v.forEach(this,(n,r)=>{const o=v.findKey(i,r);if(o){e[o]=Ti(n),delete e[r];return}const h=t?ac(r):String(r).trim();h!==r&&delete e[r],e[h]=Ti(n),i[h]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return v.forEach(this,(i,n)=>{i!=null&&i!==!1&&(e[n]=t&&v.isArray(i)?i.join(", "):i)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const i=new this(t);return e.forEach(n=>i.set(n)),i}static accessor(t){const i=(this[Nr]=this[Nr]={accessors:{}}).accessors,n=this.prototype;function r(o){const h=je(o);i[h]||(cc(n,o),i[h]=!0)}return v.isArray(t)?t.forEach(r):r(t),this}};Dt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),v.reduceDescriptors(Dt.prototype,({value:s},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>s,set(i){this[e]=i}}}),v.freezeMethods(Dt);function Rs(s,t){const e=this||$e,i=t||e,n=Dt.from(i.headers);let r=i.data;return v.forEach(s,function(h){r=h.call(e,r,n.normalize(),t?t.status:void 0)}),n.normalize(),r}function Br(s){return!!(s&&s.__CANCEL__)}let Je=class extends N{constructor(t,e,i){super(t??"canceled",N.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function Fr(s,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?s(e):t(new N("Request failed with status code "+e.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function uc(s){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return t&&t[1]||""}function fc(s,t){s=s||10;const e=new Array(s),i=new Array(s);let n=0,r=0,o;return t=t!==void 0?t:1e3,function(l){const a=Date.now(),c=i[r];o||(o=a),e[n]=l,i[n]=a;let u=r,p=0;for(;u!==n;)p+=e[u++],u=u%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),a-o<t)return;const g=c&&a-c;return g?Math.round(p*1e3/g):void 0}}function dc(s,t){let e=0,i=1e3/t,n,r;const o=(a,c=Date.now())=>{e=c,n=null,r&&(clearTimeout(r),r=null),s(...a)};return[(...a)=>{const c=Date.now(),u=c-e;u>=i?o(a,c):(n=a,r||(r=setTimeout(()=>{r=null,o(n)},i-u)))},()=>n&&o(n)]}const Ei=(s,t,e=3)=>{let i=0;const n=fc(50,250);return dc(r=>{const o=r.loaded,h=r.lengthComputable?r.total:void 0,l=o-i,a=n(l),c=o<=h;i=o;const u={loaded:o,total:h,progress:h?o/h:void 0,bytes:l,rate:a||void 0,estimated:a&&h&&c?(h-o)/a:void 0,event:r,lengthComputable:h!=null,[t?"download":"upload"]:!0};s(u)},e)},zr=(s,t)=>{const e=s!=null;return[i=>t[0]({lengthComputable:e,total:s,loaded:i}),t[1]]},Ur=s=>(...t)=>v.asap(()=>s(...t)),pc=xt.hasStandardBrowserEnv?((s,t)=>e=>(e=new URL(e,xt.origin),s.protocol===e.protocol&&s.host===e.host&&(t||s.port===e.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,mc=xt.hasStandardBrowserEnv?{write(s,t,e,i,n,r,o){if(typeof document>"u")return;const h=[`${s}=${encodeURIComponent(t)}`];v.isNumber(e)&&h.push(`expires=${new Date(e).toUTCString()}`),v.isString(i)&&h.push(`path=${i}`),v.isString(n)&&h.push(`domain=${n}`),r===!0&&h.push("secure"),v.isString(o)&&h.push(`SameSite=${o}`),document.cookie=h.join("; ")},read(s){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function gc(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function bc(s,t){return t?s.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):s}function Vr(s,t,e){let i=!gc(t);return s&&(i||e==!1)?bc(s,t):t}const Wr=s=>s instanceof Dt?{...s}:s;function ve(s,t){t=t||{};const e={};function i(a,c,u,p){return v.isPlainObject(a)&&v.isPlainObject(c)?v.merge.call({caseless:p},a,c):v.isPlainObject(c)?v.merge({},c):v.isArray(c)?c.slice():c}function n(a,c,u,p){if(v.isUndefined(c)){if(!v.isUndefined(a))return i(void 0,a,u,p)}else return i(a,c,u,p)}function r(a,c){if(!v.isUndefined(c))return i(void 0,c)}function o(a,c){if(v.isUndefined(c)){if(!v.isUndefined(a))return i(void 0,a)}else return i(void 0,c)}function h(a,c,u){if(u in t)return i(a,c);if(u in s)return i(void 0,a)}const l={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:h,headers:(a,c,u)=>n(Wr(a),Wr(c),u,!0)};return v.forEach(Object.keys({...s,...t}),function(c){const u=l[c]||n,p=u(s[c],t[c],c);v.isUndefined(p)&&u!==h||(e[c]=p)}),e}const Ir=s=>{const t=ve({},s);let{data:e,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:h}=t;if(t.headers=o=Dt.from(o),t.url=kr(Vr(t.baseURL,t.url,t.allowAbsoluteUrls),s.params,s.paramsSerializer),h&&o.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),v.isFormData(e)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(v.isFunction(e.getHeaders)){const l=e.getHeaders(),a=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{a.includes(c.toLowerCase())&&o.set(c,u)})}}if(xt.hasStandardBrowserEnv&&(i&&v.isFunction(i)&&(i=i(t)),i||i!==!1&&pc(t.url))){const l=n&&r&&mc.read(r);l&&o.set(n,l)}return t},vc=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(e,i){const n=Ir(s);let r=n.data;const o=Dt.from(n.headers).normalize();let{responseType:h,onUploadProgress:l,onDownloadProgress:a}=n,c,u,p,g,d;function f(){g&&g(),d&&d(),n.cancelToken&&n.cancelToken.unsubscribe(c),n.signal&&n.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout;function w(){if(!m)return;const R=Dt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),$={data:!h||h==="text"||h==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:R,config:s,request:m};Fr(function(G){e(G),f()},function(G){i(G),f()},$),m=null}"onloadend"in m?m.onloadend=w:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(w)},m.onabort=function(){m&&(i(new N("Request aborted",N.ECONNABORTED,s,m)),m=null)},m.onerror=function(k){const $=k&&k.message?k.message:"Network Error",Q=new N($,N.ERR_NETWORK,s,m);Q.event=k||null,i(Q),m=null},m.ontimeout=function(){let k=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const $=n.transitional||Ar;n.timeoutErrorMessage&&(k=n.timeoutErrorMessage),i(new N(k,$.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,s,m)),m=null},r===void 0&&o.setContentType(null),"setRequestHeader"in m&&v.forEach(o.toJSON(),function(k,$){m.setRequestHeader($,k)}),v.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),h&&h!=="json"&&(m.responseType=n.responseType),a&&([p,d]=Ei(a,!0),m.addEventListener("progress",p)),l&&m.upload&&([u,g]=Ei(l),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(c=R=>{m&&(i(!R||R.type?new Je(null,s,m):R),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const M=uc(n.url);if(M&&xt.protocols.indexOf(M)===-1){i(new N("Unsupported protocol "+M+":",N.ERR_BAD_REQUEST,s));return}m.send(r||null)})},yc=(s,t)=>{const{length:e}=s=s?s.filter(Boolean):[];if(t||e){let i=new AbortController,n;const r=function(a){if(!n){n=!0,h();const c=a instanceof Error?a:this.reason;i.abort(c instanceof N?c:new Je(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new N(`timeout of ${t}ms exceeded`,N.ETIMEDOUT))},t);const h=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),s=null)};s.forEach(a=>a.addEventListener("abort",r));const{signal:l}=i;return l.unsubscribe=()=>v.asap(h),l}},wc=function*(s,t){let e=s.byteLength;if(e<t){yield s;return}let i=0,n;for(;i<e;)n=i+t,yield s.slice(i,n),i=n},Sc=async function*(s,t){for await(const e of _c(s))yield*wc(e,t)},_c=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const t=s.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},qr=(s,t,e,i)=>{const n=Sc(s,t);let r=0,o,h=l=>{o||(o=!0,i&&i(l))};return new ReadableStream({async pull(l){try{const{done:a,value:c}=await n.next();if(a){h(),l.close();return}let u=c.byteLength;if(e){let p=r+=u;e(p)}l.enqueue(new Uint8Array(c))}catch(a){throw h(a),a}},cancel(l){return h(l),n.return()}},{highWaterMark:2})},Hr=64*1024,{isFunction:Ci}=v,Tc=(({Request:s,Response:t})=>({Request:s,Response:t}))(v.global),{ReadableStream:$r,TextEncoder:jr}=v.global,Jr=(s,...t)=>{try{return!!s(...t)}catch{return!1}},Ec=s=>{s=v.merge.call({skipUndefined:!0},Tc,s);const{fetch:t,Request:e,Response:i}=s,n=t?Ci(t):typeof fetch=="function",r=Ci(e),o=Ci(i);if(!n)return!1;const h=n&&Ci($r),l=n&&(typeof jr=="function"?(d=>f=>d.encode(f))(new jr):async d=>new Uint8Array(await new e(d).arrayBuffer())),a=r&&h&&Jr(()=>{let d=!1;const f=new e(xt.origin,{body:new $r,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!f}),c=o&&h&&Jr(()=>v.isReadableStream(new i("").body)),u={stream:c&&(d=>d.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(f,m)=>{let w=f&&f[d];if(w)return w.call(f);throw new N(`Response type '${d}' is not supported`,N.ERR_NOT_SUPPORT,m)})});const p=async d=>{if(d==null)return 0;if(v.isBlob(d))return d.size;if(v.isSpecCompliantForm(d))return(await new e(xt.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(v.isArrayBufferView(d)||v.isArrayBuffer(d))return d.byteLength;if(v.isURLSearchParams(d)&&(d=d+""),v.isString(d))return(await l(d)).byteLength},g=async(d,f)=>{const m=v.toFiniteNumber(d.getContentLength());return m??p(f)};return async d=>{let{url:f,method:m,data:w,signal:M,cancelToken:R,timeout:k,onDownloadProgress:$,onUploadProgress:Q,responseType:G,headers:st,withCredentials:tt="same-origin",fetchOptions:Nt}=Ir(d),Jt=t||fetch;G=G?(G+"").toLowerCase():"text";let Vt=yc([M,R&&R.toAbortSignal()],k),Bt=null;const dt=Vt&&Vt.unsubscribe&&(()=>{Vt.unsubscribe()});let et;try{if(Q&&a&&m!=="get"&&m!=="head"&&(et=await g(st,w))!==0){let gt=new e(f,{method:"POST",body:w,duplex:"half"}),J;if(v.isFormData(w)&&(J=gt.headers.get("content-type"))&&st.setContentType(J),gt.body){const[lt,St]=zr(et,Ei(Ur(Q)));w=qr(gt.body,Hr,lt,St)}}v.isString(tt)||(tt=tt?"include":"omit");const ot=r&&"credentials"in e.prototype,ht={...Nt,signal:Vt,method:m.toUpperCase(),headers:st.normalize().toJSON(),body:w,duplex:"half",credentials:ot?tt:void 0};Bt=r&&new e(f,ht);let Lt=await(r?Jt(Bt,Nt):Jt(f,ht));const wt=c&&(G==="stream"||G==="response");if(c&&($||wt&&dt)){const gt={};["status","statusText","headers"].forEach(bt=>{gt[bt]=Lt[bt]});const J=v.toFiniteNumber(Lt.headers.get("content-length")),[lt,St]=$&&zr(J,Ei(Ur($),!0))||[];Lt=new i(qr(Lt.body,Hr,lt,()=>{St&&St(),dt&&dt()}),gt)}G=G||"text";let mt=await u[v.findKey(u,G)||"text"](Lt,d);return!wt&&dt&&dt(),await new Promise((gt,J)=>{Fr(gt,J,{data:mt,headers:Dt.from(Lt.headers),status:Lt.status,statusText:Lt.statusText,config:d,request:Bt})})}catch(ot){throw dt&&dt(),ot&&ot.name==="TypeError"&&/Load failed|fetch/i.test(ot.message)?Object.assign(new N("Network Error",N.ERR_NETWORK,d,Bt),{cause:ot.cause||ot}):N.from(ot,ot&&ot.code,d,Bt)}}},Cc=new Map,Kr=s=>{let t=s&&s.env||{};const{fetch:e,Request:i,Response:n}=t,r=[i,n,e];let o=r.length,h=o,l,a,c=Cc;for(;h--;)l=r[h],a=c.get(l),a===void 0&&c.set(l,a=h?new Map:Ec(t)),c=a;return a};Kr();const Os={http:Ja,xhr:vc,fetch:{get:Kr}};v.forEach(Os,(s,t)=>{if(s){try{Object.defineProperty(s,"name",{value:t})}catch{}Object.defineProperty(s,"adapterName",{value:t})}});const Xr=s=>`- ${s}`,Lc=s=>v.isFunction(s)||s===null||s===!1;function xc(s,t){s=v.isArray(s)?s:[s];const{length:e}=s;let i,n;const r={};for(let o=0;o<e;o++){i=s[o];let h;if(n=i,!Lc(i)&&(n=Os[(h=String(i)).toLowerCase()],n===void 0))throw new N(`Unknown adapter '${h}'`);if(n&&(v.isFunction(n)||(n=n.get(t))))break;r[h||"#"+o]=n}if(!n){const o=Object.entries(r).map(([l,a])=>`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let h=e?o.length>1?`since :
|
|
4
|
+
`+o.map(Xr).join(`
|
|
5
|
+
`):" "+Xr(o[0]):"as no adapter specified";throw new N("There is no suitable adapter to dispatch the request "+h,"ERR_NOT_SUPPORT")}return n}const Yr={getAdapter:xc,adapters:Os};function ks(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Je(null,s)}function Gr(s){return ks(s),s.headers=Dt.from(s.headers),s.data=Rs.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Yr.getAdapter(s.adapter||$e.adapter,s)(s).then(function(i){return ks(s),i.data=Rs.call(s,s.transformResponse,i),i.headers=Dt.from(i.headers),i},function(i){return Br(i)||(ks(s),i&&i.response&&(i.response.data=Rs.call(s,s.transformResponse,i.response),i.response.headers=Dt.from(i.response.headers))),Promise.reject(i)})}const Zr="1.13.4",Li={};["object","boolean","number","function","string","symbol"].forEach((s,t)=>{Li[s]=function(i){return typeof i===s||"a"+(t<1?"n ":" ")+s}});const Qr={};Li.transitional=function(t,e,i){function n(r,o){return"[Axios v"+Zr+"] Transitional option '"+r+"'"+o+(i?". "+i:"")}return(r,o,h)=>{if(t===!1)throw new N(n(o," has been removed"+(e?" in "+e:"")),N.ERR_DEPRECATED);return e&&!Qr[o]&&(Qr[o]=!0,console.warn(n(o," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(r,o,h):!0}},Li.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Mc(s,t,e){if(typeof s!="object")throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const i=Object.keys(s);let n=i.length;for(;n-- >0;){const r=i[n],o=t[r];if(o){const h=s[r],l=h===void 0||o(h,r,s);if(l!==!0)throw new N("option "+r+" must be "+l,N.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new N("Unknown option "+r,N.ERR_BAD_OPTION)}}const xi={assertOptions:Mc,validators:Li},Yt=xi.validators;let ye=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Pr,response:new Pr}}async request(t,e){try{return await this._request(t,e)}catch(i){if(i instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const r=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?r&&!String(i.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(i.stack+=`
|
|
6
|
+
`+r):i.stack=r}catch{}}throw i}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=ve(this.defaults,e);const{transitional:i,paramsSerializer:n,headers:r}=e;i!==void 0&&xi.assertOptions(i,{silentJSONParsing:Yt.transitional(Yt.boolean),forcedJSONParsing:Yt.transitional(Yt.boolean),clarifyTimeoutError:Yt.transitional(Yt.boolean)},!1),n!=null&&(v.isFunction(n)?e.paramsSerializer={serialize:n}:xi.assertOptions(n,{encode:Yt.function,serialize:Yt.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),xi.assertOptions(e,{baseUrl:Yt.spelling("baseURL"),withXsrfToken:Yt.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=r&&v.merge(r.common,r[e.method]);r&&v.forEach(["delete","get","head","post","put","patch","common"],d=>{delete r[d]}),e.headers=Dt.concat(o,r);const h=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(l=l&&f.synchronous,h.unshift(f.fulfilled,f.rejected))});const a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});let c,u=0,p;if(!l){const d=[Gr.bind(this),void 0];for(d.unshift(...h),d.push(...a),p=d.length,c=Promise.resolve(e);u<p;)c=c.then(d[u++],d[u++]);return c}p=h.length;let g=e;for(;u<p;){const d=h[u++],f=h[u++];try{g=d(g)}catch(m){f.call(this,m);break}}try{c=Gr.call(this,g)}catch(d){return Promise.reject(d)}for(u=0,p=a.length;u<p;)c=c.then(a[u++],a[u++]);return c}getUri(t){t=ve(this.defaults,t);const e=Vr(t.baseURL,t.url,t.allowAbsoluteUrls);return kr(e,t.params,t.paramsSerializer)}};v.forEach(["delete","get","head","options"],function(t){ye.prototype[t]=function(e,i){return this.request(ve(i||{},{method:t,url:e,data:(i||{}).data}))}}),v.forEach(["post","put","patch"],function(t){function e(i){return function(r,o,h){return this.request(ve(h||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}ye.prototype[t]=e(),ye.prototype[t+"Form"]=e(!0)});let Rc=class No{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(r){e=r});const i=this;this.promise.then(n=>{if(!i._listeners)return;let r=i._listeners.length;for(;r-- >0;)i._listeners[r](n);i._listeners=null}),this.promise.then=n=>{let r;const o=new Promise(h=>{i.subscribe(h),r=h}).then(n);return o.cancel=function(){i.unsubscribe(r)},o},t(function(r,o,h){i.reason||(i.reason=new Je(r,o,h),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=i=>{t.abort(i)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new No(function(n){t=n}),cancel:t}}};function Oc(s){return function(e){return s.apply(null,e)}}function kc(s){return v.isObject(s)&&s.isAxiosError===!0}const Ps={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ps).forEach(([s,t])=>{Ps[t]=s});function to(s){const t=new ye(s),e=vr(ye.prototype.request,t);return v.extend(e,ye.prototype,t,{allOwnKeys:!0}),v.extend(e,t,null,{allOwnKeys:!0}),e.create=function(n){return to(ve(s,n))},e}const ft=to($e);ft.Axios=ye,ft.CanceledError=Je,ft.CancelToken=Rc,ft.isCancel=Br,ft.VERSION=Zr,ft.toFormData=_i,ft.AxiosError=N,ft.Cancel=ft.CanceledError,ft.all=function(t){return Promise.all(t)},ft.spread=Oc,ft.isAxiosError=kc,ft.mergeConfig=ve,ft.AxiosHeaders=Dt,ft.formToJSON=s=>Dr(v.isHTMLForm(s)?new FormData(s):s),ft.getAdapter=Yr.getAdapter,ft.HttpStatusCode=Ps,ft.default=ft;const{Axios:Ku,AxiosError:Xu,CanceledError:Yu,isCancel:Gu,CancelToken:Zu,VERSION:Qu,all:tf,Cancel:ef,isAxiosError:sf,spread:nf,toFormData:rf,AxiosHeaders:of,HttpStatusCode:hf,formToJSON:lf,getAdapter:af,mergeConfig:cf}=ft,Gt=Object.create(null);Gt.open="0",Gt.close="1",Gt.ping="2",Gt.pong="3",Gt.message="4",Gt.upgrade="5",Gt.noop="6";const Mi=Object.create(null);Object.keys(Gt).forEach(s=>{Mi[Gt[s]]=s});const As={type:"error",data:"parser error"},eo=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",io=typeof ArrayBuffer=="function",so=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Ds=({type:s,data:t},e,i)=>eo&&t instanceof Blob?e?i(t):no(t,i):io&&(t instanceof ArrayBuffer||so(t))?e?i(t):no(new Blob([t]),i):i(Gt[s]+(t||"")),no=(s,t)=>{const e=new FileReader;return e.onload=function(){const i=e.result.split(",")[1];t("b"+(i||""))},e.readAsDataURL(s)};function ro(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Ns;function Pc(s,t){if(eo&&s.data instanceof Blob)return s.data.arrayBuffer().then(ro).then(t);if(io&&(s.data instanceof ArrayBuffer||so(s.data)))return t(ro(s.data));Ds(s,!1,e=>{Ns||(Ns=new TextEncoder),t(Ns.encode(e))})}const oo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ke=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<oo.length;s++)Ke[oo.charCodeAt(s)]=s;const Ac=s=>{let t=s.length*.75,e=s.length,i,n=0,r,o,h,l;s[s.length-1]==="="&&(t--,s[s.length-2]==="="&&t--);const a=new ArrayBuffer(t),c=new Uint8Array(a);for(i=0;i<e;i+=4)r=Ke[s.charCodeAt(i)],o=Ke[s.charCodeAt(i+1)],h=Ke[s.charCodeAt(i+2)],l=Ke[s.charCodeAt(i+3)],c[n++]=r<<2|o>>4,c[n++]=(o&15)<<4|h>>2,c[n++]=(h&3)<<6|l&63;return a},Dc=typeof ArrayBuffer=="function",Bs=(s,t)=>{if(typeof s!="string")return{type:"message",data:ho(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:Nc(s.substring(1),t)}:Mi[e]?s.length>1?{type:Mi[e],data:s.substring(1)}:{type:Mi[e]}:As},Nc=(s,t)=>{if(Dc){const e=Ac(s);return ho(e,t)}else return{base64:!0,data:s}},ho=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,lo="",Bc=(s,t)=>{const e=s.length,i=new Array(e);let n=0;s.forEach((r,o)=>{Ds(r,!1,h=>{i[o]=h,++n===e&&t(i.join(lo))})})},Fc=(s,t)=>{const e=s.split(lo),i=[];for(let n=0;n<e.length;n++){const r=Bs(e[n],t);if(i.push(r),r.type==="error")break}return i};function zc(){return new TransformStream({transform(s,t){Pc(s,e=>{const i=e.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const r=new DataView(n.buffer);r.setUint8(0,126),r.setUint16(1,i)}else{n=new Uint8Array(9);const r=new DataView(n.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(i))}s.data&&typeof s.data!="string"&&(n[0]|=128),t.enqueue(n),t.enqueue(e)})}})}let Fs;function Ri(s){return s.reduce((t,e)=>t+e.length,0)}function Oi(s,t){if(s[0].length===t)return s.shift();const e=new Uint8Array(t);let i=0;for(let n=0;n<t;n++)e[n]=s[0][i++],i===s[0].length&&(s.shift(),i=0);return s.length&&i<s[0].length&&(s[0]=s[0].slice(i)),e}function Uc(s,t){Fs||(Fs=new TextDecoder);const e=[];let i=0,n=-1,r=!1;return new TransformStream({transform(o,h){for(e.push(o);;){if(i===0){if(Ri(e)<1)break;const l=Oi(e,1);r=(l[0]&128)===128,n=l[0]&127,n<126?i=3:n===126?i=1:i=2}else if(i===1){if(Ri(e)<2)break;const l=Oi(e,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),i=3}else if(i===2){if(Ri(e)<8)break;const l=Oi(e,8),a=new DataView(l.buffer,l.byteOffset,l.length),c=a.getUint32(0);if(c>Math.pow(2,21)-1){h.enqueue(As);break}n=c*Math.pow(2,32)+a.getUint32(4),i=3}else{if(Ri(e)<n)break;const l=Oi(e,n);h.enqueue(Bs(r?l:Fs.decode(l),t)),i=0}if(n===0||n>s){h.enqueue(As);break}}}})}const ao=4;function _t(s){if(s)return Vc(s)}function Vc(s){for(var t in _t.prototype)s[t]=_t.prototype[t];return s}_t.prototype.on=_t.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},_t.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},_t.prototype.off=_t.prototype.removeListener=_t.prototype.removeAllListeners=_t.prototype.removeEventListener=function(s,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+s];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var i,n=0;n<e.length;n++)if(i=e[n],i===t||i.fn===t){e.splice(n,1);break}return e.length===0&&delete this._callbacks["$"+s],this},_t.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+s],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(e){e=e.slice(0);for(var i=0,n=e.length;i<n;++i)e[i].apply(this,t)}return this},_t.prototype.emitReserved=_t.prototype.emit,_t.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},_t.prototype.hasListeners=function(s){return!!this.listeners(s).length};const ki=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Ut=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Wc="arraybuffer";function uf(){}function co(s,...t){return t.reduce((e,i)=>(s.hasOwnProperty(i)&&(e[i]=s[i]),e),{})}const Ic=Ut.setTimeout,qc=Ut.clearTimeout;function Pi(s,t){t.useNativeTimers?(s.setTimeoutFn=Ic.bind(Ut),s.clearTimeoutFn=qc.bind(Ut)):(s.setTimeoutFn=Ut.setTimeout.bind(Ut),s.clearTimeoutFn=Ut.clearTimeout.bind(Ut))}const Hc=1.33;function $c(s){return typeof s=="string"?jc(s):Math.ceil((s.byteLength||s.size)*Hc)}function jc(s){let t=0,e=0;for(let i=0,n=s.length;i<n;i++)t=s.charCodeAt(i),t<128?e+=1:t<2048?e+=2:t<55296||t>=57344?e+=3:(i++,e+=4);return e}function uo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Jc(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function Kc(s){let t={},e=s.split("&");for(let i=0,n=e.length;i<n;i++){let r=e[i].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}class Xc extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class zs extends _t{constructor(t){super(),this.writable=!1,Pi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,i){return super.emitReserved("error",new Xc(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Bs(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=Jc(t);return e.length?"?"+e:""}}class Yc extends zs{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||e()})),this.writable||(i++,this.once("drain",function(){--i||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Fc(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Bc(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=uo()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let fo=!1;try{fo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Gc=fo;function Zc(){}class Qc extends Yc{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let i=location.port;i||(i=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",(n,r)=>{this.onError("xhr post error",n,r)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,i)=>{this.onError("xhr poll error",e,i)}),this.pollXhr=t}}class Zt extends _t{constructor(t,e,i){super(),this.createRequest=t,Pi(this,i),this._opts=i,this._method=i.method||"GET",this._uri=e,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;const e=co(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(e);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&i.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var n;i.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=Zt.requestsCount++,Zt.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Zc,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Zt.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(Zt.requestsCount=0,Zt.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",po);else if(typeof addEventListener=="function"){const s="onpagehide"in Ut?"pagehide":"unload";addEventListener(s,po,!1)}}function po(){for(let s in Zt.requests)Zt.requests.hasOwnProperty(s)&&Zt.requests[s].abort()}const tu=(function(){const s=mo({xdomain:!1});return s&&s.responseType!==null})();class eu extends Qc{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=tu&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Zt(mo,this.uri(),t)}}function mo(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Gc))return new XMLHttpRequest}catch{}if(!t)try{return new Ut[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const go=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class iu extends zs{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,i=go?{}:co(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,i)}catch(n){return this.emitReserved("error",n)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;Ds(i,this.supportsBinary,r=>{try{this.doWrite(i,r)}catch{}n&&ki(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=uo()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Us=Ut.WebSocket||Ut.MozWebSocket;class su extends iu{createSocket(t,e,i){return go?new Us(t,e,i):e?new Us(t,e):new Us(t)}doWrite(t,e){this.ws.send(e)}}class nu extends zs{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=Uc(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),n=zc();n.readable.pipeTo(t.writable),this._writer=n.writable.getWriter();const r=()=>{i.read().then(({done:h,value:l})=>{h||(this.onPacket(l),r())}).catch(h=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const i=t[e],n=e===t.length-1;this._writer.write(i).then(()=>{n&&ki(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ru={websocket:su,webtransport:nu,polling:eu},ou=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,hu=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Vs(s){if(s.length>8e3)throw"URI too long";const t=s,e=s.indexOf("["),i=s.indexOf("]");e!=-1&&i!=-1&&(s=s.substring(0,e)+s.substring(e,i).replace(/:/g,";")+s.substring(i,s.length));let n=ou.exec(s||""),r={},o=14;for(;o--;)r[hu[o]]=n[o]||"";return e!=-1&&i!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=lu(r,r.path),r.queryKey=au(r,r.query),r}function lu(s,t){const e=/\/{2,9}/g,i=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function au(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,n,r){n&&(e[n]=r)}),e}const Ws=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ai=[];Ws&&addEventListener("offline",()=>{Ai.forEach(s=>s())},!1);class ce extends _t{constructor(t,e){if(super(),this.binaryType=Wc,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const i=Vs(t);e.hostname=i.host,e.secure=i.protocol==="https"||i.protocol==="wss",e.port=i.port,i.query&&(e.query=i.query)}else e.host&&(e.hostname=Vs(e.host).host);Pi(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(i=>{const n=i.prototype.name;this.transports.push(n),this._transportsByName[n]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Kc(this.opts.query)),Ws&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ai.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=ao,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&ce.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",ce.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let i=0;i<this.writeBuffer.length;i++){const n=this.writeBuffer[i].data;if(n&&(e+=$c(n)),i>0&&e>this._maxPayload)return this.writeBuffer.slice(0,i);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ki(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,i){return this._sendPacket("message",t,e,i),this}send(t,e,i){return this._sendPacket("message",t,e,i),this}_sendPacket(t,e,i,n){if(typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const r={type:t,data:e,options:i};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():t()}):this.upgrading?i():t()),this}_onError(t){if(ce.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ws&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=Ai.indexOf(this._offlineEventListener);i!==-1&&Ai.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}ce.protocol=ao;class cu extends ce{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),i=!1;ce.priorWebsocketSuccess=!1;const n=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",u=>{if(!i)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;ce.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(c(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=e.name,this.emitReserved("upgradeError",p)}}))};function r(){i||(i=!0,c(),e.close(),e=null)}const o=u=>{const p=new Error("probe error: "+u);p.transport=e.name,r(),this.emitReserved("upgradeError",p)};function h(){o("transport closed")}function l(){o("socket closed")}function a(u){e&&u.name!==e.name&&r()}const c=()=>{e.removeListener("open",n),e.removeListener("error",o),e.removeListener("close",h),this.off("close",l),this.off("upgrading",a)};e.once("open",n),e.once("error",o),e.once("close",h),this.once("close",l),this.once("upgrading",a),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&e.push(t[i]);return e}}let uu=class extends cu{constructor(t,e={}){const i=typeof t=="object"?t:e;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(n=>ru[n]).filter(n=>!!n)),super(t,i)}};function fu(s,t="",e){let i=s;e=e||typeof location<"u"&&location,s==null&&(s=e.protocol+"//"+e.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=e.protocol+s:s=e.host+s),/^(https?|wss?):\/\//.test(s)||(typeof e<"u"?s=e.protocol+"//"+s:s="https://"+s),i=Vs(s)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const r=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+r+":"+i.port+t,i.href=i.protocol+"://"+r+(e&&e.port===i.port?"":":"+i.port),i}const du=typeof ArrayBuffer=="function",pu=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,bo=Object.prototype.toString,mu=typeof Blob=="function"||typeof Blob<"u"&&bo.call(Blob)==="[object BlobConstructor]",gu=typeof File=="function"||typeof File<"u"&&bo.call(File)==="[object FileConstructor]";function Is(s){return du&&(s instanceof ArrayBuffer||pu(s))||mu&&s instanceof Blob||gu&&s instanceof File}function Di(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,i=s.length;e<i;e++)if(Di(s[e]))return!0;return!1}if(Is(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Di(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&Di(s[e]))return!0;return!1}function bu(s){const t=[],e=s.data,i=s;return i.data=qs(e,t),i.attachments=t.length,{packet:i,buffers:t}}function qs(s,t){if(!s)return s;if(Is(s)){const e={_placeholder:!0,num:t.length};return t.push(s),e}else if(Array.isArray(s)){const e=new Array(s.length);for(let i=0;i<s.length;i++)e[i]=qs(s[i],t);return e}else if(typeof s=="object"&&!(s instanceof Date)){const e={};for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=qs(s[i],t));return e}return s}function vu(s,t){return s.data=Hs(s.data,t),delete s.attachments,s}function Hs(s,t){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<t.length)return t[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let e=0;e<s.length;e++)s[e]=Hs(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Hs(s[e],t));return s}const yu=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Y;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(Y||(Y={}));class wu{constructor(t){this.replacer=t}encode(t){return(t.type===Y.EVENT||t.type===Y.ACK)&&Di(t)?this.encodeAsBinary({type:t.type===Y.EVENT?Y.BINARY_EVENT:Y.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===Y.BINARY_EVENT||t.type===Y.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=bu(t),i=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(i),n}}class $s extends _t{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const i=e.type===Y.BINARY_EVENT;i||e.type===Y.BINARY_ACK?(e.type=i?Y.EVENT:Y.ACK,this.reconstructor=new Su(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Is(t)||t.base64)if(this.reconstructor)e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let e=0;const i={type:Number(t.charAt(0))};if(Y[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Y.BINARY_EVENT||i.type===Y.BINARY_ACK){const r=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(r,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(t.charAt(e+1)==="/"){const r=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););i.nsp=t.substring(r,e)}else i.nsp="/";const n=t.charAt(e+1);if(n!==""&&Number(n)==n){const r=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}i.id=Number(t.substring(r,e+1))}if(t.charAt(++e)){const r=this.tryParse(t.substr(e));if($s.isPayloadValid(i.type,r))i.data=r;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case Y.CONNECT:return vo(e);case Y.DISCONNECT:return e===void 0;case Y.CONNECT_ERROR:return typeof e=="string"||vo(e);case Y.EVENT:case Y.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&yu.indexOf(e[0])===-1);case Y.ACK:case Y.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Su{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=vu(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function vo(s){return Object.prototype.toString.call(s)==="[object Object]"}const _u=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$s,Encoder:wu,get PacketType(){return Y}},Symbol.toStringTag,{value:"Module"}));function jt(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const Tu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yo extends _t{constructor(t,e,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[jt(t,"open",this.onopen.bind(this)),jt(t,"packet",this.onpacket.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var i,n,r;if(Tu.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const o={type:Y.EVENT,data:e};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const c=this.ids++,u=e.pop();this._registerAckCallback(c,u),o.id=c}const h=(n=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||n===void 0?void 0:n.writable,l=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!h||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,e){var i;const n=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(n===void 0){this.acks[t]=e;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===t&&this.sendBuffer.splice(h,1);e.call(this,new Error("operation has timed out"))},n),o=(...h)=>{this.io.clearTimeoutFn(r),e.apply(this,h)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((i,n)=>{const r=(o,h)=>o?n(o):i(h);r.withError=!0,e.push(r),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((n,...r)=>(this._queue[0],n!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(n)):(this._queue.shift(),e&&e(null,...r)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Y.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Y.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Y.EVENT:case Y.BINARY_EVENT:this.onevent(t);break;case Y.ACK:case Y.BINARY_ACK:this.onack(t);break;case Y.DISCONNECT:this.ondisconnect();break;case Y.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...n){i||(i=!0,e.packet({type:Y.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Y.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let i=0;i<e.length;i++)if(t===e[i])return e.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const i of e)i.apply(this,t.data)}}}function Re(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}Re.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*s);s=(Math.floor(t*10)&1)==0?s-e:s+e}return Math.min(s,this.max)|0},Re.prototype.reset=function(){this.attempts=0},Re.prototype.setMin=function(s){this.ms=s},Re.prototype.setMax=function(s){this.max=s},Re.prototype.setJitter=function(s){this.jitter=s};class js extends _t{constructor(t,e){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,Pi(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((i=e.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new Re({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||_u;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new uu(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=jt(e,"open",function(){i.onopen(),t&&t()}),r=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),t?t(h):this.maybeReconnectOnOpen()},o=jt(e,"error",r);if(this._timeout!==!1){const h=this._timeout,l=this.setTimeoutFn(()=>{n(),r(new Error("timeout")),e.close()},h);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(jt(t,"ping",this.onping.bind(this)),jt(t,"data",this.ondata.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this)),jt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){ki(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new yo(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const i of e)if(this.nsps[i].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;i<e.length;i++)this.engine.write(e[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(n=>{n?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",n)):t.onreconnect()}))},e);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Xe={};function Ni(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=fu(s,t.path||"/socket.io"),i=e.source,n=e.id,r=e.path,o=Xe[n]&&r in Xe[n].nsps,h=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return h?l=new js(i,t):(Xe[n]||(Xe[n]=new js(i,t)),l=Xe[n]),e.query&&!t.query&&(t.query=e.queryKey),l.socket(e.path,t)}Object.assign(Ni,{Manager:js,Socket:yo,io:Ni,connect:Ni});let Js="http://localhost:8000";function wo(s){s&&s!==Js&&(Js=s,Qt&&(Qt.disconnect(),Qt=null))}let Qt=null;function Eu(){return Ni(Js,{transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,reconnectionAttempts:1/0,timeout:1e4,forceNew:!1})}function Ks(){return Qt||(Qt=Eu()),Qt}function Cu(s,t){const e=Ks();return e.on(s,t),()=>e.off(s,t)}function Lu(s,t){Qt&&Qt.off(s,t)}function xu(s,t){Ks().emit(s,t)}function Mu(){return Qt?Qt.connected?"connected":"connecting":"disconnected"}const Xs={getSocket:Ks,on:Cu,off:Lu,emit:xu,getStatus:Mu,setBaseUrl:wo},So=E.createContext(),_o=()=>{const s=E.useContext(So);if(!s)throw new Error("useTrading must be used within TradingProvider");return s},Ru=({children:s,baseUrl:t})=>{const e=t||typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Bi&&Bi.tagName.toUpperCase()==="SCRIPT"&&Bi.src||new URL("chart-sdk.umd.js",document.baseURI).href}<"u"&&"http://localhost:8000"||"http://localhost:8000";E.useEffect(()=>{Xs.setBaseUrl(e),Po(e)},[e]);const[i,n]=E.useState("CADJPY"),[r,o]=E.useState("M1"),[h,l]=E.useState([]),[a,c]=E.useState(!0),[u,p]=E.useState([]),[g,d]=E.useState(!1),[f,m]=E.useState(1e5),[w,M]=E.useState(null),[R,k]=E.useState([]),[$,Q]=E.useState(!0),[G,st]=E.useState(!1),[tt,Nt]=E.useState(!0),[Jt,Vt]=E.useState("candles"),[Bt,dt]=E.useState(!1),et=E.useRef(null),ot=E.useRef(new Map),ht=E.useRef(null),Lt=1e3,wt=E.useCallback(async()=>{try{const U=localStorage.getItem("token");if(!U){console.log("⚠️ No token, skipping orders fetch");return}d(!0);const X=await ft.get(`${e}/api/trades`,{headers:{Authorization:`Bearer ${U}`}});if(X.data&&X.data.data){const I=X.data.data.map(K=>({id:K.id,ticket:K.ticket,symbol:K.symbol,type:K.type,volume:K.volume,price:K.price,stopLoss:K.stopLoss,takeProfit:K.takeProfit,comment:K.comment||"",status:K.status,swap:K.swap||0,profit:K.profit||0,profitCurrency:"USD",time:new Date(K.openAt).toLocaleTimeString(),openAt:K.openAt,closeAt:K.closeAt}));p(I)}else p([])}catch(U){console.error("❌ Error fetching orders:",U.response?.data||U.message),p([])}finally{d(!1)}},[]),mt=E.useCallback((U,X)=>!X||!U.price||isNaN(X)||isNaN(U.price)?U.profit||0:(U.type==="BUY"?X-U.price:U.price-X)*U.volume,[]),gt=E.useCallback(async()=>{try{const U=localStorage.getItem("token");if(!U){console.log("⚠️ No token, skipping balance fetch");return}const X=await ft.get(`${e}/api/user/account`,{headers:{Authorization:`Bearer ${U}`}});if(X.data&&X.data.data){const I=parseFloat(X.data.data.balance);isNaN(I)||m(I)}}catch(U){console.error("❌ Error fetching user balance:",U.response?.data||U.message)}},[]),J=E.useMemo(()=>{const U=f,X=u.reduce((vt,Et)=>vt+Et.volume*Et.price*.01,0),I=u.reduce((vt,Et)=>{const Wt=h.find(It=>It.symbol===Et.symbol);if(Wt){const It=Et.type==="BUY"?parseFloat(Wt.bid||0):parseFloat(Wt.ask||0);if(It&&It>0&&!isNaN(It))return vt+mt(Et,It)}return vt+(Et.profit||0)},0),K=U+I,Ft=K-X,nt=X>0?K/X*100:0;return{balance:U,equity:K,margin:X,freeMargin:Ft,level:nt.toFixed(2)}},[u,h,f,mt]);E.useEffect(()=>{localStorage.getItem("token")&&(wt(),gt())},[wt,gt]),E.useEffect(()=>{(async()=>{try{c(!0);const X=await ft.get(`${e}/api/symbols`);if(X.data&&X.data.data){const I=X.data.data;l(I),I.length>0&&(I.find(Ft=>Ft.symbol===i)||n(I[0].symbol))}else l([])}catch(X){console.error("❌ Error fetching symbols:",X.response?.data||X.message),l([])}finally{c(!1)}})()},[]);const lt=E.useCallback(()=>{const U=ot.current;if(U.size===0)return;const X=new Map(U);U.clear(),l(I=>I.map(K=>{const Ft=X.get(K.symbol);return Ft?{...K,...Ft}:K})),p(I=>{let K=!1;const Ft=I.map(nt=>{const vt=X.get(nt.symbol);if(!vt)return nt;const Et=nt.type==="BUY"?parseFloat(vt.bid||0):parseFloat(vt.ask||0);if(!Et||isNaN(Et)||Et<=0)return nt;const Wt=mt(nt,Et);return Wt===nt.profit?nt:(K=!0,{...nt,profit:Wt})});return K?Ft:I})},[mt]);E.useEffect(()=>{et.current||(et.current=Xs.getSocket());const U=et.current,X=()=>console.log("✅ TradingContext: Connected"),I=()=>console.log("⚠️ TradingContext: Disconnected"),K=nt=>{nt?.symbol&&(ot.current.set(nt.symbol,nt),ht.current||(ht.current=setTimeout(()=>{ht.current=null,lt()},Lt)))},Ft=async nt=>{if(console.log("🔔 Trade closed event received:",nt),!!nt){if(nt.newBalance!==void 0){const vt=parseFloat(nt.newBalance);isNaN(vt)||m(vt)}if(window.notify){const vt=nt.profitLoss||nt.profit||0,Et=vt>=0?`+${vt.toFixed(2)}`:vt.toFixed(2),Wt=nt.symbol||"Trade",It=nt.reason||"Closed";window.notify(`Trade Closed: ${It} | ${Wt} | P/L: ${Et} USD`,vt>=0?"success":"error")}nt.tradeId&&p(vt=>vt.filter(Et=>Et.id!==nt.tradeId)),await wt(),await gt()}};return U.on("connect",X),U.on("disconnect",I),U.on("priceUpdate",K),U.on("tradeClosed",Ft),()=>{U.off("connect",X),U.off("disconnect",I),U.off("priceUpdate",K),U.off("tradeClosed",Ft),ht.current&&(clearTimeout(ht.current),ht.current=null),ot.current.clear()}},[lt,wt,gt]);const St=E.useMemo(()=>h.find(U=>U.symbol===i)||{bid:"0.00000",ask:"0.00000",change:0},[h,i]),bt=E.useMemo(()=>({selectedSymbol:i,setSelectedSymbol:n,selectedTimeframe:r,setSelectedTimeframe:o,symbols:h,setSymbols:l,symbolsLoading:a,orders:u,setOrders:p,ordersLoading:g,fetchOrders:wt,fetchUserBalance:gt,userBalance:f,setUserBalance:m,accountSummary:J,currentSymbolData:St,activeTool:w,setActiveTool:M,chartObjects:R,setChartObjects:k,showGrid:$,setShowGrid:Q,snapToGrid:G,setSnapToGrid:st,drawingsVisible:tt,setDrawingsVisible:Nt,chartType:Jt,setChartType:Vt,chartLocked:Bt,setChartLocked:dt}),[i,r,h,a,u,g,wt,gt,f,J,St,w,R,$,G,tt,Jt,Bt]);return ne.jsx(So.Provider,{value:bt,children:s})};function Tt(s){if(s==null)return null;if(typeof s=="number"){if(Number.isNaN(s)||!Number.isFinite(s))return null;let t;s>1e10?t=s/1e3:(s<1e9,t=s);const e=Math.floor(t);return e<946684800||e>4102444800?null:e}if(typeof s=="string"){const t=Date.parse(s);return Number.isNaN(t)?null:Math.floor(t/1e3)}if(typeof s=="object"&&"year"in s&&"month"in s&&"day"in s){const e=new Date(Date.UTC(s.year,s.month-1,s.day)).getTime();return Number.isNaN(e)?null:Math.floor(e/1e3)}return null}function Ou(s,t){if(!s||s.length<2)return[];const e=[],i=2;for(let n=1;n<s.length;n++){const r=s[n-1].time,o=s[n].time,h=o-r;h>t*i&&e.push({from:r,to:o,gapSeconds:h,gapHours:(h/3600).toFixed(1),fromDate:new Date(r*1e3).toISOString(),toDate:new Date(o*1e3).toISOString()})}return e}function ku(s,t="America/New_York"){const e=new Date(s*1e3),i=new Date(e.toLocaleString("en-US",{timeZone:t})),n=i.getDay();return!(n===0||n===6||n===5&&i.getHours()>=17)}function To(s){return Array.isArray(s)?s.map(t=>({...t,time:Tt(t.time)})).filter(t=>t.time!=null):[]}function Pu(s){if(!s||s.length<2)return!0;for(let t=1;t<s.length;t++)if(s[t].time<=s[t-1].time)return!1;return!0}function Oe(s,t){return!Number.isFinite(s)||!Number.isFinite(t)||t<=0?s:Math.floor(s/t)*t}const Mt="17:00-17:00",Rt="America/New_York",te="24x7",ee="UTC",Eo={EURUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},GBPUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDCHF:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},AUDUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},USDCAD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},NZDUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURGBP:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},GBPJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},CADJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},EURJPY:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},XAUUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},XAGUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},OILUSD:{type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"},BTCUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},ETHUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},BNBUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},SOLUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},ADAUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},XRPUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},DOGEUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},DOTUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},MATICUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"},LINKUSDT:{type:"crypto",session:te,sessionTZ:ee,priceMode:"last"}},Co={type:"forex",sessionTZ:Rt,session:Mt,priceMode:"mid"};function Ye(s){return s&&Eo[s.toUpperCase()]||Co}function Au(s){return Ye(s).type==="forex"}function Ys(s){return Ye(s).type==="crypto"}function Du(s){return Ye(s).session==="24x7"}function Lo(s){if(!s||typeof s!="object")return!1;const{time:t,open:e,high:i,low:n,close:r,volume:o}=s;return!(Tt(t)==null||typeof e!="number"||!Number.isFinite(e)||typeof i!="number"||!Number.isFinite(i)||typeof n!="number"||!Number.isFinite(n)||typeof r!="number"||!Number.isFinite(r)||o!=null&&(typeof o!="number"||o<0||!Number.isFinite(o))||i<e||i<r||i<n||n>e||n>r||n>i||e<=0||i<=0||n<=0||r<=0)}function xo(s){const t=o=>Math.round(o*1e5)/1e5;let e=t(s.open),i=t(s.high),n=t(s.low),r=t(s.close);return i=Math.max(i,e,r,n),n=Math.min(n,e,r,i),{...s,open:e,high:i,low:n,close:r,volume:s.volume!=null?Math.round(s.volume):s.volume}}function Mo(s){if(!Array.isArray(s)||s.length===0)return[];const t=new Map;return s.forEach(e=>{const i=Tt(e.time);if(i!=null)if(t.has(i)){const n=t.get(i);t.set(i,{...e,time:i,open:e.open,high:Math.max(n.high,e.high),low:Math.min(n.low,e.low),close:e.close,volume:(n.volume||0)+(e.volume||0)})}else t.set(i,{...e,time:i})}),Array.from(t.values())}function Nu(s,t="percentile"){if(!Array.isArray(s)||s.length<3)return s;const e=s.map(o=>o.close).filter(o=>Number.isFinite(o));if(e.length<3)return s;const i=[...e].sort((o,h)=>o-h);let n,r;if(t==="percentile"){const o=Math.floor(i.length*.25),h=Math.floor(i.length*.75),l=i[o],a=i[h],c=a-l;n=l-1.5*c,r=a+1.5*c}else{const o=e.reduce((a,c)=>a+c,0)/e.length,h=e.reduce((a,c)=>a+Math.pow(c-o,2),0)/e.length,l=Math.sqrt(h);if(l===0)return s;n=o-3*l,r=o+3*l}return s.map((o,h)=>{const l=o.close;if(l<n||l>r){if(h===0)return o;const a=s[h-1].close;return{...o,open:a,high:Math.max(a,o.high),low:Math.min(a,o.low),close:a}}return o})}function Bu(s,t){if(!Array.isArray(s)||s.length===0)return s;const e=[],i=Math.max(t*10080,604800),n=1e4;for(let h=0;h<s.length;h++)if(e.push(s[h]),h<s.length-1){const l=s[h].time,a=s[h+1].time,c=a-l;if(c>i&&((c/3600).toFixed(1),(i/3600).toFixed(1)),c>t&&c<=i){const u=s[h];let p=l+t,g=0;for(p=Oe(p,t);p<a&&g<n;){const d=Oe(p,t);e.some(m=>m.time===d)||(e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0}),g++),p+=t}if(p<a&&g>=n){const d=Oe(a-t,t);e.some(m=>m.time===d)||e.push({time:d,open:u.close,high:u.close,low:u.close,close:u.close,volume:0})}}}e.sort((h,l)=>h.time-l.time);const r=[],o=new Set;for(const h of e)o.has(h.time)||(o.add(h.time),r.push(h));return r}function Gs(s){if(!s||typeof s!="string")return 60;const t=s.toUpperCase();if(t==="MN")return 2592e3;let e=t.match(/^([MHDW])(\d+)$/);if(e){const i=e[1];return parseInt(e[2],10)*({M:60,H:3600,D:86400,W:604800}[i]||60)}if(e=s.match(/^(\d+)([mhdwy])$/i),e){const i=parseInt(e[1],10),n=e[2].toLowerCase();return i*({m:60,h:3600,d:86400,w:604800,y:31536e3}[n]||60)}return 60}function Ro(s,t,e){if(!Array.isArray(s)||s.length===0)return{candles:[],stats:{original:0,processed:0,duplicates:0,outliers:0,gaps:[]}};const i=Ye(t),n=Gs(e),h=To(s).map(m=>({...m,time:Oe(m.time,n)})).filter(m=>Lo(m)).map(m=>xo(m)),l=Mo(h);l.sort((m,w)=>m.time-w.time);const a=l.filter((m,w)=>w===0?!0:m.time>l[w-1].time),c=a.length>10?Nu(a,"percentile"):a,u=Mo(c);u.sort((m,w)=>m.time-w.time);const p=Bu(u,n),g=[];for(let m=1;m<p.length;m++){const w=p[m].time-p[m-1].time;w>n*2&&g.push({from:p[m-1].time,to:p[m].time,gapSeconds:w,gapMinutes:Math.round(w/60),fromDate:new Date(p[m-1].time*1e3).toISOString(),toDate:new Date(p[m].time*1e3).toISOString()})}const d=c.filter((m,w)=>w===0?!1:m.close===c[w-1].close&&m.open===c[w-1].close).length,f={original:s.length,processed:p.length,duplicates:s.length-l.length,outliers:d,gaps:g,filledGaps:p.length-u.length,symbolConfig:i};return{candles:p,stats:f}}function Oo(s,t,e="1m"){if(!s||!t||!Lo(s))return null;const i=Tt(s.time);if(i==null)return null;const n=Gs(e),r=Oe(i,n);return xo({...s,time:r})}let ko="http://localhost:8000";function Po(s){s&&(ko=s)}const Fu={M1:3,M5:7,M15:14,M30:30,H1:90,H4:180,D1:1095,W1:1825,MN:3650};function Ao(s){if(!s)return 7;const t=String(s).toUpperCase();return Fu[t]??7}function zu(s,t){const e=String(s||"").toUpperCase(),i=t||Ao(s),n={M1:1440,M5:288,M15:96,M30:48,H1:24,H4:6,D1:1,W1:1/7,MN:1/30}[e]||96,r=Math.ceil(i*(typeof n=="number"?n:96));return Math.min(Math.max(r,500),5e3)}const Ot=s=>{if(!Array.isArray(s)||s.length===0)return[];const t=s.map(i=>({...i,time:Tt(i.time)})).filter(i=>i.time!=null);t.sort((i,n)=>i.time-n.time);const e=new Map;for(const i of t)e.set(i.time,i);return Array.from(e.values()).sort((i,n)=>i.time-n.time)};function Uu(s,t,e,i,n,r){const o=n-e,h=r-i,l=Math.sqrt(o*o+h*h);if(l===0)return Math.hypot(s-e,t-i);let a=((s-e)*o+(t-i)*h)/(l*l);a=Math.max(0,Math.min(1,a));const c=e+a*o,u=i+a*h;return Math.hypot(s-c,t-u)}function Zs(s,t,e,i,n){if(!e||!i||!n)return null;const r=e.time,o=i.time,h=o-r,l=e.price,a=i.price,c=n.price;if(Math.abs(h)<1e-9){const d=c-l;return[{time:r,price:l+d},{time:o+1,price:a+d}]}const u=(a-l)/h,p=c+u*(r-n.time),g=c+u*(o-n.time);return[{time:r,price:p},{time:o,price:g}]}const Vu=E.forwardRef(function({bidPrice:t="113.638",askPrice:e="113.649",showBuySellPanel:i=!0,onBuyClick:n,onSellClick:r},o){const h=E.useRef(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(null),u=E.useRef([]),p=E.useRef(!1),g=E.useRef(null),d=E.useRef(null),f=E.useRef(null),m=E.useRef(null),w=E.useRef([]),[M,R]=E.useState(null),[k,$]=E.useState([]),Q=E.useRef(null),G=E.useRef(null),st=E.useRef(null),tt=E.useRef(!1);E.useEffect(()=>{st.current=M},[M]);const Nt=E.useRef(new Map),Jt=E.useRef(null),Vt=(b,y)=>`${b}_${y}`,Bt=()=>{const b=Vt(J,lt);return Nt.current.get(b)||null},dt=b=>{if(!b)return;const y=Vt(J,lt);Nt.current.set(y,b)},{activeTool:et,setActiveTool:ot,showGrid:ht,snapToGrid:Lt,chartObjects:wt,setChartObjects:mt,orders:gt,selectedSymbol:J,selectedTimeframe:lt,drawingsVisible:St,chartType:bt,chartLocked:U}=_o(),X=E.useRef([]),[I,K]=E.useState([]),[Ft,nt]=E.useState(!0),vt=E.useRef(null),Et=E.useRef(new Map);E.useRef(null);const Wt=E.useRef(0);E.useImperativeHandle(o,()=>({zoomIn:()=>{const b=l.current?.timeScale();if(!b)return;const y=b.getVisibleRange();if(!y||!y.from||!y.to)return;const _=y.to-y.from,P=(y.from+y.to)/2,C=_*.8;try{b.setVisibleRange({from:P-C/2,to:P+C/2}),dt(b.getVisibleRange())}catch{}},zoomOut:()=>{const b=l.current?.timeScale();if(!b)return;const y=b.getVisibleRange();if(!y||!y.from||!y.to)return;const _=y.to-y.from,P=(y.from+y.to)/2,C=_*1.25;try{b.setVisibleRange({from:P-C/2,to:P+C/2}),dt(b.getVisibleRange())}catch{}}}));const It=E.useMemo(()=>I.length===0?[]:bt==="line"||bt==="area"?I.map(b=>({time:b.time,value:b.close})):I,[I,bt]);return E.useEffect(()=>{const b=h.current;if(!b)return;const y=b.getBoundingClientRect(),_=L=>{const F=Math.abs(Number(L));return Number.isFinite(F)?F>=1e3?F.toFixed(2):F>=1?F.toFixed(4):F.toFixed(5):"0"},P=la(b,{width:y.width||b.clientWidth,height:y.height||b.clientHeight,autoSize:!0,localization:{priceFormatter:_},layout:{background:{color:"#0F1720"},textColor:"#fff",fontSize:12},grid:{vertLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0}},rightPriceScale:{borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0},leftPriceScale:{visible:!1},timeScale:{borderColor:"#1e293b",timeVisible:!0,secondsVisible:!1,rightOffset:10,barSpacing:3,minBarSpacing:2,shiftVisibleRangeOnNewBar:!1,fixLeftEdge:!1,fixRightEdge:!1},crosshair:{mode:et===1?1:0,vertLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},vertLineVisible:et===1,horzLineVisible:et===1},handleScroll:{mouseWheel:!0,pressedMouseMove:et===null||et===1,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},axisTouch:{time:!0,price:!0},mouseWheel:!0,pinch:!0}}),C=P.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1});l.current=P,a.current=C;const V=P.timeScale(),W=()=>{if(tt.current&&I.length>0){const L=V.getVisibleRange();L&&dt(L)}};V.subscribeVisibleTimeRangeChange(W);const ct=new ResizeObserver(L=>{for(const F of L){const{width:it,height:q}=F.contentRect;if(it>0&&q>0&&P){const T=V.getVisibleRange();P.resize(it,q),T&&setTimeout(()=>{try{V.setVisibleRange(T)}catch{}},0)}}});return ct.observe(b),()=>{V.unsubscribeVisibleTimeRangeChange(W),ct.disconnect(),P.remove(),l.current=null,a.current=null,c.current=null,u.current=[]}},[]),E.useEffect(()=>{l.current&&l.current.applyOptions({grid:{vertLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0},horzLines:{visible:ht,color:ht?"rgba(148, 163, 184, 0.2)":"transparent",style:0}}})},[ht]),E.useEffect(()=>{if(!l.current)return;const y=!U&&!(et!==null&&et!==1&&et!==0),_=!U;l.current.applyOptions({crosshair:{mode:et===1?1:0,vertLine:{visible:et===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"},horzLine:{visible:et===1,width:1,color:"#64748b",style:0,labelBackgroundColor:"#1e293b"}},handleScroll:{mouseWheel:_,pressedMouseMove:y,horzTouchDrag:y,vertTouchDrag:y},handleScale:{axisPressedMouseMove:{time:y,price:y},axisDoubleClickReset:{time:_,price:_},axisTouch:{time:y,price:y},mouseWheel:_,pinch:_}})},[et,U]),E.useEffect(()=>{(async()=>{if(!J||!lt){K([]),tt.current=!1;return}try{if(nt(!0),K([]),tt.current=!1,a.current)try{a.current.setData([])}catch{}console.log(`📊 Fetching candles for ${J} @ ${lt}`);const y=Ao(lt),_=zu(lt,y),P=await ft.get(`${ko}/api/chart/candles`,{params:{symbol:J,timeframe:lt,limit:_,daysBack:y},timeout:1e4});if(P.data&&P.data.data&&P.data.data.length>0){const C=P.data.data;console.log(`✅ Loaded ${C.length} raw candles from server`);const{candles:V,stats:W}=Ro(C,J,lt);V.length>0?(K(V),Et.current=new Map,V.forEach(ct=>{Et.current.set(ct.time,ct)})):(console.warn(`⚠️ No valid candles after processing for ${J}`),K([]))}else console.warn(`⚠️ No candle data returned for ${J}`),K([])}catch(y){console.error(`❌ Error fetching ${J}:`,y.message),K([])}finally{nt(!1)}})()},[J,lt]),E.useEffect(()=>{vt.current||(vt.current=Xs.getSocket());const b=vt.current,y=()=>{console.log("✅ Chart WebSocket connected"),C()},_=()=>{console.log("⚠️ Chart WebSocket disconnected - will auto-reconnect")},P=W=>{console.error("❌ Chart WebSocket connection error:",W)};b.on("connect",y),b.on("disconnect",_),b.on("connect_error",P);const C=()=>{const W=Ys(J);W&&J&<&&b.connected?(console.log(`Subscribing to real-time candles: ${J}@${lt}`),b.emit("subscribeCandles",{symbol:J,timeframe:lt})):!W&&J&&console.log(`⚠️ Symbol ${J} is not a crypto symbol, skipping candle subscription`)},V=W=>{if(!W||!W.candle||!W.symbol||W.symbol.toUpperCase()!==J?.toUpperCase())return;const{candle:ct}=W,L=Oo(ct,J,lt);if(!L)return;const F=Date.now();if(F-Wt.current<200)return;Wt.current=F;const it=l.current?.timeScale(),q=it?.getVisibleRange(),T=a.current,z=l.current;if(!(!T||!z||!tt.current))try{bt==="line"||bt==="area"?T.update({time:L.time,value:L.close}):T.update({time:L.time,open:L.open,high:L.high,low:L.low,close:L.close}),Et.current.set(L.time,L),it&&q&&dt(q)}catch(x){console.error("❌ Error updating candle:",x)}};return b.on("candleUpdate",V),b.connected&&C(),()=>{b.off("candleUpdate",V),b.off("connect",y),b.off("disconnect",_),b.off("connect_error",P),J&<&&b.connected&&Ys(J)&&(console.log(`🔌 Unsubscribing from: ${J}@${lt}`),b.emit("unsubscribeCandles",{symbol:J,timeframe:lt}))}},[J,lt]),E.useEffect(()=>{const b=a.current,y=l.current;if(!(!b||!y)&&!(I.length===0&&tt.current)){if(I.length===0&&!tt.current){if(Ft)return;const _=y.timeScale();b.setData([]),_.fitContent();return}if(!tt.current){const _=y.timeScale(),P=Vt(J,lt);if(Jt.current,Jt.current=P,bt==="line"||bt==="area"){const V=[...I.map(W=>({time:W.time,value:W.close})).filter(W=>W.time!=null)].sort((W,ct)=>W.time-ct.time);V.length>0&&b.setData(V)}else{const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&b.setData(C)}_.fitContent();try{y.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,dt(_.getVisibleRange())}}},[I.length,bt,J,lt]),E.useEffect(()=>{const b=l.current;if(!b||!tt.current||I.length===0)return;const y=b.timeScale(),_=y.getVisibleRange()||Bt();if(a.current)try{b.removeSeries(a.current)}catch{}if(c.current)try{b.removeSeries(c.current),c.current=null}catch{}let P;if(bt==="bars"){P=b.addBarSeries({upColor:"#26A69A",downColor:"#EF5350",borderUpColor:"#26A69A",borderDownColor:"#EF5350",scaleMargins:{top:.1,bottom:.1}});const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&P.setData(C)}else if(bt==="line"){P=b.addLineSeries({color:"#38bdf8",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const C=Ot(It);C.length>0&&P.setData(C)}else if(bt==="area"){P=b.addAreaSeries({lineColor:"#38bdf8",topColor:"rgba(56,189,248,0.4)",bottomColor:"rgba(56,189,248,0.0)",lineWidth:2,priceLineVisible:!1,lastValueVisible:!0,scaleMargins:{top:.1,bottom:.1}});const C=Ot(It);C.length>0&&P.setData(C)}else if(bt==="volume ticks"||bt==="volume"){P=b.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,priceScaleId:"right"});const C=[...I].sort((ct,L)=>ct.time-L.time);C.length>0&&P.setData(C);const V=b.addHistogramSeries({priceFormat:{type:"volume"},priceScaleId:"vol",base:0,priceLineVisible:!1,lastValueVisible:!1,color:"rgba(38,166,154,0.15)"});b.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.3}}),b.priceScale("vol").applyOptions({scaleMargins:{top:.75,bottom:0},visible:!1});const W=C.map(ct=>({time:ct.time,value:ct.volume||0,color:ct.close>=ct.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));W.length>0&&V.setData(W),c.current=V}else{P=b.addCandlestickSeries({upColor:"#26A69A",downColor:"#EF5350",wickUpColor:"#26A69A",wickDownColor:"#EF5350",borderVisible:!1,scaleMargins:{top:.1,bottom:.1}});const C=[...I].sort((V,W)=>V.time-W.time);C.length>0&&P.setData(C)}if(a.current=P,_&&tt.current)setTimeout(()=>{try{y.setVisibleRange(_),dt(_)}catch{if(I.length>0)try{const V=I[I.length-1].time,W=V-6e3;y.setVisibleRange({from:W,to:V}),dt(y.getVisibleRange())}catch{y.fitContent(),dt(y.getVisibleRange())}}try{b.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}},0);else if(!tt.current){y.fitContent();try{b.priceScale("right").applyOptions({borderColor:"#1e293b",autoScale:!0,scaleMargins:{top:.1,bottom:.1},ticksVisible:!0,ensureEdgeTickMarksVisible:!0})}catch{}tt.current=!0,dt(y.getVisibleRange())}},[bt,I.length,It.length]),E.useEffect(()=>{const b=l.current,y=c.current;if(!b||!y||!tt.current||I.length===0||bt!=="volume"&&bt!=="volume ticks")return;const P=[...I].sort((C,V)=>C.time-V.time).map(C=>({time:C.time,value:C.volume||0,color:C.close>=C.open?"rgba(38,166,154,0.25)":"rgba(239,83,80,0.25)"}));P.length>0&&y.setData(P)},[I,bt]),E.useEffect(()=>{const b=l.current,y=a.current,_=h.current;if(!b||!y||!_)return;const C=et!==null?[null,null,"trendline","parallellines","fibonacci","rectangle","pricelevel","text",null,null,null,null,null,null,null,null,null][et]:null;if(!C){if(p.current=!1,g.current=null,d.current=null,m.current=null,f.current?.series)try{b.removeSeries(f.current.series)}catch{}f.current=null;return}if(C==="pricelevel"){const L=F=>{const it=_.getBoundingClientRect(),q=F.clientX-it.left,T=F.clientY-it.top,z=b.timeScale().coordinateToTime(q),x=y.coordinateToPrice(T);if(z==null||x==null)return;const A={type:"pricelevel",priceLine:y.createPriceLine({price:x,color:"#3b82f6",lineWidth:2,lineStyle:2,axisLabelVisible:!0,title:x.toFixed(5)}),price:x};mt(H=>[...H,A]),u.current.push(A)};return _.addEventListener("click",L),()=>{_.removeEventListener("click",L)}}if(C==="trendline"){const L=T=>{T.preventDefault(),T.stopPropagation(),T.stopImmediatePropagation();const z=_.getBoundingClientRect(),x=T.clientX-z.left,D=T.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(!(A==null||H==null)&&(A=Tt(A),A!=null))if(m.current===null){m.current={time:A,price:H};const O=b.addLineSeries({color:"#22c55e",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"trendline",series:O},O.setData([{time:A,value:H}])}else{const O=m.current,B={time:A,price:H},j=1,ut=1e-5,Z=Math.abs(B.time-O.time),pt=Math.abs(B.price-O.price);if(Z<j&&pt<ut){try{b.removeSeries(f.current.series)}catch{}m.current=null,f.current=null;return}const ie={time:O.time,price:O.price},se={time:B.time,price:B.price},qt=Ot([{time:ie.time,value:ie.price},{time:se.time,value:se.price}]);if(qt.length>0){f.current.series.setData(qt);const ue={type:"trendline",series:f.current.series,point1:ie,point2:se};mt(we=>[...we,ue]),u.current.push(ue)}ot(null),m.current=null,f.current=null}},F=T=>{if(m.current===null||f.current?.type!=="trendline")return;T.preventDefault(),T.stopPropagation();const z=_.getBoundingClientRect(),x=T.clientX-z.left,D=T.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(A==null||H==null||(A=Tt(A),A==null))return;const O=m.current,B=Ot([{time:O.time,value:O.price},{time:A,value:H}]);B.length>0&&f.current.series.setData(B)},it=T=>{T.stopPropagation()},q={capture:!0,passive:!1};return _.addEventListener("click",L,q),_.addEventListener("mousemove",F,q),_.addEventListener("mousemove",it,q),()=>{if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{b.removeSeries(f.current.series)}catch{}f.current=null}_.removeEventListener("click",L,q),_.removeEventListener("mousemove",F,q),_.removeEventListener("mousemove",it,q)}}if(C==="parallellines"){const L={capture:!0,passive:!1},F=x=>{x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation();const D=_.getBoundingClientRect(),A=x.clientX-D.left,H=x.clientY-D.top;let O=b.timeScale().coordinateToTime(A);const B=y.coordinateToPrice(H);if(O==null||B==null||(O=Tt(O),O==null))return;const j={time:O,price:B},ut=w.current;if(ut.length===0){w.current=[j];const Z=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});Z.setData([{time:O,value:B}]),f.current={type:"parallellines",series:Z,previewLine:null}}else if(ut.length===1){w.current=[ut[0],j];const Z=Ot([{time:ut[0].time,value:ut[0].price},{time:O,value:B}]);Z.length>0&&f.current.series.setData(Z),f.current.previewLine=b.addLineSeries({color:"#8b5cf6",lineWidth:2,lineStyle:2,priceLineVisible:!1,lastValueVisible:!1});const pt=Zs(b,y,ut[0],j,j);pt&&f.current.previewLine.setData(Ot([{time:pt[0].time,value:pt[0].price},{time:pt[1].time,value:pt[1].price}]))}else{const[Z,pt]=ut,ie=j;if(f.current?.previewLine){try{b.removeSeries(f.current.previewLine)}catch{}f.current.previewLine=null}const se=f.current?.series;if(!se)return;const qt=Zs(b,y,Z,pt,ie);if(!qt)return;const ue=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});se.setData(Ot([{time:Z.time,value:Z.price},{time:pt.time,value:pt.price}])),ue.setData(Ot([{time:qt[0].time,value:qt[0].price},{time:qt[1].time,value:qt[1].price}]));const we={type:"parallellines",point1:Z,point2:pt,point3:ie,baseLine:se,parallelLine:ue};mt(Ge=>[...Ge,we]),u.current.push(we),ot(null),w.current=[],f.current=null}},it=x=>{const D=w.current;if(D.length!==1||!f.current?.series)return;const A=_.getBoundingClientRect(),H=x.clientX-A.left,O=x.clientY-A.top;let B=b.timeScale().coordinateToTime(H);const j=y.coordinateToPrice(O);if(B==null||j==null||(B=Tt(B),B==null))return;const ut=Ot([{time:D[0].time,value:D[0].price},{time:B,value:j}]);ut.length>0&&f.current.series.setData(ut)},q=x=>{const D=w.current;if(D.length!==2||!f.current?.previewLine)return;const A=_.getBoundingClientRect(),H=x.clientX-A.left,O=x.clientY-A.top;let B=b.timeScale().coordinateToTime(H);const j=y.coordinateToPrice(O);if(B==null||j==null||(B=Tt(B),B==null))return;const ut={time:B,price:j},Z=Zs(b,y,D[0],D[1],ut);Z&&f.current.previewLine.setData(Ot([{time:Z[0].time,value:Z[0].price},{time:Z[1].time,value:Z[1].price}]))},T=x=>{it(x),q(x)},z=x=>{x.stopPropagation()};return _.addEventListener("click",F,L),_.addEventListener("mousemove",T,L),_.addEventListener("mousemove",z,L),()=>{if(w.current=[],f.current?.type==="parallellines"){try{f.current.series&&b.removeSeries(f.current.series),f.current.previewLine&&b.removeSeries(f.current.previewLine)}catch{}f.current=null}_.removeEventListener("click",F,L),_.removeEventListener("mousemove",T,L),_.removeEventListener("mousemove",z,L)}}if(m.current=null,f.current?.type==="trendline"&&f.current?.series){try{b.removeSeries(f.current.series)}catch{}f.current=null}const V=L=>{if(L.preventDefault(),L.stopPropagation(),L.stopImmediatePropagation(),C==="trendline"||C==="parallellines"||C!=="rectangle"&&C!=="fibonacci")return;const F=_.getBoundingClientRect(),it=L.clientX-F.left,q=L.clientY-F.top;let T=b.timeScale().coordinateToTime(it);const z=y.coordinateToPrice(q);if(!(T==null||z==null)&&(T=Tt(T),T!=null)){if(p.current=!0,g.current={time:T,price:z},d.current=null,C==="rectangle"){const x=b.addBaselineSeries({baseValue:{type:"price",price:z},topLineColor:"#2563eb",bottomLineColor:"#2563eb",topFillColor1:"rgba(59, 130, 246, 0.38)",topFillColor2:"rgba(59, 130, 246, 0.22)",bottomFillColor1:"rgba(59, 130, 246, 0.22)",bottomFillColor2:"rgba(59, 130, 246, 0.38)",priceLineVisible:!1,lastValueVisible:!1,lineWidth:2,lineStyle:0});f.current={type:"rectangle",series:x}}if(C==="fibonacci"){const x=b.addLineSeries({color:"#f59e0b",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"fibonacci",series:x,priceLines:[]}}if(C==="parallellines"){const x=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});f.current={type:"parallellines",series:x,firstLine:null,secondLine:null}}}},W=L=>{if(!p.current||!g.current||!f.current)return;L.preventDefault(),L.stopPropagation(),L.stopImmediatePropagation();const F=_.getBoundingClientRect(),it=L.clientX-F.left,q=L.clientY-F.top;let T=b.timeScale().coordinateToTime(it);const z=y.coordinateToPrice(q);if(T==null||z==null||(T=Tt(T),T==null))return;d.current={time:T,price:z};const x=g.current;if(f.current.type==="rectangle"){const D=Math.max(x.price,z),A=Math.min(x.price,z),H=Tt(Math.min(x.time,T)),O=Tt(Math.max(x.time,T));if(H==null||O==null||Math.abs(O-H)<1||Math.abs(D-A)<1e-5)return;const B=f.current.series;B.setData(Ot([{time:H,value:D},{time:O,value:D}])),B.applyOptions({baseValue:{type:"price",price:A}})}if(f.current.type==="fibonacci"){const D=[{time:x.time,value:x.price},{time:T,value:z}],A=Ot(D);A.length>0&&f.current.series.setData(A),d.current={time:T,price:z},f.current.priceLines&&(f.current.priceLines.forEach(H=>{try{y.removePriceLine(H)}catch{}}),f.current.priceLines=[])}if(f.current.type==="parallellines")if(f.current.firstLine){const D=f.current.firstLine;D.endTime-D.startTime;const A=D.endPrice-D.startPrice,H=z,O=H+A;if(f.current.secondLine)f.current.secondLine.setData([{time:x.time,value:H},{time:T,value:O}]);else{const B=b.addLineSeries({color:"#8b5cf6",lineWidth:2,priceLineVisible:!1,lastValueVisible:!1});B.setData([{time:x.time,value:H},{time:T,value:O}]),f.current.secondLine=B}}else f.current.series.setData([{time:x.time,value:x.price},{time:T,value:z}])},ct=L=>{if(L&&(L.preventDefault(),L.stopPropagation()),!p.current||!f.current||!g.current)return;const F=g.current,it=d.current||F;if(f.current.type==="parallellines")if(f.current.firstLine){const q={type:"parallellines",firstLine:f.current.series,secondLine:f.current.secondLine,firstLineData:f.current.firstLine};mt(T=>[...T,q]),u.current.push(q),ot(null),f.current=null,p.current=!1,g.current=null,d.current=null;return}else{f.current.firstLine={startTime:F.time,startPrice:F.price,endTime:it.time,endPrice:it.price},p.current=!1,g.current=null,d.current=null;return}if(f.current.type==="fibonacci"){const T=(d.current||F).price;if(Math.abs(F.price-T)<1e-4){try{b.removeSeries(f.current.series)}catch{}p.current=!1,g.current=null,d.current=null,f.current=null;return}const z=Math.max(F.price,T),x=Math.min(F.price,T),D=z-x,A=[{level:0,label:"0.0%"},{level:.236,label:"23.6%"},{level:.382,label:"38.2%"},{level:.5,label:"50.0%"},{level:.618,label:"61.8%"},{level:.786,label:"78.6%"},{level:1,label:"100.0%"}],H=[],O=f.current.series;try{b.removeSeries(O)}catch{}A.forEach(({level:j,label:ut})=>{const Z=z-D*j,pt=y.createPriceLine({price:Z,color:j===0||j===1?"#f59e0b":"#fbbf24",lineWidth:j===0||j===1?2:1,lineStyle:j===0||j===1?0:2,axisLabelVisible:!0,title:`${ut} (${Z.toFixed(5)})`,textColor:j===0||j===1?"#f59e0b":"#fbbf24"});H.push(pt)});const B={type:"fibonacci",priceLines:H,startPrice:F.price,endPrice:T,high:z,low:x};mt(j=>[...j,B]),u.current.push(B),ot(null)}if(f.current.type==="rectangle"){const q=g.current,T=d.current||q,z=Math.max(q.price,T.price),x=Math.min(q.price,T.price),D=Tt(Math.min(q.time,T.time)),A=Tt(Math.max(q.time,T.time));if(D!=null&&A!=null&&Math.abs(A-D)>=1&&Math.abs(z-x)>=1e-5){const H=f.current.series;H.setData(Ot([{time:D,value:z},{time:A,value:z}])),H.applyOptions({baseValue:{type:"price",price:x}});const O={type:"rectangle",timeStart:D,timeEnd:A,priceTop:z,priceBottom:x,series:H};mt(B=>[...B,O]),u.current.push(O),ot(null)}else try{b.removeSeries(f.current.series)}catch{}}p.current=!1,g.current=null,d.current=null,f.current=null};if(C==="rectangle"||C==="fibonacci"||C==="parallellines"){const L={capture:!0,passive:!1},F=it=>{p.current||it.stopPropagation()};return _.addEventListener("mousedown",V,L),_.addEventListener("mousemove",W,L),_.addEventListener("mousemove",F,L),_.addEventListener("mouseup",ct,L),()=>{_.removeEventListener("mousedown",V,L),_.removeEventListener("mousemove",W,L),_.removeEventListener("mousemove",F,L),_.removeEventListener("mouseup",ct,L)}}},[et,mt,ot]),E.useEffect(()=>{const b=l.current,y=a.current,_=h.current,P=et===null||et===1;if(!P||!b||!y||!_){P||(R(null),$([]));return}const C=10,V=8;function W(q,T){const z=wt.filter(x=>x.type==="trendline"&&x.point1&&x.point2);for(let x=z.length-1;x>=0;x--){const D=z[x],A=b.timeScale().timeToCoordinate(D.point1.time),H=y.priceToCoordinate(D.point1.price),O=b.timeScale().timeToCoordinate(D.point2.time),B=y.priceToCoordinate(D.point2.price);if(A==null||H==null||O==null||B==null)continue;const j=Math.hypot(q-A,T-H),ut=Math.hypot(q-O,T-B);if(j<C)return{object:D,mode:"handle1"};if(ut<C)return{object:D,mode:"handle2"};if(Uu(q,T,A,H,O,B)<V)return{object:D,mode:"line"}}return null}const ct=q=>{q.preventDefault(),q.stopPropagation();const T=_.getBoundingClientRect(),z=q.clientX-T.left,x=q.clientY-T.top,D=W(z,x);D?(R(D.object),Q.current=D.mode,D.mode==="line"&&(G.current={x:z,y:x,point1:{...D.object.point1},point2:{...D.object.point2}})):(R(null),Q.current=null)},L=q=>{if(!Q.current)return;const T=st.current;if(!T||!T.point1||!T.point2)return;const z=_.getBoundingClientRect(),x=q.clientX-z.left,D=q.clientY-z.top;let A=b.timeScale().coordinateToTime(x);const H=y.coordinateToPrice(D);if(!(A==null||H==null)&&(A=Tt(A),A!=null)){if(Q.current==="handle1"){const O={time:A,price:H},B=Ot([{time:O.time,value:O.price},{time:T.point2.time,value:T.point2.price}]);B.length>0&&T.series.setData(B);const j={...T,point1:O};mt(ut=>{const Z=ut.map(pt=>pt===T?j:pt);return u.current=Z,Z}),R(j),st.current=j}else if(Q.current==="handle2"){const O={time:A,price:H},B=Ot([{time:T.point1.time,value:T.point1.price},{time:O.time,value:O.price}]);B.length>0&&T.series.setData(B);const j={...T,point2:O};mt(ut=>{const Z=ut.map(pt=>pt===T?j:pt);return u.current=Z,Z}),R(j),st.current=j}else if(Q.current==="line"){const O=G.current;if(!O)return;const B=b.timeScale().coordinateToTime(O.x),j=y.coordinateToPrice(O.y);if(B==null||j==null)return;const ut=A-B,Z=H-j,pt={time:Tt(O.point1.time+ut),price:O.point1.price+Z},ie={time:Tt(O.point2.time+ut),price:O.point2.price+Z},se=Ot([{time:pt.time,value:pt.price},{time:ie.time,value:ie.price}]);se.length>0&&T.series.setData(se);const qt={...T,point1:pt,point2:ie};mt(ue=>{const we=ue.map(Ge=>Ge===T?qt:Ge);return u.current=we,we}),R(qt),st.current=qt}}},F=()=>{Q.current=null,G.current=null},it={capture:!0,passive:!1};return _.addEventListener("mousedown",ct,it),_.addEventListener("mousemove",L,it),_.addEventListener("mouseup",F,it),()=>{_.removeEventListener("mousedown",ct,it),_.removeEventListener("mousemove",L,it),_.removeEventListener("mouseup",F,it)}},[et,wt,mt]),E.useEffect(()=>{const b=l.current,y=a.current;if(!b||!y)return;const _=()=>{const C=M;if(!C||C.type!=="trendline"||!C.point1||!C.point2){$([]);return}const V=b.timeScale(),W=V.timeToCoordinate(C.point1.time),ct=y.priceToCoordinate(C.point1.price),L=V.timeToCoordinate(C.point2.time),F=y.priceToCoordinate(C.point2.price);W!=null&&ct!=null&&L!=null&&F!=null?$([{x:W,y:ct},{x:L,y:F}]):$([])};_();const P=b.timeScale();return P.subscribeVisibleTimeRangeChange(_),()=>{P.unsubscribeVisibleTimeRangeChange(_)}},[M]),E.useEffect(()=>{!l.current||!a.current||u.current.forEach(b=>{b.series&&b.series.applyOptions({visible:St}),b.priceLine&&b.priceLine.applyOptions(St?{color:"#3b82f6",axisLabelVisible:!0,title:typeof b.price=="number"?b.price.toFixed(5):""}:{color:"rgba(0,0,0,0)",axisLabelVisible:!1,title:""}),b.type==="fibonacci"&&b.priceLines&&b.priceLines.forEach(y=>{try{y.applyOptions({lineVisible:St,axisLabelVisible:St})}catch{}}),b.type==="rectangle"&&b.series&&b.series.applyOptions({visible:St}),b.type==="parallellines"&&(b.baseLine&&b.baseLine.applyOptions({visible:St}),b.parallelLine&&b.parallelLine.applyOptions({visible:St}),b.firstLine&&b.firstLine.applyOptions({visible:St}),b.secondLine&&b.secondLine.applyOptions({visible:St}))})},[St,wt]),E.useEffect(()=>{!St&&M&&(R(null),$([]))},[St,M]),E.useEffect(()=>{if(u.current.length>wt.length){const b=u.current.filter((y,_)=>!wt.includes(y));M&&b.some(y=>y===M)&&(R(null),$([])),b.forEach(y=>{if(y.series&&l.current?.removeSeries(y.series),y.priceLine&&a.current?.removePriceLine(y.priceLine),y.type==="fibonacci"&&y.priceLines&&y.priceLines.forEach(_=>{try{a.current?.removePriceLine(_)}catch{}}),y.type==="rectangle"&&y.series)try{l.current?.removeSeries(y.series)}catch{}if(y.type==="parallellines")try{y.baseLine&&l.current?.removeSeries(y.baseLine),y.parallelLine&&l.current?.removeSeries(y.parallelLine),y.firstLine&&l.current?.removeSeries(y.firstLine),y.secondLine&&l.current?.removeSeries(y.secondLine)}catch{}}),u.current=wt}},[wt,M]),E.useEffect(()=>{const b=a.current;return b?(X.current.forEach(_=>{try{b.removePriceLine(_)}catch{}}),X.current=[],gt.filter(_=>_.symbol===J).forEach(_=>{const P=parseFloat(_.price);if(isNaN(P))return;const V=_.type==="BUY"?"#26A69A":"#EF5350",W=b.createPriceLine({price:P,color:V,lineWidth:2,lineStyle:0,axisLabelVisible:!0,title:`${_.type} ${_.volume} @ ${_.price}`,textColor:V});X.current.push(W)}),()=>{X.current.forEach(_=>{try{b.removePriceLine(_)}catch{}}),X.current=[]}):void 0},[gt,J]),ne.jsx("div",{className:"flex-1 flex flex-col bg-primary min-w-0 overflow-hidden",children:ne.jsx("div",{ref:h,className:"flex-1 w-full h-full relative",style:{cursor:et===1||et!==null?"crosshair":"default",minHeight:0,minWidth:0},onDoubleClick:b=>{l.current&&!p.current&&(b.preventDefault(),b.stopPropagation(),l.current.timeScale().fitContent(),dt(l.current.timeScale().getVisibleRange()))},children:St&&M?.type==="trendline"&&M?.point1&&M?.point2&&k.length===2&&ne.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none","aria-hidden":!0,children:k.map((b,y)=>ne.jsx("div",{className:"absolute w-[10px] h-[10px] rounded-full border-2 border-white bg-[#22c55e] shadow",style:{left:b.x-5,top:b.y-5}},y))})})})}),Wu="1.0.0";rt.Chart=Vu,rt.SYMBOL_CONFIG=Eo,rt.TradingProvider=Ru,rt.alignToTimeframe=Oe,rt.detectGaps=Ou,rt.getSymbolConfig=Ye,rt.is24x7Symbol=Du,rt.isCryptoSymbol=Ys,rt.isForexSymbol=Au,rt.isWithinTradingSession=ku,rt.normalizeCandleTimes=To,rt.normalizeTime=Tt,rt.processCandles=Ro,rt.processSingleCandle=Oo,rt.setChartBaseUrl=Po,rt.setSocketBaseUrl=wo,rt.timeframeToSeconds=Gs,rt.useTrading=_o,rt.validateTimeOrdering=Pu,rt.version=Wu,Object.defineProperty(rt,Symbol.toStringTag,{value:"Module"})}));
|